diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2014-03-14 23:49:43 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-03-17 15:47:22 -0400 |
| commit | ad8d475244b4112a0f5331e78d043d3a4c9eb37e (patch) | |
| tree | 6b0f8bee145b6fda7f60fa4aecb223a00774fd4e | |
| parent | b6bacd550c33124ea76291bd84ac42c8d30767eb (diff) | |
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: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/linux/netpoll.h | 11 | ||||
| -rw-r--r-- | net/core/netpoll.c | 14 |
2 files changed, 18 insertions, 7 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index 154f9776056c..ab9aaaff8d04 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
| @@ -65,8 +65,6 @@ void netpoll_print_options(struct netpoll *np); | |||
| 65 | int netpoll_parse_options(struct netpoll *np, char *opt); | 65 | int netpoll_parse_options(struct netpoll *np, char *opt); |
| 66 | int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp); | 66 | int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp); |
| 67 | int netpoll_setup(struct netpoll *np); | 67 | int netpoll_setup(struct netpoll *np); |
| 68 | int netpoll_trap(void); | ||
| 69 | void netpoll_set_trap(int trap); | ||
| 70 | void __netpoll_cleanup(struct netpoll *np); | 68 | void __netpoll_cleanup(struct netpoll *np); |
| 71 | void __netpoll_free_async(struct netpoll *np); | 69 | void __netpoll_free_async(struct netpoll *np); |
| 72 | void netpoll_cleanup(struct netpoll *np); | 70 | void netpoll_cleanup(struct netpoll *np); |
| @@ -82,11 +80,20 @@ static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | |||
| 82 | } | 80 | } |
| 83 | 81 | ||
| 84 | #ifdef CONFIG_NETPOLL_TRAP | 82 | #ifdef CONFIG_NETPOLL_TRAP |
| 83 | int netpoll_trap(void); | ||
| 84 | void netpoll_set_trap(int trap); | ||
| 85 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) | 85 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) |
| 86 | { | 86 | { |
| 87 | return !list_empty(&npinfo->rx_np); | 87 | return !list_empty(&npinfo->rx_np); |
| 88 | } | 88 | } |
| 89 | #else | 89 | #else |
| 90 | static inline int netpoll_trap(void) | ||
| 91 | { | ||
| 92 | return 0; | ||
| 93 | } | ||
| 94 | static inline void netpoll_set_trap(int trap) | ||
| 95 | { | ||
| 96 | } | ||
| 90 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) | 97 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) |
| 91 | { | 98 | { |
| 92 | return false; | 99 | return false; |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 793dc04d2f19..0e45835f1737 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
| @@ -46,7 +46,9 @@ | |||
| 46 | 46 | ||
| 47 | static struct sk_buff_head skb_pool; | 47 | static struct sk_buff_head skb_pool; |
| 48 | 48 | ||
| 49 | #ifdef CONFIG_NETPOLL_TRAP | ||
| 49 | static atomic_t trapped; | 50 | static atomic_t trapped; |
| 51 | #endif | ||
| 50 | 52 | ||
| 51 | DEFINE_STATIC_SRCU(netpoll_srcu); | 53 | DEFINE_STATIC_SRCU(netpoll_srcu); |
| 52 | 54 | ||
| @@ -207,7 +209,7 @@ static void netpoll_poll_dev(struct net_device *dev) | |||
| 207 | } | 209 | } |
| 208 | 210 | ||
| 209 | if (rx_processing) | 211 | if (rx_processing) |
| 210 | atomic_inc(&trapped); | 212 | netpoll_set_trap(1); |
| 211 | 213 | ||
| 212 | ops = dev->netdev_ops; | 214 | ops = dev->netdev_ops; |
| 213 | if (!ops->ndo_poll_controller) { | 215 | if (!ops->ndo_poll_controller) { |
| @@ -221,7 +223,7 @@ static void netpoll_poll_dev(struct net_device *dev) | |||
| 221 | poll_napi(dev, budget); | 223 | poll_napi(dev, budget); |
| 222 | 224 | ||
| 223 | if (rx_processing) | 225 | if (rx_processing) |
| 224 | atomic_dec(&trapped); | 226 | netpoll_set_trap(0); |
| 225 | 227 | ||
| 226 | up(&ni->dev_lock); | 228 | up(&ni->dev_lock); |
| 227 | 229 | ||
| @@ -776,10 +778,10 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo) | |||
| 776 | goto out; | 778 | goto out; |
| 777 | 779 | ||
| 778 | /* check if netpoll clients need ARP */ | 780 | /* check if netpoll clients need ARP */ |
| 779 | if (skb->protocol == htons(ETH_P_ARP) && atomic_read(&trapped)) { | 781 | if (skb->protocol == htons(ETH_P_ARP) && netpoll_trap()) { |
| 780 | skb_queue_tail(&npinfo->neigh_tx, skb); | 782 | skb_queue_tail(&npinfo->neigh_tx, skb); |
| 781 | return 1; | 783 | return 1; |
| 782 | } else if (pkt_is_ns(skb) && atomic_read(&trapped)) { | 784 | } else if (pkt_is_ns(skb) && netpoll_trap()) { |
| 783 | skb_queue_tail(&npinfo->neigh_tx, skb); | 785 | skb_queue_tail(&npinfo->neigh_tx, skb); |
| 784 | return 1; | 786 | return 1; |
| 785 | } | 787 | } |
| @@ -896,7 +898,7 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo) | |||
| 896 | return 1; | 898 | return 1; |
| 897 | 899 | ||
| 898 | out: | 900 | out: |
| 899 | if (atomic_read(&trapped)) { | 901 | if (netpoll_trap()) { |
| 900 | kfree_skb(skb); | 902 | kfree_skb(skb); |
| 901 | return 1; | 903 | return 1; |
| 902 | } | 904 | } |
| @@ -1302,6 +1304,7 @@ out: | |||
| 1302 | } | 1304 | } |
| 1303 | EXPORT_SYMBOL(netpoll_cleanup); | 1305 | EXPORT_SYMBOL(netpoll_cleanup); |
| 1304 | 1306 | ||
| 1307 | #ifdef CONFIG_NETPOLL_TRAP | ||
| 1305 | int netpoll_trap(void) | 1308 | int netpoll_trap(void) |
| 1306 | { | 1309 | { |
| 1307 | return atomic_read(&trapped); | 1310 | return atomic_read(&trapped); |
| @@ -1316,3 +1319,4 @@ void netpoll_set_trap(int trap) | |||
| 1316 | atomic_dec(&trapped); | 1319 | atomic_dec(&trapped); |
| 1317 | } | 1320 | } |
| 1318 | EXPORT_SYMBOL(netpoll_set_trap); | 1321 | EXPORT_SYMBOL(netpoll_set_trap); |
| 1322 | #endif /* CONFIG_NETPOLL_TRAP */ | ||
