diff options
author | Rasesh Mody <rmody@brocade.com> | 2012-12-11 07:24:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-12-11 18:25:46 -0500 |
commit | 5e46631fdb1e5611969c1e61106a59a3b38af078 (patch) | |
tree | 1a9b2916295f0689039378729d8b1df289c5162e /drivers/net/ethernet/brocade | |
parent | f9c4d420c12de65e58a1a14ccee03e8b5cf99f5b (diff) |
bna: Code Cleanup and Enhancements
Change details:
- Remove unnecessary prefetch
- Simplify checking & comparison of CQ flags
- Dereference & store unmap_array, unmap_cons & current unmap_array
element only once
- Make structures tx_config & rx_config cache line aligned.
Signed-off-by: Rasesh Mody <rmody@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/brocade')
-rw-r--r-- | drivers/net/ethernet/brocade/bna/bnad.c | 43 | ||||
-rw-r--r-- | drivers/net/ethernet/brocade/bna/bnad.h | 4 |
2 files changed, 30 insertions, 17 deletions
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 76b2af64adc2..092c4c5b8ffa 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c | |||
@@ -210,7 +210,6 @@ bnad_txcmpl_process(struct bnad *bnad, | |||
210 | unmap_array = unmap_q->unmap_array; | 210 | unmap_array = unmap_q->unmap_array; |
211 | unmap_cons = unmap_q->consumer_index; | 211 | unmap_cons = unmap_q->consumer_index; |
212 | 212 | ||
213 | prefetch(&unmap_array[unmap_cons + 1]); | ||
214 | while (wis) { | 213 | while (wis) { |
215 | skb = unmap_array[unmap_cons].skb; | 214 | skb = unmap_array[unmap_cons].skb; |
216 | 215 | ||
@@ -383,6 +382,20 @@ bnad_refill_rxq(struct bnad *bnad, struct bna_rcb *rcb) | |||
383 | } | 382 | } |
384 | } | 383 | } |
385 | 384 | ||
385 | #define flags_cksum_prot_mask (BNA_CQ_EF_IPV4 | BNA_CQ_EF_L3_CKSUM_OK | \ | ||
386 | BNA_CQ_EF_IPV6 | \ | ||
387 | BNA_CQ_EF_TCP | BNA_CQ_EF_UDP | \ | ||
388 | BNA_CQ_EF_L4_CKSUM_OK) | ||
389 | |||
390 | #define flags_tcp4 (BNA_CQ_EF_IPV4 | BNA_CQ_EF_L3_CKSUM_OK | \ | ||
391 | BNA_CQ_EF_TCP | BNA_CQ_EF_L4_CKSUM_OK) | ||
392 | #define flags_tcp6 (BNA_CQ_EF_IPV6 | \ | ||
393 | BNA_CQ_EF_TCP | BNA_CQ_EF_L4_CKSUM_OK) | ||
394 | #define flags_udp4 (BNA_CQ_EF_IPV4 | BNA_CQ_EF_L3_CKSUM_OK | \ | ||
395 | BNA_CQ_EF_UDP | BNA_CQ_EF_L4_CKSUM_OK) | ||
396 | #define flags_udp6 (BNA_CQ_EF_IPV6 | \ | ||
397 | BNA_CQ_EF_UDP | BNA_CQ_EF_L4_CKSUM_OK) | ||
398 | |||
386 | static u32 | 399 | static u32 |
387 | bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) | 400 | bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) |
388 | { | 401 | { |
@@ -390,15 +403,12 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) | |||
390 | struct bna_rcb *rcb = NULL; | 403 | struct bna_rcb *rcb = NULL; |
391 | unsigned int wi_range, packets = 0, wis = 0; | 404 | unsigned int wi_range, packets = 0, wis = 0; |
392 | struct bnad_unmap_q *unmap_q; | 405 | struct bnad_unmap_q *unmap_q; |
393 | struct bnad_skb_unmap *unmap_array; | 406 | struct bnad_skb_unmap *unmap_array, *curr_ua; |
394 | struct sk_buff *skb; | 407 | struct sk_buff *skb; |
395 | u32 flags, unmap_cons; | 408 | u32 flags, unmap_cons, masked_flags; |
396 | struct bna_pkt_rate *pkt_rt = &ccb->pkt_rate; | 409 | struct bna_pkt_rate *pkt_rt = &ccb->pkt_rate; |
397 | struct bnad_rx_ctrl *rx_ctrl = (struct bnad_rx_ctrl *)(ccb->ctrl); | 410 | struct bnad_rx_ctrl *rx_ctrl = (struct bnad_rx_ctrl *)(ccb->ctrl); |
398 | 411 | ||
399 | if (!test_bit(BNAD_RXQ_STARTED, &ccb->rcb[0]->flags)) | ||
400 | return 0; | ||
401 | |||
402 | prefetch(bnad->netdev); | 412 | prefetch(bnad->netdev); |
403 | BNA_CQ_QPGE_PTR_GET(ccb->producer_index, ccb->sw_qpt, cmpl, | 413 | BNA_CQ_QPGE_PTR_GET(ccb->producer_index, ccb->sw_qpt, cmpl, |
404 | wi_range); | 414 | wi_range); |
@@ -416,12 +426,13 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) | |||
416 | unmap_array = unmap_q->unmap_array; | 426 | unmap_array = unmap_q->unmap_array; |
417 | unmap_cons = unmap_q->consumer_index; | 427 | unmap_cons = unmap_q->consumer_index; |
418 | 428 | ||
419 | skb = unmap_array[unmap_cons].skb; | 429 | curr_ua = &unmap_array[unmap_cons]; |
430 | |||
431 | skb = curr_ua->skb; | ||
420 | BUG_ON(!(skb)); | 432 | BUG_ON(!(skb)); |
421 | unmap_array[unmap_cons].skb = NULL; | 433 | curr_ua->skb = NULL; |
422 | dma_unmap_single(&bnad->pcidev->dev, | 434 | dma_unmap_single(&bnad->pcidev->dev, |
423 | dma_unmap_addr(&unmap_array[unmap_cons], | 435 | dma_unmap_addr(curr_ua, dma_addr), |
424 | dma_addr), | ||
425 | rcb->rxq->buffer_size, | 436 | rcb->rxq->buffer_size, |
426 | DMA_FROM_DEVICE); | 437 | DMA_FROM_DEVICE); |
427 | BNA_QE_INDX_ADD(unmap_q->consumer_index, 1, unmap_q->q_depth); | 438 | BNA_QE_INDX_ADD(unmap_q->consumer_index, 1, unmap_q->q_depth); |
@@ -452,13 +463,15 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) | |||
452 | } | 463 | } |
453 | 464 | ||
454 | skb_put(skb, ntohs(cmpl->length)); | 465 | skb_put(skb, ntohs(cmpl->length)); |
466 | |||
467 | masked_flags = flags & flags_cksum_prot_mask; | ||
468 | |||
455 | if (likely | 469 | if (likely |
456 | ((bnad->netdev->features & NETIF_F_RXCSUM) && | 470 | ((bnad->netdev->features & NETIF_F_RXCSUM) && |
457 | (((flags & BNA_CQ_EF_IPV4) && | 471 | ((masked_flags == flags_tcp4) || |
458 | (flags & BNA_CQ_EF_L3_CKSUM_OK)) || | 472 | (masked_flags == flags_udp4) || |
459 | (flags & BNA_CQ_EF_IPV6)) && | 473 | (masked_flags == flags_tcp6) || |
460 | (flags & (BNA_CQ_EF_TCP | BNA_CQ_EF_UDP)) && | 474 | (masked_flags == flags_udp6)))) |
461 | (flags & BNA_CQ_EF_L4_CKSUM_OK))) | ||
462 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 475 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
463 | else | 476 | else |
464 | skb_checksum_none_assert(skb); | 477 | skb_checksum_none_assert(skb); |
diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h index d78339224751..367b3a1eff0e 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.h +++ b/drivers/net/ethernet/brocade/bna/bnad.h | |||
@@ -284,8 +284,8 @@ struct bnad { | |||
284 | u8 tx_coalescing_timeo; | 284 | u8 tx_coalescing_timeo; |
285 | u8 rx_coalescing_timeo; | 285 | u8 rx_coalescing_timeo; |
286 | 286 | ||
287 | struct bna_rx_config rx_config[BNAD_MAX_RX]; | 287 | struct bna_rx_config rx_config[BNAD_MAX_RX] ____cacheline_aligned; |
288 | struct bna_tx_config tx_config[BNAD_MAX_TX]; | 288 | struct bna_tx_config tx_config[BNAD_MAX_TX] ____cacheline_aligned; |
289 | 289 | ||
290 | void __iomem *bar0; /* BAR0 address */ | 290 | void __iomem *bar0; /* BAR0 address */ |
291 | 291 | ||