Re: [PATCH v2 2/4] net: emac: implement TCP segmentation offload (TSO)
From: David Miller <davem@davemloft.net>
Date: 2018-10-23 11:17:11
From: Christian Lamparter <redacted> Date: Mon, 22 Oct 2018 13:04:12 +0200
quoted hunk ↗ jump to hunk
@@ -1452,8 +1509,49 @@ static inline u16 emac_tx_vlan(struct emac_instance *dev, struct sk_buff *skb) return 0; } +static netdev_tx_t +emac_start_xmit_sg(struct sk_buff *skb, struct net_device *ndev); + +static netdev_tx_t +emac_sw_tso(struct sk_buff *skb, struct net_device *ndev) +{ + struct emac_instance *dev = netdev_priv(ndev); + struct sk_buff *segs, *curr; + unsigned int i, frag_slots; + + /* make sure to not overflow the tx ring */ + frag_slots = dev->tx_cnt; + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i]; + + frag_slots += mal_tx_chunks(skb_frag_size(frag)); + + if (frag_slots >= NUM_TX_BUFF) + return NETDEV_TX_BUSY; + }; + + segs = skb_gso_segment(skb, ndev->features & + ~(NETIF_F_TSO | NETIF_F_TSO6));
This NETDEV_TX_BUSY isn't going to work. Your TX queue is awake. So there won't be any guaranteed event to "wake up" the queue and try sending this SKB again. Please take a look at how the tg3.c driver handles this situation. You have to first stop the queue, do you overflow test, and then you can return NETDEV_TX_BUSY if necessary.