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 4555FA04A6 for ; Wed, 9 Feb 2022 11:35:43 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CE96141144; Wed, 9 Feb 2022 11:35:42 +0100 (CET) Received: from smtpproxy21.qq.com (smtpbg702.qq.com [203.205.195.102]) by mails.dpdk.org (Postfix) with ESMTP id 5D48C41141 for ; Wed, 9 Feb 2022 11:35:41 +0100 (CET) X-QQ-mid: bizesmtp37t1644402935tsua25pq Received: from wxdbg.localdomain.com (unknown [183.129.236.74]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 09 Feb 2022 18:35:34 +0800 (CST) X-QQ-SSF: 01400000002000F0L000B00A0000000 X-QQ-FEAT: b174WCRqV1hY+KIxd3MeKXnjVdrI0fNonyHVXh2c2icza9+19BoO1gvk+cmEp 9E1G6MRy+Czn1w7WEbf5qsLP7vXajvmab+1u/gFF67P1Pagq/aeOfILlNNXmFozaONy9khY Jj/NWoJiJZ6NYn6bAOAZ0yU21mjJAFSopGyqgzzEOs4e98iDuQjuM//W7+y5lF211btcneb 7GMQdJPRS4ZG1oLoBF8G8DettZD2xs6m1UR/WVFF+X12goOGMdnvLtlSIYD5Ns6ZkHJCZhI dPkzmBd0mKQj54NwI0w+02DdAOKQAkjUiJEnn8FSoPA6KvimTBU4t2Hpzye08kPFqWQQa4W 5dj272LxoqXT3dNCjGw4NCAOaq4zmdn0Z/n2fP7hK7IO+6QVqA= X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu , stable@dpdk.org Subject: [PATCH v2 01/12] net/ngbe: fix failed to receive packets Date: Wed, 9 Feb 2022 18:42:02 +0800 Message-Id: <20220209104213.602728-2-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220209104213.602728-1-jiawenwu@trustnetic.com> References: <20220209104213.602728-1-jiawenwu@trustnetic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 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 Initialize Rx packet buffer before starting RxTx, ensure to receive packets. Fixes: 62fc35e63d0e ("net/ngbe: support Rx queue start/stop") Cc: stable@dpdk.org Signed-off-by: Jiawen Wu --- drivers/net/ngbe/base/ngbe_dummy.h | 4 ++++ drivers/net/ngbe/base/ngbe_hw.c | 27 +++++++++++++++++++++++++++ drivers/net/ngbe/base/ngbe_hw.h | 2 ++ drivers/net/ngbe/base/ngbe_type.h | 7 +++++++ drivers/net/ngbe/ngbe_ethdev.c | 1 + 5 files changed, 41 insertions(+) diff --git a/drivers/net/ngbe/base/ngbe_dummy.h b/drivers/net/ngbe/base/ngbe_dummy.h index 61b0d82bfb..d74c9f7b54 100644 --- a/drivers/net/ngbe/base/ngbe_dummy.h +++ b/drivers/net/ngbe/base/ngbe_dummy.h @@ -114,6 +114,9 @@ static inline s32 ngbe_mac_get_link_capabilities_dummy(struct ngbe_hw *TUP0, { return NGBE_ERR_OPS_DUMMY; } +static inline void ngbe_setup_pba_dummy(struct ngbe_hw *TUP0) +{ +} static inline s32 ngbe_mac_led_on_dummy(struct ngbe_hw *TUP0, u32 TUP1) { return NGBE_ERR_OPS_DUMMY; @@ -298,6 +301,7 @@ static inline void ngbe_init_ops_dummy(struct ngbe_hw *hw) hw->mac.setup_link = ngbe_mac_setup_link_dummy; hw->mac.check_link = ngbe_mac_check_link_dummy; hw->mac.get_link_capabilities = ngbe_mac_get_link_capabilities_dummy; + hw->mac.setup_pba = ngbe_setup_pba_dummy; hw->mac.led_on = ngbe_mac_led_on_dummy; hw->mac.led_off = ngbe_mac_led_off_dummy; hw->mac.set_rar = ngbe_mac_set_rar_dummy; diff --git a/drivers/net/ngbe/base/ngbe_hw.c b/drivers/net/ngbe/base/ngbe_hw.c index 0716357725..0b22ea0fb3 100644 --- a/drivers/net/ngbe/base/ngbe_hw.c +++ b/drivers/net/ngbe/base/ngbe_hw.c @@ -1609,6 +1609,30 @@ void ngbe_set_mac_anti_spoofing(struct ngbe_hw *hw, bool enable, int vf) wr32(hw, NGBE_POOLTXASMAC, pfvfspoof); } +/** + * ngbe_set_pba - Initialize Rx packet buffer + * @hw: pointer to hardware structure + * @headroom: reserve n KB of headroom + **/ +void ngbe_set_pba(struct ngbe_hw *hw) +{ + u32 rxpktsize = hw->mac.rx_pb_size; + u32 txpktsize, txpbthresh; + + /* Reserve 256 KB of headroom */ + rxpktsize -= 256; + + rxpktsize <<= 10; + wr32(hw, NGBE_PBRXSIZE, rxpktsize); + + /* Only support an equally distributed Tx packet buffer strategy. */ + txpktsize = NGBE_PBTXSIZE_MAX; + txpbthresh = (txpktsize / 1024) - NGBE_TXPKT_SIZE_MAX; + + wr32(hw, NGBE_PBTXSIZE, txpktsize); + wr32(hw, NGBE_PBTXDMATH, txpbthresh); +} + /** * ngbe_set_vlan_anti_spoofing - Enable/Disable VLAN anti-spoofing * @hw: pointer to hardware structure @@ -1907,6 +1931,8 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw) mac->check_link = ngbe_check_mac_link_em; mac->setup_link = ngbe_setup_mac_link_em; + mac->setup_pba = ngbe_set_pba; + /* Manageability interface */ mac->init_thermal_sensor_thresh = ngbe_init_thermal_sensor_thresh; mac->check_overtemp = ngbe_mac_check_overtemp; @@ -1928,6 +1954,7 @@ s32 ngbe_init_ops_pf(struct ngbe_hw *hw) mac->mcft_size = NGBE_EM_MC_TBL_SIZE; mac->vft_size = NGBE_EM_VFT_TBL_SIZE; mac->num_rar_entries = NGBE_EM_RAR_ENTRIES; + mac->rx_pb_size = NGBE_EM_RX_PB_SIZE; mac->max_rx_queues = NGBE_EM_MAX_RX_QUEUES; mac->max_tx_queues = NGBE_EM_MAX_TX_QUEUES; diff --git a/drivers/net/ngbe/base/ngbe_hw.h b/drivers/net/ngbe/base/ngbe_hw.h index ad7e8fc2d9..b32cf87ff4 100644 --- a/drivers/net/ngbe/base/ngbe_hw.h +++ b/drivers/net/ngbe/base/ngbe_hw.h @@ -13,6 +13,7 @@ #define NGBE_EM_RAR_ENTRIES 32 #define NGBE_EM_MC_TBL_SIZE 32 #define NGBE_EM_VFT_TBL_SIZE 128 +#define NGBE_EM_RX_PB_SIZE 42 /*KB*/ s32 ngbe_init_hw(struct ngbe_hw *hw); s32 ngbe_start_hw(struct ngbe_hw *hw); @@ -44,6 +45,7 @@ s32 ngbe_update_mc_addr_list(struct ngbe_hw *hw, u8 *mc_addr_list, ngbe_mc_addr_itr func, bool clear); s32 ngbe_disable_sec_rx_path(struct ngbe_hw *hw); s32 ngbe_enable_sec_rx_path(struct ngbe_hw *hw); +void ngbe_set_pba(struct ngbe_hw *hw); s32 ngbe_setup_fc_em(struct ngbe_hw *hw); s32 ngbe_fc_enable(struct ngbe_hw *hw); diff --git a/drivers/net/ngbe/base/ngbe_type.h b/drivers/net/ngbe/base/ngbe_type.h index 12847b7272..269e087d50 100644 --- a/drivers/net/ngbe/base/ngbe_type.h +++ b/drivers/net/ngbe/base/ngbe_type.h @@ -11,6 +11,9 @@ #define NGBE_FRAME_SIZE_MAX (9728) /* Maximum frame size, +FCS */ #define NGBE_FRAME_SIZE_DFT (1522) /* Default frame size, +FCS */ #define NGBE_NUM_POOL (32) +#define NGBE_PBRXSIZE_MAX 0x00080000 /* 512KB Packet Buffer */ +#define NGBE_PBTXSIZE_MAX 0x00005000 /* 20KB Packet Buffer */ +#define NGBE_TXPKT_SIZE_MAX 0xA /* Max Tx Packet size */ #define NGBE_MAX_QP (8) #define NGBE_MAX_UTA 128 @@ -269,6 +272,9 @@ struct ngbe_mac_info { s32 (*get_link_capabilities)(struct ngbe_hw *hw, u32 *speed, bool *autoneg); + /* Packet Buffer manipulation */ + void (*setup_pba)(struct ngbe_hw *hw); + /* LED */ s32 (*led_on)(struct ngbe_hw *hw, u32 index); s32 (*led_off)(struct ngbe_hw *hw, u32 index); @@ -311,6 +317,7 @@ struct ngbe_mac_info { u32 mcft_size; u32 vft_size; u32 num_rar_entries; + u32 rx_pb_size; u32 max_tx_queues; u32 max_rx_queues; bool get_link_status; diff --git a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c index 0d66c32551..180489ce38 100644 --- a/drivers/net/ngbe/ngbe_ethdev.c +++ b/drivers/net/ngbe/ngbe_ethdev.c @@ -1004,6 +1004,7 @@ ngbe_dev_start(struct rte_eth_dev *dev) goto error; } + hw->mac.setup_pba(hw); ngbe_configure_port(dev); err = ngbe_dev_rxtx_start(dev); -- 2.21.0.windows.1