mirror of
https://github.com/corundum/corundum.git
synced 2025-02-06 08:38:23 +08:00
Add dev references to CQ and EQ rings
This commit is contained in:
parent
bfc8e959bf
commit
3c6f80b80c
@ -222,6 +222,7 @@ struct mqnic_cq_ring {
|
|||||||
u8 *buf;
|
u8 *buf;
|
||||||
dma_addr_t buf_dma_addr;
|
dma_addr_t buf_dma_addr;
|
||||||
|
|
||||||
|
struct device *dev;
|
||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
struct mqnic_priv *priv;
|
struct mqnic_priv *priv;
|
||||||
struct napi_struct napi;
|
struct napi_struct napi;
|
||||||
@ -250,6 +251,7 @@ struct mqnic_eq_ring {
|
|||||||
u8 *buf;
|
u8 *buf;
|
||||||
dma_addr_t buf_dma_addr;
|
dma_addr_t buf_dma_addr;
|
||||||
|
|
||||||
|
struct device *dev;
|
||||||
struct net_device *ndev;
|
struct net_device *ndev;
|
||||||
struct mqnic_priv *priv;
|
struct mqnic_priv *priv;
|
||||||
int ring_index;
|
int ring_index;
|
||||||
|
@ -44,6 +44,7 @@ int mqnic_create_cq_ring(struct mqnic_priv *priv, struct mqnic_cq_ring **ring_pt
|
|||||||
if (!ring)
|
if (!ring)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
ring->dev = priv->dev;
|
||||||
ring->ndev = priv->ndev;
|
ring->ndev = priv->ndev;
|
||||||
ring->priv = priv;
|
ring->priv = priv;
|
||||||
|
|
||||||
@ -77,14 +78,12 @@ 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)
|
int mqnic_alloc_cq_ring(struct mqnic_cq_ring *ring, int size, int stride)
|
||||||
{
|
{
|
||||||
struct device *dev = ring->priv->dev;
|
|
||||||
|
|
||||||
ring->size = roundup_pow_of_two(size);
|
ring->size = roundup_pow_of_two(size);
|
||||||
ring->size_mask = ring->size - 1;
|
ring->size_mask = ring->size - 1;
|
||||||
ring->stride = roundup_pow_of_two(stride);
|
ring->stride = roundup_pow_of_two(stride);
|
||||||
|
|
||||||
ring->buf_size = ring->size * ring->stride;
|
ring->buf_size = ring->size * ring->stride;
|
||||||
ring->buf = dma_alloc_coherent(dev, ring->buf_size, &ring->buf_dma_addr, GFP_KERNEL);
|
ring->buf = dma_alloc_coherent(ring->dev, ring->buf_size, &ring->buf_dma_addr, GFP_KERNEL);
|
||||||
if (!ring->buf)
|
if (!ring->buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -109,14 +108,12 @@ int mqnic_alloc_cq_ring(struct mqnic_cq_ring *ring, int size, int stride)
|
|||||||
|
|
||||||
void mqnic_free_cq_ring(struct mqnic_cq_ring *ring)
|
void mqnic_free_cq_ring(struct mqnic_cq_ring *ring)
|
||||||
{
|
{
|
||||||
struct device *dev = ring->priv->dev;
|
|
||||||
|
|
||||||
mqnic_deactivate_cq_ring(ring);
|
mqnic_deactivate_cq_ring(ring);
|
||||||
|
|
||||||
if (!ring->buf)
|
if (!ring->buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dma_free_coherent(dev, ring->buf_size, ring->buf, ring->buf_dma_addr);
|
dma_free_coherent(ring->dev, ring->buf_size, ring->buf, ring->buf_dma_addr);
|
||||||
ring->buf = NULL;
|
ring->buf = NULL;
|
||||||
ring->buf_dma_addr = 0;
|
ring->buf_dma_addr = 0;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ int mqnic_create_eq_ring(struct mqnic_priv *priv, struct mqnic_eq_ring **ring_pt
|
|||||||
if (!ring)
|
if (!ring)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
ring->dev = priv->dev;
|
||||||
ring->ndev = priv->ndev;
|
ring->ndev = priv->ndev;
|
||||||
ring->priv = priv;
|
ring->priv = priv;
|
||||||
|
|
||||||
@ -89,14 +90,12 @@ void mqnic_destroy_eq_ring(struct mqnic_eq_ring **ring_ptr)
|
|||||||
|
|
||||||
int mqnic_alloc_eq_ring(struct mqnic_eq_ring *ring, int size, int stride)
|
int mqnic_alloc_eq_ring(struct mqnic_eq_ring *ring, int size, int stride)
|
||||||
{
|
{
|
||||||
struct device *dev = ring->priv->dev;
|
|
||||||
|
|
||||||
ring->size = roundup_pow_of_two(size);
|
ring->size = roundup_pow_of_two(size);
|
||||||
ring->size_mask = ring->size - 1;
|
ring->size_mask = ring->size - 1;
|
||||||
ring->stride = roundup_pow_of_two(stride);
|
ring->stride = roundup_pow_of_two(stride);
|
||||||
|
|
||||||
ring->buf_size = ring->size * ring->stride;
|
ring->buf_size = ring->size * ring->stride;
|
||||||
ring->buf = dma_alloc_coherent(dev, ring->buf_size, &ring->buf_dma_addr, GFP_KERNEL);
|
ring->buf = dma_alloc_coherent(ring->dev, ring->buf_size, &ring->buf_dma_addr, GFP_KERNEL);
|
||||||
if (!ring->buf)
|
if (!ring->buf)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -121,14 +120,12 @@ int mqnic_alloc_eq_ring(struct mqnic_eq_ring *ring, int size, int stride)
|
|||||||
|
|
||||||
void mqnic_free_eq_ring(struct mqnic_eq_ring *ring)
|
void mqnic_free_eq_ring(struct mqnic_eq_ring *ring)
|
||||||
{
|
{
|
||||||
struct device *dev = ring->priv->dev;
|
|
||||||
|
|
||||||
mqnic_deactivate_eq_ring(ring);
|
mqnic_deactivate_eq_ring(ring);
|
||||||
|
|
||||||
if (!ring->buf)
|
if (!ring->buf)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dma_free_coherent(dev, ring->buf_size, ring->buf, ring->buf_dma_addr);
|
dma_free_coherent(ring->dev, ring->buf_size, ring->buf, ring->buf_dma_addr);
|
||||||
ring->buf = NULL;
|
ring->buf = NULL;
|
||||||
ring->buf_dma_addr = 0;
|
ring->buf_dma_addr = 0;
|
||||||
}
|
}
|
||||||
@ -239,7 +236,7 @@ void mqnic_process_eq(struct mqnic_eq_ring *eq_ring)
|
|||||||
if (event->type == MQNIC_EVENT_TYPE_TX_CPL) {
|
if (event->type == MQNIC_EVENT_TYPE_TX_CPL) {
|
||||||
// transmit completion event
|
// transmit completion event
|
||||||
if (unlikely(le16_to_cpu(event->source) > priv->tx_cpl_queue_count)) {
|
if (unlikely(le16_to_cpu(event->source) > priv->tx_cpl_queue_count)) {
|
||||||
dev_err(priv->dev, "%s on port %d: unknown event source %d (index %d, type %d)",
|
dev_err(eq_ring->dev, "%s on port %d: unknown event source %d (index %d, type %d)",
|
||||||
__func__, priv->index, le16_to_cpu(event->source), eq_index,
|
__func__, priv->index, le16_to_cpu(event->source), eq_index,
|
||||||
le16_to_cpu(event->type));
|
le16_to_cpu(event->type));
|
||||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1,
|
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1,
|
||||||
@ -252,7 +249,7 @@ void mqnic_process_eq(struct mqnic_eq_ring *eq_ring)
|
|||||||
} else if (le16_to_cpu(event->type) == MQNIC_EVENT_TYPE_RX_CPL) {
|
} else if (le16_to_cpu(event->type) == MQNIC_EVENT_TYPE_RX_CPL) {
|
||||||
// receive completion event
|
// receive completion event
|
||||||
if (unlikely(le16_to_cpu(event->source) > priv->rx_cpl_queue_count)) {
|
if (unlikely(le16_to_cpu(event->source) > priv->rx_cpl_queue_count)) {
|
||||||
dev_err(priv->dev, "%s on port %d: unknown event source %d (index %d, type %d)",
|
dev_err(eq_ring->dev, "%s on port %d: unknown event source %d (index %d, type %d)",
|
||||||
__func__, priv->index, le16_to_cpu(event->source), eq_index,
|
__func__, priv->index, le16_to_cpu(event->source), eq_index,
|
||||||
le16_to_cpu(event->type));
|
le16_to_cpu(event->type));
|
||||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1,
|
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1,
|
||||||
@ -263,7 +260,7 @@ void mqnic_process_eq(struct mqnic_eq_ring *eq_ring)
|
|||||||
cq_ring->handler(cq_ring);
|
cq_ring->handler(cq_ring);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dev_err(priv->dev, "%s on port %d: unknown event type %d (index %d, source %d)",
|
dev_err(eq_ring->dev, "%s on port %d: unknown event type %d (index %d, source %d)",
|
||||||
__func__, priv->index, le16_to_cpu(event->type), eq_index,
|
__func__, priv->index, le16_to_cpu(event->type), eq_index,
|
||||||
le16_to_cpu(event->source));
|
le16_to_cpu(event->source));
|
||||||
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1,
|
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_NONE, 16, 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user