Skip to content

Commit

Permalink
ath10k-ct: Sven's antenna-gain and tx-power changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
greearb committed Jun 11, 2019
1 parent eaa2383 commit 8c08f2a
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 15 deletions.
43 changes: 40 additions & 3 deletions ath10k-4.13/mac.c
Expand Up @@ -1051,6 +1051,40 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
return ar->last_wmi_vdev_start_status;
}

static u32 ath10k_get_max_antenna_gain(struct ath10k *ar,
u32 ch_max_antenna_gain)
{
u32 max_antenna_gain;

if (ar->dfs_detector && ar->dfs_detector->region == NL80211_DFS_FCC) {
/* FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
*
* > (4) The conducted output power limit
* > specified in paragraph (b) of this section
* > is based on the use of antennas
* > with directional gains that do not exceed
* > 6 dBi. Except as shown in paragraph
* > (c) of this section, if transmitting
* > antennas of directional gain greater
* > than 6 dBi are used, the conducted
* > output power from the intentional radiator
* > shall be reduced below the stated
* > values in paragraphs (b)(1), (b)(2),
* > and (b)(3) of this section, as appropriate,
* > by the amount in dB that the
* > directional gain of the antenna exceeds
* > 6 dBi.
*
* https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
*/
max_antenna_gain = 6;
} else {
max_antenna_gain = 0;
}

return max(ch_max_antenna_gain, max_antenna_gain);
}

static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
{
struct cfg80211_chan_def *chandef = NULL;
Expand Down Expand Up @@ -1083,7 +1117,8 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
arg.channel.min_power = 0;
arg.channel.max_power = channel->max_power * 2;
arg.channel.max_reg_power = channel->max_reg_power * 2;
arg.channel.max_antenna_gain = channel->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);

reinit_completion(&ar->vdev_setup_done);

Expand Down Expand Up @@ -1525,7 +1560,8 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif,
arg.channel.min_power = 0;
arg.channel.max_power = chandef->chan->max_power * 2;
arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
chandef->chan->max_antenna_gain);

/* CT Firmware can support 32+ VDEVS, but can only support
* beacon-ing devs with dev ids 0 - 31 due to firmware limitations.
Expand Down Expand Up @@ -3683,7 +3719,8 @@ static int ath10k_update_channel_list(struct ath10k *ar)
ch->min_power = 0;
ch->max_power = channel->max_power * 2;
ch->max_reg_power = channel->max_reg_power * 2;
ch->max_antenna_gain = channel->max_antenna_gain * 2;
ch->max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);
ch->reg_class_id = 0; /* FIXME */

/* FIXME: why use only legacy modes, why not any
Expand Down
3 changes: 3 additions & 0 deletions ath10k-4.13/wmi.h
Expand Up @@ -1869,7 +1869,9 @@ struct wmi_channel {
union {
__le32 reginfo1;
struct {
/* note: power unit is 1 dBm */
u8 antenna_max;
/* note: power unit is 0.5 dBm */
u8 max_tx_power;
} __packed;
} __packed;
Expand All @@ -1889,6 +1891,7 @@ struct wmi_channel_arg {
u32 min_power;
u32 max_power;
u32 max_reg_power;
/* note: power unit is 1 dBm */
u32 max_antenna_gain;
u32 reg_class_id;
enum wmi_phy_mode mode;
Expand Down
43 changes: 40 additions & 3 deletions ath10k-4.16/mac.c
Expand Up @@ -1132,6 +1132,40 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
return ar->last_wmi_vdev_start_status;
}

static u32 ath10k_get_max_antenna_gain(struct ath10k *ar,
u32 ch_max_antenna_gain)
{
u32 max_antenna_gain;

if (ar->dfs_detector && ar->dfs_detector->region == NL80211_DFS_FCC) {
/* FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
*
* > (4) The conducted output power limit
* > specified in paragraph (b) of this section
* > is based on the use of antennas
* > with directional gains that do not exceed
* > 6 dBi. Except as shown in paragraph
* > (c) of this section, if transmitting
* > antennas of directional gain greater
* > than 6 dBi are used, the conducted
* > output power from the intentional radiator
* > shall be reduced below the stated
* > values in paragraphs (b)(1), (b)(2),
* > and (b)(3) of this section, as appropriate,
* > by the amount in dB that the
* > directional gain of the antenna exceeds
* > 6 dBi.
*
* https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
*/
max_antenna_gain = 6;
} else {
max_antenna_gain = 0;
}

return max(ch_max_antenna_gain, max_antenna_gain);
}

static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
{
struct cfg80211_chan_def *chandef = NULL;
Expand Down Expand Up @@ -1164,7 +1198,8 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
arg.channel.min_power = 0;
arg.channel.max_power = channel->max_power * 2;
arg.channel.max_reg_power = channel->max_reg_power * 2;
arg.channel.max_antenna_gain = channel->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);

reinit_completion(&ar->vdev_setup_done);

Expand Down Expand Up @@ -1606,7 +1641,8 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif,
arg.channel.min_power = 0;
arg.channel.max_power = chandef->chan->max_power * 2;
arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
chandef->chan->max_antenna_gain);

/* CT Firmware can support 32+ VDEVS, but can only support
* beacon-ing devs with dev ids 0 - 31 due to firmware limitations.
Expand Down Expand Up @@ -3764,7 +3800,8 @@ static int ath10k_update_channel_list(struct ath10k *ar)
ch->min_power = 0;
ch->max_power = channel->max_power * 2;
ch->max_reg_power = channel->max_reg_power * 2;
ch->max_antenna_gain = channel->max_antenna_gain * 2;
ch->max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);
ch->reg_class_id = 0; /* FIXME */

/* FIXME: why use only legacy modes, why not any
Expand Down
3 changes: 3 additions & 0 deletions ath10k-4.16/wmi.h
Expand Up @@ -2019,7 +2019,9 @@ struct wmi_channel {
union {
__le32 reginfo1;
struct {
/* note: power unit is 1 dBm */
u8 antenna_max;
/* note: power unit is 0.5 dBm */
u8 max_tx_power;
} __packed;
} __packed;
Expand All @@ -2039,6 +2041,7 @@ struct wmi_channel_arg {
u32 min_power;
u32 max_power;
u32 max_reg_power;
/* note: power unit is 1 dBm */
u32 max_antenna_gain;
u32 reg_class_id;
enum wmi_phy_mode mode;
Expand Down
43 changes: 40 additions & 3 deletions ath10k-4.19/mac.c
Expand Up @@ -1135,6 +1135,40 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
return ar->last_wmi_vdev_start_status;
}

static u32 ath10k_get_max_antenna_gain(struct ath10k *ar,
u32 ch_max_antenna_gain)
{
u32 max_antenna_gain;

if (ar->dfs_detector && ar->dfs_detector->region == NL80211_DFS_FCC) {
/* FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
*
* > (4) The conducted output power limit
* > specified in paragraph (b) of this section
* > is based on the use of antennas
* > with directional gains that do not exceed
* > 6 dBi. Except as shown in paragraph
* > (c) of this section, if transmitting
* > antennas of directional gain greater
* > than 6 dBi are used, the conducted
* > output power from the intentional radiator
* > shall be reduced below the stated
* > values in paragraphs (b)(1), (b)(2),
* > and (b)(3) of this section, as appropriate,
* > by the amount in dB that the
* > directional gain of the antenna exceeds
* > 6 dBi.
*
* https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
*/
max_antenna_gain = 6;
} else {
max_antenna_gain = 0;
}

return max(ch_max_antenna_gain, max_antenna_gain);
}

static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
{
struct cfg80211_chan_def *chandef = NULL;
Expand Down Expand Up @@ -1167,7 +1201,8 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
arg.channel.min_power = 0;
arg.channel.max_power = channel->max_power * 2;
arg.channel.max_reg_power = channel->max_reg_power * 2;
arg.channel.max_antenna_gain = channel->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);

reinit_completion(&ar->vdev_setup_done);

Expand Down Expand Up @@ -1609,7 +1644,8 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif,
arg.channel.min_power = 0;
arg.channel.max_power = chandef->chan->max_power * 2;
arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
chandef->chan->max_antenna_gain);

/* CT Firmware can support 32+ VDEVS, but can only support
* beacon-ing devs with dev ids 0 - 31 due to firmware limitations.
Expand Down Expand Up @@ -3781,7 +3817,8 @@ static int ath10k_update_channel_list(struct ath10k *ar)
ch->min_power = 0;
ch->max_power = channel->max_power * 2;
ch->max_reg_power = channel->max_reg_power * 2;
ch->max_antenna_gain = channel->max_antenna_gain * 2;
ch->max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);
ch->reg_class_id = 0; /* FIXME */

/* FIXME: why use only legacy modes, why not any
Expand Down
3 changes: 3 additions & 0 deletions ath10k-4.19/wmi.h
Expand Up @@ -2047,7 +2047,9 @@ struct wmi_channel {
union {
__le32 reginfo1;
struct {
/* note: power unit is 1 dBm */
u8 antenna_max;
/* note: power unit is 0.5 dBm */
u8 max_tx_power;
} __packed;
} __packed;
Expand All @@ -2067,6 +2069,7 @@ struct wmi_channel_arg {
u32 min_power;
u32 max_power;
u32 max_reg_power;
/* note: power unit is 1 dBm */
u32 max_antenna_gain;
u32 reg_class_id;
enum wmi_phy_mode mode;
Expand Down
43 changes: 40 additions & 3 deletions ath10k-4.20/mac.c
Expand Up @@ -1151,6 +1151,40 @@ static inline int ath10k_vdev_setup_sync(struct ath10k *ar)
return ar->last_wmi_vdev_start_status;
}

static u32 ath10k_get_max_antenna_gain(struct ath10k *ar,
u32 ch_max_antenna_gain)
{
u32 max_antenna_gain;

if (ar->dfs_detector && ar->dfs_detector->region == NL80211_DFS_FCC) {
/* FCC allows maximum antenna gain of 6 dBi. 15.247(b)(4):
*
* > (4) The conducted output power limit
* > specified in paragraph (b) of this section
* > is based on the use of antennas
* > with directional gains that do not exceed
* > 6 dBi. Except as shown in paragraph
* > (c) of this section, if transmitting
* > antennas of directional gain greater
* > than 6 dBi are used, the conducted
* > output power from the intentional radiator
* > shall be reduced below the stated
* > values in paragraphs (b)(1), (b)(2),
* > and (b)(3) of this section, as appropriate,
* > by the amount in dB that the
* > directional gain of the antenna exceeds
* > 6 dBi.
*
* https://www.gpo.gov/fdsys/pkg/CFR-2013-title47-vol1/pdf/CFR-2013-title47-vol1-sec15-247.pdf
*/
max_antenna_gain = 6;
} else {
max_antenna_gain = 0;
}

return max(ch_max_antenna_gain, max_antenna_gain);
}

static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
{
struct cfg80211_chan_def *chandef = NULL;
Expand Down Expand Up @@ -1183,7 +1217,8 @@ static int ath10k_monitor_vdev_start(struct ath10k *ar, int vdev_id)
arg.channel.min_power = 0;
arg.channel.max_power = channel->max_power * 2;
arg.channel.max_reg_power = channel->max_reg_power * 2;
arg.channel.max_antenna_gain = channel->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);

reinit_completion(&ar->vdev_setup_done);

Expand Down Expand Up @@ -1625,7 +1660,8 @@ static int ath10k_vdev_start_restart(struct ath10k_vif *arvif,
arg.channel.min_power = 0;
arg.channel.max_power = chandef->chan->max_power * 2;
arg.channel.max_reg_power = chandef->chan->max_reg_power * 2;
arg.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;
arg.channel.max_antenna_gain = ath10k_get_max_antenna_gain(ar,
chandef->chan->max_antenna_gain);

/* CT Firmware can support 32+ VDEVS, but can only support
* beacon-ing devs with dev ids 0 - 31 due to firmware limitations.
Expand Down Expand Up @@ -3797,7 +3833,8 @@ static int ath10k_update_channel_list(struct ath10k *ar)
ch->min_power = 0;
ch->max_power = channel->max_power * 2;
ch->max_reg_power = channel->max_reg_power * 2;
ch->max_antenna_gain = channel->max_antenna_gain * 2;
ch->max_antenna_gain = ath10k_get_max_antenna_gain(ar,
channel->max_antenna_gain);
ch->reg_class_id = 0; /* FIXME */

/* FIXME: why use only legacy modes, why not any
Expand Down
3 changes: 3 additions & 0 deletions ath10k-4.20/wmi.h
Expand Up @@ -2066,7 +2066,9 @@ struct wmi_channel {
union {
__le32 reginfo1;
struct {
/* note: power unit is 1 dBm */
u8 antenna_max;
/* note: power unit is 0.5 dBm */
u8 max_tx_power;
} __packed;
} __packed;
Expand All @@ -2086,6 +2088,7 @@ struct wmi_channel_arg {
u32 min_power;
u32 max_power;
u32 max_reg_power;
/* note: power unit is 1 dBm */
u32 max_antenna_gain;
u32 reg_class_id;
enum wmi_phy_mode mode;
Expand Down

0 comments on commit 8c08f2a

Please sign in to comment.