be2net: Add a few inline functions to test TXQ conditions

- Check qfull condition
- Check qwake condition
- Check pkts pending completion

Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Sriharsha Basavapatna 2015-02-16 08:03:48 +05:30 committed by David S. Miller
parent 152ffe5bb7
commit cf5671e699
1 changed files with 18 additions and 4 deletions

View File

@ -727,6 +727,21 @@ static u16 skb_ip_proto(struct sk_buff *skb)
ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr; ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr;
} }
static inline bool be_is_txq_full(struct be_tx_obj *txo)
{
return atomic_read(&txo->q.used) + BE_MAX_TX_FRAG_COUNT >= txo->q.len;
}
static inline bool be_can_txq_wake(struct be_tx_obj *txo)
{
return atomic_read(&txo->q.used) < txo->q.len / 2;
}
static inline bool be_is_tx_compl_pending(struct be_tx_obj *txo)
{
return atomic_read(&txo->q.used) > txo->pend_wrb_cnt;
}
static void be_get_wrb_params_from_skb(struct be_adapter *adapter, static void be_get_wrb_params_from_skb(struct be_adapter *adapter,
struct sk_buff *skb, struct sk_buff *skb,
struct be_wrb_params *wrb_params) struct be_wrb_params *wrb_params)
@ -1134,7 +1149,6 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
u16 q_idx = skb_get_queue_mapping(skb); u16 q_idx = skb_get_queue_mapping(skb);
struct be_tx_obj *txo = &adapter->tx_obj[q_idx]; struct be_tx_obj *txo = &adapter->tx_obj[q_idx];
struct be_wrb_params wrb_params = { 0 }; struct be_wrb_params wrb_params = { 0 };
struct be_queue_info *txq = &txo->q;
bool flush = !skb->xmit_more; bool flush = !skb->xmit_more;
u16 wrb_cnt; u16 wrb_cnt;
@ -1150,7 +1164,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
goto drop; goto drop;
} }
if ((atomic_read(&txq->used) + BE_MAX_TX_FRAG_COUNT) >= txq->len) { if (be_is_txq_full(txo)) {
netif_stop_subqueue(netdev, q_idx); netif_stop_subqueue(netdev, q_idx);
tx_stats(txo)->tx_stops++; tx_stats(txo)->tx_stops++;
} }
@ -2225,7 +2239,7 @@ static void be_tx_compl_clean(struct be_adapter *adapter)
atomic_sub(num_wrbs, &txq->used); atomic_sub(num_wrbs, &txq->used);
timeo = 0; timeo = 0;
} }
if (atomic_read(&txq->used) == txo->pend_wrb_cnt) if (!be_is_tx_compl_pending(txo))
pending_txqs--; pending_txqs--;
} }
@ -2638,7 +2652,7 @@ static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo,
/* As Tx wrbs have been freed up, wake up netdev queue /* As Tx wrbs have been freed up, wake up netdev queue
* if it was stopped due to lack of tx wrbs. */ * if it was stopped due to lack of tx wrbs. */
if (__netif_subqueue_stopped(adapter->netdev, idx) && if (__netif_subqueue_stopped(adapter->netdev, idx) &&
atomic_read(&txo->q.used) < txo->q.len / 2) { be_can_txq_wake(txo)) {
netif_wake_subqueue(adapter->netdev, idx); netif_wake_subqueue(adapter->netdev, idx);
} }