From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH v2 2/4] net: emac: implement TCP segmentation offload (TSO) Date: Mon, 22 Oct 2018 19:55:52 -0700 (PDT) Message-ID: <20181022.195552.1906806895915259090.davem@davemloft.net> References: <31e4c49844ba62c12e601f33ddea7d51182c359b.1540206214.git.chunkeey@gmail.com> <617f509eed6c844ffd2442b2c4b46b3fe6bc580a.1540206214.git.chunkeey@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, f.fainelli@gmail.com To: chunkeey@gmail.com Return-path: Received: from shards.monkeyblade.net ([23.128.96.9]:40104 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726438AbeJWLRL (ORCPT ); Tue, 23 Oct 2018 07:17:11 -0400 In-Reply-To: <617f509eed6c844ffd2442b2c4b46b3fe6bc580a.1540206214.git.chunkeey@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Christian Lamparter Date: Mon, 22 Oct 2018 13:04:12 +0200 > @@ -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.