aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex
diff options
context:
space:
mode:
authorSriharsha Basavapatna <sriharsha.basavapatna@emulex.com>2015-02-15 21:33:48 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-20 14:06:57 -0500
commitcf5671e6999829933aa4b9b8eefc7d3b8b85c5cb (patch)
treedced16a37b682ff635940c45a34a251bfb4b4473 /drivers/net/ethernet/emulex
parent152ffe5bb7108d39a50bcc723219685a573f8397 (diff)
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>
Diffstat (limited to 'drivers/net/ethernet/emulex')
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 78beab560bc0..c1553fba7916 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -727,6 +727,21 @@ static u16 skb_ip_proto(struct sk_buff *skb)
727 ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr; 727 ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr;
728} 728}
729 729
730static inline bool be_is_txq_full(struct be_tx_obj *txo)
731{
732 return atomic_read(&txo->q.used) + BE_MAX_TX_FRAG_COUNT >= txo->q.len;
733}
734
735static inline bool be_can_txq_wake(struct be_tx_obj *txo)
736{
737 return atomic_read(&txo->q.used) < txo->q.len / 2;
738}
739
740static inline bool be_is_tx_compl_pending(struct be_tx_obj *txo)
741{
742 return atomic_read(&txo->q.used) > txo->pend_wrb_cnt;
743}
744
730static void be_get_wrb_params_from_skb(struct be_adapter *adapter, 745static void be_get_wrb_params_from_skb(struct be_adapter *adapter,
731 struct sk_buff *skb, 746 struct sk_buff *skb,
732 struct be_wrb_params *wrb_params) 747 struct be_wrb_params *wrb_params)
@@ -1134,7 +1149,6 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
1134 u16 q_idx = skb_get_queue_mapping(skb); 1149 u16 q_idx = skb_get_queue_mapping(skb);
1135 struct be_tx_obj *txo = &adapter->tx_obj[q_idx]; 1150 struct be_tx_obj *txo = &adapter->tx_obj[q_idx];
1136 struct be_wrb_params wrb_params = { 0 }; 1151 struct be_wrb_params wrb_params = { 0 };
1137 struct be_queue_info *txq = &txo->q;
1138 bool flush = !skb->xmit_more; 1152 bool flush = !skb->xmit_more;
1139 u16 wrb_cnt; 1153 u16 wrb_cnt;
1140 1154
@@ -1150,7 +1164,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
1150 goto drop; 1164 goto drop;
1151 } 1165 }
1152 1166
1153 if ((atomic_read(&txq->used) + BE_MAX_TX_FRAG_COUNT) >= txq->len) { 1167 if (be_is_txq_full(txo)) {
1154 netif_stop_subqueue(netdev, q_idx); 1168 netif_stop_subqueue(netdev, q_idx);
1155 tx_stats(txo)->tx_stops++; 1169 tx_stats(txo)->tx_stops++;
1156 } 1170 }
@@ -2225,7 +2239,7 @@ static void be_tx_compl_clean(struct be_adapter *adapter)
2225 atomic_sub(num_wrbs, &txq->used); 2239 atomic_sub(num_wrbs, &txq->used);
2226 timeo = 0; 2240 timeo = 0;
2227 } 2241 }
2228 if (atomic_read(&txq->used) == txo->pend_wrb_cnt) 2242 if (!be_is_tx_compl_pending(txo))
2229 pending_txqs--; 2243 pending_txqs--;
2230 } 2244 }
2231 2245
@@ -2638,7 +2652,7 @@ static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo,
2638 /* As Tx wrbs have been freed up, wake up netdev queue 2652 /* As Tx wrbs have been freed up, wake up netdev queue
2639 * if it was stopped due to lack of tx wrbs. */ 2653 * if it was stopped due to lack of tx wrbs. */
2640 if (__netif_subqueue_stopped(adapter->netdev, idx) && 2654 if (__netif_subqueue_stopped(adapter->netdev, idx) &&
2641 atomic_read(&txo->q.used) < txo->q.len / 2) { 2655 be_can_txq_wake(txo)) {
2642 netif_wake_subqueue(adapter->netdev, idx); 2656 netif_wake_subqueue(adapter->netdev, idx);
2643 } 2657 }
2644 2658