From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5CF5CA0C58; Thu, 4 Nov 2021 17:19:44 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3237441223; Thu, 4 Nov 2021 17:19:44 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 3AEFF411C9 for ; Thu, 4 Nov 2021 17:19:42 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10157"; a="218638964" X-IronPort-AV: E=Sophos;i="5.87,209,1631602800"; d="scan'208";a="218638964" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Nov 2021 09:19:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,209,1631602800"; d="scan'208";a="600301745" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga004.jf.intel.com with ESMTP; 04 Nov 2021 09:19:40 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 4 Nov 2021 09:19:38 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Thu, 4 Nov 2021 09:19:38 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.101) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 4 Nov 2021 09:19:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cJjbu6CvqM28J9iMxA6aEdJTlTVjB03XrywKbLZPRptv2Kek8NV6DTZ/h8TQvjNB5AABFN0NK3uiQCyK38sUnOocepUtX7Xi7uG/amxQwrpNUAi/JifTXYzHjxm0bd92OUCfF8DIyEKkY3GoLKlnLHFtJRc7/2LGWQC9oh3MTlGueMaSjye+CCqc/SWUdJjLGrPd3YEUgm++KE35GdSkAhYQWkGYlo7tVwFyz0E3JAyparvDj2n5i4oq0DNXIsVCurX4A9w6wNnBtEQvLvdI63MI68IbRxVRAhT9IL2MUF/1WfPnkDsJHqD1IOZlJK9p1HWIJebHUe7N2A+KbTYZqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=W2VWLsKV/KDmETEkdv1eoJLEzL2WTiJt2jOZiSHSOrE=; b=YSLG1bUSRelftxT1supV/jqfFu4MxkxJXNM8DQMZh2svG4X3l4bJFpQHxBiQBYTVYtX8NEbeb4mzT4LsEK05I5OVEcVbUYCGuEO01R6Jk7EjqJAcy+1dTNkZNeGS5N37gUcBYGCEx2Ln4htUaNfuv3dAXkJ+s6xpevwJgFeJG2HVu0YL5x8+tsg2o+eO9vCWZQ0uq0rEorF7eZWW3BpHNm4RaMaQIcbedoh1dBDY45NrDwmgOk52smZSOONpfUED92Cn0htmCBuqS0j+I82x70s0j9Hl5mYPFINTt/Bi4YrBG/jyYNybdrQG2xpvztROnRO2KCQa5FYsBgiFuoSAKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W2VWLsKV/KDmETEkdv1eoJLEzL2WTiJt2jOZiSHSOrE=; b=tprJt6/kVphF4P75vWHt/wIWCQEy/iF8tpBVzv7pjZDO6jlA0ixCdasWuObRtfFPh2cpEP0kuqu2ykpX/mCs9wSSx07A/6m4BpBPMFN9fXfUV2D4DphdAaygtz9Y7wYBuXzbWzasVTyBaT6N5X7rNiIhvKM2Y4acutjVO0u+Lr8= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB5012.namprd11.prod.outlook.com (2603:10b6:303:90::18) by MWHPR11MB0016.namprd11.prod.outlook.com (2603:10b6:301:63::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.17; Thu, 4 Nov 2021 16:19:35 +0000 Received: from CO1PR11MB5012.namprd11.prod.outlook.com ([fe80::442b:2192:c62b:c6c3]) by CO1PR11MB5012.namprd11.prod.outlook.com ([fe80::442b:2192:c62b:c6c3%8]) with mapi id 15.20.4669.012; Thu, 4 Nov 2021 16:19:35 +0000 To: "Walsh, Conor" , Usama Nadeem , "thomas@monjalon.net" CC: "dev@dpdk.org" References: <20211008155111.125786-1-usama.nadeem@emumba.com> <20211014184322.5148-1-usama.nadeem@emumba.com> From: "Medvedkin, Vladimir" Message-ID: Date: Thu, 4 Nov 2021 17:19:29 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0456.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::36) To CO1PR11MB5012.namprd11.prod.outlook.com (2603:10b6:303:90::18) MIME-Version: 1.0 Received: from [192.198.151.53] (192.198.151.53) by LO2P265CA0456.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Thu, 4 Nov 2021 16:19:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b03c0c90-fd0c-4ef3-fa67-08d99faee478 X-MS-TrafficTypeDiagnostic: MWHPR11MB0016: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VnHziGQ82g2QEv21Zq+4vXhg0BmjH31VoLubwVcLktTlas1mz2WGz+edWz2ECrAE0/65rsWv1ihpTxHanvog/yv4kefXVmYo3dbWu7fcv4A/WepQjH6HxMlsugGUfz7hm8znGyjhSX+2KleL8rtmVyCZPmO4qg8Tj0rAeNsgOCCPm90PTDXMRJCxXd3vGf0/IDId5dGw0DQva5rlRR4i5xJirO0vMxwl7dzKJae696ydPhCoeOrykBgQAYct5dRURsNQi1WkU03pjHQv1yuInRgfIYyZ7Sali/BuBf6SA0Dwb51SI7aoIqIeg1G/oL5m54zzq5G4I+/38yWtD7JDqIDfdjm5Kp/t7+CPsasDMBK3BGEi95R//PMpuPJ82W4d64K2PK4ZNs75TCq75sxZ7gXaF6UDD9BmTGYB9kqPN1uaid69oggNWvz97b/btIj7XgCa5xZKo0u9jx2Fc/8xPKSRxeF6BDoZ743ETfIdK0WInsW+iTq1d8B3dtFG9bNEqM9BRhZL/q/5BDCXcTjmjNo3jCU2rZ5qCWvj/l6YM/k3HZX2Eurs12psiP8HvZrw5SwGsVJh7Qn5OvTK7wGN7pjXIhRUHIY/a/u0fF9LW+AAGWihubryZlM1b7bJL6x8fcP46eGCbTfEyb7dDyzai2hlHGBTJzh5iyzEX1zWjrF6wXH1kcwoBOrYo0P5v9AOWuxh4r7f8Xsge1HYVUiaYhb5+W9IT3Qw1pYyBrjr5fIgSskqKwefxEhcNYHCSh4AJ5uKw4KOwgMvkJ6pS8Hv+w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB5012.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(66556008)(6486002)(36756003)(66476007)(5660300002)(26005)(66946007)(6706004)(4326008)(16576012)(15650500001)(6666004)(110136005)(2616005)(8936002)(186003)(316002)(82960400001)(86362001)(38100700002)(2906002)(8676002)(53546011)(31696002)(31686004)(83380400001)(956004)(508600001)(3940600001)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WkNPcmIvbkl0cUtzMmtZdWkveG54c2JGWVhXZEVTQTVlSVY0T0N3NUNKb2RN?= =?utf-8?B?V2g3MWJxWkp5QjAxZExKWWJpVVpEKzBnL0drL00xck4yVmtQMHltMUp2OG9X?= =?utf-8?B?SlY2N3ZCOUJ0OWZzeUFRd29jWk1hYlRESFRMUnFuZFNCbWRza3VaOEJCVWZZ?= =?utf-8?B?UmIvK0JleVRPUnRkdDQ1YkswT3gwZ1h4ZXNtY1BrOGlHcGwycVRnU1NWM3pu?= =?utf-8?B?Z0FhMHd6enhoRjRJZTNJTEVVK1JFZmM0ZE1aRkcyL0tMbFA4RTFZNy9SZ2xR?= =?utf-8?B?R3AvRVVMVHRDeTc1WnVKSTlHVEZUbHhwOUJEbDJwbzBReHhwdHlpVEdiZDVn?= =?utf-8?B?cjZGYUNFRHVrS0Z0M1hPVGQyNEh6U1oyQnp0Q2pCdm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RmU1ZEdWlUaWd5RFZwckR2Z296L1cyZ3o0OFZmQUJq?= =?utf-8?Q?z1Cv1k8nZx3PkT+1oTh+zHX3AXKJBaWSqfwqV/VFLM=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: b03c0c90-fd0c-4ef3-fa67-08d99faee478 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB5012.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2021 16:19:35.7807 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RMjZQmsQu95LT6lFu/U2JftW4drez9csYbh5nDTGCqKjRN3KCJMV9igeakDrOAa2x1QSenX0C5CiJlcELRQAJ4asl3qdSz5YeIYpqf1v+0I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB0016 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4] examples/l3fwd: ipv4 and udp/tcp cksum verification through software X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Usama, On 04/11/2021 12:11, Walsh, Conor wrote: >> From: dev On Behalf Of Usama Nadeem >> Sent: Thursday 14 October 2021 19:43 >> To: thomas@monjalon.net >> Cc: dev@dpdk.org; Usama Nadeem >> Subject: [dpdk-dev] [PATCH v4] examples/l3fwd: ipv4 and udp/tcp cksum >> verification through software >> >> checks if ipv4 and udptcp cksum offload capability available >> If not available, cksum is verified through software >> If cksum is corrupt, packet is dropped, rest of the packets >> are forwarded back. >> >> Bugzilla ID:545 >> Signed-off-by: Usama Nadeem >> --- > > Hi Usama, > > This should be done in a generic way that allows all the lookup methods to support it not just LPM. > check_software_cksum should go in a common file and be called from LPM, FIB and possibly EM. > > Thanks, > Conor. > >> examples/l3fwd/l3fwd.h | 6 ++++ >> examples/l3fwd/l3fwd_lpm.c | 72 >> ++++++++++++++++++++++++++++++++++++-- >> examples/l3fwd/main.c | 33 +++++++++++++++-- >> 3 files changed, 105 insertions(+), 6 deletions(-) >> >> diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h >> index a808d60247..c2c21a91fb 100644 >> --- a/examples/l3fwd/l3fwd.h >> +++ b/examples/l3fwd/l3fwd.h >> @@ -55,6 +55,8 @@ >> #define L3FWD_HASH_ENTRIES (1024*1024*1) >> #endif >> #define HASH_ENTRY_NUMBER_DEFAULT 4 >> +extern bool l3_sft_cksum; >> +extern bool l4_sft_cksum; >> >> struct mbuf_table { >> uint16_t len; >> @@ -210,6 +212,10 @@ em_main_loop(__rte_unused void *dummy); >> int >> lpm_main_loop(__rte_unused void *dummy); >> >> +int >> +check_software_cksum(struct rte_mbuf **pkts_burst, >> +struct rte_mbuf **pkts_burst_to_send, int nb_rx); >> + >> int >> fib_main_loop(__rte_unused void *dummy); >> >> diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c >> index 232b606b54..ecaf323943 100644 >> --- a/examples/l3fwd/l3fwd_lpm.c >> +++ b/examples/l3fwd/l3fwd_lpm.c >> @@ -26,6 +26,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "l3fwd.h" >> #include "l3fwd_event.h" >> @@ -139,16 +140,65 @@ lpm_get_dst_port_with_ipv4(const struct >> lcore_conf *qconf, struct rte_mbuf *pkt, >> #include "l3fwd_lpm.h" >> #endif >> >> + >> +int check_software_cksum(struct rte_mbuf **pkts_burst, >> +struct rte_mbuf **pkts_burst_to_send, int nb_rx) >> +{ >> + int j; >> + int i = 0; >> + struct rte_net_hdr_lens hdr_lens; >> + struct rte_ipv4_hdr *ipv4_hdr; >> + void *l3_hdr; >> + void *l4_hdr; >> + rte_be16_t prev_cksum; >> + int dropped_pkts_udp_tcp = 0; >> + int dropped_pkts_ipv4 = 0; Why do you need two separate counters if you eventually summing them up? >> + bool dropped; >> + for (j = 0; j < nb_rx; j++) { >> + dropped = false; >> + rte_net_get_ptype(pkts_burst[j], &hdr_lens, >> RTE_PTYPE_ALL_MASK); >> + l3_hdr = rte_pktmbuf_mtod_offset(pkts_burst[j], >> + void *, hdr_lens.l2_len); >> + l4_hdr = rte_pktmbuf_mtod_offset(pkts_burst[j], >> + void *, hdr_lens.l2_len + hdr_lens.l3_len); here hdr_lens.l3_len could be non initialized, for example in case of MPLS packet. >> + ipv4_hdr = l3_hdr; >> + prev_cksum = ipv4_hdr->hdr_checksum; it could be non IPv4 packet. >> + ipv4_hdr->hdr_checksum = 0; >> + ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); same here and below, it can be IPv6 for example. >> + >> + if (l3_sft_cksum && prev_cksum != ipv4_hdr- >>> hdr_checksum) { >> + rte_pktmbuf_free(pkts_burst[j]); >> + dropped_pkts_ipv4++; >> + dropped = true; Do you need "dropped" value + the the final if statement at all? Maybe it's better to just ... continue; } here... >> + } else if (l4_sft_cksum && >> + rte_ipv4_udptcp_cksum_verify >> + (l3_hdr, l4_hdr) != 0) { >> + >> + rte_pktmbuf_free(pkts_burst[j]); >> + dropped_pkts_udp_tcp++; >> + dropped = true; >> + } >> + if (dropped == false) { >> + pkts_burst_to_send[i] = pkts_burst[j]; >> + i++; ...and execute this code unconditionally? >> + } >> + >> + } >> + return dropped_pkts_udp_tcp+dropped_pkts_ipv4; >> +} >> + >> /* main processing loop */ >> int >> lpm_main_loop(__rte_unused void *dummy) >> { >> struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; >> + struct rte_mbuf *pkts_burst_to_send[MAX_PKT_BURST]; >> unsigned lcore_id; >> uint64_t prev_tsc, diff_tsc, cur_tsc; >> int i, nb_rx; >> uint16_t portid; >> uint8_t queueid; >> + int dropped; >> struct lcore_conf *qconf; >> const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / >> US_PER_S * BURST_TX_DRAIN_US; >> @@ -209,19 +259,35 @@ lpm_main_loop(__rte_unused void *dummy) >> if (nb_rx == 0) >> continue; >> >> + if (l3_sft_cksum || l4_sft_cksum) { >> + dropped = >> check_software_cksum(pkts_burst, You are calling this function fight after rte_eth_rx_burst(), so pkts_burst[] can have any possible packet proto, but current check_software_cksum() implementation if purely IPv4. >> + pkts_burst_to_send, nb_rx); >> + >> + nb_rx = nb_rx-dropped; >> + } >> + >> + >> #if defined RTE_ARCH_X86 || defined __ARM_NEON \ >> || defined RTE_ARCH_PPC_64 >> + if (l3_sft_cksum == false && l4_sft_cksum == false) >> l3fwd_lpm_send_packets(nb_rx, pkts_burst, >> portid, qconf); >> + else >> + l3fwd_lpm_send_packets(nb_rx, >> pkts_burst_to_send, >> + portid, qconf); >> + >> #else >> - l3fwd_lpm_no_opt_send_packets(nb_rx, >> pkts_burst, >> + if (l3_sft_cksum == false && l4_sft_cksum == false) While those if statements are perfectly predictable, it is still better to avoid branching in hot path if possible. You can implement check_software_cksum() to work with a single pkts_burst[] modifying it in place and throw away pkts_burst_to_send[] and corresponding branches. >> + l3fwd_lpm_no_opt_send_packets(nb_rx, >> pkts_burst, >> portid, qconf); >> + else >> + l3fwd_lpm_no_opt_send_packets(nb_rx, >> + pkts_burst_to_send, portid, qconf); >> + >> #endif /* X86 */ >> } >> - >> cur_tsc = rte_rdtsc(); >> } >> - >> return 0; >> } >> >> diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c >> index 00ac267af1..a54aca070d 100644 >> --- a/examples/l3fwd/main.c >> +++ b/examples/l3fwd/main.c >> @@ -61,6 +61,9 @@ static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT; >> /**< Ports set in promiscuous mode off by default. */ >> static int promiscuous_on; >> >> +bool l3_sft_cksum; >> +bool l4_sft_cksum; >> + >> /* Select Longest-Prefix, Exact match or Forwarding Information Base. */ >> enum L3FWD_LOOKUP_MODE { >> L3FWD_LOOKUP_DEFAULT, >> @@ -123,7 +126,6 @@ static struct rte_eth_conf port_conf = { >> .mq_mode = ETH_MQ_RX_RSS, >> .max_rx_pkt_len = RTE_ETHER_MAX_LEN, >> .split_hdr_size = 0, >> - .offloads = DEV_RX_OFFLOAD_CHECKSUM, >> }, >> .rx_adv_conf = { >> .rss_conf = { >> @@ -981,6 +983,7 @@ prepare_ptype_parser(uint16_t portid, uint16_t >> queueid) >> return 0; >> } >> >> + >> static void >> l3fwd_poll_resource_setup(void) >> { >> @@ -993,7 +996,8 @@ l3fwd_poll_resource_setup(void) >> unsigned int nb_ports; >> unsigned int lcore_id; >> int ret; >> - >> + l3_sft_cksum = false; >> + l4_sft_cksum = false; >> if (check_lcore_params() < 0) >> rte_exit(EXIT_FAILURE, "check_lcore_params failed\n"); >> >> @@ -1034,11 +1038,34 @@ l3fwd_poll_resource_setup(void) >> rte_exit(EXIT_FAILURE, >> "Error during getting device (port %u) info: >> %s\n", >> portid, strerror(-ret)); >> - >> if (dev_info.tx_offload_capa & >> DEV_TX_OFFLOAD_MBUF_FAST_FREE) >> local_port_conf.txmode.offloads |= >> DEV_TX_OFFLOAD_MBUF_FAST_FREE; >> >> + if (dev_info.rx_offload_capa & >> DEV_RX_OFFLOAD_IPV4_CKSUM) >> + local_port_conf.rxmode.offloads |= >> + DEV_RX_OFFLOAD_IPV4_CKSUM; >> + else { >> + l3_sft_cksum = true; >> + printf("WARNING: IPV4 checksum offload not >> available.\n"); >> + } >> + >> + if (dev_info.rx_offload_capa & >> DEV_RX_OFFLOAD_UDP_CKSUM) >> + local_port_conf.rxmode.offloads |= >> + DEV_RX_OFFLOAD_UDP_CKSUM; >> + else { >> + l4_sft_cksum = true; >> + printf("WARNING: UDP checksum offload not >> available.\n"); >> + } >> + >> + if (dev_info.rx_offload_capa & >> DEV_RX_OFFLOAD_TCP_CKSUM) >> + local_port_conf.rxmode.offloads |= >> + DEV_RX_OFFLOAD_TCP_CKSUM; >> + else { >> + l4_sft_cksum = true; >> + printf("WARNING: TCP checksum offload not >> available.\n"); >> + } >> + >> local_port_conf.rx_adv_conf.rss_conf.rss_hf &= >> dev_info.flow_type_rss_offloads; >> >> -- >> 2.25.1 > generalizing: 1. As Conor said earlier, make it generic, not only LPM and not only for run-to-completion mode, it should be done for event mode as well. 2. Function must work not only with IPv4. 3. There should be no performance degradation if NIC supports CSUM offload. -- Regards, Vladimir