1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-30 08:32:52 +08:00

Pass EQ ring instead of index

This commit is contained in:
Alex Forencich 2021-12-12 13:58:26 -08:00
parent 0418fe33a6
commit 56706beefc
3 changed files with 14 additions and 7 deletions

View File

@ -232,6 +232,7 @@ struct mqnic_cq_ring {
struct mqnic_priv *priv;
struct napi_struct napi;
int index;
struct mqnic_eq_ring *eq_ring;
int eq_index;
int active;
@ -405,7 +406,7 @@ int mqnic_create_cq_ring(struct mqnic_priv *priv, struct mqnic_cq_ring **ring_pt
void mqnic_destroy_cq_ring(struct mqnic_cq_ring **ring_ptr);
int mqnic_alloc_cq_ring(struct mqnic_cq_ring *ring, int size, int stride);
void mqnic_free_cq_ring(struct mqnic_cq_ring *ring);
int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, int eq_index);
int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, struct mqnic_eq_ring *eq_ring);
void mqnic_deactivate_cq_ring(struct mqnic_cq_ring *ring);
bool mqnic_is_cq_ring_empty(const struct mqnic_cq_ring *ring);
bool mqnic_is_cq_ring_full(const struct mqnic_cq_ring *ring);

View File

@ -118,14 +118,15 @@ void mqnic_free_cq_ring(struct mqnic_cq_ring *ring)
ring->buf_dma_addr = 0;
}
int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, int eq_index)
int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, struct mqnic_eq_ring *eq_ring)
{
mqnic_deactivate_cq_ring(ring);
if (!ring->buf)
if (!ring->buf || !eq_ring)
return -EINVAL;
ring->eq_index = eq_index;
ring->eq_ring = eq_ring;
ring->eq_index = eq_ring->index;
// deactivate queue
iowrite32(0, ring->hw_addr + MQNIC_CPL_QUEUE_ACTIVE_LOG_SIZE_REG);
@ -133,7 +134,7 @@ int mqnic_activate_cq_ring(struct mqnic_cq_ring *ring, int eq_index)
iowrite32(ring->buf_dma_addr, ring->hw_addr + MQNIC_CPL_QUEUE_BASE_ADDR_REG + 0);
iowrite32(ring->buf_dma_addr >> 32, ring->hw_addr + MQNIC_CPL_QUEUE_BASE_ADDR_REG + 4);
// set interrupt index
iowrite32(eq_index, ring->hw_addr + MQNIC_CPL_QUEUE_INTERRUPT_INDEX_REG);
iowrite32(ring->eq_index, ring->hw_addr + MQNIC_CPL_QUEUE_INTERRUPT_INDEX_REG);
// set pointers
iowrite32(ring->head_ptr & ring->hw_ptr_mask, ring->hw_addr + MQNIC_CPL_QUEUE_HEAD_PTR_REG);
iowrite32(ring->tail_ptr & ring->hw_ptr_mask, ring->hw_addr + MQNIC_CPL_QUEUE_TAIL_PTR_REG);
@ -153,6 +154,8 @@ void mqnic_deactivate_cq_ring(struct mqnic_cq_ring *ring)
// disarm queue
iowrite32(ring->eq_index, ring->hw_addr + MQNIC_CPL_QUEUE_INTERRUPT_INDEX_REG);
ring->eq_ring = NULL;
ring->active = 0;
}
@ -178,6 +181,9 @@ void mqnic_cq_write_tail_ptr(struct mqnic_cq_ring *ring)
void mqnic_arm_cq(struct mqnic_cq_ring *ring)
{
if (!ring->active)
return;
iowrite32(ring->eq_index | MQNIC_CPL_QUEUE_ARM_MASK,
ring->hw_addr + MQNIC_CPL_QUEUE_INTERRUPT_INDEX_REG);
}

View File

@ -52,7 +52,7 @@ static int mqnic_start_port(struct net_device *ndev)
// set up RX completion queues
for (k = 0; k < priv->rx_cpl_queue_count; k++) {
mqnic_activate_cq_ring(priv->rx_cpl_ring[k],
priv->event_ring[k % priv->event_queue_count]->index);
priv->event_ring[k % priv->event_queue_count]);
priv->rx_cpl_ring[k]->handler = mqnic_rx_irq;
netif_napi_add(ndev, &priv->rx_cpl_ring[k]->napi,
@ -76,7 +76,7 @@ static int mqnic_start_port(struct net_device *ndev)
// set up TX completion queues
for (k = 0; k < priv->tx_cpl_queue_count; k++) {
mqnic_activate_cq_ring(priv->tx_cpl_ring[k],
priv->event_ring[k % priv->event_queue_count]->index);
priv->event_ring[k % priv->event_queue_count]);
priv->tx_cpl_ring[k]->handler = mqnic_tx_irq;
netif_tx_napi_add(ndev, &priv->tx_cpl_ring[k]->napi,