* [PATCH ethtool 0/7] Update RX n-tuple filtering
@ 2010-09-23 21:47 Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 1/7] ethtool-copy.h: sync with net-next-2.6 Ben Hutchings
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:47 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
This patch series brings ethtool up to date with my recent changes to RX
n-tuple filtering in the kernel.
Ben.
Ben Hutchings (7):
ethtool-copy.h: sync with net-next
ethtool: Generalise cmdline_info::unwanted_val to a "seen" flag or
bitmask
ethtool: Fix RX n-tuple masks and documentation
ethtool: Add MAC parameter type based on the parse_sopass() function
ethtool: Add Ethernet-level RX n-tuple filtering and 'clear' action
ethtool: Update sfc register dump
ethtool: Add my authorship and Solarflare copyright notice
AUTHORS | 1 +
ethtool-copy.h | 228 +++++++++++++++++++++++++++++++++---------------
ethtool.8 | 79 ++++++++++++-----
ethtool.c | 265 +++++++++++++++++++++++++++++++++++++++++---------------
sfc.c | 25 +++---
5 files changed, 426 insertions(+), 172 deletions(-)
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH ethtool 1/7] ethtool-copy.h: sync with net-next-2.6
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
@ 2010-09-23 21:48 ` Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 2/7] ethtool: Generalise cmdline_info::unwanted_val to a "seen" flag or bitmask Ben Hutchings
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:48 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool-copy.h | 228 ++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 157 insertions(+), 71 deletions(-)
diff --git a/ethtool-copy.h b/ethtool-copy.h
index 894f1da..1be08cf 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -14,6 +14,7 @@
#define _LINUX_ETHTOOL_H
#include <linux/types.h>
+#include <linux/if_ether.h>
/* This should work for both 32 and 64 bit userland. */
struct ethtool_cmd {
@@ -314,9 +315,20 @@ enum ethtool_flags {
};
/* The following structures are for supporting RX network flow
- * classification configuration. Note, all multibyte fields, e.g.,
- * ip4src, ip4dst, psrc, pdst, spi, etc. are expected to be in network
- * byte order.
+ * classification and RX n-tuple configuration. Note, all multibyte
+ * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to
+ * be in network byte order.
+ */
+
+/**
+ * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc.
+ * @ip4src: Source host
+ * @ip4dst: Destination host
+ * @psrc: Source port
+ * @pdst: Destination port
+ * @tos: Type-of-service
+ *
+ * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow.
*/
struct ethtool_tcpip4_spec {
__be32 ip4src;
@@ -326,6 +338,15 @@ struct ethtool_tcpip4_spec {
__u8 tos;
};
+/**
+ * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4
+ * @ip4src: Source host
+ * @ip4dst: Destination host
+ * @spi: Security parameters index
+ * @tos: Type-of-service
+ *
+ * This can be used to specify an IPsec transport or tunnel over IPv4.
+ */
struct ethtool_ah_espip4_spec {
__be32 ip4src;
__be32 ip4dst;
@@ -333,21 +354,17 @@ struct ethtool_ah_espip4_spec {
__u8 tos;
};
-struct ethtool_rawip4_spec {
- __be32 ip4src;
- __be32 ip4dst;
- __u8 hdata[64];
-};
-
-struct ethtool_ether_spec {
- __be16 ether_type;
- __u8 frame_size;
- __u8 eframe[16];
-};
-
#define ETH_RX_NFC_IP4 1
-#define ETH_RX_NFC_IP6 2
+/**
+ * struct ethtool_usrip4_spec - general flow specification for IPv4
+ * @ip4src: Source host
+ * @ip4dst: Destination host
+ * @l4_4_bytes: First 4 bytes of transport (layer 4) header
+ * @tos: Type-of-service
+ * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
+ * @proto: Transport protocol number; mask must be 0
+ */
struct ethtool_usrip4_spec {
__be32 ip4src;
__be32 ip4dst;
@@ -357,6 +374,15 @@ struct ethtool_usrip4_spec {
__u8 proto;
};
+/**
+ * struct ethtool_rx_flow_spec - specification for RX flow filter
+ * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
+ * @h_u: Flow fields to match (dependent on @flow_type)
+ * @m_u: Masks for flow field bits to be ignored
+ * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
+ * if packets should be discarded
+ * @location: Index of filter in hardware table
+ */
struct ethtool_rx_flow_spec {
__u32 flow_type;
union {
@@ -365,36 +391,91 @@ struct ethtool_rx_flow_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 */
+ struct ethhdr ether_spec;
+ __u8 hdata[72];
+ } h_u, m_u;
__u64 ring_cookie;
__u32 location;
};
+/**
+ * struct ethtool_rxnfc - command to get or set RX flow classification rules
+ * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH,
+ * %ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE,
+ * %ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS
+ * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW
+ * @data: Command-dependent value
+ * @fs: Flow filter specification
+ * @rule_cnt: Number of rules to be affected
+ * @rule_locs: Array of valid rule indices
+ *
+ * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating
+ * the fields included in the flow hash, e.g. %RXH_IP_SRC. The following
+ * structure fields must not be used.
+ *
+ * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues
+ * on return.
+ *
+ * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined
+ * rules on return.
+ *
+ * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the index of an
+ * existing filter rule on entry and @fs contains the rule on return.
+ *
+ * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the
+ * user buffer for @rule_locs on entry. On return, @data is the size
+ * of the filter table and @rule_locs contains the indices of the
+ * defined rules.
+ *
+ * For %ETHTOOL_SRXCLSRLINS, @fs specifies the filter rule to add or
+ * update. @fs.@location specifies the index to use and must not be
+ * ignored.
+ *
+ * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the index of an
+ * existing filter rule on entry.
+ *
+ * Implementation of indexed classification rules generally requires a
+ * TCAM.
+ */
struct ethtool_rxnfc {
__u32 cmd;
__u32 flow_type;
- /* The rx flow hash value or the rule DB size */
__u64 data;
- /* The following fields are not valid and must not be used for
- * the ETHTOOL_{G,X}RXFH commands. */
struct ethtool_rx_flow_spec fs;
__u32 rule_cnt;
__u32 rule_locs[0];
};
+/**
+ * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection
+ * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR
+ * @size: On entry, the array size of the user buffer. On return from
+ * %ETHTOOL_GRXFHINDIR, the array size of the hardware indirection table.
+ * @ring_index: RX ring/queue index for each hash value
+ */
struct ethtool_rxfh_indir {
__u32 cmd;
- /* On entry, this is the array size of the user buffer. On
- * return from ETHTOOL_GRXFHINDIR, this is the array size of
- * the hardware indirection table. */
__u32 size;
- __u32 ring_index[0]; /* ring/queue index for each hash value */
+ __u32 ring_index[0];
};
+/**
+ * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
+ * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
+ * @h_u: Flow field values to match (dependent on @flow_type)
+ * @m_u: Masks for flow field value bits to be ignored
+ * @vlan_tag: VLAN tag to match
+ * @vlan_tag_mask: Mask for VLAN tag bits to be ignored
+ * @data: Driver-dependent data to match
+ * @data_mask: Mask for driver-dependent data bits to be ignored
+ * @action: RX ring/queue index to deliver to (non-negative) or other action
+ * (negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP)
+ *
+ * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where
+ * a field value and mask are both zero this is treated as if all mask
+ * bits are set i.e. the field is ignored.
+ */
struct ethtool_rx_ntuple_flow_spec {
__u32 flow_type;
union {
@@ -403,22 +484,26 @@ struct ethtool_rx_ntuple_flow_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 */
+ struct ethhdr ether_spec;
+ __u8 hdata[72];
+ } h_u, m_u;
__u16 vlan_tag;
__u16 vlan_tag_mask;
- __u64 data; /* user-defined flow spec data */
- __u64 data_mask; /* user-defined flow spec mask */
+ __u64 data;
+ __u64 data_mask;
- /* signed to distinguish between queue and actions (DROP) */
__s32 action;
-#define ETHTOOL_RXNTUPLE_ACTION_DROP -1
+#define ETHTOOL_RXNTUPLE_ACTION_DROP (-1) /* drop packet */
+#define ETHTOOL_RXNTUPLE_ACTION_CLEAR (-2) /* clear filter */
};
+/**
+ * struct ethtool_rx_ntuple - command to set or clear RX flow filter
+ * @cmd: Command number - %ETHTOOL_SRXNTUPLE
+ * @fs: Flow filter specification
+ */
struct ethtool_rx_ntuple {
__u32 cmd;
struct ethtool_rx_ntuple_flow_spec fs;
@@ -444,29 +529,29 @@ struct ethtool_flash {
#define ETHTOOL_GREGS 0x00000004 /* Get NIC registers. */
#define ETHTOOL_GWOL 0x00000005 /* Get wake-on-lan options. */
#define ETHTOOL_SWOL 0x00000006 /* Set wake-on-lan options. */
-#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
-#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
+#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
+#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */
#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */
-#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
-#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
+#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
+#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
#define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */
#define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */
#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters. */
#define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */
#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */
-#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
-#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
-#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
-#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
+#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
+#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
+#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
+#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
#define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable
* (ethtool_value) */
#define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable
* (ethtool_value). */
#define ETHTOOL_TEST 0x0000001a /* execute NIC self-test. */
#define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */
-#define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
+#define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
#define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */
#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */
#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */
@@ -477,8 +562,8 @@ struct ethtool_flash {
#define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (ethtool_value) */
#define ETHTOOL_GFLAGS 0x00000025 /* Get flags bitmap(ethtool_value) */
#define ETHTOOL_SFLAGS 0x00000026 /* Set flags bitmap(ethtool_value) */
-#define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */
-#define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */
+#define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */
+#define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */
#define ETHTOOL_GRXFH 0x00000029 /* Get RX flow hash configuration */
#define ETHTOOL_SRXFH 0x0000002a /* Set RX flow hash configuration */
@@ -505,18 +590,18 @@ struct ethtool_flash {
/* Indicates what features are supported by the interface. */
#define SUPPORTED_10baseT_Half (1 << 0)
#define SUPPORTED_10baseT_Full (1 << 1)
-#define SUPPORTED_100baseT_Half (1 << 2)
-#define SUPPORTED_100baseT_Full (1 << 3)
+#define SUPPORTED_100baseT_Half (1 << 2)
+#define SUPPORTED_100baseT_Full (1 << 3)
#define SUPPORTED_1000baseT_Half (1 << 4)
#define SUPPORTED_1000baseT_Full (1 << 5)
#define SUPPORTED_Autoneg (1 << 6)
#define SUPPORTED_TP (1 << 7)
#define SUPPORTED_AUI (1 << 8)
#define SUPPORTED_MII (1 << 9)
-#define SUPPORTED_FIBRE (1 << 10)
+#define SUPPORTED_FIBRE (1 << 10)
#define SUPPORTED_BNC (1 << 11)
#define SUPPORTED_10000baseT_Full (1 << 12)
-#define SUPPORTED_Pause (1 << 13)
+#define SUPPORTED_Pause (1 << 13)
#define SUPPORTED_Asym_Pause (1 << 14)
#define SUPPORTED_2500baseX_Full (1 << 15)
#define SUPPORTED_Backplane (1 << 16)
@@ -526,8 +611,8 @@ struct ethtool_flash {
#define SUPPORTED_10000baseR_FEC (1 << 20)
/* Indicates what features are advertised by the interface. */
-#define ADVERTISED_10baseT_Half (1 << 0)
-#define ADVERTISED_10baseT_Full (1 << 1)
+#define ADVERTISED_10baseT_Half (1 << 0)
+#define ADVERTISED_10baseT_Full (1 << 1)
#define ADVERTISED_100baseT_Half (1 << 2)
#define ADVERTISED_100baseT_Full (1 << 3)
#define ADVERTISED_1000baseT_Half (1 << 4)
@@ -566,12 +651,12 @@ struct ethtool_flash {
#define DUPLEX_FULL 0x01
/* Which connector port. */
-#define PORT_TP 0x00
+#define PORT_TP 0x00
#define PORT_AUI 0x01
#define PORT_MII 0x02
#define PORT_FIBRE 0x03
#define PORT_BNC 0x04
-#define PORT_DA 0x05
+#define PORT_DA 0x05
#define PORT_NONE 0xef
#define PORT_OTHER 0xff
@@ -585,7 +670,7 @@ struct ethtool_flash {
/* Enable or disable autonegotiation. If this is set to enable,
* the forced link modes above are completely ignored.
*/
-#define AUTONEG_DISABLE 0x00
+#define AUTONEG_DISABLE 0x00
#define AUTONEG_ENABLE 0x01
/* Mode MDI or MDI-X */
@@ -602,22 +687,23 @@ struct ethtool_flash {
#define WAKE_MAGIC (1 << 5)
#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */
-/* L3-L4 network traffic flow types */
-#define TCP_V4_FLOW 0x01
-#define UDP_V4_FLOW 0x02
-#define SCTP_V4_FLOW 0x03
-#define AH_ESP_V4_FLOW 0x04
-#define TCP_V6_FLOW 0x05
-#define UDP_V6_FLOW 0x06
-#define SCTP_V6_FLOW 0x07
-#define AH_ESP_V6_FLOW 0x08
-#define AH_V4_FLOW 0x09
-#define ESP_V4_FLOW 0x0a
-#define AH_V6_FLOW 0x0b
-#define ESP_V6_FLOW 0x0c
-#define IP_USER_FLOW 0x0d
-#define IPV4_FLOW 0x10
-#define IPV6_FLOW 0x11
+/* L2-L4 network traffic flow types */
+#define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */
+#define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */
+#define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */
+#define AH_ESP_V4_FLOW 0x04 /* hash only */
+#define TCP_V6_FLOW 0x05 /* hash only */
+#define UDP_V6_FLOW 0x06 /* hash only */
+#define SCTP_V6_FLOW 0x07 /* hash only */
+#define AH_ESP_V6_FLOW 0x08 /* hash only */
+#define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */
+#define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */
+#define AH_V6_FLOW 0x0b /* hash only */
+#define ESP_V6_FLOW 0x0c /* hash only */
+#define IP_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */
+#define IPV4_FLOW 0x10 /* hash only */
+#define IPV6_FLOW 0x11 /* hash only */
+#define ETHER_FLOW 0x12 /* spec only (ether_spec) */
/* L3-L4 network traffic flow hash options */
#define RXH_L2DA (1 << 1)
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH ethtool 2/7] ethtool: Generalise cmdline_info::unwanted_val to a "seen" flag or bitmask
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 1/7] ethtool-copy.h: sync with net-next-2.6 Ben Hutchings
@ 2010-09-23 21:48 ` Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 3/7] ethtool: Fix RX n-tuple masks and documentation Ben Hutchings
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:48 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.c | 68 +++++++++++++++++++++++++++++++++---------------------------
1 files changed, 37 insertions(+), 31 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 6b2b7c8..8c5d595 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -290,7 +290,7 @@ static int off_tso_wanted = -1;
static int off_ufo_wanted = -1;
static int off_gso_wanted = -1;
static u32 off_flags_wanted = 0;
-static u32 off_flags_unwanted = 0;
+static u32 off_flags_mask = 0;
static int off_gro_wanted = -1;
static struct ethtool_pauseparam epause;
@@ -372,7 +372,7 @@ static int flash_region = -1;
static int msglvl_changed;
static u32 msglvl_wanted = 0;
-static u32 msglvl_unwanted =0;
+static u32 msglvl_mask = 0;
static enum {
ONLINE=0,
@@ -402,8 +402,10 @@ struct cmdline_info {
void *ioctl_val;
/* For FLAG, the flag value to be set/cleared */
u32 flag_val;
- /* For FLAG, accumulates all flags to be cleared */
- u32 *unwanted_val;
+ /* For FLAG, points to u32 and accumulates all flags seen.
+ * For anything else, points to int and is set if the option is
+ * seen. */
+ void *seen_val;
};
static struct cmdline_info cmdline_gregs[] = {
@@ -433,12 +435,12 @@ static struct cmdline_info cmdline_offload[] = {
{ "ufo", CMDL_BOOL, &off_ufo_wanted, NULL },
{ "gso", CMDL_BOOL, &off_gso_wanted, NULL },
{ "lro", CMDL_FLAG, &off_flags_wanted, NULL,
- ETH_FLAG_LRO, &off_flags_unwanted },
+ ETH_FLAG_LRO, &off_flags_mask },
{ "gro", CMDL_BOOL, &off_gro_wanted, NULL },
{ "ntuple", CMDL_FLAG, &off_flags_wanted, NULL,
- ETH_FLAG_NTUPLE, &off_flags_unwanted },
+ ETH_FLAG_NTUPLE, &off_flags_mask },
{ "rxhash", CMDL_FLAG, &off_flags_wanted, NULL,
- ETH_FLAG_RXHASH, &off_flags_unwanted },
+ ETH_FLAG_RXHASH, &off_flags_mask },
};
static struct cmdline_info cmdline_pause[] = {
@@ -497,35 +499,35 @@ static struct cmdline_info cmdline_ntuple[] = {
static struct cmdline_info cmdline_msglvl[] = {
{ "drv", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_DRV, &msglvl_unwanted },
+ NETIF_MSG_DRV, &msglvl_mask },
{ "probe", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_PROBE, &msglvl_unwanted },
+ NETIF_MSG_PROBE, &msglvl_mask },
{ "link", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_LINK, &msglvl_unwanted },
+ NETIF_MSG_LINK, &msglvl_mask },
{ "timer", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_TIMER, &msglvl_unwanted },
+ NETIF_MSG_TIMER, &msglvl_mask },
{ "ifdown", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_IFDOWN, &msglvl_unwanted },
+ NETIF_MSG_IFDOWN, &msglvl_mask },
{ "ifup", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_IFUP, &msglvl_unwanted },
+ NETIF_MSG_IFUP, &msglvl_mask },
{ "rx_err", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_RX_ERR, &msglvl_unwanted },
+ NETIF_MSG_RX_ERR, &msglvl_mask },
{ "tx_err", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_TX_ERR, &msglvl_unwanted },
+ NETIF_MSG_TX_ERR, &msglvl_mask },
{ "tx_queued", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_TX_QUEUED, &msglvl_unwanted },
+ NETIF_MSG_TX_QUEUED, &msglvl_mask },
{ "intr", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_INTR, &msglvl_unwanted },
+ NETIF_MSG_INTR, &msglvl_mask },
{ "tx_done", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_TX_DONE, &msglvl_unwanted },
+ NETIF_MSG_TX_DONE, &msglvl_mask },
{ "rx_status", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_RX_STATUS, &msglvl_unwanted },
+ NETIF_MSG_RX_STATUS, &msglvl_mask },
{ "pktdata", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_PKTDATA, &msglvl_unwanted },
+ NETIF_MSG_PKTDATA, &msglvl_mask },
{ "hw", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_HW, &msglvl_unwanted },
+ NETIF_MSG_HW, &msglvl_mask },
{ "wol", CMDL_FLAG, &msglvl_wanted, NULL,
- NETIF_MSG_WOL, &msglvl_unwanted },
+ NETIF_MSG_WOL, &msglvl_mask },
};
static long long
@@ -582,6 +584,9 @@ static void parse_generic_cmdline(int argc, char **argp,
if (!strcmp(info[idx].name, argp[i])) {
found = 1;
*changed = 1;
+ if (info[idx].type != CMDL_FLAG &&
+ info[idx].seen_val)
+ *(int *)info[idx].seen_val = 1;
i += 1;
if (i >= argc)
show_usage(1);
@@ -638,13 +643,14 @@ static void parse_generic_cmdline(int argc, char **argp,
}
case CMDL_FLAG: {
u32 *p;
- if (!strcmp(argp[i], "on"))
+ p = info[idx].seen_val;
+ *p |= info[idx].flag_val;
+ if (!strcmp(argp[i], "on")) {
p = info[idx].wanted_val;
- else if (!strcmp(argp[i], "off"))
- p = info[idx].unwanted_val;
- else
+ *p |= info[idx].flag_val;
+ } else if (strcmp(argp[i], "off")) {
show_usage(1);
- *p |= info[idx].flag_val;
+ }
break;
}
case CMDL_STR: {
@@ -1027,7 +1033,7 @@ static void parse_cmdline(int argc, char **argp)
show_usage(1);
if (isdigit((unsigned char)argp[i][0])) {
msglvl_changed = 1;
- msglvl_unwanted = ~0;
+ msglvl_mask = ~0;
msglvl_wanted =
get_uint_range(argp[i], 0,
0xffffffff);
@@ -2243,7 +2249,7 @@ static int do_soffload(int fd, struct ifreq *ifr)
return 90;
}
}
- if (off_flags_wanted || off_flags_unwanted) {
+ if (off_flags_mask) {
changed = 1;
eval.cmd = ETHTOOL_GFLAGS;
eval.data = 0;
@@ -2255,7 +2261,7 @@ static int do_soffload(int fd, struct ifreq *ifr)
}
eval.cmd = ETHTOOL_SFLAGS;
- eval.data = ((eval.data & ~off_flags_unwanted) |
+ eval.data = ((eval.data & ~off_flags_mask) |
off_flags_wanted);
err = ioctl(fd, SIOCETHTOOL, ifr);
@@ -2459,7 +2465,7 @@ static int do_sset(int fd, struct ifreq *ifr)
perror("Cannot get msglvl");
} else {
edata.cmd = ETHTOOL_SMSGLVL;
- edata.data = ((edata.data & ~msglvl_unwanted) |
+ edata.data = ((edata.data & ~msglvl_mask) |
msglvl_wanted);
ifr->ifr_data = (caddr_t)&edata;
err = send_ioctl(fd, ifr);
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH ethtool 3/7] ethtool: Fix RX n-tuple masks and documentation
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 1/7] ethtool-copy.h: sync with net-next-2.6 Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 2/7] ethtool: Generalise cmdline_info::unwanted_val to a "seen" flag or bitmask Ben Hutchings
@ 2010-09-23 21:48 ` Ben Hutchings
2010-09-23 21:49 ` [PATCH ethtool 4/7] ethtool: Add MAC parameter type based on the parse_sopass() function Ben Hutchings
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:48 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers, Peter Waskiewicz
For fields with unspecified values, explicitly mask all bits. Do not
allow specifying a mask without a value.
Change usage information to clarify which parameters are optional or
required.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.8 | 31 ++++++++--------
ethtool.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 105 insertions(+), 41 deletions(-)
diff --git a/ethtool.8 b/ethtool.8
index 3ca403c..295caab 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -235,34 +235,33 @@ ethtool \- Display or change ethernet card settings
.B ethtool \-U|\-\-config\-ntuple
.I ethX
-.RB [ flow-type
-.RB tcp4|udp4|sctp4 ]
+.A3 flow-type tcp4 udp4 sctp4
.RB [ src-ip
-.IR addr ]
+.IR addr
.RB [ src-ip-mask
-.IR mask ]
+.IR mask ]]
.RB [ dst-ip
-.IR addr ]
+.IR addr
.RB [ dst-ip-mask
-.IR mask ]
+.IR mask ]]
.RB [ src-port
-.IR port ]
+.IR port
.RB [ src-port-mask
-.IR mask ]
+.IR mask ]]
.RB [ dst-port
-.IR port ]
+.IR port
.RB [ dst-port-mask
-.IR mask ]
+.IR mask ]]
.RB [ vlan
-.IR VLAN-tag ]
+.IR VLAN-tag
.RB [ vlan-mask
-.IR mask ]
+.IR mask ]]
.RB [ user-def
-.IR data ]
+.IR data
.RB [ user-def-mask
-.IR mask ]
-.RB [ action
-.IR queue\ or\ drop ]
+.IR mask ]]
+.RI action \ N
+
.SH DESCRIPTION
.BI ethtool
is used for querying settings of an ethernet device and changing them.
diff --git a/ethtool.c b/ethtool.c
index 8c5d595..6ec1cac 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -99,6 +99,7 @@ static int do_gstats(int fd, struct ifreq *ifr);
static int rxflow_str_to_type(const char *str);
static int parse_rxfhashopts(char *optstr, u32 *data);
static char *unparse_rxfhashopts(u64 opts);
+static void parse_rxntupleopts(int argc, char **argp, int first_arg);
static int dump_rxfhash(int fhash, u64 val);
static int do_srxclass(int fd, struct ifreq *ifr);
static int do_grxclass(int fd, struct ifreq *ifr);
@@ -239,12 +240,14 @@ static struct option {
" equal N | weight W0 W1 ...\n" },
{ "-U", "--config-ntuple", MODE_SNTUPLE, "Configure Rx ntuple filters "
"and actions",
- " [ flow-type tcp4|udp4|sctp4 src-ip <addr> "
- "src-ip-mask <mask> dst-ip <addr> dst-ip-mask <mask> "
- "src-port <port> src-port-mask <mask> dst-port <port> "
- "dst-port-mask <mask> vlan <VLAN tag> vlan-mask <mask> "
- "user-def <data> user-def-mask <mask> "
- "action <queue or drop>\n" },
+ " flow-type tcp4|udp4|sctp4\n"
+ " [ src-ip ADDR [src-ip-mask MASK] ]\n"
+ " [ dst-ip ADDR [dst-ip-mask MASK] ]\n"
+ " [ src-port PORT [src-port-mask MASK] ]\n"
+ " [ dst-port PORT [dst-port-mask MASK] ]\n"
+ " [ vlan VLAN-TAG [vlan-mask MASK] ]\n"
+ " [ user-def DATA [user-def-mask MASK] ]\n"
+ " action N\n" },
{ "-u", "--show-ntuple", MODE_GNTUPLE,
"Get Rx ntuple filters and actions\n" },
{ "-h", "--help", MODE_HELP, "Show this help" },
@@ -366,6 +369,18 @@ static int rxfhindir_equal = 0;
static char **rxfhindir_weight = NULL;
static int sntuple_changed = 0;
static struct ethtool_rx_ntuple_flow_spec ntuple_fs;
+static int ntuple_ip4src_seen = 0;
+static int ntuple_ip4src_mask_seen = 0;
+static int ntuple_ip4dst_seen = 0;
+static int ntuple_ip4dst_mask_seen = 0;
+static int ntuple_psrc_seen = 0;
+static int ntuple_psrc_mask_seen = 0;
+static int ntuple_pdst_seen = 0;
+static int ntuple_pdst_mask_seen = 0;
+static int ntuple_vlan_tag_seen = 0;
+static int ntuple_vlan_tag_mask_seen = 0;
+static int ntuple_user_def_seen = 0;
+static int ntuple_user_def_mask_seen = 0;
static char *flash_file = NULL;
static int flash = -1;
static int flash_region = -1;
@@ -482,18 +497,30 @@ static struct cmdline_info cmdline_coalesce[] = {
};
static struct cmdline_info cmdline_ntuple[] = {
- { "src-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL },
- { "src-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL },
- { "dst-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL },
- { "dst-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL },
- { "src-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.psrc, NULL },
- { "src-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.psrc, NULL },
- { "dst-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.pdst, NULL },
- { "dst-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.pdst, NULL },
- { "vlan", CMDL_U16, &ntuple_fs.vlan_tag, NULL },
- { "vlan-mask", CMDL_U16, &ntuple_fs.vlan_tag_mask, NULL },
- { "user-def", CMDL_U64, &ntuple_fs.data, NULL },
- { "user-def-mask", CMDL_U64, &ntuple_fs.data_mask, NULL },
+ { "src-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL,
+ 0, &ntuple_ip4src_seen },
+ { "src-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL,
+ 0, &ntuple_ip4src_mask_seen },
+ { "dst-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4dst, NULL,
+ 0, &ntuple_ip4dst_seen },
+ { "dst-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4dst, NULL,
+ 0, &ntuple_ip4dst_mask_seen },
+ { "src-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.psrc, NULL,
+ 0, &ntuple_psrc_seen },
+ { "src-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.psrc, NULL,
+ 0, &ntuple_psrc_mask_seen },
+ { "dst-port", CMDL_BE16, &ntuple_fs.h_u.tcp_ip4_spec.pdst, NULL,
+ 0, &ntuple_pdst_seen },
+ { "dst-port-mask", CMDL_BE16, &ntuple_fs.m_u.tcp_ip4_spec.pdst, NULL,
+ 0, &ntuple_pdst_mask_seen },
+ { "vlan", CMDL_U16, &ntuple_fs.vlan_tag, NULL,
+ 0, &ntuple_vlan_tag_seen },
+ { "vlan-mask", CMDL_U16, &ntuple_fs.vlan_tag_mask, NULL,
+ 0, &ntuple_vlan_tag_mask_seen },
+ { "user-def", CMDL_U64, &ntuple_fs.data, NULL,
+ 0, &ntuple_user_def_seen },
+ { "user-def-mask", CMDL_U64, &ntuple_fs.data_mask, NULL,
+ 0, &ntuple_user_def_mask_seen },
{ "action", CMDL_S32, &ntuple_fs.action, NULL },
};
@@ -844,13 +871,7 @@ static void parse_cmdline(int argc, char **argp)
show_usage(1);
break;
}
- ntuple_fs.flow_type =
- rxflow_str_to_type(argp[i]);
- i += 1;
- parse_generic_cmdline(argc, argp, i,
- &sntuple_changed,
- cmdline_ntuple,
- ARRAY_SIZE(cmdline_ntuple));
+ parse_rxntupleopts(argc, argp, i);
i = argc;
break;
} else {
@@ -1518,6 +1539,50 @@ static char *unparse_rxfhashopts(u64 opts)
return buf;
}
+static void parse_rxntupleopts(int argc, char **argp, int i)
+{
+ ntuple_fs.flow_type = rxflow_str_to_type(argp[i]);
+
+ switch (ntuple_fs.flow_type) {
+ case TCP_V4_FLOW:
+ case UDP_V4_FLOW:
+ case SCTP_V4_FLOW:
+ parse_generic_cmdline(argc, argp, i + 1,
+ &sntuple_changed,
+ cmdline_ntuple,
+ ARRAY_SIZE(cmdline_ntuple));
+ if (!ntuple_ip4src_seen)
+ ntuple_fs.m_u.tcp_ip4_spec.ip4src = 0xffffffff;
+ if (!ntuple_ip4dst_seen)
+ ntuple_fs.m_u.tcp_ip4_spec.ip4dst = 0xffffffff;
+ if (!ntuple_psrc_seen)
+ ntuple_fs.m_u.tcp_ip4_spec.psrc = 0xffff;
+ if (!ntuple_pdst_seen)
+ ntuple_fs.m_u.tcp_ip4_spec.pdst = 0xffff;
+ ntuple_fs.m_u.tcp_ip4_spec.tos = 0xff;
+ break;
+ default:
+ fprintf(stderr, "Unsupported flow type \"%s\"\n", argp[i]);
+ exit(106);
+ break;
+ }
+
+ if (!ntuple_vlan_tag_seen)
+ ntuple_fs.vlan_tag_mask = 0xffff;
+ if (!ntuple_user_def_seen)
+ ntuple_fs.data_mask = 0xffffffffffffffffULL;
+
+ if ((ntuple_ip4src_mask_seen && !ntuple_ip4src_seen) ||
+ (ntuple_ip4dst_mask_seen && !ntuple_ip4dst_seen) ||
+ (ntuple_psrc_mask_seen && !ntuple_psrc_seen) ||
+ (ntuple_pdst_mask_seen && !ntuple_pdst_seen) ||
+ (ntuple_vlan_tag_mask_seen && !ntuple_vlan_tag_seen) ||
+ (ntuple_user_def_mask_seen && !ntuple_user_def_seen)) {
+ fprintf(stderr, "Cannot specify mask without value\n");
+ exit(107);
+ }
+}
+
static struct {
const char *name;
int (*func)(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH ethtool 4/7] ethtool: Add MAC parameter type based on the parse_sopass() function
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
` (2 preceding siblings ...)
2010-09-23 21:48 ` [PATCH ethtool 3/7] ethtool: Fix RX n-tuple masks and documentation Ben Hutchings
@ 2010-09-23 21:49 ` Ben Hutchings
2010-09-23 21:49 ` [PATCH ethtool 5/7] ethtool: Add Ethernet-level RX n-tuple filtering and 'clear' action Ben Hutchings
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:49 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 6ec1cac..ea6a26f 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -77,7 +77,7 @@ enum {
static int parse_wolopts(char *optstr, u32 *data);
static char *unparse_wolopts(int wolopts);
-static int parse_sopass(char *src, unsigned char *dest);
+static void get_mac_addr(char *src, unsigned char *dest);
static int do_gdrv(int fd, struct ifreq *ifr);
static int do_gset(int fd, struct ifreq *ifr);
static int do_sset(int fd, struct ifreq *ifr);
@@ -405,14 +405,15 @@ typedef enum {
CMDL_IP4,
CMDL_STR,
CMDL_FLAG,
+ CMDL_MAC,
} cmdline_type_t;
struct cmdline_info {
const char *name;
cmdline_type_t type;
- /* Points to int (BOOL), s32, u16, u32 (U32/FLAG/IP4), u64 or
- * char * (STR). For FLAG, the value accumulates all flags
- * to be set. */
+ /* Points to int (BOOL), s32, u16, u32 (U32/FLAG/IP4), u64,
+ * char * (STR) or u8[6] (MAC). For FLAG, the value accumulates
+ * all flags to be set. */
void *wanted_val;
void *ioctl_val;
/* For FLAG, the flag value to be set/cleared */
@@ -668,6 +669,10 @@ static void parse_generic_cmdline(int argc, char **argp,
*p = in.s_addr;
break;
}
+ case CMDL_MAC:
+ get_mac_addr(argp[i],
+ info[idx].wanted_val);
+ break;
case CMDL_FLAG: {
u32 *p;
p = info[idx].seen_val;
@@ -1044,8 +1049,7 @@ static void parse_cmdline(int argc, char **argp)
i++;
if (i >= argc)
show_usage(1);
- if (parse_sopass(argp[i], sopass_wanted) < 0)
- show_usage(1);
+ get_mac_addr(argp[i], sopass_wanted);
sopass_change = 1;
break;
} else if (!strcmp(argp[i], "msglvl")) {
@@ -1449,22 +1453,20 @@ static char *unparse_wolopts(int wolopts)
return buf;
}
-static int parse_sopass(char *src, unsigned char *dest)
+static void get_mac_addr(char *src, unsigned char *dest)
{
int count;
int i;
- int buf[SOPASS_MAX];
+ int buf[ETH_ALEN];
count = sscanf(src, "%2x:%2x:%2x:%2x:%2x:%2x",
&buf[0], &buf[1], &buf[2], &buf[3], &buf[4], &buf[5]);
- if (count != SOPASS_MAX) {
- return -1;
- }
+ if (count != ETH_ALEN)
+ show_usage(1);
for (i = 0; i < count; i++) {
dest[i] = buf[i];
}
- return 0;
}
static int parse_rxfhashopts(char *optstr, u32 *data)
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH ethtool 5/7] ethtool: Add Ethernet-level RX n-tuple filtering and 'clear' action
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
` (3 preceding siblings ...)
2010-09-23 21:49 ` [PATCH ethtool 4/7] ethtool: Add MAC parameter type based on the parse_sopass() function Ben Hutchings
@ 2010-09-23 21:49 ` Ben Hutchings
2010-09-23 21:50 ` [PATCH ethtool 6/7] ethtool: Update sfc register dump Ben Hutchings
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:49 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
ethtool.8 | 48 ++++++++++++++++++++++++++++++++++++++----
ethtool.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 103 insertions(+), 13 deletions(-)
diff --git a/ethtool.8 b/ethtool.8
index 295caab..2c54cb4 100644
--- a/ethtool.8
+++ b/ethtool.8
@@ -233,8 +233,9 @@ ethtool \- Display or change ethernet card settings
.B ethtool \-u|\-\-show\-ntuple
.I ethX
-.B ethtool \-U|\-\-config\-ntuple
-.I ethX
+.TP
+.BI ethtool\ \-U|\-\-config\-ntuple \ ethX
+.RB {
.A3 flow-type tcp4 udp4 sctp4
.RB [ src-ip
.IR addr
@@ -252,6 +253,21 @@ ethtool \- Display or change ethernet card settings
.IR port
.RB [ dst-port-mask
.IR mask ]]
+.br
+.RB | \ flow-type\ ether
+.RB [ src
+.IR mac-addr
+.RB [ src-mask
+.IR mask ]]
+.RB [ dst
+.IR mac-addr
+.RB [ dst-mask
+.IR mask ]]
+.RB [ proto
+.IR N
+.RB [ proto-mask
+.IR mask ]]\ }
+.br
.RB [ vlan
.IR VLAN-tag
.RB [ vlan-mask
@@ -649,7 +665,7 @@ Get Rx ntuple filters and actions, then display them to the user.
.B \-U \-\-config-ntuple
Configure Rx ntuple filters and actions
.TP
-.B flow-type tcp4|udp4|sctp4
+.B flow-type tcp4|udp4|sctp4|ether
.RS
.PD 0
.TP 3
@@ -658,6 +674,8 @@ Configure Rx ntuple filters and actions
.BR "udp4" " UDP over IPv4"
.TP 3
.BR "sctp4" " SCTP over IPv4"
+.TP 3
+.BR "ether" " Ethernet"
.PD
.RE
.TP
@@ -686,6 +704,25 @@ Includes the destination port.
.BI dst-port-mask \ mask
Specify a mask for the destination port.
.TP
+.BI src \ mac-addr
+Includes the source MAC address, specified as 6 bytes in hexadecimal
+separated by colons.
+.TP
+.BI src-mask \ mask
+Specify a mask for the source MAC address.
+.TP
+.BI dst \ mac-addr
+Includes the destination MAC address.
+.TP
+.BI dst-mask \ mask
+Specify a mask for the destination MAC address.
+.TP
+.BI proto \ N
+Includes the Ethernet protocol number (ethertype).
+.TP
+.BI proto-mask \ mask
+Specify a mask for the Ethernet protocol number.
+.TP
.BI vlan \ VLAN-tag
Includes the VLAN tag.
.TP
@@ -699,11 +736,12 @@ Includes 64-bits of user-specific data.
Specify a mask for the user-specific data.
.TP
.BI action \ N
-Specifies either the Rx queue to send packets to, or to drop
-the matched flow.
+Specifies the Rx queue to send packets to, or some other action.
.RS
.PD 0
.TP 3
+.BR "-2" " Clear the filter"
+.TP 3
.BR "-1" " Drop the matched flow"
.TP 3
.BR "0 or higher" " Rx queue to route the flow"
diff --git a/ethtool.c b/ethtool.c
index ea6a26f..31158f8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -240,11 +240,15 @@ static struct option {
" equal N | weight W0 W1 ...\n" },
{ "-U", "--config-ntuple", MODE_SNTUPLE, "Configure Rx ntuple filters "
"and actions",
- " flow-type tcp4|udp4|sctp4\n"
- " [ src-ip ADDR [src-ip-mask MASK] ]\n"
- " [ dst-ip ADDR [dst-ip-mask MASK] ]\n"
- " [ src-port PORT [src-port-mask MASK] ]\n"
- " [ dst-port PORT [dst-port-mask MASK] ]\n"
+ " { flow-type tcp4|udp4|sctp4\n"
+ " [ src-ip ADDR [src-ip-mask MASK] ]\n"
+ " [ dst-ip ADDR [dst-ip-mask MASK] ]\n"
+ " [ src-port PORT [src-port-mask MASK] ]\n"
+ " [ dst-port PORT [dst-port-mask MASK] ]\n"
+ " | flow-type ether\n"
+ " [ src MAC-ADDR [src-mask MASK] ]\n"
+ " [ dst MAC-ADDR [dst-mask MASK] ]\n"
+ " [ proto N [proto-mask MASK] ] }\n"
" [ vlan VLAN-TAG [vlan-mask MASK] ]\n"
" [ user-def DATA [user-def-mask MASK] ]\n"
" action N\n" },
@@ -377,6 +381,12 @@ static int ntuple_psrc_seen = 0;
static int ntuple_psrc_mask_seen = 0;
static int ntuple_pdst_seen = 0;
static int ntuple_pdst_mask_seen = 0;
+static int ntuple_ether_dst_seen = 0;
+static int ntuple_ether_dst_mask_seen = 0;
+static int ntuple_ether_src_seen = 0;
+static int ntuple_ether_src_mask_seen = 0;
+static int ntuple_ether_proto_seen = 0;
+static int ntuple_ether_proto_mask_seen = 0;
static int ntuple_vlan_tag_seen = 0;
static int ntuple_vlan_tag_mask_seen = 0;
static int ntuple_user_def_seen = 0;
@@ -497,7 +507,7 @@ static struct cmdline_info cmdline_coalesce[] = {
{ "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, &ecoal.tx_max_coalesced_frames_high },
};
-static struct cmdline_info cmdline_ntuple[] = {
+static struct cmdline_info cmdline_ntuple_tcp_ip4[] = {
{ "src-ip", CMDL_IP4, &ntuple_fs.h_u.tcp_ip4_spec.ip4src, NULL,
0, &ntuple_ip4src_seen },
{ "src-ip-mask", CMDL_IP4, &ntuple_fs.m_u.tcp_ip4_spec.ip4src, NULL,
@@ -525,6 +535,30 @@ static struct cmdline_info cmdline_ntuple[] = {
{ "action", CMDL_S32, &ntuple_fs.action, NULL },
};
+static struct cmdline_info cmdline_ntuple_ether[] = {
+ { "dst", CMDL_MAC, ntuple_fs.h_u.ether_spec.h_dest, NULL,
+ 0, &ntuple_ether_dst_seen },
+ { "dst-mask", CMDL_MAC, ntuple_fs.m_u.ether_spec.h_dest, NULL,
+ 0, &ntuple_ether_dst_mask_seen },
+ { "src", CMDL_MAC, ntuple_fs.h_u.ether_spec.h_source, NULL,
+ 0, &ntuple_ether_src_seen },
+ { "src-mask", CMDL_MAC, ntuple_fs.m_u.ether_spec.h_source, NULL,
+ 0, &ntuple_ether_src_mask_seen },
+ { "proto", CMDL_BE16, &ntuple_fs.h_u.ether_spec.h_proto, NULL,
+ 0, &ntuple_ether_proto_seen },
+ { "proto-mask", CMDL_BE16, &ntuple_fs.m_u.ether_spec.h_proto, NULL,
+ 0, &ntuple_ether_proto_mask_seen },
+ { "vlan", CMDL_U16, &ntuple_fs.vlan_tag, NULL,
+ 0, &ntuple_vlan_tag_seen },
+ { "vlan-mask", CMDL_U16, &ntuple_fs.vlan_tag_mask, NULL,
+ 0, &ntuple_vlan_tag_mask_seen },
+ { "user-def", CMDL_U64, &ntuple_fs.data, NULL,
+ 0, &ntuple_user_def_seen },
+ { "user-def-mask", CMDL_U64, &ntuple_fs.data_mask, NULL,
+ 0, &ntuple_user_def_mask_seen },
+ { "action", CMDL_S32, &ntuple_fs.action, NULL },
+};
+
static struct cmdline_info cmdline_msglvl[] = {
{ "drv", CMDL_FLAG, &msglvl_wanted, NULL,
NETIF_MSG_DRV, &msglvl_mask },
@@ -741,6 +775,8 @@ static int rxflow_str_to_type(const char *str)
flow_type = AH_ESP_V6_FLOW;
else if (!strcmp(str, "sctp6"))
flow_type = SCTP_V6_FLOW;
+ else if (!strcmp(str, "ether"))
+ flow_type = ETHER_FLOW;
return flow_type;
}
@@ -1551,8 +1587,8 @@ static void parse_rxntupleopts(int argc, char **argp, int i)
case SCTP_V4_FLOW:
parse_generic_cmdline(argc, argp, i + 1,
&sntuple_changed,
- cmdline_ntuple,
- ARRAY_SIZE(cmdline_ntuple));
+ cmdline_ntuple_tcp_ip4,
+ ARRAY_SIZE(cmdline_ntuple_tcp_ip4));
if (!ntuple_ip4src_seen)
ntuple_fs.m_u.tcp_ip4_spec.ip4src = 0xffffffff;
if (!ntuple_ip4dst_seen)
@@ -1563,6 +1599,19 @@ static void parse_rxntupleopts(int argc, char **argp, int i)
ntuple_fs.m_u.tcp_ip4_spec.pdst = 0xffff;
ntuple_fs.m_u.tcp_ip4_spec.tos = 0xff;
break;
+ case ETHER_FLOW:
+ parse_generic_cmdline(argc, argp, i + 1,
+ &sntuple_changed,
+ cmdline_ntuple_ether,
+ ARRAY_SIZE(cmdline_ntuple_ether));
+ if (!ntuple_ether_dst_seen)
+ memset(ntuple_fs.m_u.ether_spec.h_dest, 0xff, ETH_ALEN);
+ if (!ntuple_ether_src_seen)
+ memset(ntuple_fs.m_u.ether_spec.h_source, 0xff,
+ ETH_ALEN);
+ if (!ntuple_ether_proto_seen)
+ ntuple_fs.m_u.ether_spec.h_proto = 0xffff;
+ break;
default:
fprintf(stderr, "Unsupported flow type \"%s\"\n", argp[i]);
exit(106);
@@ -1578,6 +1627,9 @@ static void parse_rxntupleopts(int argc, char **argp, int i)
(ntuple_ip4dst_mask_seen && !ntuple_ip4dst_seen) ||
(ntuple_psrc_mask_seen && !ntuple_psrc_seen) ||
(ntuple_pdst_mask_seen && !ntuple_pdst_seen) ||
+ (ntuple_ether_dst_mask_seen && !ntuple_ether_dst_seen) ||
+ (ntuple_ether_src_mask_seen && !ntuple_ether_src_seen) ||
+ (ntuple_ether_proto_mask_seen && !ntuple_ether_proto_seen) ||
(ntuple_vlan_tag_mask_seen && !ntuple_vlan_tag_seen) ||
(ntuple_user_def_mask_seen && !ntuple_user_def_seen)) {
fprintf(stderr, "Cannot specify mask without value\n");
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH ethtool 6/7] ethtool: Update sfc register dump
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
` (4 preceding siblings ...)
2010-09-23 21:49 ` [PATCH ethtool 5/7] ethtool: Add Ethernet-level RX n-tuple filtering and 'clear' action Ben Hutchings
@ 2010-09-23 21:50 ` Ben Hutchings
2010-09-23 21:50 ` [PATCH ethtool 7/7] ethtool: Add my authorship and Solarflare copyright notice Ben Hutchings
2010-10-28 22:02 ` [PATCH ethtool 0/7] Update RX n-tuple filtering Jeff Garzik
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:50 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Add length checks to allow for extensions to the register dump without
changing the version number.
Show the RX IP filter table if present.
Fix address field definitions for the MAC filter tables.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
sfc.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/sfc.c b/sfc.c
index 2e4735f..c8ca74a 100644
--- a/sfc.c
+++ b/sfc.c
@@ -2420,8 +2420,8 @@
#define FRF_CZ_RMFT_RXQ_ID_WIDTH 12
#define FRF_CZ_RMFT_WILDCARD_MATCH_LBN 60
#define FRF_CZ_RMFT_WILDCARD_MATCH_WIDTH 1
-#define FRF_CZ_RMFT_DEST_MAC_LBN 16
-#define FRF_CZ_RMFT_DEST_MAC_WIDTH 44
+#define FRF_CZ_RMFT_DEST_MAC_LBN 12
+#define FRF_CZ_RMFT_DEST_MAC_WIDTH 48
#define FRF_CZ_RMFT_VLAN_ID_LBN 0
#define FRF_CZ_RMFT_VLAN_ID_WIDTH 12
@@ -2497,8 +2497,8 @@
#define FRF_CZ_TMFT_TXQ_ID_WIDTH 12
#define FRF_CZ_TMFT_WILDCARD_MATCH_LBN 60
#define FRF_CZ_TMFT_WILDCARD_MATCH_WIDTH 1
-#define FRF_CZ_TMFT_SRC_MAC_LBN 16
-#define FRF_CZ_TMFT_SRC_MAC_WIDTH 44
+#define FRF_CZ_TMFT_SRC_MAC_LBN 12
+#define FRF_CZ_TMFT_SRC_MAC_WIDTH 48
#define FRF_CZ_TMFT_VLAN_ID_LBN 0
#define FRF_CZ_TMFT_VLAN_ID_WIDTH 12
@@ -3445,9 +3445,11 @@ static const struct efx_nic_reg_field efx_nic_reg_fields_BUF_FULL_TBL[] = {
};
#define efx_nic_reg_fields_BUF_FULL_TBL_KER efx_nic_reg_fields_BUF_FULL_TBL
static const struct efx_nic_reg_field efx_nic_reg_fields_RX_FILTER_TBL0[] = {
- REGISTER_FIELD_BZ(SRC_TCP_DEST_UDP),
+ /* Source port for full match; destination port for UDP wild match */
+ REGISTER_FIELD_BZ_RENAME(SRC_TCP_DEST_UDP, "SRC_PORT"),
REGISTER_FIELD_BZ(SRC_IP),
- REGISTER_FIELD_BZ(DEST_PORT_TCP),
+ /* Destination port for full match or TCP wild match */
+ REGISTER_FIELD_BZ_RENAME(DEST_PORT_TCP, "DEST_PORT"),
REGISTER_FIELD_BZ(DEST_IP),
REGISTER_FIELD_BZ(RXQ_ID),
REGISTER_FIELD_BZ(TCP_UDP),
@@ -3663,8 +3665,7 @@ static const struct efx_nic_reg_table efx_nic_reg_tables[] = {
REGISTER_TABLE_BB_CZ(TX_DESC_PTR_TBL),
REGISTER_TABLE_AA(EVQ_PTR_TBL_KER),
REGISTER_TABLE_BB_CZ(EVQ_PTR_TBL),
- /* The register buffer is allocated with slab, so we can't
- * reasonably read all of the buffer table (up to 8MB!).
+ /* We can't reasonably read all of the buffer table (up to 8MB!).
* However this driver will only use a few entries. Reading
* 1K entries allows for some expansion of queue count and
* size before we need to change the version. */
@@ -3672,7 +3673,6 @@ static const struct efx_nic_reg_table efx_nic_reg_tables[] = {
A, A, 8, 1024),
REGISTER_TABLE_DIMENSIONS(BUF_FULL_TBL, FR_BZ_BUF_FULL_TBL,
B, Z, 8, 1024),
- /* RX_FILTER_TBL{0,1} is huge and not used by this driver */
REGISTER_TABLE_CZ(RX_MAC_FILTER_TBL0),
REGISTER_TABLE_BB_CZ(TIMER_TBL),
REGISTER_TABLE_BB_CZ(TX_PACE_TBL),
@@ -3682,6 +3682,7 @@ static const struct efx_nic_reg_table efx_nic_reg_tables[] = {
REGISTER_TABLE_CZ(MC_TREG_SMEM),
/* MSIX_PBA_TABLE is not mapped */
/* SRM_DBG is not mapped (and is redundant with BUF_FLL_TBL) */
+ REGISTER_TABLE_BZ(RX_FILTER_TBL0),
};
static size_t column_width(const struct efx_nic_reg_field *field)
@@ -3830,12 +3831,13 @@ sfc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
const struct efx_nic_reg_table *table;
unsigned revision = regs->version;
const void *buf = regs->data;
+ const void *end = regs->data + regs->len;
if (revision > REGISTER_REVISION_Z)
return -1;
for (reg = efx_nic_regs;
- reg < efx_nic_regs + ARRAY_SIZE(efx_nic_regs);
+ reg < efx_nic_regs + ARRAY_SIZE(efx_nic_regs) && buf < end;
reg++) {
if (revision >= reg->min_revision &&
revision <= reg->max_revision)
@@ -3843,7 +3845,8 @@ sfc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
}
for (table = efx_nic_reg_tables;
- table < efx_nic_reg_tables + ARRAY_SIZE(efx_nic_reg_tables);
+ table < efx_nic_reg_tables + ARRAY_SIZE(efx_nic_reg_tables) &&
+ buf < end;
table++) {
if (revision >= table->min_revision &&
revision <= table->max_revision) {
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH ethtool 7/7] ethtool: Add my authorship and Solarflare copyright notice
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
` (5 preceding siblings ...)
2010-09-23 21:50 ` [PATCH ethtool 6/7] ethtool: Update sfc register dump Ben Hutchings
@ 2010-09-23 21:50 ` Ben Hutchings
2010-10-28 22:02 ` [PATCH ethtool 0/7] Update RX n-tuple filtering Jeff Garzik
7 siblings, 0 replies; 9+ messages in thread
From: Ben Hutchings @ 2010-09-23 21:50 UTC (permalink / raw)
To: Jeff Garzik; +Cc: netdev, linux-net-drivers
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
AUTHORS | 1 +
ethtool.c | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 77500ce..aed04fa 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -6,3 +6,4 @@ Eli Kupermann <eli.kupermann@intel.com>
Chris Leech <christopher.leech@intel.com>
Scott Feldman <scott.feldman@intel.com>
Andi Kleen
+Ben Hutchings <bhutchings@solarflare.com>
diff --git a/ethtool.c b/ethtool.c
index 31158f8..7612b14 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -14,6 +14,8 @@
* amd8111e support by Reeja John <reeja.john@amd.com>
* long arguments by Andi Kleen.
* SMSC LAN911x support by Steve Glendinning <steve.glendinning@smsc.com>
+ * Various features by Ben Hutchings <bhutchings@solarflare.com>;
+ * Copyright 2009, 2010 Solarflare Communications
*
* TODO:
* * no-args => summary of each device (mii-tool style)
--
1.7.2.1
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH ethtool 0/7] Update RX n-tuple filtering
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
` (6 preceding siblings ...)
2010-09-23 21:50 ` [PATCH ethtool 7/7] ethtool: Add my authorship and Solarflare copyright notice Ben Hutchings
@ 2010-10-28 22:02 ` Jeff Garzik
7 siblings, 0 replies; 9+ messages in thread
From: Jeff Garzik @ 2010-10-28 22:02 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, linux-net-drivers
On 09/23/2010 05:47 PM, Ben Hutchings wrote:
> This patch series brings ethtool up to date with my recent changes to RX
> n-tuple filtering in the kernel.
>
> Ben.
>
> Ben Hutchings (7):
> ethtool-copy.h: sync with net-next
> ethtool: Generalise cmdline_info::unwanted_val to a "seen" flag or
> bitmask
> ethtool: Fix RX n-tuple masks and documentation
> ethtool: Add MAC parameter type based on the parse_sopass() function
> ethtool: Add Ethernet-level RX n-tuple filtering and 'clear' action
> ethtool: Update sfc register dump
> ethtool: Add my authorship and Solarflare copyright notice
>
> AUTHORS | 1 +
> ethtool-copy.h | 228 +++++++++++++++++++++++++++++++++---------------
> ethtool.8 | 79 ++++++++++++-----
> ethtool.c | 265 +++++++++++++++++++++++++++++++++++++++++---------------
> sfc.c | 25 +++---
Looks good... will push into this release (ethtool 2.6.36)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-10-28 22:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-23 21:47 [PATCH ethtool 0/7] Update RX n-tuple filtering Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 1/7] ethtool-copy.h: sync with net-next-2.6 Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 2/7] ethtool: Generalise cmdline_info::unwanted_val to a "seen" flag or bitmask Ben Hutchings
2010-09-23 21:48 ` [PATCH ethtool 3/7] ethtool: Fix RX n-tuple masks and documentation Ben Hutchings
2010-09-23 21:49 ` [PATCH ethtool 4/7] ethtool: Add MAC parameter type based on the parse_sopass() function Ben Hutchings
2010-09-23 21:49 ` [PATCH ethtool 5/7] ethtool: Add Ethernet-level RX n-tuple filtering and 'clear' action Ben Hutchings
2010-09-23 21:50 ` [PATCH ethtool 6/7] ethtool: Update sfc register dump Ben Hutchings
2010-09-23 21:50 ` [PATCH ethtool 7/7] ethtool: Add my authorship and Solarflare copyright notice Ben Hutchings
2010-10-28 22:02 ` [PATCH ethtool 0/7] Update RX n-tuple filtering Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).