forked from Minki/linux
net: axienet: fix for TX busy handling
Network driver documentation indicates we should be avoiding returning
NETDEV_TX_BUSY from ndo_start_xmit in normal cases, since it requires
the packets to be requeued. Instead the queue should be stopped after
a packet is added to the TX ring when there may not be enough room for an
additional one. Also, when TX ring entries are completed, we should only
wake the queue if we know there is room for another full maximally
fragmented packet.
Print a warning if there is insufficient space at the start of start_xmit,
since this should no longer happen.
Combined with increasing the default TX ring size (in a subsequent
patch), this appears to recover the TX performance lost by previous changes
to actually manage the TX ring state properly.
Fixes: 8a3b7a252d
("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")
Signed-off-by: Robert Hancock <robert.hancock@calian.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
aba57a823d
commit
bb193e3db8
@ -660,6 +660,32 @@ static int axienet_free_tx_chain(struct net_device *ndev, u32 first_bd,
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* axienet_check_tx_bd_space - Checks if a BD/group of BDs are currently busy
|
||||
* @lp: Pointer to the axienet_local structure
|
||||
* @num_frag: The number of BDs to check for
|
||||
*
|
||||
* Return: 0, on success
|
||||
* NETDEV_TX_BUSY, if any of the descriptors are not free
|
||||
*
|
||||
* This function is invoked before BDs are allocated and transmission starts.
|
||||
* This function returns 0 if a BD or group of BDs can be allocated for
|
||||
* transmission. If the BD or any of the BDs are not free the function
|
||||
* returns a busy status. This is invoked from axienet_start_xmit.
|
||||
*/
|
||||
static inline int axienet_check_tx_bd_space(struct axienet_local *lp,
|
||||
int num_frag)
|
||||
{
|
||||
struct axidma_bd *cur_p;
|
||||
|
||||
/* Ensure we see all descriptor updates from device or TX IRQ path */
|
||||
rmb();
|
||||
cur_p = &lp->tx_bd_v[(lp->tx_bd_tail + num_frag) % lp->tx_bd_num];
|
||||
if (cur_p->cntrl)
|
||||
return NETDEV_TX_BUSY;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* axienet_start_xmit_done - Invoked once a transmit is completed by the
|
||||
* Axi DMA Tx channel.
|
||||
@ -689,33 +715,8 @@ static void axienet_start_xmit_done(struct net_device *ndev)
|
||||
/* Matches barrier in axienet_start_xmit */
|
||||
smp_mb();
|
||||
|
||||
netif_wake_queue(ndev);
|
||||
}
|
||||
|
||||
/**
|
||||
* axienet_check_tx_bd_space - Checks if a BD/group of BDs are currently busy
|
||||
* @lp: Pointer to the axienet_local structure
|
||||
* @num_frag: The number of BDs to check for
|
||||
*
|
||||
* Return: 0, on success
|
||||
* NETDEV_TX_BUSY, if any of the descriptors are not free
|
||||
*
|
||||
* This function is invoked before BDs are allocated and transmission starts.
|
||||
* This function returns 0 if a BD or group of BDs can be allocated for
|
||||
* transmission. If the BD or any of the BDs are not free the function
|
||||
* returns a busy status. This is invoked from axienet_start_xmit.
|
||||
*/
|
||||
static inline int axienet_check_tx_bd_space(struct axienet_local *lp,
|
||||
int num_frag)
|
||||
{
|
||||
struct axidma_bd *cur_p;
|
||||
|
||||
/* Ensure we see all descriptor updates from device or TX IRQ path */
|
||||
rmb();
|
||||
cur_p = &lp->tx_bd_v[(lp->tx_bd_tail + num_frag) % lp->tx_bd_num];
|
||||
if (cur_p->cntrl)
|
||||
return NETDEV_TX_BUSY;
|
||||
return 0;
|
||||
if (!axienet_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1))
|
||||
netif_wake_queue(ndev);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -748,19 +749,14 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
||||
cur_p = &lp->tx_bd_v[lp->tx_bd_tail];
|
||||
|
||||
if (axienet_check_tx_bd_space(lp, num_frag + 1)) {
|
||||
if (netif_queue_stopped(ndev))
|
||||
return NETDEV_TX_BUSY;
|
||||
|
||||
/* Should not happen as last start_xmit call should have
|
||||
* checked for sufficient space and queue should only be
|
||||
* woken when sufficient space is available.
|
||||
*/
|
||||
netif_stop_queue(ndev);
|
||||
|
||||
/* Matches barrier in axienet_start_xmit_done */
|
||||
smp_mb();
|
||||
|
||||
/* Space might have just been freed - check again */
|
||||
if (axienet_check_tx_bd_space(lp, num_frag + 1))
|
||||
return NETDEV_TX_BUSY;
|
||||
|
||||
netif_wake_queue(ndev);
|
||||
if (net_ratelimit())
|
||||
netdev_warn(ndev, "TX ring unexpectedly full\n");
|
||||
return NETDEV_TX_BUSY;
|
||||
}
|
||||
|
||||
if (skb->ip_summed == CHECKSUM_PARTIAL) {
|
||||
@ -821,6 +817,18 @@ axienet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
|
||||
if (++lp->tx_bd_tail >= lp->tx_bd_num)
|
||||
lp->tx_bd_tail = 0;
|
||||
|
||||
/* Stop queue if next transmit may not have space */
|
||||
if (axienet_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {
|
||||
netif_stop_queue(ndev);
|
||||
|
||||
/* Matches barrier in axienet_start_xmit_done */
|
||||
smp_mb();
|
||||
|
||||
/* Space might have just been freed - check again */
|
||||
if (!axienet_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1))
|
||||
netif_wake_queue(ndev);
|
||||
}
|
||||
|
||||
return NETDEV_TX_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user