Re: [PATCH] mac80211: support FTM responder configuration/statistics

2018-10-29 Thread Pradeep Kumar Chitrapu




Yes, but we may not get there?

if (!need_new_beacon)
goto skip_beacons;

ah!..yes...Thanks..




Re: [PATCH] mac80211: support FTM responder configuration/statistics

2018-10-29 Thread Pradeep Kumar Chitrapu

memset(, 0, sizeof(params));
+   params.beacon_csa.ftm_responder = -1;

Hi Johannes,

Agree with the rest, however, I think this may not be needed because 
ftm_responder is already being set to -1,
if NL80211_ATTR_FTM_RESPONDER attribute is not included, in 
nl80211_parse_beacon, which will be called from
nl80211_channel_switch. Please let me know if I may have missed 
something..


if (attrs[NL80211_ATTR_FTM_RESPONDER]) {

} else {
bcn->ftm_responder = -1;
}



if (!info->attrs[NL80211_ATTR_WIPHY_FREQ] ||
!info->attrs[NL80211_ATTR_CH_SWITCH_COUNT])


If that seems good to you I'll submit the patch.

Sure..Thanks.


johannes


Re: [PATCH] mac80211: support FTM responder configuration/statistics

2018-10-25 Thread Pradeep Kumar Chitrapu


I just realized that this is broken in nl80211_channel_switch() and
ieee80211_set_csa_beacon(), doing a CSA will always disable FTM unless
it was actually included in the new configuration.

Hi Johannes

oops..Yes, there is a bug in the patch. The code below, I think, must 
fix this issue.

Please let me know your comments..

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 51622333d460..70d6de29425b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2934,19 +2934,20 @@ static int 
ieee80211_start_radar_detection(struct wiphy *wiphy,

memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
pos += beacon->probe_resp_len;
}
-   if (beacon->ftm_responder)
+   if (beacon->ftm_responder != -1) {
new_beacon->ftm_responder = beacon->ftm_responder;
-   if (beacon->lci) {
-   new_beacon->lci_len = beacon->lci_len;
-   new_beacon->lci = pos;
-   memcpy(pos, beacon->lci, beacon->lci_len);
-   pos += beacon->lci_len;
-   }
-   if (beacon->civicloc) {
-   new_beacon->civicloc_len = beacon->civicloc_len;
-   new_beacon->civicloc = pos;
-   memcpy(pos, beacon->civicloc, beacon->civicloc_len);
-   pos += beacon->civicloc_len;
+   if (beacon->lci) {
+   new_beacon->lci_len = beacon->lci_len;
+   new_beacon->lci = pos;
+   memcpy(pos, beacon->lci, beacon->lci_len);
+   pos += beacon->lci_len;
+   }
+   if (beacon->civicloc) {
+   new_beacon->civicloc_len = beacon->civicloc_len;
+   new_beacon->civicloc = pos;
+   memcpy(pos, beacon->civicloc, 
beacon->civicloc_len);

+   pos += beacon->civicloc_len;
+   }
}

return new_beacon;




Doing the trivial thing:

memset(, 0, sizeof(params));
+   params.beacon_after.ftm_responder = -1;

This would not be needed then.


in nl80211_channel_switch() will not help because then mac80211 will
lose all the extra configuration, and will actually store -1 into its
enabled value which is really strange.

I'd appreciate if you could take a look at this.

Thanks,
johannes


[PATCH] mac80211: support FTM responder configuration/statistics

2018-10-03 Thread Pradeep Kumar Chitrapu
New bss param ftm_responder is used to notify the driver to
enable fine timing request (FTM) responder role in AP mode.

Plumb the new cfg80211 API for FTM responder statistics through to
the driver API in mac80211.

Signed-off-by: David Spinadel 
Signed-off-by: Johannes Berg 
Signed-off-by: Pradeep Kumar Chitrapu 
---
 include/net/mac80211.h| 28 
 net/mac80211/cfg.c| 85 +++
 net/mac80211/driver-ops.h | 16 +
 net/mac80211/trace.h  | 23 +
 net/mac80211/util.c   |  5 +++
 5 files changed, 157 insertions(+)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index c4fadbafbf21..2ccd4d1bef89 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -309,6 +309,8 @@ struct ieee80211_vif_chanctx_switch {
  * @BSS_CHANGED_KEEP_ALIVE: keep alive options (idle period or protected
  * keep alive) changed.
  * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
+ * @BSS_CHANGED_FTM_RESPONDER: fime timing reasurement request responder
+ * functionality changed for this BSS (AP mode).
  *
  */
 enum ieee80211_bss_change {
@@ -338,6 +340,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_MU_GROUPS   = 1<<23,
BSS_CHANGED_KEEP_ALIVE  = 1<<24,
BSS_CHANGED_MCAST_RATE  = 1<<25,
+   BSS_CHANGED_FTM_RESPONDER   = 1<<26,
 
/* when adding here, make sure to change ieee80211_reconfig */
 };
@@ -464,6 +467,21 @@ struct ieee80211_mu_group_data {
 };
 
 /**
+ * ieee80211_ftm_responder_params - FTM responder parameters
+ *
+ * @lci: LCI subelement content
+ * @civicloc: CIVIC location subelement content
+ * @lci_len: LCI data length
+ * @civicloc_len: Civic data length
+ */
+struct ieee80211_ftm_responder_params {
+   const u8 *lci;
+   const u8 *civicloc;
+   size_t lci_len;
+   size_t civicloc_len;
+};
+
+/**
  * struct ieee80211_bss_conf - holds the BSS's changing parameters
  *
  * This structure keeps information about a BSS (and an association
@@ -562,6 +580,9 @@ struct ieee80211_mu_group_data {
  * @protected_keep_alive: if set, indicates that the station should send an RSN
  * protected frame to the AP to reset the idle timer at the AP for the
  * station.
+ * @ftm_responder: whether to enable or disable fine timing measurement FTM
+ * responder functionality.
+ * @ftmr_params: configurable lci/civic parameter when enabling FTM responder.
  */
 struct ieee80211_bss_conf {
const u8 *bssid;
@@ -612,6 +633,8 @@ struct ieee80211_bss_conf {
bool allow_p2p_go_ps;
u16 max_idle_period;
bool protected_keep_alive;
+   bool ftm_responder;
+   struct ieee80211_ftm_responder_params *ftmr_params;
 };
 
 /**
@@ -3598,6 +3621,8 @@ enum ieee80211_reconfig_type {
  * aggregating two specific frames in the same A-MSDU. The relation
  * between the skbs should be symmetric and transitive. Note that while
  * skb is always a real frame, head may or may not be an A-MSDU.
+ * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
+ * Statistics should be cumulative, currently no way to reset is provided.
  */
 struct ieee80211_ops {
void (*tx)(struct ieee80211_hw *hw,
@@ -3883,6 +3908,9 @@ struct ieee80211_ops {
bool (*can_aggregate_in_amsdu)(struct ieee80211_hw *hw,
   struct sk_buff *head,
   struct sk_buff *skb);
+   int (*get_ftm_responder_stats)(struct ieee80211_hw *hw,
+  struct ieee80211_vif *vif,
+  struct cfg80211_ftm_responder_stats 
*ftm_stats);
 };
 
 /**
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 504627e2117f..c3904d45e82a 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -790,6 +790,48 @@ static int ieee80211_set_probe_resp(struct 
ieee80211_sub_if_data *sdata,
return 0;
 }
 
+static int ieee80211_set_ftm_responder_params(
+   struct ieee80211_sub_if_data *sdata,
+   const u8 *lci, size_t lci_len,
+   const u8 *civicloc, size_t civicloc_len)
+{
+   struct ieee80211_ftm_responder_params *new, *old;
+   struct ieee80211_bss_conf *bss_conf;
+   u8 *pos;
+   int len;
+
+   if ((!lci || !lci_len) && (!civicloc || !civicloc_len))
+   return 1;
+
+   bss_conf = >vif.bss_conf;
+   old = bss_conf->ftmr_params;
+   len = lci_len + civicloc_len;
+
+   new = kzalloc(sizeof(*new) + len, GFP_KERNEL);
+   if (!new)
+   return -ENOMEM;
+
+   pos = (u8 *)(new + 1);
+   if (lci_len) {
+   new->lci_len = lci_len;
+   new->lci = pos;
+   memcpy(pos, lci, lci_len);
+   pos += lci_len;
+   }
+
+  

[PATCH] ath10k: Add support to configure channel dwell time

2018-05-11 Thread Pradeep Kumar Chitrapu
Configure channel dwell time from duration of the scan request
received from mac80211 when the duration is non-zero. When the
scan request does not have duration value, use the default ones,
the current implementation.

Corresponding flag NL80211_EXT_FEATURE_SET_SCAN_DWELL is
advertized.

Supported Chipsets:
 -QCA988X/QCA9887 PCI
 -QCA99X0/QCA9984/QCA9888/QCA4019 PCI
 -QCA6174/QCA9377 PCI/USB/SDIO
 -WCN3990 SNOC

Tested on QCA9984 with firmware ver 10.4-3.6-0010

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/core.h |  1 +
 drivers/net/wireless/ath/ath10k/mac.c  | 23 ---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/core.h 
b/drivers/net/wireless/ath/ath10k/core.h
index c17d805..39d4d7d 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -44,6 +44,7 @@
 #define WO(_f)  ((_f##_OFFSET) >> 2)
 
 #define ATH10K_SCAN_ID 0
+#define ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD 10 /* msec */
 #define WMI_READY_TIMEOUT (5 * HZ)
 #define ATH10K_FLUSH_TIMEOUT_HZ (5 * HZ)
 #define ATH10K_CONNECTION_LOSS_HZ (3 * HZ)
diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index bf05a36..c6828c7 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -5668,6 +5668,7 @@ static int ath10k_hw_scan(struct ieee80211_hw *hw,
struct wmi_start_scan_arg arg;
int ret = 0;
int i;
+   u32 scan_timeout;
 
mutex_lock(>conf_mutex);
 
@@ -5723,6 +5724,22 @@ static int ath10k_hw_scan(struct ieee80211_hw *hw,
arg.channels[i] = req->channels[i]->center_freq;
}
 
+   /* if duration is set, default dwell times will be overwritten */
+   if (req->duration) {
+   arg.dwell_time_active = req->duration;
+   arg.dwell_time_passive = req->duration;
+   arg.burst_duration_ms = req->duration;
+
+   scan_timeout = min_t(u32, arg.max_rest_time *
+   (arg.n_channels - 1) + (req->duration +
+   ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) *
+   arg.n_channels, arg.max_scan_time + 200);
+
+   } else {
+   /* Add a 200ms margin to account for event/command processing */
+   scan_timeout = arg.max_scan_time + 200;
+   }
+
ret = ath10k_start_scan(ar, );
if (ret) {
ath10k_warn(ar, "failed to start hw scan: %d\n", ret);
@@ -5731,10 +5748,8 @@ static int ath10k_hw_scan(struct ieee80211_hw *hw,
spin_unlock_bh(>data_lock);
}
 
-   /* Add a 200ms margin to account for event/command processing */
ieee80211_queue_delayed_work(ar->hw, >scan.timeout,
-msecs_to_jiffies(arg.max_scan_time +
- 200));
+msecs_to_jiffies(scan_timeout));
 
 exit:
mutex_unlock(>conf_mutex);
@@ -8351,6 +8366,8 @@ int ath10k_mac_register(struct ath10k *ar)
}
 
wiphy_ext_feature_set(ar->hw->wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
+   wiphy_ext_feature_set(ar->hw->wiphy,
+ NL80211_EXT_FEATURE_SET_SCAN_DWELL);
 
/*
 * on LL hardware queues are managed entirely by the FW
-- 
1.9.1



[PATCH] iw: Add duration parameter to scan command

2018-05-08 Thread Pradeep Kumar Chitrapu
This patch lets user to specify duration(TUs) and set duration-mandatory
flag in scan command.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---

 scan.c | 31 ---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/scan.c b/scan.c
index 74ccc06..3e9daef 100644
--- a/scan.c
+++ b/scan.c
@@ -411,10 +411,13 @@ static int handle_scan(struct nl80211_state *state,
IES,
SSID,
MESHID,
+   DURATION,
DONE,
} parse = NONE;
int freq;
+   unsigned int duration = 0;
bool passive = false, have_ssids = false, have_freqs = false;
+   bool duration_mandatory = false;
size_t ies_len = 0, meshid_len = 0;
unsigned char *ies = NULL, *meshid = NULL, *tmpies;
unsigned int flags = 0;
@@ -448,6 +451,9 @@ static int handle_scan(struct nl80211_state *state,
} else if (strcmp(argv[i], "ap-force") == 0) {
flags |= NL80211_SCAN_FLAG_AP;
break;
+   } else if (strcmp(argv[i], "duration-mandatory") == 0) {
+   duration_mandatory = true;
+   break;
} else if (strncmp(argv[i], "randomise", 9) == 0 ||
   strncmp(argv[i], "randomize", 9) == 0) {
flags |= NL80211_SCAN_FLAG_RANDOM_ADDR;
@@ -466,6 +472,9 @@ static int handle_scan(struct nl80211_state *state,
} else if (strcmp(argv[i], "meshid") == 0) {
parse = MESHID;
break;
+   } else if (strcmp(argv[i], "duration") == 0) {
+   parse = DURATION;
+   break;
}
case DONE:
nlmsg_free(ssids);
@@ -501,6 +510,10 @@ static int handle_scan(struct nl80211_state *state,
meshid_len += 2;
parse = NONE;
break;
+   case DURATION:
+   duration = strtoul(argv[i], , 10);
+   parse = NONE;
+   break;
}
}
 
@@ -535,6 +548,17 @@ static int handle_scan(struct nl80211_state *state,
nla_put_nested(msg, NL80211_ATTR_SCAN_FREQUENCIES, freqs);
if (flags)
NLA_PUT_U32(msg, NL80211_ATTR_SCAN_FLAGS, flags);
+   if (duration)
+   NLA_PUT_U16(msg, NL80211_ATTR_MEASUREMENT_DURATION, duration);
+   if (duration_mandatory) {
+   if (duration) {
+   NLA_PUT_FLAG(msg,
+
NL80211_ATTR_MEASUREMENT_DURATION_MANDATORY);
+   } else {
+   err = -EINVAL;
+   goto nla_put_failure;
+   }
+   }
 
err = 0;
  nla_put_failure:
@@ -2275,7 +2299,7 @@ static int handle_scan_combined(struct nl80211_state 
*state,
dump_argv[0] = argv[0];
return handle_cmd(state, id, dump_argc, dump_argv);
 }
-TOPLEVEL(scan, "[-u] [freq *] [ies ] [meshid ] 
[lowpri,flush,ap-force] [randomise[=/]] [ssid *|passive]", 0, 
0,
+TOPLEVEL(scan, "[-u] [freq *] [duration ] [ies ] 
[meshid ] [lowpri,flush,ap-force,duration-mandatory] 
[randomise[=/]] [ssid *|passive]", 0, 0,
 CIB_NETDEV, handle_scan_combined,
 "Scan on the given frequencies and probe for the given SSIDs\n"
 "(or wildcard if not given) unless passive scanning is requested.\n"
@@ -2285,10 +2309,11 @@ COMMAND(scan, dump, "[-u]",
NL80211_CMD_GET_SCAN, NLM_F_DUMP, CIB_NETDEV, handle_scan_dump,
"Dump the current scan results. If -u is specified, print unknown\n"
"data in scan results.");
-COMMAND(scan, trigger, "[freq *] [ies ] [meshid 
] [lowpri,flush,ap-force] [randomise[=/]] [ssid 
*|passive]",
+COMMAND(scan, trigger, "[freq *] [duration ] [ies ] [meshid ] [lowpri,flush,ap-force,duration-mandatory] 
[randomise[=/]] [ssid *|passive]",
NL80211_CMD_TRIGGER_SCAN, 0, CIB_NETDEV, handle_scan,
 "Trigger a scan on the given frequencies with probing for the given\n"
-"SSIDs (or wildcard if not given) unless passive scanning is 
requested.");
+"SSIDs (or wildcard if not given) unless passive scanning is 
requested.\n"
+"Duration(in TUs), if specified, will be used to set dwell times.\n");
 
 
 static int handle_scan_abort(struct nl80211_state *state,
-- 
1.9.1



[PATCH v2] ath10k: support for multicast rate control

2018-05-07 Thread Pradeep Kumar Chitrapu
Issues wmi command to firmwre when multicast rate change is received
with the new BSS_CHANGED_MCAST_RATE flag.
Also fixes the incorrect fixed_rate setting for CCK rates which got
introduced with addition of ath10k_rates_rev2 enum.

Tested on QCA9984 with firmware ver 10.4-3.6-00104

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
v2:
 - fixed the CCK rates setting for mcast_rate and fixed_rate paths.
 - set broadcast rate along with multicast rate setting.

 drivers/net/wireless/ath/ath10k/mac.c | 54 ---
 1 file changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index 3d7119a..70a0563 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -101,6 +101,8 @@
 #define ath10k_g_rates_rev2 (ath10k_rates_rev2 + 0)
 #define ath10k_g_rates_rev2_size (ARRAY_SIZE(ath10k_rates_rev2))
 
+#define ath10k_wmi_legacy_rates ath10k_rates
+
 static bool ath10k_mac_bitrate_is_cck(int bitrate)
 {
switch (bitrate) {
@@ -5426,8 +5428,12 @@ static void ath10k_bss_info_changed(struct ieee80211_hw 
*hw,
 {
struct ath10k *ar = hw->priv;
struct ath10k_vif *arvif = (void *)vif->drv_priv;
-   int ret = 0;
+   struct cfg80211_chan_def def;
u32 vdev_param, pdev_param, slottime, preamble;
+   u16 bitrate, hw_value;
+   u8 rate;
+   int rateidx, ret = 0;
+   enum nl80211_band band;
 
mutex_lock(>conf_mutex);
 
@@ -5595,6 +5601,44 @@ static void ath10k_bss_info_changed(struct ieee80211_hw 
*hw,
arvif->vdev_id, ret);
}
 
+   if (changed & BSS_CHANGED_MCAST_RATE &&
+   !WARN_ON(ath10k_mac_vif_chan(arvif->vif, ))) {
+   band = def.chan->band;
+   rateidx = vif->bss_conf.mcast_rate[band] - 1;
+
+   if (ar->phy_capability & WHAL_WLAN_11A_CAPABILITY)
+   rateidx += ATH10K_MAC_FIRST_OFDM_RATE_IDX;
+
+   bitrate = ath10k_wmi_legacy_rates[rateidx].bitrate;
+   hw_value = ath10k_wmi_legacy_rates[rateidx].hw_value;
+   if (ath10k_mac_bitrate_is_cck(bitrate))
+   preamble = WMI_RATE_PREAMBLE_CCK;
+   else
+   preamble = WMI_RATE_PREAMBLE_OFDM;
+
+   rate = ATH10K_HW_RATECODE(hw_value, 0, preamble);
+
+   ath10k_dbg(ar, ATH10K_DBG_MAC,
+  "mac vdev %d mcast_rate %x\n",
+  arvif->vdev_id, rate);
+
+   vdev_param = ar->wmi.vdev_param->mcast_data_rate;
+   ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
+   vdev_param, rate);
+   if (ret)
+   ath10k_warn(ar,
+   "failed to set mcast rate on vdev %i: %d\n",
+   arvif->vdev_id,  ret);
+
+   vdev_param = ar->wmi.vdev_param->bcast_data_rate;
+   ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
+   vdev_param, rate);
+   if (ret)
+   ath10k_warn(ar,
+   "failed to set bcast rate on vdev %i: %d\n",
+   arvif->vdev_id,  ret);
+   }
+
mutex_unlock(>conf_mutex);
 }
 
@@ -6895,7 +6939,6 @@ ath10k_mac_bitrate_mask_get_single_rate(
const struct cfg80211_bitrate_mask 
*mask,
u8 *rate, u8 *nss)
 {
-   struct ieee80211_supported_band *sband = >mac.sbands[band];
int rate_idx;
int i;
u16 bitrate;
@@ -6905,8 +6948,11 @@ ath10k_mac_bitrate_mask_get_single_rate(
if (hweight32(mask->control[band].legacy) == 1) {
rate_idx = ffs(mask->control[band].legacy) - 1;
 
-   hw_rate = sband->bitrates[rate_idx].hw_value;
-   bitrate = sband->bitrates[rate_idx].bitrate;
+   if (ar->phy_capability & WHAL_WLAN_11A_CAPABILITY)
+   rate_idx += ATH10K_MAC_FIRST_OFDM_RATE_IDX;
+
+   hw_rate = ath10k_wmi_legacy_rates[rate_idx].hw_value;
+   bitrate = ath10k_wmi_legacy_rates[rate_idx].bitrate;
 
if (ath10k_mac_bitrate_is_cck(bitrate))
preamble = WMI_RATE_PREAMBLE_CCK;
-- 
1.9.1



[PATCH] ath10k:add support for multicast rate control

2018-04-11 Thread Pradeep Kumar Chitrapu
Issues wmi command to firmware when multicast rate change is received
with the new BSS_CHANGED_MCAST_RATE flag.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/mac.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/mac.c 
b/drivers/net/wireless/ath/ath10k/mac.c
index bf05a36..63af46f 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -5419,8 +5419,12 @@ static void ath10k_bss_info_changed(struct ieee80211_hw 
*hw,
 {
struct ath10k *ar = hw->priv;
struct ath10k_vif *arvif = (void *)vif->drv_priv;
-   int ret = 0;
+   struct ieee80211_supported_band *sband;
+   struct cfg80211_chan_def def;
u32 vdev_param, pdev_param, slottime, preamble;
+   int rate_index, ret = 0;
+   u8 rate;
+   enum nl80211_band band;
 
mutex_lock(>conf_mutex);
 
@@ -5588,6 +5592,25 @@ static void ath10k_bss_info_changed(struct ieee80211_hw 
*hw,
arvif->vdev_id, ret);
}
 
+   if (changed & BSS_CHANGED_MCAST_RATE &&
+   !WARN_ON(ath10k_mac_vif_chan(arvif->vif, ))) {
+   band = def.chan->band;
+   sband = >mac.sbands[band];
+   vdev_param = ar->wmi.vdev_param->mcast_data_rate;
+   rate_index = vif->bss_conf.mcast_rate[band] - 1;
+   rate = ATH10K_HW_MCS_RATE(sband->bitrates[rate_index].hw_value);
+   ath10k_dbg(ar, ATH10K_DBG_MAC,
+  "mac vdev %d mcast_rate %d\n",
+  arvif->vdev_id, rate);
+
+   ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id,
+   vdev_param, rate);
+   if (ret)
+   ath10k_warn(ar,
+   "failed to set mcast rate on vdev"
+   " %i: %d\n", arvif->vdev_id,  ret);
+   }
+
mutex_unlock(>conf_mutex);
 }
 
-- 
1.9.1



[PATCH v3] mac80211: notify driver for change in multicast rates

2018-03-22 Thread Pradeep Kumar Chitrapu
It is required to pass the rate information to driver/firmware
when rate control is offloaded to firmware. This helps in changing
multicast traffic rates thereby improving the network performance.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
V3:
  - Added Documentation
V2:
  - Set the flag in missing places

 include/net/mac80211.h | 3 +++
 net/mac80211/cfg.c | 2 ++
 net/mac80211/ibss.c| 2 +-
 net/mac80211/mesh.c| 3 ++-
 net/mac80211/util.c| 3 ++-
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 4c99c13..f0e4f8a 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -309,6 +309,8 @@ struct ieee80211_vif_chanctx_switch {
  * @BSS_CHANGED_MU_GROUPS: VHT MU-MIMO group id or user position changed
  * @BSS_CHANGED_KEEP_ALIVE: keep alive options (idle period or protected
  * keep alive) changed.
+ * @BSS_CHANGED_MCAST_RATE: Multicast Rate setting changed for this interface
+ *
  */
 enum ieee80211_bss_change {
BSS_CHANGED_ASSOC   = 1<<0,
@@ -336,6 +338,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_OCB = 1<<22,
BSS_CHANGED_MU_GROUPS   = 1<<23,
BSS_CHANGED_KEEP_ALIVE  = 1<<24,
+   BSS_CHANGED_MCAST_RATE  = 1<<25,
 
/* when adding here, make sure to change ieee80211_reconfig */
 };
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0763792..22bb82e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2313,6 +2313,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, 
struct net_device *dev,
memcpy(sdata->vif.bss_conf.mcast_rate, rate,
   sizeof(int) * NUM_NL80211_BANDS);
 
+   ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MCAST_RATE);
+
return 0;
 }
 
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index e9c6aa3..f4b0634 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1840,7 +1840,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data 
*sdata,
  IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
| IEEE80211_HT_PARAM_RIFS_MODE;
 
-   changed |= BSS_CHANGED_HT;
+   changed |= BSS_CHANGED_HT | BSS_CHANGED_MCAST_RATE;
ieee80211_bss_info_change_notify(sdata, changed);
 
sdata->smps_mode = IEEE80211_SMPS_OFF;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 277398d..55c04e1 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -884,7 +884,8 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data 
*sdata)
  BSS_CHANGED_BEACON_ENABLED |
  BSS_CHANGED_HT |
  BSS_CHANGED_BASIC_RATES |
- BSS_CHANGED_BEACON_INT;
+ BSS_CHANGED_BEACON_INT |
+ BSS_CHANGED_MCAST_RATE;
 
local->fif_other_bss++;
/* mesh ifaces must set allmulti to forward mcast traffic */
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 6aef679..6594df0 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1971,7 +1971,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
  BSS_CHANGED_CQM |
  BSS_CHANGED_QOS |
  BSS_CHANGED_IDLE |
- BSS_CHANGED_TXPOWER;
+ BSS_CHANGED_TXPOWER |
+ BSS_CHANGED_MCAST_RATE;
 
if (sdata->vif.mu_mimo_owner)
changed |= BSS_CHANGED_MU_GROUPS;
-- 
1.9.1



[PATCH v2] mac80211: notify driver for change in multicast rates

2018-03-21 Thread Pradeep Kumar Chitrapu
It is required to pass the rate information to driver/firmware
when rate control is offloaded to firmware. This helps in changing
multicast traffic rates thereby improving the network performance.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
V2:
  - Set the flag in missing places

 include/net/mac80211.h | 1 +
 net/mac80211/cfg.c | 2 ++
 net/mac80211/ibss.c| 2 +-
 net/mac80211/mesh.c| 3 ++-
 net/mac80211/util.c| 3 ++-
 5 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 4c99c13..4360765 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -336,6 +336,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_OCB = 1<<22,
BSS_CHANGED_MU_GROUPS   = 1<<23,
BSS_CHANGED_KEEP_ALIVE  = 1<<24,
+   BSS_CHANGED_MCAST_RATE  = 1<<25,
 
/* when adding here, make sure to change ieee80211_reconfig */
 };
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0763792..22bb82e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2313,6 +2313,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, 
struct net_device *dev,
memcpy(sdata->vif.bss_conf.mcast_rate, rate,
   sizeof(int) * NUM_NL80211_BANDS);
 
+   ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MCAST_RATE);
+
return 0;
 }
 
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index e9c6aa3..f4b0634 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1840,7 +1840,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data 
*sdata,
  IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED
| IEEE80211_HT_PARAM_RIFS_MODE;
 
-   changed |= BSS_CHANGED_HT;
+   changed |= BSS_CHANGED_HT | BSS_CHANGED_MCAST_RATE;
ieee80211_bss_info_change_notify(sdata, changed);
 
sdata->smps_mode = IEEE80211_SMPS_OFF;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 277398d..55c04e1 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -884,7 +884,8 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data 
*sdata)
  BSS_CHANGED_BEACON_ENABLED |
  BSS_CHANGED_HT |
  BSS_CHANGED_BASIC_RATES |
- BSS_CHANGED_BEACON_INT;
+ BSS_CHANGED_BEACON_INT |
+ BSS_CHANGED_MCAST_RATE;
 
local->fif_other_bss++;
/* mesh ifaces must set allmulti to forward mcast traffic */
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 6aef679..6594df0 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1971,7 +1971,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
  BSS_CHANGED_CQM |
  BSS_CHANGED_QOS |
  BSS_CHANGED_IDLE |
- BSS_CHANGED_TXPOWER;
+ BSS_CHANGED_TXPOWER |
+ BSS_CHANGED_MCAST_RATE;
 
if (sdata->vif.mu_mimo_owner)
changed |= BSS_CHANGED_MU_GROUPS;
-- 
1.9.1



[PATCH] mac80211: notify driver for change in multicast rates

2018-03-20 Thread Pradeep Kumar Chitrapu
It is required to pass the rate information to driver/firmware
when rate control is offloaded to firmware. This helps in changing
multicast traffic rates thereby improving the network performance.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
 include/net/mac80211.h | 1 +
 net/mac80211/cfg.c | 2 ++
 net/mac80211/util.c| 3 ++-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 4c99c13..4360765 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -336,6 +336,7 @@ enum ieee80211_bss_change {
BSS_CHANGED_OCB = 1<<22,
BSS_CHANGED_MU_GROUPS   = 1<<23,
BSS_CHANGED_KEEP_ALIVE  = 1<<24,
+   BSS_CHANGED_MCAST_RATE  = 1<<25,
 
/* when adding here, make sure to change ieee80211_reconfig */
 };
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 0763792..22bb82e 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2313,6 +2313,8 @@ static int ieee80211_set_mcast_rate(struct wiphy *wiphy, 
struct net_device *dev,
memcpy(sdata->vif.bss_conf.mcast_rate, rate,
   sizeof(int) * NUM_NL80211_BANDS);
 
+   ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_MCAST_RATE);
+
return 0;
 }
 
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 6aef679..6594df0 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1971,7 +1971,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
  BSS_CHANGED_CQM |
  BSS_CHANGED_QOS |
  BSS_CHANGED_IDLE |
- BSS_CHANGED_TXPOWER;
+ BSS_CHANGED_TXPOWER |
+ BSS_CHANGED_MCAST_RATE;
 
if (sdata->vif.mu_mimo_owner)
changed |= BSS_CHANGED_MU_GROUPS;
-- 
1.9.1



[PATCH] wireless: allow send peer mac in rssi cqm notify

2017-08-22 Thread Pradeep Kumar Chitrapu
Extend cqm rssi notifier apis to include peer mac address. Currently
netlink cqm msg already accepts the mac. With this change just passing
the mac address as an argument to cfg and mac80211 apis.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
 drivers/net/wireless/intel/iwlwifi/mvm/rx.c  |  4 ++--
 drivers/net/wireless/marvell/mwifiex/sta_event.c |  4 ++--
 drivers/net/wireless/rndis_wlan.c|  2 +-
 drivers/net/wireless/rsi/rsi_91x_mac80211.c  |  3 ++-
 drivers/net/wireless/st/cw1200/sta.c |  4 ++--
 drivers/net/wireless/ti/wl1251/event.c   |  4 ++--
 drivers/net/wireless/ti/wlcore/event.c   |  4 ++--
 include/net/cfg80211.h   |  3 ++-
 include/net/mac80211.h   |  3 ++-
 net/mac80211/mlme.c  | 14 +++---
 net/mac80211/trace.h |  8 +---
 net/wireless/nl80211.c   |  6 +++---
 net/wireless/trace.h |  9 ++---
 13 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c 
b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
index 622d543abb70..82d64ef87176 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/rx.c
@@ -594,7 +594,7 @@ static void iwl_mvm_stat_iterator(void *_data, u8 *mac,
IWL_DEBUG_RX(mvm, "cqm_iterator cqm low %d\n",
 sig);
ieee80211_cqm_rssi_notify(
-   vif,
+   vif, NULL,
NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
sig,
GFP_KERNEL);
@@ -604,7 +604,7 @@ static void iwl_mvm_stat_iterator(void *_data, u8 *mac,
IWL_DEBUG_RX(mvm, "cqm_iterator cqm high %d\n",
 sig);
ieee80211_cqm_rssi_notify(
-   vif,
+   vif, NULL,
NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
sig,
GFP_KERNEL);
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_event.c 
b/drivers/net/wireless/marvell/mwifiex/sta_event.c
index 839df8a9634e..ba80d90ba5d0 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_event.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_event.c
@@ -822,7 +822,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
break;
 
case EVENT_RSSI_LOW:
-   cfg80211_cqm_rssi_notify(priv->netdev,
+   cfg80211_cqm_rssi_notify(priv->netdev, NULL,
 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
 0, GFP_KERNEL);
mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
@@ -837,7 +837,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv)
mwifiex_dbg(adapter, EVENT, "event: MAX_FAIL\n");
break;
case EVENT_RSSI_HIGH:
-   cfg80211_cqm_rssi_notify(priv->netdev,
+   cfg80211_cqm_rssi_notify(priv->netdev, NULL,
 NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
 0, GFP_KERNEL);
mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
diff --git a/drivers/net/wireless/rndis_wlan.c 
b/drivers/net/wireless/rndis_wlan.c
index 9935bd09db1f..24f192deaf3d 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -3194,7 +3194,7 @@ static void rndis_do_cqm(struct usbnet *usbdev, s32 rssi)
return;
 
priv->last_cqm_event_rssi = rssi;
-   cfg80211_cqm_rssi_notify(usbdev->net, event, rssi, GFP_KERNEL);
+   cfg80211_cqm_rssi_notify(usbdev->net, NULL, event, rssi, GFP_KERNEL);
 }
 
 #define DEVICE_POLLER_JIFFIES (HZ)
diff --git a/drivers/net/wireless/rsi/rsi_91x_mac80211.c 
b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
index 021e5ac5f107..4daf78acd2dc 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mac80211.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mac80211.c
@@ -877,7 +877,8 @@ static void rsi_perform_cqm(struct rsi_common *common,
 
common->cqm_info.last_cqm_event_rssi = rssi;
rsi_dbg(INFO_ZONE, "CQM: Notifying event: %d\n", event);
-   ieee80211_cqm_rssi_notify(adapter->vifs[0], event, rssi, GFP_KERNEL);
+   ieee80211_cqm_rssi_notify(adapter->vifs[0], NULL,  event,
+ rssi, GFP_KERNEL);
 
return;
 }
diff --git a/drivers/net/wireless/st/cw1200/sta.c 
b/drivers/net/wireless/st/cw1200/sta.c
index a52224836a2b..de786269468a 100644
--- a/drivers/net/wireless/st/cw1200/sta.c
+++ b/drivers/net/wireless/st/cw1200/sta.c
@@ -1019,8 +1019,8 @@ void cw1200_event_handler(struct work_struct

[PATCH 1/2] cfg80211: enable setting cqm config for AP mode

2017-08-09 Thread Pradeep Kumar Chitrapu
Enable connection monitoring for AP mode which makes it possible to track
signal strength of connected stations.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
 net/wireless/nl80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index bafab07530d6..beda9c62f74a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9784,7 +9784,8 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
}
 
if (wdev->iftype != NL80211_IFTYPE_STATION &&
-   wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)
+   wdev->iftype != NL80211_IFTYPE_P2P_CLIENT &&
+   wdev->iftype != NL80211_IFTYPE_AP)
return -EOPNOTSUPP;
 
wdev_lock(wdev);
-- 
1.9.1



[PATCH 2/2] mac80211: enable setting cqm config for AP mode

2017-08-09 Thread Pradeep Kumar Chitrapu
Enable connection monitoring for AP mode which makes it possible to track
signal strength of connected stations.

Signed-off-by: Pradeep Kumar Chitrapu <prade...@codeaurora.org>
---
 net/mac80211/cfg.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index a354f1939e49..1548fd34961c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2682,9 +2682,11 @@ static int ieee80211_set_cqm_rssi_config(struct wiphy 
*wiphy,
bss_conf->cqm_rssi_high = 0;
sdata->u.mgd.last_cqm_event_signal = 0;
 
-   /* tell the driver upon association, unless already associated */
-   if (sdata->u.mgd.associated &&
-   sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
+   /* if STA, tell the driver upon association, unless already associated.
+* if AP, always tell the driver.
+*/
+   if ((sdata->u.mgd.associated || vif->type == NL80211_IFTYPE_AP) &&
+   (sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI))
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
 
return 0;
@@ -2708,7 +2710,7 @@ static int ieee80211_set_cqm_rssi_range_config(struct 
wiphy *wiphy,
sdata->u.mgd.last_cqm_event_signal = 0;
 
/* tell the driver upon association, unless already associated */
-   if (sdata->u.mgd.associated &&
+   if ((sdata->u.mgd.associated  || vif->type == NL80211_IFTYPE_AP) &&
sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
 
-- 
1.9.1