diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2012-02-02 16:21:15 -0500 |
---|---|---|
committer | Ben Hutchings <bhutchings@solarflare.com> | 2012-02-13 18:40:49 -0500 |
commit | 5b6262d0ccf759a16fabe11d904a2531125a4b71 (patch) | |
tree | 812b2cab8bbeb0569909d8646ec864bef11c40c7 | |
parent | fadac6aae1b8d9344beaa18aa9035869d773fd98 (diff) |
sfc: Replace some literal constants with EFX_PAGE_SIZE/EFX_BUF_SIZE
The 'page size' for PCIe DMA, i.e. the alignment of boundaries at
which DMA must be broken, is 4KB. Name this value as EFX_PAGE_SIZE
and use it in efx_max_tx_len(). Redefine EFX_BUF_SIZE as
EFX_PAGE_SIZE since its value is also a result of that requirement,
and use it in efx_init_special_buffer().
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r-- | drivers/net/ethernet/sfc/nic.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/nic.h | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/tx.c | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c index a43d1ca270c0..dd50c4f73a9d 100644 --- a/drivers/net/ethernet/sfc/nic.c +++ b/drivers/net/ethernet/sfc/nic.c | |||
@@ -54,9 +54,6 @@ | |||
54 | #define EFX_FLUSH_INTERVAL 10 | 54 | #define EFX_FLUSH_INTERVAL 10 |
55 | #define EFX_FLUSH_POLL_COUNT 100 | 55 | #define EFX_FLUSH_POLL_COUNT 100 |
56 | 56 | ||
57 | /* Size and alignment of special buffers (4KB) */ | ||
58 | #define EFX_BUF_SIZE 4096 | ||
59 | |||
60 | /* Depth of RX flush request fifo */ | 57 | /* Depth of RX flush request fifo */ |
61 | #define EFX_RX_FLUSH_COUNT 4 | 58 | #define EFX_RX_FLUSH_COUNT 4 |
62 | 59 | ||
@@ -196,7 +193,7 @@ efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer) | |||
196 | /* Write buffer descriptors to NIC */ | 193 | /* Write buffer descriptors to NIC */ |
197 | for (i = 0; i < buffer->entries; i++) { | 194 | for (i = 0; i < buffer->entries; i++) { |
198 | index = buffer->index + i; | 195 | index = buffer->index + i; |
199 | dma_addr = buffer->dma_addr + (i * 4096); | 196 | dma_addr = buffer->dma_addr + (i * EFX_BUF_SIZE); |
200 | netif_dbg(efx, probe, efx->net_dev, | 197 | netif_dbg(efx, probe, efx->net_dev, |
201 | "mapping special buffer %d at %llx\n", | 198 | "mapping special buffer %d at %llx\n", |
202 | index, (unsigned long long)dma_addr); | 199 | index, (unsigned long long)dma_addr); |
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 905a1877d603..4f9d18ac92fe 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h | |||
@@ -65,6 +65,11 @@ enum { | |||
65 | #define FALCON_GMAC_LOOPBACKS \ | 65 | #define FALCON_GMAC_LOOPBACKS \ |
66 | (1 << LOOPBACK_GMAC) | 66 | (1 << LOOPBACK_GMAC) |
67 | 67 | ||
68 | /* Alignment of PCIe DMA boundaries (4KB) */ | ||
69 | #define EFX_PAGE_SIZE 4096 | ||
70 | /* Size and alignment of buffer table entries (same) */ | ||
71 | #define EFX_BUF_SIZE EFX_PAGE_SIZE | ||
72 | |||
68 | /** | 73 | /** |
69 | * struct falcon_board_type - board operations and type information | 74 | * struct falcon_board_type - board operations and type information |
70 | * @id: Board type id, as found in NVRAM | 75 | * @id: Board type id, as found in NVRAM |
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c index 5cb81fa3fcbd..a096e287e95f 100644 --- a/drivers/net/ethernet/sfc/tx.c +++ b/drivers/net/ethernet/sfc/tx.c | |||
@@ -110,7 +110,7 @@ efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr) | |||
110 | * little benefit from using descriptors that cross those | 110 | * little benefit from using descriptors that cross those |
111 | * boundaries and we keep things simple by not doing so. | 111 | * boundaries and we keep things simple by not doing so. |
112 | */ | 112 | */ |
113 | unsigned len = (~dma_addr & 0xfff) + 1; | 113 | unsigned len = (~dma_addr & (EFX_PAGE_SIZE - 1)) + 1; |
114 | 114 | ||
115 | /* Work around hardware bug for unaligned buffers. */ | 115 | /* Work around hardware bug for unaligned buffers. */ |
116 | if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf)) | 116 | if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf)) |