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 272BE45C4F; Fri, 1 Nov 2024 23:49:59 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0B46402C6; Fri, 1 Nov 2024 23:49:58 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2080.outbound.protection.outlook.com [40.107.243.80]) by mails.dpdk.org (Postfix) with ESMTP id 28CAA4029A for ; Fri, 1 Nov 2024 23:49:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jGnkq5gR+NV/U6HlXVGz1aOVKGdwWorxtPip5++i+lOpRI+9ZWVmQwxMVHteUsMncKp7Yqfkt5JBquv92irrfnw7YTjP3RFfGVUReY1CFCTjdC+ff8Wdecg2iTLns2f5vdMyFQnakfEi7BF+yDX12wiaoIgnJBW8MHcYWdBBpMPVxU691VS6upxdzZpmKjlmBu6U/stFp2Xzd/D38GwenU0WZJpN7pCIBLY9LX2MsGbennMwm3BEadnlxUV/a+u/F2p0cKs+ywOBctZ0+P7Ejv6L/2DN57xyzJ9GvpZBB1ridFQ/qdMc9UCBCcwq5lbEQ+u2W+dSAT+IN9dAIUzNFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=d3fJ5Pvnz0QrLzaGy6/2coAi6LqPFSj2sZb8S0/bhzA=; b=ximYFSoOmx8f0BYDPUwDjJJlTmEFziArsjVm+9LqjKdcoPMXIDLEpz7TZTl5rsRhwWvAUJv7jD6nJqzo6L3v+RxDADTlIllYLQvIEq9pg9qn/uV3kUc9F7joap8JCORaXX+TYglA033ecSOdgXLZlV0FJ81Y/o9yvRkCVkQQ5+sVWiv3UISuhvzoScUGWe1ALYD6EWDz1smoppRkSMOaHozsdrnd9Hyk7u2tP1BqVgT4b6d0tidNlOnm5cOtIEO2xupe96e+Wcu5wqiw86BQC7pc7uH7wjHZamaVL5gEGF7C7LfWgmjkxIKXhGJmuBNrfKq+NZqxXnd/aOlhTZaCtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=d3fJ5Pvnz0QrLzaGy6/2coAi6LqPFSj2sZb8S0/bhzA=; b=oTH6VAZbciFafINzWKAyAtqD6UKV0On5pnm4m+/O+/SUf03q8epge6UhapGByH7RjNkv/zIO2BS7WqbjzbhJpJAKKob2uQSWnjMIQNRV0X8P9B70AniOnuo7LFQi8USTPshVWFopj2jRMPZ9Tl65L6mg212Hz3beux3sIfxh1UE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from SN7PR12MB8818.namprd12.prod.outlook.com (2603:10b6:806:34b::15) by PH7PR12MB7841.namprd12.prod.outlook.com (2603:10b6:510:273::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23; Fri, 1 Nov 2024 22:49:52 +0000 Received: from SN7PR12MB8818.namprd12.prod.outlook.com ([fe80::d875:3b24:cbd6:8a1]) by SN7PR12MB8818.namprd12.prod.outlook.com ([fe80::d875:3b24:cbd6:8a1%5]) with mapi id 15.20.8114.020; Fri, 1 Nov 2024 22:49:52 +0000 Message-ID: <89d610c3-ebae-4fd9-91e1-f200f13584f9@amd.com> Date: Fri, 1 Nov 2024 22:49:40 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v02] net/af_packet: add rollover and defrag options To: Gur Stavi Cc: dev@dpdk.org, "John W. Linville" , Stephen Hemminger References: <0dee3d4cf2a563262bddfba86f750122b8dae5ac.1730381951.git.gur.stavi@huawei.com> Content-Language: en-US From: Ferruh Yigit In-Reply-To: <0dee3d4cf2a563262bddfba86f750122b8dae5ac.1730381951.git.gur.stavi@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0263.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:37c::12) To PH7PR12MB8827.namprd12.prod.outlook.com (2603:10b6:510:26b::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN7PR12MB8818:EE_|PH7PR12MB7841:EE_ X-MS-Office365-Filtering-Correlation-Id: dc0c6cbf-535e-4e5b-09de-08dcfac77ecf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RmxWUDJ1OHBJZXI4Z2JFU1dOaXYrUXN4UDgvQzZ5VTkvY09ETXErRGdkQU1i?= =?utf-8?B?bnM0Tk9lamU0TEFBck45STNsaWwwRkNOclczNEJYTyt2SXBITmlCSXpWdFpO?= =?utf-8?B?WHFMVnRhbm14V0dYTnhOOEx0dHJRU1F6cXE1UVZOOW4xQnhBc0d6MmNqdGsw?= =?utf-8?B?cUVIUFNQZUlEemJJQ0Z4MHRMWHRsdWNRUHRydUpJL3NpazRtSXVlVmRoOGVw?= =?utf-8?B?dlVmNS9xa1NXdzBJc3Ewcm1XWmdST1J5Q1VDODZsbnZvWjRYTEJuL0ZHb2hy?= =?utf-8?B?RlJnV2xCMjkrTDhsdEJ3c3A5TmorTmNiK3ZuSnFZc0ZVV1VnQXhpWDArQzhx?= =?utf-8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CejJ5WEEy?= =?utf-8?B?c1BLd1dRQjJvMEFKRFlFN1I0My9WREpRaXVBOHNkNTFwMWJaa2RTVlZRbktU?= =?utf-8?B?RFNnOGZhMUNWbTBBN2h3YVQxeHRKNitkdG1iSFRSSHMxM0JYci9qc2J5Qmxk?= =?utf-8?B?ZXBxVUU2Njh6Mm90YWw2UDRmUzRkNktZaTdOT01LKy9MbXYrUkJTOWVndndh?= =?utf-8?B?UmIveHQvbWR2Rk9NbnlQS3RUS2VPcFNadzY3YW1ZdStadVoweE5BcHFrd1pU?= =?utf-8?B?RjZqUk5YTXo4R1Y0TnJvNkllRUx6WWN5eEVaWlJRVlc3aWwyejFXSTdLRDd6?= =?utf-8?B?RlExOTB5MlIxbXpOSmMvYVB1YVZUWnFGbFdJRE1YcUpuSmxudEU2NUxETVJY?= =?utf-8?B?M2daUHB5WUdNQ1IzOEpHYVdsVzA0aDlKU1JHcjJlMFJxSVF2akYrSFFtdUdC?= =?utf-8?Q?E/7vL6LQBvLH9ojbzMRd?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN7PR12MB8818.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NXdpaEhCZkZjQWN4eTBwYjlteWREK3FCcEFSUm96c0JrYWlLb2ZOV0x2UUNG?= =?utf-8?B?dGJxZDBPUUFpR0JobDdhRytyOUZIZzFYZUVucC9KTEtUZnJ5QTlRYTF2MmlM?= =?utf-8?B?T0E2ekxoQ244ZlZDdThEWGNzUGVjR0lDZ3dmWVlUN0ZoWHU2bTlpN2N5Qm9m?= =?utf-8?B?WDlnb0pLYTZXVjBjZzRuS2p5emVTRmdZSW83aTdTNmhjZ1dWVVFLd1ErM2c3?= =?utf-8?B?ODBLOWh1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llWalV2?= =?utf-8?B?LytLdTQ5Q20xTS84TVJrT0dWNm9iZjVOMEppcUNpajczMFpuT1VJeDZRbGxU?= =?utf-8?Q?g0iiOIYQ5g/FcIA/KZiPQR8Gv?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc0c6cbf-535e-4e5b-09de-08dcfac77ecf X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB8827.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 22:49:52.2130 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: O1P8cltoUJdAwJXSrLQMV5vymmZO6NU3XMq/Svnmmh/dV7CDCixQe/UT9TBYnQTN X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7841 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 On 10/31/2024 1:50 PM, Gur Stavi wrote: > net_af_packet PMD multi "queue" support relies on Linux FANOUT capability. > Linux FANOUT is a SW based load balancer that is similar to HW RSS which > is more common for DPDK PMDs. Instead of multiple HW descriptor queues, > AF PACKET uses multiple sockets. > HW RSS will typically drop a packet if its selected RX queue is empty. > However, Linux FANOUT, as a SW load balancer, can be configured to avoid > this packet drop by rolling over to the next socket. > This rollover functionality was ALWAYS enabled in net_af_packet. It is > surrounded by ifdef, but only to allow compilation on ancient Linux > versions that did not have it. > > Since DPDK applications are usually designed for HW based PMDs, this > rollover functionality, which the developers are likely unaware of, could > be confusing. > > Another option that is part of Linux FANOUT is DEFRAG that instructs Linux > to compose complete IP packet out of fragments before delivering it to the > PACKET socket. Again, this behavior typically does not exist for HW based > PMDs and may confuse users. > > This patch adds 2 options to control these features: > rollover=[0|1],defrag=[0|1] > For backward compatibility both features are enabled by default even > though most users will probably want both of them disabled. > > Signed-off-by: Gur Stavi > --- > v2: > * Improve error handling for parsing of arg strings. Add a wrapper around > strtoul to replace atoi. > * Fix checkpatch indentation error due to copy-paste. > > v1: https://mails.dpdk.org/archives/dev/2024-October/307451.html > --- > doc/guides/nics/af_packet.rst | 4 ++ > drivers/net/af_packet/rte_eth_af_packet.c | 77 ++++++++++++++++++----- > 2 files changed, 65 insertions(+), 16 deletions(-) > > diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst > index 66b977e1a2..4bc748b50b 100644 > --- a/doc/guides/nics/af_packet.rst > +++ b/doc/guides/nics/af_packet.rst > @@ -29,6 +29,8 @@ Some of these, in turn, will be used to configure the PACKET_MMAP settings. > * ``framesz`` - PACKET_MMAP frame size (optional, default 2048B; Note: multiple > of 16B); > * ``framecnt`` - PACKET_MMAP frame count (optional, default 512). > +* ``rollover`` - disable(0)/enable(1) PACKET_FANOUT_ROLLOVER (optional, default 1). > +* ``defrag`` - disable(0)/enable(1) PACKET_FANOUT_FLAG_DEFRAG (optional, default 1). > +1 to introduce both options, thanks. Do you have any practical usecase to disable them? > Because this implementation is based on PACKET_MMAP, and PACKET_MMAP has its > own pre-requisites, it should be noted that the inner workings of PACKET_MMAP > @@ -47,6 +49,8 @@ For the full details behind PACKET_MMAP's structures and settings, consider > reading the `PACKET_MMAP documentation in the Kernel > `_. > > +For details of ``rollover`` anb ``defrag`` refer to the *packet(7)* man page. > + > Prerequisites > ------------- > > diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c > index 68870dd3e2..1a043e8398 100644 > --- a/drivers/net/af_packet/rte_eth_af_packet.c > +++ b/drivers/net/af_packet/rte_eth_af_packet.c > @@ -36,6 +36,8 @@ > #define ETH_AF_PACKET_FRAMESIZE_ARG "framesz" > #define ETH_AF_PACKET_FRAMECOUNT_ARG "framecnt" > #define ETH_AF_PACKET_QDISC_BYPASS_ARG "qdisc_bypass" > +#define ETH_AF_PACKET_ROLLOVER "rollover" > +#define ETH_AF_PACKET_DEFRAG "defrag" > Can you please add new arguments to 'RTE_PMD_REGISTER_PARAM_STRING' macro below? > #define DFLT_FRAME_SIZE (1 << 11) > #define DFLT_FRAME_COUNT (1 << 9) > @@ -91,6 +93,8 @@ static const char *valid_arguments[] = { > ETH_AF_PACKET_FRAMESIZE_ARG, > ETH_AF_PACKET_FRAMECOUNT_ARG, > ETH_AF_PACKET_QDISC_BYPASS_ARG, > + ETH_AF_PACKET_ROLLOVER, > + ETH_AF_PACKET_DEFRAG, > NULL > }; > > @@ -659,6 +663,20 @@ open_packet_iface(const char *key __rte_unused, > return 0; > } > > +static int > +uint_arg_parse(const char *arg_str, unsigned int *arg_val) > +{ > + unsigned long val; > + char *endptr; > + > + val = strtoul(arg_str, &endptr, 10); > + if (*arg_str == '\0' || *endptr != '\0') > + return -EINVAL; > + > + *arg_val = val; > + return 0; > +} > + > static int > rte_pmd_init_internals(struct rte_vdev_device *dev, > const int sockfd, > @@ -676,6 +694,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > const unsigned int numa_node = dev->device.numa_node; > struct rte_eth_dev_data *data = NULL; > struct rte_kvargs_pair *pair = NULL; > + const char *ifname = NULL; > struct ifreq ifr; > size_t ifnamelen; > unsigned k_idx; > @@ -686,6 +705,8 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > int rc, tpver, discard; > int qsockfd = -1; > unsigned int i, q, rdsize; > + unsigned int rollover = 1; > + unsigned int defrag = 1; > #if defined(PACKET_FANOUT) > int fanout_arg; > #endif > @@ -693,9 +714,30 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > for (k_idx = 0; k_idx < kvlist->count; k_idx++) { > pair = &kvlist->pairs[k_idx]; > if (strstr(pair->key, ETH_AF_PACKET_IFACE_ARG) != NULL) > - break; > + ifname = pair->value; > + if (strcmp(pair->key, ETH_AF_PACKET_ROLLOVER) == 0) { > + rc = uint_arg_parse(pair->value, &rollover); > + if (rc || rollover > 1) { > + PMD_LOG(ERR, > + "%s: invalid rollover value: %s", > + name, pair->value); > + return -1; > + } > + continue; > + } > + if (strcmp(pair->key, ETH_AF_PACKET_DEFRAG) == 0) { > + rc = uint_arg_parse(pair->value, &defrag); > + if (rc || defrag > 1) { > + PMD_LOG(ERR, > + "%s: invalid defrag value: %s", > + name, pair->value); > + return -1; > + } > + continue; > + } > Instead of adding parameter parsing here, they are already in 'rte_eth_from_packet()' function, better to add there, BUT, before adding more paramter, can you please fix the parameter parsing in the af_packet PMD? This is in my list for a long time now. Instead of accessing to 'kvlist' internals (kvlist->count, kvlist->pairs[]), and use 'strstr' (or 'strcmp'), there is already existing 'rte_kvargs_process()' API for it, you can find multiple samples in other drivers. > } > - if (pair == NULL) { > + > + if (ifname == NULL) { > PMD_LOG(ERR, > "%s: no interface specified for AF_PACKET ethdev", > name); > @@ -738,21 +780,21 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > req->tp_frame_size = framesize; > req->tp_frame_nr = framecnt; > > - ifnamelen = strlen(pair->value); > + ifnamelen = strlen(ifname); > if (ifnamelen < sizeof(ifr.ifr_name)) { > - memcpy(ifr.ifr_name, pair->value, ifnamelen); > + memcpy(ifr.ifr_name, ifname, ifnamelen); > ifr.ifr_name[ifnamelen] = '\0'; > } else { > PMD_LOG(ERR, > "%s: I/F name too long (%s)", > - name, pair->value); > + name, ifname); > goto free_internals; > } > if (ioctl(sockfd, SIOCGIFINDEX, &ifr) == -1) { > PMD_LOG_ERRNO(ERR, "%s: ioctl failed (SIOCGIFINDEX)", name); > goto free_internals; > } > - (*internals)->if_name = strdup(pair->value); > + (*internals)->if_name = strdup(ifname); > if ((*internals)->if_name == NULL) > goto free_internals; > (*internals)->if_index = ifr.ifr_ifindex; > @@ -770,9 +812,12 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > > #if defined(PACKET_FANOUT) > fanout_arg = (getpid() ^ (*internals)->if_index) & 0xffff; > - fanout_arg |= (PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG) << 16; > + fanout_arg |= PACKET_FANOUT_HASH << 16; > + if (defrag) > + fanout_arg |= PACKET_FANOUT_FLAG_DEFRAG << 16; > #if defined(PACKET_FANOUT_FLAG_ROLLOVER) > - fanout_arg |= PACKET_FANOUT_FLAG_ROLLOVER << 16; > + if (rollover) > + fanout_arg |= PACKET_FANOUT_FLAG_ROLLOVER << 16; > #endif > #endif > > @@ -792,7 +837,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not set PACKET_VERSION on AF_PACKET socket for %s", > - name, pair->value); > + name, ifname); > goto error; > } > > @@ -802,7 +847,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not set PACKET_LOSS on AF_PACKET socket for %s", > - name, pair->value); > + name, ifname); > goto error; > } > > @@ -813,7 +858,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not set PACKET_QDISC_BYPASS on AF_PACKET socket for %s", > - name, pair->value); > + name, ifname); > goto error; > } > #endif > @@ -823,7 +868,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not set PACKET_RX_RING on AF_PACKET socket for %s", > - name, pair->value); > + name, ifname); > goto error; > } > > @@ -831,7 +876,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not set PACKET_TX_RING on AF_PACKET " > - "socket for %s", name, pair->value); > + "socket for %s", name, ifname); > goto error; > } > > @@ -844,7 +889,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rx_queue->map == MAP_FAILED) { > PMD_LOG_ERRNO(ERR, > "%s: call to mmap failed on AF_PACKET socket for %s", > - name, pair->value); > + name, ifname); > goto error; > } > > @@ -881,7 +926,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not bind AF_PACKET socket to %s", > - name, pair->value); > + name, ifname); > goto error; > } > > @@ -891,7 +936,7 @@ rte_pmd_init_internals(struct rte_vdev_device *dev, > if (rc == -1) { > PMD_LOG_ERRNO(ERR, > "%s: could not set PACKET_FANOUT on AF_PACKET socket for %s", > - name, pair->value); > + name, ifname); > goto error; > } > #endif > > base-commit: 98613d32e3dac58d685f4f236cf8cc9733abaaf3 > -- > 2.40.1 >