aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-10-23 04:31:20 -0400
committerDavid S. Miller <davem@davemloft.net>2009-10-24 07:27:07 -0400
commit63f1988419ccaa544d1d31aadc1dd309f6471ffe (patch)
treed973e7c103b9453063d02c8895f629c4ca692a33 /drivers/net/sfc
parent6d51d307509f98f070688b4bff1d0f7462c4d3ec (diff)
sfc: Move all TX DMA length limiting into tx.c
Replace the duplicated logic in efx_enqueue_skb() and efx_tx_queue_insert() with an inline function, efx_max_tx_len(). Remove the failed attempt at abstracting hardware-specifics and put all the magic numbers in efx_max_tx_len(). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc')
-rw-r--r--drivers/net/sfc/falcon.c7
-rw-r--r--drivers/net/sfc/net_driver.h4
-rw-r--r--drivers/net/sfc/tx.c37
-rw-r--r--drivers/net/sfc/workarounds.h2
4 files changed, 25 insertions, 25 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 47507b67ba80..34b475e9b29d 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -127,9 +127,6 @@ MODULE_PARM_DESC(rx_xon_thresh_bytes, "RX fifo XON threshold");
127 ************************************************************************** 127 **************************************************************************
128 */ 128 */
129 129
130/* TX DMA length mask (13-bit) */
131#define FALCON_TX_DMA_MASK (4096 - 1)
132
133/* Size and alignment of special buffers (4KB) */ 130/* Size and alignment of special buffers (4KB) */
134#define FALCON_BUF_SIZE 4096 131#define FALCON_BUF_SIZE 4096
135 132
@@ -3146,8 +3143,6 @@ struct efx_nic_type falcon_a_nic_type = {
3146 .evq_ptr_tbl_base = FR_AA_EVQ_PTR_TBL_KER, 3143 .evq_ptr_tbl_base = FR_AA_EVQ_PTR_TBL_KER,
3147 .evq_rptr_tbl_base = FR_AA_EVQ_RPTR_KER, 3144 .evq_rptr_tbl_base = FR_AA_EVQ_RPTR_KER,
3148 .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH), 3145 .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH),
3149 .tx_dma_mask = FALCON_TX_DMA_MASK,
3150 .bug5391_mask = 0xf,
3151 .rx_buffer_padding = 0x24, 3146 .rx_buffer_padding = 0x24,
3152 .max_interrupt_mode = EFX_INT_MODE_MSI, 3147 .max_interrupt_mode = EFX_INT_MODE_MSI,
3153 .phys_addr_channels = 4, 3148 .phys_addr_channels = 4,
@@ -3167,8 +3162,6 @@ struct efx_nic_type falcon_b_nic_type = {
3167 .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL, 3162 .evq_ptr_tbl_base = FR_BZ_EVQ_PTR_TBL,
3168 .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR, 3163 .evq_rptr_tbl_base = FR_BZ_EVQ_RPTR,
3169 .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH), 3164 .max_dma_mask = DMA_BIT_MASK(FSF_AZ_TX_KER_BUF_ADDR_WIDTH),
3170 .tx_dma_mask = FALCON_TX_DMA_MASK,
3171 .bug5391_mask = 0,
3172 .rx_buffer_padding = 0, 3165 .rx_buffer_padding = 0,
3173 .max_interrupt_mode = EFX_INT_MODE_MSIX, 3166 .max_interrupt_mode = EFX_INT_MODE_MSIX,
3174 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy 3167 .phys_addr_channels = 32, /* Hardware limit is 64, but the legacy
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 3afadc621a81..91d8952e7884 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -870,8 +870,6 @@ static inline const char *efx_dev_name(struct efx_nic *efx)
870 * @evq_ptr_tbl_base: Event queue pointer table base address 870 * @evq_ptr_tbl_base: Event queue pointer table base address
871 * @evq_rptr_tbl_base: Event queue read-pointer table base address 871 * @evq_rptr_tbl_base: Event queue read-pointer table base address
872 * @max_dma_mask: Maximum possible DMA mask 872 * @max_dma_mask: Maximum possible DMA mask
873 * @tx_dma_mask: TX DMA mask
874 * @bug5391_mask: Address mask for bug 5391 workaround
875 * @rx_buffer_padding: Padding added to each RX buffer 873 * @rx_buffer_padding: Padding added to each RX buffer
876 * @max_interrupt_mode: Highest capability interrupt mode supported 874 * @max_interrupt_mode: Highest capability interrupt mode supported
877 * from &enum efx_init_mode. 875 * from &enum efx_init_mode.
@@ -888,8 +886,6 @@ struct efx_nic_type {
888 unsigned int evq_rptr_tbl_base; 886 unsigned int evq_rptr_tbl_base;
889 887
890 u64 max_dma_mask; 888 u64 max_dma_mask;
891 unsigned int tx_dma_mask;
892 unsigned bug5391_mask;
893 889
894 unsigned int rx_buffer_padding; 890 unsigned int rx_buffer_padding;
895 unsigned int max_interrupt_mode; 891 unsigned int max_interrupt_mode;
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index ae554eec0563..303919a34df6 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -124,6 +124,24 @@ static void efx_tsoh_free(struct efx_tx_queue *tx_queue,
124} 124}
125 125
126 126
127static inline unsigned
128efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr)
129{
130 /* Depending on the NIC revision, we can use descriptor
131 * lengths up to 8K or 8K-1. However, since PCI Express
132 * devices must split read requests at 4K boundaries, there is
133 * little benefit from using descriptors that cross those
134 * boundaries and we keep things simple by not doing so.
135 */
136 unsigned len = (~dma_addr & 0xfff) + 1;
137
138 /* Work around hardware bug for unaligned buffers. */
139 if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf))
140 len = min_t(unsigned, len, 512 - (dma_addr & 0xf));
141
142 return len;
143}
144
127/* 145/*
128 * Add a socket buffer to a TX queue 146 * Add a socket buffer to a TX queue
129 * 147 *
@@ -146,7 +164,7 @@ static netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue,
146 skb_frag_t *fragment; 164 skb_frag_t *fragment;
147 struct page *page; 165 struct page *page;
148 int page_offset; 166 int page_offset;
149 unsigned int len, unmap_len = 0, fill_level, insert_ptr, misalign; 167 unsigned int len, unmap_len = 0, fill_level, insert_ptr;
150 dma_addr_t dma_addr, unmap_addr = 0; 168 dma_addr_t dma_addr, unmap_addr = 0;
151 unsigned int dma_len; 169 unsigned int dma_len;
152 bool unmap_single; 170 bool unmap_single;
@@ -223,14 +241,10 @@ static netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue,
223 EFX_BUG_ON_PARANOID(!buffer->continuation); 241 EFX_BUG_ON_PARANOID(!buffer->continuation);
224 EFX_BUG_ON_PARANOID(buffer->unmap_len); 242 EFX_BUG_ON_PARANOID(buffer->unmap_len);
225 243
226 dma_len = (((~dma_addr) & efx->type->tx_dma_mask) + 1); 244 dma_len = efx_max_tx_len(efx, dma_addr);
227 if (likely(dma_len > len)) 245 if (likely(dma_len >= len))
228 dma_len = len; 246 dma_len = len;
229 247
230 misalign = (unsigned)dma_addr & efx->type->bug5391_mask;
231 if (misalign && dma_len + misalign > 512)
232 dma_len = 512 - misalign;
233
234 /* Fill out per descriptor fields */ 248 /* Fill out per descriptor fields */
235 buffer->len = dma_len; 249 buffer->len = dma_len;
236 buffer->dma_addr = dma_addr; 250 buffer->dma_addr = dma_addr;
@@ -703,7 +717,7 @@ static int efx_tx_queue_insert(struct efx_tx_queue *tx_queue,
703{ 717{
704 struct efx_tx_buffer *buffer; 718 struct efx_tx_buffer *buffer;
705 struct efx_nic *efx = tx_queue->efx; 719 struct efx_nic *efx = tx_queue->efx;
706 unsigned dma_len, fill_level, insert_ptr, misalign; 720 unsigned dma_len, fill_level, insert_ptr;
707 int q_space; 721 int q_space;
708 722
709 EFX_BUG_ON_PARANOID(len <= 0); 723 EFX_BUG_ON_PARANOID(len <= 0);
@@ -752,12 +766,7 @@ static int efx_tx_queue_insert(struct efx_tx_queue *tx_queue,
752 766
753 buffer->dma_addr = dma_addr; 767 buffer->dma_addr = dma_addr;
754 768
755 /* Ensure we do not cross a boundary unsupported by H/W */ 769 dma_len = efx_max_tx_len(efx, dma_addr);
756 dma_len = (~dma_addr & efx->type->tx_dma_mask) + 1;
757
758 misalign = (unsigned)dma_addr & efx->type->bug5391_mask;
759 if (misalign && dma_len + misalign > 512)
760 dma_len = 512 - misalign;
761 770
762 /* If there is enough space to send then do so */ 771 /* If there is enough space to send then do so */
763 if (dma_len >= len) 772 if (dma_len >= len)
diff --git a/drivers/net/sfc/workarounds.h b/drivers/net/sfc/workarounds.h
index c821c15445a0..325029949488 100644
--- a/drivers/net/sfc/workarounds.h
+++ b/drivers/net/sfc/workarounds.h
@@ -41,6 +41,8 @@
41 41
42/* Spurious parity errors in TSORT buffers */ 42/* Spurious parity errors in TSORT buffers */
43#define EFX_WORKAROUND_5129 EFX_WORKAROUND_FALCON_A 43#define EFX_WORKAROUND_5129 EFX_WORKAROUND_FALCON_A
44/* Unaligned read request >512 bytes after aligning may break TSORT */
45#define EFX_WORKAROUND_5391 EFX_WORKAROUND_FALCON_A
44/* iSCSI parsing errors */ 46/* iSCSI parsing errors */
45#define EFX_WORKAROUND_5583 EFX_WORKAROUND_FALCON_A 47#define EFX_WORKAROUND_5583 EFX_WORKAROUND_FALCON_A
46/* RX events go missing */ 48/* RX events go missing */