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 ECD544326F for ; Thu, 2 Nov 2023 14:13:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E66D342D45; Thu, 2 Nov 2023 14:13:42 +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 197F7402E3 for ; Thu, 2 Nov 2023 14:13:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698930820; 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=q8VGy3hlqLh9mVBLdzuR0Mng2o9GCKfdIFa83+/SZO0=; b=OV/INSycXwuepYFOTItIp0KpuH5pNMMoLUfCqpGhIVdrEBCOVNaGbfzbYK0dYdCHu0+Y6C m5D30KblUMmoXQ6TMaDFkfn7SEG3OBCAd3k34U7MXXB7MPLPeLaKFFXayIfc7+78v2xzsQ skGu6fHB1ubWf+jlB7kKzwFkbDFuOCM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-ImrWp1QUMQOjdU4YQd3zsA-1; Thu, 02 Nov 2023 09:13:39 -0400 X-MC-Unique: ImrWp1QUMQOjdU4YQd3zsA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BB53382BA80; Thu, 2 Nov 2023 13:13:38 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07D5B492BFA; Thu, 2 Nov 2023 13:13:37 +0000 (UTC) From: Kevin Traynor To: Jiawen Wu Cc: dpdk stable Subject: patch 'net/ngbe: fix flow control' has been queued to stable release 21.11.6 Date: Thu, 2 Nov 2023 13:11:24 +0000 Message-ID: <20231102131254.315947-18-ktraynor@redhat.com> In-Reply-To: <20231102131254.315947-1-ktraynor@redhat.com> References: <20231102131254.315947-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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.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 11/08/23. 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/51451e5516b4b0dd4320f8fb58f388cc83b88b0d Thanks. Kevin --- >From 51451e5516b4b0dd4320f8fb58f388cc83b88b0d Mon Sep 17 00:00:00 2001 From: Jiawen Wu Date: Thu, 28 Sep 2023 17:47:50 +0800 Subject: [PATCH] net/ngbe: fix flow control [ upstream commit d19fa5a1f447244aa961a3cc8c52c9024f9109ab ] Fix flow control high/low water limit. Fixes: f40e9f0e2278 ("net/ngbe: support flow control") Signed-off-by: Jiawen Wu --- drivers/net/ngbe/base/ngbe_type.h | 40 ++++++++++++++ drivers/net/ngbe/ngbe_ethdev.c | 89 +++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h index 015f484e8f..8f87398c17 100644 --- a/drivers/net/ngbe/base/ngbe_type.h +++ b/drivers/net/ngbe/base/ngbe_type.h @@ -111,4 +111,44 @@ struct ngbe_fc_info { }; +/* Flow Control Data Sheet defined values + * Calculation and defines taken from 802.1bb Annex O + */ +/* BitTimes (BT) conversion */ +#define NGBE_BT2KB(BT) (((BT) + (8 * 1024 - 1)) / (8 * 1024)) +#define NGBE_B2BT(BT) ((BT) * 8) + +/* Calculate Delay to respond to PFC */ +#define NGBE_PFC_D 672 + +/* Calculate Cable Delay */ +#define NGBE_CABLE_DC 5556 /* Delay Copper */ + +/* Calculate Interface Delay */ +#define NGBE_PHY_D 12800 +#define NGBE_MAC_D 4096 +#define NGBE_XAUI_D (2 * 1024) + +#define NGBE_ID (NGBE_MAC_D + NGBE_XAUI_D + NGBE_PHY_D) + +/* Calculate Delay incurred from higher layer */ +#define NGBE_HD 6144 + +/* Calculate PCI Bus delay for low thresholds */ +#define NGBE_PCI_DELAY 10000 + +/* Calculate delay value in bit times */ +#define NGBE_DV(_max_frame_link, _max_frame_tc) \ + ((36 * \ + (NGBE_B2BT(_max_frame_link) + \ + NGBE_PFC_D + \ + (2 * NGBE_CABLE_DC) + \ + (2 * NGBE_ID) + \ + NGBE_HD) / 25 + 1) + \ + 2 * NGBE_B2BT(_max_frame_tc)) + +#define NGBE_LOW_DV(_max_frame_tc) \ + (2 * ((2 * NGBE_B2BT(_max_frame_tc) + \ + (36 * NGBE_PCI_DELAY / 25) + 1))) + /* Statistics counters collected by the MAC */ /* PB[] RxTx */ diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 4c927379d7..1e755f03a5 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -91,4 +91,5 @@ static int ngbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev); static void ngbe_dev_interrupt_handler(void *param); static void ngbe_configure_msix(struct rte_eth_dev *dev); +static void ngbe_pbthresh_set(struct rte_eth_dev *dev); #define NGBE_SET_HWSTRIP(h, q) do {\ @@ -1021,4 +1022,5 @@ ngbe_dev_start(struct rte_eth_dev *dev) hw->mac.setup_pba(hw); + ngbe_pbthresh_set(dev); ngbe_configure_port(dev); @@ -2341,4 +2343,91 @@ ngbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) } +/* Additional bittime to account for NGBE framing */ +#define NGBE_ETH_FRAMING 20 + +/* + * ngbe_fc_hpbthresh_set - calculate high water mark for flow control + * + * @dv_id: device interface delay + * @pb: packet buffer to calculate + */ +static s32 +ngbe_fc_hpbthresh_set(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); + u32 max_frame_size, tc, dv_id, rx_pb; + s32 kb, marker; + + /* Calculate max LAN frame size */ + max_frame_size = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK); + tc = max_frame_size + NGBE_ETH_FRAMING; + + /* Calculate delay value for device */ + dv_id = NGBE_DV(tc, tc); + + /* Loopback switch introduces additional latency */ + if (pci_dev->max_vfs) + dv_id += NGBE_B2BT(tc); + + /* Delay value is calculated in bit times convert to KB */ + kb = NGBE_BT2KB(dv_id); + rx_pb = rd32(hw, NGBE_PBRXSIZE) >> 10; + + marker = rx_pb - kb; + + /* It is possible that the packet buffer is not large enough + * to provide required headroom. In this case throw an error + * to user and do the best we can. + */ + if (marker < 0) { + PMD_DRV_LOG(WARNING, "Packet Buffer can not provide enough headroom to support flow control."); + marker = tc + 1; + } + + return marker; +} + +/* + * ngbe_fc_lpbthresh_set - calculate low water mark for flow control + * + * @dv_id: device interface delay + */ +static s32 +ngbe_fc_lpbthresh_set(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + u32 max_frame_size, tc, dv_id; + s32 kb; + + /* Calculate max LAN frame size */ + max_frame_size = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK); + tc = max_frame_size + NGBE_ETH_FRAMING; + + /* Calculate delay value for device */ + dv_id = NGBE_LOW_DV(tc); + + /* Delay value is calculated in bit times convert to KB */ + kb = NGBE_BT2KB(dv_id); + + return kb; +} + +/* + * ngbe_pbthresh_setup - calculate and setup high low water marks + */ +static void +ngbe_pbthresh_set(struct rte_eth_dev *dev) +{ + struct ngbe_hw *hw = ngbe_dev_hw(dev); + + hw->fc.high_water = ngbe_fc_hpbthresh_set(dev); + hw->fc.low_water = ngbe_fc_lpbthresh_set(dev); + + /* Low water marks must not be larger than high water marks */ + if (hw->fc.low_water > hw->fc.high_water) + hw->fc.low_water = 0; +} + int ngbe_dev_rss_reta_update(struct rte_eth_dev *dev, -- 2.41.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-11-02 13:09:41.323904618 +0000 +++ 0018-net-ngbe-fix-flow-control.patch 2023-11-02 13:09:40.798163287 +0000 @@ -1 +1 @@ -From d19fa5a1f447244aa961a3cc8c52c9024f9109ab Mon Sep 17 00:00:00 2001 +From 51451e5516b4b0dd4320f8fb58f388cc83b88b0d Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit d19fa5a1f447244aa961a3cc8c52c9024f9109ab ] + @@ -9 +10,0 @@ -Cc: stable@dpdk.org @@ -18 +19 @@ -index 37be288a74..8a7d2cd331 100644 +index 015f484e8f..8f87398c17 100644 @@ -21 +22 @@ -@@ -117,4 +117,44 @@ struct ngbe_fc_info { +@@ -111,4 +111,44 @@ struct ngbe_fc_info { @@ -67 +68 @@ -index af77081d9a..a83fdc002a 100644 +index 4c927379d7..1e755f03a5 100644 @@ -76 +77 @@ -@@ -1038,4 +1039,5 @@ ngbe_dev_start(struct rte_eth_dev *dev) +@@ -1021,4 +1022,5 @@ ngbe_dev_start(struct rte_eth_dev *dev) @@ -82 +83 @@ -@@ -2387,4 +2389,91 @@ ngbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) +@@ -2341,4 +2343,91 @@ ngbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)