[NETPOLL]: Introduce a netpoll_info struct

This patch introduces a netpoll_info structure, which the struct net_device
will now point to instead of pointing to a struct netpoll.  The reason for
this is two-fold: 1) fields such as the rx_flags, poll_owner, and poll_lock
should be maintained per net_device, not per netpoll;  and 2) this is a first
step in providing support for multiple netpoll clients to register against the
same net_device.

The struct netpoll is now pointed to by the netpoll_info structure.  As
such, the previous behaviour of the code is preserved.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jeff Moyer
2005-06-22 22:05:31 -07:00
committed by David S. Miller
parent 6ca4f65e6b
commit 115c1d6e61
3 changed files with 57 additions and 29 deletions

View File

@ -16,14 +16,18 @@ struct netpoll;
struct netpoll {
struct net_device *dev;
char dev_name[16], *name;
int rx_flags;
void (*rx_hook)(struct netpoll *, int, char *, int);
void (*drop)(struct sk_buff *skb);
u32 local_ip, remote_ip;
u16 local_port, remote_port;
unsigned char local_mac[6], remote_mac[6];
};
struct netpoll_info {
spinlock_t poll_lock;
int poll_owner;
int rx_flags;
struct netpoll *np;
};
void netpoll_poll(struct netpoll *np);
@ -39,22 +43,27 @@ void netpoll_queue(struct sk_buff *skb);
#ifdef CONFIG_NETPOLL
static inline int netpoll_rx(struct sk_buff *skb)
{
return skb->dev->np && skb->dev->np->rx_flags && __netpoll_rx(skb);
struct netpoll_info *npinfo = skb->dev->npinfo;
if (!npinfo || !npinfo->rx_flags)
return 0;
return npinfo->np && __netpoll_rx(skb);
}
static inline void netpoll_poll_lock(struct net_device *dev)
{
if (dev->np) {
spin_lock(&dev->np->poll_lock);
dev->np->poll_owner = smp_processor_id();
if (dev->npinfo) {
spin_lock(&dev->npinfo->poll_lock);
dev->npinfo->poll_owner = smp_processor_id();
}
}
static inline void netpoll_poll_unlock(struct net_device *dev)
{
if (dev->np) {
dev->np->poll_owner = -1;
spin_unlock(&dev->np->poll_lock);
if (dev->npinfo) {
dev->npinfo->poll_owner = -1;
spin_unlock(&dev->npinfo->poll_lock);
}
}