mirror of
https://github.com/corundum/corundum.git
synced 2025-01-30 08:32:52 +08:00
Fix pointer updating for correct teardown behavior
This commit is contained in:
parent
137a6778da
commit
d506c9305a
@ -44,6 +44,8 @@ int mqnic_create_cq_ring(struct mqnic_if *interface, struct mqnic_cq_ring **ring
|
||||
if (!ring)
|
||||
return -ENOMEM;
|
||||
|
||||
*ring_ptr = ring;
|
||||
|
||||
ring->dev = interface->dev;
|
||||
ring->interface = interface;
|
||||
|
||||
@ -61,17 +63,16 @@ int mqnic_create_cq_ring(struct mqnic_if *interface, struct mqnic_cq_ring **ring
|
||||
// deactivate queue
|
||||
iowrite32(0, ring->hw_addr + MQNIC_CPL_QUEUE_ACTIVE_LOG_SIZE_REG);
|
||||
|
||||
*ring_ptr = ring;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mqnic_destroy_cq_ring(struct mqnic_cq_ring **ring_ptr)
|
||||
{
|
||||
struct mqnic_cq_ring *ring = *ring_ptr;
|
||||
*ring_ptr = NULL;
|
||||
|
||||
mqnic_free_cq_ring(ring);
|
||||
|
||||
*ring_ptr = NULL;
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,8 @@ int mqnic_create_eq_ring(struct mqnic_if *interface, struct mqnic_eq_ring **ring
|
||||
if (!ring)
|
||||
return -ENOMEM;
|
||||
|
||||
*ring_ptr = ring;
|
||||
|
||||
ring->dev = interface->dev;
|
||||
ring->interface = interface;
|
||||
|
||||
@ -73,17 +75,16 @@ int mqnic_create_eq_ring(struct mqnic_if *interface, struct mqnic_eq_ring **ring
|
||||
// deactivate queue
|
||||
iowrite32(0, ring->hw_addr + MQNIC_EVENT_QUEUE_ACTIVE_LOG_SIZE_REG);
|
||||
|
||||
*ring_ptr = ring;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mqnic_destroy_eq_ring(struct mqnic_eq_ring **ring_ptr)
|
||||
{
|
||||
struct mqnic_eq_ring *ring = *ring_ptr;
|
||||
*ring_ptr = NULL;
|
||||
|
||||
mqnic_free_eq_ring(ring);
|
||||
|
||||
*ring_ptr = NULL;
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
if (!interface)
|
||||
return -ENOMEM;
|
||||
|
||||
*interface_ptr = interface;
|
||||
|
||||
interface->mdev = mdev;
|
||||
interface->dev = dev;
|
||||
|
||||
@ -188,8 +190,6 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
|
||||
desc_block_size = min_t(u32, interface->max_desc_block_size, 4);
|
||||
|
||||
*interface_ptr = interface;
|
||||
|
||||
// create rings
|
||||
for (k = 0; k < interface->event_queue_count; k++) {
|
||||
ret = mqnic_create_eq_ring(interface, &interface->event_ring[k], k,
|
||||
|
@ -364,6 +364,8 @@ int mqnic_create_netdev(struct mqnic_if *interface, struct net_device **ndev_ptr
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
*ndev_ptr = ndev;
|
||||
|
||||
SET_NETDEV_DEV(ndev, dev);
|
||||
ndev->dev_port = dev_port;
|
||||
|
||||
@ -493,8 +495,6 @@ int mqnic_create_netdev(struct mqnic_if *interface, struct net_device **ndev_ptr
|
||||
|
||||
priv->registered = 1;
|
||||
|
||||
*ndev_ptr = ndev;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
@ -511,8 +511,6 @@ void mqnic_destroy_netdev(struct net_device **ndev_ptr)
|
||||
if (priv->registered)
|
||||
unregister_netdev(ndev);
|
||||
|
||||
*ndev_ptr = NULL;
|
||||
|
||||
// free rings
|
||||
for (k = 0; k < ARRAY_SIZE(priv->tx_ring); k++)
|
||||
if (priv->tx_ring[k])
|
||||
@ -530,5 +528,6 @@ void mqnic_destroy_netdev(struct net_device **ndev_ptr)
|
||||
if (priv->rx_cpl_ring[k])
|
||||
mqnic_free_cq_ring(priv->rx_cpl_ring[k]);
|
||||
|
||||
*ndev_ptr = NULL;
|
||||
free_netdev(ndev);
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ void mqnic_destroy_port(struct mqnic_port **port_ptr)
|
||||
{
|
||||
struct mqnic_port *port = *port_ptr;
|
||||
int k;
|
||||
*port_ptr = NULL;
|
||||
|
||||
mqnic_deactivate_port(port);
|
||||
|
||||
@ -113,6 +112,7 @@ void mqnic_destroy_port(struct mqnic_port **port_ptr)
|
||||
if (port->rb_list)
|
||||
free_reg_block_list(port->rb_list);
|
||||
|
||||
*port_ptr = NULL;
|
||||
kfree(port);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ int mqnic_create_rx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_pt
|
||||
if (!ring)
|
||||
return -ENOMEM;
|
||||
|
||||
*ring_ptr = ring;
|
||||
|
||||
ring->dev = interface->dev;
|
||||
ring->interface = interface;
|
||||
|
||||
@ -62,17 +64,16 @@ int mqnic_create_rx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_pt
|
||||
// deactivate queue
|
||||
iowrite32(0, ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
|
||||
|
||||
*ring_ptr = ring;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mqnic_destroy_rx_ring(struct mqnic_ring **ring_ptr)
|
||||
{
|
||||
struct mqnic_ring *ring = *ring_ptr;
|
||||
*ring_ptr = NULL;
|
||||
|
||||
mqnic_free_rx_ring(ring);
|
||||
|
||||
*ring_ptr = NULL;
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ int mqnic_create_tx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_pt
|
||||
if (!ring)
|
||||
return -ENOMEM;
|
||||
|
||||
*ring_ptr = ring;
|
||||
|
||||
ring->dev = interface->dev;
|
||||
ring->interface = interface;
|
||||
|
||||
@ -63,17 +65,16 @@ int mqnic_create_tx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_pt
|
||||
// deactivate queue
|
||||
iowrite32(0, ring->hw_addr + MQNIC_QUEUE_ACTIVE_LOG_SIZE_REG);
|
||||
|
||||
*ring_ptr = ring;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mqnic_destroy_tx_ring(struct mqnic_ring **ring_ptr)
|
||||
{
|
||||
struct mqnic_ring *ring = *ring_ptr;
|
||||
*ring_ptr = NULL;
|
||||
|
||||
mqnic_free_tx_ring(ring);
|
||||
|
||||
*ring_ptr = NULL;
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user