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 34EF845DAF; Wed, 27 Nov 2024 00:18:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C1C6D40EE3; Wed, 27 Nov 2024 00:18:12 +0100 (CET) Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by mails.dpdk.org (Postfix) with ESMTP id 15034402A7 for ; Wed, 27 Nov 2024 00:18:11 +0100 (CET) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-724d8422f37so4599832b3a.2 for ; Tue, 26 Nov 2024 15:18:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1732663090; x=1733267890; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f/WN+kGMJ7Ejogg9uASq5CLRELLibRL+BioTFqEq94c=; b=PwTdVOTjklScy0W5U9jv1R0NmpzwEPhUlLRkkXbLJJnTnAtcRN003lPQRv7i+qNra9 yeK0p7WikYB7NfLEMZB73kVZJvbeEv5iYNO+a3YCIQ88pk3GAmxydAgC48YQoZRlBe4z pGTXQTsP6zG5iGm9GcoJ7e5xpvD7MmPfx4r36FF5gtb933hiQgCbJ8fDDtuOeFU/zCEv PJl2Q30TMPzaZ4ZXFgnZVvqyUNIYQC8UtkQfZN4V5BK8cLr7QD9Q8PX/Yg5sp3GUhebC ckT3lQUUFiwsepIN679lD9zvC4Yw2wUKqgCqRLM1bTNmK8qqwBnEnjRbeVpOtEuMbu+8 ZrSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732663090; x=1733267890; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f/WN+kGMJ7Ejogg9uASq5CLRELLibRL+BioTFqEq94c=; b=WGMi5N2JwWPqfTub+mfFd10ZkQXlD/9vzmDJecdpifkKzP5P94ZZNKiXGoTnhtE69i AMUDJVS+8SfX+wEqpIUfYZMECaZ960MqrJogInWF1Rw8qcwUGkRN3n23M8XOGgtstNVC EMJPTiAFzo9MdLudGwhE/1n1xz5Utx53TdZ/WA8Me4TLrlXvRy+lnyJfQTr5nrqAgQsw ETiAAmgPU2jSN/LJbAMrhdiyFYgrukGkdTyH2/J2chE9P4VbCzsz4Y93GT8OCdO92BRG ReKo9ZkB1XwuCP2qjoCrpbBJzrECQgpbglI/2dvVun+AXe+b0sfYBJQHXLKIU1/byVTF /+Gg== X-Gm-Message-State: AOJu0YwcaApzdgC5WwD/iH3mejxJQMYOQQnstMpQqcvS48m4wU+7pq8x K10D72+RF4iGVoMpysJVmmx6Iei5DCfRBc3LcHwVDb4X4EJuFCoM0FsEeV92IpUTibOePMNgUFl M X-Gm-Gg: ASbGncvNG925CM8h/wYebya24cUcdmdlkknCQmQ8H8vBvW5ic/2Wi4CIlQntDA1MnAk /TmcBEZbgiVFO4BTeQjau2ILkdrQKr12nIX0ER/chCX7lLvxVCb3Q4NVWdrUVSxUg41phvI5HXm RqkuxC7a2nmYPezu5pMFtLsOz6g/xUJm+Zt4ZyhJa6iL8/CZKlSpHc97S0ztpolo5gQrnBhHKMZ SdwG8pnH0mne5ar+ZYT2HU5B4WHkLy6L0InDIQqKnjeVojpzA1nS2NDZedOcbTtCkNASGCE/Lc5 cjdaKz9LgwgQTZhQ8jz5b0Iaifg= X-Google-Smtp-Source: AGHT+IHlWptG0ixMQgisDAoWnDQ5wN0lxhlHYtZEVf+NmgNbKjmUPkurRrGDBXL59dJ0ZdIP68Jc1Q== X-Received: by 2002:a05:6a00:4b12:b0:71e:4196:ddb2 with SMTP id d2e1a72fcca58-7253001536bmr1339688b3a.9.1732663089926; Tue, 26 Nov 2024 15:18:09 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fbcc3f62ddsm7989574a12.70.2024.11.26.15.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2024 15:18:09 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Jie Hai Subject: [RFC] net/hns3: clarify handling of crc reinsert Date: Tue, 26 Nov 2024 15:17:11 -0800 Message-ID: <20241126231758.133355-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718114806.577298-4-haijie1@huawei.com> References: <20240718114806.577298-4-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Use a static assert rather than a comment to express why there will be space in the buffer. Use memcpy() rather than rte_memcpy(). Signed-off-by: Stephen Hemminger --- drivers/net/hns3/hns3_rxtx.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 861511547d..9272584d24 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2449,6 +2449,15 @@ hns3_need_recalculate_crc(struct hns3_rx_queue *rxq, struct rte_mbuf *m) return true; } +/* + * The hns3 driver requires that mbuf size must be at least 512B. + * When CRC is stripped by hardware, the pkt_len must be less than + * or equal to 60B. Therefore, the space of the mbuf is enough + * to insert the CRC. + */ +static_assert(HNS3_KEEP_CRC_OK_MIN_PKT_LEN < HNS3_MIN_BD_BUF_SIZE, + "buffer size too small to insert CRC"); + static inline void hns3_recalculate_crc(struct rte_mbuf *m) { @@ -2459,18 +2468,13 @@ hns3_recalculate_crc(struct rte_mbuf *m) m->data_len, RTE_NET_CRC32_ETH); /* - * The hns3 driver requires that mbuf size must be at least 512B. - * When CRC is stripped by hardware, the pkt_len must be less than - * or equal to 60B. Therefore, the space of the mbuf is enough - * to insert the CRC. - * - * In addition, after CRC is stripped by hardware, pkt_len and data_len - * do not contain the CRC length. Therefore, after CRC data is appended - * by PMD again, both pkt_len and data_len add the CRC length. + * After CRC is stripped by hardware, pkt_len and data_len do not contain the CRC length. + * Therefore, after CRC data is appended by PMD again. */ append_data = rte_pktmbuf_append(m, RTE_NET_CRC32_ETH); - /* The CRC data is binary data and does not care about the byte order. */ - rte_memcpy(append_data, (void *)&crc, RTE_NET_CRC32_ETH); + + /* CRC data is binary data and does not care about the byte order. */ + memcpy(append_data, &crc, RTE_NET_CRC32_ETH); } uint16_t -- 2.45.2