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 AE616A0545; Tue, 11 Oct 2022 15:46:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C90242DE1; Tue, 11 Oct 2022 15:46:22 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2055.outbound.protection.outlook.com [40.107.223.55]) by mails.dpdk.org (Postfix) with ESMTP id 836B642B7D for ; Tue, 11 Oct 2022 15:46:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+KCXfNtMvH8DV3HY/yL3V1YdboaKJpzvz5CJw0TtoIVa7HkPWmIR5in8DFaDpz8OfPu3MFM7BaqmsS3DTtuL9ODAaQlXALmqqXKCWMbQrI5/78WyznTsgpUjR3twF/sUdD0UQHBc3UvENWmU/vV9huS3TpzEwJiN6/q27Gn9ZAtcdAytcqM2CbKDJJQYweGw+LxEjbJbJhM9qPQENEx7TfYmOnOetjQksyG8AYDHYcSrRhsKMcOgx7KQ/JB70AH4kAFBPpk8w6dScr/34JZTyxeJqzsJrW4EX4EhdWTG/MJZXPEnVfdGSESLCCw6NbiPqII0zV5u3mQSDGaVedC5w== 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=rsXNbz1GEZ+s9v442nBTRwC8ukXsh+AeDU0w+3a/gnI=; b=UQn85zdn3JMx03mv37ke8CxW+vCSngsiS8sXRf3I37a215NP4lJjQiNsPHox5E+mNS1lRBXO+jHMkaArVofb7LlY3Utb4vB4aiU5wMZDEnAJe2lzFa3JxWKI2IdbSdskIOHs3OsuR+zknZPK9JACcHo1i1qrTK7gOpDsc7CRPqfDXM8G4CIUHq9ipXziWrMow2Y7aDn/rAyOSX9/+6GWMshKaico78hxNWkCZLi0y3ODxnSC70SUC9IcGQWRguPYGmq+vnA2q++Nd2qIBOxS1paE2afdnDDDHBSal67+ZY7BFgYQun5/IePEKo+mj5/brlPac+TZ/XicSCMOLWh26w== 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=rsXNbz1GEZ+s9v442nBTRwC8ukXsh+AeDU0w+3a/gnI=; b=M18oOeVtQ9gIThF7nTxQGS6KSXCPmXlX6dura2hRAYfq36F/LCz5C6yezW65SmfyNpaNwZLKdKnah1IikBE/tZFRYXWwVQEvWwz9lH/kdki8J+92d/1HzOVTam5tHmHiCpQUNbm17Ck1QVwEQZ3GI8RWC2Czl+4Cxmr0rJ6Zixg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM6PR12MB4297.namprd12.prod.outlook.com (2603:10b6:5:211::20) by MW3PR12MB4380.namprd12.prod.outlook.com (2603:10b6:303:5a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.15; Tue, 11 Oct 2022 13:46:18 +0000 Received: from DM6PR12MB4297.namprd12.prod.outlook.com ([fe80::b9fd:e732:4585:6b25]) by DM6PR12MB4297.namprd12.prod.outlook.com ([fe80::b9fd:e732:4585:6b25%7]) with mapi id 15.20.5676.036; Tue, 11 Oct 2022 13:46:18 +0000 Message-ID: <6e1eb50c-8633-a4b1-e18a-84b525074e32@amd.com> Date: Tue, 11 Oct 2022 14:46:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: CRC offload from application's POV Content-Language: en-US To: Viacheslav Galaktionov , Simei Su , Wenjun Wu Cc: Denis Pryazhennikov , dev@dpdk.org References: <11b33bf3-413a-6955-423a-cc47a73e2202@arknetworks.am> <103627bd-d704-84a2-9f3e-5e4a7341e6a7@amd.com> <2f221574-ac04-2931-275b-e758669e0bef@arknetworks.am> From: Ferruh Yigit In-Reply-To: <2f221574-ac04-2931-275b-e758669e0bef@arknetworks.am> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P123CA0001.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:a6::13) To DM6PR12MB4297.namprd12.prod.outlook.com (2603:10b6:5:211::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR12MB4297:EE_|MW3PR12MB4380:EE_ X-MS-Office365-Filtering-Correlation-Id: c0370a06-e976-42b0-f5cb-08daab8ef917 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rbXW9YKA122SiH4L/OIoIhlfPV53K6fadYawIbtMVPScQBnO39FOiJgZ64SZUk0Euqhi1fHngHRSkh6ZUjiU7NdVSSK1KU3NL2cT++dtDioTaAwZ3NAPFGD7TatzC/mKuBHg46WQPLVqmlaKrYr7HS4v+nlNtXF5+UeTQ+32RsLHS+SkzPlur4tnWT5fhCG09seh+X9BjJcZnbEaSZT2YTnoB0tOYA1+iAxhCA800ZWEFaAnyAqH6zpJIMZElQ9l+oYF5WYVC4Lt4AxICM6S2VdGWSxNXvk7v/+J1qcPrHGhM/JdKqxFmojNDDMLPFF3mmnIEANz1ujzxnY/acYCGPgKYnD8ullG1gBW3YAdG4+XUA50G4lNPNawBn/BQbqg3MXQQagmWUhM7yI366oImY+YNRAK58d87gxkH8mbjTOVWiKEd06BpW/ML2iy0uGnP6HtkFfFMYlaMuK5LwB5r5Zt4htobGHMQd4Ms88BIorwMjXEc5pus+gBbML4YdtmZn8a75XK5+ENxQlMraW7Jqp0MYZdCyrlG723laut+RsIvaFggvsBSeqOe9sjW+Tp+hLODzj2IDzaaSkRNXwf75nK03olM4ArPrzK/3qA0wg3EtS+LxLsJ/okGS2iqHtYl7AXDKWaANL6s/j6CPDrhvzj3vaQKOGXNr0zJ+VYaoReu3LhzGHBZdZJM5mYIPwR8CW8DPqIChoA+dBK8GAbp/LCbJe54cHLDj3TQN/5/Sn5WAUwA8RCZ1aU/Ps/i9rhVjFFZaNMVkDOWeWOpYlq4qJvQlLkBkF26hsNyKXAxdk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR12MB4297.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(376002)(39860400002)(396003)(366004)(136003)(346002)(451199015)(4326008)(2906002)(44832011)(8676002)(66946007)(66476007)(66556008)(41300700001)(5660300002)(8936002)(26005)(86362001)(38100700002)(6666004)(316002)(2616005)(53546011)(6506007)(6486002)(36756003)(31686004)(6512007)(478600001)(110136005)(186003)(31696002)(83380400001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SG5zZ1kzYi9JZytoaWRWZ3MvQ1NyUW1qOEF4OEtpYnNtVGk2dVhzNWJvZk0r?= =?utf-8?B?blM3aW11alQzaXBNbEMxRUFiTGlUeTJsMXRDRXl3RmVlemJQdFNLeitJSEgz?= =?utf-8?B?UGQ1Nnc1Vll0NEpWVENubmZ4bWRwNmx4RUNjSVpFa0J6UTYwWWZudFdtamZp?= =?utf-8?B?d3RTQkNOQVpIUGM2dVNDRTA5MUNSMmEzakcydXlaN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BsWXZTeVVWM1pEYjNMYlE3ZHRRRjBGY3FvOFpCaHhXMVRLWEhXa2NJ?= =?utf-8?B?UU9VNm4zVXZLYWtYMVNCd3g0MHpneDcwaTBEWDU5eWZ3cmdUY2wyMmhVWXlH?= =?utf-8?Q?NzXI=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0370a06-e976-42b0-f5cb-08daab8ef917 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4297.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Oct 2022 13:46:18.2272 (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: mac7M7bCLIDt2YYXq97Sm4p6ZmP8Yc5XBZfwYSCm+AbFawgp14RKWAqYNULgClJI X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4380 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/11/2022 12:54 PM, Viacheslav Galaktionov wrote: > On 10/11/22 15:36, Ferruh Yigit wrote: >> On 10/11/2022 11:48 AM, Viacheslav Galaktionov wrote: >>> Hi! >>> >>> We're looking to implement CRC offload in our driver and we're having >>> difficulties understanding what >>> the feature changes from the application's point of view. If we >>> enable the KEEP_CRC offload, then the >>> NIC is supposed to preserve the CRC in the packet, that much is >>> clear. But we checked other drivers >>> and it seems common for PMDs to remove the CRC from the final mbufs. >>> Why is that? >>> >>> We couldn't find any place where the CRC would be stored after >>> removal, so it looks like the application >>> doesn't have access to this piece of data. And if so, what's the >>> point of having this feature if the CRC >>> is discarded either way? >>> >>> We're probably missing something and would really appreciate any help >>> with this. >>> >> >> Hi Viacheslav, >> >> As you said default behavior is to strip the CRC from packet, even >> some devices doesn't support having CRC in the packet it is removed by >> HW automatically. In this case application can't access to the CRC. >> >> For the devices that has capability to keep CRC, KEEP_CRC offload >> should enable having CRC as part of the packet. There is no special >> field to store the CRC. >> > I'm asking because I'm seeing a common pattern in the code base: if the > hardware didn't remove the CRC, > the driver does this itself. Grepping the code for "crc_len" will show > you what I mean. One of the most apparent > examples of this happening can be seen in drivers/net/e1000/em_rxtx.c: > > /* >  * This is the last buffer of the received packet. >  * If the CRC is not stripped by the hardware: >  *   - Subtract the CRC    length from the total packet length. >  *   - If the last buffer only contains the whole CRC or a part >  *     of it, free the mbuf associated to the last buffer. >  *     If part of the CRC is also contained in the previous >  *     mbuf, subtract the length of that CRC part from the >  *     data length of the previous mbuf. >  */ > > I don't understand why this is necessary, and whether this is just a > particularity of this driver or how the feature > is supposed to be implemented everywhere. I haven't checked every > driver, but it seems like a lot of them do > something similar to this. That looks wrong to me too, cc'ed maintainers for comment. That piece of code seems remaining from first upstream of the driver (2012), it is before KEEP_CRC change, looks like it is missed. CRC should be kept in the packet if driver supports it and user requested KEEP_CRC offload. But Rx stats should not include CRC, as it is common to use 'm->pkt_len' for received packet stat, when CRC is in packet that should taken into account for stats.