ethtool: Introduce n-tuple filter programming support
Subsystems (3)
PATCH 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 | 49 +++++++ include/linux/netdevice.h | 3 net/core/dev.c | 9 + net/core/ethtool.c | 335 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 395 insertions(+), 1 deletions(-)
include/linux/ethtool.h +49 -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,47 @@ 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_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; +int count; +}; + +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 ,
@@ -500,6 +544,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 +605,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 +9 -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,12 @@ void free_netdev(struct net_device *dev)/* Flush device addresses */ dev_addr_flush (dev); +/* Clear ethtool n-tuple list */ +list_for_each_entry_safe (fsc, f, &dev->ethtool_ntuple_list.list, list) { +list_del (&fsc->list); + } + dev->ethtool_ntuple_list.count =0 ; +list_for_each_entry_safe (p, n, &dev->napi_list, dev_list)netif_napi_del (p);
net/core/ethtool.c +334 -1
380 lines not on this page · raw message
PATCH 2/3 ixgbe: Add support for the new ethtool n-tuple programming interface
From: 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 | 13 ++++ drivers/net/ixgbe/ixgbe_type.h | 9 +++ 5 files changed, 225 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 +11 -2
@@ -4187,6 +4187,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 +4215,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 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: Thu, 04 Feb 2010 22:21:49 -0800
include/linux/ethtool.h struct ethtool_rxnfc { · line 403
Quoted 11 lines
include/linux/ethtool.h +11
-0+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; +int count; +};
These are kernel private data structures, please therefore put them in the __KERNEL__ protected area of ethtool.h
Thanks.