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 796C743E52; Fri, 12 Apr 2024 14:46:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FAD5402A8; Fri, 12 Apr 2024 14:46:57 +0200 (CEST) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by mails.dpdk.org (Postfix) with ESMTP id DC6AD402A2; Fri, 12 Apr 2024 14:46:55 +0200 (CEST) Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VGGRJ3701z6K9Rk; Fri, 12 Apr 2024 20:42:04 +0800 (CST) Received: from frapeml100008.china.huawei.com (unknown [7.182.85.131]) by mail.maildlp.com (Postfix) with ESMTPS id A8699140A1B; Fri, 12 Apr 2024 20:46:54 +0800 (CST) Received: from frapeml500007.china.huawei.com (7.182.85.172) by frapeml100008.china.huawei.com (7.182.85.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 14:46:54 +0200 Received: from frapeml500007.china.huawei.com ([7.182.85.172]) by frapeml500007.china.huawei.com ([7.182.85.172]) with mapi id 15.01.2507.035; Fri, 12 Apr 2024 14:46:54 +0200 From: Konstantin Ananyev To: =?iso-8859-1?Q?Morten_Br=F8rup?= , "David Marchand" , "dev@dpdk.org" CC: "thomas@monjalon.net" , "ferruh.yigit@amd.com" , "stable@dpdk.org" , Olivier Matz , Jijiang Liu , "Andrew Rybchenko" , Ferruh Yigit , Kaiwen Deng , "qiming.yang@intel.com" , "yidingx.zhou@intel.com" , Aman Singh , "Yuying Zhang" , Thomas Monjalon , "Jerin Jacob" Subject: RE: [PATCH v2 3/8] mbuf: fix Tx checksum offload examples Thread-Topic: [PATCH v2 3/8] mbuf: fix Tx checksum offload examples Thread-Index: AQHah2gcwh+zxBWPrEOmSW2nVSxrXbFZuegAgAX4BtCAAE6MMIABTCywgAAbf0CAAzI3UA== Date: Fri, 12 Apr 2024 12:46:54 +0000 Message-ID: <52850a78c83445548a0b78bfd04e6f91@huawei.com> References: <20240405125039.897933-1-david.marchand@redhat.com> <20240405144604.906695-1-david.marchand@redhat.com> <20240405144604.906695-4-david.marchand@redhat.com> <98CBD80474FA8B44BF855DF32C47DC35E9F36C@smartserver.smartshare.dk> <10b564b42f8d4db387f6302701f24ce3@huawei.com> <98CBD80474FA8B44BF855DF32C47DC35E9F381@smartserver.smartshare.dk> <409157f5da3e4c628ca678dd9e2c7957@huawei.com> <98CBD80474FA8B44BF855DF32C47DC35E9F38F@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F38F@smartserver.smartshare.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.206.138.42] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 > > > > > > Mandate use of rte_eth_tx_prepare() in the mbuf Tx checksum off= load > > > > > > examples. > > > > > > > > > > I strongly disagree with this change! > > > > > > > > > > It will cause a huge performance degradation for shaping applicat= ions: > > > > > > > > > > A packet will be processed and finalized at an output or forwardi= ng > > > > pipeline stage, where some other fields might also be written, so > > > > > zeroing e.g. the out_ip checksum at this stage has low cost (no n= ew > > > > cache misses). > > > > > > > > > > Then, the packet might be queued for QoS or similar. > > > > > > > > > > If rte_eth_tx_prepare() must be called at the egress pipeline sta= ge, > > > > it has to write to the packet and cause a cache miss per packet, > > > > > instead of simply passing on the packet to the NIC hardware. > > > > > > > > > > It must be possible to finalize the packet at the output/forwardi= ng > > > > pipeline stage! > > > > > > > > If you can finalize your packet on output/forwarding, then why you > > > > can't invoke tx_prepare() on the same stage? > > > > There seems to be some misunderstanding about what tx_prepare() doe= s - > > > > in fact it doesn't communicate with HW queue (doesn't update TXD ri= ng, > > > > etc.), what it does - just make changes in mbuf itself. > > > > Yes, it reads some fields in SW TX queue struct (max number of TXDs= per > > > > packet, etc.), but AFAIK it is safe > > > > to call tx_prepare() and tx_burst() from different threads. > > > > At least on implementations I am aware about. > > > > Just checked the docs - it seems not stated explicitly anywhere, mi= ght > > > > be that's why it causing such misunderstanding. > > > > > > > > > > > > > > Also, how is rte_eth_tx_prepare() supposed to work for cloned pac= kets > > > > egressing on different NIC hardware? > > > > > > > > If you create a clone of full packet (including L2/L3) headers then > > > > obviously such construction might not > > > > work properly with tx_prepare() over two different NICs. > > > > Though In majority of cases you do clone segments with data, while = at > > > > least L2 headers are put into different segments. > > > > One simple approach would be to keep L3 header in that separate seg= ment. > > > > But yes, there is a problem when you'll need to send exactly the sa= me > > > > packet over different NICs. > > > > As I remember, for bonding PMD things don't work quite well here - = you > > > > might have a bond over 2 NICs with > > > > different tx_prepare() and which one to call might be not clear til= l > > > > actual PMD tx_burst() is invoked. > > > > > > > > > > > > > > In theory, it might get even worse if we make this opaque instead= of > > > > transparent and standardized: > > > > > One PMD might reset out_ip checksum to 0x0000, and another PMD mi= ght > > > > reset it to 0xFFFF. > > > > > > > > > > > > > > I can only see one solution: > > > > > We need to standardize on common minimum requirements for how to > > > > prepare packets for each TX offload. > > > > > > > > If we can make each and every vendor to agree here - that definitel= y > > > > will help to simplify things quite a bit. > > > > > > An API is more than a function name and parameters. > > > It also has preconditions and postconditions. > > > > > > All major NIC vendors are contributing to DPDK. > > > It should be possible to reach consensus for reasonable minimum requi= rements > > for offloads. > > > Hardware- and driver-specific exceptions can be documented with the o= ffload > > flag, or with rte_eth_rx/tx_burst(), like the note to > > > rte_eth_rx_burst(): > > > "Some drivers using vector instructions require that nb_pkts is divis= ible by > > 4 or 8, depending on the driver implementation." > > > > If we introduce a rule that everyone supposed to follow and then straig= htway > > allow people to have a 'documented exceptions', > > for me it means like 'no rule' in practice. > > A 'documented exceptions' approach might work if you have 5 different P= MDs to > > support, but not when you have 50+. > > No-one would write an app with possible 10 different exception cases in= his > > head. > > Again, with such approach we can forget about backward compatibility. > > I think we already had this discussion before, my opinion remains the s= ame > > here - > > 'documented exceptions' approach is a way to trouble. >=20 > The "minimum requirements" should be the lowest common denominator of all= NICs. > Exceptions should be extremely few, for outlier NICs that still want to p= rovide an offload and its driver is unable to live up to the > minimum requirements. > Any exception should require techboard approval. If a NIC/driver does not= support the "minimum requirements" for an offload > feature, it is not allowed to claim support for that offload feature, or = needs to seek approval for an exception. >=20 > As another option for NICs not supporting the minimum requirements of an = offload feature, we could introduce offload flags with > finer granularity. E.g. one offload flag for "gold standard" TX checksum = update (where the packet's checksum field can have any > value), and another offload flag for "silver standard" TX checksum update= (where the packet's checksum field must have a > precomputed value). Actually yes, I was thinking in the same direction - we need some extra API= to allow user to distinguish.=20 Probably we can do something like that: a new API for the ethdev call that = would take as a parameter TX offloads bitmap and in return specify would it need to modify contents o= f packet to support these offloads or not. Something like: int rte_ethdev_tx_offload_pkt_mod_required(unt64_t tx_offloads)=20 For the majority of the drivers that satisfy these "minimum requirements" c= orresponding devops entry will be empty and we'll always return 0, otherwise PMD has to provide= a proper devop. Then again, it would be up to the user, to determine can he pass same packe= t to 2 different NICs or not.=20 I suppose it is similar to what you were talking about? > For reference, consider RSS, where the feature support flags have very hi= gh granularity. >=20 > > > > > You mention the bonding driver, which is a good example. > > > The rte_eth_tx_burst() documentation has a note about the API postcon= dition > > exception for the bonding driver: > > > "This function must not modify mbufs (including packets data) unless = the > > refcnt is 1. An exception is the bonding PMD, [...], mbufs > > > may be modified." > > > > For me, what we've done for bonding tx_prepare/tx_burst() is a really b= ad > > example. > > Initial agreement and design choice was that tx_burst() should not modi= fy > > contents of the packets > > (that actually was one of the reasons why tx_prepare() was introduced). > > The only reason I agreed on that exception - because I couldn't come-up= with > > something less uglier. > > > > Actually, these problems with bonding PMD made me to start thinking tha= t > > current > > tx_prepare/tx_burst approach might need to be reconsidered somehow. >=20 > In cases where a preceding call to tx_prepare() is required, how is it wo= rse modifying the packet in tx_burst() than modifying the > packet in tx_prepare()? >=20 > Both cases violate the postcondition that packets are not modified at egr= ess. >=20 > > > > > > Then we can probably have one common tx_prepare() for all vendors ;= ) > > > > > > Yes, that would be the goal. > > > More realistically, the ethdev layer could perform the common checks,= and > > only the non-conforming drivers would have to implement > > > their specific tweaks. > > > > Hmm, but that's what we have right now: > > - fields in mbuf and packet data that user has to fill correctly and de= v > > specific tx_prepare(). > > How what you suggest will differ then? >=20 > You're 100 % right here. We could move more checks into the ethdev layer,= specifically checks related to the "minimum > requirements". >=20 > > And how it will help let say with bonding PMD situation, or with TX-ing= of the > > same packet over 2 different NICs? >=20 > The bonding driver is broken. > It can only be fixed by not violating the egress postcondition in either = tx_burst() or tx_prepare(). > "Minimum requirements" might help doing that. >=20 > > > > > If we don't standardize the meaning of the offload flags, the applica= tion > > developers cannot trust them! > > > I'm afraid this is the current situation - application developers eit= her > > test with specific NIC hardware, or don't use the offload features. > > > > Well, I have used TX offloads through several projects, it worked quite= well. >=20 > That is good to hear. > And I don't oppose to that. >=20 > In this discussion, I am worried about the roadmap direction for DPDK. > I oppose to the concept of requiring calling tx_prepare() before calling = tx_burst() when using offload. I think it is conceptually wrong, > and breaks the egress postcondition. > I propose "minimum requirements" as a better solution. >=20 > > Though have to admit, never have to use TX offloads together with our b= onding > > PMD. > >