From a2ce454c22b9026dd5413effc491f6cc3dd20b3d Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Tue, 21 Apr 2020 14:38:21 -0700 Subject: [PATCH] Add log_desc_block_size to driver --- modules/mqnic/mqnic.h | 3 +++ modules/mqnic/mqnic_rx.c | 10 +++++++--- modules/mqnic/mqnic_tx.c | 10 +++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/mqnic/mqnic.h b/modules/mqnic/mqnic.h index 17a9940f2..81b6375a6 100644 --- a/modules/mqnic/mqnic.h +++ b/modules/mqnic/mqnic.h @@ -153,6 +153,9 @@ struct mqnic_ring { u32 mtu; u32 page_order; + u32 desc_block_size; + u32 log_desc_block_size; + size_t buf_size; u8 *buf; dma_addr_t buf_dma_addr; diff --git a/modules/mqnic/mqnic_rx.c b/modules/mqnic/mqnic_rx.c index 4efbe3348..a6afa17e1 100644 --- a/modules/mqnic/mqnic_rx.c +++ b/modules/mqnic/mqnic_rx.c @@ -50,6 +50,10 @@ int mqnic_create_rx_ring(struct mqnic_priv *priv, struct mqnic_ring **ring_ptr, ring->size_mask = ring->size-1; ring->stride = roundup_pow_of_two(stride); + ring->desc_block_size = ring->stride/MQNIC_DESC_SIZE; + ring->log_desc_block_size = ring->desc_block_size < 2 ? 0 : ilog2(ring->desc_block_size-1)+1; + ring->desc_block_size = 1 << ring->log_desc_block_size; + ring->rx_info = kvzalloc(sizeof(*ring->rx_info)*ring->size, GFP_KERNEL); if (!ring->rx_info) { @@ -87,7 +91,7 @@ int mqnic_create_rx_ring(struct mqnic_priv *priv, struct mqnic_ring **ring_ptr, iowrite32(ring->head_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_HEAD_PTR_REG); iowrite32(ring->tail_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_TAIL_PTR_REG); // set size - iowrite32(ilog2(ring->size), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); + iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); *ring_ptr = ring; return 0; @@ -130,7 +134,7 @@ int mqnic_activate_rx_ring(struct mqnic_priv *priv, struct mqnic_ring *ring, int iowrite32(ring->head_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_HEAD_PTR_REG); iowrite32(ring->tail_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_TAIL_PTR_REG); // set size and activate queue - iowrite32(ilog2(ring->size) | MQNIC_QUEUE_ACTIVE_MASK, ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); + iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8) | MQNIC_QUEUE_ACTIVE_MASK, ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); mqnic_refill_rx_buffers(priv, ring); @@ -140,7 +144,7 @@ int mqnic_activate_rx_ring(struct mqnic_priv *priv, struct mqnic_ring *ring, int void mqnic_deactivate_rx_ring(struct mqnic_priv *priv, struct mqnic_ring *ring) { // deactivate queue - iowrite32(ilog2(ring->size), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); + iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); } bool mqnic_is_rx_ring_empty(const struct mqnic_ring *ring) diff --git a/modules/mqnic/mqnic_tx.c b/modules/mqnic/mqnic_tx.c index 9eadfd96a..26e2d1285 100644 --- a/modules/mqnic/mqnic_tx.c +++ b/modules/mqnic/mqnic_tx.c @@ -52,6 +52,10 @@ int mqnic_create_tx_ring(struct mqnic_priv *priv, struct mqnic_ring **ring_ptr, ring->size_mask = ring->size-1; ring->stride = roundup_pow_of_two(stride); + ring->desc_block_size = ring->stride/MQNIC_DESC_SIZE; + ring->log_desc_block_size = ring->desc_block_size < 2 ? 0 : ilog2(ring->desc_block_size-1)+1; + ring->desc_block_size = 1 << ring->log_desc_block_size; + ring->tx_info = kvzalloc(sizeof(*ring->tx_info)*ring->size, GFP_KERNEL); if (!ring->tx_info) { @@ -89,7 +93,7 @@ int mqnic_create_tx_ring(struct mqnic_priv *priv, struct mqnic_ring **ring_ptr, iowrite32(ring->head_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_HEAD_PTR_REG); iowrite32(ring->tail_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_TAIL_PTR_REG); // set size - iowrite32(ilog2(ring->size), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); + iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); *ring_ptr = ring; return 0; @@ -132,7 +136,7 @@ int mqnic_activate_tx_ring(struct mqnic_priv *priv, struct mqnic_ring *ring, int iowrite32(ring->head_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_HEAD_PTR_REG); iowrite32(ring->tail_ptr & ring->hw_ptr_mask, ring->hw_addr+MQNIC_QUEUE_TAIL_PTR_REG); // set size and activate queue - iowrite32(ilog2(ring->size) | MQNIC_QUEUE_ACTIVE_MASK, ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); + iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8) | MQNIC_QUEUE_ACTIVE_MASK, ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); return 0; } @@ -140,7 +144,7 @@ int mqnic_activate_tx_ring(struct mqnic_priv *priv, struct mqnic_ring *ring, int void mqnic_deactivate_tx_ring(struct mqnic_priv *priv, struct mqnic_ring *ring) { // deactivate queue - iowrite32(ilog2(ring->size), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); + iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8), ring->hw_addr+MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG); } bool mqnic_is_tx_ring_empty(const struct mqnic_ring *ring)