9f7ac903eb1f4c9c6147560634ba0b60d45f21ef
[openwrt/staging/mans0n.git] /
1 From: Sven Eckelmann <seckelmann@datto.com>
2 Date: Wed, 28 Nov 2018 16:16:27 +0100
3 Subject: ath10k: adjust tx power reduction for US regulatory domain
4
5 FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
6
7 > (4) The conducted output power limit
8 > specified in paragraph (b) of this section
9 > is based on the use of antennas
10 > with directional gains that do not exceed
11 > 6 dBi. Except as shown in paragraph
12 > (c) of this section, if transmitting
13 > antennas of directional gain greater
14 > than 6 dBi are used, the conducted
15 > output power from the intentional radiator
16 > shall be reduced below the stated
17 > values in paragraphs (b)(1), (b)(2),
18 > and (b)(3) of this section, as appropriate,
19 > by the amount in dB that the
20 > directional gain of the antenna exceeds
21 > 6 dBi.
22
23 https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
24
25 Signed-off-by: Sven Eckelmann <seckelmann@datto.com>
26
27 Forwarded: no
28
29 --- a/drivers/net/wireless/ath/ath10k/mac.c
30 +++ b/drivers/net/wireless/ath/ath10k/mac.c
31 @@ -1017,6 +1017,40 @@ static inline int ath10k_vdev_setup_sync
32 return ar->last_wmi_vdev_start_status;
33 }
34
35 +static u32 ath10k_get_max_antenna_gain(struct ath10k *ar,
36 + u32 ch_max_antenna_gain)
37 +{
38 + u32 max_antenna_gain;
39 +
40 + if (ar->dfs_detector && ar->dfs_detector->region == NL80211_DFS_FCC) {
41 + /* FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
42 + *
43 + * > (4) The conducted output power limit
44 + * > specified in paragraph (b) of this section
45 + * > is based on the use of antennas
46 + * > with directional gains that do not exceed
47 + * > 6 dBi. Except as shown in paragraph
48 + * > (c) of this section, if transmitting
49 + * > antennas of directional gain greater
50 + * > than 6 dBi are used, the conducted
51 + * > output power from the intentional radiator
52 + * > shall be reduced below the stated
53 + * > values in paragraphs (b)(1), (b)(2),
54 + * > and (b)(3) of this section, as appropriate,
55 + * > by the amount in dB that the
56 + * > directional gain of the antenna exceeds
57 + * > 6 dBi.
58 + *
59 + * https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
60 + */
61 + max_antenna_gain = 6;
62 + } else {
63 + max_antenna_gain = 0;
64 + }
65 +
66 + return max(ch_max_antenna_gain, max_antenna_gain);
67 +}
68 +
69 static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
70 {
71 struct cfg80211_chan_def *chandef = NULL;
72 @@ -1049,7 +1083,8 @@ static int ath10k_monitor_vdev_start(str
73 arg.channel.min_power = 0;
74 arg.channel.max_power = channel->max_power * 2;
75 arg.channel.max_reg_power = channel->max_reg_power * 2;
76 - arg.channel.max_antenna_gain = channel->max_antenna_gain;
77 + arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
78 + channel->max_antenna_gain);
79
80 reinit_completion(&ar->vdev_setup_done);
81 reinit_completion(&ar->vdev_delete_done);
82 @@ -1495,7 +1530,8 @@ static int ath10k_vdev_start_restart(str
83 arg.channel.min_power = 0;
84 arg.channel.max_power = chandef->chan->max_power * 2;
85 arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
86 - arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain;
87 + arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
88 + chandef->chan->max_antenna_gain);
89
90 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
91 arg.ssid = arvif->u.ap.ssid;
92 @@ -3423,7 +3459,8 @@ static int ath10k_update_channel_list(st
93 ch->min_power = 0;
94 ch->max_power = channel->max_power * 2;
95 ch->max_reg_power = channel->max_reg_power * 2;
96 - ch->max_antenna_gain = channel->max_antenna_gain;
97 + ch->max_antenna_gain = ath10k_get_max_antenna_gain(ar,
98 + channel->max_antenna_gain);
99 ch->reg_class_id = 0; /* FIXME */
100
101 /* FIXME: why use only legacy modes, why not any