diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-04-14 06:08:02 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-04-14 14:57:11 -0400 |
commit | 29ba877e7c8092a4dd3cbef80cca4e857129ca55 (patch) | |
tree | d1b6cc4b86b18b116813bcb602a57730eb54aaa5 /drivers/net | |
parent | 4668ae1fbcab89af5ffbb161d4c70b25ce4c50f4 (diff) |
bgmac: drop ring->num_slots
The ring size is always known at compile time, so make the code a bit
more efficient
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ethernet/broadcom/bgmac.c | 27 | ||||
-rw-r--r-- | drivers/net/ethernet/broadcom/bgmac.h | 3 |
2 files changed, 15 insertions, 15 deletions
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c index 29af9e656a7a..5cb93d1f50a4 100644 --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c | |||
@@ -123,7 +123,7 @@ bgmac_dma_tx_add_buf(struct bgmac *bgmac, struct bgmac_dma_ring *ring, | |||
123 | struct bgmac_dma_desc *dma_desc; | 123 | struct bgmac_dma_desc *dma_desc; |
124 | u32 ctl1; | 124 | u32 ctl1; |
125 | 125 | ||
126 | if (i == ring->num_slots - 1) | 126 | if (i == BGMAC_TX_RING_SLOTS - 1) |
127 | ctl0 |= BGMAC_DESC_CTL0_EOT; | 127 | ctl0 |= BGMAC_DESC_CTL0_EOT; |
128 | 128 | ||
129 | ctl1 = len & BGMAC_DESC_CTL1_LEN; | 129 | ctl1 = len & BGMAC_DESC_CTL1_LEN; |
@@ -382,7 +382,7 @@ static void bgmac_dma_rx_setup_desc(struct bgmac *bgmac, | |||
382 | struct bgmac_dma_desc *dma_desc = ring->cpu_base + desc_idx; | 382 | struct bgmac_dma_desc *dma_desc = ring->cpu_base + desc_idx; |
383 | u32 ctl0 = 0, ctl1 = 0; | 383 | u32 ctl0 = 0, ctl1 = 0; |
384 | 384 | ||
385 | if (desc_idx == ring->num_slots - 1) | 385 | if (desc_idx == BGMAC_RX_RING_SLOTS - 1) |
386 | ctl0 |= BGMAC_DESC_CTL0_EOT; | 386 | ctl0 |= BGMAC_DESC_CTL0_EOT; |
387 | ctl1 |= BGMAC_RX_BUF_SIZE & BGMAC_DESC_CTL1_LEN; | 387 | ctl1 |= BGMAC_RX_BUF_SIZE & BGMAC_DESC_CTL1_LEN; |
388 | /* Is there any BGMAC device that requires extension? */ | 388 | /* Is there any BGMAC device that requires extension? */ |
@@ -521,7 +521,7 @@ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac, | |||
521 | struct bgmac_slot_info *slot; | 521 | struct bgmac_slot_info *slot; |
522 | int i; | 522 | int i; |
523 | 523 | ||
524 | for (i = 0; i < ring->num_slots; i++) { | 524 | for (i = 0; i < BGMAC_TX_RING_SLOTS; i++) { |
525 | int len = dma_desc[i].ctl1 & BGMAC_DESC_CTL1_LEN; | 525 | int len = dma_desc[i].ctl1 & BGMAC_DESC_CTL1_LEN; |
526 | 526 | ||
527 | slot = &ring->slots[i]; | 527 | slot = &ring->slots[i]; |
@@ -546,7 +546,7 @@ static void bgmac_dma_rx_ring_free(struct bgmac *bgmac, | |||
546 | struct bgmac_slot_info *slot; | 546 | struct bgmac_slot_info *slot; |
547 | int i; | 547 | int i; |
548 | 548 | ||
549 | for (i = 0; i < ring->num_slots; i++) { | 549 | for (i = 0; i < BGMAC_RX_RING_SLOTS; i++) { |
550 | slot = &ring->slots[i]; | 550 | slot = &ring->slots[i]; |
551 | if (!slot->dma_addr) | 551 | if (!slot->dma_addr) |
552 | continue; | 552 | continue; |
@@ -560,7 +560,8 @@ static void bgmac_dma_rx_ring_free(struct bgmac *bgmac, | |||
560 | } | 560 | } |
561 | 561 | ||
562 | static void bgmac_dma_ring_desc_free(struct bgmac *bgmac, | 562 | static void bgmac_dma_ring_desc_free(struct bgmac *bgmac, |
563 | struct bgmac_dma_ring *ring) | 563 | struct bgmac_dma_ring *ring, |
564 | int num_slots) | ||
564 | { | 565 | { |
565 | struct device *dma_dev = bgmac->core->dma_dev; | 566 | struct device *dma_dev = bgmac->core->dma_dev; |
566 | int size; | 567 | int size; |
@@ -569,7 +570,7 @@ static void bgmac_dma_ring_desc_free(struct bgmac *bgmac, | |||
569 | return; | 570 | return; |
570 | 571 | ||
571 | /* Free ring of descriptors */ | 572 | /* Free ring of descriptors */ |
572 | size = ring->num_slots * sizeof(struct bgmac_dma_desc); | 573 | size = num_slots * sizeof(struct bgmac_dma_desc); |
573 | dma_free_coherent(dma_dev, size, ring->cpu_base, | 574 | dma_free_coherent(dma_dev, size, ring->cpu_base, |
574 | ring->dma_base); | 575 | ring->dma_base); |
575 | } | 576 | } |
@@ -590,10 +591,12 @@ static void bgmac_dma_free(struct bgmac *bgmac) | |||
590 | int i; | 591 | int i; |
591 | 592 | ||
592 | for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) | 593 | for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) |
593 | bgmac_dma_ring_desc_free(bgmac, &bgmac->tx_ring[i]); | 594 | bgmac_dma_ring_desc_free(bgmac, &bgmac->tx_ring[i], |
595 | BGMAC_TX_RING_SLOTS); | ||
594 | 596 | ||
595 | for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) | 597 | for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) |
596 | bgmac_dma_ring_desc_free(bgmac, &bgmac->rx_ring[i]); | 598 | bgmac_dma_ring_desc_free(bgmac, &bgmac->rx_ring[i], |
599 | BGMAC_RX_RING_SLOTS); | ||
597 | } | 600 | } |
598 | 601 | ||
599 | static int bgmac_dma_alloc(struct bgmac *bgmac) | 602 | static int bgmac_dma_alloc(struct bgmac *bgmac) |
@@ -616,11 +619,10 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) | |||
616 | 619 | ||
617 | for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { | 620 | for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { |
618 | ring = &bgmac->tx_ring[i]; | 621 | ring = &bgmac->tx_ring[i]; |
619 | ring->num_slots = BGMAC_TX_RING_SLOTS; | ||
620 | ring->mmio_base = ring_base[i]; | 622 | ring->mmio_base = ring_base[i]; |
621 | 623 | ||
622 | /* Alloc ring of descriptors */ | 624 | /* Alloc ring of descriptors */ |
623 | size = ring->num_slots * sizeof(struct bgmac_dma_desc); | 625 | size = BGMAC_TX_RING_SLOTS * sizeof(struct bgmac_dma_desc); |
624 | ring->cpu_base = dma_zalloc_coherent(dma_dev, size, | 626 | ring->cpu_base = dma_zalloc_coherent(dma_dev, size, |
625 | &ring->dma_base, | 627 | &ring->dma_base, |
626 | GFP_KERNEL); | 628 | GFP_KERNEL); |
@@ -642,11 +644,10 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) | |||
642 | 644 | ||
643 | for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) { | 645 | for (i = 0; i < BGMAC_MAX_RX_RINGS; i++) { |
644 | ring = &bgmac->rx_ring[i]; | 646 | ring = &bgmac->rx_ring[i]; |
645 | ring->num_slots = BGMAC_RX_RING_SLOTS; | ||
646 | ring->mmio_base = ring_base[i]; | 647 | ring->mmio_base = ring_base[i]; |
647 | 648 | ||
648 | /* Alloc ring of descriptors */ | 649 | /* Alloc ring of descriptors */ |
649 | size = ring->num_slots * sizeof(struct bgmac_dma_desc); | 650 | size = BGMAC_RX_RING_SLOTS * sizeof(struct bgmac_dma_desc); |
650 | ring->cpu_base = dma_zalloc_coherent(dma_dev, size, | 651 | ring->cpu_base = dma_zalloc_coherent(dma_dev, size, |
651 | &ring->dma_base, | 652 | &ring->dma_base, |
652 | GFP_KERNEL); | 653 | GFP_KERNEL); |
@@ -709,7 +710,7 @@ static int bgmac_dma_init(struct bgmac *bgmac) | |||
709 | 710 | ||
710 | ring->start = 0; | 711 | ring->start = 0; |
711 | ring->end = 0; | 712 | ring->end = 0; |
712 | for (j = 0; j < ring->num_slots; j++) { | 713 | for (j = 0; j < BGMAC_RX_RING_SLOTS; j++) { |
713 | err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]); | 714 | err = bgmac_dma_rx_skb_for_slot(bgmac, &ring->slots[j]); |
714 | if (err) | 715 | if (err) |
715 | goto error; | 716 | goto error; |
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index e45e303ebc22..db27febbb215 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h | |||
@@ -419,11 +419,10 @@ struct bgmac_dma_ring { | |||
419 | u32 start; | 419 | u32 start; |
420 | u32 end; | 420 | u32 end; |
421 | 421 | ||
422 | u16 num_slots; | ||
423 | u16 mmio_base; | ||
424 | struct bgmac_dma_desc *cpu_base; | 422 | struct bgmac_dma_desc *cpu_base; |
425 | dma_addr_t dma_base; | 423 | dma_addr_t dma_base; |
426 | u32 index_base; /* Used for unaligned rings only, otherwise 0 */ | 424 | u32 index_base; /* Used for unaligned rings only, otherwise 0 */ |
425 | u16 mmio_base; | ||
427 | bool unaligned; | 426 | bool unaligned; |
428 | 427 | ||
429 | struct bgmac_slot_info slots[BGMAC_RX_RING_SLOTS]; | 428 | struct bgmac_slot_info slots[BGMAC_RX_RING_SLOTS]; |