ethtool: Add support for control of RX flow hash indirection
Subsystems (3)
PATCH 1/2 ethtool: Add support for control of RX flow hash indirection
Many NICs use an indirection table to map an RX flow hash value to one of an arbitrary number of queues (not necessarily a power of 2). It can be useful to remove some queues from this indirection table so that they are only used for flows that are specifically filtered there. It may also be useful to weight the mapping to account for user processes with the same CPU-affinity as the RX interrupts.
--- include/linux/ethtool.h | 15 +++++++++ net/core/ethtool.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 0 deletions(-)
include/linux/ethtool.h +15 -0
@@ -384,6 +384,15 @@ struct ethtool_rxnfc {__u32 rule_locs[0 ]; }; +struct ethtool_rxfh_indir { +__u32 cmd; +/* On entry, this is the array size of the user buffer. On +* return from ETHTOOL_GRXFHINDIR, this is the array size of +* the hardware indirection table. */ +__u32 size; +__u32 ring_index[0 ];/* ring/queue index for each hash value */ +}; +struct ethtool_rx_ntuple_flow_spec {__u32 flow_type;union {
@@ -576,6 +585,10 @@ struct ethtool_ops {int (*set_rx_ntuple)(struct net_device *,struct ethtool_rx_ntuple *);int (*get_rx_ntuple)(struct net_device *,u32 stringset,void *); +int (*get_rxfh_indir)(struct net_device *, +struct ethtool_rxfh_indir *); +int (*set_rxfh_indir)(struct net_device *, + const struct ethtool_rxfh_indir *); };#endif /* __KERNEL__ */
@@ -637,6 +650,8 @@ struct ethtool_ops {#define ETHTOOL_SRXNTUPLE 0x00000035/* Add an n-tuple filter to device */ #define ETHTOOL_GRXNTUPLE 0x00000036/* Get n-tuple filters from device */ #define ETHTOOL_GSSET_INFO 0x00000037/* Get string set info */ +#define ETHTOOL_GRXFHINDIR 0x00000038/* Get RX flow hash indir'n table */ +#define ETHTOOL_SRXFHINDIR 0x00000039/* Set RX flow hash indir'n table */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET
net/core/ethtool.c +80 -0
92 lines not on this page · raw message
Signature · 7 lines
1.6.2.5 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 2/2 sfc: Add support for RX flow hash control
Allow ethtool to query the number of RX rings, the fields used in RX flow hashing and the hash indirection table.
Allow ethtool to update the RX flow hash indirection table.
--- drivers/net/sfc/efx.c | 3 + drivers/net/sfc/ethtool.c | 90 ++++++++++++++++++++++++++++++++++++++++++ drivers/net/sfc/net_driver.h | 2 + drivers/net/sfc/nic.c | 19 ++++----- drivers/net/sfc/nic.h | 1 + 5 files changed, 105 insertions(+), 10 deletions(-)
drivers/net/sfc/efx.c +3 -0
@@ -1121,6 +1121,7 @@ static void efx_set_channels(struct efx_nic *efx)static int efx_probe_nic (struct efx_nic *efx) { +size_t i;int rc;netif_dbg (efx, probe, efx->net_dev,"creating NIC\n" );
@@ -1136,6 +1137,8 @@ static int efx_probe_nic(struct efx_nic *efx)if (efx->n_channels >1 )get_random_bytes (&efx->rx_hash_key,sizeof (efx->rx_hash_key)); +for (i =0 ; i <ARRAY_SIZE (efx->rx_indir_table); i++) + efx->rx_indir_table[i] = i % efx->n_rx_channels;efx_set_channels (efx); efx->net_dev->real_num_tx_queues = efx->n_tx_channels;
drivers/net/sfc/ethtool.c +90 -0
100 lines not on this page · raw message
drivers/net/sfc/net_driver.h +2 -0
@@ -647,6 +647,7 @@ union efx_multicast_hash {* @n_tx_channels: Number of channels used for TX * @rx_buffer_len: RX buffer length * @rx_buffer_order: Order (log2) of number of pages for each RX buffer +* @rx_indir_table: Indirection table for RSS * @int_error_count: Number of internal errors seen recently * @int_error_expire: Time at which error count will be expired * @irq_status: Interrupt status buffer
@@ -734,6 +735,7 @@ struct efx_nic {unsigned int rx_buffer_len;unsigned int rx_buffer_order;u8 rx_hash_key[40 ]; +u32 rx_indir_table[128 ];unsigned int_error_count;unsigned long int_error_expire;
drivers/net/sfc/nic.c +9 -10
@@ -1484,22 +1484,21 @@ static irqreturn_t efx_msi_interrupt(int irq, void *dev_id)/* Setup RSS indirection table. * This maps from the hash value of the packet to RXQ */ -static void efx_setup_rss_indir_table (struct efx_nic *efx) +void efx_nic_push_rx_indir_table (struct efx_nic *efx) { -int i =0 ; -unsigned long offset; +size_t i =0 ;efx_dword_t dword;if (efx_nic_rev (efx) <EFX_REV_FALCON_B0 )return ; -for (offset =FR_BZ_RX_INDIRECTION_TBL ; - offset <FR_BZ_RX_INDIRECTION_TBL +0x800 ; - offset +=0x10 ) { +BUILD_BUG_ON (ARRAY_SIZE (efx->rx_indir_table) != +FR_BZ_RX_INDIRECTION_TBL_ROWS ); + +for (i =0 ; i <FR_BZ_RX_INDIRECTION_TBL_ROWS ; i++) {EFX_POPULATE_DWORD_1 (dword,FRF_BZ_IT_QUEUE , - i % efx->n_rx_channels); -efx_writed (efx, &dword, offset); - i++; + efx->rx_indir_table[i]); +efx_writed_table (efx, &dword,FR_BZ_RX_INDIRECTION_TBL , i); } }
@@ -1634,7 +1633,7 @@ void efx_nic_init_common(struct efx_nic *efx)EFX_INVERT_OWORD (temp);efx_writeo (efx, &temp,FR_AZ_FATAL_INTR_KER ); -efx_setup_rss_indir_table (efx); +efx_nic_push_rx_indir_table (efx);/* Disable the ugly timer-based TX DMA backoff and allow TX DMA to be * controlled by the RX FIFO fill level. Set arbitration to one pkt/Q.
drivers/net/sfc/nic.h +1 -0
@@ -207,6 +207,7 @@ extern void falcon_stop_nic_stats(struct efx_nic *efx);extern void falcon_setup_xaui (struct efx_nic *efx);extern int falcon_reset_xaui (struct efx_nic *efx);extern void efx_nic_init_common (struct efx_nic *efx); +extern void efx_nic_push_rx_indir_table (struct efx_nic *efx);int efx_nic_alloc_buffer (struct efx_nic *efx,struct efx_buffer *buffer,unsigned int len);
Signature · 6 lines
1.6.2.5 -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
David Miller
maintainerFrom: Ben Hutchings <[email protected]>
Date: Wed, 30 Jun 2010 16:05:23 +0100
Quoted 8 lines
Many NICs use an indirection table to map an RX flow hash value to one of an arbitrary number of queues (not necessarily a power of 2). It can be useful to remove some queues from this indirection table so that they are only used for flows that are specifically filtered there. It may also be useful to weight the mapping to account for user processes with the same CPU-affinity as the RX interrupts.
Signed-off-by Ben Hutchings <[email protected]>
Looks good, applied, thanks Ben.
Re: [PATCH net-next-2.6 2/2] sfc: Add support for RX flow hash control
In reply to Ben HutchingsFrom: Ben Hutchings <[email protected]>
Date: Wed, 30 Jun 2010 16:06:28 +0100
Quoted 6 lines
Allow ethtool to query the number of RX rings, the fields used in RX flow hashing and the hash indirection table.
Allow ethtool to update the RX flow hash indirection table.
Signed-off-by Ben Hutchings <[email protected]>
Applied.