diff options
author | Sriharsha Basavapatna <sriharsha.basavapatna@emulex.com> | 2015-02-15 21:33:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-20 14:06:57 -0500 |
commit | 152ffe5bb7108d39a50bcc723219685a573f8397 (patch) | |
tree | 9918da8c016952e0d0ce0c1b7ae6d962a95ee463 /drivers/net/ethernet/emulex | |
parent | 79a0d7d8e0b2981dabc241cbeec6b99620dd7c5b (diff) |
be2net: Minor code cleanup in tx completion process
- To avoid multiple accesses to CQE, extract compl_status and end_idx from
be_tx_compl_get().
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.h | 7 | ||||
-rw-r--r-- | drivers/net/ethernet/emulex/benet/be_main.c | 47 |
2 files changed, 31 insertions, 23 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index bc7f3d6872f4..ad33bf1f1df1 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h | |||
@@ -238,10 +238,17 @@ struct be_tx_stats { | |||
238 | struct u64_stats_sync sync_compl; | 238 | struct u64_stats_sync sync_compl; |
239 | }; | 239 | }; |
240 | 240 | ||
241 | /* Structure to hold some data of interest obtained from a TX CQE */ | ||
242 | struct be_tx_compl_info { | ||
243 | u8 status; /* Completion status */ | ||
244 | u16 end_index; /* Completed TXQ Index */ | ||
245 | }; | ||
246 | |||
241 | struct be_tx_obj { | 247 | struct be_tx_obj { |
242 | u32 db_offset; | 248 | u32 db_offset; |
243 | struct be_queue_info q; | 249 | struct be_queue_info q; |
244 | struct be_queue_info cq; | 250 | struct be_queue_info cq; |
251 | struct be_tx_compl_info txcp; | ||
245 | /* Remember the skbs that were transmitted */ | 252 | /* Remember the skbs that were transmitted */ |
246 | struct sk_buff *sent_skb_list[TX_Q_LEN]; | 253 | struct sk_buff *sent_skb_list[TX_Q_LEN]; |
247 | struct be_tx_stats stats; | 254 | struct be_tx_stats stats; |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index a6df4c96150f..78beab560bc0 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -2064,18 +2064,23 @@ static void be_post_rx_frags(struct be_rx_obj *rxo, gfp_t gfp, u32 frags_needed) | |||
2064 | } | 2064 | } |
2065 | } | 2065 | } |
2066 | 2066 | ||
2067 | static struct be_eth_tx_compl *be_tx_compl_get(struct be_queue_info *tx_cq) | 2067 | static struct be_tx_compl_info *be_tx_compl_get(struct be_tx_obj *txo) |
2068 | { | 2068 | { |
2069 | struct be_eth_tx_compl *txcp = queue_tail_node(tx_cq); | 2069 | struct be_queue_info *tx_cq = &txo->cq; |
2070 | struct be_tx_compl_info *txcp = &txo->txcp; | ||
2071 | struct be_eth_tx_compl *compl = queue_tail_node(tx_cq); | ||
2070 | 2072 | ||
2071 | if (txcp->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] == 0) | 2073 | if (compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] == 0) |
2072 | return NULL; | 2074 | return NULL; |
2073 | 2075 | ||
2076 | /* Ensure load ordering of valid bit dword and other dwords below */ | ||
2074 | rmb(); | 2077 | rmb(); |
2075 | be_dws_le_to_cpu(txcp, sizeof(*txcp)); | 2078 | be_dws_le_to_cpu(compl, sizeof(*compl)); |
2076 | 2079 | ||
2077 | txcp->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] = 0; | 2080 | txcp->status = GET_TX_COMPL_BITS(status, compl); |
2081 | txcp->end_index = GET_TX_COMPL_BITS(wrb_index, compl); | ||
2078 | 2082 | ||
2083 | compl->dw[offsetof(struct amap_eth_tx_compl, valid) / 32] = 0; | ||
2079 | queue_tail_inc(tx_cq); | 2084 | queue_tail_inc(tx_cq); |
2080 | return txcp; | 2085 | return txcp; |
2081 | } | 2086 | } |
@@ -2196,9 +2201,9 @@ static void be_tx_compl_clean(struct be_adapter *adapter) | |||
2196 | { | 2201 | { |
2197 | u16 end_idx, notified_idx, cmpl = 0, timeo = 0, num_wrbs = 0; | 2202 | u16 end_idx, notified_idx, cmpl = 0, timeo = 0, num_wrbs = 0; |
2198 | struct device *dev = &adapter->pdev->dev; | 2203 | struct device *dev = &adapter->pdev->dev; |
2199 | struct be_tx_obj *txo; | 2204 | struct be_tx_compl_info *txcp; |
2200 | struct be_queue_info *txq; | 2205 | struct be_queue_info *txq; |
2201 | struct be_eth_tx_compl *txcp; | 2206 | struct be_tx_obj *txo; |
2202 | int i, pending_txqs; | 2207 | int i, pending_txqs; |
2203 | 2208 | ||
2204 | /* Stop polling for compls when HW has been silent for 10ms */ | 2209 | /* Stop polling for compls when HW has been silent for 10ms */ |
@@ -2209,10 +2214,10 @@ static void be_tx_compl_clean(struct be_adapter *adapter) | |||
2209 | cmpl = 0; | 2214 | cmpl = 0; |
2210 | num_wrbs = 0; | 2215 | num_wrbs = 0; |
2211 | txq = &txo->q; | 2216 | txq = &txo->q; |
2212 | while ((txcp = be_tx_compl_get(&txo->cq))) { | 2217 | while ((txcp = be_tx_compl_get(txo))) { |
2213 | end_idx = GET_TX_COMPL_BITS(wrb_index, txcp); | 2218 | num_wrbs += |
2214 | num_wrbs += be_tx_compl_process(adapter, txo, | 2219 | be_tx_compl_process(adapter, txo, |
2215 | end_idx); | 2220 | txcp->end_index); |
2216 | cmpl++; | 2221 | cmpl++; |
2217 | } | 2222 | } |
2218 | if (cmpl) { | 2223 | if (cmpl) { |
@@ -2571,7 +2576,7 @@ loop_continue: | |||
2571 | return work_done; | 2576 | return work_done; |
2572 | } | 2577 | } |
2573 | 2578 | ||
2574 | static inline void be_update_tx_err(struct be_tx_obj *txo, u32 status) | 2579 | static inline void be_update_tx_err(struct be_tx_obj *txo, u8 status) |
2575 | { | 2580 | { |
2576 | switch (status) { | 2581 | switch (status) { |
2577 | case BE_TX_COMP_HDR_PARSE_ERR: | 2582 | case BE_TX_COMP_HDR_PARSE_ERR: |
@@ -2586,7 +2591,7 @@ static inline void be_update_tx_err(struct be_tx_obj *txo, u32 status) | |||
2586 | } | 2591 | } |
2587 | } | 2592 | } |
2588 | 2593 | ||
2589 | static inline void lancer_update_tx_err(struct be_tx_obj *txo, u32 status) | 2594 | static inline void lancer_update_tx_err(struct be_tx_obj *txo, u8 status) |
2590 | { | 2595 | { |
2591 | switch (status) { | 2596 | switch (status) { |
2592 | case LANCER_TX_COMP_LSO_ERR: | 2597 | case LANCER_TX_COMP_LSO_ERR: |
@@ -2611,22 +2616,18 @@ static inline void lancer_update_tx_err(struct be_tx_obj *txo, u32 status) | |||
2611 | static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo, | 2616 | static void be_process_tx(struct be_adapter *adapter, struct be_tx_obj *txo, |
2612 | int idx) | 2617 | int idx) |
2613 | { | 2618 | { |
2614 | struct be_eth_tx_compl *txcp; | ||
2615 | int num_wrbs = 0, work_done = 0; | 2619 | int num_wrbs = 0, work_done = 0; |
2616 | u32 compl_status; | 2620 | struct be_tx_compl_info *txcp; |
2617 | u16 last_idx; | ||
2618 | 2621 | ||
2619 | while ((txcp = be_tx_compl_get(&txo->cq))) { | 2622 | while ((txcp = be_tx_compl_get(txo))) { |
2620 | last_idx = GET_TX_COMPL_BITS(wrb_index, txcp); | 2623 | num_wrbs += be_tx_compl_process(adapter, txo, txcp->end_index); |
2621 | num_wrbs += be_tx_compl_process(adapter, txo, last_idx); | ||
2622 | work_done++; | 2624 | work_done++; |
2623 | 2625 | ||
2624 | compl_status = GET_TX_COMPL_BITS(status, txcp); | 2626 | if (txcp->status) { |
2625 | if (compl_status) { | ||
2626 | if (lancer_chip(adapter)) | 2627 | if (lancer_chip(adapter)) |
2627 | lancer_update_tx_err(txo, compl_status); | 2628 | lancer_update_tx_err(txo, txcp->status); |
2628 | else | 2629 | else |
2629 | be_update_tx_err(txo, compl_status); | 2630 | be_update_tx_err(txo, txcp->status); |
2630 | } | 2631 | } |
2631 | } | 2632 | } |
2632 | 2633 | ||