Commit 5b6262d0 authored by Ben Hutchings's avatar Ben Hutchings

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: default avatarBen Hutchings <bhutchings@solarflare.com>
parent fadac6aa
...@@ -54,9 +54,6 @@ ...@@ -54,9 +54,6 @@
#define EFX_FLUSH_INTERVAL 10 #define EFX_FLUSH_INTERVAL 10
#define EFX_FLUSH_POLL_COUNT 100 #define EFX_FLUSH_POLL_COUNT 100
/* Size and alignment of special buffers (4KB) */
#define EFX_BUF_SIZE 4096
/* Depth of RX flush request fifo */ /* Depth of RX flush request fifo */
#define EFX_RX_FLUSH_COUNT 4 #define EFX_RX_FLUSH_COUNT 4
...@@ -196,7 +193,7 @@ efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer) ...@@ -196,7 +193,7 @@ efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer)
/* Write buffer descriptors to NIC */ /* Write buffer descriptors to NIC */
for (i = 0; i < buffer->entries; i++) { for (i = 0; i < buffer->entries; i++) {
index = buffer->index + i; index = buffer->index + i;
dma_addr = buffer->dma_addr + (i * 4096); dma_addr = buffer->dma_addr + (i * EFX_BUF_SIZE);
netif_dbg(efx, probe, efx->net_dev, netif_dbg(efx, probe, efx->net_dev,
"mapping special buffer %d at %llx\n", "mapping special buffer %d at %llx\n",
index, (unsigned long long)dma_addr); index, (unsigned long long)dma_addr);
......
...@@ -65,6 +65,11 @@ enum { ...@@ -65,6 +65,11 @@ enum {
#define FALCON_GMAC_LOOPBACKS \ #define FALCON_GMAC_LOOPBACKS \
(1 << LOOPBACK_GMAC) (1 << LOOPBACK_GMAC)
/* Alignment of PCIe DMA boundaries (4KB) */
#define EFX_PAGE_SIZE 4096
/* Size and alignment of buffer table entries (same) */
#define EFX_BUF_SIZE EFX_PAGE_SIZE
/** /**
* struct falcon_board_type - board operations and type information * struct falcon_board_type - board operations and type information
* @id: Board type id, as found in NVRAM * @id: Board type id, as found in NVRAM
......
...@@ -110,7 +110,7 @@ efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr) ...@@ -110,7 +110,7 @@ efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr)
* little benefit from using descriptors that cross those * little benefit from using descriptors that cross those
* boundaries and we keep things simple by not doing so. * boundaries and we keep things simple by not doing so.
*/ */
unsigned len = (~dma_addr & 0xfff) + 1; unsigned len = (~dma_addr & (EFX_PAGE_SIZE - 1)) + 1;
/* Work around hardware bug for unaligned buffers. */ /* Work around hardware bug for unaligned buffers. */
if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf)) if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment