diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netpoll.h | 73 |
1 files changed, 40 insertions, 33 deletions
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index ab9aaaff8d04..a0632af88d8b 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h | |||
| @@ -24,32 +24,38 @@ struct netpoll { | |||
| 24 | struct net_device *dev; | 24 | struct net_device *dev; |
| 25 | char dev_name[IFNAMSIZ]; | 25 | char dev_name[IFNAMSIZ]; |
| 26 | const char *name; | 26 | const char *name; |
| 27 | void (*rx_skb_hook)(struct netpoll *np, int source, struct sk_buff *skb, | ||
| 28 | int offset, int len); | ||
| 29 | 27 | ||
| 30 | union inet_addr local_ip, remote_ip; | 28 | union inet_addr local_ip, remote_ip; |
| 31 | bool ipv6; | 29 | bool ipv6; |
| 32 | u16 local_port, remote_port; | 30 | u16 local_port, remote_port; |
| 33 | u8 remote_mac[ETH_ALEN]; | 31 | u8 remote_mac[ETH_ALEN]; |
| 34 | 32 | ||
| 35 | struct list_head rx; /* rx_np list element */ | ||
| 36 | struct work_struct cleanup_work; | 33 | struct work_struct cleanup_work; |
| 34 | |||
| 35 | #ifdef CONFIG_NETPOLL_TRAP | ||
| 36 | void (*rx_skb_hook)(struct netpoll *np, int source, struct sk_buff *skb, | ||
| 37 | int offset, int len); | ||
| 38 | struct list_head rx; /* rx_np list element */ | ||
| 39 | #endif | ||
| 37 | }; | 40 | }; |
| 38 | 41 | ||
| 39 | struct netpoll_info { | 42 | struct netpoll_info { |
| 40 | atomic_t refcnt; | 43 | atomic_t refcnt; |
| 41 | 44 | ||
| 42 | spinlock_t rx_lock; | ||
| 43 | struct semaphore dev_lock; | 45 | struct semaphore dev_lock; |
| 44 | struct list_head rx_np; /* netpolls that registered an rx_skb_hook */ | ||
| 45 | 46 | ||
| 46 | struct sk_buff_head neigh_tx; /* list of neigh requests to reply to */ | ||
| 47 | struct sk_buff_head txq; | 47 | struct sk_buff_head txq; |
| 48 | 48 | ||
| 49 | struct delayed_work tx_work; | 49 | struct delayed_work tx_work; |
| 50 | 50 | ||
| 51 | struct netpoll *netpoll; | 51 | struct netpoll *netpoll; |
| 52 | struct rcu_head rcu; | 52 | struct rcu_head rcu; |
| 53 | |||
| 54 | #ifdef CONFIG_NETPOLL_TRAP | ||
| 55 | spinlock_t rx_lock; | ||
| 56 | struct list_head rx_np; /* netpolls that registered an rx_skb_hook */ | ||
| 57 | struct sk_buff_head neigh_tx; /* list of neigh requests to reply to */ | ||
| 58 | #endif | ||
| 53 | }; | 59 | }; |
| 54 | 60 | ||
| 55 | #ifdef CONFIG_NETPOLL | 61 | #ifdef CONFIG_NETPOLL |
| @@ -68,7 +74,6 @@ int netpoll_setup(struct netpoll *np); | |||
| 68 | void __netpoll_cleanup(struct netpoll *np); | 74 | void __netpoll_cleanup(struct netpoll *np); |
| 69 | void __netpoll_free_async(struct netpoll *np); | 75 | void __netpoll_free_async(struct netpoll *np); |
| 70 | void netpoll_cleanup(struct netpoll *np); | 76 | void netpoll_cleanup(struct netpoll *np); |
| 71 | int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo); | ||
| 72 | void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, | 77 | void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb, |
| 73 | struct net_device *dev); | 78 | struct net_device *dev); |
| 74 | static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | 79 | static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) |
| @@ -82,25 +87,12 @@ static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb) | |||
| 82 | #ifdef CONFIG_NETPOLL_TRAP | 87 | #ifdef CONFIG_NETPOLL_TRAP |
| 83 | int netpoll_trap(void); | 88 | int netpoll_trap(void); |
| 84 | void netpoll_set_trap(int trap); | 89 | void netpoll_set_trap(int trap); |
| 90 | int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo); | ||
| 85 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) | 91 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) |
| 86 | { | 92 | { |
| 87 | return !list_empty(&npinfo->rx_np); | 93 | return !list_empty(&npinfo->rx_np); |
| 88 | } | 94 | } |
| 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 | } | ||
| 97 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) | ||
| 98 | { | ||
| 99 | return false; | ||
| 100 | } | ||
| 101 | #endif | ||
| 102 | 95 | ||
| 103 | #ifdef CONFIG_NETPOLL | ||
| 104 | static inline bool netpoll_rx_on(struct sk_buff *skb) | 96 | static inline bool netpoll_rx_on(struct sk_buff *skb) |
| 105 | { | 97 | { |
| 106 | struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo); | 98 | struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo); |
| @@ -138,6 +130,33 @@ static inline int netpoll_receive_skb(struct sk_buff *skb) | |||
| 138 | return 0; | 130 | return 0; |
| 139 | } | 131 | } |
| 140 | 132 | ||
| 133 | #else | ||
| 134 | static inline int netpoll_trap(void) | ||
| 135 | { | ||
| 136 | return 0; | ||
| 137 | } | ||
| 138 | static inline void netpoll_set_trap(int trap) | ||
| 139 | { | ||
| 140 | } | ||
| 141 | static inline bool netpoll_rx_processing(struct netpoll_info *npinfo) | ||
| 142 | { | ||
| 143 | return false; | ||
| 144 | } | ||
| 145 | static inline bool netpoll_rx(struct sk_buff *skb) | ||
| 146 | { | ||
| 147 | return false; | ||
| 148 | } | ||
| 149 | static inline bool netpoll_rx_on(struct sk_buff *skb) | ||
| 150 | { | ||
| 151 | return false; | ||
| 152 | } | ||
| 153 | static inline int netpoll_receive_skb(struct sk_buff *skb) | ||
| 154 | { | ||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | #endif | ||
| 158 | |||
| 159 | #ifdef CONFIG_NETPOLL | ||
| 141 | static inline void *netpoll_poll_lock(struct napi_struct *napi) | 160 | static inline void *netpoll_poll_lock(struct napi_struct *napi) |
| 142 | { | 161 | { |
| 143 | struct net_device *dev = napi->dev; | 162 | struct net_device *dev = napi->dev; |
| @@ -166,18 +185,6 @@ static inline bool netpoll_tx_running(struct net_device *dev) | |||
| 166 | } | 185 | } |
| 167 | 186 | ||
| 168 | #else | 187 | #else |
| 169 | static inline bool netpoll_rx(struct sk_buff *skb) | ||
| 170 | { | ||
| 171 | return false; | ||
| 172 | } | ||
| 173 | static inline bool netpoll_rx_on(struct sk_buff *skb) | ||
| 174 | { | ||
| 175 | return false; | ||
| 176 | } | ||
| 177 | static inline int netpoll_receive_skb(struct sk_buff *skb) | ||
| 178 | { | ||
| 179 | return 0; | ||
| 180 | } | ||
| 181 | static inline void *netpoll_poll_lock(struct napi_struct *napi) | 188 | static inline void *netpoll_poll_lock(struct napi_struct *napi) |
| 182 | { | 189 | { |
| 183 | return NULL; | 190 | return NULL; |
