allow to dynamically change RSS configuration
v2 cover allow to dynamically change RSS configuration
This set of patches allows to dynamically get and set the RSS configuration of a port:
- rss functions (IPv4/IPv6//UDP/TCP ...)
- rss hash key
Changes included in v2:
- Rename functions "rss_hash_conf_update" to "rss_hash_update"
- In RSS hash update functions of igb and ixgbe PMDs, add tests that do not allow RSS to be dynamically enabled or disabled.
--
Ivan Boule
Ivan Boule (5):
ethdev: check RX queue indices in RETA config against number of queues
ethdev: allow to set RSS hash computation flags and/or key app/testpmd: configure RSS without restart
ethdev: allow to get RSS hash functions and key app/testpmd: allow to configure RSS hash key
app/test-pmd/cmdline.c | 177 +++++++++++++++++++++++++++++++--- app/test-pmd/config.c | 93 ++++++++++++++++++ app/test-pmd/testpmd.h | 3 + lib/librte_ether/rte_ethdev.c | 47 ++++++++- lib/librte_ether/rte_ethdev.h | 47 +++++++++ lib/librte_pmd_e1000/e1000_ethdev.h | 6 ++ lib/librte_pmd_e1000/igb_ethdev.c | 2 + lib/librte_pmd_e1000/igb_rxtx.c | 175 ++++++++++++++++++++++++++-------- lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 2 + lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 6 ++ lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 178 ++++++++++++++++++++++++++++------- 11 files changed, 645 insertions(+), 91 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v2 1/5 ethdev: check RX queue indices in RETA config against number of queues
In reply to a message not in the archiveEach entry of the RSS redirection table (RETA) of igb and ixgbe ports contains a 4-bit RX queue index, thus imposing RSS RX queue indices to be strictly lower than 16.
In addition, if a RETA entry is configured with a RX queue index that is strictly lower than 16, but is greater or equal to the number of RX queues of the port, then all input packets whose RSS hash value indexes that RETA entry are silently dropped by the NIC.
Make the function rte_eth_dev_rss_reta_update() check that RX queue indices that are supplied in the reta_conf argument are strictly lower than ETH_RSS_RETA_MAX_QUEUE (16) and are strictly lower than the number of RX queues of the port.
--- lib/librte_ether/rte_ethdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
lib/librte_ether/rte_ethdev.c +6 -4
@@ -1501,6 +1501,7 @@ int rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf) { struct rte_eth_dev *dev; +uint16_t max_rxq;uint8_t i,j;if (port_id >= nb_ports) {
@@ -1514,10 +1515,13 @@ rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)return (-EINVAL ); } + dev = &rte_eth_devices[port_id]; + max_rxq = (dev->data->nb_rx_queues <=ETH_RSS_RETA_MAX_QUEUE ) ? + dev->data->nb_rx_queues :ETH_RSS_RETA_MAX_QUEUE ;if (reta_conf->mask_lo !=0 ) {for (i =0 ; i <ETH_RSS_RETA_NUM_ENTRIES /2 ; i++) {if ((reta_conf->mask_lo & (1ULL << i)) && - (reta_conf->reta[i] >=ETH_RSS_RETA_MAX_QUEUE )) { + (reta_conf->reta[i] >= max_rxq)) {PMD_DEBUG_TRACE ("RETA hash index output" "configration for port=%d,invalid" "queue=%d\n" ,port_id,reta_conf->reta[i]);
@@ -1533,7 +1537,7 @@ rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf)/* Check if the max entry >= 128 */ if ((reta_conf->mask_hi & (1ULL << i)) && - (reta_conf->reta[j] >=ETH_RSS_RETA_MAX_QUEUE )) { + (reta_conf->reta[j] >= max_rxq)) {PMD_DEBUG_TRACE ("RETA hash index output" "configration for port=%d,invalid" "queue=%d\n" ,port_id,reta_conf->reta[j]);
@@ -1543,8 +1547,6 @@ rte_eth_dev_rss_reta_update(uint8_t port_id, struct rte_eth_rss_reta *reta_conf) } } - dev = &rte_eth_devices[port_id]; -FUNC_PTR_OR_ERR_RET (*dev->dev_ops->reta_update, -ENOTSUP );return (*dev->dev_ops->reta_update)(dev, reta_conf); }
Signature · 1 line
1.7.10.4
PATCH v2 2/5 ethdev: allow to set RSS hash computation flags and/or key
In reply to a message not in the archive1) Add a new function "rss_hash_update" in the PMD API to dynamically update the RSS flags and/or the RSS key used by a NIC to compute the RSS hash of input packets.
The new function uses the existing data structure "rte_eth_rss_conf" for the argument that contains the new hash flags and/or the new hash key to use.
2) Add the ixgbe-specific function "ixgbe_dev_rss_hash_update" and the igb-specific function "eth_igb_rss_hash_update" to update the RSS hash configuration of ixgbe and igb controllers respectively. Before changing anything, these 2 functions check that the update RSS operation does not attempt to disable RSS, if RSS was enabled at port initialization time, or does not attempt to enable RSS, if RSS was disabled at port initialization time.
Note:
Configuring the RSS hash flags and the RSS key used by a NIC consists in updating appropriate PCI registers of the NIC.
These operations have been manually tested with the interactive commands "write reg" and "write regbit" of the testpmd application.
--- lib/librte_ether/rte_ethdev.c | 22 ++++++ lib/librte_ether/rte_ethdev.h | 24 +++++++ lib/librte_pmd_e1000/e1000_ethdev.h | 3 + lib/librte_pmd_e1000/igb_ethdev.c | 1 + lib/librte_pmd_e1000/igb_rxtx.c | 123 +++++++++++++++++++++++----------- lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 1 + lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 3 + lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 125 +++++++++++++++++++++++++---------- 8 files changed, 227 insertions(+), 75 deletions(-)
lib/librte_ether/rte_ethdev.c +22 -0
@@ -1572,6 +1572,28 @@ rte_eth_dev_rss_reta_query(uint8_t port_id, struct rte_eth_rss_reta *reta_conf) }int +rte_eth_dev_rss_hash_update (uint8_t port_id,struct rte_eth_rss_conf *rss_conf) +{ +struct rte_eth_dev *dev; +uint16_t rss_hash_protos; + +if (port_id >= nb_ports) { +PMD_DEBUG_TRACE ("Invalid port_id=%d\n" , port_id); +return (-ENODEV ); + } + rss_hash_protos = rss_conf->rss_hf; +if ((rss_hash_protos !=0 ) && + ((rss_hash_protos Ð_RSS_PROTO_MASK ) ==0 )) { +PMD_DEBUG_TRACE ("Invalid rss_hash_protos=0x%x\n" , + rss_hash_protos); +return (-EINVAL ); + } + dev = &rte_eth_devices[port_id]; +FUNC_PTR_OR_ERR_RET (*dev->dev_ops->rss_hash_update, -ENOTSUP ); +return (*dev->dev_ops->rss_hash_update)(dev, rss_conf); +} + +int rte_eth_led_on (uint8_t port_id) {struct rte_eth_dev *dev;
lib/librte_ether/rte_ethdev.h +24 -0
@@ -331,6 +331,8 @@ struct rte_eth_rss_conf {#define ETH_RSS_IPV4_UDP 0x0040/**< IPv4/UDP packet. */ #define ETH_RSS_IPV6_UDP 0x0080/**< IPv6/UDP packet. */ #define ETH_RSS_IPV6_UDP_EX 0x0100/**< IPv6/UDP with extension headers. */ + +#define ETH_RSS_PROTO_MASK 0x01FF/**< Mask of valid RSS hash protocols */ /* Definitions used for redirection table entry size */ #define ETH_RSS_RETA_NUM_ENTRIES 128#define ETH_RSS_RETA_MAX_QUEUE 16
@@ -966,6 +968,10 @@ typedef int (*reta_query_t)(struct rte_eth_dev *dev, struct rte_eth_rss_reta *reta_conf);/**< @internal Query RSS redirection table on an Ethernet device */ +typedef int (*rss_hash_update_t )(struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf); +/**< @internal Update RSS hash configuration of an Ethernet device */ +typedef int (*eth_dev_led_on_t )(struct rte_eth_dev *dev);/**< @internal Turn on SW controllable LED on an Ethernet device */
@@ -1153,6 +1159,8 @@ struct eth_dev_ops {bypass_wd_reset_t bypass_wd_reset;#endif +/** Configure RSS hash protocols. */ +rss_hash_update_t rss_hash_update; };/**
@@ -2859,6 +2867,22 @@ int rte_eth_dev_bypass_wd_timeout_show(uint8_t port, uint32_t *wd_timeout);*/ int rte_eth_dev_bypass_wd_reset (uint8_t port); +/** +* Configuration of Receive Side Scaling hash computation of Ethernet device. +* +* @param port +* The port identifier of the Ethernet device. +* @param rss_conf +* The new configuration to use for RSS hash computation on the port. +* @return +* - (0) if successful. +* - (-ENODEV) if port identifier is invalid. +* - (-ENOTSUP) if hardware doesn't support. +* - (-EINVAL) if bad parameter. +*/ +int rte_eth_dev_rss_hash_update (uint8_t port_id, +struct rte_eth_rss_conf *rss_conf); + #ifdef __cplusplus }#endif
lib/librte_pmd_e1000/e1000_ethdev.h +3 -0
@@ -138,6 +138,9 @@ uint16_t eth_igb_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts,uint16_t eth_igb_recv_scattered_pkts (void *rxq,struct rte_mbuf **rx_pkts,uint16_t nb_pkts); +int eth_igb_rss_hash_update (struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf); +int eth_igbvf_rx_init (struct rte_eth_dev *dev);void eth_igbvf_tx_init (struct rte_eth_dev *dev);
lib/librte_pmd_e1000/igb_ethdev.c +1 -0
@@ -193,6 +193,7 @@ static struct eth_dev_ops eth_igb_ops = { .mac_addr_remove = eth_igb_rar_clear, .reta_update = eth_igb_rss_reta_update, .reta_query = eth_igb_rss_reta_query, + .rss_hash_update = eth_igb_rss_hash_update, };/*
lib/librte_pmd_e1000/igb_rxtx.c +84 -39
143 lines not on this page · raw message
lib/librte_pmd_ixgbe/ixgbe_ethdev.c +1 -0
@@ -300,6 +300,7 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = { .bypass_ver_show = ixgbe_bypass_ver_show, .bypass_wd_reset = ixgbe_bypass_wd_reset,#endif /* RTE_NIC_BYPASS */ + .rss_hash_update = ixgbe_dev_rss_hash_update, };/*
lib/librte_pmd_ixgbe/ixgbe_ethdev.h +3 -0
@@ -235,6 +235,9 @@ uint16_t ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,uint16_t ixgbe_xmit_pkts_simple (void *tx_queue,struct rte_mbuf **tx_pkts,uint16_t nb_pkts); +int ixgbe_dev_rss_hash_update (struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf); +/* * Flow director function prototypes */
lib/librte_pmd_ixgbe/ixgbe_rxtx.c +89 -36
144 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 3/5 app/testpmd: configure RSS without restart
In reply to a message not in the archiveThe function cmd_config_rss_parsed() associated with the command "port config rss all" required to first stop all ports, in order to then entirely re-configure all ports with the new RSS hash computation parameters.
Use now the new function rte_eth_dev_rss_hash_conf_update() that dynamically only changes the RSS hash computation parameters of a port, without needing to previously stop the port.
--- app/test-pmd/cmdline.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
app/test-pmd/cmdline.c +8 -12
@@ -1145,26 +1145,22 @@ cmd_config_rss_parsed(void *parsed_result, __attribute__((unused)) void *data) {struct cmd_config_rss *res = parsed_result; - -if (!all_ports_stopped ()) { -printf ("Please stop all ports first\n" ); -return ; - } +struct rte_eth_rss_conf rss_conf; +uint8_t i;if (!strcmp (res->value,"ip" )) - rss_hf =ETH_RSS_IPV4 |ETH_RSS_IPV6 ; + rss_conf.rss_hf =ETH_RSS_IPV4 |ETH_RSS_IPV6 ;else if (!strcmp (res->value,"udp" )) - rss_hf =ETH_RSS_IPV4 |ETH_RSS_IPV6 |ETH_RSS_IPV4_UDP ; + rss_conf.rss_hf =ETH_RSS_IPV4_UDP |ETH_RSS_IPV6_UDP ;else if (!strcmp (res->value,"none" )) - rss_hf =0 ; + rss_conf.rss_hf =0 ;else {printf ("Unknown parameter\n" );return ; } - -init_port_config (); - -cmd_reconfig_device_queue (RTE_PORT_ALL ,1 ,1 ); + rss_conf.rss_key =NULL ; +for (i =0 ; i <rte_eth_dev_count (); i++) +rte_eth_dev_rss_hash_update (i, &rss_conf); } cmdline_parse_token_string_t cmd_config_rss_port =
Signature · 1 line
1.7.10.4
PATCH v2 4/5 ethdev: allow to get RSS hash functions and key
In reply to a message not in the archive1) Add a new function "rss_hash_conf_get" in the PMD API to retrieve the current configuration of the RSS functions and/or of the RSS key used by a NIC to compute the RSS hash of input packets.
The new function uses the existing data structure "rte_eth_rss_conf" for returning the RSS hash configuration.
2) Add the ixgbe-specific function "ixgbe_dev_rss_hash_conf_get" and the igb-specific function "eth_igb_rss_hash_conf_get" to retrieve the RSS hash configuration of ixgbe and igb controllers respectively.
3) Add the command "show port X rss-hash [key]" in the testpmd application to display the RSS hash configuration of port X.
--- app/test-pmd/cmdline.c | 63 +++++++++++++++++++++++++++++++++ app/test-pmd/config.c | 65 +++++++++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 2 ++ lib/librte_ether/rte_ethdev.c | 15 ++++++++ lib/librte_ether/rte_ethdev.h | 23 +++++++++++++ lib/librte_pmd_e1000/e1000_ethdev.h | 3 ++ lib/librte_pmd_e1000/igb_ethdev.c | 1 + lib/librte_pmd_e1000/igb_rxtx.c | 52 ++++++++++++++++++++++++++++ lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 3 +- lib/librte_pmd_ixgbe/ixgbe_ethdev.h | 3 ++ lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 53 ++++++++++++++++++++++++++++ 11 files changed, 282 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +63 -0
@@ -182,6 +182,10 @@ static void cmd_help_long_parsed(void *parsed_result,"show port (info|stats|fdir|stat_qmap) (port_id|all)\n" " Display information for port_id, or all.\n\n" +"show port rss-hash [key]\n" +" Display the RSS hash functions and RSS hash key" +" of port X\n\n" +"clear port (info|stats|fdir|stat_qmap) (port_id|all)\n" " Clear information for port_id, or all.\n\n"
@@ -1364,6 +1368,63 @@ cmdline_parse_inst_t cmd_showport_reta = { }, }; +/* *** Show RSS hash configuration *** */ +struct cmd_showport_rss_hash { +cmdline_fixed_string_t show; +cmdline_fixed_string_t port; +uint8_t port_id; +cmdline_fixed_string_t rss_hash; +cmdline_fixed_string_t key;/* optional argument */ +}; + +static void cmd_showport_rss_hash_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, +void *show_rss_key) +{ +struct cmd_showport_rss_hash *res = parsed_result; + +port_rss_hash_conf_show (res->port_id, show_rss_key !=NULL ); +} + +cmdline_parse_token_string_t cmd_showport_rss_hash_show = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, show, "show"); +cmdline_parse_token_string_t cmd_showport_rss_hash_port = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, port, "port"); +cmdline_parse_token_num_t cmd_showport_rss_hash_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_showport_rss_hash, port_id, UINT8); +cmdline_parse_token_string_t cmd_showport_rss_hash_rss_hash = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, rss_hash, +"rss-hash" ); +cmdline_parse_token_string_t cmd_showport_rss_hash_rss_key = + TOKEN_STRING_INITIALIZER(struct cmd_showport_rss_hash, key, "key"); + +cmdline_parse_inst_t cmd_showport_rss_hash = { + .f = cmd_showport_rss_hash_parsed, + .data =NULL , + .help_str ="show port X rss-hash (X = port number)\n" , + .tokens = { + (void *)&cmd_showport_rss_hash_show, + (void *)&cmd_showport_rss_hash_port, + (void *)&cmd_showport_rss_hash_port_id, + (void *)&cmd_showport_rss_hash_rss_hash, +NULL , + }, +}; + +cmdline_parse_inst_t cmd_showport_rss_hash_key = { + .f = cmd_showport_rss_hash_parsed, + .data ="show_rss_key" , + .help_str ="show port X rss-hash key (X = port number)\n" , + .tokens = { + (void *)&cmd_showport_rss_hash_show, + (void *)&cmd_showport_rss_hash_port, + (void *)&cmd_showport_rss_hash_port_id, + (void *)&cmd_showport_rss_hash_rss_hash, + (void *)&cmd_showport_rss_hash_rss_key, +NULL , + }, +}; +/* *** Configure DCB *** */ struct cmd_config_dcb {cmdline_fixed_string_t port;
@@ -5259,6 +5320,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mirror_mask, (cmdline_parse_inst_t *)&cmd_set_mirror_link, (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, + (cmdline_parse_inst_t *)&cmd_showport_rss_hash, + (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, NULL,
app/test-pmd/config.c +65 -0
71 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -523,6 +523,8 @@ void set_vf_traffic(portid_t port_id, uint8_t is_rx, uint16_t vf, uint8_t on);void set_vf_rx_vlan (portid_t port_id,uint16_t vlan_id,uint64_t vf_mask,uint8_t on); +void port_rss_hash_conf_show (portid_t port_id,int show_rss_key); +/* * Work-around of a compilation error with ICC on invocations of the * rte_be_to_cpu_16() function.
lib/librte_ether/rte_ethdev.c +15 -0
@@ -1594,6 +1594,21 @@ rte_eth_dev_rss_hash_update(uint8_t port_id, struct rte_eth_rss_conf *rss_conf) }int +rte_eth_dev_rss_hash_conf_get (uint8_t port_id, +struct rte_eth_rss_conf *rss_conf) +{ +struct rte_eth_dev *dev; + +if (port_id >= nb_ports) { +PMD_DEBUG_TRACE ("Invalid port_id=%d\n" , port_id); +return (-ENODEV ); + } + dev = &rte_eth_devices[port_id]; +FUNC_PTR_OR_ERR_RET (*dev->dev_ops->rss_hash_conf_get, -ENOTSUP ); +return (*dev->dev_ops->rss_hash_conf_get)(dev, rss_conf); +} + +int rte_eth_led_on (uint8_t port_id) {struct rte_eth_dev *dev;
lib/librte_ether/rte_ethdev.h +23 -0
@@ -972,6 +972,10 @@ typedef int (*rss_hash_update_t)(struct rte_eth_dev *dev, struct rte_eth_rss_conf *rss_conf);/**< @internal Update RSS hash configuration of an Ethernet device */ +typedef int (*rss_hash_conf_get_t )(struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf); +/**< @internal Get current RSS hash configuration of an Ethernet device */ +typedef int (*eth_dev_led_on_t )(struct rte_eth_dev *dev);/**< @internal Turn on SW controllable LED on an Ethernet device */
@@ -1161,6 +1165,8 @@ struct eth_dev_ops {/** Configure RSS hash protocols. */ rss_hash_update_t rss_hash_update; +/** Get current RSS hash configuration. */ +rss_hash_conf_get_t rss_hash_conf_get; };/**
@@ -2883,6 +2889,23 @@ int rte_eth_dev_bypass_wd_reset(uint8_t port);int rte_eth_dev_rss_hash_update (uint8_t port_id,struct rte_eth_rss_conf *rss_conf); +/** +* Retrieve current configuration of Receive Side Scaling hash computation +* of Ethernet device. +* +* @param port +* The port identifier of the Ethernet device. +* @param rss_conf +* Where to store the current RSS hash configuration of the Ethernet device. +* @return +* - (0) if successful. +* - (-ENODEV) if port identifier is invalid. +* - (-ENOTSUP) if hardware doesn't support RSS. +*/ +int +rte_eth_dev_rss_hash_conf_get (uint8_t port_id, +struct rte_eth_rss_conf *rss_conf); + #ifdef __cplusplus }#endif
lib/librte_pmd_e1000/e1000_ethdev.h +3 -0
@@ -141,6 +141,9 @@ uint16_t eth_igb_recv_scattered_pkts(void *rxq,int eth_igb_rss_hash_update (struct rte_eth_dev *dev,struct rte_eth_rss_conf *rss_conf); +int eth_igb_rss_hash_conf_get (struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf); +int eth_igbvf_rx_init (struct rte_eth_dev *dev);void eth_igbvf_tx_init (struct rte_eth_dev *dev);
lib/librte_pmd_e1000/igb_ethdev.c +1 -0
@@ -194,6 +194,7 @@ static struct eth_dev_ops eth_igb_ops = { .reta_update = eth_igb_rss_reta_update, .reta_query = eth_igb_rss_reta_query, .rss_hash_update = eth_igb_rss_hash_update, + .rss_hash_conf_get = eth_igb_rss_hash_conf_get, };/*
lib/librte_pmd_e1000/igb_rxtx.c +52 -0
58 lines not on this page · raw message
lib/librte_pmd_ixgbe/ixgbe_ethdev.c +2 -1
@@ -300,7 +300,8 @@ static struct eth_dev_ops ixgbe_eth_dev_ops = { .bypass_ver_show = ixgbe_bypass_ver_show, .bypass_wd_reset = ixgbe_bypass_wd_reset,#endif /* RTE_NIC_BYPASS */ - .rss_hash_update = ixgbe_dev_rss_hash_update, + .rss_hash_update = ixgbe_dev_rss_hash_update, + .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get, };/*
lib/librte_pmd_ixgbe/ixgbe_ethdev.h +3 -0
@@ -238,6 +238,9 @@ uint16_t ixgbe_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts,int ixgbe_dev_rss_hash_update (struct rte_eth_dev *dev,struct rte_eth_rss_conf *rss_conf); +int ixgbe_dev_rss_hash_conf_get (struct rte_eth_dev *dev, +struct rte_eth_rss_conf *rss_conf); +/* * Flow director function prototypes */
lib/librte_pmd_ixgbe/ixgbe_rxtx.c +53 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 5/5 app/testpmd: allow to configure RSS hash key
In reply to a message not in the archiveAdd the command "port config X rss-hash-key key" in the 'testpmd' application to configure the RSS hash key used to compute the RSS hash of input [IP] packets received on port X.
--- app/test-pmd/cmdline.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++- app/test-pmd/config.c | 28 ++++++++++++++ app/test-pmd/testpmd.h | 1 + 3 files changed, 124 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +95 -1
@@ -1192,6 +1192,99 @@ cmdline_parse_inst_t cmd_config_rss = { }, }; +/* *** configure rss hash key *** */ +struct cmd_config_rss_hash_key { +cmdline_fixed_string_t port; +cmdline_fixed_string_t config; +uint8_t port_id; +cmdline_fixed_string_t rss_hash_key; +cmdline_fixed_string_t key; +}; + +#define RSS_HASH_KEY_LENGTH 40 +static uint8_t +hexa_digit_to_value (char hexa_digit) +{ +if ((hexa_digit >='0' ) && (hexa_digit <='9' )) +return (uint8_t ) (hexa_digit -'0' ); +if ((hexa_digit >='a' ) && (hexa_digit <='f' )) +return (uint8_t ) ((hexa_digit -'a' ) +10 ); +if ((hexa_digit >='A' ) && (hexa_digit <='F' )) +return (uint8_t ) ((hexa_digit -'A' ) +10 ); +/* Invalid hexa digit */ +return 0xFF ; +} + +static uint8_t +parse_and_check_key_hexa_digit (char *key,int idx) +{ +uint8_t hexa_v; + + hexa_v =hexa_digit_to_value (key[idx]); +if (hexa_v ==0xFF ) +printf ("invalid key: character %c at position %d is not a " +"valid hexa digit\n" , key[idx], idx); +return hexa_v; +} + +static void +cmd_config_rss_hash_key_parsed (void *parsed_result, + __attribute__((unused))struct cmdline *cl, + __attribute__((unused))void *data) +{ +struct cmd_config_rss_hash_key *res = parsed_result; +uint8_t hash_key[RSS_HASH_KEY_LENGTH ]; +uint8_t xdgt0; +uint8_t xdgt1; +int i; + +/* Check the length of the RSS hash key */ +if (strlen (res->key) != (RSS_HASH_KEY_LENGTH *2 )) { +printf ("key length: %d invalid - key must be a string of %d" +"hexa-decimal numbers\n" , (int )strlen (res->key), +RSS_HASH_KEY_LENGTH *2 ); +return ; + } +/* Translate RSS hash key into binary representation */ +for (i =0 ; i <RSS_HASH_KEY_LENGTH ; i++) { + xdgt0 =parse_and_check_key_hexa_digit (res->key, (i *2 )); +if (xdgt0 ==0xFF ) +return ; + xdgt1 =parse_and_check_key_hexa_digit (res->key, (i *2 ) +1 ); +if (xdgt1 ==0xFF ) +return ; + hash_key[i]= (uint8_t ) ((xdgt0 *16 ) + xdgt1); + } +port_rss_hash_key_update (res->port_id, hash_key); +} + +cmdline_parse_token_string_t cmd_config_rss_hash_key_port = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, port, "port"); +cmdline_parse_token_string_t cmd_config_rss_hash_key_config = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, config, +"config" ); +cmdline_parse_token_string_t cmd_config_rss_hash_key_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_config_rss_hash_key, port_id, UINT8); +cmdline_parse_token_string_t cmd_config_rss_hash_key_rss_hash_key = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, + rss_hash_key,"rss-hash-key" ); +cmdline_parse_token_string_t cmd_config_rss_hash_key_value = + TOKEN_STRING_INITIALIZER(struct cmd_config_rss_hash_key, key, NULL); + +cmdline_parse_inst_t cmd_config_rss_hash_key = { + .f = cmd_config_rss_hash_key_parsed, + .data =NULL , + .help_str ="port config X rss-hash-key 80 hexa digits" , + .tokens = { + (void *)&cmd_config_rss_hash_key_port, + (void *)&cmd_config_rss_hash_key_config, + (void *)&cmd_config_rss_hash_key_port_id, + (void *)&cmd_config_rss_hash_key_rss_hash_key, + (void *)&cmd_config_rss_hash_key_value, +NULL , + }, +}; +/* *** Configure RSS RETA *** */ struct cmd_config_rss_reta {cmdline_fixed_string_t port;
@@ -1413,7 +1506,7 @@ cmdline_parse_inst_t cmd_showport_rss_hash = {cmdline_parse_inst_t cmd_showport_rss_hash_key = { .f = cmd_showport_rss_hash_parsed, - .data ="show_rss_key" , + .data = (void *)1 , .help_str ="show port X rss-hash key (X = port number)\n" , .tokens = { (void *)&cmd_showport_rss_hash_show,
@@ -5322,6 +5415,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_reset_mirror_rule, (cmdline_parse_inst_t *)&cmd_showport_rss_hash, (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, + (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, NULL,
app/test-pmd/config.c +28 -0
@@ -746,6 +746,34 @@ port_rss_hash_conf_show(portid_t port_id, int show_rss_key)printf ("\n" ); } +void +port_rss_hash_key_update (portid_t port_id,uint8_t *hash_key) +{ +struct rte_eth_rss_conf rss_conf; +int diag; + + rss_conf.rss_key =NULL ; + diag =rte_eth_dev_rss_hash_conf_get (port_id, &rss_conf); +if (diag ==0 ) { + rss_conf.rss_key = hash_key; + diag =rte_eth_dev_rss_hash_update (port_id, &rss_conf); + } +if (diag ==0 ) +return ; + +switch (diag) { +case -ENODEV : +printf ("port index %d invalid\n" , port_id); +break ; +case -ENOTSUP : +printf ("operation not supported by device\n" ); +break ; +default : +printf ("operation failed - diag=%d\n" , diag); +break ; + } +} +/* * Setup forwarding configuration for each logical core. */
app/test-pmd/testpmd.h +1 -0
@@ -524,6 +524,7 @@ void set_vf_rx_vlan(portid_t port_id, uint16_t vlan_id, uint64_t vf_mask, uint8_t on);void port_rss_hash_conf_show (portid_t port_id,int show_rss_key); +void port_rss_hash_key_update (portid_t port_id,uint8_t *hash_key);/* * Work-around of a compilation error with ICC on invocations of the
Signature · 1 line
1.7.10.4
Thomas Monjalon
Acked-by2014-05-16 10:58, Ivan Boule:
Quoted 13 lines
This set of patches allows to dynamically get and set the RSS configuration of a port:
- rss functions (IPv4/IPv6//UDP/TCP ...)
- rss hash keyChanges included in v2:
- Rename functions "rss_hash_conf_update" to "rss_hash_update"
- In RSS hash update functions of igb and ixgbe PMDs, add tests that do not allow RSS to be dynamically enabled or disabled.--
Ivan Boule
Quoted 6 lines
Ivan Boule (5):
ethdev: check RX queue indices in RETA config against number of queues
ethdev: allow to set RSS hash computation flags and/or key app/testpmd: configure RSS without restart
ethdev: allow to get RSS hash functions and key app/testpmd: allow to configure RSS hash key
Applied for version 1.7.0.
Thanks
Signature · 1 line
Thomas