From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Eugene Surovegin <ebs@ebshome.net>
Subject: [PATCH] add init_dummy_netdev() for napi only dummy intefaces
Date: Tue, 12 Dec 2006 16:27:38 +1100 [thread overview]
Message-ID: <1165901258.11914.32.camel@localhost.localdomain> (raw)
This adds an init_dummy_netdev() function that gets a network device
structure (allocation and lifetime entirely under caller's control) and
initialize the minimum amount of fields so it can be used to schedule
NAPI polls without registering a full blown interface. This is to be
used by drivers that need to tie several hardware interfaces to a single
NAPI poll scheduler due to HW limitations.
It also updates the ibm_emac driver to use that instead of doing it's
own initializations by hand.
Symbol is exported GPL only a I don't think we want binary drivers doing
that sort of acrobatics (if we want them at all).
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
I'm shit at inventing function names so feel free to come up with
something nicer !
Index: linux-cell/drivers/net/ibm_emac/ibm_emac_mal.c
===================================================================
--- linux-cell.orig/drivers/net/ibm_emac/ibm_emac_mal.c 2006-12-12 16:13:27.000000000 +1100
+++ linux-cell/drivers/net/ibm_emac/ibm_emac_mal.c 2006-12-12 16:23:21.000000000 +1100
@@ -426,11 +426,10 @@ static int __init mal_probe(struct ocp_d
mal->def = ocpdev->def;
INIT_LIST_HEAD(&mal->poll_list);
- set_bit(__LINK_STATE_START, &mal->poll_dev.state);
+ init_dummy_netdev(&mal->poll_dev);
mal->poll_dev.weight = CONFIG_IBM_EMAC_POLL_WEIGHT;
mal->poll_dev.poll = mal_poll;
mal->poll_dev.priv = mal;
- atomic_set(&mal->poll_dev.refcnt, 1);
INIT_LIST_HEAD(&mal->list);
Index: linux-cell/include/linux/netdevice.h
===================================================================
--- linux-cell.orig/include/linux/netdevice.h 2006-12-12 16:06:24.000000000 +1100
+++ linux-cell/include/linux/netdevice.h 2006-12-12 16:12:17.000000000 +1100
@@ -454,6 +454,7 @@ struct net_device
NETREG_UNREGISTERING, /* called unregister_netdevice */
NETREG_UNREGISTERED, /* completed unregister todo */
NETREG_RELEASED, /* called free_netdev */
+ NETREG_DUMMY, /* dummy device for NAPI poll */
} reg_state;
/* Called after device is detached from network. */
@@ -581,6 +582,7 @@ extern int dev_close(struct net_device
extern int dev_queue_xmit(struct sk_buff *skb);
extern int register_netdevice(struct net_device *dev);
extern int unregister_netdevice(struct net_device *dev);
+extern int init_dummy_netdev(struct net_device *dev);
extern void free_netdev(struct net_device *dev);
extern void synchronize_net(void);
extern int register_netdevice_notifier(struct notifier_block *nb);
Index: linux-cell/net/core/dev.c
===================================================================
--- linux-cell.orig/net/core/dev.c 2006-12-12 16:01:59.000000000 +1100
+++ linux-cell/net/core/dev.c 2006-12-12 16:23:23.000000000 +1100
@@ -3007,6 +3007,42 @@ out_err:
}
/**
+ * init_dummy_netdev - init a dummy network device for NAPI
+ * @dev: device to init
+ *
+ * This takes a network device structure and initialize the minimum
+ * amount of fields so it can be used to schedule NAPI polls without
+ * registering a full blown interface. This is to be used by drivers
+ * that need to tie several hardware interfaces to a single NAPI
+ * poll scheduler due to HW limitations.
+ */
+int init_dummy_netdev(struct net_device *dev)
+{
+ /* Clear everything. Note we don't initialize spinlocks
+ * are they aren't supposed to be taken by any of the
+ * NAPI code and this dummy netdev is supposed to be
+ * only ever used for NAPI polls
+ */
+ memset(dev, 0, sizeof(struct net_device));
+
+ /* make sure we BUG if trying to hit standard
+ * register/unregister code path
+ */
+ dev->reg_state = NETREG_DUMMY;
+
+ /* initialize the ref count */
+ atomic_set(&dev->refcnt, 1);
+
+ /* a dummy interface is started by default */
+ set_bit(__LINK_STATE_PRESENT, &dev->state);
+ set_bit(__LINK_STATE_START, &dev->state);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(init_dummy_netdev);
+
+
+/**
* register_netdev - register a network device
* @dev: device to register
*
next reply other threads:[~2006-12-12 5:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-12 5:27 Benjamin Herrenschmidt [this message]
2006-12-13 19:35 ` [PATCH] add init_dummy_netdev() for napi only dummy intefaces Stephen Hemminger
2006-12-13 20:42 ` Benjamin Herrenschmidt
2006-12-13 21:06 ` Stephen Hemminger
2006-12-13 23:46 ` [RFC] split NAPI from network device Stephen Hemminger
2006-12-14 20:01 ` Benjamin Herrenschmidt
2007-02-21 5:31 ` David Miller
2007-02-21 7:39 ` Divy Le Ray
2007-02-21 7:47 ` David Miller
2007-02-21 23:24 ` Benjamin Herrenschmidt
2007-02-22 11:18 ` David Miller
2007-02-22 12:24 ` Divy Le Ray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1165901258.11914.32.camel@localhost.localdomain \
--to=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=ebs@ebshome.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).