aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>2007-07-06 16:36:20 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-07-11 01:16:21 -0400
commitf25f4e44808f0f6c9875d94ef1c41ef86c288eb2 (patch)
treed7809dd5e957f1626185326d0c3438ff9a04d350 /include
parenta093bf006e09a305e95ff0938c0a18b7520aef67 (diff)
[CORE] Stack changes to add multiqueue hardware support API
Add the multiqueue hardware device support API to the core network stack. Allow drivers to allocate multiple queues and manage them at the netdev level if they choose to do so. Added a new field to sk_buff, namely queue_mapping, for drivers to know which tx_ring to select based on OS classification of the flow. Signed-off-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/linux/etherdevice.h3
-rw-r--r--include/linux/netdevice.h80
-rw-r--r--include/linux/skbuff.h25
3 files changed, 99 insertions, 9 deletions
diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
index f48eb89efd0f..6cdb97365e47 100644
--- a/include/linux/etherdevice.h
+++ b/include/linux/etherdevice.h
@@ -39,7 +39,8 @@ extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev
39extern int eth_header_cache(struct neighbour *neigh, 39extern int eth_header_cache(struct neighbour *neigh,
40 struct hh_cache *hh); 40 struct hh_cache *hh);
41 41
42extern struct net_device *alloc_etherdev(int sizeof_priv); 42extern struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count);
43#define alloc_etherdev(sizeof_priv) alloc_etherdev_mq(sizeof_priv, 1)
43 44
44/** 45/**
45 * is_zero_ether_addr - Determine if give Ethernet address is all zeros. 46 * is_zero_ether_addr - Determine if give Ethernet address is all zeros.
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 2c0cc19edfb2..9817821729c4 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -108,6 +108,14 @@ struct wireless_dev;
108#define MAX_HEADER (LL_MAX_HEADER + 48) 108#define MAX_HEADER (LL_MAX_HEADER + 48)
109#endif 109#endif
110 110
111struct net_device_subqueue
112{
113 /* Give a control state for each queue. This struct may contain
114 * per-queue locks in the future.
115 */
116 unsigned long state;
117};
118
111/* 119/*
112 * Network device statistics. Akin to the 2.0 ether stats but 120 * Network device statistics. Akin to the 2.0 ether stats but
113 * with byte counters. 121 * with byte counters.
@@ -331,6 +339,7 @@ struct net_device
331#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */ 339#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
332#define NETIF_F_GSO 2048 /* Enable software GSO. */ 340#define NETIF_F_GSO 2048 /* Enable software GSO. */
333#define NETIF_F_LLTX 4096 /* LockLess TX */ 341#define NETIF_F_LLTX 4096 /* LockLess TX */
342#define NETIF_F_MULTI_QUEUE 16384 /* Has multiple TX/RX queues */
334 343
335 /* Segmentation offload features */ 344 /* Segmentation offload features */
336#define NETIF_F_GSO_SHIFT 16 345#define NETIF_F_GSO_SHIFT 16
@@ -557,6 +566,10 @@ struct net_device
557 566
558 /* rtnetlink link ops */ 567 /* rtnetlink link ops */
559 const struct rtnl_link_ops *rtnl_link_ops; 568 const struct rtnl_link_ops *rtnl_link_ops;
569
570 /* The TX queue control structures */
571 unsigned int egress_subqueue_count;
572 struct net_device_subqueue egress_subqueue[0];
560}; 573};
561#define to_net_dev(d) container_of(d, struct net_device, dev) 574#define to_net_dev(d) container_of(d, struct net_device, dev)
562 575
@@ -565,9 +578,7 @@ struct net_device
565 578
566static inline void *netdev_priv(const struct net_device *dev) 579static inline void *netdev_priv(const struct net_device *dev)
567{ 580{
568 return (char *)dev + ((sizeof(struct net_device) 581 return dev->priv;
569 + NETDEV_ALIGN_CONST)
570 & ~NETDEV_ALIGN_CONST);
571} 582}
572 583
573#define SET_MODULE_OWNER(dev) do { } while (0) 584#define SET_MODULE_OWNER(dev) do { } while (0)
@@ -719,6 +730,62 @@ static inline int netif_running(const struct net_device *dev)
719 return test_bit(__LINK_STATE_START, &dev->state); 730 return test_bit(__LINK_STATE_START, &dev->state);
720} 731}
721 732
733/*
734 * Routines to manage the subqueues on a device. We only need start
735 * stop, and a check if it's stopped. All other device management is
736 * done at the overall netdevice level.
737 * Also test the device if we're multiqueue.
738 */
739static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
740{
741#ifdef CONFIG_NETDEVICES_MULTIQUEUE
742 clear_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
743#endif
744}
745
746static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
747{
748#ifdef CONFIG_NETDEVICES_MULTIQUEUE
749#ifdef CONFIG_NETPOLL_TRAP
750 if (netpoll_trap())
751 return;
752#endif
753 set_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state);
754#endif
755}
756
757static inline int netif_subqueue_stopped(const struct net_device *dev,
758 u16 queue_index)
759{
760#ifdef CONFIG_NETDEVICES_MULTIQUEUE
761 return test_bit(__LINK_STATE_XOFF,
762 &dev->egress_subqueue[queue_index].state);
763#else
764 return 0;
765#endif
766}
767
768static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
769{
770#ifdef CONFIG_NETDEVICES_MULTIQUEUE
771#ifdef CONFIG_NETPOLL_TRAP
772 if (netpoll_trap())
773 return;
774#endif
775 if (test_and_clear_bit(__LINK_STATE_XOFF,
776 &dev->egress_subqueue[queue_index].state))
777 __netif_schedule(dev);
778#endif
779}
780
781static inline int netif_is_multiqueue(const struct net_device *dev)
782{
783#ifdef CONFIG_NETDEVICES_MULTIQUEUE
784 return (!!(NETIF_F_MULTI_QUEUE & dev->features));
785#else
786 return 0;
787#endif
788}
722 789
723/* Use this variant when it is known for sure that it 790/* Use this variant when it is known for sure that it
724 * is executing from interrupt context. 791 * is executing from interrupt context.
@@ -1009,8 +1076,11 @@ static inline void netif_tx_disable(struct net_device *dev)
1009extern void ether_setup(struct net_device *dev); 1076extern void ether_setup(struct net_device *dev);
1010 1077
1011/* Support for loadable net-drivers */ 1078/* Support for loadable net-drivers */
1012extern struct net_device *alloc_netdev(int sizeof_priv, const char *name, 1079extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
1013 void (*setup)(struct net_device *)); 1080 void (*setup)(struct net_device *),
1081 unsigned int queue_count);
1082#define alloc_netdev(sizeof_priv, name, setup) \
1083 alloc_netdev_mq(sizeof_priv, name, setup, 1)
1014extern int register_netdev(struct net_device *dev); 1084extern int register_netdev(struct net_device *dev);
1015extern void unregister_netdev(struct net_device *dev); 1085extern void unregister_netdev(struct net_device *dev);
1016/* Functions used for secondary unicast and multicast support */ 1086/* Functions used for secondary unicast and multicast support */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 881fe80f01d0..2d6a14f5f2f1 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -196,7 +196,6 @@ typedef unsigned char *sk_buff_data_t;
196 * @sk: Socket we are owned by 196 * @sk: Socket we are owned by
197 * @tstamp: Time we arrived 197 * @tstamp: Time we arrived
198 * @dev: Device we arrived on/are leaving by 198 * @dev: Device we arrived on/are leaving by
199 * @iif: ifindex of device we arrived on
200 * @transport_header: Transport layer header 199 * @transport_header: Transport layer header
201 * @network_header: Network layer header 200 * @network_header: Network layer header
202 * @mac_header: Link layer header 201 * @mac_header: Link layer header
@@ -231,6 +230,8 @@ typedef unsigned char *sk_buff_data_t;
231 * @nfctinfo: Relationship of this skb to the connection 230 * @nfctinfo: Relationship of this skb to the connection
232 * @nfct_reasm: netfilter conntrack re-assembly pointer 231 * @nfct_reasm: netfilter conntrack re-assembly pointer
233 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c 232 * @nf_bridge: Saved data about a bridged frame - see br_netfilter.c
233 * @iif: ifindex of device we arrived on
234 * @queue_mapping: Queue mapping for multiqueue devices
234 * @tc_index: Traffic control index 235 * @tc_index: Traffic control index
235 * @tc_verd: traffic control verdict 236 * @tc_verd: traffic control verdict
236 * @dma_cookie: a cookie to one of several possible DMA operations 237 * @dma_cookie: a cookie to one of several possible DMA operations
@@ -246,8 +247,6 @@ struct sk_buff {
246 struct sock *sk; 247 struct sock *sk;
247 ktime_t tstamp; 248 ktime_t tstamp;
248 struct net_device *dev; 249 struct net_device *dev;
249 int iif;
250 /* 4 byte hole on 64 bit*/
251 250
252 struct dst_entry *dst; 251 struct dst_entry *dst;
253 struct sec_path *sp; 252 struct sec_path *sp;
@@ -290,12 +289,18 @@ struct sk_buff {
290#ifdef CONFIG_BRIDGE_NETFILTER 289#ifdef CONFIG_BRIDGE_NETFILTER
291 struct nf_bridge_info *nf_bridge; 290 struct nf_bridge_info *nf_bridge;
292#endif 291#endif
292
293 int iif;
294 __u16 queue_mapping;
295
293#ifdef CONFIG_NET_SCHED 296#ifdef CONFIG_NET_SCHED
294 __u16 tc_index; /* traffic control index */ 297 __u16 tc_index; /* traffic control index */
295#ifdef CONFIG_NET_CLS_ACT 298#ifdef CONFIG_NET_CLS_ACT
296 __u16 tc_verd; /* traffic control verdict */ 299 __u16 tc_verd; /* traffic control verdict */
297#endif 300#endif
298#endif 301#endif
302 /* 2 byte hole */
303
299#ifdef CONFIG_NET_DMA 304#ifdef CONFIG_NET_DMA
300 dma_cookie_t dma_cookie; 305 dma_cookie_t dma_cookie;
301#endif 306#endif
@@ -1725,6 +1730,20 @@ static inline void skb_init_secmark(struct sk_buff *skb)
1725{ } 1730{ }
1726#endif 1731#endif
1727 1732
1733static inline void skb_set_queue_mapping(struct sk_buff *skb, u16 queue_mapping)
1734{
1735#ifdef CONFIG_NETDEVICES_MULTIQUEUE
1736 skb->queue_mapping = queue_mapping;
1737#endif
1738}
1739
1740static inline void skb_copy_queue_mapping(struct sk_buff *to, const struct sk_buff *from)
1741{
1742#ifdef CONFIG_NETDEVICES_MULTIQUEUE
1743 to->queue_mapping = from->queue_mapping;
1744#endif
1745}
1746
1728static inline int skb_is_gso(const struct sk_buff *skb) 1747static inline int skb_is_gso(const struct sk_buff *skb)
1729{ 1748{
1730 return skb_shinfo(skb)->gso_size; 1749 return skb_shinfo(skb)->gso_size;