From 81b0fbb85b3a69912f3fa9be8ed73538ac9df68b Mon Sep 17 00:00:00 2001 From: Alvin Zhang Date: Wed, 15 Sep 2021 13:47:04 +0800 Subject: [PATCH] ethdev: add IPv4 and L4 checksum RSS offload types This patch defines new RSS offload types for IPv4 and L4(TCP/UDP/SCTP) checksum, which are required when users want to distribute packets based on the IPv4 or L4 checksum field. For example "flow create 0 ingress pattern eth / ipv4 / end actions rss types ipv4-chksum end queues end / end", this flow causes all matching packets to be distributed to queues on basis of IPv4 checksum. Signed-off-by: Alvin Zhang Reviewed-by: Qi Zhang Acked-by: Ajit Khaparde Acked-by: Aman Deep Singh Acked-by: Ferruh Yigit --- app/test-pmd/cmdline.c | 4 +++- app/test-pmd/config.c | 2 ++ doc/guides/rel_notes/release_21_11.rst | 5 +++++ lib/ethdev/rte_ethdev.h | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 7dd3965d6f..a9efd027c3 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -2252,6 +2252,8 @@ cmd_config_rss_parsed(void *parsed_result, rss_conf.rss_hf = ETH_RSS_ECPRI; else if (!strcmp(res->value, "mpls")) rss_conf.rss_hf = ETH_RSS_MPLS; + else if (!strcmp(res->value, "ipv4-chksum")) + rss_conf.rss_hf = ETH_RSS_IPV4_CHKSUM; else if (!strcmp(res->value, "none")) rss_conf.rss_hf = 0; else if (!strcmp(res->value, "level-default")) { @@ -2323,7 +2325,7 @@ cmdline_parse_inst_t cmd_config_rss = { .help_str = "port config all rss " "all|default|eth|vlan|ip|tcp|udp|sctp|ether|port|vxlan|geneve|" "nvgre|vxlan-gpe|l2tpv3|esp|ah|pfcp|ecpri|mpls|none|level-default|" - "level-outer|level-inner|", + "level-outer|level-inner|ipv4-chksum|", .tokens = { (void *)&cmd_config_rss_port, (void *)&cmd_config_rss_keyword, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index f5765b34f7..9c66329e96 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -140,6 +140,8 @@ const struct rss_type_info rss_type_table[] = { { "gtpu", ETH_RSS_GTPU }, { "ecpri", ETH_RSS_ECPRI }, { "mpls", ETH_RSS_MPLS }, + { "ipv4-chksum", ETH_RSS_IPV4_CHKSUM }, + { "l4-chksum", ETH_RSS_L4_CHKSUM }, { NULL, 0 }, }; diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index f85dc99c8b..568577ca8e 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -62,6 +62,11 @@ New Features * Added bus-level parsing of the devargs syntax. * Kept compatibility with the legacy syntax as parsing fallback. +* **Added new RSS offload types for IPv4/L4 checksum in RSS flow.** + + Added macros ETH_RSS_IPV4_CHKSUM and ETH_RSS_L4_CHKSUM, now IPv4 and + TCP/UDP/SCTP header checksum field can be used as input set for RSS. + * **Updated Marvell cnxk ethdev driver.** * Added rte_flow support for dual VLAN insert and strip actions. diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index bef24173cf..3c8af317d1 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -537,6 +537,21 @@ struct rte_eth_rss_conf { #define ETH_RSS_PPPOE (1ULL << 31) #define ETH_RSS_ECPRI (1ULL << 32) #define ETH_RSS_MPLS (1ULL << 33) +#define ETH_RSS_IPV4_CHKSUM (1ULL << 34) + +/** + * The ETH_RSS_L4_CHKSUM works on checksum field of any L4 header. + * It is similar to ETH_RSS_PORT that they don't specify the specific type of + * L4 header. This macro is defined to replace some specific L4 (TCP/UDP/SCTP) + * checksum type for constructing the use of RSS offload bits. + * + * Due to above reason, some old APIs (and configuration) don't support + * ETH_RSS_L4_CHKSUM. The rte_flow RSS API supports it. + * + * For the case that checksum is not used in an UDP header, + * it takes the reserved value 0 as input for the hash function. + */ +#define ETH_RSS_L4_CHKSUM (1ULL << 35) /* * We use the following macros to combine with above ETH_RSS_* for -- 2.20.1