Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix known issues in the snull driver #92

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions snull/snull.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ static struct snull_packet *snull_get_tx_buffer(struct net_device *dev)
pkt = priv->ppool;
if(!pkt) {
PDEBUG("Out of Pool\n");
return pkt;
goto out;
}
priv->ppool = pkt->next;
if (priv->ppool == NULL) {
printk (KERN_INFO "Pool empty\n");
netif_stop_queue(dev);
}

out:
spin_unlock_irqrestore(&priv->lock, flags);
return pkt;
}
Expand Down Expand Up @@ -426,9 +428,9 @@ static void snull_napi_interrupt(int irq, void *dev_id, struct pt_regs *regs)
/* retrieve statusword: real netdevices use I/O instructions */
statusword = priv->status;
priv->status = 0;
if (statusword & SNULL_RX_INTR) {
if (statusword & SNULL_RX_INTR && napi_schedule_prep(&priv->napi)) {
snull_rx_ints(dev, 0); /* Disable further interrupts */
napi_schedule(&priv->napi);
__napi_schedule(&priv->napi);
}
if (statusword & SNULL_TX_INTR) {
/* a transmission is over: free the skb */
Expand Down Expand Up @@ -750,28 +752,29 @@ static void snull_cleanup(void)

static int snull_init_module(void)
{
int result, i, ret = -ENOMEM;
int result, i, ret = 0;

snull_interrupt = use_napi ? snull_napi_interrupt : snull_regular_interrupt;

/* Allocate the devices */
snull_devs[0] = alloc_netdev(sizeof(struct snull_priv), "sn%d",
NET_NAME_UNKNOWN, snull_init);
snull_devs[1] = alloc_netdev(sizeof(struct snull_priv), "sn%d",
/* Allocate and register the devices */
for (i = 0; i < 2; i++) {
snull_devs[i] = alloc_netdev(sizeof(struct snull_priv), "sn%d",
NET_NAME_UNKNOWN, snull_init);
if (snull_devs[0] == NULL || snull_devs[1] == NULL)
goto out;

ret = -ENODEV;
for (i = 0; i < 2; i++)
if ((result = register_netdev(snull_devs[i])))
if (snull_devs[i] == NULL) {
ret = -ENOMEM;
break;
}

if ((result = register_netdev(snull_devs[i]))) {
printk("snull: error %i registering device \"%s\"\n",
result, snull_devs[i]->name);
else
ret = 0;
out:
if (ret)
snull_cleanup();
free_netdev(snull_devs[i]);
ret = -ENODEV;
break;
}
}

return ret;
}

Expand Down