diff mbox series

[v2,4/4] brcmfmac: add a variable for packet forwarding condition

Message ID 20201020022812.37064-5-wright.feng@cypress.com
State New
Headers show
Series brcmfmac: Add few features in AP mode | expand

Commit Message

Wright Feng Oct. 20, 2020, 2:28 a.m. UTC
From: Ting-Ying Li <tingying.li@cypress.com>

When the "ap_isolate" function is not set by the host,
host-based packet forwarding will be enabled if the packet
forwarding mechanism is not offloaded to the lower layer.

Signed-off-by: Ting-Ying Li <tingying.li@cypress.com>
Signed-off-by: Chi-hsien Lin <chi-hsien.lin@cypress.com>
Signed-off-by: Wright Feng <wright.feng@cypress.com>
---
v4: Change conditional statements
---
 .../broadcom/brcm80211/brcmfmac/cfg80211.c      | 17 +++++++++++++++--
 .../wireless/broadcom/brcm80211/brcmfmac/core.h |  1 +
 .../broadcom/brcm80211/brcmfmac/msgbuf.c        |  2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 5e49ac3d82b9..063cbb09d751 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -5484,8 +5484,8 @@  brcmf_cfg80211_change_bss(struct wiphy *wiphy, struct net_device *dev,
 			  struct bss_parameters *params)
 {
 	struct brcmf_if *ifp;
-	int ret = 0;
-	u32 ap_isolate;
+	int ret = 0, result = 0;
+	u32 ap_isolate, val;
 
 	brcmf_dbg(TRACE, "Enter\n");
 	ifp = netdev_priv(dev);
@@ -5496,6 +5496,19 @@  brcmf_cfg80211_change_bss(struct wiphy *wiphy, struct net_device *dev,
 			brcmf_err("ap_isolate iovar failed: ret=%d\n", ret);
 	}
 
+	/* Get ap_isolate value from firmware to detemine whether fmac */
+	/* driver enables packet forwarding. */
+	result = brcmf_fil_iovar_int_get(ifp, "ap_isolate", &val);
+	if (result == 0 &&
+	    params->ap_isolate == 0 &&
+	    val == 1) {
+		ifp->fmac_pkt_fwd_en = true;
+	} else {
+		if (result < 0)
+			brcmf_err("get ap_isolate iovar failed: result=%d\n", result);
+		ifp->fmac_pkt_fwd_en = false;
+	}
+
 	return ret;
 }
 
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
index 9ebafe0b2117..30b29053d133 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
@@ -195,6 +195,7 @@  struct brcmf_if {
 	bool fwil_fwerr;
 	struct list_head sta_list;              /* sll of associated stations */
 	spinlock_t sta_list_lock;
+	bool fmac_pkt_fwd_en;
 };
 
 struct ether_addr {
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
index b98cf5e2d0a8..2d7e77097209 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
@@ -1192,7 +1192,7 @@  brcmf_msgbuf_process_rx_complete(struct brcmf_msgbuf *msgbuf, void *buf)
 	}
 
 	eh = (struct ethhdr *)(skb->data);
-	if (brcmf_is_apmode(ifp->vif)) {
+	if (brcmf_is_apmode(ifp->vif) && ifp->fmac_pkt_fwd_en) {
 		skb_set_network_header(skb, sizeof(struct ethhdr));
 		skb->protocol = eh->h_proto;
 		skb->priority = cfg80211_classify8021d(skb, NULL);