Subject: Re: [net PATCH 1/1] drivers: net: cpsw: dual_emac: fix reducing of rx descriptor during ifdown

From: Mugunthan V N <[email-masked]>
Date: Tue, 2 Sep 2014 14:51:05 +0530

David

On Tuesday 02 September 2014 07:01 AM, David Miller wrote:
> From: Mugunthan V N <[email-masked]>
> Date: Fri, 29 Aug 2014 14:52:25 +0530
> 
>> In Dual EMAC, when both interface are up and while doing ifdown with heavy
>> traffic then skbs already processed by DMA from that slave emac has to be
>> requeued as still the other interface is up and running.
>>
>> Signed-off-by: Mugunthan V N <[email-masked]>
> 
> I don't see why this is important.
> 
> If the packet arrived via the down interface, let it be dropped and
> the sender will simply resend if necessary.
> 
> Also you are putting this new multi-slave logic under the "status < 0"
> condition as well as the interface being down, that's not right either.
> 

Multi slave logic is already there though out the driver, this is one
corner case where it fails. Let me explain more

DMA is common for both interfaces and serves both the slave ports. In
heavy traffic when one interface is put down, there are chances that
some packets are already processed in are in completed state.

Since DMA is a common entity for both interface, DMA is disabled only
when there all the slave interfaces are down. so when both interface is
up and putting down one interface, DMA de-init doesn't  happen as the
other interface is up.

In this scenario, when cpsw_rx_handler is called for processing the
packet which might have packets for interfaces which is down already.
Previously the driver simply drops the skb and doesn't do re-queue of
the descriptor which results in one descriptor less for rx DMA.

When ifup and ifdown is run continuously, for each spilled packet (for
interface which is down) from DMA, the total number of rx descriptor
goes down and at one instance all the descriptor is lost and both the
interface stops working.

To recover from this we need to put down both the interface and open the
interface which will re-init the DMA which intern queues fresh set of
skbs for rx.

So to overcome this issue, I did this fix by re-queuing the rx
descriptor back to DMA when any one interface is so that the no of rx
descriptor is kept constant always.

Regards
Mugunthan V N