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 6C835A0350 for ; Mon, 21 Feb 2022 16:39:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6878A41147; Mon, 21 Feb 2022 16:39:51 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id C0EF1410F2 for ; Mon, 21 Feb 2022 16:39:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645457990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SWpjc98lf13oRUnvOOWJPnanabgPwxU5oBwXhtngVJw=; b=bR2/usDZcHVs1bnM/47E7QOy6gblqXtx7XrrMR2EZStKJzCb1pQN6HwDepGoGQ4EGtZbvE SZ/9Y880rZy5ZSNZ+4j1TOslVAX/7R13GYEtdm52h+x9UrxMnYp6SlWMguHM6ppUb1gAaE /vk6KhB8sG9EpmMj9QpIKNauyZD6Lz4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-o1TiSPSTNwuG_c8Dppv2pw-1; Mon, 21 Feb 2022 10:39:46 -0500 X-MC-Unique: o1TiSPSTNwuG_c8Dppv2pw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0CDF801ADA; Mon, 21 Feb 2022 15:39:45 +0000 (UTC) Received: from rh.Home (unknown [10.39.195.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23AA37E2EA; Mon, 21 Feb 2022 15:39:44 +0000 (UTC) From: Kevin Traynor To: "Min Hu (Connor)" Cc: dpdk stable Subject: patch 'net/hns3: fix vector Rx/Tx when PTP enabled' has been queued to stable release 21.11.1 Date: Mon, 21 Feb 2022 15:34:52 +0000 Message-Id: <20220221153625.152324-103-ktraynor@redhat.com> In-Reply-To: <20220221153625.152324-1-ktraynor@redhat.com> References: <20220221153625.152324-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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 21.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/26/22. 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/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/6492c9875d0b337d8f338f8020356d195fcd04e4 Thanks. Kevin --- >From 6492c9875d0b337d8f338f8020356d195fcd04e4 Mon Sep 17 00:00:00 2001 From: "Min Hu (Connor)" Date: Mon, 17 Jan 2022 10:43:02 +0800 Subject: [PATCH] net/hns3: fix vector Rx/Tx when PTP enabled [ upstream commit 3ca3dcd6510127162aaef359cf5b28684693da07 ] If hardware supports IEEE 1588 PTP, PTP capability will be set. Currently, vec and sve burst is unsupported when PTP capability is set. For sake of Rx/Tx performance, IEEE 1588 PTP is not supported in sve or vec burst mode. When enabling IEEE 1588 PTP, Rx/Tx burst mode should be simple or common. Rx/Tx burst mode could be set like this, for example: -a 0000:35:00.0,rx_func_hint=common,tx_func_hint=common This patch supports vec and sve burst when PTP is disabled. And only support simple or common burst When PTP is enabled. Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") Signed-off-by: Min Hu (Connor) --- doc/guides/nics/hns3.rst | 5 +++++ drivers/net/hns3/hns3_ethdev.c | 8 +------- drivers/net/hns3/hns3_ptp.c | 1 + drivers/net/hns3/hns3_rxtx.c | 29 +++++++++++++++++------------ drivers/net/hns3/hns3_rxtx_vec.c | 20 ++++++++++++-------- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst index 5f68a10ecf..791c9cc2ed 100644 --- a/doc/guides/nics/hns3.rst +++ b/doc/guides/nics/hns3.rst @@ -291,4 +291,9 @@ by kernel mode hns3 ethdev driver. VF is not supported when PF is driven by DPDK driver. +For sake of Rx/Tx performance, IEEE 1588 is not supported when using vec or +sve burst function. When enabling IEEE 1588, Rx/Tx burst mode should be +simple or common. It is recommended that enable IEEE 1588 before ethdev +start. In this way, the correct Rx/Tx burst function can be selected. + Build with ICC is not supported yet. X86-32, Power8, ARMv7 and BSD are not supported yet. diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 3b897492d3..ef13d31d19 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -228,15 +228,9 @@ out: } -static bool -hns3_is_1588_event_type(uint32_t event_type) -{ - return (event_type == HNS3_VECTOR0_EVENT_PTP); -} - static void hns3_clear_event_cause(struct hns3_hw *hw, uint32_t event_type, uint32_t regclr) { if (event_type == HNS3_VECTOR0_EVENT_RST || - hns3_is_1588_event_type(event_type)) + event_type == HNS3_VECTOR0_EVENT_PTP) hns3_write_dev(hw, HNS3_MISC_RESET_STS_REG, regclr); else if (event_type == HNS3_VECTOR0_EVENT_MBX) diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c index 9a829d7011..1442241a4e 100644 --- a/drivers/net/hns3/hns3_ptp.c +++ b/drivers/net/hns3/hns3_ptp.c @@ -126,4 +126,5 @@ hns3_timesync_enable(struct rte_eth_dev *dev) if (pf->ptp_enable) return 0; + hns3_warn(hw, "note: please ensure Rx/Tx burst mode is simple or common when enabling PTP!"); rte_spinlock_lock(&hw->lock); diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c index c86aeb2366..c43131cac6 100644 --- a/drivers/net/hns3/hns3_rxtx.c +++ b/drivers/net/hns3/hns3_rxtx.c @@ -2389,12 +2389,12 @@ hns3_rx_alloc_buffer(struct hns3_rx_queue *rxq) } -static inline void +static void hns3_rx_ptp_timestamp_handle(struct hns3_rx_queue *rxq, struct rte_mbuf *mbuf, - volatile struct hns3_desc *rxd) + uint64_t timestamp) { struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(rxq->hns); - uint64_t timestamp = rte_le_to_cpu_64(rxd->timestamp); - mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP | RTE_MBUF_F_RX_IEEE1588_TMST; + mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP | + RTE_MBUF_F_RX_IEEE1588_TMST; if (hns3_timestamp_rx_dynflag > 0) { *RTE_MBUF_DYNFIELD(mbuf, hns3_timestamp_dynfield_offset, @@ -2470,5 +2470,6 @@ hns3_recv_pkts_simple(void *rx_queue, if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) - hns3_rx_ptp_timestamp_handle(rxq, rxm, rxdp); + hns3_rx_ptp_timestamp_handle(rxq, rxm, + rte_le_to_cpu_64(rxdp->timestamp)); dma_addr = rte_mbuf_data_iova_default(nmb); @@ -2541,4 +2542,5 @@ hns3_recv_scattered_pkts(void *rx_queue, struct rte_eth_dev *dev; uint32_t bd_base_info; + uint64_t timestamp; uint32_t l234_info; uint32_t gro_size; @@ -2650,4 +2652,7 @@ hns3_recv_scattered_pkts(void *rx_queue, rxe->mbuf = nmb; + if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) + timestamp = rte_le_to_cpu_64(rxdp->timestamp); + dma_addr = rte_cpu_to_le_64(rte_mbuf_data_iova_default(nmb)); rxdp->rx.bd_base_info = 0; @@ -2672,5 +2677,5 @@ hns3_recv_scattered_pkts(void *rx_queue, if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) - hns3_rx_ptp_timestamp_handle(rxq, first_seg, rxdp); + hns3_rx_ptp_timestamp_handle(rxq, first_seg, timestamp); /* @@ -4045,5 +4050,5 @@ hns3_tx_setup_4bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) { #define PER_LOOP_NUM 4 - const uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); + uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); uint64_t dma_addr; uint32_t i; @@ -4056,4 +4061,6 @@ hns3_tx_setup_4bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) txdp->tx.type_cs_vlan_tso_len = 0; txdp->tx.ol_type_vlan_len_msec = 0; + if (unlikely((*pkts)->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)) + bd_flag |= BIT(HNS3_TXD_TSYN_B); txdp->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(bd_flag); } @@ -4063,5 +4070,5 @@ static inline void hns3_tx_setup_1bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) { - const uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); + uint16_t bd_flag = BIT(HNS3_TXD_VLD_B) | BIT(HNS3_TXD_FE_B); uint64_t dma_addr; @@ -4072,4 +4079,6 @@ hns3_tx_setup_1bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) txdp->tx.type_cs_vlan_tso_len = 0; txdp->tx.ol_type_vlan_len_msec = 0; + if (unlikely((*pkts)->ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST)) + bd_flag |= BIT(HNS3_TXD_TSYN_B); txdp->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(bd_flag); } @@ -4313,8 +4322,4 @@ hns3_tx_check_simple_support(struct rte_eth_dev *dev) uint64_t offloads = dev->data->dev_conf.txmode.offloads; - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - if (hns3_dev_get_support(hw, PTP)) - return false; - return (offloads == (offloads & RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE)); } diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c index 455110361a..73f0ab6bc8 100644 --- a/drivers/net/hns3/hns3_rxtx_vec.c +++ b/drivers/net/hns3/hns3_rxtx_vec.c @@ -18,8 +18,6 @@ hns3_tx_check_vec_support(struct rte_eth_dev *dev) { struct rte_eth_txmode *txmode = &dev->data->dev_conf.txmode; - - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - if (hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_pf *pf = &hns->pf; /* Only support RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE */ @@ -27,4 +25,8 @@ hns3_tx_check_vec_support(struct rte_eth_dev *dev) return -ENOTSUP; + /* Vec is not supported when PTP enabled */ + if (pf->ptp_enable) + return -ENOTSUP; + return 0; } @@ -233,8 +235,6 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) uint64_t offloads_mask = RTE_ETH_RX_OFFLOAD_TCP_LRO | RTE_ETH_RX_OFFLOAD_VLAN; - - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - if (hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; + struct hns3_adapter *hns = dev->data->dev_private; + struct hns3_pf *pf = &hns->pf; if (dev->data->scattered_rx) @@ -250,4 +250,8 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) return -ENOTSUP; + /* Vec is not supported when PTP enabled */ + if (pf->ptp_enable) + return -ENOTSUP; + return 0; } -- 2.34.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2022-02-21 15:22:46.843086725 +0000 +++ 0103-net-hns3-fix-vector-Rx-Tx-when-PTP-enabled.patch 2022-02-21 15:22:44.208704389 +0000 @@ -1 +1 @@ -From 3ca3dcd6510127162aaef359cf5b28684693da07 Mon Sep 17 00:00:00 2001 +From 6492c9875d0b337d8f338f8020356d195fcd04e4 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 3ca3dcd6510127162aaef359cf5b28684693da07 ] + @@ -18 +19,0 @@ -Cc: stable@dpdk.org