1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-16 08:12:53 +08:00

Track ring active state

This commit is contained in:
Alex Forencich 2021-12-10 21:04:52 -08:00
parent c9de7d24d0
commit 5e65a384e2
5 changed files with 43 additions and 4 deletions

View File

@ -200,6 +200,7 @@ struct mqnic_ring {
struct net_device *ndev;
struct mqnic_priv *priv;
int ring_index;
int active;
u32 hw_ptr_mask;
u8 __iomem *hw_addr;
@ -225,6 +226,7 @@ struct mqnic_cq_ring {
struct napi_struct napi;
int ring_index;
int eq_index;
int active;
void (*handler)(struct mqnic_cq_ring *ring);
@ -251,6 +253,7 @@ struct mqnic_eq_ring {
struct mqnic_priv *priv;
int ring_index;
int int_index;
int active;
int irq;

View File

@ -50,6 +50,7 @@ int mqnic_create_cq_ring(struct mqnic_priv *priv, struct mqnic_cq_ring **ring_pt
ring->priv = priv;
ring->ring_index = index;
ring->active = 0;
ring->size = roundup_pow_of_two(size);
ring->size_mask = ring->size - 1;
@ -98,7 +99,8 @@ void mqnic_destroy_cq_ring(struct mqnic_cq_ring **ring_ptr)
struct mqnic_cq_ring *ring = *ring_ptr;
*ring_ptr = NULL;
mqnic_deactivate_cq_ring(ring);
if (ring->active)
mqnic_deactivate_cq_ring(ring);
dma_free_coherent(ring->priv->dev, ring->buf_size, ring->buf, ring->buf_dma_addr);
kfree(ring);
@ -106,6 +108,9 @@ void mqnic_destroy_cq_ring(struct mqnic_cq_ring **ring_ptr)
int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, int eq_index)
{
if (ring->active)
mqnic_deactivate_cq_ring(ring);
ring->eq_index = eq_index;
// deactivate queue
@ -122,6 +127,8 @@ int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, int eq_index)
iowrite32(ilog2(ring->size) | MQNIC_CPL_QUEUE_ACTIVE_MASK,
ring->hw_addr + MQNIC_CPL_QUEUE_ACTIVE_LOG_SIZE_REG);
ring->active = 1;
return 0;
}
@ -131,6 +138,8 @@ void mqnic_deactivate_cq_ring(struct mqnic_cq_ring *ring)
iowrite32(ilog2(ring->size), ring->hw_addr + MQNIC_CPL_QUEUE_ACTIVE_LOG_SIZE_REG);
// disarm queue
iowrite32(ring->eq_index, ring->hw_addr + MQNIC_CPL_QUEUE_INTERRUPT_INDEX_REG);
ring->active = 0;
}
bool mqnic_is_cq_ring_empty(const struct mqnic_cq_ring *ring)

View File

@ -50,6 +50,7 @@ int mqnic_create_eq_ring(struct mqnic_priv *priv, struct mqnic_eq_ring **ring_pt
ring->priv = priv;
ring->ring_index = index;
ring->active = 0;
ring->size = roundup_pow_of_two(size);
ring->size_mask = ring->size - 1;
@ -101,7 +102,8 @@ void mqnic_destroy_eq_ring(struct mqnic_eq_ring **ring_ptr)
struct device *dev = ring->priv->dev;
*ring_ptr = NULL;
mqnic_deactivate_eq_ring(ring);
if (ring->active)
mqnic_deactivate_eq_ring(ring);
dma_free_coherent(dev, ring->buf_size, ring->buf, ring->buf_dma_addr);
kfree(ring);
@ -109,6 +111,9 @@ void mqnic_destroy_eq_ring(struct mqnic_eq_ring **ring_ptr)
int mqnic_activate_eq_ring(struct mqnic_eq_ring *ring, int int_index)
{
if (ring->active)
mqnic_deactivate_eq_ring(ring);
ring->int_index = int_index;
// deactivate queue
@ -127,6 +132,8 @@ int mqnic_activate_eq_ring(struct mqnic_eq_ring *ring, int int_index)
iowrite32(ilog2(ring->size) | MQNIC_EVENT_QUEUE_ACTIVE_MASK,
ring->hw_addr + MQNIC_EVENT_QUEUE_ACTIVE_LOG_SIZE_REG);
ring->active = 1;
return 0;
}
@ -136,6 +143,8 @@ void mqnic_deactivate_eq_ring(struct mqnic_eq_ring *ring)
iowrite32(ilog2(ring->size), ring->hw_addr + MQNIC_EVENT_QUEUE_ACTIVE_LOG_SIZE_REG);
// disarm queue
iowrite32(ring->int_index, ring->hw_addr + MQNIC_EVENT_QUEUE_INTERRUPT_INDEX_REG);
ring->active = 0;
}
bool mqnic_is_eq_ring_empty(const struct mqnic_eq_ring *ring)

View File

@ -51,6 +51,7 @@ int mqnic_create_rx_ring(struct mqnic_priv *priv, struct mqnic_ring **ring_ptr,
ring->priv = priv;
ring->ring_index = index;
ring->active = 0;
ring->size = roundup_pow_of_two(size);
ring->size_mask = ring->size - 1;
@ -114,7 +115,8 @@ void mqnic_destroy_rx_ring(struct mqnic_ring **ring_ptr)
struct mqnic_ring *ring = *ring_ptr;
*ring_ptr = NULL;
mqnic_deactivate_rx_ring(ring);
if (ring->active)
mqnic_deactivate_rx_ring(ring);
mqnic_free_rx_buf(ring);
@ -126,6 +128,9 @@ void mqnic_destroy_rx_ring(struct mqnic_ring **ring_ptr)
int mqnic_activate_rx_ring(struct mqnic_ring *ring, int cpl_index)
{
if (ring->active)
mqnic_deactivate_rx_ring(ring);
// deactivate queue
iowrite32(0, ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
// set base address
@ -140,6 +145,8 @@ int mqnic_activate_rx_ring(struct mqnic_ring *ring, int cpl_index)
iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8) | MQNIC_QUEUE_ACTIVE_MASK,
ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
ring->active = 1;
mqnic_refill_rx_buffers(ring);
return 0;
@ -150,6 +157,8 @@ void mqnic_deactivate_rx_ring(struct mqnic_ring *ring)
// deactivate queue
iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8),
ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
ring->active = 0;
}
bool mqnic_is_rx_ring_empty(const struct mqnic_ring *ring)

View File

@ -52,6 +52,7 @@ int mqnic_create_tx_ring(struct mqnic_priv *priv, struct mqnic_ring **ring_ptr,
ring->priv = priv;
ring->ring_index = index;
ring->active = 0;
ring->size = roundup_pow_of_two(size);
ring->full_size = ring->size >> 1;
@ -116,7 +117,8 @@ void mqnic_destroy_tx_ring(struct mqnic_ring **ring_ptr)
struct mqnic_ring *ring = *ring_ptr;
*ring_ptr = NULL;
mqnic_deactivate_tx_ring(ring);
if (ring->active)
mqnic_deactivate_tx_ring(ring);
mqnic_free_tx_buf(ring);
@ -128,6 +130,9 @@ void mqnic_destroy_tx_ring(struct mqnic_ring **ring_ptr)
int mqnic_activate_tx_ring(struct mqnic_ring *ring, int cpl_index)
{
if (ring->active)
mqnic_deactivate_tx_ring(ring);
// deactivate queue
iowrite32(0, ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
// set base address
@ -142,6 +147,8 @@ int mqnic_activate_tx_ring(struct mqnic_ring *ring, int cpl_index)
iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8) | MQNIC_QUEUE_ACTIVE_MASK,
ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
ring->active = 1;
return 0;
}
@ -150,6 +157,8 @@ void mqnic_deactivate_tx_ring(struct mqnic_ring *ring)
// deactivate queue
iowrite32(ilog2(ring->size) | (ring->log_desc_block_size << 8),
ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
ring->active = 0;
}
bool mqnic_is_tx_ring_empty(const struct mqnic_ring *ring)