From 3cb7cd8a0d2eafe6500940d55b93d067ee897271 Mon Sep 17 00:00:00 2001 From: Maxim Uvarov Date: Wed, 14 Nov 2012 08:22:39 -0800 Subject: [PATCH] sfc: Replace some literal constants with EFX_PAGE_SIZE/EFX_BUF_SIZE Mainline commit 5b6262d0ccf759a16fabe11d904a2531125a4b71 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 Orabug: 14769994 Signed-off-by: Chuck Anderson (cherry picked from commit 0d66c9ee8813a35eb5ce78ac0b2fb0286cd088ea) Conflicts: drivers/net/sfc/nic.h --- drivers/net/sfc/nic.c | 5 +---- drivers/net/sfc/tx.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/sfc/nic.c b/drivers/net/sfc/nic.c index 5ac9fa2cd3bc..2d46567b4539 100644 --- a/drivers/net/sfc/nic.c +++ b/drivers/net/sfc/nic.c @@ -53,9 +53,6 @@ #define EFX_FLUSH_INTERVAL 10 #define EFX_FLUSH_POLL_COUNT 100 -/* Size and alignment of special buffers (4KB) */ -#define EFX_BUF_SIZE 4096 - /* Depth of RX flush request fifo */ #define EFX_RX_FLUSH_COUNT 4 @@ -195,7 +192,7 @@ efx_init_special_buffer(struct efx_nic *efx, struct efx_special_buffer *buffer) /* Write buffer descriptors to NIC */ for (i = 0; i < buffer->entries; 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, "mapping special buffer %d at %llx\n", index, (unsigned long long)dma_addr); diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c index aa51c0957113..b7809f0d8959 100644 --- a/drivers/net/sfc/tx.c +++ b/drivers/net/sfc/tx.c @@ -106,7 +106,7 @@ efx_max_tx_len(struct efx_nic *efx, dma_addr_t dma_addr) * little benefit from using descriptors that cross those * 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. */ if (EFX_WORKAROUND_5391(efx) && (dma_addr & 0xf)) -- 2.50.1