diff mbox series

[v2,06/12] wcn36xx: Add ipv6 namespace offload in suspend

Message ID 20210315120937.2512341-7-bryan.odonoghue@linaro.org
State Superseded
Headers show
Series wcn36xx: Enable downstream consistent Wake on Lan | expand

Commit Message

Bryan O'Donoghue March 15, 2021, 12:09 p.m. UTC
We need to respond to ipv6 namespace lookups when in suspend. This patch
adds the necessary changes to issue the appropriate firmware command on
suspend and resume to enter/exit firmware offloaded ns lookup.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

---
 drivers/net/wireless/ath/wcn36xx/hal.h  |  3 ++
 drivers/net/wireless/ath/wcn36xx/main.c |  4 ++
 drivers/net/wireless/ath/wcn36xx/smd.c  | 55 +++++++++++++++++++++++++
 drivers/net/wireless/ath/wcn36xx/smd.h  |  3 ++
 4 files changed, 65 insertions(+)

-- 
2.30.1

Comments

kernel test robot March 15, 2021, 2:18 p.m. UTC | #1
Hi Bryan,

I love your patch! Yet something to improve:

[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on wireless-drivers/master ath6kl/ath-next v5.12-rc3 next-20210315]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Bryan-O-Donoghue/wcn36xx-Enable-downstream-consistent-Wake-on-Lan/20210315-201014
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: h8300-randconfig-r032-20210315 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/84a113e3918b369b7f17d291899f9eefbbc60ca9
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bryan-O-Donoghue/wcn36xx-Enable-downstream-consistent-Wake-on-Lan/20210315-201014
        git checkout 84a113e3918b369b7f17d291899f9eefbbc60ca9
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=h8300 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/net/wireless/ath/wcn36xx/smd.c: In function 'wcn36xx_smd_ipv6_ns_offload':
>> drivers/net/wireless/ath/wcn36xx/smd.c:2815:15: error: 'struct wcn36xx_vif' has no member named 'num_target_ipv6_addrs'

    2815 |   if (vif_priv->num_target_ipv6_addrs) {
         |               ^~
>> drivers/net/wireless/ath/wcn36xx/smd.c:2817:20: error: 'struct wcn36xx_vif' has no member named 'target_ipv6_addrs'

    2817 |           &vif_priv->target_ipv6_addrs[0].in6_u,
         |                    ^~
   drivers/net/wireless/ath/wcn36xx/smd.c:2820:20: error: 'struct wcn36xx_vif' has no member named 'target_ipv6_addrs'
    2820 |           &vif_priv->target_ipv6_addrs[0].in6_u,
         |                    ^~
   drivers/net/wireless/ath/wcn36xx/smd.c:2824:15: error: 'struct wcn36xx_vif' has no member named 'num_target_ipv6_addrs'
    2824 |   if (vif_priv->num_target_ipv6_addrs > 1) {
         |               ^~
   drivers/net/wireless/ath/wcn36xx/smd.c:2826:20: error: 'struct wcn36xx_vif' has no member named 'target_ipv6_addrs'
    2826 |           &vif_priv->target_ipv6_addrs[1].in6_u,
         |                    ^~


vim +2815 drivers/net/wireless/ath/wcn36xx/smd.c

  2795	
  2796	int wcn36xx_smd_ipv6_ns_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif,
  2797					bool enable)
  2798	{
  2799		struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
  2800		struct wcn36xx_hal_host_offload_req_msg msg_body;
  2801		struct wcn36xx_hal_ns_offload_params *ns_params;
  2802		struct wcn36xx_hal_host_offload_req *ho_params;
  2803		int ret;
  2804	
  2805		mutex_lock(&wcn->hal_mutex);
  2806	
  2807		INIT_HAL_MSG(msg_body, WCN36XX_HAL_HOST_OFFLOAD_REQ);
  2808		ho_params = &msg_body.host_offload_params;
  2809		ns_params = &msg_body.ns_offload_params;
  2810	
  2811		ho_params->offload_type = WCN36XX_HAL_IPV6_NS_OFFLOAD;
  2812		if (enable) {
  2813			ho_params->enable =
  2814				WCN36XX_HAL_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE;
> 2815			if (vif_priv->num_target_ipv6_addrs) {

  2816				memcpy(&ho_params->u,
> 2817				       &vif_priv->target_ipv6_addrs[0].in6_u,

  2818				       sizeof(struct in6_addr));
  2819				memcpy(&ns_params->target_ipv6_addr1,
  2820				       &vif_priv->target_ipv6_addrs[0].in6_u,
  2821				       sizeof(struct in6_addr));
  2822				ns_params->target_ipv6_addr1_valid = 1;
  2823			}
  2824			if (vif_priv->num_target_ipv6_addrs > 1) {
  2825				memcpy(&ns_params->target_ipv6_addr2,
  2826				       &vif_priv->target_ipv6_addrs[1].in6_u,
  2827				       sizeof(struct in6_addr));
  2828				ns_params->target_ipv6_addr2_valid = 1;
  2829			}
  2830		}
  2831		memcpy(&ns_params->self_addr, vif->addr, ETH_ALEN);
  2832		ns_params->bss_index = vif_priv->bss_index;
  2833	
  2834		PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
  2835	
  2836		ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
  2837		if (ret) {
  2838			wcn36xx_err("Sending host_offload_arp failed\n");
  2839			goto out;
  2840		}
  2841		ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
  2842		if (ret) {
  2843			wcn36xx_err("host_offload_arp failed err=%d\n", ret);
  2844			goto out;
  2845		}
  2846	out:
  2847		mutex_unlock(&wcn->hal_mutex);
  2848		return ret;
  2849	}
  2850	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
Bryan O'Donoghue March 15, 2021, 3:16 p.m. UTC | #2
On 15/03/2021 14:18, kernel test robot wrote:
> Reported-by: kernel test robot<lkp@intel.com>


I should ifdef this function for CONFIG_IPV6.

I'll include that in V3 once I've left this set here long enough comments

_______________________________________________
wcn36xx mailing list
wcn36xx@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/wcn36xx
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/wcn36xx/hal.h b/drivers/net/wireless/ath/wcn36xx/hal.h
index 90333daed845..3b949b0b3792 100644
--- a/drivers/net/wireless/ath/wcn36xx/hal.h
+++ b/drivers/net/wireless/ath/wcn36xx/hal.h
@@ -3464,6 +3464,9 @@  struct wcn36xx_hal_rem_bcn_filter_req {
 #define WCN36XX_HAL_OFFLOAD_DISABLE                         0
 #define WCN36XX_HAL_OFFLOAD_ENABLE                          1
 #define WCN36XX_HAL_OFFLOAD_BCAST_FILTER_ENABLE             0x2
+#define WCN36XX_HAL_OFFLOAD_MCAST_FILTER_ENABLE             0x4
+#define WCN36XX_HAL_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE	\
+	(WCN36XX_HAL_OFFLOAD_ENABLE | WCN36XX_HAL_OFFLOAD_MCAST_FILTER_ENABLE)
 #define WCN36XX_HAL_OFFLOAD_ARP_AND_BCAST_FILTER_ENABLE	\
 	(WCN36XX_HAL_OFFLOAD_ENABLE | WCN36XX_HAL_OFFLOAD_BCAST_FILTER_ENABLE)
 #define WCN36XX_HAL_IPV6_OFFLOAD_ADDR_MAX		0x02
diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
index 93eff6563187..36cf771d8a20 100644
--- a/drivers/net/wireless/ath/wcn36xx/main.c
+++ b/drivers/net/wireless/ath/wcn36xx/main.c
@@ -1118,6 +1118,9 @@  static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow)
 		if (!vif_priv->sta_assoc)
 			goto out;
 		ret = wcn36xx_smd_arp_offload(wcn, vif, true);
+		if (ret)
+			goto out;
+		ret = wcn36xx_smd_ipv6_ns_offload(wcn, vif, true);
 		if (ret)
 			goto out;
 		ret = wcn36xx_smd_set_power_params(wcn, true);
@@ -1143,6 +1146,7 @@  static int wcn36xx_resume(struct ieee80211_hw *hw)
 			goto out;
 
 		wcn36xx_smd_set_power_params(wcn, false);
+		wcn36xx_smd_ipv6_ns_offload(wcn, vif, false);
 		wcn36xx_smd_arp_offload(wcn, vif, false);
 	}
 out:
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 478e363610e1..c3095d800c32 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2793,6 +2793,61 @@  int wcn36xx_smd_arp_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif,
 	return ret;
 }
 
+int wcn36xx_smd_ipv6_ns_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif,
+				bool enable)
+{
+	struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif);
+	struct wcn36xx_hal_host_offload_req_msg msg_body;
+	struct wcn36xx_hal_ns_offload_params *ns_params;
+	struct wcn36xx_hal_host_offload_req *ho_params;
+	int ret;
+
+	mutex_lock(&wcn->hal_mutex);
+
+	INIT_HAL_MSG(msg_body, WCN36XX_HAL_HOST_OFFLOAD_REQ);
+	ho_params = &msg_body.host_offload_params;
+	ns_params = &msg_body.ns_offload_params;
+
+	ho_params->offload_type = WCN36XX_HAL_IPV6_NS_OFFLOAD;
+	if (enable) {
+		ho_params->enable =
+			WCN36XX_HAL_OFFLOAD_NS_AND_MCAST_FILTER_ENABLE;
+		if (vif_priv->num_target_ipv6_addrs) {
+			memcpy(&ho_params->u,
+			       &vif_priv->target_ipv6_addrs[0].in6_u,
+			       sizeof(struct in6_addr));
+			memcpy(&ns_params->target_ipv6_addr1,
+			       &vif_priv->target_ipv6_addrs[0].in6_u,
+			       sizeof(struct in6_addr));
+			ns_params->target_ipv6_addr1_valid = 1;
+		}
+		if (vif_priv->num_target_ipv6_addrs > 1) {
+			memcpy(&ns_params->target_ipv6_addr2,
+			       &vif_priv->target_ipv6_addrs[1].in6_u,
+			       sizeof(struct in6_addr));
+			ns_params->target_ipv6_addr2_valid = 1;
+		}
+	}
+	memcpy(&ns_params->self_addr, vif->addr, ETH_ALEN);
+	ns_params->bss_index = vif_priv->bss_index;
+
+	PREPARE_HAL_BUF(wcn->hal_buf, msg_body);
+
+	ret = wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
+	if (ret) {
+		wcn36xx_err("Sending host_offload_arp failed\n");
+		goto out;
+	}
+	ret = wcn36xx_smd_rsp_status_check(wcn->hal_buf, wcn->hal_rsp_len);
+	if (ret) {
+		wcn36xx_err("host_offload_arp failed err=%d\n", ret);
+		goto out;
+	}
+out:
+	mutex_unlock(&wcn->hal_mutex);
+	return ret;
+}
+
 int wcn36xx_smd_rsp_process(struct rpmsg_device *rpdev,
 			    void *buf, int len, void *priv, u32 addr)
 {
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.h b/drivers/net/wireless/ath/wcn36xx/smd.h
index 6492a628ea6a..e03ab7878432 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.h
+++ b/drivers/net/wireless/ath/wcn36xx/smd.h
@@ -150,4 +150,7 @@  int wcn36xx_smd_set_mc_list(struct wcn36xx *wcn,
 int wcn36xx_smd_arp_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif,
 			    bool enable);
 
+int wcn36xx_smd_ipv6_ns_offload(struct wcn36xx *wcn, struct ieee80211_vif *vif,
+				bool enable);
+
 #endif	/* _SMD_H_ */