Commit ad8d4752 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

netpoll: Move netpoll_trap under CONFIG_NETPOLL_TRAP

Now that we no longer need to receive packets to safely drain the
network drivers receive queue move netpoll_trap and netpoll_set_trap
under CONFIG_NETPOLL_TRAP

Making netpoll_trap and netpoll_set_trap noop inline functions
when CONFIG_NETPOLL_TRAP is not set.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b6bacd55
...@@ -65,8 +65,6 @@ void netpoll_print_options(struct netpoll *np); ...@@ -65,8 +65,6 @@ void netpoll_print_options(struct netpoll *np);
int netpoll_parse_options(struct netpoll *np, char *opt); int netpoll_parse_options(struct netpoll *np, char *opt);
int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp); int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp);
int netpoll_setup(struct netpoll *np); int netpoll_setup(struct netpoll *np);
int netpoll_trap(void);
void netpoll_set_trap(int trap);
void __netpoll_cleanup(struct netpoll *np); void __netpoll_cleanup(struct netpoll *np);
void __netpoll_free_async(struct netpoll *np); void __netpoll_free_async(struct netpoll *np);
void netpoll_cleanup(struct netpoll *np); void netpoll_cleanup(struct netpoll *np);
...@@ -82,11 +80,20 @@ static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) ...@@ -82,11 +80,20 @@ static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
} }
#ifdef CONFIG_NETPOLL_TRAP #ifdef CONFIG_NETPOLL_TRAP
int netpoll_trap(void);
void netpoll_set_trap(int trap);
static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) static inline bool netpoll_rx_processing(struct netpoll_info *npinfo)
{ {
return !list_empty(&npinfo->rx_np); return !list_empty(&npinfo->rx_np);
} }
#else #else
static inline int netpoll_trap(void)
{
return 0;
}
static inline void netpoll_set_trap(int trap)
{
}
static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) static inline bool netpoll_rx_processing(struct netpoll_info *npinfo)
{ {
return false; return false;
......
...@@ -46,7 +46,9 @@ ...@@ -46,7 +46,9 @@
static struct sk_buff_head skb_pool; static struct sk_buff_head skb_pool;
#ifdef CONFIG_NETPOLL_TRAP
static atomic_t trapped; static atomic_t trapped;
#endif
DEFINE_STATIC_SRCU(netpoll_srcu); DEFINE_STATIC_SRCU(netpoll_srcu);
...@@ -207,7 +209,7 @@ static void netpoll_poll_dev(struct net_device *dev) ...@@ -207,7 +209,7 @@ static void netpoll_poll_dev(struct net_device *dev)
} }
if (rx_processing) if (rx_processing)
atomic_inc(&trapped); netpoll_set_trap(1);
ops = dev->netdev_ops; ops = dev->netdev_ops;
if (!ops->ndo_poll_controller) { if (!ops->ndo_poll_controller) {
...@@ -221,7 +223,7 @@ static void netpoll_poll_dev(struct net_device *dev) ...@@ -221,7 +223,7 @@ static void netpoll_poll_dev(struct net_device *dev)
poll_napi(dev, budget); poll_napi(dev, budget);
if (rx_processing) if (rx_processing)
atomic_dec(&trapped); netpoll_set_trap(0);
up(&ni->dev_lock); up(&ni->dev_lock);
...@@ -776,10 +778,10 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo) ...@@ -776,10 +778,10 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
goto out; goto out;
/* check if netpoll clients need ARP */ /* check if netpoll clients need ARP */
if (skb->protocol == htons(ETH_P_ARP) && atomic_read(&trapped)) { if (skb->protocol == htons(ETH_P_ARP) && netpoll_trap()) {
skb_queue_tail(&npinfo->neigh_tx, skb); skb_queue_tail(&npinfo->neigh_tx, skb);
return 1; return 1;
} else if (pkt_is_ns(skb) && atomic_read(&trapped)) { } else if (pkt_is_ns(skb) && netpoll_trap()) {
skb_queue_tail(&npinfo->neigh_tx, skb); skb_queue_tail(&npinfo->neigh_tx, skb);
return 1; return 1;
} }
...@@ -896,7 +898,7 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo) ...@@ -896,7 +898,7 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
return 1; return 1;
out: out:
if (atomic_read(&trapped)) { if (netpoll_trap()) {
kfree_skb(skb); kfree_skb(skb);
return 1; return 1;
} }
...@@ -1302,6 +1304,7 @@ void netpoll_cleanup(struct netpoll *np) ...@@ -1302,6 +1304,7 @@ void netpoll_cleanup(struct netpoll *np)
} }
EXPORT_SYMBOL(netpoll_cleanup); EXPORT_SYMBOL(netpoll_cleanup);
#ifdef CONFIG_NETPOLL_TRAP
int netpoll_trap(void) int netpoll_trap(void)
{ {
return atomic_read(&trapped); return atomic_read(&trapped);
...@@ -1316,3 +1319,4 @@ void netpoll_set_trap(int trap) ...@@ -1316,3 +1319,4 @@ void netpoll_set_trap(int trap)
atomic_dec(&trapped); atomic_dec(&trapped);
} }
EXPORT_SYMBOL(netpoll_set_trap); EXPORT_SYMBOL(netpoll_set_trap);
#endif /* CONFIG_NETPOLL_TRAP */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment