]> git.droids-corp.org - dpdk.git/commitdiff
net/ngbe: fix Rx by initializing packet buffer early
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 9 Feb 2022 10:42:02 +0000 (18:42 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 11 Feb 2022 12:49:12 +0000 (13:49 +0100)
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 <jiawenwu@trustnetic.com>
drivers/net/ngbe/base/ngbe_dummy.h
drivers/net/ngbe/base/ngbe_hw.c
drivers/net/ngbe/base/ngbe_hw.h
drivers/net/ngbe/base/ngbe_type.h
drivers/net/ngbe/ngbe_ethdev.c

index 61b0d82bfb715d6eb462139f957698ce6cd98116..d74c9f7b54c0cd8319e8833bb7907aacdd9ec880 100644 (file)
@@ -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;
index 0716357725bf45ae98add2817cf173d7c7c7111d..0b22ea0fb322952b381f93ae10f266459cd44677 100644 (file)
@@ -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;
 
index ad7e8fc2d9c764cd85829fb06129a6a2d7a1ba07..b32cf87ff426542f1739bbb60291249943e5c627 100644 (file)
@@ -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);
index 12847b72729cc0b916e4cb22b0a12c0d813a4af6..269e087d50d4971d956c05b0337ee7746656cf72 100644 (file)
@@ -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;
index 0d66c32551fb13f45df150cee006c569ac97ae28..180489ce38a57aa9f627dafa7ce0957f2e944b6a 100644 (file)
@@ -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);