Introduce n-tuple ethtool support
Subsystems (3)
v5 cover Introduce n-tuple ethtool support
One more round of fixes, based on feedback from Patrick McHardy
1) Change the list count to an unsigned value
2) Fix a memory leak
3) Removed an unnecessary list traversal in the ethtool core
4) Moved all list destruction to a helper function, allowing the driver to control when it clears the list (aside from when free_netdev() kills the cached list).
---
Peter Waskiewicz (3):
ixgbe: Bump driver version up
ixgbe: Add support for the new ethtool n-tuple programming interface
ethtool: Introduce n-tuple filter programming support
drivers/net/ixgbe/ixgbe.h | 4 drivers/net/ixgbe/ixgbe_82599.c | 106 ++++++++++-- drivers/net/ixgbe/ixgbe_ethtool.c | 111 ++++++++++++ drivers/net/ixgbe/ixgbe_main.c | 18 ++ drivers/net/ixgbe/ixgbe_type.h | 9 + include/linux/ethtool.h | 50 ++++++ include/linux/netdevice.h | 3 net/core/dev.c | 6 + net/core/ethtool.c | 332 +++++++++++++++++++++++++++++++++++++ 9 files changed, 619 insertions(+), 20 deletions(-)
Signature · 2 lines
Cheers, Jeff
PATCH v5 1/3 ethtool: Introduce n-tuple filter programming support
From: Peter Waskiewicz <[email protected]>
This patchset enables the ethtool layer to program n-tuple filters to an underlying device. The idea is to allow capable hardware to have static rules applied that can assist steering flows into appropriate queues.
Hardware that is known to support these types of filters today are ixgbe and niu.
---
include/linux/ethtool.h | 50 +++++++ include/linux/netdevice.h | 3 net/core/dev.c | 6 + net/core/ethtool.c | 332 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 390 insertions(+), 1 deletions(-)
include/linux/ethtool.h +50 -0
@@ -14,6 +14,7 @@#define _LINUX_ETHTOOL_H#include <linux/types.h> +#include <linux/rculist.h> /* This should work for both 32 and 64 bit userland. */ struct ethtool_cmd {
@@ -242,6 +243,7 @@ enum ethtool_stringset {ETH_SS_TEST =0 ,ETH_SS_STATS ,ETH_SS_PRIV_FLAGS , + ETH_SS_NTUPLE_FILTERS, };/* for passing string sets for data tagging */
@@ -290,6 +292,7 @@ struct ethtool_perm_addr {*/ enum ethtool_flags {ETH_FLAG_LRO = (1 <<15 ),/* LRO is enabled */ +ETH_FLAG_NTUPLE = (1 <<27 ),/* N-tuple filters enabled */ };/* The following structures are for supporting RX network flow
@@ -363,6 +366,35 @@ struct ethtool_rxnfc {__u32 rule_locs[0 ]; }; +struct ethtool_rx_ntuple_flow_spec { +__u32 flow_type; +union { +struct ethtool_tcpip4_spec tcp_ip4_spec; +struct ethtool_tcpip4_spec udp_ip4_spec; +struct ethtool_tcpip4_spec sctp_ip4_spec; +struct ethtool_ah_espip4_spec ah_ip4_spec; +struct ethtool_ah_espip4_spec esp_ip4_spec; +struct ethtool_rawip4_spec raw_ip4_spec; +struct ethtool_ether_spec ether_spec; +struct ethtool_usrip4_spec usr_ip4_spec; +__u8 hdata[64 ]; + } h_u, m_u;/* entry, mask */ + +__u16 vlan_tag; +__u16 vlan_tag_mask; +__u64 data;/* user-defined flow spec data */ +__u64 data_mask;/* user-defined flow spec mask */ + +/* signed to distinguish between queue and actions (DROP) */ +__s32 action; +#define ETHTOOL_RXNTUPLE_ACTION_DROP -1 +}; + +struct ethtool_rx_ntuple { +__u32 cmd; +struct ethtool_rx_ntuple_flow_spec fs; +}; +#define ETHTOOL_FLASH_MAX_FILENAME 128enum ethtool_flash_op_type {ETHTOOL_FLASH_ALL_REGIONS =0 ,
@@ -377,6 +409,18 @@ struct ethtool_flash {#ifdef __KERNEL__ +struct ethtool_rx_ntuple_flow_spec_container { +struct ethtool_rx_ntuple_flow_spec fs; +struct list_head list; +}; + +struct ethtool_rx_ntuple_list { +#define ETHTOOL_MAX_NTUPLE_LIST_ENTRY 1024 +#define ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY 14 +struct list_head list; +unsigned int count; +}; +struct net_device ;/* Some generic methods drivers may use in their ethtool_ops */
@@ -394,6 +438,7 @@ u32 ethtool_op_get_ufo(struct net_device *dev);int ethtool_op_set_ufo (struct net_device *dev,u32 data);u32 ethtool_op_get_flags (struct net_device *dev);int ethtool_op_set_flags (struct net_device *dev,u32 data); +void ethtool_ntuple_flush (struct net_device *dev);/** * ðtool_ops - Alter and report network device settings
@@ -500,6 +545,8 @@ struct ethtool_ops {int (*set_rxnfc)(struct net_device *,struct ethtool_rxnfc *);int (*flash_device)(struct net_device *,struct ethtool_flash *);int (*reset)(struct net_device *,u32 *); +int (*set_rx_ntuple)(struct net_device *,struct ethtool_rx_ntuple *); + int (*get_rx_ntuple)(struct net_device *, u32 stringset, void *); };#endif /* __KERNEL__ */
@@ -559,6 +606,9 @@ struct ethtool_ops {#define ETHTOOL_FLASHDEV 0x00000033/* Flash firmware to device */ #define ETHTOOL_RESET 0x00000034/* Reset hardware */ +#define ETHTOOL_SRXNTUPLE 0x00000035/* Add an n-tuple filter to device */ +#define ETHTOOL_GRXNTUPLE 0x00000036/* Get n-tuple filters from device */ +/* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET#define SPARC_ETH_SSET ETHTOOL_SSET
include/linux/netdevice.h +3 -0
@@ -746,6 +746,7 @@ struct net_device {#define NETIF_F_FCOE_CRC (1 << 24)/* FCoE CRC32 */ #define NETIF_F_SCTP_CSUM (1 << 25)/* SCTP checksum offload */ #define NETIF_F_FCOE_MTU (1 << 26)/* Supports max FCoE MTU, 2158 bytes*/ +#define NETIF_F_NTUPLE (1 << 27)/* N-tuple filters supported */ /* Segmentation offload features */ #define NETIF_F_GSO_SHIFT 16
@@ -954,6 +955,8 @@ struct net_device {/* max exchange id for FCoE LRO by ddp */ unsigned int fcoe_ddp_xid;#endif +/* n-tuple filter list attached to this device */ +struct ethtool_rx_ntuple_list ethtool_ntuple_list; };#define to_net_dev (d) container_of(d, struct net_device, dev)
net/core/dev.c +6 -0
@@ -5419,6 +5419,8 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,netdev_init_queues (dev); +INIT_LIST_HEAD (&dev->ethtool_ntuple_list.list); + dev->ethtool_ntuple_list.count =0 ;INIT_LIST_HEAD (&dev->napi_list);INIT_LIST_HEAD (&dev->unreg_list);INIT_LIST_HEAD (&dev->link_watch_list);
@@ -5447,6 +5449,7 @@ EXPORT_SYMBOL(alloc_netdev_mq);void free_netdev (struct net_device *dev) {struct napi_struct *p, *n; +struct ethtool_rx_ntuple_flow_spec_container *fsc, *f;release_net (dev_net (dev));
@@ -5455,6 +5458,9 @@ void free_netdev(struct net_device *dev)/* Flush device addresses */ dev_addr_flush (dev); +/* Clear ethtool n-tuple list */ +ethtool_ntuple_flush (dev); +list_for_each_entry_safe (p, n, &dev->napi_list, dev_list)netif_napi_del (p);
net/core/ethtool.c +331 -1
377 lines not on this page · raw message
PATCH v5 2/3 ixgbe: Add support for the new ethtool n-tuple programming interface
In reply to Jeff KirsherFrom: Peter Waskiewicz <[email protected]>
This patch adds n-tuple filter programming to 82599.
---
drivers/net/ixgbe/ixgbe.h | 4 + drivers/net/ixgbe/ixgbe_82599.c | 106 +++++++++++++++++++++++++++++++---- drivers/net/ixgbe/ixgbe_ethtool.c | 111 ++++++++++++++++++++++++++++++++++++- drivers/net/ixgbe/ixgbe_main.c | 16 +++++ drivers/net/ixgbe/ixgbe_type.h | 9 +++ 5 files changed, 228 insertions(+), 18 deletions(-)
drivers/net/ixgbe/ixgbe.h +4 -0
@@ -453,6 +453,10 @@ extern s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 pballoc);extern s32 ixgbe_fdir_add_signature_filter_82599 (struct ixgbe_hw *hw,struct ixgbe_atr_input *input,u8 queue); +extern s32 ixgbe_fdir_add_perfect_filter_82599 (struct ixgbe_hw *hw, +struct ixgbe_atr_input *input, +struct ixgbe_atr_input_masks *input_masks, +u16 soft_id,u8 queue);extern s32 ixgbe_atr_set_vlan_id_82599 (struct ixgbe_atr_input *input,u16 vlan_id); extern s32 ixgbe_atr_set_src_ipv4_82599(struct ixgbe_atr_input *input,
drivers/net/ixgbe/ixgbe_82599.c +93 -13
197 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_ethtool.c +108 -3
143 lines not on this page · raw message
drivers/net/ixgbe/ixgbe_main.c +14 -2
@@ -3253,6 +3253,9 @@ void ixgbe_down(struct ixgbe_adapter *adapter)netif_carrier_off (netdev); +/* clear n-tuple filters that are cached */ +ethtool_ntuple_flush (netdev); +if (!pci_channel_offline (adapter->pdev))ixgbe_reset (adapter);ixgbe_clean_all_tx_rings (adapter);
@@ -4187,6 +4190,7 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) {struct ixgbe_hw *hw = &adapter->hw;struct pci_dev *pdev = adapter->pdev; +struct net_device *dev = adapter->netdev;unsigned int rss;#ifdef CONFIG_IXGBE_DCB int j;
@@ -4214,10 +4218,18 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter) adapter->max_msix_q_vectors =MAX_MSIX_Q_VECTORS_82599 ; adapter->flags2 |=IXGBE_FLAG2_RSC_CAPABLE ; adapter->flags2 |=IXGBE_FLAG2_RSC_ENABLED ; - adapter->flags |=IXGBE_FLAG_FDIR_HASH_CAPABLE ; +if (dev->features &NETIF_F_NTUPLE ) { +/* Flow Director perfect filter enabled */ + adapter->flags |=IXGBE_FLAG_FDIR_PERFECT_CAPABLE ; + adapter->atr_sample_rate =0 ; +spin_lock_init (&adapter->fdir_perfect_lock); + }else { +/* Flow Director hash filters enabled */ + adapter->flags |=IXGBE_FLAG_FDIR_HASH_CAPABLE ; + adapter->atr_sample_rate =20 ; + } adapter->ring_feature[RING_F_FDIR ].indices =IXGBE_MAX_FDIR_INDICES ; - adapter->atr_sample_rate =20 ; adapter->fdir_pballoc =0 ;#ifdef IXGBE_FCOE adapter->flags |=IXGBE_FLAG_FCOE_CAPABLE ;
drivers/net/ixgbe/ixgbe_type.h +9 -0
@@ -2129,6 +2129,15 @@ struct ixgbe_atr_input {u8 byte_stream[42 ]; }; +struct ixgbe_atr_input_masks { +u32 src_ip_mask; +u32 dst_ip_mask; +u16 src_port_mask; +u16 dst_port_mask; +u16 vlan_id_mask; +u16 data_mask; +}; +enum ixgbe_eeprom_type { ixgbe_eeprom_uninitialized =0 , ixgbe_eeprom_spi,
PATCH v5 3/3 ixgbe: Bump driver version up
In reply to Jeff KirsherFrom: Peter Waskiewicz <[email protected]>
Driver has gone under significant changes, the version should reflect that.
---
drivers/net/ixgbe/ixgbe_main.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/ixgbe/ixgbe_main.c +1 -1
@@ -51,7 +51,7 @@ char ixgbe_driver_name[] = "ixgbe";static const char ixgbe_driver_string[] ="Intel(R) 10 Gigabit PCI Express Network Driver" ; -#define DRV_VERSION "2.0.44-k2" +#define DRV_VERSION "2.0.62-k2"const char ixgbe_driver_version[] =DRV_VERSION ;static char ixgbe_copyright[] ="Copyright (c) 1999-2010 Intel Corporation." ;
David Miller
maintainerFrom: Jeff Kirsher <[email protected]>
Date: Wed, 10 Feb 2010 18:07:18 -0800
Quoted 8 lines
One more round of fixes, based on feedback from Patrick McHardy
1) Change the list count to an unsigned value
2) Fix a memory leak
3) Removed an unnecessary list traversal in the ethtool core
4) Moved all list destruction to a helper function, allowing the driver to control when it clears the list (aside from whenfree_netdev()kills the cached list).
All applied, thanks.
Pj, can you look a shoring up the behavior of one more thing for me?
When rules get added, it first installs the filter by calling into the driver.
_Then_ is tries to add the software copy of the rule to the device list. This does an allocation which may fail.
If it does fail, we return -ENOMEM but we left the device configured with the new rule.
Probably better to do it something like:
p = NULL;
if (need_sw_rule_list)
p = alloc_rule();
if (!p)
return -ENOMEM;
}
ret = op->install_rule();
if (ret) {
kfree(p);
return ret;
}
if (need_sw_rule_list)
sw_rule_insert(dev, p);You get the idea, we can do the kfree() unconditonally because kfree(NULL) is OK, etc.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Wed, 10 Feb 2010 19:54:45 -0800 (PST)
Quoted 1 line
All applied, thanks.
Guys please check your changes for warnings in the build:
net/core/dev.c: In function ‘free_netdev’:net/core/dev.c:5452: warning: unused variable ‘f’ net/core/dev.c:5452: warning: unused variable ‘fsc’
CC [M] drivers/net/e1000e/lib.o CC [M] drivers/net/e1000e/phy.o CC net/core/ethtool.o CC [M] drivers/net/e1000e/param.o
net/core/ethtool.c: In function ‘ethtool_reset’:net/core/ethtool.c:626: warning: unused variable ‘f’ net/core/ethtool.c:626: warning: unused variable ‘fsc’ net/core/ethtool.c: In function ‘ethtool_nway_reset’:net/core/ethtool.c:676: warning: unused variable ‘f’ net/core/ethtool.c:676: warning: unused variable ‘fsc’
I'll fix this up, but you know... :-/
Quoted 43 lines · David Miller
From: Jeff Kirsher <[email protected]>
Date: Wed, 10 Feb 2010 18:07:18 -0800Quoted 8 lines
One more round of fixes, based on feedback from Patrick McHardy
1) Change the list count to an unsigned value
2) Fix a memory leak
3) Removed an unnecessary list traversal in the ethtool core
4) Moved all list destruction to a helper function, allowing the driver to control when it clears the list (aside from whenfree_netdev()kills the cached list).All applied, thanks.
Pj, can you look a shoring up the behavior of one more thing for me?
When rules get added, it first installs the filter by calling into the driver.
_Then_ is tries to add the software copy of the rule to the device list. This does an allocation which may fail.
If it does fail, we return
-ENOMEMbut we left the device configured with the new rule.Probably better to do it something like:
p = NULL; if (need_sw_rule_list) p = alloc_rule(); if (!p) return -ENOMEM; } ret = op->install_rule(); if (ret) { kfree(p); return ret; } if (need_sw_rule_list) sw_rule_insert(dev, p);
Quoted 2 lines
You get the idea, we can do the
kfree()unconditonally because kfree(NULL) is OK, etc.
No problem. I'll get a patch together asap for 2.6.34.
Also, probably for 2.6.35, I'm going to try and add a remove capability.
Cheers,
-PJ
includes build break - was Re: [net-next-2.6 PATCH v5 0/3] Introduce n-tuple ethtool support
In reply to David MillerQuoted 5 lines · David Miller
From: Jeff Kirsher <[email protected]>
Date: Wed, 10 Feb 2010 18:07:18 -0800Quoted 2 lines
One more round of fixes, based on feedback from Patrick McHardy
Quoted 9 lines
Quoted 6 lines
1) Change the list count to an unsigned value
2) Fix a memory leak
3) Removed an unnecessary list traversal in the ethtool core
4) Moved all list destruction to a helper function, allowing the driver to control when it clears the list (aside from whenfree_netdev()kills the cached list).All applied, thanks.
Hi Peter,
compiling the latest net-next-2.6 i got this problem:
CHECK include/linux (358 files)/home/hartko/net-next-2.6/usr/include/linux/ethtool.h:17: included file 'linux/rculist.h' is not exported
Which has been introduced by
("ethtool: Introduce n-tuple filter programming support")
The patch below fixes the issue.
---
include/linux/ethtool.h +2 -0
@@ -14,7 +14,9 @@#define _LINUX_ETHTOOL_H#include <linux/types.h> +#ifdef __KERNEL__#include <linux/rculist.h> +#endif /* This should work for both 32 and 64 bit userland. */ struct ethtool_cmd {
David Miller
maintainerRe: includes build break - was Re: [net-next-2.6 PATCH v5 0/3] Introduce n-tuple ethtool support
From: Oliver Hartkopp <[email protected]>
Date: Sun, 14 Feb 2010 12:56:28 +0100
Quoted 3 lines
The patch below fixes the issue.
Signed-off-by Oliver Hartkopp <[email protected]>
Oliver, thanks for your patch.
I'm going to fix this slightly differently by moving the rculist.h include down into the existing __KERNEL__ ifdef protected code block.
Thanks!
v5 cover Introduce n-tuple ethtool support
In reply to Jeff KirsherNice. Next step would be to control the RSS-traffic. Doing this we can easily get total separation between "control" and "data" plane. We did a dirty hack to separate out bgp/ssh to one queue/cpu. I think just a RSS_mask would be a good start - each bit controlling if queue should receive RSS traffic or not.
Cheers
--ro
Quoted 35 lines · Jeff Kirsher
One more round of fixes, based on feedback from Patrick McHardy
1) Change the list count to an unsigned value
2) Fix a memory leak
3) Removed an unnecessary list traversal in the ethtool core
4) Moved all list destruction to a helper function, allowing the driver to control when it clears the list (aside from whenfree_netdev()kills the cached list).---
Peter Waskiewicz (3):
ixgbe: Bump driver version up
ixgbe: Add support for the new ethtool n-tuple programming interface
ethtool: Introduce n-tuple filter programming supportdrivers/net/ixgbe/ixgbe.h | 4 drivers/net/ixgbe/ixgbe_82599.c | 106 ++++++++++-- drivers/net/ixgbe/ixgbe_ethtool.c | 111 ++++++++++++ drivers/net/ixgbe/ixgbe_main.c | 18 ++ drivers/net/ixgbe/ixgbe_type.h | 9 + include/linux/ethtool.h | 50 ++++++ include/linux/netdevice.h | 3 net/core/dev.c | 6 + net/core/ethtool.c | 332 +++++++++++++++++++++++++++++++++++++ 9 files changed, 619 insertions(+), 20 deletions(-)Signature · 6 lines
Cheers, Jeff -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html