ethtool: Support n-tuple filter programming
Subsystems (2)
PATCH 1/1 ethtool: Support n-tuple filter programming
From: Peter Waskiewicz <[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to ethtool_flags, allowing n-tuple programming to be toggled using the set_flags call.
---
ethtool-copy.h | 35 +++++++++++++ ethtool.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 186 insertions(+), 5 deletions(-)
ethtool-copy.h +35 -0
@@ -241,6 +241,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 */
@@ -289,6 +290,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
@@ -374,6 +376,36 @@ struct ethtool_flash {char data[ETHTOOL_FLASH_MAX_FILENAME ]; }; +struct ethtool_rx_ntuple_flow_spec { +int 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) */ +int action; +#define ETHTOOL_RXNTUPLE_ACTION_DROP -1 +}; + +#define ETHTOOL_MAX_NTUPLE_LIST_ENTRY 1024 +#define ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY 14 +struct ethtool_rx_ntuple { +__u32 cmd; +struct ethtool_rx_ntuple_flow_spec fs; +};/* CMDs currently supported */ #define ETHTOOL_GSET 0x00000001/* Get settings. */
@@ -431,6 +463,9 @@ struct ethtool_flash {#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
ethtool.c +151 -5
270 lines not on this page · raw message
Jeff Garzik
AppliedQuoted 8 lines · Jeff Kirsher
From: Peter Waskiewicz<[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.
Quoted 7 lines
Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>---
ethtool-copy.h | 35 +++++++++++++ ethtool.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 186 insertions(+), 5 deletions(-)
applied, but two problems remain:
1) you failed to document this in the man page. I will expect a patch to ethtool.8.
2) you introduced a deviation from the upstream kernel ethtool.h:
net-next-2.6/include/linux/ethtool.h 2010-02-24 22:14:43.000000000 -0500 renamed from ethtool-copy.h 2010-02-24 22:39:21.000000000 -0500 +0 -2
@@ -389,8 +389,6 @@ #define ETHTOOL_RXNTUPLE_ACTION_DROP -1 }; -#define ETHTOOL_MAX_NTUPLE_LIST_ENTRY 1024 -#define ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY 14 struct ethtool_rx_ntuple { __u32 cmd; struct ethtool_rx_ntuple_flow_spec fs;
Quoted 13 lines · Jeff Garzik
Quoted 12 lines · Jeff Kirsher
From: Peter Waskiewicz<[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>---
Quoted 8 lines
Quoted 3 lines
ethtool-copy.h | 35 +++++++++++++ ethtool.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 186 insertions(+), 5 deletions(-)applied, but two problems remain:
1) you failed to document this in the man page. I will expect a patch to ethtool.8.
And you shall have it shortly. My bad.
Quoted 2 lines
2) you introduced a deviation from the upstream kernel
ethtool.h:
I see what happened. We moved those two entries in ethtool.h into the #ifdef __KERNEL__ section. I can create a patch for the kernel ethtool.h to move them back to match userspace if that is what folks want.
Quoted 17 lines
net-next-2.6/include/linux/ethtool.h 2010-02-24 renamed from ethtool-copy.h 2010-02-24 22:39:21.000000000 -0500 +0
-022:14:43.000000000 -0500
net-next-2.6/include/linux/ethtool.h 2010-02-24 renamed from ethtool-copy.h 2010-02-24 22:39:21.000000000 -0500 +0
-2@@ -389,8 +389,6 @@ #define ETHTOOL_RXNTUPLE_ACTION_DROP -1 }; -#define ETHTOOL_MAX_NTUPLE_LIST_ENTRY 1024 -#define ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY 14 struct ethtool_rx_ntuple { __u32 cmd; struct ethtool_rx_ntuple_flow_spec fs;
Quoted 24 lines · Peter P
Quoted 13 lines · Jeff Garzik
Quoted 12 lines · Jeff Kirsher
From: Peter Waskiewicz<[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>---
Quoted 8 lines
Quoted 3 lines
ethtool-copy.h | 35 +++++++++++++ ethtool.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 186 insertions(+), 5 deletions(-)applied, but two problems remain:
1) you failed to document this in the man page. I will expect a patch to ethtool.8.
Quoted 8 lines
And you shall have it shortly. My bad.
Quoted 2 lines
2) you introduced a deviation from the upstream kernel
ethtool.h:I see what happened. We moved those two entries in
ethtool.hinto the #ifdef__KERNEL__section. I can create a patch for the kernelethtool.hto move them back to match userspace if that is what folks want.
One way or another, userspace ethtool-copy.h must match the kernel's, and userspace ethtool does not build without those definitions... They are de facto part of the interface at this point, though you are welcome to change that if you wish.
Jeff
Quoted 17 lines · Jeff Garzik
Quoted 8 lines · Jeff Kirsher
From: Peter Waskiewicz<[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.Quoted 7 lines
Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>---
ethtool-copy.h | 35 +++++++++++++ ethtool.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 186 insertions(+), 5 deletions(-)
Quoted 6 lines
applied, but two problems remain:
1) you failed to document this in the man page. I will expect a patch to ethtool.8.
2) you introduced a deviation from the upstream kernel
ethtool.h:
The way I've come up with to fix this is less intrusive than I want, but I think it's right way to do it. The intent wasn't to have ethtool (userspace) enforce how many filters could be returned. What it should do is get the number of strings through drvinfo to make the proper memory allocation.
What I need to change is the drvinfo struct in the kernel to include the ethtool strings field, returned from get_sset_count(). Then I can pull that into userspace and make the correct memory allocation, then call get_rx_ntuple().
This will require a small kernel change. Will something like this be pulled in at this point, given that 2.6.33 just released?
-PJ
Quoted 32 lines · Peter P
Quoted 17 lines · Jeff Garzik
Quoted 8 lines · Jeff Kirsher
From: Peter Waskiewicz<[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.Quoted 7 lines
Signed-off-by Peter P Waskiewicz Jr<[email protected]>Signed-off-by Jeff Kirsher<[email protected]>---
ethtool-copy.h | 35 +++++++++++++ ethtool.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 186 insertions(+), 5 deletions(-)Quoted 6 lines
applied, but two problems remain:
1) you failed to document this in the man page. I will expect a patch to ethtool.8.
2) you introduced a deviation from the upstream kernel
ethtool.h:The way I've come up with to fix this is less intrusive than I want, but I think it's right way to do it. The intent wasn't to have ethtool (userspace) enforce how many filters could be returned. What it should do is get the number of strings through drvinfo to make the proper memory allocation.
Quoted 4 lines
What I need to change is the drvinfo struct in the kernel to include the ethtool strings field, returned from
get_sset_count(). Then I can pull that into userspace and make the correct memory allocation, then callget_rx_ntuple().
I would say we need a ETHTOOL_GSTRINGS_COUNT rather than expanding drvinfo anymore... but yeah, expanding drvinfo would work too.
Quoted 2 lines
This will require a small kernel change. Will something like this be pulled in at this point, given that 2.6.33 just released?
The n-tuple stuff is not in 2.6.33's ethtool interface, so it hasn't actually made it into a released kernel at this point.
It seems reasonable for 2.6.34 to either add ETHTOOL_GSTRINGS_COUNT or update drvinfo. Even if net-next has already been pulled into post-2.6.33 merge window, that would IMO qualify as a reasonable interface bugfix to get upstream. The ethtool n-tuple ABI is not locked into stone until 2.6.34 is released by Linus.
Jeff
David Miller
maintainerFrom: Jeff Garzik <[email protected]>
Date: Thu, 25 Feb 2010 21:26:38 -0500
Quoted 12 lines · Peter P
Quoted 2 lines
This will require a small kernel change. Will something like this be pulled in at this point, given that 2.6.33 just released?
The n-tuple stuff is not in 2.6.33's ethtool interface, so it hasn't actually made it into a released kernel at this point.
It seems reasonable for 2.6.34 to either add
ETHTOOL_GSTRINGS_COUNTor update drvinfo. Even if net-next has already been pulled into post-2.6.33 merge window, that would IMO qualify as a reasonable interface bugfix to get upstream. The ethtool n-tuple ABI is not locked into stone until 2.6.34 is released by Linus.
Right.
Quoted 10 lines · David Miller
From: Jeff Garzik <[email protected]>
Date: Thu, 25 Feb 2010 21:26:38 -0500Quoted 7 lines · Peter P
Quoted 2 lines
This will require a small kernel change. Will something like this be pulled in at this point, given that 2.6.33 just released?
The n-tuple stuff is not in 2.6.33's ethtool interface, so it hasn't actually made it into a released kernel at this point.
Quoted 7 lines
Quoted 5 lines
It seems reasonable for 2.6.34 to either add
ETHTOOL_GSTRINGS_COUNTor update drvinfo. Even if net-next has already been pulled into post-2.6.33 merge window, that would IMO qualify as a reasonable interface bugfix to get upstream. The ethtool n-tuple ABI is not locked into stone until 2.6.34 is released by Linus.Right.
Sounds good. I wanted to make sure before I changed the ethtool bits. Expect a patch for both the kernel side and userspace side shortly.
-PJ
Quoted 1 line · Jeff Garzik
On 02/25/2010 08:49 PM, Waskiewicz Jr, Peter P wrote:
[...]
Quoted 11 lines
Quoted 2 lines
This will require a small kernel change. Will something like this be pulled in at this point, given that 2.6.33 just released?
The n-tuple stuff is not in 2.6.33's ethtool interface, so it hasn't actually made it into a released kernel at this point.
It seems reasonable for 2.6.34 to either add
ETHTOOL_GSTRINGS_COUNTor update drvinfo. Even if net-next has already been pulled into post-2.6.33 merge window, that would IMO qualify as a reasonable interface bugfix to get upstream. The ethtool n-tuple ABI is not locked into stone until 2.6.34 is released by Linus.
Given that, I would really like to see the tuple strings replaced with binary structures. Setting them in binary format and retrieving them in text format is inelegant. Also we should not assume that ethtool is the only user of the ethtool API. If someone wanted to write a GUI to manage the filter tuples, or a tool that would programmatically reconfigure filters, they would have to parse the strings.
Even the lookup of number of strings seems to be completely misconceived. It's delegated to the driver thus:
ret = ops->get_sset_count(dev, gstrings.string_set);
if (ret < 0)
return ret;What if gstrings.string_set != ETH_SS_NTUPLE_FILTERS? Why is that even a parameter to the operation?
Further, each filter can be formatted as multiple strings. So is the driver supposed to know how many strings the ethtool core might generate?
Ben.
Signature · 3 lines
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.
Quoted 29 lines · Ben Hutchings
Quoted 1 line · Jeff Garzik
On 02/25/2010 08:49 PM, Waskiewicz Jr, Peter P wrote:
[...]
Quoted 11 lines
Quoted 2 lines
This will require a small kernel change. Will something like this be pulled in at this point, given that 2.6.33 just released?
The n-tuple stuff is not in 2.6.33's ethtool interface, so it hasn't actually made it into a released kernel at this point.
It seems reasonable for 2.6.34 to either add
ETHTOOL_GSTRINGS_COUNTor update drvinfo. Even if net-next has already been pulled into post-2.6.33 merge window, that would IMO qualify as a reasonable interface bugfix to get upstream. The ethtool n-tuple ABI is not locked into stone until 2.6.34 is released by Linus.Given that, I would really like to see the tuple strings replaced with binary structures. Setting them in binary format and retrieving them in text format is inelegant. Also we should not assume that ethtool is the only user of the ethtool API. If someone wanted to write a GUI to manage the filter tuples, or a tool that would programmatically reconfigure filters, they would have to parse the strings.
Even the lookup of number of strings seems to be completely misconceived. It's delegated to the driver thus:
ret = ops->get_sset_count(dev, gstrings.string_set); if (ret< 0) return ret;
Quoted 6 lines
What if gstrings.string_set !=
ETH_SS_NTUPLE_FILTERS? Why is that even a parameter to the operation?Further, each filter can be formatted as multiple strings. So is the driver supposed to know how many strings the ethtool core might generate?
Speaking _generally_, not specifically about n-tuple filters, text strings are much more flexible across varied types of hardware. For example, the "private flags" ethtool interface is intended to be used as a generic means for a driver to export a set of hardware-specific boolean knobs.
For example, e1000e's SmartPowerDownEnable need not be a module-wide parameter applying to all e1000e devices in the system. ethtool's private-flags interface could enable per-net_device runtime setting of this Intel-specific feature, simply by exporting a string "SmartPowerDownEnable" as a private flag.
Thus, text strings isolate the problem of hardware-specific settings, features and structures entirely in the kernel driver itself.
Getting back to n-tuple filters, the question becomes: how hardware-specific are the filter formats?
Using binary structures is generally more efficient... but efficiency is not really a primary goal. Working across a broad spectrum of hardware, future-proof-edness, is more important. Binary structures may lock ethtool users into a very specific filter specification -- one that might not be as easily applicable to other vendors' hardware, or even future hardware from the same vendor.
procfs and sysfs exist in their current, ASCII-friendly form in part because Linus has often observed that text strings are often easier and more resilient kernel<->userspace interfaces than binary interfaces.
All that said, I cannot argue that there are elements of the current Intel implementation that are quite inelegant, and binary structures may simply be easier.
Like everything else in life, it's a balance... ;-)
Jeff
Quoted 7 lines · Jeff Kirsher
From: Peter Waskiewicz <[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.
I just noticed a problem with the implementation which makes me wonder whether this was tested at all:
[...]
Quoted 15 lines
ethtool.c +15
-0+static struct cmdline_info cmdline_ntuple[] = { + {"src-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4src,NULL }, + {"src-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4src,NULL }, + {"dst-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4dst,NULL }, + {"dst-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4dst,NULL }, + {"src-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.psrc,NULL }, + {"src-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.psrc,NULL }, + {"dst-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.pdst,NULL }, + {"dst-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.pdst,NULL }, + {"vlan" ,CMDL_INT , &ntuple_fs.vlan_tag,NULL }, + {"vlan-mask" ,CMDL_UINT , &ntuple_fs.vlan_tag_mask,NULL }, + {"user-def" ,CMDL_INT , &ntuple_fs.data,NULL }, + {"user-def-mask" ,CMDL_UINT , &ntuple_fs.data_mask,NULL }, + {"action" ,CMDL_INT , &ntuple_fs.action,NULL }, +};
[...]
Quoted 11 lines
ethtool.c +11
-0+if (mode ==MODE_SNTUPLE ) { +if (!strcmp (argp[i],"flow-type" )) { + i +=1 ; +if (i >= argc) { +show_usage (1 ); +break ; + } + ntuple_fs.flow_type = +rxflow_str_to_type (argp[i]); + i +=1 ; + parse_generic_cmdline(argc, argp, i,
ethtool.c static void parse_cmdline(int argc, char **argp) · line 686
Quoted 10 lines
ethtool.c +10
-0+ &sntuple_changed, + cmdline_ntuple, + ARRAY_SIZE(cmdline_ntuple)); + i = argc; +break ; + }else { +show_usage (1 ); + } +break ; + }
[...]
parse_generic_cmdline() will write an int for each argument defined with type CMDL_INT or CMDL_UINT. But the fields in ntuple_fs are not all of type int (or even 32-bit) - some of them are 16-bit or 64-bit, and some of them are big-endian. I also wonder whether anyone really wants to enter an IPv4 address as a single integer.
Ben.
Signature · 3 lines
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.
Quoted 11 lines · Ben Hutchings
Quoted 7 lines · Jeff Kirsher
From: Peter Waskiewicz <[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.I just noticed a problem with the implementation which makes me wonder whether this was tested at all:
Yes, it was tested. We didn't hit every corner case, which I think your catch below is a corner case issue. Our hardware can only do so much.
Quoted 39 lines
[...]
Quoted 15 lines
ethtool.c +15
-0+static struct cmdline_info cmdline_ntuple[] = { + {"src-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4src,NULL }, + {"src-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4src,NULL }, + {"dst-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4dst,NULL }, + {"dst-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4dst,NULL }, + {"src-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.psrc,NULL }, + {"src-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.psrc,NULL }, + {"dst-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.pdst,NULL }, + {"dst-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.pdst,NULL }, + {"vlan" ,CMDL_INT , &ntuple_fs.vlan_tag,NULL }, + {"vlan-mask" ,CMDL_UINT , &ntuple_fs.vlan_tag_mask,NULL }, + {"user-def" ,CMDL_INT , &ntuple_fs.data,NULL }, + {"user-def-mask" ,CMDL_UINT , &ntuple_fs.data_mask,NULL }, + {"action" ,CMDL_INT , &ntuple_fs.action,NULL }, +};[...]
Quoted 11 lines
ethtool.c +11
-0+if (mode ==MODE_SNTUPLE ) { +if (!strcmp (argp[i],"flow-type" )) { + i +=1 ; +if (i >= argc) { +show_usage (1 ); +break ; + } + ntuple_fs.flow_type = +rxflow_str_to_type (argp[i]); + i +=1 ; + parse_generic_cmdline(argc, argp, i,ethtool.c static void parse_cmdline(int argc, char **argp) · line 686
Quoted 10 lines
ethtool.c +10
-0+ &sntuple_changed, + cmdline_ntuple, + ARRAY_SIZE(cmdline_ntuple)); + i = argc; +break ; + }else { +show_usage (1 ); + } +break ; + }
Quoted 7 lines
[...]
parse_generic_cmdline()will write an int for each argument defined with typeCMDL_INTorCMDL_UINT. But the fields inntuple_fsare not all of type int (or even 32-bit) - some of them are 16-bit or 64-bit, and some of them are big-endian. I also wonder whether anyone really wants to enter an IPv4 address as a single integer.
The assignment is broken since 'p' is an int. That can be fixed. Also, we can fix the 64-bit field. I added the user-defined field to be 64-bit so that we weren't locking anyone down. My hardware only uses 2 bytes, so I was only able to test that.
When this was proposed, we added the IPv4 address as a single int. People seemed ok with it at the time, so we went with it. If you have a different approach, please present it.
Cheers,
-PJ
Quoted 8 lines · Peter P Waskiewicz Jr
Quoted 6 lines · Ben Hutchings
Quoted 5 lines · Jeff Kirsher
From: Peter Waskiewicz <[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
Quoted 29 lines
Quoted 5 lines
Quoted 2 lines
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.I just noticed a problem with the implementation which makes me wonder whether this was tested at all:
Yes, it was tested. We didn't hit every corner case, which I think your catch below is a corner case issue. Our hardware can only do so much.
Quoted 21 lines
[...]
Quoted 15 lines
ethtool.c +15
-0+static struct cmdline_info cmdline_ntuple[] = { + {"src-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4src,NULL }, + {"src-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4src,NULL }, + {"dst-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4dst,NULL }, + {"dst-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4dst,NULL }, + {"src-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.psrc,NULL }, + {"src-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.psrc,NULL }, + {"dst-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.pdst,NULL }, + {"dst-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.pdst,NULL }, + {"vlan" ,CMDL_INT , &ntuple_fs.vlan_tag,NULL }, + {"vlan-mask" ,CMDL_UINT , &ntuple_fs.vlan_tag_mask,NULL }, + {"user-def" ,CMDL_INT , &ntuple_fs.data,NULL }, + {"user-def-mask" ,CMDL_UINT , &ntuple_fs.data_mask,NULL }, + {"action" ,CMDL_INT , &ntuple_fs.action,NULL }, +};[...]
Quoted 3 lines
ethtool.c +3
-0+if (mode ==MODE_SNTUPLE ) { +if (!strcmp (argp[i],"flow-type" )) { + i +=1 ;
Why not " i++; " ?
Quoted 7 lines
Quoted 7 lines
ethtool.c static void parse_cmdline(int argc, char **argp) · line 675
Quoted 7 lines
ethtool.c +7
-0+if (i >= argc) { +show_usage (1 ); +break ; + } + ntuple_fs.flow_type = +rxflow_str_to_type (argp[i]); + i +=1 ;
Why not " i++; " ?
Quoted 19 lines
Quoted 11 lines
ethtool.c static void parse_cmdline(int argc, char **argp) · line 686
Quoted 11 lines
ethtool.c +11
-0+parse_generic_cmdline (argc, argp, i, + &sntuple_changed, + cmdline_ntuple, +ARRAY_SIZE (cmdline_ntuple)); + i = argc; +break ; + }else { +show_usage (1 ); + } +break ; + }Quoted 7 lines
[...]
parse_generic_cmdline()will write an int for each argument defined with typeCMDL_INTorCMDL_UINT. But the fields inntuple_fsare not all of type int (or even 32-bit) - some of them are 16-bit or 64-bit, and some of them are big-endian. I also wonder whether anyone really wants to enter an IPv4 address as a single integer.
Quoted 6 lines
The assignment is broken since 'p' is an int. That can be fixed. Also, we can fix the 64-bit field. I added the user-defined field to be 64-bit so that we weren't locking anyone down. My hardware only uses 2 bytes, so I was only able to test that.
When this was proposed, we added the IPv4 address as a single int. People seemed ok with it at the time, so we went with it. If you have a different approach, please present it.
Cheers,
-PJ
Without changing the flow:
NIT cleanup.
See inline.
Mitchell Erblich
Quoted 4 lines
--
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
Quoted 37 lines · Mitchell Erblich
Quoted 34 lines · Peter P Waskiewicz Jr
Quoted 11 lines · Ben Hutchings
Quoted 7 lines · Jeff Kirsher
From: Peter Waskiewicz <[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.I just noticed a problem with the implementation which makes me wonder whether this was tested at all:
Yes, it was tested. We didn't hit every corner case, which I think your catch below is a corner case issue. Our hardware can only do so much.
Quoted 18 lines
[...]
Quoted 15 lines
ethtool.c +15
-0+static struct cmdline_info cmdline_ntuple[] = { + {"src-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4src,NULL }, + {"src-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4src,NULL }, + {"dst-ip" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.ip4dst,NULL }, + {"dst-ip-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.ip4dst,NULL }, + {"src-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.psrc,NULL }, + {"src-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.psrc,NULL }, + {"dst-port" ,CMDL_INT , &ntuple_fs.h_u.tcp_ip4_spec.pdst,NULL }, + {"dst-port-mask" ,CMDL_UINT , &ntuple_fs.m_u.tcp_ip4_spec.pdst,NULL }, + {"vlan" ,CMDL_INT , &ntuple_fs.vlan_tag,NULL }, + {"vlan-mask" ,CMDL_UINT , &ntuple_fs.vlan_tag_mask,NULL }, + {"user-def" ,CMDL_INT , &ntuple_fs.data,NULL }, + {"user-def-mask" ,CMDL_UINT , &ntuple_fs.data_mask,NULL }, + {"action" ,CMDL_INT , &ntuple_fs.action,NULL }, +};[...]
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
ethtool.c static void parse_cmdline(int argc, char **argp) · line 668
Quoted 3 lines
ethtool.c +3
-0+if (mode ==MODE_SNTUPLE ) { +if (!strcmp (argp[i],"flow-type" )) { + i +=1 ;Why not " i++; " ?
I used previous style in the file. Either is fine. However, please note this code has already been committed and released. If we want to change this, then a new patch should be submitted. I don't think it's worth the thrash though.
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
ethtool.c static void parse_cmdline(int argc, char **argp) · line 675
Quoted 8 lines
ethtool.c +7
-0+if (i >= argc) { +show_usage (1 ); +break ; + } + ntuple_fs.flow_type = +rxflow_str_to_type (argp[i]); + i +=1 ;Why not " i++; " ?
See above.
Quoted 39 lines
Quoted 20 lines
Quoted 12 lines
ethtool.c static void parse_cmdline(int argc, char **argp) · line 686
Quoted 12 lines
ethtool.c +11
-0+parse_generic_cmdline (argc, argp, i, + &sntuple_changed, + cmdline_ntuple, +ARRAY_SIZE (cmdline_ntuple)); + i = argc; +break ; + }else { +show_usage (1 ); + } +break ; + }Quoted 7 lines
[...]
parse_generic_cmdline()will write an int for each argument defined with typeCMDL_INTorCMDL_UINT. But the fields inntuple_fsare not all of type int (or even 32-bit) - some of them are 16-bit or 64-bit, and some of them are big-endian. I also wonder whether anyone really wants to enter an IPv4 address as a single integer.Quoted 6 lines
The assignment is broken since 'p' is an int. That can be fixed. Also, we can fix the 64-bit field. I added the user-defined field to be 64-bit so that we weren't locking anyone down. My hardware only uses 2 bytes, so I was only able to test that.
When this was proposed, we added the IPv4 address as a single int. People seemed ok with it at the time, so we went with it. If you have a different approach, please present it.
Cheers,
-PJWithout changing the flow:
NIT cleanup.
See inline.Mitchell Erblich
Quoted 4 lines
--
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
Quoted 8 lines · Peter P Waskiewicz Jr
Quoted 6 lines · Ben Hutchings
Quoted 5 lines · Jeff Kirsher
From: Peter Waskiewicz <[email protected]>
Program underlying ethernet devices with n-tuple flow classification filters.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
This also adds a new flag to
ethtool_flags, allowing n-tuple programming to be toggled using theset_flagscall.I just noticed a problem with the implementation which makes me wonder whether this was tested at all:
Yes, it was tested. We didn't hit every corner case, which I think your catch below is a corner case issue. Our hardware can only do so much.
It's not a corner case. You have added options that cannot work correctly.
[...]
Quoted 3 lines
When this was proposed, we added the IPv4 address as a single int. People seemed ok with it at the time, so we went with it. If you have a different approach, please present it.
And you don't think it matters that the address has to be written differently on big- and little-endian architectures?
Ben.
Signature · 3 lines
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.