diff mbox series

ath10k: support NET_DETECT WoWLAN feature

Message ID 1534214568-25226-1-git-send-email-wgong@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series ath10k: support NET_DETECT WoWLAN feature | expand

Commit Message

Wen Gong Aug. 14, 2018, 2:42 a.m. UTC
For WoWLAN support, it expect to support wake up based on discovery of
one or more known SSIDs. This is the WIPHY_WOWLAN_NET_DETECT feature,
which shows up as an NL80211 feature flag.

With an upgrade iw, this shows up in 'iw phy' as:
WoWLAN support:
* wake up on network detection, up to 16 match sets
And it can use command:
"iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412
matches ssid foo" to configure the parameters of net detect.

Firmware will do scan by the configured parameters after suspend and
wakeup if it found matched SSIDs. Tested with QCA6174 hw3.0 with
firmware WLAN.RM.4.4.1-00110-QCARMSWPZ-1.

Signed-off-by: Wen Gong <wgong@codeaurora.org>
---
 drivers/net/wireless/ath/ath10k/core.h    |   1 +
 drivers/net/wireless/ath/ath10k/mac.c     |  12 ++
 drivers/net/wireless/ath/ath10k/wmi-ops.h |  21 +++
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 178 ++++++++++++++++++++++-
 drivers/net/wireless/ath/ath10k/wmi-tlv.h | 226 ++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/wmi.h     |  57 ++++++++
 drivers/net/wireless/ath/ath10k/wow.c     | 168 ++++++++++++++++++++++
 7 files changed, 662 insertions(+), 1 deletion(-)

Comments

kernel test robot Aug. 14, 2018, 12:52 p.m. UTC | #1
Hi Wen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ath6kl/ath-next]
[also build test WARNING on v4.18 next-20180813]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Wen-Gong/ath10k-support-NET_DETECT-WoWLAN-feature/20180814-174257
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/net/wireless/ath/ath10k/wow.c: In function 'ath10k_wow_op_resume':
>> drivers/net/wireless/ath/ath10k/wow.c:451:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
      if (ret) {
         ^
   drivers/net/wireless/ath/ath10k/wow.c:421:6: note: 'ret' was declared here
     int ret;
         ^~~

vim +/ret +451 drivers/net/wireless/ath/ath10k/wow.c

   441	
   442	static int ath10k_wow_nlo_cleanup(struct ath10k *ar)
   443	{
   444		struct ath10k_vif *arvif;
   445		int ret;
   446	
   447		lockdep_assert_held(&ar->conf_mutex);
   448	
   449		list_for_each_entry(arvif, &ar->arvifs, list) {
   450			ret = ath10k_vif_wow_clean_nlo(arvif);
 > 451			if (ret) {
   452				ath10k_warn(ar, "failed to clean nlo settings on vdev %i: %d\n",
   453					    arvif->vdev_id, ret);
   454				return ret;
   455			}
   456		}
   457	
   458		return 0;
   459	}
   460	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Aug. 14, 2018, 2:05 p.m. UTC | #2
Hi Wen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ath6kl/ath-next]
[also build test WARNING on v4.18 next-20180813]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Wen-Gong/ath10k-support-NET_DETECT-WoWLAN-feature/20180814-174257
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/slab.h:631:13: sparse: undefined identifier '__builtin_mul_overflow'
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:2700:19: sparse: expression using sizeof(void)
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3461:30: sparse: expression using sizeof(void)
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3464:33: sparse: expression using sizeof(void)
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3477:22: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] vdev_id @@    got unsignerestricted __le32 [usertype] vdev_id @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3477:22:    expected restricted __le32 [usertype] vdev_id
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3477:22:    got unsigned char [unsigned] [usertype] vdev_id
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3478:20: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] flags @@    got e] flags @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3478:20:    expected restricted __le32 [usertype] flags
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3478:20:    got int
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3481:32: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] active_dwell_time @@    got unsignrestricted __le32 [usertype] active_dwell_time @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3481:32:    expected restricted __le32 [usertype] active_dwell_time
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3481:32:    got unsigned int [unsigned] [usertype] active_max_time
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3482:33: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] passive_dwell_time @@    got unsignrestricted __le32 [usertype] passive_dwell_time @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3482:33:    expected restricted __le32 [usertype] passive_dwell_time
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3482:33:    got unsigned int [unsigned] [usertype] passive_max_time
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3485:28: sparse: invalid assignment: |=
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3485:28:    left side has type restricted __le32
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3485:28:    right side has type int
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3487:31: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] fast_scan_period @@    got unsignrestricted __le32 [usertype] fast_scan_period @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3487:31:    expected restricted __le32 [usertype] fast_scan_period
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3487:31:    got unsigned int [unsigned] [usertype] fast_scan_period
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3488:31: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] slow_scan_period @@    got unsignrestricted __le32 [usertype] slow_scan_period @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3488:31:    expected restricted __le32 [usertype] slow_scan_period
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3488:31:    got unsigned int [unsigned] [usertype] slow_scan_period
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3489:35: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] fast_scan_max_cycles @@    got unsignerestricted __le32 [usertype] fast_scan_max_cycles @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3489:35:    expected restricted __le32 [usertype] fast_scan_max_cycles
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3489:35:    got unsigned char [unsigned] [usertype] fast_scan_max_cycles
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3490:31: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] delay_start_time @@    got unsignrestricted __le32 [usertype] delay_start_time @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3490:31:    expected restricted __le32 [usertype] delay_start_time
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3490:31:    got unsigned int [unsigned] [usertype] delay_start_time
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3492:28: sparse: invalid assignment: |=
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3492:28:    left side has type restricted __le32
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3492:28:    right side has type int
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3501:28: sparse: expression using sizeof(void)
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3501:26: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] no_of_ssids @@    got e] no_of_ssids @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3501:26:    expected restricted __le32 [usertype] no_of_ssids
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3501:26:    got int
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3504:20: sparse: restricted __le32 degrades to integer
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3509:28: sparse: restricted __le32 degrades to integer
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3515:40: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] valid @@    got e] valid @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3515:40:    expected restricted __le32 [usertype] valid
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3515:40:    got int
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3517:17: sparse: incorrect type in argument 3 (different base types) @@    expected unsigned long [unsigned] [usertype] len @@    got d long [unsigned] [usertype] len @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3517:17:    expected unsigned long [unsigned] [usertype] len
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3517:17:    got restricted __le32 [usertype] ssid_len
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3524:53: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] valid @@    got e] valid @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3524:53:    expected restricted __le32 [usertype] valid
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3524:53:    got int
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3525:52: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] rssi @@    got signed int [signed] [urestricted __le32 [usertype] rssi @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3525:52:    expected restricted __le32 [usertype] rssi
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3525:52:    got signed int [signed] [usertype] [explicitly-signed] rssi_threshold
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3528:49: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] valid @@    got e] valid @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3528:49:    expected restricted __le32 [usertype] valid
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3528:49:    got int
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3529:57: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] bcast_nw_type @@    got unsignrestricted __le32 [usertype] bcast_nw_type @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3529:57:    expected restricted __le32 [usertype] bcast_nw_type
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3529:57:    got unsigned int [unsigned] [usertype] bcast_nw_type
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3533:19: sparse: restricted __le32 degrades to integer
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3536:32: sparse: expression using sizeof(void)
>> drivers/net/wireless/ath/ath10k/wmi-tlv.c:3536:30: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] num_of_channels @@    got e] num_of_channels @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3536:30:    expected restricted __le32 [usertype] num_of_channels
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3536:30:    got int
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3541:20: sparse: restricted __le32 degrades to integer
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3545:28: sparse: restricted __le32 degrades to integer
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3580:20: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] flags @@    got e] flags @@
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3580:20:    expected restricted __le32 [usertype] flags
   drivers/net/wireless/ath/ath10k/wmi-tlv.c:3580:20:    got int
   include/linux/slab.h:631:13: sparse: call with no type!
--
>> drivers/net/wireless/ath/ath10k/wow.c:207:50: sparse: incorrect type in assignment (different base types) @@    expected restricted __le32 [usertype] ssid_len @@    got unsignerestricted __le32 [usertype] ssid_len @@
   drivers/net/wireless/ath/ath10k/wow.c:207:50:    expected restricted __le32 [usertype] ssid_len
   drivers/net/wireless/ath/ath10k/wow.c:207:50:    got unsigned char [unsigned] [usertype] ssid_len
>> drivers/net/wireless/ath/ath10k/wow.c:211:44: sparse: restricted __le32 degrades to integer
   drivers/net/wireless/ath/ath10k/wow.c:242:52: sparse: restricted __le32 degrades to integer
>> drivers/net/wireless/ath/ath10k/wow.c:246:56: sparse: incorrect type in argument 3 (different base types) @@    expected unsigned long [unsigned] [usertype] <noident> @@    got d long [unsigned] [usertype] <noident> @@
   drivers/net/wireless/ath/ath10k/wow.c:246:56:    expected unsigned long [unsigned] [usertype] <noident>
   drivers/net/wireless/ath/ath10k/wow.c:246:56:    got restricted __le32 [usertype] ssid_len
   drivers/net/wireless/ath/ath10k/wow.c: In function 'ath10k_wow_op_resume':
   drivers/net/wireless/ath/ath10k/wow.c:451:6: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
      if (ret) {
         ^
   drivers/net/wireless/ath/ath10k/wow.c:421:6: note: 'ret' was declared here
     int ret;
         ^~~

vim +3477 drivers/net/wireless/ath/ath10k/wmi-tlv.c

  3437	
  3438	/* Request FW to start PNO operation */
  3439	static struct sk_buff *ath10k_wmi_tlv_op_gen_config_pno_start
  3440					(struct ath10k *ar,
  3441					u32 vdev_id,
  3442					struct wmi_pno_scan_req *pno)
  3443	{
  3444		struct wmi_tlv_wow_nlo_config_cmd *cmd;
  3445		struct wmi_tlv *tlv;
  3446		struct sk_buff *skb;
  3447		struct nlo_configured_parameters *nlo_list;
  3448		u32 *channel_list;
  3449		void *ptr;
  3450		size_t len;
  3451		u32 i;
  3452	
  3453		len = sizeof(*tlv) + sizeof(*cmd) +
  3454		      sizeof(*tlv) +
  3455		      /* TLV place holder for array of structures
  3456		       * nlo_configured_parameters(nlo_list)
  3457		       */
  3458		      sizeof(*tlv);
  3459		      /* TLV place holder for array of uint32 channel_list */
  3460	
  3461		len += sizeof(u32) * min_t(u8, pno->a_networks[0].channel_count,
  3462					   WMI_NLO_MAX_CHAN);
  3463		len += sizeof(struct nlo_configured_parameters) *
  3464					min_t(u8, pno->uc_networks_count, WMI_NLO_MAX_SSIDS);
  3465	
  3466		skb = ath10k_wmi_alloc_skb(ar, len);
  3467		if (!skb)
  3468			return ERR_PTR(-ENOMEM);
  3469	
  3470		ptr = (void *)skb->data;
  3471		tlv = ptr;
  3472		tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD);
  3473		tlv->len = __cpu_to_le16(sizeof(*cmd));
  3474		cmd = (void *)tlv->value;
  3475	
  3476		/* wmi_tlv_wow_nlo_config_cmd parameters*/
> 3477		cmd->vdev_id = pno->vdev_id;
> 3478		cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
  3479	
  3480		/* Current FW does not support min-max range for dwell time */
> 3481		cmd->active_dwell_time = pno->active_max_time;
> 3482		cmd->passive_dwell_time = pno->passive_max_time;
  3483	
  3484		if (pno->do_passive_scan)
> 3485			cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
  3486		/* Copy scan interval */
> 3487		cmd->fast_scan_period = pno->fast_scan_period;
> 3488		cmd->slow_scan_period = pno->slow_scan_period;
> 3489		cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
> 3490		cmd->delay_start_time = pno->delay_start_time;
  3491		if (pno->enable_pno_scan_randomization) {
> 3492			cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
  3493					WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
  3494			ether_addr_copy(cmd->mac_addr.addr, pno->mac_addr);
  3495			ether_addr_copy(cmd->mac_mask.addr, pno->mac_addr_mask);
  3496		}
  3497		ptr += sizeof(*tlv);
  3498		ptr += sizeof(*cmd);
  3499	
  3500		/* nlo_configured_parameters(nlo_list) */
> 3501		cmd->no_of_ssids = min_t(u8, pno->uc_networks_count, WMI_NLO_MAX_SSIDS);
  3502		tlv = ptr;
  3503		tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
> 3504		tlv->len = __cpu_to_le16
  3505			(cmd->no_of_ssids * sizeof(struct nlo_configured_parameters));
  3506	
  3507		ptr += sizeof(*tlv);
  3508		nlo_list = ptr;
  3509		for (i = 0; i < cmd->no_of_ssids; i++) {
  3510			tlv = (struct wmi_tlv *)(&nlo_list[i].tlv_header);
  3511			tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
  3512			tlv->len = __cpu_to_le16
  3513				(sizeof(struct nlo_configured_parameters) - sizeof(*tlv));
  3514			/* Copy ssid and it's length */
> 3515			nlo_list[i].ssid.valid = true;
  3516			nlo_list[i].ssid.ssid.ssid_len = pno->a_networks[i].ssid.ssid_len;
> 3517			memcpy(nlo_list[i].ssid.ssid.ssid,
  3518			       pno->a_networks[i].ssid.ssid,
  3519			       nlo_list[i].ssid.ssid.ssid_len);
  3520	
  3521			/* Copy rssi threshold */
  3522			if (pno->a_networks[i].rssi_threshold &&
  3523			    pno->a_networks[i].rssi_threshold > -300) {
> 3524				nlo_list[i].rssi_cond.valid = true;
> 3525				nlo_list[i].rssi_cond.rssi = pno->a_networks[i].rssi_threshold;
  3526			}
  3527	
  3528			nlo_list[i].bcast_nw_type.valid = true;
> 3529			nlo_list[i].bcast_nw_type.bcast_nw_type =
  3530				pno->a_networks[i].bcast_nw_type;
  3531		}
  3532	
  3533		ptr += cmd->no_of_ssids * sizeof(struct nlo_configured_parameters);
  3534	
  3535		/* Copy channel info */
> 3536		cmd->num_of_channels = min_t(u8, pno->a_networks[0].channel_count,
  3537					     WMI_NLO_MAX_CHAN);
  3538	
  3539		tlv = ptr;
  3540		tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
  3541		tlv->len = __cpu_to_le16(cmd->num_of_channels * sizeof(u_int32_t));
  3542		ptr += sizeof(*tlv);
  3543	
  3544		channel_list = (u32 *)ptr;
  3545		for (i = 0; i < cmd->num_of_channels; i++)
  3546			channel_list[i] = pno->a_networks[0].channels[i];
  3547	
  3548		ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start pno config vdev_id %d\n", vdev_id);
  3549		return skb;
  3550	}
  3551	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Aug. 15, 2018, 9:23 p.m. UTC | #3
Hi Wen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on ath6kl/ath-next]
[also build test WARNING on v4.18 next-20180814]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Wen-Gong/ath10k-support-NET_DETECT-WoWLAN-feature/20180814-174257
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next


coccinelle warnings: (new ones prefixed by >>)

>> drivers/net/wireless/ath/ath10k/wow.c:321:3-6: alloc with no test, possible model on line 324

vim +321 drivers/net/wireless/ath/ath10k/wow.c

   282	
   283	static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif,
   284					      struct cfg80211_wowlan *wowlan)
   285	{
   286		int ret, i;
   287		unsigned long wow_mask = 0;
   288		struct ath10k *ar = arvif->ar;
   289		const struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
   290		int pattern_id = 0;
   291	
   292		/* Setup requested WOW features */
   293		switch (arvif->vdev_type) {
   294		case WMI_VDEV_TYPE_IBSS:
   295			__set_bit(WOW_BEACON_EVENT, &wow_mask);
   296			 /* fall through */
   297		case WMI_VDEV_TYPE_AP:
   298			__set_bit(WOW_DEAUTH_RECVD_EVENT, &wow_mask);
   299			__set_bit(WOW_DISASSOC_RECVD_EVENT, &wow_mask);
   300			__set_bit(WOW_PROBE_REQ_WPS_IE_EVENT, &wow_mask);
   301			__set_bit(WOW_AUTH_REQ_EVENT, &wow_mask);
   302			__set_bit(WOW_ASSOC_REQ_EVENT, &wow_mask);
   303			__set_bit(WOW_HTT_EVENT, &wow_mask);
   304			__set_bit(WOW_RA_MATCH_EVENT, &wow_mask);
   305			break;
   306		case WMI_VDEV_TYPE_STA:
   307			if (wowlan->disconnect) {
   308				__set_bit(WOW_DEAUTH_RECVD_EVENT, &wow_mask);
   309				__set_bit(WOW_DISASSOC_RECVD_EVENT, &wow_mask);
   310				__set_bit(WOW_BMISS_EVENT, &wow_mask);
   311				__set_bit(WOW_CSA_IE_EVENT, &wow_mask);
   312			}
   313	
   314			if (wowlan->magic_pkt)
   315				__set_bit(WOW_MAGIC_PKT_RECVD_EVENT, &wow_mask);
   316	
   317			if (wowlan->nd_config) {
   318				struct wmi_pno_scan_req *pno;
   319				int ret;
   320	
 > 321				pno = kzalloc(sizeof(*pno), GFP_KERNEL);
   322				ar->nlo_enabled = true;
   323	
 > 324				ret = ath10k_wmi_pno_check(ar, arvif->vdev_id,
   325							   wowlan->nd_config, pno);
   326				if (!ret) {
   327					ath10k_wmi_wow_config_pno(ar, arvif->vdev_id, pno);
   328					__set_bit(WOW_NLO_DETECTED_EVENT, &wow_mask);
   329				}
   330	
   331				kfree(pno);
   332			}
   333			break;
   334		default:
   335			break;
   336		}
   337	
   338		for (i = 0; i < wowlan->n_patterns; i++) {
   339			u8 bitmask[WOW_MAX_PATTERN_SIZE] = {};
   340			u8 ath_pattern[WOW_MAX_PATTERN_SIZE] = {};
   341			u8 ath_bitmask[WOW_MAX_PATTERN_SIZE] = {};
   342			struct cfg80211_pkt_pattern new_pattern = {};
   343			struct cfg80211_pkt_pattern old_pattern = patterns[i];
   344			int j;
   345	
   346			new_pattern.pattern = ath_pattern;
   347			new_pattern.mask = ath_bitmask;
   348			if (patterns[i].pattern_len > WOW_MAX_PATTERN_SIZE)
   349				continue;
   350			/* convert bytemask to bitmask */
   351			for (j = 0; j < patterns[i].pattern_len; j++)
   352				if (patterns[i].mask[j / 8] & BIT(j % 8))
   353					bitmask[j] = 0xff;
   354			old_pattern.mask = bitmask;
   355			new_pattern = old_pattern;
   356	
   357			if (ar->wmi.rx_decap_mode == ATH10K_HW_TXRX_NATIVE_WIFI) {
   358				if (patterns[i].pkt_offset < ETH_HLEN)
   359					ath10k_wow_convert_8023_to_80211(&new_pattern,
   360									 &old_pattern);
   361				else
   362					new_pattern.pkt_offset += WOW_HDR_LEN - ETH_HLEN;
   363			}
   364	
   365			if (WARN_ON(new_pattern.pattern_len > WOW_MAX_PATTERN_SIZE))
   366				return -EINVAL;
   367	
   368			ret = ath10k_wmi_wow_add_pattern(ar, arvif->vdev_id,
   369							 pattern_id,
   370							 new_pattern.pattern,
   371							 new_pattern.mask,
   372							 new_pattern.pattern_len,
   373							 new_pattern.pkt_offset);
   374			if (ret) {
   375				ath10k_warn(ar, "failed to add pattern %i to vdev %i: %d\n",
   376					    pattern_id,
   377					    arvif->vdev_id, ret);
   378				return ret;
   379			}
   380	
   381			pattern_id++;
   382			__set_bit(WOW_PATTERN_MATCH_EVENT, &wow_mask);
   383		}
   384	
   385		for (i = 0; i < WOW_EVENT_MAX; i++) {
   386			if (!test_bit(i, &wow_mask))
   387				continue;
   388			ret = ath10k_wmi_wow_add_wakeup_event(ar, arvif->vdev_id, i, 1);
   389			if (ret) {
   390				ath10k_warn(ar, "failed to enable wakeup event %s on vdev %i: %d\n",
   391					    wow_wakeup_event(i), arvif->vdev_id, ret);
   392				return ret;
   393			}
   394		}
   395	
   396		return 0;
   397	}
   398	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h
index 427ee57..7885462 100644
--- a/drivers/net/wireless/ath/ath10k/core.h
+++ b/drivers/net/wireless/ath/ath10k/core.h
@@ -904,6 +904,7 @@  struct ath10k {
 	u32 high_5ghz_chan;
 	bool ani_enabled;
 
+	bool nlo_enabled;
 	bool p2p;
 
 	struct {
diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index f31ae3b..423f67a 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -8348,6 +8348,18 @@  int ath10k_mac_register(struct ath10k *ar)
 	ar->hw->wiphy->max_scan_ssids = WLAN_SCAN_PARAMS_MAX_SSID;
 	ar->hw->wiphy->max_scan_ie_len = WLAN_SCAN_PARAMS_MAX_IE_LEN;
 
+	if (test_bit(WMI_SERVICE_NLO, ar->wmi.svc_map)) {
+		ar->hw->wiphy->max_sched_scan_reqs = 1;
+		ar->hw->wiphy->max_sched_scan_ssids = WMI_PNO_MAX_SUPP_NETWORKS;
+		ar->hw->wiphy->max_match_sets       = WMI_PNO_MAX_SUPP_NETWORKS;
+		ar->hw->wiphy->max_sched_scan_ie_len = WMI_PNO_MAX_IE_LENGTH;
+		ar->hw->wiphy->max_sched_scan_plans = WMI_PNO_MAX_SCHED_SCAN_PLANS;
+		ar->hw->wiphy->max_sched_scan_plan_interval =
+			WMI_PNO_MAX_SCHED_SCAN_PLAN_INT;
+		ar->hw->wiphy->max_sched_scan_plan_iterations =
+			WMI_PNO_MAX_SCHED_SCAN_PLAN_ITRNS;
+	}
+
 	ar->hw->vif_data_size = sizeof(struct ath10k_vif);
 	ar->hw->sta_data_size = sizeof(struct ath10k_sta);
 	ar->hw->txq_data_size = sizeof(struct ath10k_txq);
diff --git a/drivers/net/wireless/ath/ath10k/wmi-ops.h b/drivers/net/wireless/ath/ath10k/wmi-ops.h
index 5ecce04..68fff3a 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-ops.h
+++ b/drivers/net/wireless/ath/ath10k/wmi-ops.h
@@ -208,6 +208,9 @@  struct wmi_ops {
 					       u32 fw_feature_bitmap);
 	int (*get_vdev_subtype)(struct ath10k *ar,
 				enum wmi_vdev_subtype subtype);
+	struct sk_buff *(*gen_wow_config_pno)(struct ath10k *ar,
+					      u32 vdev_id,
+					      struct wmi_pno_scan_req *pno_scan);
 	struct sk_buff *(*gen_pdev_bss_chan_info_req)
 					(struct ath10k *ar,
 					 enum wmi_bss_survey_req_type type);
@@ -1349,6 +1352,24 @@  struct wmi_ops {
 }
 
 static inline int
+ath10k_wmi_wow_config_pno(struct ath10k *ar, u32 vdev_id,
+			  struct wmi_pno_scan_req  *pno_scan)
+{
+	struct sk_buff *skb;
+	u32 cmd_id;
+
+	if (!ar->wmi.ops->gen_wow_config_pno)
+		return -EOPNOTSUPP;
+
+	skb = ar->wmi.ops->gen_wow_config_pno(ar, vdev_id, pno_scan);
+	if (IS_ERR(skb))
+		return PTR_ERR(skb);
+
+	cmd_id = ar->wmi.cmd->network_list_offload_config_cmdid;
+	return ath10k_wmi_cmd_send(ar, skb, cmd_id);
+}
+
+static inline int
 ath10k_wmi_update_fw_tdls_state(struct ath10k *ar, u32 vdev_id,
 				enum wmi_tdls_state state)
 {
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index 8c49a26..c4060d7 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -3237,7 +3237,6 @@  static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
 	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_WOW_HOSTWAKEUP_FROM_SLEEP_CMD);
 	tlv->len = __cpu_to_le16(sizeof(*cmd));
 	cmd = (void *)tlv->value;
-
 	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv wow host wakeup ind\n");
 	return skb;
 }
@@ -3370,6 +3369,182 @@  static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
 	return skb;
 }
 
+/* Request FW to start PNO operation */
+static struct sk_buff *ath10k_wmi_tlv_op_gen_config_pno_start
+				(struct ath10k *ar,
+				u32 vdev_id,
+				struct wmi_pno_scan_req *pno)
+{
+	struct wmi_tlv_wow_nlo_config_cmd *cmd;
+	struct wmi_tlv *tlv;
+	struct sk_buff *skb;
+	struct nlo_configured_parameters *nlo_list;
+	u32 *channel_list;
+	void *ptr;
+	size_t len;
+	u32 i;
+
+	len = sizeof(*tlv) + sizeof(*cmd) +
+	      sizeof(*tlv) +
+	      /* TLV place holder for array of structures
+	       * nlo_configured_parameters(nlo_list)
+	       */
+	      sizeof(*tlv);
+	      /* TLV place holder for array of uint32 channel_list */
+
+	len += sizeof(u32) * min_t(u8, pno->a_networks[0].channel_count,
+				   WMI_NLO_MAX_CHAN);
+	len += sizeof(struct nlo_configured_parameters) *
+				min_t(u8, pno->uc_networks_count, WMI_NLO_MAX_SSIDS);
+
+	skb = ath10k_wmi_alloc_skb(ar, len);
+	if (!skb)
+		return ERR_PTR(-ENOMEM);
+
+	ptr = (void *)skb->data;
+	tlv = ptr;
+	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD);
+	tlv->len = __cpu_to_le16(sizeof(*cmd));
+	cmd = (void *)tlv->value;
+
+	/* wmi_tlv_wow_nlo_config_cmd parameters*/
+	cmd->vdev_id = pno->vdev_id;
+	cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
+
+	/* Current FW does not support min-max range for dwell time */
+	cmd->active_dwell_time = pno->active_max_time;
+	cmd->passive_dwell_time = pno->passive_max_time;
+
+	if (pno->do_passive_scan)
+		cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
+	/* Copy scan interval */
+	cmd->fast_scan_period = pno->fast_scan_period;
+	cmd->slow_scan_period = pno->slow_scan_period;
+	cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
+	cmd->delay_start_time = pno->delay_start_time;
+	if (pno->enable_pno_scan_randomization) {
+		cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
+				WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
+		ether_addr_copy(cmd->mac_addr.addr, pno->mac_addr);
+		ether_addr_copy(cmd->mac_mask.addr, pno->mac_addr_mask);
+	}
+	ptr += sizeof(*tlv);
+	ptr += sizeof(*cmd);
+
+	/* nlo_configured_parameters(nlo_list) */
+	cmd->no_of_ssids = min_t(u8, pno->uc_networks_count, WMI_NLO_MAX_SSIDS);
+	tlv = ptr;
+	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
+	tlv->len = __cpu_to_le16
+		(cmd->no_of_ssids * sizeof(struct nlo_configured_parameters));
+
+	ptr += sizeof(*tlv);
+	nlo_list = ptr;
+	for (i = 0; i < cmd->no_of_ssids; i++) {
+		tlv = (struct wmi_tlv *)(&nlo_list[i].tlv_header);
+		tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_BYTE);
+		tlv->len = __cpu_to_le16
+			(sizeof(struct nlo_configured_parameters) - sizeof(*tlv));
+		/* Copy ssid and it's length */
+		nlo_list[i].ssid.valid = true;
+		nlo_list[i].ssid.ssid.ssid_len = pno->a_networks[i].ssid.ssid_len;
+		memcpy(nlo_list[i].ssid.ssid.ssid,
+		       pno->a_networks[i].ssid.ssid,
+		       nlo_list[i].ssid.ssid.ssid_len);
+
+		/* Copy rssi threshold */
+		if (pno->a_networks[i].rssi_threshold &&
+		    pno->a_networks[i].rssi_threshold > -300) {
+			nlo_list[i].rssi_cond.valid = true;
+			nlo_list[i].rssi_cond.rssi = pno->a_networks[i].rssi_threshold;
+		}
+
+		nlo_list[i].bcast_nw_type.valid = true;
+		nlo_list[i].bcast_nw_type.bcast_nw_type =
+			pno->a_networks[i].bcast_nw_type;
+	}
+
+	ptr += cmd->no_of_ssids * sizeof(struct nlo_configured_parameters);
+
+	/* Copy channel info */
+	cmd->num_of_channels = min_t(u8, pno->a_networks[0].channel_count,
+				     WMI_NLO_MAX_CHAN);
+
+	tlv = ptr;
+	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
+	tlv->len = __cpu_to_le16(cmd->num_of_channels * sizeof(u_int32_t));
+	ptr += sizeof(*tlv);
+
+	channel_list = (u32 *)ptr;
+	for (i = 0; i < cmd->num_of_channels; i++)
+		channel_list[i] = pno->a_networks[0].channels[i];
+
+	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv start pno config vdev_id %d\n", vdev_id);
+	return skb;
+}
+
+/* Request FW to stop ongoing PNO operation */
+static struct sk_buff *ath10k_wmi_tlv_op_gen_config_pno_stop(struct ath10k *ar,
+							     u32 vdev_id)
+{
+	struct wmi_tlv_wow_nlo_config_cmd *cmd;
+	struct wmi_tlv *tlv;
+	struct sk_buff *skb;
+	void *ptr;
+	size_t len;
+
+	len = sizeof(*tlv) + sizeof(*cmd) +
+	      sizeof(*tlv) +
+	      /* TLV place holder for array of structures
+	       * nlo_configured_parameters(nlo_list)
+	       */
+	      sizeof(*tlv);
+	      /* TLV place holder for array of uint32 channel_list */
+	skb = ath10k_wmi_alloc_skb(ar, len);
+	if (!skb)
+		return ERR_PTR(-ENOMEM);
+
+	ptr = (void *)skb->data;
+	tlv = ptr;
+	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_STRUCT_NLO_CONFIG_CMD);
+	tlv->len = __cpu_to_le16(sizeof(*cmd));
+	cmd = (void *)tlv->value;
+
+	cmd->vdev_id = __cpu_to_le32(vdev_id);
+	cmd->flags = WMI_NLO_CONFIG_STOP;
+
+	ptr += sizeof(*tlv);
+	ptr += sizeof(*cmd);
+
+	/* nlo_configured_parameters(nlo_list) */
+	tlv = ptr;
+	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_STRUCT);
+	tlv->len = __cpu_to_le16(0);
+
+	ptr += sizeof(*tlv);
+
+	/* channel list */
+	tlv = ptr;
+	tlv->tag = __cpu_to_le16(WMI_TLV_TAG_ARRAY_UINT32);
+	tlv->len = __cpu_to_le16(0);
+
+	ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi tlv stop pno config vdev_id %d\n", vdev_id);
+	return skb;
+}
+
+static struct sk_buff *
+ath10k_wmi_tlv_op_gen_config_pno(struct ath10k *ar, u32 vdev_id,
+				 struct wmi_pno_scan_req *pno_scan)
+{
+	struct sk_buff *skb;
+
+	if (pno_scan->enable)
+		skb = ath10k_wmi_tlv_op_gen_config_pno_start(ar, vdev_id, pno_scan);
+	else
+		skb = ath10k_wmi_tlv_op_gen_config_pno_stop(ar, vdev_id);
+	return skb;
+}
+
 static struct sk_buff *
 ath10k_wmi_tlv_op_gen_adaptive_qcs(struct ath10k *ar, bool enable)
 {
@@ -3901,6 +4076,7 @@  static u32 ath10k_wmi_tlv_prepare_peer_qos(u8 uapsd_queues, u8 sp)
 	.gen_wow_host_wakeup_ind = ath10k_wmi_tlv_gen_wow_host_wakeup_ind,
 	.gen_wow_add_pattern = ath10k_wmi_tlv_op_gen_wow_add_pattern,
 	.gen_wow_del_pattern = ath10k_wmi_tlv_op_gen_wow_del_pattern,
+	.gen_wow_config_pno = ath10k_wmi_tlv_op_gen_config_pno,
 	.gen_update_fw_tdls_state = ath10k_wmi_tlv_op_gen_update_fw_tdls_state,
 	.gen_tdls_peer_update = ath10k_wmi_tlv_op_gen_tdls_peer_update,
 	.gen_adaptive_qcs = ath10k_wmi_tlv_op_gen_adaptive_qcs,
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.h b/drivers/net/wireless/ath/ath10k/wmi-tlv.h
index 3e1e340..ce706eb 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.h
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.h
@@ -2129,6 +2129,232 @@  struct wmi_tlv_tdls_peer_event {
 
 void ath10k_wmi_tlv_attach(struct ath10k *ar);
 
+enum wmi_nlo_auth_algorithm {
+	WMI_NLO_AUTH_ALGO_80211_OPEN        = 1,
+	WMI_NLO_AUTH_ALGO_80211_SHARED_KEY  = 2,
+	WMI_NLO_AUTH_ALGO_WPA               = 3,
+	WMI_NLO_AUTH_ALGO_WPA_PSK           = 4,
+	WMI_NLO_AUTH_ALGO_WPA_NONE          = 5,
+	WMI_NLO_AUTH_ALGO_RSNA              = 6,
+	WMI_NLO_AUTH_ALGO_RSNA_PSK          = 7,
+};
+
+enum wmi_nlo_cipher_algorithm {
+	WMI_NLO_CIPHER_ALGO_NONE           = 0x00,
+	WMI_NLO_CIPHER_ALGO_WEP40          = 0x01,
+	WMI_NLO_CIPHER_ALGO_TKIP           = 0x02,
+	WMI_NLO_CIPHER_ALGO_CCMP           = 0x04,
+	WMI_NLO_CIPHER_ALGO_WEP104         = 0x05,
+	WMI_NLO_CIPHER_ALGO_BIP            = 0x06,
+	WMI_NLO_CIPHER_ALGO_WPA_USE_GROUP  = 0x100,
+	WMI_NLO_CIPHER_ALGO_RSN_USE_GROUP  = 0x100,
+	WMI_NLO_CIPHER_ALGO_WEP            = 0x101,
+};
+
+/* SSID broadcast  type passed in NLO params */
+enum wmi_nlo_ssid_bcastnwtype {
+	WMI_NLO_BCAST_UNKNOWN      = 0,
+	WMI_NLO_BCAST_NORMAL       = 1,
+	WMI_NLO_BCAST_HIDDEN       = 2,
+};
+
+#define WMI_NLO_MAX_SSIDS    16
+#define WMI_NLO_MAX_CHAN     48
+
+#define WMI_NLO_CONFIG_STOP                             (0x1 << 0)
+#define WMI_NLO_CONFIG_START                            (0x1 << 1)
+#define WMI_NLO_CONFIG_RESET                            (0x1 << 2)
+#define WMI_NLO_CONFIG_SLOW_SCAN                        (0x1 << 4)
+#define WMI_NLO_CONFIG_FAST_SCAN                        (0x1 << 5)
+#define WMI_NLO_CONFIG_SSID_HIDE_EN                     (0x1 << 6)
+/* This bit is used to indicate if EPNO or supplicant PNO is enabled.
+ * Only one of them can be enabled at a given time
+ */
+#define WMI_NLO_CONFIG_ENLO                             (0x1 << 7)
+#define WMI_NLO_CONFIG_SCAN_PASSIVE                     (0x1 << 8)
+#define WMI_NLO_CONFIG_ENLO_RESET                       (0x1 << 9)
+#define WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ         (0x1 << 10)
+#define WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ       (0x1 << 11)
+#define WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ (0x1 << 12)
+#define WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG          (0x1 << 13)
+
+/* Whether directed scan needs to be performed (for hidden SSIDs) */
+#define WMI_ENLO_FLAG_DIRECTED_SCAN      1
+/* Whether PNO event shall be triggered if the network is found on A band */
+#define WMI_ENLO_FLAG_A_BAND             2
+/* Whether PNO event shall be triggered if the network is found on G band */
+#define WMI_ENLO_FLAG_G_BAND             4
+/* Whether strict matching is required (i.e. firmware shall not
+ * match on the entire SSID)
+ */
+#define WMI_ENLO_FLAG_STRICT_MATCH       8
+
+/* Code for matching the beacon AUTH IE - additional codes TBD */
+/* open */
+#define WMI_ENLO_AUTH_CODE_OPEN  1
+/* WPA_PSK or WPA2PSK */
+#define WMI_ENLO_AUTH_CODE_PSK   2
+/* any EAPOL */
+#define WMI_ENLO_AUTH_CODE_EAPOL 4
+
+/* NOTE: wmi_nlo_ssid_param structure can't be changed
+ * without breaking the compatibility
+ */
+struct wmi_nlo_ssid_param {
+	__le32 valid;
+	struct wmi_ssid ssid;
+} __packed;
+
+/* NOTE: wmi_nlo_enc_param structure can't be changed without
+ * breaking the compatibility
+ */
+struct wmi_nlo_enc_param {
+	__le32 valid;
+	__le32 enc_type;
+} __packed;
+
+/* NOTE: wmi_nlo_auth_param structure can't be changed without
+ * breaking the compatibility
+ */
+struct wmi_nlo_auth_param {
+	__le32 valid;
+	__le32 auth_type;
+} __packed;
+
+/* NOTE: wmi_nlo_bcast_nw_param structure can't be changed without
+ * breaking the compatibility
+ */
+struct wmi_nlo_bcast_nw_param {
+	__le32 valid;
+	/* If WMI_NLO_CONFIG_EPNO is not set. Supplicant PNO is enabled.
+	 * The value should be true/false. Otherwise EPNO is enabled.
+	 * bcast_nw_type would be used as a bit flag contains WMI_ENLO_FLAG_XXX
+	 */
+	__le32 bcast_nw_type;
+} __packed;
+
+/* NOTE: wmi_nlo_rssi_param structure can't be changed without
+ * breaking the compatibility
+ */
+struct wmi_nlo_rssi_param {
+	__le32 valid;
+	__le32 rssi;
+} __packed;
+
+struct nlo_configured_parameters {
+	/* TLV tag and len;*/
+	__le32 tlv_header;
+	struct wmi_nlo_ssid_param ssid;
+	struct wmi_nlo_enc_param enc_type;
+	struct wmi_nlo_auth_param auth_type;
+	struct wmi_nlo_rssi_param rssi_cond;
+	/* indicates if the SSID is hidden or not */
+	struct wmi_nlo_bcast_nw_param bcast_nw_type;
+} __packed;
+
+/* Support channel prediction for PNO scan after scanning top_k_num channels
+ * if stationary_threshold is met.
+ */
+struct nlo_channel_prediction_cfg {
+	__le32 tlv_header;
+	/* Enable or disable this feature. */
+	__le32 enable;
+	/* Top K channels will be scanned before deciding whether to further scan
+	 * or stop. Minimum value is 3 and maximum is 5.
+	 */
+	__le32 top_k_num;
+	/* Preconfigured stationary threshold.
+	 * Lesser value means more conservative. Bigger value means more aggressive.
+	 * Maximum is 100 and mininum is 0.
+	 */
+	__le32 stationary_threshold;
+	/* Periodic full channel scan in milliseconds unit.
+	 * After full_scan_period_ms since last full scan, channel prediction
+	 * scan is suppressed and will do full scan.
+	 * This is to help detecting sudden AP power-on or -off. Value 0 means no
+	 * full scan at all (not recommended).
+	 */
+	__le32 full_scan_period_ms;
+} __packed;
+
+struct enlo_candidate_score_params_t {
+	__le32 tlv_header;   /* TLV tag and len; */
+	/* minimum 5GHz RSSI for a BSSID to be considered (units = dBm) */
+	__le32 min5GHz_rssi;
+	/* minimum 2.4GHz RSSI for a BSSID to be considered (units = dBm) */
+	__le32 min24GHz_rssi;
+	/* the maximum score that a network can have before bonuses */
+	__le32 initial_score_max;
+	/* current_connection_bonus:
+	 * only report when there is a network's score this much higher
+	 * than the current connection
+	 */
+	__le32 current_connection_bonus;
+	/* score bonus for all networks with the same network flag */
+	__le32 same_network_bonus;
+	__le32 secure_bonus; /* score bonus for networks that are not open */
+	__le32 band5GHz_bonus; /* 5GHz RSSI score bonus (applied to all 5GHz networks) */
+} __packed;
+
+struct connected_nlo_bss_band_rssi_pref_t {
+	__le32 tlv_header; /* TLV tag and len;*/
+	/* band which needs to get preference over other band
+	 * - see wmi_set_vdev_ie_band enum
+	 */
+	__le32 band;
+	/* Amount of RSSI preference (in dB) that can be given to a band */
+	__le32  rssi_pref;
+} __packed;
+
+struct connected_nlo_rssi_params_t {
+	__le32 tlv_header; /* TLV tag and len;*/
+	/* Relative rssi threshold (in dB) by which new BSS should have better rssi than
+	 * the current connected BSS.
+	 */
+	__le32  relative_rssi;
+	/* The amount of rssi preference (in dB) that can be given
+	 * to a 5G BSS over 2.4G BSS.
+	 */
+	__le32  relative_rssi_5g_pref;
+} __packed;
+
+struct wmi_tlv_wow_nlo_config_cmd {
+	__le32 flags;
+	__le32 vdev_id;
+	__le32 fast_scan_max_cycles;
+	__le32 active_dwell_time;
+	__le32 passive_dwell_time; /* PDT in msecs */
+	__le32 probe_bundle_size;
+	__le32 rest_time;  /* ART = IRT */
+	__le32 max_rest_time; /* Max value that can be reached after SBM */
+	__le32 scan_backoff_multiplier;  /* SBM */
+	__le32 fast_scan_period; /* SCBM */
+	__le32 slow_scan_period; /* specific to windows */
+	__le32 no_of_ssids;
+	__le32 num_of_channels;
+	__le32 delay_start_time; /* NLO scan start delay time in milliseconds */
+	/** MAC Address to use in Probe Req as SA **/
+	struct wmi_mac_addr mac_addr;
+	/** Mask on which MAC has to be randomized **/
+	struct wmi_mac_addr mac_mask;
+	/** IE bitmap to use in Probe Req **/
+	__le32 ie_bitmap[8];
+	/** Number of vendor OUIs. In the TLV vendor_oui[] **/
+	__le32 num_vendor_oui;
+	/** Number of connected NLO band preferences **/
+	__le32 num_cnlo_band_pref;
+
+	/* The TLVs will follow.
+	 * nlo_configured_parameters nlo_list[];
+	 * A_UINT32 channel_list[num_of_channels];
+	 * nlo_channel_prediction_cfg ch_prediction_cfg;
+	 * enlo_candidate_score_params candidate_score_params;
+	 * wmi_vendor_oui vendor_oui[num_vendor_oui];
+	 * connected_nlo_rssi_params cnlo_rssi_params;
+	 * connected_nlo_bss_band_rssi_pref cnlo_bss_band_rssi_pref[num_cnlo_band_pref];
+	 */
+} __packed;
+
 struct wmi_tlv_mgmt_tx_cmd {
 	__le32 vdev_id;
 	__le32 desc_id;
diff --git a/drivers/net/wireless/ath/ath10k/wmi.h b/drivers/net/wireless/ath/ath10k/wmi.h
index b48db54..6ad8992 100644
--- a/drivers/net/wireless/ath/ath10k/wmi.h
+++ b/drivers/net/wireless/ath/ath10k/wmi.h
@@ -7012,6 +7012,63 @@  struct wmi_pdev_set_adaptive_cca_params {
 	__le32 cca_detect_margin;
 } __packed;
 
+#define WMI_PNO_MAX_SCHED_SCAN_PLANS      2
+#define WMI_PNO_MAX_SCHED_SCAN_PLAN_INT   7200
+#define WMI_PNO_MAX_SCHED_SCAN_PLAN_ITRNS 100
+#define WMI_PNO_MAX_NETW_CHANNELS         26
+#define WMI_PNO_MAX_NETW_CHANNELS_EX      60
+#define WMI_PNO_MAX_SUPP_NETWORKS         WLAN_SCAN_PARAMS_MAX_SSID
+#define WMI_PNO_MAX_IE_LENGTH             WLAN_SCAN_PARAMS_MAX_IE_LEN
+
+/*size based of dot11 declaration without extra IEs as we will not carry those for PNO*/
+#define WMI_PNO_MAX_PB_REQ_SIZE    450
+
+#define WMI_PNO_24G_DEFAULT_CH     1
+#define WMI_PNO_5G_DEFAULT_CH      36
+
+#define WMI_ACTIVE_MAX_CHANNEL_TIME 40
+#define WMI_PASSIVE_MAX_CHANNEL_TIME   110
+
+/* SSID broadcast type */
+enum wmi_SSID_bcast_type {
+	BCAST_UNKNOWN      = 0,
+	BCAST_NORMAL       = 1,
+	BCAST_HIDDEN       = 2,
+};
+
+struct wmi_network_type {
+	struct wmi_ssid ssid;
+	u32 authentication;
+	u32 encryption;
+	u32 bcast_nw_type;
+	u8 channel_count;
+	u16 channels[WMI_PNO_MAX_NETW_CHANNELS_EX];
+	s32 rssi_threshold;
+} __packed;
+
+struct wmi_pno_scan_req {
+	u8 enable;
+	u8 vdev_id;
+	u8 uc_networks_count;
+	struct wmi_network_type a_networks[WMI_PNO_MAX_SUPP_NETWORKS];
+	u32 fast_scan_period;
+	u32 slow_scan_period;
+	u8 fast_scan_max_cycles;
+
+	bool do_passive_scan;
+
+	u32 delay_start_time;
+	u32 active_min_time;
+	u32 active_max_time;
+	u32 passive_min_time;
+	u32 passive_max_time;
+
+	/* mac address randomization attributes */
+	u32 enable_pno_scan_randomization;
+	u8 mac_addr[ETH_ALEN];
+	u8 mac_addr_mask[ETH_ALEN];
+} __packed;
+
 enum wmi_host_platform_type {
 	WMI_HOST_PLATFORM_HIGH_PERF,
 	WMI_HOST_PLATFORM_LOW_PERF,
diff --git a/drivers/net/wireless/ath/ath10k/wow.c b/drivers/net/wireless/ath/ath10k/wow.c
index a6b179f..666c8bc 100644
--- a/drivers/net/wireless/ath/ath10k/wow.c
+++ b/drivers/net/wireless/ath/ath10k/wow.c
@@ -180,6 +180,106 @@  static int ath10k_wow_cleanup(struct ath10k *ar)
 	}
 }
 
+static int ath10k_wmi_pno_check
+	(struct ath10k *ar, u32 vdev_id,
+	struct cfg80211_sched_scan_request *nd_config,
+	struct wmi_pno_scan_req *pno)
+{
+	int ret = 0;
+	int i, j;
+
+	pno->enable = 1;
+	pno->vdev_id = vdev_id;
+	pno->uc_networks_count = nd_config->n_match_sets;
+	if (!pno->uc_networks_count ||
+	    pno->uc_networks_count > WMI_PNO_MAX_SUPP_NETWORKS) {
+		ret = -EINVAL;
+		return ret;
+	}
+
+	if (nd_config->n_channels > WMI_PNO_MAX_NETW_CHANNELS_EX) {
+		ret = -EINVAL;
+		return ret;
+	}
+
+	/* Filling per profile  params */
+	for (i = 0; i < pno->uc_networks_count; i++) {
+		pno->a_networks[i].ssid.ssid_len =
+			nd_config->match_sets[i].ssid.ssid_len;
+
+		if (pno->a_networks[i].ssid.ssid_len == 0 ||
+		    pno->a_networks[i].ssid.ssid_len > 32) {
+			ret = -EINVAL;
+			return ret;
+		}
+
+		memcpy(pno->a_networks[i].ssid.ssid,
+		       nd_config->match_sets[i].ssid.ssid,
+		       nd_config->match_sets[i].ssid.ssid_len);
+		pno->a_networks[i].authentication = 0;
+		pno->a_networks[i].encryption     = 0;
+		pno->a_networks[i].bcast_nw_type  = 0;
+
+		/*Copying list of valid channel into request */
+		pno->a_networks[i].channel_count = nd_config->n_channels;
+		pno->a_networks[i].rssi_threshold = nd_config->match_sets[i].rssi_thold;
+
+		for (j = 0; j < nd_config->n_channels; j++) {
+			pno->a_networks[i].channels[j] =
+					nd_config->channels[j]->center_freq;
+		}
+	}
+
+	/* set scan to passive if no SSIDs are specified in the request */
+	if (nd_config->n_ssids == 0)
+		pno->do_passive_scan = true;
+	else
+		pno->do_passive_scan = false;
+
+	for (i = 0; i < nd_config->n_ssids; i++) {
+		j = 0;
+		while (j < pno->uc_networks_count) {
+			if (pno->a_networks[j].ssid.ssid_len ==
+				nd_config->ssids[i].ssid_len &&
+			(memcmp(pno->a_networks[j].ssid.ssid,
+				nd_config->ssids[i].ssid,
+				pno->a_networks[j].ssid.ssid_len) == 0)) {
+				pno->a_networks[j].bcast_nw_type = BCAST_HIDDEN;
+				break;
+			}
+			j++;
+		}
+	}
+
+	if (nd_config->n_scan_plans == 2) {
+		pno->fast_scan_period = nd_config->scan_plans[0].interval * MSEC_PER_SEC;
+		pno->fast_scan_max_cycles = nd_config->scan_plans[0].iterations;
+		pno->slow_scan_period =
+			nd_config->scan_plans[1].interval * MSEC_PER_SEC;
+	} else if (nd_config->n_scan_plans == 1) {
+		pno->fast_scan_period = nd_config->scan_plans[0].interval * MSEC_PER_SEC;
+		pno->fast_scan_max_cycles = 1;
+		pno->slow_scan_period = nd_config->scan_plans[0].interval * MSEC_PER_SEC;
+	} else {
+		ath10k_warn(ar, "Invalid number of scan plans %d !!",
+			    nd_config->n_scan_plans);
+	}
+
+	if (nd_config->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
+		/* enable mac randomization */
+		pno->enable_pno_scan_randomization = 1;
+		memcpy(pno->mac_addr, nd_config->mac_addr, ETH_ALEN);
+		memcpy(pno->mac_addr_mask, nd_config->mac_addr_mask, ETH_ALEN);
+	}
+
+	pno->delay_start_time = nd_config->delay;
+
+	/* Current FW does not support min-max range for dwell time */
+	pno->active_max_time = WMI_ACTIVE_MAX_CHANNEL_TIME;
+	pno->passive_max_time = WMI_PASSIVE_MAX_CHANNEL_TIME;
+	return ret;
+}
+
 static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif,
 				      struct cfg80211_wowlan *wowlan)
 {
@@ -213,6 +313,23 @@  static int ath10k_vif_wow_set_wakeups(struct ath10k_vif *arvif,
 
 		if (wowlan->magic_pkt)
 			__set_bit(WOW_MAGIC_PKT_RECVD_EVENT, &wow_mask);
+
+		if (wowlan->nd_config) {
+			struct wmi_pno_scan_req *pno;
+			int ret;
+
+			pno = kzalloc(sizeof(*pno), GFP_KERNEL);
+			ar->nlo_enabled = true;
+
+			ret = ath10k_wmi_pno_check(ar, arvif->vdev_id,
+						   wowlan->nd_config, pno);
+			if (!ret) {
+				ath10k_wmi_wow_config_pno(ar, arvif->vdev_id, pno);
+				__set_bit(WOW_NLO_DETECTED_EVENT, &wow_mask);
+			}
+
+			kfree(pno);
+		}
 		break;
 	default:
 		break;
@@ -299,6 +416,48 @@  static int ath10k_wow_set_wakeups(struct ath10k *ar,
 	return 0;
 }
 
+static int ath10k_vif_wow_clean_nlo(struct ath10k_vif *arvif)
+{
+	int ret;
+	struct ath10k *ar = arvif->ar;
+
+	switch (arvif->vdev_type) {
+	case WMI_VDEV_TYPE_STA:
+		if (ar->nlo_enabled) {
+			struct wmi_pno_scan_req *pno;
+
+			pno = kzalloc(sizeof(*pno), GFP_KERNEL);
+			pno->enable = 0;
+			ar->nlo_enabled = false;
+			ret = ath10k_wmi_wow_config_pno(ar, arvif->vdev_id, pno);
+			kfree(pno);
+		}
+		break;
+	default:
+		break;
+	}
+	return ret;
+}
+
+static int ath10k_wow_nlo_cleanup(struct ath10k *ar)
+{
+	struct ath10k_vif *arvif;
+	int ret;
+
+	lockdep_assert_held(&ar->conf_mutex);
+
+	list_for_each_entry(arvif, &ar->arvifs, list) {
+		ret = ath10k_vif_wow_clean_nlo(arvif);
+		if (ret) {
+			ath10k_warn(ar, "failed to clean nlo settings on vdev %i: %d\n",
+				    arvif->vdev_id, ret);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
 static int ath10k_wow_enable(struct ath10k *ar)
 {
 	int ret;
@@ -434,6 +593,10 @@  int ath10k_wow_op_resume(struct ieee80211_hw *hw)
 	if (ret)
 		ath10k_warn(ar, "failed to wakeup from wow: %d\n", ret);
 
+	ret = ath10k_wow_nlo_cleanup(ar);
+	if (ret)
+		ath10k_warn(ar, "failed to cleanup nlo: %d\n", ret);
+
 exit:
 	if (ret) {
 		switch (ar->state) {
@@ -473,6 +636,11 @@  int ath10k_wow_init(struct ath10k *ar)
 		ar->wow.wowlan_support.max_pkt_offset -= WOW_MAX_REDUCE;
 	}
 
+	if (test_bit(WMI_SERVICE_NLO, ar->wmi.svc_map)) {
+		ar->wow.wowlan_support.flags |= WIPHY_WOWLAN_NET_DETECT;
+		ar->wow.wowlan_support.max_nd_match_sets = WMI_PNO_MAX_SUPP_NETWORKS;
+	}
+
 	ar->wow.wowlan_support.n_patterns = ar->wow.max_num_patterns;
 	ar->hw->wiphy->wowlan = &ar->wow.wowlan_support;