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
5 FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
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
23 https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
25 Signed-off-by: Sven Eckelmann <seckelmann@datto.com>
29 --- a/drivers/net/wireless/ath/ath10k/mac.c
30 +++ b/drivers/net/wireless/ath/ath10k/mac.c
31 @@ -1028,6 +1028,40 @@ static inline int ath10k_vdev_setup_sync
32 return ar->last_wmi_vdev_start_status;
35 +static u32 ath10k_get_max_antenna_gain(struct ath10k *ar,
36 + u32 ch_max_antenna_gain)
38 + u32 max_antenna_gain;
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):
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
59 + * https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
61 + max_antenna_gain = 6;
63 + max_antenna_gain = 0;
66 + return max(ch_max_antenna_gain, max_antenna_gain);
69 static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
71 struct cfg80211_chan_def *chandef = NULL;
72 @@ -1060,7 +1094,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);
80 reinit_completion(&ar->vdev_setup_done);
81 reinit_completion(&ar->vdev_delete_done);
82 @@ -1506,7 +1541,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);
90 if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
91 arg.ssid = arvif->u.ap.ssid;
92 @@ -3437,7 +3473,8 @@ static int ath10k_update_channel_list(st
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 */
101 /* FIXME: why use only legacy modes, why not any