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 2B0C04569C for ; Wed, 24 Jul 2024 13:34:20 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24CF1433B7; Wed, 24 Jul 2024 13:34:20 +0200 (CEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mails.dpdk.org (Postfix) with ESMTP id 37809433CA for ; Wed, 24 Jul 2024 13:34:19 +0200 (CEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42122ac2f38so4782535e9.1 for ; Wed, 24 Jul 2024 04:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721820859; x=1722425659; 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=0BGVw6Xi035d5w1wZOgUNxtaRC5qrKSIH+kuHNlzTVA=; b=CDYaiMyXEpUp8NBb9CqYDNZVeBjuGjkoEwlgrEwUqyyztubvcRZ5WcxhFqUeseoTqW 1oZ5Q9EB+G3roWPLjaQ6LeQHES3ecLeAuJKl0aO2vk3ARHhUI1C/EuGKxHlhgwlAxJ9o qxkFAXgAu7Mk3Fqyst7kv93TLhVHrZ0/UIj6WxvJ0kMC0UTRSwpuhA4rK+FtMxam2Hsd LvxOEbtCbo2abL7yp33ngFAnQJ49ZtQVtyoOxptKqFmjqzj4OfOjvrzRyiGKAupEpObb 2eYLu02eGzrjFCm2btvY8WsdrUnfs21JivJ6e61HVsvL7osKWJVOMSF+UrDIrUpC3hMU 4DWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721820859; x=1722425659; 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=0BGVw6Xi035d5w1wZOgUNxtaRC5qrKSIH+kuHNlzTVA=; b=baOsQpvZUChVGs+3HbKeDYkXhCIpuM/2nyIOzrnHNQk2zu4ABu60nK5x3wXYrGldAq YA8ALOmZ5Od11PBFRdazHMkDwk/xvz4x8ek05oCCwIb5InQN0+TEEBnOKKFQCzEm6kLY drgpjnFonm7B+j0IbWMTo2ErOg/eJQQxBT24yXwEnRfaYTxGnVGQX/L/K2KjrvEZe72V dzqvUZ4r+ERU0ecxkzsiT25b/IG9SyZy9x5s86x2mECGHqS8vo1qFkWi9nwKxzm2k/vx yCSjCbgTemtK2b3nqjbnUFtSnh4nqlNNTdsyXIlMyApnRP5UwFzyjKBJJH0hqxDtGf/3 8LSw== X-Forwarded-Encrypted: i=1; AJvYcCWdxykqWJ+x7A1eb6mniWtB+v6Fs1NZWqxprbyXeA2ly5yftSxCDBRuqJIPRTNPPWfNu6JeRe0ErjpObYNLis4= X-Gm-Message-State: AOJu0Yz1bCzqJUi9OqxZxhqIv2XHJ7wGwpn2AWl/DT58jTJRWMKpTKwi cPH661JE0iloQjfpbejF54xrPtJvGKahwlgNoX8xoSxZ7/7uUsVe X-Google-Smtp-Source: AGHT+IGToYOOhfgXm/W7I6svPLXAeYRV7xc2TxdjlkLF8BKzEb0Sis0VtBY9HYKalHmGoExd49QyEw== X-Received: by 2002:a7b:c303:0:b0:426:5cc7:82f with SMTP id 5b1f17b1804b1-427f9a13d02mr12705085e9.13.1721820858586; Wed, 24 Jul 2024 04:34:18 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:7aef:1aaa:3dff:d546]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f935dc1bsm26073385e9.6.2024.07.24.04.34.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 04:34:18 -0700 (PDT) From: luca.boccassi@gmail.com To: Chengwen Feng Cc: Jie Hai , dpdk stable Subject: patch 'net/hns3: check Rx DMA address alignmnent' has been queued to stable release 22.11.6 Date: Wed, 24 Jul 2024 12:32:58 +0100 Message-Id: <20240724113318.616754-20-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240724113318.616754-1-luca.boccassi@gmail.com> References: <20240715152704.2229503-86-luca.boccassi@gmail.com> <20240724113318.616754-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 22.11.6 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/24. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/1c9c96641a99c4becca1670a1b07e89dd432c887 Thanks. Luca Boccassi --- >From 1c9c96641a99c4becca1670a1b07e89dd432c887 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Mon, 15 Jul 2024 10:04:39 +0800 Subject: [PATCH] net/hns3: check Rx DMA address alignmnent [ upstream commit d14c995b775a9b5910c51c3ab3685b320736f3f6 ] The network engine has Rx DMA address align requirement, if this requirement is violated, the Rx function will be abnormal. The detail requirement is: 1) For HIP08 platform, require 64-bytes alignment. 2) For later platform, require 128-bytes alignment. The setup Rx DMA address exists both on the control and data plane, to ensure performance, the alignment check is added only on the control plane. Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") Signed-off-by: Chengwen Feng Signed-off-by: Jie Hai --- drivers/net/hns3/hns3_ethdev.c | 2 ++ drivers/net/hns3/hns3_ethdev.h | 8 ++++++++ drivers/net/hns3/hns3_ethdev_vf.c | 2 ++ drivers/net/hns3/hns3_rxtx.c | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 6672b80c21..2c32f48af6 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -2742,6 +2742,7 @@ hns3_get_capability(struct hns3_hw *hw) hw->rss_info.ipv6_sctp_offload_supported = false; hw->udp_cksum_mode = HNS3_SPECIAL_PORT_SW_CKSUM_MODE; pf->support_multi_tc_pause = false; + hw->rx_dma_addr_align = HNS3_RX_DMA_ADDR_ALIGN_64; return 0; } @@ -2762,6 +2763,7 @@ hns3_get_capability(struct hns3_hw *hw) hw->rss_info.ipv6_sctp_offload_supported = true; hw->udp_cksum_mode = HNS3_SPECIAL_PORT_HW_CKSUM_MODE; pf->support_multi_tc_pause = true; + hw->rx_dma_addr_align = HNS3_RX_DMA_ADDR_ALIGN_128; return 0; } diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 9f95a523ec..1afe4c4ff7 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -485,6 +485,9 @@ struct hns3_queue_intr { #define HNS3_PKTS_DROP_STATS_MODE1 0 #define HNS3_PKTS_DROP_STATS_MODE2 1 +#define HNS3_RX_DMA_ADDR_ALIGN_128 128 +#define HNS3_RX_DMA_ADDR_ALIGN_64 64 + struct hns3_hw { struct rte_eth_dev_data *data; void *io_base; @@ -552,6 +555,11 @@ struct hns3_hw { * direction. */ uint8_t min_tx_pkt_len; + /* + * The required alignment of the DMA address of the RX buffer. + * See HNS3_RX_DMA_ADDR_ALIGN_XXX for available values. + */ + uint16_t rx_dma_addr_align; struct hns3_queue_intr intr; /* diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 9e5d69f485..6d7654206b 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -788,6 +788,7 @@ hns3vf_get_capability(struct hns3_hw *hw) hw->min_tx_pkt_len = HNS3_HIP08_MIN_TX_PKT_LEN; hw->rss_info.ipv6_sctp_offload_supported = false; hw->promisc_mode = HNS3_UNLIMIT_PROMISC_MODE; + hw->rx_dma_addr_align = HNS3_RX_DMA_ADDR_ALIGN_64; return 0; } @@ -805,6 +806,7 @@ hns3vf_get_capability(struct hns3_hw *hw) hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2; hw->rss_info.ipv6_sctp_offload_supported = true; hw->promisc_mode = HNS3_LIMIT_PROMISC_MODE; + hw->rx_dma_addr_align = HNS3_RX_DMA_ADDR_ALIGN_128; return 0; } diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index 4343a3e4df..16cb174f4d 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -273,12 +273,27 @@ hns3_free_all_queues(struct rte_eth_dev *dev) hns3_free_tx_queues(dev); } +static int +hns3_check_rx_dma_addr(struct hns3_hw *hw, uint64_t dma_addr) +{ + uint64_t rem; + + rem = dma_addr & (hw->rx_dma_addr_align - 1); + if (rem > 0) { + hns3_err(hw, "The IO address of the beginning of the mbuf data " + "must be %u-byte aligned", hw->rx_dma_addr_align); + return -EINVAL; + } + return 0; +} + static int hns3_alloc_rx_queue_mbufs(struct hns3_hw *hw, struct hns3_rx_queue *rxq) { struct rte_mbuf *mbuf; uint64_t dma_addr; uint16_t i; + int ret; for (i = 0; i < rxq->nb_rx_desc; i++) { mbuf = rte_mbuf_raw_alloc(rxq->mb_pool); @@ -299,6 +314,12 @@ hns3_alloc_rx_queue_mbufs(struct hns3_hw *hw, struct hns3_rx_queue *rxq) dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(mbuf)); rxq->rx_ring[i].addr = dma_addr; rxq->rx_ring[i].rx.bd_base_info = 0; + + ret = hns3_check_rx_dma_addr(hw, dma_addr); + if (ret != 0) { + hns3_rx_queue_release_mbufs(rxq); + return ret; + } } return 0; -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2024-07-24 12:29:22.315438309 +0100 +++ 0020-net-hns3-check-Rx-DMA-address-alignmnent.patch 2024-07-24 12:29:20.767026050 +0100 @@ -1 +1 @@ -From d14c995b775a9b5910c51c3ab3685b320736f3f6 Mon Sep 17 00:00:00 2001 +From 1c9c96641a99c4becca1670a1b07e89dd432c887 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d14c995b775a9b5910c51c3ab3685b320736f3f6 ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org @@ -29 +30 @@ -index 327f6fe908..ec1251cb7e 100644 +index 6672b80c21..2c32f48af6 100644 @@ -32 +33 @@ -@@ -2738,6 +2738,7 @@ hns3_get_capability(struct hns3_hw *hw) +@@ -2742,6 +2742,7 @@ hns3_get_capability(struct hns3_hw *hw) @@ -40 +41 @@ -@@ -2758,6 +2759,7 @@ hns3_get_capability(struct hns3_hw *hw) +@@ -2762,6 +2763,7 @@ hns3_get_capability(struct hns3_hw *hw) @@ -49 +50 @@ -index a6b652455b..799b61038a 100644 +index 9f95a523ec..1afe4c4ff7 100644 @@ -52 +53 @@ -@@ -487,6 +487,9 @@ struct hns3_queue_intr { +@@ -485,6 +485,9 @@ struct hns3_queue_intr { @@ -62 +63 @@ -@@ -554,6 +557,11 @@ struct hns3_hw { +@@ -552,6 +555,11 @@ struct hns3_hw { @@ -75 +76 @@ -index b83d5b9589..ea9225cd26 100644 +index 9e5d69f485..6d7654206b 100644 @@ -78 +79 @@ -@@ -707,6 +707,7 @@ hns3vf_get_capability(struct hns3_hw *hw) +@@ -788,6 +788,7 @@ hns3vf_get_capability(struct hns3_hw *hw) @@ -86 +87 @@ -@@ -724,6 +725,7 @@ hns3vf_get_capability(struct hns3_hw *hw) +@@ -805,6 +806,7 @@ hns3vf_get_capability(struct hns3_hw *hw) @@ -95 +96 @@ -index d7f9cff547..5941b966e0 100644 +index 4343a3e4df..16cb174f4d 100644