diff options
author | Lendacky, Thomas <Thomas.Lendacky@amd.com> | 2015-01-16 13:46:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-16 22:24:20 -0500 |
commit | 270894e7dc7afad8fb79592fe02aa05e604ddfc8 (patch) | |
tree | a78dafeccd2e57f9734088afea99145b61874c58 | |
parent | 916102c6664dcfc11f76ab1da27882aee1d01d8c (diff) |
amd-xgbe: Simplify the Rx desciptor ring tracking
Make the Rx descriptor ring processing similar to the Tx descriptor
ring processing. Remove the realloc_index and realloc_threshold
variables and base everything on the current index counter and the
dirty index counter.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/amd/xgbe/xgbe-desc.c | 32 | ||||
-rw-r--r-- | drivers/net/ethernet/amd/xgbe/xgbe-drv.c | 25 | ||||
-rw-r--r-- | drivers/net/ethernet/amd/xgbe/xgbe.h | 11 |
3 files changed, 25 insertions, 43 deletions
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c index a50891f52197..d81fc6bd4759 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-desc.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-desc.c | |||
@@ -422,7 +422,6 @@ static void xgbe_wrapper_rx_descriptor_init(struct xgbe_prv_data *pdata) | |||
422 | 422 | ||
423 | ring->cur = 0; | 423 | ring->cur = 0; |
424 | ring->dirty = 0; | 424 | ring->dirty = 0; |
425 | memset(&ring->rx, 0, sizeof(ring->rx)); | ||
426 | 425 | ||
427 | hw_if->rx_desc_init(channel); | 426 | hw_if->rx_desc_init(channel); |
428 | } | 427 | } |
@@ -621,35 +620,6 @@ err_out: | |||
621 | return 0; | 620 | return 0; |
622 | } | 621 | } |
623 | 622 | ||
624 | static void xgbe_realloc_rx_buffer(struct xgbe_channel *channel) | ||
625 | { | ||
626 | struct xgbe_prv_data *pdata = channel->pdata; | ||
627 | struct xgbe_hw_if *hw_if = &pdata->hw_if; | ||
628 | struct xgbe_ring *ring = channel->rx_ring; | ||
629 | struct xgbe_ring_data *rdata; | ||
630 | int i; | ||
631 | |||
632 | DBGPR("-->xgbe_realloc_rx_buffer: rx_ring->rx.realloc_index = %u\n", | ||
633 | ring->rx.realloc_index); | ||
634 | |||
635 | for (i = 0; i < ring->dirty; i++) { | ||
636 | rdata = XGBE_GET_DESC_DATA(ring, ring->rx.realloc_index); | ||
637 | |||
638 | /* Reset rdata values */ | ||
639 | xgbe_unmap_rdata(pdata, rdata); | ||
640 | |||
641 | if (xgbe_map_rx_buffer(pdata, ring, rdata)) | ||
642 | break; | ||
643 | |||
644 | hw_if->rx_desc_reset(rdata); | ||
645 | |||
646 | ring->rx.realloc_index++; | ||
647 | } | ||
648 | ring->dirty = 0; | ||
649 | |||
650 | DBGPR("<--xgbe_realloc_rx_buffer\n"); | ||
651 | } | ||
652 | |||
653 | void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if) | 623 | void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if) |
654 | { | 624 | { |
655 | DBGPR("-->xgbe_init_function_ptrs_desc\n"); | 625 | DBGPR("-->xgbe_init_function_ptrs_desc\n"); |
@@ -657,7 +627,7 @@ void xgbe_init_function_ptrs_desc(struct xgbe_desc_if *desc_if) | |||
657 | desc_if->alloc_ring_resources = xgbe_alloc_ring_resources; | 627 | desc_if->alloc_ring_resources = xgbe_alloc_ring_resources; |
658 | desc_if->free_ring_resources = xgbe_free_ring_resources; | 628 | desc_if->free_ring_resources = xgbe_free_ring_resources; |
659 | desc_if->map_tx_skb = xgbe_map_tx_skb; | 629 | desc_if->map_tx_skb = xgbe_map_tx_skb; |
660 | desc_if->realloc_rx_buffer = xgbe_realloc_rx_buffer; | 630 | desc_if->map_rx_buffer = xgbe_map_rx_buffer; |
661 | desc_if->unmap_rdata = xgbe_unmap_rdata; | 631 | desc_if->unmap_rdata = xgbe_unmap_rdata; |
662 | desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init; | 632 | desc_if->wrapper_tx_desc_init = xgbe_wrapper_tx_descriptor_init; |
663 | desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init; | 633 | desc_if->wrapper_rx_desc_init = xgbe_wrapper_rx_descriptor_init; |
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c index bdb373c87050..e2f560ff5104 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c | |||
@@ -225,6 +225,11 @@ static inline unsigned int xgbe_tx_avail_desc(struct xgbe_ring *ring) | |||
225 | return (ring->rdesc_count - (ring->cur - ring->dirty)); | 225 | return (ring->rdesc_count - (ring->cur - ring->dirty)); |
226 | } | 226 | } |
227 | 227 | ||
228 | static inline unsigned int xgbe_rx_dirty_desc(struct xgbe_ring *ring) | ||
229 | { | ||
230 | return (ring->cur - ring->dirty); | ||
231 | } | ||
232 | |||
228 | static int xgbe_maybe_stop_tx_queue(struct xgbe_channel *channel, | 233 | static int xgbe_maybe_stop_tx_queue(struct xgbe_channel *channel, |
229 | struct xgbe_ring *ring, unsigned int count) | 234 | struct xgbe_ring *ring, unsigned int count) |
230 | { | 235 | { |
@@ -1775,15 +1780,28 @@ struct net_device_ops *xgbe_get_netdev_ops(void) | |||
1775 | static void xgbe_rx_refresh(struct xgbe_channel *channel) | 1780 | static void xgbe_rx_refresh(struct xgbe_channel *channel) |
1776 | { | 1781 | { |
1777 | struct xgbe_prv_data *pdata = channel->pdata; | 1782 | struct xgbe_prv_data *pdata = channel->pdata; |
1783 | struct xgbe_hw_if *hw_if = &pdata->hw_if; | ||
1778 | struct xgbe_desc_if *desc_if = &pdata->desc_if; | 1784 | struct xgbe_desc_if *desc_if = &pdata->desc_if; |
1779 | struct xgbe_ring *ring = channel->rx_ring; | 1785 | struct xgbe_ring *ring = channel->rx_ring; |
1780 | struct xgbe_ring_data *rdata; | 1786 | struct xgbe_ring_data *rdata; |
1781 | 1787 | ||
1782 | desc_if->realloc_rx_buffer(channel); | 1788 | while (ring->dirty != ring->cur) { |
1789 | rdata = XGBE_GET_DESC_DATA(ring, ring->dirty); | ||
1790 | |||
1791 | /* Reset rdata values */ | ||
1792 | desc_if->unmap_rdata(pdata, rdata); | ||
1793 | |||
1794 | if (desc_if->map_rx_buffer(pdata, ring, rdata)) | ||
1795 | break; | ||
1796 | |||
1797 | hw_if->rx_desc_reset(rdata); | ||
1798 | |||
1799 | ring->dirty++; | ||
1800 | } | ||
1783 | 1801 | ||
1784 | /* Update the Rx Tail Pointer Register with address of | 1802 | /* Update the Rx Tail Pointer Register with address of |
1785 | * the last cleaned entry */ | 1803 | * the last cleaned entry */ |
1786 | rdata = XGBE_GET_DESC_DATA(ring, ring->rx.realloc_index - 1); | 1804 | rdata = XGBE_GET_DESC_DATA(ring, ring->dirty - 1); |
1787 | XGMAC_DMA_IOWRITE(channel, DMA_CH_RDTR_LO, | 1805 | XGMAC_DMA_IOWRITE(channel, DMA_CH_RDTR_LO, |
1788 | lower_32_bits(rdata->rdesc_dma)); | 1806 | lower_32_bits(rdata->rdesc_dma)); |
1789 | } | 1807 | } |
@@ -1933,7 +1951,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) | |||
1933 | read_again: | 1951 | read_again: |
1934 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); | 1952 | rdata = XGBE_GET_DESC_DATA(ring, ring->cur); |
1935 | 1953 | ||
1936 | if (ring->dirty > (XGBE_RX_DESC_CNT >> 3)) | 1954 | if (xgbe_rx_dirty_desc(ring) > (XGBE_RX_DESC_CNT >> 3)) |
1937 | xgbe_rx_refresh(channel); | 1955 | xgbe_rx_refresh(channel); |
1938 | 1956 | ||
1939 | if (hw_if->dev_read(channel)) | 1957 | if (hw_if->dev_read(channel)) |
@@ -1941,7 +1959,6 @@ read_again: | |||
1941 | 1959 | ||
1942 | received++; | 1960 | received++; |
1943 | ring->cur++; | 1961 | ring->cur++; |
1944 | ring->dirty++; | ||
1945 | 1962 | ||
1946 | incomplete = XGMAC_GET_BITS(packet->attributes, | 1963 | incomplete = XGMAC_GET_BITS(packet->attributes, |
1947 | RX_PACKET_ATTRIBUTES, | 1964 | RX_PACKET_ATTRIBUTES, |
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe.h b/drivers/net/ethernet/amd/xgbe/xgbe.h index 2af6affc35a7..e6ee64e1d6ec 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe.h +++ b/drivers/net/ethernet/amd/xgbe/xgbe.h | |||
@@ -361,8 +361,7 @@ struct xgbe_ring { | |||
361 | * cur - Tx: index of descriptor to be used for current transfer | 361 | * cur - Tx: index of descriptor to be used for current transfer |
362 | * Rx: index of descriptor to check for packet availability | 362 | * Rx: index of descriptor to check for packet availability |
363 | * dirty - Tx: index of descriptor to check for transfer complete | 363 | * dirty - Tx: index of descriptor to check for transfer complete |
364 | * Rx: count of descriptors in which a packet has been received | 364 | * Rx: index of descriptor to check for buffer reallocation |
365 | * (used with skb_realloc_index to refresh the ring) | ||
366 | */ | 365 | */ |
367 | unsigned int cur; | 366 | unsigned int cur; |
368 | unsigned int dirty; | 367 | unsigned int dirty; |
@@ -377,11 +376,6 @@ struct xgbe_ring { | |||
377 | unsigned short cur_mss; | 376 | unsigned short cur_mss; |
378 | unsigned short cur_vlan_ctag; | 377 | unsigned short cur_vlan_ctag; |
379 | } tx; | 378 | } tx; |
380 | |||
381 | struct { | ||
382 | unsigned int realloc_index; | ||
383 | unsigned int realloc_threshold; | ||
384 | } rx; | ||
385 | }; | 379 | }; |
386 | } ____cacheline_aligned; | 380 | } ____cacheline_aligned; |
387 | 381 | ||
@@ -596,7 +590,8 @@ struct xgbe_desc_if { | |||
596 | int (*alloc_ring_resources)(struct xgbe_prv_data *); | 590 | int (*alloc_ring_resources)(struct xgbe_prv_data *); |
597 | void (*free_ring_resources)(struct xgbe_prv_data *); | 591 | void (*free_ring_resources)(struct xgbe_prv_data *); |
598 | int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *); | 592 | int (*map_tx_skb)(struct xgbe_channel *, struct sk_buff *); |
599 | void (*realloc_rx_buffer)(struct xgbe_channel *); | 593 | int (*map_rx_buffer)(struct xgbe_prv_data *, struct xgbe_ring *, |
594 | struct xgbe_ring_data *); | ||
600 | void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *); | 595 | void (*unmap_rdata)(struct xgbe_prv_data *, struct xgbe_ring_data *); |
601 | void (*wrapper_tx_desc_init)(struct xgbe_prv_data *); | 596 | void (*wrapper_tx_desc_init)(struct xgbe_prv_data *); |
602 | void (*wrapper_rx_desc_init)(struct xgbe_prv_data *); | 597 | void (*wrapper_rx_desc_init)(struct xgbe_prv_data *); |