Subject: Re: [PATCH 3/3] net: mvneta: Introduce a software TSO implementation

From: Willy Tarreau <[email-masked]>
Date: Wed, 7 May 2014 08:04:25 +0200

Hi Ezequiel,

On Mon, May 05, 2014 at 11:47:02AM -0300, Ezequiel Garcia wrote:
> Hi all,
> 
> On 10 Apr 07:58 PM, Ezequiel Garcia wrote:
> [..]
> > +
> > +	/* Calculate expected number of TX descriptors */
> > +	desc_count = skb_shinfo(skb)->gso_segs * 2 + skb_shinfo(skb)->nr_frags;
> > +	if ((txq->count + desc_count) >= txq->size)
> > +		return 0;
> > +
> 
> Is this calculus correct? Does it give the accurate number of needed
> descriptors or is it an approximation?
> 
> Tilera's tilegx driver does a much stricter descriptor count (see
> tso_count_edescs). This functions loops through the skb_frag_t fragments
> as it's done later in the data egress, hence strictly counting the
> needed descriptors.
> 
> However, as it's a much heavier routine than the one shown above,
> I'm wondering if we can get away without it.
> 
> Willy, Any ideas here?

I think we don't absolutely need to have the exact value, provided we
don't fall into the case where we cannot send a single skb with an
empty queue. Here we have 532 tx descriptors max, which means that
with an MSS below 246 bytes, we may fall into this situation.

Eric pointed out commit 7e6d06f0de3f7 which applies a limit on the
number of segments for the sfc driver, I think you should take a look
at it. I haven't played with gso_max_segs yet, but there are clear
explanations in the commit message and in the comments that can serve
as a nice starting point.

Hoping this helps :-/

Willy