Subject: Re: [PATCH (net-next.git) 04/18] stmmac: remove modulo in stmmac_xmit()

From: Giuseppe CAVALLARO <[email-masked]>
Date: Tue, 5 Jan 2016 09:56:24 +0100

Hi David

On 1/5/2016 4:34 AM, David Miller wrote:
> From: Giuseppe Cavallaro <[email-masked]>
> Date: Mon, 4 Jan 2016 14:06:49 +0100
>
>> @@ -2056,7 +2068,10 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
>>   	priv->hw->desc->set_tx_owner(first);
>>   	wmb();
>>
>> -	priv->cur_tx++;
>> +	if (++entry >= txsize)
>> +		entry = 0;
>
> You are doing this over and over again, encapsulate it into a helper
> like "NEXT_TX(x)" or similar.
>
> Also, this is just fundamentally completely stupid.  Enforce the ring

this is not completely gentle but I share the final advice and I will 
fix that asap.

thanks for the review.

peppe

> size to be a power-of-2, then you can just go "x + 1 & (size - 1)" and
> not even have the conditional statement.
>
> Thanks.
>