diff options
Diffstat (limited to 'drivers/net/ethernet/sfc')
| -rw-r--r-- | drivers/net/ethernet/sfc/efx.c | 8 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 31 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/rx.c | 8 |
3 files changed, 24 insertions, 23 deletions
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 01b99206139a..39e4cb39de29 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c | |||
| @@ -638,14 +638,16 @@ static void efx_start_datapath(struct efx_nic *efx) | |||
| 638 | EFX_MAX_FRAME_LEN(efx->net_dev->mtu) + | 638 | EFX_MAX_FRAME_LEN(efx->net_dev->mtu) + |
| 639 | efx->type->rx_buffer_padding); | 639 | efx->type->rx_buffer_padding); |
| 640 | rx_buf_len = (sizeof(struct efx_rx_page_state) + | 640 | rx_buf_len = (sizeof(struct efx_rx_page_state) + |
| 641 | EFX_PAGE_IP_ALIGN + efx->rx_dma_len); | 641 | NET_IP_ALIGN + efx->rx_dma_len); |
| 642 | if (rx_buf_len <= PAGE_SIZE) { | 642 | if (rx_buf_len <= PAGE_SIZE) { |
| 643 | efx->rx_scatter = false; | 643 | efx->rx_scatter = false; |
| 644 | efx->rx_buffer_order = 0; | 644 | efx->rx_buffer_order = 0; |
| 645 | } else if (efx->type->can_rx_scatter) { | 645 | } else if (efx->type->can_rx_scatter) { |
| 646 | BUILD_BUG_ON(EFX_RX_USR_BUF_SIZE % L1_CACHE_BYTES); | ||
| 646 | BUILD_BUG_ON(sizeof(struct efx_rx_page_state) + | 647 | BUILD_BUG_ON(sizeof(struct efx_rx_page_state) + |
| 647 | EFX_PAGE_IP_ALIGN + EFX_RX_USR_BUF_SIZE > | 648 | 2 * ALIGN(NET_IP_ALIGN + EFX_RX_USR_BUF_SIZE, |
| 648 | PAGE_SIZE / 2); | 649 | EFX_RX_BUF_ALIGNMENT) > |
| 650 | PAGE_SIZE); | ||
| 649 | efx->rx_scatter = true; | 651 | efx->rx_scatter = true; |
| 650 | efx->rx_dma_len = EFX_RX_USR_BUF_SIZE; | 652 | efx->rx_dma_len = EFX_RX_USR_BUF_SIZE; |
| 651 | efx->rx_buffer_order = 0; | 653 | efx->rx_buffer_order = 0; |
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 9bd433a095c5..39d6bd77f015 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
| @@ -72,8 +72,20 @@ | |||
| 72 | /* Maximum possible MTU the driver supports */ | 72 | /* Maximum possible MTU the driver supports */ |
| 73 | #define EFX_MAX_MTU (9 * 1024) | 73 | #define EFX_MAX_MTU (9 * 1024) |
| 74 | 74 | ||
| 75 | /* Size of an RX scatter buffer. Small enough to pack 2 into a 4K page. */ | 75 | /* Size of an RX scatter buffer. Small enough to pack 2 into a 4K page, |
| 76 | #define EFX_RX_USR_BUF_SIZE 1824 | 76 | * and should be a multiple of the cache line size. |
| 77 | */ | ||
| 78 | #define EFX_RX_USR_BUF_SIZE (2048 - 256) | ||
| 79 | |||
| 80 | /* If possible, we should ensure cache line alignment at start and end | ||
| 81 | * of every buffer. Otherwise, we just need to ensure 4-byte | ||
| 82 | * alignment of the network header. | ||
| 83 | */ | ||
| 84 | #if NET_IP_ALIGN == 0 | ||
| 85 | #define EFX_RX_BUF_ALIGNMENT L1_CACHE_BYTES | ||
| 86 | #else | ||
| 87 | #define EFX_RX_BUF_ALIGNMENT 4 | ||
| 88 | #endif | ||
| 77 | 89 | ||
| 78 | /* Forward declare Precision Time Protocol (PTP) support structure. */ | 90 | /* Forward declare Precision Time Protocol (PTP) support structure. */ |
| 79 | struct efx_ptp_data; | 91 | struct efx_ptp_data; |
| @@ -468,24 +480,11 @@ enum nic_state { | |||
| 468 | }; | 480 | }; |
| 469 | 481 | ||
| 470 | /* | 482 | /* |
| 471 | * Alignment of page-allocated RX buffers | ||
| 472 | * | ||
| 473 | * Controls the number of bytes inserted at the start of an RX buffer. | ||
| 474 | * This is the equivalent of NET_IP_ALIGN [which controls the alignment | ||
| 475 | * of the skb->head for hardware DMA]. | ||
| 476 | */ | ||
| 477 | #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS | ||
| 478 | #define EFX_PAGE_IP_ALIGN 0 | ||
| 479 | #else | ||
| 480 | #define EFX_PAGE_IP_ALIGN NET_IP_ALIGN | ||
| 481 | #endif | ||
| 482 | |||
| 483 | /* | ||
| 484 | * Alignment of the skb->head which wraps a page-allocated RX buffer | 483 | * Alignment of the skb->head which wraps a page-allocated RX buffer |
| 485 | * | 484 | * |
| 486 | * The skb allocated to wrap an rx_buffer can have this alignment. Since | 485 | * The skb allocated to wrap an rx_buffer can have this alignment. Since |
| 487 | * the data is memcpy'd from the rx_buf, it does not need to be equal to | 486 | * the data is memcpy'd from the rx_buf, it does not need to be equal to |
| 488 | * EFX_PAGE_IP_ALIGN. | 487 | * NET_IP_ALIGN. |
| 489 | */ | 488 | */ |
| 490 | #define EFX_PAGE_SKB_ALIGN 2 | 489 | #define EFX_PAGE_SKB_ALIGN 2 |
| 491 | 490 | ||
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index e73e30bac10e..a7dfe36cabf4 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c | |||
| @@ -93,8 +93,8 @@ static inline void efx_sync_rx_buffer(struct efx_nic *efx, | |||
| 93 | 93 | ||
| 94 | void efx_rx_config_page_split(struct efx_nic *efx) | 94 | void efx_rx_config_page_split(struct efx_nic *efx) |
| 95 | { | 95 | { |
| 96 | efx->rx_page_buf_step = ALIGN(efx->rx_dma_len + EFX_PAGE_IP_ALIGN, | 96 | efx->rx_page_buf_step = ALIGN(efx->rx_dma_len + NET_IP_ALIGN, |
| 97 | L1_CACHE_BYTES); | 97 | EFX_RX_BUF_ALIGNMENT); |
| 98 | efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 : | 98 | efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 : |
| 99 | ((PAGE_SIZE - sizeof(struct efx_rx_page_state)) / | 99 | ((PAGE_SIZE - sizeof(struct efx_rx_page_state)) / |
| 100 | efx->rx_page_buf_step); | 100 | efx->rx_page_buf_step); |
| @@ -188,9 +188,9 @@ static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue) | |||
| 188 | do { | 188 | do { |
| 189 | index = rx_queue->added_count & rx_queue->ptr_mask; | 189 | index = rx_queue->added_count & rx_queue->ptr_mask; |
| 190 | rx_buf = efx_rx_buffer(rx_queue, index); | 190 | rx_buf = efx_rx_buffer(rx_queue, index); |
| 191 | rx_buf->dma_addr = dma_addr + EFX_PAGE_IP_ALIGN; | 191 | rx_buf->dma_addr = dma_addr + NET_IP_ALIGN; |
| 192 | rx_buf->page = page; | 192 | rx_buf->page = page; |
| 193 | rx_buf->page_offset = page_offset + EFX_PAGE_IP_ALIGN; | 193 | rx_buf->page_offset = page_offset + NET_IP_ALIGN; |
| 194 | rx_buf->len = efx->rx_dma_len; | 194 | rx_buf->len = efx->rx_dma_len; |
| 195 | rx_buf->flags = 0; | 195 | rx_buf->flags = 0; |
| 196 | ++rx_queue->added_count; | 196 | ++rx_queue->added_count; |
