mirror of
https://github.com/corundum/corundum.git
synced 2025-01-30 08:32:52 +08:00
modules/mqnic: Return pointers directly and use ERR_PTR during object creation
Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
parent
66f5b9fcc1
commit
1c7ae0ee73
@ -521,9 +521,8 @@ int mqnic_irq_init_platform(struct mqnic_dev *mdev);
|
||||
extern const struct file_operations mqnic_fops;
|
||||
|
||||
// mqnic_if.c
|
||||
int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_ptr,
|
||||
int index, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_interface(struct mqnic_if **interface_ptr);
|
||||
struct mqnic_if *mqnic_create_interface(struct mqnic_dev *mdev, int index, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_interface(struct mqnic_if *interface);
|
||||
u32 mqnic_interface_get_tx_mtu(struct mqnic_if *interface);
|
||||
void mqnic_interface_set_tx_mtu(struct mqnic_if *interface, u32 mtu);
|
||||
u32 mqnic_interface_get_rx_mtu(struct mqnic_if *interface);
|
||||
@ -536,29 +535,28 @@ u32 mqnic_interface_get_rx_queue_map_indir_table(struct mqnic_if *interface, int
|
||||
void mqnic_interface_set_rx_queue_map_indir_table(struct mqnic_if *interface, int port, int index, u32 val);
|
||||
|
||||
// mqnic_port.c
|
||||
int mqnic_create_port(struct mqnic_if *interface, struct mqnic_port **port_ptr,
|
||||
int index, struct mqnic_reg_block *port_rb);
|
||||
void mqnic_destroy_port(struct mqnic_port **port_ptr);
|
||||
struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
|
||||
struct mqnic_reg_block *port_rb);
|
||||
void mqnic_destroy_port(struct mqnic_port *port);
|
||||
u32 mqnic_port_get_tx_status(struct mqnic_port *port);
|
||||
u32 mqnic_port_get_rx_status(struct mqnic_port *port);
|
||||
|
||||
// mqnic_netdev.c
|
||||
void mqnic_update_stats(struct net_device *ndev);
|
||||
int mqnic_create_netdev(struct mqnic_if *interface, struct net_device **ndev_ptr,
|
||||
int index, int dev_port);
|
||||
void mqnic_destroy_netdev(struct net_device **ndev_ptr);
|
||||
struct net_device *mqnic_create_netdev(struct mqnic_if *interface, int index, int dev_port);
|
||||
void mqnic_destroy_netdev(struct net_device *ndev);
|
||||
|
||||
// mqnic_sched_block.c
|
||||
int mqnic_create_sched_block(struct mqnic_if *interface, struct mqnic_sched_block **block_ptr,
|
||||
struct mqnic_sched_block *mqnic_create_sched_block(struct mqnic_if *interface,
|
||||
int index, struct mqnic_reg_block *rb);
|
||||
void mqnic_destroy_sched_block(struct mqnic_sched_block **block_ptr);
|
||||
void mqnic_destroy_sched_block(struct mqnic_sched_block *block);
|
||||
int mqnic_activate_sched_block(struct mqnic_sched_block *block);
|
||||
void mqnic_deactivate_sched_block(struct mqnic_sched_block *block);
|
||||
|
||||
// mqnic_scheduler.c
|
||||
int mqnic_create_scheduler(struct mqnic_sched_block *block, struct mqnic_sched **sched_ptr,
|
||||
struct mqnic_sched *mqnic_create_scheduler(struct mqnic_sched_block *block,
|
||||
int index, struct mqnic_reg_block *rb);
|
||||
void mqnic_destroy_scheduler(struct mqnic_sched **sched_ptr);
|
||||
void mqnic_destroy_scheduler(struct mqnic_sched *sched);
|
||||
int mqnic_scheduler_enable(struct mqnic_sched *sched);
|
||||
void mqnic_scheduler_disable(struct mqnic_sched *sched);
|
||||
|
||||
@ -596,9 +594,9 @@ void mqnic_stats_init(struct mqnic_dev *mdev);
|
||||
u64 mqnic_stats_read(struct mqnic_dev *mdev, int index);
|
||||
|
||||
// mqnic_eq.c
|
||||
int mqnic_create_eq(struct mqnic_if *interface, struct mqnic_eq **eq_ptr,
|
||||
struct mqnic_eq *mqnic_create_eq(struct mqnic_if *interface,
|
||||
int eqn, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_eq(struct mqnic_eq **eq_ptr);
|
||||
void mqnic_destroy_eq(struct mqnic_eq *eq);
|
||||
int mqnic_alloc_eq(struct mqnic_eq *eq, int size, int stride);
|
||||
void mqnic_free_eq(struct mqnic_eq *eq);
|
||||
int mqnic_activate_eq(struct mqnic_eq *eq, struct mqnic_irq *irq);
|
||||
@ -609,9 +607,9 @@ void mqnic_arm_eq(struct mqnic_eq *eq);
|
||||
void mqnic_process_eq(struct mqnic_eq *eq);
|
||||
|
||||
// mqnic_cq.c
|
||||
int mqnic_create_cq(struct mqnic_if *interface, struct mqnic_cq **cq_ptr,
|
||||
struct mqnic_cq *mqnic_create_cq(struct mqnic_if *interface,
|
||||
int cqn, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_cq(struct mqnic_cq **cq_ptr);
|
||||
void mqnic_destroy_cq(struct mqnic_cq *cq);
|
||||
int mqnic_alloc_cq(struct mqnic_cq *cq, int size, int stride);
|
||||
void mqnic_free_cq(struct mqnic_cq *cq);
|
||||
int mqnic_activate_cq(struct mqnic_cq *cq, struct mqnic_eq *eq);
|
||||
@ -621,9 +619,9 @@ void mqnic_cq_write_tail_ptr(struct mqnic_cq *cq);
|
||||
void mqnic_arm_cq(struct mqnic_cq *cq);
|
||||
|
||||
// mqnic_tx.c
|
||||
int mqnic_create_tx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_ptr,
|
||||
struct mqnic_ring *mqnic_create_tx_ring(struct mqnic_if *interface,
|
||||
int index, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_tx_ring(struct mqnic_ring **ring_ptr);
|
||||
void mqnic_destroy_tx_ring(struct mqnic_ring *ring);
|
||||
int mqnic_alloc_tx_ring(struct mqnic_ring *ring, int size, int stride);
|
||||
void mqnic_free_tx_ring(struct mqnic_ring *ring);
|
||||
int mqnic_activate_tx_ring(struct mqnic_ring *ring, struct mqnic_priv *priv,
|
||||
@ -641,9 +639,9 @@ int mqnic_poll_tx_cq(struct napi_struct *napi, int budget);
|
||||
netdev_tx_t mqnic_start_xmit(struct sk_buff *skb, struct net_device *dev);
|
||||
|
||||
// mqnic_rx.c
|
||||
int mqnic_create_rx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_ptr,
|
||||
struct mqnic_ring *mqnic_create_rx_ring(struct mqnic_if *interface,
|
||||
int index, u8 __iomem *hw_addr);
|
||||
void mqnic_destroy_rx_ring(struct mqnic_ring **ring_ptr);
|
||||
void mqnic_destroy_rx_ring(struct mqnic_ring *ring);
|
||||
int mqnic_alloc_rx_ring(struct mqnic_ring *ring, int size, int stride);
|
||||
void mqnic_free_rx_ring(struct mqnic_ring *ring);
|
||||
int mqnic_activate_rx_ring(struct mqnic_ring *ring, struct mqnic_priv *priv,
|
||||
|
@ -35,16 +35,14 @@
|
||||
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_cq(struct mqnic_if *interface, struct mqnic_cq **cq_ptr,
|
||||
struct mqnic_cq *mqnic_create_cq(struct mqnic_if *interface,
|
||||
int cqn, u8 __iomem *hw_addr)
|
||||
{
|
||||
struct mqnic_cq *cq;
|
||||
|
||||
cq = kzalloc(sizeof(*cq), GFP_KERNEL);
|
||||
if (!cq)
|
||||
return -ENOMEM;
|
||||
|
||||
*cq_ptr = cq;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
cq->dev = interface->dev;
|
||||
cq->interface = interface;
|
||||
@ -63,16 +61,13 @@ int mqnic_create_cq(struct mqnic_if *interface, struct mqnic_cq **cq_ptr,
|
||||
// deactivate queue
|
||||
iowrite32(0, cq->hw_addr + MQNIC_CQ_ACTIVE_LOG_SIZE_REG);
|
||||
|
||||
return 0;
|
||||
return cq;
|
||||
}
|
||||
|
||||
void mqnic_destroy_cq(struct mqnic_cq **cq_ptr)
|
||||
void mqnic_destroy_cq(struct mqnic_cq *cq)
|
||||
{
|
||||
struct mqnic_cq *cq = *cq_ptr;
|
||||
|
||||
mqnic_free_cq(cq);
|
||||
|
||||
*cq_ptr = NULL;
|
||||
kfree(cq);
|
||||
}
|
||||
|
||||
|
@ -45,16 +45,14 @@ static int mqnic_eq_int(struct notifier_block *nb, unsigned long action, void *d
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
int mqnic_create_eq(struct mqnic_if *interface, struct mqnic_eq **eq_ptr,
|
||||
struct mqnic_eq *mqnic_create_eq(struct mqnic_if *interface,
|
||||
int eqn, u8 __iomem *hw_addr)
|
||||
{
|
||||
struct mqnic_eq *eq;
|
||||
|
||||
eq = kzalloc(sizeof(*eq), GFP_KERNEL);
|
||||
if (!eq)
|
||||
return -ENOMEM;
|
||||
|
||||
*eq_ptr = eq;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
eq->dev = interface->dev;
|
||||
eq->interface = interface;
|
||||
@ -75,16 +73,13 @@ int mqnic_create_eq(struct mqnic_if *interface, struct mqnic_eq **eq_ptr,
|
||||
// deactivate queue
|
||||
iowrite32(0, eq->hw_addr + MQNIC_EQ_ACTIVE_LOG_SIZE_REG);
|
||||
|
||||
return 0;
|
||||
return eq;
|
||||
}
|
||||
|
||||
void mqnic_destroy_eq(struct mqnic_eq **eq_ptr)
|
||||
void mqnic_destroy_eq(struct mqnic_eq *eq)
|
||||
{
|
||||
struct mqnic_eq *eq = *eq_ptr;
|
||||
|
||||
mqnic_free_eq(eq);
|
||||
|
||||
*eq_ptr = NULL;
|
||||
kfree(eq);
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,7 @@
|
||||
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_ptr,
|
||||
int index, u8 __iomem *hw_addr)
|
||||
struct mqnic_if *mqnic_create_interface(struct mqnic_dev *mdev, int index, u8 __iomem *hw_addr)
|
||||
{
|
||||
struct device *dev = mdev->dev;
|
||||
struct mqnic_if *interface;
|
||||
@ -48,9 +47,7 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
|
||||
interface = kzalloc(sizeof(*interface), GFP_KERNEL);
|
||||
if (!interface)
|
||||
return -ENOMEM;
|
||||
|
||||
*interface_ptr = interface;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
interface->mdev = mdev;
|
||||
interface->dev = dev;
|
||||
@ -219,50 +216,67 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
|
||||
// create rings
|
||||
for (k = 0; k < interface->eq_count; k++) {
|
||||
ret = mqnic_create_eq(interface, &interface->eq[k], k,
|
||||
struct mqnic_eq *eq = mqnic_create_eq(interface, k,
|
||||
hw_addr + interface->eq_offset + k * interface->eq_stride);
|
||||
if (ret)
|
||||
if (IS_ERR_OR_NULL(eq)) {
|
||||
ret = PTR_ERR(eq);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = mqnic_alloc_eq(interface->eq[k], mqnic_num_eq_entries,
|
||||
interface->eq[k] = eq;
|
||||
|
||||
ret = mqnic_alloc_eq(eq, mqnic_num_eq_entries,
|
||||
MQNIC_EVENT_SIZE);
|
||||
if (ret)
|
||||
goto fail;
|
||||
|
||||
mqnic_activate_eq(interface->eq[k], mdev->irq[k % mdev->irq_count]);
|
||||
mqnic_arm_eq(interface->eq[k]);
|
||||
mqnic_activate_eq(eq, mdev->irq[k % mdev->irq_count]);
|
||||
mqnic_arm_eq(eq);
|
||||
}
|
||||
|
||||
for (k = 0; k < interface->txq_count; k++) {
|
||||
ret = mqnic_create_tx_ring(interface, &interface->txq[k], k,
|
||||
struct mqnic_ring *txq = mqnic_create_tx_ring(interface, k,
|
||||
hw_addr + interface->txq_offset + k * interface->txq_stride);
|
||||
if (ret)
|
||||
if (IS_ERR_OR_NULL(txq)) {
|
||||
ret = PTR_ERR(txq);
|
||||
goto fail;
|
||||
}
|
||||
interface->txq[k] = txq;
|
||||
}
|
||||
|
||||
for (k = 0; k < interface->tx_cq_count; k++) {
|
||||
ret = mqnic_create_cq(interface, &interface->tx_cq[k], k,
|
||||
struct mqnic_cq *cq = mqnic_create_cq(interface, k,
|
||||
hw_addr + interface->tx_cq_offset + k * interface->tx_cq_stride);
|
||||
if (ret)
|
||||
if (IS_ERR_OR_NULL(cq)) {
|
||||
ret = PTR_ERR(cq);
|
||||
goto fail;
|
||||
}
|
||||
interface->tx_cq[k] = cq;
|
||||
}
|
||||
|
||||
for (k = 0; k < interface->rxq_count; k++) {
|
||||
ret = mqnic_create_rx_ring(interface, &interface->rxq[k], k,
|
||||
struct mqnic_ring *rxq = mqnic_create_rx_ring(interface, k,
|
||||
hw_addr + interface->rxq_offset + k * interface->rxq_stride);
|
||||
if (ret)
|
||||
if (IS_ERR_OR_NULL(rxq)) {
|
||||
ret = PTR_ERR(rxq);
|
||||
goto fail;
|
||||
}
|
||||
interface->rxq[k] = rxq;
|
||||
}
|
||||
|
||||
for (k = 0; k < interface->rx_cq_count; k++) {
|
||||
ret = mqnic_create_cq(interface, &interface->rx_cq[k], k,
|
||||
struct mqnic_cq *cq = mqnic_create_cq(interface, k,
|
||||
hw_addr + interface->rx_cq_offset + k * interface->rx_cq_stride);
|
||||
if (ret)
|
||||
if (IS_ERR_OR_NULL(cq)) {
|
||||
ret = PTR_ERR(cq);
|
||||
goto fail;
|
||||
}
|
||||
interface->rx_cq[k] = cq;
|
||||
}
|
||||
|
||||
// create ports
|
||||
for (k = 0; k < interface->port_count; k++) {
|
||||
struct mqnic_port *port;
|
||||
struct mqnic_reg_block *port_rb = mqnic_find_reg_block(interface->rb_list, MQNIC_RB_PORT_TYPE, MQNIC_RB_PORT_VER, k);
|
||||
|
||||
if (!port_rb) {
|
||||
@ -271,14 +285,17 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = mqnic_create_port(interface, &interface->port[k],
|
||||
k, port_rb);
|
||||
if (ret)
|
||||
port = mqnic_create_port(interface, k, port_rb);
|
||||
if (IS_ERR_OR_NULL(port)) {
|
||||
ret = PTR_ERR(port);
|
||||
goto fail;
|
||||
}
|
||||
interface->port[k] = port;
|
||||
}
|
||||
|
||||
// create schedulers
|
||||
for (k = 0; k < interface->sched_block_count; k++) {
|
||||
struct mqnic_sched_block *sched_block;
|
||||
struct mqnic_reg_block *sched_block_rb = mqnic_find_reg_block(interface->rb_list, MQNIC_RB_SCHED_BLOCK_TYPE, MQNIC_RB_SCHED_BLOCK_VER, k);
|
||||
|
||||
if (!sched_block_rb) {
|
||||
@ -287,10 +304,12 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = mqnic_create_sched_block(interface, &interface->sched_block[k],
|
||||
k, sched_block_rb);
|
||||
if (ret)
|
||||
sched_block = mqnic_create_sched_block(interface, k, sched_block_rb);
|
||||
if (IS_ERR_OR_NULL(sched_block)) {
|
||||
ret = PTR_ERR(sched_block);
|
||||
goto fail;
|
||||
}
|
||||
interface->sched_block[k] = sched_block;
|
||||
}
|
||||
|
||||
// create net_devices
|
||||
@ -299,63 +318,88 @@ int mqnic_create_interface(struct mqnic_dev *mdev, struct mqnic_if **interface_p
|
||||
|
||||
interface->ndev_count = 1;
|
||||
for (k = 0; k < interface->ndev_count; k++) {
|
||||
ret = mqnic_create_netdev(interface, &interface->ndev[k], k, interface->dev_port_max++);
|
||||
if (ret)
|
||||
struct net_device *ndev = mqnic_create_netdev(interface, k, interface->dev_port_max++);
|
||||
if (IS_ERR_OR_NULL(ndev)) {
|
||||
ret = PTR_ERR(ndev);
|
||||
goto fail;
|
||||
}
|
||||
interface->ndev[k] = ndev;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return interface;
|
||||
|
||||
fail:
|
||||
mqnic_destroy_interface(interface_ptr);
|
||||
return ret;
|
||||
mqnic_destroy_interface(interface);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
void mqnic_destroy_interface(struct mqnic_if **interface_ptr)
|
||||
void mqnic_destroy_interface(struct mqnic_if *interface)
|
||||
{
|
||||
struct mqnic_if *interface = *interface_ptr;
|
||||
int k;
|
||||
|
||||
// destroy associated net_devices
|
||||
for (k = 0; k < ARRAY_SIZE(interface->ndev); k++)
|
||||
if (interface->ndev[k])
|
||||
mqnic_destroy_netdev(&interface->ndev[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->ndev); k++) {
|
||||
if (interface->ndev[k]) {
|
||||
mqnic_destroy_netdev(interface->ndev[k]);
|
||||
interface->ndev[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// free rings
|
||||
for (k = 0; k < ARRAY_SIZE(interface->eq); k++)
|
||||
if (interface->eq[k])
|
||||
mqnic_destroy_eq(&interface->eq[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->eq); k++) {
|
||||
if (interface->eq[k]) {
|
||||
mqnic_destroy_eq(interface->eq[k]);
|
||||
interface->eq[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(interface->txq); k++)
|
||||
if (interface->txq[k])
|
||||
mqnic_destroy_tx_ring(&interface->txq[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->txq); k++) {
|
||||
if (interface->txq[k]) {
|
||||
mqnic_destroy_tx_ring(interface->txq[k]);
|
||||
interface->txq[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(interface->tx_cq); k++)
|
||||
if (interface->tx_cq[k])
|
||||
mqnic_destroy_cq(&interface->tx_cq[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->tx_cq); k++) {
|
||||
if (interface->tx_cq[k]) {
|
||||
mqnic_destroy_cq(interface->tx_cq[k]);
|
||||
interface->tx_cq[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(interface->rxq); k++)
|
||||
if (interface->rxq[k])
|
||||
mqnic_destroy_rx_ring(&interface->rxq[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->rxq); k++) {
|
||||
if (interface->rxq[k]) {
|
||||
mqnic_destroy_rx_ring(interface->rxq[k]);
|
||||
interface->rxq[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(interface->rx_cq); k++)
|
||||
if (interface->rx_cq[k])
|
||||
mqnic_destroy_cq(&interface->rx_cq[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->rx_cq); k++) {
|
||||
if (interface->rx_cq[k]) {
|
||||
mqnic_destroy_cq(interface->rx_cq[k]);
|
||||
interface->rx_cq[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// free schedulers
|
||||
for (k = 0; k < ARRAY_SIZE(interface->sched_block); k++)
|
||||
if (interface->sched_block[k])
|
||||
mqnic_destroy_sched_block(&interface->sched_block[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->sched_block); k++) {
|
||||
if (interface->sched_block[k]) {
|
||||
mqnic_destroy_sched_block(interface->sched_block[k]);
|
||||
interface->sched_block[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// free ports
|
||||
for (k = 0; k < ARRAY_SIZE(interface->port); k++)
|
||||
if (interface->port[k])
|
||||
mqnic_destroy_port(&interface->port[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(interface->port); k++) {
|
||||
if (interface->port[k]) {
|
||||
mqnic_destroy_port(interface->port[k]);
|
||||
interface->port[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (interface->rb_list)
|
||||
mqnic_free_reg_block_list(interface->rb_list);
|
||||
|
||||
*interface_ptr = NULL;
|
||||
kfree(interface);
|
||||
}
|
||||
|
||||
|
@ -397,12 +397,14 @@ static int mqnic_common_probe(struct mqnic_dev *mqnic)
|
||||
mqnic->if_count = min_t(u32, mqnic->if_count, MQNIC_MAX_IF);
|
||||
|
||||
for (k = 0; k < mqnic->if_count; k++) {
|
||||
struct mqnic_if *interface;
|
||||
dev_info(dev, "Creating interface %d", k);
|
||||
ret = mqnic_create_interface(mqnic, &mqnic->interface[k], k, mqnic->hw_addr + k * mqnic->if_stride);
|
||||
if (ret) {
|
||||
interface = mqnic_create_interface(mqnic, k, mqnic->hw_addr + k * mqnic->if_stride);
|
||||
if (IS_ERR_OR_NULL(interface)) {
|
||||
dev_err(dev, "Failed to create interface: %d", ret);
|
||||
goto fail_create_if;
|
||||
}
|
||||
mqnic->interface[k] = interface;
|
||||
mqnic->dev_port_max = mqnic->interface[k]->dev_port_max;
|
||||
}
|
||||
|
||||
@ -497,9 +499,12 @@ static void mqnic_common_remove(struct mqnic_dev *mqnic)
|
||||
if (mqnic->misc_dev.this_device)
|
||||
misc_deregister(&mqnic->misc_dev);
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(mqnic->interface); k++)
|
||||
if (mqnic->interface[k])
|
||||
mqnic_destroy_interface(&mqnic->interface[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(mqnic->interface); k++) {
|
||||
if (mqnic->interface[k]) {
|
||||
mqnic_destroy_interface(mqnic->interface[k]);
|
||||
mqnic->interface[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mqnic_unregister_phc(mqnic);
|
||||
if (mqnic->pfdev) {
|
||||
|
@ -410,8 +410,7 @@ static void mqnic_link_status_timeout(struct timer_list *timer)
|
||||
mod_timer(&priv->link_status_timer, jiffies + msecs_to_jiffies(mqnic_link_status_poll));
|
||||
}
|
||||
|
||||
int mqnic_create_netdev(struct mqnic_if *interface, struct net_device **ndev_ptr,
|
||||
int index, int dev_port)
|
||||
struct net_device *mqnic_create_netdev(struct mqnic_if *interface, int index, int dev_port)
|
||||
{
|
||||
struct mqnic_dev *mdev = interface->mdev;
|
||||
struct device *dev = interface->dev;
|
||||
@ -424,11 +423,9 @@ int mqnic_create_netdev(struct mqnic_if *interface, struct net_device **ndev_ptr
|
||||
ndev = alloc_etherdev_mqs(sizeof(*priv), MQNIC_MAX_TXQ, MQNIC_MAX_RXQ);
|
||||
if (!ndev) {
|
||||
dev_err(dev, "Failed to allocate memory");
|
||||
return -ENOMEM;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
*ndev_ptr = ndev;
|
||||
|
||||
SET_NETDEV_DEV(ndev, dev);
|
||||
ndev->dev_port = dev_port;
|
||||
|
||||
@ -565,16 +562,15 @@ int mqnic_create_netdev(struct mqnic_if *interface, struct net_device **ndev_ptr
|
||||
|
||||
priv->registered = 1;
|
||||
|
||||
return 0;
|
||||
return ndev;
|
||||
|
||||
fail:
|
||||
mqnic_destroy_netdev(ndev_ptr);
|
||||
return ret;
|
||||
mqnic_destroy_netdev(ndev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
void mqnic_destroy_netdev(struct net_device **ndev_ptr)
|
||||
void mqnic_destroy_netdev(struct net_device *ndev)
|
||||
{
|
||||
struct net_device *ndev = *ndev_ptr;
|
||||
struct mqnic_priv *priv = netdev_priv(ndev);
|
||||
int k;
|
||||
|
||||
@ -598,6 +594,5 @@ void mqnic_destroy_netdev(struct net_device **ndev_ptr)
|
||||
if (priv->rx_cq[k])
|
||||
mqnic_free_cq(priv->rx_cq[k]);
|
||||
|
||||
*ndev_ptr = NULL;
|
||||
free_netdev(ndev);
|
||||
}
|
||||
|
@ -35,8 +35,8 @@
|
||||
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_port(struct mqnic_if *interface, struct mqnic_port **port_ptr,
|
||||
int index, struct mqnic_reg_block *port_rb)
|
||||
struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
|
||||
struct mqnic_reg_block *port_rb)
|
||||
{
|
||||
struct device *dev = interface->dev;
|
||||
struct mqnic_port *port;
|
||||
@ -46,9 +46,7 @@ int mqnic_create_port(struct mqnic_if *interface, struct mqnic_port **port_ptr,
|
||||
|
||||
port = kzalloc(sizeof(*port), GFP_KERNEL);
|
||||
if (!port)
|
||||
return -ENOMEM;
|
||||
|
||||
*port_ptr = port;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
port->dev = dev;
|
||||
port->interface = interface;
|
||||
@ -87,21 +85,18 @@ int mqnic_create_port(struct mqnic_if *interface, struct mqnic_port **port_ptr,
|
||||
dev_info(dev, "Port TX status: 0x%08x", mqnic_port_get_tx_status(port));
|
||||
dev_info(dev, "Port RX status: 0x%08x", mqnic_port_get_rx_status(port));
|
||||
|
||||
return 0;
|
||||
return port;
|
||||
|
||||
fail:
|
||||
mqnic_destroy_port(port_ptr);
|
||||
return ret;
|
||||
mqnic_destroy_port(port);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
void mqnic_destroy_port(struct mqnic_port **port_ptr)
|
||||
void mqnic_destroy_port(struct mqnic_port *port)
|
||||
{
|
||||
struct mqnic_port *port = *port_ptr;
|
||||
|
||||
if (port->rb_list)
|
||||
mqnic_free_reg_block_list(port->rb_list);
|
||||
|
||||
*port_ptr = NULL;
|
||||
kfree(port);
|
||||
}
|
||||
|
||||
|
@ -35,16 +35,14 @@
|
||||
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_rx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_ptr,
|
||||
struct mqnic_ring *mqnic_create_rx_ring(struct mqnic_if *interface,
|
||||
int index, u8 __iomem *hw_addr)
|
||||
{
|
||||
struct mqnic_ring *ring;
|
||||
|
||||
ring = kzalloc(sizeof(*ring), GFP_KERNEL);
|
||||
if (!ring)
|
||||
return -ENOMEM;
|
||||
|
||||
*ring_ptr = ring;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
ring->dev = interface->dev;
|
||||
ring->interface = interface;
|
||||
@ -63,16 +61,13 @@ 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);
|
||||
|
||||
return 0;
|
||||
return ring;
|
||||
}
|
||||
|
||||
void mqnic_destroy_rx_ring(struct mqnic_ring **ring_ptr)
|
||||
void mqnic_destroy_rx_ring(struct mqnic_ring *ring)
|
||||
{
|
||||
struct mqnic_ring *ring = *ring_ptr;
|
||||
|
||||
mqnic_free_rx_ring(ring);
|
||||
|
||||
*ring_ptr = NULL;
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_sched_block(struct mqnic_if *interface, struct mqnic_sched_block **block_ptr,
|
||||
struct mqnic_sched_block *mqnic_create_sched_block(struct mqnic_if *interface,
|
||||
int index, struct mqnic_reg_block *block_rb)
|
||||
{
|
||||
struct device *dev = interface->dev;
|
||||
@ -46,9 +46,7 @@ int mqnic_create_sched_block(struct mqnic_if *interface, struct mqnic_sched_bloc
|
||||
|
||||
block = kzalloc(sizeof(*block), GFP_KERNEL);
|
||||
if (!block)
|
||||
return -ENOMEM;
|
||||
|
||||
*block_ptr = block;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
block->dev = dev;
|
||||
block->interface = interface;
|
||||
@ -77,12 +75,15 @@ int mqnic_create_sched_block(struct mqnic_if *interface, struct mqnic_sched_bloc
|
||||
block->sched_count = 0;
|
||||
for (rb = block->rb_list; rb->regs; rb++) {
|
||||
if (rb->type == MQNIC_RB_SCHED_RR_TYPE && rb->version == MQNIC_RB_SCHED_RR_VER) {
|
||||
ret = mqnic_create_scheduler(block, &block->sched[block->sched_count],
|
||||
struct mqnic_sched *sched = mqnic_create_scheduler(block,
|
||||
block->sched_count, rb);
|
||||
|
||||
if (ret)
|
||||
if (IS_ERR_OR_NULL(sched)) {
|
||||
ret = PTR_ERR(sched);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
block->sched[block->sched_count] = sched;
|
||||
block->sched_count++;
|
||||
}
|
||||
}
|
||||
@ -91,28 +92,29 @@ int mqnic_create_sched_block(struct mqnic_if *interface, struct mqnic_sched_bloc
|
||||
|
||||
mqnic_deactivate_sched_block(block);
|
||||
|
||||
return 0;
|
||||
return block;
|
||||
|
||||
fail:
|
||||
mqnic_destroy_sched_block(block_ptr);
|
||||
return ret;
|
||||
mqnic_destroy_sched_block(block);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
void mqnic_destroy_sched_block(struct mqnic_sched_block **block_ptr)
|
||||
void mqnic_destroy_sched_block(struct mqnic_sched_block *block)
|
||||
{
|
||||
struct mqnic_sched_block *block = *block_ptr;
|
||||
int k;
|
||||
|
||||
mqnic_deactivate_sched_block(block);
|
||||
|
||||
for (k = 0; k < ARRAY_SIZE(block->sched); k++)
|
||||
if (block->sched[k])
|
||||
mqnic_destroy_scheduler(&block->sched[k]);
|
||||
for (k = 0; k < ARRAY_SIZE(block->sched); k++) {
|
||||
if (block->sched[k]) {
|
||||
mqnic_destroy_scheduler(block->sched[k]);
|
||||
block->sched[k] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (block->rb_list)
|
||||
mqnic_free_reg_block_list(block->rb_list);
|
||||
|
||||
*block_ptr = NULL;
|
||||
kfree(block);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_scheduler(struct mqnic_sched_block *block, struct mqnic_sched **sched_ptr,
|
||||
struct mqnic_sched *mqnic_create_scheduler(struct mqnic_sched_block *block,
|
||||
int index, struct mqnic_reg_block *rb)
|
||||
{
|
||||
struct device *dev = block->dev;
|
||||
@ -43,9 +43,7 @@ int mqnic_create_scheduler(struct mqnic_sched_block *block, struct mqnic_sched *
|
||||
|
||||
sched = kzalloc(sizeof(*sched), GFP_KERNEL);
|
||||
if (!sched)
|
||||
return -ENOMEM;
|
||||
|
||||
*sched_ptr = sched;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
sched->dev = dev;
|
||||
sched->interface = block->interface;
|
||||
@ -69,14 +67,11 @@ int mqnic_create_scheduler(struct mqnic_sched_block *block, struct mqnic_sched *
|
||||
|
||||
mqnic_scheduler_disable(sched);
|
||||
|
||||
return 0;
|
||||
return sched;
|
||||
}
|
||||
|
||||
void mqnic_destroy_scheduler(struct mqnic_sched **sched_ptr)
|
||||
void mqnic_destroy_scheduler(struct mqnic_sched *sched)
|
||||
{
|
||||
struct mqnic_sched *sched = *sched_ptr;
|
||||
*sched_ptr = NULL;
|
||||
|
||||
mqnic_scheduler_disable(sched);
|
||||
|
||||
kfree(sched);
|
||||
|
@ -36,16 +36,14 @@
|
||||
#include <linux/version.h>
|
||||
#include "mqnic.h"
|
||||
|
||||
int mqnic_create_tx_ring(struct mqnic_if *interface, struct mqnic_ring **ring_ptr,
|
||||
struct mqnic_ring *mqnic_create_tx_ring(struct mqnic_if *interface,
|
||||
int index, u8 __iomem *hw_addr)
|
||||
{
|
||||
struct mqnic_ring *ring;
|
||||
|
||||
ring = kzalloc(sizeof(*ring), GFP_KERNEL);
|
||||
if (!ring)
|
||||
return -ENOMEM;
|
||||
|
||||
*ring_ptr = ring;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
ring->dev = interface->dev;
|
||||
ring->interface = interface;
|
||||
@ -64,16 +62,13 @@ 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);
|
||||
|
||||
return 0;
|
||||
return ring;
|
||||
}
|
||||
|
||||
void mqnic_destroy_tx_ring(struct mqnic_ring **ring_ptr)
|
||||
void mqnic_destroy_tx_ring(struct mqnic_ring *ring)
|
||||
{
|
||||
struct mqnic_ring *ring = *ring_ptr;
|
||||
|
||||
mqnic_free_tx_ring(ring);
|
||||
|
||||
*ring_ptr = NULL;
|
||||
kfree(ring);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user