* Pull request: Fixes for new ethtool RSS commands
@ 2014-06-02 0:57 Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 1/8] ethtool: Return immediately on error in ethtool_copy_validate_indir() Ben Hutchings
` (9 more replies)
0 siblings, 10 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 0:57 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 2777 bytes --]
The following changes since commit eb02a272c97b6e25d8e5fcf1ea93923e6f155595:
driver/net/ethernet/ec_bhf.c: fix sparse warnings (2014-05-14 16:09:33 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/bwh/net-next.git ethtool-rssh-fixes
for you to fetch changes up to dfe805c14a2018c5a58cfa3921f1897032740501:
ethtool: Check that reserved fields of struct ethtool_rxfh are 0 (2014-05-19 01:30:30 +0100)
This addresses several problems I previously identified with the new
ETHTOOL_{G,S}RSSH commands:
1. Missing validation of reserved parameters
2. Vague documentation
3. Use of unnamed magic number
4. No consolidation with existing driver operations
I don't currently have access to suitable network hardware, but have
tested these changes with a dummy driver that can support various
combinations of operations and sizes, together with (a) Debian's ethtool
3.13 (b) ethtool 3.14 with the submitted patch to use ETHTOOL_{G,S}RSSH
and minor adjustment for fixes 1 and 3.
Ben.
----------------------------------------------------------------
Ben Hutchings (8):
ethtool: Return immediately on error in ethtool_copy_validate_indir()
ethtool: Name the 'no change' value for setting RSS hash key but not indir table
ethtool: Improve explanation of the two arrays following struct ethtool_rxfh
ethtool: Expand documentation of ethtool_ops::{get,set}_rxfh()
ethtool: Disallow ETHTOOL_SRSSH with both indir table and hash key unchanged
ethtool, be2net: constify array pointer parameters to ethtool_ops::set_rxfh
ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh()
ethtool: Check that reserved fields of struct ethtool_rxfh are 0
.../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 15 +--
drivers/net/ethernet/broadcom/tg3.c | 8 +-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 +-
drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
drivers/net/ethernet/emulex/benet/be_cmds.h | 2 +-
drivers/net/ethernet/emulex/benet/be_ethtool.c | 3 +-
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 15 +--
drivers/net/ethernet/intel/igb/igb_ethtool.c | 9 +-
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 10 +-
drivers/net/ethernet/sfc/ethtool.c | 10 +-
include/linux/ethtool.h | 24 ++---
include/uapi/linux/ethtool.h | 25 ++---
net/core/ethtool.c | 110 +++++++++------------
13 files changed, 116 insertions(+), 125 deletions(-)
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH net-next 1/8] ethtool: Return immediately on error in ethtool_copy_validate_indir()
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
@ 2014-06-02 1:01 ` Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 2/8] ethtool: Name the 'no change' value for setting RSS hash key but not indir table Ben Hutchings
` (8 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:01 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 1166 bytes --]
We must return -EFAULT immediately rather than continuing into
the loop.
Similarly, we may as well return -EINVAL directly.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
net/core/ethtool.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index aa8978a..c834cb2 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -561,19 +561,17 @@ static int ethtool_copy_validate_indir(u32 *indir, void __user *useraddr,
struct ethtool_rxnfc *rx_rings,
u32 size)
{
- int ret = 0, i;
+ int i;
if (copy_from_user(indir, useraddr, size * sizeof(indir[0])))
- ret = -EFAULT;
+ return -EFAULT;
/* Validate ring indices */
- for (i = 0; i < size; i++) {
- if (indir[i] >= rx_rings->data) {
- ret = -EINVAL;
- break;
- }
- }
- return ret;
+ for (i = 0; i < size; i++)
+ if (indir[i] >= rx_rings->data)
+ return -EINVAL;
+
+ return 0;
}
static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 2/8] ethtool: Name the 'no change' value for setting RSS hash key but not indir table
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 1/8] ethtool: Return immediately on error in ethtool_copy_validate_indir() Ben Hutchings
@ 2014-06-02 1:01 ` Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 3/8] ethtool: Improve explanation of the two arrays following struct ethtool_rxfh Ben Hutchings
` (7 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:01 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 3760 bytes --]
We usually allocate special values of u32 fields starting from the top
down, so also change the value to 0xffffffff. As these operations
haven't been included in a stable release yet, it's not too late to
change.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
include/uapi/linux/ethtool.h | 12 +++++++-----
net/core/ethtool.c | 12 +++++++-----
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index d47d31d..cba18e3 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -850,7 +850,8 @@ struct ethtool_rxfh_indir {
* struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key.
* @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH
* @rss_context: RSS context identifier.
- * @indir_size: On entry, the array size of the user buffer, which may be zero.
+ * @indir_size: On entry, the array size of the user buffer, which may be zero,
+ * or (for %ETHTOOL_SRSSH), %ETH_RXFH_INDIR_NO_CHANGE.
* On return from %ETHTOOL_GRSSH, the array size of the hardware
* indirection table.
* @key_size: On entry, the array size of the user buffer in bytes,
@@ -861,10 +862,10 @@ struct ethtool_rxfh_indir {
* of size @indir_size followed by hash key of size @key_size.
*
* For %ETHTOOL_GRSSH, a @indir_size and key_size of zero means that only the
- * size should be returned. For %ETHTOOL_SRSSH, a @indir_size of 0xDEADBEEF
- * means that indir table setting is not requested and a @indir_size of zero
- * means the indir table should be reset to default values. This last feature
- * is not supported by the original implementations.
+ * size should be returned. For %ETHTOOL_SRSSH, an @indir_size of
+ * %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested
+ * and a @indir_size of zero means the indir table should be reset to default
+ * values.
*/
struct ethtool_rxfh {
__u32 cmd;
@@ -874,6 +875,7 @@ struct ethtool_rxfh {
__u32 rsvd[2];
__u32 rss_config[0];
};
+#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
/**
* struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index c834cb2..7156fe5 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -803,12 +803,13 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
/* If either indir or hash key is valid, proceed further.
*/
- if ((user_indir_size && ((user_indir_size != 0xDEADBEEF) &&
- user_indir_size != dev_indir_size)) ||
+ if ((user_indir_size &&
+ user_indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
+ user_indir_size != dev_indir_size) ||
(user_key_size && (user_key_size != dev_key_size)))
return -EINVAL;
- if (user_indir_size != 0xDEADBEEF)
+ if (user_indir_size != ETH_RXFH_INDIR_NO_CHANGE)
indir_bytes = dev_indir_size * sizeof(indir[0]);
rss_config = kzalloc(indir_bytes + user_key_size, GFP_USER);
@@ -821,9 +822,10 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
goto out;
/* user_indir_size == 0 means reset the indir table to default.
- * user_indir_size == 0xDEADBEEF means indir setting is not requested.
+ * user_indir_size == ETH_RXFH_INDIR_NO_CHANGE means leave it unchanged.
*/
- if (user_indir_size && user_indir_size != 0xDEADBEEF) {
+ if (user_indir_size &&
+ user_indir_size != ETH_RXFH_INDIR_NO_CHANGE) {
indir = (u32 *)rss_config;
ret = ethtool_copy_validate_indir(indir,
useraddr + rss_cfg_offset,
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 3/8] ethtool: Improve explanation of the two arrays following struct ethtool_rxfh
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 1/8] ethtool: Return immediately on error in ethtool_copy_validate_indir() Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 2/8] ethtool: Name the 'no change' value for setting RSS hash key but not indir table Ben Hutchings
@ 2014-06-02 1:01 ` Ben Hutchings
2014-06-02 1:02 ` [PATCH net-next 4/8] ethtool: Expand documentation of ethtool_ops::{get,set}_rxfh() Ben Hutchings
` (6 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:01 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 2031 bytes --]
The use of two variable-length arrays is unusual so deserves a bit
more explanation.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
include/uapi/linux/ethtool.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h
index cba18e3..e3c7a71 100644
--- a/include/uapi/linux/ethtool.h
+++ b/include/uapi/linux/ethtool.h
@@ -850,16 +850,17 @@ struct ethtool_rxfh_indir {
* struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key.
* @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH
* @rss_context: RSS context identifier.
- * @indir_size: On entry, the array size of the user buffer, which may be zero,
- * or (for %ETHTOOL_SRSSH), %ETH_RXFH_INDIR_NO_CHANGE.
- * On return from %ETHTOOL_GRSSH, the array size of the hardware
- * indirection table.
- * @key_size: On entry, the array size of the user buffer in bytes,
- * which may be zero.
- * On return from %ETHTOOL_GRSSH, the size of the RSS hash key.
+ * @indir_size: On entry, the array size of the user buffer for the
+ * indirection table, which may be zero, or (for %ETHTOOL_SRSSH),
+ * %ETH_RXFH_INDIR_NO_CHANGE. On return from %ETHTOOL_GRSSH,
+ * the array size of the hardware indirection table.
+ * @key_size: On entry, the array size of the user buffer for the hash key,
+ * which may be zero. On return from %ETHTOOL_GRSSH, the size of the
+ * hardware hash key.
* @rsvd: Reserved for future extensions.
* @rss_config: RX ring/queue index for each hash value i.e., indirection table
- * of size @indir_size followed by hash key of size @key_size.
+ * of @indir_size __u32 elements, followed by hash key of @key_size
+ * bytes.
*
* For %ETHTOOL_GRSSH, a @indir_size and key_size of zero means that only the
* size should be returned. For %ETHTOOL_SRSSH, an @indir_size of
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 4/8] ethtool: Expand documentation of ethtool_ops::{get,set}_rxfh()
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (2 preceding siblings ...)
2014-06-02 1:01 ` [PATCH net-next 3/8] ethtool: Improve explanation of the two arrays following struct ethtool_rxfh Ben Hutchings
@ 2014-06-02 1:02 ` Ben Hutchings
2014-06-02 1:02 ` [PATCH net-next 5/8] ethtool: Disallow ETHTOOL_SRSSH with both indir table and hash key unchanged Ben Hutchings
` (5 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:02 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]
Some corner-cases are not explained properly.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
include/linux/ethtool.h | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 212f537..886e127 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -162,15 +162,16 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
* Will not be called if @get_rxfh_indir_size returns zero.
* @get_rxfh: Get the contents of the RX flow hash indirection table and hash
* key.
- * Will not be called if @get_rxfh_indir_size and @get_rxfh_key_size
- * returns zero.
+ * Will only be called if one or both of @get_rxfh_indir_size and
+ * @get_rxfh_key_size are implemented and return non-zero.
* Returns a negative error code or zero.
* @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
* Will not be called if @get_rxfh_indir_size returns zero.
- * @set_rxfh: Set the contents of the RX flow hash indirection table and
- * hash key.
- * Will not be called if @get_rxfh_indir_size and @get_rxfh_key_size
- * returns zero.
+ * @set_rxfh: Set the contents of the RX flow hash indirection table and/or
+ * hash key. Either or both arguments may be %NULL if that attribute
+ * is not to be changed.
+ * Will only be called if one or both of @get_rxfh_indir_size and
+ * @get_rxfh_key_size are implemented and return non-zero.
* Returns a negative error code or zero.
* @get_channels: Get number of channels.
* @set_channels: Set number of channels. Returns a negative error code or
@@ -244,8 +245,8 @@ struct ethtool_ops {
int (*reset)(struct net_device *, u32 *);
u32 (*get_rxfh_key_size)(struct net_device *);
u32 (*get_rxfh_indir_size)(struct net_device *);
- int (*get_rxfh)(struct net_device *, u32 *, u8 *);
- int (*set_rxfh)(struct net_device *, u32 *, u8 *);
+ int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key);
+ int (*set_rxfh)(struct net_device *, u32 *indir, u8 *key);
int (*get_rxfh_indir)(struct net_device *, u32 *);
int (*set_rxfh_indir)(struct net_device *, const u32 *);
void (*get_channels)(struct net_device *, struct ethtool_channels *);
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 5/8] ethtool: Disallow ETHTOOL_SRSSH with both indir table and hash key unchanged
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (3 preceding siblings ...)
2014-06-02 1:02 ` [PATCH net-next 4/8] ethtool: Expand documentation of ethtool_ops::{get,set}_rxfh() Ben Hutchings
@ 2014-06-02 1:02 ` Ben Hutchings
2014-06-02 1:02 ` [PATCH net-next 6/8] ethtool, be2net: constify array pointer parameters to ethtool_ops::set_rxfh Ben Hutchings
` (4 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:02 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 2168 bytes --]
This would be a no-op, so there is no reason to request it.
This also allows conversion of the current implementations of
ethtool_ops::{get,set}_rxfh_indir to ethtool_ops::{get,set}_rxfh
with no change other than their parameters.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
include/linux/ethtool.h | 4 ++--
net/core/ethtool.c | 5 ++++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 886e127..de687a9 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -168,8 +168,8 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
* @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
* Will not be called if @get_rxfh_indir_size returns zero.
* @set_rxfh: Set the contents of the RX flow hash indirection table and/or
- * hash key. Either or both arguments may be %NULL if that attribute
- * is not to be changed.
+ * hash key. In case only the indirection table or hash key is to be
+ * changed, the other argument will be %NULL.
* Will only be called if one or both of @get_rxfh_indir_size and
* @get_rxfh_key_size are implemented and return non-zero.
* Returns a negative error code or zero.
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 7156fe5..b885734 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -802,11 +802,14 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
return -EFAULT;
/* If either indir or hash key is valid, proceed further.
+ * It is not valid to request that both be unchanged.
*/
if ((user_indir_size &&
user_indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
user_indir_size != dev_indir_size) ||
- (user_key_size && (user_key_size != dev_key_size)))
+ (user_key_size && (user_key_size != dev_key_size)) ||
+ (user_indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
+ user_key_size == 0))
return -EINVAL;
if (user_indir_size != ETH_RXFH_INDIR_NO_CHANGE)
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 6/8] ethtool, be2net: constify array pointer parameters to ethtool_ops::set_rxfh
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (4 preceding siblings ...)
2014-06-02 1:02 ` [PATCH net-next 5/8] ethtool: Disallow ETHTOOL_SRSSH with both indir table and hash key unchanged Ben Hutchings
@ 2014-06-02 1:02 ` Ben Hutchings
2014-06-02 1:03 ` [PATCH net-next 7/8] ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh() Ben Hutchings
` (3 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:02 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 3126 bytes --]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
drivers/net/ethernet/emulex/benet/be_cmds.h | 2 +-
drivers/net/ethernet/emulex/benet/be_ethtool.c | 3 ++-
include/linux/ethtool.h | 3 ++-
4 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index 476752d..7b59da2 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -2033,7 +2033,7 @@ int be_cmd_reset_function(struct be_adapter *adapter)
}
int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
- u32 rss_hash_opts, u16 table_size, u8 *rss_hkey)
+ u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey)
{
struct be_mcc_wrb *wrb;
struct be_cmd_req_rss_config *req;
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 228d4b6..451f313 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -2068,7 +2068,7 @@ int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num,
u32 *function_mode, u32 *function_caps, u16 *asic_rev);
int be_cmd_reset_function(struct be_adapter *adapter);
int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
- u32 rss_hash_opts, u16 table_size, u8 *rss_hkey);
+ u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey);
int be_process_mcc(struct be_adapter *adapter);
int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon,
u8 status, u8 state);
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index 970ae33..e2da4d2 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -1117,7 +1117,8 @@ static int be_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey)
return 0;
}
-static int be_set_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey)
+static int be_set_rxfh(struct net_device *netdev, const u32 *indir,
+ const u8 *hkey)
{
int rc = 0, i, j;
struct be_adapter *adapter = netdev_priv(netdev);
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index de687a9..874fde0 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -246,7 +246,8 @@ struct ethtool_ops {
u32 (*get_rxfh_key_size)(struct net_device *);
u32 (*get_rxfh_indir_size)(struct net_device *);
int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key);
- int (*set_rxfh)(struct net_device *, u32 *indir, u8 *key);
+ int (*set_rxfh)(struct net_device *, const u32 *indir,
+ const u8 *key);
int (*get_rxfh_indir)(struct net_device *, u32 *);
int (*set_rxfh_indir)(struct net_device *, const u32 *);
void (*get_channels)(struct net_device *, struct ethtool_channels *);
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 7/8] ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh()
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (5 preceding siblings ...)
2014-06-02 1:02 ` [PATCH net-next 6/8] ethtool, be2net: constify array pointer parameters to ethtool_ops::set_rxfh Ben Hutchings
@ 2014-06-02 1:03 ` Ben Hutchings
2014-06-02 3:09 ` Jeff Kirsher
2014-06-02 1:04 ` [PATCH net-next 8/8] ethtool: Check that reserved fields of struct ethtool_rxfh are 0 Ben Hutchings
` (2 subsequent siblings)
9 siblings, 1 reply; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:03 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 15426 bytes --]
ETHTOOL_{G,S}RXFHINDIR and ETHTOOL_{G,S}RSSH should work for drivers
regardless of whether they expose the hash key, unless you try to
set a hash key for a driver that doesn't expose it.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 15 ++++++++-------
drivers/net/ethernet/broadcom/tg3.c | 8 ++++----
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 ++++----
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 15 +++++++++------
drivers/net/ethernet/intel/igb/igb_ethtool.c | 9 +++++----
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 10 +++++-----
drivers/net/ethernet/sfc/ethtool.c | 10 +++++-----
include/linux/ethtool.h | 6 ------
net/core/ethtool.c | 8 ++++----
9 files changed, 44 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index 0322409..af138f8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -3316,7 +3316,7 @@ static u32 bnx2x_get_rxfh_indir_size(struct net_device *dev)
return T_ETH_INDIRECTION_TABLE_SIZE;
}
-static int bnx2x_get_rxfh_indir(struct net_device *dev, u32 *indir)
+static int bnx2x_get_rxfh(struct net_device *dev, u32 *indir, u8 *key)
{
struct bnx2x *bp = netdev_priv(dev);
u8 ind_table[T_ETH_INDIRECTION_TABLE_SIZE] = {0};
@@ -3340,14 +3340,15 @@ static int bnx2x_get_rxfh_indir(struct net_device *dev, u32 *indir)
return 0;
}
-static int bnx2x_set_rxfh_indir(struct net_device *dev, const u32 *indir)
+static int bnx2x_set_rxfh(struct net_device *dev, const u32 *indir,
+ const u8 *key)
{
struct bnx2x *bp = netdev_priv(dev);
size_t i;
for (i = 0; i < T_ETH_INDIRECTION_TABLE_SIZE; i++) {
/*
- * The same as in bnx2x_get_rxfh_indir: we can't use a memcpy()
+ * The same as in bnx2x_get_rxfh: we can't use a memcpy()
* as an internal storage of an indirection table is a u8 array
* while indir->ring_index points to an array of u32.
*
@@ -3471,8 +3472,8 @@ static const struct ethtool_ops bnx2x_ethtool_ops = {
.get_rxnfc = bnx2x_get_rxnfc,
.set_rxnfc = bnx2x_set_rxnfc,
.get_rxfh_indir_size = bnx2x_get_rxfh_indir_size,
- .get_rxfh_indir = bnx2x_get_rxfh_indir,
- .set_rxfh_indir = bnx2x_set_rxfh_indir,
+ .get_rxfh = bnx2x_get_rxfh,
+ .set_rxfh = bnx2x_set_rxfh,
.get_channels = bnx2x_get_channels,
.set_channels = bnx2x_set_channels,
.get_module_info = bnx2x_get_module_info,
@@ -3498,8 +3499,8 @@ static const struct ethtool_ops bnx2x_vf_ethtool_ops = {
.get_rxnfc = bnx2x_get_rxnfc,
.set_rxnfc = bnx2x_set_rxnfc,
.get_rxfh_indir_size = bnx2x_get_rxfh_indir_size,
- .get_rxfh_indir = bnx2x_get_rxfh_indir,
- .set_rxfh_indir = bnx2x_set_rxfh_indir,
+ .get_rxfh = bnx2x_get_rxfh,
+ .set_rxfh = bnx2x_set_rxfh,
.get_channels = bnx2x_get_channels,
.set_channels = bnx2x_set_channels,
};
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index ccd9015..8c2314e 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -12501,7 +12501,7 @@ static u32 tg3_get_rxfh_indir_size(struct net_device *dev)
return size;
}
-static int tg3_get_rxfh_indir(struct net_device *dev, u32 *indir)
+static int tg3_get_rxfh(struct net_device *dev, u32 *indir, u8 *key)
{
struct tg3 *tp = netdev_priv(dev);
int i;
@@ -12512,7 +12512,7 @@ static int tg3_get_rxfh_indir(struct net_device *dev, u32 *indir)
return 0;
}
-static int tg3_set_rxfh_indir(struct net_device *dev, const u32 *indir)
+static int tg3_set_rxfh(struct net_device *dev, const u32 *indir, const u8 *key)
{
struct tg3 *tp = netdev_priv(dev);
size_t i;
@@ -14044,8 +14044,8 @@ static const struct ethtool_ops tg3_ethtool_ops = {
.get_sset_count = tg3_get_sset_count,
.get_rxnfc = tg3_get_rxnfc,
.get_rxfh_indir_size = tg3_get_rxfh_indir_size,
- .get_rxfh_indir = tg3_get_rxfh_indir,
- .set_rxfh_indir = tg3_set_rxfh_indir,
+ .get_rxfh = tg3_get_rxfh,
+ .set_rxfh = tg3_set_rxfh,
.get_channels = tg3_get_channels,
.set_channels = tg3_set_channels,
.get_ts_info = tg3_get_ts_info,
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 266a5bc..8cf6be9 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -2739,7 +2739,7 @@ static u32 get_rss_table_size(struct net_device *dev)
return pi->rss_size;
}
-static int get_rss_table(struct net_device *dev, u32 *p)
+static int get_rss_table(struct net_device *dev, u32 *p, u8 *key)
{
const struct port_info *pi = netdev_priv(dev);
unsigned int n = pi->rss_size;
@@ -2749,7 +2749,7 @@ static int get_rss_table(struct net_device *dev, u32 *p)
return 0;
}
-static int set_rss_table(struct net_device *dev, const u32 *p)
+static int set_rss_table(struct net_device *dev, const u32 *p, const u8 *key)
{
unsigned int i;
struct port_info *pi = netdev_priv(dev);
@@ -2851,8 +2851,8 @@ static const struct ethtool_ops cxgb_ethtool_ops = {
.set_wol = set_wol,
.get_rxnfc = get_rxnfc,
.get_rxfh_indir_size = get_rss_table_size,
- .get_rxfh_indir = get_rss_table,
- .set_rxfh_indir = set_rss_table,
+ .get_rxfh = get_rss_table,
+ .set_rxfh = set_rss_table,
.flash_device = set_flash,
};
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
index 77e786d..dbc8986 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c
@@ -626,13 +626,14 @@ static u32 i40evf_get_rxfh_indir_size(struct net_device *netdev)
}
/**
- * i40evf_get_rxfh_indir - get the rx flow hash indirection table
+ * i40evf_get_rxfh - get the rx flow hash indirection table
* @netdev: network interface device structure
* @indir: indirection table
+ * @key: hash key (will be %NULL until get_rxfh_key_size is implemented)
*
* Reads the indirection table directly from the hardware. Always returns 0.
**/
-static int i40evf_get_rxfh_indir(struct net_device *netdev, u32 *indir)
+static int i40evf_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
{
struct i40evf_adapter *adapter = netdev_priv(netdev);
struct i40e_hw *hw = &adapter->hw;
@@ -650,14 +651,16 @@ static int i40evf_get_rxfh_indir(struct net_device *netdev, u32 *indir)
}
/**
- * i40evf_set_rxfh_indir - set the rx flow hash indirection table
+ * i40evf_set_rxfh - set the rx flow hash indirection table
* @netdev: network interface device structure
* @indir: indirection table
+ * @key: hash key (will be %NULL until get_rxfh_key_size is implemented)
*
* Returns -EINVAL if the table specifies an inavlid queue id, otherwise
* returns 0 after programming the table.
**/
-static int i40evf_set_rxfh_indir(struct net_device *netdev, const u32 *indir)
+static int i40evf_set_rxfh(struct net_device *netdev, const u32 *indir,
+ const u8 *key)
{
struct i40evf_adapter *adapter = netdev_priv(netdev);
struct i40e_hw *hw = &adapter->hw;
@@ -691,8 +694,8 @@ static struct ethtool_ops i40evf_ethtool_ops = {
.get_rxnfc = i40evf_get_rxnfc,
.set_rxnfc = i40evf_set_rxnfc,
.get_rxfh_indir_size = i40evf_get_rxfh_indir_size,
- .get_rxfh_indir = i40evf_get_rxfh_indir,
- .set_rxfh_indir = i40evf_set_rxfh_indir,
+ .get_rxfh = i40evf_get_rxfh,
+ .set_rxfh = i40evf_set_rxfh,
.get_channels = i40evf_get_channels,
};
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index a84297c..d8bbcf1 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -2830,7 +2830,7 @@ static u32 igb_get_rxfh_indir_size(struct net_device *netdev)
return IGB_RETA_SIZE;
}
-static int igb_get_rxfh_indir(struct net_device *netdev, u32 *indir)
+static int igb_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
{
struct igb_adapter *adapter = netdev_priv(netdev);
int i;
@@ -2876,7 +2876,8 @@ void igb_write_rss_indir_tbl(struct igb_adapter *adapter)
}
}
-static int igb_set_rxfh_indir(struct net_device *netdev, const u32 *indir)
+static int igb_set_rxfh(struct net_device *netdev, const u32 *indir,
+ const u8 *key)
{
struct igb_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw;
@@ -3025,8 +3026,8 @@ static const struct ethtool_ops igb_ethtool_ops = {
.get_module_info = igb_get_module_info,
.get_module_eeprom = igb_get_module_eeprom,
.get_rxfh_indir_size = igb_get_rxfh_indir_size,
- .get_rxfh_indir = igb_get_rxfh_indir,
- .set_rxfh_indir = igb_set_rxfh_indir,
+ .get_rxfh = igb_get_rxfh,
+ .set_rxfh = igb_set_rxfh,
.get_channels = igb_get_channels,
.set_channels = igb_set_channels,
.begin = igb_ethtool_begin,
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
index a72d99f..263a1c7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
@@ -564,7 +564,7 @@ static u32 mlx4_en_get_rxfh_indir_size(struct net_device *dev)
return priv->rx_ring_num;
}
-static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index)
+static int mlx4_en_get_rxfh(struct net_device *dev, u32 *ring_index, u8 *key)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_rss_map *rss_map = &priv->rss_map;
@@ -582,8 +582,8 @@ static int mlx4_en_get_rxfh_indir(struct net_device *dev, u32 *ring_index)
return err;
}
-static int mlx4_en_set_rxfh_indir(struct net_device *dev,
- const u32 *ring_index)
+static int mlx4_en_set_rxfh(struct net_device *dev, const u32 *ring_index,
+ const u8 *key)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
struct mlx4_en_dev *mdev = priv->mdev;
@@ -1224,8 +1224,8 @@ const struct ethtool_ops mlx4_en_ethtool_ops = {
.get_rxnfc = mlx4_en_get_rxnfc,
.set_rxnfc = mlx4_en_set_rxnfc,
.get_rxfh_indir_size = mlx4_en_get_rxfh_indir_size,
- .get_rxfh_indir = mlx4_en_get_rxfh_indir,
- .set_rxfh_indir = mlx4_en_set_rxfh_indir,
+ .get_rxfh = mlx4_en_get_rxfh,
+ .set_rxfh = mlx4_en_set_rxfh,
.get_channels = mlx4_en_get_channels,
.set_channels = mlx4_en_set_channels,
.get_ts_info = mlx4_en_get_ts_info,
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c
index 0de8b07..74739c4 100644
--- a/drivers/net/ethernet/sfc/ethtool.c
+++ b/drivers/net/ethernet/sfc/ethtool.c
@@ -1033,7 +1033,7 @@ static u32 efx_ethtool_get_rxfh_indir_size(struct net_device *net_dev)
0 : ARRAY_SIZE(efx->rx_indir_table));
}
-static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
+static int efx_ethtool_get_rxfh(struct net_device *net_dev, u32 *indir, u8 *key)
{
struct efx_nic *efx = netdev_priv(net_dev);
@@ -1041,8 +1041,8 @@ static int efx_ethtool_get_rxfh_indir(struct net_device *net_dev, u32 *indir)
return 0;
}
-static int efx_ethtool_set_rxfh_indir(struct net_device *net_dev,
- const u32 *indir)
+static int efx_ethtool_set_rxfh(struct net_device *net_dev,
+ const u32 *indir, const u8 *key)
{
struct efx_nic *efx = netdev_priv(net_dev);
@@ -1125,8 +1125,8 @@ const struct ethtool_ops efx_ethtool_ops = {
.get_rxnfc = efx_ethtool_get_rxnfc,
.set_rxnfc = efx_ethtool_set_rxnfc,
.get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
- .get_rxfh_indir = efx_ethtool_get_rxfh_indir,
- .set_rxfh_indir = efx_ethtool_set_rxfh_indir,
+ .get_rxfh = efx_ethtool_get_rxfh,
+ .set_rxfh = efx_ethtool_set_rxfh,
.get_ts_info = efx_ethtool_get_ts_info,
.get_module_info = efx_ethtool_get_module_info,
.get_module_eeprom = efx_ethtool_get_module_eeprom,
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 874fde0..e658229 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -158,15 +158,11 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings)
* Returns zero if not supported for this specific device.
* @get_rxfh_indir_size: Get the size of the RX flow hash indirection table.
* Returns zero if not supported for this specific device.
- * @get_rxfh_indir: Get the contents of the RX flow hash indirection table.
- * Will not be called if @get_rxfh_indir_size returns zero.
* @get_rxfh: Get the contents of the RX flow hash indirection table and hash
* key.
* Will only be called if one or both of @get_rxfh_indir_size and
* @get_rxfh_key_size are implemented and return non-zero.
* Returns a negative error code or zero.
- * @set_rxfh_indir: Set the contents of the RX flow hash indirection table.
- * Will not be called if @get_rxfh_indir_size returns zero.
* @set_rxfh: Set the contents of the RX flow hash indirection table and/or
* hash key. In case only the indirection table or hash key is to be
* changed, the other argument will be %NULL.
@@ -248,8 +244,6 @@ struct ethtool_ops {
int (*get_rxfh)(struct net_device *, u32 *indir, u8 *key);
int (*set_rxfh)(struct net_device *, const u32 *indir,
const u8 *key);
- int (*get_rxfh_indir)(struct net_device *, u32 *);
- int (*set_rxfh_indir)(struct net_device *, const u32 *);
void (*get_channels)(struct net_device *, struct ethtool_channels *);
int (*set_channels)(struct net_device *, struct ethtool_channels *);
int (*get_dump_flag)(struct net_device *, struct ethtool_dump *);
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index b885734..8ae452a 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -582,7 +582,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
int ret;
if (!dev->ethtool_ops->get_rxfh_indir_size ||
- !dev->ethtool_ops->get_rxfh_indir)
+ !dev->ethtool_ops->get_rxfh)
return -EOPNOTSUPP;
dev_size = dev->ethtool_ops->get_rxfh_indir_size(dev);
if (dev_size == 0)
@@ -608,7 +608,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev,
if (!indir)
return -ENOMEM;
- ret = dev->ethtool_ops->get_rxfh_indir(dev, indir);
+ ret = dev->ethtool_ops->get_rxfh(dev, indir, NULL);
if (ret)
goto out;
@@ -632,7 +632,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
int ret;
u32 ringidx_offset = offsetof(struct ethtool_rxfh_indir, ring_index[0]);
- if (!ops->get_rxfh_indir_size || !ops->set_rxfh_indir ||
+ if (!ops->get_rxfh_indir_size || !ops->set_rxfh ||
!ops->get_rxnfc)
return -EOPNOTSUPP;
@@ -669,7 +669,7 @@ static noinline_for_stack int ethtool_set_rxfh_indir(struct net_device *dev,
goto out;
}
- ret = ops->set_rxfh_indir(dev, indir);
+ ret = ops->set_rxfh(dev, indir, NULL);
out:
kfree(indir);
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH net-next 8/8] ethtool: Check that reserved fields of struct ethtool_rxfh are 0
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (6 preceding siblings ...)
2014-06-02 1:03 ` [PATCH net-next 7/8] ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh() Ben Hutchings
@ 2014-06-02 1:04 ` Ben Hutchings
2014-06-02 1:11 ` Pull request: Fixes for new ethtool RSS commands Ben Hutchings
2014-06-03 0:13 ` David Miller
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:04 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 6181 bytes --]
We should fail rather than silently ignoring use of these extensions.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
net/core/ethtool.c | 89 ++++++++++++++++++++++--------------------------------
1 file changed, 36 insertions(+), 53 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 8ae452a..17cb912 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -681,11 +681,11 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
{
int ret;
const struct ethtool_ops *ops = dev->ethtool_ops;
- u32 user_indir_size = 0, user_key_size = 0;
+ u32 user_indir_size, user_key_size;
u32 dev_indir_size = 0, dev_key_size = 0;
+ struct ethtool_rxfh rxfh;
u32 total_size;
- u32 indir_offset, indir_bytes;
- u32 key_offset;
+ u32 indir_bytes;
u32 *indir = NULL;
u8 *hkey = NULL;
u8 *rss_config;
@@ -697,33 +697,24 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,
if (ops->get_rxfh_indir_size)
dev_indir_size = ops->get_rxfh_indir_size(dev);
-
- indir_offset = offsetof(struct ethtool_rxfh, indir_size);
-
- if (copy_from_user(&user_indir_size,
- useraddr + indir_offset,
- sizeof(user_indir_size)))
- return -EFAULT;
-
- if (copy_to_user(useraddr + indir_offset,
- &dev_indir_size, sizeof(dev_indir_size)))
- return -EFAULT;
-
if (ops->get_rxfh_key_size)
dev_key_size = ops->get_rxfh_key_size(dev);
if ((dev_key_size + dev_indir_size) == 0)
return -EOPNOTSUPP;
- key_offset = offsetof(struct ethtool_rxfh, key_size);
-
- if (copy_from_user(&user_key_size,
- useraddr + key_offset,
- sizeof(user_key_size)))
+ if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
return -EFAULT;
+ user_indir_size = rxfh.indir_size;
+ user_key_size = rxfh.key_size;
- if (copy_to_user(useraddr + key_offset,
- &dev_key_size, sizeof(dev_key_size)))
+ /* Check that reserved fields are 0 for now */
+ if (rxfh.rss_context || rxfh.rsvd[0] || rxfh.rsvd[1])
+ return -EINVAL;
+
+ rxfh.indir_size = dev_indir_size;
+ rxfh.key_size = dev_key_size;
+ if (copy_to_user(useraddr, &rxfh, sizeof(rxfh)))
return -EFAULT;
/* If the user buffer size is 0, this is just a query for the
@@ -768,12 +759,11 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
int ret;
const struct ethtool_ops *ops = dev->ethtool_ops;
struct ethtool_rxnfc rx_rings;
- u32 user_indir_size = 0, dev_indir_size = 0, i;
- u32 user_key_size = 0, dev_key_size = 0;
+ struct ethtool_rxfh rxfh;
+ u32 dev_indir_size = 0, dev_key_size = 0, i;
u32 *indir = NULL, indir_bytes = 0;
u8 *hkey = NULL;
u8 *rss_config;
- u32 indir_offset, key_offset;
u32 rss_cfg_offset = offsetof(struct ethtool_rxfh, rss_config[0]);
if (!(ops->get_rxfh_indir_size || ops->get_rxfh_key_size) ||
@@ -782,40 +772,33 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
if (ops->get_rxfh_indir_size)
dev_indir_size = ops->get_rxfh_indir_size(dev);
-
- indir_offset = offsetof(struct ethtool_rxfh, indir_size);
- if (copy_from_user(&user_indir_size,
- useraddr + indir_offset,
- sizeof(user_indir_size)))
- return -EFAULT;
-
if (ops->get_rxfh_key_size)
dev_key_size = dev->ethtool_ops->get_rxfh_key_size(dev);
-
if ((dev_key_size + dev_indir_size) == 0)
return -EOPNOTSUPP;
- key_offset = offsetof(struct ethtool_rxfh, key_size);
- if (copy_from_user(&user_key_size,
- useraddr + key_offset,
- sizeof(user_key_size)))
+ if (copy_from_user(&rxfh, useraddr, sizeof(rxfh)))
return -EFAULT;
+ /* Check that reserved fields are 0 for now */
+ if (rxfh.rss_context || rxfh.rsvd[0] || rxfh.rsvd[1])
+ return -EINVAL;
+
/* If either indir or hash key is valid, proceed further.
* It is not valid to request that both be unchanged.
*/
- if ((user_indir_size &&
- user_indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
- user_indir_size != dev_indir_size) ||
- (user_key_size && (user_key_size != dev_key_size)) ||
- (user_indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
- user_key_size == 0))
+ if ((rxfh.indir_size &&
+ rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE &&
+ rxfh.indir_size != dev_indir_size) ||
+ (rxfh.key_size && (rxfh.key_size != dev_key_size)) ||
+ (rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE &&
+ rxfh.key_size == 0))
return -EINVAL;
- if (user_indir_size != ETH_RXFH_INDIR_NO_CHANGE)
+ if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE)
indir_bytes = dev_indir_size * sizeof(indir[0]);
- rss_config = kzalloc(indir_bytes + user_key_size, GFP_USER);
+ rss_config = kzalloc(indir_bytes + rxfh.key_size, GFP_USER);
if (!rss_config)
return -ENOMEM;
@@ -824,29 +807,29 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
if (ret)
goto out;
- /* user_indir_size == 0 means reset the indir table to default.
- * user_indir_size == ETH_RXFH_INDIR_NO_CHANGE means leave it unchanged.
+ /* rxfh.indir_size == 0 means reset the indir table to default.
+ * rxfh.indir_size == ETH_RXFH_INDIR_NO_CHANGE means leave it unchanged.
*/
- if (user_indir_size &&
- user_indir_size != ETH_RXFH_INDIR_NO_CHANGE) {
+ if (rxfh.indir_size &&
+ rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE) {
indir = (u32 *)rss_config;
ret = ethtool_copy_validate_indir(indir,
useraddr + rss_cfg_offset,
&rx_rings,
- user_indir_size);
+ rxfh.indir_size);
if (ret)
goto out;
- } else if (user_indir_size == 0) {
+ } else if (rxfh.indir_size == 0) {
indir = (u32 *)rss_config;
for (i = 0; i < dev_indir_size; i++)
indir[i] = ethtool_rxfh_indir_default(i, rx_rings.data);
}
- if (user_key_size) {
+ if (rxfh.key_size) {
hkey = rss_config + indir_bytes;
if (copy_from_user(hkey,
useraddr + rss_cfg_offset + indir_bytes,
- user_key_size)) {
+ rxfh.key_size)) {
ret = -EFAULT;
goto out;
}
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: Pull request: Fixes for new ethtool RSS commands
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (7 preceding siblings ...)
2014-06-02 1:04 ` [PATCH net-next 8/8] ethtool: Check that reserved fields of struct ethtool_rxfh are 0 Ben Hutchings
@ 2014-06-02 1:11 ` Ben Hutchings
2014-06-03 0:13 ` David Miller
9 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-02 1:11 UTC (permalink / raw)
To: Venkat Duvvuru; +Cc: netdev
[-- Attachment #1.1: Type: text/plain, Size: 239 bytes --]
Here are the dummy driver module source and the ethtool changes (based
on your patch) that I used to exercise ETHTOOL_{G,S}RSSH.
Ben.
--
Ben Hutchings
Any smoothly functioning technology is indistinguishable from a rigged demo.
[-- Attachment #1.2: modtest.c --]
[-- Type: text/x-csrc, Size: 3174 bytes --]
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
/* Values to be returned by ethtool ops */
static unsigned int rx_rings = 2;
module_param(rx_rings, uint, 0444);
static int indir_size;
module_param(indir_size, int, 0444);
static int key_size;
module_param(key_size, int, 0444);
/* Global state */
static u32 *modtest_indir;
static u8 *modtest_key;
static struct net_device *modtest_netdev;
static int modtest_open(struct net_device *dev)
{
return -EOPNOTSUPP;
}
static struct net_device_ops modtest_netdev_ops = {
.ndo_open = modtest_open,
};
static int modtest_get_rxnfc(struct net_device *netdev,
struct ethtool_rxnfc *rxnfc,
u32 *foo)
{
if (rxnfc->cmd == ETHTOOL_GRXRINGS) {
rxnfc->data = rx_rings;
return 0;
} else {
return -EOPNOTSUPP;
}
}
static u32 modtest_get_rxfh_indir_size(struct net_device *netdev)
{
return indir_size;
}
static u32 modtest_get_rxfh_key_size(struct net_device *netdev)
{
return key_size;
}
static int modtest_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key)
{
WARN_ON(!indir && !key);
if (indir)
memcpy(indir, modtest_indir, indir_size * sizeof(*indir));
if (key)
memcpy(key, modtest_key, key_size);
return 0;
}
static int modtest_set_rxfh(struct net_device *netdev,
const u32 *indir, const u8 *key)
{
WARN_ON(!indir && !key);
if (indir)
memcpy(modtest_indir, indir, indir_size * sizeof(*indir));
if (key)
memcpy(modtest_key, key, key_size);
return 0;
}
static struct ethtool_ops modtest_ethtool_ops = {
.get_rxnfc = modtest_get_rxnfc,
.get_rxfh_indir_size = modtest_get_rxfh_indir_size,
.get_rxfh_key_size = modtest_get_rxfh_key_size,
.get_rxfh = modtest_get_rxfh,
.set_rxfh = modtest_set_rxfh,
};
static int modtest_init(void)
{
int rc;
/* Also allow ethtool ops to be removed */
if (indir_size < 0)
modtest_ethtool_ops.get_rxfh_indir_size = NULL;
if (key_size < 0)
modtest_ethtool_ops.get_rxfh_key_size = NULL;
if (indir_size < 0 && key_size < 0) {
modtest_ethtool_ops.get_rxfh = NULL;
modtest_ethtool_ops.set_rxfh = NULL;
}
modtest_indir = kcalloc(indir_size, sizeof(*modtest_indir), GFP_KERNEL);
if (!modtest_indir)
return -ENOMEM;
modtest_key = kzalloc(key_size, GFP_KERNEL);
if (!modtest_key) {
rc = -ENOMEM;
goto fail_free_indir;
}
modtest_netdev = alloc_etherdev(0);
if (!modtest_netdev) {
rc = -ENOMEM;
goto fail_free_key;
}
modtest_netdev->netdev_ops = &modtest_netdev_ops;
modtest_netdev->ethtool_ops = &modtest_ethtool_ops;
strcpy(modtest_netdev->name, "modtest%d");
rc = register_netdev(modtest_netdev);
if (rc)
goto fail_free_netdev;
return 0;
fail_free_netdev:
free_netdev(modtest_netdev);
fail_free_key:
kfree(modtest_key);
fail_free_indir:
kfree(modtest_indir);
return rc;
}
static void modtest_exit(void)
{
unregister_netdev(modtest_netdev);
free_netdev(modtest_netdev);
kfree(modtest_key);
kfree(modtest_indir);
}
module_init(modtest_init);
module_exit(modtest_exit);
MODULE_LICENSE("GPL");
[-- Attachment #1.3: ethtool-rssh.patch --]
[-- Type: text/x-patch, Size: 37602 bytes --]
diff --git a/ethtool-copy.h b/ethtool-copy.h
index b5515c2..e3c7a71 100644
--- a/ethtool-copy.h
+++ b/ethtool-copy.h
@@ -10,47 +10,107 @@
* Portions Copyright (C) Sun Microsystems 2008
*/
-#ifndef _LINUX_ETHTOOL_H
-#define _LINUX_ETHTOOL_H
+#ifndef _UAPI_LINUX_ETHTOOL_H
+#define _UAPI_LINUX_ETHTOOL_H
#include <linux/types.h>
#include <linux/if_ether.h>
-/* This should work for both 32 and 64 bit userland. */
+/* All structures exposed to userland should be defined such that they
+ * have the same layout for 32-bit and 64-bit userland.
+ */
+
+/**
+ * struct ethtool_cmd - link control and status
+ * @cmd: Command number = %ETHTOOL_GSET or %ETHTOOL_SSET
+ * @supported: Bitmask of %SUPPORTED_* flags for the link modes,
+ * physical connectors and other link features for which the
+ * interface supports autonegotiation or auto-detection.
+ * Read-only.
+ * @advertising: Bitmask of %ADVERTISED_* flags for the link modes,
+ * physical connectors and other link features that are
+ * advertised through autonegotiation or enabled for
+ * auto-detection.
+ * @speed: Low bits of the speed
+ * @duplex: Duplex mode; one of %DUPLEX_*
+ * @port: Physical connector type; one of %PORT_*
+ * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not
+ * applicable. For clause 45 PHYs this is the PRTAD.
+ * @transceiver: Historically used to distinguish different possible
+ * PHY types, but not in a consistent way. Deprecated.
+ * @autoneg: Enable/disable autonegotiation and auto-detection;
+ * either %AUTONEG_DISABLE or %AUTONEG_ENABLE
+ * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO
+ * protocols supported by the interface; 0 if unknown.
+ * Read-only.
+ * @maxtxpkt: Historically used to report TX IRQ coalescing; now
+ * obsoleted by &struct ethtool_coalesce. Read-only; deprecated.
+ * @maxrxpkt: Historically used to report RX IRQ coalescing; now
+ * obsoleted by &struct ethtool_coalesce. Read-only; deprecated.
+ * @speed_hi: High bits of the speed
+ * @eth_tp_mdix: Ethernet twisted-pair MDI(-X) status; one of
+ * %ETH_TP_MDI_*. If the status is unknown or not applicable, the
+ * value will be %ETH_TP_MDI_INVALID. Read-only.
+ * @eth_tp_mdix_ctrl: Ethernet twisted pair MDI(-X) control; one of
+ * %ETH_TP_MDI_*. If MDI(-X) control is not implemented, reads
+ * yield %ETH_TP_MDI_INVALID and writes may be ignored or rejected.
+ * When written successfully, the link should be renegotiated if
+ * necessary.
+ * @lp_advertising: Bitmask of %ADVERTISED_* flags for the link modes
+ * and other link features that the link partner advertised
+ * through autonegotiation; 0 if unknown or not applicable.
+ * Read-only.
+ *
+ * The link speed in Mbps is split between @speed and @speed_hi. Use
+ * the ethtool_cmd_speed() and ethtool_cmd_speed_set() functions to
+ * access it.
+ *
+ * If autonegotiation is disabled, the speed and @duplex represent the
+ * fixed link mode and are writable if the driver supports multiple
+ * link modes. If it is enabled then they are read-only; if the link
+ * is up they represent the negotiated link mode; if the link is down,
+ * the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and
+ * @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode.
+ *
+ * Some hardware interfaces may have multiple PHYs and/or physical
+ * connectors fitted or do not allow the driver to detect which are
+ * fitted. For these interfaces @port and/or @phy_address may be
+ * writable, possibly dependent on @autoneg being %AUTONEG_DISABLE.
+ * Otherwise, attempts to write different values may be ignored or
+ * rejected.
+ *
+ * Users should assume that all fields not marked read-only are
+ * writable and subject to validation by the driver. They should use
+ * %ETHTOOL_GSET to get the current values before making specific
+ * changes and then applying them with %ETHTOOL_SSET.
+ *
+ * Drivers that implement set_settings() should validate all fields
+ * other than @cmd that are not described as read-only or deprecated,
+ * and must ignore all fields described as read-only.
+ *
+ * Deprecated fields should be ignored by both users and drivers.
+ */
struct ethtool_cmd {
__u32 cmd;
- __u32 supported; /* Features this interface supports */
- __u32 advertising; /* Features this interface advertises */
- __u16 speed; /* The forced speed (lower bits) in
- * Mbps. Please use
- * ethtool_cmd_speed()/_set() to
- * access it */
- __u8 duplex; /* Duplex, half or full */
- __u8 port; /* Which connector port */
- __u8 phy_address; /* MDIO PHY address (PRTAD for clause 45).
- * May be read-only or read-write
- * depending on the driver.
- */
- __u8 transceiver; /* Which transceiver to use */
- __u8 autoneg; /* Enable or disable autonegotiation */
- __u8 mdio_support; /* MDIO protocols supported. Read-only.
- * Not set by all drivers.
- */
- __u32 maxtxpkt; /* Tx pkts before generating tx int */
- __u32 maxrxpkt; /* Rx pkts before generating rx int */
- __u16 speed_hi; /* The forced speed (upper
- * bits) in Mbps. Please use
- * ethtool_cmd_speed()/_set() to
- * access it */
- __u8 eth_tp_mdix; /* twisted pair MDI-X status */
- __u8 eth_tp_mdix_ctrl; /* twisted pair MDI-X control, when set,
- * link should be renegotiated if necessary
- */
- __u32 lp_advertising; /* Features the link partner advertises */
+ __u32 supported;
+ __u32 advertising;
+ __u16 speed;
+ __u8 duplex;
+ __u8 port;
+ __u8 phy_address;
+ __u8 transceiver;
+ __u8 autoneg;
+ __u8 mdio_support;
+ __u32 maxtxpkt;
+ __u32 maxrxpkt;
+ __u16 speed_hi;
+ __u8 eth_tp_mdix;
+ __u8 eth_tp_mdix_ctrl;
+ __u32 lp_advertising;
__u32 reserved[2];
};
-static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
+static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
__u32 speed)
{
@@ -58,7 +118,7 @@ static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
ep->speed_hi = (__u16)(speed >> 16);
}
-static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
+static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
{
return (ep->speed_hi << 16) | ep->speed;
}
@@ -79,37 +139,68 @@ static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
#define ETHTOOL_FWVERS_LEN 32
#define ETHTOOL_BUSINFO_LEN 32
-/* these strings are set to whatever the driver author decides... */
+
+/**
+ * struct ethtool_drvinfo - general driver and device information
+ * @cmd: Command number = %ETHTOOL_GDRVINFO
+ * @driver: Driver short name. This should normally match the name
+ * in its bus driver structure (e.g. pci_driver::name). Must
+ * not be an empty string.
+ * @version: Driver version string; may be an empty string
+ * @fw_version: Firmware version string; may be an empty string
+ * @bus_info: Device bus address. This should match the dev_name()
+ * string for the underlying bus device, if there is one. May be
+ * an empty string.
+ * @n_priv_flags: Number of flags valid for %ETHTOOL_GPFLAGS and
+ * %ETHTOOL_SPFLAGS commands; also the number of strings in the
+ * %ETH_SS_PRIV_FLAGS set
+ * @n_stats: Number of u64 statistics returned by the %ETHTOOL_GSTATS
+ * command; also the number of strings in the %ETH_SS_STATS set
+ * @testinfo_len: Number of results returned by the %ETHTOOL_TEST
+ * command; also the number of strings in the %ETH_SS_TEST set
+ * @eedump_len: Size of EEPROM accessible through the %ETHTOOL_GEEPROM
+ * and %ETHTOOL_SEEPROM commands, in bytes
+ * @regdump_len: Size of register dump returned by the %ETHTOOL_GREGS
+ * command, in bytes
+ *
+ * Users can use the %ETHTOOL_GSSET_INFO command to get the number of
+ * strings in any string set (from Linux 2.6.34).
+ *
+ * Drivers should set at most @driver, @version, @fw_version and
+ * @bus_info in their get_drvinfo() implementation. The ethtool
+ * core fills in the other fields using other driver operations.
+ */
struct ethtool_drvinfo {
__u32 cmd;
- char driver[32]; /* driver short name, "tulip", "eepro100" */
- char version[32]; /* driver version string */
- char fw_version[ETHTOOL_FWVERS_LEN]; /* firmware version string */
- char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */
- /* For PCI devices, use pci_name(pci_dev). */
+ char driver[32];
+ char version[32];
+ char fw_version[ETHTOOL_FWVERS_LEN];
+ char bus_info[ETHTOOL_BUSINFO_LEN];
char reserved1[32];
char reserved2[12];
- /*
- * Some struct members below are filled in
- * using ops->get_sset_count(). Obtaining
- * this info from ethtool_drvinfo is now
- * deprecated; Use ETHTOOL_GSSET_INFO
- * instead.
- */
- __u32 n_priv_flags; /* number of flags valid in ETHTOOL_GPFLAGS */
- __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
+ __u32 n_priv_flags;
+ __u32 n_stats;
__u32 testinfo_len;
- __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */
- __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */
+ __u32 eedump_len;
+ __u32 regdump_len;
};
#define SOPASS_MAX 6
-/* wake-on-lan settings */
+
+/**
+ * struct ethtool_wolinfo - Wake-On-Lan configuration
+ * @cmd: Command number = %ETHTOOL_GWOL or %ETHTOOL_SWOL
+ * @supported: Bitmask of %WAKE_* flags for supported Wake-On-Lan modes.
+ * Read-only.
+ * @wolopts: Bitmask of %WAKE_* flags for enabled Wake-On-Lan modes.
+ * @sopass: SecureOn(tm) password; meaningful only if %WAKE_MAGICSECURE
+ * is set in @wolopts.
+ */
struct ethtool_wolinfo {
__u32 cmd;
__u32 supported;
__u32 wolopts;
- __u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */
+ __u8 sopass[SOPASS_MAX];
};
/* for passing single values */
@@ -118,20 +209,51 @@ struct ethtool_value {
__u32 data;
};
-/* for passing big chunks of data */
+/**
+ * struct ethtool_regs - hardware register dump
+ * @cmd: Command number = %ETHTOOL_GREGS
+ * @version: Dump format version. This is driver-specific and may
+ * distinguish different chips/revisions. Drivers must use new
+ * version numbers whenever the dump format changes in an
+ * incompatible way.
+ * @len: On entry, the real length of @data. On return, the number of
+ * bytes used.
+ * @data: Buffer for the register dump
+ *
+ * Users should use %ETHTOOL_GDRVINFO to find the maximum length of
+ * a register dump for the interface. They must allocate the buffer
+ * immediately following this structure.
+ */
struct ethtool_regs {
__u32 cmd;
- __u32 version; /* driver-specific, indicates different chips/revs */
- __u32 len; /* bytes */
+ __u32 version;
+ __u32 len;
__u8 data[0];
};
-/* for passing EEPROM chunks */
+/**
+ * struct ethtool_eeprom - EEPROM dump
+ * @cmd: Command number = %ETHTOOL_GEEPROM, %ETHTOOL_GMODULEEEPROM or
+ * %ETHTOOL_SEEPROM
+ * @magic: A 'magic cookie' value to guard against accidental changes.
+ * The value passed in to %ETHTOOL_SEEPROM must match the value
+ * returned by %ETHTOOL_GEEPROM for the same device. This is
+ * unused when @cmd is %ETHTOOL_GMODULEEEPROM.
+ * @offset: Offset within the EEPROM to begin reading/writing, in bytes
+ * @len: On entry, number of bytes to read/write. On successful
+ * return, number of bytes actually read/written. In case of
+ * error, this may indicate at what point the error occurred.
+ * @data: Buffer to read/write from
+ *
+ * Users may use %ETHTOOL_GDRVINFO or %ETHTOOL_GMODULEINFO to find
+ * the length of an on-board or module EEPROM, respectively. They
+ * must allocate the buffer immediately following this structure.
+ */
struct ethtool_eeprom {
__u32 cmd;
__u32 magic;
- __u32 offset; /* in bytes */
- __u32 len; /* in bytes */
+ __u32 offset;
+ __u32 len;
__u8 data[0];
};
@@ -229,17 +351,18 @@ struct ethtool_modinfo {
* @rate_sample_interval: How often to do adaptive coalescing packet rate
* sampling, measured in seconds. Must not be zero.
*
- * Each pair of (usecs, max_frames) fields specifies this exit
- * condition for interrupt coalescing:
+ * Each pair of (usecs, max_frames) fields specifies that interrupts
+ * should be coalesced until
* (usecs > 0 && time_since_first_completion >= usecs) ||
* (max_frames > 0 && completed_frames >= max_frames)
+ *
* It is illegal to set both usecs and max_frames to zero as this
* would cause interrupts to never be generated. To disable
* coalescing, set usecs = 0 and max_frames = 1.
*
* Some implementations ignore the value of max_frames and use the
- * condition:
- * time_since_first_completion >= usecs
+ * condition time_since_first_completion >= usecs
+ *
* This is deprecated. Drivers for hardware that does not support
* counting completions should validate that max_frames == !rx_usecs.
*
@@ -279,22 +402,37 @@ struct ethtool_coalesce {
__u32 rate_sample_interval;
};
-/* for configuring RX/TX ring parameters */
+/**
+ * struct ethtool_ringparam - RX/TX ring parameters
+ * @cmd: Command number = %ETHTOOL_GRINGPARAM or %ETHTOOL_SRINGPARAM
+ * @rx_max_pending: Maximum supported number of pending entries per
+ * RX ring. Read-only.
+ * @rx_mini_max_pending: Maximum supported number of pending entries
+ * per RX mini ring. Read-only.
+ * @rx_jumbo_max_pending: Maximum supported number of pending entries
+ * per RX jumbo ring. Read-only.
+ * @tx_max_pending: Maximum supported number of pending entries per
+ * TX ring. Read-only.
+ * @rx_pending: Current maximum number of pending entries per RX ring
+ * @rx_mini_pending: Current maximum number of pending entries per RX
+ * mini ring
+ * @rx_jumbo_pending: Current maximum number of pending entries per RX
+ * jumbo ring
+ * @tx_pending: Current maximum supported number of pending entries
+ * per TX ring
+ *
+ * If the interface does not have separate RX mini and/or jumbo rings,
+ * @rx_mini_max_pending and/or @rx_jumbo_max_pending will be 0.
+ *
+ * There may also be driver-dependent minimum values for the number
+ * of entries per ring.
+ */
struct ethtool_ringparam {
- __u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */
-
- /* Read only attributes. These indicate the maximum number
- * of pending RX/TX ring entries the driver will allow the
- * user to set.
- */
+ __u32 cmd;
__u32 rx_max_pending;
__u32 rx_mini_max_pending;
__u32 rx_jumbo_max_pending;
__u32 tx_max_pending;
-
- /* Values changeable by the user. The valid values are
- * in the range 1 to the "*_max_pending" counterpart above.
- */
__u32 rx_pending;
__u32 rx_mini_pending;
__u32 rx_jumbo_pending;
@@ -329,51 +467,96 @@ struct ethtool_channels {
__u32 combined_count;
};
-/* for configuring link flow control parameters */
+/**
+ * struct ethtool_pauseparam - Ethernet pause (flow control) parameters
+ * @cmd: Command number = %ETHTOOL_GPAUSEPARAM or %ETHTOOL_SPAUSEPARAM
+ * @autoneg: Flag to enable autonegotiation of pause frame use
+ * @rx_pause: Flag to enable reception of pause frames
+ * @tx_pause: Flag to enable transmission of pause frames
+ *
+ * Drivers should reject a non-zero setting of @autoneg when
+ * autoneogotiation is disabled (or not supported) for the link.
+ *
+ * If the link is autonegotiated, drivers should use
+ * mii_advertise_flowctrl() or similar code to set the advertised
+ * pause frame capabilities based on the @rx_pause and @tx_pause flags,
+ * even if @autoneg is zero. They should also allow the advertised
+ * pause frame capabilities to be controlled directly through the
+ * advertising field of &struct ethtool_cmd.
+ *
+ * If @autoneg is non-zero, the MAC is configured to send and/or
+ * receive pause frames according to the result of autonegotiation.
+ * Otherwise, it is configured directly based on the @rx_pause and
+ * @tx_pause flags.
+ */
struct ethtool_pauseparam {
- __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */
-
- /* If the link is being auto-negotiated (via ethtool_cmd.autoneg
- * being true) the user may set 'autoneg' here non-zero to have the
- * pause parameters be auto-negotiated too. In such a case, the
- * {rx,tx}_pause values below determine what capabilities are
- * advertised.
- *
- * If 'autoneg' is zero or the link is not being auto-negotiated,
- * then {rx,tx}_pause force the driver to use/not-use pause
- * flow control.
- */
+ __u32 cmd;
__u32 autoneg;
__u32 rx_pause;
__u32 tx_pause;
};
#define ETH_GSTRING_LEN 32
+
+/**
+ * enum ethtool_stringset - string set ID
+ * @ETH_SS_TEST: Self-test result names, for use with %ETHTOOL_TEST
+ * @ETH_SS_STATS: Statistic names, for use with %ETHTOOL_GSTATS
+ * @ETH_SS_PRIV_FLAGS: Driver private flag names, for use with
+ * %ETHTOOL_GPFLAGS and %ETHTOOL_SPFLAGS
+ * @ETH_SS_NTUPLE_FILTERS: Previously used with %ETHTOOL_GRXNTUPLE;
+ * now deprecated
+ * @ETH_SS_FEATURES: Device feature names
+ */
enum ethtool_stringset {
ETH_SS_TEST = 0,
ETH_SS_STATS,
ETH_SS_PRIV_FLAGS,
- ETH_SS_NTUPLE_FILTERS, /* Do not use, GRXNTUPLE is now deprecated */
+ ETH_SS_NTUPLE_FILTERS,
ETH_SS_FEATURES,
};
-/* for passing string sets for data tagging */
+/**
+ * struct ethtool_gstrings - string set for data tagging
+ * @cmd: Command number = %ETHTOOL_GSTRINGS
+ * @string_set: String set ID; one of &enum ethtool_stringset
+ * @len: On return, the number of strings in the string set
+ * @data: Buffer for strings. Each string is null-padded to a size of
+ * %ETH_GSTRING_LEN.
+ *
+ * Users must use %ETHTOOL_GSSET_INFO to find the number of strings in
+ * the string set. They must allocate a buffer of the appropriate
+ * size immediately following this structure.
+ */
struct ethtool_gstrings {
- __u32 cmd; /* ETHTOOL_GSTRINGS */
- __u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/
- __u32 len; /* number of strings in the string set */
+ __u32 cmd;
+ __u32 string_set;
+ __u32 len;
__u8 data[0];
};
+/**
+ * struct ethtool_sset_info - string set information
+ * @cmd: Command number = %ETHTOOL_GSSET_INFO
+ * @sset_mask: On entry, a bitmask of string sets to query, with bits
+ * numbered according to &enum ethtool_stringset. On return, a
+ * bitmask of those string sets queried that are supported.
+ * @data: Buffer for string set sizes. On return, this contains the
+ * size of each string set that was queried and supported, in
+ * order of ID.
+ *
+ * Example: The user passes in @sset_mask = 0x7 (sets 0, 1, 2) and on
+ * return @sset_mask == 0x6 (sets 1, 2). Then @data[0] contains the
+ * size of set 1 and @data[1] contains the size of set 2.
+ *
+ * Users must allocate a buffer of the appropriate size (4 * number of
+ * sets queried) immediately following this structure.
+ */
struct ethtool_sset_info {
- __u32 cmd; /* ETHTOOL_GSSET_INFO */
+ __u32 cmd;
__u32 reserved;
- __u64 sset_mask; /* input: each bit selects an sset to query */
- /* output: each bit a returned sset */
- __u32 data[0]; /* ETH_SS_xxx count, in order, based on bits
- in sset_mask. One bit implies one
- __u32, two bits implies two
- __u32's, etc. */
+ __u64 sset_mask;
+ __u32 data[0];
};
/**
@@ -393,24 +576,58 @@ enum ethtool_test_flags {
ETH_TEST_FL_EXTERNAL_LB_DONE = (1 << 3),
};
-/* for requesting NIC test and getting results*/
+/**
+ * struct ethtool_test - device self-test invocation
+ * @cmd: Command number = %ETHTOOL_TEST
+ * @flags: A bitmask of flags from &enum ethtool_test_flags. Some
+ * flags may be set by the user on entry; others may be set by
+ * the driver on return.
+ * @len: On return, the number of test results
+ * @data: Array of test results
+ *
+ * Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
+ * number of test results that will be returned. They must allocate a
+ * buffer of the appropriate size (8 * number of results) immediately
+ * following this structure.
+ */
struct ethtool_test {
- __u32 cmd; /* ETHTOOL_TEST */
- __u32 flags; /* ETH_TEST_FL_xxx */
+ __u32 cmd;
+ __u32 flags;
__u32 reserved;
- __u32 len; /* result length, in number of u64 elements */
+ __u32 len;
__u64 data[0];
};
-/* for dumping NIC-specific statistics */
+/**
+ * struct ethtool_stats - device-specific statistics
+ * @cmd: Command number = %ETHTOOL_GSTATS
+ * @n_stats: On return, the number of statistics
+ * @data: Array of statistics
+ *
+ * Users must use %ETHTOOL_GSSET_INFO or %ETHTOOL_GDRVINFO to find the
+ * number of statistics that will be returned. They must allocate a
+ * buffer of the appropriate size (8 * number of statistics)
+ * immediately following this structure.
+ */
struct ethtool_stats {
- __u32 cmd; /* ETHTOOL_GSTATS */
- __u32 n_stats; /* number of u64's being returned */
+ __u32 cmd;
+ __u32 n_stats;
__u64 data[0];
};
+/**
+ * struct ethtool_perm_addr - permanent hardware address
+ * @cmd: Command number = %ETHTOOL_GPERMADDR
+ * @size: On entry, the size of the buffer. On return, the size of the
+ * address. The command fails if the buffer is too small.
+ * @data: Buffer for the address
+ *
+ * Users must allocate the buffer immediately following this structure.
+ * A buffer size of %MAX_ADDR_LEN should be sufficient for any address
+ * type.
+ */
struct ethtool_perm_addr {
- __u32 cmd; /* ETHTOOL_GPERMADDR */
+ __u32 cmd;
__u32 size;
__u8 data[0];
};
@@ -593,7 +810,7 @@ struct ethtool_rx_flow_spec {
* %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused
* location, and may remove a rule at a later location (lower
* priority) that matches exactly the same set of flows. The special
- * values are: %RX_CLS_LOC_ANY, selecting any location;
+ * values are %RX_CLS_LOC_ANY, selecting any location;
* %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum
* priority); and %RX_CLS_LOC_LAST, selecting the last suitable
* location (minimum priority). Additional special values may be
@@ -630,6 +847,38 @@ struct ethtool_rxfh_indir {
};
/**
+ * struct ethtool_rxfh - command to get/set RX flow hash indir or/and hash key.
+ * @cmd: Specific command number - %ETHTOOL_GRSSH or %ETHTOOL_SRSSH
+ * @rss_context: RSS context identifier.
+ * @indir_size: On entry, the array size of the user buffer for the
+ * indirection table, which may be zero, or (for %ETHTOOL_SRSSH),
+ * %ETH_RXFH_INDIR_NO_CHANGE. On return from %ETHTOOL_GRSSH,
+ * the array size of the hardware indirection table.
+ * @key_size: On entry, the array size of the user buffer for the hash key,
+ * which may be zero. On return from %ETHTOOL_GRSSH, the size of the
+ * hardware hash key.
+ * @rsvd: Reserved for future extensions.
+ * @rss_config: RX ring/queue index for each hash value i.e., indirection table
+ * of @indir_size __u32 elements, followed by hash key of @key_size
+ * bytes.
+ *
+ * For %ETHTOOL_GRSSH, a @indir_size and key_size of zero means that only the
+ * size should be returned. For %ETHTOOL_SRSSH, an @indir_size of
+ * %ETH_RXFH_INDIR_NO_CHANGE means that indir table setting is not requested
+ * and a @indir_size of zero means the indir table should be reset to default
+ * values.
+ */
+struct ethtool_rxfh {
+ __u32 cmd;
+ __u32 rss_context;
+ __u32 indir_size;
+ __u32 key_size;
+ __u32 rsvd[2];
+ __u32 rss_config[0];
+};
+#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
+
+/**
* 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)
@@ -704,9 +953,6 @@ struct ethtool_flash {
* for %ETHTOOL_GET_DUMP_FLAG command
* @data: data collected for get dump data operation
*/
-
-#define ETH_FW_DUMP_DISABLE 0
-
struct ethtool_dump {
__u32 cmd;
__u32 version;
@@ -715,6 +961,8 @@ struct ethtool_dump {
__u8 data[0];
};
+#define ETH_FW_DUMP_DISABLE 0
+
/* for returning and changing feature sets */
/**
@@ -734,8 +982,9 @@ struct ethtool_get_features_block {
/**
* struct ethtool_gfeatures - command to get state of device's features
* @cmd: command number = %ETHTOOL_GFEATURES
- * @size: in: number of elements in the features[] array;
- * out: number of elements in features[] needed to hold all features
+ * @size: On entry, the number of elements in the features[] array;
+ * on return, the number of elements in features[] needed to hold
+ * all features
* @features: state of features
*/
struct ethtool_gfeatures {
@@ -901,11 +1150,13 @@ enum ethtool_sfeatures_retval_bits {
#define ETHTOOL_GEEE 0x00000044 /* Get EEE settings */
#define ETHTOOL_SEEE 0x00000045 /* Set EEE settings */
+#define ETHTOOL_GRSSH 0x00000046 /* Get RX flow hash configuration */
+#define ETHTOOL_SRSSH 0x00000047 /* Set RX flow hash configuration */
+
/* compatibility with older code */
#define SPARC_ETH_GSET ETHTOOL_GSET
#define SPARC_ETH_SSET ETHTOOL_SSET
-/* 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)
@@ -934,7 +1185,6 @@ enum ethtool_sfeatures_retval_bits {
#define SUPPORTED_40000baseSR4_Full (1 << 25)
#define SUPPORTED_40000baseLR4_Full (1 << 26)
-/* Indicates what features are advertised by the interface. */
#define ADVERTISED_10baseT_Half (1 << 0)
#define ADVERTISED_10baseT_Full (1 << 1)
#define ADVERTISED_100baseT_Half (1 << 2)
@@ -993,15 +1243,13 @@ enum ethtool_sfeatures_retval_bits {
#define PORT_OTHER 0xff
/* Which transceiver to use. */
-#define XCVR_INTERNAL 0x00
-#define XCVR_EXTERNAL 0x01
+#define XCVR_INTERNAL 0x00 /* PHY and MAC are in the same package */
+#define XCVR_EXTERNAL 0x01 /* PHY and MAC are in different packages */
#define XCVR_DUMMY1 0x02
#define XCVR_DUMMY2 0x03
#define XCVR_DUMMY3 0x04
-/* Enable or disable autonegotiation. If this is set to enable,
- * the forced link modes above are completely ignored.
- */
+/* Enable or disable autonegotiation. */
#define AUTONEG_DISABLE 0x00
#define AUTONEG_ENABLE 0x01
@@ -1097,4 +1345,4 @@ enum ethtool_reset_flags {
};
#define ETH_RESET_SHARED_SHIFT 16
-#endif /* _LINUX_ETHTOOL_H */
+#endif /* _UAPI_LINUX_ETHTOOL_H */
diff --git a/ethtool.8.in b/ethtool.8.in
index bb394cc..df5a6ce 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -286,11 +286,12 @@ ethtool \- query or control network driver and hardware settings
.B ethtool \-T|\-\-show\-time\-stamping
.I devname
.HP
-.B ethtool \-x|\-\-show\-rxfh\-indir
+.B ethtool \-x|\-\-show\-rxfh\-indir|\-\-show\-rxfh
.I devname
.HP
-.B ethtool \-X|\-\-set\-rxfh\-indir
+.B ethtool \-X|\-\-set\-rxfh\-indir|\-\-rxfh
.I devname
+.RB [ hkey \ \*(MA:\...]
.RB [\ equal
.IR N \ |
.BI weight\ W0
@@ -784,11 +785,16 @@ Sets the dump flag for the device.
Show the device's time stamping capabilities and associated PTP
hardware clock.
.TP
-.B \-x \-\-show\-rxfh\-indir
-Retrieves the receive flow hash indirection table.
+.B \-x \-\-show\-rxfh\-indir \-\-show\-rxfh
+Retrieves the receive flow hash indirection table and/or RSS hash key.
.TP
-.B \-X \-\-set\-rxfh\-indir
-Configures the receive flow hash indirection table.
+.B \-X \-\-set\-rxfh\-indir \-\-rxfh
+Configures the receive flow hash indirection table and/or RSS hash key.
+.TP
+.BI hkey
+Sets rss hash key of the specified network device. RSS hash key should be of device supported length.
+Hash key format must be in xx:yy:zz:aa:bb:cc format meaning both the nibbles of a byte should be mentioned
+even if a nibble is zero.
.TP
.BI equal\ N
Sets the receive flow hash indirection table to spread flows evenly
diff --git a/ethtool.c b/ethtool.c
index 8e968a8..6b6af6a 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -878,6 +878,73 @@ static char *unparse_rxfhashopts(u64 opts)
return buf;
}
+static int convert_string_to_hashkey(char *rss_hkey, u32 key_size,
+ const char *rss_hkey_string)
+{
+ int i = 0;
+ int hex_byte;
+
+ do {
+ if (i > (key_size - 1)) {
+ fprintf(stderr,
+ "Invalid key: Device supports %d bytes key\n",
+ key_size);
+ goto err;
+ }
+
+ if (!(isxdigit(*rss_hkey_string) &&
+ isxdigit(*(rss_hkey_string + 1)))) {
+ fprintf(stderr, "Invalid RSS Hash Key Format\n");
+ goto err;
+ }
+
+ sscanf(rss_hkey_string, "%2x", &hex_byte);
+ rss_hkey[i++] = hex_byte;
+ rss_hkey_string += 2;
+
+ if (*rss_hkey_string == ':') {
+ rss_hkey_string++;
+ } else if (*rss_hkey_string != '\0') {
+ fprintf(stderr, "Invalid RSS Hash Key Format\n");
+ goto err;
+ }
+
+ } while (*rss_hkey_string);
+
+ if (i != key_size) {
+ fprintf(stderr, "Invalid key: Device supports %d bytes key\n",
+ key_size);
+ goto err;
+ }
+
+ return 0;
+err:
+ exit_bad_args();
+}
+
+static int parse_hkey(char **rss_hkey, u32 key_size,
+ const char *rss_hkey_string)
+{
+ if (!key_size) {
+ fprintf(stderr,
+ "Cannot set RX flow hash configuration:\n"
+ " Hash key setting not supported\n");
+ exit(1);
+ }
+
+ *rss_hkey = malloc(key_size);
+ if (!(*rss_hkey))
+ return -ENOMEM;
+
+ if (convert_string_to_hashkey(*rss_hkey, key_size,
+ rss_hkey_string) < 0) {
+ free(*rss_hkey);
+ *rss_hkey = NULL;
+ return -EINVAL;
+ }
+ return 0;
+}
+
static const struct {
const char *name;
int (*func)(struct ethtool_drvinfo *info, struct ethtool_regs *regs);
@@ -3041,13 +3108,14 @@ static int do_grxclass(struct cmd_context *ctx)
return err ? 1 : 0;
}
-static int do_grxfhindir(struct cmd_context *ctx)
+static int do_grxfh(struct cmd_context *ctx)
{
struct ethtool_rxnfc ring_count;
- struct ethtool_rxfh_indir indir_head;
- struct ethtool_rxfh_indir *indir;
- u32 i;
+ struct ethtool_rxfh rss_head = {};
+ struct ethtool_rxfh *rss;
+ u32 i, indir_bytes;
int err;
+ char *hkey;
ring_count.cmd = ETHTOOL_GRXRINGS;
err = send_ioctl(ctx, &ring_count);
@@ -3056,77 +3124,142 @@ static int do_grxfhindir(struct cmd_context *ctx)
return 102;
}
- indir_head.cmd = ETHTOOL_GRXFHINDIR;
- indir_head.size = 0;
- err = send_ioctl(ctx, &indir_head);
- if (err < 0) {
- perror("Cannot get RX flow hash indirection table size");
+ rss_head.cmd = ETHTOOL_GRSSH;
+ err = send_ioctl(ctx, &rss_head);
+ if ((err < 0) || (!rss_head.indir_size && !rss_head.key_size)) {
+ perror("Cannot get RX flow hash indirection and key size");
return 103;
}
- indir = malloc(sizeof(*indir) +
- indir_head.size * sizeof(*indir->ring_index));
- indir->cmd = ETHTOOL_GRXFHINDIR;
- indir->size = indir_head.size;
- err = send_ioctl(ctx, indir);
+ rss = calloc(1, sizeof(*rss) +
+ rss_head.indir_size * sizeof(rss_head.rss_config[0]) +
+ rss_head.key_size);
+ rss->cmd = ETHTOOL_GRSSH;
+ rss->indir_size = rss_head.indir_size;
+ rss->key_size = rss_head.key_size;
+ err = send_ioctl(ctx, rss);
if (err < 0) {
- perror("Cannot get RX flow hash indirection table");
+ perror("Cannot get RX flow hash configuration");
return 103;
}
printf("RX flow hash indirection table for %s with %llu RX ring(s):\n",
ctx->devname, ring_count.data);
- for (i = 0; i < indir->size; i++) {
+ if (!rss->indir_size)
+ printf("*** Operation Not Supported ***\n");
+
+ for (i = 0; i < rss->indir_size; i++) {
if (i % 8 == 0)
printf("%5u: ", i);
- printf(" %5u", indir->ring_index[i]);
+ printf(" %5u", rss->rss_config[i]);
if (i % 8 == 7)
fputc('\n', stdout);
}
+
+ indir_bytes = rss->indir_size * sizeof(rss->rss_config[0]);
+ hkey = ((char *)rss->rss_config + indir_bytes);
+
+ printf("RSS hash key:\n");
+ if (!rss->key_size)
+ printf("*** Operation Not Supported ***\n");
+
+ for (i = 0; i < rss->key_size; i++) {
+ if (i == (rss->key_size - 1))
+ printf("%02x\n", (u8) hkey[i]);
+ else
+ printf("%02x:", (u8) hkey[i]);
+ }
return 0;
}
-static int do_srxfhindir(struct cmd_context *ctx)
+
+
+
+static int do_srxfh(struct cmd_context *ctx)
{
+ struct ethtool_rxfh rss_head = {};
+ struct ethtool_rxfh *rss;
+ struct ethtool_rxnfc ring_count;
int rxfhindir_equal = 0;
char **rxfhindir_weight = NULL;
- struct ethtool_rxfh_indir indir_head;
- struct ethtool_rxfh_indir *indir;
- u32 i;
+ char *rss_hkey = NULL;
int err;
+ u32 i, arg_num = 0, indir_bytes = 0;
+ u32 entry_size = sizeof(rss_head.rss_config[0]);
+ u8 parse_indir = 1;
if (ctx->argc < 2)
exit_bad_args();
- if (!strcmp(ctx->argp[0], "equal")) {
- if (ctx->argc != 2)
- exit_bad_args();
- rxfhindir_equal = get_int_range(ctx->argp[1], 0, 1, INT_MAX);
- } else if (!strcmp(ctx->argp[0], "weight")) {
- rxfhindir_weight = ctx->argp + 1;
- } else {
- exit_bad_args();
+
+ ring_count.cmd = ETHTOOL_GRXRINGS;
+ err = send_ioctl(ctx, &ring_count);
+ if (err < 0) {
+ perror("Cannot get RX ring count");
+ return 102;
}
- indir_head.cmd = ETHTOOL_GRXFHINDIR;
- indir_head.size = 0;
- err = send_ioctl(ctx, &indir_head);
+ rss_head.cmd = ETHTOOL_GRSSH;
+ err = send_ioctl(ctx, &rss_head);
if (err < 0) {
- perror("Cannot get RX flow hash indirection table size");
- return 104;
+ perror("Cannot get RX flow hash indirection and key size");
+ return 103;
}
- indir = malloc(sizeof(*indir) +
- indir_head.size * sizeof(*indir->ring_index));
- indir->cmd = ETHTOOL_SRXFHINDIR;
- indir->size = indir_head.size;
+ if (!strcmp(ctx->argp[0], "hkey")) {
+ err = parse_hkey(&rss_hkey, rss_head.key_size,
+ ctx->argp[1]);
+ if (err < 0)
+ return err;
+
+ arg_num = 2;
+ if (!ctx->argp[arg_num])
+ parse_indir = 0;
+ }
+ if (parse_indir) {
+ if (!strcmp(ctx->argp[arg_num], "equal"))
+ rxfhindir_equal = get_int_range(ctx->argp[arg_num + 1],
+ 0, 1, INT_MAX);
+ else if (!strcmp(ctx->argp[arg_num], "weight"))
+ rxfhindir_weight = ctx->argp + arg_num + 1;
+ else
+ exit_bad_args();
+
+ indir_bytes = rss_head.indir_size * entry_size;
+ }
+
+ rss = calloc(1, sizeof(*rss) + indir_bytes + rss_head.key_size);
+ rss->cmd = ETHTOOL_SRSSH;
+ rss->indir_size = rss_head.indir_size;
+ rss->key_size = rss_head.key_size;
+
+ /*
+ * indir_size = 0 ==> reset indir to default
+ * indir_size = 0xDEADBEEF ==> ignore indir
+ */
if (rxfhindir_equal) {
- for (i = 0; i < indir->size; i++)
- indir->ring_index[i] = i % rxfhindir_equal;
- } else {
+ for (i = 0; i < rss->indir_size; i++)
+ rss->rss_config[i] = i % rxfhindir_equal;
+ arg_num += 2;
+ if (ctx->argp[arg_num] &&
+ !strcmp(ctx->argp[arg_num], "hkey")) {
+ err = parse_hkey(&rss_hkey, rss_head.key_size,
+ ctx->argp[arg_num + 1]);
+ if (err < 0)
+ return err;
+ }
+ } else if (rxfhindir_weight) {
u32 j, weight, sum = 0, partial = 0;
for (j = 0; rxfhindir_weight[j]; j++) {
+ if (!strcmp(rxfhindir_weight[j], "hkey")) {
+ err = parse_hkey(&rss_hkey,
+ rss_head.key_size,
+ rxfhindir_weight[++j]);
+ if (err < 0)
+ return err;
+ break;
+ }
weight = get_u32(rxfhindir_weight[j], 0);
sum += weight;
}
@@ -3137,7 +3270,7 @@ static int do_srxfhindir(struct cmd_context *ctx)
exit(1);
}
- if (sum > indir->size) {
+ if (sum > rss->indir_size) {
fprintf(stderr,
"Total weight exceeds the size of the "
"indirection table\n");
@@ -3145,22 +3278,31 @@ static int do_srxfhindir(struct cmd_context *ctx)
}
j = -1;
- for (i = 0; i < indir->size; i++) {
- while (i >= indir->size * partial / sum) {
+ for (i = 0; i < rss->indir_size; i++) {
+ while (i >= rss->indir_size * partial / sum) {
j += 1;
weight = get_u32(rxfhindir_weight[j], 0);
partial += weight;
}
- indir->ring_index[i] = j;
+ rss->rss_config[i] = j;
}
+ } else {
+ rss->indir_size = ETH_RXFH_INDIR_NO_CHANGE;
}
- err = send_ioctl(ctx, indir);
+ if (rss_hkey) {
+ memcpy((char *)rss->rss_config + indir_bytes,
+ rss_hkey, rss->key_size);
+ free(rss_hkey);
+ } else {
+ rss->key_size = 0;
+ }
+
+ err = send_ioctl(ctx, rss);
if (err < 0) {
- perror("Cannot set RX flow hash indirection table");
+ perror("Cannot set RX flow hash configuration");
return 105;
}
-
return 0;
}
@@ -3841,11 +3983,12 @@ static const struct option {
" delete %d\n" },
{ "-T|--show-time-stamping", 1, do_tsinfo,
"Show time stamping capabilities" },
- { "-x|--show-rxfh-indir", 1, do_grxfhindir,
- "Show Rx flow hash indirection" },
- { "-X|--set-rxfh-indir", 1, do_srxfhindir,
- "Set Rx flow hash indirection",
- " equal N | weight W0 W1 ...\n" },
+ { "-x|--show-rxfh-indir|--show-rxfh", 1, do_grxfh,
+ "Show Rx flow hash indirection and/or hashkey" },
+ { "-X|--set-rxfh-indir|--rxfh", 1, do_srxfh,
+ "Set Rx flow hash indirection and/or hashkey",
+ " equal N | weight W0 W1 ...\n"
+ " [ hkey %x:%x:%x:%x:%x:.... ]\n" },
{ "-f|--flash", 1, do_flash,
"Flash firmware image from the specified file to a region on the device",
" FILENAME [ REGION-NUMBER-TO-FLASH ]\n" },
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH net-next 7/8] ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh()
2014-06-02 1:03 ` [PATCH net-next 7/8] ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh() Ben Hutchings
@ 2014-06-02 3:09 ` Jeff Kirsher
0 siblings, 0 replies; 16+ messages in thread
From: Jeff Kirsher @ 2014-06-02 3:09 UTC (permalink / raw)
To: Ben Hutchings; +Cc: David Miller, netdev, Venkat Duvvuru
On Sun, Jun 1, 2014 at 6:03 PM, Ben Hutchings <ben@decadent.org.uk> wrote:
> ETHTOOL_{G,S}RXFHINDIR and ETHTOOL_{G,S}RSSH should work for drivers
> regardless of whether they expose the hash key, unless you try to
> set a hash key for a driver that doesn't expose it.
>
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> ---
> drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 15 ++++++++-------
> drivers/net/ethernet/broadcom/tg3.c | 8 ++++----
> drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 ++++----
> drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 15 +++++++++------
> drivers/net/ethernet/intel/igb/igb_ethtool.c | 9 +++++----
> drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 10 +++++-----
> drivers/net/ethernet/sfc/ethtool.c | 10 +++++-----
> include/linux/ethtool.h | 6 ------
> net/core/ethtool.c | 8 ++++----
> 9 files changed, 44 insertions(+), 45 deletions(-)
>
For the Intel driver changes...
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Pull request: Fixes for new ethtool RSS commands
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
` (8 preceding siblings ...)
2014-06-02 1:11 ` Pull request: Fixes for new ethtool RSS commands Ben Hutchings
@ 2014-06-03 0:13 ` David Miller
2014-06-03 0:23 ` David Miller
9 siblings, 1 reply; 16+ messages in thread
From: David Miller @ 2014-06-03 0:13 UTC (permalink / raw)
To: ben; +Cc: netdev
From: Ben Hutchings <ben@decadent.org.uk>
Date: Mon, 02 Jun 2014 01:57:39 +0100
> The following changes since commit eb02a272c97b6e25d8e5fcf1ea93923e6f155595:
>
> driver/net/ethernet/ec_bhf.c: fix sparse warnings (2014-05-14 16:09:33 -0400)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/bwh/net-next.git ethtool-rssh-fixes
>
> for you to fetch changes up to dfe805c14a2018c5a58cfa3921f1897032740501:
>
> ethtool: Check that reserved fields of struct ethtool_rxfh are 0 (2014-05-19 01:30:30 +0100)
>
> This addresses several problems I previously identified with the new
> ETHTOOL_{G,S}RSSH commands:
Pulled into net-next, thanks Ben.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Pull request: Fixes for new ethtool RSS commands
2014-06-03 0:13 ` David Miller
@ 2014-06-03 0:23 ` David Miller
2014-06-03 1:42 ` Ben Hutchings
0 siblings, 1 reply; 16+ messages in thread
From: David Miller @ 2014-06-03 0:23 UTC (permalink / raw)
To: ben; +Cc: netdev
From: David Miller <davem@davemloft.net>
Date: Mon, 02 Jun 2014 17:13:14 -0700 (PDT)
> From: Ben Hutchings <ben@decadent.org.uk>
> Date: Mon, 02 Jun 2014 01:57:39 +0100
>
>> The following changes since commit eb02a272c97b6e25d8e5fcf1ea93923e6f155595:
>>
>> driver/net/ethernet/ec_bhf.c: fix sparse warnings (2014-05-14 16:09:33 -0400)
>>
>> are available in the git repository at:
>>
>> git://git.kernel.org/pub/scm/linux/kernel/git/bwh/net-next.git ethtool-rssh-fixes
>>
>> for you to fetch changes up to dfe805c14a2018c5a58cfa3921f1897032740501:
>>
>> ethtool: Check that reserved fields of struct ethtool_rxfh are 0 (2014-05-19 01:30:30 +0100)
>>
>> This addresses several problems I previously identified with the new
>> ETHTOOL_{G,S}RSSH commands:
>
> Pulled into net-next, thanks Ben.
Actually, it looks like you missed some drivers, please fix this up and
resubmit:
drivers/net/vmxnet3/vmxnet3_ethtool.c:631:2: error: unknown field ‘get_rxfh_indir’ specified in initializer
drivers/net/vmxnet3/vmxnet3_ethtool.c:631:2: warning: initialization from incompatible pointer type [enabled by default]
drivers/net/vmxnet3/vmxnet3_ethtool.c:631:2: warning: (near initialization for ‘vmxnet3_ethtool_ops.get_rxfh’) [enabled by default]
drivers/net/vmxnet3/vmxnet3_ethtool.c:632:2: error: unknown field ‘set_rxfh_indir’ specified in initializer
drivers/net/vmxnet3/vmxnet3_ethtool.c:632:2: warning: initialization from incompatible pointer type [enabled by default]
drivers/net/vmxnet3/vmxnet3_ethtool.c:632:2: warning: (near initialization for ‘vmxnet3_ethtool_ops.set_rxfh’) [enabled by default]
make[3]: *** [drivers/net/vmxnet3/vmxnet3_ethtool.o] Error 1
make[2]: *** [drivers/net/vmxnet3] Error 2
make[2]: *** Waiting for unfinished jobs....
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Pull request: Fixes for new ethtool RSS commands
2014-06-03 0:23 ` David Miller
@ 2014-06-03 1:42 ` Ben Hutchings
0 siblings, 0 replies; 16+ messages in thread
From: Ben Hutchings @ 2014-06-03 1:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 2191 bytes --]
On Mon, 2014-06-02 at 17:23 -0700, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Mon, 02 Jun 2014 17:13:14 -0700 (PDT)
>
> > From: Ben Hutchings <ben@decadent.org.uk>
> > Date: Mon, 02 Jun 2014 01:57:39 +0100
> >
> >> The following changes since commit eb02a272c97b6e25d8e5fcf1ea93923e6f155595:
> >>
> >> driver/net/ethernet/ec_bhf.c: fix sparse warnings (2014-05-14 16:09:33 -0400)
> >>
> >> are available in the git repository at:
> >>
> >> git://git.kernel.org/pub/scm/linux/kernel/git/bwh/net-next.git ethtool-rssh-fixes
> >>
> >> for you to fetch changes up to dfe805c14a2018c5a58cfa3921f1897032740501:
> >>
> >> ethtool: Check that reserved fields of struct ethtool_rxfh are 0 (2014-05-19 01:30:30 +0100)
> >>
> >> This addresses several problems I previously identified with the new
> >> ETHTOOL_{G,S}RSSH commands:
> >
> > Pulled into net-next, thanks Ben.
>
> Actually, it looks like you missed some drivers, please fix this up and
> resubmit:
>
> drivers/net/vmxnet3/vmxnet3_ethtool.c:631:2: error: unknown field ‘get_rxfh_indir’ specified in initializer
> drivers/net/vmxnet3/vmxnet3_ethtool.c:631:2: warning: initialization from incompatible pointer type [enabled by default]
> drivers/net/vmxnet3/vmxnet3_ethtool.c:631:2: warning: (near initialization for ‘vmxnet3_ethtool_ops.get_rxfh’) [enabled by default]
> drivers/net/vmxnet3/vmxnet3_ethtool.c:632:2: error: unknown field ‘set_rxfh_indir’ specified in initializer
> drivers/net/vmxnet3/vmxnet3_ethtool.c:632:2: warning: initialization from incompatible pointer type [enabled by default]
> drivers/net/vmxnet3/vmxnet3_ethtool.c:632:2: warning: (near initialization for ‘vmxnet3_ethtool_ops.set_rxfh’) [enabled by default]
> make[3]: *** [drivers/net/vmxnet3/vmxnet3_ethtool.o] Error 1
> make[2]: *** [drivers/net/vmxnet3] Error 2
> make[2]: *** Waiting for unfinished jobs....
Sorry, I think I must have checked for the old operation names only in
drivers/net/ethernet/. vmxnet3 is the only other driver implementing
them.
Ben.
--
Ben Hutchings
If more than one person is responsible for a bug, no one is at fault.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: Pull request: Fixes for new ethtool RSS commands
2014-06-03 1:49 Ben Hutchings
@ 2014-06-03 6:07 ` David Miller
0 siblings, 0 replies; 16+ messages in thread
From: David Miller @ 2014-06-03 6:07 UTC (permalink / raw)
To: ben; +Cc: netdev, VenkatKumar.Duvvuru
From: Ben Hutchings <ben@decadent.org.uk>
Date: Tue, 03 Jun 2014 02:49:21 +0100
> This addresses several problems I previously identified with the new
> ETHTOOL_{G,S}RSSH commands:
>
> 1. Missing validation of reserved parameters
> 2. Vague documentation
> 3. Use of unnamed magic number
> 4. No consolidation with existing driver operations
>
> I don't currently have access to suitable network hardware, but have
> tested these changes with a dummy driver that can support various
> combinations of operations and sizes, together with (a) Debian's ethtool
> 3.13 (b) ethtool 3.14 with the submitted patch to use ETHTOOL_{G,S}RSSH
> and minor adjustment for fixes 1 and 3.
>
> v2: Update RSS operations in vmxnet3 too
Pulled, will push out once my build test completes ;-)
^ permalink raw reply [flat|nested] 16+ messages in thread
* Pull request: Fixes for new ethtool RSS commands
@ 2014-06-03 1:49 Ben Hutchings
2014-06-03 6:07 ` David Miller
0 siblings, 1 reply; 16+ messages in thread
From: Ben Hutchings @ 2014-06-03 1:49 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Venkat Duvvuru
[-- Attachment #1: Type: text/plain, Size: 2876 bytes --]
The following changes since commit eb02a272c97b6e25d8e5fcf1ea93923e6f155595:
driver/net/ethernet/ec_bhf.c: fix sparse warnings (2014-05-14 16:09:33 -0400)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/bwh/net-next.git ethtool-rssh-fixes
for you to fetch changes up to f062a3844845d267e3716cbc188ad502a15898b7:
ethtool: Check that reserved fields of struct ethtool_rxfh are 0 (2014-06-03 02:43:16 +0100)
This addresses several problems I previously identified with the new
ETHTOOL_{G,S}RSSH commands:
1. Missing validation of reserved parameters
2. Vague documentation
3. Use of unnamed magic number
4. No consolidation with existing driver operations
I don't currently have access to suitable network hardware, but have
tested these changes with a dummy driver that can support various
combinations of operations and sizes, together with (a) Debian's ethtool
3.13 (b) ethtool 3.14 with the submitted patch to use ETHTOOL_{G,S}RSSH
and minor adjustment for fixes 1 and 3.
v2: Update RSS operations in vmxnet3 too
Ben.
----------------------------------------------------------------
Ben Hutchings (8):
ethtool: Return immediately on error in ethtool_copy_validate_indir()
ethtool: Name the 'no change' value for setting RSS hash key but not indir table
ethtool: Improve explanation of the two arrays following struct ethtool_rxfh
ethtool: Expand documentation of ethtool_ops::{get,set}_rxfh()
ethtool: Disallow ETHTOOL_SRSSH with both indir table and hash key unchanged
ethtool, be2net: constify array pointer parameters to ethtool_ops::set_rxfh
ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh()
ethtool: Check that reserved fields of struct ethtool_rxfh are 0
.../net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 15 +--
drivers/net/ethernet/broadcom/tg3.c | 8 +-
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 8 +-
drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
drivers/net/ethernet/emulex/benet/be_cmds.h | 2 +-
drivers/net/ethernet/emulex/benet/be_ethtool.c | 3 +-
drivers/net/ethernet/intel/i40evf/i40evf_ethtool.c | 15 +--
drivers/net/ethernet/intel/igb/igb_ethtool.c | 9 +-
drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 10 +-
drivers/net/ethernet/sfc/ethtool.c | 10 +-
drivers/net/vmxnet3/vmxnet3_ethtool.c | 8 +-
include/linux/ethtool.h | 24 ++---
include/uapi/linux/ethtool.h | 25 ++---
net/core/ethtool.c | 110 +++++++++------------
14 files changed, 120 insertions(+), 129 deletions(-)
--
Ben Hutchings
If more than one person is responsible for a bug, no one is at fault.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2014-06-03 6:07 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-02 0:57 Pull request: Fixes for new ethtool RSS commands Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 1/8] ethtool: Return immediately on error in ethtool_copy_validate_indir() Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 2/8] ethtool: Name the 'no change' value for setting RSS hash key but not indir table Ben Hutchings
2014-06-02 1:01 ` [PATCH net-next 3/8] ethtool: Improve explanation of the two arrays following struct ethtool_rxfh Ben Hutchings
2014-06-02 1:02 ` [PATCH net-next 4/8] ethtool: Expand documentation of ethtool_ops::{get,set}_rxfh() Ben Hutchings
2014-06-02 1:02 ` [PATCH net-next 5/8] ethtool: Disallow ETHTOOL_SRSSH with both indir table and hash key unchanged Ben Hutchings
2014-06-02 1:02 ` [PATCH net-next 6/8] ethtool, be2net: constify array pointer parameters to ethtool_ops::set_rxfh Ben Hutchings
2014-06-02 1:03 ` [PATCH net-next 7/8] ethtool: Replace ethtool_ops::{get,set}_rxfh_indir() with {get,set}_rxfh() Ben Hutchings
2014-06-02 3:09 ` Jeff Kirsher
2014-06-02 1:04 ` [PATCH net-next 8/8] ethtool: Check that reserved fields of struct ethtool_rxfh are 0 Ben Hutchings
2014-06-02 1:11 ` Pull request: Fixes for new ethtool RSS commands Ben Hutchings
2014-06-03 0:13 ` David Miller
2014-06-03 0:23 ` David Miller
2014-06-03 1:42 ` Ben Hutchings
2014-06-03 1:49 Ben Hutchings
2014-06-03 6:07 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.