Skip to contentSkip to conversation

brcmfmac: Don't increase 8021x_cnt for dropped packets

PATCH Superseded [email protected] 1 participant 2 messages Mar 30, 2016 – Mar 31, 2016 Broadcom BRCM80211 IEEE802.11 wireless drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 brcmfmac: Don't increase 8021x_cnt for dropped packets

From: Per Forlin <[email protected]>

The pend_8021x_cnt gets into a state where it's not being decreased. When the brcmf_netdev_wait_pend8021x is called it will timeout because there are no pending packets to be consumed. There is no easy way of getting out of this state once it has happened. Preventing the counter from being increased in case of dropped packets seem like a reasonable solution.

Log showing overflow txq and increased cnt:

// Extra debug prints
brcmfmac: [brcmf_netdev_wait_pend8021x] pend_8021x_cnt == 0
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 1
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 2

brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!

// Extra debug prints
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 3
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 4
brcmfmac: [brcmf_netdev_wait_pend8021x] pend_8021x_cnt == 4

WARNING: at .../brcmfmac/core.c:1289 brcmf_netdev_wait_pend8021x
  (warn_slowpath_common)
  (warn_slowpath_null)
  (brcmf_netdev_wait_pend8021x [brcmfmac])
  (send_key_to_dongle [brcmfmac])
  (brcmf_cfg80211_del_key [brcmfmac])
  (nl80211_del_key [cfg80211])
  (genl_rcv_msg)
  (netlink_rcv_skb)
  (genl_rcv)
  (netlink_unicast)
  (netlink_sendmsg)
  (sock_sendmsg)
  (___sys_sendmsg)
  (__sys_sendmsg)
  (SyS_sendmsg)

---
I came across this bug in an older kernel but it seems relevant for the latest kernel as well. I'm not familiar with the code but I can reproduce the issue and verify a fix for it. This patch seems to work for my use case but I need to run some more tests to know for sure.

drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 2 ++

 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +2 -0
index ed9998b..8b1e30c 100644
@@ -241,7 +241,8 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
 done:
 	if (ret) {
 		ifp->stats.tx_dropped++;
+		if (eh->h_proto == htons(ETH_P_PAE))
+			atomic_dec(&ifp->pend_8021x_cnt);
 	} else {
 		ifp->stats.tx_packets++;
 		ifp->stats.tx_bytes += skb->len;
Signature · 1 line
2.1.4
#1 lore raw

2016-03-30 23:04 GMT+02:00 <[email protected]>:

Quoted 67 lines

From: Per Forlin <[email protected]>

The pend_8021x_cnt gets into a state where it's not being decreased. When the brcmf_netdev_wait_pend8021x is called it will timeout because there are no pending packets to be consumed. There is no easy way of getting out of this state once it has happened. Preventing the counter from being increased in case of dropped packets seem like a reasonable solution.

Log showing overflow txq and increased cnt:

// Extra debug prints
brcmfmac: [brcmf_netdev_wait_pend8021x] pend_8021x_cnt == 0
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 1
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 2

brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!
brcmfmac: brcmf_sdio_bus_txdata: out of bus->txq !!!

// Extra debug prints
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 3
brcmfmac: [brcmf_netdev_start_xmit] pend_8021x_cnt == 4
brcmfmac: [brcmf_netdev_wait_pend8021x] pend_8021x_cnt == 4

WARNING: at .../brcmfmac/core.c:1289 brcmf_netdev_wait_pend8021x
  (warn_slowpath_common)
  (warn_slowpath_null)
  (brcmf_netdev_wait_pend8021x [brcmfmac])
  (send_key_to_dongle [brcmfmac])
  (brcmf_cfg80211_del_key [brcmfmac])
  (nl80211_del_key [cfg80211])
  (genl_rcv_msg)
  (netlink_rcv_skb)
  (genl_rcv)
  (netlink_unicast)
  (netlink_sendmsg)
  (sock_sendmsg)
  (___sys_sendmsg)
  (__sys_sendmsg)
  (SyS_sendmsg)

---
I came across this bug in an older kernel but it seems relevant for the latest kernel as well. I'm not familiar with the code but I can reproduce the issue and verify a fix for it. This patch seems to work for my use case but I need to run some more tests to know for sure.

drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 2 ++

 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +0 -0
index ed9998b..8b1e30c 100644

drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb, · line 244

Quoted 4 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1 -0
@@ -241,7 +241,8 @@ static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
 done:
        if (ret) {
                ifp->stats.tx_dropped++;
+               if (eh->h_proto == htons(ETH_P_PAE))

Loking closer at this the if statement here is not reliable. We may end up here without having increased the count before. On way to fix this is to add a variable that is true in case "pend_8021x_cnt" was increased or false if not.
if (pend_8021x_cnt_increased)

Quoted 7 lines
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1 -1
+                       atomic_dec(&ifp->pend_8021x_cnt);
        } else {
                ifp->stats.tx_packets++;
                ifp->stats.tx_bytes += skb->len;
--

2.1.4