summaryrefslogtreecommitdiffstats
path: root/include/linux/netpoll.h
diff options
context:
space:
mode:
authorJeff Moyer <jmoyer@redhat.com>2005-06-22 22:05:59 -0700
committerDavid S. Miller <davem@davemloft.net>2005-06-22 22:05:59 -0700
commitfbeec2e1552949002065435c9829dc244ad85407 (patch)
treed97dc663bbef4bf59a1858b23a327f14043c33d1 /include/linux/netpoll.h
parent115c1d6e61b70851d9a363328c3b8d4c2559a1d3 (diff)
downloadlinux-fbeec2e1552949002065435c9829dc244ad85407.tar.gz
linux-fbeec2e1552949002065435c9829dc244ad85407.tar.bz2
linux-fbeec2e1552949002065435c9829dc244ad85407.zip
[NETPOLL]: allow multiple netpoll_clients to register against one interface
This patch provides support for registering multiple netpoll clients to the same network device. Only one of these clients may register an rx_hook, however. In practice, this restriction has not been problematic. It is worth mentioning, though, that the current design can be easily extended to allow for the registration of multiple rx_hooks. The basic idea of the patch is that the rx_np pointer in the netpoll_info structure points to the struct netpoll that has rx_hook filled in. Aside from this one case, there is no need for a pointer from the struct net_device to an individual struct netpoll. A lock is introduced to protect the setting and clearing of the np_rx pointer. The pointer will only be cleared upon netpoll client module removal, and the lock should be uncontested. Signed-off-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netpoll.h')
-rw-r--r--include/linux/netpoll.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 388cd91bc7a6..bcd0ac33f592 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -27,7 +27,8 @@ struct netpoll_info {
spinlock_t poll_lock;
int poll_owner;
int rx_flags;
- struct netpoll *np;
+ spinlock_t rx_lock;
+ struct netpoll *rx_np; /* netpoll that registered an rx_hook */
};
void netpoll_poll(struct netpoll *np);
@@ -44,11 +45,19 @@ void netpoll_queue(struct sk_buff *skb);
static inline int netpoll_rx(struct sk_buff *skb)
{
struct netpoll_info *npinfo = skb->dev->npinfo;
+ unsigned long flags;
+ int ret = 0;
- if (!npinfo || !npinfo->rx_flags)
+ if (!npinfo || (!npinfo->rx_np && !npinfo->rx_flags))
return 0;
- return npinfo->np && __netpoll_rx(skb);
+ spin_lock_irqsave(&npinfo->rx_lock, flags);
+ /* check rx_flags again with the lock held */
+ if (npinfo->rx_flags && __netpoll_rx(skb))
+ ret = 1;
+ spin_unlock_irqrestore(&npinfo->rx_lock, flags);
+
+ return ret;
}
static inline void netpoll_poll_lock(struct net_device *dev)