Skip to content

Commit

Permalink
be2net: Add a few inline functions to test TXQ conditions
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
Sriharsha Basavapatna authored and David S. Miller committed Feb 20, 2015
1 parent 152ffe5 commit cf5671e
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions drivers/net/ethernet/emulex/benet/be_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,21 @@ static u16 skb_ip_proto(struct sk_buff *skb)
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,
struct sk_buff *skb,
struct be_wrb_params *wrb_params)
Expand Down Expand Up @@ -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);
struct be_tx_obj *txo = &adapter->tx_obj[q_idx];
struct be_wrb_params wrb_params = { 0 };
struct be_queue_info *txq = &txo->q;
bool flush = !skb->xmit_more;
u16 wrb_cnt;

Expand All @@ -1150,7 +1164,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
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);
tx_stats(txo)->tx_stops++;
}
Expand Down Expand Up @@ -2225,7 +2239,7 @@ static void be_tx_compl_clean(struct be_adapter *adapter)
atomic_sub(num_wrbs, &txq->used);
timeo = 0;
}
if (atomic_read(&txq->used) == txo->pend_wrb_cnt)
if (!be_is_tx_compl_pending(txo))
pending_txqs--;
}

Expand Down Expand Up @@ -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
* if it was stopped due to lack of tx wrbs. */
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);
}

Expand Down

0 comments on commit cf5671e

Please sign in to comment.