diff --git a/0001-net-hns3-adjust-MAC-address-logging.patch b/0001-net-hns3-adjust-MAC-address-logging.patch deleted file mode 100644 index 0258b34..0000000 --- a/0001-net-hns3-adjust-MAC-address-logging.patch +++ /dev/null @@ -1,396 +0,0 @@ -From 8124e9841e2563dc916d4c8b0fce83d1ae470b85 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Thu, 10 Dec 2020 20:48:42 +0800 -Subject: [PATCH 001/189] net/hns3: adjust MAC address logging - -Here the printing of MAC addresses is adjusted. After the -modification, only some bytes of the MAC address are -displayed. - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 53 +++++++++++++++++++++++---------------- - drivers/net/hns3/hns3_ethdev.h | 2 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 32 +++++++++++------------ - 3 files changed, 49 insertions(+), 38 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2011378..d6d3f03 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -102,6 +102,15 @@ static int hns3_remove_mc_addr(struct hns3_hw *hw, - static int hns3_restore_fec(struct hns3_hw *hw); - static int hns3_query_dev_fec_info(struct rte_eth_dev *dev); - -+void hns3_ether_format_addr(char *buf, uint16_t size, -+ const struct rte_ether_addr *ether_addr) -+{ -+ snprintf(buf, size, "%02X:**:**:**:%02X:%02X", -+ ether_addr->addr_bytes[0], -+ ether_addr->addr_bytes[4], -+ ether_addr->addr_bytes[5]); -+} -+ - static void - hns3_pf_disable_irq0(struct hns3_hw *hw) - { -@@ -1449,7 +1458,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - /* check if mac addr is valid */ - if (!rte_is_valid_assigned_ether_addr(mac_addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Add unicast mac addr err! addr(%s) invalid", - mac_str); -@@ -1489,7 +1498,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return -ENOSPC; - } - -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr); -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, mac_addr); - - /* check if we just hit the duplicate */ - if (ret == 0) { -@@ -1515,7 +1524,7 @@ hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - addr = &hw->mc_addrs[i]; - /* Check if there are duplicate addresses */ - if (rte_is_same_ether_addr(addr, mac_addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to add mc mac addr, same addrs" - "(%s) is added by the set_mc_mac_addr_list " -@@ -1526,7 +1535,7 @@ hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - ret = hns3_add_mc_addr(hw, mac_addr); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mc mac addr(%s), ret = %d", - mac_str, ret); -@@ -1542,7 +1551,7 @@ hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - ret = hns3_remove_mc_addr(hw, mac_addr); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to remove mc mac addr(%s), ret = %d", - mac_str, ret); -@@ -1576,7 +1585,7 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - - if (ret) { - rte_spinlock_unlock(&hw->lock); -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str, - ret); -@@ -1599,7 +1608,7 @@ hns3_remove_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - /* check if mac addr is valid */ - if (!rte_is_valid_assigned_ether_addr(mac_addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "remove unicast mac addr err! addr(%s) invalid", - mac_str); -@@ -1635,7 +1644,7 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - ret = hns3_remove_uc_addr_common(hw, mac_addr); - rte_spinlock_unlock(&hw->lock); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to remove mac addr(%s), ret = %d", mac_str, - ret); -@@ -1666,7 +1675,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - if (default_addr_setted) { - ret = hns3_remove_uc_addr_common(hw, oaddr); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - oaddr); - hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", - mac_str, ret); -@@ -1677,7 +1686,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - - ret = hns3_add_uc_addr_common(hw, mac_addr); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to set mac addr(%s): %d", mac_str, ret); - goto err_add_uc_addr; -@@ -1699,7 +1708,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - err_pause_addr_cfg: - ret_val = hns3_remove_uc_addr_common(hw, mac_addr); - if (ret_val) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_warn(hw, - "Failed to roll back to del setted mac addr(%s): %d", -@@ -1710,7 +1719,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - if (rm_succes) { - ret_val = hns3_add_uc_addr_common(hw, oaddr); - if (ret_val) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - oaddr); - hns3_warn(hw, - "Failed to restore old uc mac addr(%s): %d", -@@ -1746,7 +1755,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - - if (ret) { - err = ret; -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to %s mac addr(%s) index:%d " - "ret = %d.", del ? "remove" : "restore", -@@ -1795,7 +1804,7 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - /* Check if mac addr is valid */ - if (!rte_is_multicast_ether_addr(mac_addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mc mac addr, addr(%s) invalid", - mac_str); -@@ -1823,7 +1832,7 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - if (ret) { - if (ret == -ENOSPC) - hns3_err(hw, "mc mac vlan table is full"); -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mc mac addr(%s): %d", mac_str, ret); - } -@@ -1842,7 +1851,7 @@ hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - /* Check if mac addr is valid */ - if (!rte_is_multicast_ether_addr(mac_addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to rm mc mac addr, addr(%s) invalid", - mac_str); -@@ -1870,7 +1879,7 @@ hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - } - - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to rm mc mac addr(%s): %d", mac_str, ret); - } -@@ -1899,7 +1908,7 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - for (i = 0; i < nb_mc_addr; i++) { - addr = &mc_addr_set[i]; - if (!rte_is_multicast_ether_addr(addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, - "failed to set mc mac addr, addr(%s) invalid.", -@@ -1910,7 +1919,7 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - /* Check if there are duplicate addresses */ - for (j = i + 1; j < nb_mc_addr; j++) { - if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) { -- rte_ether_format_addr(mac_str, -+ hns3_ether_format_addr(mac_str, - RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to set mc mac addr, " -@@ -1927,7 +1936,7 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - for (j = 0; j < HNS3_UC_MACADDR_NUM; j++) { - if (rte_is_same_ether_addr(addr, - &hw->data->mac_addrs[j])) { -- rte_ether_format_addr(mac_str, -+ hns3_ether_format_addr(mac_str, - RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to set mc mac addr, " -@@ -2101,7 +2110,7 @@ hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - ret = hns3_add_mc_addr(hw, addr); - if (ret) { - err = ret; -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_dbg(hw, "%s mc mac addr: %s failed for pf: ret = %d", - del ? "Remove" : "Restore", mac_str, ret); -@@ -6160,7 +6169,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - eth_addr = (struct rte_ether_addr *)hw->mac.mac_addr; - if (!rte_is_valid_assigned_ether_addr(eth_addr)) { - rte_eth_random_addr(hw->mac.mac_addr); -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - (struct rte_ether_addr *)hw->mac.mac_addr); - hns3_warn(hw, "default mac_addr from firmware is an invalid " - "unicast address, using random MAC address %s", -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 4c40df1..31f78a1 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -935,6 +935,8 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, - bool hns3_is_reset_pending(struct hns3_adapter *hns); - bool hns3vf_is_reset_pending(struct hns3_adapter *hns); - void hns3_update_link_status(struct hns3_hw *hw); -+void hns3_ether_format_addr(char *buf, uint16_t size, -+ const struct rte_ether_addr *ether_addr); - - static inline bool - is_reset_pending(struct hns3_adapter *hns) -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 0366b9d..f09cabc 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -170,7 +170,7 @@ hns3vf_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - HNS3_MBX_MAC_VLAN_UC_ADD, mac_addr->addr_bytes, - RTE_ETHER_ADDR_LEN, false, NULL, 0); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add uc mac addr(%s), ret = %d", - mac_str, ret); -@@ -190,7 +190,7 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, - false, NULL, 0); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add uc mac addr(%s), ret = %d", - mac_str, ret); -@@ -210,7 +210,7 @@ hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - addr = &hw->mc_addrs[i]; - /* Check if there are duplicate addresses */ - if (rte_is_same_ether_addr(addr, mac_addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to add mc mac addr, same addrs" - "(%s) is added by the set_mc_mac_addr_list " -@@ -221,7 +221,7 @@ hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - ret = hns3vf_add_mc_mac_addr(hw, mac_addr); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mc mac addr(%s), ret = %d", - mac_str, ret); -@@ -256,7 +256,7 @@ hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - - rte_spinlock_unlock(&hw->lock); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str, - ret); -@@ -283,7 +283,7 @@ hns3vf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - - rte_spinlock_unlock(&hw->lock); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to remove mac addr(%s), ret = %d", - mac_str, ret); -@@ -324,12 +324,12 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, - * -EPREM to VF driver through mailbox. - */ - if (ret == -EPERM) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - old_addr); - hns3_warn(hw, "Has permanet mac addr(%s) for vf", - mac_str); - } else { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to set mac addr(%s) for vf: %d", - mac_str, ret); -@@ -366,7 +366,7 @@ hns3vf_configure_mac_addr(struct hns3_adapter *hns, bool del) - - if (ret) { - err = ret; -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to %s mac addr(%s) index:%d " - "ret = %d.", del ? "remove" : "restore", -@@ -388,7 +388,7 @@ hns3vf_add_mc_mac_addr(struct hns3_hw *hw, - mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false, - NULL, 0); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to add mc mac addr(%s) for vf: %d", - mac_str, ret); -@@ -409,7 +409,7 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, - mac_addr->addr_bytes, RTE_ETHER_ADDR_LEN, false, - NULL, 0); - if (ret) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "Failed to remove mc mac addr(%s) for vf: %d", - mac_str, ret); -@@ -439,7 +439,7 @@ hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw, - for (i = 0; i < nb_mc_addr; i++) { - addr = &mc_addr_set[i]; - if (!rte_is_multicast_ether_addr(addr)) { -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, - "failed to set mc mac addr, addr(%s) invalid.", -@@ -450,7 +450,7 @@ hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw, - /* Check if there are duplicate addresses */ - for (j = i + 1; j < nb_mc_addr; j++) { - if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) { -- rte_ether_format_addr(mac_str, -+ hns3_ether_format_addr(mac_str, - RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to set mc mac addr, " -@@ -467,7 +467,7 @@ hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw, - for (j = 0; j < HNS3_VF_UC_MACADDR_NUM; j++) { - if (rte_is_same_ether_addr(addr, - &hw->data->mac_addrs[j])) { -- rte_ether_format_addr(mac_str, -+ hns3_ether_format_addr(mac_str, - RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "failed to set mc mac addr, " -@@ -550,7 +550,7 @@ hns3vf_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - ret = hns3vf_add_mc_mac_addr(hw, addr); - if (ret) { - err = ret; -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); - hns3_err(hw, "Failed to %s mc mac addr: %s for vf: %d", - del ? "Remove" : "Restore", mac_str, ret); -@@ -2468,7 +2468,7 @@ hns3vf_check_default_mac_change(struct hns3_hw *hw) - ret = rte_is_same_ether_addr(&hw->data->mac_addrs[0], hw_mac); - if (!ret) { - rte_ether_addr_copy(hw_mac, &hw->data->mac_addrs[0]); -- rte_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - &hw->data->mac_addrs[0]); - hns3_warn(hw, "Default MAC address has been changed to:" - " %s by the host PF kernel ethdev driver", --- -2.7.4 - diff --git a/0002-net-hns3-fix-FEC-state-query.patch b/0002-net-hns3-fix-FEC-state-query.patch deleted file mode 100644 index 8c130ce..0000000 --- a/0002-net-hns3-fix-FEC-state-query.patch +++ /dev/null @@ -1,128 +0,0 @@ -From e435d9efcb10bc24f528aacee20a25061a7fb70f Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 10 Dec 2020 20:48:43 +0800 -Subject: [PATCH 002/189] net/hns3: fix FEC state query - -As FEC is not supported below 10 Gbps, -CMD(HNS3_OPC_CONFIG_FEC_MODE) offered from -Firmware read will return fail in 10 Gbps device. - -This patch will prevent read this CMD when below 10 Gbps, -as this is non-sense. - -Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 40 ++++++++++++++++++++++++++-------------- - drivers/net/hns3/hns3_ethdev.h | 2 ++ - 2 files changed, 28 insertions(+), 14 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index d6d3f03..7c34e38 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -100,7 +100,7 @@ static int hns3_add_mc_addr(struct hns3_hw *hw, - static int hns3_remove_mc_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); - static int hns3_restore_fec(struct hns3_hw *hw); --static int hns3_query_dev_fec_info(struct rte_eth_dev *dev); -+static int hns3_query_dev_fec_info(struct hns3_hw *hw); - - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr) -@@ -3010,13 +3010,6 @@ hns3_get_capability(struct hns3_hw *hw) - device_id == HNS3_DEV_ID_200G_RDMA) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_DCB_B, 1); - -- ret = hns3_query_dev_fec_info(eth_dev); -- if (ret) { -- PMD_INIT_LOG(ERR, -- "failed to query FEC information, ret = %d", ret); -- return ret; -- } -- - /* Get PCI revision id */ - ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, - HNS3_PCI_REVISION_ID); -@@ -3148,8 +3141,15 @@ hns3_get_configuration(struct hns3_hw *hw) - } - - ret = hns3_get_board_configuration(hw); -- if (ret) -+ if (ret) { - PMD_INIT_LOG(ERR, "failed to get board configuration: %d", ret); -+ return ret; -+ } -+ -+ ret = hns3_query_dev_fec_info(hw); -+ if (ret) -+ PMD_INIT_LOG(ERR, -+ "failed to query FEC information, ret = %d", ret); - - return ret; - } -@@ -5797,6 +5797,16 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) - struct hns3_cmd_desc desc; - int ret; - -+ /* -+ * CMD(HNS3_OPC_CONFIG_FEC_MODE) read is not supported -+ * in device of link speed -+ * below 10 Gbps. -+ */ -+ if (hw->mac.link_speed < ETH_SPEED_NUM_10G) { -+ *state = 0; -+ return 0; -+ } -+ - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CONFIG_FEC_MODE, true); - req = (struct hns3_config_fec_cmd *)desc.data; - ret = hns3_cmd_send(hw, &desc, 1); -@@ -6003,14 +6013,14 @@ hns3_restore_fec(struct hns3_hw *hw) - } - - static int --hns3_query_dev_fec_info(struct rte_eth_dev *dev) -+hns3_query_dev_fec_info(struct hns3_hw *hw) - { -- struct hns3_adapter *hns = dev->data->dev_private; -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); -- struct hns3_pf *pf = &hns->pf; -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(hns); -+ struct rte_eth_dev *eth_dev = hns->eth_dev; - int ret; - -- ret = hns3_fec_get(dev, &pf->fec_mode); -+ ret = hns3_fec_get(eth_dev, &pf->fec_mode); - if (ret) - hns3_err(hw, "query device FEC info failed, ret = %d", ret); - -@@ -6096,6 +6106,8 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -+ hns->eth_dev = eth_dev; -+ - eth_dev->process_private = (struct hns3_process_private *) - rte_zmalloc_socket("hns3_filter_list", - sizeof(struct hns3_process_private), -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 31f78a1..8d6b8cd 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -743,6 +743,8 @@ struct hns3_adapter { - struct hns3_vf vf; - }; - -+ struct rte_eth_dev *eth_dev; -+ - bool rx_simple_allowed; - bool rx_vec_allowed; - bool tx_simple_allowed; --- -2.7.4 - diff --git a/0003-net-hns3-fix-build-with-SVE.patch b/0003-net-hns3-fix-build-with-SVE.patch deleted file mode 100644 index 3a28f65..0000000 --- a/0003-net-hns3-fix-build-with-SVE.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 0114915c86b2cadefe4c0323f28868c4f11be2f2 Mon Sep 17 00:00:00 2001 -From: Ruifeng Wang -Date: Tue, 12 Jan 2021 02:57:05 +0000 -Subject: [PATCH 003/189] net/hns3: fix build with SVE -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Building with SVE extension enabled stopped with error: - - error: ACLE function ‘svwhilelt_b64_s32’ requires ISA extension ‘sve’ - 18 | #define PG64_256BIT svwhilelt_b64(0, 4) - -This is caused by unintentional cflags reset. -Fixed the issue by not touching cflags, and using flags defined by -compiler. - -Fixes: 952ebacce4f2 ("net/hns3: support SVE Rx") -Cc: stable@dpdk.org - -Signed-off-by: Ruifeng Wang -Reviewed-by: Honnappa Nagarahalli ---- - drivers/net/hns3/hns3_rxtx.c | 4 ++-- - drivers/net/hns3/meson.build | 1 - - 2 files changed, 2 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 88d3bab..5ac36b3 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -10,7 +10,7 @@ - #include - #include - #include --#if defined(RTE_ARCH_ARM64) && defined(CC_SVE_SUPPORT) -+#if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_SVE) - #include - #endif - -@@ -2467,7 +2467,7 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, - static bool - hns3_check_sve_support(void) - { --#if defined(RTE_ARCH_ARM64) && defined(CC_SVE_SUPPORT) -+#if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_SVE) - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SVE)) - return true; - #endif -diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build -index 45cee34..5674d98 100644 ---- a/drivers/net/hns3/meson.build -+++ b/drivers/net/hns3/meson.build -@@ -32,7 +32,6 @@ deps += ['hash'] - if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64') - sources += files('hns3_rxtx_vec.c') - if cc.get_define('__ARM_FEATURE_SVE', args: machine_args) != '' -- cflags = ['-DCC_SVE_SUPPORT'] - sources += files('hns3_rxtx_vec_sve.c') - endif - endif --- -2.7.4 - diff --git a/0004-net-hns3-fix-interception-with-flow-director.patch b/0004-net-hns3-fix-interception-with-flow-director.patch deleted file mode 100644 index c651c93..0000000 --- a/0004-net-hns3-fix-interception-with-flow-director.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 7a6944f354740866bc35cf716ce3979999b7396e Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Wed, 6 Jan 2021 11:46:27 +0800 -Subject: [PATCH 004/189] net/hns3: fix interception with flow director - -The rte_fdir_conf structure has deprecated and users need -to use the specified rule parameters of rte_flow structure -when configure a flow rule. As a result, it is incorrectly -used in the rte_flow API. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index ee6ec15..f303df4 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1208,11 +1208,6 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, - RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Fdir not supported in VF"); - -- if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) -- return rte_flow_error_set(error, ENOTSUP, -- RTE_FLOW_ERROR_TYPE_HANDLE, NULL, -- "fdir_conf.mode isn't perfect"); -- - step_mngr.items = first_items; - step_mngr.count = ARRAY_SIZE(first_items); - for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { --- -2.7.4 - diff --git a/0005-net-hns3-fix-xstats-with-id-and-names.patch b/0005-net-hns3-fix-xstats-with-id-and-names.patch deleted file mode 100644 index 311f37f..0000000 --- a/0005-net-hns3-fix-xstats-with-id-and-names.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 094b7303b76507e93d4b8e1eaa7e0c819362b67a Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 6 Jan 2021 11:46:28 +0800 -Subject: [PATCH 005/189] net/hns3: fix xstats with id and names - -Currently, validity check for ids and values in the -hns3_dev_xstats_get_by_id API is incorrect, which will -cause a problem. Namely, if the ID range of the xstats -stats item does not include the basic stats item, the -app can not obtain the corresponding xstats statistics -in hns3_dev_xstats_get_by_id. - -Similarly, the hns3_dev_xstats_get_names_by_id interface -also has a problem. - -Although the input parameter verification code cannot be -executed due to the implementation of the ethdev framework -interface, the driver needs to ensure the correctness of -the input parameters. - -Fixes: 8839c5e202f3 ("net/hns3: support device stats") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_stats.c | 24 ++++++++++++++++++++++-- - 1 file changed, 22 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 91168ac..1597af3 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -933,9 +933,13 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, - uint32_t i; - int ret; - -- if (ids == NULL || size < cnt_stats) -+ if (ids == NULL && values == NULL) - return cnt_stats; - -+ if (ids == NULL) -+ if (size < cnt_stats) -+ return cnt_stats; -+ - /* Update tqp stats by read register */ - ret = hns3_update_tqp_stats(hw); - if (ret) { -@@ -957,6 +961,15 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, - return -EINVAL; - } - -+ if (ids == NULL && values != NULL) { -+ for (i = 0; i < cnt_stats; i++) -+ memcpy(&values[i], &values_copy[i].value, -+ sizeof(values[i])); -+ -+ rte_free(values_copy); -+ return cnt_stats; -+ } -+ - for (i = 0; i < size; i++) { - if (ids[i] >= cnt_stats) { - hns3_err(hw, "ids[%u] (%" PRIx64 ") is invalid, " -@@ -1005,9 +1018,16 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - uint64_t len; - uint32_t i; - -- if (ids == NULL || xstats_names == NULL) -+ if (xstats_names == NULL) - return cnt_stats; - -+ if (ids == NULL) { -+ if (size < cnt_stats) -+ return cnt_stats; -+ -+ return hns3_dev_xstats_get_names(dev, xstats_names, cnt_stats); -+ } -+ - len = cnt_stats * sizeof(struct rte_eth_xstat_name); - names_copy = rte_zmalloc("hns3_xstats_names", len, 0); - if (names_copy == NULL) { --- -2.7.4 - diff --git a/0006-net-hns3-fix-error-code-in-xstats.patch b/0006-net-hns3-fix-error-code-in-xstats.patch deleted file mode 100644 index 0679b9f..0000000 --- a/0006-net-hns3-fix-error-code-in-xstats.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 8cbd6fc2895cdbb0a64c2d2a31e53ff4b0608752 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 6 Jan 2021 11:46:29 +0800 -Subject: [PATCH 006/189] net/hns3: fix error code in xstats - -The ethdev API has processed the failure to obtain -xstats statistics. Therefore, driver should return -an error code instead of 0 in 'hns3_dev_xstats_get' -API. - -Fixes: 8839c5e202f3 ("net/hns3: support device stats") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_stats.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 1597af3..42ec9b8 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -739,9 +739,9 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - if (!hns->is_vf) { - /* Update Mac stats */ - ret = hns3_query_update_mac_stats(dev); -- if (ret) { -+ if (ret < 0) { - hns3_err(hw, "Update Mac stats fail : %d", ret); -- return 0; -+ return ret; - } - - /* Get MAC stats from hw->hw_xstats.mac_stats struct */ --- -2.7.4 - diff --git a/0007-net-hns3-fix-Rx-Tx-errors-stats.patch b/0007-net-hns3-fix-Rx-Tx-errors-stats.patch deleted file mode 100644 index 7ff3cf3..0000000 --- a/0007-net-hns3-fix-Rx-Tx-errors-stats.patch +++ /dev/null @@ -1,119 +0,0 @@ -From d799cf475d2d9b22264cef9c4447e48671e8d76a Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 6 Jan 2021 11:46:30 +0800 -Subject: [PATCH 007/189] net/hns3: fix Rx/Tx errors stats - -Abnormal errors stats in Rx/Tx datapath are statistics -items in driver, and displayed in xstats. They should -be cleared by the rte_eth_xstats_reset api, instead of -the rte_eth_stats_reset. - -Fixes: c4b7d6761d01 ("net/hns3: get Tx abnormal errors in xstats") -Fixes: 521ab3e93361 ("net/hns3: add simple Rx path") -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_stats.c | 59 ++++++++++++++++++++++++++++--------------- - 1 file changed, 39 insertions(+), 20 deletions(-) - -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 42ec9b8..62a712b 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -551,7 +551,6 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - struct hns3_hw *hw = &hns->hw; - struct hns3_cmd_desc desc_reset; - struct hns3_rx_queue *rxq; -- struct hns3_tx_queue *txq; - uint16_t i; - int ret; - -@@ -581,29 +580,15 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - } - } - -- /* Clear the Rx BD errors stats */ -- for (i = 0; i != eth_dev->data->nb_rx_queues; ++i) { -+ /* -+ * Clear soft stats of rx error packet which will be dropped -+ * in driver. -+ */ -+ for (i = 0; i < eth_dev->data->nb_rx_queues; ++i) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq) { - rxq->pkt_len_errors = 0; - rxq->l2_errors = 0; -- rxq->l3_csum_errors = 0; -- rxq->l4_csum_errors = 0; -- rxq->ol3_csum_errors = 0; -- rxq->ol4_csum_errors = 0; -- } -- } -- -- /* Clear the Tx errors stats */ -- for (i = 0; i != eth_dev->data->nb_tx_queues; ++i) { -- txq = eth_dev->data->tx_queues[i]; -- if (txq) { -- txq->over_length_pkt_cnt = 0; -- txq->exceed_limit_bd_pkt_cnt = 0; -- txq->exceed_limit_bd_reassem_fail = 0; -- txq->unsupported_tunnel_pkt_cnt = 0; -- txq->queue_full_cnt = 0; -- txq->pkt_padding_fail_cnt = 0; - } - } - -@@ -1053,6 +1038,38 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - return size; - } - -+static void -+hns3_tqp_dfx_stats_clear(struct rte_eth_dev *dev) -+{ -+ struct hns3_rx_queue *rxq; -+ struct hns3_tx_queue *txq; -+ int i; -+ -+ /* Clear Rx dfx stats */ -+ for (i = 0; i < dev->data->nb_rx_queues; ++i) { -+ rxq = dev->data->rx_queues[i]; -+ if (rxq) { -+ rxq->l3_csum_errors = 0; -+ rxq->l4_csum_errors = 0; -+ rxq->ol3_csum_errors = 0; -+ rxq->ol4_csum_errors = 0; -+ } -+ } -+ -+ /* Clear Tx dfx stats */ -+ for (i = 0; i < dev->data->nb_tx_queues; ++i) { -+ txq = dev->data->tx_queues[i]; -+ if (txq) { -+ txq->over_length_pkt_cnt = 0; -+ txq->exceed_limit_bd_pkt_cnt = 0; -+ txq->exceed_limit_bd_reassem_fail = 0; -+ txq->unsupported_tunnel_pkt_cnt = 0; -+ txq->queue_full_cnt = 0; -+ txq->pkt_padding_fail_cnt = 0; -+ } -+ } -+} -+ - int - hns3_dev_xstats_reset(struct rte_eth_dev *dev) - { -@@ -1068,6 +1085,8 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) - /* Clear reset stats */ - memset(&hns->hw.reset.stats, 0, sizeof(struct hns3_reset_stats)); - -+ hns3_tqp_dfx_stats_clear(dev); -+ - if (hns->is_vf) - return 0; - --- -2.7.4 - diff --git a/0008-net-hns3-fix-crash-with-multi-process.patch b/0008-net-hns3-fix-crash-with-multi-process.patch deleted file mode 100644 index 8f2d50f..0000000 --- a/0008-net-hns3-fix-crash-with-multi-process.patch +++ /dev/null @@ -1,102 +0,0 @@ -From 8e6c3a65eed79da35189319577235f43a7423612 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Wed, 6 Jan 2021 11:46:31 +0800 -Subject: [PATCH 008/189] net/hns3: fix crash with multi-process - -In current version, procedure of saving eth_dev in -hns3 PMD init will be called more than twice, one -for primary, the other for secondary. That will cause -segmentation fault in Multi-process as eth_dev will -be changed in secondary process, which is different -from one in primary process. - -The initial problem was access to 'rte_eth_devices' -global variable, which is wrong. But current approach -can cause problem for the secondaries, moving 'eth_dev' -to process private can work but before making things -more complex. - -This patch deserted the procedure of saving eth_dev in -hns3 PMD init. Instead, it creates an internal function -that gets "struct hns3_hw" as parameter and it can be -called internally without knowing 'eth_dev'and the -.dev_ops can be wrapper to this. - -Fixes: 2390bf217f4d ("net/hns3: fix FEC state query") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 16 ++++++++++------ - drivers/net/hns3/hns3_ethdev.h | 2 -- - 2 files changed, 10 insertions(+), 8 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7c34e38..90544fe 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5821,10 +5821,9 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) - } - - static int --hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) -+hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) - { - #define QUERY_ACTIVE_SPEED 1 -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_sfp_speed_cmd *resp; - uint32_t tmp_fec_capa; - uint8_t auto_state; -@@ -5885,6 +5884,14 @@ hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) - } - - static int -+hns3_fec_get(struct rte_eth_dev *dev, uint32_t *fec_capa) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ -+ return hns3_fec_get_internal(hw, fec_capa); -+} -+ -+static int - hns3_set_fec_hw(struct hns3_hw *hw, uint32_t mode) - { - struct hns3_config_fec_cmd *req; -@@ -6017,10 +6024,9 @@ hns3_query_dev_fec_info(struct hns3_hw *hw) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(hns); -- struct rte_eth_dev *eth_dev = hns->eth_dev; - int ret; - -- ret = hns3_fec_get(eth_dev, &pf->fec_mode); -+ ret = hns3_fec_get_internal(hw, &pf->fec_mode); - if (ret) - hns3_err(hw, "query device FEC info failed, ret = %d", ret); - -@@ -6106,8 +6112,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- hns->eth_dev = eth_dev; -- - eth_dev->process_private = (struct hns3_process_private *) - rte_zmalloc_socket("hns3_filter_list", - sizeof(struct hns3_process_private), -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 8d6b8cd..31f78a1 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -743,8 +743,6 @@ struct hns3_adapter { - struct hns3_vf vf; - }; - -- struct rte_eth_dev *eth_dev; -- - bool rx_simple_allowed; - bool rx_vec_allowed; - bool tx_simple_allowed; --- -2.7.4 - diff --git a/0009-net-hns3-remove-unnecessary-memset.patch b/0009-net-hns3-remove-unnecessary-memset.patch deleted file mode 100644 index bc0f347..0000000 --- a/0009-net-hns3-remove-unnecessary-memset.patch +++ /dev/null @@ -1,37 +0,0 @@ -From c06b9cd500facfb6a10057490c1ec1090408ff12 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Wed, 6 Jan 2021 11:46:32 +0800 -Subject: [PATCH 009/189] net/hns3: remove unnecessary memset - -The hns3_cmd_desc has memset when setup and the memset -for req is unnecessary. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_rss.c | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c -index e2f0468..b5df374 100644 ---- a/drivers/net/hns3/hns3_rss.c -+++ b/drivers/net/hns3/hns3_rss.c -@@ -633,16 +633,11 @@ hns3_set_rss_tc_mode(struct hns3_hw *hw) - static void - hns3_rss_tuple_uninit(struct hns3_hw *hw) - { -- struct hns3_rss_input_tuple_cmd *req; - struct hns3_cmd_desc desc; - int ret; - - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_RSS_INPUT_TUPLE, false); - -- req = (struct hns3_rss_input_tuple_cmd *)desc.data; -- -- memset(req, 0, sizeof(struct hns3_rss_tuple_cfg)); -- - ret = hns3_cmd_send(hw, &desc, 1); - if (ret) { - hns3_err(hw, "RSS uninit tuple failed %d", ret); --- -2.7.4 - diff --git a/0010-net-hns3-fix-jumbo-frame-flag-condition-for-MTU-set.patch b/0010-net-hns3-fix-jumbo-frame-flag-condition-for-MTU-set.patch deleted file mode 100644 index c2267da..0000000 --- a/0010-net-hns3-fix-jumbo-frame-flag-condition-for-MTU-set.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 2a7fd245e7d1c752bd53df6e0e7967b1dadfe876 Mon Sep 17 00:00:00 2001 -From: Steve Yang -Date: Mon, 18 Jan 2021 07:04:12 +0000 -Subject: [PATCH 010/189] net/hns3: fix jumbo frame flag condition for MTU set - -The jumbo frame uses the 'RTE_ETHER_MAX_LEN' as boundary condition, -but the Ether overhead is larger than 18 when it supports dual VLAN tags. -That will cause the jumbo flag rx offload is wrong when MTU size is -'RTE_ETHER_MTU'. - -This fix will change the boundary condition with 'HSN3_DEFAULT_FRAME_LEN', -that perhaps impacts the cases of the jumbo frame related. - -Fixes: 1f5ca0b460cd ("net/hns3: support some device operations") -Fixes: a5475d61fa34 ("net/hns3: support VF") -Cc: stable@dpdk.org - -Signed-off-by: Steve Yang -Acked-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 2 +- - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 90544fe..bf633a3 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2467,7 +2467,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - } - - rte_spinlock_lock(&hw->lock); -- is_jumbo_frame = frame_size > RTE_ETHER_MAX_LEN ? true : false; -+ is_jumbo_frame = frame_size > HNS3_DEFAULT_FRAME_LEN ? true : false; - frame_size = RTE_MAX(frame_size, HNS3_DEFAULT_FRAME_LEN); - - /* -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index f09cabc..ef03fb1 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -928,7 +928,7 @@ hns3vf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - rte_spinlock_unlock(&hw->lock); - return ret; - } -- if (frame_size > RTE_ETHER_MAX_LEN) -+ if (mtu > RTE_ETHER_MTU) - dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; - else --- -2.7.4 - diff --git a/0011-net-hns3-use-C11-atomics-builtins-for-resetting.patch b/0011-net-hns3-use-C11-atomics-builtins-for-resetting.patch deleted file mode 100644 index 46ccc2d..0000000 --- a/0011-net-hns3-use-C11-atomics-builtins-for-resetting.patch +++ /dev/null @@ -1,209 +0,0 @@ -From ec2a9e9b56f0bfd4d0926c9f59183d682de9670e Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Thu, 14 Jan 2021 21:33:30 +0800 -Subject: [PATCH 011/189] net/hns3: use C11 atomics builtins for resetting - -Use C11 atomic builtins with explicit ordering instead of -rte_atomic ops with the resetting member of hns3_reset_data -structure. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_dcb.c | 5 +++-- - drivers/net/hns3/hns3_ethdev.c | 8 ++++---- - drivers/net/hns3/hns3_ethdev.h | 2 +- - drivers/net/hns3/hns3_ethdev_vf.c | 12 ++++++------ - drivers/net/hns3/hns3_intr.c | 8 ++++---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - 6 files changed, 19 insertions(+), 18 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index fb50179..b32d5af 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -633,7 +633,7 @@ hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q) - * and configured directly to the hardware in the RESET_STAGE_RESTORE - * stage of the reset process. - */ -- if (rte_atomic16_read(&hw->reset.resetting) == 0) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - for (i = 0; i < HNS3_RSS_IND_TBL_SIZE; i++) - rss_cfg->rss_indirection_tbl[i] = - i % hw->alloc_rss_size; -@@ -1562,7 +1562,8 @@ hns3_dcb_configure(struct hns3_adapter *hns) - int ret; - - hns3_dcb_cfg_validate(hns, &num_tc, &map_changed); -- if (map_changed || rte_atomic16_read(&hw->reset.resetting)) { -+ if (map_changed || -+ __atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { - ret = hns3_dcb_info_update(hns, num_tc); - if (ret) { - hns3_err(hw, "dcb info update failed: %d", ret); -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index bf633a3..d0d1d3a 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1017,7 +1017,7 @@ hns3_init_vlan_config(struct hns3_adapter *hns) - * ensure that the hardware configuration remains unchanged before and - * after reset. - */ -- if (rte_atomic16_read(&hw->reset.resetting) == 0) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - hw->port_base_vlan_cfg.state = HNS3_PORT_BASE_VLAN_DISABLE; - hw->port_base_vlan_cfg.pvid = HNS3_INVALID_PVID; - } -@@ -1041,7 +1041,7 @@ hns3_init_vlan_config(struct hns3_adapter *hns) - * we will restore configurations to hardware in hns3_restore_vlan_table - * and hns3_restore_vlan_conf later. - */ -- if (rte_atomic16_read(&hw->reset.resetting) == 0) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - ret = hns3_vlan_pvid_configure(hns, HNS3_INVALID_PVID, 0); - if (ret) { - hns3_err(hw, "pvid set fail in pf, ret =%d", ret); -@@ -4872,7 +4872,7 @@ hns3_dev_start(struct rte_eth_dev *dev) - int ret; - - PMD_INIT_FUNC_TRACE(); -- if (rte_atomic16_read(&hw->reset.resetting)) -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) - return -EBUSY; - - rte_spinlock_lock(&hw->lock); -@@ -5018,7 +5018,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) - rte_delay_ms(hw->tqps_num); - - rte_spinlock_lock(&hw->lock); -- if (rte_atomic16_read(&hw->reset.resetting) == 0) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - hns3_stop_tqps(hw); - hns3_do_stop(hns); - hns3_unmap_rx_interrupt(dev); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 31f78a1..0d86683 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -350,7 +350,7 @@ struct hns3_reset_data { - enum hns3_reset_stage stage; - rte_atomic16_t schedule; - /* Reset flag, covering the entire reset process */ -- rte_atomic16_t resetting; -+ uint16_t resetting; - /* Used to disable sending cmds during reset */ - rte_atomic16_t disable_cmd; - /* The reset level being processed */ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index ef03fb1..c126384 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -898,7 +898,7 @@ hns3vf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - * MTU value issued by hns3 VF PMD driver must be less than or equal to - * PF's MTU. - */ -- if (rte_atomic16_read(&hw->reset.resetting)) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { - hns3_err(hw, "Failed to set mtu during resetting"); - return -EIO; - } -@@ -1438,7 +1438,7 @@ hns3vf_request_link_info(struct hns3_hw *hw) - uint8_t resp_msg; - int ret; - -- if (rte_atomic16_read(&hw->reset.resetting)) -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) - return; - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false, - &resp_msg, sizeof(resp_msg)); -@@ -1471,7 +1471,7 @@ hns3vf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) - struct hns3_hw *hw = &hns->hw; - int ret; - -- if (rte_atomic16_read(&hw->reset.resetting)) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { - hns3_err(hw, - "vf set vlan id failed during resetting, vlan_id =%u", - vlan_id); -@@ -1510,7 +1510,7 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask) - unsigned int tmp_mask; - int ret = 0; - -- if (rte_atomic16_read(&hw->reset.resetting)) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { - hns3_err(hw, "vf set vlan offload failed during resetting, " - "mask = 0x%x", mask); - return -EIO; -@@ -1957,7 +1957,7 @@ hns3vf_dev_stop(struct rte_eth_dev *dev) - rte_delay_ms(hw->tqps_num); - - rte_spinlock_lock(&hw->lock); -- if (rte_atomic16_read(&hw->reset.resetting) == 0) { -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - hns3_stop_tqps(hw); - hns3vf_do_stop(hns); - hns3vf_unmap_rx_interrupt(dev); -@@ -2188,7 +2188,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - int ret; - - PMD_INIT_FUNC_TRACE(); -- if (rte_atomic16_read(&hw->reset.resetting)) -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) - return -EBUSY; - - rte_spinlock_lock(&hw->lock); -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 99c500d..51f19b4 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1761,7 +1761,7 @@ hns3_reset_init(struct hns3_hw *hw) - hw->reset.stage = RESET_STAGE_NONE; - hw->reset.request = 0; - hw->reset.pending = 0; -- rte_atomic16_init(&hw->reset.resetting); -+ hw->reset.resetting = 0; - rte_atomic16_init(&hw->reset.disable_cmd); - hw->reset.wait_data = rte_zmalloc("wait_data", - sizeof(struct hns3_wait_data), 0); -@@ -2011,7 +2011,7 @@ hns3_reset_pre(struct hns3_adapter *hns) - int ret; - - if (hw->reset.stage == RESET_STAGE_NONE) { -- rte_atomic16_set(&hns->hw.reset.resetting, 1); -+ __atomic_store_n(&hns->hw.reset.resetting, 1, __ATOMIC_RELAXED); - hw->reset.stage = RESET_STAGE_DOWN; - ret = hw->reset.ops->stop_service(hns); - gettimeofday(&tv, NULL); -@@ -2098,7 +2098,7 @@ hns3_reset_post(struct hns3_adapter *hns) - /* IMP will wait ready flag before reset */ - hns3_notify_reset_ready(hw, false); - hns3_clear_reset_level(hw, &hw->reset.pending); -- rte_atomic16_clear(&hns->hw.reset.resetting); -+ __atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED); - hw->reset.attempts = 0; - hw->reset.stats.success_cnt++; - hw->reset.stage = RESET_STAGE_NONE; -@@ -2223,7 +2223,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) - hw->reset.mbuf_deferred_free = false; - } - rte_spinlock_unlock(&hw->lock); -- rte_atomic16_clear(&hns->hw.reset.resetting); -+ __atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED); - hw->reset.stage = RESET_STAGE_NONE; - gettimeofday(&tv, NULL); - timersub(&tv, &hw->reset.start_time, &tv_delta); -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 5ac36b3..0badfc9 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -3744,7 +3744,7 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - eth_tx_prep_t prep = NULL; - - if (hns->hw.adapter_state == HNS3_NIC_STARTED && -- rte_atomic16_read(&hns->hw.reset.resetting) == 0) { -+ __atomic_load_n(&hns->hw.reset.resetting, __ATOMIC_RELAXED) == 0) { - eth_dev->rx_pkt_burst = hns3_get_rx_function(eth_dev); - eth_dev->tx_pkt_burst = hns3_get_tx_function(eth_dev, &prep); - eth_dev->tx_pkt_prepare = prep; --- -2.7.4 - diff --git a/0012-net-hns3-support-traffic-management.patch b/0012-net-hns3-support-traffic-management.patch deleted file mode 100644 index fcd8486..0000000 --- a/0012-net-hns3-support-traffic-management.patch +++ /dev/null @@ -1,1885 +0,0 @@ -From f0523548580b29532793025e08a1b5bee8f682ff Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 14 Jan 2021 21:33:31 +0800 -Subject: [PATCH 012/189] net/hns3: support traffic management - -This patch support RTE TM ops function for PF, which could -used to: -1. config port's peak rate. -2. config TC's peak rate. - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_dcb.c | 216 ++++--- - drivers/net/hns3/hns3_dcb.h | 3 + - drivers/net/hns3/hns3_ethdev.c | 20 +- - drivers/net/hns3/hns3_ethdev.h | 14 + - drivers/net/hns3/hns3_tm.c | 1291 ++++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_tm.h | 103 ++++ - drivers/net/hns3/meson.build | 3 +- - 7 files changed, 1554 insertions(+), 96 deletions(-) - create mode 100644 drivers/net/hns3/hns3_tm.c - create mode 100644 drivers/net/hns3/hns3_tm.h - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index b32d5af..5aa374c 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -76,16 +76,13 @@ hns3_shaper_para_calc(struct hns3_hw *hw, uint32_t ir, uint8_t shaper_level, - shaper_para->ir_b = SHAPER_DEFAULT_IR_B; - } else if (ir_calc > ir) { - /* Increasing the denominator to select ir_s value */ -- do { -+ while (ir_calc >= ir && ir) { - ir_s_calc++; - ir_calc = DIVISOR_IR_B_126 / (tick * (1 << ir_s_calc)); -- } while (ir_calc > ir); -+ } - -- if (ir_calc == ir) -- shaper_para->ir_b = SHAPER_DEFAULT_IR_B; -- else -- shaper_para->ir_b = (ir * tick * (1 << ir_s_calc) + -- (DIVISOR_CLK >> 1)) / DIVISOR_CLK; -+ shaper_para->ir_b = (ir * tick * (1 << ir_s_calc) + -+ (DIVISOR_CLK >> 1)) / DIVISOR_CLK; - } else { - /* - * Increasing the numerator to select ir_u value. ir_u_calc will -@@ -320,6 +317,10 @@ hns3_dcb_get_shapping_para(uint8_t ir_b, uint8_t ir_u, uint8_t ir_s, - { - uint32_t shapping_para = 0; - -+ /* If ir_b is zero it means IR is 0Mbps, return zero of shapping_para */ -+ if (ir_b == 0) -+ return shapping_para; -+ - hns3_dcb_set_field(shapping_para, IR_B, ir_b); - hns3_dcb_set_field(shapping_para, IR_U, ir_u); - hns3_dcb_set_field(shapping_para, IR_S, ir_s); -@@ -402,14 +403,57 @@ hns3_dcb_pg_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, - return hns3_cmd_send(hw, &desc, 1); - } - --static int --hns3_dcb_pg_shaper_cfg(struct hns3_hw *hw) -+int -+hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate) - { -- struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_shaper_parameter shaper_parameter; -- struct hns3_pf *pf = &hns->pf; - uint32_t ir_u, ir_b, ir_s; - uint32_t shaper_para; -+ int ret; -+ -+ /* Calc shaper para */ -+ ret = hns3_shaper_para_calc(hw, rate, HNS3_SHAPER_LVL_PG, -+ &shaper_parameter); -+ if (ret) { -+ hns3_err(hw, "calculate shaper parameter fail, ret = %d.", -+ ret); -+ return ret; -+ } -+ -+ shaper_para = hns3_dcb_get_shapping_para(0, 0, 0, -+ HNS3_SHAPER_BS_U_DEF, -+ HNS3_SHAPER_BS_S_DEF); -+ -+ ret = hns3_dcb_pg_shapping_cfg(hw, HNS3_DCB_SHAP_C_BUCKET, pg_id, -+ shaper_para, rate); -+ if (ret) { -+ hns3_err(hw, "config PG CIR shaper parameter fail, ret = %d.", -+ ret); -+ return ret; -+ } -+ -+ ir_b = shaper_parameter.ir_b; -+ ir_u = shaper_parameter.ir_u; -+ ir_s = shaper_parameter.ir_s; -+ shaper_para = hns3_dcb_get_shapping_para(ir_b, ir_u, ir_s, -+ HNS3_SHAPER_BS_U_DEF, -+ HNS3_SHAPER_BS_S_DEF); -+ -+ ret = hns3_dcb_pg_shapping_cfg(hw, HNS3_DCB_SHAP_P_BUCKET, pg_id, -+ shaper_para, rate); -+ if (ret) { -+ hns3_err(hw, "config PG PIR shaper parameter fail, ret = %d.", -+ ret); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_dcb_pg_shaper_cfg(struct hns3_hw *hw) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); - uint32_t rate; - uint8_t i; - int ret; -@@ -421,44 +465,9 @@ hns3_dcb_pg_shaper_cfg(struct hns3_hw *hw) - /* Pg to pri */ - for (i = 0; i < hw->dcb_info.num_pg; i++) { - rate = hw->dcb_info.pg_info[i].bw_limit; -- -- /* Calc shaper para */ -- ret = hns3_shaper_para_calc(hw, rate, HNS3_SHAPER_LVL_PG, -- &shaper_parameter); -- if (ret) { -- hns3_err(hw, "calculate shaper parameter failed: %d", -- ret); -- return ret; -- } -- -- shaper_para = hns3_dcb_get_shapping_para(0, 0, 0, -- HNS3_SHAPER_BS_U_DEF, -- HNS3_SHAPER_BS_S_DEF); -- -- ret = hns3_dcb_pg_shapping_cfg(hw, HNS3_DCB_SHAP_C_BUCKET, i, -- shaper_para, rate); -- if (ret) { -- hns3_err(hw, -- "config PG CIR shaper parameter failed: %d", -- ret); -- return ret; -- } -- -- ir_b = shaper_parameter.ir_b; -- ir_u = shaper_parameter.ir_u; -- ir_s = shaper_parameter.ir_s; -- shaper_para = hns3_dcb_get_shapping_para(ir_b, ir_u, ir_s, -- HNS3_SHAPER_BS_U_DEF, -- HNS3_SHAPER_BS_S_DEF); -- -- ret = hns3_dcb_pg_shapping_cfg(hw, HNS3_DCB_SHAP_P_BUCKET, i, -- shaper_para, rate); -- if (ret) { -- hns3_err(hw, -- "config PG PIR shaper parameter failed: %d", -- ret); -+ ret = hns3_pg_shaper_rate_cfg(hw, i, rate); -+ if (ret) - return ret; -- } - } - - return 0; -@@ -530,74 +539,75 @@ hns3_dcb_pri_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, - return hns3_cmd_send(hw, &desc, 1); - } - --static int --hns3_dcb_pri_tc_base_shaper_cfg(struct hns3_hw *hw) -+int -+hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate) - { - struct hns3_shaper_parameter shaper_parameter; - uint32_t ir_u, ir_b, ir_s; - uint32_t shaper_para; -- uint32_t rate; -- int ret, i; -+ int ret; - -- for (i = 0; i < hw->dcb_info.num_tc; i++) { -- rate = hw->dcb_info.tc_info[i].bw_limit; -- ret = hns3_shaper_para_calc(hw, rate, HNS3_SHAPER_LVL_PRI, -- &shaper_parameter); -- if (ret) { -- hns3_err(hw, "calculate shaper parameter failed: %d", -- ret); -- return ret; -- } -+ ret = hns3_shaper_para_calc(hw, rate, HNS3_SHAPER_LVL_PRI, -+ &shaper_parameter); -+ if (ret) { -+ hns3_err(hw, "calculate shaper parameter failed: %d.", -+ ret); -+ return ret; -+ } - -- shaper_para = hns3_dcb_get_shapping_para(0, 0, 0, -- HNS3_SHAPER_BS_U_DEF, -- HNS3_SHAPER_BS_S_DEF); -+ shaper_para = hns3_dcb_get_shapping_para(0, 0, 0, -+ HNS3_SHAPER_BS_U_DEF, -+ HNS3_SHAPER_BS_S_DEF); - -- ret = hns3_dcb_pri_shapping_cfg(hw, HNS3_DCB_SHAP_C_BUCKET, i, -- shaper_para, rate); -- if (ret) { -- hns3_err(hw, -- "config priority CIR shaper parameter failed: %d", -- ret); -- return ret; -- } -+ ret = hns3_dcb_pri_shapping_cfg(hw, HNS3_DCB_SHAP_C_BUCKET, tc_no, -+ shaper_para, rate); -+ if (ret) { -+ hns3_err(hw, -+ "config priority CIR shaper parameter failed: %d.", -+ ret); -+ return ret; -+ } - -- ir_b = shaper_parameter.ir_b; -- ir_u = shaper_parameter.ir_u; -- ir_s = shaper_parameter.ir_s; -- shaper_para = hns3_dcb_get_shapping_para(ir_b, ir_u, ir_s, -- HNS3_SHAPER_BS_U_DEF, -- HNS3_SHAPER_BS_S_DEF); -+ ir_b = shaper_parameter.ir_b; -+ ir_u = shaper_parameter.ir_u; -+ ir_s = shaper_parameter.ir_s; -+ shaper_para = hns3_dcb_get_shapping_para(ir_b, ir_u, ir_s, -+ HNS3_SHAPER_BS_U_DEF, -+ HNS3_SHAPER_BS_S_DEF); - -- ret = hns3_dcb_pri_shapping_cfg(hw, HNS3_DCB_SHAP_P_BUCKET, i, -- shaper_para, rate); -- if (ret) { -- hns3_err(hw, -- "config priority PIR shaper parameter failed: %d", -- ret); -- return ret; -- } -+ ret = hns3_dcb_pri_shapping_cfg(hw, HNS3_DCB_SHAP_P_BUCKET, tc_no, -+ shaper_para, rate); -+ if (ret) { -+ hns3_err(hw, -+ "config priority PIR shaper parameter failed: %d.", -+ ret); -+ return ret; - } - - return 0; - } - -- - static int - hns3_dcb_pri_shaper_cfg(struct hns3_hw *hw) - { -- struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -- struct hns3_pf *pf = &hns->pf; -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ uint32_t rate; -+ uint8_t i; - int ret; - - if (pf->tx_sch_mode != HNS3_FLAG_TC_BASE_SCH_MODE) - return -EINVAL; - -- ret = hns3_dcb_pri_tc_base_shaper_cfg(hw); -- if (ret) -- hns3_err(hw, "config port shaper failed: %d", ret); -+ for (i = 0; i < hw->dcb_info.num_tc; i++) { -+ rate = hw->dcb_info.tc_info[i].bw_limit; -+ ret = hns3_pri_shaper_rate_cfg(hw, i, rate); -+ if (ret) { -+ hns3_err(hw, "config pri shaper failed: %d.", ret); -+ return ret; -+ } -+ } - -- return ret; -+ return 0; - } - - static int -@@ -680,6 +690,26 @@ hns3_tc_queue_mapping_cfg(struct hns3_hw *hw, uint16_t nb_tx_q) - return 0; - } - -+uint8_t -+hns3_txq_mapped_tc_get(struct hns3_hw *hw, uint16_t txq_no) -+{ -+ struct hns3_tc_queue_info *tc_queue; -+ uint8_t i; -+ -+ for (i = 0; i < HNS3_MAX_TC_NUM; i++) { -+ tc_queue = &hw->tc_queue[i]; -+ if (!tc_queue->enable) -+ continue; -+ -+ if (txq_no >= tc_queue->tqp_offset && -+ txq_no < tc_queue->tqp_offset + tc_queue->tqp_count) -+ return i; -+ } -+ -+ /* return TC0 in default case */ -+ return 0; -+} -+ - int - hns3_queue_to_tc_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, uint16_t nb_tx_q) - { -diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h -index fee23d9..8248434 100644 ---- a/drivers/net/hns3/hns3_dcb.h -+++ b/drivers/net/hns3/hns3_dcb.h -@@ -209,5 +209,8 @@ int hns3_queue_to_tc_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, - - int hns3_dcb_cfg_update(struct hns3_adapter *hns); - int hns3_dcb_port_shaper_cfg(struct hns3_hw *hw); -+int hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate); -+int hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate); -+uint8_t hns3_txq_mapped_tc_get(struct hns3_hw *hw, uint16_t txq_no); - - #endif /* _HNS3_DCB_H_ */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index d0d1d3a..2bc28ef 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5,7 +5,6 @@ - #include - #include - #include --#include - #include - - #include "hns3_ethdev.h" -@@ -2494,7 +2493,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - return 0; - } - --static int -+int - hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - { - struct hns3_adapter *hns = eth_dev->data->dev_private; -@@ -4679,6 +4678,8 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_enable_intr; - } - -+ hns3_tm_conf_init(eth_dev); -+ - return 0; - - err_enable_intr: -@@ -4712,6 +4713,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -+ hns3_tm_conf_uninit(eth_dev); - hns3_enable_hw_error_intr(hns, false); - hns3_rss_uninit(hns); - (void)hns3_config_gro(hw, false); -@@ -4739,6 +4741,16 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - if (ret) - return ret; - -+ /* -+ * The hns3_dcb_cfg_update may configure TM module, so -+ * hns3_tm_conf_update must called later. -+ */ -+ ret = hns3_tm_conf_update(hw); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "failed to update tm conf, ret = %d.", ret); -+ return ret; -+ } -+ - ret = hns3_init_queues(hns, reset_queue); - if (ret) { - PMD_INIT_LOG(ERR, "failed to init queues, ret = %d.", ret); -@@ -4936,6 +4948,8 @@ hns3_dev_start(struct rte_eth_dev *dev) - */ - hns3_start_tqps(hw); - -+ hns3_tm_dev_start_proc(hw); -+ - hns3_info(hw, "hns3 dev start successful!"); - return 0; - } -@@ -5019,6 +5033,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) - - rte_spinlock_lock(&hw->lock); - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { -+ hns3_tm_dev_stop_proc(hw); - hns3_stop_tqps(hw); - hns3_do_stop(hns); - hns3_unmap_rx_interrupt(dev); -@@ -6089,6 +6104,7 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { - .fec_get_capability = hns3_fec_get_capability, - .fec_get = hns3_fec_get, - .fec_set = hns3_fec_set, -+ .tm_ops_get = hns3_tm_ops_get, - }; - - static const struct hns3_reset_ops hns3_reset_ops = { -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 0d86683..0d17170 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -7,12 +7,16 @@ - - #include - #include -+#include -+#include -+#include - - #include "hns3_cmd.h" - #include "hns3_mbx.h" - #include "hns3_rss.h" - #include "hns3_fdir.h" - #include "hns3_stats.h" -+#include "hns3_tm.h" - - /* Vendor ID */ - #define PCI_VENDOR_ID_HUAWEI 0x19e5 -@@ -727,6 +731,8 @@ struct hns3_pf { - - struct hns3_fdir_info fdir; /* flow director info */ - LIST_HEAD(counters, hns3_flow_counter) flow_counters; -+ -+ struct hns3_tm_conf tm_conf; - }; - - struct hns3_vf { -@@ -796,6 +802,12 @@ struct hns3_adapter { - #define HNS3_DEV_HW_TO_ADAPTER(hw) \ - container_of(hw, struct hns3_adapter, hw) - -+static inline struct hns3_pf *HNS3_DEV_HW_TO_PF(struct hns3_hw *hw) -+{ -+ struct hns3_adapter *adapter = HNS3_DEV_HW_TO_ADAPTER(hw); -+ return &adapter->pf; -+} -+ - #define hns3_set_field(origin, mask, shift, val) \ - do { \ - (origin) &= (~(mask)); \ -@@ -937,6 +949,8 @@ bool hns3vf_is_reset_pending(struct hns3_adapter *hns); - void hns3_update_link_status(struct hns3_hw *hw); - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr); -+int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, -+ struct rte_eth_dev_info *info); - - static inline bool - is_reset_pending(struct hns3_adapter *hns) -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -new file mode 100644 -index 0000000..d1639d4 ---- /dev/null -+++ b/drivers/net/hns3/hns3_tm.c -@@ -0,0 +1,1291 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2020-2020 Hisilicon Limited. -+ */ -+ -+#include -+ -+#include "hns3_ethdev.h" -+#include "hns3_dcb.h" -+#include "hns3_logs.h" -+#include "hns3_tm.h" -+ -+static inline uint32_t -+hns3_tm_max_tx_queues_get(struct rte_eth_dev *dev) -+{ -+ /* -+ * This API will called in pci device probe stage, we can't call -+ * rte_eth_dev_info_get to get max_tx_queues (due to rte_eth_devices -+ * not setup), so we call the hns3_dev_infos_get. -+ */ -+ struct rte_eth_dev_info dev_info; -+ -+ memset(&dev_info, 0, sizeof(dev_info)); -+ (void)hns3_dev_infos_get(dev, &dev_info); -+ return RTE_MIN(dev_info.max_tx_queues, RTE_MAX_QUEUES_PER_PORT); -+} -+ -+void -+hns3_tm_conf_init(struct rte_eth_dev *dev) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); -+ -+ pf->tm_conf.nb_leaf_nodes_max = max_tx_queues; -+ pf->tm_conf.nb_nodes_max = 1 + HNS3_MAX_TC_NUM + max_tx_queues; -+ pf->tm_conf.nb_shaper_profile_max = 1 + HNS3_MAX_TC_NUM; -+ -+ TAILQ_INIT(&pf->tm_conf.shaper_profile_list); -+ pf->tm_conf.nb_shaper_profile = 0; -+ -+ pf->tm_conf.root = NULL; -+ TAILQ_INIT(&pf->tm_conf.tc_list); -+ TAILQ_INIT(&pf->tm_conf.queue_list); -+ pf->tm_conf.nb_tc_node = 0; -+ pf->tm_conf.nb_queue_node = 0; -+ -+ pf->tm_conf.committed = false; -+} -+ -+void -+hns3_tm_conf_uninit(struct rte_eth_dev *dev) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_shaper_profile *shaper_profile; -+ struct hns3_tm_node *tm_node; -+ -+ if (pf->tm_conf.nb_queue_node > 0) { -+ while ((tm_node = TAILQ_FIRST(&pf->tm_conf.queue_list))) { -+ TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node); -+ rte_free(tm_node); -+ } -+ pf->tm_conf.nb_queue_node = 0; -+ } -+ -+ if (pf->tm_conf.nb_tc_node > 0) { -+ while ((tm_node = TAILQ_FIRST(&pf->tm_conf.tc_list))) { -+ TAILQ_REMOVE(&pf->tm_conf.tc_list, tm_node, node); -+ rte_free(tm_node); -+ } -+ pf->tm_conf.nb_tc_node = 0; -+ } -+ -+ if (pf->tm_conf.root != NULL) { -+ rte_free(pf->tm_conf.root); -+ pf->tm_conf.root = NULL; -+ } -+ -+ if (pf->tm_conf.nb_shaper_profile > 0) { -+ while ((shaper_profile = -+ TAILQ_FIRST(&pf->tm_conf.shaper_profile_list))) { -+ TAILQ_REMOVE(&pf->tm_conf.shaper_profile_list, -+ shaper_profile, node); -+ rte_free(shaper_profile); -+ } -+ pf->tm_conf.nb_shaper_profile = 0; -+ } -+ -+ pf->tm_conf.nb_leaf_nodes_max = 0; -+ pf->tm_conf.nb_nodes_max = 0; -+ pf->tm_conf.nb_shaper_profile_max = 0; -+} -+ -+static inline uint64_t -+hns3_tm_rate_convert_firmware2tm(uint32_t firmware_rate) -+{ -+#define FIRMWARE_TO_TM_RATE_SCALE 125000 -+ /* tm rate unit is Bps, firmware rate is Mbps */ -+ return ((uint64_t)firmware_rate) * FIRMWARE_TO_TM_RATE_SCALE; -+} -+ -+static inline uint32_t -+hns3_tm_rate_convert_tm2firmware(uint64_t tm_rate) -+{ -+#define TM_TO_FIRMWARE_RATE_SCALE 125000 -+ /* tm rate unit is Bps, firmware rate is Mbps */ -+ return (uint32_t)(tm_rate / TM_TO_FIRMWARE_RATE_SCALE); -+} -+ -+static int -+hns3_tm_capabilities_get(struct rte_eth_dev *dev, -+ struct rte_tm_capabilities *cap, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); -+ -+ if (cap == NULL || error == NULL) -+ return -EINVAL; -+ -+ error->type = RTE_TM_ERROR_TYPE_NONE; -+ -+ memset(cap, 0, sizeof(struct rte_tm_capabilities)); -+ -+ cap->n_nodes_max = 1 + HNS3_MAX_TC_NUM + max_tx_queues; -+ cap->n_levels_max = HNS3_TM_NODE_LEVEL_MAX; -+ cap->non_leaf_nodes_identical = 1; -+ cap->leaf_nodes_identical = 1; -+ cap->shaper_n_max = 1 + HNS3_MAX_TC_NUM; -+ cap->shaper_private_n_max = 1 + HNS3_MAX_TC_NUM; -+ cap->shaper_private_dual_rate_n_max = 0; -+ cap->shaper_private_rate_min = 0; -+ cap->shaper_private_rate_max = -+ hns3_tm_rate_convert_firmware2tm(hw->max_tm_rate); -+ cap->shaper_shared_n_max = 0; -+ cap->shaper_shared_n_nodes_per_shaper_max = 0; -+ cap->shaper_shared_n_shapers_per_node_max = 0; -+ cap->shaper_shared_dual_rate_n_max = 0; -+ cap->shaper_shared_rate_min = 0; -+ cap->shaper_shared_rate_max = 0; -+ -+ cap->sched_n_children_max = max_tx_queues; -+ cap->sched_sp_n_priorities_max = 1; -+ cap->sched_wfq_n_children_per_group_max = 0; -+ cap->sched_wfq_n_groups_max = 0; -+ cap->sched_wfq_weight_max = 1; -+ -+ cap->cman_head_drop_supported = 0; -+ cap->dynamic_update_mask = 0; -+ cap->shaper_pkt_length_adjust_min = RTE_TM_ETH_FRAMING_OVERHEAD; -+ cap->shaper_pkt_length_adjust_max = RTE_TM_ETH_FRAMING_OVERHEAD_FCS; -+ cap->cman_wred_context_n_max = 0; -+ cap->cman_wred_context_private_n_max = 0; -+ cap->cman_wred_context_shared_n_max = 0; -+ cap->cman_wred_context_shared_n_nodes_per_context_max = 0; -+ cap->cman_wred_context_shared_n_contexts_per_node_max = 0; -+ cap->stats_mask = 0; -+ -+ return 0; -+} -+ -+static struct hns3_tm_shaper_profile * -+hns3_tm_shaper_profile_search(struct rte_eth_dev *dev, -+ uint32_t shaper_profile_id) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_shaper_profile_list *shaper_profile_list = -+ &pf->tm_conf.shaper_profile_list; -+ struct hns3_tm_shaper_profile *shaper_profile; -+ -+ TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) { -+ if (shaper_profile_id == shaper_profile->shaper_profile_id) -+ return shaper_profile; -+ } -+ -+ return NULL; -+} -+ -+static int -+hns3_tm_shaper_profile_param_check(struct rte_eth_dev *dev, -+ struct rte_tm_shaper_params *profile, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ -+ if (profile->committed.rate) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE; -+ error->message = "committed rate not supported"; -+ return -EINVAL; -+ } -+ -+ if (profile->committed.size) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE; -+ error->message = "committed bucket size not supported"; -+ return -EINVAL; -+ } -+ -+ if (profile->peak.rate > -+ hns3_tm_rate_convert_firmware2tm(hw->max_tm_rate)) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE; -+ error->message = "peak rate too large"; -+ return -EINVAL; -+ } -+ -+ if (profile->peak.size) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE; -+ error->message = "peak bucket size not supported"; -+ return -EINVAL; -+ } -+ -+ if (profile->pkt_length_adjust) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PKT_ADJUST_LEN; -+ error->message = "packet length adjustment not supported"; -+ return -EINVAL; -+ } -+ -+ if (profile->packet_mode) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PACKET_MODE; -+ error->message = "packet mode not supported"; -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_tm_shaper_profile_add(struct rte_eth_dev *dev, -+ uint32_t shaper_profile_id, -+ struct rte_tm_shaper_params *profile, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_shaper_profile *shaper_profile; -+ int ret; -+ -+ if (profile == NULL || error == NULL) -+ return -EINVAL; -+ -+ if (pf->tm_conf.nb_shaper_profile >= -+ pf->tm_conf.nb_shaper_profile_max) { -+ error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; -+ error->message = "too much profiles"; -+ return -EINVAL; -+ } -+ -+ ret = hns3_tm_shaper_profile_param_check(dev, profile, error); -+ if (ret) -+ return ret; -+ -+ shaper_profile = hns3_tm_shaper_profile_search(dev, shaper_profile_id); -+ if (shaper_profile) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID; -+ error->message = "profile ID exist"; -+ return -EINVAL; -+ } -+ -+ shaper_profile = rte_zmalloc("hns3_tm_shaper_profile", -+ sizeof(struct hns3_tm_shaper_profile), -+ 0); -+ if (shaper_profile == NULL) -+ return -ENOMEM; -+ -+ shaper_profile->shaper_profile_id = shaper_profile_id; -+ memcpy(&shaper_profile->profile, profile, -+ sizeof(struct rte_tm_shaper_params)); -+ TAILQ_INSERT_TAIL(&pf->tm_conf.shaper_profile_list, -+ shaper_profile, node); -+ pf->tm_conf.nb_shaper_profile++; -+ -+ return 0; -+} -+ -+static int -+hns3_tm_shaper_profile_del(struct rte_eth_dev *dev, -+ uint32_t shaper_profile_id, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_shaper_profile *shaper_profile; -+ -+ if (error == NULL) -+ return -EINVAL; -+ -+ shaper_profile = hns3_tm_shaper_profile_search(dev, shaper_profile_id); -+ if (shaper_profile == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID; -+ error->message = "profile ID not exist"; -+ return -EINVAL; -+ } -+ -+ if (shaper_profile->reference_count) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE; -+ error->message = "profile in use"; -+ return -EINVAL; -+ } -+ -+ TAILQ_REMOVE(&pf->tm_conf.shaper_profile_list, shaper_profile, node); -+ rte_free(shaper_profile); -+ pf->tm_conf.nb_shaper_profile--; -+ -+ return 0; -+} -+ -+static struct hns3_tm_node * -+hns3_tm_node_search(struct rte_eth_dev *dev, -+ uint32_t node_id, -+ enum hns3_tm_node_type *node_type) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_node_list *queue_list = &pf->tm_conf.queue_list; -+ struct hns3_tm_node_list *tc_list = &pf->tm_conf.tc_list; -+ struct hns3_tm_node *tm_node; -+ -+ if (pf->tm_conf.root && pf->tm_conf.root->id == node_id) { -+ *node_type = HNS3_TM_NODE_TYPE_PORT; -+ return pf->tm_conf.root; -+ } -+ -+ TAILQ_FOREACH(tm_node, tc_list, node) { -+ if (tm_node->id == node_id) { -+ *node_type = HNS3_TM_NODE_TYPE_TC; -+ return tm_node; -+ } -+ } -+ -+ TAILQ_FOREACH(tm_node, queue_list, node) { -+ if (tm_node->id == node_id) { -+ *node_type = HNS3_TM_NODE_TYPE_QUEUE; -+ return tm_node; -+ } -+ } -+ -+ return NULL; -+} -+ -+static int -+hns3_tm_nonleaf_node_param_check(struct rte_eth_dev *dev, -+ struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+{ -+ struct hns3_tm_shaper_profile *shaper_profile; -+ -+ if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) { -+ shaper_profile = hns3_tm_shaper_profile_search(dev, -+ params->shaper_profile_id); -+ if (shaper_profile == NULL) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID; -+ error->message = "shaper profile not exist"; -+ return -EINVAL; -+ } -+ } -+ -+ if (params->nonleaf.wfq_weight_mode) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE; -+ error->message = "WFQ not supported"; -+ return -EINVAL; -+ } -+ -+ if (params->nonleaf.n_sp_priorities != 1) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES; -+ error->message = "SP priority not supported"; -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_tm_leaf_node_param_check(struct rte_eth_dev *dev __rte_unused, -+ struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+ -+{ -+ if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_SHAPER_PROFILE_ID; -+ error->message = "shaper not supported"; -+ return -EINVAL; -+ } -+ -+ if (params->leaf.cman) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN; -+ error->message = "congestion management not supported"; -+ return -EINVAL; -+ } -+ -+ if (params->leaf.wred.wred_profile_id != RTE_TM_WRED_PROFILE_ID_NONE) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID; -+ error->message = "WRED not supported"; -+ return -EINVAL; -+ } -+ -+ if (params->leaf.wred.shared_wred_context_id) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID; -+ error->message = "WRED not supported"; -+ return -EINVAL; -+ } -+ -+ if (params->leaf.wred.n_shared_wred_contexts) { -+ error->type = -+ RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS; -+ error->message = "WRED not supported"; -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_tm_node_param_check(struct rte_eth_dev *dev, uint32_t node_id, -+ uint32_t priority, uint32_t weight, -+ struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ enum hns3_tm_node_type node_type = HNS3_TM_NODE_TYPE_MAX; -+ -+ if (node_id == RTE_TM_NODE_ID_NULL) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "invalid node id"; -+ return -EINVAL; -+ } -+ -+ if (hns3_tm_node_search(dev, node_id, &node_type)) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "node id already used"; -+ return -EINVAL; -+ } -+ -+ if (priority) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PRIORITY; -+ error->message = "priority should be 0"; -+ return -EINVAL; -+ } -+ -+ if (weight != 1) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_WEIGHT; -+ error->message = "weight must be 1"; -+ return -EINVAL; -+ } -+ -+ if (params->shared_shaper_id) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID; -+ error->message = "shared shaper not supported"; -+ return -EINVAL; -+ } -+ if (params->n_shared_shapers) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS; -+ error->message = "shared shaper not supported"; -+ return -EINVAL; -+ } -+ -+ if (node_id >= pf->tm_conf.nb_leaf_nodes_max) -+ return hns3_tm_nonleaf_node_param_check(dev, params, error); -+ else -+ return hns3_tm_leaf_node_param_check(dev, params, error); -+} -+ -+static int -+hns3_tm_port_node_add(struct rte_eth_dev *dev, uint32_t node_id, -+ uint32_t level_id, struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_node *tm_node; -+ -+ if (level_id != RTE_TM_NODE_LEVEL_ID_ANY && -+ level_id != HNS3_TM_NODE_LEVEL_PORT) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; -+ error->message = "wrong level"; -+ return -EINVAL; -+ } -+ -+ if (node_id != pf->tm_conf.nb_nodes_max - 1) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "invalid port node ID"; -+ return -EINVAL; -+ } -+ -+ if (pf->tm_conf.root) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID; -+ error->message = "already have a root"; -+ return -EINVAL; -+ } -+ -+ tm_node = rte_zmalloc("hns3_tm_node", sizeof(struct hns3_tm_node), 0); -+ if (tm_node == NULL) -+ return -ENOMEM; -+ -+ tm_node->id = node_id; -+ tm_node->reference_count = 0; -+ tm_node->parent = NULL; -+ tm_node->shaper_profile = hns3_tm_shaper_profile_search(dev, -+ params->shaper_profile_id); -+ memcpy(&tm_node->params, params, sizeof(struct rte_tm_node_params)); -+ pf->tm_conf.root = tm_node; -+ -+ if (tm_node->shaper_profile) -+ tm_node->shaper_profile->reference_count++; -+ -+ return 0; -+} -+ -+static int -+hns3_tm_tc_node_add(struct rte_eth_dev *dev, uint32_t node_id, -+ uint32_t level_id, struct hns3_tm_node *parent_node, -+ struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_node *tm_node; -+ -+ if (level_id != RTE_TM_NODE_LEVEL_ID_ANY && -+ level_id != HNS3_TM_NODE_LEVEL_TC) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; -+ error->message = "wrong level"; -+ return -EINVAL; -+ } -+ -+ if (node_id >= pf->tm_conf.nb_nodes_max - 1 || -+ node_id < pf->tm_conf.nb_leaf_nodes_max || -+ hns3_tm_calc_node_tc_no(&pf->tm_conf, node_id) >= hw->num_tc) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "invalid tc node ID"; -+ return -EINVAL; -+ } -+ -+ if (pf->tm_conf.nb_tc_node >= hw->num_tc) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "too many TCs"; -+ return -EINVAL; -+ } -+ -+ tm_node = rte_zmalloc("hns3_tm_node", sizeof(struct hns3_tm_node), 0); -+ if (tm_node == NULL) -+ return -ENOMEM; -+ -+ tm_node->id = node_id; -+ tm_node->reference_count = 0; -+ tm_node->parent = parent_node; -+ tm_node->shaper_profile = hns3_tm_shaper_profile_search(dev, -+ params->shaper_profile_id); -+ memcpy(&tm_node->params, params, sizeof(struct rte_tm_node_params)); -+ TAILQ_INSERT_TAIL(&pf->tm_conf.tc_list, tm_node, node); -+ pf->tm_conf.nb_tc_node++; -+ tm_node->parent->reference_count++; -+ -+ if (tm_node->shaper_profile) -+ tm_node->shaper_profile->reference_count++; -+ -+ return 0; -+} -+ -+static int -+hns3_tm_queue_node_add(struct rte_eth_dev *dev, uint32_t node_id, -+ uint32_t level_id, struct hns3_tm_node *parent_node, -+ struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_tm_node *tm_node; -+ -+ if (level_id != RTE_TM_NODE_LEVEL_ID_ANY && -+ level_id != HNS3_TM_NODE_LEVEL_QUEUE) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; -+ error->message = "wrong level"; -+ return -EINVAL; -+ } -+ -+ /* note: dev->data->nb_tx_queues <= max_tx_queues */ -+ if (node_id >= dev->data->nb_tx_queues) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "invalid queue node ID"; -+ return -EINVAL; -+ } -+ -+ if (hns3_txq_mapped_tc_get(hw, node_id) != -+ hns3_tm_calc_node_tc_no(&pf->tm_conf, parent_node->id)) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "queue's TC not match parent's TC"; -+ return -EINVAL; -+ } -+ -+ tm_node = rte_zmalloc("hns3_tm_node", sizeof(struct hns3_tm_node), 0); -+ if (tm_node == NULL) -+ return -ENOMEM; -+ -+ tm_node->id = node_id; -+ tm_node->reference_count = 0; -+ tm_node->parent = parent_node; -+ memcpy(&tm_node->params, params, sizeof(struct rte_tm_node_params)); -+ TAILQ_INSERT_TAIL(&pf->tm_conf.queue_list, tm_node, node); -+ pf->tm_conf.nb_queue_node++; -+ tm_node->parent->reference_count++; -+ -+ return 0; -+} -+ -+static int -+hns3_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id, -+ uint32_t parent_node_id, uint32_t priority, -+ uint32_t weight, uint32_t level_id, -+ struct rte_tm_node_params *params, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ enum hns3_tm_node_type parent_node_type = HNS3_TM_NODE_TYPE_MAX; -+ struct hns3_tm_node *parent_node; -+ int ret; -+ -+ if (params == NULL || error == NULL) -+ return -EINVAL; -+ -+ if (pf->tm_conf.committed) { -+ error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; -+ error->message = "already committed"; -+ return -EINVAL; -+ } -+ -+ ret = hns3_tm_node_param_check(dev, node_id, priority, weight, -+ params, error); -+ if (ret) -+ return ret; -+ -+ /* root node who don't have a parent */ -+ if (parent_node_id == RTE_TM_NODE_ID_NULL) -+ return hns3_tm_port_node_add(dev, node_id, level_id, -+ params, error); -+ -+ parent_node = hns3_tm_node_search(dev, parent_node_id, -+ &parent_node_type); -+ if (parent_node == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID; -+ error->message = "parent not exist"; -+ return -EINVAL; -+ } -+ -+ if (parent_node_type != HNS3_TM_NODE_TYPE_PORT && -+ parent_node_type != HNS3_TM_NODE_TYPE_TC) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID; -+ error->message = "parent is not port or TC"; -+ return -EINVAL; -+ } -+ -+ if (parent_node_type == HNS3_TM_NODE_TYPE_PORT) -+ return hns3_tm_tc_node_add(dev, node_id, level_id, -+ parent_node, params, error); -+ else -+ return hns3_tm_queue_node_add(dev, node_id, level_id, -+ parent_node, params, error); -+} -+ -+static void -+hns3_tm_node_do_delete(struct hns3_pf *pf, -+ enum hns3_tm_node_type node_type, -+ struct hns3_tm_node *tm_node) -+{ -+ if (node_type == HNS3_TM_NODE_TYPE_PORT) { -+ if (tm_node->shaper_profile) -+ tm_node->shaper_profile->reference_count--; -+ rte_free(tm_node); -+ pf->tm_conf.root = NULL; -+ return; -+ } -+ -+ if (tm_node->shaper_profile) -+ tm_node->shaper_profile->reference_count--; -+ tm_node->parent->reference_count--; -+ if (node_type == HNS3_TM_NODE_TYPE_TC) { -+ TAILQ_REMOVE(&pf->tm_conf.tc_list, tm_node, node); -+ pf->tm_conf.nb_tc_node--; -+ } else { -+ TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node); -+ pf->tm_conf.nb_queue_node--; -+ } -+ rte_free(tm_node); -+} -+ -+static int -+hns3_tm_node_delete(struct rte_eth_dev *dev, -+ uint32_t node_id, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ enum hns3_tm_node_type node_type = HNS3_TM_NODE_TYPE_MAX; -+ struct hns3_tm_node *tm_node; -+ -+ if (error == NULL) -+ return -EINVAL; -+ -+ if (pf->tm_conf.committed) { -+ error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; -+ error->message = "already committed"; -+ return -EINVAL; -+ } -+ -+ tm_node = hns3_tm_node_search(dev, node_id, &node_type); -+ if (tm_node == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "no such node"; -+ return -EINVAL; -+ } -+ -+ if (tm_node->reference_count) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "cannot delete a node which has children"; -+ return -EINVAL; -+ } -+ -+ hns3_tm_node_do_delete(pf, node_type, tm_node); -+ -+ return 0; -+} -+ -+static int -+hns3_tm_node_type_get(struct rte_eth_dev *dev, uint32_t node_id, -+ int *is_leaf, struct rte_tm_error *error) -+{ -+ enum hns3_tm_node_type node_type = HNS3_TM_NODE_TYPE_MAX; -+ struct hns3_tm_node *tm_node; -+ -+ if (is_leaf == NULL || error == NULL) -+ return -EINVAL; -+ -+ tm_node = hns3_tm_node_search(dev, node_id, &node_type); -+ if (tm_node == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "no such node"; -+ return -EINVAL; -+ } -+ -+ if (node_type == HNS3_TM_NODE_TYPE_QUEUE) -+ *is_leaf = true; -+ else -+ *is_leaf = false; -+ -+ return 0; -+} -+ -+static void -+hns3_tm_nonleaf_level_capsbilities_get(struct rte_eth_dev *dev, -+ uint32_t level_id, -+ struct rte_tm_level_capabilities *cap) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); -+ -+ if (level_id == HNS3_TM_NODE_LEVEL_PORT) { -+ cap->n_nodes_max = 1; -+ cap->n_nodes_nonleaf_max = 1; -+ cap->n_nodes_leaf_max = 0; -+ } else { -+ cap->n_nodes_max = HNS3_MAX_TC_NUM; -+ cap->n_nodes_nonleaf_max = HNS3_MAX_TC_NUM; -+ cap->n_nodes_leaf_max = 0; -+ } -+ -+ cap->non_leaf_nodes_identical = 1; -+ cap->leaf_nodes_identical = 1; -+ -+ cap->nonleaf.shaper_private_supported = true; -+ cap->nonleaf.shaper_private_dual_rate_supported = false; -+ cap->nonleaf.shaper_private_rate_min = 0; -+ cap->nonleaf.shaper_private_rate_max = -+ hns3_tm_rate_convert_firmware2tm(hw->max_tm_rate); -+ cap->nonleaf.shaper_shared_n_max = 0; -+ if (level_id == HNS3_TM_NODE_LEVEL_PORT) -+ cap->nonleaf.sched_n_children_max = HNS3_MAX_TC_NUM; -+ else -+ cap->nonleaf.sched_n_children_max = max_tx_queues; -+ cap->nonleaf.sched_sp_n_priorities_max = 1; -+ cap->nonleaf.sched_wfq_n_children_per_group_max = 0; -+ cap->nonleaf.sched_wfq_n_groups_max = 0; -+ cap->nonleaf.sched_wfq_weight_max = 1; -+ cap->nonleaf.stats_mask = 0; -+} -+ -+static void -+hns3_tm_leaf_level_capabilities_get(struct rte_eth_dev *dev, -+ struct rte_tm_level_capabilities *cap) -+{ -+ uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); -+ -+ cap->n_nodes_max = max_tx_queues; -+ cap->n_nodes_nonleaf_max = 0; -+ cap->n_nodes_leaf_max = max_tx_queues; -+ -+ cap->non_leaf_nodes_identical = 1; -+ cap->leaf_nodes_identical = 1; -+ -+ cap->leaf.shaper_private_supported = false; -+ cap->leaf.shaper_private_dual_rate_supported = false; -+ cap->leaf.shaper_private_rate_min = 0; -+ cap->leaf.shaper_private_rate_max = 0; -+ cap->leaf.shaper_shared_n_max = 0; -+ cap->leaf.cman_head_drop_supported = false; -+ cap->leaf.cman_wred_context_private_supported = false; -+ cap->leaf.cman_wred_context_shared_n_max = 0; -+ cap->leaf.stats_mask = 0; -+} -+ -+static int -+hns3_tm_level_capabilities_get(struct rte_eth_dev *dev, -+ uint32_t level_id, -+ struct rte_tm_level_capabilities *cap, -+ struct rte_tm_error *error) -+{ -+ if (cap == NULL || error == NULL) -+ return -EINVAL; -+ -+ if (level_id >= HNS3_TM_NODE_LEVEL_MAX) { -+ error->type = RTE_TM_ERROR_TYPE_LEVEL_ID; -+ error->message = "too deep level"; -+ return -EINVAL; -+ } -+ -+ memset(cap, 0, sizeof(struct rte_tm_level_capabilities)); -+ -+ if (level_id != HNS3_TM_NODE_LEVEL_QUEUE) -+ hns3_tm_nonleaf_level_capsbilities_get(dev, level_id, cap); -+ else -+ hns3_tm_leaf_level_capabilities_get(dev, cap); -+ -+ return 0; -+} -+ -+static void -+hns3_tm_nonleaf_node_capabilities_get(struct rte_eth_dev *dev, -+ enum hns3_tm_node_type node_type, -+ struct rte_tm_node_capabilities *cap) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); -+ -+ cap->shaper_private_supported = true; -+ cap->shaper_private_dual_rate_supported = false; -+ cap->shaper_private_rate_min = 0; -+ cap->shaper_private_rate_max = -+ hns3_tm_rate_convert_firmware2tm(hw->max_tm_rate); -+ cap->shaper_shared_n_max = 0; -+ -+ if (node_type == HNS3_TM_NODE_TYPE_PORT) -+ cap->nonleaf.sched_n_children_max = HNS3_MAX_TC_NUM; -+ else -+ cap->nonleaf.sched_n_children_max = max_tx_queues; -+ cap->nonleaf.sched_sp_n_priorities_max = 1; -+ cap->nonleaf.sched_wfq_n_children_per_group_max = 0; -+ cap->nonleaf.sched_wfq_n_groups_max = 0; -+ cap->nonleaf.sched_wfq_weight_max = 1; -+ -+ cap->stats_mask = 0; -+} -+ -+static void -+hns3_tm_leaf_node_capabilities_get(struct rte_eth_dev *dev __rte_unused, -+ struct rte_tm_node_capabilities *cap) -+{ -+ cap->shaper_private_supported = false; -+ cap->shaper_private_dual_rate_supported = false; -+ cap->shaper_private_rate_min = 0; -+ cap->shaper_private_rate_max = 0; -+ cap->shaper_shared_n_max = 0; -+ -+ cap->leaf.cman_head_drop_supported = false; -+ cap->leaf.cman_wred_context_private_supported = false; -+ cap->leaf.cman_wred_context_shared_n_max = 0; -+ -+ cap->stats_mask = 0; -+} -+ -+static int -+hns3_tm_node_capabilities_get(struct rte_eth_dev *dev, -+ uint32_t node_id, -+ struct rte_tm_node_capabilities *cap, -+ struct rte_tm_error *error) -+{ -+ enum hns3_tm_node_type node_type; -+ struct hns3_tm_node *tm_node; -+ -+ if (cap == NULL || error == NULL) -+ return -EINVAL; -+ -+ tm_node = hns3_tm_node_search(dev, node_id, &node_type); -+ if (tm_node == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "no such node"; -+ return -EINVAL; -+ } -+ -+ memset(cap, 0, sizeof(struct rte_tm_node_capabilities)); -+ -+ if (node_type != HNS3_TM_NODE_TYPE_QUEUE) -+ hns3_tm_nonleaf_node_capabilities_get(dev, node_type, cap); -+ else -+ hns3_tm_leaf_node_capabilities_get(dev, cap); -+ -+ return 0; -+} -+ -+static int -+hns3_tm_config_port_rate(struct hns3_hw *hw, -+ struct hns3_tm_shaper_profile *shaper_profile) -+{ -+ uint32_t firmware_rate; -+ uint64_t rate; -+ -+ if (shaper_profile) { -+ rate = shaper_profile->profile.peak.rate; -+ firmware_rate = hns3_tm_rate_convert_tm2firmware(rate); -+ } else { -+ firmware_rate = hw->dcb_info.pg_info[0].bw_limit; -+ } -+ -+ /* -+ * The TM shaper topology after device inited: -+ * pri0 shaper --->| -+ * pri1 shaper --->| -+ * ... |----> pg0 shaper ----> port shaper -+ * ... | -+ * priX shaper --->| -+ * -+ * Because port shaper rate maybe changed by firmware, to avoid -+ * concurrent configure, driver use pg0 shaper to achieve the rate limit -+ * of port. -+ * -+ * The finally port rate = MIN(pg0 shaper rate, port shaper rate) -+ */ -+ return hns3_pg_shaper_rate_cfg(hw, 0, firmware_rate); -+} -+ -+static int -+hns3_tm_config_tc_rate(struct hns3_hw *hw, -+ uint8_t tc_no, -+ struct hns3_tm_shaper_profile *shaper_profile) -+{ -+ uint32_t firmware_rate; -+ uint64_t rate; -+ -+ if (shaper_profile) { -+ rate = shaper_profile->profile.peak.rate; -+ firmware_rate = hns3_tm_rate_convert_tm2firmware(rate); -+ } else { -+ firmware_rate = hw->dcb_info.tc_info[tc_no].bw_limit; -+ } -+ -+ return hns3_pri_shaper_rate_cfg(hw, tc_no, firmware_rate); -+} -+ -+static bool -+hns3_tm_configure_check(struct hns3_hw *hw, struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ struct hns3_tm_conf *tm_conf = &pf->tm_conf; -+ struct hns3_tm_node_list *tc_list = &tm_conf->tc_list; -+ struct hns3_tm_node_list *queue_list = &tm_conf->queue_list; -+ struct hns3_tm_node *tm_node; -+ -+ /* TC */ -+ TAILQ_FOREACH(tm_node, tc_list, node) { -+ if (!tm_node->reference_count) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; -+ error->message = "TC without queue assigned"; -+ return false; -+ } -+ -+ if (hns3_tm_calc_node_tc_no(tm_conf, tm_node->id) >= -+ hw->num_tc) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "node's TC not exist"; -+ return false; -+ } -+ } -+ -+ /* Queue */ -+ TAILQ_FOREACH(tm_node, queue_list, node) { -+ if (tm_node->id >= hw->data->nb_tx_queues) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "node's queue invalid"; -+ return false; -+ } -+ -+ if (hns3_txq_mapped_tc_get(hw, tm_node->id) != -+ hns3_tm_calc_node_tc_no(tm_conf, tm_node->parent->id)) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "queue's TC not match parent's TC"; -+ return false; -+ } -+ } -+ -+ return true; -+} -+ -+static int -+hns3_tm_hierarchy_do_commit(struct hns3_hw *hw, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ struct hns3_tm_node_list *tc_list = &pf->tm_conf.tc_list; -+ struct hns3_tm_node *tm_node; -+ uint8_t tc_no; -+ int ret; -+ -+ /* port */ -+ tm_node = pf->tm_conf.root; -+ if (tm_node->shaper_profile) { -+ ret = hns3_tm_config_port_rate(hw, tm_node->shaper_profile); -+ if (ret) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE; -+ error->message = "fail to set port peak rate"; -+ return -EIO; -+ } -+ } -+ -+ /* TC */ -+ TAILQ_FOREACH(tm_node, tc_list, node) { -+ if (tm_node->shaper_profile == NULL) -+ continue; -+ -+ tc_no = hns3_tm_calc_node_tc_no(&pf->tm_conf, tm_node->id); -+ ret = hns3_tm_config_tc_rate(hw, tc_no, -+ tm_node->shaper_profile); -+ if (ret) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS; -+ error->message = "fail to set TC peak rate"; -+ return -EIO; -+ } -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_tm_hierarchy_commit(struct rte_eth_dev *dev, -+ int clear_on_fail, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ int ret; -+ -+ if (error == NULL) -+ return -EINVAL; -+ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { -+ error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; -+ error->message = "device is resetting"; -+ /* don't goto fail_clear, user may try later */ -+ return -EBUSY; -+ } -+ -+ if (pf->tm_conf.root == NULL) -+ goto done; -+ -+ /* check configure before commit make sure key configure not violated */ -+ if (!hns3_tm_configure_check(hw, error)) -+ goto fail_clear; -+ -+ ret = hns3_tm_hierarchy_do_commit(hw, error); -+ if (ret) -+ goto fail_clear; -+ -+done: -+ pf->tm_conf.committed = true; -+ return 0; -+ -+fail_clear: -+ if (clear_on_fail) { -+ hns3_tm_conf_uninit(dev); -+ hns3_tm_conf_init(dev); -+ } -+ return -EINVAL; -+} -+ -+static int -+hns3_tm_hierarchy_commit_wrap(struct rte_eth_dev *dev, -+ int clear_on_fail, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ rte_spinlock_lock(&hw->lock); -+ ret = hns3_tm_hierarchy_commit(dev, clear_on_fail, error); -+ rte_spinlock_unlock(&hw->lock); -+ -+ return ret; -+} -+ -+static int -+hns3_tm_node_shaper_do_update(struct hns3_hw *hw, -+ uint32_t node_id, -+ enum hns3_tm_node_type node_type, -+ struct hns3_tm_shaper_profile *shaper_profile, -+ struct rte_tm_error *error) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ uint8_t tc_no; -+ int ret; -+ -+ if (node_type == HNS3_TM_NODE_TYPE_QUEUE) { -+ if (shaper_profile != NULL) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID; -+ error->message = "queue node shaper not supported"; -+ return -EINVAL; -+ } -+ return 0; -+ } -+ -+ if (!pf->tm_conf.committed) -+ return 0; -+ -+ if (node_type == HNS3_TM_NODE_TYPE_PORT) { -+ ret = hns3_tm_config_port_rate(hw, shaper_profile); -+ if (ret) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE; -+ error->message = "fail to update port peak rate"; -+ } -+ -+ return ret; -+ } -+ -+ /* -+ * update TC's shaper -+ */ -+ tc_no = hns3_tm_calc_node_tc_no(&pf->tm_conf, node_id); -+ ret = hns3_tm_config_tc_rate(hw, tc_no, shaper_profile); -+ if (ret) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE; -+ error->message = "fail to update TC peak rate"; -+ } -+ -+ return ret; -+} -+ -+static int -+hns3_tm_node_shaper_update(struct rte_eth_dev *dev, -+ uint32_t node_id, -+ uint32_t shaper_profile_id, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ enum hns3_tm_node_type node_type = HNS3_TM_NODE_TYPE_MAX; -+ struct hns3_tm_shaper_profile *profile = NULL; -+ struct hns3_tm_node *tm_node; -+ -+ if (error == NULL) -+ return -EINVAL; -+ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { -+ error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED; -+ error->message = "device is resetting"; -+ return -EBUSY; -+ } -+ -+ tm_node = hns3_tm_node_search(dev, node_id, &node_type); -+ if (tm_node == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_NODE_ID; -+ error->message = "no such node"; -+ return -EINVAL; -+ } -+ -+ if (shaper_profile_id == tm_node->params.shaper_profile_id) -+ return 0; -+ -+ if (shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) { -+ profile = hns3_tm_shaper_profile_search(dev, shaper_profile_id); -+ if (profile == NULL) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID; -+ error->message = "profile ID not exist"; -+ return -EINVAL; -+ } -+ } -+ -+ if (hns3_tm_node_shaper_do_update(hw, node_id, node_type, -+ profile, error)) -+ return -EINVAL; -+ -+ if (tm_node->shaper_profile) -+ tm_node->shaper_profile->reference_count--; -+ tm_node->shaper_profile = profile; -+ tm_node->params.shaper_profile_id = shaper_profile_id; -+ if (profile != NULL) -+ profile->reference_count++; -+ -+ return 0; -+} -+ -+static int -+hns3_tm_node_shaper_update_wrap(struct rte_eth_dev *dev, -+ uint32_t node_id, -+ uint32_t shaper_profile_id, -+ struct rte_tm_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ rte_spinlock_lock(&hw->lock); -+ ret = hns3_tm_node_shaper_update(dev, node_id, -+ shaper_profile_id, error); -+ rte_spinlock_unlock(&hw->lock); -+ -+ return ret; -+} -+ -+static const struct rte_tm_ops hns3_tm_ops = { -+ .capabilities_get = hns3_tm_capabilities_get, -+ .shaper_profile_add = hns3_tm_shaper_profile_add, -+ .shaper_profile_delete = hns3_tm_shaper_profile_del, -+ .node_add = hns3_tm_node_add, -+ .node_delete = hns3_tm_node_delete, -+ .node_type_get = hns3_tm_node_type_get, -+ .level_capabilities_get = hns3_tm_level_capabilities_get, -+ .node_capabilities_get = hns3_tm_node_capabilities_get, -+ .hierarchy_commit = hns3_tm_hierarchy_commit_wrap, -+ .node_shaper_update = hns3_tm_node_shaper_update_wrap, -+}; -+ -+int -+hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, -+ void *arg) -+{ -+ if (arg == NULL) -+ return -EINVAL; -+ -+ *(const void **)arg = &hns3_tm_ops; -+ -+ return 0; -+} -+ -+void -+hns3_tm_dev_start_proc(struct hns3_hw *hw) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ -+ if (pf->tm_conf.root && !pf->tm_conf.committed) -+ hns3_warn(hw, -+ "please call hierarchy_commit() before starting the port."); -+} -+ -+/* -+ * We need clear tm_conf committed flag when device stop so that user can modify -+ * tm configuration (e.g. add or delete node). -+ * -+ * If user don't call hierarchy commit when device start later, the Port/TC's -+ * shaper rate still the same as previous committed. -+ * -+ * To avoid the above problem, we need recover Port/TC shaper rate when device -+ * stop. -+ */ -+void -+hns3_tm_dev_stop_proc(struct hns3_hw *hw) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ struct hns3_tm_node_list *tc_list = &pf->tm_conf.tc_list; -+ struct hns3_tm_node *tm_node; -+ uint8_t tc_no; -+ -+ if (!pf->tm_conf.committed) -+ return; -+ -+ tm_node = pf->tm_conf.root; -+ if (tm_node != NULL && tm_node->shaper_profile) -+ (void)hns3_tm_config_port_rate(hw, NULL); -+ -+ TAILQ_FOREACH(tm_node, tc_list, node) { -+ if (tm_node->shaper_profile == NULL) -+ continue; -+ tc_no = hns3_tm_calc_node_tc_no(&pf->tm_conf, tm_node->id); -+ (void)hns3_tm_config_tc_rate(hw, tc_no, NULL); -+ } -+ -+ pf->tm_conf.committed = false; -+} -+ -+int -+hns3_tm_conf_update(struct hns3_hw *hw) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ struct rte_tm_error error; -+ -+ if (pf->tm_conf.root == NULL || !pf->tm_conf.committed) -+ return 0; -+ -+ memset(&error, 0, sizeof(struct rte_tm_error)); -+ return hns3_tm_hierarchy_do_commit(hw, &error); -+} -diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h -new file mode 100644 -index 0000000..d8de3e4 ---- /dev/null -+++ b/drivers/net/hns3/hns3_tm.h -@@ -0,0 +1,103 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2020-2020 Hisilicon Limited. -+ */ -+ -+#ifndef _HNS3_TM_H_ -+#define _HNS3_TM_H_ -+ -+#include -+#include -+#include -+ -+enum hns3_tm_node_type { -+ HNS3_TM_NODE_TYPE_PORT, -+ HNS3_TM_NODE_TYPE_TC, -+ HNS3_TM_NODE_TYPE_QUEUE, -+ HNS3_TM_NODE_TYPE_MAX, -+}; -+ -+enum hns3_tm_node_level { -+ HNS3_TM_NODE_LEVEL_PORT, -+ HNS3_TM_NODE_LEVEL_TC, -+ HNS3_TM_NODE_LEVEL_QUEUE, -+ HNS3_TM_NODE_LEVEL_MAX, -+}; -+ -+struct hns3_tm_shaper_profile { -+ TAILQ_ENTRY(hns3_tm_shaper_profile) node; -+ uint32_t shaper_profile_id; -+ uint32_t reference_count; -+ struct rte_tm_shaper_params profile; -+}; -+ -+TAILQ_HEAD(hns3_shaper_profile_list, hns3_tm_shaper_profile); -+ -+struct hns3_tm_node { -+ TAILQ_ENTRY(hns3_tm_node) node; -+ uint32_t id; -+ uint32_t reference_count; -+ struct hns3_tm_node *parent; -+ struct hns3_tm_shaper_profile *shaper_profile; -+ struct rte_tm_node_params params; -+}; -+ -+TAILQ_HEAD(hns3_tm_node_list, hns3_tm_node); -+ -+struct hns3_tm_conf { -+ uint32_t nb_leaf_nodes_max; /* max numbers of leaf nodes */ -+ uint32_t nb_nodes_max; /* max numbers of nodes */ -+ uint32_t nb_shaper_profile_max; /* max numbers of shaper profile */ -+ -+ struct hns3_shaper_profile_list shaper_profile_list; -+ uint32_t nb_shaper_profile; /* number of shaper profile */ -+ -+ struct hns3_tm_node *root; -+ struct hns3_tm_node_list tc_list; -+ struct hns3_tm_node_list queue_list; -+ uint32_t nb_tc_node; /* number of added TC nodes */ -+ uint32_t nb_queue_node; /* number of added queue nodes */ -+ -+ /* -+ * This flag is used to check if APP can change the TM node -+ * configuration. -+ * When it's true, means the configuration is applied to HW, -+ * APP should not add/delete the TM node configuration. -+ * When starting the port, APP should call the hierarchy_commit API to -+ * set this flag to true. When stopping the port, this flag should be -+ * set to false. -+ */ -+ bool committed; -+}; -+ -+/* -+ * This API used to calc node TC no. User must make sure the node id is in the -+ * TC node id range. -+ * -+ * User could call rte_eth_dev_info_get API to get port's max_tx_queues, The TM -+ * id's assignment should following the below rules: -+ * [0, max_tx_queues-1]: correspond queues's node id -+ * max_tx_queues + 0 : correspond TC0's node id -+ * max_tx_queues + 1 : correspond TC1's node id -+ * ... -+ * max_tx_queues + 7 : correspond TC7's node id -+ * max_tx_queues + 8 : correspond port's node id -+ * -+ */ -+static inline uint8_t -+hns3_tm_calc_node_tc_no(struct hns3_tm_conf *conf, uint32_t node_id) -+{ -+ if (node_id >= conf->nb_leaf_nodes_max && -+ node_id < conf->nb_nodes_max - 1) -+ return node_id - conf->nb_leaf_nodes_max; -+ else -+ return 0; -+} -+ -+void hns3_tm_conf_init(struct rte_eth_dev *dev); -+void hns3_tm_conf_uninit(struct rte_eth_dev *dev); -+int hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *arg); -+void hns3_tm_dev_start_proc(struct hns3_hw *hw); -+void hns3_tm_dev_stop_proc(struct hns3_hw *hw); -+int hns3_tm_conf_update(struct hns3_hw *hw); -+ -+#endif /* _HNS3_TM_H */ -diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build -index 5674d98..f6aac69 100644 ---- a/drivers/net/hns3/meson.build -+++ b/drivers/net/hns3/meson.build -@@ -25,7 +25,8 @@ sources = files('hns3_cmd.c', - 'hns3_rss.c', - 'hns3_rxtx.c', - 'hns3_stats.c', -- 'hns3_mp.c') -+ 'hns3_mp.c', -+ 'hns3_tm.c') - - deps += ['hash'] - --- -2.7.4 - diff --git a/0013-net-hns3-fix-VF-query-link-status-in-dev-init.patch b/0013-net-hns3-fix-VF-query-link-status-in-dev-init.patch deleted file mode 100644 index 93878c2..0000000 --- a/0013-net-hns3-fix-VF-query-link-status-in-dev-init.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 92f474b6b5f954d20b81576549a25ce8b7bc2a2b Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 14 Jan 2021 21:33:32 +0800 -Subject: [PATCH 013/189] net/hns3: fix VF query link status in dev init - -Current hns3vf queried link status in dev init stage, but the link -status should be maintained in dev start stage, this patch fix this. - -Also, in the dev start stage, we use quick query instead of delayed -query to make sure update the link status soon. - -Fixes: a5475d61fa34 ("net/hns3: support VF") -Fixes: 958edf6627d5 ("net/hns3: fix VF link status") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev_vf.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index c126384..ee89505 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1749,7 +1749,6 @@ hns3vf_init_hardware(struct hns3_adapter *hns) - goto err_init_hardware; - } - -- hns3vf_request_link_info(hw); - return 0; - - err_init_hardware: -@@ -2238,7 +2237,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - hns3_rx_scattered_calc(dev); - hns3_set_rxtx_function(dev); - hns3_mp_req_start_rxtx(dev); -- rte_eal_alarm_set(HNS3VF_SERVICE_INTERVAL, hns3vf_service_handler, dev); -+ hns3vf_service_handler(dev); - - hns3vf_restore_filter(dev); - --- -2.7.4 - diff --git a/0014-net-hns3-use-new-opcode-for-clearing-hardware-resour.patch b/0014-net-hns3-use-new-opcode-for-clearing-hardware-resour.patch deleted file mode 100644 index c524d96..0000000 --- a/0014-net-hns3-use-new-opcode-for-clearing-hardware-resour.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 1f68430b13d5aed1851c97761163b44b38d4f37d Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Thu, 14 Jan 2021 21:33:33 +0800 -Subject: [PATCH 014/189] net/hns3: use new opcode for clearing hardware - resource - -The original command opcode '0x700A' may cause firmware error, -so '0x700A' is deserted, now use '0x700B' to replace it. - -Fixes: 223d9eceaeee ("net/hns3: clear residual hardware configurations on init") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 194c3a7..e40293b 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -203,7 +203,7 @@ enum hns3_opcode_type { - HNS3_OPC_FD_COUNTER_OP = 0x1205, - - /* Clear hardware state command */ -- HNS3_OPC_CLEAR_HW_STATE = 0x700A, -+ HNS3_OPC_CLEAR_HW_STATE = 0x700B, - - /* SFP command */ - HNS3_OPC_SFP_GET_SPEED = 0x7104, --- -2.7.4 - diff --git a/0015-net-hns3-fix-register-length-when-dumping-registers.patch b/0015-net-hns3-fix-register-length-when-dumping-registers.patch deleted file mode 100644 index 28bba41..0000000 --- a/0015-net-hns3-fix-register-length-when-dumping-registers.patch +++ /dev/null @@ -1,59 +0,0 @@ -From 7fab993aa57ba5f2e4bce07949de602e1a40daf1 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 14 Jan 2021 21:33:34 +0800 -Subject: [PATCH 015/189] net/hns3: fix register length when dumping registers - -Currently, the reg length return by HNS3 is the total length of all the -registers. But for upper layer user, the total register length is the -length multiplied by width. This can lead to a waste of memory and print -some invalid information. - -This patch corrects the length and width of the register. - -Fixes: 936eda25e8da ("net/hns3: support dump register") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_regs.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index b2cc599..32597fe 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -104,6 +104,7 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - uint32_t cmdq_lines, common_lines, ring_lines, tqp_intr_lines; - uint32_t regs_num_32_bit, regs_num_64_bit; -+ uint32_t dfx_reg_lines; - uint32_t len; - int ret; - -@@ -117,7 +118,7 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) - tqp_intr_lines = sizeof(tqp_intr_reg_addrs) / REG_LEN_PER_LINE + 1; - - len = (cmdq_lines + common_lines + ring_lines * hw->tqps_num + -- tqp_intr_lines * hw->num_msi) * REG_LEN_PER_LINE; -+ tqp_intr_lines * hw->num_msi) * REG_NUM_PER_LINE; - - if (!hns->is_vf) { - ret = hns3_get_regs_num(hw, ®s_num_32_bit, ®s_num_64_bit); -@@ -126,8 +127,11 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) - ret); - return -ENOTSUP; - } -- len += regs_num_32_bit * sizeof(uint32_t) + -- regs_num_64_bit * sizeof(uint64_t); -+ dfx_reg_lines = regs_num_32_bit * sizeof(uint32_t) / -+ REG_LEN_PER_LINE + 1; -+ dfx_reg_lines += regs_num_64_bit * sizeof(uint64_t) / -+ REG_LEN_PER_LINE + 1; -+ len += dfx_reg_lines * REG_NUM_PER_LINE; - } - - *length = len; --- -2.7.4 - diff --git a/0016-net-hns3-fix-data-overwriting-during-register-dump.patch b/0016-net-hns3-fix-data-overwriting-during-register-dump.patch deleted file mode 100644 index 7923fbf..0000000 --- a/0016-net-hns3-fix-data-overwriting-during-register-dump.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 3c4b289d438451fa8e3c520bef4b1a32d68f4bea Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 14 Jan 2021 21:33:35 +0800 -Subject: [PATCH 016/189] net/hns3: fix data overwriting during register dump - -The data pointer has not moved after BAR register dumped. This causes -the later register to overwrite the previous data. - -This patch fix the overwriting by move the pointer after every dump -function. And the missing separator between 32-bit register and the -64-bit register is also added to avoid a parsing error. - -Fixes: 936eda25e8da ("net/hns3: support dump register") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_regs.c | 70 +++++++++++++++++++++++++------------------- - 1 file changed, 40 insertions(+), 30 deletions(-) - -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index 32597fe..775e096 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -252,63 +252,68 @@ hns3_get_64_bit_regs(struct hns3_hw *hw, uint32_t regs_num, void *data) - return 0; - } - --static void -+static int -+hns3_insert_reg_separator(int reg_num, uint32_t *data) -+{ -+ int separator_num; -+ int i; -+ -+ separator_num = MAX_SEPARATE_NUM - reg_num % REG_NUM_PER_LINE; -+ for (i = 0; i < separator_num; i++) -+ *data++ = SEPARATOR_VALUE; -+ return separator_num; -+} -+ -+static int - hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ uint32_t *origin_data_ptr = data; - uint32_t reg_offset; -- int separator_num; -- int reg_um; -+ int reg_num; - int i, j; - - /* fetching per-PF registers values from PF PCIe register space */ -- reg_um = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); -- separator_num = MAX_SEPARATE_NUM - reg_um % REG_NUM_PER_LINE; -- for (i = 0; i < reg_um; i++) -+ reg_num = sizeof(cmdq_reg_addrs) / sizeof(uint32_t); -+ for (i = 0; i < reg_num; i++) - *data++ = hns3_read_dev(hw, cmdq_reg_addrs[i]); -- for (i = 0; i < separator_num; i++) -- *data++ = SEPARATOR_VALUE; -+ data += hns3_insert_reg_separator(reg_num, data); - - if (hns->is_vf) -- reg_um = sizeof(common_vf_reg_addrs) / sizeof(uint32_t); -+ reg_num = sizeof(common_vf_reg_addrs) / sizeof(uint32_t); - else -- reg_um = sizeof(common_reg_addrs) / sizeof(uint32_t); -- separator_num = MAX_SEPARATE_NUM - reg_um % REG_NUM_PER_LINE; -- for (i = 0; i < reg_um; i++) -+ reg_num = sizeof(common_reg_addrs) / sizeof(uint32_t); -+ for (i = 0; i < reg_num; i++) - if (hns->is_vf) - *data++ = hns3_read_dev(hw, common_vf_reg_addrs[i]); - else - *data++ = hns3_read_dev(hw, common_reg_addrs[i]); -- for (i = 0; i < separator_num; i++) -- *data++ = SEPARATOR_VALUE; -+ data += hns3_insert_reg_separator(reg_num, data); - -- reg_um = sizeof(ring_reg_addrs) / sizeof(uint32_t); -- separator_num = MAX_SEPARATE_NUM - reg_um % REG_NUM_PER_LINE; -+ reg_num = sizeof(ring_reg_addrs) / sizeof(uint32_t); - for (j = 0; j < hw->tqps_num; j++) { - reg_offset = hns3_get_tqp_reg_offset(j); -- for (i = 0; i < reg_um; i++) -+ for (i = 0; i < reg_num; i++) - *data++ = hns3_read_dev(hw, - ring_reg_addrs[i] + reg_offset); -- for (i = 0; i < separator_num; i++) -- *data++ = SEPARATOR_VALUE; -+ data += hns3_insert_reg_separator(reg_num, data); - } - -- reg_um = sizeof(tqp_intr_reg_addrs) / sizeof(uint32_t); -- separator_num = MAX_SEPARATE_NUM - reg_um % REG_NUM_PER_LINE; -+ reg_num = sizeof(tqp_intr_reg_addrs) / sizeof(uint32_t); - for (j = 0; j < hw->num_msi; j++) { - reg_offset = HNS3_TQP_INTR_REG_SIZE * j; -- for (i = 0; i < reg_um; i++) -- *data++ = hns3_read_dev(hw, -- tqp_intr_reg_addrs[i] + -+ for (i = 0; i < reg_num; i++) -+ *data++ = hns3_read_dev(hw, tqp_intr_reg_addrs[i] + - reg_offset); -- for (i = 0; i < separator_num; i++) -- *data++ = SEPARATOR_VALUE; -+ data += hns3_insert_reg_separator(reg_num, data); - } -+ return data - origin_data_ptr; - } - - int - hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - { -+#define HNS3_64_BIT_REG_SIZE (sizeof(uint64_t) / sizeof(uint32_t)) - struct hns3_adapter *hns = eth_dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - uint32_t regs_num_32_bit; -@@ -338,7 +343,7 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - return -ENOTSUP; - - /* fetching per-PF registers values from PF PCIe register space */ -- hns3_direct_access_regs(hw, data); -+ data += hns3_direct_access_regs(hw, data); - - if (hns->is_vf) - return 0; -@@ -355,11 +360,16 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - hns3_err(hw, "Get 32 bit register failed, ret = %d", ret); - return ret; - } -- - data += regs_num_32_bit; -+ data += hns3_insert_reg_separator(regs_num_32_bit, data); -+ - ret = hns3_get_64_bit_regs(hw, regs_num_64_bit, data); -- if (ret) -+ if (ret) { - hns3_err(hw, "Get 64 bit register failed, ret = %d", ret); -- -+ return ret; -+ } -+ data += regs_num_64_bit * HNS3_64_BIT_REG_SIZE; -+ data += hns3_insert_reg_separator(regs_num_64_bit * -+ HNS3_64_BIT_REG_SIZE, data); - return ret; - } --- -2.7.4 - diff --git a/0017-net-hns3-fix-dump-register-out-of-range.patch b/0017-net-hns3-fix-dump-register-out-of-range.patch deleted file mode 100644 index 7175809..0000000 --- a/0017-net-hns3-fix-dump-register-out-of-range.patch +++ /dev/null @@ -1,38 +0,0 @@ -From a69abf12f46295044e4e59b60e49e73bc66afe10 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 14 Jan 2021 21:33:36 +0800 -Subject: [PATCH 017/189] net/hns3: fix dump register out of range - -Currently, when dump the queue interrupt registers, the number of -registers that should be dumped is calculated from num_msi. But the -value of num_msi includes the number of misc interrupts. So, for some -hardware version, like kupeng930, it will lead to an illegal access. - -This patch replace num_msi with intr_tqps_num which indicate the -number of interrupts used by the tqps. - -Fixes: 936eda25e8da ("net/hns3: support dump register") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_regs.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index 775e096..f2cb465 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -300,7 +300,7 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) - } - - reg_num = sizeof(tqp_intr_reg_addrs) / sizeof(uint32_t); -- for (j = 0; j < hw->num_msi; j++) { -+ for (j = 0; j < hw->intr_tqps_num; j++) { - reg_offset = HNS3_TQP_INTR_REG_SIZE * j; - for (i = 0; i < reg_num; i++) - *data++ = hns3_read_dev(hw, tqp_intr_reg_addrs[i] + --- -2.7.4 - diff --git a/0018-net-hns3-remove-unused-assignment-for-RSS-key.patch b/0018-net-hns3-remove-unused-assignment-for-RSS-key.patch deleted file mode 100644 index c2fd704..0000000 --- a/0018-net-hns3-remove-unused-assignment-for-RSS-key.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 3405d3daec40b258341eeccc5e07c0a9cfd29e6e Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Thu, 14 Jan 2021 21:33:37 +0800 -Subject: [PATCH 018/189] net/hns3: remove unused assignment for RSS key - -The default RSS key does not need to be configured repeatedly -when call hns3_dev_configure function with the NULL RSS key -because the default RSS key has been configured when the PMD -driver run hns3_do_start function with starting device. - -Besides, it will not overwrite the initialized key if -rte_eth_dev_configure API will be called directly and RSS key is NULL -after init PMD driver. - -Therefore, the assignment for RSS key in hns3_dev_configure -function is unnecessary. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 6 ------ - drivers/net/hns3/hns3_ethdev_vf.c | 6 ------ - 2 files changed, 12 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2bc28ef..449d967 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2316,7 +2316,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) - struct rte_eth_conf *conf = &dev->data->dev_conf; - enum rte_eth_rx_mq_mode mq_mode = conf->rxmode.mq_mode; - struct hns3_hw *hw = &hns->hw; -- struct hns3_rss_conf *rss_cfg = &hw->rss_info; - uint16_t nb_rx_q = dev->data->nb_rx_queues; - uint16_t nb_tx_q = dev->data->nb_tx_queues; - struct rte_eth_rss_conf rss_conf; -@@ -2363,11 +2362,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) - conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH; - rss_conf = conf->rx_adv_conf.rss_conf; - hw->rss_dis_flag = false; -- if (rss_conf.rss_key == NULL) { -- rss_conf.rss_key = rss_cfg->key; -- rss_conf.rss_key_len = HNS3_RSS_KEY_SIZE; -- } -- - ret = hns3_dev_rss_hash_update(dev, &rss_conf); - if (ret) - goto cfg_err; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index ee89505..bb4ec6b 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -773,7 +773,6 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -- struct hns3_rss_conf *rss_cfg = &hw->rss_info; - struct rte_eth_conf *conf = &dev->data->dev_conf; - enum rte_eth_rx_mq_mode mq_mode = conf->rxmode.mq_mode; - uint16_t nb_rx_q = dev->data->nb_rx_queues; -@@ -816,11 +815,6 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - conf->rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH; - hw->rss_dis_flag = false; - rss_conf = conf->rx_adv_conf.rss_conf; -- if (rss_conf.rss_key == NULL) { -- rss_conf.rss_key = rss_cfg->key; -- rss_conf.rss_key_len = HNS3_RSS_KEY_SIZE; -- } -- - ret = hns3_dev_rss_hash_update(dev, &rss_conf); - if (ret) - goto cfg_err; --- -2.7.4 - diff --git a/0019-net-hns3-encapsulate-DFX-stats-in-datapath.patch b/0019-net-hns3-encapsulate-DFX-stats-in-datapath.patch deleted file mode 100644 index 0cbec6e..0000000 --- a/0019-net-hns3-encapsulate-DFX-stats-in-datapath.patch +++ /dev/null @@ -1,704 +0,0 @@ -From e5d1fe93d832492bd12a0a01c37d2e326d2701f4 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Jan 2021 18:18:39 +0800 -Subject: [PATCH 019/189] net/hns3: encapsulate DFX stats in datapath - -pkt_len_errors and l2_errors in Rx datapath indicate that driver -needs to discard received packets. And driver does not discard -packets for l3/l4/ol3/ol4_csum_errors in Rx datapath and others -stats in Tx datapath. Therefore, it is necessary for improving -code readability and maintainability to encapsulate error stats -and dfx stats. - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_rxtx.c | 30 ++--- - drivers/net/hns3/hns3_rxtx.h | 134 ++++++++++--------- - drivers/net/hns3/hns3_rxtx_vec_neon.h | 2 +- - drivers/net/hns3/hns3_stats.c | 243 ++++++++++++++++++++++------------ - drivers/net/hns3/hns3_stats.h | 9 +- - 5 files changed, 251 insertions(+), 167 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 0badfc9..3d5f74f 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1792,12 +1792,8 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - rxq->io_head_reg = (volatile void *)((char *)rxq->io_base + - HNS3_RING_RX_HEAD_REG); - rxq->rx_buf_len = rx_buf_size; -- rxq->l2_errors = 0; -- rxq->pkt_len_errors = 0; -- rxq->l3_csum_errors = 0; -- rxq->l4_csum_errors = 0; -- rxq->ol3_csum_errors = 0; -- rxq->ol4_csum_errors = 0; -+ memset(&rxq->err_stats, 0, sizeof(struct hns3_rx_bd_errors_stats)); -+ memset(&rxq->dfx_stats, 0, sizeof(struct hns3_rx_dfx_stats)); - - /* CRC len set here is used for amending packet length */ - if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC) -@@ -2622,12 +2618,8 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - HNS3_RING_TX_TAIL_REG); - txq->min_tx_pkt_len = hw->min_tx_pkt_len; - txq->tso_mode = hw->tso_mode; -- txq->over_length_pkt_cnt = 0; -- txq->exceed_limit_bd_pkt_cnt = 0; -- txq->exceed_limit_bd_reassem_fail = 0; -- txq->unsupported_tunnel_pkt_cnt = 0; -- txq->queue_full_cnt = 0; -- txq->pkt_padding_fail_cnt = 0; -+ memset(&txq->dfx_stats, 0, sizeof(struct hns3_tx_dfx_stats)); -+ - rte_spinlock_lock(&hw->lock); - dev->data->tx_queues[idx] = txq; - rte_spinlock_unlock(&hw->lock); -@@ -3350,7 +3342,7 @@ hns3_parse_cksum(struct hns3_tx_queue *txq, uint16_t tx_desc_id, - if (m->ol_flags & HNS3_TX_CKSUM_OFFLOAD_MASK) { - /* Fill in tunneling parameters if necessary */ - if (hns3_parse_tunneling_params(txq, m, tx_desc_id)) { -- txq->unsupported_tunnel_pkt_cnt++; -+ txq->dfx_stats.unsupported_tunnel_pkt_cnt++; - return -EINVAL; - } - -@@ -3380,17 +3372,17 @@ hns3_check_non_tso_pkt(uint16_t nb_buf, struct rte_mbuf **m_seg, - * driver support, the packet will be ignored. - */ - if (unlikely(rte_pktmbuf_pkt_len(tx_pkt) > HNS3_MAX_FRAME_LEN)) { -- txq->over_length_pkt_cnt++; -+ txq->dfx_stats.over_length_pkt_cnt++; - return -EINVAL; - } - - max_non_tso_bd_num = txq->max_non_tso_bd_num; - if (unlikely(nb_buf > max_non_tso_bd_num)) { -- txq->exceed_limit_bd_pkt_cnt++; -+ txq->dfx_stats.exceed_limit_bd_pkt_cnt++; - ret = hns3_reassemble_tx_pkts(tx_pkt, &new_pkt, - max_non_tso_bd_num); - if (ret) { -- txq->exceed_limit_bd_reassem_fail++; -+ txq->dfx_stats.exceed_limit_bd_reassem_fail++; - return ret; - } - *m_seg = new_pkt; -@@ -3528,7 +3520,7 @@ hns3_xmit_pkts_simple(void *tx_queue, - nb_pkts = RTE_MIN(txq->tx_bd_ready, nb_pkts); - if (unlikely(nb_pkts == 0)) { - if (txq->tx_bd_ready == 0) -- txq->queue_full_cnt++; -+ txq->dfx_stats.queue_full_cnt++; - return 0; - } - -@@ -3580,7 +3572,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) - nb_buf = tx_pkt->nb_segs; - - if (nb_buf > txq->tx_bd_ready) { -- txq->queue_full_cnt++; -+ txq->dfx_stats.queue_full_cnt++; - if (nb_tx == 0) - return 0; - -@@ -3601,7 +3593,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) - rte_pktmbuf_pkt_len(tx_pkt); - appended = rte_pktmbuf_append(tx_pkt, add_len); - if (appended == NULL) { -- txq->pkt_padding_fail_cnt++; -+ txq->dfx_stats.pkt_padding_fail_cnt++; - break; - } - -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 6538848..8a0c981 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -266,6 +266,18 @@ struct hns3_entry { - struct rte_mbuf *mbuf; - }; - -+struct hns3_rx_dfx_stats { -+ uint64_t l3_csum_errors; -+ uint64_t l4_csum_errors; -+ uint64_t ol3_csum_errors; -+ uint64_t ol4_csum_errors; -+}; -+ -+struct hns3_rx_bd_errors_stats { -+ uint64_t l2_errors; -+ uint64_t pkt_len_errors; -+}; -+ - struct hns3_rx_queue { - void *io_base; - volatile void *io_head_reg; -@@ -312,12 +324,10 @@ struct hns3_rx_queue { - bool pvid_sw_discard_en; - bool enabled; /* indicate if Rx queue has been enabled */ - -- uint64_t l2_errors; -- uint64_t pkt_len_errors; -- uint64_t l3_csum_errors; -- uint64_t l4_csum_errors; -- uint64_t ol3_csum_errors; -- uint64_t ol4_csum_errors; -+ /* DFX statistics that driver does not need to discard packets */ -+ struct hns3_rx_dfx_stats dfx_stats; -+ /* Error statistics that driver needs to discard packets */ -+ struct hns3_rx_bd_errors_stats err_stats; - - struct rte_mbuf *bulk_mbuf[HNS3_BULK_ALLOC_MBUF_NUM]; - uint16_t bulk_mbuf_num; -@@ -328,6 +338,57 @@ struct hns3_rx_queue { - struct rte_mbuf fake_mbuf; /* fake mbuf used with vector rx */ - }; - -+/* -+ * The following items are used for the abnormal errors statistics in -+ * the Tx datapath. When upper level application calls the -+ * rte_eth_tx_burst API function to send multiple packets at a time with -+ * burst mode based on hns3 network engine, there are some abnormal -+ * conditions that cause the driver to fail to operate the hardware to -+ * send packets correctly. -+ * Note: When using burst mode to call the rte_eth_tx_burst API function -+ * to send multiple packets at a time. When the first abnormal error is -+ * detected, add one to the relevant error statistics item, and then -+ * exit the loop of sending multiple packets of the function. That is to -+ * say, even if there are multiple packets in which abnormal errors may -+ * be detected in the burst, the relevant error statistics in the driver -+ * will only be increased by one. -+ * The detail description of the Tx abnormal errors statistic items as -+ * below: -+ * - over_length_pkt_cnt -+ * Total number of greater than HNS3_MAX_FRAME_LEN the driver -+ * supported. -+ * -+ * - exceed_limit_bd_pkt_cnt -+ * Total number of exceeding the hardware limited bd which process -+ * a packet needed bd numbers. -+ * -+ * - exceed_limit_bd_reassem_fail -+ * Total number of exceeding the hardware limited bd fail which -+ * process a packet needed bd numbers and reassemble fail. -+ * -+ * - unsupported_tunnel_pkt_cnt -+ * Total number of unsupported tunnel packet. The unsupported tunnel -+ * type: vxlan_gpe, gtp, ipip and MPLSINUDP, MPLSINUDP is a packet -+ * with MPLS-in-UDP RFC 7510 header. -+ * -+ * - queue_full_cnt -+ * Total count which the available bd numbers in current bd queue is -+ * less than the bd numbers with the pkt process needed. -+ * -+ * - pkt_padding_fail_cnt -+ * Total count which the packet length is less than minimum packet -+ * length(struct hns3_tx_queue::min_tx_pkt_len) supported by -+ * hardware in Tx direction and fail to be appended with 0. -+ */ -+struct hns3_tx_dfx_stats { -+ uint64_t over_length_pkt_cnt; -+ uint64_t exceed_limit_bd_pkt_cnt; -+ uint64_t exceed_limit_bd_reassem_fail; -+ uint64_t unsupported_tunnel_pkt_cnt; -+ uint64_t queue_full_cnt; -+ uint64_t pkt_padding_fail_cnt; -+}; -+ - struct hns3_tx_queue { - void *io_base; - volatile void *io_tail_reg; -@@ -411,54 +472,7 @@ struct hns3_tx_queue { - bool pvid_sw_shift_en; - bool enabled; /* indicate if Tx queue has been enabled */ - -- /* -- * The following items are used for the abnormal errors statistics in -- * the Tx datapath. When upper level application calls the -- * rte_eth_tx_burst API function to send multiple packets at a time with -- * burst mode based on hns3 network engine, there are some abnormal -- * conditions that cause the driver to fail to operate the hardware to -- * send packets correctly. -- * Note: When using burst mode to call the rte_eth_tx_burst API function -- * to send multiple packets at a time. When the first abnormal error is -- * detected, add one to the relevant error statistics item, and then -- * exit the loop of sending multiple packets of the function. That is to -- * say, even if there are multiple packets in which abnormal errors may -- * be detected in the burst, the relevant error statistics in the driver -- * will only be increased by one. -- * The detail description of the Tx abnormal errors statistic items as -- * below: -- * - over_length_pkt_cnt -- * Total number of greater than HNS3_MAX_FRAME_LEN the driver -- * supported. -- * -- * - exceed_limit_bd_pkt_cnt -- * Total number of exceeding the hardware limited bd which process -- * a packet needed bd numbers. -- * -- * - exceed_limit_bd_reassem_fail -- * Total number of exceeding the hardware limited bd fail which -- * process a packet needed bd numbers and reassemble fail. -- * -- * - unsupported_tunnel_pkt_cnt -- * Total number of unsupported tunnel packet. The unsupported tunnel -- * type: vxlan_gpe, gtp, ipip and MPLSINUDP, MPLSINUDP is a packet -- * with MPLS-in-UDP RFC 7510 header. -- * -- * - queue_full_cnt -- * Total count which the available bd numbers in current bd queue is -- * less than the bd numbers with the pkt process needed. -- * -- * - pkt_padding_fail_cnt -- * Total count which the packet length is less than minimum packet -- * length(struct hns3_tx_queue::min_tx_pkt_len) supported by -- * hardware in Tx direction and fail to be appended with 0. -- */ -- uint64_t over_length_pkt_cnt; -- uint64_t exceed_limit_bd_pkt_cnt; -- uint64_t exceed_limit_bd_reassem_fail; -- uint64_t unsupported_tunnel_pkt_cnt; -- uint64_t queue_full_cnt; -- uint64_t pkt_padding_fail_cnt; -+ struct hns3_tx_dfx_stats dfx_stats; - }; - - #define HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) \ -@@ -511,9 +525,9 @@ hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, - - if (unlikely((l234_info & L2E_TRUNC_ERR_FLAG) || rxm->pkt_len == 0)) { - if (l234_info & BIT(HNS3_RXD_L2E_B)) -- rxq->l2_errors++; -+ rxq->err_stats.l2_errors++; - else -- rxq->pkt_len_errors++; -+ rxq->err_stats.pkt_len_errors++; - return -EINVAL; - } - -@@ -525,24 +539,24 @@ hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, - - if (unlikely(l234_info & BIT(HNS3_RXD_L3E_B))) { - rxm->ol_flags |= PKT_RX_IP_CKSUM_BAD; -- rxq->l3_csum_errors++; -+ rxq->dfx_stats.l3_csum_errors++; - tmp |= HNS3_L3_CKSUM_ERR; - } - - if (unlikely(l234_info & BIT(HNS3_RXD_L4E_B))) { - rxm->ol_flags |= PKT_RX_L4_CKSUM_BAD; -- rxq->l4_csum_errors++; -+ rxq->dfx_stats.l4_csum_errors++; - tmp |= HNS3_L4_CKSUM_ERR; - } - - if (unlikely(l234_info & BIT(HNS3_RXD_OL3E_B))) { -- rxq->ol3_csum_errors++; -+ rxq->dfx_stats.ol3_csum_errors++; - tmp |= HNS3_OUTER_L3_CKSUM_ERR; - } - - if (unlikely(l234_info & BIT(HNS3_RXD_OL4E_B))) { - rxm->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD; -- rxq->ol4_csum_errors++; -+ rxq->dfx_stats.ol4_csum_errors++; - tmp |= HNS3_OUTER_L4_CKSUM_ERR; - } - } -diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h -index 54addbf..a693b4b 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_neon.h -+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h -@@ -42,7 +42,7 @@ hns3_xmit_fixed_burst_vec(void *__restrict tx_queue, - - nb_commit = RTE_MIN(txq->tx_bd_ready, nb_pkts); - if (unlikely(nb_commit == 0)) { -- txq->queue_full_cnt++; -+ txq->dfx_stats.queue_full_cnt++; - return 0; - } - nb_tx = nb_commit; -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 62a712b..419d7e2 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -262,34 +262,38 @@ static const struct hns3_xstats_name_offset hns3_reset_stats_strings[] = { - - /* The statistic of errors in Rx BD */ - static const struct hns3_xstats_name_offset hns3_rx_bd_error_strings[] = { -- {"RX_PKT_LEN_ERRORS", -+ {"PKT_LEN_ERRORS", - HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(pkt_len_errors)}, -- {"L2_RX_ERRORS", -- HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(l2_errors)}, -- {"RX_L3_CHECKSUM_ERRORS", -- HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(l3_csum_errors)}, -- {"RX_L4_CHECKSUM_ERRORS", -- HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(l4_csum_errors)}, -- {"RX_OL3_CHECKSUM_ERRORS", -- HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(ol3_csum_errors)}, -- {"RX_OL4_CHECKSUM_ERRORS", -- HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(ol4_csum_errors)} -+ {"L2_ERRORS", -+ HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(l2_errors)} - }; - --/* The statistic of the Tx errors */ --static const struct hns3_xstats_name_offset hns3_tx_errors_strings[] = { -- {"TX_OVER_LENGTH_PKT_CNT", -- HNS3_TX_ERROR_STATS_FIELD_OFFSET(over_length_pkt_cnt)}, -- {"TX_EXCEED_LIMITED_BD_PKT_CNT", -- HNS3_TX_ERROR_STATS_FIELD_OFFSET(exceed_limit_bd_pkt_cnt)}, -- {"TX_EXCEED_LIMITED_BD_PKT_REASSEMBLE_FAIL_CNT", -- HNS3_TX_ERROR_STATS_FIELD_OFFSET(exceed_limit_bd_reassem_fail)}, -- {"TX_UNSUPPORTED_TUNNEL_PKT_CNT", -- HNS3_TX_ERROR_STATS_FIELD_OFFSET(unsupported_tunnel_pkt_cnt)}, -- {"TX_QUEUE_FULL_CNT", -- HNS3_TX_ERROR_STATS_FIELD_OFFSET(queue_full_cnt)}, -- {"TX_SHORT_PKT_PAD_FAIL_CNT", -- HNS3_TX_ERROR_STATS_FIELD_OFFSET(pkt_padding_fail_cnt)} -+/* The dfx statistic in Rx datapath */ -+static const struct hns3_xstats_name_offset hns3_rxq_dfx_stats_strings[] = { -+ {"L3_CHECKSUM_ERRORS", -+ HNS3_RXQ_DFX_STATS_FIELD_OFFSET(l3_csum_errors)}, -+ {"L4_CHECKSUM_ERRORS", -+ HNS3_RXQ_DFX_STATS_FIELD_OFFSET(l4_csum_errors)}, -+ {"OL3_CHECKSUM_ERRORS", -+ HNS3_RXQ_DFX_STATS_FIELD_OFFSET(ol3_csum_errors)}, -+ {"OL4_CHECKSUM_ERRORS", -+ HNS3_RXQ_DFX_STATS_FIELD_OFFSET(ol4_csum_errors)} -+}; -+ -+/* The dfx statistic in Tx datapath */ -+static const struct hns3_xstats_name_offset hns3_txq_dfx_stats_strings[] = { -+ {"OVER_LENGTH_PKT_CNT", -+ HNS3_TXQ_DFX_STATS_FIELD_OFFSET(over_length_pkt_cnt)}, -+ {"EXCEED_LIMITED_BD_PKT_CNT", -+ HNS3_TXQ_DFX_STATS_FIELD_OFFSET(exceed_limit_bd_pkt_cnt)}, -+ {"EXCEED_LIMITED_BD_PKT_REASSEMBLE_FAIL_CNT", -+ HNS3_TXQ_DFX_STATS_FIELD_OFFSET(exceed_limit_bd_reassem_fail)}, -+ {"UNSUPPORTED_TUNNEL_PKT_CNT", -+ HNS3_TXQ_DFX_STATS_FIELD_OFFSET(unsupported_tunnel_pkt_cnt)}, -+ {"QUEUE_FULL_CNT", -+ HNS3_TXQ_DFX_STATS_FIELD_OFFSET(queue_full_cnt)}, -+ {"SHORT_PKT_PAD_FAIL_CNT", -+ HNS3_TXQ_DFX_STATS_FIELD_OFFSET(pkt_padding_fail_cnt)} - }; - - /* The statistic of rx queue */ -@@ -314,8 +318,11 @@ static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = { - #define HNS3_NUM_RX_BD_ERROR_XSTATS (sizeof(hns3_rx_bd_error_strings) / \ - sizeof(hns3_rx_bd_error_strings[0])) - --#define HNS3_NUM_TX_ERRORS_XSTATS (sizeof(hns3_tx_errors_strings) / \ -- sizeof(hns3_tx_errors_strings[0])) -+#define HNS3_NUM_RXQ_DFX_XSTATS (sizeof(hns3_rxq_dfx_stats_strings) / \ -+ sizeof(hns3_rxq_dfx_stats_strings[0])) -+ -+#define HNS3_NUM_TXQ_DFX_XSTATS (sizeof(hns3_txq_dfx_stats_strings) / \ -+ sizeof(hns3_txq_dfx_stats_strings[0])) - - #define HNS3_NUM_RX_QUEUE_STATS (sizeof(hns3_rx_queue_strings) / \ - sizeof(hns3_rx_queue_strings[0])) -@@ -519,7 +526,8 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - for (i = 0; i != num; ++i) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq) { -- cnt = rxq->l2_errors + rxq->pkt_len_errors; -+ cnt = rxq->err_stats.l2_errors + -+ rxq->err_stats.pkt_len_errors; - rte_stats->q_errors[i] = cnt; - rte_stats->q_ipackets[i] = - stats->rcb_rx_ring_pktnum[i] - cnt; -@@ -584,11 +592,11 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - * Clear soft stats of rx error packet which will be dropped - * in driver. - */ -- for (i = 0; i < eth_dev->data->nb_rx_queues; ++i) { -+ for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq) { -- rxq->pkt_len_errors = 0; -- rxq->l2_errors = 0; -+ rxq->err_stats.pkt_len_errors = 0; -+ rxq->err_stats.l2_errors = 0; - } - } - -@@ -621,21 +629,24 @@ static int - hns3_xstats_calc_num(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; -- int bderr_stats = dev->data->nb_rx_queues * HNS3_NUM_RX_BD_ERROR_XSTATS; -- int tx_err_stats = dev->data->nb_tx_queues * HNS3_NUM_TX_ERRORS_XSTATS; -- int rx_queue_stats = dev->data->nb_rx_queues * HNS3_NUM_RX_QUEUE_STATS; -- int tx_queue_stats = dev->data->nb_tx_queues * HNS3_NUM_TX_QUEUE_STATS; -+ uint16_t nb_rx_q = dev->data->nb_rx_queues; -+ uint16_t nb_tx_q = dev->data->nb_tx_queues; -+ int bderr_stats = nb_rx_q * HNS3_NUM_RX_BD_ERROR_XSTATS; -+ int rx_dfx_stats = nb_rx_q * HNS3_NUM_RXQ_DFX_XSTATS; -+ int tx_dfx_stats = nb_tx_q * HNS3_NUM_TXQ_DFX_XSTATS; -+ int rx_queue_stats = nb_rx_q * HNS3_NUM_RX_QUEUE_STATS; -+ int tx_queue_stats = nb_tx_q * HNS3_NUM_TX_QUEUE_STATS; - - if (hns->is_vf) -- return bderr_stats + tx_err_stats + rx_queue_stats + -- tx_queue_stats + HNS3_NUM_RESET_XSTATS; -+ return bderr_stats + rx_dfx_stats + tx_dfx_stats + -+ rx_queue_stats + tx_queue_stats + HNS3_NUM_RESET_XSTATS; - else -- return bderr_stats + tx_err_stats + rx_queue_stats + -- tx_queue_stats + HNS3_FIX_NUM_STATS; -+ return bderr_stats + rx_dfx_stats + tx_dfx_stats + -+ rx_queue_stats + tx_queue_stats + HNS3_FIX_NUM_STATS; - } - - static void --hns3_get_queue_stats(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+hns3_queue_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - int *count) - { - struct hns3_adapter *hns = dev->data->dev_private; -@@ -683,6 +694,63 @@ hns3_error_int_stats_add(struct hns3_adapter *hns, const char *err) - } - } - -+static void -+hns3_rxq_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ struct hns3_rx_dfx_stats *dfx_stats; -+ struct hns3_rx_queue *rxq; -+ uint16_t i, j; -+ char *val; -+ -+ for (i = 0; i < dev->data->nb_rx_queues; i++) { -+ rxq = (struct hns3_rx_queue *)dev->data->rx_queues[i]; -+ if (rxq == NULL) -+ continue; -+ -+ dfx_stats = &rxq->dfx_stats; -+ for (j = 0; j < HNS3_NUM_RXQ_DFX_XSTATS; j++) { -+ val = (char *)dfx_stats + -+ hns3_rxq_dfx_stats_strings[j].offset; -+ xstats[*count].value = *(uint64_t *)val; -+ xstats[*count].id = *count; -+ (*count)++; -+ } -+ } -+} -+ -+static void -+hns3_txq_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ struct hns3_tx_dfx_stats *dfx_stats; -+ struct hns3_tx_queue *txq; -+ uint16_t i, j; -+ char *val; -+ -+ for (i = 0; i < dev->data->nb_tx_queues; i++) { -+ txq = (struct hns3_tx_queue *)dev->data->tx_queues[i]; -+ if (txq == NULL) -+ continue; -+ -+ dfx_stats = &txq->dfx_stats; -+ for (j = 0; j < HNS3_NUM_TXQ_DFX_XSTATS; j++) { -+ val = (char *)dfx_stats + -+ hns3_txq_dfx_stats_strings[j].offset; -+ xstats[*count].value = *(uint64_t *)val; -+ xstats[*count].id = *count; -+ (*count)++; -+ } -+ } -+} -+ -+static void -+hns3_tqp_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ hns3_rxq_dfx_stats_get(dev, xstats, count); -+ hns3_txq_dfx_stats_get(dev, xstats, count); -+} - /* - * Retrieve extended(tqp | Mac) statistics of an Ethernet device. - * @param dev -@@ -705,8 +773,8 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - struct hns3_hw *hw = &hns->hw; - struct hns3_mac_stats *mac_stats = &hw->mac_stats; - struct hns3_reset_stats *reset_stats = &hw->reset.stats; -+ struct hns3_rx_bd_errors_stats *rx_err_stats; - struct hns3_rx_queue *rxq; -- struct hns3_tx_queue *txq; - uint16_t i, j; - char *addr; - int count; -@@ -758,26 +826,49 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - for (j = 0; j < dev->data->nb_rx_queues; j++) { - for (i = 0; i < HNS3_NUM_RX_BD_ERROR_XSTATS; i++) { - rxq = dev->data->rx_queues[j]; -- addr = (char *)rxq + hns3_rx_bd_error_strings[i].offset; -- xstats[count].value = *(uint64_t *)addr; -- xstats[count].id = count; -- count++; -+ if (rxq) { -+ rx_err_stats = &rxq->err_stats; -+ addr = (char *)rx_err_stats + -+ hns3_rx_bd_error_strings[i].offset; -+ xstats[count].value = *(uint64_t *)addr; -+ xstats[count].id = count; -+ count++; -+ } - } - } - -- /* Get the Tx errors stats */ -- for (j = 0; j < dev->data->nb_tx_queues; j++) { -- for (i = 0; i < HNS3_NUM_TX_ERRORS_XSTATS; i++) { -- txq = dev->data->tx_queues[j]; -- addr = (char *)txq + hns3_tx_errors_strings[i].offset; -- xstats[count].value = *(uint64_t *)addr; -- xstats[count].id = count; -- count++; -+ hns3_tqp_dfx_stats_get(dev, xstats, &count); -+ hns3_queue_stats_get(dev, xstats, &count); -+ -+ return count; -+} -+ -+static void -+hns3_tqp_dfx_stats_name_get(struct rte_eth_dev *dev, -+ struct rte_eth_xstat_name *xstats_names, -+ uint32_t *count) -+{ -+ uint16_t i, j; -+ -+ for (j = 0; j < dev->data->nb_rx_queues; j++) { -+ for (i = 0; i < HNS3_NUM_RXQ_DFX_XSTATS; i++) { -+ snprintf(xstats_names[*count].name, -+ sizeof(xstats_names[*count].name), -+ "rx_q%u_%s", j, -+ hns3_rxq_dfx_stats_strings[i].name); -+ (*count)++; - } - } - -- hns3_get_queue_stats(dev, xstats, &count); -- return count; -+ for (j = 0; j < dev->data->nb_tx_queues; j++) { -+ for (i = 0; i < HNS3_NUM_TXQ_DFX_XSTATS; i++) { -+ snprintf(xstats_names[*count].name, -+ sizeof(xstats_names[*count].name), -+ "tx_q%u_%s", j, -+ hns3_txq_dfx_stats_strings[i].name); -+ (*count)++; -+ } -+ } - } - - /* -@@ -845,27 +936,19 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - for (i = 0; i < HNS3_NUM_RX_BD_ERROR_XSTATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), -- "rx_q%u%s", j, -+ "rx_q%u_%s", j, - hns3_rx_bd_error_strings[i].name); - count++; - } - } - -- for (j = 0; j < dev->data->nb_tx_queues; j++) { -- for (i = 0; i < HNS3_NUM_TX_ERRORS_XSTATS; i++) { -- snprintf(xstats_names[count].name, -- sizeof(xstats_names[count].name), -- "tx_q%u%s", j, -- hns3_tx_errors_strings[i].name); -- count++; -- } -- } -+ hns3_tqp_dfx_stats_name_get(dev, xstats_names, &count); - - for (j = 0; j < dev->data->nb_rx_queues; j++) { - for (i = 0; i < HNS3_NUM_RX_QUEUE_STATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), -- "rx_q%u%s", j, hns3_rx_queue_strings[i].name); -+ "rx_q%u_%s", j, hns3_rx_queue_strings[i].name); - count++; - } - } -@@ -874,7 +957,7 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - for (i = 0; i < HNS3_NUM_TX_QUEUE_STATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), -- "tx_q%u%s", j, hns3_tx_queue_strings[i].name); -+ "tx_q%u_%s", j, hns3_tx_queue_strings[i].name); - count++; - } - } -@@ -1043,30 +1126,22 @@ hns3_tqp_dfx_stats_clear(struct rte_eth_dev *dev) - { - struct hns3_rx_queue *rxq; - struct hns3_tx_queue *txq; -- int i; -+ uint16_t i; - - /* Clear Rx dfx stats */ -- for (i = 0; i < dev->data->nb_rx_queues; ++i) { -+ for (i = 0; i < dev->data->nb_rx_queues; i++) { - rxq = dev->data->rx_queues[i]; -- if (rxq) { -- rxq->l3_csum_errors = 0; -- rxq->l4_csum_errors = 0; -- rxq->ol3_csum_errors = 0; -- rxq->ol4_csum_errors = 0; -- } -+ if (rxq) -+ memset(&rxq->dfx_stats, 0, -+ sizeof(struct hns3_rx_dfx_stats)); - } - - /* Clear Tx dfx stats */ -- for (i = 0; i < dev->data->nb_tx_queues; ++i) { -+ for (i = 0; i < dev->data->nb_tx_queues; i++) { - txq = dev->data->tx_queues[i]; -- if (txq) { -- txq->over_length_pkt_cnt = 0; -- txq->exceed_limit_bd_pkt_cnt = 0; -- txq->exceed_limit_bd_reassem_fail = 0; -- txq->unsupported_tunnel_pkt_cnt = 0; -- txq->queue_full_cnt = 0; -- txq->pkt_padding_fail_cnt = 0; -- } -+ if (txq) -+ memset(&txq->dfx_stats, 0, -+ sizeof(struct hns3_tx_dfx_stats)); - } - } - -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index 9fcd5f9..12842cd 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -127,10 +127,13 @@ struct hns3_reset_stats; - (offsetof(struct hns3_reset_stats, f)) - - #define HNS3_RX_BD_ERROR_STATS_FIELD_OFFSET(f) \ -- (offsetof(struct hns3_rx_queue, f)) -+ (offsetof(struct hns3_rx_bd_errors_stats, f)) - --#define HNS3_TX_ERROR_STATS_FIELD_OFFSET(f) \ -- (offsetof(struct hns3_tx_queue, f)) -+#define HNS3_RXQ_DFX_STATS_FIELD_OFFSET(f) \ -+ (offsetof(struct hns3_rx_dfx_stats, f)) -+ -+#define HNS3_TXQ_DFX_STATS_FIELD_OFFSET(f) \ -+ (offsetof(struct hns3_tx_dfx_stats, f)) - - int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); - int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, --- -2.7.4 - diff --git a/0020-net-hns3-move-queue-stats-to-xstats.patch b/0020-net-hns3-move-queue-stats-to-xstats.patch deleted file mode 100644 index 0f24454..0000000 --- a/0020-net-hns3-move-queue-stats-to-xstats.patch +++ /dev/null @@ -1,505 +0,0 @@ -From e658ac6ea47f304cb8b0c9e8e100dd1016bcac0b Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Jan 2021 18:18:40 +0800 -Subject: [PATCH 020/189] net/hns3: move queue stats to xstats - -One of the hot discussions in community recently was moving queue stats -to xstats. In this solution, a temporary -'RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS' device flag is created to implement -the smooth switch. And the first half of this work has been completed in -the ethdev framework. Now driver needs to remove the flag from the -driver initialization process and does the rest of work. - -For better readability and reasonability, per-queue stats also should be -cleared when rte_eth_stats is cleared. Otherwise, the sum of one item in -per-queue stats may be greater than corresponding item in rte_eth_stats. - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 2 - - drivers/net/hns3/hns3_ethdev_vf.c | 2 - - drivers/net/hns3/hns3_rxtx.c | 2 + - drivers/net/hns3/hns3_rxtx.h | 13 ++ - drivers/net/hns3/hns3_stats.c | 241 +++++++++++++++++++++++++++++++------- - drivers/net/hns3/hns3_stats.h | 6 + - 6 files changed, 221 insertions(+), 45 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 449d967..7c51e83 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6148,8 +6148,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - return 0; - } - -- eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; -- - ret = hns3_mp_init_primary(); - if (ret) { - PMD_INIT_LOG(ERR, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index bb4ec6b..37135d7 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2746,8 +2746,6 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - return 0; - } - -- eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; -- - ret = hns3_mp_init_primary(); - if (ret) { - PMD_INIT_LOG(ERR, -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 3d5f74f..30f1e06 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1792,6 +1792,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - rxq->io_head_reg = (volatile void *)((char *)rxq->io_base + - HNS3_RING_RX_HEAD_REG); - rxq->rx_buf_len = rx_buf_size; -+ memset(&rxq->basic_stats, 0, sizeof(struct hns3_rx_basic_stats)); - memset(&rxq->err_stats, 0, sizeof(struct hns3_rx_bd_errors_stats)); - memset(&rxq->dfx_stats, 0, sizeof(struct hns3_rx_dfx_stats)); - -@@ -2618,6 +2619,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - HNS3_RING_TX_TAIL_REG); - txq->min_tx_pkt_len = hw->min_tx_pkt_len; - txq->tso_mode = hw->tso_mode; -+ memset(&txq->basic_stats, 0, sizeof(struct hns3_tx_basic_stats)); - memset(&txq->dfx_stats, 0, sizeof(struct hns3_tx_dfx_stats)); - - rte_spinlock_lock(&hw->lock); -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 8a0c981..331b507 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -266,6 +266,12 @@ struct hns3_entry { - struct rte_mbuf *mbuf; - }; - -+struct hns3_rx_basic_stats { -+ uint64_t packets; -+ uint64_t bytes; -+ uint64_t errors; -+}; -+ - struct hns3_rx_dfx_stats { - uint64_t l3_csum_errors; - uint64_t l4_csum_errors; -@@ -324,6 +330,7 @@ struct hns3_rx_queue { - bool pvid_sw_discard_en; - bool enabled; /* indicate if Rx queue has been enabled */ - -+ struct hns3_rx_basic_stats basic_stats; - /* DFX statistics that driver does not need to discard packets */ - struct hns3_rx_dfx_stats dfx_stats; - /* Error statistics that driver needs to discard packets */ -@@ -338,6 +345,11 @@ struct hns3_rx_queue { - struct rte_mbuf fake_mbuf; /* fake mbuf used with vector rx */ - }; - -+struct hns3_tx_basic_stats { -+ uint64_t packets; -+ uint64_t bytes; -+}; -+ - /* - * The following items are used for the abnormal errors statistics in - * the Tx datapath. When upper level application calls the -@@ -472,6 +484,7 @@ struct hns3_tx_queue { - bool pvid_sw_shift_en; - bool enabled; /* indicate if Tx queue has been enabled */ - -+ struct hns3_tx_basic_stats basic_stats; - struct hns3_tx_dfx_stats dfx_stats; - }; - -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 419d7e2..3ba09e2 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -11,6 +11,24 @@ - #include "hns3_logs.h" - #include "hns3_regs.h" - -+/* The statistics of the per-rxq basic stats */ -+static const struct hns3_xstats_name_offset hns3_rxq_basic_stats_strings[] = { -+ {"packets", -+ HNS3_RXQ_BASIC_STATS_FIELD_OFFSET(packets)}, -+ {"bytes", -+ HNS3_RXQ_BASIC_STATS_FIELD_OFFSET(bytes)}, -+ {"errors", -+ HNS3_RXQ_BASIC_STATS_FIELD_OFFSET(errors)} -+}; -+ -+/* The statistics of the per-txq basic stats */ -+static const struct hns3_xstats_name_offset hns3_txq_basic_stats_strings[] = { -+ {"packets", -+ HNS3_TXQ_BASIC_STATS_FIELD_OFFSET(packets)}, -+ {"bytes", -+ HNS3_TXQ_BASIC_STATS_FIELD_OFFSET(bytes)} -+}; -+ - /* MAC statistics */ - static const struct hns3_xstats_name_offset hns3_mac_strings[] = { - {"mac_tx_mac_pause_num", -@@ -330,6 +348,12 @@ static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = { - #define HNS3_NUM_TX_QUEUE_STATS (sizeof(hns3_tx_queue_strings) / \ - sizeof(hns3_tx_queue_strings[0])) - -+#define HNS3_NUM_RXQ_BASIC_STATS (sizeof(hns3_rxq_basic_stats_strings) / \ -+ sizeof(hns3_rxq_basic_stats_strings[0])) -+ -+#define HNS3_NUM_TXQ_BASIC_STATS (sizeof(hns3_txq_basic_stats_strings) / \ -+ sizeof(hns3_txq_basic_stats_strings[0])) -+ - #define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + HNS3_NUM_ERROR_INT_XSTATS + \ - HNS3_NUM_RESET_XSTATS) - -@@ -508,9 +532,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - struct hns3_hw *hw = &hns->hw; - struct hns3_tqp_stats *stats = &hw->tqp_stats; - struct hns3_rx_queue *rxq; -- struct hns3_tx_queue *txq; - uint64_t cnt; -- uint64_t num; - uint16_t i; - int ret; - -@@ -522,25 +544,14 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - } - - /* Get the error stats of received packets */ -- num = RTE_MIN(RTE_ETHDEV_QUEUE_STAT_CNTRS, eth_dev->data->nb_rx_queues); -- for (i = 0; i != num; ++i) { -+ for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq) { - cnt = rxq->err_stats.l2_errors + - rxq->err_stats.pkt_len_errors; -- rte_stats->q_errors[i] = cnt; -- rte_stats->q_ipackets[i] = -- stats->rcb_rx_ring_pktnum[i] - cnt; - rte_stats->ierrors += cnt; - } - } -- /* Get the error stats of transmitted packets */ -- num = RTE_MIN(RTE_ETHDEV_QUEUE_STAT_CNTRS, eth_dev->data->nb_tx_queues); -- for (i = 0; i < num; i++) { -- txq = eth_dev->data->tx_queues[i]; -- if (txq) -- rte_stats->q_opackets[i] = stats->rcb_tx_ring_pktnum[i]; -- } - - rte_stats->oerrors = 0; - rte_stats->ipackets = stats->rcb_rx_ring_pktnum_rcd - -@@ -600,6 +611,11 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - } - } - -+ /* -+ * 'packets' in hns3_tx_basic_stats and hns3_rx_basic_stats come -+ * from hw->tqp_stats. And clearing tqp stats is like clearing -+ * their source. -+ */ - hns3_tqp_stats_clear(hw); - - return 0; -@@ -628,21 +644,26 @@ hns3_mac_stats_reset(__rte_unused struct rte_eth_dev *dev) - static int - hns3_xstats_calc_num(struct rte_eth_dev *dev) - { -+#define HNS3_PF_VF_RX_COMM_STATS_NUM (HNS3_NUM_RX_BD_ERROR_XSTATS + \ -+ HNS3_NUM_RXQ_DFX_XSTATS + \ -+ HNS3_NUM_RX_QUEUE_STATS + \ -+ HNS3_NUM_RXQ_BASIC_STATS) -+#define HNS3_PF_VF_TX_COMM_STATS_NUM (HNS3_NUM_TXQ_DFX_XSTATS + \ -+ HNS3_NUM_TX_QUEUE_STATS + \ -+ HNS3_NUM_TXQ_BASIC_STATS) -+ - struct hns3_adapter *hns = dev->data->dev_private; - uint16_t nb_rx_q = dev->data->nb_rx_queues; - uint16_t nb_tx_q = dev->data->nb_tx_queues; -- int bderr_stats = nb_rx_q * HNS3_NUM_RX_BD_ERROR_XSTATS; -- int rx_dfx_stats = nb_rx_q * HNS3_NUM_RXQ_DFX_XSTATS; -- int tx_dfx_stats = nb_tx_q * HNS3_NUM_TXQ_DFX_XSTATS; -- int rx_queue_stats = nb_rx_q * HNS3_NUM_RX_QUEUE_STATS; -- int tx_queue_stats = nb_tx_q * HNS3_NUM_TX_QUEUE_STATS; -+ int rx_comm_stats_num = nb_rx_q * HNS3_PF_VF_RX_COMM_STATS_NUM; -+ int tx_comm_stats_num = nb_tx_q * HNS3_PF_VF_TX_COMM_STATS_NUM; - - if (hns->is_vf) -- return bderr_stats + rx_dfx_stats + tx_dfx_stats + -- rx_queue_stats + tx_queue_stats + HNS3_NUM_RESET_XSTATS; -+ return rx_comm_stats_num + tx_comm_stats_num + -+ HNS3_NUM_RESET_XSTATS; - else -- return bderr_stats + rx_dfx_stats + tx_dfx_stats + -- rx_queue_stats + tx_queue_stats + HNS3_FIX_NUM_STATS; -+ return rx_comm_stats_num + tx_comm_stats_num + -+ HNS3_FIX_NUM_STATS; - } - - static void -@@ -751,6 +772,118 @@ hns3_tqp_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - hns3_rxq_dfx_stats_get(dev, xstats, count); - hns3_txq_dfx_stats_get(dev, xstats, count); - } -+ -+static void -+hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_tqp_stats *stats = &hw->tqp_stats; -+ struct hns3_rx_basic_stats *rxq_stats; -+ struct hns3_rx_queue *rxq; -+ uint16_t i, j; -+ char *val; -+ -+ for (i = 0; i < dev->data->nb_rx_queues; i++) { -+ rxq = dev->data->rx_queues[i]; -+ if (rxq == NULL) -+ continue; -+ -+ rxq_stats = &rxq->basic_stats; -+ rxq_stats->errors = rxq->err_stats.l2_errors + -+ rxq->err_stats.pkt_len_errors; -+ rxq_stats->packets = stats->rcb_rx_ring_pktnum[i] - -+ rxq_stats->errors; -+ rxq_stats->bytes = 0; -+ for (j = 0; j < HNS3_NUM_RXQ_BASIC_STATS; j++) { -+ val = (char *)rxq_stats + -+ hns3_rxq_basic_stats_strings[j].offset; -+ xstats[*count].value = *(uint64_t *)val; -+ xstats[*count].id = *count; -+ (*count)++; -+ } -+ } -+} -+ -+static void -+hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_tqp_stats *stats = &hw->tqp_stats; -+ struct hns3_tx_basic_stats *txq_stats; -+ struct hns3_tx_queue *txq; -+ uint16_t i, j; -+ char *val; -+ -+ for (i = 0; i < dev->data->nb_tx_queues; i++) { -+ txq = dev->data->tx_queues[i]; -+ if (txq == NULL) -+ continue; -+ -+ txq_stats = &txq->basic_stats; -+ txq_stats->packets = stats->rcb_tx_ring_pktnum[i]; -+ txq_stats->bytes = 0; -+ for (j = 0; j < HNS3_NUM_TXQ_BASIC_STATS; j++) { -+ val = (char *)txq_stats + -+ hns3_txq_basic_stats_strings[j].offset; -+ xstats[*count].value = *(uint64_t *)val; -+ xstats[*count].id = *count; -+ (*count)++; -+ } -+ } -+} -+ -+static int -+hns3_tqp_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ /* Update tqp stats by read register */ -+ ret = hns3_update_tqp_stats(hw); -+ if (ret) { -+ hns3_err(hw, "Update tqp stats fail, ret = %d.", ret); -+ return ret; -+ } -+ -+ hns3_rxq_basic_stats_get(dev, xstats, count); -+ hns3_txq_basic_stats_get(dev, xstats, count); -+ -+ return 0; -+} -+ -+/* -+ * The function is only called by hns3_dev_xstats_reset to clear -+ * basic stats of per-queue. TQP stats are all cleared in hns3_stats_reset -+ * which is called before this function. -+ * -+ * @param dev -+ * Pointer to Ethernet device. -+ */ -+static void -+hns3_tqp_basic_stats_clear(struct rte_eth_dev *dev) -+{ -+ struct hns3_tx_queue *txq; -+ struct hns3_rx_queue *rxq; -+ uint16_t i; -+ -+ for (i = 0; i < dev->data->nb_rx_queues; i++) { -+ rxq = dev->data->rx_queues[i]; -+ if (rxq) -+ memset(&rxq->basic_stats, 0, -+ sizeof(struct hns3_rx_basic_stats)); -+ } -+ -+ for (i = 0; i < dev->data->nb_tx_queues; i++) { -+ txq = dev->data->tx_queues[i]; -+ if (txq) -+ memset(&txq->basic_stats, 0, -+ sizeof(struct hns3_tx_basic_stats)); -+ } -+} -+ - /* - * Retrieve extended(tqp | Mac) statistics of an Ethernet device. - * @param dev -@@ -789,6 +922,10 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - - count = 0; - -+ ret = hns3_tqp_basic_stats_get(dev, xstats, &count); -+ if (ret < 0) -+ return ret; -+ - if (!hns->is_vf) { - /* Update Mac stats */ - ret = hns3_query_update_mac_stats(dev); -@@ -844,28 +981,55 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - } - - static void -+hns3_tqp_basic_stats_name_get(struct rte_eth_dev *dev, -+ struct rte_eth_xstat_name *xstats_names, -+ uint32_t *count) -+{ -+ uint16_t i, j; -+ -+ for (i = 0; i < dev->data->nb_rx_queues; i++) { -+ for (j = 0; j < HNS3_NUM_RXQ_BASIC_STATS; j++) { -+ snprintf(xstats_names[*count].name, -+ sizeof(xstats_names[*count].name), -+ "rx_q%u_%s", i, -+ hns3_rxq_basic_stats_strings[j].name); -+ (*count)++; -+ } -+ } -+ for (i = 0; i < dev->data->nb_tx_queues; i++) { -+ for (j = 0; j < HNS3_NUM_TXQ_BASIC_STATS; j++) { -+ snprintf(xstats_names[*count].name, -+ sizeof(xstats_names[*count].name), -+ "tx_q%u_%s", i, -+ hns3_txq_basic_stats_strings[j].name); -+ (*count)++; -+ } -+ } -+} -+ -+static void - hns3_tqp_dfx_stats_name_get(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - uint32_t *count) - { - uint16_t i, j; - -- for (j = 0; j < dev->data->nb_rx_queues; j++) { -- for (i = 0; i < HNS3_NUM_RXQ_DFX_XSTATS; i++) { -+ for (i = 0; i < dev->data->nb_rx_queues; i++) { -+ for (j = 0; j < HNS3_NUM_RXQ_DFX_XSTATS; j++) { - snprintf(xstats_names[*count].name, - sizeof(xstats_names[*count].name), -- "rx_q%u_%s", j, -- hns3_rxq_dfx_stats_strings[i].name); -+ "rx_q%u_%s", i, -+ hns3_rxq_dfx_stats_strings[j].name); - (*count)++; - } - } - -- for (j = 0; j < dev->data->nb_tx_queues; j++) { -- for (i = 0; i < HNS3_NUM_TXQ_DFX_XSTATS; i++) { -+ for (i = 0; i < dev->data->nb_tx_queues; i++) { -+ for (j = 0; j < HNS3_NUM_TXQ_DFX_XSTATS; j++) { - snprintf(xstats_names[*count].name, - sizeof(xstats_names[*count].name), -- "tx_q%u_%s", j, -- hns3_txq_dfx_stats_strings[i].name); -+ "tx_q%u_%s", i, -+ hns3_txq_dfx_stats_strings[j].name); - (*count)++; - } - } -@@ -908,6 +1072,8 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - if (xstats_names == NULL) - return cnt_stats; - -+ hns3_tqp_basic_stats_name_get(dev, xstats_names, &count); -+ - /* Note: size limited checked in rte_eth_xstats_get_names() */ - if (!hns->is_vf) { - /* Get MAC name from hw->hw_xstats.mac_stats struct */ -@@ -999,7 +1165,6 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, - uint32_t count_value; - uint64_t len; - uint32_t i; -- int ret; - - if (ids == NULL && values == NULL) - return cnt_stats; -@@ -1008,13 +1173,6 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, - if (size < cnt_stats) - return cnt_stats; - -- /* Update tqp stats by read register */ -- ret = hns3_update_tqp_stats(hw); -- if (ret) { -- hns3_err(hw, "Update tqp stats fail : %d", ret); -- return ret; -- } -- - len = cnt_stats * sizeof(struct rte_eth_xstat); - values_copy = rte_zmalloc("hns3_xstats_values", len, 0); - if (values_copy == NULL) { -@@ -1157,11 +1315,12 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) - if (ret) - return ret; - -+ hns3_tqp_basic_stats_clear(dev); -+ hns3_tqp_dfx_stats_clear(dev); -+ - /* Clear reset stats */ - memset(&hns->hw.reset.stats, 0, sizeof(struct hns3_reset_stats)); - -- hns3_tqp_dfx_stats_clear(dev); -- - if (hns->is_vf) - return 0; - -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index 12842cd..d213be5 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -135,6 +135,12 @@ struct hns3_reset_stats; - #define HNS3_TXQ_DFX_STATS_FIELD_OFFSET(f) \ - (offsetof(struct hns3_tx_dfx_stats, f)) - -+#define HNS3_RXQ_BASIC_STATS_FIELD_OFFSET(f) \ -+ (offsetof(struct hns3_rx_basic_stats, f)) -+ -+#define HNS3_TXQ_BASIC_STATS_FIELD_OFFSET(f) \ -+ (offsetof(struct hns3_tx_basic_stats, f)) -+ - int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); - int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - unsigned int n); --- -2.7.4 - diff --git a/0021-net-hns3-refactor-converting-descriptor-error.patch b/0021-net-hns3-refactor-converting-descriptor-error.patch deleted file mode 100644 index f5693b4..0000000 --- a/0021-net-hns3-refactor-converting-descriptor-error.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 17327e444434b1062063a03060d6cc5a1876aa3f Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:41 +0800 -Subject: [PATCH 021/189] net/hns3: refactor converting descriptor error - -Use errno array instead of switch-case for refactor -the hns3_cmd_convert_err_code function. - -Besides, we add a type for ROH(RDMA Over HCCS) check -cmdq return error in Kunpeng930 NIC hardware. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.c | 54 ++++++++++++++++++++++----------------------- - drivers/net/hns3/hns3_cmd.h | 1 + - 2 files changed, 27 insertions(+), 28 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index f58f4f7..4c301cb 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -247,34 +247,32 @@ hns3_is_special_opcode(uint16_t opcode) - static int - hns3_cmd_convert_err_code(uint16_t desc_ret) - { -- switch (desc_ret) { -- case HNS3_CMD_EXEC_SUCCESS: -- return 0; -- case HNS3_CMD_NO_AUTH: -- return -EPERM; -- case HNS3_CMD_NOT_SUPPORTED: -- return -EOPNOTSUPP; -- case HNS3_CMD_QUEUE_FULL: -- return -EXFULL; -- case HNS3_CMD_NEXT_ERR: -- return -ENOSR; -- case HNS3_CMD_UNEXE_ERR: -- return -ENOTBLK; -- case HNS3_CMD_PARA_ERR: -- return -EINVAL; -- case HNS3_CMD_RESULT_ERR: -- return -ERANGE; -- case HNS3_CMD_TIMEOUT: -- return -ETIME; -- case HNS3_CMD_HILINK_ERR: -- return -ENOLINK; -- case HNS3_CMD_QUEUE_ILLEGAL: -- return -ENXIO; -- case HNS3_CMD_INVALID: -- return -EBADR; -- default: -- return -EREMOTEIO; -- } -+ static const struct { -+ uint16_t imp_errcode; -+ int linux_errcode; -+ } hns3_cmdq_status[] = { -+ {HNS3_CMD_EXEC_SUCCESS, 0}, -+ {HNS3_CMD_NO_AUTH, -EPERM}, -+ {HNS3_CMD_NOT_SUPPORTED, -EOPNOTSUPP}, -+ {HNS3_CMD_QUEUE_FULL, -EXFULL}, -+ {HNS3_CMD_NEXT_ERR, -ENOSR}, -+ {HNS3_CMD_UNEXE_ERR, -ENOTBLK}, -+ {HNS3_CMD_PARA_ERR, -EINVAL}, -+ {HNS3_CMD_RESULT_ERR, -ERANGE}, -+ {HNS3_CMD_TIMEOUT, -ETIME}, -+ {HNS3_CMD_HILINK_ERR, -ENOLINK}, -+ {HNS3_CMD_QUEUE_ILLEGAL, -ENXIO}, -+ {HNS3_CMD_INVALID, -EBADR}, -+ {HNS3_CMD_ROH_CHECK_FAIL, -EINVAL} -+ }; -+ -+ uint32_t i; -+ -+ for (i = 0; i < ARRAY_SIZE(hns3_cmdq_status); i++) -+ if (hns3_cmdq_status[i].imp_errcode == desc_ret) -+ return hns3_cmdq_status[i].linux_errcode; -+ -+ return -EREMOTEIO; - } - - static int -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index e40293b..6152f6e 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -52,6 +52,7 @@ enum hns3_cmd_return_status { - HNS3_CMD_HILINK_ERR = 9, - HNS3_CMD_QUEUE_ILLEGAL = 10, - HNS3_CMD_INVALID = 11, -+ HNS3_CMD_ROH_CHECK_FAIL = 12 - }; - - enum hns3_cmd_status { --- -2.7.4 - diff --git a/0022-net-hns3-refactor-flow-checks-into-own-functions.patch b/0022-net-hns3-refactor-flow-checks-into-own-functions.patch deleted file mode 100644 index 7b041c6..0000000 --- a/0022-net-hns3-refactor-flow-checks-into-own-functions.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 2d64078bc27c055bfeb486230ea64eebe1cb65cb Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:42 +0800 -Subject: [PATCH 022/189] net/hns3: refactor flow checks into own functions - -Here moves some judgement conditions to a separated function -for parsing IPv4 hdr and TCP hdr in hns3_parse_normal function. -Also, move the check of the selected input tuple of RSS to a -separated functions named hns3_rss_input_tuple_supported -in order to enhance scalability and complexity. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 69 ++++++++++++++++++++++++++++++-------------- - 1 file changed, 48 insertions(+), 21 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index f303df4..889fa2f 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -525,6 +525,17 @@ hns3_parse_vlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - return 0; - } - -+static bool -+hns3_check_ipv4_mask_supported(const struct rte_flow_item_ipv4 *ipv4_mask) -+{ -+ if (ipv4_mask->hdr.total_length || ipv4_mask->hdr.packet_id || -+ ipv4_mask->hdr.fragment_offset || ipv4_mask->hdr.time_to_live || -+ ipv4_mask->hdr.hdr_checksum) -+ return false; -+ -+ return true; -+} -+ - static int - hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - struct rte_flow_error *error) -@@ -546,11 +557,7 @@ hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - - if (item->mask) { - ipv4_mask = item->mask; -- if (ipv4_mask->hdr.total_length || -- ipv4_mask->hdr.packet_id || -- ipv4_mask->hdr.fragment_offset || -- ipv4_mask->hdr.time_to_live || -- ipv4_mask->hdr.hdr_checksum) { -+ if (!hns3_check_ipv4_mask_supported(ipv4_mask)) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_MASK, - item, -@@ -648,6 +655,18 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - return 0; - } - -+static bool -+hns3_check_tcp_mask_supported(const struct rte_flow_item_tcp *tcp_mask) -+{ -+ if (tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack || -+ tcp_mask->hdr.data_off || tcp_mask->hdr.tcp_flags || -+ tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum || -+ tcp_mask->hdr.tcp_urp) -+ return false; -+ -+ return true; -+} -+ - static int - hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - struct rte_flow_error *error) -@@ -670,10 +689,7 @@ hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - - if (item->mask) { - tcp_mask = item->mask; -- if (tcp_mask->hdr.sent_seq || tcp_mask->hdr.recv_ack || -- tcp_mask->hdr.data_off || tcp_mask->hdr.tcp_flags || -- tcp_mask->hdr.rx_win || tcp_mask->hdr.cksum || -- tcp_mask->hdr.tcp_urp) { -+ if (!hns3_check_tcp_mask_supported(tcp_mask)) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ITEM_MASK, - item, -@@ -1328,6 +1344,28 @@ hns3_rss_conf_copy(struct hns3_rss_conf *out, - return 0; - } - -+static bool -+hns3_rss_input_tuple_supported(struct hns3_hw *hw, -+ const struct rte_flow_action_rss *rss) -+{ -+ /* -+ * For IP packet, it is not supported to use src/dst port fields to RSS -+ * hash for the following packet types. -+ * - IPV4 FRAG | IPV4 NONFRAG | IPV6 FRAG | IPV6 NONFRAG -+ * Besides, for Kunpeng920, the NIC HW is not supported to use src/dst -+ * port fields to RSS hash for IPV6 SCTP packet type. However, the -+ * Kunpeng930 and future kunpeng series support to use src/dst port -+ * fields to RSS hash for IPv6 SCTP packet type. -+ */ -+ if (rss->types & (ETH_RSS_L4_DST_ONLY | ETH_RSS_L4_SRC_ONLY) && -+ (rss->types & ETH_RSS_IP || -+ (!hw->rss_info.ipv6_sctp_offload_supported && -+ rss->types & ETH_RSS_NONFRAG_IPV6_SCTP))) -+ return false; -+ -+ return true; -+} -+ - /* - * This function is used to parse rss action validatation. - */ -@@ -1386,18 +1424,7 @@ hns3_parse_rss_filter(struct rte_eth_dev *dev, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, act, - "RSS hash key must be exactly 40 bytes"); - -- /* -- * For Kunpeng920 and Kunpeng930 NIC hardware, it is not supported to -- * use dst port/src port fields to RSS hash for the following packet -- * types. -- * - IPV4 FRAG | IPV4 NONFRAG | IPV6 FRAG | IPV6 NONFRAG -- * Besides, for Kunpeng920, The NIC hardware is not supported to use -- * src/dst port fields to RSS hash for IPV6 SCTP packet type. -- */ -- if (rss->types & (ETH_RSS_L4_DST_ONLY | ETH_RSS_L4_SRC_ONLY) && -- (rss->types & ETH_RSS_IP || -- (!hw->rss_info.ipv6_sctp_offload_supported && -- rss->types & ETH_RSS_NONFRAG_IPV6_SCTP))) -+ if (!hns3_rss_input_tuple_supported(hw, rss)) - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, - &rss->types, --- -2.7.4 - diff --git a/0023-net-hns3-reconstruct-Rx-interrupt-map.patch b/0023-net-hns3-reconstruct-Rx-interrupt-map.patch deleted file mode 100644 index e7850d9..0000000 --- a/0023-net-hns3-reconstruct-Rx-interrupt-map.patch +++ /dev/null @@ -1,190 +0,0 @@ -From badcc5f38dcf223578f870574653fdd20e00c6f8 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Fri, 22 Jan 2021 18:18:43 +0800 -Subject: [PATCH 023/189] net/hns3: reconstruct Rx interrupt map - -This patch reconstruct the Rx interrupt map to reduce the cyclic -complexity and improve readability and maintainability. - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 59 +++++++++++++++++++-------------------- - drivers/net/hns3/hns3_ethdev_vf.c | 55 ++++++++++++++++++------------------ - 2 files changed, 56 insertions(+), 58 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7c51e83..f3ce639 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4782,27 +4782,28 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev) - uint16_t q_id; - int ret; - -- if (dev->data->dev_conf.intr_conf.rxq == 0) -+ /* -+ * hns3 needs a separate interrupt to be used as event interrupt which -+ * could not be shared with task queue pair, so KERNEL drivers need -+ * support multiple interrupt vectors. -+ */ -+ if (dev->data->dev_conf.intr_conf.rxq == 0 || -+ !rte_intr_cap_multiple(intr_handle)) - return 0; - -- /* disable uio/vfio intr/eventfd mapping */ - rte_intr_disable(intr_handle); -+ intr_vector = hw->used_rx_queues; -+ /* creates event fd for each intr vector when MSIX is used */ -+ if (rte_intr_efd_enable(intr_handle, intr_vector)) -+ return -EINVAL; - -- /* check and configure queue intr-vector mapping */ -- if (rte_intr_cap_multiple(intr_handle) || -- !RTE_ETH_DEV_SRIOV(dev).active) { -- intr_vector = hw->used_rx_queues; -- /* creates event fd for each intr vector when MSIX is used */ -- if (rte_intr_efd_enable(intr_handle, intr_vector)) -- return -EINVAL; -- } -- if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) { -+ if (intr_handle->intr_vec == NULL) { - intr_handle->intr_vec = - rte_zmalloc("intr_vec", - hw->used_rx_queues * sizeof(int), 0); - if (intr_handle->intr_vec == NULL) { -- hns3_err(hw, "Failed to allocate %u rx_queues" -- " intr_vec", hw->used_rx_queues); -+ hns3_err(hw, "failed to allocate %u rx_queues intr_vec", -+ hw->used_rx_queues); - ret = -ENOMEM; - goto alloc_intr_vec_error; - } -@@ -4812,28 +4813,26 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev) - vec = RTE_INTR_VEC_RXTX_OFFSET; - base = RTE_INTR_VEC_RXTX_OFFSET; - } -- if (rte_intr_dp_is_en(intr_handle)) { -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- ret = hns3_bind_ring_with_vector(hw, vec, true, -- HNS3_RING_TYPE_RX, -- q_id); -- if (ret) -- goto bind_vector_error; -- intr_handle->intr_vec[q_id] = vec; -- if (vec < base + intr_handle->nb_efd - 1) -- vec++; -- } -+ -+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -+ ret = hns3_bind_ring_with_vector(hw, vec, true, -+ HNS3_RING_TYPE_RX, q_id); -+ if (ret) -+ goto bind_vector_error; -+ intr_handle->intr_vec[q_id] = vec; -+ /* -+ * If there are not enough efds (e.g. not enough interrupt), -+ * remaining queues will be bond to the last interrupt. -+ */ -+ if (vec < base + intr_handle->nb_efd - 1) -+ vec++; - } - rte_intr_enable(intr_handle); - return 0; - - bind_vector_error: -- rte_intr_efd_disable(intr_handle); -- if (intr_handle->intr_vec) { -- free(intr_handle->intr_vec); -- intr_handle->intr_vec = NULL; -- } -- return ret; -+ rte_free(intr_handle->intr_vec); -+ intr_handle->intr_vec = NULL; - alloc_intr_vec_error: - rte_intr_efd_disable(intr_handle); - return ret; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 37135d7..3a1d4cb 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2085,21 +2085,22 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) - uint16_t q_id; - int ret; - -- if (dev->data->dev_conf.intr_conf.rxq == 0) -+ /* -+ * hns3 needs a separate interrupt to be used as event interrupt which -+ * could not be shared with task queue pair, so KERNEL drivers need -+ * support multiple interrupt vectors. -+ */ -+ if (dev->data->dev_conf.intr_conf.rxq == 0 || -+ !rte_intr_cap_multiple(intr_handle)) - return 0; - -- /* disable uio/vfio intr/eventfd mapping */ - rte_intr_disable(intr_handle); -+ intr_vector = hw->used_rx_queues; -+ /* It creates event fd for each intr vector when MSIX is used */ -+ if (rte_intr_efd_enable(intr_handle, intr_vector)) -+ return -EINVAL; - -- /* check and configure queue intr-vector mapping */ -- if (rte_intr_cap_multiple(intr_handle) || -- !RTE_ETH_DEV_SRIOV(dev).active) { -- intr_vector = hw->used_rx_queues; -- /* It creates event fd for each intr vector when MSIX is used */ -- if (rte_intr_efd_enable(intr_handle, intr_vector)) -- return -EINVAL; -- } -- if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) { -+ if (intr_handle->intr_vec == NULL) { - intr_handle->intr_vec = - rte_zmalloc("intr_vec", - hw->used_rx_queues * sizeof(int), 0); -@@ -2115,28 +2116,26 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) - vec = RTE_INTR_VEC_RXTX_OFFSET; - base = RTE_INTR_VEC_RXTX_OFFSET; - } -- if (rte_intr_dp_is_en(intr_handle)) { -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- ret = hns3vf_bind_ring_with_vector(hw, vec, true, -- HNS3_RING_TYPE_RX, -- q_id); -- if (ret) -- goto vf_bind_vector_error; -- intr_handle->intr_vec[q_id] = vec; -- if (vec < base + intr_handle->nb_efd - 1) -- vec++; -- } -+ -+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -+ ret = hns3vf_bind_ring_with_vector(hw, vec, true, -+ HNS3_RING_TYPE_RX, q_id); -+ if (ret) -+ goto vf_bind_vector_error; -+ intr_handle->intr_vec[q_id] = vec; -+ /* -+ * If there are not enough efds (e.g. not enough interrupt), -+ * remaining queues will be bond to the last interrupt. -+ */ -+ if (vec < base + intr_handle->nb_efd - 1) -+ vec++; - } - rte_intr_enable(intr_handle); - return 0; - - vf_bind_vector_error: -- rte_intr_efd_disable(intr_handle); -- if (intr_handle->intr_vec) { -- free(intr_handle->intr_vec); -- intr_handle->intr_vec = NULL; -- } -- return ret; -+ free(intr_handle->intr_vec); -+ intr_handle->intr_vec = NULL; - vf_alloc_intr_vec_error: - rte_intr_efd_disable(intr_handle); - return ret; --- -2.7.4 - diff --git a/0024-net-hns3-extract-common-checks-for-flow-director.patch b/0024-net-hns3-extract-common-checks-for-flow-director.patch deleted file mode 100644 index df9ed91..0000000 --- a/0024-net-hns3-extract-common-checks-for-flow-director.patch +++ /dev/null @@ -1,197 +0,0 @@ -From ea7fb351ca32444916ea099c644d1f29295ffdeb Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:44 +0800 -Subject: [PATCH 024/189] net/hns3: extract common checks for flow director - -When parse flow director with all types, it needs to judge the spec -of item and mask of item for all packet types. The judgement is the -same for all types. Therefore, we move it into the concentrated -location. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 84 +++++++++++--------------------------------- - 1 file changed, 20 insertions(+), 64 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 889fa2f..9b161f4 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -433,17 +433,12 @@ hns3_check_attr(const struct rte_flow_attr *attr, struct rte_flow_error *error) - } - - static int --hns3_parse_eth(const struct rte_flow_item *item, -- struct hns3_fdir_rule *rule, struct rte_flow_error *error) -+hns3_parse_eth(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, -+ struct rte_flow_error *error __rte_unused) - { - const struct rte_flow_item_eth *eth_spec; - const struct rte_flow_item_eth *eth_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - /* Only used to describe the protocol stack. */ - if (item->spec == NULL && item->mask == NULL) - return 0; -@@ -483,11 +478,6 @@ hns3_parse_vlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_vlan *vlan_spec; - const struct rte_flow_item_vlan *vlan_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - rule->key_conf.vlan_num++; - if (rule->key_conf.vlan_num > VLAN_TAG_NUM_MAX) - return rte_flow_error_set(error, EINVAL, -@@ -543,14 +533,10 @@ hns3_parse_ipv4(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_ipv4 *ipv4_spec; - const struct rte_flow_item_ipv4 *ipv4_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - hns3_set_bit(rule->input_set, INNER_ETH_TYPE, 1); - rule->key_conf.spec.ether_type = RTE_ETHER_TYPE_IPV4; - rule->key_conf.mask.ether_type = ETHER_TYPE_MASK; -+ - /* Only used to describe the protocol stack. */ - if (item->spec == NULL && item->mask == NULL) - return 0; -@@ -606,11 +592,6 @@ hns3_parse_ipv6(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_ipv6 *ipv6_spec; - const struct rte_flow_item_ipv6 *ipv6_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - hns3_set_bit(rule->input_set, INNER_ETH_TYPE, 1); - rule->key_conf.spec.ether_type = RTE_ETHER_TYPE_IPV6; - rule->key_conf.mask.ether_type = ETHER_TYPE_MASK; -@@ -674,11 +655,6 @@ hns3_parse_tcp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_tcp *tcp_spec; - const struct rte_flow_item_tcp *tcp_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1); - rule->key_conf.spec.ip_proto = IPPROTO_TCP; - rule->key_conf.mask.ip_proto = IPPROTO_MASK; -@@ -722,11 +698,6 @@ hns3_parse_udp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_udp *udp_spec; - const struct rte_flow_item_udp *udp_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1); - rule->key_conf.spec.ip_proto = IPPROTO_UDP; - rule->key_conf.mask.ip_proto = IPPROTO_MASK; -@@ -768,11 +739,6 @@ hns3_parse_sctp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_sctp *sctp_spec; - const struct rte_flow_item_sctp *sctp_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- - hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1); - rule->key_conf.spec.ip_proto = IPPROTO_SCTP; - rule->key_conf.mask.ip_proto = IPPROTO_MASK; -@@ -904,15 +870,6 @@ hns3_parse_vxlan(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_vxlan *vxlan_spec; - const struct rte_flow_item_vxlan *vxlan_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- else if (item->spec && (item->mask == NULL)) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Tunnel packets must configure with mask"); -- - hns3_set_bit(rule->input_set, OUTER_DST_PORT, 1); - rule->key_conf.mask.tunnel_type = TUNNEL_TYPE_MASK; - if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN) -@@ -955,15 +912,6 @@ hns3_parse_nvgre(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_nvgre *nvgre_spec; - const struct rte_flow_item_nvgre *nvgre_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- else if (item->spec && (item->mask == NULL)) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Tunnel packets must configure with mask"); -- - hns3_set_bit(rule->input_set, OUTER_IP_PROTO, 1); - rule->key_conf.spec.outer_proto = IPPROTO_GRE; - rule->key_conf.mask.outer_proto = IPPROTO_MASK; -@@ -1013,15 +961,6 @@ hns3_parse_geneve(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - const struct rte_flow_item_geneve *geneve_spec; - const struct rte_flow_item_geneve *geneve_mask; - -- if (item->spec == NULL && item->mask) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Can't configure FDIR with mask but without spec"); -- else if (item->spec && (item->mask == NULL)) -- return rte_flow_error_set(error, EINVAL, -- RTE_FLOW_ERROR_TYPE_ITEM, item, -- "Tunnel packets must configure with mask"); -- - hns3_set_bit(rule->input_set, OUTER_DST_PORT, 1); - rule->key_conf.spec.tunnel_type = HNS3_TUNNEL_TYPE_GENEVE; - rule->key_conf.mask.tunnel_type = TUNNEL_TYPE_MASK; -@@ -1058,6 +997,17 @@ hns3_parse_tunnel(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - { - int ret; - -+ if (item->spec == NULL && item->mask) -+ return rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, item, -+ "Can't configure FDIR with mask " -+ "but without spec"); -+ else if (item->spec && (item->mask == NULL)) -+ return rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, item, -+ "Tunnel packets must configure " -+ "with mask"); -+ - switch (item->type) { - case RTE_FLOW_ITEM_TYPE_VXLAN: - case RTE_FLOW_ITEM_TYPE_VXLAN_GPE: -@@ -1086,6 +1036,12 @@ hns3_parse_normal(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - { - int ret; - -+ if (item->spec == NULL && item->mask) -+ return rte_flow_error_set(error, EINVAL, -+ RTE_FLOW_ERROR_TYPE_ITEM, item, -+ "Can't configure FDIR with mask " -+ "but without spec"); -+ - switch (item->type) { - case RTE_FLOW_ITEM_TYPE_ETH: - ret = hns3_parse_eth(item, rule, error); --- -2.7.4 - diff --git a/0025-net-hns3-refactor-reset-event-report-function.patch b/0025-net-hns3-refactor-reset-event-report-function.patch deleted file mode 100644 index f9478da..0000000 --- a/0025-net-hns3-refactor-reset-event-report-function.patch +++ /dev/null @@ -1,122 +0,0 @@ -From 2e88b488d2b8f3086b7d94179722066b9915a7b9 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:45 +0800 -Subject: [PATCH 025/189] net/hns3: refactor reset event report function - -Here encapsulate the process code of the imp reset report and -global reset report into function in order to reduce the -complexity of the hns3_check_event_cause function. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 69 +++++++++++++++++++++++++++--------------- - 1 file changed, 45 insertions(+), 24 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f3ce639..817d1dc 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -123,6 +123,47 @@ hns3_pf_enable_irq0(struct hns3_hw *hw) - } - - static enum hns3_evt_cause -+hns3_proc_imp_reset_event(struct hns3_adapter *hns, bool is_delay, -+ uint32_t *vec_val) -+{ -+ struct hns3_hw *hw = &hns->hw; -+ -+ rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending); -+ *vec_val = BIT(HNS3_VECTOR0_IMPRESET_INT_B); -+ if (!is_delay) { -+ hw->reset.stats.imp_cnt++; -+ hns3_warn(hw, "IMP reset detected, clear reset status"); -+ } else { -+ hns3_schedule_delayed_reset(hns); -+ hns3_warn(hw, "IMP reset detected, don't clear reset status"); -+ } -+ -+ return HNS3_VECTOR0_EVENT_RST; -+} -+ -+static enum hns3_evt_cause -+hns3_proc_global_reset_event(struct hns3_adapter *hns, bool is_delay, -+ uint32_t *vec_val) -+{ -+ struct hns3_hw *hw = &hns->hw; -+ -+ rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ hns3_atomic_set_bit(HNS3_GLOBAL_RESET, &hw->reset.pending); -+ *vec_val = BIT(HNS3_VECTOR0_GLOBALRESET_INT_B); -+ if (!is_delay) { -+ hw->reset.stats.global_cnt++; -+ hns3_warn(hw, "Global reset detected, clear reset status"); -+ } else { -+ hns3_schedule_delayed_reset(hns); -+ hns3_warn(hw, -+ "Global reset detected, don't clear reset status"); -+ } -+ -+ return HNS3_VECTOR0_EVENT_RST; -+} -+ -+static enum hns3_evt_cause - hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - { - struct hns3_hw *hw = &hns->hw; -@@ -131,12 +172,14 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - uint32_t hw_err_src_reg; - uint32_t val; - enum hns3_evt_cause ret; -+ bool is_delay; - - /* fetch the events from their corresponding regs */ - vector0_int_stats = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); - cmdq_src_val = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG); - hw_err_src_reg = hns3_read_dev(hw, HNS3_RAS_PF_OTHER_INT_STS_REG); - -+ is_delay = clearval == NULL ? true : false; - /* - * Assumption: If by any chance reset and mailbox events are reported - * together then we will only process reset event and defer the -@@ -145,35 +188,13 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - * from H/W just for the mailbox. - */ - if (BIT(HNS3_VECTOR0_IMPRESET_INT_B) & vector0_int_stats) { /* IMP */ -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -- hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending); -- val = BIT(HNS3_VECTOR0_IMPRESET_INT_B); -- if (clearval) { -- hw->reset.stats.imp_cnt++; -- hns3_warn(hw, "IMP reset detected, clear reset status"); -- } else { -- hns3_schedule_delayed_reset(hns); -- hns3_warn(hw, "IMP reset detected, don't clear reset status"); -- } -- -- ret = HNS3_VECTOR0_EVENT_RST; -+ ret = hns3_proc_imp_reset_event(hns, is_delay, &val); - goto out; - } - - /* Global reset */ - if (BIT(HNS3_VECTOR0_GLOBALRESET_INT_B) & vector0_int_stats) { -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -- hns3_atomic_set_bit(HNS3_GLOBAL_RESET, &hw->reset.pending); -- val = BIT(HNS3_VECTOR0_GLOBALRESET_INT_B); -- if (clearval) { -- hw->reset.stats.global_cnt++; -- hns3_warn(hw, "Global reset detected, clear reset status"); -- } else { -- hns3_schedule_delayed_reset(hns); -- hns3_warn(hw, "Global reset detected, don't clear reset status"); -- } -- -- ret = HNS3_VECTOR0_EVENT_RST; -+ ret = hns3_proc_global_reset_event(hns, is_delay, &val); - goto out; - } - --- -2.7.4 - diff --git a/0026-net-hns3-fix-memory-leak-on-secondary-process-exit.patch b/0026-net-hns3-fix-memory-leak-on-secondary-process-exit.patch deleted file mode 100644 index 21402ee..0000000 --- a/0026-net-hns3-fix-memory-leak-on-secondary-process-exit.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 64c98e007bf57084bab1be0256d5d8cabf8e5b29 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:46 +0800 -Subject: [PATCH 026/189] net/hns3: fix memory leak on secondary process exit - -The secondary process is applied a memory for the process_private -during initialization. Therefore, the memory needs to be released -when exiting. - -Fixes: c203571b3602 ("net/hns3: register and add log interface") -Cc: stable@dpdk.org - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 7 +++++-- - drivers/net/hns3/hns3_ethdev_vf.c | 12 +++++++++--- - 2 files changed, 14 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 817d1dc..2a5689c 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6263,8 +6263,11 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -- return -EPERM; -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ rte_free(eth_dev->process_private); -+ eth_dev->process_private = NULL; -+ return 0; -+ } - - if (hw->adapter_state < HNS3_NIC_CLOSING) - hns3_dev_close(eth_dev); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 3a1d4cb..948d914 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1971,8 +1971,11 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - struct hns3_hw *hw = &hns->hw; - int ret = 0; - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ rte_free(eth_dev->process_private); -+ eth_dev->process_private = NULL; - return 0; -+ } - - if (hw->adapter_state == HNS3_NIC_STARTED) - ret = hns3vf_dev_stop(eth_dev); -@@ -2839,8 +2842,11 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -- return -EPERM; -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ rte_free(eth_dev->process_private); -+ eth_dev->process_private = NULL; -+ return 0; -+ } - - if (hw->adapter_state < HNS3_NIC_CLOSING) - hns3vf_dev_close(eth_dev); --- -2.7.4 - diff --git a/0027-net-hns3-fix-interrupt-resources-in-Rx-interrupt-mod.patch b/0027-net-hns3-fix-interrupt-resources-in-Rx-interrupt-mod.patch deleted file mode 100644 index f37c77d..0000000 --- a/0027-net-hns3-fix-interrupt-resources-in-Rx-interrupt-mod.patch +++ /dev/null @@ -1,244 +0,0 @@ -From 30c133006d7929fafad11a379fc18f3d23dc0178 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Fri, 22 Jan 2021 18:18:47 +0800 -Subject: [PATCH 027/189] net/hns3: fix interrupt resources in Rx interrupt - mode - -For Kunpeng930, the NIC engine support 1280 tqps being taken over by -a PF. In this case, a maximum of 1281 interrupt resources are also -supported in this PF. To support the maximum number of queues, several -patches are made. But the interrupt related modification are missing. -So, in RX interrupt mode, a large number of queues will be aggregated -into one interrupt due to insufficient interrupts. It will lead to -waste of interrupt resources and reduces usability. - -To utilize all these interrupt resources, related IMP command has been -extended. And, the I/O address of the extended interrupt resources are -different from the existing ones. So, a function used for calculating -the address offset has been added. - -Fixes: 76d794566d43 ("net/hns3: maximize queue number") -Fixes: 27911a6e62e5 ("net/hns3: add Rx interrupts compatibility") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang ---- - drivers/net/hns3/hns3_cmd.h | 8 ++++++-- - drivers/net/hns3/hns3_ethdev.c | 17 +++++++++-------- - drivers/net/hns3/hns3_regs.c | 2 +- - drivers/net/hns3/hns3_regs.h | 24 +++++++++++++++--------- - drivers/net/hns3/hns3_rxtx.c | 28 +++++++++++++++++++++++----- - drivers/net/hns3/hns3_rxtx.h | 1 + - 6 files changed, 55 insertions(+), 25 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 6152f6e..dc97a1a 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -776,12 +776,16 @@ enum hns3_int_gl_idx { - #define HNS3_TQP_ID_M GENMASK(12, 2) - #define HNS3_INT_GL_IDX_S 13 - #define HNS3_INT_GL_IDX_M GENMASK(14, 13) -+#define HNS3_TQP_INT_ID_L_S 0 -+#define HNS3_TQP_INT_ID_L_M GENMASK(7, 0) -+#define HNS3_TQP_INT_ID_H_S 8 -+#define HNS3_TQP_INT_ID_H_M GENMASK(15, 8) - struct hns3_ctrl_vector_chain_cmd { -- uint8_t int_vector_id; -+ uint8_t int_vector_id; /* the low order of the interrupt id */ - uint8_t int_cause_num; - uint16_t tqp_type_and_id[HNS3_VECTOR_ELEMENTS_PER_CMD]; - uint8_t vfid; -- uint8_t rsv; -+ uint8_t int_vector_id_h; /* the high order of the interrupt id */ - }; - - struct hns3_config_max_frm_size_cmd { -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2a5689c..4356860 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2232,7 +2232,7 @@ hns3_check_dcb_cfg(struct rte_eth_dev *dev) - } - - static int --hns3_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id, bool mmap, -+hns3_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool en, - enum hns3_ring_type queue_type, uint16_t queue_id) - { - struct hns3_cmd_desc desc; -@@ -2241,13 +2241,15 @@ hns3_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id, bool mmap, - enum hns3_cmd_status status; - enum hns3_opcode_type op; - uint16_t tqp_type_and_id = 0; -- const char *op_str; - uint16_t type; - uint16_t gl; - -- op = mmap ? HNS3_OPC_ADD_RING_TO_VECTOR : HNS3_OPC_DEL_RING_TO_VECTOR; -+ op = en ? HNS3_OPC_ADD_RING_TO_VECTOR : HNS3_OPC_DEL_RING_TO_VECTOR; - hns3_cmd_setup_basic_desc(&desc, op, false); -- req->int_vector_id = vector_id; -+ req->int_vector_id = hns3_get_field(vector_id, HNS3_TQP_INT_ID_L_M, -+ HNS3_TQP_INT_ID_L_S); -+ req->int_vector_id_h = hns3_get_field(vector_id, HNS3_TQP_INT_ID_H_M, -+ HNS3_TQP_INT_ID_H_S); - - if (queue_type == HNS3_RING_TYPE_RX) - gl = HNS3_RING_GL_RX; -@@ -2263,11 +2265,10 @@ hns3_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id, bool mmap, - gl); - req->tqp_type_and_id[0] = rte_cpu_to_le_16(tqp_type_and_id); - req->int_cause_num = 1; -- op_str = mmap ? "Map" : "Unmap"; - status = hns3_cmd_send(hw, &desc, 1); - if (status) { - hns3_err(hw, "%s TQP %u fail, vector_id is %u, status is %d.", -- op_str, queue_id, req->int_vector_id, status); -+ en ? "Map" : "Unmap", queue_id, vector_id, status); - return status; - } - -@@ -4797,8 +4798,8 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev) - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); - struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; -- uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET; -+ uint16_t base = RTE_INTR_VEC_ZERO_OFFSET; -+ uint16_t vec = RTE_INTR_VEC_ZERO_OFFSET; - uint32_t intr_vector; - uint16_t q_id; - int ret; -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index f2cb465..8afe132 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -301,7 +301,7 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) - - reg_num = sizeof(tqp_intr_reg_addrs) / sizeof(uint32_t); - for (j = 0; j < hw->intr_tqps_num; j++) { -- reg_offset = HNS3_TQP_INTR_REG_SIZE * j; -+ reg_offset = hns3_get_tqp_intr_reg_offset(j); - for (i = 0; i < reg_num; i++) - *data++ = hns3_read_dev(hw, tqp_intr_reg_addrs[i] + - reg_offset); -diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h -index 81a0af5..39fc5d1 100644 ---- a/drivers/net/hns3/hns3_regs.h -+++ b/drivers/net/hns3/hns3_regs.h -@@ -95,15 +95,21 @@ - #define HNS3_MIN_EXTEND_QUEUE_ID 1024 - - /* bar registers for tqp interrupt */ --#define HNS3_TQP_INTR_CTRL_REG 0x20000 --#define HNS3_TQP_INTR_GL0_REG 0x20100 --#define HNS3_TQP_INTR_GL1_REG 0x20200 --#define HNS3_TQP_INTR_GL2_REG 0x20300 --#define HNS3_TQP_INTR_RL_REG 0x20900 --#define HNS3_TQP_INTR_TX_QL_REG 0x20e00 --#define HNS3_TQP_INTR_RX_QL_REG 0x20f00 -- --#define HNS3_TQP_INTR_REG_SIZE 4 -+#define HNS3_TQP_INTR_REG_BASE 0x20000 -+#define HNS3_TQP_INTR_EXT_REG_BASE 0x30000 -+#define HNS3_TQP_INTR_CTRL_REG 0 -+#define HNS3_TQP_INTR_GL0_REG 0x100 -+#define HNS3_TQP_INTR_GL1_REG 0x200 -+#define HNS3_TQP_INTR_GL2_REG 0x300 -+#define HNS3_TQP_INTR_RL_REG 0x900 -+#define HNS3_TQP_INTR_TX_QL_REG 0xe00 -+#define HNS3_TQP_INTR_RX_QL_REG 0xf00 -+#define HNS3_TQP_INTR_RL_EN_B 6 -+ -+#define HNS3_MIN_EXT_TQP_INTR_ID 64 -+#define HNS3_TQP_INTR_LOW_ORDER_OFFSET 0x4 -+#define HNS3_TQP_INTR_HIGH_ORDER_OFFSET 0x1000 -+ - #define HNS3_TQP_INTR_GL_MAX 0x1FE0 - #define HNS3_TQP_INTR_GL_DEFAULT 20 - #define HNS3_TQP_INTR_GL_UNIT_1US BIT(31) -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 30f1e06..1991b4e 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -834,6 +834,24 @@ hns3_reset_queue(struct hns3_hw *hw, uint16_t queue_id, - return ret; - } - -+uint32_t -+hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id) -+{ -+ uint32_t reg_offset; -+ -+ /* Need an extend offset to config queues > 64 */ -+ if (tqp_intr_id < HNS3_MIN_EXT_TQP_INTR_ID) -+ reg_offset = HNS3_TQP_INTR_REG_BASE + -+ tqp_intr_id * HNS3_TQP_INTR_LOW_ORDER_OFFSET; -+ else -+ reg_offset = HNS3_TQP_INTR_EXT_REG_BASE + -+ tqp_intr_id / HNS3_MIN_EXT_TQP_INTR_ID * -+ HNS3_TQP_INTR_HIGH_ORDER_OFFSET + -+ tqp_intr_id % HNS3_MIN_EXT_TQP_INTR_ID * -+ HNS3_TQP_INTR_LOW_ORDER_OFFSET; -+ -+ return reg_offset; -+} - - void - hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, -@@ -847,7 +865,7 @@ hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, - if (gl_idx >= RTE_DIM(offset) || gl_value > HNS3_TQP_INTR_GL_MAX) - return; - -- addr = offset[gl_idx] + queue_id * HNS3_TQP_INTR_REG_SIZE; -+ addr = offset[gl_idx] + hns3_get_tqp_intr_reg_offset(queue_id); - if (hw->intr.gl_unit == HNS3_INTR_COALESCE_GL_UINT_1US) - value = gl_value | HNS3_TQP_INTR_GL_UNIT_1US; - else -@@ -864,7 +882,7 @@ hns3_set_queue_intr_rl(struct hns3_hw *hw, uint16_t queue_id, uint16_t rl_value) - if (rl_value > HNS3_TQP_INTR_RL_MAX) - return; - -- addr = HNS3_TQP_INTR_RL_REG + queue_id * HNS3_TQP_INTR_REG_SIZE; -+ addr = HNS3_TQP_INTR_RL_REG + hns3_get_tqp_intr_reg_offset(queue_id); - value = HNS3_RL_USEC_TO_REG(rl_value); - if (value > 0) - value |= HNS3_TQP_INTR_RL_ENABLE_MASK; -@@ -885,10 +903,10 @@ hns3_set_queue_intr_ql(struct hns3_hw *hw, uint16_t queue_id, uint16_t ql_value) - if (hw->intr.int_ql_max == HNS3_INTR_QL_NONE) - return; - -- addr = HNS3_TQP_INTR_TX_QL_REG + queue_id * HNS3_TQP_INTR_REG_SIZE; -+ addr = HNS3_TQP_INTR_TX_QL_REG + hns3_get_tqp_intr_reg_offset(queue_id); - hns3_write_dev(hw, addr, ql_value); - -- addr = HNS3_TQP_INTR_RX_QL_REG + queue_id * HNS3_TQP_INTR_REG_SIZE; -+ addr = HNS3_TQP_INTR_RX_QL_REG + hns3_get_tqp_intr_reg_offset(queue_id); - hns3_write_dev(hw, addr, ql_value); - } - -@@ -897,7 +915,7 @@ hns3_queue_intr_enable(struct hns3_hw *hw, uint16_t queue_id, bool en) - { - uint32_t addr, value; - -- addr = HNS3_TQP_INTR_CTRL_REG + queue_id * HNS3_TQP_INTR_REG_SIZE; -+ addr = HNS3_TQP_INTR_CTRL_REG + hns3_get_tqp_intr_reg_offset(queue_id); - value = en ? 1 : 0; - - hns3_write_dev(hw, addr, value); -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 331b507..8f5ae5c 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -680,6 +680,7 @@ int hns3_tx_burst_mode_get(struct rte_eth_dev *dev, - const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev); - void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev); - void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev); -+uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id); - void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, - uint8_t gl_idx, uint16_t gl_value); - void hns3_set_queue_intr_rl(struct hns3_hw *hw, uint16_t queue_id, --- -2.7.4 - diff --git a/0028-net-hns3-rename-RSS-functions.patch b/0028-net-hns3-rename-RSS-functions.patch deleted file mode 100644 index f971195..0000000 --- a/0028-net-hns3-rename-RSS-functions.patch +++ /dev/null @@ -1,137 +0,0 @@ -From 65ffb8730c023e703e90dfefde782d1b70e830bf Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:48 +0800 -Subject: [PATCH 028/189] net/hns3: rename RSS functions - -Rename some function about RSS implement functions -in order to make the functions naming style more -reasonable and consistency. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 2 +- - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- - drivers/net/hns3/hns3_flow.c | 2 +- - drivers/net/hns3/hns3_rss.c | 12 ++++++------ - drivers/net/hns3/hns3_rss.h | 4 ++-- - 5 files changed, 11 insertions(+), 11 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 4356860..94b6e44 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4685,7 +4685,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_fdir; - } - -- hns3_set_default_rss_args(hw); -+ hns3_rss_set_default_args(hw); - - ret = hns3_enable_hw_error_intr(hns, true); - if (ret) { -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 948d914..7eb0b11 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1832,7 +1832,7 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) - if (ret) - goto err_set_tc_queue; - -- hns3_set_default_rss_args(hw); -+ hns3_rss_set_default_args(hw); - - return 0; - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 9b161f4..8a5179d 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1469,7 +1469,7 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) - if (ret) - return ret; - -- ret = hns3_set_rss_algo_key(hw, rss_config->key); -+ ret = hns3_rss_set_algo_key(hw, rss_config->key); - if (ret) - return ret; - -diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c -index b5df374..7d1a297 100644 ---- a/drivers/net/hns3/hns3_rss.c -+++ b/drivers/net/hns3/hns3_rss.c -@@ -193,7 +193,7 @@ static const struct { - * Used to set algorithm, key_offset and hash key of rss. - */ - int --hns3_set_rss_algo_key(struct hns3_hw *hw, const uint8_t *key) -+hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key) - { - #define HNS3_KEY_OFFSET_MAX 3 - #define HNS3_SET_HASH_KEY_BYTE_FOUR 2 -@@ -245,7 +245,7 @@ hns3_set_rss_algo_key(struct hns3_hw *hw, const uint8_t *key) - * Used to configure the tuple selection for RSS hash input. - */ - static int --hns3_set_rss_input_tuple(struct hns3_hw *hw) -+hns3_rss_set_input_tuple(struct hns3_hw *hw) - { - struct hns3_rss_conf *rss_config = &hw->rss_info; - struct hns3_rss_input_tuple_cmd *req; -@@ -443,7 +443,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, - ret = -EINVAL; - goto conf_err; - } -- ret = hns3_set_rss_algo_key(hw, key); -+ ret = hns3_rss_set_algo_key(hw, key); - if (ret) - goto conf_err; - } -@@ -649,7 +649,7 @@ hns3_rss_tuple_uninit(struct hns3_hw *hw) - * Set the default rss configuration in the init of driver. - */ - void --hns3_set_default_rss_args(struct hns3_hw *hw) -+hns3_rss_set_default_args(struct hns3_hw *hw) - { - struct hns3_rss_conf *rss_cfg = &hw->rss_info; - uint16_t queue_num = hw->alloc_rss_size; -@@ -696,12 +696,12 @@ hns3_config_rss(struct hns3_adapter *hns) - hns3_rss_uninit(hns); - - /* Configure RSS hash algorithm and hash key offset */ -- ret = hns3_set_rss_algo_key(hw, hash_key); -+ ret = hns3_rss_set_algo_key(hw, hash_key); - if (ret) - return ret; - - /* Configure the tuple selection for RSS hash input */ -- ret = hns3_set_rss_input_tuple(hw); -+ ret = hns3_rss_set_input_tuple(hw); - if (ret) - return ret; - -diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h -index 6d1d25f..05d5c26 100644 ---- a/drivers/net/hns3/hns3_rss.h -+++ b/drivers/net/hns3/hns3_rss.h -@@ -102,7 +102,7 @@ int hns3_dev_rss_reta_update(struct rte_eth_dev *dev, - int hns3_dev_rss_reta_query(struct rte_eth_dev *dev, - struct rte_eth_rss_reta_entry64 *reta_conf, - uint16_t reta_size); --void hns3_set_default_rss_args(struct hns3_hw *hw); -+void hns3_rss_set_default_args(struct hns3_hw *hw); - int hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, - uint16_t size); - int hns3_rss_reset_indir_table(struct hns3_hw *hw); -@@ -111,7 +111,7 @@ void hns3_rss_uninit(struct hns3_adapter *hns); - int hns3_set_rss_tuple_by_rss_hf(struct hns3_hw *hw, - struct hns3_rss_tuple_cfg *tuple, - uint64_t rss_hf); --int hns3_set_rss_algo_key(struct hns3_hw *hw, const uint8_t *key); -+int hns3_rss_set_algo_key(struct hns3_hw *hw, const uint8_t *key); - int hns3_restore_rss_filter(struct rte_eth_dev *dev); - - #endif /* _HNS3_RSS_H_ */ --- -2.7.4 - diff --git a/0029-net-hns3-adjust-some-comments.patch b/0029-net-hns3-adjust-some-comments.patch deleted file mode 100644 index 6a64123..0000000 --- a/0029-net-hns3-adjust-some-comments.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 2cfeae90323331be6a395bae314e170bfb3ff3b2 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:49 +0800 -Subject: [PATCH 029/189] net/hns3: adjust some comments - -Fix some error comments and remove some meaningless comments. - -Fixes: f8e7fcbfd0b8 ("net/hns3: support flow action of queue region") -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Fixes: c37ca66f2b27 ("net/hns3: support RSS") -Fixes: ec674cb742e5 ("net/hns3: fix flushing RSS rule") -Cc: stable@dpdk.org - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 19 ++++++++----------- - 1 file changed, 8 insertions(+), 11 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 8a5179d..f2bff1e 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -91,9 +91,9 @@ net_addr_to_host(uint32_t *dst, const rte_be32_t *src, size_t len) - /* - * This function is used to find rss general action. - * 1. As we know RSS is used to spread packets among several queues, the flow -- * API provide the struct rte_flow_action_rss, user could config it's field -+ * API provide the struct rte_flow_action_rss, user could config its field - * sush as: func/level/types/key/queue to control RSS function. -- * 2. The flow API also support queue region configuration for hns3. It was -+ * 2. The flow API also supports queue region configuration for hns3. It was - * implemented by FDIR + RSS in hns3 hardware, user can create one FDIR rule - * which action is RSS queues region. - * 3. When action is RSS, we use the following rule to distinguish: -@@ -128,11 +128,11 @@ hns3_find_rss_general_action(const struct rte_flow_item pattern[], - rss = act->conf; - if (have_eth && rss->conf.queue_num) { - /* -- * Patter have ETH and action's queue_num > 0, indicate this is -+ * Pattern have ETH and action's queue_num > 0, indicate this is - * queue region configuration. - * Because queue region is implemented by FDIR + RSS in hns3 -- * hardware, it need enter FDIR process, so here return NULL to -- * avoid enter RSS process. -+ * hardware, it needs to enter FDIR process, so here return NULL -+ * to avoid enter RSS process. - */ - return NULL; - } -@@ -405,7 +405,6 @@ hns3_handle_actions(struct rte_eth_dev *dev, - return 0; - } - --/* Parse to get the attr and action info of flow director rule. */ - static int - hns3_check_attr(const struct rte_flow_attr *attr, struct rte_flow_error *error) - { -@@ -782,7 +781,7 @@ hns3_parse_sctp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - } - - /* -- * Check items before tunnel, save inner configs to outer configs,and clear -+ * Check items before tunnel, save inner configs to outer configs, and clear - * inner configs. - * The key consists of two parts: meta_data and tuple keys. - * Meta data uses 15 bits, including vlan_num(2bit), des_port(12bit) and tunnel -@@ -1473,10 +1472,8 @@ hns3_hw_rss_hash_set(struct hns3_hw *hw, struct rte_flow_action_rss *rss_config) - if (ret) - return ret; - -- /* Update algorithm of hw */ - hw->rss_info.conf.func = rss_config->func; - -- /* Set flow type supported */ - tuple = &hw->rss_info.rss_tuple_sets; - ret = hns3_set_rss_tuple_by_rss_hf(hw, tuple, rss_config->types); - if (ret) -@@ -1561,7 +1558,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, - if (rss_flow_conf.queue_num) { - /* - * Due the content of queue pointer have been reset to -- * 0, the rss_info->conf.queue should be set NULL -+ * 0, the rss_info->conf.queue should be set to NULL - */ - rss_info->conf.queue = NULL; - rss_info->conf.queue_num = 0; -@@ -1727,7 +1724,7 @@ hns3_flow_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - /* - * Create or destroy a flow rule. - * Theorically one rule can match more than one filters. -- * We will let it use the filter which it hitt first. -+ * We will let it use the filter which it hit first. - * So, the sequence matters. - */ - static struct rte_flow * --- -2.7.4 - diff --git a/0030-net-hns3-remove-unnecessary-parentheses.patch b/0030-net-hns3-remove-unnecessary-parentheses.patch deleted file mode 100644 index 064dc97..0000000 --- a/0030-net-hns3-remove-unnecessary-parentheses.patch +++ /dev/null @@ -1,45 +0,0 @@ -From d7fa7d59733c34f7d8083a6567ca8a0e3efb1fb6 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:50 +0800 -Subject: [PATCH 030/189] net/hns3: remove unnecessary parentheses - -Remove unnecessary parentheses as well as keep a reasonable -blank line. - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index f2bff1e..e9d0a0b 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -700,6 +700,7 @@ hns3_parse_udp(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - hns3_set_bit(rule->input_set, INNER_IP_PROTO, 1); - rule->key_conf.spec.ip_proto = IPPROTO_UDP; - rule->key_conf.mask.ip_proto = IPPROTO_MASK; -+ - /* Only used to describe the protocol stack. */ - if (item->spec == NULL && item->mask == NULL) - return 0; -@@ -1264,7 +1265,7 @@ hns3_action_rss_same(const struct rte_flow_action_rss *comp, - if (comp->func == RTE_ETH_HASH_FUNCTION_MAX) - func_is_same = false; - else -- func_is_same = (with->func ? (comp->func == with->func) : true); -+ func_is_same = with->func ? (comp->func == with->func) : true; - - return (func_is_same && - comp->types == (with->types & HNS3_ETH_RSS_SUPPORT) && -@@ -1861,6 +1862,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_HANDLE, - flow, "Flow is NULL"); -+ - filter_type = flow->filter_type; - switch (filter_type) { - case RTE_ETH_FILTER_FDIR: --- -2.7.4 - diff --git a/0031-net-hns3-adjust-format-specifier-for-enum.patch b/0031-net-hns3-adjust-format-specifier-for-enum.patch deleted file mode 100644 index 1409236..0000000 --- a/0031-net-hns3-adjust-format-specifier-for-enum.patch +++ /dev/null @@ -1,31 +0,0 @@ -From dc8b97b9ef327bcb295bc7a2d2e4ffaaca6ba1f0 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Fri, 22 Jan 2021 18:18:51 +0800 -Subject: [PATCH 031/189] net/hns3: adjust format specifier for enum - -Here uses %d as printing output for enumeration member. - -Fixes: c37ca66f2b27 ("net/hns3: support RSS") -Cc: stable@dpdk.org - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index e9d0a0b..3e387ac 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1447,7 +1447,7 @@ hns3_parse_rss_algorithm(struct hns3_hw *hw, enum rte_eth_hash_function *func, - *hash_algo = HNS3_RSS_HASH_ALGO_SYMMETRIC_TOEP; - break; - default: -- hns3_err(hw, "Invalid RSS algorithm configuration(%u)", -+ hns3_err(hw, "Invalid RSS algorithm configuration(%d)", - algo_func); - return -EINVAL; - } --- -2.7.4 - diff --git a/0032-net-hns3-support-LSC-event-report.patch b/0032-net-hns3-support-LSC-event-report.patch deleted file mode 100644 index 23df2bf..0000000 --- a/0032-net-hns3-support-LSC-event-report.patch +++ /dev/null @@ -1,245 +0,0 @@ -From 0112993819b0a5ae9bf35f8a3adf45c6134d69bd Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 22 Jan 2021 18:18:52 +0800 -Subject: [PATCH 032/189] net/hns3: support LSC event report - -This patch support LSC (Link Status Change) event report. - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 52 +++++++++++++++++++++++++++++++++++---- - drivers/net/hns3/hns3_ethdev.h | 4 ++- - drivers/net/hns3/hns3_ethdev_vf.c | 40 +++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_mbx.c | 14 ++++++----- - 4 files changed, 97 insertions(+), 13 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 94b6e44..bc77608 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -19,6 +19,7 @@ - #define HNS3_DEFAULT_PORT_CONF_QUEUES_NUM 1 - - #define HNS3_SERVICE_INTERVAL 1000000 /* us */ -+#define HNS3_SERVICE_QUICK_INTERVAL 10 - #define HNS3_INVALID_PVID 0xFFFF - - #define HNS3_FILTER_TYPE_VF 0 -@@ -93,6 +94,7 @@ static int hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); - static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, - int on); - static int hns3_update_speed_duplex(struct rte_eth_dev *eth_dev); -+static bool hns3_update_link_status(struct hns3_hw *hw); - - static int hns3_add_mc_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); -@@ -4458,7 +4460,7 @@ hns3_get_mac_link_status(struct hns3_hw *hw) - return !!link_status; - } - --void -+static bool - hns3_update_link_status(struct hns3_hw *hw) - { - int state; -@@ -4467,7 +4469,36 @@ hns3_update_link_status(struct hns3_hw *hw) - if (state != hw->mac.link_status) { - hw->mac.link_status = state; - hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); -+ return true; - } -+ -+ return false; -+} -+ -+/* -+ * Current, the PF driver get link status by two ways: -+ * 1) Periodic polling in the intr thread context, driver call -+ * hns3_update_link_status to update link status. -+ * 2) Firmware report async interrupt, driver process the event in the intr -+ * thread context, and call hns3_update_link_status to update link status. -+ * -+ * If detect link status changed, driver need report LSE. One method is add the -+ * report LSE logic in hns3_update_link_status. -+ * -+ * But the PF driver ops(link_update) also call hns3_update_link_status to -+ * update link status. -+ * If we report LSE in hns3_update_link_status, it may lead to deadlock in the -+ * bonding application. -+ * -+ * So add the one new API which used only in intr thread context. -+ */ -+void -+hns3_update_link_status_and_event(struct hns3_hw *hw) -+{ -+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ bool changed = hns3_update_link_status(hw); -+ if (changed) -+ rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); - } - - static void -@@ -4479,9 +4510,10 @@ hns3_service_handler(void *param) - - if (!hns3_is_reset_pending(hns)) { - hns3_update_speed_duplex(eth_dev); -- hns3_update_link_status(hw); -- } else -+ hns3_update_link_status_and_event(hw); -+ } else { - hns3_warn(hw, "Cancel the query when reset is pending"); -+ } - - rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev); - } -@@ -5557,8 +5589,10 @@ hns3_stop_service(struct hns3_adapter *hns) - struct rte_eth_dev *eth_dev; - - eth_dev = &rte_eth_devices[hw->data->port_id]; -- if (hw->adapter_state == HNS3_NIC_STARTED) -+ if (hw->adapter_state == HNS3_NIC_STARTED) { - rte_eal_alarm_cancel(hns3_service_handler, eth_dev); -+ hns3_update_link_status_and_event(hw); -+ } - hw->mac.link_status = ETH_LINK_DOWN; - - hns3_set_rxtx_function(eth_dev); -@@ -5601,7 +5635,15 @@ hns3_start_service(struct hns3_adapter *hns) - hns3_set_rxtx_function(eth_dev); - hns3_mp_req_start_rxtx(eth_dev); - if (hw->adapter_state == HNS3_NIC_STARTED) { -- hns3_service_handler(eth_dev); -+ /* -+ * This API parent function already hold the hns3_hw.lock, the -+ * hns3_service_handler may report lse, in bonding application -+ * it will call driver's ops which may acquire the hns3_hw.lock -+ * again, thus lead to deadlock. -+ * We defer calls hns3_service_handler to avoid the deadlock. -+ */ -+ rte_eal_alarm_set(HNS3_SERVICE_QUICK_INTERVAL, -+ hns3_service_handler, eth_dev); - - /* Enable interrupt of all rx queues before enabling queues */ - hns3_dev_all_rx_queue_intr_enable(hw, true); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 0d17170..547e991 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -946,11 +946,13 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, - enum rte_filter_op filter_op, void *arg); - bool hns3_is_reset_pending(struct hns3_adapter *hns); - bool hns3vf_is_reset_pending(struct hns3_adapter *hns); --void hns3_update_link_status(struct hns3_hw *hw); -+void hns3_update_link_status_and_event(struct hns3_hw *hw); - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr); - int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, - struct rte_eth_dev_info *info); -+void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, -+ uint32_t link_speed, uint8_t link_duplex); - - static inline bool - is_reset_pending(struct hns3_adapter *hns) -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 7eb0b11..3a682e5 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1440,6 +1440,41 @@ hns3vf_request_link_info(struct hns3_hw *hw) - hns3_err(hw, "Failed to fetch link status from PF: %d", ret); - } - -+void -+hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, -+ uint32_t link_speed, uint8_t link_duplex) -+{ -+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ struct hns3_mac *mac = &hw->mac; -+ bool report_lse; -+ bool changed; -+ -+ changed = mac->link_status != link_status || -+ mac->link_speed != link_speed || -+ mac->link_duplex != link_duplex; -+ if (!changed) -+ return; -+ -+ /* -+ * VF's link status/speed/duplex were updated by polling from PF driver, -+ * because the link status/speed/duplex may be changed in the polling -+ * interval, so driver will report lse (lsc event) once any of the above -+ * thress variables changed. -+ * But if the PF's link status is down and driver saved link status is -+ * also down, there are no need to report lse. -+ */ -+ report_lse = true; -+ if (link_status == ETH_LINK_DOWN && link_status == mac->link_status) -+ report_lse = false; -+ -+ mac->link_status = link_status; -+ mac->link_speed = link_speed; -+ mac->link_duplex = link_duplex; -+ -+ if (report_lse) -+ rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); -+} -+ - static int - hns3vf_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) - { -@@ -2373,8 +2408,11 @@ hns3vf_stop_service(struct hns3_adapter *hns) - struct rte_eth_dev *eth_dev; - - eth_dev = &rte_eth_devices[hw->data->port_id]; -- if (hw->adapter_state == HNS3_NIC_STARTED) -+ if (hw->adapter_state == HNS3_NIC_STARTED) { - rte_eal_alarm_cancel(hns3vf_service_handler, eth_dev); -+ hns3vf_update_link_status(hw, ETH_LINK_DOWN, hw->mac.link_speed, -+ hw->mac.link_duplex); -+ } - hw->mac.link_status = ETH_LINK_DOWN; - - hns3_set_rxtx_function(eth_dev); -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index d2a5db8..3e44e3b 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -203,8 +203,9 @@ hns3_cmd_crq_empty(struct hns3_hw *hw) - static void - hns3_mbx_handler(struct hns3_hw *hw) - { -- struct hns3_mac *mac = &hw->mac; - enum hns3_reset_level reset_level; -+ uint8_t link_status, link_duplex; -+ uint32_t link_speed; - uint16_t *msg_q; - uint8_t opcode; - uint32_t tail; -@@ -218,10 +219,11 @@ hns3_mbx_handler(struct hns3_hw *hw) - opcode = msg_q[0] & 0xff; - switch (opcode) { - case HNS3_MBX_LINK_STAT_CHANGE: -- memcpy(&mac->link_speed, &msg_q[2], -- sizeof(mac->link_speed)); -- mac->link_status = rte_le_to_cpu_16(msg_q[1]); -- mac->link_duplex = (uint8_t)rte_le_to_cpu_16(msg_q[4]); -+ memcpy(&link_speed, &msg_q[2], sizeof(link_speed)); -+ link_status = rte_le_to_cpu_16(msg_q[1]); -+ link_duplex = (uint8_t)rte_le_to_cpu_16(msg_q[4]); -+ hns3vf_update_link_status(hw, link_status, link_speed, -+ link_duplex); - break; - case HNS3_MBX_ASSERTING_RESET: - /* PF has asserted reset hence VF should go in pending -@@ -310,7 +312,7 @@ hns3_handle_link_change_event(struct hns3_hw *hw, - if (!req->msg[LINK_STATUS_OFFSET]) - hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]); - -- hns3_update_link_status(hw); -+ hns3_update_link_status_and_event(hw); - } - - static void --- -2.7.4 - diff --git a/0033-net-hns3-fix-query-order-of-link-status-and-link-inf.patch b/0033-net-hns3-fix-query-order-of-link-status-and-link-inf.patch deleted file mode 100644 index 6e1bb96..0000000 --- a/0033-net-hns3-fix-query-order-of-link-status-and-link-inf.patch +++ /dev/null @@ -1,96 +0,0 @@ -From fd6de494db0d040ca42a6f57f202515f537a62b3 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 3 Feb 2021 20:23:47 +0800 -Subject: [PATCH 033/189] net/hns3: fix query order of link status and link - info - -When link information is updated in the firmware, the link information -is updated first and then the link status is updated. In a 1s periodic -task, PF driver queries the link information and then obtains link -status. -It may lead to a 1s time difference for obtaining valid link information -when the port is up. Therefore, the query order of driver should be -reversed to the order of firmware. - -Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox") -Fixes: 59fad0f32135 ("net/hns3: support link update operation") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 27 ++++++++++++++++++++------- - 1 file changed, 20 insertions(+), 7 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index bc77608..b624fce 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -93,7 +93,7 @@ static enum hns3_reset_level hns3_get_reset_level(struct hns3_adapter *hns, - static int hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu); - static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, - int on); --static int hns3_update_speed_duplex(struct rte_eth_dev *eth_dev); -+static int hns3_update_link_info(struct rte_eth_dev *eth_dev); - static bool hns3_update_link_status(struct hns3_hw *hw); - - static int hns3_add_mc_addr(struct hns3_hw *hw, -@@ -2642,8 +2642,8 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, - struct rte_eth_link new_link; - - if (!hns3_is_reset_pending(hns)) { -- hns3_update_speed_duplex(eth_dev); - hns3_update_link_status(hw); -+ hns3_update_link_info(eth_dev); - } - - memset(&new_link, 0, sizeof(new_link)); -@@ -4368,11 +4368,9 @@ hns3_cfg_mac_speed_dup(struct hns3_hw *hw, uint32_t speed, uint8_t duplex) - } - - static int --hns3_update_speed_duplex(struct rte_eth_dev *eth_dev) -+hns3_update_fiber_link_info(struct hns3_hw *hw) - { -- struct hns3_adapter *hns = eth_dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- struct hns3_pf *pf = &hns->pf; -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); - uint32_t speed; - int ret; - -@@ -4395,6 +4393,21 @@ hns3_update_speed_duplex(struct rte_eth_dev *eth_dev) - } - - static int -+hns3_update_link_info(struct rte_eth_dev *eth_dev) -+{ -+ struct hns3_adapter *hns = eth_dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ int ret = 0; -+ -+ if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) -+ return 0; -+ else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) -+ ret = hns3_update_fiber_link_info(hw); -+ -+ return ret; -+} -+ -+static int - hns3_cfg_mac_mode(struct hns3_hw *hw, bool enable) - { - struct hns3_config_mac_mode_cmd *req; -@@ -4509,8 +4522,8 @@ hns3_service_handler(void *param) - struct hns3_hw *hw = &hns->hw; - - if (!hns3_is_reset_pending(hns)) { -- hns3_update_speed_duplex(eth_dev); - hns3_update_link_status_and_event(hw); -+ hns3_update_link_info(eth_dev); - } else { - hns3_warn(hw, "Cancel the query when reset is pending"); - } --- -2.7.4 - diff --git a/0034-net-hns3-fix-link-status-change-from-firmware.patch b/0034-net-hns3-fix-link-status-change-from-firmware.patch deleted file mode 100644 index 4cf077b..0000000 --- a/0034-net-hns3-fix-link-status-change-from-firmware.patch +++ /dev/null @@ -1,115 +0,0 @@ -From 721dce02ae8a5ca9da07849d9759310f1e3cafda Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 3 Feb 2021 20:23:48 +0800 -Subject: [PATCH 034/189] net/hns3: fix link status change from firmware - -When the hardware link status changes, the firmware proactively -reports the link status change message, and then driver update -link status. This feature is lack of a switch to control in PF -driver. Otherwise, this feature does not take effect when the -kernel PF driver that supports the feature is not loaded. - -Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.h | 10 ++++++++++ - drivers/net/hns3/hns3_ethdev.c | 31 +++++++++++++++++++++++++++++++ - 2 files changed, 41 insertions(+) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index dc97a1a..ad5e188 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -206,6 +206,9 @@ enum hns3_opcode_type { - /* Clear hardware state command */ - HNS3_OPC_CLEAR_HW_STATE = 0x700B, - -+ /* Firmware stats command */ -+ HNS3_OPC_FIRMWARE_COMPAT_CFG = 0x701A, -+ - /* SFP command */ - HNS3_OPC_SFP_GET_SPEED = 0x7104, - -@@ -633,6 +636,13 @@ enum hns3_promisc_type { - HNS3_BROADCAST = 3, - }; - -+#define HNS3_LINK_EVENT_REPORT_EN_B 0 -+#define HNS3_NCSI_ERROR_REPORT_EN_B 1 -+struct hns3_firmware_compat_cmd { -+ uint32_t compat; -+ uint8_t rsv[20]; -+}; -+ - #define HNS3_MAC_TX_EN_B 6 - #define HNS3_MAC_RX_EN_B 7 - #define HNS3_MAC_PAD_TX_B 11 -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index b624fce..30f09a7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -3919,6 +3919,26 @@ hns3_buffer_alloc(struct hns3_hw *hw) - } - - static int -+hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) -+{ -+ struct hns3_firmware_compat_cmd *req; -+ struct hns3_cmd_desc desc; -+ uint32_t compat = 0; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false); -+ req = (struct hns3_firmware_compat_cmd *)desc.data; -+ -+ if (is_init) { -+ hns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1); -+ hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); -+ } -+ -+ req->compat = rte_cpu_to_le_32(compat); -+ -+ return hns3_cmd_send(hw, &desc, 1); -+} -+ -+static int - hns3_mac_init(struct hns3_hw *hw) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -@@ -4610,6 +4630,15 @@ hns3_init_hardware(struct hns3_adapter *hns) - goto err_mac_init; - } - -+ /* -+ * Requiring firmware to enable some features, driver can -+ * still work without it. -+ */ -+ ret = hns3_firmware_compat_config(hw, true); -+ if (ret) -+ PMD_INIT_LOG(WARNING, "firmware compatible features not " -+ "supported, ret = %d.", ret); -+ - return 0; - - err_mac_init: -@@ -4746,6 +4775,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - err_enable_intr: - hns3_fdir_filter_uninit(hns); - err_fdir: -+ (void)hns3_firmware_compat_config(hw, false); - hns3_uninit_umv_space(hw); - err_init_hw: - hns3_tqp_stats_uninit(hw); -@@ -4780,6 +4810,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - (void)hns3_config_gro(hw, false); - hns3_promisc_uninit(hw); - hns3_fdir_filter_uninit(hns); -+ (void)hns3_firmware_compat_config(hw, false); - hns3_uninit_umv_space(hw); - hns3_tqp_stats_uninit(hw); - hns3_pf_disable_irq0(hw); --- -2.7.4 - diff --git a/0035-net-hns3-fix-RSS-indirection-table-size.patch b/0035-net-hns3-fix-RSS-indirection-table-size.patch deleted file mode 100644 index 197876c..0000000 --- a/0035-net-hns3-fix-RSS-indirection-table-size.patch +++ /dev/null @@ -1,334 +0,0 @@ -From 00cee658ee4db31787baecbaff321d14734f6494 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Wed, 3 Feb 2021 20:23:49 +0800 -Subject: [PATCH 035/189] net/hns3: fix RSS indirection table size - -The driver should not use the fixed value as the validity check of -RSS indirection table size with HW supported. As a result, it will -cause misjudgment when the RSS RETA size with HW supported have -changed. - -Fixes: c37ca66f2b27 ("net/hns3: support RSS") -Cc: stable@dpdk.org - -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.c | 11 +++++++++++ - drivers/net/hns3/hns3_cmd.h | 7 ++++++- - drivers/net/hns3/hns3_dcb.c | 2 +- - drivers/net/hns3/hns3_ethdev.c | 18 ++++++++++++++++-- - drivers/net/hns3/hns3_ethdev_vf.c | 18 ++++++++++++++++-- - drivers/net/hns3/hns3_flow.c | 6 +++--- - drivers/net/hns3/hns3_rss.c | 28 ++++++++++++++-------------- - drivers/net/hns3/hns3_rss.h | 5 ++--- - 8 files changed, 69 insertions(+), 26 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 4c301cb..a6ea072 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -430,6 +430,16 @@ static void hns3_parse_capability(struct hns3_hw *hw, - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_STASH_B, 1); - } - -+static uint32_t -+hns3_build_api_caps(void) -+{ -+ uint32_t api_caps = 0; -+ -+ hns3_set_bit(api_caps, HNS3_API_CAP_FLEX_RSS_TBL_B, 1); -+ -+ return rte_cpu_to_le_32(api_caps); -+} -+ - static enum hns3_cmd_status - hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw) - { -@@ -439,6 +449,7 @@ hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw) - - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_FW_VER, 1); - resp = (struct hns3_query_version_cmd *)desc.data; -+ resp->api_caps = hns3_build_api_caps(); - - /* Initialize the cmd function */ - ret = hns3_cmd_send(hw, &desc, 1); -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index ad5e188..5640fe4 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -295,11 +295,16 @@ enum HNS3_CAPS_BITS { - HNS3_CAPS_HW_PAD_B, - HNS3_CAPS_STASH_B, - }; -+ -+enum HNS3_API_CAP_BITS { -+ HNS3_API_CAP_FLEX_RSS_TBL_B, -+}; -+ - #define HNS3_QUERY_CAP_LENGTH 3 - struct hns3_query_version_cmd { - uint32_t firmware; - uint32_t hardware; -- uint32_t rsv; -+ uint32_t api_caps; - uint32_t caps[HNS3_QUERY_CAP_LENGTH]; /* capabilities of device */ - }; - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 5aa374c..7fc6ac9 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -644,7 +644,7 @@ hns3_set_rss_size(struct hns3_hw *hw, uint16_t nb_rx_q) - * stage of the reset process. - */ - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { -- for (i = 0; i < HNS3_RSS_IND_TBL_SIZE; i++) -+ for (i = 0; i < hw->rss_ind_tbl_size; i++) - rss_cfg->rss_indirection_tbl[i] = - i % hw->alloc_rss_size; - } -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 30f09a7..df7220b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2593,7 +2593,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - - info->vmdq_queue_num = 0; - -- info->reta_size = HNS3_RSS_IND_TBL_SIZE; -+ info->reta_size = hw->rss_ind_tbl_size; - info->hash_key_size = HNS3_RSS_KEY_SIZE; - info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; - -@@ -2984,6 +2984,20 @@ hns3_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) - } - - static int -+hns3_check_dev_specifications(struct hns3_hw *hw) -+{ -+ if (hw->rss_ind_tbl_size == 0 || -+ hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { -+ hns3_err(hw, "the size of hash lookup table configured (%u)" -+ " exceeds the maximum(%u)", hw->rss_ind_tbl_size, -+ HNS3_RSS_IND_TBL_SIZE_MAX); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int - hns3_query_dev_specifications(struct hns3_hw *hw) - { - struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; -@@ -3003,7 +3017,7 @@ hns3_query_dev_specifications(struct hns3_hw *hw) - - hns3_parse_dev_specifications(hw, desc); - -- return 0; -+ return hns3_check_dev_specifications(hw); - } - - static int -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 3a682e5..1b1989e 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1016,7 +1016,7 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - - info->vmdq_queue_num = 0; - -- info->reta_size = HNS3_RSS_IND_TBL_SIZE; -+ info->reta_size = hw->rss_ind_tbl_size; - info->hash_key_size = HNS3_RSS_KEY_SIZE; - info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; - info->default_rxportconf.ring_size = HNS3_DEFAULT_RING_DESC; -@@ -1149,6 +1149,20 @@ hns3vf_parse_dev_specifications(struct hns3_hw *hw, struct hns3_cmd_desc *desc) - } - - static int -+hns3vf_check_dev_specifications(struct hns3_hw *hw) -+{ -+ if (hw->rss_ind_tbl_size == 0 || -+ hw->rss_ind_tbl_size > HNS3_RSS_IND_TBL_SIZE_MAX) { -+ hns3_warn(hw, "the size of hash lookup table configured (%u)" -+ " exceeds the maximum(%u)", hw->rss_ind_tbl_size, -+ HNS3_RSS_IND_TBL_SIZE_MAX); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int - hns3vf_query_dev_specifications(struct hns3_hw *hw) - { - struct hns3_cmd_desc desc[HNS3_QUERY_DEV_SPECS_BD_NUM]; -@@ -1168,7 +1182,7 @@ hns3vf_query_dev_specifications(struct hns3_hw *hw) - - hns3vf_parse_dev_specifications(hw, desc); - -- return 0; -+ return hns3vf_check_dev_specifications(hw); - } - - static int -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 3e387ac..a601124 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1489,14 +1489,14 @@ hns3_update_indir_table(struct rte_eth_dev *dev, - { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -- uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE]; -+ uint16_t indir_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; - uint16_t j; - uint32_t i; - - /* Fill in redirection table */ - memcpy(indir_tbl, hw->rss_info.rss_indirection_tbl, - sizeof(hw->rss_info.rss_indirection_tbl)); -- for (i = 0, j = 0; i < HNS3_RSS_IND_TBL_SIZE; i++, j++) { -+ for (i = 0, j = 0; i < hw->rss_ind_tbl_size; i++, j++) { - j %= num; - if (conf->queue[j] >= hw->alloc_rss_size) { - hns3_err(hw, "queue id(%u) set to redirection table " -@@ -1507,7 +1507,7 @@ hns3_update_indir_table(struct rte_eth_dev *dev, - indir_tbl[i] = conf->queue[j]; - } - -- return hns3_set_rss_indir_table(hw, indir_tbl, HNS3_RSS_IND_TBL_SIZE); -+ return hns3_set_rss_indir_table(hw, indir_tbl, hw->rss_ind_tbl_size); - } - - static int -diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c -index 7d1a297..858e31a 100644 ---- a/drivers/net/hns3/hns3_rss.c -+++ b/drivers/net/hns3/hns3_rss.c -@@ -312,7 +312,7 @@ hns3_set_rss_indir_table(struct hns3_hw *hw, uint16_t *indir, uint16_t size) - - /* Update redirection table of hw */ - memcpy(hw->rss_info.rss_indirection_tbl, indir, -- sizeof(hw->rss_info.rss_indirection_tbl)); -+ sizeof(uint16_t) * size); - - return 0; - } -@@ -324,13 +324,13 @@ hns3_rss_reset_indir_table(struct hns3_hw *hw) - int ret; - - lut = rte_zmalloc("hns3_rss_lut", -- HNS3_RSS_IND_TBL_SIZE * sizeof(uint16_t), 0); -+ hw->rss_ind_tbl_size * sizeof(uint16_t), 0); - if (lut == NULL) { - hns3_err(hw, "No hns3_rss_lut memory can be allocated"); - return -ENOMEM; - } - -- ret = hns3_set_rss_indir_table(hw, lut, HNS3_RSS_IND_TBL_SIZE); -+ ret = hns3_set_rss_indir_table(hw, lut, hw->rss_ind_tbl_size); - if (ret) - hns3_err(hw, "RSS uninit indir table failed: %d", ret); - rte_free(lut); -@@ -428,7 +428,7 @@ hns3_dev_rss_hash_update(struct rte_eth_dev *dev, - } else if (rss_hf && rss_cfg->conf.types == 0) { - /* Enable RSS, restore indirection table by hw's config */ - ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl, -- HNS3_RSS_IND_TBL_SIZE); -+ hw->rss_ind_tbl_size); - if (ret) - goto conf_err; - } -@@ -505,15 +505,15 @@ hns3_dev_rss_reta_update(struct rte_eth_dev *dev, - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - struct hns3_rss_conf *rss_cfg = &hw->rss_info; -- uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */ -- uint16_t indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; -+ uint16_t indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; - uint16_t idx, shift; -+ uint16_t i; - int ret; - -- if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) { -+ if (reta_size != hw->rss_ind_tbl_size) { - hns3_err(hw, "The size of hash lookup table configured (%u)" - "doesn't match the number hardware can supported" -- "(%u)", reta_size, indir_size); -+ "(%u)", reta_size, hw->rss_ind_tbl_size); - return -EINVAL; - } - rte_spinlock_lock(&hw->lock); -@@ -536,7 +536,7 @@ hns3_dev_rss_reta_update(struct rte_eth_dev *dev, - } - - ret = hns3_set_rss_indir_table(hw, indirection_tbl, -- HNS3_RSS_IND_TBL_SIZE); -+ hw->rss_ind_tbl_size); - - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -561,13 +561,13 @@ hns3_dev_rss_reta_query(struct rte_eth_dev *dev, - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - struct hns3_rss_conf *rss_cfg = &hw->rss_info; -- uint16_t i, indir_size = HNS3_RSS_IND_TBL_SIZE; /* Table size is 512 */ - uint16_t idx, shift; -+ uint16_t i; - -- if (reta_size != indir_size || reta_size > ETH_RSS_RETA_SIZE_512) { -+ if (reta_size != hw->rss_ind_tbl_size) { - hns3_err(hw, "The size of hash lookup table configured (%u)" - " doesn't match the number hardware can supported" -- "(%u)", reta_size, indir_size); -+ "(%u)", reta_size, hw->rss_ind_tbl_size); - return -EINVAL; - } - rte_spinlock_lock(&hw->lock); -@@ -662,7 +662,7 @@ hns3_rss_set_default_args(struct hns3_hw *hw) - memcpy(rss_cfg->key, hns3_hash_key, HNS3_RSS_KEY_SIZE); - - /* Initialize RSS indirection table */ -- for (i = 0; i < HNS3_RSS_IND_TBL_SIZE; i++) -+ for (i = 0; i < hw->rss_ind_tbl_size; i++) - rss_cfg->rss_indirection_tbl[i] = i % queue_num; - } - -@@ -711,7 +711,7 @@ hns3_config_rss(struct hns3_adapter *hns) - */ - if (((uint32_t)mq_mode & ETH_MQ_RX_RSS_FLAG)) { - ret = hns3_set_rss_indir_table(hw, rss_cfg->rss_indirection_tbl, -- HNS3_RSS_IND_TBL_SIZE); -+ hw->rss_ind_tbl_size); - if (ret) - goto rss_tuple_uninit; - } -diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h -index 05d5c26..94668ed 100644 ---- a/drivers/net/hns3/hns3_rss.h -+++ b/drivers/net/hns3/hns3_rss.h -@@ -24,9 +24,8 @@ - ETH_RSS_L4_DST_ONLY) - - #define HNS3_RSS_IND_TBL_SIZE 512 /* The size of hash lookup table */ -+#define HNS3_RSS_IND_TBL_SIZE_MAX 2048 - #define HNS3_RSS_KEY_SIZE 40 --#define HNS3_RSS_CFG_TBL_NUM \ -- (HNS3_RSS_IND_TBL_SIZE / HNS3_RSS_CFG_TBL_SIZE) - #define HNS3_RSS_SET_BITMAP_MSK 0xffff - - #define HNS3_RSS_HASH_ALGO_TOEPLITZ 0 -@@ -45,7 +44,7 @@ struct hns3_rss_conf { - uint8_t hash_algo; /* hash function type definited by hardware */ - uint8_t key[HNS3_RSS_KEY_SIZE]; /* Hash key */ - struct hns3_rss_tuple_cfg rss_tuple_sets; -- uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE]; /* Shadow table */ -+ uint16_t rss_indirection_tbl[HNS3_RSS_IND_TBL_SIZE_MAX]; - uint16_t queue[HNS3_RSS_QUEUES_BUFFER_NUM]; /* Queues indices to use */ - bool valid; /* check if RSS rule is valid */ - /* --- -2.7.4 - diff --git a/0036-net-hns3-constrain-TM-peak-rate.patch b/0036-net-hns3-constrain-TM-peak-rate.patch deleted file mode 100644 index 9b5fd76..0000000 --- a/0036-net-hns3-constrain-TM-peak-rate.patch +++ /dev/null @@ -1,37 +0,0 @@ -From aefb4f06db3a837b7e93f8088c1d4882aa9a5041 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 3 Feb 2021 20:23:50 +0800 -Subject: [PATCH 036/189] net/hns3: constrain TM peak rate - -User could config Port or TC's peak rate by TM ops, but hardware does -not support peak rate which lower than 1Mbps. So we constraint TM -peak rate must be at least 1Mbps. - -Fixes: c09c7847d892 ("net/hns3: support traffic management") - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_tm.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index d1639d4..bcae57a 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -200,6 +200,12 @@ hns3_tm_shaper_profile_param_check(struct rte_eth_dev *dev, - return -EINVAL; - } - -+ if (profile->peak.rate < hns3_tm_rate_convert_firmware2tm(1)) { -+ error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE; -+ error->message = "peak rate must be at least 1Mbps"; -+ return -EINVAL; -+ } -+ - if (profile->peak.size) { - error->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE; - error->message = "peak bucket size not supported"; --- -2.7.4 - diff --git a/0037-net-hns3-remove-MPLS-from-supported-flow-items.patch b/0037-net-hns3-remove-MPLS-from-supported-flow-items.patch deleted file mode 100644 index 1f1525d..0000000 --- a/0037-net-hns3-remove-MPLS-from-supported-flow-items.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 93de9a96a68093772f0137a9899616cfd8cea0c6 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 3 Feb 2021 20:23:51 +0800 -Subject: [PATCH 037/189] net/hns3: remove MPLS from supported flow items - -The Kunpeng920 and Kunpeng930 don't support parse MPLS packet, so -remove the type from supported flow items. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 9 +++------ - 1 file changed, 3 insertions(+), 6 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index a601124..c484114 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -44,8 +44,7 @@ static enum rte_flow_item_type first_items[] = { - RTE_FLOW_ITEM_TYPE_NVGRE, - RTE_FLOW_ITEM_TYPE_VXLAN, - RTE_FLOW_ITEM_TYPE_GENEVE, -- RTE_FLOW_ITEM_TYPE_VXLAN_GPE, -- RTE_FLOW_ITEM_TYPE_MPLS -+ RTE_FLOW_ITEM_TYPE_VXLAN_GPE - }; - - static enum rte_flow_item_type L2_next_items[] = { -@@ -65,8 +64,7 @@ static enum rte_flow_item_type L3_next_items[] = { - static enum rte_flow_item_type L4_next_items[] = { - RTE_FLOW_ITEM_TYPE_VXLAN, - RTE_FLOW_ITEM_TYPE_GENEVE, -- RTE_FLOW_ITEM_TYPE_VXLAN_GPE, -- RTE_FLOW_ITEM_TYPE_MPLS -+ RTE_FLOW_ITEM_TYPE_VXLAN_GPE - }; - - static enum rte_flow_item_type tunnel_next_items[] = { -@@ -1118,8 +1116,7 @@ is_tunnel_packet(enum rte_flow_item_type type) - if (type == RTE_FLOW_ITEM_TYPE_VXLAN_GPE || - type == RTE_FLOW_ITEM_TYPE_VXLAN || - type == RTE_FLOW_ITEM_TYPE_NVGRE || -- type == RTE_FLOW_ITEM_TYPE_GENEVE || -- type == RTE_FLOW_ITEM_TYPE_MPLS) -+ type == RTE_FLOW_ITEM_TYPE_GENEVE) - return true; - return false; - } --- -2.7.4 - diff --git a/0038-net-hns3-fix-stats-flip-overflow.patch b/0038-net-hns3-fix-stats-flip-overflow.patch deleted file mode 100644 index 9aa09ac..0000000 --- a/0038-net-hns3-fix-stats-flip-overflow.patch +++ /dev/null @@ -1,67 +0,0 @@ -From a2524d07bf2f71c925d363fbb7fcfc6d7def57c4 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 3 Feb 2021 20:23:52 +0800 -Subject: [PATCH 038/189] net/hns3: fix stats flip overflow - -Currently, statistics may overflow in some scenarios. - -For example, if HW statistics are reset by stats reset operation, -but there are still a lot of residual packets exist in the HW -queues and these packets are error packets, flip may occurred -because the ipacket is obtained by subtracting the number of -software error packets from the number of HW received packets. - -This patch verifies the calculation and returns 0 when overflow -may occur. - -Fixes: 8839c5e202f3 ("net/hns3: support device stats") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_stats.c | 21 +++++++++++++++++---- - 1 file changed, 17 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 3ba09e2..e0e40ca 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -554,8 +554,14 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - } - - rte_stats->oerrors = 0; -- rte_stats->ipackets = stats->rcb_rx_ring_pktnum_rcd - -- rte_stats->ierrors; -+ /* -+ * If HW statistics are reset by stats_reset, but a lot of residual -+ * packets exist in the hardware queue and these packets are error -+ * packets, flip overflow may occurred. So return 0 in this case. -+ */ -+ rte_stats->ipackets = -+ stats->rcb_rx_ring_pktnum_rcd > rte_stats->ierrors ? -+ stats->rcb_rx_ring_pktnum_rcd - rte_stats->ierrors : 0; - rte_stats->opackets = stats->rcb_tx_ring_pktnum_rcd - - rte_stats->oerrors; - rte_stats->rx_nombuf = eth_dev->data->rx_mbuf_alloc_failed; -@@ -792,8 +798,15 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - rxq_stats = &rxq->basic_stats; - rxq_stats->errors = rxq->err_stats.l2_errors + - rxq->err_stats.pkt_len_errors; -- rxq_stats->packets = stats->rcb_rx_ring_pktnum[i] - -- rxq_stats->errors; -+ /* -+ * If HW statistics are reset by stats_reset, but a lot of -+ * residual packets exist in the hardware queue and these -+ * packets are error packets, flip overflow may occurred. -+ * So return 0 in this case. -+ */ -+ rxq_stats->packets = -+ stats->rcb_rx_ring_pktnum[i] > rxq_stats->errors ? -+ stats->rcb_rx_ring_pktnum[i] - rxq_stats->errors : 0; - rxq_stats->bytes = 0; - for (j = 0; j < HNS3_NUM_RXQ_BASIC_STATS; j++) { - val = (char *)rxq_stats + --- -2.7.4 - diff --git a/0039-net-hns3-use-C11-atomics.patch b/0039-net-hns3-use-C11-atomics.patch deleted file mode 100644 index 804e533..0000000 --- a/0039-net-hns3-use-C11-atomics.patch +++ /dev/null @@ -1,338 +0,0 @@ -From 458bb9377c72010ed41f4d2faedad2bd08562cd1 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 3 Feb 2021 20:23:53 +0800 -Subject: [PATCH 039/189] net/hns3: use C11 atomics - -Replace all the atomic type with C11 atomic builtins in hns3 -PMD. - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.c | 13 +++++++------ - drivers/net/hns3/hns3_ethdev.c | 21 ++++++++++++--------- - drivers/net/hns3/hns3_ethdev.h | 4 ++-- - drivers/net/hns3/hns3_ethdev_vf.c | 19 +++++++++++-------- - drivers/net/hns3/hns3_intr.c | 22 ++++++++++++++-------- - drivers/net/hns3/hns3_mbx.c | 4 ++-- - 6 files changed, 48 insertions(+), 35 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index a6ea072..9393978 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -202,7 +202,8 @@ hns3_cmd_csq_clean(struct hns3_hw *hw) - hns3_err(hw, "wrong cmd head (%u, %u-%u)", head, - csq->next_to_use, csq->next_to_clean); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, -+ __ATOMIC_RELAXED); - hns3_schedule_delayed_reset(HNS3_DEV_HW_TO_ADAPTER(hw)); - } - -@@ -311,7 +312,7 @@ static int hns3_cmd_poll_reply(struct hns3_hw *hw) - if (hns3_cmd_csq_done(hw)) - return 0; - -- if (rte_atomic16_read(&hw->reset.disable_cmd)) { -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { - hns3_err(hw, - "Don't wait for reply because of disable_cmd"); - return -EBUSY; -@@ -358,7 +359,7 @@ hns3_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, int num) - int retval; - uint32_t ntc; - -- if (rte_atomic16_read(&hw->reset.disable_cmd)) -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) - return -EBUSY; - - rte_spinlock_lock(&hw->cmq.csq.lock); -@@ -535,7 +536,7 @@ hns3_cmd_init(struct hns3_hw *hw) - ret = -EBUSY; - goto err_cmd_init; - } -- rte_atomic16_clear(&hw->reset.disable_cmd); -+ __atomic_store_n(&hw->reset.disable_cmd, 0, __ATOMIC_RELAXED); - - ret = hns3_cmd_query_firmware_version_and_capability(hw); - if (ret) { -@@ -557,7 +558,7 @@ hns3_cmd_init(struct hns3_hw *hw) - return 0; - - err_cmd_init: -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - return ret; - } - -@@ -583,7 +584,7 @@ hns3_cmd_uninit(struct hns3_hw *hw) - { - rte_spinlock_lock(&hw->cmq.csq.lock); - rte_spinlock_lock(&hw->cmq.crq.lock); -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - hns3_cmd_clear_regs(hw); - rte_spinlock_unlock(&hw->cmq.crq.lock); - rte_spinlock_unlock(&hw->cmq.csq.lock); -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index df7220b..f54b7c2 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -130,7 +130,7 @@ hns3_proc_imp_reset_event(struct hns3_adapter *hns, bool is_delay, - { - struct hns3_hw *hw = &hns->hw; - -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending); - *vec_val = BIT(HNS3_VECTOR0_IMPRESET_INT_B); - if (!is_delay) { -@@ -150,7 +150,7 @@ hns3_proc_global_reset_event(struct hns3_adapter *hns, bool is_delay, - { - struct hns3_hw *hw = &hns->hw; - -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - hns3_atomic_set_bit(HNS3_GLOBAL_RESET, &hw->reset.pending); - *vec_val = BIT(HNS3_VECTOR0_GLOBALRESET_INT_B); - if (!is_delay) { -@@ -5070,7 +5070,7 @@ hns3_do_stop(struct hns3_adapter *hns) - return ret; - hw->mac.link_status = ETH_LINK_DOWN; - -- if (rte_atomic16_read(&hw->reset.disable_cmd) == 0) { -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) { - hns3_configure_all_mac_addr(hns, true); - ret = hns3_reset_all_tqps(hns); - if (ret) { -@@ -5613,7 +5613,7 @@ hns3_prepare_reset(struct hns3_adapter *hns) - * any mailbox handling or command to firmware is only valid - * after hns3_cmd_init is called. - */ -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - hw->reset.stats.request_cnt++; - break; - case HNS3_IMP_RESET: -@@ -5673,7 +5673,7 @@ hns3_stop_service(struct hns3_adapter *hns) - * from table space. Hence, for function reset software intervention is - * required to delete the entries - */ -- if (rte_atomic16_read(&hw->reset.disable_cmd) == 0) -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) - hns3_configure_all_mc_mac_addr(hns, true); - rte_spinlock_unlock(&hw->lock); - -@@ -5795,8 +5795,10 @@ hns3_reset_service(void *param) - * The interrupt may have been lost. It is necessary to handle - * the interrupt to recover from the error. - */ -- if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_DEFERRED) { -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_REQUESTED); -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -+ SCHEDULE_DEFERRED) { -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, -+ __ATOMIC_RELAXED); - hns3_err(hw, "Handling interrupts in delayed tasks"); - hns3_interrupt_handler(&rte_eth_devices[hw->data->port_id]); - reset_level = hns3_get_reset_level(hns, &hw->reset.pending); -@@ -5805,7 +5807,7 @@ hns3_reset_service(void *param) - hns3_atomic_set_bit(HNS3_IMP_RESET, &hw->reset.pending); - } - } -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_NONE); -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_NONE, __ATOMIC_RELAXED); - - /* - * Check if there is any ongoing reset in the hardware. This status can -@@ -6325,7 +6327,8 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - - hw->adapter_state = HNS3_NIC_INITIALIZED; - -- if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_PENDING) { -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -+ SCHEDULE_PENDING) { - hns3_err(hw, "Reschedule reset service after dev_init"); - hns3_schedule_reset(hns); - } else { -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 547e991..cf42ef1 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -352,11 +352,11 @@ enum hns3_schedule { - - struct hns3_reset_data { - enum hns3_reset_stage stage; -- rte_atomic16_t schedule; -+ uint16_t schedule; - /* Reset flag, covering the entire reset process */ - uint16_t resetting; - /* Used to disable sending cmds during reset */ -- rte_atomic16_t disable_cmd; -+ uint16_t disable_cmd; - /* The reset level being processed */ - enum hns3_reset_level level; - /* Reset level set, each bit represents a reset level */ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 1b1989e..42cee37 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1059,7 +1059,7 @@ hns3vf_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - rst_ing_reg = hns3_read_dev(hw, HNS3_FUN_RST_ING); - hns3_warn(hw, "resetting reg: 0x%x", rst_ing_reg); - hns3_atomic_set_bit(HNS3_VF_RESET, &hw->reset.pending); -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - val = hns3_read_dev(hw, HNS3_VF_RST_ING); - hns3_write_dev(hw, HNS3_VF_RST_ING, val | HNS3_VF_RST_ING_BIT); - val = cmdq_stat_reg & ~BIT(HNS3_VECTOR0_RST_INT_B); -@@ -1934,7 +1934,7 @@ hns3vf_do_stop(struct hns3_adapter *hns) - - hw->mac.link_status = ETH_LINK_DOWN; - -- if (rte_atomic16_read(&hw->reset.disable_cmd) == 0) { -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) { - hns3vf_configure_mac_addr(hns, true); - ret = hns3_reset_all_tqps(hns); - if (ret) { -@@ -2410,7 +2410,7 @@ hns3vf_prepare_reset(struct hns3_adapter *hns) - ret = hns3_send_mbx_msg(hw, HNS3_MBX_RESET, 0, NULL, - 0, true, NULL, 0); - } -- rte_atomic16_set(&hw->reset.disable_cmd, 1); -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - - return ret; - } -@@ -2449,7 +2449,7 @@ hns3vf_stop_service(struct hns3_adapter *hns) - * from table space. Hence, for function reset software intervention is - * required to delete the entries. - */ -- if (rte_atomic16_read(&hw->reset.disable_cmd) == 0) -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) - hns3vf_configure_all_mc_mac_addr(hns, true); - rte_spinlock_unlock(&hw->lock); - -@@ -2621,8 +2621,10 @@ hns3vf_reset_service(void *param) - * The interrupt may have been lost. It is necessary to handle - * the interrupt to recover from the error. - */ -- if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_DEFERRED) { -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_REQUESTED); -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -+ SCHEDULE_DEFERRED) { -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, -+ __ATOMIC_RELAXED); - hns3_err(hw, "Handling interrupts in delayed tasks"); - hns3vf_interrupt_handler(&rte_eth_devices[hw->data->port_id]); - reset_level = hns3vf_get_reset_level(hw, &hw->reset.pending); -@@ -2631,7 +2633,7 @@ hns3vf_reset_service(void *param) - hns3_atomic_set_bit(HNS3_VF_RESET, &hw->reset.pending); - } - } -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_NONE); -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_NONE, __ATOMIC_RELAXED); - - /* - * Hardware reset has been notified, we now have to poll & check if -@@ -2854,7 +2856,8 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - - hw->adapter_state = HNS3_NIC_INITIALIZED; - -- if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_PENDING) { -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -+ SCHEDULE_PENDING) { - hns3_err(hw, "Reschedule reset service after dev_init"); - hns3_schedule_reset(hns); - } else { -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 51f19b4..88ce4c6 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1762,7 +1762,7 @@ hns3_reset_init(struct hns3_hw *hw) - hw->reset.request = 0; - hw->reset.pending = 0; - hw->reset.resetting = 0; -- rte_atomic16_init(&hw->reset.disable_cmd); -+ __atomic_store_n(&hw->reset.disable_cmd, 0, __ATOMIC_RELAXED); - hw->reset.wait_data = rte_zmalloc("wait_data", - sizeof(struct hns3_wait_data), 0); - if (!hw->reset.wait_data) { -@@ -1779,7 +1779,8 @@ hns3_schedule_reset(struct hns3_adapter *hns) - - /* Reschedule the reset process after successful initialization */ - if (hw->adapter_state == HNS3_NIC_UNINITIALIZED) { -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_PENDING); -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_PENDING, -+ __ATOMIC_RELAXED); - return; - } - -@@ -1787,11 +1788,14 @@ hns3_schedule_reset(struct hns3_adapter *hns) - return; - - /* Schedule restart alarm if it is not scheduled yet */ -- if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_REQUESTED) -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -+ SCHEDULE_REQUESTED) - return; -- if (rte_atomic16_read(&hns->hw.reset.schedule) == SCHEDULE_DEFERRED) -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -+ SCHEDULE_DEFERRED) - rte_eal_alarm_cancel(hw->reset.ops->reset_service, hns); -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_REQUESTED); -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, -+ __ATOMIC_RELAXED); - - rte_eal_alarm_set(SWITCH_CONTEXT_US, hw->reset.ops->reset_service, hns); - } -@@ -1808,9 +1812,11 @@ hns3_schedule_delayed_reset(struct hns3_adapter *hns) - return; - } - -- if (rte_atomic16_read(&hns->hw.reset.schedule) != SCHEDULE_NONE) -+ if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) != -+ SCHEDULE_NONE) - return; -- rte_atomic16_set(&hns->hw.reset.schedule, SCHEDULE_DEFERRED); -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_DEFERRED, -+ __ATOMIC_RELAXED); - rte_eal_alarm_set(DEFERRED_SCHED_US, hw->reset.ops->reset_service, hns); - } - -@@ -1983,7 +1989,7 @@ hns3_reset_err_handle(struct hns3_adapter *hns) - * Regardless of whether the execution is successful or not, the - * flow after execution must be continued. - */ -- if (rte_atomic16_read(&hw->reset.disable_cmd)) -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) - (void)hns3_cmd_init(hw); - reset_fail: - hw->reset.attempts = 0; -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 3e44e3b..e745843 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -83,7 +83,7 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, - end = now + HNS3_MAX_RETRY_MS; - while ((hw->mbx_resp.head != hw->mbx_resp.tail + hw->mbx_resp.lost) && - (now < end)) { -- if (rte_atomic16_read(&hw->reset.disable_cmd)) { -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { - hns3_err(hw, "Don't wait for mbx respone because of " - "disable_cmd"); - return -EBUSY; -@@ -369,7 +369,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - int i; - - while (!hns3_cmd_crq_empty(hw)) { -- if (rte_atomic16_read(&hw->reset.disable_cmd)) -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) - return; - - desc = &crq->desc[crq->next_to_use]; --- -2.7.4 - diff --git a/0040-net-hns3-fix-flow-director-rule-residue-on-malloc-fa.patch b/0040-net-hns3-fix-flow-director-rule-residue-on-malloc-fa.patch deleted file mode 100644 index 8332e2f..0000000 --- a/0040-net-hns3-fix-flow-director-rule-residue-on-malloc-fa.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 2b24ee3f6acfaa8170a37022aab4b5b93d4dc0ae Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 3 Feb 2021 20:23:54 +0800 -Subject: [PATCH 040/189] net/hns3: fix flow director rule residue on malloc - failure - -After FD rule config success, driver will malloc fdir_rule to hold the -rule info, if malloc fail the FD rule in hardware was not cleanup. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_flow.c | 21 +++++++++++---------- - 1 file changed, 11 insertions(+), 10 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index c484114..a016857 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1806,17 +1806,18 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - - flow->counter_id = fdir_rule.act_cnt.id; - } -+ -+ fdir_rule_ptr = rte_zmalloc("hns3 fdir rule", -+ sizeof(struct hns3_fdir_rule_ele), -+ 0); -+ if (fdir_rule_ptr == NULL) { -+ hns3_err(hw, "failed to allocate fdir_rule memory."); -+ ret = -ENOMEM; -+ goto err_fdir; -+ } -+ - ret = hns3_fdir_filter_program(hns, &fdir_rule, false); - if (!ret) { -- fdir_rule_ptr = rte_zmalloc("hns3 fdir rule", -- sizeof(struct hns3_fdir_rule_ele), -- 0); -- if (fdir_rule_ptr == NULL) { -- hns3_err(hw, "Failed to allocate fdir_rule memory"); -- ret = -ENOMEM; -- goto err_fdir; -- } -- - memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule, - sizeof(struct hns3_fdir_rule)); - TAILQ_INSERT_TAIL(&process_list->fdir_list, -@@ -1827,10 +1828,10 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - return flow; - } - -+ rte_free(fdir_rule_ptr); - err_fdir: - if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) - hns3_counter_release(dev, fdir_rule.act_cnt.id); -- - err: - rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Failed to create flow"); --- -2.7.4 - diff --git a/0041-net-hns3-fix-firmware-exceptions-by-concurrent-comma.patch b/0041-net-hns3-fix-firmware-exceptions-by-concurrent-comma.patch deleted file mode 100644 index 0a053a8..0000000 --- a/0041-net-hns3-fix-firmware-exceptions-by-concurrent-comma.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 50cb4151490c7814418be61cc54d45ad335c11aa Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 3 Feb 2021 20:23:55 +0800 -Subject: [PATCH 041/189] net/hns3: fix firmware exceptions by concurrent - commands - -There are two scenarios that command queue uninit performed -concurrently with the firmware command: asynchronous command -and timeout command. - -For asynchronous command, if a large number of functions send -commands, these commands may need to be queued to wait for -firmware processing. If a function is uninited suddenly, CMDQ -clearing and firmware processing may be performed concurrently. - -For timeout command, if the command failed due to busy scheduling -of firmware, this command will be processed in the next scheduling. -And this may lead to concurrency. - -The preceding concurrency may lead to a firmware exceptions. - -This patch add a waiting time to ensure the firmware complete the -processing of left over command when PMD uninit. - -Fixes: 737f30e1c3ab ("net/hns3: support command interface with firmware") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.c | 14 +++++++++++++- - drivers/net/hns3/hns3_cmd.h | 1 + - 2 files changed, 14 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 9393978..0590898 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -582,9 +582,21 @@ hns3_cmd_destroy_queue(struct hns3_hw *hw) - void - hns3_cmd_uninit(struct hns3_hw *hw) - { -+ __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); -+ -+ /* -+ * A delay is added to ensure that the register cleanup operations -+ * will not be performed concurrently with the firmware command and -+ * ensure that all the reserved commands are executed. -+ * Concurrency may occur in two scenarios: asynchronous command and -+ * timeout command. If the command fails to be executed due to busy -+ * scheduling, the command will be processed in the next scheduling -+ * of the firmware. -+ */ -+ rte_delay_ms(HNS3_CMDQ_CLEAR_WAIT_TIME); -+ - rte_spinlock_lock(&hw->cmq.csq.lock); - rte_spinlock_lock(&hw->cmq.crq.lock); -- __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - hns3_cmd_clear_regs(hw); - rte_spinlock_unlock(&hw->cmq.crq.lock); - rte_spinlock_unlock(&hw->cmq.csq.lock); -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 5640fe4..5010278 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -8,6 +8,7 @@ - #include - - #define HNS3_CMDQ_TX_TIMEOUT 30000 -+#define HNS3_CMDQ_CLEAR_WAIT_TIME 200 - #define HNS3_CMDQ_RX_INVLD_B 0 - #define HNS3_CMDQ_RX_OUTVLD_B 1 - #define HNS3_CMD_DESC_ALIGNMENT 4096 --- -2.7.4 - diff --git a/0042-net-hns3-fix-VF-reset-on-mailbox-failure.patch b/0042-net-hns3-fix-VF-reset-on-mailbox-failure.patch deleted file mode 100644 index 58533e7..0000000 --- a/0042-net-hns3-fix-VF-reset-on-mailbox-failure.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 6ceabcab7a4b103f854f338486c1d9fd08349e90 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 3 Feb 2021 20:23:56 +0800 -Subject: [PATCH 042/189] net/hns3: fix VF reset on mailbox failure - -Currently, during the VF reset, the VF will send a MBX to inform -PF to reset it and the disable command bit will be set whether -the MBX is successful. Generally, multiple reset attempts are made -after a failure. However, because the command is disabled, all -subsequent reset will all fail. - -This patch disable the command only after the MBX message is -successfully. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev_vf.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 42cee37..fc9f3c8 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2404,15 +2404,17 @@ static int - hns3vf_prepare_reset(struct hns3_adapter *hns) - { - struct hns3_hw *hw = &hns->hw; -- int ret = 0; -+ int ret; - - if (hw->reset.level == HNS3_VF_FUNC_RESET) { - ret = hns3_send_mbx_msg(hw, HNS3_MBX_RESET, 0, NULL, - 0, true, NULL, 0); -+ if (ret) -+ return ret; - } - __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - -- return ret; -+ return 0; - } - - static int --- -2.7.4 - diff --git a/0043-net-hns3-validate-requested-maximum-Rx-frame-length.patch b/0043-net-hns3-validate-requested-maximum-Rx-frame-length.patch deleted file mode 100644 index a352dce..0000000 --- a/0043-net-hns3-validate-requested-maximum-Rx-frame-length.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 835880a4bec5fc2fd64d199f3a899e2864c11252 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 3 Feb 2021 20:23:57 +0800 -Subject: [PATCH 043/189] net/hns3: validate requested maximum Rx frame length - -When jumbo frame is enabled, the MTU size needs to be modified -based on 'max_rx_pkt_len'. Driver needs to check the validity -of 'max_rx_pkt_len'. And it should be in the range of -HNS3_DEFAULT_FRAME_LEN and HNS3_MAX_FRAME_LEN. Otherwise, it may -cause that the MTU size is inconsistent with jumbo frame offload. - -Fixes: 19a3ca4c99cf ("net/hns3: add start/stop and configure operations") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 19 +++++++++++++------ - drivers/net/hns3/hns3_ethdev_vf.c | 19 +++++++++++++------ - 2 files changed, 26 insertions(+), 12 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f54b7c2..7ed55b1 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2343,6 +2343,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) - uint16_t nb_rx_q = dev->data->nb_rx_queues; - uint16_t nb_tx_q = dev->data->nb_tx_queues; - struct rte_eth_rss_conf rss_conf; -+ uint32_t max_rx_pkt_len; - uint16_t mtu; - bool gro_en; - int ret; -@@ -2396,12 +2397,18 @@ hns3_dev_configure(struct rte_eth_dev *dev) - * according to the maximum RX packet length. - */ - if (conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { -- /* -- * Security of max_rx_pkt_len is guaranteed in dpdk frame. -- * Maximum value of max_rx_pkt_len is HNS3_MAX_FRAME_LEN, so it -- * can safely assign to "uint16_t" type variable. -- */ -- mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(conf->rxmode.max_rx_pkt_len); -+ max_rx_pkt_len = conf->rxmode.max_rx_pkt_len; -+ if (max_rx_pkt_len > HNS3_MAX_FRAME_LEN || -+ max_rx_pkt_len <= HNS3_DEFAULT_FRAME_LEN) { -+ hns3_err(hw, "maximum Rx packet length must be greater " -+ "than %u and less than %u when jumbo frame enabled.", -+ (uint16_t)HNS3_DEFAULT_FRAME_LEN, -+ (uint16_t)HNS3_MAX_FRAME_LEN); -+ ret = -EINVAL; -+ goto cfg_err; -+ } -+ -+ mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(max_rx_pkt_len); - ret = hns3_dev_mtu_set(dev, mtu); - if (ret) - goto cfg_err; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index fc9f3c8..d5157cf 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -778,6 +778,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - uint16_t nb_rx_q = dev->data->nb_rx_queues; - uint16_t nb_tx_q = dev->data->nb_tx_queues; - struct rte_eth_rss_conf rss_conf; -+ uint32_t max_rx_pkt_len; - uint16_t mtu; - bool gro_en; - int ret; -@@ -825,12 +826,18 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - * according to the maximum RX packet length. - */ - if (conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { -- /* -- * Security of max_rx_pkt_len is guaranteed in dpdk frame. -- * Maximum value of max_rx_pkt_len is HNS3_MAX_FRAME_LEN, so it -- * can safely assign to "uint16_t" type variable. -- */ -- mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(conf->rxmode.max_rx_pkt_len); -+ max_rx_pkt_len = conf->rxmode.max_rx_pkt_len; -+ if (max_rx_pkt_len > HNS3_MAX_FRAME_LEN || -+ max_rx_pkt_len <= HNS3_DEFAULT_FRAME_LEN) { -+ hns3_err(hw, "maximum Rx packet length must be greater " -+ "than %u and less than %u when jumbo frame enabled.", -+ (uint16_t)HNS3_DEFAULT_FRAME_LEN, -+ (uint16_t)HNS3_MAX_FRAME_LEN); -+ ret = -EINVAL; -+ goto cfg_err; -+ } -+ -+ mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(max_rx_pkt_len); - ret = hns3vf_dev_mtu_set(dev, mtu); - if (ret) - goto cfg_err; --- -2.7.4 - diff --git a/0044-drivers-net-redefine-array-size-macros.patch b/0044-drivers-net-redefine-array-size-macros.patch deleted file mode 100644 index d6cd224..0000000 --- a/0044-drivers-net-redefine-array-size-macros.patch +++ /dev/null @@ -1,156 +0,0 @@ -From 6b66b8fd3b82d5f7c7d35b5e1c52d2611abc4317 Mon Sep 17 00:00:00 2001 -From: Andrew Boyer -Date: Fri, 29 Jan 2021 14:44:32 -0800 -Subject: [PATCH 044/189] drivers/net: redefine array size macros - -Replace copies of size(arr)/size(arr[0]) with RTE_DIM(). -Eventually all of these macro definitions should be removed. - -Signed-off-by: Andrew Boyer -Reviewed-by: Ferruh Yigit ---- - drivers/net/atlantic/atl_hw_regs.h | 2 +- - drivers/net/axgbe/axgbe_common.h | 2 +- - drivers/net/bnx2x/bnx2x.h | 2 +- - drivers/net/bnx2x/elink.h | 2 +- - drivers/net/ena/ena_ethdev.c | 2 +- - drivers/net/enic/base/vnic_devcmd.h | 2 +- - drivers/net/hns3/hns3_ethdev.h | 2 +- - drivers/net/i40e/base/i40e_osdep.h | 2 +- - drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h | 2 +- - drivers/net/thunderx/base/nicvf_hw.h | 2 +- - 10 files changed, 10 insertions(+), 10 deletions(-) - -diff --git a/drivers/net/atlantic/atl_hw_regs.h b/drivers/net/atlantic/atl_hw_regs.h -index a2d6ca8..4f6cd35 100644 ---- a/drivers/net/atlantic/atl_hw_regs.h -+++ b/drivers/net/atlantic/atl_hw_regs.h -@@ -26,7 +26,7 @@ - - #define mdelay rte_delay_ms - #define udelay rte_delay_us --#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -+#define ARRAY_SIZE(arr) RTE_DIM(arr) - #define BIT(x) (1UL << (x)) - - #define AQ_HW_WAIT_FOR(_B_, _US_, _N_) \ -diff --git a/drivers/net/axgbe/axgbe_common.h b/drivers/net/axgbe/axgbe_common.h -index fb97f0b..799382a 100644 ---- a/drivers/net/axgbe/axgbe_common.h -+++ b/drivers/net/axgbe/axgbe_common.h -@@ -42,7 +42,7 @@ - - #define BIT(nr) (1 << (nr)) - #ifndef ARRAY_SIZE --#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -+#define ARRAY_SIZE(arr) RTE_DIM(arr) - #endif - - #define AXGBE_HZ 250 -diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h -index 69cc143..e13ab15 100644 ---- a/drivers/net/bnx2x/bnx2x.h -+++ b/drivers/net/bnx2x/bnx2x.h -@@ -81,7 +81,7 @@ - #endif - - #ifndef ARRAY_SIZE --#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -+#define ARRAY_SIZE(arr) RTE_DIM(arr) - #endif - #ifndef DIV_ROUND_UP - #define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) -diff --git a/drivers/net/bnx2x/elink.h b/drivers/net/bnx2x/elink.h -index dd70ac6..6b2e85f 100644 ---- a/drivers/net/bnx2x/elink.h -+++ b/drivers/net/bnx2x/elink.h -@@ -86,7 +86,7 @@ extern void elink_cb_notify_link_changed(struct bnx2x_softc *sc); - #define ELINK_EVENT_ID_SFP_UNQUALIFIED_MODULE 1 - #define ELINK_EVENT_ID_SFP_POWER_FAULT 2 - --#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -+#define ARRAY_SIZE(x) RTE_DIM(x) - /* Debug prints */ - #ifdef ELINK_DEBUG - -diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c -index 20ff365..b4b8794 100644 ---- a/drivers/net/ena/ena_ethdev.c -+++ b/drivers/net/ena/ena_ethdev.c -@@ -47,7 +47,7 @@ - #define ENA_HASH_KEY_SIZE 40 - #define ETH_GSTRING_LEN 32 - --#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -+#define ARRAY_SIZE(x) RTE_DIM(x) - - #define ENA_MIN_RING_DESC 128 - -diff --git a/drivers/net/enic/base/vnic_devcmd.h b/drivers/net/enic/base/vnic_devcmd.h -index a2f577f..4675e5a 100644 ---- a/drivers/net/enic/base/vnic_devcmd.h -+++ b/drivers/net/enic/base/vnic_devcmd.h -@@ -63,7 +63,7 @@ - #define _CMD_VTYPE(cmd) (((cmd) >> _CMD_VTYPESHIFT) & _CMD_VTYPEMASK) - #define _CMD_N(cmd) (((cmd) >> _CMD_NSHIFT) & _CMD_NMASK) - --#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -+#define ARRAY_SIZE(x) RTE_DIM(x) - - enum vnic_devcmd_cmd { - CMD_NONE = _CMDC(_CMD_DIR_NONE, _CMD_VTYPE_NONE, 0), -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index cf42ef1..6178f0b 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -887,7 +887,7 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) - #define hns3_read_dev(a, reg) \ - hns3_read_reg((a)->io_base, (reg)) - --#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -+#define ARRAY_SIZE(x) RTE_DIM(x) - - #define NEXT_ITEM_OF_ACTION(act, actions, index) \ - do { \ -diff --git a/drivers/net/i40e/base/i40e_osdep.h b/drivers/net/i40e/base/i40e_osdep.h -index 9b50330..9b79ece 100644 ---- a/drivers/net/i40e/base/i40e_osdep.h -+++ b/drivers/net/i40e/base/i40e_osdep.h -@@ -155,7 +155,7 @@ static inline uint32_t i40e_read_addr(volatile void *addr) - I40E_PCI_REG_WRITE(I40E_PCI_REG_ADDR((a), (reg)), (value)) - #define flush(a) i40e_read_addr(I40E_PCI_REG_ADDR((a), (I40E_GLGEN_STAT))) - --#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) -+#define ARRAY_SIZE(arr) RTE_DIM(arr) - - /* memory allocation tracking */ - struct i40e_dma_mem { -diff --git a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h -index d46574b..7b64e2d 100644 ---- a/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h -+++ b/drivers/net/nfp/nfpcore/nfp-common/nfp_platform.h -@@ -23,7 +23,7 @@ - #endif - - #ifndef ARRAY_SIZE --#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -+#define ARRAY_SIZE(x) RTE_DIM(x) - #endif - - #define NFP_ERRNO(err) (errno = (err), -1) -diff --git a/drivers/net/thunderx/base/nicvf_hw.h b/drivers/net/thunderx/base/nicvf_hw.h -index fd13ea8..d6f3a57 100644 ---- a/drivers/net/thunderx/base/nicvf_hw.h -+++ b/drivers/net/thunderx/base/nicvf_hw.h -@@ -17,7 +17,7 @@ - #define PCI_SUB_DEVICE_ID_CN81XX_NICVF 0xA234 - #define PCI_SUB_DEVICE_ID_CN83XX_NICVF 0xA334 - --#define NICVF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) -+#define NICVF_ARRAY_SIZE(arr) RTE_DIM(arr) - - #define NICVF_GET_RX_STATS(reg) \ - nicvf_reg_read(nic, NIC_VNIC_RX_STAT_0_13 | (reg << 3)) --- -2.7.4 - diff --git a/0045-net-hns3-support-module-EEPROM-dump.patch b/0045-net-hns3-support-module-EEPROM-dump.patch deleted file mode 100644 index 2c756ef..0000000 --- a/0045-net-hns3-support-module-EEPROM-dump.patch +++ /dev/null @@ -1,241 +0,0 @@ -From 4d36d14e1683f50904525e26fbf311c0aa677940 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 4 Mar 2021 15:44:41 +0800 -Subject: [PATCH 045/189] net/hns3: support module EEPROM dump - -This patch add support for dumping module EEPROM. - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - doc/guides/nics/features/hns3.ini | 1 + - drivers/net/hns3/hns3_cmd.h | 16 ++++ - drivers/net/hns3/hns3_ethdev.c | 159 ++++++++++++++++++++++++++++++++++++++ - 3 files changed, 176 insertions(+) - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index f0747e3..5ccaca5 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -38,6 +38,7 @@ Extended stats = Y - Stats per queue = Y - FW version = Y - Registers dump = Y -+Module EEPROM dump = Y - Multiprocess aware = Y - Linux UIO = Y - Linux VFIO = Y -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 5010278..ff424a0 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -211,6 +211,8 @@ enum hns3_opcode_type { - HNS3_OPC_FIRMWARE_COMPAT_CFG = 0x701A, - - /* SFP command */ -+ HNS3_OPC_GET_SFP_EEPROM = 0x7100, -+ HNS3_OPC_GET_SFP_EXIST = 0x7101, - HNS3_OPC_SFP_GET_SPEED = 0x7104, - - /* Interrupts commands */ -@@ -714,6 +716,20 @@ struct hns3_config_auto_neg_cmd { - #define HNS3_MAC_FEC_BASER 1 - #define HNS3_MAC_FEC_RS 2 - -+#define HNS3_SFP_INFO_BD0_LEN 20UL -+#define HNS3_SFP_INFO_BDX_LEN 24UL -+ -+struct hns3_sfp_info_bd0_cmd { -+ uint16_t offset; -+ uint16_t read_len; -+ uint8_t data[HNS3_SFP_INFO_BD0_LEN]; -+}; -+ -+struct hns3_sfp_type { -+ uint8_t type; -+ uint8_t ext_type; -+}; -+ - struct hns3_sfp_speed_cmd { - uint32_t sfp_speed; - uint8_t query_type; /* 0: sfp speed, 1: active fec */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7ed55b1..2a37fcc 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6172,6 +6172,163 @@ hns3_query_dev_fec_info(struct hns3_hw *hw) - return ret; - } - -+static bool -+hns3_optical_module_existed(struct hns3_hw *hw) -+{ -+ struct hns3_cmd_desc desc; -+ bool existed; -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_GET_SFP_EXIST, true); -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, -+ "fail to get optical module exist state, ret = %d.\n", -+ ret); -+ return false; -+ } -+ existed = !!desc.data[0]; -+ -+ return existed; -+} -+ -+static int -+hns3_get_module_eeprom_data(struct hns3_hw *hw, uint32_t offset, -+ uint32_t len, uint8_t *data) -+{ -+#define HNS3_SFP_INFO_CMD_NUM 6 -+#define HNS3_SFP_INFO_MAX_LEN \ -+ (HNS3_SFP_INFO_BD0_LEN + \ -+ (HNS3_SFP_INFO_CMD_NUM - 1) * HNS3_SFP_INFO_BDX_LEN) -+ struct hns3_cmd_desc desc[HNS3_SFP_INFO_CMD_NUM]; -+ struct hns3_sfp_info_bd0_cmd *sfp_info_bd0; -+ uint16_t read_len; -+ uint16_t copy_len; -+ int ret; -+ int i; -+ -+ for (i = 0; i < HNS3_SFP_INFO_CMD_NUM; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_GET_SFP_EEPROM, -+ true); -+ if (i < HNS3_SFP_INFO_CMD_NUM - 1) -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ -+ sfp_info_bd0 = (struct hns3_sfp_info_bd0_cmd *)desc[0].data; -+ sfp_info_bd0->offset = rte_cpu_to_le_16((uint16_t)offset); -+ read_len = RTE_MIN(len, HNS3_SFP_INFO_MAX_LEN); -+ sfp_info_bd0->read_len = rte_cpu_to_le_16((uint16_t)read_len); -+ -+ ret = hns3_cmd_send(hw, desc, HNS3_SFP_INFO_CMD_NUM); -+ if (ret) { -+ hns3_err(hw, "fail to get module EEPROM info, ret = %d.\n", -+ ret); -+ return ret; -+ } -+ -+ /* The data format in BD0 is different with the others. */ -+ copy_len = RTE_MIN(len, HNS3_SFP_INFO_BD0_LEN); -+ memcpy(data, sfp_info_bd0->data, copy_len); -+ read_len = copy_len; -+ -+ for (i = 1; i < HNS3_SFP_INFO_CMD_NUM; i++) { -+ if (read_len >= len) -+ break; -+ -+ copy_len = RTE_MIN(len - read_len, HNS3_SFP_INFO_BDX_LEN); -+ memcpy(data + read_len, desc[i].data, copy_len); -+ read_len += copy_len; -+ } -+ -+ return (int)read_len; -+} -+ -+static int -+hns3_get_module_eeprom(struct rte_eth_dev *dev, -+ struct rte_dev_eeprom_info *info) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); -+ uint32_t offset = info->offset; -+ uint32_t len = info->length; -+ uint8_t *data = info->data; -+ uint32_t read_len = 0; -+ -+ if (hw->mac.media_type != HNS3_MEDIA_TYPE_FIBER) -+ return -ENOTSUP; -+ -+ if (!hns3_optical_module_existed(hw)) { -+ hns3_err(hw, "fail to read module EEPROM: no module is connected.\n"); -+ return -EIO; -+ } -+ -+ while (read_len < len) { -+ int ret; -+ ret = hns3_get_module_eeprom_data(hw, offset + read_len, -+ len - read_len, -+ data + read_len); -+ if (ret < 0) -+ return -EIO; -+ read_len += ret; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_get_module_info(struct rte_eth_dev *dev, -+ struct rte_eth_dev_module_info *modinfo) -+{ -+#define HNS3_SFF8024_ID_SFP 0x03 -+#define HNS3_SFF8024_ID_QSFP_8438 0x0c -+#define HNS3_SFF8024_ID_QSFP_8436_8636 0x0d -+#define HNS3_SFF8024_ID_QSFP28_8636 0x11 -+#define HNS3_SFF_8636_V1_3 0x03 -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(hns); -+ struct rte_dev_eeprom_info info; -+ struct hns3_sfp_type sfp_type; -+ int ret; -+ -+ memset(&sfp_type, 0, sizeof(sfp_type)); -+ memset(&info, 0, sizeof(info)); -+ info.data = (uint8_t *)&sfp_type; -+ info.length = sizeof(sfp_type); -+ ret = hns3_get_module_eeprom(dev, &info); -+ if (ret) -+ return ret; -+ -+ switch (sfp_type.type) { -+ case HNS3_SFF8024_ID_SFP: -+ modinfo->type = RTE_ETH_MODULE_SFF_8472; -+ modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8472_LEN; -+ break; -+ case HNS3_SFF8024_ID_QSFP_8438: -+ modinfo->type = RTE_ETH_MODULE_SFF_8436; -+ modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8436_MAX_LEN; -+ break; -+ case HNS3_SFF8024_ID_QSFP_8436_8636: -+ if (sfp_type.ext_type < HNS3_SFF_8636_V1_3) { -+ modinfo->type = RTE_ETH_MODULE_SFF_8436; -+ modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8436_MAX_LEN; -+ } else { -+ modinfo->type = RTE_ETH_MODULE_SFF_8636; -+ modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8636_MAX_LEN; -+ } -+ break; -+ case HNS3_SFF8024_ID_QSFP28_8636: -+ modinfo->type = RTE_ETH_MODULE_SFF_8636; -+ modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8636_MAX_LEN; -+ break; -+ default: -+ hns3_err(hw, "unknown module, type = %u, extra_type = %u.\n", -+ sfp_type.type, sfp_type.ext_type); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ - static const struct eth_dev_ops hns3_eth_dev_ops = { - .dev_configure = hns3_dev_configure, - .dev_start = hns3_dev_start, -@@ -6223,6 +6380,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { - .vlan_offload_set = hns3_vlan_offload_set, - .vlan_pvid_set = hns3_vlan_pvid_set, - .get_reg = hns3_get_regs, -+ .get_module_info = hns3_get_module_info, -+ .get_module_eeprom = hns3_get_module_eeprom, - .get_dcb_info = hns3_get_dcb_info, - .dev_supported_ptypes_get = hns3_dev_supported_ptypes_get, - .fec_get_capability = hns3_fec_get_capability, --- -2.7.4 - diff --git a/0046-net-hns3-add-more-registers-to-dump.patch b/0046-net-hns3-add-more-registers-to-dump.patch deleted file mode 100644 index 54ff5d9..0000000 --- a/0046-net-hns3-add-more-registers-to-dump.patch +++ /dev/null @@ -1,255 +0,0 @@ -From b7995f87e190e4ab83ff6a5faea584a4ea4c2198 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 4 Mar 2021 15:44:42 +0800 -Subject: [PATCH 046/189] net/hns3: add more registers to dump - -This patch makes more registers dumped in the dump_reg API to help -locate the fault. - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.h | 13 ++++ - drivers/net/hns3/hns3_regs.c | 171 ++++++++++++++++++++++++++++++++++++++++++- - 2 files changed, 180 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index ff424a0..2e23f99 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -95,6 +95,19 @@ enum hns3_opcode_type { - HNS3_OPC_QUERY_REG_NUM = 0x0040, - HNS3_OPC_QUERY_32_BIT_REG = 0x0041, - HNS3_OPC_QUERY_64_BIT_REG = 0x0042, -+ HNS3_OPC_DFX_BD_NUM = 0x0043, -+ HNS3_OPC_DFX_BIOS_COMMON_REG = 0x0044, -+ HNS3_OPC_DFX_SSU_REG_0 = 0x0045, -+ HNS3_OPC_DFX_SSU_REG_1 = 0x0046, -+ HNS3_OPC_DFX_IGU_EGU_REG = 0x0047, -+ HNS3_OPC_DFX_RPU_REG_0 = 0x0048, -+ HNS3_OPC_DFX_RPU_REG_1 = 0x0049, -+ HNS3_OPC_DFX_NCSI_REG = 0x004A, -+ HNS3_OPC_DFX_RTC_REG = 0x004B, -+ HNS3_OPC_DFX_PPP_REG = 0x004C, -+ HNS3_OPC_DFX_RCB_REG = 0x004D, -+ HNS3_OPC_DFX_TQP_REG = 0x004E, -+ HNS3_OPC_DFX_SSU_REG_2 = 0x004F, - - HNS3_OPC_QUERY_DEV_SPECS = 0x0050, - -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index 8afe132..5b14727 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -15,6 +15,8 @@ - #define REG_NUM_PER_LINE 4 - #define REG_LEN_PER_LINE (REG_NUM_PER_LINE * sizeof(uint32_t)) - -+static int hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *length); -+ - static const uint32_t cmdq_reg_addrs[] = {HNS3_CMDQ_TX_ADDR_L_REG, - HNS3_CMDQ_TX_ADDR_H_REG, - HNS3_CMDQ_TX_DEPTH_REG, -@@ -77,6 +79,21 @@ static const uint32_t tqp_intr_reg_addrs[] = {HNS3_TQP_INTR_CTRL_REG, - HNS3_TQP_INTR_GL2_REG, - HNS3_TQP_INTR_RL_REG}; - -+static const uint32_t hns3_dfx_reg_opcode_list[] = { -+ HNS3_OPC_DFX_BIOS_COMMON_REG, -+ HNS3_OPC_DFX_SSU_REG_0, -+ HNS3_OPC_DFX_SSU_REG_1, -+ HNS3_OPC_DFX_IGU_EGU_REG, -+ HNS3_OPC_DFX_RPU_REG_0, -+ HNS3_OPC_DFX_RPU_REG_1, -+ HNS3_OPC_DFX_NCSI_REG, -+ HNS3_OPC_DFX_RTC_REG, -+ HNS3_OPC_DFX_PPP_REG, -+ HNS3_OPC_DFX_RCB_REG, -+ HNS3_OPC_DFX_TQP_REG, -+ HNS3_OPC_DFX_SSU_REG_2 -+}; -+ - static int - hns3_get_regs_num(struct hns3_hw *hw, uint32_t *regs_num_32_bit, - uint32_t *regs_num_64_bit) -@@ -123,14 +140,21 @@ hns3_get_regs_length(struct hns3_hw *hw, uint32_t *length) - if (!hns->is_vf) { - ret = hns3_get_regs_num(hw, ®s_num_32_bit, ®s_num_64_bit); - if (ret) { -- hns3_err(hw, "Get register number failed, ret = %d.", -- ret); -- return -ENOTSUP; -+ hns3_err(hw, "fail to get the number of registers, " -+ "ret = %d.", ret); -+ return ret; - } - dfx_reg_lines = regs_num_32_bit * sizeof(uint32_t) / - REG_LEN_PER_LINE + 1; - dfx_reg_lines += regs_num_64_bit * sizeof(uint64_t) / - REG_LEN_PER_LINE + 1; -+ -+ ret = hns3_get_dfx_reg_line(hw, &dfx_reg_lines); -+ if (ret) { -+ hns3_err(hw, "fail to get the number of dfx registers, " -+ "ret = %d.", ret); -+ return ret; -+ } - len += dfx_reg_lines * REG_NUM_PER_LINE; - } - -@@ -310,6 +334,144 @@ hns3_direct_access_regs(struct hns3_hw *hw, uint32_t *data) - return data - origin_data_ptr; - } - -+static int -+hns3_get_dfx_reg_bd_num(struct hns3_hw *hw, uint32_t *bd_num_list, -+ uint32_t list_size) -+{ -+#define HNS3_GET_DFX_REG_BD_NUM_SIZE 4 -+ struct hns3_cmd_desc desc[HNS3_GET_DFX_REG_BD_NUM_SIZE]; -+ uint32_t index, desc_index; -+ uint32_t bd_num; -+ uint32_t i; -+ int ret; -+ -+ for (i = 0; i < HNS3_GET_DFX_REG_BD_NUM_SIZE - 1; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_DFX_BD_NUM, true); -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ /* The last BD does not need a next flag */ -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_DFX_BD_NUM, true); -+ -+ ret = hns3_cmd_send(hw, desc, HNS3_GET_DFX_REG_BD_NUM_SIZE); -+ if (ret) { -+ hns3_err(hw, "fail to get dfx bd num, ret = %d.\n", ret); -+ return ret; -+ } -+ -+ /* The first data in the first BD is a reserved field */ -+ for (i = 1; i <= list_size; i++) { -+ desc_index = i / HNS3_CMD_DESC_DATA_NUM; -+ index = i % HNS3_CMD_DESC_DATA_NUM; -+ bd_num = rte_le_to_cpu_32(desc[desc_index].data[index]); -+ bd_num_list[i - 1] = bd_num; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_dfx_reg_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, -+ int bd_num, uint32_t opcode) -+{ -+ int ret; -+ int i; -+ -+ for (i = 0; i < bd_num - 1; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], opcode, true); -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ /* The last BD does not need a next flag */ -+ hns3_cmd_setup_basic_desc(&desc[i], opcode, true); -+ -+ ret = hns3_cmd_send(hw, desc, bd_num); -+ if (ret) { -+ hns3_err(hw, "fail to query dfx registers, opcode = 0x%04X, " -+ "ret = %d.\n", opcode, ret); -+ } -+ -+ return ret; -+} -+ -+static int -+hns3_dfx_reg_fetch_data(struct hns3_cmd_desc *desc, int bd_num, uint32_t *reg) -+{ -+ int desc_index; -+ int reg_num; -+ int index; -+ int i; -+ -+ reg_num = bd_num * HNS3_CMD_DESC_DATA_NUM; -+ for (i = 0; i < reg_num; i++) { -+ desc_index = i / HNS3_CMD_DESC_DATA_NUM; -+ index = i % HNS3_CMD_DESC_DATA_NUM; -+ *reg++ = desc[desc_index].data[index]; -+ } -+ reg_num += hns3_insert_reg_separator(reg_num, reg); -+ -+ return reg_num; -+} -+ -+static int -+hns3_get_dfx_reg_line(struct hns3_hw *hw, uint32_t *lines) -+{ -+ int opcode_num = RTE_DIM(hns3_dfx_reg_opcode_list); -+ uint32_t bd_num_list[opcode_num]; -+ uint32_t bd_num, data_len; -+ int ret; -+ int i; -+ -+ ret = hns3_get_dfx_reg_bd_num(hw, bd_num_list, opcode_num); -+ if (ret) -+ return ret; -+ -+ for (i = 0; i < opcode_num; i++) { -+ bd_num = bd_num_list[i]; -+ data_len = bd_num * HNS3_CMD_DESC_DATA_NUM * sizeof(uint32_t); -+ *lines += data_len / REG_LEN_PER_LINE + 1; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_get_dfx_regs(struct hns3_hw *hw, void **data) -+{ -+ int opcode_num = RTE_DIM(hns3_dfx_reg_opcode_list); -+ uint32_t max_bd_num, bd_num, opcode; -+ uint32_t bd_num_list[opcode_num]; -+ struct hns3_cmd_desc *cmd_descs; -+ uint32_t *reg_val = (uint32_t *)*data; -+ int ret; -+ int i; -+ -+ ret = hns3_get_dfx_reg_bd_num(hw, bd_num_list, opcode_num); -+ if (ret) -+ return ret; -+ -+ max_bd_num = 0; -+ for (i = 0; i < opcode_num; i++) -+ max_bd_num = RTE_MAX(bd_num_list[i], max_bd_num); -+ -+ cmd_descs = rte_zmalloc(NULL, sizeof(*cmd_descs) * max_bd_num, 0); -+ if (cmd_descs == NULL) -+ return -ENOMEM; -+ -+ for (i = 0; i < opcode_num; i++) { -+ opcode = hns3_dfx_reg_opcode_list[i]; -+ bd_num = bd_num_list[i]; -+ if (bd_num == 0) -+ continue; -+ ret = hns3_dfx_reg_cmd_send(hw, cmd_descs, bd_num, opcode); -+ if (ret) -+ break; -+ reg_val += hns3_dfx_reg_fetch_data(cmd_descs, bd_num, reg_val); -+ } -+ rte_free(cmd_descs); -+ *data = (void *)reg_val; -+ -+ return ret; -+} -+ - int - hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - { -@@ -371,5 +533,6 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - data += regs_num_64_bit * HNS3_64_BIT_REG_SIZE; - data += hns3_insert_reg_separator(regs_num_64_bit * - HNS3_64_BIT_REG_SIZE, data); -- return ret; -+ -+ return hns3_get_dfx_regs(hw, (void **)&data); - } --- -2.7.4 - diff --git a/0047-net-hns3-implement-Tx-mbuf-free-on-demand.patch b/0047-net-hns3-implement-Tx-mbuf-free-on-demand.patch deleted file mode 100644 index 17fcd7f..0000000 --- a/0047-net-hns3-implement-Tx-mbuf-free-on-demand.patch +++ /dev/null @@ -1,151 +0,0 @@ -From f789787f6d1f096a04d39e3de46e5292a7bde3fe Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 4 Mar 2021 15:44:43 +0800 -Subject: [PATCH 047/189] net/hns3: implement Tx mbuf free on demand - -This patch add support tx_done_cleanup ops, which could support for -the API rte_eth_tx_done_cleanup to free consumed mbufs on Tx ring. - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - doc/guides/nics/features/hns3.ini | 1 + - doc/guides/nics/features/hns3_vf.ini | 1 + - drivers/net/hns3/hns3_ethdev.c | 1 + - drivers/net/hns3/hns3_ethdev_vf.c | 1 + - drivers/net/hns3/hns3_rxtx.c | 59 ++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_rxtx.h | 1 + - 6 files changed, 64 insertions(+) - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index 5ccaca5..00a26cd 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -10,6 +10,7 @@ Queue start/stop = Y - Runtime Rx queue setup = Y - Runtime Tx queue setup = Y - Burst mode info = Y -+Free Tx mbuf on demand = Y - MTU update = Y - Jumbo frame = Y - Scattered Rx = Y -diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini -index 3128b63..f3dd239 100644 ---- a/doc/guides/nics/features/hns3_vf.ini -+++ b/doc/guides/nics/features/hns3_vf.ini -@@ -10,6 +10,7 @@ Queue start/stop = Y - Runtime Rx queue setup = Y - Runtime Tx queue setup = Y - Burst mode info = Y -+Free Tx mbuf on demand = Y - MTU update = Y - Jumbo frame = Y - Scattered Rx = Y -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2a37fcc..6e0f3b1 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6388,6 +6388,7 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { - .fec_get = hns3_fec_get, - .fec_set = hns3_fec_set, - .tm_ops_get = hns3_tm_ops_get, -+ .tx_done_cleanup = hns3_tx_done_cleanup, - }; - - static const struct hns3_reset_ops hns3_reset_ops = { -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index d5157cf..5b4c587 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2763,6 +2763,7 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { - .vlan_offload_set = hns3vf_vlan_offload_set, - .get_reg = hns3_get_regs, - .dev_supported_ptypes_get = hns3_dev_supported_ptypes_get, -+ .tx_done_cleanup = hns3_tx_done_cleanup, - }; - - static const struct hns3_reset_ops hns3vf_reset_ops = { -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 1991b4e..df97018 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -3913,6 +3913,65 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) - return 0; - } - -+static int -+hns3_tx_done_cleanup_full(struct hns3_tx_queue *txq, uint32_t free_cnt) -+{ -+ uint16_t next_to_clean = txq->next_to_clean; -+ uint16_t next_to_use = txq->next_to_use; -+ uint16_t tx_bd_ready = txq->tx_bd_ready; -+ struct hns3_entry *tx_pkt = &txq->sw_ring[next_to_clean]; -+ struct hns3_desc *desc = &txq->tx_ring[next_to_clean]; -+ uint32_t idx; -+ -+ if (free_cnt == 0 || free_cnt > txq->nb_tx_desc) -+ free_cnt = txq->nb_tx_desc; -+ -+ for (idx = 0; idx < free_cnt; idx++) { -+ if (next_to_clean == next_to_use) -+ break; -+ -+ if (desc->tx.tp_fe_sc_vld_ra_ri & -+ rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B))) -+ break; -+ -+ if (tx_pkt->mbuf != NULL) { -+ rte_pktmbuf_free_seg(tx_pkt->mbuf); -+ tx_pkt->mbuf = NULL; -+ } -+ -+ next_to_clean++; -+ tx_bd_ready++; -+ tx_pkt++; -+ desc++; -+ if (next_to_clean == txq->nb_tx_desc) { -+ tx_pkt = txq->sw_ring; -+ desc = txq->tx_ring; -+ next_to_clean = 0; -+ } -+ } -+ -+ if (idx > 0) { -+ txq->next_to_clean = next_to_clean; -+ txq->tx_bd_ready = tx_bd_ready; -+ } -+ -+ return (int)idx; -+} -+ -+int -+hns3_tx_done_cleanup(void *txq, uint32_t free_cnt) -+{ -+ struct hns3_tx_queue *q = (struct hns3_tx_queue *)txq; -+ struct rte_eth_dev *dev = &rte_eth_devices[q->port_id]; -+ -+ if (dev->tx_pkt_burst == hns3_xmit_pkts) -+ return hns3_tx_done_cleanup_full(q, free_cnt); -+ else if (dev->tx_pkt_burst == hns3_dummy_rxtx_burst) -+ return 0; -+ else -+ return -ENOTSUP; -+} -+ - uint32_t - hns3_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) - { -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 8f5ae5c..7118bd4 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -706,5 +706,6 @@ int hns3_start_all_txqs(struct rte_eth_dev *dev); - int hns3_start_all_rxqs(struct rte_eth_dev *dev); - void hns3_stop_all_txqs(struct rte_eth_dev *dev); - void hns3_restore_tqp_enable_state(struct hns3_hw *hw); -+int hns3_tx_done_cleanup(void *txq, uint32_t free_cnt); - - #endif /* _HNS3_RXTX_H_ */ --- -2.7.4 - diff --git a/0048-net-hns3-add-bytes-stats.patch b/0048-net-hns3-add-bytes-stats.patch deleted file mode 100644 index 062040e..0000000 --- a/0048-net-hns3-add-bytes-stats.patch +++ /dev/null @@ -1,210 +0,0 @@ -From e5b9ec998c2de659f177332bcdb4868116063b17 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 4 Mar 2021 15:44:44 +0800 -Subject: [PATCH 048/189] net/hns3: add bytes stats - -In current HNS3 PMD, Rx/Tx bytes from packet stats are not -implemented. - -This patch implemented Rx/Tx bytes using soft counters. - -Signed-off-by: Min Hu (Connor) -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_rxtx.c | 16 ++++++++++++++++ - drivers/net/hns3/hns3_rxtx_vec_neon.h | 9 +++++++++ - drivers/net/hns3/hns3_rxtx_vec_sve.c | 8 ++++++++ - drivers/net/hns3/hns3_stats.c | 18 ++++++++++++++---- - 4 files changed, 47 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index df97018..897e5fa 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2181,6 +2181,9 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) - cksum_err); - hns3_rxd_to_vlan_tci(rxq, rxm, l234_info, &rxd); - -+ /* Increment bytes counter */ -+ rxq->basic_stats.bytes += rxm->pkt_len; -+ - rx_pkts[nb_rx++] = rxm; - continue; - pkt_err: -@@ -2401,6 +2404,9 @@ hns3_recv_scattered_pkts(void *rx_queue, - cksum_err); - hns3_rxd_to_vlan_tci(rxq, first_seg, l234_info, &rxd); - -+ /* Increment bytes counter */ -+ rxq->basic_stats.bytes += first_seg->pkt_len; -+ - rx_pkts[nb_rx++] = first_seg; - first_seg = NULL; - continue; -@@ -3516,6 +3522,11 @@ hns3_tx_fill_hw_ring(struct hns3_tx_queue *txq, - for (i = 0; i < mainpart; i += PER_LOOP_NUM) { - hns3_tx_backup_4mbuf(tx_entry + i, pkts + i); - hns3_tx_setup_4bd(txdp + i, pkts + i); -+ -+ /* Increment bytes counter */ -+ uint32_t j; -+ for (j = 0; j < PER_LOOP_NUM; j++) -+ txq->basic_stats.bytes += pkts[i + j]->pkt_len; - } - if (unlikely(leftover > 0)) { - for (i = 0; i < leftover; i++) { -@@ -3523,6 +3534,9 @@ hns3_tx_fill_hw_ring(struct hns3_tx_queue *txq, - pkts + mainpart + i); - hns3_tx_setup_1bd(txdp + mainpart + i, - pkts + mainpart + i); -+ -+ /* Increment bytes counter */ -+ txq->basic_stats.bytes += pkts[mainpart + i]->pkt_len; - } - } - } -@@ -3661,6 +3675,8 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) - desc->tx.tp_fe_sc_vld_ra_ri |= - rte_cpu_to_le_16(BIT(HNS3_TXD_FE_B)); - -+ /* Increment bytes counter */ -+ txq->basic_stats.bytes += tx_pkt->pkt_len; - nb_hold += i; - txq->next_to_use = tx_next_use; - txq->tx_bd_ready -= i; -diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h -index a693b4b..68f098f 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_neon.h -+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h -@@ -61,6 +61,9 @@ hns3_xmit_fixed_burst_vec(void *__restrict tx_queue, - for (i = 0; i < n; i++, tx_pkts++, tx_desc++) { - hns3_vec_tx(tx_desc, *tx_pkts); - tx_entry[i].mbuf = *tx_pkts; -+ -+ /* Increment bytes counter */ -+ txq->basic_stats.bytes += (*tx_pkts)->pkt_len; - } - - nb_commit -= n; -@@ -72,6 +75,9 @@ hns3_xmit_fixed_burst_vec(void *__restrict tx_queue, - for (i = 0; i < nb_commit; i++, tx_pkts++, tx_desc++) { - hns3_vec_tx(tx_desc, *tx_pkts); - tx_entry[i].mbuf = *tx_pkts; -+ -+ /* Increment bytes counter */ -+ txq->basic_stats.bytes += (*tx_pkts)->pkt_len; - } - - next_to_use += nb_commit; -@@ -116,6 +122,9 @@ hns3_desc_parse_field(struct hns3_rx_queue *rxq, - if (likely(bd_base_info & BIT(HNS3_RXD_L3L4P_B))) - hns3_rx_set_cksum_flag(pkt, pkt->packet_type, - cksum_err); -+ -+ /* Increment bytes counter */ -+ rxq->basic_stats.bytes += pkt->pkt_len; - } - - return retcode; -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index 8c2c8f6..947c19f 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -58,6 +58,9 @@ hns3_desc_parse_field_sve(struct hns3_rx_queue *rxq, - if (likely(key->bd_base_info[i] & BIT(HNS3_RXD_L3L4P_B))) - hns3_rx_set_cksum_flag(rx_pkts[i], - rx_pkts[i]->packet_type, cksum_err); -+ -+ /* Increment bytes counter */ -+ rxq->basic_stats.bytes += rx_pkts[i]->pkt_len; - } - - return retcode; -@@ -408,6 +411,11 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, - svst1_scatter_u64offset_u64(pg, (uint64_t *)&txdp->tx.paylen, - offsets, svdup_n_u64(valid_bit)); - -+ /* Increment bytes counter */ -+ uint32_t idx; -+ for (idx = 0; idx < svcntd(); idx++) -+ txq->basic_stats.bytes += pkts[idx]->pkt_len; -+ - /* update index for next loop */ - i += svcntd(); - pkts += svcntd(); -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index e0e40ca..777d36a 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -358,6 +358,7 @@ static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = { - HNS3_NUM_RESET_XSTATS) - - static void hns3_tqp_stats_clear(struct hns3_hw *hw); -+static void hns3_tqp_basic_stats_clear(struct rte_eth_dev *dev); - - /* - * Query all the MAC statistics data of Network ICL command ,opcode id: 0x0034. -@@ -543,16 +544,26 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - return ret; - } - -- /* Get the error stats of received packets */ -+ /* Get the error stats and bytes of received packets */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq) { - cnt = rxq->err_stats.l2_errors + - rxq->err_stats.pkt_len_errors; - rte_stats->ierrors += cnt; -+ -+ rte_stats->ibytes += rxq->basic_stats.bytes; - } - } - -+ /* Get the bytes of received packets */ -+ struct hns3_tx_queue *txq; -+ for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { -+ txq = eth_dev->data->tx_queues[i]; -+ if (txq) -+ rte_stats->obytes += txq->basic_stats.bytes; -+ } -+ - rte_stats->oerrors = 0; - /* - * If HW statistics are reset by stats_reset, but a lot of residual -@@ -623,6 +634,7 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - * their source. - */ - hns3_tqp_stats_clear(hw); -+ hns3_tqp_basic_stats_clear(eth_dev); - - return 0; - } -@@ -807,7 +819,6 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - rxq_stats->packets = - stats->rcb_rx_ring_pktnum[i] > rxq_stats->errors ? - stats->rcb_rx_ring_pktnum[i] - rxq_stats->errors : 0; -- rxq_stats->bytes = 0; - for (j = 0; j < HNS3_NUM_RXQ_BASIC_STATS; j++) { - val = (char *)rxq_stats + - hns3_rxq_basic_stats_strings[j].offset; -@@ -836,7 +847,7 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - - txq_stats = &txq->basic_stats; - txq_stats->packets = stats->rcb_tx_ring_pktnum[i]; -- txq_stats->bytes = 0; -+ - for (j = 0; j < HNS3_NUM_TXQ_BASIC_STATS; j++) { - val = (char *)txq_stats + - hns3_txq_basic_stats_strings[j].offset; -@@ -1328,7 +1339,6 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) - if (ret) - return ret; - -- hns3_tqp_basic_stats_clear(dev); - hns3_tqp_dfx_stats_clear(dev); - - /* Clear reset stats */ --- -2.7.4 - diff --git a/0049-net-hns3-add-imissed-packet-stats.patch b/0049-net-hns3-add-imissed-packet-stats.patch deleted file mode 100644 index 222d3fa..0000000 --- a/0049-net-hns3-add-imissed-packet-stats.patch +++ /dev/null @@ -1,274 +0,0 @@ -From 682546e9b26cf26a4b82a0c022f5c8dd4a7aa7ed Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 4 Mar 2021 15:44:45 +0800 -Subject: [PATCH 049/189] net/hns3: add imissed packet stats - -This patch implement Rx imissed stats by querying cmdq. - -Signed-off-by: Min Hu (Connor) -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.h | 7 +++ - drivers/net/hns3/hns3_ethdev.c | 7 +++ - drivers/net/hns3/hns3_ethdev.h | 1 + - drivers/net/hns3/hns3_stats.c | 106 ++++++++++++++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_stats.h | 8 ++++ - 5 files changed, 128 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 2e23f99..93bfa74 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -905,6 +905,13 @@ struct hns3_dev_specs_0_cmd { - uint32_t max_tm_rate; - }; - -+struct hns3_query_rpu_cmd { -+ uint32_t tc_queue_num; -+ uint32_t rsv1[2]; -+ uint32_t rpu_rx_pkt_drop_cnt; -+ uint32_t rsv2[2]; -+}; -+ - #define HNS3_MAX_TQP_NUM_HIP08_PF 64 - #define HNS3_DEFAULT_TX_BUF 0x4000 /* 16k bytes */ - #define HNS3_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 6e0f3b1..96ad9b0 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4742,6 +4742,13 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_cmd_init; - } - -+ /* Hardware statistics of imissed registers cleared. */ -+ ret = hns3_update_imissed_stats(hw, true); -+ if (ret) { -+ hns3_err(hw, "clear imissed stats failed, ret = %d", ret); -+ return ret; -+ } -+ - hns3_config_all_msix_error(hw, true); - - ret = rte_intr_callback_register(&pci_dev->intr_handle, -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 6178f0b..2954422 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -434,6 +434,7 @@ struct hns3_hw { - struct hns3_tqp_stats tqp_stats; - /* Include Mac stats | Rx stats | Tx stats */ - struct hns3_mac_stats mac_stats; -+ struct hns3_rx_missed_stats imissed_stats; - uint32_t fw_version; - - uint16_t num_msi; -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 777d36a..87035e3 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -324,6 +324,12 @@ static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = { - {"TX_QUEUE_FBD", HNS3_RING_TX_FBDNUM_REG} - }; - -+/* The statistic of imissed packet */ -+static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { -+ {"RPU_DROP_CNT", -+ HNS3_IMISSED_STATS_FIELD_OFFSET(rpu_rx_drop_cnt)}, -+}; -+ - #define HNS3_NUM_MAC_STATS (sizeof(hns3_mac_strings) / \ - sizeof(hns3_mac_strings[0])) - -@@ -354,8 +360,11 @@ static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = { - #define HNS3_NUM_TXQ_BASIC_STATS (sizeof(hns3_txq_basic_stats_strings) / \ - sizeof(hns3_txq_basic_stats_strings[0])) - -+#define HNS3_NUM_IMISSED_XSTATS (sizeof(hns3_imissed_stats_strings) / \ -+ sizeof(hns3_imissed_stats_strings[0])) -+ - #define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + HNS3_NUM_ERROR_INT_XSTATS + \ -- HNS3_NUM_RESET_XSTATS) -+ HNS3_NUM_RESET_XSTATS + HNS3_NUM_IMISSED_XSTATS) - - static void hns3_tqp_stats_clear(struct hns3_hw *hw); - static void hns3_tqp_basic_stats_clear(struct rte_eth_dev *dev); -@@ -515,6 +524,52 @@ hns3_update_tqp_stats(struct hns3_hw *hw) - return 0; - } - -+static int -+hns3_update_rpu_drop_stats(struct hns3_hw *hw) -+{ -+ struct hns3_rx_missed_stats *stats = &hw->imissed_stats; -+ struct hns3_query_rpu_cmd *req; -+ struct hns3_cmd_desc desc; -+ uint64_t cnt; -+ uint32_t tc_num; -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_DFX_RPU_REG_0, true); -+ req = (struct hns3_query_rpu_cmd *)desc.data; -+ -+ /* -+ * tc_num is 0, means rpu stats of all TC channels will be -+ * get from firmware -+ */ -+ tc_num = 0; -+ req->tc_queue_num = rte_cpu_to_le_32(tc_num); -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, "failed to query RPU stats: %d", ret); -+ return ret; -+ } -+ -+ cnt = rte_le_to_cpu_32(req->rpu_rx_pkt_drop_cnt); -+ stats->rpu_rx_drop_cnt += cnt; -+ -+ return 0; -+} -+ -+int -+hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear) -+{ -+ int ret; -+ -+ ret = hns3_update_rpu_drop_stats(hw); -+ if (ret) -+ return ret; -+ -+ if (is_clear) -+ memset(&hw->imissed_stats, 0, sizeof(hw->imissed_stats)); -+ -+ return 0; -+} -+ - /* - * Query tqp tx queue statistics ,opcode id: 0x0B03. - * Query tqp rx queue statistics ,opcode id: 0x0B13. -@@ -531,6 +586,7 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - { - struct hns3_adapter *hns = eth_dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -+ struct hns3_rx_missed_stats *imissed_stats = &hw->imissed_stats; - struct hns3_tqp_stats *stats = &hw->tqp_stats; - struct hns3_rx_queue *rxq; - uint64_t cnt; -@@ -544,6 +600,18 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - return ret; - } - -+ if (!hns->is_vf) { -+ /* Update imissed stats */ -+ ret = hns3_update_imissed_stats(hw, false); -+ if (ret) { -+ hns3_err(hw, "update imissed stats failed, ret = %d", -+ ret); -+ return ret; -+ } -+ -+ rte_stats->imissed = imissed_stats->rpu_rx_drop_cnt; -+ } -+ - /* Get the error stats and bytes of received packets */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; -@@ -616,6 +684,19 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - } - } - -+ if (!hns->is_vf) { -+ /* -+ * Note: Reading hardware statistics of imissed registers will -+ * clear them. -+ */ -+ ret = hns3_update_imissed_stats(hw, true); -+ if (ret) { -+ hns3_err(hw, "clear imissed stats failed, ret = %d", -+ ret); -+ return ret; -+ } -+ } -+ - /* - * Clear soft stats of rx error packet which will be dropped - * in driver. -@@ -928,6 +1009,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_pf *pf = &hns->pf; - struct hns3_hw *hw = &hns->hw; -+ struct hns3_rx_missed_stats *imissed_stats = &hw->imissed_stats; - struct hns3_mac_stats *mac_stats = &hw->mac_stats; - struct hns3_reset_stats *reset_stats = &hw->reset.stats; - struct hns3_rx_bd_errors_stats *rx_err_stats; -@@ -966,6 +1048,21 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - count++; - } - -+ ret = hns3_update_imissed_stats(hw, false); -+ if (ret) { -+ hns3_err(hw, "update imissed stats failed, ret = %d", -+ ret); -+ return ret; -+ } -+ -+ for (i = 0; i < HNS3_NUM_IMISSED_XSTATS; i++) { -+ addr = (char *)imissed_stats + -+ hns3_imissed_stats_strings[i].offset; -+ xstats[count].value = *(uint64_t *)addr; -+ xstats[count].id = count; -+ count++; -+ } -+ - for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) { - addr = (char *)&pf->abn_int_stats + - hns3_error_int_stats_strings[i].offset; -@@ -1108,6 +1205,13 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - count++; - } - -+ for (i = 0; i < HNS3_NUM_IMISSED_XSTATS; i++) { -+ snprintf(xstats_names[count].name, -+ sizeof(xstats_names[count].name), -+ "%s", hns3_imissed_stats_strings[i].name); -+ count++; -+ } -+ - for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index d213be5..01b4f36 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -110,6 +110,10 @@ struct hns3_mac_stats { - uint64_t mac_rx_ctrl_pkt_num; - }; - -+struct hns3_rx_missed_stats { -+ uint64_t rpu_rx_drop_cnt; -+}; -+ - /* store statistics names and its offset in stats structure */ - struct hns3_xstats_name_offset { - char name[RTE_ETH_XSTATS_NAME_SIZE]; -@@ -141,6 +145,9 @@ struct hns3_reset_stats; - #define HNS3_TXQ_BASIC_STATS_FIELD_OFFSET(f) \ - (offsetof(struct hns3_tx_basic_stats, f)) - -+#define HNS3_IMISSED_STATS_FIELD_OFFSET(f) \ -+ (offsetof(struct hns3_rx_missed_stats, f)) -+ - int hns3_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats); - int hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - unsigned int n); -@@ -160,5 +167,6 @@ int hns3_stats_reset(struct rte_eth_dev *dev); - void hns3_error_int_stats_add(struct hns3_adapter *hns, const char *err); - int hns3_tqp_stats_init(struct hns3_hw *hw); - void hns3_tqp_stats_uninit(struct hns3_hw *hw); -+int hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear); - - #endif /* _HNS3_STATS_H_ */ --- -2.7.4 - diff --git a/0050-net-hns3-encapsulate-port-shaping-interface.patch b/0050-net-hns3-encapsulate-port-shaping-interface.patch deleted file mode 100644 index 50ef1f9..0000000 --- a/0050-net-hns3-encapsulate-port-shaping-interface.patch +++ /dev/null @@ -1,122 +0,0 @@ -From 73f3a8aa0b5926083482f5e1f9999e246856a2ae Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 4 Mar 2021 15:44:46 +0800 -Subject: [PATCH 050/189] net/hns3: encapsulate port shaping interface - -When rate of port changes, the rate limit of the port needs to -be updated. So it is necessary to encapsulate an interface that -configures the rate limit based on the rate. - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_dcb.c | 22 +++++++++++++++++----- - drivers/net/hns3/hns3_dcb.h | 2 +- - drivers/net/hns3/hns3_ethdev.c | 10 +++------- - 3 files changed, 21 insertions(+), 13 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 7fc6ac9..ebfc240 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -330,8 +330,8 @@ hns3_dcb_get_shapping_para(uint8_t ir_b, uint8_t ir_u, uint8_t ir_s, - return shapping_para; - } - --int --hns3_dcb_port_shaper_cfg(struct hns3_hw *hw) -+static int -+hns3_dcb_port_shaper_cfg(struct hns3_hw *hw, uint32_t speed) - { - struct hns3_port_shapping_cmd *shap_cfg_cmd; - struct hns3_shaper_parameter shaper_parameter; -@@ -340,7 +340,7 @@ hns3_dcb_port_shaper_cfg(struct hns3_hw *hw) - struct hns3_cmd_desc desc; - int ret; - -- ret = hns3_shaper_para_calc(hw, hw->mac.link_speed, -+ ret = hns3_shaper_para_calc(hw, speed, - HNS3_SHAPER_LVL_PORT, &shaper_parameter); - if (ret) { - hns3_err(hw, "calculate shaper parameter failed: %d", ret); -@@ -366,12 +366,24 @@ hns3_dcb_port_shaper_cfg(struct hns3_hw *hw) - * depends on the firmware version. But driver still needs to - * calculate it and configure to firmware for better compatibility. - */ -- shap_cfg_cmd->port_rate = rte_cpu_to_le_32(hw->mac.link_speed); -+ shap_cfg_cmd->port_rate = rte_cpu_to_le_32(speed); - hns3_set_bit(shap_cfg_cmd->flag, HNS3_TM_RATE_VLD_B, 1); - - return hns3_cmd_send(hw, &desc, 1); - } - -+int -+hns3_port_shaper_update(struct hns3_hw *hw, uint32_t speed) -+{ -+ int ret; -+ -+ ret = hns3_dcb_port_shaper_cfg(hw, speed); -+ if (ret) -+ hns3_err(hw, "configure port shappering failed: ret = %d", ret); -+ -+ return ret; -+} -+ - static int - hns3_dcb_pg_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, - uint8_t pg_id, uint32_t shapping_para, uint32_t rate) -@@ -961,7 +973,7 @@ hns3_dcb_shaper_cfg(struct hns3_hw *hw) - { - int ret; - -- ret = hns3_dcb_port_shaper_cfg(hw); -+ ret = hns3_dcb_port_shaper_cfg(hw, hw->mac.link_speed); - if (ret) { - hns3_err(hw, "config port shaper failed: %d", ret); - return ret; -diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h -index 8248434..0d25d3b 100644 ---- a/drivers/net/hns3/hns3_dcb.h -+++ b/drivers/net/hns3/hns3_dcb.h -@@ -208,7 +208,7 @@ int hns3_queue_to_tc_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, - uint16_t nb_tx_q); - - int hns3_dcb_cfg_update(struct hns3_adapter *hns); --int hns3_dcb_port_shaper_cfg(struct hns3_hw *hw); -+int hns3_port_shaper_update(struct hns3_hw *hw, uint32_t speed); - int hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate); - int hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate); - uint8_t hns3_txq_mapped_tc_get(struct hns3_hw *hw, uint16_t txq_no); -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 96ad9b0..94c08e8 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4384,7 +4384,6 @@ static int - hns3_cfg_mac_speed_dup(struct hns3_hw *hw, uint32_t speed, uint8_t duplex) - { - struct hns3_mac *mac = &hw->mac; -- uint32_t cur_speed = mac->link_speed; - int ret; - - duplex = hns3_check_speed_dup(duplex, speed); -@@ -4395,14 +4394,11 @@ hns3_cfg_mac_speed_dup(struct hns3_hw *hw, uint32_t speed, uint8_t duplex) - if (ret) - return ret; - -- mac->link_speed = speed; -- ret = hns3_dcb_port_shaper_cfg(hw); -- if (ret) { -- hns3_err(hw, "failed to configure port shaper, ret = %d.", ret); -- mac->link_speed = cur_speed; -+ ret = hns3_port_shaper_update(hw, speed); -+ if (ret) - return ret; -- } - -+ mac->link_speed = speed; - mac->link_duplex = duplex; - - return 0; --- -2.7.4 - diff --git a/0051-net-hns3-fix-device-capabilities-for-copper-media-ty.patch b/0051-net-hns3-fix-device-capabilities-for-copper-media-ty.patch deleted file mode 100644 index 1457ab4..0000000 --- a/0051-net-hns3-fix-device-capabilities-for-copper-media-ty.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 35469e7e3c26afc79f340b8477bf7ce1dc65746e Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 4 Mar 2021 15:44:47 +0800 -Subject: [PATCH 051/189] net/hns3: fix device capabilities for copper media - type - -The configuration operation for PHY is implemented by firmware. And -a capability flag will be report to driver, which means the firmware -supports the PHY driver. However, the current implementation only -supports obtaining the capability bit, but some basic functions of -copper ports in driver, such as, the query of link status and link -info, are not supported. - -Therefore, it is necessary for driver to set the copper capability -bit to zero when the firmware supports the configuration of the PHY. - -Fixes: 438752358158 ("net/hns3: get device capability from firmware") -Fixes: 95e50325864c ("net/hns3: support copper media type") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li ---- - drivers/net/hns3/hns3_cmd.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 0590898..f0bc177 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -423,8 +423,14 @@ static void hns3_parse_capability(struct hns3_hw *hw, - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_PTP_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1); -+ /* -+ * Currently, the query of link status and link info on copper ports -+ * are not supported. So it is necessary for driver to set the copper -+ * capability bit to zero when the firmware supports the configuration -+ * of the PHY. -+ */ - if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B)) -- hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 1); -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 0); - if (hns3_get_bit(caps, HNS3_CAPS_TQP_TXRX_INDEP_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_INDEP_TXRX_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_STASH_B)) --- -2.7.4 - diff --git a/0052-net-hns3-support-PF-device-with-copper-PHYs.patch b/0052-net-hns3-support-PF-device-with-copper-PHYs.patch deleted file mode 100644 index 5a766a3..0000000 --- a/0052-net-hns3-support-PF-device-with-copper-PHYs.patch +++ /dev/null @@ -1,279 +0,0 @@ -From ed40b1477365a3c581f487ba3c8261c53dcdc255 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 4 Mar 2021 15:44:48 +0800 -Subject: [PATCH 052/189] net/hns3: support PF device with copper PHYs - -The normal operation of devices with copper phys depends on the -initialization and configuration of the PHY chip. The task of -driving the PHY chip is implemented in some firmware versions. -If firmware supports the phy driver, it will report a capability -flag to driver in probing process. The driver determines whether -to support PF device with copper phys based on the capability bit. -If supported, the driver set a flag indicating that the firmware -takes over the PHY, and then the firmware initializes the PHY. - -This patch supports the query of link status and link info, and -existing basic features for PF device with copper phys. - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.c | 8 +-- - drivers/net/hns3/hns3_cmd.h | 37 +++++++++++++ - drivers/net/hns3/hns3_ethdev.c | 115 ++++++++++++++++++++++++++++++++++++++--- - drivers/net/hns3/hns3_ethdev.h | 5 ++ - 4 files changed, 152 insertions(+), 13 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index f0bc177..0590898 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -423,14 +423,8 @@ static void hns3_parse_capability(struct hns3_hw *hw, - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_PTP_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1); -- /* -- * Currently, the query of link status and link info on copper ports -- * are not supported. So it is necessary for driver to set the copper -- * capability bit to zero when the firmware supports the configuration -- * of the PHY. -- */ - if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B)) -- hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 0); -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_TQP_TXRX_INDEP_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_INDEP_TXRX_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_STASH_B)) -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 93bfa74..7f567cb 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -222,6 +222,8 @@ enum hns3_opcode_type { - - /* Firmware stats command */ - HNS3_OPC_FIRMWARE_COMPAT_CFG = 0x701A, -+ /* Firmware control phy command */ -+ HNS3_OPC_PHY_PARAM_CFG = 0x7025, - - /* SFP command */ - HNS3_OPC_GET_SFP_EEPROM = 0x7100, -@@ -659,11 +661,46 @@ enum hns3_promisc_type { - - #define HNS3_LINK_EVENT_REPORT_EN_B 0 - #define HNS3_NCSI_ERROR_REPORT_EN_B 1 -+#define HNS3_FIRMWARE_PHY_DRIVER_EN_B 2 - struct hns3_firmware_compat_cmd { - uint32_t compat; - uint8_t rsv[20]; - }; - -+/* Bitmap flags in supported, advertising and lp_advertising */ -+#define HNS3_PHY_LINK_SPEED_10M_HD_BIT BIT(0) -+#define HNS3_PHY_LINK_SPEED_10M_BIT BIT(1) -+#define HNS3_PHY_LINK_SPEED_100M_HD_BIT BIT(2) -+#define HNS3_PHY_LINK_SPEED_100M_BIT BIT(3) -+#define HNS3_PHY_LINK_MODE_AUTONEG_BIT BIT(6) -+#define HNS3_PHY_LINK_MODE_PAUSE_BIT BIT(13) -+#define HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT BIT(14) -+ -+#define HNS3_PHY_PARAM_CFG_BD_NUM 2 -+struct hns3_phy_params_bd0_cmd { -+ uint32_t speed; -+#define HNS3_PHY_DUPLEX_CFG_B 0 -+ uint8_t duplex; -+#define HNS3_PHY_AUTONEG_CFG_B 0 -+ uint8_t autoneg; -+ uint8_t eth_tp_mdix; -+ uint8_t eth_tp_mdix_ctrl; -+ uint8_t port; -+ uint8_t transceiver; -+ uint8_t phy_address; -+ uint8_t rsv; -+ uint32_t supported; -+ uint32_t advertising; -+ uint32_t lp_advertising; -+}; -+ -+struct hns3_phy_params_bd1_cmd { -+ uint8_t master_slave_cfg; -+ uint8_t master_slave_state; -+ uint8_t rsv1[2]; -+ uint32_t rsv2[5]; -+}; -+ - #define HNS3_MAC_TX_EN_B 6 - #define HNS3_MAC_RX_EN_B 7 - #define HNS3_MAC_PAD_TX_B 11 -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 94c08e8..6cb6bec 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -3090,6 +3090,37 @@ hns3_get_capability(struct hns3_hw *hw) - } - - static int -+hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type) -+{ -+ int ret; -+ -+ switch (media_type) { -+ case HNS3_MEDIA_TYPE_COPPER: -+ if (!hns3_dev_copper_supported(hw)) { -+ PMD_INIT_LOG(ERR, -+ "Media type is copper, not supported."); -+ ret = -EOPNOTSUPP; -+ } else { -+ ret = 0; -+ } -+ break; -+ case HNS3_MEDIA_TYPE_FIBER: -+ ret = 0; -+ break; -+ case HNS3_MEDIA_TYPE_BACKPLANE: -+ PMD_INIT_LOG(ERR, "Media type is Backplane, not supported."); -+ ret = -EOPNOTSUPP; -+ break; -+ default: -+ PMD_INIT_LOG(ERR, "Unknown media type = %u!", media_type); -+ ret = -EINVAL; -+ break; -+ } -+ -+ return ret; -+} -+ -+static int - hns3_get_board_configuration(struct hns3_hw *hw) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -@@ -3103,11 +3134,9 @@ hns3_get_board_configuration(struct hns3_hw *hw) - return ret; - } - -- if (cfg.media_type == HNS3_MEDIA_TYPE_COPPER && -- !hns3_dev_copper_supported(hw)) { -- PMD_INIT_LOG(ERR, "media type is copper, not supported."); -- return -EOPNOTSUPP; -- } -+ ret = hns3_check_media_type(hw, cfg.media_type); -+ if (ret) -+ return ret; - - hw->mac.media_type = cfg.media_type; - hw->rss_size_max = cfg.rss_size_max; -@@ -3952,6 +3981,8 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) - if (is_init) { - hns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1); - hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); -+ if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) -+ hns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1); - } - - req->compat = rte_cpu_to_le_32(compat); -@@ -4429,6 +4460,78 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) - return hns3_cfg_mac_speed_dup(hw, speed, ETH_LINK_FULL_DUPLEX); - } - -+static void -+hns3_parse_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) -+{ -+ struct hns3_phy_params_bd0_cmd *req; -+ -+ req = (struct hns3_phy_params_bd0_cmd *)desc[0].data; -+ mac->link_speed = rte_le_to_cpu_32(req->speed); -+ mac->link_duplex = hns3_get_bit(req->duplex, -+ HNS3_PHY_DUPLEX_CFG_B); -+ mac->link_autoneg = hns3_get_bit(req->autoneg, -+ HNS3_PHY_AUTONEG_CFG_B); -+ mac->supported_capa = rte_le_to_cpu_32(req->supported); -+ mac->advertising = rte_le_to_cpu_32(req->advertising); -+ mac->lp_advertising = rte_le_to_cpu_32(req->lp_advertising); -+ mac->support_autoneg = !!(mac->supported_capa & -+ HNS3_PHY_LINK_MODE_AUTONEG_BIT); -+} -+ -+static int -+hns3_get_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) -+{ -+ struct hns3_cmd_desc desc[HNS3_PHY_PARAM_CFG_BD_NUM]; -+ uint16_t i; -+ int ret; -+ -+ for (i = 0; i < HNS3_PHY_PARAM_CFG_BD_NUM - 1; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_PHY_PARAM_CFG, -+ true); -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_PHY_PARAM_CFG, true); -+ -+ ret = hns3_cmd_send(hw, desc, HNS3_PHY_PARAM_CFG_BD_NUM); -+ if (ret) { -+ hns3_err(hw, "get phy parameters failed, ret = %d.", ret); -+ return ret; -+ } -+ -+ hns3_parse_phy_params(desc, mac); -+ -+ return 0; -+} -+ -+static int -+hns3_update_phy_link_info(struct hns3_hw *hw) -+{ -+ struct hns3_mac *mac = &hw->mac; -+ struct hns3_mac mac_info; -+ int ret; -+ -+ memset(&mac_info, 0, sizeof(struct hns3_mac)); -+ ret = hns3_get_phy_params(hw, &mac_info); -+ if (ret) -+ return ret; -+ -+ if (mac_info.link_speed != mac->link_speed) { -+ ret = hns3_port_shaper_update(hw, mac_info.link_speed); -+ if (ret) -+ return ret; -+ } -+ -+ mac->link_speed = mac_info.link_speed; -+ mac->link_duplex = mac_info.link_duplex; -+ mac->link_autoneg = mac_info.link_autoneg; -+ mac->supported_capa = mac_info.supported_capa; -+ mac->advertising = mac_info.advertising; -+ mac->lp_advertising = mac_info.lp_advertising; -+ mac->support_autoneg = mac_info.support_autoneg; -+ -+ return 0; -+} -+ - static int - hns3_update_link_info(struct rte_eth_dev *eth_dev) - { -@@ -4437,7 +4540,7 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev) - int ret = 0; - - if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) -- return 0; -+ ret = hns3_update_phy_link_info(hw); - else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) - ret = hns3_update_fiber_link_info(hw); - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 2954422..3cbc2f2 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -180,6 +180,11 @@ struct hns3_mac { - uint8_t link_autoneg : 1; /* ETH_LINK_[AUTONEG/FIXED] */ - uint8_t link_status : 1; /* ETH_LINK_[DOWN/UP] */ - uint32_t link_speed; /* ETH_SPEED_NUM_ */ -+ uint32_t supported_capa; /* supported capability for current media */ -+ uint32_t advertising; /* advertised capability in the local part */ -+ /* advertised capability in the link partner */ -+ uint32_t lp_advertising; -+ uint8_t support_autoneg; - }; - - struct hns3_fake_queue_data { --- -2.7.4 - diff --git a/0053-net-hns3-support-Rx-descriptor-advanced-layout.patch b/0053-net-hns3-support-Rx-descriptor-advanced-layout.patch deleted file mode 100644 index 14a81da..0000000 --- a/0053-net-hns3-support-Rx-descriptor-advanced-layout.patch +++ /dev/null @@ -1,442 +0,0 @@ -From dd8dbf370b25e67e3ffaa845960c41c67775baa8 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 4 Mar 2021 15:44:49 +0800 -Subject: [PATCH 053/189] net/hns3: support Rx descriptor advanced layout - -Currently, the driver get packet type by parse the -L3_ID/L4_ID/OL3_ID/OL4_ID from Rx descriptor and then lookup multiple -tables, it's time consuming. - -Now Kunpeng930 support advanced RXD layout, which: -1. Combine OL3_ID/OL4_ID to 8bit PTYPE filed, so the driver get packet - type by lookup only one table. Note: L3_ID/L4_ID become reserved - fields. -2. The 1588 timestamp located at Rx descriptor instead of query from - firmware. -3. The L3E/L4E/OL3E/OL4E will be zero when L3L4P is zero, so driver - could optimize the good checksum calculations (when L3E/L4E is zero - then mark PKT_RX_IP_CKSUM_GOOD/PKT_RX_L4_CKSUM_GOOD). - -Considering compatibility, the firmware will report capability of -RXD advanced layout, the driver will identify and enable it by default. - -This patch only provides basic function: identify and enable the RXD -advanced layout, and lookup ptype table if supported. - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.c | 8 +- - drivers/net/hns3/hns3_cmd.h | 5 + - drivers/net/hns3/hns3_ethdev.c | 2 + - drivers/net/hns3/hns3_ethdev.h | 16 +++ - drivers/net/hns3/hns3_ethdev_vf.c | 2 + - drivers/net/hns3/hns3_regs.h | 1 + - drivers/net/hns3/hns3_rxtx.c | 200 ++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_rxtx.h | 11 +++ - 8 files changed, 243 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 0590898..8a2cc2d 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -409,8 +409,9 @@ hns3_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, int num) - return retval; - } - --static void hns3_parse_capability(struct hns3_hw *hw, -- struct hns3_query_version_cmd *cmd) -+static void -+hns3_parse_capability(struct hns3_hw *hw, -+ struct hns3_query_version_cmd *cmd) - { - uint32_t caps = rte_le_to_cpu_32(cmd->caps[0]); - -@@ -429,6 +430,9 @@ static void hns3_parse_capability(struct hns3_hw *hw, - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_INDEP_TXRX_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_STASH_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_STASH_B, 1); -+ if (hns3_get_bit(caps, HNS3_CAPS_RXD_ADV_LAYOUT_B)) -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, -+ 1); - } - - static uint32_t -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 7f567cb..6ceb655 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -312,6 +312,11 @@ enum HNS3_CAPS_BITS { - HNS3_CAPS_TQP_TXRX_INDEP_B, - HNS3_CAPS_HW_PAD_B, - HNS3_CAPS_STASH_B, -+ HNS3_CAPS_UDP_TUNNEL_CSUM_B, -+ HNS3_CAPS_RAS_IMP_B, -+ HNS3_CAPS_FEC_B, -+ HNS3_CAPS_PAUSE_B, -+ HNS3_CAPS_RXD_ADV_LAYOUT_B, - }; - - enum HNS3_API_CAP_BITS { -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 6cb6bec..7993d2d 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4970,6 +4970,8 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - return ret; - } - -+ hns3_enable_rxd_adv_layout(hw); -+ - ret = hns3_init_queues(hns, reset_queue); - if (ret) { - PMD_INIT_LOG(ERR, "failed to init queues, ret = %d.", ret); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 3cbc2f2..52e6c49 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -667,8 +667,13 @@ struct hns3_mp_param { - #define HNS3_OL2TBL_NUM 4 - #define HNS3_OL3TBL_NUM 16 - #define HNS3_OL4TBL_NUM 16 -+#define HNS3_PTYPE_NUM 256 - - struct hns3_ptype_table { -+ /* -+ * The next fields used to calc packet-type by the -+ * L3_ID/L4_ID/OL3_ID/OL4_ID from the Rx descriptor. -+ */ - uint32_t l2l3table[HNS3_L2TBL_NUM][HNS3_L3TBL_NUM]; - uint32_t l4table[HNS3_L4TBL_NUM]; - uint32_t inner_l2table[HNS3_L2TBL_NUM]; -@@ -677,6 +682,13 @@ struct hns3_ptype_table { - uint32_t ol2table[HNS3_OL2TBL_NUM]; - uint32_t ol3table[HNS3_OL3TBL_NUM]; - uint32_t ol4table[HNS3_OL4TBL_NUM]; -+ -+ /* -+ * The next field used to calc packet-type by the PTYPE from the Rx -+ * descriptor, it functions only when firmware report the capability of -+ * HNS3_CAPS_RXD_ADV_LAYOUT_B and driver enabled it. -+ */ -+ uint32_t ptype[HNS3_PTYPE_NUM] __rte_cache_min_aligned; - }; - - #define HNS3_FIXED_MAX_TQP_NUM_MODE 0 -@@ -771,6 +783,7 @@ struct hns3_adapter { - #define HNS3_DEV_SUPPORT_TX_PUSH_B 0x5 - #define HNS3_DEV_SUPPORT_INDEP_TXRX_B 0x6 - #define HNS3_DEV_SUPPORT_STASH_B 0x7 -+#define HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B 0x9 - - #define hns3_dev_dcb_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B) -@@ -801,6 +814,9 @@ struct hns3_adapter { - #define hns3_dev_stash_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_STASH_B) - -+#define hns3_dev_rxd_adv_layout_supported(hw) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B) -+ - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 5b4c587..90951df 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2125,6 +2125,8 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) - if (ret) - return ret; - -+ hns3_enable_rxd_adv_layout(hw); -+ - ret = hns3_init_queues(hns, reset_queue); - if (ret) - hns3_err(hw, "failed to init queues, ret = %d.", ret); -diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h -index 39fc5d1..0540554 100644 ---- a/drivers/net/hns3/hns3_regs.h -+++ b/drivers/net/hns3/hns3_regs.h -@@ -36,6 +36,7 @@ - #define HNS3_GLOBAL_RESET_REG 0x20A00 - #define HNS3_FUN_RST_ING 0x20C00 - #define HNS3_GRO_EN_REG 0x28000 -+#define HNS3_RXD_ADV_LAYOUT_EN_REG 0x28008 - - /* Vector0 register bits for reset */ - #define HNS3_VECTOR0_FUNCRESET_INT_B 0 -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 897e5fa..09b38d4 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1802,6 +1802,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - HNS3_PORT_BASE_VLAN_ENABLE; - else - rxq->pvid_sw_discard_en = false; -+ rxq->ptype_en = hns3_dev_rxd_adv_layout_supported(hw) ? true : false; - rxq->configured = true; - rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + - idx * HNS3_TQP_REG_SIZE); -@@ -1987,6 +1988,193 @@ hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) - tbl->ol4table[2] = RTE_PTYPE_TUNNEL_NVGRE; - } - -+static void -+hns3_init_adv_layout_ptype(struct hns3_ptype_table *tbl) -+{ -+ uint32_t *ptype = tbl->ptype; -+ -+ /* Non-tunnel L2 */ -+ ptype[1] = RTE_PTYPE_L2_ETHER_ARP; -+ ptype[3] = RTE_PTYPE_L2_ETHER_LLDP; -+ ptype[8] = RTE_PTYPE_L2_ETHER_TIMESYNC; -+ -+ /* Non-tunnel IPv4 */ -+ ptype[17] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_FRAG; -+ ptype[18] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_NONFRAG; -+ ptype[19] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_UDP; -+ ptype[20] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_TCP; -+ /* The next ptype is GRE over IPv4 */ -+ ptype[21] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; -+ ptype[22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_SCTP; -+ ptype[23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_IGMP; -+ ptype[24] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_ICMP; -+ /* The next ptype is PTP over IPv4 + UDP */ -+ ptype[25] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_L4_UDP; -+ -+ /* IPv4 --> GRE/Teredo/VXLAN */ -+ ptype[29] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT; -+ /* IPv4 --> GRE/Teredo/VXLAN --> MAC */ -+ ptype[30] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER; -+ -+ /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */ -+ ptype[31] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_FRAG; -+ ptype[32] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_NONFRAG; -+ ptype[33] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_UDP; -+ ptype[34] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_TCP; -+ ptype[35] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_SCTP; -+ /* The next ptype's inner L4 is IGMP */ -+ ptype[36] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; -+ ptype[37] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_ICMP; -+ -+ /* IPv4 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */ -+ ptype[39] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_FRAG; -+ ptype[40] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_NONFRAG; -+ ptype[41] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_UDP; -+ ptype[42] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_TCP; -+ ptype[43] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_SCTP; -+ /* The next ptype's inner L4 is IGMP */ -+ ptype[44] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; -+ ptype[45] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_ICMP; -+ -+ /* Non-tunnel IPv6 */ -+ ptype[111] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_FRAG; -+ ptype[112] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_NONFRAG; -+ ptype[113] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_UDP; -+ ptype[114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_TCP; -+ /* The next ptype is GRE over IPv6 */ -+ ptype[115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; -+ ptype[116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_SCTP; -+ ptype[117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_IGMP; -+ ptype[118] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_ICMP; -+ /* Special for PTP over IPv6 + UDP */ -+ ptype[119] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_L4_UDP; -+ -+ /* IPv6 --> GRE/Teredo/VXLAN */ -+ ptype[123] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT; -+ /* IPv6 --> GRE/Teredo/VXLAN --> MAC */ -+ ptype[124] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER; -+ -+ /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv4 */ -+ ptype[125] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_FRAG; -+ ptype[126] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_NONFRAG; -+ ptype[127] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_UDP; -+ ptype[128] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_TCP; -+ ptype[129] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_SCTP; -+ /* The next ptype's inner L4 is IGMP */ -+ ptype[130] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; -+ ptype[131] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_ICMP; -+ -+ /* IPv6 --> GRE/Teredo/VXLAN --> MAC --> IPv6 */ -+ ptype[133] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_FRAG; -+ ptype[134] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_NONFRAG; -+ ptype[135] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_UDP; -+ ptype[136] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_TCP; -+ ptype[137] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_SCTP; -+ /* The next ptype's inner L4 is IGMP */ -+ ptype[138] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; -+ ptype[139] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRENAT | RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_INNER_L4_ICMP; -+} -+ - void - hns3_init_rx_ptype_tble(struct rte_eth_dev *dev) - { -@@ -1997,6 +2185,7 @@ hns3_init_rx_ptype_tble(struct rte_eth_dev *dev) - - hns3_init_non_tunnel_ptype_tbl(tbl); - hns3_init_tunnel_ptype_tbl(tbl); -+ hns3_init_adv_layout_ptype(tbl); - } - - static inline void -@@ -4012,3 +4201,14 @@ hns3_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) - else - return fbd_num - driver_hold_bd_num; - } -+ -+void -+hns3_enable_rxd_adv_layout(struct hns3_hw *hw) -+{ -+ /* -+ * If the hardware support rxd advanced layout, then driver enable it -+ * default. -+ */ -+ if (hns3_dev_rxd_adv_layout_supported(hw)) -+ hns3_write_dev(hw, HNS3_RXD_ADV_LAYOUT_EN_REG, 1); -+} -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 7118bd4..9adeb24 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -88,6 +88,8 @@ - #define HNS3_RXD_OL3ID_M (0xf << HNS3_RXD_OL3ID_S) - #define HNS3_RXD_OL4ID_S 8 - #define HNS3_RXD_OL4ID_M (0xf << HNS3_RXD_OL4ID_S) -+#define HNS3_RXD_PTYPE_S 4 -+#define HNS3_RXD_PTYPE_M (0xff << HNS3_RXD_PTYPE_S) - #define HNS3_RXD_FBHI_S 12 - #define HNS3_RXD_FBHI_M (0x3 << HNS3_RXD_FBHI_S) - #define HNS3_RXD_FBLI_S 14 -@@ -328,6 +330,7 @@ struct hns3_rx_queue { - * point, the pvid_sw_discard_en will be false. - */ - bool pvid_sw_discard_en; -+ bool ptype_en; /* indicate if the ptype field enabled */ - bool enabled; /* indicate if Rx queue has been enabled */ - - struct hns3_rx_basic_stats basic_stats; -@@ -609,6 +612,13 @@ hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, - const struct hns3_ptype_table * const ptype_tbl = rxq->ptype_tbl; - uint32_t l2id, l3id, l4id; - uint32_t ol3id, ol4id, ol2id; -+ uint32_t ptype; -+ -+ if (rxq->ptype_en) { -+ ptype = hns3_get_field(ol_info, HNS3_RXD_PTYPE_M, -+ HNS3_RXD_PTYPE_S); -+ return ptype_tbl->ptype[ptype]; -+ } - - ol4id = hns3_get_field(ol_info, HNS3_RXD_OL4ID_M, HNS3_RXD_OL4ID_S); - ol3id = hns3_get_field(ol_info, HNS3_RXD_OL3ID_M, HNS3_RXD_OL3ID_S); -@@ -707,5 +717,6 @@ int hns3_start_all_rxqs(struct rte_eth_dev *dev); - void hns3_stop_all_txqs(struct rte_eth_dev *dev); - void hns3_restore_tqp_enable_state(struct hns3_hw *hw); - int hns3_tx_done_cleanup(void *txq, uint32_t free_cnt); -+void hns3_enable_rxd_adv_layout(struct hns3_hw *hw); - - #endif /* _HNS3_RXTX_H_ */ --- -2.7.4 - diff --git a/0054-net-hns3-fix-HW-buffer-size-on-MTU-update.patch b/0054-net-hns3-fix-HW-buffer-size-on-MTU-update.patch deleted file mode 100644 index a77fe4a..0000000 --- a/0054-net-hns3-fix-HW-buffer-size-on-MTU-update.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 7e76a11ae316966bb1094e3797a7f7c8fe4e3213 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 4 Mar 2021 15:44:50 +0800 -Subject: [PATCH 054/189] net/hns3: fix HW buffer size on MTU update - -After MTU changed, the buffer used to store packets in HW should be -reallocated. And buffer size is allocated based on the maximum frame -size in the PF struct. However, the value of maximum frame size is -not updated in time when MTU is changed. This would lead to a packet -loss for not enough buffer. - -This patch update the maximum frame size before reallocating the HW -buffer. And a rollback operation is added to avoid the side effects -of buffer reallocation failures. - -Fixes: 1f5ca0b460cd ("net/hns3: support some device operations") -Fixes: d51867db65c1 ("net/hns3: add initialization") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 24 ++++++++++++++++++++---- - 1 file changed, 20 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7993d2d..6a56a05 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2460,17 +2460,33 @@ hns3_set_mac_mtu(struct hns3_hw *hw, uint16_t new_mps) - static int - hns3_config_mtu(struct hns3_hw *hw, uint16_t mps) - { -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ uint16_t original_mps = hns->pf.mps; -+ int err; - int ret; - - ret = hns3_set_mac_mtu(hw, mps); - if (ret) { -- hns3_err(hw, "Failed to set mtu, ret = %d", ret); -+ hns3_err(hw, "failed to set mtu, ret = %d", ret); - return ret; - } - -+ hns->pf.mps = mps; - ret = hns3_buffer_alloc(hw); -- if (ret) -- hns3_err(hw, "Failed to allocate buffer, ret = %d", ret); -+ if (ret) { -+ hns3_err(hw, "failed to allocate buffer, ret = %d", ret); -+ goto rollback; -+ } -+ -+ return 0; -+ -+rollback: -+ err = hns3_set_mac_mtu(hw, original_mps); -+ if (err) { -+ hns3_err(hw, "fail to rollback MTU, err = %d", err); -+ return ret; -+ } -+ hns->pf.mps = original_mps; - - return ret; - } -@@ -2505,7 +2521,7 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - dev->data->port_id, mtu, ret); - return ret; - } -- hns->pf.mps = (uint16_t)frame_size; -+ - if (is_jumbo_frame) - dev->data->dev_conf.rxmode.offloads |= - DEV_RX_OFFLOAD_JUMBO_FRAME; --- -2.7.4 - diff --git a/0055-net-hns3-remove-unused-parameter-markers.patch b/0055-net-hns3-remove-unused-parameter-markers.patch deleted file mode 100644 index b1b95ca..0000000 --- a/0055-net-hns3-remove-unused-parameter-markers.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 82c54c157d1cb684ef41a0ccdec0be4ecfa64a31 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 4 Mar 2021 15:44:51 +0800 -Subject: [PATCH 055/189] net/hns3: remove unused parameter markers - -All input parameters in the "hns3_dev_xstats_get_by_id" API are used, -so the rte_unused flag of some variables should be deleted. - -Fixes: 3213d584b698 ("net/hns3: fix xstats with id and names") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_stats.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index 01b4f36..70a9c5b 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -156,8 +156,8 @@ int hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int size); - int hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, -- __rte_unused const uint64_t *ids, -- __rte_unused uint64_t *values, -+ const uint64_t *ids, -+ uint64_t *values, - uint32_t size); - int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - struct rte_eth_xstat_name *xstats_names, --- -2.7.4 - diff --git a/0056-net-hns3-fix-mbuf-leakage.patch b/0056-net-hns3-fix-mbuf-leakage.patch deleted file mode 100644 index 31a3424..0000000 --- a/0056-net-hns3-fix-mbuf-leakage.patch +++ /dev/null @@ -1,200 +0,0 @@ -From bd503f5817a2597e8431e02675a8c3847a31992e Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 4 Mar 2021 15:44:52 +0800 -Subject: [PATCH 056/189] net/hns3: fix mbuf leakage - -The mbufs of rx queue will be allocated in "hns3_do_start" function. -But these mbufs are not released when "hns3_dev_start" executes -failed. - -Fixes: c4ae39b2cfc5 ("net/hns3: fix Rx interrupt after reset") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_ethdev.c | 45 ++++++++++++++++++++++++--------------- - drivers/net/hns3/hns3_ethdev_vf.c | 43 ++++++++++++++++++++++--------------- - 2 files changed, 54 insertions(+), 34 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 6a56a05..1d56916 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -102,6 +102,7 @@ static int hns3_remove_mc_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); - static int hns3_restore_fec(struct hns3_hw *hw); - static int hns3_query_dev_fec_info(struct hns3_hw *hw); -+static int hns3_do_stop(struct hns3_adapter *hns); - - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr) -@@ -5133,11 +5134,8 @@ hns3_dev_start(struct rte_eth_dev *dev) - return ret; - } - ret = hns3_map_rx_interrupt(dev); -- if (ret) { -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto map_rx_inter_err; - - /* - * There are three register used to control the status of a TQP -@@ -5151,19 +5149,12 @@ hns3_dev_start(struct rte_eth_dev *dev) - * status of queue in the dpdk framework. - */ - ret = hns3_start_all_txqs(dev); -- if (ret) { -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto map_rx_inter_err; - - ret = hns3_start_all_rxqs(dev); -- if (ret) { -- hns3_stop_all_txqs(dev); -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto start_all_rxqs_fail; - - hw->adapter_state = HNS3_NIC_STARTED; - rte_spinlock_unlock(&hw->lock); -@@ -5187,7 +5178,17 @@ hns3_dev_start(struct rte_eth_dev *dev) - hns3_tm_dev_start_proc(hw); - - hns3_info(hw, "hns3 dev start successful!"); -+ - return 0; -+ -+start_all_rxqs_fail: -+ hns3_stop_all_txqs(dev); -+map_rx_inter_err: -+ (void)hns3_do_stop(hns); -+ hw->adapter_state = HNS3_NIC_CONFIGURED; -+ rte_spinlock_unlock(&hw->lock); -+ -+ return ret; - } - - static int -@@ -5196,6 +5197,17 @@ hns3_do_stop(struct hns3_adapter *hns) - struct hns3_hw *hw = &hns->hw; - int ret; - -+ /* -+ * The "hns3_do_stop" function will also be called by .stop_service to -+ * prepare reset. At the time of global or IMP reset, the command cannot -+ * be sent to stop the tx/rx queues. The mbuf in Tx/Rx queues may be -+ * accessed during the reset process. So the mbuf can not be released -+ * during reset and is required to be released after the reset is -+ * completed. -+ */ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) -+ hns3_dev_release_mbufs(hns); -+ - ret = hns3_cfg_mac_mode(hw, false); - if (ret) - return ret; -@@ -5273,7 +5285,6 @@ hns3_dev_stop(struct rte_eth_dev *dev) - hns3_stop_tqps(hw); - hns3_do_stop(hns); - hns3_unmap_rx_interrupt(dev); -- hns3_dev_release_mbufs(hns); - hw->adapter_state = HNS3_NIC_CONFIGURED; - } - hns3_rx_scattered_reset(dev); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 90951df..12af105 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1941,6 +1941,17 @@ hns3vf_do_stop(struct hns3_adapter *hns) - - hw->mac.link_status = ETH_LINK_DOWN; - -+ /* -+ * The "hns3vf_do_stop" function will also be called by .stop_service to -+ * prepare reset. At the time of global or IMP reset, the command cannot -+ * be sent to stop the tx/rx queues. The mbuf in Tx/Rx queues may be -+ * accessed during the reset process. So the mbuf can not be released -+ * during reset and is required to be released after the reset is -+ * completed. -+ */ -+ if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) -+ hns3_dev_release_mbufs(hns); -+ - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) { - hns3vf_configure_mac_addr(hns, true); - ret = hns3_reset_all_tqps(hns); -@@ -2010,7 +2021,6 @@ hns3vf_dev_stop(struct rte_eth_dev *dev) - hns3_stop_tqps(hw); - hns3vf_do_stop(hns); - hns3vf_unmap_rx_interrupt(dev); -- hns3_dev_release_mbufs(hns); - hw->adapter_state = HNS3_NIC_CONFIGURED; - } - hns3_rx_scattered_reset(dev); -@@ -2253,11 +2263,8 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - return ret; - } - ret = hns3vf_map_rx_interrupt(dev); -- if (ret) { -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto map_rx_inter_err; - - /* - * There are three register used to control the status of a TQP -@@ -2271,19 +2278,12 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - * status of queue in the dpdk framework. - */ - ret = hns3_start_all_txqs(dev); -- if (ret) { -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto map_rx_inter_err; - - ret = hns3_start_all_rxqs(dev); -- if (ret) { -- hns3_stop_all_txqs(dev); -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto start_all_rxqs_fail; - - hw->adapter_state = HNS3_NIC_STARTED; - rte_spinlock_unlock(&hw->lock); -@@ -2305,6 +2305,15 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - hns3_start_tqps(hw); - - return ret; -+ -+start_all_rxqs_fail: -+ hns3_stop_all_txqs(dev); -+map_rx_inter_err: -+ (void)hns3vf_do_stop(hns); -+ hw->adapter_state = HNS3_NIC_CONFIGURED; -+ rte_spinlock_unlock(&hw->lock); -+ -+ return ret; - } - - static bool --- -2.7.4 - diff --git a/0057-net-hns3-process-MAC-interrupt.patch b/0057-net-hns3-process-MAC-interrupt.patch deleted file mode 100644 index d02fa91..0000000 --- a/0057-net-hns3-process-MAC-interrupt.patch +++ /dev/null @@ -1,211 +0,0 @@ -From b9fbefb52b791730d5720946713e6cb187337652 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Thu, 4 Mar 2021 15:44:53 +0800 -Subject: [PATCH 057/189] net/hns3: process MAC interrupt - -TNL is the abbreviation of tunnel, which means port -here. MAC TNL interrupt indicates the MAC status -report of the network port, which will be generated -when the MAC status changes. - -This patch enables MAC TNL interrupt reporting, and -queries and prints the corresponding MAC status when -the interrupt is received, then clear the MAC interrupt -status. Because this interrupt uses the same interrupt -as RAS, the interrupt log is adjusted. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_cmd.h | 3 +++ - drivers/net/hns3/hns3_ethdev.c | 57 ++++++++++++++++++++++++++++++++++++------ - drivers/net/hns3/hns3_intr.c | 20 +++++++++++++++ - drivers/net/hns3/hns3_intr.h | 4 +++ - 4 files changed, 76 insertions(+), 8 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 6ceb655..094bf7e 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -116,6 +116,9 @@ enum hns3_opcode_type { - HNS3_OPC_QUERY_LINK_STATUS = 0x0307, - HNS3_OPC_CONFIG_MAX_FRM_SIZE = 0x0308, - HNS3_OPC_CONFIG_SPEED_DUP = 0x0309, -+ HNS3_OPC_QUERY_MAC_TNL_INT = 0x0310, -+ HNS3_OPC_MAC_TNL_INT_EN = 0x0311, -+ HNS3_OPC_CLEAR_MAC_TNL_INT = 0x0312, - HNS3_OPC_CONFIG_FEC_MODE = 0x031A, - - /* PFC/Pause commands */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 1d56916..80f91a7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -217,9 +217,6 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - goto out; - } - -- if (clearval && (vector0_int_stats || cmdq_src_val || hw_err_src_reg)) -- hns3_warn(hw, "vector0_int_stats:0x%x cmdq_src_val:0x%x hw_err_src_reg:0x%x", -- vector0_int_stats, cmdq_src_val, hw_err_src_reg); - val = vector0_int_stats; - ret = HNS3_VECTOR0_EVENT_OTHER; - out: -@@ -258,6 +255,34 @@ hns3_clear_all_event_cause(struct hns3_hw *hw) - } - - static void -+hns3_handle_mac_tnl(struct hns3_hw *hw) -+{ -+ struct hns3_cmd_desc desc; -+ uint32_t status; -+ int ret; -+ -+ /* query and clear mac tnl interruptions */ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_MAC_TNL_INT, true); -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, "failed to query mac tnl int, ret = %d.", ret); -+ return; -+ } -+ -+ status = rte_le_to_cpu_32(desc.data[0]); -+ if (status) { -+ hns3_warn(hw, "mac tnl int occurs, status = 0x%x.", status); -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CLEAR_MAC_TNL_INT, -+ false); -+ desc.data[0] = rte_cpu_to_le_32(HNS3_MAC_TNL_INT_CLR); -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) -+ hns3_err(hw, "failed to clear mac tnl int, ret = %d.", -+ ret); -+ } -+} -+ -+static void - hns3_interrupt_handler(void *param) - { - struct rte_eth_dev *dev = (struct rte_eth_dev *)param; -@@ -265,24 +290,36 @@ hns3_interrupt_handler(void *param) - struct hns3_hw *hw = &hns->hw; - enum hns3_evt_cause event_cause; - uint32_t clearval = 0; -+ uint32_t vector0_int; -+ uint32_t ras_int; -+ uint32_t cmdq_int; - - /* Disable interrupt */ - hns3_pf_disable_irq0(hw); - - event_cause = hns3_check_event_cause(hns, &clearval); -+ vector0_int = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); -+ ras_int = hns3_read_dev(hw, HNS3_RAS_PF_OTHER_INT_STS_REG); -+ cmdq_int = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG); - /* vector 0 interrupt is shared with reset and mailbox source events. */ - if (event_cause == HNS3_VECTOR0_EVENT_ERR) { -- hns3_warn(hw, "Received err interrupt"); -+ hns3_warn(hw, "received interrupt: vector0_int_stat:0x%x " -+ "ras_int_stat:0x%x cmdq_int_stat:0x%x", -+ vector0_int, ras_int, cmdq_int); - hns3_handle_msix_error(hns, &hw->reset.request); - hns3_handle_ras_error(hns, &hw->reset.request); -+ hns3_handle_mac_tnl(hw); - hns3_schedule_reset(hns); - } else if (event_cause == HNS3_VECTOR0_EVENT_RST) { -- hns3_warn(hw, "Received reset interrupt"); -+ hns3_warn(hw, "received reset interrupt"); - hns3_schedule_reset(hns); -- } else if (event_cause == HNS3_VECTOR0_EVENT_MBX) -+ } else if (event_cause == HNS3_VECTOR0_EVENT_MBX) { - hns3_dev_handle_mbx_msg(hw); -- else -- hns3_err(hw, "Received unknown event"); -+ } else { -+ hns3_warn(hw, "received unknown event: vector0_int_stat:0x%x " -+ "ras_int_stat:0x%x cmdq_int_stat:0x%x", -+ vector0_int, ras_int, cmdq_int); -+ } - - hns3_clear_event_cause(hw, event_cause, clearval); - /* Enable interrupt if it is not cause by reset */ -@@ -4639,6 +4676,8 @@ hns3_update_link_status(struct hns3_hw *hw) - if (state != hw->mac.link_status) { - hw->mac.link_status = state; - hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); -+ hns3_config_mac_tnl_int(hw, -+ state == ETH_LINK_UP ? true : false); - return true; - } - -@@ -4957,6 +4996,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - (void)hns3_firmware_compat_config(hw, false); - hns3_uninit_umv_space(hw); - hns3_tqp_stats_uninit(hw); -+ hns3_config_mac_tnl_int(hw, false); - hns3_pf_disable_irq0(hw); - rte_intr_disable(&pci_dev->intr_handle); - hns3_intr_unregister(&pci_dev->intr_handle, hns3_interrupt_handler, -@@ -5282,6 +5322,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) - rte_spinlock_lock(&hw->lock); - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - hns3_tm_dev_stop_proc(hw); -+ hns3_config_mac_tnl_int(hw, false); - hns3_stop_tqps(hw); - hns3_do_stop(hns); - hns3_unmap_rx_interrupt(dev); -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 88ce4c6..2563504 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1248,6 +1248,26 @@ enable_ssu_err_intr(struct hns3_adapter *hns, bool en) - return ret; - } - -+void -+hns3_config_mac_tnl_int(struct hns3_hw *hw, bool en) -+{ -+ struct hns3_cmd_desc desc; -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MAC_TNL_INT_EN, false); -+ if (en) -+ desc.data[0] = rte_cpu_to_le_32(HNS3_MAC_TNL_INT_EN); -+ else -+ desc.data[0] = 0; -+ -+ desc.data[1] = rte_cpu_to_le_32(HNS3_MAC_TNL_INT_EN_MASK); -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) -+ hns3_err(hw, "fail to %s mac tnl intr, ret = %d", -+ en ? "enable" : "disable", ret); -+} -+ - static int - config_ppu_err_intrs(struct hns3_adapter *hns, uint32_t cmd, bool en) - { -diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h -index 19de1aa..c569a9d 100644 ---- a/drivers/net/hns3/hns3_intr.h -+++ b/drivers/net/hns3/hns3_intr.h -@@ -22,6 +22,9 @@ - - #define HNS3_MAC_COMMON_ERR_INT_EN 0x107FF - #define HNS3_MAC_COMMON_ERR_INT_EN_MASK 0x107FF -+#define HNS3_MAC_TNL_INT_EN GENMASK(9, 0) -+#define HNS3_MAC_TNL_INT_EN_MASK GENMASK(9, 0) -+#define HNS3_MAC_TNL_INT_CLR GENMASK(9, 0) - - #define HNS3_IMP_TCM_ECC_ERR_INT_EN 0xFFFF0000 - #define HNS3_IMP_TCM_ECC_ERR_INT_EN_MASK 0xFFFF0000 -@@ -99,6 +102,7 @@ struct hns3_hw_error_desc { - int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool state); - void hns3_handle_msix_error(struct hns3_adapter *hns, uint64_t *levels); - void hns3_handle_ras_error(struct hns3_adapter *hns, uint64_t *levels); -+void hns3_config_mac_tnl_int(struct hns3_hw *hw, bool en); - - void hns3_intr_unregister(const struct rte_intr_handle *hdl, - rte_intr_callback_fn cb_fn, void *cb_arg); --- -2.7.4 - diff --git a/0058-net-hns3-fix-imprecise-statistics.patch b/0058-net-hns3-fix-imprecise-statistics.patch deleted file mode 100644 index e6347f4..0000000 --- a/0058-net-hns3-fix-imprecise-statistics.patch +++ /dev/null @@ -1,376 +0,0 @@ -From 7905cce75947b36dc0d955234d0930367e86bc17 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 4 Mar 2021 15:44:54 +0800 -Subject: [PATCH 058/189] net/hns3: fix imprecise statistics - -Currently, the hns3 statistics may be inaccurate due to the -following two problems: - -1. Queue-level statistics are read from the firmware, and only one Rx or - Tx can be read at a time. This results in a large time interval - between reading multiple queues statistics in a stress scenario, such - as 1280 queues used by a PF or 256 functions used at the same time. - Especially when the 256 functions are used at the same time, the - interval between every two firmware commands in a function can be - huge, because the scheduling mechanism of the firmware is similar to - RR. - -2. The current statistics are read by type. The HW statistics are read - first, and then the software statistics are read. Due to preceding - reasons, HW reading may be time-consuming, which cause a - synchronization problem between SW and HW statistics of the same - queue. - -In this patch, queue-level statistics are directly read from the bar -instead of the firmware, and all the statistics of a queue include HW -and SW are read at a time to reduce inconsistency. - -Fixes: 8839c5e202f3 ("net/hns3: support device stats") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Lijun Ou ---- - drivers/net/hns3/hns3_stats.c | 221 ++++++++++++++---------------------------- - 1 file changed, 72 insertions(+), 149 deletions(-) - -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 87035e3..941c75f 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -367,7 +367,6 @@ static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { - HNS3_NUM_RESET_XSTATS + HNS3_NUM_IMISSED_XSTATS) - - static void hns3_tqp_stats_clear(struct hns3_hw *hw); --static void hns3_tqp_basic_stats_clear(struct rte_eth_dev *dev); - - /* - * Query all the MAC statistics data of Network ICL command ,opcode id: 0x0034. -@@ -481,49 +480,6 @@ hns3_query_update_mac_stats(struct rte_eth_dev *dev) - return ret; - } - --/* Get tqp stats from register */ --static int --hns3_update_tqp_stats(struct hns3_hw *hw) --{ -- struct hns3_tqp_stats *stats = &hw->tqp_stats; -- struct hns3_cmd_desc desc; -- uint64_t cnt; -- uint16_t i; -- int ret; -- -- for (i = 0; i < hw->tqps_num; i++) { -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_RX_STATUS, -- true); -- -- desc.data[0] = rte_cpu_to_le_32((uint32_t)i); -- ret = hns3_cmd_send(hw, &desc, 1); -- if (ret) { -- hns3_err(hw, "Failed to query RX No.%u queue stat: %d", -- i, ret); -- return ret; -- } -- cnt = rte_le_to_cpu_32(desc.data[1]); -- stats->rcb_rx_ring_pktnum_rcd += cnt; -- stats->rcb_rx_ring_pktnum[i] += cnt; -- -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_TX_STATUS, -- true); -- -- desc.data[0] = rte_cpu_to_le_32((uint32_t)i); -- ret = hns3_cmd_send(hw, &desc, 1); -- if (ret) { -- hns3_err(hw, "Failed to query TX No.%u queue stat: %d", -- i, ret); -- return ret; -- } -- cnt = rte_le_to_cpu_32(desc.data[1]); -- stats->rcb_tx_ring_pktnum_rcd += cnt; -- stats->rcb_tx_ring_pktnum[i] += cnt; -- } -- -- return 0; --} -- - static int - hns3_update_rpu_drop_stats(struct hns3_hw *hw) - { -@@ -589,17 +545,11 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - struct hns3_rx_missed_stats *imissed_stats = &hw->imissed_stats; - struct hns3_tqp_stats *stats = &hw->tqp_stats; - struct hns3_rx_queue *rxq; -+ struct hns3_tx_queue *txq; - uint64_t cnt; - uint16_t i; - int ret; - -- /* Update tqp stats by read register */ -- ret = hns3_update_tqp_stats(hw); -- if (ret) { -- hns3_err(hw, "Update tqp stats fail : %d", ret); -- return ret; -- } -- - if (!hns->is_vf) { - /* Update imissed stats */ - ret = hns3_update_imissed_stats(hw, false); -@@ -612,24 +562,34 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - rte_stats->imissed = imissed_stats->rpu_rx_drop_cnt; - } - -- /* Get the error stats and bytes of received packets */ -+ /* Reads all the stats of a rxq in a loop to keep them synchronized */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; -- if (rxq) { -- cnt = rxq->err_stats.l2_errors + -- rxq->err_stats.pkt_len_errors; -- rte_stats->ierrors += cnt; -+ if (rxq == NULL) -+ continue; - -- rte_stats->ibytes += rxq->basic_stats.bytes; -- } -+ cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); -+ /* -+ * Read hardware and software in adjacent positions to minumize -+ * the timing variance. -+ */ -+ rte_stats->ierrors += rxq->err_stats.l2_errors + -+ rxq->err_stats.pkt_len_errors; -+ stats->rcb_rx_ring_pktnum_rcd += cnt; -+ stats->rcb_rx_ring_pktnum[i] += cnt; -+ rte_stats->ibytes += rxq->basic_stats.bytes; - } - -- /* Get the bytes of received packets */ -- struct hns3_tx_queue *txq; -+ /* Reads all the stats of a txq in a loop to keep them synchronized */ - for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { - txq = eth_dev->data->tx_queues[i]; -- if (txq) -- rte_stats->obytes += txq->basic_stats.bytes; -+ if (txq == NULL) -+ continue; -+ -+ cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); -+ stats->rcb_tx_ring_pktnum_rcd += cnt; -+ stats->rcb_tx_ring_pktnum[i] += cnt; -+ rte_stats->obytes += txq->basic_stats.bytes; - } - - rte_stats->oerrors = 0; -@@ -653,37 +613,11 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - { - struct hns3_adapter *hns = eth_dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -- struct hns3_cmd_desc desc_reset; - struct hns3_rx_queue *rxq; -+ struct hns3_tx_queue *txq; - uint16_t i; - int ret; - -- /* -- * Note: Reading hardware statistics of rx/tx queue packet number -- * will clear them. -- */ -- for (i = 0; i < hw->tqps_num; i++) { -- hns3_cmd_setup_basic_desc(&desc_reset, HNS3_OPC_QUERY_RX_STATUS, -- true); -- desc_reset.data[0] = rte_cpu_to_le_32((uint32_t)i); -- ret = hns3_cmd_send(hw, &desc_reset, 1); -- if (ret) { -- hns3_err(hw, "Failed to reset RX No.%u queue stat: %d", -- i, ret); -- return ret; -- } -- -- hns3_cmd_setup_basic_desc(&desc_reset, HNS3_OPC_QUERY_TX_STATUS, -- true); -- desc_reset.data[0] = rte_cpu_to_le_32((uint32_t)i); -- ret = hns3_cmd_send(hw, &desc_reset, 1); -- if (ret) { -- hns3_err(hw, "Failed to reset TX No.%u queue stat: %d", -- i, ret); -- return ret; -- } -- } -- - if (!hns->is_vf) { - /* - * Note: Reading hardware statistics of imissed registers will -@@ -697,25 +631,44 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - } - } - -- /* -- * Clear soft stats of rx error packet which will be dropped -- * in driver. -- */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; -- if (rxq) { -- rxq->err_stats.pkt_len_errors = 0; -- rxq->err_stats.l2_errors = 0; -- } -+ if (rxq == NULL) -+ continue; -+ -+ rxq->err_stats.pkt_len_errors = 0; -+ rxq->err_stats.l2_errors = 0; -+ } -+ -+ /* Clear all the stats of a rxq in a loop to keep them synchronized */ -+ for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { -+ rxq = eth_dev->data->rx_queues[i]; -+ if (rxq == NULL) -+ continue; -+ -+ memset(&rxq->basic_stats, 0, -+ sizeof(struct hns3_rx_basic_stats)); -+ -+ /* This register is read-clear */ -+ (void)hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); -+ rxq->err_stats.pkt_len_errors = 0; -+ rxq->err_stats.l2_errors = 0; -+ } -+ -+ /* Clear all the stats of a txq in a loop to keep them synchronized */ -+ for (i = 0; i < eth_dev->data->nb_tx_queues; i++) { -+ txq = eth_dev->data->tx_queues[i]; -+ if (txq == NULL) -+ continue; -+ -+ memset(&txq->basic_stats, 0, -+ sizeof(struct hns3_tx_basic_stats)); -+ -+ /* This register is read-clear */ -+ (void)hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); - } - -- /* -- * 'packets' in hns3_tx_basic_stats and hns3_rx_basic_stats come -- * from hw->tqp_stats. And clearing tqp stats is like clearing -- * their source. -- */ - hns3_tqp_stats_clear(hw); -- hns3_tqp_basic_stats_clear(eth_dev); - - return 0; - } -@@ -881,6 +834,7 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - struct hns3_rx_basic_stats *rxq_stats; - struct hns3_rx_queue *rxq; - uint16_t i, j; -+ uint32_t cnt; - char *val; - - for (i = 0; i < dev->data->nb_rx_queues; i++) { -@@ -888,9 +842,17 @@ hns3_rxq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - if (rxq == NULL) - continue; - -+ cnt = hns3_read_dev(rxq, HNS3_RING_RX_PKTNUM_RECORD_REG); -+ /* -+ * Read hardware and software in adjacent positions to minimize -+ * the time difference. -+ */ - rxq_stats = &rxq->basic_stats; - rxq_stats->errors = rxq->err_stats.l2_errors + - rxq->err_stats.pkt_len_errors; -+ stats->rcb_rx_ring_pktnum_rcd += cnt; -+ stats->rcb_rx_ring_pktnum[i] += cnt; -+ - /* - * If HW statistics are reset by stats_reset, but a lot of - * residual packets exist in the hardware queue and these -@@ -919,6 +881,7 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - struct hns3_tx_basic_stats *txq_stats; - struct hns3_tx_queue *txq; - uint16_t i, j; -+ uint32_t cnt; - char *val; - - for (i = 0; i < dev->data->nb_tx_queues; i++) { -@@ -926,6 +889,10 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - if (txq == NULL) - continue; - -+ cnt = hns3_read_dev(txq, HNS3_RING_TX_PKTNUM_RECORD_REG); -+ stats->rcb_tx_ring_pktnum_rcd += cnt; -+ stats->rcb_tx_ring_pktnum[i] += cnt; -+ - txq_stats = &txq->basic_stats; - txq_stats->packets = stats->rcb_tx_ring_pktnum[i]; - -@@ -939,54 +906,12 @@ hns3_txq_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - } - } - --static int -+static void - hns3_tqp_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - int *count) - { -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- int ret; -- -- /* Update tqp stats by read register */ -- ret = hns3_update_tqp_stats(hw); -- if (ret) { -- hns3_err(hw, "Update tqp stats fail, ret = %d.", ret); -- return ret; -- } -- - hns3_rxq_basic_stats_get(dev, xstats, count); - hns3_txq_basic_stats_get(dev, xstats, count); -- -- return 0; --} -- --/* -- * The function is only called by hns3_dev_xstats_reset to clear -- * basic stats of per-queue. TQP stats are all cleared in hns3_stats_reset -- * which is called before this function. -- * -- * @param dev -- * Pointer to Ethernet device. -- */ --static void --hns3_tqp_basic_stats_clear(struct rte_eth_dev *dev) --{ -- struct hns3_tx_queue *txq; -- struct hns3_rx_queue *rxq; -- uint16_t i; -- -- for (i = 0; i < dev->data->nb_rx_queues; i++) { -- rxq = dev->data->rx_queues[i]; -- if (rxq) -- memset(&rxq->basic_stats, 0, -- sizeof(struct hns3_rx_basic_stats)); -- } -- -- for (i = 0; i < dev->data->nb_tx_queues; i++) { -- txq = dev->data->tx_queues[i]; -- if (txq) -- memset(&txq->basic_stats, 0, -- sizeof(struct hns3_tx_basic_stats)); -- } - } - - /* -@@ -1028,9 +953,7 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - - count = 0; - -- ret = hns3_tqp_basic_stats_get(dev, xstats, &count); -- if (ret < 0) -- return ret; -+ hns3_tqp_basic_stats_get(dev, xstats, &count); - - if (!hns->is_vf) { - /* Update Mac stats */ --- -2.7.4 - diff --git a/0059-net-hns3-add-runtime-config-to-select-IO-burst-funct.patch b/0059-net-hns3-add-runtime-config-to-select-IO-burst-funct.patch deleted file mode 100644 index 05a1b0e..0000000 --- a/0059-net-hns3-add-runtime-config-to-select-IO-burst-funct.patch +++ /dev/null @@ -1,341 +0,0 @@ -From 20570791fbb46112707b5ddb21da9446da8a938d Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 23 Mar 2021 19:21:00 +0800 -Subject: [PATCH 059/189] net/hns3: add runtime config to select IO burst - function - -Currently, the driver support multiple IO burst function and auto -selection of the most appropriate function based on offload -configuration. - -Most applications such as l2fwd/l3fwd don't provide the means to -change offload configuration, so it will use the auto selection's io -burst function. - -This patch support runtime config to select io burst function, which -add two config: rx_func_hint and tx_func_hint, both could assign -vec/sve/simple/common. - -The driver will use the following rules to select io burst func: -a. if hint equal vec and meet the vec Rx/Tx usage condition then use the - neon function. -b. if hint equal sve and meet the sve Rx/Tx usage condition then use the - sve function. -c. if hint equal simple and meet the simple Rx/Tx usage condition then - use the simple function. -d. if hint equal common then use the common function. -e. if hint not set then: -e.1. if meet the vec Rx/Tx usage condition then use the neon function. -e.2. if meet the simple Rx/Tx usage condition then use the simple - function. -e.3. else use the common function. - -Note: the sve Rx/Tx usage condition based on the vec Rx/Tx usage -condition and runtime environment (which must support SVE). - -In the previous versions, driver will preferred use the sve function -when meet the sve Rx/Tx usage condition, but in this case driver could -get better performance if use the neon function. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/hns3.rst | 37 +++++++++++++++++++ - drivers/net/hns3/hns3_ethdev.c | 77 +++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_ethdev.h | 15 ++++++++ - drivers/net/hns3/hns3_ethdev_vf.c | 4 ++ - drivers/net/hns3/hns3_rxtx.c | 54 ++++++++++++++++++++------- - 5 files changed, 173 insertions(+), 14 deletions(-) - -diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst -index 8db8867..e8abd07 100644 ---- a/doc/guides/nics/hns3.rst -+++ b/doc/guides/nics/hns3.rst -@@ -46,6 +46,43 @@ Prerequisites - - Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup the basic DPDK environment. - - -+Runtime Config Options -+---------------------- -+ -+- ``rx_func_hint`` (default ``none``) -+ -+ Used to select Rx burst function, supported value are ``vec``, ``sve``, -+ ``simple``, ``common``. -+ ``vec``, if supported use the ``vec`` Rx function which indicates the -+ default vector algorithm, neon for Kunpeng Arm platform. -+ ``sve``, if supported use the ``sve`` Rx function which indicates the -+ sve algorithm. -+ ``simple``, if supported use the ``simple`` Rx function which indicates -+ the scalar algorithm. -+ ``common``, if supported use the ``common`` Rx function which indicates -+ the scalar scattered algorithm. -+ -+ When provided parameter is not supported, ``vec`` usage condition will -+ be first checked, if meets, use the ``vec``. Then, ``simple``, at last -+ ``common``. -+ -+- ``tx_func_hint`` (default ``none``) -+ -+ Used to select Tx burst function, supported value are ``vec``, ``sve``, -+ ``simple``, ``common``. -+ ``vec``, if supported use the ``vec`` Tx function which indicates the -+ default vector algorithm, neon for Kunpeng Arm platform. -+ ``sve``, if supported use the ``sve`` Tx function which indicates the -+ sve algorithm. -+ ``simple``, if supported use the ``simple`` Tx function which indicates -+ the scalar simple algorithm. -+ ``common``, if supported use the ``common`` Tx function which indicates -+ the scalar algorithm. -+ -+ When provided parameter is not supported, ``vec`` usage condition will -+ be first checked, if meets, use the ``vec``. Then, ``simple``, at last -+ ``common``. -+ - Driver compilation and testing - ------------------------------ - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 80f91a7..f6ec8ac 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - - #include "hns3_ethdev.h" - #include "hns3_logs.h" -@@ -6505,6 +6506,78 @@ hns3_get_module_info(struct rte_eth_dev *dev, - return 0; - } - -+static int -+hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) -+{ -+ uint32_t hint = HNS3_IO_FUNC_HINT_NONE; -+ -+ RTE_SET_USED(key); -+ -+ if (strcmp(value, "vec") == 0) -+ hint = HNS3_IO_FUNC_HINT_VEC; -+ else if (strcmp(value, "sve") == 0) -+ hint = HNS3_IO_FUNC_HINT_SVE; -+ else if (strcmp(value, "simple") == 0) -+ hint = HNS3_IO_FUNC_HINT_SIMPLE; -+ else if (strcmp(value, "common") == 0) -+ hint = HNS3_IO_FUNC_HINT_COMMON; -+ -+ /* If the hint is valid then update output parameters */ -+ if (hint != HNS3_IO_FUNC_HINT_NONE) -+ *(uint32_t *)extra_args = hint; -+ -+ return 0; -+} -+ -+static const char * -+hns3_get_io_hint_func_name(uint32_t hint) -+{ -+ switch (hint) { -+ case HNS3_IO_FUNC_HINT_VEC: -+ return "vec"; -+ case HNS3_IO_FUNC_HINT_SVE: -+ return "sve"; -+ case HNS3_IO_FUNC_HINT_SIMPLE: -+ return "simple"; -+ case HNS3_IO_FUNC_HINT_COMMON: -+ return "common"; -+ default: -+ return "none"; -+ } -+} -+ -+void -+hns3_parse_devargs(struct rte_eth_dev *dev) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ uint32_t rx_func_hint = HNS3_IO_FUNC_HINT_NONE; -+ uint32_t tx_func_hint = HNS3_IO_FUNC_HINT_NONE; -+ struct hns3_hw *hw = &hns->hw; -+ struct rte_kvargs *kvlist; -+ -+ if (dev->device->devargs == NULL) -+ return; -+ -+ kvlist = rte_kvargs_parse(dev->device->devargs->args, NULL); -+ if (!kvlist) -+ return; -+ -+ rte_kvargs_process(kvlist, HNS3_DEVARG_RX_FUNC_HINT, -+ &hns3_parse_io_hint_func, &rx_func_hint); -+ rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, -+ &hns3_parse_io_hint_func, &tx_func_hint); -+ rte_kvargs_free(kvlist); -+ -+ if (rx_func_hint != HNS3_IO_FUNC_HINT_NONE) -+ hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_RX_FUNC_HINT, -+ hns3_get_io_hint_func_name(rx_func_hint)); -+ hns->rx_func_hint = rx_func_hint; -+ if (tx_func_hint != HNS3_IO_FUNC_HINT_NONE) -+ hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_TX_FUNC_HINT, -+ hns3_get_io_hint_func_name(tx_func_hint)); -+ hns->tx_func_hint = tx_func_hint; -+} -+ - static const struct eth_dev_ops hns3_eth_dev_ops = { - .dev_configure = hns3_dev_configure, - .dev_start = hns3_dev_start, -@@ -6625,6 +6698,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = false; - hw->data = eth_dev->data; -+ hns3_parse_devargs(eth_dev); - - /* - * Set default max packet size according to the mtu -@@ -6758,5 +6832,8 @@ static struct rte_pci_driver rte_hns3_pmd = { - RTE_PMD_REGISTER_PCI(net_hns3, rte_hns3_pmd); - RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map); - RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci"); -+RTE_PMD_REGISTER_PARAM_STRING(net_hns3, -+ HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " -+ HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common "); - RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE); - RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 52e6c49..67a69ba 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -772,9 +772,23 @@ struct hns3_adapter { - bool tx_simple_allowed; - bool tx_vec_allowed; - -+ uint32_t rx_func_hint; -+ uint32_t tx_func_hint; -+ - struct hns3_ptype_table ptype_tbl __rte_cache_min_aligned; - }; - -+enum { -+ HNS3_IO_FUNC_HINT_NONE = 0, -+ HNS3_IO_FUNC_HINT_VEC, -+ HNS3_IO_FUNC_HINT_SVE, -+ HNS3_IO_FUNC_HINT_SIMPLE, -+ HNS3_IO_FUNC_HINT_COMMON -+}; -+ -+#define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint" -+#define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint" -+ - #define HNS3_DEV_SUPPORT_DCB_B 0x0 - #define HNS3_DEV_SUPPORT_COPPER_B 0x1 - #define HNS3_DEV_SUPPORT_UDP_GSO_B 0x2 -@@ -975,6 +989,7 @@ int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, - struct rte_eth_dev_info *info); - void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); -+void hns3_parse_devargs(struct rte_eth_dev *dev); - - static inline bool - is_reset_pending(struct hns3_adapter *hns) -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 12af105..a4fd8ca 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2834,6 +2834,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = true; - hw->data = eth_dev->data; -+ hns3_parse_devargs(eth_dev); - - ret = hns3_reset_init(hw); - if (ret) -@@ -2962,3 +2963,6 @@ static struct rte_pci_driver rte_hns3vf_pmd = { - RTE_PMD_REGISTER_PCI(net_hns3_vf, rte_hns3vf_pmd); - RTE_PMD_REGISTER_PCI_TABLE(net_hns3_vf, pci_id_hns3vf_map); - RTE_PMD_REGISTER_KMOD_DEP(net_hns3_vf, "* igb_uio | vfio-pci"); -+RTE_PMD_REGISTER_PARAM_STRING(net_hns3_vf, -+ HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " -+ HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common "); -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 09b38d4..8e927f1 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2689,13 +2689,26 @@ hns3_get_rx_function(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; - uint64_t offloads = dev->data->dev_conf.rxmode.offloads; -+ bool vec_allowed, sve_allowed, simple_allowed; -+ -+ vec_allowed = hns->rx_vec_allowed && -+ hns3_rx_check_vec_support(dev) == 0; -+ sve_allowed = vec_allowed && hns3_check_sve_support(); -+ simple_allowed = hns->rx_simple_allowed && !dev->data->scattered_rx && -+ (offloads & DEV_RX_OFFLOAD_TCP_LRO) == 0; -+ -+ if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_VEC && vec_allowed) -+ return hns3_recv_pkts_vec; -+ if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_SVE && sve_allowed) -+ return hns3_recv_pkts_vec_sve; -+ if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_SIMPLE && simple_allowed) -+ return hns3_recv_pkts; -+ if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_COMMON) -+ return hns3_recv_scattered_pkts; - -- if (hns->rx_vec_allowed && hns3_rx_check_vec_support(dev) == 0) -- return hns3_check_sve_support() ? hns3_recv_pkts_vec_sve : -- hns3_recv_pkts_vec; -- -- if (hns->rx_simple_allowed && !dev->data->scattered_rx && -- (offloads & DEV_RX_OFFLOAD_TCP_LRO) == 0) -+ if (vec_allowed) -+ return hns3_recv_pkts_vec; -+ if (simple_allowed) - return hns3_recv_pkts; - - return hns3_recv_scattered_pkts; -@@ -3930,19 +3943,32 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - { - uint64_t offloads = dev->data->dev_conf.txmode.offloads; - struct hns3_adapter *hns = dev->data->dev_private; -+ bool vec_allowed, sve_allowed, simple_allowed; - -- if (hns->tx_vec_allowed && hns3_tx_check_vec_support(dev) == 0) { -- *prep = NULL; -- return hns3_check_sve_support() ? hns3_xmit_pkts_vec_sve : -- hns3_xmit_pkts_vec; -- } -+ vec_allowed = hns->tx_vec_allowed && -+ hns3_tx_check_vec_support(dev) == 0; -+ sve_allowed = vec_allowed && hns3_check_sve_support(); -+ simple_allowed = hns->tx_simple_allowed && -+ offloads == (offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE); - -- if (hns->tx_simple_allowed && -- offloads == (offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)) { -- *prep = NULL; -+ *prep = NULL; -+ -+ if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_VEC && vec_allowed) -+ return hns3_xmit_pkts_vec; -+ if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_SVE && sve_allowed) -+ return hns3_xmit_pkts_vec_sve; -+ if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_SIMPLE && simple_allowed) - return hns3_xmit_pkts_simple; -+ if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_COMMON) { -+ *prep = hns3_prep_pkts; -+ return hns3_xmit_pkts; - } - -+ if (vec_allowed) -+ return hns3_xmit_pkts_vec; -+ if (simple_allowed) -+ return hns3_xmit_pkts_simple; -+ - *prep = hns3_prep_pkts; - return hns3_xmit_pkts; - } --- -2.7.4 - diff --git a/0060-net-hns3-support-outer-UDP-checksum.patch b/0060-net-hns3-support-outer-UDP-checksum.patch deleted file mode 100644 index 98bf5c0..0000000 --- a/0060-net-hns3-support-outer-UDP-checksum.patch +++ /dev/null @@ -1,292 +0,0 @@ -From a9ababcfe9b34d979359f023833fbaebbb04e9d0 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Tue, 23 Mar 2021 19:21:01 +0800 -Subject: [PATCH 060/189] net/hns3: support outer UDP checksum - -Kunpeng930 support outer UDP cksum, this patch add support for it. - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 3 ++ - drivers/net/hns3/hns3_ethdev.c | 3 ++ - drivers/net/hns3/hns3_ethdev.h | 4 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 3 ++ - drivers/net/hns3/hns3_rxtx.c | 85 +++++++++++++++++++++++++++++------- - drivers/net/hns3/hns3_rxtx.h | 4 +- - drivers/net/hns3/hns3_rxtx_vec_sve.c | 5 ++- - 7 files changed, 88 insertions(+), 19 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 8a2cc2d..f8d8b0a 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -433,6 +433,9 @@ hns3_parse_capability(struct hns3_hw *hw, - if (hns3_get_bit(caps, HNS3_CAPS_RXD_ADV_LAYOUT_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, - 1); -+ if (hns3_get_bit(caps, HNS3_CAPS_UDP_TUNNEL_CSUM_B)) -+ hns3_set_bit(hw->capability, -+ HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, 1); - } - - static uint32_t -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f6ec8ac..5da00b3 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2620,6 +2620,9 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - DEV_TX_OFFLOAD_MBUF_FAST_FREE | - hns3_txvlan_cap_get(hw)); - -+ if (hns3_dev_outer_udp_cksum_supported(hw)) -+ info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; -+ - if (hns3_dev_indep_txrx_supported(hw)) - info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | - RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 67a69ba..dc27bb1 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -798,6 +798,7 @@ enum { - #define HNS3_DEV_SUPPORT_INDEP_TXRX_B 0x6 - #define HNS3_DEV_SUPPORT_STASH_B 0x7 - #define HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B 0x9 -+#define HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B 0xA - - #define hns3_dev_dcb_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B) -@@ -831,6 +832,9 @@ enum { - #define hns3_dev_rxd_adv_layout_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B) - -+#define hns3_dev_outer_udp_cksum_supported(hw) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B) -+ - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index a4fd8ca..35c42ca 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -988,6 +988,9 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - DEV_TX_OFFLOAD_MBUF_FAST_FREE | - hns3_txvlan_cap_get(hw)); - -+ if (hns3_dev_outer_udp_cksum_supported(hw)) -+ info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; -+ - if (hns3_dev_indep_txrx_supported(hw)) - info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | - RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 8e927f1..404c403 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2967,7 +2967,7 @@ hns3_fill_first_desc(struct hns3_tx_queue *txq, struct hns3_desc *desc, - hdr_len += (ol_flags & PKT_TX_TUNNEL_MASK) ? - rxm->outer_l2_len + rxm->outer_l3_len : 0; - paylen = rxm->pkt_len - hdr_len; -- desc->tx.paylen = rte_cpu_to_le_32(paylen); -+ desc->tx.paylen_fd_dop_ol4cs |= rte_cpu_to_le_32(paylen); - hns3_set_tso(desc, paylen, rxm); - - /* -@@ -3204,8 +3204,10 @@ hns3_parse_tunneling_params(struct hns3_tx_queue *txq, struct rte_mbuf *m, - { - struct hns3_desc *tx_ring = txq->tx_ring; - struct hns3_desc *desc = &tx_ring[tx_desc_id]; -+ uint64_t ol_flags = m->ol_flags; - uint32_t tmp_outer = 0; - uint32_t tmp_inner = 0; -+ uint32_t tmp_ol4cs; - int ret; - - /* -@@ -3215,7 +3217,7 @@ hns3_parse_tunneling_params(struct hns3_tx_queue *txq, struct rte_mbuf *m, - * calculations, the length of the L2 header include the outer and - * inner, will be filled during the parsing of tunnel packects. - */ -- if (!(m->ol_flags & PKT_TX_TUNNEL_MASK)) { -+ if (!(ol_flags & PKT_TX_TUNNEL_MASK)) { - /* - * For non tunnel type the tunnel type id is 0, so no need to - * assign a value to it. Only the inner(normal) L2 header length -@@ -3230,7 +3232,8 @@ hns3_parse_tunneling_params(struct hns3_tx_queue *txq, struct rte_mbuf *m, - * inner l2_len. It would lead a cksum error. So driver has to - * calculate the header length. - */ -- if (unlikely(!(m->ol_flags & PKT_TX_OUTER_IP_CKSUM) && -+ if (unlikely(!(ol_flags & -+ (PKT_TX_OUTER_IP_CKSUM | PKT_TX_OUTER_UDP_CKSUM)) && - m->outer_l2_len == 0)) { - struct rte_net_hdr_lens hdr_len; - (void)rte_net_get_ptype(m, &hdr_len, -@@ -3247,6 +3250,9 @@ hns3_parse_tunneling_params(struct hns3_tx_queue *txq, struct rte_mbuf *m, - - desc->tx.ol_type_vlan_len_msec = rte_cpu_to_le_32(tmp_outer); - desc->tx.type_cs_vlan_tso_len = rte_cpu_to_le_32(tmp_inner); -+ tmp_ol4cs = ol_flags & PKT_TX_OUTER_UDP_CKSUM ? -+ BIT(HNS3_TXD_OL4CS_B) : 0; -+ desc->tx.paylen_fd_dop_ol4cs = rte_cpu_to_le_32(tmp_ol4cs); - - return 0; - } -@@ -3376,31 +3382,78 @@ hns3_pkt_need_linearized(struct rte_mbuf *tx_pkts, uint32_t bd_num, - return false; - } - -+static bool -+hns3_outer_ipv4_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, -+ uint32_t *l4_proto) -+{ -+ struct rte_ipv4_hdr *ipv4_hdr; -+ ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, -+ m->outer_l2_len); -+ if (ol_flags & PKT_TX_OUTER_IP_CKSUM) -+ ipv4_hdr->hdr_checksum = 0; -+ if (ol_flags & PKT_TX_OUTER_UDP_CKSUM) { -+ struct rte_udp_hdr *udp_hdr; -+ /* -+ * If OUTER_UDP_CKSUM is support, HW can caclulate the pseudo -+ * header for TSO packets -+ */ -+ if (ol_flags & PKT_TX_TCP_SEG) -+ return true; -+ udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, -+ m->outer_l2_len + m->outer_l3_len); -+ udp_hdr->dgram_cksum = rte_ipv4_phdr_cksum(ipv4_hdr, ol_flags); -+ -+ return true; -+ } -+ *l4_proto = ipv4_hdr->next_proto_id; -+ return false; -+} -+ -+static bool -+hns3_outer_ipv6_cksum_prepared(struct rte_mbuf *m, uint64_t ol_flags, -+ uint32_t *l4_proto) -+{ -+ struct rte_ipv6_hdr *ipv6_hdr; -+ ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, -+ m->outer_l2_len); -+ if (ol_flags & PKT_TX_OUTER_UDP_CKSUM) { -+ struct rte_udp_hdr *udp_hdr; -+ /* -+ * If OUTER_UDP_CKSUM is support, HW can caclulate the pseudo -+ * header for TSO packets -+ */ -+ if (ol_flags & PKT_TX_TCP_SEG) -+ return true; -+ udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, -+ m->outer_l2_len + m->outer_l3_len); -+ udp_hdr->dgram_cksum = rte_ipv6_phdr_cksum(ipv6_hdr, ol_flags); -+ -+ return true; -+ } -+ *l4_proto = ipv6_hdr->proto; -+ return false; -+} -+ - static void - hns3_outer_header_cksum_prepare(struct rte_mbuf *m) - { - uint64_t ol_flags = m->ol_flags; - uint32_t paylen, hdr_len, l4_proto; -+ struct rte_udp_hdr *udp_hdr; - - if (!(ol_flags & (PKT_TX_OUTER_IPV4 | PKT_TX_OUTER_IPV6))) - return; - - if (ol_flags & PKT_TX_OUTER_IPV4) { -- struct rte_ipv4_hdr *ipv4_hdr; -- ipv4_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv4_hdr *, -- m->outer_l2_len); -- l4_proto = ipv4_hdr->next_proto_id; -- if (ol_flags & PKT_TX_OUTER_IP_CKSUM) -- ipv4_hdr->hdr_checksum = 0; -+ if (hns3_outer_ipv4_cksum_prepared(m, ol_flags, &l4_proto)) -+ return; - } else { -- struct rte_ipv6_hdr *ipv6_hdr; -- ipv6_hdr = rte_pktmbuf_mtod_offset(m, struct rte_ipv6_hdr *, -- m->outer_l2_len); -- l4_proto = ipv6_hdr->proto; -+ if (hns3_outer_ipv6_cksum_prepared(m, ol_flags, &l4_proto)) -+ return; - } -+ - /* driver should ensure the outer udp cksum is 0 for TUNNEL TSO */ - if (l4_proto == IPPROTO_UDP && (ol_flags & PKT_TX_TCP_SEG)) { -- struct rte_udp_hdr *udp_hdr; - hdr_len = m->l2_len + m->l3_len + m->l4_len; - hdr_len += m->outer_l2_len + m->outer_l3_len; - paylen = m->pkt_len - hdr_len; -@@ -3686,7 +3739,7 @@ hns3_tx_setup_4bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) - dma_addr = rte_mbuf_data_iova(*pkts); - txdp->addr = rte_cpu_to_le_64(dma_addr); - txdp->tx.send_size = rte_cpu_to_le_16((*pkts)->data_len); -- txdp->tx.paylen = 0; -+ txdp->tx.paylen_fd_dop_ol4cs = 0; - txdp->tx.type_cs_vlan_tso_len = 0; - txdp->tx.ol_type_vlan_len_msec = 0; - txdp->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(bd_flag); -@@ -3702,7 +3755,7 @@ hns3_tx_setup_1bd(struct hns3_desc *txdp, struct rte_mbuf **pkts) - dma_addr = rte_mbuf_data_iova(*pkts); - txdp->addr = rte_cpu_to_le_64(dma_addr); - txdp->tx.send_size = rte_cpu_to_le_16((*pkts)->data_len); -- txdp->tx.paylen = 0; -+ txdp->tx.paylen_fd_dop_ol4cs = 0; - txdp->tx.type_cs_vlan_tso_len = 0; - txdp->tx.ol_type_vlan_len_msec = 0; - txdp->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(bd_flag); -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 9adeb24..cd04200 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -149,6 +149,7 @@ - #define HNS3_TXD_MSS_S 0 - #define HNS3_TXD_MSS_M (0x3fff << HNS3_TXD_MSS_S) - -+#define HNS3_TXD_OL4CS_B 22 - #define HNS3_L2_LEN_UNIT 1UL - #define HNS3_L3_LEN_UNIT 2UL - #define HNS3_L4_LEN_UNIT 2UL -@@ -234,7 +235,7 @@ struct hns3_desc { - }; - }; - -- uint32_t paylen; -+ uint32_t paylen_fd_dop_ol4cs; - uint16_t tp_fe_sc_vld_ra_ri; - uint16_t mss; - } tx; -@@ -503,6 +504,7 @@ struct hns3_queue_info { - }; - - #define HNS3_TX_CKSUM_OFFLOAD_MASK ( \ -+ PKT_TX_OUTER_UDP_CKSUM | \ - PKT_TX_OUTER_IP_CKSUM | \ - PKT_TX_IP_CKSUM | \ - PKT_TX_TCP_SEG | \ -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index 947c19f..f6c6f52 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -408,8 +408,9 @@ hns3_tx_fill_hw_ring_sve(struct hns3_tx_queue *txq, - (uint64_t *)&txdp->tx.outer_vlan_tag, - offsets, svdup_n_u64(0)); - /* save offset 24~31byte of every BD */ -- svst1_scatter_u64offset_u64(pg, (uint64_t *)&txdp->tx.paylen, -- offsets, svdup_n_u64(valid_bit)); -+ svst1_scatter_u64offset_u64(pg, -+ (uint64_t *)&txdp->tx.paylen_fd_dop_ol4cs, -+ offsets, svdup_n_u64(valid_bit)); - - /* Increment bytes counter */ - uint32_t idx; --- -2.7.4 - diff --git a/0061-net-hns3-adjust-format-of-RAS-related-structures.patch b/0061-net-hns3-adjust-format-of-RAS-related-structures.patch deleted file mode 100644 index c7ff1b7..0000000 --- a/0061-net-hns3-adjust-format-of-RAS-related-structures.patch +++ /dev/null @@ -1,2251 +0,0 @@ -From 8d96829c74a9177cd4958c25946ae7ccf3db1957 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Tue, 23 Mar 2021 19:21:02 +0800 -Subject: [PATCH 061/189] net/hns3: adjust format of RAS related structures - -Adjust the format of hns3 RAS related structures to resolve -the static check warnings. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_intr.c | 2126 ++++++++++++++++++++++++------------------ - 1 file changed, 1224 insertions(+), 902 deletions(-) - -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 2563504..265dae8 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -28,282 +28,375 @@ static const char *reset_string[HNS3_MAX_RESET] = { - }; - - static const struct hns3_hw_error mac_afifo_tnl_int[] = { -- { .int_msk = BIT(0), -- .msg = "egu_cge_afifo_ecc_1bit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(1), -- .msg = "egu_cge_afifo_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "egu_lge_afifo_ecc_1bit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(3), -- .msg = "egu_lge_afifo_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "cge_igu_afifo_ecc_1bit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(5), -- .msg = "cge_igu_afifo_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "lge_igu_afifo_ecc_1bit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(7), -- .msg = "lge_igu_afifo_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "cge_igu_afifo_overflow_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "lge_igu_afifo_overflow_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(10), -- .msg = "egu_cge_afifo_underrun_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "egu_lge_afifo_underrun_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(12), -- .msg = "egu_ge_afifo_underrun_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "ge_igu_afifo_overflow_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "egu_cge_afifo_ecc_1bit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "egu_cge_afifo_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "egu_lge_afifo_ecc_1bit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "egu_lge_afifo_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "cge_igu_afifo_ecc_1bit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "cge_igu_afifo_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "lge_igu_afifo_ecc_1bit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "lge_igu_afifo_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "cge_igu_afifo_overflow_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "lge_igu_afifo_overflow_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(10), -+ .msg = "egu_cge_afifo_underrun_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "egu_lge_afifo_underrun_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(12), -+ .msg = "egu_ge_afifo_underrun_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "ge_igu_afifo_overflow_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppu_mpf_abnormal_int_st1[] = { -- { .int_msk = 0xFFFFFFFF, -- .msg = "rpu_rx_pkt_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = 0xFFFFFFFF, -+ .msg = "rpu_rx_pkt_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppu_mpf_abnormal_int_st2_ras[] = { -- { .int_msk = BIT(13), -- .msg = "rpu_rx_pkt_bit32_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(14), -- .msg = "rpu_rx_pkt_bit33_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(15), -- .msg = "rpu_rx_pkt_bit34_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(16), -- .msg = "rpu_rx_pkt_bit35_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(17), -- .msg = "rcb_tx_ring_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(18), -- .msg = "rcb_rx_ring_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(19), -- .msg = "rcb_tx_fbd_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(20), -- .msg = "rcb_rx_ebd_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(21), -- .msg = "rcb_tso_info_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(22), -- .msg = "rcb_tx_int_info_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(23), -- .msg = "rcb_rx_int_info_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(24), -- .msg = "tpu_tx_pkt_0_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(25), -- .msg = "tpu_tx_pkt_1_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(26), -- .msg = "rd_bus_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(27), -- .msg = "wr_bus_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(30), -- .msg = "ooo_ecc_err_detect", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(31), -- .msg = "ooo_ecc_err_multpl", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(13), -+ .msg = "rpu_rx_pkt_bit32_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(14), -+ .msg = "rpu_rx_pkt_bit33_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "rpu_rx_pkt_bit34_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(16), -+ .msg = "rpu_rx_pkt_bit35_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "rcb_tx_ring_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(18), -+ .msg = "rcb_rx_ring_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(19), -+ .msg = "rcb_tx_fbd_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(20), -+ .msg = "rcb_rx_ebd_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(21), -+ .msg = "rcb_tso_info_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(22), -+ .msg = "rcb_tx_int_info_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(23), -+ .msg = "rcb_rx_int_info_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(24), -+ .msg = "tpu_tx_pkt_0_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(25), -+ .msg = "tpu_tx_pkt_1_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(26), -+ .msg = "rd_bus_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(27), -+ .msg = "wr_bus_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(30), -+ .msg = "ooo_ecc_err_detect", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(31), -+ .msg = "ooo_ecc_err_multpl", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppu_mpf_abnormal_int_st2_msix[] = { -- { .int_msk = BIT(29), -- .msg = "rx_q_search_miss", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(29), -+ .msg = "rx_q_search_miss", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ssu_port_based_pf_int[] = { -- { .int_msk = BIT(0), -- .msg = "roc_pkt_without_key_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "low_water_line_err_port", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "roc_pkt_without_key_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "low_water_line_err_port", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppp_pf_abnormal_int[] = { -- { .int_msk = BIT(0), -- .msg = "tx_vlan_tag_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(1), -- .msg = "rss_list_tc_unassigned_queue_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "tx_vlan_tag_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "rss_list_tc_unassigned_queue_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppu_pf_abnormal_int_ras[] = { -- { .int_msk = BIT(3), -- .msg = "tx_rd_fbd_poison", -- .reset_level = HNS3_FUNC_RESET }, -- { .int_msk = BIT(4), -- .msg = "rx_rd_ebd_poison", -- .reset_level = HNS3_FUNC_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(3), -+ .msg = "tx_rd_fbd_poison", -+ .reset_level = HNS3_FUNC_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "rx_rd_ebd_poison", -+ .reset_level = HNS3_FUNC_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppu_pf_abnormal_int_msix[] = { -- { .int_msk = BIT(0), -- .msg = "over_8bd_no_fe", -- .reset_level = HNS3_FUNC_RESET }, -- { .int_msk = BIT(1), -- .msg = "tso_mss_cmp_min_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(2), -- .msg = "tso_mss_cmp_max_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(5), -- .msg = "buf_wait_timeout", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "over_8bd_no_fe", -+ .reset_level = HNS3_FUNC_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "tso_mss_cmp_min_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "tso_mss_cmp_max_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "buf_wait_timeout", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error imp_tcm_ecc_int[] = { -- { .int_msk = BIT(1), -- .msg = "imp_itcm0_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(3), -- .msg = "imp_itcm1_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(5), -- .msg = "imp_itcm2_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(7), -- .msg = "imp_itcm3_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(9), -- .msg = "imp_dtcm0_mem0_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(11), -- .msg = "imp_dtcm0_mem1_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(13), -- .msg = "imp_dtcm1_mem0_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(15), -- .msg = "imp_dtcm1_mem1_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(17), -- .msg = "imp_itcm4_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(1), -+ .msg = "imp_itcm0_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "imp_itcm1_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "imp_itcm2_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "imp_itcm3_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "imp_dtcm0_mem0_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "imp_dtcm0_mem1_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "imp_dtcm1_mem0_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "imp_dtcm1_mem1_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "imp_itcm4_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error cmdq_mem_ecc_int[] = { -- { .int_msk = BIT(1), -- .msg = "cmdq_nic_rx_depth_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(3), -- .msg = "cmdq_nic_tx_depth_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(5), -- .msg = "cmdq_nic_rx_tail_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(7), -- .msg = "cmdq_nic_tx_tail_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(9), -- .msg = "cmdq_nic_rx_head_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(11), -- .msg = "cmdq_nic_tx_head_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(13), -- .msg = "cmdq_nic_rx_addr_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(15), -- .msg = "cmdq_nic_tx_addr_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(1), -+ .msg = "cmdq_nic_rx_depth_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "cmdq_nic_tx_depth_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "cmdq_nic_rx_tail_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "cmdq_nic_tx_tail_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "cmdq_nic_rx_head_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "cmdq_nic_tx_head_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "cmdq_nic_rx_addr_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "cmdq_nic_tx_addr_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error tqp_int_ecc_int[] = { -- { .int_msk = BIT(6), -- .msg = "tqp_int_cfg_even_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(7), -- .msg = "tqp_int_cfg_odd_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(8), -- .msg = "tqp_int_ctrl_even_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(9), -- .msg = "tqp_int_ctrl_odd_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(10), -- .msg = "tx_queue_scan_int_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(11), -- .msg = "rx_queue_scan_int_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(6), -+ .msg = "tqp_int_cfg_even_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "tqp_int_cfg_odd_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "tqp_int_ctrl_even_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "tqp_int_ctrl_odd_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(10), -+ .msg = "tx_queue_scan_int_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "rx_queue_scan_int_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error imp_rd_poison_int[] = { -- { .int_msk = BIT(0), -- .msg = "imp_rd_poison_int", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "imp_rd_poison_int", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - #define HNS3_SSU_MEM_ECC_ERR(x) \ -- { .int_msk = BIT(x), \ -- .msg = "ssu_mem" #x "_ecc_mbit_err", \ -- .reset_level = HNS3_GLOBAL_RESET } -+{ \ -+ .int_msk = BIT(x), \ -+ .msg = "ssu_mem" #x "_ecc_mbit_err", \ -+ .reset_level = HNS3_GLOBAL_RESET \ -+} - - static const struct hns3_hw_error ssu_ecc_multi_bit_int_0[] = { - HNS3_SSU_MEM_ECC_ERR(0), -@@ -344,722 +437,951 @@ static const struct hns3_hw_error ssu_ecc_multi_bit_int_0[] = { - }; - - static const struct hns3_hw_error ssu_ecc_multi_bit_int_1[] = { -- { .int_msk = BIT(0), -- .msg = "ssu_mem32_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "ssu_mem32_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ssu_common_ecc_int[] = { -- { .int_msk = BIT(0), -- .msg = "buf_sum_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(1), -- .msg = "ppp_mb_num_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = BIT(2), -- .msg = "ppp_mbid_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "ppp_rlt_mac_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "ppp_rlt_host_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "cks_edit_position_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "cks_edit_condition_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "vlan_edit_condition_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "vlan_num_ot_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "vlan_num_in_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "buf_sum_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "ppp_mb_num_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "ppp_mbid_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "ppp_rlt_mac_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "ppp_rlt_host_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "cks_edit_position_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "cks_edit_condition_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "vlan_edit_condition_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "vlan_num_ot_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "vlan_num_in_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error igu_int[] = { -- { .int_msk = BIT(0), -- .msg = "igu_rx_buf0_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "igu_rx_buf1_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "igu_rx_buf0_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "igu_rx_buf1_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error msix_ecc_int[] = { -- { .int_msk = BIT(1), -- .msg = "msix_nic_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(1), -+ .msg = "msix_nic_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppp_mpf_abnormal_int_st1[] = { -- { .int_msk = BIT(0), -- .msg = "vf_vlan_ad_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(1), -- .msg = "umv_mcast_group_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "umv_key_mem0_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "umv_key_mem1_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "umv_key_mem2_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "umv_key_mem3_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "umv_ad_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "rss_tc_mode_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "rss_idt_mem0_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "rss_idt_mem1_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(10), -- .msg = "rss_idt_mem2_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "rss_idt_mem3_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(12), -- .msg = "rss_idt_mem4_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "rss_idt_mem5_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(14), -- .msg = "rss_idt_mem6_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(15), -- .msg = "rss_idt_mem7_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(16), -- .msg = "rss_idt_mem8_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(17), -- .msg = "rss_idt_mem9_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(18), -- .msg = "rss_idt_mem10_ecc_m1bit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(19), -- .msg = "rss_idt_mem11_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(20), -- .msg = "rss_idt_mem12_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(21), -- .msg = "rss_idt_mem13_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(22), -- .msg = "rss_idt_mem14_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(23), -- .msg = "rss_idt_mem15_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(24), -- .msg = "port_vlan_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(25), -- .msg = "mcast_linear_table_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(26), -- .msg = "mcast_result_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(27), -- .msg = "flow_director_ad_mem0_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(28), -- .msg = "flow_director_ad_mem1_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(29), -- .msg = "rx_vlan_tag_memory_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(30), -- .msg = "Tx_UP_mapping_config_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "vf_vlan_ad_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "umv_mcast_group_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "umv_key_mem0_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "umv_key_mem1_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "umv_key_mem2_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "umv_key_mem3_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "umv_ad_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "rss_tc_mode_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "rss_idt_mem0_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "rss_idt_mem1_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(10), -+ .msg = "rss_idt_mem2_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "rss_idt_mem3_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(12), -+ .msg = "rss_idt_mem4_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "rss_idt_mem5_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(14), -+ .msg = "rss_idt_mem6_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "rss_idt_mem7_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(16), -+ .msg = "rss_idt_mem8_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "rss_idt_mem9_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(18), -+ .msg = "rss_idt_mem10_ecc_m1bit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(19), -+ .msg = "rss_idt_mem11_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(20), -+ .msg = "rss_idt_mem12_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(21), -+ .msg = "rss_idt_mem13_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(22), -+ .msg = "rss_idt_mem14_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(23), -+ .msg = "rss_idt_mem15_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(24), -+ .msg = "port_vlan_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(25), -+ .msg = "mcast_linear_table_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(26), -+ .msg = "mcast_result_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(27), -+ .msg = "flow_director_ad_mem0_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(28), -+ .msg = "flow_director_ad_mem1_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(29), -+ .msg = "rx_vlan_tag_memory_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(30), -+ .msg = "Tx_UP_mapping_config_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppp_mpf_abnormal_int_st3[] = { -- { .int_msk = BIT(0), -- .msg = "hfs_fifo_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(1), -- .msg = "rslt_descr_fifo_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "tx_vlan_tag_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "FD_CN0_memory_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "FD_CN1_memory_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "GRO_AD_memory_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "hfs_fifo_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "rslt_descr_fifo_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "tx_vlan_tag_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "FD_CN0_memory_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "FD_CN1_memory_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "GRO_AD_memory_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ppu_mpf_abnormal_int_st3[] = { -- { .int_msk = BIT(4), -- .msg = "gro_bd_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "gro_context_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "rx_stash_cfg_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "axi_rd_fbd_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(4), -+ .msg = "gro_bd_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "gro_context_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "rx_stash_cfg_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "axi_rd_fbd_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error tm_sch_int[] = { -- { .int_msk = BIT(1), -- .msg = "tm_sch_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "tm_sch_port_shap_sub_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "tm_sch_port_shap_sub_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "tm_sch_pg_pshap_sub_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "tm_sch_pg_pshap_sub_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "tm_sch_pg_cshap_sub_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "tm_sch_pg_cshap_sub_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "tm_sch_pri_pshap_sub_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "tm_sch_pri_pshap_sub_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(10), -- .msg = "tm_sch_pri_cshap_sub_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "tm_sch_pri_cshap_sub_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(12), -- .msg = "tm_sch_port_shap_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "tm_sch_port_shap_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(14), -- .msg = "tm_sch_pg_pshap_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(15), -- .msg = "tm_sch_pg_pshap_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(16), -- .msg = "tm_sch_pg_cshap_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(17), -- .msg = "tm_sch_pg_cshap_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(18), -- .msg = "tm_sch_pri_pshap_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(19), -- .msg = "tm_sch_pri_pshap_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(20), -- .msg = "tm_sch_pri_cshap_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(21), -- .msg = "tm_sch_pri_cshap_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(22), -- .msg = "tm_sch_rq_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(23), -- .msg = "tm_sch_rq_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(24), -- .msg = "tm_sch_nq_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(25), -- .msg = "tm_sch_nq_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(26), -- .msg = "tm_sch_roce_up_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(27), -- .msg = "tm_sch_roce_up_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(28), -- .msg = "tm_sch_rcb_byte_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(29), -- .msg = "tm_sch_rcb_byte_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(30), -- .msg = "tm_sch_ssu_byte_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(31), -- .msg = "tm_sch_ssu_byte_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(1), -+ .msg = "tm_sch_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "tm_sch_port_shap_sub_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "tm_sch_port_shap_sub_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "tm_sch_pg_pshap_sub_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "tm_sch_pg_pshap_sub_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "tm_sch_pg_cshap_sub_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "tm_sch_pg_cshap_sub_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "tm_sch_pri_pshap_sub_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "tm_sch_pri_pshap_sub_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(10), -+ .msg = "tm_sch_pri_cshap_sub_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "tm_sch_pri_cshap_sub_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(12), -+ .msg = "tm_sch_port_shap_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "tm_sch_port_shap_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(14), -+ .msg = "tm_sch_pg_pshap_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "tm_sch_pg_pshap_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(16), -+ .msg = "tm_sch_pg_cshap_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "tm_sch_pg_cshap_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(18), -+ .msg = "tm_sch_pri_pshap_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(19), -+ .msg = "tm_sch_pri_pshap_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(20), -+ .msg = "tm_sch_pri_cshap_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(21), -+ .msg = "tm_sch_pri_cshap_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(22), -+ .msg = "tm_sch_rq_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(23), -+ .msg = "tm_sch_rq_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(24), -+ .msg = "tm_sch_nq_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(25), -+ .msg = "tm_sch_nq_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(26), -+ .msg = "tm_sch_roce_up_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(27), -+ .msg = "tm_sch_roce_up_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(28), -+ .msg = "tm_sch_rcb_byte_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(29), -+ .msg = "tm_sch_rcb_byte_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(30), -+ .msg = "tm_sch_ssu_byte_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(31), -+ .msg = "tm_sch_ssu_byte_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error qcn_fifo_int[] = { -- { .int_msk = BIT(0), -- .msg = "qcn_shap_gp0_sch_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(1), -- .msg = "qcn_shap_gp0_sch_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "qcn_shap_gp1_sch_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "qcn_shap_gp1_sch_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "qcn_shap_gp2_sch_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "qcn_shap_gp2_sch_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "qcn_shap_gp3_sch_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "qcn_shap_gp3_sch_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "qcn_shap_gp0_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "qcn_shap_gp0_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(10), -- .msg = "qcn_shap_gp1_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "qcn_shap_gp1_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(12), -- .msg = "qcn_shap_gp2_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "qcn_shap_gp2_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(14), -- .msg = "qcn_shap_gp3_offset_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(15), -- .msg = "qcn_shap_gp3_offset_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(16), -- .msg = "qcn_byte_info_fifo_rd_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(17), -- .msg = "qcn_byte_info_fifo_wr_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "qcn_shap_gp0_sch_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "qcn_shap_gp0_sch_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "qcn_shap_gp1_sch_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "qcn_shap_gp1_sch_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "qcn_shap_gp2_sch_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "qcn_shap_gp2_sch_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "qcn_shap_gp3_sch_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "qcn_shap_gp3_sch_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "qcn_shap_gp0_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "qcn_shap_gp0_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(10), -+ .msg = "qcn_shap_gp1_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "qcn_shap_gp1_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(12), -+ .msg = "qcn_shap_gp2_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "qcn_shap_gp2_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(14), -+ .msg = "qcn_shap_gp3_offset_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "qcn_shap_gp3_offset_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(16), -+ .msg = "qcn_byte_info_fifo_rd_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "qcn_byte_info_fifo_wr_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error qcn_ecc_int[] = { -- { .int_msk = BIT(1), -- .msg = "qcn_byte_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "qcn_time_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "qcn_fb_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "qcn_link_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "qcn_rate_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "qcn_tmplt_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "qcn_shap_cfg_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(15), -- .msg = "qcn_gp0_barrel_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(17), -- .msg = "qcn_gp1_barrel_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(19), -- .msg = "qcn_gp2_barrel_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(21), -- .msg = "qcn_gp3_barral_mem_ecc_mbit_err", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(1), -+ .msg = "qcn_byte_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "qcn_time_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "qcn_fb_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "qcn_link_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "qcn_rate_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "qcn_tmplt_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "qcn_shap_cfg_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "qcn_gp0_barrel_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "qcn_gp1_barrel_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(19), -+ .msg = "qcn_gp2_barrel_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(21), -+ .msg = "qcn_gp3_barral_mem_ecc_mbit_err", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ncsi_ecc_int[] = { -- { .int_msk = BIT(1), -- .msg = "ncsi_tx_ecc_mbit_err", -- .reset_level = HNS3_NONE_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(1), -+ .msg = "ncsi_tx_ecc_mbit_err", -+ .reset_level = HNS3_NONE_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ssu_fifo_overflow_int[] = { -- { .int_msk = BIT(0), -- .msg = "ig_mac_inf_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(1), -- .msg = "ig_host_inf_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "ig_roc_buf_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "ig_host_data_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "ig_host_key_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "tx_qcn_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "rx_qcn_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "tx_pf_rd_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "rx_pf_rd_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(9), -- .msg = "qm_eof_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(10), -- .msg = "mb_rlt_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "dup_uncopy_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(12), -- .msg = "dup_cnt_rd_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "dup_cnt_drop_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(14), -- .msg = "dup_cnt_wrb_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(15), -- .msg = "host_cmd_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(16), -- .msg = "mac_cmd_fifo_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(17), -- .msg = "host_cmd_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(18), -- .msg = "mac_cmd_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(19), -- .msg = "dup_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(20), -- .msg = "out_queue_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(21), -- .msg = "bank2_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(22), -- .msg = "bank1_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(23), -- .msg = "bank0_bitmap_empty_int", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "ig_mac_inf_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "ig_host_inf_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "ig_roc_buf_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "ig_host_data_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "ig_host_key_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "tx_qcn_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "rx_qcn_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "tx_pf_rd_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "rx_pf_rd_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(9), -+ .msg = "qm_eof_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(10), -+ .msg = "mb_rlt_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "dup_uncopy_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(12), -+ .msg = "dup_cnt_rd_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "dup_cnt_drop_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(14), -+ .msg = "dup_cnt_wrb_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(15), -+ .msg = "host_cmd_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(16), -+ .msg = "mac_cmd_fifo_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(17), -+ .msg = "host_cmd_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(18), -+ .msg = "mac_cmd_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(19), -+ .msg = "dup_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(20), -+ .msg = "out_queue_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(21), -+ .msg = "bank2_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(22), -+ .msg = "bank1_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(23), -+ .msg = "bank0_bitmap_empty_int", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ssu_ets_tcg_int[] = { -- { .int_msk = BIT(0), -- .msg = "ets_rd_int_rx_tcg", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(1), -- .msg = "ets_wr_int_rx_tcg", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "ets_rd_int_tx_tcg", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "ets_wr_int_tx_tcg", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "ets_rd_int_rx_tcg", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "ets_wr_int_rx_tcg", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "ets_rd_int_tx_tcg", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "ets_wr_int_tx_tcg", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error igu_egu_tnl_int[] = { -- { .int_msk = BIT(0), -- .msg = "rx_buf_overflow", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(1), -- .msg = "rx_stp_fifo_overflow", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "rx_stp_fifo_underflow", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "tx_buf_overflow", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "tx_buf_underrun", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "rx_stp_buf_overflow", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "rx_buf_overflow", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "rx_stp_fifo_overflow", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "rx_stp_fifo_underflow", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "tx_buf_overflow", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "tx_buf_underrun", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "rx_stp_buf_overflow", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error ssu_port_based_err_int[] = { -- { .int_msk = BIT(0), -- .msg = "roc_pkt_without_key_port", -- .reset_level = HNS3_FUNC_RESET }, -- { .int_msk = BIT(1), -- .msg = "tpu_pkt_without_key_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(2), -- .msg = "igu_pkt_without_key_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(3), -- .msg = "roc_eof_mis_match_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(4), -- .msg = "tpu_eof_mis_match_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(5), -- .msg = "igu_eof_mis_match_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(6), -- .msg = "roc_sof_mis_match_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(7), -- .msg = "tpu_sof_mis_match_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(8), -- .msg = "igu_sof_mis_match_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(11), -- .msg = "ets_rd_int_rx_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(12), -- .msg = "ets_wr_int_rx_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(13), -- .msg = "ets_rd_int_tx_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = BIT(14), -- .msg = "ets_wr_int_tx_port", -- .reset_level = HNS3_GLOBAL_RESET }, -- { .int_msk = 0, -- .msg = NULL, -- .reset_level = HNS3_NONE_RESET} -+ { -+ .int_msk = BIT(0), -+ .msg = "roc_pkt_without_key_port", -+ .reset_level = HNS3_FUNC_RESET -+ }, { -+ .int_msk = BIT(1), -+ .msg = "tpu_pkt_without_key_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(2), -+ .msg = "igu_pkt_without_key_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(3), -+ .msg = "roc_eof_mis_match_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(4), -+ .msg = "tpu_eof_mis_match_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(5), -+ .msg = "igu_eof_mis_match_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(6), -+ .msg = "roc_sof_mis_match_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(7), -+ .msg = "tpu_sof_mis_match_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(8), -+ .msg = "igu_sof_mis_match_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(11), -+ .msg = "ets_rd_int_rx_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(12), -+ .msg = "ets_wr_int_rx_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(13), -+ .msg = "ets_rd_int_tx_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = BIT(14), -+ .msg = "ets_wr_int_tx_port", -+ .reset_level = HNS3_GLOBAL_RESET -+ }, { -+ .int_msk = 0, -+ .msg = NULL, -+ .reset_level = HNS3_NONE_RESET -+ } - }; - - static const struct hns3_hw_error_desc mpf_ras_err_tbl[] = { -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = "IMP_TCM_ECC_INT_STS", -- .hw_err = imp_tcm_ecc_int }, -- { .desc_offset = 0, -- .data_offset = 1, -- .msg = "CMDQ_MEM_ECC_INT_STS", -- .hw_err = cmdq_mem_ecc_int }, -- { .desc_offset = 0, -- .data_offset = 2, -- .msg = "IMP_RD_POISON_INT_STS", -- .hw_err = imp_rd_poison_int }, -- { .desc_offset = 0, -- .data_offset = 3, -- .msg = "TQP_INT_ECC_INT_STS", -- .hw_err = tqp_int_ecc_int }, -- { .desc_offset = 0, -- .data_offset = 4, -- .msg = "MSIX_ECC_INT_STS", -- .hw_err = msix_ecc_int }, -- { .desc_offset = 2, -- .data_offset = 2, -- .msg = "SSU_ECC_MULTI_BIT_INT_0", -- .hw_err = ssu_ecc_multi_bit_int_0 }, -- { .desc_offset = 2, -- .data_offset = 3, -- .msg = "SSU_ECC_MULTI_BIT_INT_1", -- .hw_err = ssu_ecc_multi_bit_int_1 }, -- { .desc_offset = 2, -- .data_offset = 4, -- .msg = "SSU_COMMON_ERR_INT", -- .hw_err = ssu_common_ecc_int }, -- { .desc_offset = 3, -- .data_offset = 0, -- .msg = "IGU_INT_STS", -- .hw_err = igu_int }, -- { .desc_offset = 4, -- .data_offset = 1, -- .msg = "PPP_MPF_ABNORMAL_INT_ST1", -- .hw_err = ppp_mpf_abnormal_int_st1 }, -- { .desc_offset = 4, -- .data_offset = 3, -- .msg = "PPP_MPF_ABNORMAL_INT_ST3", -- .hw_err = ppp_mpf_abnormal_int_st3 }, -- { .desc_offset = 5, -- .data_offset = 1, -- .msg = "PPU_MPF_ABNORMAL_INT_ST1", -- .hw_err = ppu_mpf_abnormal_int_st1 }, -- { .desc_offset = 5, -- .data_offset = 2, -- .msg = "PPU_MPF_ABNORMAL_INT_ST2_RAS", -- .hw_err = ppu_mpf_abnormal_int_st2_ras }, -- { .desc_offset = 5, -- .data_offset = 3, -- .msg = "PPU_MPF_ABNORMAL_INT_ST3", -- .hw_err = ppu_mpf_abnormal_int_st3 }, -- { .desc_offset = 6, -- .data_offset = 0, -- .msg = "TM_SCH_RINT", -- .hw_err = tm_sch_int }, -- { .desc_offset = 7, -- .data_offset = 0, -- .msg = "QCN_FIFO_RINT", -- .hw_err = qcn_fifo_int }, -- { .desc_offset = 7, -- .data_offset = 1, -- .msg = "QCN_ECC_RINT", -- .hw_err = qcn_ecc_int }, -- { .desc_offset = 9, -- .data_offset = 0, -- .msg = "NCSI_ECC_INT_RPT", -- .hw_err = ncsi_ecc_int }, -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = NULL, -- .hw_err = NULL } -+ { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = "IMP_TCM_ECC_INT_STS", -+ .hw_err = imp_tcm_ecc_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 1, -+ .msg = "CMDQ_MEM_ECC_INT_STS", -+ .hw_err = cmdq_mem_ecc_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 2, -+ .msg = "IMP_RD_POISON_INT_STS", -+ .hw_err = imp_rd_poison_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 3, -+ .msg = "TQP_INT_ECC_INT_STS", -+ .hw_err = tqp_int_ecc_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 4, -+ .msg = "MSIX_ECC_INT_STS", -+ .hw_err = msix_ecc_int -+ }, { -+ .desc_offset = 2, -+ .data_offset = 2, -+ .msg = "SSU_ECC_MULTI_BIT_INT_0", -+ .hw_err = ssu_ecc_multi_bit_int_0 -+ }, { -+ .desc_offset = 2, -+ .data_offset = 3, -+ .msg = "SSU_ECC_MULTI_BIT_INT_1", -+ .hw_err = ssu_ecc_multi_bit_int_1 -+ }, { -+ .desc_offset = 2, -+ .data_offset = 4, -+ .msg = "SSU_COMMON_ERR_INT", -+ .hw_err = ssu_common_ecc_int -+ }, { -+ .desc_offset = 3, -+ .data_offset = 0, -+ .msg = "IGU_INT_STS", -+ .hw_err = igu_int -+ }, { -+ .desc_offset = 4, -+ .data_offset = 1, -+ .msg = "PPP_MPF_ABNORMAL_INT_ST1", -+ .hw_err = ppp_mpf_abnormal_int_st1 -+ }, { -+ .desc_offset = 4, -+ .data_offset = 3, -+ .msg = "PPP_MPF_ABNORMAL_INT_ST3", -+ .hw_err = ppp_mpf_abnormal_int_st3 -+ }, { -+ .desc_offset = 5, -+ .data_offset = 1, -+ .msg = "PPU_MPF_ABNORMAL_INT_ST1", -+ .hw_err = ppu_mpf_abnormal_int_st1 -+ }, { -+ .desc_offset = 5, -+ .data_offset = 2, -+ .msg = "PPU_MPF_ABNORMAL_INT_ST2_RAS", -+ .hw_err = ppu_mpf_abnormal_int_st2_ras -+ }, { -+ .desc_offset = 5, -+ .data_offset = 3, -+ .msg = "PPU_MPF_ABNORMAL_INT_ST3", -+ .hw_err = ppu_mpf_abnormal_int_st3 -+ }, { -+ .desc_offset = 6, -+ .data_offset = 0, -+ .msg = "TM_SCH_RINT", -+ .hw_err = tm_sch_int -+ }, { -+ .desc_offset = 7, -+ .data_offset = 0, -+ .msg = "QCN_FIFO_RINT", -+ .hw_err = qcn_fifo_int -+ }, { -+ .desc_offset = 7, -+ .data_offset = 1, -+ .msg = "QCN_ECC_RINT", -+ .hw_err = qcn_ecc_int -+ }, { -+ .desc_offset = 9, -+ .data_offset = 0, -+ .msg = "NCSI_ECC_INT_RPT", -+ .hw_err = ncsi_ecc_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = NULL, -+ .hw_err = NULL -+ } - }; - - static const struct hns3_hw_error_desc pf_ras_err_tbl[] = { -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = "SSU_PORT_BASED_ERR_INT_RAS", -- .hw_err = ssu_port_based_err_int }, -- { .desc_offset = 0, -- .data_offset = 1, -- .msg = "SSU_FIFO_OVERFLOW_INT", -- .hw_err = ssu_fifo_overflow_int }, -- { .desc_offset = 0, -- .data_offset = 2, -- .msg = "SSU_ETS_TCG_INT", -- .hw_err = ssu_ets_tcg_int }, -- { .desc_offset = 1, -- .data_offset = 0, -- .msg = "IGU_EGU_TNL_INT_STS", -- .hw_err = igu_egu_tnl_int }, -- { .desc_offset = 3, -- .data_offset = 0, -- .msg = "PPU_PF_ABNORMAL_INT_ST_RAS", -- .hw_err = ppu_pf_abnormal_int_ras }, -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = NULL, -- .hw_err = NULL } -+ { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = "SSU_PORT_BASED_ERR_INT_RAS", -+ .hw_err = ssu_port_based_err_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 1, -+ .msg = "SSU_FIFO_OVERFLOW_INT", -+ .hw_err = ssu_fifo_overflow_int -+ }, { -+ .desc_offset = 0, -+ .data_offset = 2, -+ .msg = "SSU_ETS_TCG_INT", -+ .hw_err = ssu_ets_tcg_int -+ }, { -+ .desc_offset = 1, -+ .data_offset = 0, -+ .msg = "IGU_EGU_TNL_INT_STS", -+ .hw_err = igu_egu_tnl_int -+ }, { -+ .desc_offset = 3, -+ .data_offset = 0, -+ .msg = "PPU_PF_ABNORMAL_INT_ST_RAS", -+ .hw_err = ppu_pf_abnormal_int_ras -+ }, { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = NULL, -+ .hw_err = NULL -+ } - }; - - static const struct hns3_hw_error_desc mpf_msix_err_tbl[] = { -- { .desc_offset = 1, -- .data_offset = 0, -- .msg = "MAC_AFIFO_TNL_INT_R", -- .hw_err = mac_afifo_tnl_int }, -- { .desc_offset = 5, -- .data_offset = 2, -- .msg = "PPU_MPF_ABNORMAL_INT_ST2_MSIX", -- .hw_err = ppu_mpf_abnormal_int_st2_msix }, -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = NULL, -- .hw_err = NULL } -+ { -+ .desc_offset = 1, -+ .data_offset = 0, -+ .msg = "MAC_AFIFO_TNL_INT_R", -+ .hw_err = mac_afifo_tnl_int -+ }, { -+ .desc_offset = 5, -+ .data_offset = 2, -+ .msg = "PPU_MPF_ABNORMAL_INT_ST2_MSIX", -+ .hw_err = ppu_mpf_abnormal_int_st2_msix -+ }, { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = NULL, -+ .hw_err = NULL -+ } - }; - - static const struct hns3_hw_error_desc pf_msix_err_tbl[] = { -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = "SSU_PORT_BASED_ERR_INT_MSIX", -- .hw_err = ssu_port_based_pf_int }, -- { .desc_offset = 2, -- .data_offset = 0, -- .msg = "PPP_PF_ABNORMAL_INT_ST0", -- .hw_err = ppp_pf_abnormal_int }, -- { .desc_offset = 3, -- .data_offset = 0, -- .msg = "PPU_PF_ABNORMAL_INT_ST_MSIX", -- .hw_err = ppu_pf_abnormal_int_msix }, -- { .desc_offset = 0, -- .data_offset = 0, -- .msg = NULL, -- .hw_err = NULL } -+ { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = "SSU_PORT_BASED_ERR_INT_MSIX", -+ .hw_err = ssu_port_based_pf_int -+ }, { -+ .desc_offset = 2, -+ .data_offset = 0, -+ .msg = "PPP_PF_ABNORMAL_INT_ST0", -+ .hw_err = ppp_pf_abnormal_int -+ }, { -+ .desc_offset = 3, -+ .data_offset = 0, -+ .msg = "PPU_PF_ABNORMAL_INT_ST_MSIX", -+ .hw_err = ppu_pf_abnormal_int_msix -+ }, { -+ .desc_offset = 0, -+ .data_offset = 0, -+ .msg = NULL, -+ .hw_err = NULL -+ } - }; - - enum hns3_hw_err_type { --- -2.7.4 - diff --git a/0062-net-hns3-delete-redundant-xstats-RAS-statistics.patch b/0062-net-hns3-delete-redundant-xstats-RAS-statistics.patch deleted file mode 100644 index d2cc6ad..0000000 --- a/0062-net-hns3-delete-redundant-xstats-RAS-statistics.patch +++ /dev/null @@ -1,287 +0,0 @@ -From 95824ab5efc3996a682c57af118571fdccc5f677 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Tue, 23 Mar 2021 19:21:03 +0800 -Subject: [PATCH 062/189] net/hns3: delete redundant xstats RAS statistics - -The current RAS code stores the reported RAS statistics in xstats. -This part of statistics is of little use in practice, and because -of the change of RAS scheme on Kunpeng930, the driver can not -obtain the RAS information any more, so this patch delete these -redundant RAS statistics. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 - - drivers/net/hns3/hns3_ethdev.h | 35 --------------- - drivers/net/hns3/hns3_intr.c | 1 - - drivers/net/hns3/hns3_stats.c | 100 +---------------------------------------- - drivers/net/hns3/hns3_stats.h | 1 - - 5 files changed, 1 insertion(+), 138 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 5da00b3..7bdc6f7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5768,14 +5768,12 @@ hns3_record_imp_error(struct hns3_adapter *hns) - reg_val = hns3_read_dev(hw, HNS3_VECTOR0_OTER_EN_REG); - if (hns3_get_bit(reg_val, HNS3_VECTOR0_IMP_RD_POISON_B)) { - hns3_warn(hw, "Detected IMP RD poison!"); -- hns3_error_int_stats_add(hns, "IMP_RD_POISON_INT_STS"); - hns3_set_bit(reg_val, HNS3_VECTOR0_IMP_RD_POISON_B, 0); - hns3_write_dev(hw, HNS3_VECTOR0_OTER_EN_REG, reg_val); - } - - if (hns3_get_bit(reg_val, HNS3_VECTOR0_IMP_CMDQ_ERR_B)) { - hns3_warn(hw, "Detected IMP CMDQ error!"); -- hns3_error_int_stats_add(hns, "CMDQ_MEM_ECC_INT_STS"); - hns3_set_bit(reg_val, HNS3_VECTOR0_IMP_CMDQ_ERR_B, 0); - hns3_write_dev(hw, HNS3_VECTOR0_OTER_EN_REG, reg_val); - } -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index dc27bb1..dfe0c59 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -561,38 +561,6 @@ struct hns3_hw { - #define HNS3_FLAG_TC_BASE_SCH_MODE 1 - #define HNS3_FLAG_VNET_BASE_SCH_MODE 2 - --struct hns3_err_msix_intr_stats { -- uint64_t mac_afifo_tnl_int_cnt; -- uint64_t ppu_mpf_abn_int_st2_msix_cnt; -- uint64_t ssu_port_based_pf_int_cnt; -- uint64_t ppp_pf_abnormal_int_cnt; -- uint64_t ppu_pf_abnormal_int_msix_cnt; -- -- uint64_t imp_tcm_ecc_int_cnt; -- uint64_t cmdq_mem_ecc_int_cnt; -- uint64_t imp_rd_poison_int_cnt; -- uint64_t tqp_int_ecc_int_cnt; -- uint64_t msix_ecc_int_cnt; -- uint64_t ssu_ecc_multi_bit_int_0_cnt; -- uint64_t ssu_ecc_multi_bit_int_1_cnt; -- uint64_t ssu_common_ecc_int_cnt; -- uint64_t igu_int_cnt; -- uint64_t ppp_mpf_abnormal_int_st1_cnt; -- uint64_t ppp_mpf_abnormal_int_st3_cnt; -- uint64_t ppu_mpf_abnormal_int_st1_cnt; -- uint64_t ppu_mpf_abn_int_st2_ras_cnt; -- uint64_t ppu_mpf_abnormal_int_st3_cnt; -- uint64_t tm_sch_int_cnt; -- uint64_t qcn_fifo_int_cnt; -- uint64_t qcn_ecc_int_cnt; -- uint64_t ncsi_ecc_int_cnt; -- uint64_t ssu_port_based_err_int_cnt; -- uint64_t ssu_fifo_overflow_int_cnt; -- uint64_t ssu_ets_tcg_int_cnt; -- uint64_t igu_egu_tnl_int_cnt; -- uint64_t ppu_pf_abnormal_int_ras_cnt; --}; -- - /* vlan entry information. */ - struct hns3_user_vlan_table { - LIST_ENTRY(hns3_user_vlan_table) next; -@@ -738,9 +706,6 @@ struct hns3_pf { - uint16_t max_umv_size; - uint16_t used_umv_size; - -- /* Statistics information for abnormal interrupt */ -- struct hns3_err_msix_intr_stats abn_int_stats; -- - bool support_sfp_query; - uint32_t fec_mode; /* current FEC mode for ethdev */ - -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 265dae8..c259f2e 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1838,7 +1838,6 @@ hns3_find_highest_level(struct hns3_adapter *hns, const char *reg, - reset_level = err->reset_level; - need_reset = true; - } -- hns3_error_int_stats_add(hns, reg); - } - err++; - } -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 941c75f..7cda36c 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -201,65 +201,6 @@ static const struct hns3_xstats_name_offset hns3_mac_strings[] = { - HNS3_MAC_STATS_OFFSET(mac_rx_send_app_bad_pkt_num)} - }; - --static const struct hns3_xstats_name_offset hns3_error_int_stats_strings[] = { -- {"MAC_AFIFO_TNL_INT_R", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(mac_afifo_tnl_int_cnt)}, -- {"PPU_MPF_ABNORMAL_INT_ST2_MSIX", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abn_int_st2_msix_cnt)}, -- {"SSU_PORT_BASED_ERR_INT_MSIX", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_port_based_pf_int_cnt)}, -- {"PPP_PF_ABNORMAL_INT_ST0", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppp_pf_abnormal_int_cnt)}, -- {"PPU_PF_ABNORMAL_INT_ST_MSIX", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_pf_abnormal_int_msix_cnt)}, -- {"IMP_TCM_ECC_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(imp_tcm_ecc_int_cnt)}, -- {"CMDQ_MEM_ECC_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(cmdq_mem_ecc_int_cnt)}, -- {"IMP_RD_POISON_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(imp_rd_poison_int_cnt)}, -- {"TQP_INT_ECC_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(tqp_int_ecc_int_cnt)}, -- {"MSIX_ECC_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(msix_ecc_int_cnt)}, -- {"SSU_ECC_MULTI_BIT_INT_0", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_ecc_multi_bit_int_0_cnt)}, -- {"SSU_ECC_MULTI_BIT_INT_1", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_ecc_multi_bit_int_1_cnt)}, -- {"SSU_COMMON_ERR_INT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_common_ecc_int_cnt)}, -- {"IGU_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(igu_int_cnt)}, -- {"PPP_MPF_ABNORMAL_INT_ST1", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppp_mpf_abnormal_int_st1_cnt)}, -- {"PPP_MPF_ABNORMAL_INT_ST3", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppp_mpf_abnormal_int_st3_cnt)}, -- {"PPU_MPF_ABNORMAL_INT_ST1", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abnormal_int_st1_cnt)}, -- {"PPU_MPF_ABNORMAL_INT_ST2_RAS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abn_int_st2_ras_cnt)}, -- {"PPU_MPF_ABNORMAL_INT_ST3", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_mpf_abnormal_int_st3_cnt)}, -- {"TM_SCH_RINT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(tm_sch_int_cnt)}, -- {"QCN_FIFO_RINT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(qcn_fifo_int_cnt)}, -- {"QCN_ECC_RINT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(qcn_ecc_int_cnt)}, -- {"NCSI_ECC_INT_RPT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ncsi_ecc_int_cnt)}, -- {"SSU_PORT_BASED_ERR_INT_RAS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_port_based_err_int_cnt)}, -- {"SSU_FIFO_OVERFLOW_INT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_fifo_overflow_int_cnt)}, -- {"SSU_ETS_TCG_INT", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ssu_ets_tcg_int_cnt)}, -- {"IGU_EGU_TNL_INT_STS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(igu_egu_tnl_int_cnt)}, -- {"PPU_PF_ABNORMAL_INT_ST_RAS", -- HNS3_ERR_INT_STATS_FIELD_OFFSET(ppu_pf_abnormal_int_ras_cnt)}, --}; -- - /* The statistic of reset */ - static const struct hns3_xstats_name_offset hns3_reset_stats_strings[] = { - {"REQ_RESET_CNT", -@@ -333,9 +274,6 @@ static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { - #define HNS3_NUM_MAC_STATS (sizeof(hns3_mac_strings) / \ - sizeof(hns3_mac_strings[0])) - --#define HNS3_NUM_ERROR_INT_XSTATS (sizeof(hns3_error_int_stats_strings) / \ -- sizeof(hns3_error_int_stats_strings[0])) -- - #define HNS3_NUM_RESET_XSTATS (sizeof(hns3_reset_stats_strings) / \ - sizeof(hns3_reset_stats_strings[0])) - -@@ -363,7 +301,7 @@ static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { - #define HNS3_NUM_IMISSED_XSTATS (sizeof(hns3_imissed_stats_strings) / \ - sizeof(hns3_imissed_stats_strings[0])) - --#define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + HNS3_NUM_ERROR_INT_XSTATS + \ -+#define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + \ - HNS3_NUM_RESET_XSTATS + HNS3_NUM_IMISSED_XSTATS) - - static void hns3_tqp_stats_clear(struct hns3_hw *hw); -@@ -750,23 +688,6 @@ hns3_queue_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - } - } - --void --hns3_error_int_stats_add(struct hns3_adapter *hns, const char *err) --{ -- struct hns3_pf *pf = &hns->pf; -- uint16_t i; -- char *addr; -- -- for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) { -- if (strcmp(hns3_error_int_stats_strings[i].name, err) == 0) { -- addr = (char *)&pf->abn_int_stats + -- hns3_error_int_stats_strings[i].offset; -- *(uint64_t *)addr += 1; -- break; -- } -- } --} -- - static void - hns3_rxq_dfx_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - int *count) -@@ -932,7 +853,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - unsigned int n) - { - struct hns3_adapter *hns = dev->data->dev_private; -- struct hns3_pf *pf = &hns->pf; - struct hns3_hw *hw = &hns->hw; - struct hns3_rx_missed_stats *imissed_stats = &hw->imissed_stats; - struct hns3_mac_stats *mac_stats = &hw->mac_stats; -@@ -986,13 +906,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - count++; - } - -- for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) { -- addr = (char *)&pf->abn_int_stats + -- hns3_error_int_stats_strings[i].offset; -- xstats[count].value = *(uint64_t *)addr; -- xstats[count].id = count; -- count++; -- } - } - - /* Get the reset stat */ -@@ -1134,13 +1047,6 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - "%s", hns3_imissed_stats_strings[i].name); - count++; - } -- -- for (i = 0; i < HNS3_NUM_ERROR_INT_XSTATS; i++) { -- snprintf(xstats_names[count].name, -- sizeof(xstats_names[count].name), -- "%s", hns3_error_int_stats_strings[i].name); -- count++; -- } - } - for (i = 0; i < HNS3_NUM_RESET_XSTATS; i++) { - snprintf(xstats_names[count].name, -@@ -1358,7 +1264,6 @@ int - hns3_dev_xstats_reset(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; -- struct hns3_pf *pf = &hns->pf; - int ret; - - /* Clear tqp stats */ -@@ -1379,9 +1284,6 @@ hns3_dev_xstats_reset(struct rte_eth_dev *dev) - if (ret) - return ret; - -- /* Clear error stats */ -- memset(&pf->abn_int_stats, 0, sizeof(struct hns3_err_msix_intr_stats)); -- - return 0; - } - -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index 70a9c5b..8ea69b4 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -164,7 +164,6 @@ int hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - const uint64_t *ids, - uint32_t size); - int hns3_stats_reset(struct rte_eth_dev *dev); --void hns3_error_int_stats_add(struct hns3_adapter *hns, const char *err); - int hns3_tqp_stats_init(struct hns3_hw *hw); - void hns3_tqp_stats_uninit(struct hns3_hw *hw); - int hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear); --- -2.7.4 - diff --git a/0063-net-hns3-support-imissed-stats-for-PF-VF.patch b/0063-net-hns3-support-imissed-stats-for-PF-VF.patch deleted file mode 100644 index 510283c..0000000 --- a/0063-net-hns3-support-imissed-stats-for-PF-VF.patch +++ /dev/null @@ -1,516 +0,0 @@ -From e8d6fcbfdb76309172f36de8b046c5543a4f4cf1 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Tue, 23 Mar 2021 19:21:04 +0800 -Subject: [PATCH 063/189] net/hns3: support imissed stats for PF/VF - -This patch added function level imissed stats for PF and VF. In -Kunpeng920, imissed is supported, only including RPU drop stats in PF. -In kunpeng930, imissed is supported,including RPU drop stats and SSU -drop stats in PF. - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 13 +++ - drivers/net/hns3/hns3_ethdev.c | 2 + - drivers/net/hns3/hns3_ethdev.h | 21 ++++ - drivers/net/hns3/hns3_ethdev_vf.c | 9 ++ - drivers/net/hns3/hns3_regs.h | 2 + - drivers/net/hns3/hns3_stats.c | 234 +++++++++++++++++++++++++++++--------- - drivers/net/hns3/hns3_stats.h | 1 + - 7 files changed, 230 insertions(+), 52 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 094bf7e..e704d0c 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -111,6 +111,8 @@ enum hns3_opcode_type { - - HNS3_OPC_QUERY_DEV_SPECS = 0x0050, - -+ HNS3_OPC_SSU_DROP_REG = 0x0065, -+ - /* MAC command */ - HNS3_OPC_CONFIG_MAC_MODE = 0x0301, - HNS3_OPC_QUERY_LINK_STATUS = 0x0307, -@@ -957,6 +959,17 @@ struct hns3_query_rpu_cmd { - uint32_t rsv2[2]; - }; - -+#define HNS3_OPC_SSU_DROP_REG_NUM 2 -+ -+struct hns3_query_ssu_cmd { -+ uint8_t rxtx; -+ uint8_t rsv[3]; -+ uint32_t full_drop_cnt; -+ uint32_t part_drop_cnt; -+ uint32_t oq_drop_cnt; -+ uint32_t rev1[2]; -+}; -+ - #define HNS3_MAX_TQP_NUM_HIP08_PF 64 - #define HNS3_DEFAULT_TX_BUF 0x4000 /* 16k bytes */ - #define HNS3_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7bdc6f7..b5057da 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -3122,6 +3122,7 @@ hns3_get_capability(struct hns3_hw *hw) - hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US; - hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM; - hw->vlan_mode = HNS3_SW_SHIFT_AND_DISCARD_MODE; -+ hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE1; - hw->min_tx_pkt_len = HNS3_HIP08_MIN_TX_PKT_LEN; - pf->tqp_config_mode = HNS3_FIXED_MAX_TQP_NUM_MODE; - hw->rss_info.ipv6_sctp_offload_supported = false; -@@ -3140,6 +3141,7 @@ hns3_get_capability(struct hns3_hw *hw) - hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_1US; - hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM; - hw->vlan_mode = HNS3_HW_SHIFT_AND_DISCARD_MODE; -+ hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2; - hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN; - pf->tqp_config_mode = HNS3_FLEX_MAX_TQP_NUM_MODE; - hw->rss_info.ipv6_sctp_offload_supported = true; -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index dfe0c59..01561cc 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -426,6 +426,9 @@ struct hns3_queue_intr { - #define HNS3_TSO_SW_CAL_PSEUDO_H_CSUM 0 - #define HNS3_TSO_HW_CAL_PSEUDO_H_CSUM 1 - -+#define HNS3_PKTS_DROP_STATS_MODE1 0 -+#define HNS3_PKTS_DROP_STATS_MODE2 1 -+ - struct hns3_hw { - struct rte_eth_dev_data *data; - void *io_base; -@@ -544,6 +547,24 @@ struct hns3_hw { - * port won't be copied to the function which has set promisc mode. - */ - uint8_t promisc_mode; -+ -+ /* -+ * drop_stats_mode mode. -+ * value range: -+ * HNS3_PKTS_DROP_STATS_MODE1/HNS3_PKTS_DROP_STATS_MODE2 -+ * -+ * - HNS3_PKTS_DROP_STATS_MODE1 -+ * This mode for kunpeng920. In this mode, port level imissed stats -+ * is supported. It only includes RPU drop stats. -+ * -+ * - HNS3_PKTS_DROP_STATS_MODE2 -+ * This mode for kunpeng930. In this mode, imissed stats and oerrors -+ * stats is supported. Function level imissed stats is supported. It -+ * includes RPU drop stats in VF, and includes both RPU drop stats -+ * and SSU drop stats in PF. Oerror stats is also supported in PF. -+ */ -+ uint8_t drop_stats_mode; -+ - uint8_t max_non_tso_bd_num; /* max BD number of one non-TSO packet */ - - struct hns3_port_base_vlan_config port_base_vlan_cfg; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 35c42ca..c567dff 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1221,6 +1221,7 @@ hns3vf_get_capability(struct hns3_hw *hw) - hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_RSV_ONE; - hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_2US; - hw->tso_mode = HNS3_TSO_SW_CAL_PSEUDO_H_CSUM; -+ hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE1; - 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; -@@ -1238,6 +1239,7 @@ hns3vf_get_capability(struct hns3_hw *hw) - hw->intr.mapping_mode = HNS3_INTR_MAPPING_VEC_ALL; - hw->intr.gl_unit = HNS3_INTR_COALESCE_GL_UINT_1US; - hw->tso_mode = HNS3_TSO_HW_CAL_PSEUDO_H_CSUM; -+ hw->drop_stats_mode = HNS3_PKTS_DROP_STATS_MODE2; - hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN; - hw->rss_info.ipv6_sctp_offload_supported = true; - hw->promisc_mode = HNS3_LIMIT_PROMISC_MODE; -@@ -1875,6 +1877,13 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) - if (ret) - goto err_get_config; - -+ /* Hardware statistics of imissed registers cleared. */ -+ ret = hns3_update_imissed_stats(hw, true); -+ if (ret) { -+ hns3_err(hw, "clear imissed stats failed, ret = %d", ret); -+ goto err_set_tc_queue; -+ } -+ - ret = hns3vf_set_tc_queue_mapping(hns, hw->tqps_num, hw->tqps_num); - if (ret) { - PMD_INIT_LOG(ERR, "failed to set tc info, ret = %d.", ret); -diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h -index 0540554..e141fe1 100644 ---- a/drivers/net/hns3/hns3_regs.h -+++ b/drivers/net/hns3/hns3_regs.h -@@ -36,6 +36,8 @@ - #define HNS3_GLOBAL_RESET_REG 0x20A00 - #define HNS3_FUN_RST_ING 0x20C00 - #define HNS3_GRO_EN_REG 0x28000 -+ -+#define HNS3_RPU_DROP_CNT_REG 0x28004 - #define HNS3_RXD_ADV_LAYOUT_EN_REG 0x28008 - - /* Vector0 register bits for reset */ -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 7cda36c..e802c0b 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -269,6 +269,8 @@ static const struct hns3_xstats_name_offset hns3_tx_queue_strings[] = { - static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { - {"RPU_DROP_CNT", - HNS3_IMISSED_STATS_FIELD_OFFSET(rpu_rx_drop_cnt)}, -+ {"SSU_DROP_CNT", -+ HNS3_IMISSED_STATS_FIELD_OFFSET(ssu_rx_drop_cnt)}, - }; - - #define HNS3_NUM_MAC_STATS (sizeof(hns3_mac_strings) / \ -@@ -301,8 +303,7 @@ static const struct hns3_xstats_name_offset hns3_imissed_stats_strings[] = { - #define HNS3_NUM_IMISSED_XSTATS (sizeof(hns3_imissed_stats_strings) / \ - sizeof(hns3_imissed_stats_strings[0])) - --#define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + \ -- HNS3_NUM_RESET_XSTATS + HNS3_NUM_IMISSED_XSTATS) -+#define HNS3_FIX_NUM_STATS (HNS3_NUM_MAC_STATS + HNS3_NUM_RESET_XSTATS) - - static void hns3_tqp_stats_clear(struct hns3_hw *hw); - -@@ -419,7 +420,7 @@ hns3_query_update_mac_stats(struct rte_eth_dev *dev) - } - - static int --hns3_update_rpu_drop_stats(struct hns3_hw *hw) -+hns3_update_port_rpu_drop_stats(struct hns3_hw *hw) - { - struct hns3_rx_missed_stats *stats = &hw->imissed_stats; - struct hns3_query_rpu_cmd *req; -@@ -449,11 +450,90 @@ hns3_update_rpu_drop_stats(struct hns3_hw *hw) - return 0; - } - -+static void -+hns3_update_function_rpu_drop_stats(struct hns3_hw *hw) -+{ -+ struct hns3_rx_missed_stats *stats = &hw->imissed_stats; -+ -+ stats->rpu_rx_drop_cnt += hns3_read_dev(hw, HNS3_RPU_DROP_CNT_REG); -+} -+ -+static int -+hns3_update_rpu_drop_stats(struct hns3_hw *hw) -+{ -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ int ret = 0; -+ -+ if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE1 && !hns->is_vf) -+ ret = hns3_update_port_rpu_drop_stats(hw); -+ else if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE2) -+ hns3_update_function_rpu_drop_stats(hw); -+ -+ return ret; -+} -+ -+static int -+hns3_get_ssu_drop_stats(struct hns3_hw *hw, struct hns3_cmd_desc *desc, -+ int bd_num, bool is_rx) -+{ -+ struct hns3_query_ssu_cmd *req; -+ int ret; -+ int i; -+ -+ for (i = 0; i < bd_num - 1; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], -+ HNS3_OPC_SSU_DROP_REG, true); -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_SSU_DROP_REG, true); -+ req = (struct hns3_query_ssu_cmd *)desc[0].data; -+ req->rxtx = is_rx ? 0 : 1; -+ ret = hns3_cmd_send(hw, desc, bd_num); -+ -+ return ret; -+} -+ -+static int -+hns3_update_port_rx_ssu_drop_stats(struct hns3_hw *hw) -+{ -+ struct hns3_rx_missed_stats *stats = &hw->imissed_stats; -+ struct hns3_cmd_desc desc[HNS3_OPC_SSU_DROP_REG_NUM]; -+ struct hns3_query_ssu_cmd *req; -+ uint64_t cnt; -+ int ret; -+ -+ ret = hns3_get_ssu_drop_stats(hw, desc, HNS3_OPC_SSU_DROP_REG_NUM, -+ true); -+ if (ret) { -+ hns3_err(hw, "failed to get Rx SSU drop stats, ret = %d", ret); -+ return ret; -+ } -+ -+ req = (struct hns3_query_ssu_cmd *)desc[0].data; -+ cnt = rte_le_to_cpu_32(req->oq_drop_cnt) + -+ rte_le_to_cpu_32(req->full_drop_cnt) + -+ rte_le_to_cpu_32(req->part_drop_cnt); -+ -+ stats->ssu_rx_drop_cnt += cnt; -+ -+ return 0; -+} -+ - int - hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear) - { -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - int ret; - -+ if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE1 && hns->is_vf) -+ return 0; -+ -+ if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE2 && !hns->is_vf) { -+ ret = hns3_update_port_rx_ssu_drop_stats(hw); -+ if (ret) -+ return ret; -+ } -+ - ret = hns3_update_rpu_drop_stats(hw); - if (ret) - return ret; -@@ -488,19 +568,17 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - uint16_t i; - int ret; - -- if (!hns->is_vf) { -- /* Update imissed stats */ -- ret = hns3_update_imissed_stats(hw, false); -- if (ret) { -- hns3_err(hw, "update imissed stats failed, ret = %d", -- ret); -- return ret; -- } -- -- rte_stats->imissed = imissed_stats->rpu_rx_drop_cnt; -+ /* Update imissed stats */ -+ ret = hns3_update_imissed_stats(hw, false); -+ if (ret) { -+ hns3_err(hw, "update imissed stats failed, ret = %d", -+ ret); -+ return ret; - } -+ rte_stats->imissed = imissed_stats->rpu_rx_drop_cnt + -+ imissed_stats->ssu_rx_drop_cnt; - -- /* Reads all the stats of a rxq in a loop to keep them synchronized */ -+ /* Get the error stats and bytes of received packets */ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq == NULL) -@@ -556,17 +634,14 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - uint16_t i; - int ret; - -- if (!hns->is_vf) { -- /* -- * Note: Reading hardware statistics of imissed registers will -- * clear them. -- */ -- ret = hns3_update_imissed_stats(hw, true); -- if (ret) { -- hns3_err(hw, "clear imissed stats failed, ret = %d", -- ret); -- return ret; -- } -+ /* -+ * Note: Reading hardware statistics of imissed registers will -+ * clear them. -+ */ -+ ret = hns3_update_imissed_stats(hw, true); -+ if (ret) { -+ hns3_err(hw, "clear imissed stats failed, ret = %d", ret); -+ return ret; - } - - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { -@@ -630,6 +705,22 @@ hns3_mac_stats_reset(__rte_unused struct rte_eth_dev *dev) - return 0; - } - -+static int -+hns3_get_imissed_stats_num(struct hns3_adapter *hns) -+{ -+#define NO_IMISSED_STATS_NUM 0 -+#define RPU_STATS_ITEM_NUM 1 -+ struct hns3_hw *hw = &hns->hw; -+ -+ if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE1 && hns->is_vf) -+ return NO_IMISSED_STATS_NUM; -+ -+ if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE2 && !hns->is_vf) -+ return HNS3_NUM_IMISSED_XSTATS; -+ -+ return RPU_STATS_ITEM_NUM; -+} -+ - /* This function calculates the number of xstats based on the current config */ - static int - hns3_xstats_calc_num(struct rte_eth_dev *dev) -@@ -647,13 +738,17 @@ hns3_xstats_calc_num(struct rte_eth_dev *dev) - uint16_t nb_tx_q = dev->data->nb_tx_queues; - int rx_comm_stats_num = nb_rx_q * HNS3_PF_VF_RX_COMM_STATS_NUM; - int tx_comm_stats_num = nb_tx_q * HNS3_PF_VF_TX_COMM_STATS_NUM; -+ int stats_num; -+ -+ stats_num = rx_comm_stats_num + tx_comm_stats_num; -+ stats_num += hns3_get_imissed_stats_num(hns); - - if (hns->is_vf) -- return rx_comm_stats_num + tx_comm_stats_num + -- HNS3_NUM_RESET_XSTATS; -+ stats_num += HNS3_NUM_RESET_XSTATS; - else -- return rx_comm_stats_num + tx_comm_stats_num + -- HNS3_FIX_NUM_STATS; -+ stats_num += HNS3_FIX_NUM_STATS; -+ -+ return stats_num; - } - - static void -@@ -835,6 +930,31 @@ hns3_tqp_basic_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - hns3_txq_basic_stats_get(dev, xstats, count); - } - -+static void -+hns3_imissed_stats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, -+ int *count) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_rx_missed_stats *imissed_stats = &hw->imissed_stats; -+ int imissed_stats_num; -+ int cnt = *count; -+ char *addr; -+ uint16_t i; -+ -+ imissed_stats_num = hns3_get_imissed_stats_num(hns); -+ -+ for (i = 0; i < imissed_stats_num; i++) { -+ addr = (char *)imissed_stats + -+ hns3_imissed_stats_strings[i].offset; -+ xstats[cnt].value = *(uint64_t *)addr; -+ xstats[cnt].id = cnt; -+ cnt++; -+ } -+ -+ *count = cnt; -+} -+ - /* - * Retrieve extended(tqp | Mac) statistics of an Ethernet device. - * @param dev -@@ -854,7 +974,6 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -- struct hns3_rx_missed_stats *imissed_stats = &hw->imissed_stats; - struct hns3_mac_stats *mac_stats = &hw->mac_stats; - struct hns3_reset_stats *reset_stats = &hw->reset.stats; - struct hns3_rx_bd_errors_stats *rx_err_stats; -@@ -890,24 +1009,17 @@ hns3_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, - xstats[count].id = count; - count++; - } -+ } - -- ret = hns3_update_imissed_stats(hw, false); -- if (ret) { -- hns3_err(hw, "update imissed stats failed, ret = %d", -- ret); -- return ret; -- } -- -- for (i = 0; i < HNS3_NUM_IMISSED_XSTATS; i++) { -- addr = (char *)imissed_stats + -- hns3_imissed_stats_strings[i].offset; -- xstats[count].value = *(uint64_t *)addr; -- xstats[count].id = count; -- count++; -- } -- -+ ret = hns3_update_imissed_stats(hw, false); -+ if (ret) { -+ hns3_err(hw, "update imissed stats failed, ret = %d", -+ ret); -+ return ret; - } - -+ hns3_imissed_stats_get(dev, xstats, &count); -+ - /* Get the reset stat */ - for (i = 0; i < HNS3_NUM_RESET_XSTATS; i++) { - addr = (char *)reset_stats + hns3_reset_stats_strings[i].offset; -@@ -992,6 +1104,28 @@ hns3_tqp_dfx_stats_name_get(struct rte_eth_dev *dev, - } - } - -+static void -+hns3_imissed_stats_name_get(struct rte_eth_dev *dev, -+ struct rte_eth_xstat_name *xstats_names, -+ uint32_t *count) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ uint32_t cnt = *count; -+ int imissed_stats_num; -+ uint16_t i; -+ -+ imissed_stats_num = hns3_get_imissed_stats_num(hns); -+ -+ for (i = 0; i < imissed_stats_num; i++) { -+ snprintf(xstats_names[cnt].name, -+ sizeof(xstats_names[cnt].name), -+ "%s", hns3_imissed_stats_strings[i].name); -+ cnt++; -+ } -+ -+ *count = cnt; -+} -+ - /* - * Retrieve names of extended statistics of an Ethernet device. - * -@@ -1040,14 +1174,10 @@ hns3_dev_xstats_get_names(struct rte_eth_dev *dev, - "%s", hns3_mac_strings[i].name); - count++; - } -- -- for (i = 0; i < HNS3_NUM_IMISSED_XSTATS; i++) { -- snprintf(xstats_names[count].name, -- sizeof(xstats_names[count].name), -- "%s", hns3_imissed_stats_strings[i].name); -- count++; -- } - } -+ -+ hns3_imissed_stats_name_get(dev, xstats_names, &count); -+ - for (i = 0; i < HNS3_NUM_RESET_XSTATS; i++) { - snprintf(xstats_names[count].name, - sizeof(xstats_names[count].name), -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index 8ea69b4..273be42 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -112,6 +112,7 @@ struct hns3_mac_stats { - - struct hns3_rx_missed_stats { - uint64_t rpu_rx_drop_cnt; -+ uint64_t ssu_rx_drop_cnt; - }; - - /* store statistics names and its offset in stats structure */ --- -2.7.4 - diff --git a/0064-net-hns3-support-oerrors-stats-in-PF.patch b/0064-net-hns3-support-oerrors-stats-in-PF.patch deleted file mode 100644 index d92c24d..0000000 --- a/0064-net-hns3-support-oerrors-stats-in-PF.patch +++ /dev/null @@ -1,124 +0,0 @@ -From afd493a7e66236c538bf9ab7feb332200cbd2e76 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Tue, 23 Mar 2021 19:21:05 +0800 -Subject: [PATCH 064/189] net/hns3: support oerrors stats in PF - -This patch added oerrors stats for PF in kunpeng930. - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 1 + - drivers/net/hns3/hns3_stats.c | 64 +++++++++++++++++++++++++++++++++++++++++- - 2 files changed, 64 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 01561cc..6800ee0 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -443,6 +443,7 @@ struct hns3_hw { - /* Include Mac stats | Rx stats | Tx stats */ - struct hns3_mac_stats mac_stats; - struct hns3_rx_missed_stats imissed_stats; -+ uint64_t oerror_stats; - uint32_t fw_version; - - uint16_t num_msi; -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index e802c0b..1af689f 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -519,6 +519,31 @@ hns3_update_port_rx_ssu_drop_stats(struct hns3_hw *hw) - return 0; - } - -+static int -+hns3_update_port_tx_ssu_drop_stats(struct hns3_hw *hw) -+{ -+ struct hns3_cmd_desc desc[HNS3_OPC_SSU_DROP_REG_NUM]; -+ struct hns3_query_ssu_cmd *req; -+ uint64_t cnt; -+ int ret; -+ -+ ret = hns3_get_ssu_drop_stats(hw, desc, HNS3_OPC_SSU_DROP_REG_NUM, -+ false); -+ if (ret) { -+ hns3_err(hw, "failed to get Tx SSU drop stats, ret = %d", ret); -+ return ret; -+ } -+ -+ req = (struct hns3_query_ssu_cmd *)desc[0].data; -+ cnt = rte_le_to_cpu_32(req->oq_drop_cnt) + -+ rte_le_to_cpu_32(req->full_drop_cnt) + -+ rte_le_to_cpu_32(req->part_drop_cnt); -+ -+ hw->oerror_stats += cnt; -+ -+ return 0; -+} -+ - int - hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear) - { -@@ -544,6 +569,25 @@ hns3_update_imissed_stats(struct hns3_hw *hw, bool is_clear) - return 0; - } - -+static int -+hns3_update_oerror_stats(struct hns3_hw *hw, bool is_clear) -+{ -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ int ret; -+ -+ if (hw->drop_stats_mode == HNS3_PKTS_DROP_STATS_MODE1 || hns->is_vf) -+ return 0; -+ -+ ret = hns3_update_port_tx_ssu_drop_stats(hw); -+ if (ret) -+ return ret; -+ -+ if (is_clear) -+ hw->oerror_stats = 0; -+ -+ return 0; -+} -+ - /* - * Query tqp tx queue statistics ,opcode id: 0x0B03. - * Query tqp rx queue statistics ,opcode id: 0x0B13. -@@ -608,7 +652,14 @@ hns3_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *rte_stats) - rte_stats->obytes += txq->basic_stats.bytes; - } - -- rte_stats->oerrors = 0; -+ ret = hns3_update_oerror_stats(hw, false); -+ if (ret) { -+ hns3_err(hw, "update oerror stats failed, ret = %d", -+ ret); -+ return ret; -+ } -+ rte_stats->oerrors = hw->oerror_stats; -+ - /* - * If HW statistics are reset by stats_reset, but a lot of residual - * packets exist in the hardware queue and these packets are error -@@ -644,6 +695,17 @@ hns3_stats_reset(struct rte_eth_dev *eth_dev) - return ret; - } - -+ /* -+ * Note: Reading hardware statistics of oerror registers will -+ * clear them. -+ */ -+ ret = hns3_update_oerror_stats(hw, true); -+ if (ret) { -+ hns3_err(hw, "clear oerror stats failed, ret = %d", -+ ret); -+ return ret; -+ } -+ - for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { - rxq = eth_dev->data->rx_queues[i]; - if (rxq == NULL) --- -2.7.4 - diff --git a/0065-net-hns3-support-Tx-descriptor-status-query.patch b/0065-net-hns3-support-Tx-descriptor-status-query.patch deleted file mode 100644 index 6ca2ecb..0000000 --- a/0065-net-hns3-support-Tx-descriptor-status-query.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 71c308ebc61180d6f7a65c9f4dfdfc5e6d1fb782 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Tue, 23 Mar 2021 19:21:06 +0800 -Subject: [PATCH 065/189] net/hns3: support Tx descriptor status query - -Add support for query Tx descriptor status in hns3 driver. Check the -descriptor specified and provide the status information of the -corresponding descriptor. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/features/hns3.ini | 1 + - doc/guides/nics/features/hns3_vf.ini | 1 + - drivers/net/hns3/hns3_ethdev.c | 1 + - drivers/net/hns3/hns3_ethdev_vf.c | 1 + - drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_rxtx.h | 1 + - 6 files changed, 33 insertions(+) - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index 00a26cd..445d391 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -34,6 +34,7 @@ L4 checksum offload = Y - Inner L3 checksum = Y - Inner L4 checksum = Y - Packet type parsing = Y -+Tx descriptor status = Y - Basic stats = Y - Extended stats = Y - Stats per queue = Y -diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini -index f3dd239..eb55b4f 100644 ---- a/doc/guides/nics/features/hns3_vf.ini -+++ b/doc/guides/nics/features/hns3_vf.ini -@@ -32,6 +32,7 @@ L4 checksum offload = Y - Inner L3 checksum = Y - Inner L4 checksum = Y - Packet type parsing = Y -+Tx descriptor status = Y - Basic stats = Y - Extended stats = Y - Stats per queue = Y -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index b5057da..5b07183 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6774,6 +6774,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; -+ eth_dev->tx_descriptor_status = NULL; - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; - return ret; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index c567dff..2688c19 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2917,6 +2917,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - eth_dev->rx_pkt_burst = NULL; - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; -+ eth_dev->tx_descriptor_status = NULL; - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 404c403..efdb49a 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4044,6 +4044,7 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - eth_dev->rx_pkt_burst = hns3_get_rx_function(eth_dev); - eth_dev->tx_pkt_burst = hns3_get_tx_function(eth_dev, &prep); - eth_dev->tx_pkt_prepare = prep; -+ eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; - } else { - eth_dev->rx_pkt_burst = hns3_dummy_rxtx_burst; - eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst; -@@ -4256,6 +4257,33 @@ hns3_tx_done_cleanup(void *txq, uint32_t free_cnt) - return -ENOTSUP; - } - -+int -+hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) -+{ -+ volatile struct hns3_desc *txdp; -+ struct hns3_tx_queue *txq; -+ struct rte_eth_dev *dev; -+ uint16_t desc_id; -+ -+ txq = (struct hns3_tx_queue *)tx_queue; -+ if (offset >= txq->nb_tx_desc) -+ return -EINVAL; -+ -+ dev = &rte_eth_devices[txq->port_id]; -+ if (dev->tx_pkt_burst != hns3_xmit_pkts_simple && -+ dev->tx_pkt_burst != hns3_xmit_pkts && -+ dev->tx_pkt_burst != hns3_xmit_pkts_vec_sve && -+ dev->tx_pkt_burst != hns3_xmit_pkts_vec) -+ return RTE_ETH_TX_DESC_UNAVAIL; -+ -+ desc_id = (txq->next_to_use + offset) % txq->nb_tx_desc; -+ txdp = &txq->tx_ring[desc_id]; -+ if (txdp->tx.tp_fe_sc_vld_ra_ri & rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B))) -+ return RTE_ETH_TX_DESC_FULL; -+ else -+ return RTE_ETH_TX_DESC_DONE; -+} -+ - uint32_t - hns3_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) - { -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index cd04200..82d5aa0 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -720,5 +720,6 @@ void hns3_stop_all_txqs(struct rte_eth_dev *dev); - void hns3_restore_tqp_enable_state(struct hns3_hw *hw); - int hns3_tx_done_cleanup(void *txq, uint32_t free_cnt); - void hns3_enable_rxd_adv_layout(struct hns3_hw *hw); -+int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); - - #endif /* _HNS3_RXTX_H_ */ --- -2.7.4 - diff --git a/0066-net-hns3-support-Rx-descriptor-status-query.patch b/0066-net-hns3-support-Rx-descriptor-status-query.patch deleted file mode 100644 index 792e846..0000000 --- a/0066-net-hns3-support-Rx-descriptor-status-query.patch +++ /dev/null @@ -1,137 +0,0 @@ -From d29daf59b08c1314190c6d1cab0e22ee176b6c0f Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Tue, 23 Mar 2021 19:21:07 +0800 -Subject: [PATCH 066/189] net/hns3: support Rx descriptor status query - -Add support for query Rx descriptor status in hns3 driver. Check the -descriptor specified and provide the status information of the -corresponding descriptor. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/features/hns3.ini | 1 + - doc/guides/nics/features/hns3_vf.ini | 1 + - drivers/net/hns3/hns3_ethdev.c | 1 + - drivers/net/hns3/hns3_ethdev_vf.c | 1 + - drivers/net/hns3/hns3_rxtx.c | 36 ++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_rxtx.h | 1 + - 6 files changed, 41 insertions(+) - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index 445d391..d407b2f 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -34,6 +34,7 @@ L4 checksum offload = Y - Inner L3 checksum = Y - Inner L4 checksum = Y - Packet type parsing = Y -+Rx descriptor status = Y - Tx descriptor status = Y - Basic stats = Y - Extended stats = Y -diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini -index eb55b4f..a0fd56d 100644 ---- a/doc/guides/nics/features/hns3_vf.ini -+++ b/doc/guides/nics/features/hns3_vf.ini -@@ -33,6 +33,7 @@ Inner L3 checksum = Y - Inner L4 checksum = Y - Packet type parsing = Y - Tx descriptor status = Y -+Rx descriptor status = Y - Basic stats = Y - Extended stats = Y - Stats per queue = Y -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 5b07183..12cc3ac 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6772,6 +6772,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - err_mp_init_secondary: - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; -+ eth_dev->rx_descriptor_status = NULL; - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; - eth_dev->tx_descriptor_status = NULL; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 2688c19..6404264 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2915,6 +2915,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - err_mp_init_secondary: - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; -+ eth_dev->rx_descriptor_status = NULL; - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; - eth_dev->tx_descriptor_status = NULL; -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index efdb49a..6a7c360 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4042,6 +4042,7 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - if (hns->hw.adapter_state == HNS3_NIC_STARTED && - __atomic_load_n(&hns->hw.reset.resetting, __ATOMIC_RELAXED) == 0) { - eth_dev->rx_pkt_burst = hns3_get_rx_function(eth_dev); -+ eth_dev->rx_descriptor_status = hns3_dev_rx_descriptor_status; - eth_dev->tx_pkt_burst = hns3_get_tx_function(eth_dev, &prep); - eth_dev->tx_pkt_prepare = prep; - eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; -@@ -4258,6 +4259,41 @@ hns3_tx_done_cleanup(void *txq, uint32_t free_cnt) - } - - int -+hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) -+{ -+ volatile struct hns3_desc *rxdp; -+ struct hns3_rx_queue *rxq; -+ struct rte_eth_dev *dev; -+ uint32_t bd_base_info; -+ uint16_t desc_id; -+ -+ rxq = (struct hns3_rx_queue *)rx_queue; -+ if (offset >= rxq->nb_rx_desc) -+ return -EINVAL; -+ -+ desc_id = (rxq->next_to_use + offset) % rxq->nb_rx_desc; -+ rxdp = &rxq->rx_ring[desc_id]; -+ bd_base_info = rte_le_to_cpu_32(rxdp->rx.bd_base_info); -+ dev = &rte_eth_devices[rxq->port_id]; -+ if (dev->rx_pkt_burst == hns3_recv_pkts || -+ dev->rx_pkt_burst == hns3_recv_scattered_pkts) { -+ if (offset >= rxq->nb_rx_desc - rxq->rx_free_hold) -+ return RTE_ETH_RX_DESC_UNAVAIL; -+ } else if (dev->rx_pkt_burst == hns3_recv_pkts_vec || -+ dev->rx_pkt_burst == hns3_recv_pkts_vec_sve){ -+ if (offset >= rxq->nb_rx_desc - rxq->rx_rearm_nb) -+ return RTE_ETH_RX_DESC_UNAVAIL; -+ } else { -+ return RTE_ETH_RX_DESC_UNAVAIL; -+ } -+ -+ if (!(bd_base_info & BIT(HNS3_RXD_VLD_B))) -+ return RTE_ETH_RX_DESC_AVAIL; -+ else -+ return RTE_ETH_RX_DESC_DONE; -+} -+ -+int - hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset) - { - volatile struct hns3_desc *txdp; -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 82d5aa0..f9b3048 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -720,6 +720,7 @@ void hns3_stop_all_txqs(struct rte_eth_dev *dev); - void hns3_restore_tqp_enable_state(struct hns3_hw *hw); - int hns3_tx_done_cleanup(void *txq, uint32_t free_cnt); - void hns3_enable_rxd_adv_layout(struct hns3_hw *hw); -+int hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); - int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); - - #endif /* _HNS3_RXTX_H_ */ --- -2.7.4 - diff --git a/0067-net-hns3-fix-reporting-undefined-speed.patch b/0067-net-hns3-fix-reporting-undefined-speed.patch deleted file mode 100644 index 7a9d92d..0000000 --- a/0067-net-hns3-fix-reporting-undefined-speed.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 3a77c6eecf9089843c3f4452139c07ffe5c6823d Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 23 Mar 2021 21:45:51 +0800 -Subject: [PATCH 067/189] net/hns3: fix reporting undefined speed - -There may be a case in future that the speed obtained from firmware -is undefined (such as, 400G or other rate), and link status of device is -up. At this case, PMD driver will reports 100Mbps to the user in the -"hns3_dev_link_update" API, which is unreasonable. Besides, if the -speed from firmware is zero, driver should report zero instead of -100Mbps. - -Fixes: 59fad0f32135 ("net/hns3: support link update operation") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 5 ++++- - drivers/net/hns3/hns3_ethdev_vf.c | 5 ++++- - 2 files changed, 8 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 12cc3ac..55e2f07 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2725,7 +2725,10 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, - new_link.link_speed = mac->link_speed; - break; - default: -- new_link.link_speed = ETH_SPEED_NUM_100M; -+ if (mac->link_status) -+ new_link.link_speed = ETH_SPEED_NUM_UNKNOWN; -+ else -+ new_link.link_speed = ETH_SPEED_NUM_NONE; - break; - } - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 6404264..26f0698 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2123,7 +2123,10 @@ hns3vf_dev_link_update(struct rte_eth_dev *eth_dev, - new_link.link_speed = mac->link_speed; - break; - default: -- new_link.link_speed = ETH_SPEED_NUM_100M; -+ if (mac->link_status) -+ new_link.link_speed = ETH_SPEED_NUM_UNKNOWN; -+ else -+ new_link.link_speed = ETH_SPEED_NUM_NONE; - break; - } - --- -2.7.4 - diff --git a/0068-net-hns3-fix-build-for-SVE-path.patch b/0068-net-hns3-fix-build-for-SVE-path.patch deleted file mode 100644 index 3bd8423..0000000 --- a/0068-net-hns3-fix-build-for-SVE-path.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 2043f4bf46fe0403c6015da614d0bb3f9f9f4344 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 23 Mar 2021 21:45:52 +0800 -Subject: [PATCH 068/189] net/hns3: fix build for SVE path - -The 'queue_full_cnt' stats have been encapsulated in 'dfx_stats'. -However, the modification in the SVE algorithm is omitted. -As a result, the driver fails to be compiled when the SVE -algorithm is used. - -Fixes: 9b77f1fe303f ("net/hns3: encapsulate DFX stats in datapath") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx_vec_sve.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index f6c6f52..2700e6e 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -439,7 +439,7 @@ hns3_xmit_fixed_burst_vec_sve(void *__restrict tx_queue, - - nb_pkts = RTE_MIN(txq->tx_bd_ready, nb_pkts); - if (unlikely(nb_pkts == 0)) { -- txq->queue_full_cnt++; -+ txq->dfx_stats.queue_full_cnt++; - return 0; - } - --- -2.7.4 - diff --git a/0069-net-hns3-fix-processing-Tx-offload-flags.patch b/0069-net-hns3-fix-processing-Tx-offload-flags.patch deleted file mode 100644 index 96b187d..0000000 --- a/0069-net-hns3-fix-processing-Tx-offload-flags.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 5233a6a3449ff374def3469b79d98a85e6cfd6f1 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Tue, 23 Mar 2021 21:45:53 +0800 -Subject: [PATCH 069/189] net/hns3: fix processing Tx offload flags - -Currently, if the PKT_TX_TCP_SEG and PKT_TX_TCP_CKSUM offload flags set -in the same time, hns3 PMD can not process the descriptors correctly. - -This patch fixes it by adding the processing of this situation. - -Fixes: fb6eb9009f41 ("net/hns3: fix Tx checksum with fixed header length") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 6a7c360..62c56f6 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -3291,6 +3291,7 @@ hns3_parse_l4_cksum_params(struct rte_mbuf *m, uint32_t *type_cs_vlan_tso_len) - uint32_t tmp; - /* Enable L4 checksum offloads */ - switch (ol_flags & (PKT_TX_L4_MASK | PKT_TX_TCP_SEG)) { -+ case PKT_TX_TCP_CKSUM | PKT_TX_TCP_SEG: - case PKT_TX_TCP_CKSUM: - case PKT_TX_TCP_SEG: - tmp = *type_cs_vlan_tso_len; --- -2.7.4 - diff --git a/0070-net-hns3-fix-Tx-checksum-for-UDP-packets-with-specia.patch b/0070-net-hns3-fix-Tx-checksum-for-UDP-packets-with-specia.patch deleted file mode 100644 index 16e83a9..0000000 --- a/0070-net-hns3-fix-Tx-checksum-for-UDP-packets-with-specia.patch +++ /dev/null @@ -1,225 +0,0 @@ -From 77d2a11852ab27e6ac367cc3bf2146b9e1aa2d0c Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Tue, 23 Mar 2021 21:45:54 +0800 -Subject: [PATCH 070/189] net/hns3: fix Tx checksum for UDP packets with - special port - -For Kunpeng920 network engine, UDP packets with destination port 6081, -4789 or 4790 will be identified as tunnel packets. If the UDP CKSUM -offload is set in the mbuf, and the TX tunnel mask is not set, the -CKSUM of these packets will be wrong. In this case, the upper layer -user may not identify the packet as a tunnel packet, and processes it -as non-tunnel packet, and expect to offload the outer UDP CKSUM, so -they may not fill the outer L2/L3 length to mbuf. However, the HW -identifies these packet as tunnel packets and therefore offload the -inner UDP CKSUM. As a result, the inner and outer UDP CKSUM are -incorrect. And for non-tunnel UDP packets with preceding special -destination port will also exist similar checksum error. - -For the new generation Kunpeng930 network engine, the above errata -have been fixed. Therefore, the concept of udp_cksum_mode is -introduced. There are two udp_cksum_mode for hns3 PMD, -HNS3_SPECIAL_PORT_HW_CKSUM_MODE means HW could solve the above -problem. And in HNS3_SPECIAL_PORT_SW_CKSUM_MODE, hns3 PMD will check -packets in the Tx prepare and perform the UDP CKSUM for such packets -to avoid a checksum error. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 ++ - drivers/net/hns3/hns3_ethdev.h | 19 ++++++++++++ - drivers/net/hns3/hns3_rxtx.c | 68 ++++++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_rxtx.h | 16 ++++++++++ - 4 files changed, 105 insertions(+) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 55e2f07..3e0b28a 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -3129,6 +3129,7 @@ hns3_get_capability(struct hns3_hw *hw) - hw->min_tx_pkt_len = HNS3_HIP08_MIN_TX_PKT_LEN; - pf->tqp_config_mode = HNS3_FIXED_MAX_TQP_NUM_MODE; - hw->rss_info.ipv6_sctp_offload_supported = false; -+ hw->udp_cksum_mode = HNS3_SPECIAL_PORT_SW_CKSUM_MODE; - return 0; - } - -@@ -3148,6 +3149,7 @@ hns3_get_capability(struct hns3_hw *hw) - hw->min_tx_pkt_len = HNS3_HIP09_MIN_TX_PKT_LEN; - pf->tqp_config_mode = HNS3_FLEX_MAX_TQP_NUM_MODE; - hw->rss_info.ipv6_sctp_offload_supported = true; -+ hw->udp_cksum_mode = HNS3_SPECIAL_PORT_HW_CKSUM_MODE; - - return 0; - } -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 6800ee0..eb2203c 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -47,6 +47,9 @@ - #define HNS3_UNLIMIT_PROMISC_MODE 0 - #define HNS3_LIMIT_PROMISC_MODE 1 - -+#define HNS3_SPECIAL_PORT_SW_CKSUM_MODE 0 -+#define HNS3_SPECIAL_PORT_HW_CKSUM_MODE 1 -+ - #define HNS3_UC_MACADDR_NUM 128 - #define HNS3_VF_UC_MACADDR_NUM 48 - #define HNS3_MC_MACADDR_NUM 128 -@@ -567,6 +570,22 @@ struct hns3_hw { - uint8_t drop_stats_mode; - - uint8_t max_non_tso_bd_num; /* max BD number of one non-TSO packet */ -+ /* -+ * udp checksum mode. -+ * value range: -+ * HNS3_SPECIAL_PORT_HW_CKSUM_MODE/HNS3_SPECIAL_PORT_SW_CKSUM_MODE -+ * -+ * - HNS3_SPECIAL_PORT_SW_CKSUM_MODE -+ * In this mode, HW can not do checksum for special UDP port like -+ * 4789, 4790, 6081 for non-tunnel UDP packets and UDP tunnel -+ * packets without the PKT_TX_TUNEL_MASK in the mbuf. So, PMD need -+ * do the checksum for these packets to avoid a checksum error. -+ * -+ * - HNS3_SPECIAL_PORT_HW_CKSUM_MODE -+ * In this mode, HW does not have the preceding problems and can -+ * directly calculate the checksum of these UDP packets. -+ */ -+ uint8_t udp_cksum_mode; - - struct hns3_port_base_vlan_config port_base_vlan_cfg; - /* -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 62c56f6..626f91f 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -5,6 +5,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -2845,6 +2846,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - HNS3_RING_TX_TAIL_REG); - txq->min_tx_pkt_len = hw->min_tx_pkt_len; - txq->tso_mode = hw->tso_mode; -+ txq->udp_cksum_mode = hw->udp_cksum_mode; - memset(&txq->basic_stats, 0, sizeof(struct hns3_tx_basic_stats)); - memset(&txq->dfx_stats, 0, sizeof(struct hns3_tx_dfx_stats)); - -@@ -3548,6 +3550,69 @@ hns3_vld_vlan_chk(struct hns3_tx_queue *txq, struct rte_mbuf *m) - } - #endif - -+static uint16_t -+hns3_udp_cksum_help(struct rte_mbuf *m) -+{ -+ uint64_t ol_flags = m->ol_flags; -+ uint16_t cksum = 0; -+ uint32_t l4_len; -+ -+ if (ol_flags & PKT_TX_IPV4) { -+ struct rte_ipv4_hdr *ipv4_hdr = rte_pktmbuf_mtod_offset(m, -+ struct rte_ipv4_hdr *, m->l2_len); -+ l4_len = rte_be_to_cpu_16(ipv4_hdr->total_length) - m->l3_len; -+ } else { -+ struct rte_ipv6_hdr *ipv6_hdr = rte_pktmbuf_mtod_offset(m, -+ struct rte_ipv6_hdr *, m->l2_len); -+ l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len); -+ } -+ -+ rte_raw_cksum_mbuf(m, m->l2_len + m->l3_len, l4_len, &cksum); -+ -+ cksum = ~cksum; -+ /* -+ * RFC 768:If the computed checksum is zero for UDP, it is transmitted -+ * as all ones -+ */ -+ if (cksum == 0) -+ cksum = 0xffff; -+ -+ return (uint16_t)cksum; -+} -+ -+static bool -+hns3_validate_tunnel_cksum(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m) -+{ -+ uint64_t ol_flags = m->ol_flags; -+ struct rte_udp_hdr *udp_hdr; -+ uint16_t dst_port; -+ -+ if (tx_queue->udp_cksum_mode == HNS3_SPECIAL_PORT_HW_CKSUM_MODE || -+ ol_flags & PKT_TX_TUNNEL_MASK || -+ (ol_flags & PKT_TX_L4_MASK) != PKT_TX_UDP_CKSUM) -+ return true; -+ /* -+ * A UDP packet with the same dst_port as VXLAN\VXLAN_GPE\GENEVE will -+ * be recognized as a tunnel packet in HW. In this case, if UDP CKSUM -+ * offload is set and the tunnel mask has not been set, the CKSUM will -+ * be wrong since the header length is wrong and driver should complete -+ * the CKSUM to avoid CKSUM error. -+ */ -+ udp_hdr = rte_pktmbuf_mtod_offset(m, struct rte_udp_hdr *, -+ m->l2_len + m->l3_len); -+ dst_port = rte_be_to_cpu_16(udp_hdr->dst_port); -+ switch (dst_port) { -+ case RTE_VXLAN_DEFAULT_PORT: -+ case RTE_VXLAN_GPE_DEFAULT_PORT: -+ case RTE_GENEVE_DEFAULT_PORT: -+ udp_hdr->dgram_cksum = hns3_udp_cksum_help(m); -+ m->ol_flags = ol_flags & ~PKT_TX_L4_MASK; -+ return false; -+ default: -+ return true; -+ } -+} -+ - static int - hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m) - { -@@ -3592,6 +3657,9 @@ hns3_prep_pkt_proc(struct hns3_tx_queue *tx_queue, struct rte_mbuf *m) - return ret; - } - -+ if (!hns3_validate_tunnel_cksum(tx_queue, m)) -+ return 0; -+ - hns3_outer_header_cksum_prepare(m); - - return 0; -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index f9b3048..6689397 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -465,6 +465,22 @@ struct hns3_tx_queue { - */ - uint8_t tso_mode; - /* -+ * udp checksum mode. -+ * value range: -+ * HNS3_SPECIAL_PORT_HW_CKSUM_MODE/HNS3_SPECIAL_PORT_SW_CKSUM_MODE -+ * -+ * - HNS3_SPECIAL_PORT_SW_CKSUM_MODE -+ * In this mode, HW can not do checksum for special UDP port like -+ * 4789, 4790, 6081 for non-tunnel UDP packets and UDP tunnel -+ * packets without the PKT_TX_TUNEL_MASK in the mbuf. So, PMD need -+ * do the checksum for these packets to avoid a checksum error. -+ * -+ * - HNS3_SPECIAL_PORT_HW_CKSUM_MODE -+ * In this mode, HW does not have the preceding problems and can -+ * directly calculate the checksum of these UDP packets. -+ */ -+ uint8_t udp_cksum_mode; -+ /* - * The minimum length of the packet supported by hardware in the Tx - * direction. - */ --- -2.7.4 - diff --git a/0071-net-hns3-fix-link-update-when-failed-to-get-link-inf.patch b/0071-net-hns3-fix-link-update-when-failed-to-get-link-inf.patch deleted file mode 100644 index 04b24de..0000000 --- a/0071-net-hns3-fix-link-update-when-failed-to-get-link-inf.patch +++ /dev/null @@ -1,112 +0,0 @@ -From 46602854722b87761da2e56e6bd95461ddd7b6ea Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 23 Mar 2021 21:45:55 +0800 -Subject: [PATCH 071/189] net/hns3: fix link update when failed to get link - info - -In the "hns3_dev_link_update" API, the link information of the port is -obtained first, and then 'dev_link' in dev->data is updated. When the -driver is resetting or fails to obtain link info, the current driver -still reports the previous link info to the user. This may cause that -the dev->data->dev_link may be inconsistent with the hw link status. - -Therefore, the link status consistency between the hardware, driver, -and framework can be ensured in this interface regardless of whether -the driver is normal or abnormal. - -Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 55 +++++++++++++++++++++++++++++------------- - 1 file changed, 38 insertions(+), 17 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 3e0b28a..356c52a 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2698,20 +2698,22 @@ hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, - } - - static int --hns3_dev_link_update(struct rte_eth_dev *eth_dev, -- __rte_unused int wait_to_complete) -+hns3_update_port_link_info(struct rte_eth_dev *eth_dev) - { -- struct hns3_adapter *hns = eth_dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- struct hns3_mac *mac = &hw->mac; -- struct rte_eth_link new_link; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - -- if (!hns3_is_reset_pending(hns)) { -- hns3_update_link_status(hw); -- hns3_update_link_info(eth_dev); -- } -+ (void)hns3_update_link_status(hw); -+ -+ return hns3_update_link_info(eth_dev); -+} -+ -+static void -+hns3_setup_linkstatus(struct rte_eth_dev *eth_dev, -+ struct rte_eth_link *new_link) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); -+ struct hns3_mac *mac = &hw->mac; - -- memset(&new_link, 0, sizeof(new_link)); - switch (mac->link_speed) { - case ETH_SPEED_NUM_10M: - case ETH_SPEED_NUM_100M: -@@ -2722,20 +2724,39 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, - case ETH_SPEED_NUM_50G: - case ETH_SPEED_NUM_100G: - case ETH_SPEED_NUM_200G: -- new_link.link_speed = mac->link_speed; -+ new_link->link_speed = mac->link_speed; - break; - default: - if (mac->link_status) -- new_link.link_speed = ETH_SPEED_NUM_UNKNOWN; -+ new_link->link_speed = ETH_SPEED_NUM_UNKNOWN; - else -- new_link.link_speed = ETH_SPEED_NUM_NONE; -+ new_link->link_speed = ETH_SPEED_NUM_NONE; - break; - } - -- new_link.link_duplex = mac->link_duplex; -- new_link.link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN; -- new_link.link_autoneg = -+ new_link->link_duplex = mac->link_duplex; -+ new_link->link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN; -+ new_link->link_autoneg = - !(eth_dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED); -+} -+ -+static int -+hns3_dev_link_update(struct rte_eth_dev *eth_dev, -+ __rte_unused int wait_to_complete) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); -+ struct hns3_mac *mac = &hw->mac; -+ struct rte_eth_link new_link; -+ int ret; -+ -+ ret = hns3_update_port_link_info(eth_dev); -+ if (ret) { -+ mac->link_status = ETH_LINK_DOWN; -+ hns3_err(hw, "failed to get port link info, ret = %d.", ret); -+ } -+ -+ memset(&new_link, 0, sizeof(new_link)); -+ hns3_setup_linkstatus(eth_dev, &new_link); - - return rte_eth_linkstatus_set(eth_dev, &new_link); - } --- -2.7.4 - diff --git a/0072-net-hns3-fix-long-task-queue-pairs-reset-time.patch b/0072-net-hns3-fix-long-task-queue-pairs-reset-time.patch deleted file mode 100644 index 4fb6c5a..0000000 --- a/0072-net-hns3-fix-long-task-queue-pairs-reset-time.patch +++ /dev/null @@ -1,211 +0,0 @@ -From 081a3335ccdc6cce70ab9cde9e5df87e2dcd591f Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Tue, 23 Mar 2021 21:45:56 +0800 -Subject: [PATCH 072/189] net/hns3: fix long task queue pairs reset time - -Currently, the queue reset process needs to be performed one by one, -which is inefficient. However, the queues reset in the same function is -almost at the same stage. To optimize the queue reset process, a new -function has been added to the firmware command HNS3_OPC_CFG_RST_TRIGGER -to reset all queues in the same function at a time. And the related -queue reset MBX message is adjusted in the same way too. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 8 ++- - drivers/net/hns3/hns3_rxtx.c | 125 ++++++++++++++++++++++++++++++++++++------- - 2 files changed, 114 insertions(+), 19 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index e704d0c..30aca82 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -933,10 +933,16 @@ struct hns3_reset_tqp_queue_cmd { - - #define HNS3_CFG_RESET_MAC_B 3 - #define HNS3_CFG_RESET_FUNC_B 7 -+#define HNS3_CFG_RESET_RCB_B 1 - struct hns3_reset_cmd { - uint8_t mac_func_reset; - uint8_t fun_reset_vfid; -- uint8_t rsv[22]; -+ uint8_t fun_reset_rcb; -+ uint8_t rsv1; -+ uint16_t fun_reset_rcb_vqid_start; -+ uint16_t fun_reset_rcb_vqid_num; -+ uint8_t fun_reset_rcb_return_status; -+ uint8_t rsv2[15]; - }; - - #define HNS3_QUERY_DEV_SPECS_BD_NUM 4 -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 626f91f..0596c9c 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -629,10 +629,6 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) - uint64_t end; - int ret; - -- ret = hns3_tqp_enable(hw, queue_id, false); -- if (ret) -- return ret; -- - /* - * In current version VF is not supported when PF is driven by DPDK - * driver, all task queue pairs are mapped to PF function, so PF's queue -@@ -679,11 +675,6 @@ hns3vf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) - uint8_t msg_data[2]; - int ret; - -- /* Disable VF's queue before send queue reset msg to PF */ -- ret = hns3_tqp_enable(hw, queue_id, false); -- if (ret) -- return ret; -- - memcpy(msg_data, &queue_id, sizeof(uint16_t)); - - ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, -@@ -695,14 +686,105 @@ hns3vf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) - } - - static int --hns3_reset_tqp(struct hns3_adapter *hns, uint16_t queue_id) -+hns3_reset_rcb_cmd(struct hns3_hw *hw, uint8_t *reset_status) - { -- struct hns3_hw *hw = &hns->hw; -+ struct hns3_reset_cmd *req; -+ struct hns3_cmd_desc desc; -+ int ret; - -- if (hns->is_vf) -- return hns3vf_reset_tqp(hw, queue_id); -- else -- return hns3pf_reset_tqp(hw, queue_id); -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_RST_TRIGGER, false); -+ req = (struct hns3_reset_cmd *)desc.data; -+ hns3_set_bit(req->mac_func_reset, HNS3_CFG_RESET_RCB_B, 1); -+ -+ /* -+ * The start qid should be the global qid of the first tqp of the -+ * function which should be reset in this port. Since our PF not -+ * support take over of VFs, so we only need to reset function 0, -+ * and its start qid is always 0. -+ */ -+ req->fun_reset_rcb_vqid_start = rte_cpu_to_le_16(0); -+ req->fun_reset_rcb_vqid_num = rte_cpu_to_le_16(hw->cfg_max_queues); -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, "fail to send rcb reset cmd, ret = %d.", ret); -+ return ret; -+ } -+ -+ *reset_status = req->fun_reset_rcb_return_status; -+ return 0; -+} -+ -+static int -+hns3pf_reset_all_tqps(struct hns3_hw *hw) -+{ -+#define HNS3_RESET_RCB_NOT_SUPPORT 0U -+#define HNS3_RESET_ALL_TQP_SUCCESS 1U -+ uint8_t reset_status; -+ int ret; -+ int i; -+ -+ ret = hns3_reset_rcb_cmd(hw, &reset_status); -+ if (ret) -+ return ret; -+ -+ /* -+ * If the firmware version is low, it may not support the rcb reset -+ * which means reset all the tqps at a time. In this case, we should -+ * reset tqps one by one. -+ */ -+ if (reset_status == HNS3_RESET_RCB_NOT_SUPPORT) { -+ for (i = 0; i < hw->cfg_max_queues; i++) { -+ ret = hns3pf_reset_tqp(hw, i); -+ if (ret) { -+ hns3_err(hw, -+ "fail to reset tqp, queue_id = %d, ret = %d.", -+ i, ret); -+ return ret; -+ } -+ } -+ } else if (reset_status != HNS3_RESET_ALL_TQP_SUCCESS) { -+ hns3_err(hw, "fail to reset all tqps, reset_status = %u.", -+ reset_status); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3vf_reset_all_tqps(struct hns3_hw *hw) -+{ -+#define HNS3VF_RESET_ALL_TQP_DONE 1U -+ uint8_t reset_status; -+ uint8_t msg_data[2]; -+ int ret; -+ int i; -+ -+ memset(msg_data, 0, sizeof(uint16_t)); -+ ret = hns3_send_mbx_msg(hw, HNS3_MBX_QUEUE_RESET, 0, msg_data, -+ sizeof(msg_data), true, &reset_status, -+ sizeof(reset_status)); -+ if (ret) { -+ hns3_err(hw, "fail to send rcb reset mbx, ret = %d.", ret); -+ return ret; -+ } -+ -+ if (reset_status == HNS3VF_RESET_ALL_TQP_DONE) -+ return 0; -+ -+ /* -+ * If the firmware version or kernel PF version is low, it may not -+ * support the rcb reset which means reset all the tqps at a time. -+ * In this case, we should reset tqps one by one. -+ */ -+ for (i = 1; i < hw->cfg_max_queues; i++) { -+ ret = hns3vf_reset_tqp(hw, i); -+ if (ret) -+ return ret; -+ } -+ -+ return 0; - } - - int -@@ -711,14 +793,21 @@ hns3_reset_all_tqps(struct hns3_adapter *hns) - struct hns3_hw *hw = &hns->hw; - int ret, i; - -+ /* Disable all queues before reset all queues */ - for (i = 0; i < hw->cfg_max_queues; i++) { -- ret = hns3_reset_tqp(hns, i); -+ ret = hns3_tqp_enable(hw, i, false); - if (ret) { -- hns3_err(hw, "Failed to reset No.%d queue: %d", i, ret); -+ hns3_err(hw, -+ "fail to disable tqps before tqps reset, ret = %d.", -+ ret); - return ret; - } - } -- return 0; -+ -+ if (hns->is_vf) -+ return hns3vf_reset_all_tqps(hw); -+ else -+ return hns3pf_reset_all_tqps(hw); - } - - static int --- -2.7.4 - diff --git a/0073-net-hns3-fix-MTU-config-complexity.patch b/0073-net-hns3-fix-MTU-config-complexity.patch deleted file mode 100644 index de928dd..0000000 --- a/0073-net-hns3-fix-MTU-config-complexity.patch +++ /dev/null @@ -1,106 +0,0 @@ -From 85c88060616e97d475df4b2321843a57218b80d9 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 1 Apr 2021 21:38:03 +0800 -Subject: [PATCH 073/189] net/hns3: fix MTU config complexity - -This patch fixed cyclomatic complexity about MTU -in device configure process. - -Fixes: 1f5ca0b460cd ("net/hns3: support some device operations") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 62 ++++++++++++++++++++++++++---------------- - 1 file changed, 38 insertions(+), 24 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 356c52a..ffdf019 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2373,6 +2373,41 @@ hns3_init_ring_with_vector(struct hns3_hw *hw) - } - - static int -+hns3_refresh_mtu(struct rte_eth_dev *dev, struct rte_eth_conf *conf) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ uint32_t max_rx_pkt_len; -+ uint16_t mtu; -+ int ret; -+ -+ if (!(conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)) -+ return 0; -+ -+ /* -+ * If jumbo frames are enabled, MTU needs to be refreshed -+ * according to the maximum RX packet length. -+ */ -+ max_rx_pkt_len = conf->rxmode.max_rx_pkt_len; -+ if (max_rx_pkt_len > HNS3_MAX_FRAME_LEN || -+ max_rx_pkt_len <= HNS3_DEFAULT_FRAME_LEN) { -+ hns3_err(hw, "maximum Rx packet length must be greater than %u " -+ "and no more than %u when jumbo frame enabled.", -+ (uint16_t)HNS3_DEFAULT_FRAME_LEN, -+ (uint16_t)HNS3_MAX_FRAME_LEN); -+ return -EINVAL; -+ } -+ -+ mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(max_rx_pkt_len); -+ ret = hns3_dev_mtu_set(dev, mtu); -+ if (ret) -+ return ret; -+ dev->data->mtu = mtu; -+ -+ return 0; -+} -+ -+static int - hns3_dev_configure(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; -@@ -2382,8 +2417,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) - uint16_t nb_rx_q = dev->data->nb_rx_queues; - uint16_t nb_tx_q = dev->data->nb_tx_queues; - struct rte_eth_rss_conf rss_conf; -- uint32_t max_rx_pkt_len; -- uint16_t mtu; - bool gro_en; - int ret; - -@@ -2431,28 +2464,9 @@ hns3_dev_configure(struct rte_eth_dev *dev) - goto cfg_err; - } - -- /* -- * If jumbo frames are enabled, MTU needs to be refreshed -- * according to the maximum RX packet length. -- */ -- if (conf->rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) { -- max_rx_pkt_len = conf->rxmode.max_rx_pkt_len; -- if (max_rx_pkt_len > HNS3_MAX_FRAME_LEN || -- max_rx_pkt_len <= HNS3_DEFAULT_FRAME_LEN) { -- hns3_err(hw, "maximum Rx packet length must be greater " -- "than %u and less than %u when jumbo frame enabled.", -- (uint16_t)HNS3_DEFAULT_FRAME_LEN, -- (uint16_t)HNS3_MAX_FRAME_LEN); -- ret = -EINVAL; -- goto cfg_err; -- } -- -- mtu = (uint16_t)HNS3_PKTLEN_TO_MTU(max_rx_pkt_len); -- ret = hns3_dev_mtu_set(dev, mtu); -- if (ret) -- goto cfg_err; -- dev->data->mtu = mtu; -- } -+ ret = hns3_refresh_mtu(dev, conf); -+ if (ret) -+ goto cfg_err; - - ret = hns3_dev_configure_vlan(dev); - if (ret) --- -2.7.4 - diff --git a/0074-net-hns3-support-IEEE-1588-PTP.patch b/0074-net-hns3-support-IEEE-1588-PTP.patch deleted file mode 100644 index 7e227f1..0000000 --- a/0074-net-hns3-support-IEEE-1588-PTP.patch +++ /dev/null @@ -1,793 +0,0 @@ -From 95a068d7af10549d1a084b94b86fbffd03c0e3bd Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 1 Apr 2021 21:38:04 +0800 -Subject: [PATCH 074/189] net/hns3: support IEEE 1588 PTP - -Add hns3 support for new ethdev APIs to enable and read IEEE1588/ -802.1AS PTP timestamps. - -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/features/hns3.ini | 2 + - doc/guides/nics/hns3.rst | 1 + - drivers/net/hns3/hns3_cmd.h | 30 ++++ - drivers/net/hns3/hns3_ethdev.c | 41 +++++- - drivers/net/hns3/hns3_ethdev.h | 20 +++ - drivers/net/hns3/hns3_ptp.c | 292 ++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_regs.h | 23 +++ - drivers/net/hns3/hns3_rxtx.c | 47 +++++- - drivers/net/hns3/hns3_rxtx.h | 7 + - drivers/net/hns3/hns3_rxtx_vec.c | 15 +- - drivers/net/hns3/meson.build | 3 +- - 11 files changed, 468 insertions(+), 13 deletions(-) - create mode 100644 drivers/net/hns3/hns3_ptp.c - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index d407b2f..cc1ad0f 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -42,6 +42,8 @@ Stats per queue = Y - FW version = Y - Registers dump = Y - Module EEPROM dump = Y -+Timesync = Y -+Timestamp offload = Y - Multiprocess aware = Y - Linux UIO = Y - Linux VFIO = Y -diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst -index e8abd07..d722509 100644 ---- a/doc/guides/nics/hns3.rst -+++ b/doc/guides/nics/hns3.rst -@@ -37,6 +37,7 @@ Features of the HNS3 PMD are: - - MTU update - - NUMA support - - Generic flow API -+- IEEE1588/802.1AS timestamping - - Prerequisites - ------------- -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 30aca82..5d1fb67 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -123,6 +123,10 @@ enum hns3_opcode_type { - HNS3_OPC_CLEAR_MAC_TNL_INT = 0x0312, - HNS3_OPC_CONFIG_FEC_MODE = 0x031A, - -+ /* PTP command */ -+ HNS3_OPC_PTP_INT_EN = 0x0501, -+ HNS3_OPC_CFG_PTP_MODE = 0x0507, -+ - /* PFC/Pause commands */ - HNS3_OPC_CFG_MAC_PAUSE_EN = 0x0701, - HNS3_OPC_CFG_PFC_PAUSE_EN = 0x0702, -@@ -976,6 +980,32 @@ struct hns3_query_ssu_cmd { - uint32_t rev1[2]; - }; - -+#define HNS3_PTP_ENABLE_B 0 -+#define HNS3_PTP_TX_ENABLE_B 1 -+#define HNS3_PTP_RX_ENABLE_B 2 -+ -+#define HNS3_PTP_TYPE_S 0 -+#define HNS3_PTP_TYPE_M (0x3 << HNS3_PTP_TYPE_S) -+ -+#define ALL_PTP_V2_TYPE 0xF -+#define HNS3_PTP_MESSAGE_TYPE_S 0 -+#define HNS3_PTP_MESSAGE_TYPE_M (0xF << HNS3_PTP_MESSAGE_TYPE_S) -+ -+#define PTP_TYPE_L2_V2_TYPE 0 -+ -+struct hns3_ptp_mode_cfg_cmd { -+ uint8_t enable; -+ uint8_t ptp_type; -+ uint8_t v2_message_type_1; -+ uint8_t v2_message_type_0; -+ uint8_t rsv[20]; -+}; -+ -+struct hns3_ptp_int_cmd { -+ uint8_t int_en; -+ uint8_t rsvd[23]; -+}; -+ - #define HNS3_MAX_TQP_NUM_HIP08_PF 64 - #define HNS3_DEFAULT_TX_BUF 0x4000 /* 16k bytes */ - #define HNS3_TOTAL_PKT_BUF 0x108000 /* 1.03125M bytes */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index ffdf019..aef1ebf 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -58,6 +58,7 @@ enum hns3_evt_cause { - HNS3_VECTOR0_EVENT_RST, - HNS3_VECTOR0_EVENT_MBX, - HNS3_VECTOR0_EVENT_ERR, -+ HNS3_VECTOR0_EVENT_PTP, - HNS3_VECTOR0_EVENT_OTHER, - }; - -@@ -202,6 +203,13 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - goto out; - } - -+ /* Check for vector0 1588 event source */ -+ if (BIT(HNS3_VECTOR0_1588_INT_B) & vector0_int_stats) { -+ val = BIT(HNS3_VECTOR0_1588_INT_B); -+ ret = HNS3_VECTOR0_EVENT_PTP; -+ goto out; -+ } -+ - /* check for vector0 msix event source */ - if (vector0_int_stats & HNS3_VECTOR0_REG_MSIX_MASK || - hw_err_src_reg & HNS3_RAS_REG_NFE_MASK) { -@@ -227,10 +235,17 @@ hns3_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - return ret; - } - -+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) -+ if (event_type == HNS3_VECTOR0_EVENT_RST || -+ hns3_is_1588_event_type(event_type)) - hns3_write_dev(hw, HNS3_MISC_RESET_STS_REG, regclr); - else if (event_type == HNS3_VECTOR0_EVENT_MBX) - hns3_write_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG, regclr); -@@ -253,6 +268,8 @@ hns3_clear_all_event_cause(struct hns3_hw *hw) - BIT(HNS3_VECTOR0_GLOBALRESET_INT_B) | - BIT(HNS3_VECTOR0_CORERESET_INT_B)); - hns3_clear_event_cause(hw, HNS3_VECTOR0_EVENT_MBX, 0); -+ hns3_clear_event_cause(hw, HNS3_VECTOR0_EVENT_PTP, -+ BIT(HNS3_VECTOR0_1588_INT_B)); - } - - static void -@@ -2468,6 +2485,10 @@ hns3_dev_configure(struct rte_eth_dev *dev) - if (ret) - goto cfg_err; - -+ ret = hns3_mbuf_dyn_rx_timestamp_register(dev, conf); -+ if (ret) -+ goto cfg_err; -+ - ret = hns3_dev_configure_vlan(dev); - if (ret) - goto cfg_err; -@@ -2641,6 +2662,9 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | - RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; - -+ if (hns3_dev_ptp_supported(hw)) -+ info->rx_offload_capa |= DEV_RX_OFFLOAD_TIMESTAMP; -+ - info->rx_desc_lim = (struct rte_eth_desc_lim) { - .nb_max = HNS3_MAX_RING_DESC, - .nb_min = HNS3_MIN_RING_DESC, -@@ -4960,6 +4984,10 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_intr_callback_register; - } - -+ ret = hns3_ptp_init(hw); -+ if (ret) -+ goto err_get_config; -+ - /* Enable interrupt */ - rte_intr_enable(&pci_dev->intr_handle); - hns3_pf_enable_irq0(hw); -@@ -5977,6 +6005,10 @@ hns3_restore_conf(struct hns3_adapter *hns) - if (ret) - goto err_promisc; - -+ ret = hns3_restore_ptp(hns); -+ if (ret) -+ goto err_promisc; -+ - ret = hns3_restore_rx_interrupt(hw); - if (ret) - goto err_promisc; -@@ -6681,6 +6713,13 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { - .fec_set = hns3_fec_set, - .tm_ops_get = hns3_tm_ops_get, - .tx_done_cleanup = hns3_tx_done_cleanup, -+ .timesync_enable = hns3_timesync_enable, -+ .timesync_disable = hns3_timesync_disable, -+ .timesync_read_rx_timestamp = hns3_timesync_read_rx_timestamp, -+ .timesync_read_tx_timestamp = hns3_timesync_read_tx_timestamp, -+ .timesync_adjust_time = hns3_timesync_adjust_time, -+ .timesync_read_time = hns3_timesync_read_time, -+ .timesync_write_time = hns3_timesync_write_time, - }; - - static const struct hns3_reset_ops hns3_reset_ops = { -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index eb2203c..25cb5e2 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -750,6 +750,11 @@ struct hns3_pf { - bool support_sfp_query; - uint32_t fec_mode; /* current FEC mode for ethdev */ - -+ bool ptp_enable; -+ -+ /* Stores timestamp of last received packet on dev */ -+ uint64_t rx_timestamp; -+ - struct hns3_vtag_cfg vtag_config; - LIST_HEAD(vlan_tbl, hns3_user_vlan_table) vlan_list; - -@@ -1000,6 +1005,21 @@ int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, - void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); - void hns3_parse_devargs(struct rte_eth_dev *dev); -+int hns3_restore_ptp(struct hns3_adapter *hns); -+int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, -+ struct rte_eth_conf *conf); -+int hns3_ptp_init(struct hns3_hw *hw); -+int hns3_timesync_enable(struct rte_eth_dev *dev); -+int hns3_timesync_disable(struct rte_eth_dev *dev); -+int hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev, -+ struct timespec *timestamp, -+ uint32_t flags __rte_unused); -+int hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, -+ struct timespec *timestamp); -+int hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts); -+int hns3_timesync_write_time(struct rte_eth_dev *dev, -+ const struct timespec *ts); -+int hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta); - - static inline bool - is_reset_pending(struct hns3_adapter *hns) -diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c -new file mode 100644 -index 0000000..146b69d ---- /dev/null -+++ b/drivers/net/hns3/hns3_ptp.c -@@ -0,0 +1,292 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021-2021 Hisilicon Limited. -+ */ -+ -+#include -+#include -+#include -+ -+#include "hns3_ethdev.h" -+#include "hns3_regs.h" -+#include "hns3_logs.h" -+ -+uint64_t hns3_timestamp_rx_dynflag; -+int hns3_timestamp_dynfield_offset = -1; -+ -+int -+hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, -+ struct rte_eth_conf *conf) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ int ret; -+ -+ if (!(conf->rxmode.offloads & DEV_RX_OFFLOAD_TIMESTAMP)) -+ return 0; -+ -+ ret = rte_mbuf_dyn_rx_timestamp_register -+ (&hns3_timestamp_dynfield_offset, -+ &hns3_timestamp_rx_dynflag); -+ if (ret) { -+ hns3_err(hw, -+ "failed to register Rx timestamp field/flag"); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_ptp_int_en(struct hns3_hw *hw, bool en) -+{ -+ struct hns3_ptp_int_cmd *req; -+ struct hns3_cmd_desc desc; -+ int ret; -+ -+ req = (struct hns3_ptp_int_cmd *)desc.data; -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_PTP_INT_EN, false); -+ req->int_en = en ? 1 : 0; -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) -+ hns3_err(hw, -+ "failed to %s ptp interrupt, ret = %d\n", -+ en ? "enable" : "disable", ret); -+ -+ return ret; -+} -+ -+int -+hns3_ptp_init(struct hns3_hw *hw) -+{ -+ int ret; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return 0; -+ -+ ret = hns3_ptp_int_en(hw, true); -+ if (ret) -+ return ret; -+ -+ /* Start PTP timer */ -+ hns3_write_dev(hw, HNS3_CFG_TIME_CYC_EN, 1); -+ -+ return 0; -+} -+ -+static int -+hns3_timesync_configure(struct hns3_adapter *hns, bool en) -+{ -+ struct hns3_ptp_mode_cfg_cmd *req; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_pf *pf = &hns->pf; -+ struct hns3_cmd_desc desc; -+ int val; -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_PTP_MODE, false); -+ -+ req = (struct hns3_ptp_mode_cfg_cmd *)desc.data; -+ -+ val = en ? 1 : 0; -+ hns3_set_bit(req->enable, HNS3_PTP_ENABLE_B, val); -+ hns3_set_bit(req->enable, HNS3_PTP_TX_ENABLE_B, val); -+ hns3_set_bit(req->enable, HNS3_PTP_RX_ENABLE_B, val); -+ -+ if (en) { -+ hns3_set_field(req->ptp_type, HNS3_PTP_TYPE_M, HNS3_PTP_TYPE_S, -+ PTP_TYPE_L2_V2_TYPE); -+ hns3_set_field(req->v2_message_type_1, HNS3_PTP_MESSAGE_TYPE_M, -+ HNS3_PTP_MESSAGE_TYPE_S, ALL_PTP_V2_TYPE); -+ } -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, "configure PTP time failed, en = %d, ret = %d", -+ en, ret); -+ return ret; -+ } -+ -+ pf->ptp_enable = en; -+ -+ return 0; -+} -+ -+int -+hns3_timesync_enable(struct rte_eth_dev *dev) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_pf *pf = &hns->pf; -+ int ret; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ if (pf->ptp_enable) -+ return 0; -+ -+ rte_spinlock_lock(&hw->lock); -+ ret = hns3_timesync_configure(hns, true); -+ rte_spinlock_unlock(&hw->lock); -+ return ret; -+} -+ -+int -+hns3_timesync_disable(struct rte_eth_dev *dev) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_pf *pf = &hns->pf; -+ int ret; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ if (!pf->ptp_enable) -+ return 0; -+ -+ rte_spinlock_lock(&hw->lock); -+ ret = hns3_timesync_configure(hns, false); -+ rte_spinlock_unlock(&hw->lock); -+ -+ return ret; -+} -+ -+int -+hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev, -+ struct timespec *timestamp, -+ uint32_t flags __rte_unused) -+{ -+#define TIME_RX_STAMP_NS_MASK 0x3FFFFFFF -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_pf *pf = &hns->pf; -+ uint64_t ns, sec; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ ns = pf->rx_timestamp & TIME_RX_STAMP_NS_MASK; -+ sec = upper_32_bits(pf->rx_timestamp); -+ -+ ns += sec * NSEC_PER_SEC; -+ *timestamp = rte_ns_to_timespec(ns); -+ -+ return 0; -+} -+ -+int -+hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, -+ struct timespec *timestamp) -+{ -+#define TIME_TX_STAMP_NS_MASK 0x3FFFFFFF -+#define TIME_TX_STAMP_VALID 24 -+#define TIME_TX_STAMP_CNT_MASK 0x7 -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ uint64_t sec; -+ uint64_t tmp; -+ uint64_t ns; -+ int ts_cnt; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ ts_cnt = hns3_read_dev(hw, HNS3_TX_1588_BACK_TSP_CNT) & -+ TIME_TX_STAMP_CNT_MASK; -+ if (ts_cnt == 0) -+ return -EINVAL; -+ -+ ns = hns3_read_dev(hw, HNS3_TX_1588_TSP_BACK_0) & TIME_TX_STAMP_NS_MASK; -+ sec = hns3_read_dev(hw, HNS3_TX_1588_TSP_BACK_1); -+ tmp = hns3_read_dev(hw, HNS3_TX_1588_TSP_BACK_2) & 0xFFFF; -+ sec = (tmp << 32) | sec; -+ -+ ns += sec * NSEC_PER_SEC; -+ -+ *timestamp = rte_ns_to_timespec(ns); -+ -+ /* Clear current timestamp hardware stores */ -+ hns3_read_dev(hw, HNS3_TX_1588_SEQID_BACK); -+ -+ return 0; -+} -+ -+int -+hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ uint64_t ns, sec; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ sec = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L); -+ sec |= (uint64_t)(hns3_read_dev(hw, HNS3_CURR_TIME_OUT_H) & 0xFFFF) -+ << 32; -+ -+ ns = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_NS); -+ ns += sec * NSEC_PER_SEC; -+ *ts = rte_ns_to_timespec(ns); -+ -+ return 0; -+} -+ -+int -+hns3_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ uint64_t sec = ts->tv_sec; -+ uint64_t ns = ts->tv_nsec; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ /* Set the timecounters to a new value. */ -+ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_H, upper_32_bits(sec)); -+ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_M, lower_32_bits(sec)); -+ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_L, lower_32_bits(ns)); -+ hns3_write_dev(hw, HNS3_CFG_TIME_SYNC_RDY, 1); -+ -+ return 0; -+} -+ -+int -+hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta) -+{ -+#define TIME_SYNC_L_MASK 0x7FFFFFFF -+#define SYMBOL_BIT_OFFSET 31 -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct timespec cur_time; -+ uint64_t ns; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ -+ (void)hns3_timesync_read_time(dev, &cur_time); -+ ns = rte_timespec_to_ns((const struct timespec *)&cur_time); -+ cur_time = rte_ns_to_timespec(ns + delta); -+ (void)hns3_timesync_write_time(dev, (const struct timespec *)&cur_time); -+ -+ return 0; -+} -+ -+int -+hns3_restore_ptp(struct hns3_adapter *hns) -+{ -+ struct hns3_pf *pf = &hns->pf; -+ struct hns3_hw *hw = &hns->hw; -+ bool en = pf->ptp_enable; -+ int ret; -+ -+ if (!hns3_dev_ptp_supported(hw)) -+ return 0; -+ -+ ret = hns3_timesync_configure(hns, en); -+ if (ret) -+ hns3_err(hw, "restore PTP enable state(%d) failed, ret = %d", -+ en, ret); -+ -+ return ret; -+} -diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h -index e141fe1..c9e10be 100644 ---- a/drivers/net/hns3/hns3_regs.h -+++ b/drivers/net/hns3/hns3_regs.h -@@ -121,6 +121,29 @@ - #define HNS3_TQP_INTR_RL_DEFAULT 0 - #define HNS3_TQP_INTR_QL_DEFAULT 0 - -+/* Register bit for 1588 event */ -+#define HNS3_VECTOR0_1588_INT_B 0 -+ -+#define HNS3_PTP_BASE_ADDRESS 0x29000 -+ -+#define HNS3_TX_1588_SEQID_BACK (HNS3_PTP_BASE_ADDRESS + 0x0) -+#define HNS3_TX_1588_TSP_BACK_0 (HNS3_PTP_BASE_ADDRESS + 0x4) -+#define HNS3_TX_1588_TSP_BACK_1 (HNS3_PTP_BASE_ADDRESS + 0x8) -+#define HNS3_TX_1588_TSP_BACK_2 (HNS3_PTP_BASE_ADDRESS + 0xc) -+ -+#define HNS3_TX_1588_BACK_TSP_CNT (HNS3_PTP_BASE_ADDRESS + 0x30) -+ -+#define HNS3_CFG_TIME_SYNC_H (HNS3_PTP_BASE_ADDRESS + 0x50) -+#define HNS3_CFG_TIME_SYNC_M (HNS3_PTP_BASE_ADDRESS + 0x54) -+#define HNS3_CFG_TIME_SYNC_L (HNS3_PTP_BASE_ADDRESS + 0x58) -+#define HNS3_CFG_TIME_SYNC_RDY (HNS3_PTP_BASE_ADDRESS + 0x5c) -+ -+#define HNS3_CFG_TIME_CYC_EN (HNS3_PTP_BASE_ADDRESS + 0x70) -+ -+#define HNS3_CURR_TIME_OUT_H (HNS3_PTP_BASE_ADDRESS + 0x74) -+#define HNS3_CURR_TIME_OUT_L (HNS3_PTP_BASE_ADDRESS + 0x78) -+#define HNS3_CURR_TIME_OUT_NS (HNS3_PTP_BASE_ADDRESS + 0x7c) -+ - /* gl_usec convert to hardware count, as writing each 1 represents 2us */ - #define HNS3_GL_USEC_TO_REG(gl_usec) ((gl_usec) >> 1) - /* rl_usec convert to hardware count, as writing each 1 represents 4us */ -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 0596c9c..c41cccb 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2365,6 +2365,23 @@ hns3_rx_alloc_buffer(struct hns3_rx_queue *rxq) - return rte_mbuf_raw_alloc(rxq->mb_pool); - } - -+static inline void -+hns3_rx_ptp_timestamp_handle(struct hns3_rx_queue *rxq, struct rte_mbuf *mbuf, -+ volatile struct hns3_desc *rxd) -+{ -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(rxq->hns); -+ uint64_t timestamp = rte_le_to_cpu_64(rxd->timestamp); -+ -+ mbuf->ol_flags |= PKT_RX_IEEE1588_PTP | PKT_RX_IEEE1588_TMST; -+ if (hns3_timestamp_rx_dynflag > 0) { -+ *RTE_MBUF_DYNFIELD(mbuf, hns3_timestamp_dynfield_offset, -+ rte_mbuf_timestamp_t *) = timestamp; -+ mbuf->ol_flags |= hns3_timestamp_rx_dynflag; -+ } -+ -+ pf->rx_timestamp = timestamp; -+} -+ - uint16_t - hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) - { -@@ -2424,8 +2441,12 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) - } - - rxm = rxe->mbuf; -+ rxm->ol_flags = 0; - rxe->mbuf = nmb; - -+ if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) -+ hns3_rx_ptp_timestamp_handle(rxq, rxm, rxdp); -+ - dma_addr = rte_mbuf_data_iova_default(nmb); - rxdp->addr = rte_cpu_to_le_64(dma_addr); - rxdp->rx.bd_base_info = 0; -@@ -2436,7 +2457,7 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) - rxm->data_len = rxm->pkt_len; - rxm->port = rxq->port_id; - rxm->hash.rss = rte_le_to_cpu_32(rxd.rx.rss_hash); -- rxm->ol_flags = PKT_RX_RSS_HASH; -+ rxm->ol_flags |= PKT_RX_RSS_HASH; - if (unlikely(bd_base_info & BIT(HNS3_RXD_LUM_B))) { - rxm->hash.fdir.hi = - rte_le_to_cpu_16(rxd.rx.fd_id); -@@ -2455,6 +2476,9 @@ hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) - - rxm->packet_type = hns3_rx_calc_ptype(rxq, l234_info, ol_info); - -+ if (rxm->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) -+ rxm->ol_flags |= PKT_RX_IEEE1588_PTP; -+ - if (likely(bd_base_info & BIT(HNS3_RXD_L3L4P_B))) - hns3_rx_set_cksum_flag(rxm, rxm->packet_type, - cksum_err); -@@ -3043,7 +3067,7 @@ hns3_fill_per_desc(struct hns3_desc *desc, struct rte_mbuf *rxm) - { - desc->addr = rte_mbuf_data_iova(rxm); - desc->tx.send_size = rte_cpu_to_le_16(rte_pktmbuf_data_len(rxm)); -- desc->tx.tp_fe_sc_vld_ra_ri = rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)); -+ desc->tx.tp_fe_sc_vld_ra_ri |= rte_cpu_to_le_16(BIT(HNS3_TXD_VLD_B)); - } - - static void -@@ -3091,6 +3115,10 @@ hns3_fill_first_desc(struct hns3_tx_queue *txq, struct hns3_desc *desc, - rte_cpu_to_le_32(BIT(HNS3_TXD_VLAN_B)); - desc->tx.vlan_tag = rte_cpu_to_le_16(rxm->vlan_tci); - } -+ -+ if (ol_flags & PKT_TX_IEEE1588_TMST) -+ desc->tx.tp_fe_sc_vld_ra_ri |= -+ rte_cpu_to_le_16(BIT(HNS3_TXD_TSYN_B)); - } - - static inline int -@@ -4149,10 +4177,21 @@ hns3_tx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, - return 0; - } - -+static bool -+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_ptp_supported(hw)) -+ return false; -+ -+ return (offloads == (offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)); -+} -+ - static eth_tx_burst_t - hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - { -- uint64_t offloads = dev->data->dev_conf.txmode.offloads; - struct hns3_adapter *hns = dev->data->dev_private; - bool vec_allowed, sve_allowed, simple_allowed; - -@@ -4160,7 +4199,7 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - hns3_tx_check_vec_support(dev) == 0; - sve_allowed = vec_allowed && hns3_check_sve_support(); - simple_allowed = hns->tx_simple_allowed && -- offloads == (offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE); -+ hns3_tx_check_simple_support(dev); - - *prep = NULL; - -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 6689397..eebbebf 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -106,6 +106,8 @@ - #define HNS3_RXD_L3L4P_B 11 - #define HNS3_RXD_TSIND_S 12 - #define HNS3_RXD_TSIND_M (0x7 << HNS3_RXD_TSIND_S) -+ -+#define HNS3_RXD_TS_VLD_B 14 - #define HNS3_RXD_LKBK_B 15 - #define HNS3_RXD_GRO_SIZE_S 16 - #define HNS3_RXD_GRO_SIZE_M (0x3fff << HNS3_RXD_GRO_SIZE_S) -@@ -200,6 +202,8 @@ enum hns3_pkt_tun_type { - struct hns3_desc { - union { - uint64_t addr; -+ uint64_t timestamp; -+ - struct { - uint32_t addr0; - uint32_t addr1; -@@ -534,6 +538,9 @@ enum hns3_cksum_status { - HNS3_OUTER_L4_CKSUM_ERR = 8 - }; - -+extern uint64_t hns3_timestamp_rx_dynflag; -+extern int hns3_timestamp_dynfield_offset; -+ - static inline int - hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, - uint32_t bd_base_info, uint32_t l234_info, -diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c -index a26c83d..fd7b272 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.c -+++ b/drivers/net/hns3/hns3_rxtx_vec.c -@@ -18,6 +18,10 @@ 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_ptp_supported(hw)) -+ return -ENOTSUP; -+ - /* Only support DEV_TX_OFFLOAD_MBUF_FAST_FREE */ - if (txmode->offloads != DEV_TX_OFFLOAD_MBUF_FAST_FREE) - return -ENOTSUP; -@@ -167,7 +171,6 @@ hns3_rxq_vec_setup(struct hns3_rx_queue *rxq) - memset(rxq->offset_table, 0, sizeof(rxq->offset_table)); - } - --#ifndef RTE_LIBRTE_IEEE1588 - static int - hns3_rxq_vec_check(struct hns3_rx_queue *rxq, void *arg) - { -@@ -183,17 +186,19 @@ hns3_rxq_vec_check(struct hns3_rx_queue *rxq, void *arg) - RTE_SET_USED(arg); - return 0; - } --#endif - - int - hns3_rx_check_vec_support(struct rte_eth_dev *dev) - { --#ifndef RTE_LIBRTE_IEEE1588 - struct rte_fdir_conf *fconf = &dev->data->dev_conf.fdir_conf; - struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode; - uint64_t offloads_mask = DEV_RX_OFFLOAD_TCP_LRO | - DEV_RX_OFFLOAD_VLAN; - -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ if (hns3_dev_ptp_supported(hw)) -+ return -ENOTSUP; -+ - if (dev->data->scattered_rx) - return -ENOTSUP; - -@@ -207,8 +212,4 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) - return -ENOTSUP; - - return 0; --#else -- RTE_SET_USED(dev); -- return -ENOTSUP; --#endif - } -diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build -index f6aac69..6d78c33 100644 ---- a/drivers/net/hns3/meson.build -+++ b/drivers/net/hns3/meson.build -@@ -26,7 +26,8 @@ sources = files('hns3_cmd.c', - 'hns3_rxtx.c', - 'hns3_stats.c', - 'hns3_mp.c', -- 'hns3_tm.c') -+ 'hns3_tm.c', -+ 'hns3_ptp.c') - - deps += ['hash'] - --- -2.7.4 - diff --git a/0075-ethdev-validate-input-in-register-info.patch b/0075-ethdev-validate-input-in-register-info.patch deleted file mode 100644 index 98edcae..0000000 --- a/0075-ethdev-validate-input-in-register-info.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 94240428064fc641a78c2189329094acb4059eb8 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Fri, 2 Apr 2021 10:58:49 +0800 -Subject: [PATCH 075/189] ethdev: validate input in register info - -This patch adds validity check of input pointer in regs dump API. - -Fixes: 7a3f27cbf59b ("ethdev: add access to specific device info") -Fixes: 936eda25e8da ("net/hns3: support dump register") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) -Reviewed-by: Ferruh Yigit ---- - drivers/net/hns3/hns3_regs.c | 5 ----- - lib/librte_ethdev/rte_ethdev.c | 2 ++ - lib/librte_ethdev/rte_ethdev.h | 1 + - 3 files changed, 3 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index 5b14727..93055a4 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -484,11 +484,6 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - uint32_t *data; - int ret; - -- if (regs == NULL) { -- hns3_err(hw, "the input parameter regs is NULL!"); -- return -EINVAL; -- } -- - ret = hns3_get_regs_length(hw, &length); - if (ret) - return ret; -diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c -index 17ddacc..f311868 100644 ---- a/lib/librte_ethdev/rte_ethdev.c -+++ b/lib/librte_ethdev/rte_ethdev.c -@@ -5239,6 +5239,8 @@ rte_eth_dev_get_reg_info(uint16_t port_id, struct rte_dev_reg_info *info) - struct rte_eth_dev *dev; - - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); -+ if (info == NULL) -+ return -EINVAL; - - dev = &rte_eth_devices[port_id]; - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_reg, -ENOTSUP); -diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h -index f5f8919..e89fc50 100644 ---- a/lib/librte_ethdev/rte_ethdev.h -+++ b/lib/librte_ethdev/rte_ethdev.h -@@ -4395,6 +4395,7 @@ int rte_eth_dev_get_eeprom(uint16_t port_id, struct rte_dev_eeprom_info *info); - * @return - * - (0) if successful. - * - (-ENOTSUP) if hardware doesn't support. -+ * - (-EINVAL) if bad parameter. - * - (-ENODEV) if *port_id* invalid. - * - (-EIO) if device is removed. - * - others depends on the specific operations implementation. --- -2.7.4 - diff --git a/0076-net-hns3-support-wait-in-link-update.patch b/0076-net-hns3-support-wait-in-link-update.patch deleted file mode 100644 index 91ec8ba..0000000 --- a/0076-net-hns3-support-wait-in-link-update.patch +++ /dev/null @@ -1,64 +0,0 @@ -From ee9d7f7372170853e7538256c5e764bf154f3132 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 30 Mar 2021 20:53:25 +0800 -Subject: [PATCH 076/189] net/hns3: support wait in link update - -There are two APIs in ethdev layer to get link status of device, namely, -"rte_eth_link_get" and "rte_eth_link_get_nowait". When the device link -is unstable or auto-negotiation is in progress, the first API supports -the function of waiting for the NIC to link up, and the maximum waiting -time is 9 seconds based on DPDK Documentation. For the hns3 PMD driver, -the link can be established within 2 seconds. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 26 +++++++++++++++++++------- - 1 file changed, 19 insertions(+), 7 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index aef1ebf..05f199e 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2779,19 +2779,31 @@ hns3_setup_linkstatus(struct rte_eth_dev *eth_dev, - } - - static int --hns3_dev_link_update(struct rte_eth_dev *eth_dev, -- __rte_unused int wait_to_complete) -+hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete) - { -+#define HNS3_LINK_CHECK_INTERVAL 100 /* 100ms */ -+#define HNS3_MAX_LINK_CHECK_TIMES 20 /* 2s (100 * 20ms) in total */ -+ - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); -+ uint32_t retry_cnt = HNS3_MAX_LINK_CHECK_TIMES; - struct hns3_mac *mac = &hw->mac; - struct rte_eth_link new_link; - int ret; - -- ret = hns3_update_port_link_info(eth_dev); -- if (ret) { -- mac->link_status = ETH_LINK_DOWN; -- hns3_err(hw, "failed to get port link info, ret = %d.", ret); -- } -+ do { -+ ret = hns3_update_port_link_info(eth_dev); -+ if (ret) { -+ mac->link_status = ETH_LINK_DOWN; -+ hns3_err(hw, "failed to get port link info, ret = %d.", -+ ret); -+ break; -+ } -+ -+ if (!wait_to_complete || mac->link_status == ETH_LINK_UP) -+ break; -+ -+ rte_delay_ms(HNS3_LINK_CHECK_INTERVAL); -+ } while (retry_cnt--); - - memset(&new_link, 0, sizeof(new_link)); - hns3_setup_linkstatus(eth_dev, &new_link); --- -2.7.4 - diff --git a/0077-net-hns3-fix-some-function-names-for-copper-media-ty.patch b/0077-net-hns3-fix-some-function-names-for-copper-media-ty.patch deleted file mode 100644 index d1e58a2..0000000 --- a/0077-net-hns3-fix-some-function-names-for-copper-media-ty.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 45da720c44c7a7758cc811bea609116088168f25 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 31 Mar 2021 18:01:35 +0800 -Subject: [PATCH 077/189] net/hns3: fix some function names for copper media - type - -PHY is a common concept for the copper and optical media type interface. -There are some inappropriate function names for copper ports, which -needs to be adjusted. - -Fixes: 2e4859f3b362 ("net/hns3: support PF device with copper PHYs") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 05f199e..4dff016 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4597,7 +4597,7 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) - } - - static void --hns3_parse_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) -+hns3_parse_copper_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) - { - struct hns3_phy_params_bd0_cmd *req; - -@@ -4615,7 +4615,7 @@ hns3_parse_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) - } - - static int --hns3_get_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) -+hns3_get_copper_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) - { - struct hns3_cmd_desc desc[HNS3_PHY_PARAM_CFG_BD_NUM]; - uint16_t i; -@@ -4634,20 +4634,20 @@ hns3_get_phy_params(struct hns3_hw *hw, struct hns3_mac *mac) - return ret; - } - -- hns3_parse_phy_params(desc, mac); -+ hns3_parse_copper_phy_params(desc, mac); - - return 0; - } - - static int --hns3_update_phy_link_info(struct hns3_hw *hw) -+hns3_update_copper_link_info(struct hns3_hw *hw) - { - struct hns3_mac *mac = &hw->mac; - struct hns3_mac mac_info; - int ret; - - memset(&mac_info, 0, sizeof(struct hns3_mac)); -- ret = hns3_get_phy_params(hw, &mac_info); -+ ret = hns3_get_copper_phy_params(hw, &mac_info); - if (ret) - return ret; - -@@ -4676,7 +4676,7 @@ hns3_update_link_info(struct rte_eth_dev *eth_dev) - int ret = 0; - - if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) -- ret = hns3_update_phy_link_info(hw); -+ ret = hns3_update_copper_link_info(hw); - else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) - ret = hns3_update_fiber_link_info(hw); - --- -2.7.4 - diff --git a/0078-net-hns3-fix-setting-default-MAC-address-in-bonding-.patch b/0078-net-hns3-fix-setting-default-MAC-address-in-bonding-.patch deleted file mode 100644 index 6d5ee19..0000000 --- a/0078-net-hns3-fix-setting-default-MAC-address-in-bonding-.patch +++ /dev/null @@ -1,187 +0,0 @@ -From 3429fe6859a5524353d748e4011f4610aeea781c Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 31 Mar 2021 18:01:36 +0800 -Subject: [PATCH 078/189] net/hns3: fix setting default MAC address in bonding - of VF - -When start testpmd with two hns3 VFs(0000:bd:01.0, 0000:bd:01.7), and -then execute the following commands: - testpmd> create bonded device 1 0 - testpmd> set bonding mac_addr 2 3c:12:34:56:78:9a - testpmd> add bonding slave 0 2 - testpmd> add bonding slave 1 2 - testpmd> set portmask 0x4 - testpmd> port start 2 - -It will occurs the following error in a low probability: - 0000:bd:01.0 hns3_get_mbx_resp(): VF could not get mbx(3,0) - head(16) tail(15) lost(1) from PF in_irq:0 - 0000:bd:01.0 hns3vf_set_default_mac_addr(): Failed to set mac - addr(3C:**:**:**:78:9A) for vf: -62 - mac_address_slaves_update(1541) - Failed to update port Id 0 - MAC address - -The problem replay: -1. The 'port start 2' command will start slave ports and then set slave - mac address, the function call flow: bond_ethdev_start -> - mac_address_slaves_update. -2. There are also a monitor task which running in intr thread will check - slave ports link status and update slave ports mac address, the - function call flow: bond_ethdev_slave_link_status_change_monitor -> - bond_ethdev_lsc_event_callback -> mac_address_slaves_update. -3. Because the above step1&2 running on different threads, they may both - call drivers ops mac_addr_set which is hns3vf_set_default_mac_addr. -4. hns3vf_set_default_mac_addr will first acquire hw.lock and then send - mailbox to PF and wait PF's response message. Note: the PF's - response is an independent message which will received in hw.cmq.crq, - the receiving operation can only performed in intr thread. -5. So if the step1 operation hold the hw.lock and try get response - message, and step2 operation try acquire the hw.lock and so it can't - process the response message, this will lead to step1 fail. - -The solution: -1. make all threads could process the mailbox response message, which - protected by the hw.cmq.crq.lock. -2. use the following rules to avoid deadlock: -2.1. ensure use the correct locking sequence: hw.lock > - hw.mbx_resp.lock > hw.cmq.crq.lock. -2.2. make sure don't acquire such as hw.lock & hw.mbx_resp.lock again - when process mailbox response message. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 1 - - drivers/net/hns3/hns3_ethdev_vf.c | 3 --- - drivers/net/hns3/hns3_mbx.c | 51 +++++++++++---------------------------- - 3 files changed, 14 insertions(+), 41 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 25cb5e2..fc0dc37 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -439,7 +439,6 @@ struct hns3_hw { - struct hns3_cmq cmq; - struct hns3_mbx_resp_status mbx_resp; /* mailbox response */ - struct hns3_mbx_arq_ring arq; /* mailbox async rx queue */ -- pthread_t irq_thread_id; - struct hns3_mac mac; - unsigned int secondary_cnt; /* Number of secondary processes init'd. */ - struct hns3_tqp_stats tqp_stats; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 26f0698..22281c8 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1109,9 +1109,6 @@ hns3vf_interrupt_handler(void *param) - enum hns3vf_evt_cause event_cause; - uint32_t clearval; - -- if (hw->irq_thread_id == 0) -- hw->irq_thread_id = pthread_self(); -- - /* Disable interrupt */ - hns3vf_disable_irq0(hw); - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index e745843..b9190a1 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -40,36 +40,14 @@ hns3_resp_to_errno(uint16_t resp_code) - return -EIO; - } - --static void --hns3_poll_all_sync_msg(void) --{ -- struct rte_eth_dev *eth_dev; -- struct hns3_adapter *adapter; -- const char *name; -- uint16_t port_id; -- -- RTE_ETH_FOREACH_DEV(port_id) { -- eth_dev = &rte_eth_devices[port_id]; -- name = eth_dev->device->driver->name; -- if (strcmp(name, "net_hns3") && strcmp(name, "net_hns3_vf")) -- continue; -- adapter = eth_dev->data->dev_private; -- if (!adapter || adapter->hw.adapter_state == HNS3_NIC_CLOSED) -- continue; -- /* Synchronous msg, the mbx_resp.req_msg_data is non-zero */ -- if (adapter->hw.mbx_resp.req_msg_data) -- hns3_dev_handle_mbx_msg(&adapter->hw); -- } --} -- - static int - hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, - uint8_t *resp_data, uint16_t resp_len) - { - #define HNS3_MAX_RETRY_MS 500 -+#define HNS3_WAIT_RESP_US 100 - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_mbx_resp_status *mbx_resp; -- bool in_irq = false; - uint64_t now; - uint64_t end; - -@@ -96,26 +74,19 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, - return -EIO; - } - -- /* -- * The mbox response is running on the interrupt thread. -- * Sending mbox in the interrupt thread cannot wait for the -- * response, so polling the mbox response on the irq thread. -- */ -- if (pthread_equal(hw->irq_thread_id, pthread_self())) { -- in_irq = true; -- hns3_poll_all_sync_msg(); -- } else { -- rte_delay_ms(HNS3_POLL_RESPONE_MS); -- } -+ hns3_dev_handle_mbx_msg(hw); -+ rte_delay_us(HNS3_WAIT_RESP_US); -+ - now = get_timeofday_ms(); - } - hw->mbx_resp.req_msg_data = 0; - if (now >= end) { - hw->mbx_resp.lost++; - hns3_err(hw, -- "VF could not get mbx(%u,%u) head(%u) tail(%u) lost(%u) from PF in_irq:%d", -+ "VF could not get mbx(%u,%u) head(%u) tail(%u) " -+ "lost(%u) from PF", - code0, code1, hw->mbx_resp.head, hw->mbx_resp.tail, -- hw->mbx_resp.lost, in_irq); -+ hw->mbx_resp.lost); - return -ETIME; - } - rte_io_rmb(); -@@ -368,9 +339,13 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - uint8_t *temp; - int i; - -+ rte_spinlock_lock(&hw->cmq.crq.lock); -+ - while (!hns3_cmd_crq_empty(hw)) { -- if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) -+ if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { -+ rte_spinlock_unlock(&hw->cmq.crq.lock); - return; -+ } - - desc = &crq->desc[crq->next_to_use]; - req = (struct hns3_mbx_pf_to_vf_cmd *)desc->data; -@@ -441,4 +416,6 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - - /* Write back CMDQ_RQ header pointer, IMP need this pointer */ - hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use); -+ -+ rte_spinlock_unlock(&hw->cmq.crq.lock); - } --- -2.7.4 - diff --git a/0079-net-hns3-fix-FLR-miss-detection.patch b/0079-net-hns3-fix-FLR-miss-detection.patch deleted file mode 100644 index 22aba55..0000000 --- a/0079-net-hns3-fix-FLR-miss-detection.patch +++ /dev/null @@ -1,57 +0,0 @@ -From f66e027f9088852b8047f3e6c0e6ff3535c4c172 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Wed, 31 Mar 2021 18:01:37 +0800 -Subject: [PATCH 079/189] net/hns3: fix FLR miss detection - -When FLR occurs, the head pointer register of -the command queue will be cleared, resulting in -abnormal detection of the head pointer register -of the command queue. At present, FLR is detected -in this way, and the reset recovery process is -executed. - -However, when FLR occurs, the header pointer -register of the command queue is not necessarily -abnormal. For example, when the driver runs -normally, the value of the header pointer register -of the command queue may also be 0, which will -lead to the miss detection of FLR. - -Therefore, the judgment that whether the base -address register of command queue is 0 is added -to ensure that FLR not miss detection. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index f8d8b0a..1bf1c32 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -195,12 +195,14 @@ hns3_cmd_csq_clean(struct hns3_hw *hw) - { - struct hns3_cmq_ring *csq = &hw->cmq.csq; - uint32_t head; -+ uint32_t addr; - int clean; - - head = hns3_read_dev(hw, HNS3_CMDQ_TX_HEAD_REG); -- if (!is_valid_csq_clean_head(csq, head)) { -- hns3_err(hw, "wrong cmd head (%u, %u-%u)", head, -- csq->next_to_use, csq->next_to_clean); -+ addr = hns3_read_dev(hw, HNS3_CMDQ_TX_ADDR_L_REG); -+ if (!is_valid_csq_clean_head(csq, head) || addr == 0) { -+ hns3_err(hw, "wrong cmd addr(%0x) head (%u, %u-%u)", addr, head, -+ csq->next_to_use, csq->next_to_clean); - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - __atomic_store_n(&hw->reset.disable_cmd, 1, - __ATOMIC_RELAXED); --- -2.7.4 - diff --git a/0080-net-hns3-fix-rollback-after-setting-PVID-failure.patch b/0080-net-hns3-fix-rollback-after-setting-PVID-failure.patch deleted file mode 100644 index 5e0b410..0000000 --- a/0080-net-hns3-fix-rollback-after-setting-PVID-failure.patch +++ /dev/null @@ -1,75 +0,0 @@ -From cb332ad8f8abb2973606f877024867deba6a6ec3 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 31 Mar 2021 18:01:38 +0800 -Subject: [PATCH 080/189] net/hns3: fix rollback after setting PVID failure - -Currently, three hardware operations are involved in setting the PVID. -If any operation fails, a failure will be returned. And there may be -residual hardware configurations because no rollback is performed. - -This patch adds rollback operation for setting PVID to avoid residual -hardware configuration after the PVID fails to be configured. - -Fixes: 411d23b9eafb ("net/hns3: support VLAN") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 20 +++++++++++++++++--- - 1 file changed, 17 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 4dff016..4984ff9 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -981,7 +981,7 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) - { - struct hns3_hw *hw = &hns->hw; - uint16_t port_base_vlan_state; -- int ret; -+ int ret, err; - - if (on == 0 && pvid != hw->port_base_vlan_cfg.pvid) { - if (hw->port_base_vlan_cfg.pvid != HNS3_INVALID_PVID) -@@ -1004,7 +1004,7 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) - if (ret) { - hns3_err(hw, "failed to config rx vlan strip for pvid, " - "ret = %d", ret); -- return ret; -+ goto pvid_vlan_strip_fail; - } - - if (pvid == HNS3_INVALID_PVID) -@@ -1013,13 +1013,27 @@ hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, int on) - if (ret) { - hns3_err(hw, "failed to update vlan filter entries, ret = %d", - ret); -- return ret; -+ goto vlan_filter_set_fail; - } - - out: - hw->port_base_vlan_cfg.state = port_base_vlan_state; - hw->port_base_vlan_cfg.pvid = on ? pvid : HNS3_INVALID_PVID; - return ret; -+ -+vlan_filter_set_fail: -+ err = hns3_en_pvid_strip(hns, hw->port_base_vlan_cfg.state == -+ HNS3_PORT_BASE_VLAN_ENABLE); -+ if (err) -+ hns3_err(hw, "fail to rollback pvid strip, ret = %d", err); -+ -+pvid_vlan_strip_fail: -+ err = hns3_vlan_txvlan_cfg(hns, hw->port_base_vlan_cfg.state, -+ hw->port_base_vlan_cfg.pvid); -+ if (err) -+ hns3_err(hw, "fail to rollback txvlan status, ret = %d", err); -+ -+ return ret; - } - - static int --- -2.7.4 - diff --git a/0081-net-hns3-fix-flow-control-exception.patch b/0081-net-hns3-fix-flow-control-exception.patch deleted file mode 100644 index e26359c..0000000 --- a/0081-net-hns3-fix-flow-control-exception.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 21b64900224a9d81aee3ee20349073f18c5c927f Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 31 Mar 2021 18:01:39 +0800 -Subject: [PATCH 081/189] net/hns3: fix flow control exception - -In multi-TC scenarios, MAC pause is not supported. Otherwise, only -TC0 can trigger pause frames, and other TCs cannot trigger pause -frames. In this case, flow control does not meet the expectation. - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 4984ff9..6f3502f 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5554,6 +5554,11 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - return -EOPNOTSUPP; - } - -+ if (hw->num_tc > 1) { -+ hns3_err(hw, "in multi-TC scenarios, MAC pause is not supported."); -+ return -EOPNOTSUPP; -+ } -+ - hns3_get_fc_mode(hw, fc_conf->mode); - if (hw->requested_mode == hw->current_mode && - pf->pause_time == fc_conf->pause_time) --- -2.7.4 - diff --git a/0082-net-hns3-fix-flow-counter-value.patch b/0082-net-hns3-fix-flow-counter-value.patch deleted file mode 100644 index eb18115..0000000 --- a/0082-net-hns3-fix-flow-counter-value.patch +++ /dev/null @@ -1,53 +0,0 @@ -From c75bc1ba60e3af6a8751048a912a01175d940833 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 31 Mar 2021 18:01:40 +0800 -Subject: [PATCH 082/189] net/hns3: fix flow counter value - -User could create flow rules with specified counter by the action of -RTE_FLOW_ACTION_TYPE_COUNT, but the counter may retain the original -value when create. - -This patch fix the bug by read the counter when creating the rule -because the counter is read-clear. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_flow.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index a016857..3cca416 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -158,7 +158,10 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, - { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_pf *pf = &hns->pf; -+ struct hns3_hw *hw = &hns->hw; - struct hns3_flow_counter *cnt; -+ uint64_t value; -+ int ret; - - cnt = hns3_counter_lookup(dev, id); - if (cnt) { -@@ -171,6 +174,13 @@ hns3_counter_new(struct rte_eth_dev *dev, uint32_t shared, uint32_t id, - return 0; - } - -+ /* Clear the counter by read ops because the counter is read-clear */ -+ ret = hns3_get_count(hw, id, &value); -+ if (ret) -+ return rte_flow_error_set(error, EIO, -+ RTE_FLOW_ERROR_TYPE_HANDLE, NULL, -+ "Clear counter failed!"); -+ - cnt = rte_zmalloc("hns3 counter", sizeof(*cnt), 0); - if (cnt == NULL) - return rte_flow_error_set(error, ENOMEM, --- -2.7.4 - diff --git a/0083-net-hns3-fix-VF-mailbox-head-field.patch b/0083-net-hns3-fix-VF-mailbox-head-field.patch deleted file mode 100644 index 3e1642d..0000000 --- a/0083-net-hns3-fix-VF-mailbox-head-field.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 4c2dcb5bd22a65d3b30ca64e5c96f67c3b9f5e7e Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 31 Mar 2021 18:01:41 +0800 -Subject: [PATCH 083/189] net/hns3: fix VF mailbox head field - -Currently, the VF mailbox synchronization communication is based on -three fields: head/tail/lost, when head equals tail plus lost, it -means the response is received successfully. - -The head field indicates the number of requests that are successfully -sent. If the request sending fails, it should not be updated. - -This patch fix the above bug by roll back updates when the sending -fails. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index b9190a1..7357d7f 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -142,6 +142,7 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - hw->mbx_resp.head++; - ret = hns3_cmd_send(hw, &desc, 1); - if (ret) { -+ hw->mbx_resp.head--; - rte_spinlock_unlock(&hw->mbx_resp.lock); - hns3_err(hw, "VF failed(=%d) to send mbx message to PF", - ret); --- -2.7.4 - diff --git a/0084-net-hns3-support-get-device-version-when-dump-regist.patch b/0084-net-hns3-support-get-device-version-when-dump-regist.patch deleted file mode 100644 index 074bdd7..0000000 --- a/0084-net-hns3-support-get-device-version-when-dump-regist.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 07e64207da01090076fc5066fed401caf89fc20e Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 31 Mar 2021 18:01:42 +0800 -Subject: [PATCH 084/189] net/hns3: support get device version when dump - register - -Support get device version which is equal to the firmware version -when dump register. - -Fixes: 936eda25e8da ("net/hns3: support dump register") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_regs.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index 93055a4..374b9ea 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -499,6 +499,8 @@ hns3_get_regs(struct rte_eth_dev *eth_dev, struct rte_dev_reg_info *regs) - if (regs->length && regs->length != length) - return -ENOTSUP; - -+ regs->version = hw->fw_version; -+ - /* fetching per-PF registers values from PF PCIe register space */ - data += hns3_direct_access_regs(hw, data); - --- -2.7.4 - diff --git a/0085-net-hns3-delete-redundant-blank-line.patch b/0085-net-hns3-delete-redundant-blank-line.patch deleted file mode 100644 index 1c2ebab..0000000 --- a/0085-net-hns3-delete-redundant-blank-line.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 59aed028f457ad2f029b85d48bcdf9c9678b3b07 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Wed, 31 Mar 2021 18:01:43 +0800 -Subject: [PATCH 085/189] net/hns3: delete redundant blank line - -Delete redundant blank line in "hns3vf_check_event_cause" to -solve the static warning. - -Fixes: a5475d61fa34 ("net/hns3: support VF") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev_vf.c | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 22281c8..2a302e5 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1064,7 +1064,6 @@ hns3vf_check_event_cause(struct hns3_adapter *hns, uint32_t *clearval) - - /* Fetch the events from their corresponding regs */ - cmdq_stat_reg = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_STAT_REG); -- - if (BIT(HNS3_VECTOR0_RST_INT_B) & cmdq_stat_reg) { - rst_ing_reg = hns3_read_dev(hw, HNS3_FUN_RST_ING); - hns3_warn(hw, "resetting reg: 0x%x", rst_ing_reg); --- -2.7.4 - diff --git a/0086-net-hns3-fix-code-style.patch b/0086-net-hns3-fix-code-style.patch deleted file mode 100644 index 1f215e6..0000000 --- a/0086-net-hns3-fix-code-style.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 65df0c1e556bfcbb39382da267141676a894decd Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Wed, 31 Mar 2021 18:01:44 +0800 -Subject: [PATCH 086/189] net/hns3: fix code style - -Add one space before the left brace to solve the static warning. - -Fixes: 63e05f19b82b ("net/hns3: support Rx descriptor status query") - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index c41cccb..b06b723 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4477,7 +4477,7 @@ hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) - if (offset >= rxq->nb_rx_desc - rxq->rx_free_hold) - return RTE_ETH_RX_DESC_UNAVAIL; - } else if (dev->rx_pkt_burst == hns3_recv_pkts_vec || -- dev->rx_pkt_burst == hns3_recv_pkts_vec_sve){ -+ dev->rx_pkt_burst == hns3_recv_pkts_vec_sve) { - if (offset >= rxq->nb_rx_desc - rxq->rx_rearm_nb) - return RTE_ETH_RX_DESC_UNAVAIL; - } else { --- -2.7.4 - diff --git a/0087-net-hns3-refactor-VF-LSC-event-report.patch b/0087-net-hns3-refactor-VF-LSC-event-report.patch deleted file mode 100644 index 7dd6c79..0000000 --- a/0087-net-hns3-refactor-VF-LSC-event-report.patch +++ /dev/null @@ -1,464 +0,0 @@ -From 053fca7a826300094e247e01c6376ba72f611673 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 9 Apr 2021 12:45:21 +0800 -Subject: [PATCH 087/189] net/hns3: refactor VF LSC event report - -Currently, VF driver periodically obtains link status from PF kernel -driver, and reports lsc event when detects link status change. Because -the period is 1 second, it's probably too late to report especially -in such as bonding scenario. - -To solve this problem we use the following scheme: -1. PF kernel driver support immediate push link status to all VFs when - it detects the link status changes. -2. VF driver will detect PF kernel driver whether support push link - status in device init stage by sending request link info mailbox - message to PF, PF then tell VF the push capability by extend - HNS3_MBX_LINK_STAT_CHANGE mailbox message. -3. VF driver marks RTE_PCI_DRV_INTR_LSC in rte_pci_driver by default, - when it detects PF doesn't support push link status then it will clear - RTE_ETH_DEV_INTR_LSC flag. - -So if PF kernel driver supports push link status to VF, then VF driver -will have RTE_ETH_DEV_INTR_LSC capability. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/features/hns3_vf.ini | 1 + - drivers/net/hns3/hns3_ethdev.h | 27 ++++++ - drivers/net/hns3/hns3_ethdev_vf.c | 171 ++++++++++++++++++++++++++++------- - drivers/net/hns3/hns3_intr.c | 30 ++++++ - drivers/net/hns3/hns3_intr.h | 2 + - drivers/net/hns3/hns3_mbx.c | 3 + - 6 files changed, 199 insertions(+), 35 deletions(-) - -diff --git a/doc/guides/nics/features/hns3_vf.ini b/doc/guides/nics/features/hns3_vf.ini -index a0fd56d..22bb890 100644 ---- a/doc/guides/nics/features/hns3_vf.ini -+++ b/doc/guides/nics/features/hns3_vf.ini -@@ -5,6 +5,7 @@ - ; - [Features] - Link status = Y -+Link status event = Y - Rx interrupt = Y - Queue start/stop = Y - Runtime Rx queue setup = Y -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index fc0dc37..dcf14d6 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -763,8 +763,26 @@ struct hns3_pf { - struct hns3_tm_conf tm_conf; - }; - -+enum { -+ HNS3_PF_PUSH_LSC_CAP_NOT_SUPPORTED, -+ HNS3_PF_PUSH_LSC_CAP_SUPPORTED, -+ HNS3_PF_PUSH_LSC_CAP_UNKNOWN -+}; -+ - struct hns3_vf { - struct hns3_adapter *adapter; -+ -+ /* Whether PF support push link status change to VF */ -+ uint16_t pf_push_lsc_cap; -+ -+ /* -+ * If PF support push link status change, VF still need send request to -+ * get link status in some cases (such as reset recover stage), so use -+ * the req_link_info_cnt to control max request count. -+ */ -+ uint16_t req_link_info_cnt; -+ -+ uint16_t poll_job_started; /* whether poll job is started */ - }; - - struct hns3_adapter { -@@ -849,6 +867,8 @@ enum { - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ - (&((struct hns3_adapter *)adapter)->pf) -+#define HNS3_DEV_PRIVATE_TO_VF(adapter) \ -+ (&((struct hns3_adapter *)adapter)->vf) - #define HNS3_DEV_HW_TO_ADAPTER(hw) \ - container_of(hw, struct hns3_adapter, hw) - -@@ -858,6 +878,12 @@ static inline struct hns3_pf *HNS3_DEV_HW_TO_PF(struct hns3_hw *hw) - return &adapter->pf; - } - -+static inline struct hns3_vf *HNS3_DEV_HW_TO_VF(struct hns3_hw *hw) -+{ -+ struct hns3_adapter *adapter = HNS3_DEV_HW_TO_ADAPTER(hw); -+ return &adapter->vf; -+} -+ - #define hns3_set_field(origin, mask, shift, val) \ - do { \ - (origin) &= (~(mask)); \ -@@ -1004,6 +1030,7 @@ int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, - void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); - void hns3_parse_devargs(struct rte_eth_dev *dev); -+void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); - int hns3_restore_ptp(struct hns3_adapter *hns); - int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, - struct rte_eth_conf *conf); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 2a302e5..13f92da 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -44,6 +44,9 @@ static int hns3vf_add_mc_mac_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); - static int hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); -+static int hns3vf_dev_link_update(struct rte_eth_dev *eth_dev, -+ __rte_unused int wait_to_complete); -+ - /* set PCI bus mastering */ - static int - hns3vf_set_bus_master(const struct rte_pci_device *device, bool op) -@@ -1191,6 +1194,65 @@ hns3vf_query_dev_specifications(struct hns3_hw *hw) - return hns3vf_check_dev_specifications(hw); - } - -+void -+hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported) -+{ -+ uint16_t val = supported ? HNS3_PF_PUSH_LSC_CAP_SUPPORTED : -+ HNS3_PF_PUSH_LSC_CAP_NOT_SUPPORTED; -+ uint16_t exp = HNS3_PF_PUSH_LSC_CAP_UNKNOWN; -+ struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); -+ -+ if (vf->pf_push_lsc_cap == HNS3_PF_PUSH_LSC_CAP_UNKNOWN) -+ __atomic_compare_exchange(&vf->pf_push_lsc_cap, &exp, &val, 0, -+ __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE); -+} -+ -+static void -+hns3vf_get_push_lsc_cap(struct hns3_hw *hw) -+{ -+#define HNS3_CHECK_PUSH_LSC_CAP_TIMEOUT_MS 500 -+ -+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ int32_t remain_ms = HNS3_CHECK_PUSH_LSC_CAP_TIMEOUT_MS; -+ uint16_t val = HNS3_PF_PUSH_LSC_CAP_NOT_SUPPORTED; -+ uint16_t exp = HNS3_PF_PUSH_LSC_CAP_UNKNOWN; -+ struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); -+ -+ __atomic_store_n(&vf->pf_push_lsc_cap, HNS3_PF_PUSH_LSC_CAP_UNKNOWN, -+ __ATOMIC_RELEASE); -+ -+ (void)hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false, -+ NULL, 0); -+ -+ while (remain_ms > 0) { -+ rte_delay_ms(HNS3_POLL_RESPONE_MS); -+ if (__atomic_load_n(&vf->pf_push_lsc_cap, __ATOMIC_ACQUIRE) != -+ HNS3_PF_PUSH_LSC_CAP_UNKNOWN) -+ break; -+ remain_ms--; -+ } -+ -+ /* -+ * When exit above loop, the pf_push_lsc_cap could be one of the three -+ * state: unknown (means pf not ack), not_supported, supported. -+ * Here config it as 'not_supported' when it's 'unknown' state. -+ */ -+ __atomic_compare_exchange(&vf->pf_push_lsc_cap, &exp, &val, 0, -+ __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE); -+ -+ if (__atomic_load_n(&vf->pf_push_lsc_cap, __ATOMIC_ACQUIRE) == -+ HNS3_PF_PUSH_LSC_CAP_SUPPORTED) { -+ hns3_info(hw, "detect PF support push link status change!"); -+ } else { -+ /* -+ * Framework already set RTE_ETH_DEV_INTR_LSC bit because driver -+ * declared RTE_PCI_DRV_INTR_LSC in drv_flags. So here cleared -+ * the RTE_ETH_DEV_INTR_LSC capability. -+ */ -+ dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC; -+ } -+} -+ - static int - hns3vf_get_capability(struct hns3_hw *hw) - { -@@ -1404,6 +1466,8 @@ hns3vf_get_configuration(struct hns3_hw *hw) - return ret; - } - -+ hns3vf_get_push_lsc_cap(hw); -+ - /* Get queue configuration from PF */ - ret = hns3vf_get_queue_info(hw); - if (ret) -@@ -1451,15 +1515,28 @@ hns3vf_set_tc_queue_mapping(struct hns3_adapter *hns, uint16_t nb_rx_q, - static void - hns3vf_request_link_info(struct hns3_hw *hw) - { -+ struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); - uint8_t resp_msg; -+ bool send_req; - int ret; - - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) - return; -+ -+ send_req = vf->pf_push_lsc_cap == HNS3_PF_PUSH_LSC_CAP_NOT_SUPPORTED || -+ vf->req_link_info_cnt > 0; -+ if (!send_req) -+ return; -+ - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false, - &resp_msg, sizeof(resp_msg)); -- if (ret) -- hns3_err(hw, "Failed to fetch link status from PF: %d", ret); -+ if (ret) { -+ hns3_err(hw, "failed to fetch link status, ret = %d", ret); -+ return; -+ } -+ -+ if (vf->req_link_info_cnt > 0) -+ vf->req_link_info_cnt--; - } - - void -@@ -1467,34 +1544,30 @@ hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex) - { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); - struct hns3_mac *mac = &hw->mac; -- bool report_lse; -- bool changed; -- -- changed = mac->link_status != link_status || -- mac->link_speed != link_speed || -- mac->link_duplex != link_duplex; -- if (!changed) -- return; -+ int ret; - - /* -- * VF's link status/speed/duplex were updated by polling from PF driver, -- * because the link status/speed/duplex may be changed in the polling -- * interval, so driver will report lse (lsc event) once any of the above -- * thress variables changed. -- * But if the PF's link status is down and driver saved link status is -- * also down, there are no need to report lse. -+ * PF kernel driver may push link status when VF driver is in resetting, -+ * driver will stop polling job in this case, after resetting done -+ * driver will start polling job again. -+ * When polling job started, driver will get initial link status by -+ * sending request to PF kernel driver, then could update link status by -+ * process PF kernel driver's link status mailbox message. - */ -- report_lse = true; -- if (link_status == ETH_LINK_DOWN && link_status == mac->link_status) -- report_lse = false; -+ if (!__atomic_load_n(&vf->poll_job_started, __ATOMIC_RELAXED)) -+ return; -+ -+ if (hw->adapter_state != HNS3_NIC_STARTED) -+ return; - - mac->link_status = link_status; - mac->link_speed = link_speed; - mac->link_duplex = link_duplex; -- -- if (report_lse) -- rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); -+ ret = hns3vf_dev_link_update(dev, 0); -+ if (ret == 0 && dev->data->dev_conf.intr_conf.lsc != 0) -+ hns3_start_report_lse(dev); - } - - static int -@@ -1710,8 +1783,8 @@ hns3vf_service_handler(void *param) - - /* - * The query link status and reset processing are executed in the -- * interrupt thread.When the IMP reset occurs, IMP will not respond, -- * and the query operation will time out after 30ms. In the case of -+ * interrupt thread. When the IMP reset occurs, IMP will not respond, -+ * and the query operation will timeout after 30ms. In the case of - * multiple PF/VFs, each query failure timeout causes the IMP reset - * interrupt to fail to respond within 100ms. - * Before querying the link status, check whether there is a reset -@@ -1726,6 +1799,31 @@ hns3vf_service_handler(void *param) - eth_dev); - } - -+static void -+hns3vf_start_poll_job(struct rte_eth_dev *dev) -+{ -+#define HNS3_REQUEST_LINK_INFO_REMAINS_CNT 3 -+ -+ struct hns3_vf *vf = HNS3_DEV_PRIVATE_TO_VF(dev->data->dev_private); -+ -+ if (vf->pf_push_lsc_cap == HNS3_PF_PUSH_LSC_CAP_SUPPORTED) -+ vf->req_link_info_cnt = HNS3_REQUEST_LINK_INFO_REMAINS_CNT; -+ -+ __atomic_store_n(&vf->poll_job_started, 1, __ATOMIC_RELAXED); -+ -+ hns3vf_service_handler(dev); -+} -+ -+static void -+hns3vf_stop_poll_job(struct rte_eth_dev *dev) -+{ -+ struct hns3_vf *vf = HNS3_DEV_PRIVATE_TO_VF(dev->data->dev_private); -+ -+ rte_eal_alarm_cancel(hns3vf_service_handler, dev); -+ -+ __atomic_store_n(&vf->poll_job_started, 0, __ATOMIC_RELAXED); -+} -+ - static int - hns3_query_vf_resource(struct hns3_hw *hw) - { -@@ -2032,7 +2130,8 @@ hns3vf_dev_stop(struct rte_eth_dev *dev) - hw->adapter_state = HNS3_NIC_CONFIGURED; - } - hns3_rx_scattered_reset(dev); -- rte_eal_alarm_cancel(hns3vf_service_handler, dev); -+ hns3vf_stop_poll_job(dev); -+ hns3_stop_report_lse(dev); - rte_spinlock_unlock(&hw->lock); - - return 0; -@@ -2302,19 +2401,17 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - hns3_rx_scattered_calc(dev); - hns3_set_rxtx_function(dev); - hns3_mp_req_start_rxtx(dev); -- hns3vf_service_handler(dev); - - hns3vf_restore_filter(dev); - - /* Enable interrupt of all rx queues before enabling queues */ - hns3_dev_all_rx_queue_intr_enable(hw, true); -- -- /* -- * After finished the initialization, start all tqps to receive/transmit -- * packets and refresh all queue status. -- */ - hns3_start_tqps(hw); - -+ if (dev->data->dev_conf.intr_conf.lsc != 0) -+ hns3vf_dev_link_update(dev, 0); -+ hns3vf_start_poll_job(dev); -+ - return ret; - - start_all_rxqs_fail: -@@ -2454,9 +2551,13 @@ hns3vf_stop_service(struct hns3_adapter *hns) - - eth_dev = &rte_eth_devices[hw->data->port_id]; - if (hw->adapter_state == HNS3_NIC_STARTED) { -- rte_eal_alarm_cancel(hns3vf_service_handler, eth_dev); -+ /* -+ * Make sure call update link status before hns3vf_stop_poll_job -+ * because update link status depend on polling job exist. -+ */ - hns3vf_update_link_status(hw, ETH_LINK_DOWN, hw->mac.link_speed, -- hw->mac.link_duplex); -+ hw->mac.link_duplex); -+ hns3vf_stop_poll_job(eth_dev); - } - hw->mac.link_status = ETH_LINK_DOWN; - -@@ -2497,7 +2598,7 @@ hns3vf_start_service(struct hns3_adapter *hns) - hns3_set_rxtx_function(eth_dev); - hns3_mp_req_start_rxtx(eth_dev); - if (hw->adapter_state == HNS3_NIC_STARTED) { -- hns3vf_service_handler(eth_dev); -+ hns3vf_start_poll_job(eth_dev); - - /* Enable interrupt of all rx queues before enabling queues */ - hns3_dev_all_rx_queue_intr_enable(hw, true); -@@ -2968,7 +3069,7 @@ static const struct rte_pci_id pci_id_hns3vf_map[] = { - - static struct rte_pci_driver rte_hns3vf_pmd = { - .id_table = pci_id_hns3vf_map, -- .drv_flags = RTE_PCI_DRV_NEED_MAPPING, -+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, - .probe = eth_hns3vf_pci_probe, - .remove = eth_hns3vf_pci_remove, - }; -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index c259f2e..6250c36 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2614,3 +2614,33 @@ hns3_reset_abort(struct hns3_adapter *hns) - reset_string[hw->reset.level], tv.tv_sec, tv.tv_usec); - } - } -+ -+static void -+hns3_report_lse(void *arg) -+{ -+ struct rte_eth_dev *dev = (struct rte_eth_dev *)arg; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ -+ if (hw->adapter_state == HNS3_NIC_STARTED) -+ rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); -+} -+ -+void -+hns3_start_report_lse(struct rte_eth_dev *dev) -+{ -+#define DELAY_REPORT_LSE_US 1 -+ /* -+ * When this function called, the context may hold hns3_hw.lock, if -+ * report lse right now, in some application such as bonding, it will -+ * trigger call driver's ops which may acquire hns3_hw.lock again, so -+ * lead to deadlock. -+ * Here we use delay report to avoid the deadlock. -+ */ -+ rte_eal_alarm_set(DELAY_REPORT_LSE_US, hns3_report_lse, dev); -+} -+ -+void -+hns3_stop_report_lse(struct rte_eth_dev *dev) -+{ -+ rte_eal_alarm_cancel(hns3_report_lse, dev); -+} -diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h -index c569a9d..4a0a731 100644 ---- a/drivers/net/hns3/hns3_intr.h -+++ b/drivers/net/hns3/hns3_intr.h -@@ -115,5 +115,7 @@ int hns3_reset_req_hw_reset(struct hns3_adapter *hns); - int hns3_reset_process(struct hns3_adapter *hns, - enum hns3_reset_level reset_level); - void hns3_reset_abort(struct hns3_adapter *hns); -+void hns3_start_report_lse(struct rte_eth_dev *dev); -+void hns3_stop_report_lse(struct rte_eth_dev *dev); - - #endif /* _HNS3_INTR_H_ */ -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 7357d7f..ea2953e 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -177,6 +177,7 @@ hns3_mbx_handler(struct hns3_hw *hw) - { - enum hns3_reset_level reset_level; - uint8_t link_status, link_duplex; -+ uint8_t support_push_lsc; - uint32_t link_speed; - uint16_t *msg_q; - uint8_t opcode; -@@ -196,6 +197,8 @@ hns3_mbx_handler(struct hns3_hw *hw) - link_duplex = (uint8_t)rte_le_to_cpu_16(msg_q[4]); - hns3vf_update_link_status(hw, link_status, link_speed, - link_duplex); -+ support_push_lsc = (*(uint8_t *)&msg_q[5]) & 1u; -+ hns3vf_update_push_lsc_cap(hw, support_push_lsc); - break; - case HNS3_MBX_ASSERTING_RESET: - /* PF has asserted reset hence VF should go in pending --- -2.7.4 - diff --git a/0088-net-hns3-refactor-PF-LSC-event-report.patch b/0088-net-hns3-refactor-PF-LSC-event-report.patch deleted file mode 100644 index dea3358..0000000 --- a/0088-net-hns3-refactor-PF-LSC-event-report.patch +++ /dev/null @@ -1,242 +0,0 @@ -From 4190f95f69d9dde53221a65d44672bc61e100419 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 9 Apr 2021 12:45:22 +0800 -Subject: [PATCH 088/189] net/hns3: refactor PF LSC event report - -Currently, PF driver will report lsc when it detects the link status -change, it's not a generic implementation. - -We refactor PF lsc event report by following scheme: -1. PF driver marks RTE_PCI_DRV_INTR_LSC in rte_pci_driver by default. -2. In the init stage, PF driver will detect whether firmware supports - lsc interrupt or not, driver will clear RTE_ETH_DEV_INTR_LSC flag if - firmware doesn't support lsc interrupt. -3. PF driver will report lsc event only when dev_conf.intr_conf.lsc is - set. - -Note: If the firmware supports lsc interrupt, we also keep periodic -polling to deal with the interrupt loss. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/features/hns3.ini | 1 + - drivers/net/hns3/hns3_ethdev.c | 85 ++++++++++++++++++++++++--------------- - drivers/net/hns3/hns3_ethdev.h | 2 +- - drivers/net/hns3/hns3_mbx.c | 2 +- - 4 files changed, 56 insertions(+), 34 deletions(-) - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index cc1ad0f..d1a493b 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -5,6 +5,7 @@ - ; - [Features] - Link status = Y -+Link status event = Y - Rx interrupt = Y - Queue start/stop = Y - Runtime Rx queue setup = Y -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 6f3502f..54c72e9 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2753,10 +2753,15 @@ static int - hns3_update_port_link_info(struct rte_eth_dev *eth_dev) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); -+ int ret; - - (void)hns3_update_link_status(hw); - -- return hns3_update_link_info(eth_dev); -+ ret = hns3_update_link_info(eth_dev); -+ if (ret) -+ hw->mac.link_status = ETH_LINK_DOWN; -+ -+ return ret; - } - - static void -@@ -2807,7 +2812,6 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete) - do { - ret = hns3_update_port_link_info(eth_dev); - if (ret) { -- mac->link_status = ETH_LINK_DOWN; - hns3_err(hw, "failed to get port link info, ret = %d.", - ret); - break; -@@ -4780,30 +4784,22 @@ hns3_update_link_status(struct hns3_hw *hw) - return false; - } - --/* -- * Current, the PF driver get link status by two ways: -- * 1) Periodic polling in the intr thread context, driver call -- * hns3_update_link_status to update link status. -- * 2) Firmware report async interrupt, driver process the event in the intr -- * thread context, and call hns3_update_link_status to update link status. -- * -- * If detect link status changed, driver need report LSE. One method is add the -- * report LSE logic in hns3_update_link_status. -- * -- * But the PF driver ops(link_update) also call hns3_update_link_status to -- * update link status. -- * If we report LSE in hns3_update_link_status, it may lead to deadlock in the -- * bonding application. -- * -- * So add the one new API which used only in intr thread context. -- */ - void --hns3_update_link_status_and_event(struct hns3_hw *hw) -+hns3_update_linkstatus_and_event(struct hns3_hw *hw, bool query) - { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -- bool changed = hns3_update_link_status(hw); -- if (changed) -- rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL); -+ struct rte_eth_link new_link; -+ int ret; -+ -+ if (query) -+ hns3_update_port_link_info(dev); -+ -+ memset(&new_link, 0, sizeof(new_link)); -+ hns3_setup_linkstatus(dev, &new_link); -+ -+ ret = rte_eth_linkstatus_set(dev, &new_link); -+ if (ret == 0 && dev->data->dev_conf.intr_conf.lsc != 0) -+ hns3_start_report_lse(dev); - } - - static void -@@ -4813,16 +4809,36 @@ hns3_service_handler(void *param) - struct hns3_adapter *hns = eth_dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - -- if (!hns3_is_reset_pending(hns)) { -- hns3_update_link_status_and_event(hw); -- hns3_update_link_info(eth_dev); -- } else { -+ if (!hns3_is_reset_pending(hns)) -+ hns3_update_linkstatus_and_event(hw, true); -+ else - hns3_warn(hw, "Cancel the query when reset is pending"); -- } - - rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev); - } - -+static void -+hns3_update_dev_lsc_cap(struct hns3_hw *hw, -+ int fw_compact_cmd_result) -+{ -+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ -+ if (hw->adapter_state != HNS3_NIC_UNINITIALIZED) -+ return; -+ -+ if (fw_compact_cmd_result != 0) { -+ /* -+ * If fw_compact_cmd_result is not zero, it means firmware don't -+ * support link status change interrupt. -+ * Framework already set RTE_ETH_DEV_INTR_LSC bit because driver -+ * declared RTE_PCI_DRV_INTR_LSC in drv_flags. It need to clear -+ * the RTE_ETH_DEV_INTR_LSC capability when detect firmware -+ * don't support link status change interrupt. -+ */ -+ dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC; -+ } -+} -+ - static int - hns3_init_hardware(struct hns3_adapter *hns) - { -@@ -4910,6 +4926,7 @@ hns3_init_hardware(struct hns3_adapter *hns) - if (ret) - PMD_INIT_LOG(WARNING, "firmware compatible features not " - "supported, ret = %d.", ret); -+ hns3_update_dev_lsc_cap(hw, ret); - - return 0; - -@@ -5302,7 +5319,6 @@ hns3_dev_start(struct rte_eth_dev *dev) - hns3_rx_scattered_calc(dev); - hns3_set_rxtx_function(dev); - hns3_mp_req_start_rxtx(dev); -- rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, dev); - - hns3_restore_filter(dev); - -@@ -5317,6 +5333,10 @@ hns3_dev_start(struct rte_eth_dev *dev) - - hns3_tm_dev_start_proc(hw); - -+ if (dev->data->dev_conf.intr_conf.lsc != 0) -+ hns3_dev_link_update(dev, 0); -+ rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, dev); -+ - hns3_info(hw, "hns3 dev start successful!"); - - return 0; -@@ -5430,6 +5450,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) - } - hns3_rx_scattered_reset(dev); - rte_eal_alarm_cancel(hns3_service_handler, dev); -+ hns3_stop_report_lse(dev); - rte_spinlock_unlock(&hw->lock); - - return 0; -@@ -5933,11 +5954,11 @@ hns3_stop_service(struct hns3_adapter *hns) - struct rte_eth_dev *eth_dev; - - eth_dev = &rte_eth_devices[hw->data->port_id]; -+ hw->mac.link_status = ETH_LINK_DOWN; - if (hw->adapter_state == HNS3_NIC_STARTED) { - rte_eal_alarm_cancel(hns3_service_handler, eth_dev); -- hns3_update_link_status_and_event(hw); -+ hns3_update_linkstatus_and_event(hw, false); - } -- hw->mac.link_status = ETH_LINK_DOWN; - - hns3_set_rxtx_function(eth_dev); - rte_wmb(); -@@ -6939,7 +6960,7 @@ static const struct rte_pci_id pci_id_hns3_map[] = { - - static struct rte_pci_driver rte_hns3_pmd = { - .id_table = pci_id_hns3_map, -- .drv_flags = RTE_PCI_DRV_NEED_MAPPING, -+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC, - .probe = eth_hns3_pci_probe, - .remove = eth_hns3_pci_remove, - }; -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index dcf14d6..585eeaf 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1022,7 +1022,7 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, - enum rte_filter_op filter_op, void *arg); - bool hns3_is_reset_pending(struct hns3_adapter *hns); - bool hns3vf_is_reset_pending(struct hns3_adapter *hns); --void hns3_update_link_status_and_event(struct hns3_hw *hw); -+void hns3_update_linkstatus_and_event(struct hns3_hw *hw, bool query); - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr); - int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index ea2953e..2a96f6c 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -287,7 +287,7 @@ hns3_handle_link_change_event(struct hns3_hw *hw, - if (!req->msg[LINK_STATUS_OFFSET]) - hns3_link_fail_parse(hw, req->msg[LINK_FAIL_CODE_OFFSET]); - -- hns3_update_link_status_and_event(hw); -+ hns3_update_linkstatus_and_event(hw, true); - } - - static void --- -2.7.4 - diff --git a/0089-net-hns3-log-selected-datapath.patch b/0089-net-hns3-log-selected-datapath.patch deleted file mode 100644 index 6f9bb8b..0000000 --- a/0089-net-hns3-log-selected-datapath.patch +++ /dev/null @@ -1,51 +0,0 @@ -From b9cd59d3f64c7a594fa9b7cbaa3907788fe4696f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 9 Apr 2021 18:26:43 +0800 -Subject: [PATCH 089/189] net/hns3: log selected datapath - -This patch adds debug info for Rx/Tx burst function which was choosing. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 17 +++++++++++++++++ - 1 file changed, 17 insertions(+) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index b06b723..e81344c 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4231,6 +4231,22 @@ hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused, - return 0; - } - -+static void -+hns3_trace_rxtx_function(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct rte_eth_burst_mode rx_mode; -+ struct rte_eth_burst_mode tx_mode; -+ -+ memset(&rx_mode, 0, sizeof(rx_mode)); -+ memset(&tx_mode, 0, sizeof(tx_mode)); -+ (void)hns3_rx_burst_mode_get(dev, 0, &rx_mode); -+ (void)hns3_tx_burst_mode_get(dev, 0, &tx_mode); -+ -+ hns3_dbg(hw, "using rx_pkt_burst: %s, tx_pkt_burst: %s.", -+ rx_mode.info, tx_mode.info); -+} -+ - void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - { - struct hns3_adapter *hns = eth_dev->data->dev_private; -@@ -4243,6 +4259,7 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - eth_dev->tx_pkt_burst = hns3_get_tx_function(eth_dev, &prep); - eth_dev->tx_pkt_prepare = prep; - eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; -+ hns3_trace_rxtx_function(eth_dev); - } else { - eth_dev->rx_pkt_burst = hns3_dummy_rxtx_burst; - eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst; --- -2.7.4 - diff --git a/0090-net-hns3-simplify-selecting-Rx-Tx-function.patch b/0090-net-hns3-simplify-selecting-Rx-Tx-function.patch deleted file mode 100644 index 9b3dabe..0000000 --- a/0090-net-hns3-simplify-selecting-Rx-Tx-function.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 2633d60f38e8ce132379c3af0dda026e1812a7a2 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 10 Apr 2021 09:11:14 +0800 -Subject: [PATCH 090/189] net/hns3: simplify selecting Rx/Tx function - -Currently, there are four control variables (rx_simple_allowed, -rx_vec_allowed, tx_simple_allowed and tx_vec_allowed) which are used -to impact the selection of Rx/Tx burst function. - -The purpose of the design is to provide a way to control the selection -of Rx/Tx burst function by modifying it's values, but these variables -have no entry to modify unless make intrusive modifications. - -Now we already support runtime config to select Rx/Tx function, these -variables could be removed. - -Fixes: a124f9e9591b ("net/hns3: add runtime config to select IO burst function") - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 5 ----- - drivers/net/hns3/hns3_ethdev.h | 5 ----- - drivers/net/hns3/hns3_ethdev_vf.c | 5 ----- - drivers/net/hns3/hns3_rxtx.c | 11 ++++------- - 4 files changed, 4 insertions(+), 22 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 54c72e9..40af6b8 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2513,11 +2513,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) - if (ret) - goto cfg_err; - -- hns->rx_simple_allowed = true; -- hns->rx_vec_allowed = true; -- hns->tx_simple_allowed = true; -- hns->tx_vec_allowed = true; -- - hns3_init_rx_ptype_tble(dev); - hw->adapter_state = HNS3_NIC_CONFIGURED; - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 585eeaf..cd15bf3 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -795,11 +795,6 @@ struct hns3_adapter { - struct hns3_vf vf; - }; - -- bool rx_simple_allowed; -- bool rx_vec_allowed; -- bool tx_simple_allowed; -- bool tx_vec_allowed; -- - uint32_t rx_func_hint; - uint32_t tx_func_hint; - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 13f92da..dd8f248 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -857,11 +857,6 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - if (ret) - goto cfg_err; - -- hns->rx_simple_allowed = true; -- hns->rx_vec_allowed = true; -- hns->tx_simple_allowed = true; -- hns->tx_vec_allowed = true; -- - hns3_init_rx_ptype_tble(dev); - - hw->adapter_state = HNS3_NIC_CONFIGURED; -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index e81344c..4ea6b8b 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2805,10 +2805,9 @@ hns3_get_rx_function(struct rte_eth_dev *dev) - uint64_t offloads = dev->data->dev_conf.rxmode.offloads; - bool vec_allowed, sve_allowed, simple_allowed; - -- vec_allowed = hns->rx_vec_allowed && -- hns3_rx_check_vec_support(dev) == 0; -+ vec_allowed = hns3_rx_check_vec_support(dev) == 0; - sve_allowed = vec_allowed && hns3_check_sve_support(); -- simple_allowed = hns->rx_simple_allowed && !dev->data->scattered_rx && -+ simple_allowed = !dev->data->scattered_rx && - (offloads & DEV_RX_OFFLOAD_TCP_LRO) == 0; - - if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_VEC && vec_allowed) -@@ -4195,11 +4194,9 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - struct hns3_adapter *hns = dev->data->dev_private; - bool vec_allowed, sve_allowed, simple_allowed; - -- vec_allowed = hns->tx_vec_allowed && -- hns3_tx_check_vec_support(dev) == 0; -+ vec_allowed = hns3_tx_check_vec_support(dev) == 0; - sve_allowed = vec_allowed && hns3_check_sve_support(); -- simple_allowed = hns->tx_simple_allowed && -- hns3_tx_check_simple_support(dev); -+ simple_allowed = hns3_tx_check_simple_support(dev); - - *prep = NULL; - --- -2.7.4 - diff --git a/0091-net-hns3-fix-rollback-in-PF-init.patch b/0091-net-hns3-fix-rollback-in-PF-init.patch deleted file mode 100644 index c43415d..0000000 --- a/0091-net-hns3-fix-rollback-in-PF-init.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 396d7c32a45fd944587cec3424a948f0e1b51e2d Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Sat, 10 Apr 2021 09:11:15 +0800 -Subject: [PATCH 091/189] net/hns3: fix rollback in PF init - -This patch adds rollback processing when updating imissed -stats failed in PF init. - -Fixes: 3e9f3042d7c8 ("net/hns3: add imissed packet stats") - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 40af6b8..c67486c 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5009,7 +5009,7 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - ret = hns3_update_imissed_stats(hw, true); - if (ret) { - hns3_err(hw, "clear imissed stats failed, ret = %d", ret); -- return ret; -+ goto err_cmd_init; - } - - hns3_config_all_msix_error(hw, true); --- -2.7.4 - diff --git a/0092-net-hns3-fix-concurrent-interrupt-handling.patch b/0092-net-hns3-fix-concurrent-interrupt-handling.patch deleted file mode 100644 index 7921d20..0000000 --- a/0092-net-hns3-fix-concurrent-interrupt-handling.patch +++ /dev/null @@ -1,42 +0,0 @@ -From c7b459449995a35bdb5eac512ce8fb65a28cfe7f Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Sat, 10 Apr 2021 09:11:16 +0800 -Subject: [PATCH 092/189] net/hns3: fix concurrent interrupt handling - -Currently, if RAS interrupt and FLR occurred at the same time, FLR will -be detected and corresponding schedule state will be set during RAS -interrupt processing. However, the schedule state value will be -overridden in subsequent RAS processing, resulting in FLR processing -failure. This patch solves this problem. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_intr.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 6250c36..ccc90c5 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2133,10 +2133,11 @@ hns3_schedule_reset(struct hns3_adapter *hns) - SCHEDULE_REQUESTED) - return; - if (__atomic_load_n(&hw->reset.schedule, __ATOMIC_RELAXED) == -- SCHEDULE_DEFERRED) -+ SCHEDULE_DEFERRED) - rte_eal_alarm_cancel(hw->reset.ops->reset_service, hns); -- __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, -- __ATOMIC_RELAXED); -+ else -+ __atomic_store_n(&hw->reset.schedule, SCHEDULE_REQUESTED, -+ __ATOMIC_RELAXED); - - rte_eal_alarm_set(SWITCH_CONTEXT_US, hw->reset.ops->reset_service, hns); - } --- -2.7.4 - diff --git a/0093-net-hns3-fix-some-packet-types.patch b/0093-net-hns3-fix-some-packet-types.patch deleted file mode 100644 index b97d784..0000000 --- a/0093-net-hns3-fix-some-packet-types.patch +++ /dev/null @@ -1,177 +0,0 @@ -From 4d90ba638f71a610da429d136fec5f3ebc076f97 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 10 Apr 2021 09:11:17 +0800 -Subject: [PATCH 093/189] net/hns3: fix some packet types - -Currently, the packet type calculated by -vlan/ovlan/l3id/l4id/ol3id/ol4id fields have the following problems: -1) Identify error when exist VLAN strip which will lead to the data - buffer has non VLAN header but mbuf's ptype have L2_ETHER_VLAN flag. -2) Some packet identifies error, eg: hardware report it's RARP or - unknown packet, but ptype will marked with L2_ETHER . - -So driver will calculate packet type only by l3id/l4id/ol3id/ol4id -fields. - -Fixes: 0e98d5e6d9c3 ("net/hns3: fix packet type report in Rx") -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 4 +-- - drivers/net/hns3/hns3_rxtx.c | 60 +++++++++++++----------------------------- - drivers/net/hns3/hns3_rxtx.h | 14 ++++------ - 3 files changed, 24 insertions(+), 54 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index cd15bf3..47d998d 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -682,12 +682,10 @@ struct hns3_ptype_table { - * The next fields used to calc packet-type by the - * L3_ID/L4_ID/OL3_ID/OL4_ID from the Rx descriptor. - */ -- uint32_t l2l3table[HNS3_L2TBL_NUM][HNS3_L3TBL_NUM]; -+ uint32_t l3table[HNS3_L3TBL_NUM]; - uint32_t l4table[HNS3_L4TBL_NUM]; -- uint32_t inner_l2table[HNS3_L2TBL_NUM]; - uint32_t inner_l3table[HNS3_L3TBL_NUM]; - uint32_t inner_l4table[HNS3_L4TBL_NUM]; -- uint32_t ol2table[HNS3_OL2TBL_NUM]; - uint32_t ol3table[HNS3_OL3TBL_NUM]; - uint32_t ol4table[HNS3_OL4TBL_NUM]; - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 4ea6b8b..46d6943 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2003,32 +2003,12 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) - static void - hns3_init_non_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) - { -- tbl->l2l3table[0][0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4; -- tbl->l2l3table[0][1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6; -- tbl->l2l3table[0][2] = RTE_PTYPE_L2_ETHER_ARP; -- tbl->l2l3table[0][3] = RTE_PTYPE_L2_ETHER; -- tbl->l2l3table[0][4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT; -- tbl->l2l3table[0][5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT; -- tbl->l2l3table[0][6] = RTE_PTYPE_L2_ETHER_LLDP; -- tbl->l2l3table[0][15] = RTE_PTYPE_L2_ETHER; -- -- tbl->l2l3table[1][0] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4; -- tbl->l2l3table[1][1] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV6; -- tbl->l2l3table[1][2] = RTE_PTYPE_L2_ETHER_ARP; -- tbl->l2l3table[1][3] = RTE_PTYPE_L2_ETHER_VLAN; -- tbl->l2l3table[1][4] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV4_EXT; -- tbl->l2l3table[1][5] = RTE_PTYPE_L2_ETHER_VLAN | RTE_PTYPE_L3_IPV6_EXT; -- tbl->l2l3table[1][6] = RTE_PTYPE_L2_ETHER_LLDP; -- tbl->l2l3table[1][15] = RTE_PTYPE_L2_ETHER_VLAN; -- -- tbl->l2l3table[2][0] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV4; -- tbl->l2l3table[2][1] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV6; -- tbl->l2l3table[2][2] = RTE_PTYPE_L2_ETHER_ARP; -- tbl->l2l3table[2][3] = RTE_PTYPE_L2_ETHER_QINQ; -- tbl->l2l3table[2][4] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV4_EXT; -- tbl->l2l3table[2][5] = RTE_PTYPE_L2_ETHER_QINQ | RTE_PTYPE_L3_IPV6_EXT; -- tbl->l2l3table[2][6] = RTE_PTYPE_L2_ETHER_LLDP; -- tbl->l2l3table[2][15] = RTE_PTYPE_L2_ETHER_QINQ; -+ tbl->l3table[0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4; -+ tbl->l3table[1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6; -+ tbl->l3table[2] = RTE_PTYPE_L2_ETHER_ARP; -+ tbl->l3table[4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT; -+ tbl->l3table[5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT; -+ tbl->l3table[6] = RTE_PTYPE_L2_ETHER_LLDP; - - tbl->l4table[0] = RTE_PTYPE_L4_UDP; - tbl->l4table[1] = RTE_PTYPE_L4_TCP; -@@ -2041,17 +2021,17 @@ hns3_init_non_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) - static void - hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) - { -- tbl->inner_l2table[0] = RTE_PTYPE_INNER_L2_ETHER; -- tbl->inner_l2table[1] = RTE_PTYPE_INNER_L2_ETHER_VLAN; -- tbl->inner_l2table[2] = RTE_PTYPE_INNER_L2_ETHER_QINQ; -- -- tbl->inner_l3table[0] = RTE_PTYPE_INNER_L3_IPV4; -- tbl->inner_l3table[1] = RTE_PTYPE_INNER_L3_IPV6; -+ tbl->inner_l3table[0] = RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4; -+ tbl->inner_l3table[1] = RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6; - /* There is not a ptype for inner ARP/RARP */ - tbl->inner_l3table[2] = RTE_PTYPE_UNKNOWN; - tbl->inner_l3table[3] = RTE_PTYPE_UNKNOWN; -- tbl->inner_l3table[4] = RTE_PTYPE_INNER_L3_IPV4_EXT; -- tbl->inner_l3table[5] = RTE_PTYPE_INNER_L3_IPV6_EXT; -+ tbl->inner_l3table[4] = RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV4_EXT; -+ tbl->inner_l3table[5] = RTE_PTYPE_INNER_L2_ETHER | -+ RTE_PTYPE_INNER_L3_IPV6_EXT; - - tbl->inner_l4table[0] = RTE_PTYPE_INNER_L4_UDP; - tbl->inner_l4table[1] = RTE_PTYPE_INNER_L4_TCP; -@@ -2062,16 +2042,12 @@ hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) - tbl->inner_l4table[4] = RTE_PTYPE_UNKNOWN; - tbl->inner_l4table[5] = RTE_PTYPE_INNER_L4_ICMP; - -- tbl->ol2table[0] = RTE_PTYPE_L2_ETHER; -- tbl->ol2table[1] = RTE_PTYPE_L2_ETHER_VLAN; -- tbl->ol2table[2] = RTE_PTYPE_L2_ETHER_QINQ; -- -- tbl->ol3table[0] = RTE_PTYPE_L3_IPV4; -- tbl->ol3table[1] = RTE_PTYPE_L3_IPV6; -+ tbl->ol3table[0] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4; -+ tbl->ol3table[1] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6; - tbl->ol3table[2] = RTE_PTYPE_UNKNOWN; - tbl->ol3table[3] = RTE_PTYPE_UNKNOWN; -- tbl->ol3table[4] = RTE_PTYPE_L3_IPV4_EXT; -- tbl->ol3table[5] = RTE_PTYPE_L3_IPV6_EXT; -+ tbl->ol3table[4] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT; -+ tbl->ol3table[5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT; - - tbl->ol4table[0] = RTE_PTYPE_UNKNOWN; - tbl->ol4table[1] = RTE_PTYPE_TUNNEL_VXLAN; -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index eebbebf..44d0ca7 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -635,8 +635,8 @@ hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, - const uint32_t ol_info) - { - const struct hns3_ptype_table * const ptype_tbl = rxq->ptype_tbl; -- uint32_t l2id, l3id, l4id; -- uint32_t ol3id, ol4id, ol2id; -+ uint32_t ol3id, ol4id; -+ uint32_t l3id, l4id; - uint32_t ptype; - - if (rxq->ptype_en) { -@@ -647,20 +647,16 @@ hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, - - ol4id = hns3_get_field(ol_info, HNS3_RXD_OL4ID_M, HNS3_RXD_OL4ID_S); - ol3id = hns3_get_field(ol_info, HNS3_RXD_OL3ID_M, HNS3_RXD_OL3ID_S); -- ol2id = hns3_get_field(ol_info, HNS3_RXD_OVLAN_M, HNS3_RXD_OVLAN_S); -- l2id = hns3_get_field(l234_info, HNS3_RXD_VLAN_M, HNS3_RXD_VLAN_S); - l3id = hns3_get_field(l234_info, HNS3_RXD_L3ID_M, HNS3_RXD_L3ID_S); - l4id = hns3_get_field(l234_info, HNS3_RXD_L4ID_M, HNS3_RXD_L4ID_S); - - if (unlikely(ptype_tbl->ol4table[ol4id])) -- return ptype_tbl->inner_l2table[l2id] | -- ptype_tbl->inner_l3table[l3id] | -+ return ptype_tbl->inner_l3table[l3id] | - ptype_tbl->inner_l4table[l4id] | - ptype_tbl->ol3table[ol3id] | -- ptype_tbl->ol4table[ol4id] | ptype_tbl->ol2table[ol2id]; -+ ptype_tbl->ol4table[ol4id]; - else -- return ptype_tbl->l2l3table[l2id][l3id] | -- ptype_tbl->l4table[l4id]; -+ return ptype_tbl->l3table[l3id] | ptype_tbl->l4table[l4id]; - } - - void hns3_dev_rx_queue_release(void *queue); --- -2.7.4 - diff --git a/0094-net-hns3-fix-timing-in-resetting-queues.patch b/0094-net-hns3-fix-timing-in-resetting-queues.patch deleted file mode 100644 index 21cf73d..0000000 --- a/0094-net-hns3-fix-timing-in-resetting-queues.patch +++ /dev/null @@ -1,63 +0,0 @@ -From b4cc7885926cc27da1934c457e4d3ebb43926056 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 10 Apr 2021 09:11:18 +0800 -Subject: [PATCH 094/189] net/hns3: fix timing in resetting queues - -During the task queue pairs reset, the getimeofday is used to obtain the -timestamp to determine whether the command execution times out. But -gettimeofday is not monotonous, it can be modified by system -administrators, so the timing may not be accurate or even cause the loop -to wait consistently. -And actually, in this scenario, it is not necessary to obtain the -timestamp. - -This patch removes the operation of obtaining the timestamp from the task -queue pairs reset function. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 46d6943..b864350 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -625,8 +625,8 @@ static int - hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) - { - #define HNS3_TQP_RESET_TRY_MS 200 -+ uint16_t wait_time = 0; - uint8_t reset_status; -- uint64_t end; - int ret; - - /* -@@ -639,17 +639,18 @@ hns3pf_reset_tqp(struct hns3_hw *hw, uint16_t queue_id) - hns3_err(hw, "Send reset tqp cmd fail, ret = %d", ret); - return ret; - } -- end = get_timeofday_ms() + HNS3_TQP_RESET_TRY_MS; -+ - do { - /* Wait for tqp hw reset */ - rte_delay_ms(HNS3_POLL_RESPONE_MS); -+ wait_time += HNS3_POLL_RESPONE_MS; - ret = hns3_get_tqp_reset_status(hw, queue_id, &reset_status); - if (ret) - goto tqp_reset_fail; - - if (reset_status) - break; -- } while (get_timeofday_ms() < end); -+ } while (wait_time < HNS3_TQP_RESET_TRY_MS); - - if (!reset_status) { - ret = -ETIMEDOUT; --- -2.7.4 - diff --git a/0095-net-hns3-fix-queue-state-when-concurrent-with-reset.patch b/0095-net-hns3-fix-queue-state-when-concurrent-with-reset.patch deleted file mode 100644 index f291797..0000000 --- a/0095-net-hns3-fix-queue-state-when-concurrent-with-reset.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 94765554f123475e03c5900686b19c2227ce05ad Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 10 Apr 2021 09:11:19 +0800 -Subject: [PATCH 095/189] net/hns3: fix queue state when concurrent with reset - -At the end of the reset, the state of queues need to be restored -according to the states saved in the driver. If the start and stop -operations of the queues are concurrent at this time, it may cause the -final status to be uncertain. - -This patch requires queues to acquire the hw lock before starting and -stopping. If the device is being restored due to reset at this time, it -will block until the reset is completed. - -Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 11 +++++++++++ - 1 file changed, 11 insertions(+) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index b864350..cbcfb0b 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4287,10 +4287,12 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) - if (!hns3_dev_indep_txrx_supported(hw)) - return -ENOTSUP; - -+ rte_spinlock_lock(&hw->lock); - ret = hns3_reset_queue(hw, rx_queue_id, HNS3_RING_TYPE_RX); - if (ret) { - hns3_err(hw, "fail to reset Rx queue %u, ret = %d.", - rx_queue_id, ret); -+ rte_spinlock_unlock(&hw->lock); - return ret; - } - -@@ -4298,11 +4300,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) - if (ret) { - hns3_err(hw, "fail to init Rx queue %u, ret = %d.", - rx_queue_id, ret); -+ rte_spinlock_unlock(&hw->lock); - return ret; - } - - hns3_enable_rxq(rxq, true); - dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; -+ rte_spinlock_unlock(&hw->lock); - - return ret; - } -@@ -4329,12 +4333,14 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) - if (!hns3_dev_indep_txrx_supported(hw)) - return -ENOTSUP; - -+ rte_spinlock_lock(&hw->lock); - hns3_enable_rxq(rxq, false); - - hns3_rx_queue_release_mbufs(rxq); - - hns3_reset_sw_rxq(rxq); - dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; -+ rte_spinlock_unlock(&hw->lock); - - return 0; - } -@@ -4349,16 +4355,19 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) - if (!hns3_dev_indep_txrx_supported(hw)) - return -ENOTSUP; - -+ rte_spinlock_lock(&hw->lock); - ret = hns3_reset_queue(hw, tx_queue_id, HNS3_RING_TYPE_TX); - if (ret) { - hns3_err(hw, "fail to reset Tx queue %u, ret = %d.", - tx_queue_id, ret); -+ rte_spinlock_unlock(&hw->lock); - return ret; - } - - hns3_init_txq(txq); - hns3_enable_txq(txq, true); - dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED; -+ rte_spinlock_unlock(&hw->lock); - - return ret; - } -@@ -4372,6 +4381,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) - if (!hns3_dev_indep_txrx_supported(hw)) - return -ENOTSUP; - -+ rte_spinlock_lock(&hw->lock); - hns3_enable_txq(txq, false); - hns3_tx_queue_release_mbufs(txq); - /* -@@ -4383,6 +4393,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) - */ - hns3_init_txq(txq); - dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED; -+ rte_spinlock_unlock(&hw->lock); - - return 0; - } --- -2.7.4 - diff --git a/0096-net-hns3-fix-configure-FEC-when-concurrent-with-rese.patch b/0096-net-hns3-fix-configure-FEC-when-concurrent-with-rese.patch deleted file mode 100644 index 06ed0bd..0000000 --- a/0096-net-hns3-fix-configure-FEC-when-concurrent-with-rese.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 755d92e8a3c3327632dc9e6f74fb7f07b4073a3e Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 10 Apr 2021 09:11:20 +0800 -Subject: [PATCH 096/189] net/hns3: fix configure FEC when concurrent with - reset - -Currently, after the reset is complete, the PMD restores the FEC -according to the FEC configuration reserved in the driver. If there is a -concurrency between the FEC setup operation and the restore operation -after a reset, the FEC status of the last hardware may be unknown. - -This patch adds the step of obtaining the lock when setting the FEC to -avoid concurrency between restore operation and setting operation. - -Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index c67486c..85e54ae 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6433,11 +6433,16 @@ hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode) - return -EINVAL; - } - -+ rte_spinlock_lock(&hw->lock); - ret = hns3_set_fec_hw(hw, mode); -- if (ret) -+ if (ret) { -+ rte_spinlock_unlock(&hw->lock); - return ret; -+ } - - pf->fec_mode = mode; -+ rte_spinlock_unlock(&hw->lock); -+ - return 0; - } - --- -2.7.4 - diff --git a/0097-net-hns3-delete-mailbox-arq-ring.patch b/0097-net-hns3-delete-mailbox-arq-ring.patch deleted file mode 100644 index ad2550c..0000000 --- a/0097-net-hns3-delete-mailbox-arq-ring.patch +++ /dev/null @@ -1,197 +0,0 @@ -From b46465d9deb6c1e0ef26cc53f4050cb7f6322d56 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:00 +0800 -Subject: [PATCH 097/189] net/hns3: delete mailbox arq ring - -Currently, driver will copy mailbox messages body into arq ring when -process HNS3_MBX_LINK_STAT_CHANGE and HNS3_MBX_LINK_STAT_CHANGE -message, and then call hns3_mbx_handler API which will direct process -pre-copy messages. In the whole process, the arq ring don't have a -substantial effect. - -Note: The arq ring is designed for kernel environment which could not -do much job in interrupt context, but for DPDK it's not required. - -Also we rename hns3_handle_link_change_event to -hns3pf_handle_link_change_event which add 'pf' suffix to make it -better to distinguish. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 1 - - drivers/net/hns3/hns3_mbx.c | 83 +++++++++++++++++------------------------- - drivers/net/hns3/hns3_mbx.h | 14 ------- - 3 files changed, 33 insertions(+), 65 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 47d998d..1763cc9 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -438,7 +438,6 @@ struct hns3_hw { - uint8_t revision; /* PCI revision, low byte of class word */ - struct hns3_cmq cmq; - struct hns3_mbx_resp_status mbx_resp; /* mailbox response */ -- struct hns3_mbx_arq_ring arq; /* mailbox async rx queue */ - struct hns3_mac mac; - unsigned int secondary_cnt; /* Number of secondary processes init'd. */ - struct hns3_tqp_stats tqp_stats; -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 2a96f6c..6768207 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -173,55 +173,42 @@ hns3_cmd_crq_empty(struct hns3_hw *hw) - } - - static void --hns3_mbx_handler(struct hns3_hw *hw) -+hns3vf_handle_link_change_event(struct hns3_hw *hw, -+ struct hns3_mbx_pf_to_vf_cmd *req) - { -- enum hns3_reset_level reset_level; - uint8_t link_status, link_duplex; -+ uint16_t *msg_q = req->msg; - uint8_t support_push_lsc; - uint32_t link_speed; -- uint16_t *msg_q; -- uint8_t opcode; -- uint32_t tail; - -- tail = hw->arq.tail; -- -- /* process all the async queue messages */ -- while (tail != hw->arq.head) { -- msg_q = hw->arq.msg_q[hw->arq.head]; -+ memcpy(&link_speed, &msg_q[2], sizeof(link_speed)); -+ link_status = rte_le_to_cpu_16(msg_q[1]); -+ link_duplex = (uint8_t)rte_le_to_cpu_16(msg_q[4]); -+ hns3vf_update_link_status(hw, link_status, link_speed, -+ link_duplex); -+ support_push_lsc = (*(uint8_t *)&msg_q[5]) & 1u; -+ hns3vf_update_push_lsc_cap(hw, support_push_lsc); -+} - -- opcode = msg_q[0] & 0xff; -- switch (opcode) { -- case HNS3_MBX_LINK_STAT_CHANGE: -- memcpy(&link_speed, &msg_q[2], sizeof(link_speed)); -- link_status = rte_le_to_cpu_16(msg_q[1]); -- link_duplex = (uint8_t)rte_le_to_cpu_16(msg_q[4]); -- hns3vf_update_link_status(hw, link_status, link_speed, -- link_duplex); -- support_push_lsc = (*(uint8_t *)&msg_q[5]) & 1u; -- hns3vf_update_push_lsc_cap(hw, support_push_lsc); -- break; -- case HNS3_MBX_ASSERTING_RESET: -- /* PF has asserted reset hence VF should go in pending -- * state and poll for the hardware reset status till it -- * has been completely reset. After this stack should -- * eventually be re-initialized. -- */ -- reset_level = rte_le_to_cpu_16(msg_q[1]); -- hns3_atomic_set_bit(reset_level, &hw->reset.pending); -+static void -+hns3_handle_asserting_reset(struct hns3_hw *hw, -+ struct hns3_mbx_pf_to_vf_cmd *req) -+{ -+ enum hns3_reset_level reset_level; -+ uint16_t *msg_q = req->msg; - -- hns3_warn(hw, "PF inform reset level %d", reset_level); -- hw->reset.stats.request_cnt++; -- hns3_schedule_reset(HNS3_DEV_HW_TO_ADAPTER(hw)); -- break; -- default: -- hns3_err(hw, "Fetched unsupported(%u) message from arq", -- opcode); -- break; -- } -+ /* -+ * PF has asserted reset hence VF should go in pending -+ * state and poll for the hardware reset status till it -+ * has been completely reset. After this stack should -+ * eventually be re-initialized. -+ */ -+ reset_level = rte_le_to_cpu_16(msg_q[1]); -+ hns3_atomic_set_bit(reset_level, &hw->reset.pending); - -- hns3_mbx_head_ptr_move_arq(hw->arq); -- msg_q = hw->arq.msg_q[hw->arq.head]; -- } -+ hns3_warn(hw, "PF inform reset level %d", reset_level); -+ hw->reset.stats.request_cnt++; -+ hns3_schedule_reset(HNS3_DEV_HW_TO_ADAPTER(hw)); - } - - /* -@@ -278,7 +265,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) - } - - static void --hns3_handle_link_change_event(struct hns3_hw *hw, -+hns3pf_handle_link_change_event(struct hns3_hw *hw, - struct hns3_mbx_pf_to_vf_cmd *req) - { - #define LINK_STATUS_OFFSET 1 -@@ -337,7 +324,6 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - struct hns3_mbx_pf_to_vf_cmd *req; - struct hns3_cmd_desc *desc; - uint32_t msg_data; -- uint16_t *msg_q; - uint8_t opcode; - uint16_t flag; - uint8_t *temp; -@@ -380,16 +366,13 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - hns3_update_resp_position(hw, msg_data); - break; - case HNS3_MBX_LINK_STAT_CHANGE: -+ hns3vf_handle_link_change_event(hw, req); -+ break; - case HNS3_MBX_ASSERTING_RESET: -- msg_q = hw->arq.msg_q[hw->arq.tail]; -- memcpy(&msg_q[0], req->msg, -- HNS3_MBX_MAX_ARQ_MSG_SIZE * sizeof(uint16_t)); -- hns3_mbx_tail_ptr_move_arq(hw->arq); -- -- hns3_mbx_handler(hw); -+ hns3_handle_asserting_reset(hw, req); - break; - case HNS3_MBX_PUSH_LINK_STATUS: -- hns3_handle_link_change_event(hw, req); -+ hns3pf_handle_link_change_event(hw, req); - break; - case HNS3_MBX_PUSH_VLAN_INFO: - /* -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index 7f7ade1..adb77b5 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -144,22 +144,8 @@ struct hns3_pf_rst_done_cmd { - - #define HNS3_PF_RESET_DONE_BIT BIT(0) - --/* used by VF to store the received Async responses from PF */ --struct hns3_mbx_arq_ring { --#define HNS3_MBX_MAX_ARQ_MSG_SIZE 8 --#define HNS3_MBX_MAX_ARQ_MSG_NUM 1024 -- uint32_t head; -- uint32_t tail; -- uint32_t count; -- uint16_t msg_q[HNS3_MBX_MAX_ARQ_MSG_NUM][HNS3_MBX_MAX_ARQ_MSG_SIZE]; --}; -- - #define hns3_mbx_ring_ptr_move_crq(crq) \ - ((crq)->next_to_use = ((crq)->next_to_use + 1) % (crq)->desc_num) --#define hns3_mbx_tail_ptr_move_arq(arq) \ -- ((arq).tail = ((arq).tail + 1) % HNS3_MBX_MAX_ARQ_MSG_SIZE) --#define hns3_mbx_head_ptr_move_arq(arq) \ -- ((arq).head = ((arq).head + 1) % HNS3_MBX_MAX_ARQ_MSG_SIZE) - - struct hns3_hw; - void hns3_dev_handle_mbx_msg(struct hns3_hw *hw); --- -2.7.4 - diff --git a/0098-net-hns3-fix-possible-mismatched-response-of-mailbox.patch b/0098-net-hns3-fix-possible-mismatched-response-of-mailbox.patch deleted file mode 100644 index 0ebe1a8..0000000 --- a/0098-net-hns3-fix-possible-mismatched-response-of-mailbox.patch +++ /dev/null @@ -1,298 +0,0 @@ -From a996a465d332ce155ff5a98c451a824516d85e73 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:01 +0800 -Subject: [PATCH 098/189] net/hns3: fix possible mismatched response of mailbox - -Currently, the mailbox synchronous communication between VF and PF use -the following fields to maintain communication: -1. Req_msg_data which was combined by message code and subcode, used to - match request and response. -2. Head which means the number of requests successfully sent by VF. -3. Tail which means the number of responses successfully received by VF. -4. Lost which means the number of requests which are timeout. - -There may possible mismatches of the following situation: -1. VF sends message A with code=1 subcode=1. - Then head=1, tail=0, lost=0. -2. PF was blocked about 500ms when processing the message A. -3. VF will detect message A timeout because it can't get the response -within 500ms. - Then head=1, tail=0, lost=1. -4. VF sends message B with code=1 subcode=1 which equal message A. - Then head=2, tail=0, lost=1. -5. PF processes the first message A and send the response message to VF. -6. VF will update tail field to 1, but the lost field will remain - unchanged because the code/subcode equal message B's, so driver will - return success because now the head(2) equals tail(1) plus lost(1). - This will lead to mismatch of request and response. - -To fix the above bug, we use the following scheme: -1. The message sent from VF was labelled with match_id which was a - unique 16-bit non-zero value. -2. The response sent from PF will label with match_id which got from the - request. -3. The VF uses the match_id to match request and response message. - -This scheme depends on the PF driver, if the PF driver don't support -then VF will uses the original scheme. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 120 +++++++++++++++++++++++++++++++++++--------- - drivers/net/hns3/hns3_mbx.h | 20 +++++++- - 2 files changed, 114 insertions(+), 26 deletions(-) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 6768207..7a69b63 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -40,14 +40,32 @@ hns3_resp_to_errno(uint16_t resp_code) - return -EIO; - } - -+static void -+hns3_mbx_proc_timeout(struct hns3_hw *hw, uint16_t code, uint16_t subcode) -+{ -+ if (hw->mbx_resp.matching_scheme == -+ HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL) { -+ hw->mbx_resp.lost++; -+ hns3_err(hw, -+ "VF could not get mbx(%u,%u) head(%u) tail(%u) " -+ "lost(%u) from PF", -+ code, subcode, hw->mbx_resp.head, hw->mbx_resp.tail, -+ hw->mbx_resp.lost); -+ return; -+ } -+ -+ hns3_err(hw, "VF could not get mbx(%u,%u) from PF", code, subcode); -+} -+ - static int --hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, -+hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - uint8_t *resp_data, uint16_t resp_len) - { - #define HNS3_MAX_RETRY_MS 500 - #define HNS3_WAIT_RESP_US 100 - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_mbx_resp_status *mbx_resp; -+ bool received; - uint64_t now; - uint64_t end; - -@@ -59,8 +77,7 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, - - now = get_timeofday_ms(); - end = now + HNS3_MAX_RETRY_MS; -- while ((hw->mbx_resp.head != hw->mbx_resp.tail + hw->mbx_resp.lost) && -- (now < end)) { -+ while (now < end) { - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { - hns3_err(hw, "Don't wait for mbx respone because of " - "disable_cmd"); -@@ -77,16 +94,20 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, - hns3_dev_handle_mbx_msg(hw); - rte_delay_us(HNS3_WAIT_RESP_US); - -+ if (hw->mbx_resp.matching_scheme == -+ HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL) -+ received = (hw->mbx_resp.head == -+ hw->mbx_resp.tail + hw->mbx_resp.lost); -+ else -+ received = hw->mbx_resp.received_match_resp; -+ if (received) -+ break; -+ - now = get_timeofday_ms(); - } - hw->mbx_resp.req_msg_data = 0; - if (now >= end) { -- hw->mbx_resp.lost++; -- hns3_err(hw, -- "VF could not get mbx(%u,%u) head(%u) tail(%u) " -- "lost(%u) from PF", -- code0, code1, hw->mbx_resp.head, hw->mbx_resp.tail, -- hw->mbx_resp.lost); -+ hns3_mbx_proc_timeout(hw, code, subcode); - return -ETIME; - } - rte_io_rmb(); -@@ -101,6 +122,29 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code0, uint16_t code1, - return 0; - } - -+static void -+hns3_mbx_prepare_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode) -+{ -+ /* -+ * Init both matching scheme fields because we may not know the exact -+ * scheme will be used when in the initial phase. -+ * -+ * Also, there are OK to init both matching scheme fields even though -+ * we get the exact scheme which is used. -+ */ -+ hw->mbx_resp.req_msg_data = (uint32_t)code << 16 | subcode; -+ hw->mbx_resp.head++; -+ -+ /* Update match_id and ensure the value of match_id is not zero */ -+ hw->mbx_resp.match_id++; -+ if (hw->mbx_resp.match_id == 0) -+ hw->mbx_resp.match_id = 1; -+ hw->mbx_resp.received_match_resp = false; -+ -+ hw->mbx_resp.resp_status = 0; -+ memset(hw->mbx_resp.additional_info, 0, HNS3_MBX_MAX_RESP_DATA_SIZE); -+} -+ - int - hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - const uint8_t *msg_data, uint8_t msg_len, bool need_resp, -@@ -138,8 +182,8 @@ hns3_send_mbx_msg(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - if (need_resp) { - req->mbx_need_resp |= HNS3_MBX_NEED_RESP_BIT; - rte_spinlock_lock(&hw->mbx_resp.lock); -- hw->mbx_resp.req_msg_data = (uint32_t)code << 16 | subcode; -- hw->mbx_resp.head++; -+ hns3_mbx_prepare_resp(hw, code, subcode); -+ req->match_id = hw->mbx_resp.match_id; - ret = hns3_cmd_send(hw, &desc, 1); - if (ret) { - hw->mbx_resp.head--; -@@ -244,6 +288,46 @@ hns3_update_resp_position(struct hns3_hw *hw, uint32_t resp_msg) - } - - static void -+hns3_handle_mbx_response(struct hns3_hw *hw, struct hns3_mbx_pf_to_vf_cmd *req) -+{ -+ struct hns3_mbx_resp_status *resp = &hw->mbx_resp; -+ uint32_t msg_data; -+ -+ if (req->match_id != 0) { -+ /* -+ * If match_id is not zero, it means PF support copy request's -+ * match_id to its response. So VF could use the match_id -+ * to match the request. -+ */ -+ if (resp->matching_scheme != -+ HNS3_MBX_RESP_MATCHING_SCHEME_OF_MATCH_ID) { -+ resp->matching_scheme = -+ HNS3_MBX_RESP_MATCHING_SCHEME_OF_MATCH_ID; -+ hns3_info(hw, "detect mailbox support match id!"); -+ } -+ if (req->match_id == resp->match_id) { -+ resp->resp_status = hns3_resp_to_errno(req->msg[3]); -+ memcpy(resp->additional_info, &req->msg[4], -+ HNS3_MBX_MAX_RESP_DATA_SIZE); -+ rte_io_wmb(); -+ resp->received_match_resp = true; -+ } -+ return; -+ } -+ -+ /* -+ * If the below instructions can be executed, it means PF does not -+ * support copy request's match_id to its response. So VF follows the -+ * original scheme to process. -+ */ -+ resp->resp_status = hns3_resp_to_errno(req->msg[3]); -+ memcpy(resp->additional_info, &req->msg[4], -+ HNS3_MBX_MAX_RESP_DATA_SIZE); -+ msg_data = (uint32_t)req->msg[1] << 16 | req->msg[2]; -+ hns3_update_resp_position(hw, msg_data); -+} -+ -+static void - hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) - { - switch (link_fail_code) { -@@ -319,15 +403,11 @@ hns3_handle_promisc_info(struct hns3_hw *hw, uint16_t promisc_en) - void - hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - { -- struct hns3_mbx_resp_status *resp = &hw->mbx_resp; - struct hns3_cmq_ring *crq = &hw->cmq.crq; - struct hns3_mbx_pf_to_vf_cmd *req; - struct hns3_cmd_desc *desc; -- uint32_t msg_data; - uint8_t opcode; - uint16_t flag; -- uint8_t *temp; -- int i; - - rte_spinlock_lock(&hw->cmq.crq.lock); - -@@ -355,15 +435,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - - switch (opcode) { - case HNS3_MBX_PF_VF_RESP: -- resp->resp_status = hns3_resp_to_errno(req->msg[3]); -- -- temp = (uint8_t *)&req->msg[4]; -- for (i = 0; i < HNS3_MBX_MAX_RESP_DATA_SIZE; i++) { -- resp->additional_info[i] = *temp; -- temp++; -- } -- msg_data = (uint32_t)req->msg[1] << 16 | req->msg[2]; -- hns3_update_resp_position(hw, msg_data); -+ hns3_handle_mbx_response(hw, req); - break; - case HNS3_MBX_LINK_STAT_CHANGE: - hns3vf_handle_link_change_event(hw, req); -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index adb77b5..338c2c2 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -83,12 +83,26 @@ enum hns3_mbx_link_fail_subcode { - #define HNS3_MBX_RING_MAP_BASIC_MSG_NUM 3 - #define HNS3_MBX_RING_NODE_VARIABLE_NUM 3 - -+enum { -+ HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL = 0, -+ HNS3_MBX_RESP_MATCHING_SCHEME_OF_MATCH_ID -+}; -+ - struct hns3_mbx_resp_status { - rte_spinlock_t lock; /* protects against contending sync cmd resp */ -+ -+ uint8_t matching_scheme; -+ -+ /* The following fields used in the matching scheme for original */ - uint32_t req_msg_data; - uint32_t head; - uint32_t tail; - uint32_t lost; -+ -+ /* The following fields used in the matching scheme for match_id */ -+ uint16_t match_id; -+ bool received_match_resp; -+ - int resp_status; - uint8_t additional_info[HNS3_MBX_MAX_RESP_DATA_SIZE]; - }; -@@ -106,7 +120,8 @@ struct hns3_mbx_vf_to_pf_cmd { - uint8_t mbx_need_resp; - uint8_t rsv1; - uint8_t msg_len; -- uint8_t rsv2[3]; -+ uint8_t rsv2; -+ uint16_t match_id; - uint8_t msg[HNS3_MBX_MAX_MSG_SIZE]; - }; - -@@ -114,7 +129,8 @@ struct hns3_mbx_pf_to_vf_cmd { - uint8_t dest_vfid; - uint8_t rsv[3]; - uint8_t msg_len; -- uint8_t rsv1[3]; -+ uint8_t rsv1; -+ uint16_t match_id; - uint16_t msg[8]; - }; - --- -2.7.4 - diff --git a/0099-net-hns3-fix-VF-handling-LSC-event-in-secondary-proc.patch b/0099-net-hns3-fix-VF-handling-LSC-event-in-secondary-proc.patch deleted file mode 100644 index e4b8069..0000000 --- a/0099-net-hns3-fix-VF-handling-LSC-event-in-secondary-proc.patch +++ /dev/null @@ -1,135 +0,0 @@ -From 454906f37a15048b7ed19934382234c762842ef0 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:02 +0800 -Subject: [PATCH 099/189] net/hns3: fix VF handling LSC event in secondary - process - -VF will build two queues (csq: command send queue, crq: command receive -queue) with firmware, the crq may contain the following messages: -1) mailbox response message which was the ack of mailbox sync request. -2) PF's link status change message which may send by PF at anytime; - -Currently, any threads in the primary and secondary processes could -send mailbox sync request, so it will need to process the crq messages -in there own thread context. - -If the crq hold two messages: a) PF's link status change message, b) -mailbox response message when secondary process deals with the crq -messages, it will lead to report lsc event in secondary process -because it uses the policy of processing all pending messages at once. - -We use the following scheme to solve it: -1) threads in secondary process could only process specifics messages - (eg. mailbox response message) in crq, if the message processed, its - opcode will rewrite with zero, then the intr thread in primary - process will not process again. -2) threads other than intr thread in the primary process use the same - processing logic as the threads in secondary process. -3) intr thread in the primary process could process all messages. - -Fixes: 76a3836b98c4 ("net/hns3: fix setting default MAC address in bonding of VF") -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 68 insertions(+) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 7a69b63..5a88fe2 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -400,6 +400,44 @@ hns3_handle_promisc_info(struct hns3_hw *hw, uint16_t promisc_en) - } - } - -+static void -+hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) -+{ -+ struct hns3_cmq_ring *crq = &hw->cmq.crq; -+ struct hns3_mbx_pf_to_vf_cmd *req; -+ struct hns3_cmd_desc *desc; -+ uint32_t tail, next_to_use; -+ uint8_t opcode; -+ uint16_t flag; -+ -+ tail = hns3_read_dev(hw, HNS3_CMDQ_RX_TAIL_REG); -+ next_to_use = crq->next_to_use; -+ while (next_to_use != tail) { -+ desc = &crq->desc[next_to_use]; -+ req = (struct hns3_mbx_pf_to_vf_cmd *)desc->data; -+ opcode = req->msg[0] & 0xff; -+ -+ flag = rte_le_to_cpu_16(crq->desc[next_to_use].flag); -+ if (!hns3_get_bit(flag, HNS3_CMDQ_RX_OUTVLD_B)) -+ goto scan_next; -+ -+ if (crq->desc[next_to_use].opcode == 0) -+ goto scan_next; -+ -+ if (opcode == HNS3_MBX_PF_VF_RESP) { -+ hns3_handle_mbx_response(hw, req); -+ /* -+ * Clear opcode to inform intr thread don't process -+ * again. -+ */ -+ crq->desc[crq->next_to_use].opcode = 0; -+ } -+ -+scan_next: -+ next_to_use = (next_to_use + 1) % hw->cmq.crq.desc_num; -+ } -+} -+ - void - hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - { -@@ -411,6 +449,29 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - - rte_spinlock_lock(&hw->cmq.crq.lock); - -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY || -+ !rte_thread_is_intr()) { -+ /* -+ * Currently, any threads in the primary and secondary processes -+ * could send mailbox sync request, so it will need to process -+ * the crq message (which is the HNS3_MBX_PF_VF_RESP) in there -+ * own thread context. It may also process other messages -+ * because it uses the policy of processing all pending messages -+ * at once. -+ * But some messages such as HNS3_MBX_PUSH_LINK_STATUS could -+ * only process within the intr thread in primary process, -+ * otherwise it may lead to report lsc event in secondary -+ * process. -+ * So the threads other than intr thread in primary process -+ * could only process HNS3_MBX_PF_VF_RESP message, if the -+ * message processed, its opcode will rewrite with zero, then -+ * the intr thread in primary process will not process again. -+ */ -+ hns3_handle_mbx_msg_out_intr(hw); -+ rte_spinlock_unlock(&hw->cmq.crq.lock); -+ return; -+ } -+ - while (!hns3_cmd_crq_empty(hw)) { - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { - rte_spinlock_unlock(&hw->cmq.crq.lock); -@@ -433,6 +494,13 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - continue; - } - -+ if (desc->opcode == 0) { -+ /* Message already processed by other thread */ -+ crq->desc[crq->next_to_use].flag = 0; -+ hns3_mbx_ring_ptr_move_crq(crq); -+ continue; -+ } -+ - switch (opcode) { - case HNS3_MBX_PF_VF_RESP: - hns3_handle_mbx_response(hw, req); --- -2.7.4 - diff --git a/0100-net-hns3-fix-timing-in-mailbox.patch b/0100-net-hns3-fix-timing-in-mailbox.patch deleted file mode 100644 index ec549fa..0000000 --- a/0100-net-hns3-fix-timing-in-mailbox.patch +++ /dev/null @@ -1,70 +0,0 @@ -From bfcf3af1b6ccb9eb022ceabcc6d41f3985445c3f Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Tue, 13 Apr 2021 19:50:03 +0800 -Subject: [PATCH 100/189] net/hns3: fix timing in mailbox - -Currently, when processing MBX messages, the system timestamp is obtained -to determine whether timeout occurs. However, the gettimeofday function -is not monotonically increasing. Therefore, this may lead to incorrect -judgment or difficulty exiting the loop. And actually, in this scenario, -it is not necessary to obtain the timestamp. - -This patch deletes the call to the gettimeofday function during MBX -message processing. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 13 +++++-------- - 1 file changed, 5 insertions(+), 8 deletions(-) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 5a88fe2..9955f27 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -61,13 +61,12 @@ static int - hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - uint8_t *resp_data, uint16_t resp_len) - { --#define HNS3_MAX_RETRY_MS 500 -+#define HNS3_MAX_RETRY_US 500000 - #define HNS3_WAIT_RESP_US 100 - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_mbx_resp_status *mbx_resp; -+ uint32_t wait_time = 0; - bool received; -- uint64_t now; -- uint64_t end; - - if (resp_len > HNS3_MBX_MAX_RESP_DATA_SIZE) { - hns3_err(hw, "VF mbx response len(=%u) exceeds maximum(=%d)", -@@ -75,9 +74,7 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - return -EINVAL; - } - -- now = get_timeofday_ms(); -- end = now + HNS3_MAX_RETRY_MS; -- while (now < end) { -+ while (wait_time < HNS3_MAX_RETRY_US) { - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { - hns3_err(hw, "Don't wait for mbx respone because of " - "disable_cmd"); -@@ -103,10 +100,10 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - if (received) - break; - -- now = get_timeofday_ms(); -+ wait_time += HNS3_WAIT_RESP_US; - } - hw->mbx_resp.req_msg_data = 0; -- if (now >= end) { -+ if (wait_time >= HNS3_MAX_RETRY_US) { - hns3_mbx_proc_timeout(hw, code, subcode); - return -ETIME; - } --- -2.7.4 - diff --git a/0101-net-hns3-fix-use-of-command-status-enumeration.patch b/0101-net-hns3-fix-use-of-command-status-enumeration.patch deleted file mode 100644 index 1af67a0..0000000 --- a/0101-net-hns3-fix-use-of-command-status-enumeration.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 1e3415f3ba207dfb012e5f4fab96bb5760419fae Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Tue, 13 Apr 2021 19:50:04 +0800 -Subject: [PATCH 101/189] net/hns3: fix use of command status enumeration - -The type of return value of hns3_cmd_send is int, some function declare -the return value as hns3_cmd_status. - -This patch fix the incorrect use of the enum hns3_cmd_status. - -Fixes: 737f30e1c3ab ("net/hns3: support command interface with firmware") -Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 2 +- - drivers/net/hns3/hns3_cmd.h | 9 +-------- - drivers/net/hns3/hns3_ethdev.c | 12 ++++++------ - 3 files changed, 8 insertions(+), 15 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 1bf1c32..58833ce 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -450,7 +450,7 @@ hns3_build_api_caps(void) - return rte_cpu_to_le_32(api_caps); - } - --static enum hns3_cmd_status -+static int - hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw) - { - struct hns3_query_version_cmd *resp; -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 5d1fb67..9a975b8 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -56,13 +56,6 @@ enum hns3_cmd_return_status { - HNS3_CMD_ROH_CHECK_FAIL = 12 - }; - --enum hns3_cmd_status { -- HNS3_STATUS_SUCCESS = 0, -- HNS3_ERR_CSQ_FULL = -1, -- HNS3_ERR_CSQ_TIMEOUT = -2, -- HNS3_ERR_CSQ_ERROR = -3, --}; -- - struct hns3_misc_vector { - uint8_t *addr; - int vector_irq; -@@ -72,7 +65,7 @@ struct hns3_cmq { - struct hns3_cmq_ring csq; - struct hns3_cmq_ring crq; - uint16_t tx_timeout; -- enum hns3_cmd_status last_status; -+ enum hns3_cmd_return_status last_status; - }; - - enum hns3_opcode_type { -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 85e54ae..a06fdc9 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2310,11 +2310,11 @@ hns3_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool en, - struct hns3_cmd_desc desc; - struct hns3_ctrl_vector_chain_cmd *req = - (struct hns3_ctrl_vector_chain_cmd *)desc.data; -- enum hns3_cmd_status status; - enum hns3_opcode_type op; - uint16_t tqp_type_and_id = 0; - uint16_t type; - uint16_t gl; -+ int ret; - - op = en ? HNS3_OPC_ADD_RING_TO_VECTOR : HNS3_OPC_DEL_RING_TO_VECTOR; - hns3_cmd_setup_basic_desc(&desc, op, false); -@@ -2337,11 +2337,11 @@ hns3_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool en, - gl); - req->tqp_type_and_id[0] = rte_cpu_to_le_16(tqp_type_and_id); - req->int_cause_num = 1; -- status = hns3_cmd_send(hw, &desc, 1); -- if (status) { -- hns3_err(hw, "%s TQP %u fail, vector_id is %u, status is %d.", -- en ? "Map" : "Unmap", queue_id, vector_id, status); -- return status; -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, "%s TQP %u fail, vector_id = %u, ret = %d.", -+ en ? "Map" : "Unmap", queue_id, vector_id, ret); -+ return ret; - } - - return 0; --- -2.7.4 - diff --git a/0102-net-hns3-fix-verification-of-NEON-support.patch b/0102-net-hns3-fix-verification-of-NEON-support.patch deleted file mode 100644 index f964b7c..0000000 --- a/0102-net-hns3-fix-verification-of-NEON-support.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 0be6bd46ca0352c7308a9bdb04d2f1a9d9ccd888 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:05 +0800 -Subject: [PATCH 102/189] net/hns3: fix verification of NEON support - -This patch adds verification of whether NEON supported. - -Fixes: a3d4f4d291d7 ("net/hns3: support NEON Rx") -Fixes: e31f123db06b ("net/hns3: support NEON Tx") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 26 ++++++++++++++++++++------ - 1 file changed, 20 insertions(+), 6 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index cbcfb0b..f3ced19 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -11,7 +11,7 @@ - #include - #include - #include --#if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_SVE) -+#if defined(RTE_ARCH_ARM64) - #include - #endif - -@@ -2766,7 +2766,17 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, - } - - static bool --hns3_check_sve_support(void) -+hns3_get_default_vec_support(void) -+{ -+#if defined(RTE_ARCH_ARM64) -+ if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON)) -+ return true; -+#endif -+ return false; -+} -+ -+static bool -+hns3_get_sve_support(void) - { - #if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_SVE) - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SVE)) -@@ -2781,9 +2791,11 @@ hns3_get_rx_function(struct rte_eth_dev *dev) - struct hns3_adapter *hns = dev->data->dev_private; - uint64_t offloads = dev->data->dev_conf.rxmode.offloads; - bool vec_allowed, sve_allowed, simple_allowed; -+ bool vec_support; - -- vec_allowed = hns3_rx_check_vec_support(dev) == 0; -- sve_allowed = vec_allowed && hns3_check_sve_support(); -+ vec_support = hns3_rx_check_vec_support(dev) == 0; -+ vec_allowed = vec_support && hns3_get_default_vec_support(); -+ sve_allowed = vec_support && hns3_get_sve_support(); - simple_allowed = !dev->data->scattered_rx && - (offloads & DEV_RX_OFFLOAD_TCP_LRO) == 0; - -@@ -4170,9 +4182,11 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - { - struct hns3_adapter *hns = dev->data->dev_private; - bool vec_allowed, sve_allowed, simple_allowed; -+ bool vec_support; - -- vec_allowed = hns3_tx_check_vec_support(dev) == 0; -- sve_allowed = vec_allowed && hns3_check_sve_support(); -+ vec_support = hns3_tx_check_vec_support(dev) == 0; -+ vec_allowed = vec_support && hns3_get_default_vec_support(); -+ sve_allowed = vec_support && hns3_get_sve_support(); - simple_allowed = hns3_tx_check_simple_support(dev); - - *prep = NULL; --- -2.7.4 - diff --git a/0103-net-hns3-fix-missing-outer-L4-UDP-flag-for-VXLAN.patch b/0103-net-hns3-fix-missing-outer-L4-UDP-flag-for-VXLAN.patch deleted file mode 100644 index 8529f3f..0000000 --- a/0103-net-hns3-fix-missing-outer-L4-UDP-flag-for-VXLAN.patch +++ /dev/null @@ -1,32 +0,0 @@ -From e8eb8b70d1d9cf8c1fd6ece253d4195e49208a21 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:06 +0800 -Subject: [PATCH 103/189] net/hns3: fix missing outer L4 UDP flag for VXLAN - -This patch adds RTE_PTYPE_L4_UDP flag when parsed tunnel vxlan packet. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index f3ced19..7e9b762 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2051,7 +2051,7 @@ hns3_init_tunnel_ptype_tbl(struct hns3_ptype_table *tbl) - tbl->ol3table[5] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT; - - tbl->ol4table[0] = RTE_PTYPE_UNKNOWN; -- tbl->ol4table[1] = RTE_PTYPE_TUNNEL_VXLAN; -+ tbl->ol4table[1] = RTE_PTYPE_L4_UDP | RTE_PTYPE_TUNNEL_VXLAN; - tbl->ol4table[2] = RTE_PTYPE_TUNNEL_NVGRE; - } - --- -2.7.4 - diff --git a/0104-net-hns3-add-reporting-tunnel-GRE-packet-type.patch b/0104-net-hns3-add-reporting-tunnel-GRE-packet-type.patch deleted file mode 100644 index 7583553..0000000 --- a/0104-net-hns3-add-reporting-tunnel-GRE-packet-type.patch +++ /dev/null @@ -1,45 +0,0 @@ -From a501cc13ee7b3047e81233c9488a5782108ede68 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:07 +0800 -Subject: [PATCH 104/189] net/hns3: add reporting tunnel GRE packet type - -This patch supports reporting TUNNEL GRE packet type when rxd advanced -layout enabled. - -Fixes: fb5e90694022 ("net/hns3: support Rx descriptor advanced layout") - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 7e9b762..db64578 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2074,8 +2074,8 @@ hns3_init_adv_layout_ptype(struct hns3_ptype_table *tbl) - RTE_PTYPE_L4_UDP; - ptype[20] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | - RTE_PTYPE_L4_TCP; -- /* The next ptype is GRE over IPv4 */ -- ptype[21] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; -+ ptype[21] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRE; - ptype[22] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | - RTE_PTYPE_L4_SCTP; - ptype[23] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV4_EXT_UNKNOWN | -@@ -2162,8 +2162,8 @@ hns3_init_adv_layout_ptype(struct hns3_ptype_table *tbl) - RTE_PTYPE_L4_UDP; - ptype[114] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | - RTE_PTYPE_L4_TCP; -- /* The next ptype is GRE over IPv6 */ -- ptype[115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; -+ ptype[115] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | -+ RTE_PTYPE_TUNNEL_GRE; - ptype[116] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | - RTE_PTYPE_L4_SCTP; - ptype[117] = RTE_PTYPE_L2_ETHER | RTE_PTYPE_L3_IPV6_EXT_UNKNOWN | --- -2.7.4 - diff --git a/0105-net-hns3-fix-PTP-capability-report.patch b/0105-net-hns3-fix-PTP-capability-report.patch deleted file mode 100644 index 14de7cc..0000000 --- a/0105-net-hns3-fix-PTP-capability-report.patch +++ /dev/null @@ -1,47 +0,0 @@ -From de73577fd9d4db0ea444cd88ab32b03f7d67e81f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:08 +0800 -Subject: [PATCH 105/189] net/hns3: fix PTP capability report - -The PTP depends on special packet type reported by hardware which -enabled rxd advanced layout, so if the hardware doesn't support rxd -advanced layout, driver should ignore the PTP capability. - -Fixes: 438752358158 ("net/hns3: get device capability from firmware") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 15 +++++++++++++-- - 1 file changed, 13 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 58833ce..41e2caa 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -422,8 +422,19 @@ hns3_parse_capability(struct hns3_hw *hw, - if (hns3_get_bit(caps, HNS3_CAPS_FD_QUEUE_REGION_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, - 1); -- if (hns3_get_bit(caps, HNS3_CAPS_PTP_B)) -- hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_PTP_B, 1); -+ if (hns3_get_bit(caps, HNS3_CAPS_PTP_B)) { -+ /* -+ * PTP depends on special packet type reported by hardware which -+ * enabled rxd advanced layout, so if the hardware doesn't -+ * support rxd advanced layout, driver should ignore the PTP -+ * capability. -+ */ -+ if (hns3_get_bit(caps, HNS3_CAPS_RXD_ADV_LAYOUT_B)) -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_PTP_B, 1); -+ else -+ hns3_warn(hw, "ignore PTP capability due to lack of " -+ "rxd advanced layout capability."); -+ } - if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B)) --- -2.7.4 - diff --git a/0106-net-hns3-list-supported-ptypes-for-advanced-Rx-descr.patch b/0106-net-hns3-list-supported-ptypes-for-advanced-Rx-descr.patch deleted file mode 100644 index 53475f7..0000000 --- a/0106-net-hns3-list-supported-ptypes-for-advanced-Rx-descr.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 80f567aff0391603b59243ef493730ec360caaba Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:10 +0800 -Subject: [PATCH 106/189] net/hns3: list supported ptypes for advanced Rx - descriptor - -Kunpeng 930 supports RXD advanced layout. If enabled the layout, the -hardware will report packet type by 8-bit PTYPE filed in the Rx -descriptor, and the supported ptypes are different from original -scheme. So this patch adds supported list for RXD advanced layout. - -Fixes: fb5e90694022 ("net/hns3: support Rx descriptor advanced layout") - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 37 +++++++++++++++++++++++++++++++++++-- - 1 file changed, 35 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index db64578..a37c3c1 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1991,12 +1991,45 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) - RTE_PTYPE_TUNNEL_NVGRE, - RTE_PTYPE_UNKNOWN - }; -+ static const uint32_t adv_layout_ptypes[] = { -+ RTE_PTYPE_L2_ETHER, -+ RTE_PTYPE_L2_ETHER_TIMESYNC, -+ RTE_PTYPE_L2_ETHER_LLDP, -+ RTE_PTYPE_L2_ETHER_ARP, -+ RTE_PTYPE_L3_IPV4_EXT_UNKNOWN, -+ RTE_PTYPE_L3_IPV6_EXT_UNKNOWN, -+ RTE_PTYPE_L4_FRAG, -+ RTE_PTYPE_L4_NONFRAG, -+ RTE_PTYPE_L4_UDP, -+ RTE_PTYPE_L4_TCP, -+ RTE_PTYPE_L4_SCTP, -+ RTE_PTYPE_L4_IGMP, -+ RTE_PTYPE_L4_ICMP, -+ RTE_PTYPE_TUNNEL_GRE, -+ RTE_PTYPE_TUNNEL_GRENAT, -+ RTE_PTYPE_INNER_L2_ETHER, -+ RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN, -+ RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN, -+ RTE_PTYPE_INNER_L4_FRAG, -+ RTE_PTYPE_INNER_L4_ICMP, -+ RTE_PTYPE_INNER_L4_NONFRAG, -+ RTE_PTYPE_INNER_L4_UDP, -+ RTE_PTYPE_INNER_L4_TCP, -+ RTE_PTYPE_INNER_L4_SCTP, -+ RTE_PTYPE_INNER_L4_ICMP, -+ RTE_PTYPE_UNKNOWN -+ }; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - - if (dev->rx_pkt_burst == hns3_recv_pkts || - dev->rx_pkt_burst == hns3_recv_scattered_pkts || - dev->rx_pkt_burst == hns3_recv_pkts_vec || -- dev->rx_pkt_burst == hns3_recv_pkts_vec_sve) -- return ptypes; -+ dev->rx_pkt_burst == hns3_recv_pkts_vec_sve) { -+ if (hns3_dev_rxd_adv_layout_supported(hw)) -+ return adv_layout_ptypes; -+ else -+ return ptypes; -+ } - - return NULL; - } --- -2.7.4 - diff --git a/0107-net-hns3-remove-VLAN-QinQ-ptypes-from-support-list.patch b/0107-net-hns3-remove-VLAN-QinQ-ptypes-from-support-list.patch deleted file mode 100644 index 5df13d5..0000000 --- a/0107-net-hns3-remove-VLAN-QinQ-ptypes-from-support-list.patch +++ /dev/null @@ -1,49 +0,0 @@ -From e535bf3131e855ad973c309ec6c5b35e627751aa Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 13 Apr 2021 19:50:11 +0800 -Subject: [PATCH 107/189] net/hns3: remove VLAN/QinQ ptypes from support list - -In the previous patch, driver will calculate packet type by ignoring -VLAN information because the packet type may calculate error when -exist VLAN and VLAN strip. - -So here remove the following ptypes from support list: -1) RTE_PTYPE_L2_ETHER_VLAN -2) RTE_PTYPE_L2_ETHER_QINQ -3) RTE_PTYPE_INNER_L2_ETHER_VLAN -4) RTE_PTYPE_INNER_L2_ETHER_QINQ - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index a37c3c1..43f8c64 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1962,8 +1962,6 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) - { - static const uint32_t ptypes[] = { - RTE_PTYPE_L2_ETHER, -- RTE_PTYPE_L2_ETHER_VLAN, -- RTE_PTYPE_L2_ETHER_QINQ, - RTE_PTYPE_L2_ETHER_LLDP, - RTE_PTYPE_L2_ETHER_ARP, - RTE_PTYPE_L3_IPV4, -@@ -1977,8 +1975,6 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) - RTE_PTYPE_L4_UDP, - RTE_PTYPE_TUNNEL_GRE, - RTE_PTYPE_INNER_L2_ETHER, -- RTE_PTYPE_INNER_L2_ETHER_VLAN, -- RTE_PTYPE_INNER_L2_ETHER_QINQ, - RTE_PTYPE_INNER_L3_IPV4, - RTE_PTYPE_INNER_L3_IPV6, - RTE_PTYPE_INNER_L3_IPV4_EXT, --- -2.7.4 - diff --git a/0108-net-hns3-fix-supported-speed-of-copper-ports.patch b/0108-net-hns3-fix-supported-speed-of-copper-ports.patch deleted file mode 100644 index 692973d..0000000 --- a/0108-net-hns3-fix-supported-speed-of-copper-ports.patch +++ /dev/null @@ -1,75 +0,0 @@ -From aab52c0cbdfbd5c05a8589d08bcdbaa6f34739be Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:11 +0800 -Subject: [PATCH 108/189] net/hns3: fix supported speed of copper ports - -The "supported capability" obtained from firmware on copper ports -includes the speed capability, auto-negotiation capability, and flow -control capability. Therefore, this patch changes "supported_capa" to -"supported_speed" and parses the speed capability supported by the -driver from the "supported capability". - -Fixes: 2e4859f3b362 ("net/hns3: support PF device with copper PHYs") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 11 +++++++---- - drivers/net/hns3/hns3_ethdev.h | 2 +- - 2 files changed, 8 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index a06fdc9..e57163b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4612,7 +4612,10 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) - static void - hns3_parse_copper_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) - { -+#define HNS3_PHY_SUPPORTED_SPEED_MASK 0x2f -+ - struct hns3_phy_params_bd0_cmd *req; -+ uint32_t supported; - - req = (struct hns3_phy_params_bd0_cmd *)desc[0].data; - mac->link_speed = rte_le_to_cpu_32(req->speed); -@@ -4620,11 +4623,11 @@ hns3_parse_copper_phy_params(struct hns3_cmd_desc *desc, struct hns3_mac *mac) - HNS3_PHY_DUPLEX_CFG_B); - mac->link_autoneg = hns3_get_bit(req->autoneg, - HNS3_PHY_AUTONEG_CFG_B); -- mac->supported_capa = rte_le_to_cpu_32(req->supported); - mac->advertising = rte_le_to_cpu_32(req->advertising); - mac->lp_advertising = rte_le_to_cpu_32(req->lp_advertising); -- mac->support_autoneg = !!(mac->supported_capa & -- HNS3_PHY_LINK_MODE_AUTONEG_BIT); -+ supported = rte_le_to_cpu_32(req->supported); -+ mac->supported_speed = supported & HNS3_PHY_SUPPORTED_SPEED_MASK; -+ mac->support_autoneg = !!(supported & HNS3_PHY_LINK_MODE_AUTONEG_BIT); - } - - static int -@@ -4673,7 +4676,7 @@ hns3_update_copper_link_info(struct hns3_hw *hw) - mac->link_speed = mac_info.link_speed; - mac->link_duplex = mac_info.link_duplex; - mac->link_autoneg = mac_info.link_autoneg; -- mac->supported_capa = mac_info.supported_capa; -+ mac->supported_speed = mac_info.supported_speed; - mac->advertising = mac_info.advertising; - mac->lp_advertising = mac_info.lp_advertising; - mac->support_autoneg = mac_info.support_autoneg; -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 1763cc9..986bf26 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -183,7 +183,7 @@ struct hns3_mac { - uint8_t link_autoneg : 1; /* ETH_LINK_[AUTONEG/FIXED] */ - uint8_t link_status : 1; /* ETH_LINK_[DOWN/UP] */ - uint32_t link_speed; /* ETH_SPEED_NUM_ */ -- uint32_t supported_capa; /* supported capability for current media */ -+ uint32_t supported_speed; /* supported speed for current media type */ - uint32_t advertising; /* advertised capability in the local part */ - /* advertised capability in the link partner */ - uint32_t lp_advertising; --- -2.7.4 - diff --git a/0109-net-hns3-add-1000M-speed-bit-for-copper-PHYs.patch b/0109-net-hns3-add-1000M-speed-bit-for-copper-PHYs.patch deleted file mode 100644 index 07e60e7..0000000 --- a/0109-net-hns3-add-1000M-speed-bit-for-copper-PHYs.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 8000e1aa7b8666b401153b6e31519b62d1423aa3 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:12 +0800 -Subject: [PATCH 109/189] net/hns3: add 1000M speed bit for copper PHYs - -The bit(5) of supported, advertising and lp_advertising for copper -PHYs obtained from the firmware indicates 1000M full-duplex. This -speed capability bit is missing in the current codes. - -Fixes: 2e4859f3b362 ("net/hns3: support PF device with copper PHYs") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 9a975b8..a7dd2b5 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -679,6 +679,7 @@ struct hns3_firmware_compat_cmd { - #define HNS3_PHY_LINK_SPEED_10M_BIT BIT(1) - #define HNS3_PHY_LINK_SPEED_100M_HD_BIT BIT(2) - #define HNS3_PHY_LINK_SPEED_100M_BIT BIT(3) -+#define HNS3_PHY_LINK_SPEED_1000M_BIT BIT(5) - #define HNS3_PHY_LINK_MODE_AUTONEG_BIT BIT(6) - #define HNS3_PHY_LINK_MODE_PAUSE_BIT BIT(13) - #define HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT BIT(14) --- -2.7.4 - diff --git a/0110-net-hns3-fix-flow-control-mode.patch b/0110-net-hns3-fix-flow-control-mode.patch deleted file mode 100644 index 785897c..0000000 --- a/0110-net-hns3-fix-flow-control-mode.patch +++ /dev/null @@ -1,245 +0,0 @@ -From ad7b090b87b90f4348cc257b22f4253e466e46f3 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:13 +0800 -Subject: [PATCH 110/189] net/hns3: fix flow control mode - -Currently, hns3 driver doesn't support to flow control auto-negotiation. -The FC mode requested by user is the same as the current FC mode. It is -not necessary to maintain the current FC mode. We only report the current -FC mode based on actual flow control mode in hns3_flow_ctrl_get(). - -This patch removes this redundant field. In addition, "requested_mode" in -hns3_hw struct indicates the FC mode requested by user, and the name is -unreasonable. It needs to be modified to "requested_fc_mode". - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 23 ++++++++--------------- - drivers/net/hns3/hns3_ethdev.c | 28 ++++++++++------------------ - drivers/net/hns3/hns3_ethdev.h | 3 +-- - 3 files changed, 19 insertions(+), 35 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index ebfc240..49b8be7 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1238,7 +1238,7 @@ hns3_qs_bp_cfg(struct hns3_hw *hw, uint8_t tc, uint8_t grp_id, uint32_t bit_map) - static void - hns3_get_rx_tx_en_status(struct hns3_hw *hw, bool *tx_en, bool *rx_en) - { -- switch (hw->current_mode) { -+ switch (hw->requested_fc_mode) { - case HNS3_FC_NONE: - *tx_en = false; - *rx_en = false; -@@ -1415,7 +1415,7 @@ hns3_dcb_cfg_validate(struct hns3_adapter *hns, uint8_t *tc, bool *changed) - * We ensure that dcb information can be reconfigured - * after the hns3_priority_flow_ctrl_set function called. - */ -- if (hw->current_mode != HNS3_FC_FULL) -+ if (hw->requested_fc_mode != HNS3_FC_FULL) - *changed = true; - pfc_en = RTE_LEN2MASK((uint8_t)dcb_rx_conf->nb_tcs, uint8_t); - if (hw->dcb_info.pfc_en != pfc_en) -@@ -1529,7 +1529,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - struct hns3_pf *pf = &hns->pf; - struct hns3_hw *hw = &hns->hw; - enum hns3_fc_status fc_status = hw->current_fc_status; -- enum hns3_fc_mode current_mode = hw->current_mode; -+ enum hns3_fc_mode requested_fc_mode = hw->requested_fc_mode; - uint8_t hw_pfc_map = hw->dcb_info.hw_pfc_map; - int ret, status; - -@@ -1559,7 +1559,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - return ret; - - hw->current_fc_status = HNS3_FC_STATUS_PFC; -- hw->current_mode = HNS3_FC_FULL; -+ hw->requested_fc_mode = HNS3_FC_FULL; - ret = hns3_dcb_pause_setup_hw(hw); - if (ret) { - hns3_err(hw, "setup pfc failed! ret = %d", ret); -@@ -1580,7 +1580,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - return 0; - - pfc_setup_fail: -- hw->current_mode = current_mode; -+ hw->requested_fc_mode = requested_fc_mode; - hw->current_fc_status = fc_status; - hw->dcb_info.hw_pfc_map = hw_pfc_map; - status = hns3_buffer_alloc(hw); -@@ -1659,8 +1659,7 @@ hns3_dcb_init(struct hns3_hw *hw) - * will be changed. - */ - if (hw->adapter_state == HNS3_NIC_UNINITIALIZED) { -- hw->requested_mode = HNS3_FC_NONE; -- hw->current_mode = hw->requested_mode; -+ hw->requested_fc_mode = HNS3_FC_NONE; - pf->pause_time = HNS3_DEFAULT_PAUSE_TRANS_TIME; - hw->current_fc_status = HNS3_FC_STATUS_NONE; - -@@ -1761,7 +1760,6 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); - enum hns3_fc_status fc_status = hw->current_fc_status; -- enum hns3_fc_mode current_mode = hw->current_mode; - uint8_t hw_pfc_map = hw->dcb_info.hw_pfc_map; - uint8_t pfc_en = hw->dcb_info.pfc_en; - uint8_t priority = pfc_conf->priority; -@@ -1769,7 +1767,6 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - int ret, status; - - pf->pause_time = pfc_conf->fc.pause_time; -- hw->current_mode = hw->requested_mode; - hw->current_fc_status = HNS3_FC_STATUS_PFC; - hw->dcb_info.pfc_en |= BIT(priority); - hw->dcb_info.hw_pfc_map = -@@ -1780,7 +1777,7 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - - /* - * The flow control mode of all UPs will be changed based on -- * current_mode coming from user. -+ * requested_fc_mode coming from user. - */ - ret = hns3_dcb_pause_setup_hw(hw); - if (ret) { -@@ -1791,7 +1788,6 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - return 0; - - pfc_setup_fail: -- hw->current_mode = current_mode; - hw->current_fc_status = fc_status; - pf->pause_time = pause_time; - hw->dcb_info.pfc_en = pfc_en; -@@ -1815,18 +1811,16 @@ hns3_fc_enable(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); - enum hns3_fc_status fc_status = hw->current_fc_status; -- enum hns3_fc_mode current_mode = hw->current_mode; - uint16_t pause_time = pf->pause_time; - int ret; - - pf->pause_time = fc_conf->pause_time; -- hw->current_mode = hw->requested_mode; - - /* - * In fact, current_fc_status is HNS3_FC_STATUS_NONE when mode - * of flow control is configured to be HNS3_FC_NONE. - */ -- if (hw->current_mode == HNS3_FC_NONE) -+ if (hw->requested_fc_mode == HNS3_FC_NONE) - hw->current_fc_status = HNS3_FC_STATUS_NONE; - else - hw->current_fc_status = HNS3_FC_STATUS_MAC_PAUSE; -@@ -1840,7 +1834,6 @@ hns3_fc_enable(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - return 0; - - setup_fc_fail: -- hw->current_mode = current_mode; - hw->current_fc_status = fc_status; - pf->pause_time = pause_time; - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index e57163b..5e7ac54 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5496,8 +5496,11 @@ hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - - fc_conf->pause_time = pf->pause_time; - -- /* return fc current mode */ -- switch (hw->current_mode) { -+ /* -+ * If fc auto-negotiation is not supported, the configured fc mode -+ * from user is the current fc mode. -+ */ -+ switch (hw->requested_fc_mode) { - case HNS3_FC_FULL: - fc_conf->mode = RTE_FC_FULL; - break; -@@ -5521,19 +5524,19 @@ hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) - { - switch (mode) { - case RTE_FC_NONE: -- hw->requested_mode = HNS3_FC_NONE; -+ hw->requested_fc_mode = HNS3_FC_NONE; - break; - case RTE_FC_RX_PAUSE: -- hw->requested_mode = HNS3_FC_RX_PAUSE; -+ hw->requested_fc_mode = HNS3_FC_RX_PAUSE; - break; - case RTE_FC_TX_PAUSE: -- hw->requested_mode = HNS3_FC_TX_PAUSE; -+ hw->requested_fc_mode = HNS3_FC_TX_PAUSE; - break; - case RTE_FC_FULL: -- hw->requested_mode = HNS3_FC_FULL; -+ hw->requested_fc_mode = HNS3_FC_FULL; - break; - default: -- hw->requested_mode = HNS3_FC_NONE; -+ hw->requested_fc_mode = HNS3_FC_NONE; - hns3_warn(hw, "fc_mode(%u) exceeds member scope and is " - "configured to RTE_FC_NONE", mode); - break; -@@ -5544,7 +5547,6 @@ static int - hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); - int ret; - - if (fc_conf->high_water || fc_conf->low_water || -@@ -5579,9 +5581,6 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - } - - hns3_get_fc_mode(hw, fc_conf->mode); -- if (hw->requested_mode == hw->current_mode && -- pf->pause_time == fc_conf->pause_time) -- return 0; - - rte_spinlock_lock(&hw->lock); - ret = hns3_fc_enable(dev, fc_conf); -@@ -5595,8 +5594,6 @@ hns3_priority_flow_ctrl_set(struct rte_eth_dev *dev, - struct rte_eth_pfc_conf *pfc_conf) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -- uint8_t priority; - int ret; - - if (!hns3_dev_dcb_supported(hw)) { -@@ -5631,12 +5628,7 @@ hns3_priority_flow_ctrl_set(struct rte_eth_dev *dev, - return -EOPNOTSUPP; - } - -- priority = pfc_conf->priority; - hns3_get_fc_mode(hw, pfc_conf->fc.mode); -- if (hw->dcb_info.pfc_en & BIT(priority) && -- hw->requested_mode == hw->current_mode && -- pfc_conf->fc.pause_time == pf->pause_time) -- return 0; - - rte_spinlock_lock(&hw->lock); - ret = hns3_dcb_pfc_enable(dev, pfc_conf); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 986bf26..03bb783 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -469,8 +469,7 @@ struct hns3_hw { - - uint8_t num_tc; /* Total number of enabled TCs */ - uint8_t hw_tc_map; -- enum hns3_fc_mode current_mode; -- enum hns3_fc_mode requested_mode; -+ enum hns3_fc_mode requested_fc_mode; /* FC mode requested by user */ - struct hns3_dcb_info dcb_info; - enum hns3_fc_status current_fc_status; /* current flow control status */ - struct hns3_tc_queue_info tc_queue[HNS3_MAX_TC_NUM]; --- -2.7.4 - diff --git a/0111-net-hns3-fix-firmware-compatibility-configuration.patch b/0111-net-hns3-fix-firmware-compatibility-configuration.patch deleted file mode 100644 index 1c01a12..0000000 --- a/0111-net-hns3-fix-firmware-compatibility-configuration.patch +++ /dev/null @@ -1,278 +0,0 @@ -From a74108b0e8f10b207b2b253c5511efd519d071a3 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:14 +0800 -Subject: [PATCH 111/189] net/hns3: fix firmware compatibility configuration - -The firmware compatibility configuration in PF driver is used to -maintain the compatibility of some features of the driver and -firmware, and requires firmware to enable these features. Currently, -the configuration is in hns3_init_hardware(), which is a little back. -Because firmware may clear some configurations (such as, MAC related) -after receiving the command. And firmware can not be aware of some -default initializations (such as, flow control) before executing the -command to set the copper PHY when the PHY is controlled by firmware. -Therefore, it is recommended that no other hardware resources are -configured before the compatibility configuration. And it should be -moved to hns3_cmd_init(), which is responsible for the firmware -command initialization of driver. - -In addition, the driver needs to perform corresponding processing -if the command fails to be sent. -1) If firmware fails to take over the copper PHY, the copper port fails - to initialize. -2) If fails to enable the report of link events, the device does not - support the LSC capability. - -Fixes: bff6ebfe30d4 ("net/hns3: refactor PF LSC event report") -Fixes: bac6a0644121 ("net/hns3: fix link status change from firmware") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 116 +++++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_ethdev.c | 56 -------------------- - 2 files changed, 116 insertions(+), 56 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 41e2caa..15bf781 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -526,9 +526,99 @@ hns3_cmd_init_queue(struct hns3_hw *hw) - return ret; - } - -+static void -+hns3_update_dev_lsc_cap(struct hns3_hw *hw, int fw_compact_cmd_result) -+{ -+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ -+ if (hw->adapter_state != HNS3_NIC_UNINITIALIZED) -+ return; -+ -+ if (fw_compact_cmd_result != 0) { -+ /* -+ * If fw_compact_cmd_result is not zero, it means firmware don't -+ * support link status change interrupt. -+ * Framework already set RTE_ETH_DEV_INTR_LSC bit because driver -+ * declared RTE_PCI_DRV_INTR_LSC in drv_flags. It need to clear -+ * the RTE_ETH_DEV_INTR_LSC capability when detect firmware -+ * don't support link status change interrupt. -+ */ -+ dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC; -+ } -+} -+ -+static int -+hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result) -+{ -+ if (result != 0 && hns3_dev_copper_supported(hw)) { -+ hns3_err(hw, "firmware fails to initialize the PHY, ret = %d.", -+ result); -+ return result; -+ } -+ -+ hns3_update_dev_lsc_cap(hw, result); -+ -+ return 0; -+} -+ -+static int -+hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) -+{ -+ struct hns3_firmware_compat_cmd *req; -+ struct hns3_cmd_desc desc; -+ uint32_t compat = 0; -+ -+#if defined(RTE_HNS3_ONLY_1630_FPGA) -+ /* If resv reg enabled phy driver of imp is not configured, driver -+ * will use temporary phy driver. -+ */ -+ struct rte_pci_device *pci_dev; -+ struct rte_eth_dev *eth_dev; -+ uint8_t revision; -+ int ret; -+ -+ eth_dev = &rte_eth_devices[hw->data->port_id]; -+ pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); -+ /* Get PCI revision id */ -+ ret = rte_pci_read_config(pci_dev, &revision, HNS3_PCI_REVISION_ID_LEN, -+ HNS3_PCI_REVISION_ID); -+ if (ret != HNS3_PCI_REVISION_ID_LEN) { -+ PMD_INIT_LOG(ERR, "failed to read pci revision id, ret = %d", -+ ret); -+ return -EIO; -+ } -+ if (revision == PCI_REVISION_ID_HIP09_A) { -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ if (hns3_dev_copper_supported(hw) == 0 || pf->is_tmp_phy) { -+ PMD_INIT_LOG(ERR, "***use temp phy driver in dpdk***"); -+ pf->is_tmp_phy = true; -+ hns3_set_bit(hw->capability, -+ HNS3_DEV_SUPPORT_COPPER_B, 1); -+ return 0; -+ } -+ -+ PMD_INIT_LOG(ERR, "***use phy driver in imp***"); -+ } -+#endif -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false); -+ req = (struct hns3_firmware_compat_cmd *)desc.data; -+ -+ if (is_init) { -+ hns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1); -+ hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); -+ if (hns3_dev_copper_supported(hw)) -+ hns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1); -+ } -+ req->compat = rte_cpu_to_le_32(compat); -+ -+ return hns3_cmd_send(hw, &desc, 1); -+} -+ - int - hns3_cmd_init(struct hns3_hw *hw) - { -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - uint32_t version; - int ret; - -@@ -575,6 +665,27 @@ hns3_cmd_init(struct hns3_hw *hw) - hns3_get_field(version, HNS3_FW_VERSION_BYTE0_M, - HNS3_FW_VERSION_BYTE0_S)); - -+ if (hns->is_vf) -+ return 0; -+ -+ /* -+ * Requiring firmware to enable some features, firber port can still -+ * work without it, but copper port can't work because the firmware -+ * fails to take over the PHY. -+ */ -+ ret = hns3_firmware_compat_config(hw, true); -+ if (ret) -+ PMD_INIT_LOG(WARNING, "firmware compatible features not " -+ "supported, ret = %d.", ret); -+ -+ /* -+ * Perform some corresponding operations based on the firmware -+ * compatibility configuration result. -+ */ -+ ret = hns3_apply_fw_compat_cmd_result(hw, ret); -+ if (ret) -+ goto err_cmd_init; -+ - return 0; - - err_cmd_init: -@@ -602,6 +713,11 @@ hns3_cmd_destroy_queue(struct hns3_hw *hw) - void - hns3_cmd_uninit(struct hns3_hw *hw) - { -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ -+ if (!hns->is_vf) -+ (void)hns3_firmware_compat_config(hw, false); -+ - __atomic_store_n(&hw->reset.disable_cmd, 1, __ATOMIC_RELAXED); - - /* -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 5e7ac54..7bae923 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4118,28 +4118,6 @@ hns3_buffer_alloc(struct hns3_hw *hw) - } - - static int --hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) --{ -- struct hns3_firmware_compat_cmd *req; -- struct hns3_cmd_desc desc; -- uint32_t compat = 0; -- -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_FIRMWARE_COMPAT_CFG, false); -- req = (struct hns3_firmware_compat_cmd *)desc.data; -- -- if (is_init) { -- hns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1); -- hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); -- if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) -- hns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1); -- } -- -- req->compat = rte_cpu_to_le_32(compat); -- -- return hns3_cmd_send(hw, &desc, 1); --} -- --static int - hns3_mac_init(struct hns3_hw *hw) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -@@ -4815,28 +4793,6 @@ hns3_service_handler(void *param) - rte_eal_alarm_set(HNS3_SERVICE_INTERVAL, hns3_service_handler, eth_dev); - } - --static void --hns3_update_dev_lsc_cap(struct hns3_hw *hw, -- int fw_compact_cmd_result) --{ -- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -- -- if (hw->adapter_state != HNS3_NIC_UNINITIALIZED) -- return; -- -- if (fw_compact_cmd_result != 0) { -- /* -- * If fw_compact_cmd_result is not zero, it means firmware don't -- * support link status change interrupt. -- * Framework already set RTE_ETH_DEV_INTR_LSC bit because driver -- * declared RTE_PCI_DRV_INTR_LSC in drv_flags. It need to clear -- * the RTE_ETH_DEV_INTR_LSC capability when detect firmware -- * don't support link status change interrupt. -- */ -- dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC; -- } --} -- - static int - hns3_init_hardware(struct hns3_adapter *hns) - { -@@ -4916,16 +4872,6 @@ hns3_init_hardware(struct hns3_adapter *hns) - goto err_mac_init; - } - -- /* -- * Requiring firmware to enable some features, driver can -- * still work without it. -- */ -- ret = hns3_firmware_compat_config(hw, true); -- if (ret) -- PMD_INIT_LOG(WARNING, "firmware compatible features not " -- "supported, ret = %d.", ret); -- hns3_update_dev_lsc_cap(hw, ret); -- - return 0; - - err_mac_init: -@@ -5073,7 +5019,6 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - err_enable_intr: - hns3_fdir_filter_uninit(hns); - err_fdir: -- (void)hns3_firmware_compat_config(hw, false); - hns3_uninit_umv_space(hw); - err_init_hw: - hns3_tqp_stats_uninit(hw); -@@ -5108,7 +5053,6 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - (void)hns3_config_gro(hw, false); - hns3_promisc_uninit(hw); - hns3_fdir_filter_uninit(hns); -- (void)hns3_firmware_compat_config(hw, false); - hns3_uninit_umv_space(hw); - hns3_tqp_stats_uninit(hw); - hns3_config_mac_tnl_int(hw, false); --- -2.7.4 - diff --git a/0112-net-hns3-obtain-supported-speed-for-fiber-port.patch b/0112-net-hns3-obtain-supported-speed-for-fiber-port.patch deleted file mode 100644 index 6aa88f4..0000000 --- a/0112-net-hns3-obtain-supported-speed-for-fiber-port.patch +++ /dev/null @@ -1,275 +0,0 @@ -From 984fd9914cfd3f9d24eb9b6c0914595dba9f3575 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:15 +0800 -Subject: [PATCH 112/189] net/hns3: obtain supported speed for fiber port - -Currently, the speed of fiber port is obtained by using the default -query type of HNS3_OPC_GET_SFP_INFO opcode. In this way, only -the speed of the optical module can be obtained. In fact, the opcode -also supports an active query type, which is a channel for obtaining -information such as the speed, the supported speed, auto-negotiation -capability, and FEC mode. This patch changes the query type of the -opcode from the default query type to the active query type to obtain -the supported speed of fiber port. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 41 ++++++++++++++-------- - drivers/net/hns3/hns3_ethdev.c | 80 ++++++++++++++++++++++++++++++++---------- - drivers/net/hns3/hns3_ethdev.h | 26 ++++++++++++-- - 3 files changed, 113 insertions(+), 34 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index a7dd2b5..4c25c43 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -230,7 +230,7 @@ enum hns3_opcode_type { - /* SFP command */ - HNS3_OPC_GET_SFP_EEPROM = 0x7100, - HNS3_OPC_GET_SFP_EXIST = 0x7101, -- HNS3_OPC_SFP_GET_SPEED = 0x7104, -+ HNS3_OPC_GET_SFP_INFO = 0x7104, - - /* Interrupts commands */ - HNS3_OPC_ADD_RING_TO_VECTOR = 0x1503, -@@ -767,13 +767,6 @@ struct hns3_config_auto_neg_cmd { - uint8_t rsv[20]; - }; - --#define HNS3_MAC_CFG_FEC_AUTO_EN_B 0 --#define HNS3_MAC_CFG_FEC_MODE_S 1 --#define HNS3_MAC_CFG_FEC_MODE_M GENMASK(3, 1) --#define HNS3_MAC_FEC_OFF 0 --#define HNS3_MAC_FEC_BASER 1 --#define HNS3_MAC_FEC_RS 2 -- - #define HNS3_SFP_INFO_BD0_LEN 20UL - #define HNS3_SFP_INFO_BDX_LEN 24UL - -@@ -788,14 +781,34 @@ struct hns3_sfp_type { - uint8_t ext_type; - }; - --struct hns3_sfp_speed_cmd { -- uint32_t sfp_speed; -- uint8_t query_type; /* 0: sfp speed, 1: active fec */ -- uint8_t active_fec; /* current FEC mode */ -- uint16_t rsv1; -- uint32_t rsv2[4]; -+/* Bitmap flags in supported_speed */ -+#define HNS3_FIBER_LINK_SPEED_1G_BIT BIT(0) -+#define HNS3_FIBER_LINK_SPEED_10G_BIT BIT(1) -+#define HNS3_FIBER_LINK_SPEED_25G_BIT BIT(2) -+#define HNS3_FIBER_LINK_SPEED_50G_BIT BIT(3) -+#define HNS3_FIBER_LINK_SPEED_100G_BIT BIT(4) -+#define HNS3_FIBER_LINK_SPEED_40G_BIT BIT(5) -+#define HNS3_FIBER_LINK_SPEED_100M_BIT BIT(6) -+#define HNS3_FIBER_LINK_SPEED_10M_BIT BIT(7) -+#define HNS3_FIBER_LINK_SPEED_200G_BIT BIT(8) -+ -+struct hns3_sfp_info_cmd { -+ uint32_t sfp_speed; -+ uint8_t query_type; /* 0: sfp speed, 1: active */ -+ uint8_t active_fec; /* current FEC mode */ -+ uint16_t rsv; -+ uint32_t supported_speed; /* speed supported by current media */ -+ uint32_t module_type; -+ uint8_t rsv1[8]; - }; - -+#define HNS3_MAC_CFG_FEC_AUTO_EN_B 0 -+#define HNS3_MAC_CFG_FEC_MODE_S 1 -+#define HNS3_MAC_CFG_FEC_MODE_M GENMASK(3, 1) -+#define HNS3_MAC_FEC_OFF 0 -+#define HNS3_MAC_FEC_BASER 1 -+#define HNS3_MAC_FEC_RS 2 -+ - /* Configure FEC mode, opcode:0x031A */ - struct hns3_config_fec_cmd { - uint8_t fec_mode; -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7bae923..5f629e7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4507,24 +4507,45 @@ hns3_dev_promisc_restore(struct hns3_adapter *hns) - } - - static int --hns3_get_sfp_speed(struct hns3_hw *hw, uint32_t *speed) -+hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info) - { -- struct hns3_sfp_speed_cmd *resp; -+ struct hns3_sfp_info_cmd *resp; - struct hns3_cmd_desc desc; - int ret; - -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_SFP_GET_SPEED, true); -- resp = (struct hns3_sfp_speed_cmd *)desc.data; -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_GET_SFP_INFO, true); -+ resp = (struct hns3_sfp_info_cmd *)desc.data; -+ resp->query_type = HNS3_ACTIVE_QUERY; -+ - ret = hns3_cmd_send(hw, &desc, 1); - if (ret == -EOPNOTSUPP) { -- hns3_err(hw, "IMP do not support get SFP speed %d", ret); -+ hns3_warn(hw, "firmware does not support get SFP info," -+ " ret = %d.", ret); - return ret; - } else if (ret) { -- hns3_err(hw, "get sfp speed failed %d", ret); -+ hns3_err(hw, "get sfp info failed, ret = %d.", ret); - return ret; - } - -- *speed = resp->sfp_speed; -+ /* -+ * In some case, the speed of MAC obtained from firmware may be 0, it -+ * shouldn't be set to mac->speed. -+ */ -+ if (!rte_le_to_cpu_32(resp->sfp_speed)) -+ return 0; -+ -+ mac_info->link_speed = rte_le_to_cpu_32(resp->sfp_speed); -+ /* -+ * if resp->supported_speed is 0, it means it's an old version -+ * firmware, do not update these params. -+ */ -+ if (resp->supported_speed) { -+ mac_info->query_type = HNS3_ACTIVE_QUERY; -+ mac_info->supported_speed = -+ rte_le_to_cpu_32(resp->supported_speed); -+ } else { -+ mac_info->query_type = HNS3_DEFAULT_QUERY; -+ } - - return 0; - } -@@ -4566,25 +4587,49 @@ static int - hns3_update_fiber_link_info(struct hns3_hw *hw) - { - struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -- uint32_t speed; -+ struct hns3_mac *mac = &hw->mac; -+ struct hns3_mac mac_info; - int ret; - -- /* If IMP do not support get SFP/qSFP speed, return directly */ -+ /* If firmware do not support get SFP/qSFP speed, return directly */ - if (!pf->support_sfp_query) - return 0; - -- ret = hns3_get_sfp_speed(hw, &speed); -+ memset(&mac_info, 0, sizeof(struct hns3_mac)); -+ ret = hns3_get_sfp_info(hw, &mac_info); - if (ret == -EOPNOTSUPP) { - pf->support_sfp_query = false; - return ret; - } else if (ret) - return ret; - -- if (speed == ETH_SPEED_NUM_NONE) -- return 0; /* do nothing if no SFP */ -+ /* Do nothing if no SFP */ -+ if (mac_info.link_speed == ETH_SPEED_NUM_NONE) -+ return 0; -+ -+ /* -+ * If query_type is HNS3_ACTIVE_QUERY, it is no need -+ * to reconfigure the speed of MAC. Otherwise, it indicates -+ * that the current firmware only supports to obtain the -+ * speed of the SFP, and the speed of MAC needs to reconfigure. -+ */ -+ mac->query_type = mac_info.query_type; -+ if (mac->query_type == HNS3_ACTIVE_QUERY) { -+ if (mac_info.link_speed != mac->link_speed) { -+ ret = hns3_port_shaper_update(hw, mac_info.link_speed); -+ if (ret) -+ return ret; -+ } -+ -+ mac->link_speed = mac_info.link_speed; -+ mac->supported_speed = mac_info.supported_speed; -+ -+ return 0; -+ } - - /* Config full duplex for SFP */ -- return hns3_cfg_mac_speed_dup(hw, speed, ETH_LINK_FULL_DUPLEX); -+ return hns3_cfg_mac_speed_dup(hw, mac_info.link_speed, -+ ETH_LINK_FULL_DUPLEX); - } - - static void -@@ -6200,8 +6245,7 @@ get_current_fec_auto_state(struct hns3_hw *hw, uint8_t *state) - static int - hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) - { --#define QUERY_ACTIVE_SPEED 1 -- struct hns3_sfp_speed_cmd *resp; -+ struct hns3_sfp_info_cmd *resp; - uint32_t tmp_fec_capa; - uint8_t auto_state; - struct hns3_cmd_desc desc; -@@ -6223,9 +6267,9 @@ hns3_fec_get_internal(struct hns3_hw *hw, uint32_t *fec_capa) - } - } - -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_SFP_GET_SPEED, true); -- resp = (struct hns3_sfp_speed_cmd *)desc.data; -- resp->query_type = QUERY_ACTIVE_SPEED; -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_GET_SFP_INFO, true); -+ resp = (struct hns3_sfp_info_cmd *)desc.data; -+ resp->query_type = HNS3_ACTIVE_QUERY; - - ret = hns3_cmd_send(hw, &desc, 1); - if (ret == -EOPNOTSUPP) { -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 03bb783..a677ddc 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -174,6 +174,9 @@ enum hns3_media_type { - HNS3_MEDIA_TYPE_NONE, - }; - -+#define HNS3_DEFAULT_QUERY 0 -+#define HNS3_ACTIVE_QUERY 1 -+ - struct hns3_mac { - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; - bool default_addr_setted; /* whether default addr(mac_addr) is set */ -@@ -183,10 +186,29 @@ struct hns3_mac { - uint8_t link_autoneg : 1; /* ETH_LINK_[AUTONEG/FIXED] */ - uint8_t link_status : 1; /* ETH_LINK_[DOWN/UP] */ - uint32_t link_speed; /* ETH_SPEED_NUM_ */ -+ /* -+ * Some firmware versions support only the SFP speed query. In addition -+ * to the SFP speed query, some firmware supports the query of the speed -+ * capability, auto-negotiation capability, and FEC mode, which can be -+ * selected by the 'query_type' filed in the HNS3_OPC_GET_SFP_INFO CMD. -+ * This field is used to record the SFP information query mode. -+ * Value range: -+ * HNS3_DEFAULT_QUERY/HNS3_ACTIVE_QUERY -+ * -+ * - HNS3_DEFAULT_QUERY -+ * Speed obtained is from SFP. When the queried speed changes, the MAC -+ * speed needs to be reconfigured. -+ * -+ * - HNS3_ACTIVE_QUERY -+ * Speed obtained is from MAC. At this time, it is unnecessary for -+ * driver to reconfigured the MAC speed. In addition, more information, -+ * such as, the speed capability, auto-negotiation capability and FEC -+ * mode, can be obtained by the HNS3_OPC_GET_SFP_INFO CMD. -+ */ -+ uint8_t query_type; - uint32_t supported_speed; /* supported speed for current media type */ - uint32_t advertising; /* advertised capability in the local part */ -- /* advertised capability in the link partner */ -- uint32_t lp_advertising; -+ uint32_t lp_advertising; /* advertised capability in the link partner */ - uint8_t support_autoneg; - }; - --- -2.7.4 - diff --git a/0113-net-hns3-report-speed-capability-for-PF.patch b/0113-net-hns3-report-speed-capability-for-PF.patch deleted file mode 100644 index 477715f..0000000 --- a/0113-net-hns3-report-speed-capability-for-PF.patch +++ /dev/null @@ -1,206 +0,0 @@ -From 52ae922fdca38de506df971337fcbd0a0cefcd78 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:16 +0800 -Subject: [PATCH 113/189] net/hns3: report speed capability for PF - -The speed capability of the device can be reported to the upper-layer app -in rte_eth_dev_info_get API. In this API, the speed capability is derived -from the 'supported_speed', which is the speed capability actually -supported by the NIC. The value of the 'supported_speed' is obtained -once in the probe stage and may be updated in the scheduled task to deal -with the change of the transmission interface. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/features/hns3.ini | 1 + - drivers/net/hns3/hns3_ethdev.c | 136 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 137 insertions(+) - -diff --git a/doc/guides/nics/features/hns3.ini b/doc/guides/nics/features/hns3.ini -index d1a493b..4685cc1 100644 ---- a/doc/guides/nics/features/hns3.ini -+++ b/doc/guides/nics/features/hns3.ini -@@ -4,6 +4,7 @@ - ; Refer to default.ini for the full list of available PMD features. - ; - [Features] -+Speed capabilities = Y - Link status = Y - Link status event = Y - Rx interrupt = Y -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 5f629e7..aa9f140 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2617,6 +2617,67 @@ hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - return 0; - } - -+static uint32_t -+hns3_get_copper_port_speed_capa(uint32_t supported_speed) -+{ -+ uint32_t speed_capa = 0; -+ -+ if (supported_speed & HNS3_PHY_LINK_SPEED_10M_HD_BIT) -+ speed_capa |= ETH_LINK_SPEED_10M_HD; -+ if (supported_speed & HNS3_PHY_LINK_SPEED_10M_BIT) -+ speed_capa |= ETH_LINK_SPEED_10M; -+ if (supported_speed & HNS3_PHY_LINK_SPEED_100M_HD_BIT) -+ speed_capa |= ETH_LINK_SPEED_100M_HD; -+ if (supported_speed & HNS3_PHY_LINK_SPEED_100M_BIT) -+ speed_capa |= ETH_LINK_SPEED_100M; -+ if (supported_speed & HNS3_PHY_LINK_SPEED_1000M_BIT) -+ speed_capa |= ETH_LINK_SPEED_1G; -+ -+ return speed_capa; -+} -+ -+static uint32_t -+hns3_get_firber_port_speed_capa(uint32_t supported_speed) -+{ -+ uint32_t speed_capa = 0; -+ -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_1G_BIT) -+ speed_capa |= ETH_LINK_SPEED_1G; -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_10G_BIT) -+ speed_capa |= ETH_LINK_SPEED_10G; -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_25G_BIT) -+ speed_capa |= ETH_LINK_SPEED_25G; -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_40G_BIT) -+ speed_capa |= ETH_LINK_SPEED_40G; -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_50G_BIT) -+ speed_capa |= ETH_LINK_SPEED_50G; -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_100G_BIT) -+ speed_capa |= ETH_LINK_SPEED_100G; -+ if (supported_speed & HNS3_FIBER_LINK_SPEED_200G_BIT) -+ speed_capa |= ETH_LINK_SPEED_200G; -+ -+ return speed_capa; -+} -+ -+static uint32_t -+hns3_get_speed_capa(struct hns3_hw *hw) -+{ -+ struct hns3_mac *mac = &hw->mac; -+ uint32_t speed_capa; -+ -+ if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) -+ speed_capa = -+ hns3_get_copper_port_speed_capa(mac->supported_speed); -+ else -+ speed_capa = -+ hns3_get_firber_port_speed_capa(mac->supported_speed); -+ -+ if (mac->support_autoneg == 0) -+ speed_capa |= ETH_LINK_SPEED_FIXED; -+ -+ return speed_capa; -+} -+ - int - hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - { -@@ -2688,6 +2749,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - .nb_mtu_seg_max = hw->max_non_tso_bd_num, - }; - -+ info->speed_capa = hns3_get_speed_capa(hw); - info->default_rxconf = (struct rte_eth_rxconf) { - .rx_free_thresh = HNS3_DEFAULT_RX_FREE_THRESH, - /* -@@ -4957,6 +5019,71 @@ hns3_config_all_msix_error(struct hns3_hw *hw, bool enable) - hns3_write_dev(hw, HNS3_VECTOR0_OTER_EN_REG, val); - } - -+static uint32_t -+hns3_set_firber_default_support_speed(struct hns3_hw *hw) -+{ -+ struct hns3_mac *mac = &hw->mac; -+ -+ switch (mac->link_speed) { -+ case ETH_SPEED_NUM_1G: -+ return HNS3_FIBER_LINK_SPEED_1G_BIT; -+ case ETH_SPEED_NUM_10G: -+ return HNS3_FIBER_LINK_SPEED_10G_BIT; -+ case ETH_SPEED_NUM_25G: -+ return HNS3_FIBER_LINK_SPEED_25G_BIT; -+ case ETH_SPEED_NUM_40G: -+ return HNS3_FIBER_LINK_SPEED_40G_BIT; -+ case ETH_SPEED_NUM_50G: -+ return HNS3_FIBER_LINK_SPEED_50G_BIT; -+ case ETH_SPEED_NUM_100G: -+ return HNS3_FIBER_LINK_SPEED_100G_BIT; -+ case ETH_SPEED_NUM_200G: -+ return HNS3_FIBER_LINK_SPEED_200G_BIT; -+ default: -+ hns3_warn(hw, "invalid speed %u Mbps.", mac->link_speed); -+ return 0; -+ } -+} -+ -+/* -+ * Validity of supported_speed for firber and copper media type can be -+ * guaranteed by the following policy: -+ * Copper: -+ * Although the initialization of the phy in the firmware may not be -+ * completed, the firmware can guarantees that the supported_speed is -+ * an valid value. -+ * Firber: -+ * If the version of firmware supports the acitive query way of the -+ * HNS3_OPC_GET_SFP_INFO opcode, the supported_speed can be obtained -+ * through it. If unsupported, use the SFP's speed as the value of the -+ * supported_speed. -+ */ -+static int -+hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev) -+{ -+ struct hns3_adapter *hns = eth_dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_mac *mac = &hw->mac; -+ int ret; -+ -+ ret = hns3_update_link_info(eth_dev); -+ if (ret) -+ return ret; -+ -+ if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) { -+ /* -+ * Some firmware does not support the report of supported_speed, -+ * and only report the effective speed of SFP. In this case, it -+ * is necessary to use the SFP's speed as the supported_speed. -+ */ -+ if (mac->supported_speed == 0) -+ mac->supported_speed = -+ hns3_set_firber_default_support_speed(hw); -+ } -+ -+ return 0; -+} -+ - static int - hns3_init_pf(struct rte_eth_dev *eth_dev) - { -@@ -5057,10 +5184,19 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_enable_intr; - } - -+ ret = hns3_get_port_supported_speed(eth_dev); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "failed to get speed capabilities supported " -+ "by device, ret = %d.", ret); -+ goto err_supported_speed; -+ } -+ - hns3_tm_conf_init(eth_dev); - - return 0; - -+err_supported_speed: -+ (void)hns3_enable_hw_error_intr(hns, false); - err_enable_intr: - hns3_fdir_filter_uninit(hns); - err_fdir: --- -2.7.4 - diff --git a/0114-net-hns3-support-link-speed-autoneg-for-PF.patch b/0114-net-hns3-support-link-speed-autoneg-for-PF.patch deleted file mode 100644 index e86ad81..0000000 --- a/0114-net-hns3-support-link-speed-autoneg-for-PF.patch +++ /dev/null @@ -1,254 +0,0 @@ -From 80276e4e599abc03596ab80ebbb4637282299474 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:17 +0800 -Subject: [PATCH 114/189] net/hns3: support link speed autoneg for PF - -This patch supports link speed auto-negotiation for PF. If the -device supports auto-negotiation, the device negotiates with -the link partner at all speeds supported by the device. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 5 +- - drivers/net/hns3/hns3_ethdev.c | 152 ++++++++++++++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_ethdev.h | 6 ++ - 3 files changed, 160 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 4c25c43..a24063b 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -108,6 +108,7 @@ enum hns3_opcode_type { - - /* MAC command */ - HNS3_OPC_CONFIG_MAC_MODE = 0x0301, -+ HNS3_OPC_CONFIG_AN_MODE = 0x0304, - HNS3_OPC_QUERY_LINK_STATUS = 0x0307, - HNS3_OPC_CONFIG_MAX_FRM_SIZE = 0x0308, - HNS3_OPC_CONFIG_SPEED_DUP = 0x0309, -@@ -796,7 +797,9 @@ struct hns3_sfp_info_cmd { - uint32_t sfp_speed; - uint8_t query_type; /* 0: sfp speed, 1: active */ - uint8_t active_fec; /* current FEC mode */ -- uint16_t rsv; -+ uint8_t autoneg; /* current autoneg state */ -+ /* 0: not support autoneg, 1: support autoneg */ -+ uint8_t autoneg_ability; - uint32_t supported_speed; /* speed supported by current media */ - uint32_t module_type; - uint8_t rsv1[8]; -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index aa9f140..019d9fe 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2850,8 +2850,7 @@ hns3_setup_linkstatus(struct rte_eth_dev *eth_dev, - - new_link->link_duplex = mac->link_duplex; - new_link->link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN; -- new_link->link_autoneg = -- !(eth_dev->data->dev_conf.link_speeds & ETH_LINK_SPEED_FIXED); -+ new_link->link_autoneg = mac->link_autoneg; - } - - static int -@@ -4605,6 +4604,9 @@ hns3_get_sfp_info(struct hns3_hw *hw, struct hns3_mac *mac_info) - mac_info->query_type = HNS3_ACTIVE_QUERY; - mac_info->supported_speed = - rte_le_to_cpu_32(resp->supported_speed); -+ mac_info->support_autoneg = resp->autoneg_ability; -+ mac_info->link_autoneg = (resp->autoneg == 0) ? ETH_LINK_FIXED -+ : ETH_LINK_AUTONEG; - } else { - mac_info->query_type = HNS3_DEFAULT_QUERY; - } -@@ -4685,6 +4687,8 @@ hns3_update_fiber_link_info(struct hns3_hw *hw) - - mac->link_speed = mac_info.link_speed; - mac->supported_speed = mac_info.supported_speed; -+ mac->support_autoneg = mac_info.support_autoneg; -+ mac->link_autoneg = mac_info.link_autoneg; - - return 0; - } -@@ -5248,6 +5252,144 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - } - - static int -+hns3_set_copper_port_link_speed(struct hns3_hw *hw, -+ struct hns3_set_link_speed_cfg *cfg) -+{ -+ struct hns3_cmd_desc desc[HNS3_PHY_PARAM_CFG_BD_NUM]; -+ struct hns3_phy_params_bd0_cmd *req; -+ uint16_t i; -+ -+ for (i = 0; i < HNS3_PHY_PARAM_CFG_BD_NUM - 1; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_PHY_PARAM_CFG, -+ false); -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_PHY_PARAM_CFG, false); -+ req = (struct hns3_phy_params_bd0_cmd *)desc[0].data; -+ req->autoneg = cfg->autoneg; -+ -+ /* -+ * The full speed capability is used to negotiate when -+ * auto-negotiation is enabled. -+ */ -+ if (cfg->autoneg) { -+ req->advertising = HNS3_PHY_LINK_SPEED_10M_BIT | -+ HNS3_PHY_LINK_SPEED_10M_HD_BIT | -+ HNS3_PHY_LINK_SPEED_100M_BIT | -+ HNS3_PHY_LINK_SPEED_100M_HD_BIT | -+ HNS3_PHY_LINK_SPEED_1000M_BIT; -+ } -+ -+ return hns3_cmd_send(hw, desc, HNS3_PHY_PARAM_CFG_BD_NUM); -+} -+ -+static int -+hns3_set_autoneg(struct hns3_hw *hw, bool enable) -+{ -+ struct hns3_config_auto_neg_cmd *req; -+ struct hns3_cmd_desc desc; -+ uint32_t flag = 0; -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CONFIG_AN_MODE, false); -+ -+ req = (struct hns3_config_auto_neg_cmd *)desc.data; -+ if (enable) -+ hns3_set_bit(flag, HNS3_MAC_CFG_AN_EN_B, 1); -+ req->cfg_an_cmd_flag = rte_cpu_to_le_32(flag); -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) -+ hns3_err(hw, "autoneg set cmd failed, ret = %d.", ret); -+ -+ return ret; -+} -+ -+static int -+hns3_set_fiber_port_link_speed(struct hns3_hw *hw, -+ struct hns3_set_link_speed_cfg *cfg) -+{ -+ int ret; -+ -+ if (hw->mac.support_autoneg) { -+ ret = hns3_set_autoneg(hw, cfg->autoneg); -+ if (ret) { -+ hns3_err(hw, "failed to configure auto-negotiation."); -+ return ret; -+ } -+ -+ /* -+ * To enable auto-negotiation, we only need to open the switch -+ * of auto-negotiation, then firmware sets all speed -+ * capabilities. -+ */ -+ if (cfg->autoneg) -+ return 0; -+ } -+ -+ /* -+ * Some hardware doesn't support auto-negotiation, but users may not -+ * configure link_speeds (default 0), which means auto-negotiation -+ * In this case, a warning message need to be printed, instead of -+ * an error. -+ */ -+ if (cfg->autoneg) { -+ hns3_warn(hw, "auto-negotiation is not supported."); -+ return 0; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_set_port_link_speed(struct hns3_hw *hw, -+ struct hns3_set_link_speed_cfg *cfg) -+{ -+ int ret; -+ -+ if (hw->mac.media_type == HNS3_MEDIA_TYPE_COPPER) { -+#if defined(RTE_HNS3_ONLY_1630_FPGA) -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ if (pf->is_tmp_phy) -+ return 0; -+#endif -+ -+ ret = hns3_set_copper_port_link_speed(hw, cfg); -+ if (ret) { -+ hns3_err(hw, "failed to set copper port link speed," -+ "ret = %d.", ret); -+ return ret; -+ } -+ } else if (hw->mac.media_type == HNS3_MEDIA_TYPE_FIBER) { -+ ret = hns3_set_fiber_port_link_speed(hw, cfg); -+ if (ret) { -+ hns3_err(hw, "failed to set fiber port link speed," -+ "ret = %d.", ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_apply_link_speed(struct hns3_hw *hw) -+{ -+ struct rte_eth_conf *conf = &hw->data->dev_conf; -+ struct hns3_set_link_speed_cfg cfg; -+ -+ memset(&cfg, 0, sizeof(struct hns3_set_link_speed_cfg)); -+ cfg.autoneg = (conf->link_speeds == ETH_LINK_SPEED_AUTONEG) ? -+ ETH_LINK_AUTONEG : ETH_LINK_FIXED; -+ if (cfg.autoneg != ETH_LINK_AUTONEG) { -+ hns3_err(hw, "device doesn't support to force link speed."); -+ return -EOPNOTSUPP; -+ } -+ -+ return hns3_set_port_link_speed(hw, &cfg); -+} -+ -+static int - hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - { - struct hns3_hw *hw = &hns->hw; -@@ -5280,9 +5422,15 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - PMD_INIT_LOG(ERR, "failed to enable MAC, ret = %d", ret); - goto err_config_mac_mode; - } -+ -+ ret = hns3_apply_link_speed(hw); -+ if (ret) -+ goto err_config_mac_mode; -+ - return 0; - - err_config_mac_mode: -+ (void)hns3_cfg_mac_mode(hw, false); - hns3_dev_release_mbufs(hns); - /* - * Here is exception handling, hns3_reset_all_tqps will have the -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index a677ddc..8b6c0d2 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -165,6 +165,12 @@ struct hns3_cfg { - uint16_t umv_space; - }; - -+struct hns3_set_link_speed_cfg { -+ uint32_t speed; -+ uint8_t duplex : 1; -+ uint8_t autoneg : 1; -+}; -+ - /* mac media type */ - enum hns3_media_type { - HNS3_MEDIA_TYPE_UNKNOWN, --- -2.7.4 - diff --git a/0115-net-hns3-support-flow-control-autoneg-for-copper-por.patch b/0115-net-hns3-support-flow-control-autoneg-for-copper-por.patch deleted file mode 100644 index 706f60d..0000000 --- a/0115-net-hns3-support-flow-control-autoneg-for-copper-por.patch +++ /dev/null @@ -1,239 +0,0 @@ -From d2f7bc262f17f8f640e279706f6b3bc99a4dbb0f Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:18 +0800 -Subject: [PATCH 115/189] net/hns3: support flow control autoneg for copper - port - -If the flow control auto-negotiation is not supported and the flow -control modes on the local and link partner is asymmetric, the flow -control on the NIC does not take effect. The support of the -auto-negotiation capability requires the cooperation of the firmware -and driver. - -This patch supports the flow control auto-negotiation only for copper -port. For optical ports, the forced flow control mode is still used. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 162 ++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 152 insertions(+), 10 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 019d9fe..1ee1651 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5088,6 +5088,24 @@ hns3_get_port_supported_speed(struct rte_eth_dev *eth_dev) - return 0; - } - -+static void -+hns3_get_fc_autoneg_capability(struct hns3_adapter *hns) -+{ -+ struct hns3_mac *mac = &hns->hw.mac; -+ -+ if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) { -+ hns->pf.support_fc_autoneg = true; -+ return; -+ } -+ -+ /* -+ * Flow control auto-negotiation requires the cooperation of the driver -+ * and firmware. Currently, the optical port does not support flow -+ * control auto-negotiation. -+ */ -+ hns->pf.support_fc_autoneg = false; -+} -+ - static int - hns3_init_pf(struct rte_eth_dev *eth_dev) - { -@@ -5195,6 +5213,8 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_supported_speed; - } - -+ hns3_get_fc_autoneg_capability(hns); -+ - hns3_tm_conf_init(eth_dev); - - return 0; -@@ -5761,19 +5781,102 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - return ret; - } - --static int --hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) -+static void -+hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause, -+ bool *tx_pause) -+{ -+ struct hns3_mac *mac = &hw->mac; -+ uint32_t advertising = mac->advertising; -+ uint32_t lp_advertising = mac->lp_advertising; -+ *rx_pause = false; -+ *tx_pause = false; -+ -+ if (advertising & lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) { -+ *rx_pause = true; -+ *tx_pause = true; -+ } else if (advertising & lp_advertising & -+ HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) { -+ if (advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) -+ *rx_pause = true; -+ else if (lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) -+ *tx_pause = true; -+ } -+} -+ -+static enum hns3_fc_mode -+hns3_get_autoneg_fc_mode(struct hns3_hw *hw) -+{ -+ enum hns3_fc_mode current_mode; -+ bool rx_pause = false; -+ bool tx_pause = false; -+ -+ switch (hw->mac.media_type) { -+ case HNS3_MEDIA_TYPE_COPPER: -+ hns3_get_autoneg_rxtx_pause_copper(hw, &rx_pause, &tx_pause); -+ break; -+ -+ /* -+ * Flow control auto-negotiation is not supported for fiber and -+ * backpalne media type. -+ */ -+ case HNS3_MEDIA_TYPE_FIBER: -+ case HNS3_MEDIA_TYPE_BACKPLANE: -+ hns3_err(hw, "autoneg FC mode can't be obtained, but flow control auto-negotiation is enabled."); -+ current_mode = hw->requested_fc_mode; -+ goto out; -+ default: -+ hns3_err(hw, "autoneg FC mode can't be obtained for unknown media type(%u).", -+ hw->mac.media_type); -+ current_mode = HNS3_FC_NONE; -+ goto out; -+ } -+ -+ if (rx_pause && tx_pause) -+ current_mode = HNS3_FC_FULL; -+ else if (rx_pause) -+ current_mode = HNS3_FC_RX_PAUSE; -+ else if (tx_pause) -+ current_mode = HNS3_FC_TX_PAUSE; -+ else -+ current_mode = HNS3_FC_NONE; -+ -+out: -+ return current_mode; -+} -+ -+static enum hns3_fc_mode -+hns3_get_current_fc_mode(struct rte_eth_dev *dev) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_mac *mac = &hw->mac; - -- fc_conf->pause_time = pf->pause_time; -+ /* -+ * When the flow control mode is obtained, the device may not complete -+ * auto-negotiation. It is necessary to wait for link establishment. -+ */ -+ (void)hns3_dev_link_update(dev, 1); - - /* -- * If fc auto-negotiation is not supported, the configured fc mode -- * from user is the current fc mode. -+ * If the link auto-negotiation of the nic is disabled, or the flow -+ * control auto-negotiation is not supported, the forced flow control -+ * mode is used. - */ -- switch (hw->requested_fc_mode) { -+ if (mac->link_autoneg == 0 || !pf->support_fc_autoneg) -+ return hw->requested_fc_mode; -+ -+ return hns3_get_autoneg_fc_mode(hw); -+} -+ -+static int -+hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ enum hns3_fc_mode current_mode; -+ -+ current_mode = hns3_get_current_fc_mode(dev); -+ switch (current_mode) { - case HNS3_FC_FULL: - fc_conf->mode = RTE_FC_FULL; - break; -@@ -5789,6 +5892,9 @@ hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - break; - } - -+ fc_conf->pause_time = pf->pause_time; -+ fc_conf->autoneg = pf->support_fc_autoneg ? hw->mac.link_autoneg : 0; -+ - return 0; - } - -@@ -5817,6 +5923,41 @@ hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) - } - - static int -+hns3_check_fc_autoneg_valid(struct hns3_hw *hw, uint8_t autoneg) -+{ -+ struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -+ -+ if (!pf->support_fc_autoneg) { -+ if (autoneg != 0) { -+ hns3_err(hw, "unsupported fc auto-negotiation setting."); -+ return -EOPNOTSUPP; -+ } -+ -+ /* -+ * Flow control auto-negotiation of the NIC is not supported, -+ * but other auto-negotiation features may be supported. -+ */ -+ if (autoneg != hw->mac.link_autoneg) { -+ hns3_err(hw, "please use 'link_speeds' in struct rte_eth_conf to disable autoneg!"); -+ return -EOPNOTSUPP; -+ } -+ -+ return 0; -+ } -+ -+ /* -+ * If flow control auto-negotiation of the NIC is supported, all -+ * auto-negotiation features are supported. -+ */ -+ if (autoneg != hw->mac.link_autoneg) { -+ hns3_err(hw, "please use 'link_speeds' in struct rte_eth_conf to change autoneg!"); -+ return -EOPNOTSUPP; -+ } -+ -+ return 0; -+} -+ -+static int - hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -@@ -5831,10 +5972,11 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - fc_conf->send_xon, fc_conf->mac_ctrl_frame_fwd); - return -EINVAL; - } -- if (fc_conf->autoneg) { -- hns3_err(hw, "Unsupported fc auto-negotiation setting."); -- return -EINVAL; -- } -+ -+ ret = hns3_check_fc_autoneg_valid(hw, fc_conf->autoneg); -+ if (ret) -+ return ret; -+ - if (!fc_conf->pause_time) { - hns3_err(hw, "Invalid pause time %u setting.", - fc_conf->pause_time); --- -2.7.4 - diff --git a/0116-net-hns3-support-fixed-link-speed.patch b/0116-net-hns3-support-fixed-link-speed.patch deleted file mode 100644 index 47e3ab6..0000000 --- a/0116-net-hns3-support-fixed-link-speed.patch +++ /dev/null @@ -1,204 +0,0 @@ -From 50d4bb519096de30035d48d3a8a2246bd4b09469 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 13 Apr 2021 21:47:19 +0800 -Subject: [PATCH 116/189] net/hns3: support fixed link speed - -This patch adds the configuration of fixed speed for the PF device. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 144 ++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 135 insertions(+), 9 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 1ee1651..1d09b5b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2473,12 +2473,6 @@ hns3_dev_configure(struct rte_eth_dev *dev) - } - - hw->adapter_state = HNS3_NIC_CONFIGURING; -- if (conf->link_speeds & ETH_LINK_SPEED_FIXED) { -- hns3_err(hw, "setting link speed/duplex not supported"); -- ret = -EINVAL; -- goto cfg_err; -- } -- - if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) { - ret = hns3_check_dcb_cfg(dev); - if (ret) -@@ -5271,6 +5265,130 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - hw->io_base = NULL; - } - -+static uint32_t -+hns3_convert_link_speeds2bitmap_copper(uint32_t link_speeds) -+{ -+ uint32_t speed_bit; -+ -+ switch (link_speeds & ~ETH_LINK_SPEED_FIXED) { -+ case ETH_LINK_SPEED_10M: -+ speed_bit = HNS3_PHY_LINK_SPEED_10M_BIT; -+ break; -+ case ETH_LINK_SPEED_10M_HD: -+ speed_bit = HNS3_PHY_LINK_SPEED_10M_HD_BIT; -+ break; -+ case ETH_LINK_SPEED_100M: -+ speed_bit = HNS3_PHY_LINK_SPEED_100M_BIT; -+ break; -+ case ETH_LINK_SPEED_100M_HD: -+ speed_bit = HNS3_PHY_LINK_SPEED_100M_HD_BIT; -+ break; -+ case ETH_LINK_SPEED_1G: -+ speed_bit = HNS3_PHY_LINK_SPEED_1000M_BIT; -+ break; -+ default: -+ speed_bit = 0; -+ break; -+ } -+ -+ return speed_bit; -+} -+ -+static uint32_t -+hns3_convert_link_speeds2bitmap_fiber(uint32_t link_speeds) -+{ -+ uint32_t speed_bit; -+ -+ switch (link_speeds & ~ETH_LINK_SPEED_FIXED) { -+ case ETH_LINK_SPEED_1G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_1G_BIT; -+ break; -+ case ETH_LINK_SPEED_10G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_10G_BIT; -+ break; -+ case ETH_LINK_SPEED_25G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_25G_BIT; -+ break; -+ case ETH_LINK_SPEED_40G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_40G_BIT; -+ break; -+ case ETH_LINK_SPEED_50G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_50G_BIT; -+ break; -+ case ETH_LINK_SPEED_100G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_100G_BIT; -+ break; -+ case ETH_LINK_SPEED_200G: -+ speed_bit = HNS3_FIBER_LINK_SPEED_200G_BIT; -+ break; -+ default: -+ speed_bit = 0; -+ break; -+ } -+ -+ return speed_bit; -+} -+ -+static int -+hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds) -+{ -+ struct hns3_mac *mac = &hw->mac; -+ uint32_t supported_speed = mac->supported_speed; -+ uint32_t speed_bit = 0; -+ -+ if (mac->media_type == HNS3_MEDIA_TYPE_COPPER) -+ speed_bit = hns3_convert_link_speeds2bitmap_copper(link_speeds); -+ else if (mac->media_type == HNS3_MEDIA_TYPE_FIBER) -+ speed_bit = hns3_convert_link_speeds2bitmap_fiber(link_speeds); -+ -+ if (!(speed_bit & supported_speed)) { -+ hns3_err(hw, "link_speeds(0x%x) exceeds the supported speed capability or is incorrect.", -+ link_speeds); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static inline uint32_t -+hns3_get_link_speed(uint32_t link_speeds) -+{ -+ uint32_t speed = ETH_SPEED_NUM_NONE; -+ -+ if (link_speeds & ETH_LINK_SPEED_10M || -+ link_speeds & ETH_LINK_SPEED_10M_HD) -+ speed = ETH_SPEED_NUM_10M; -+ if (link_speeds & ETH_LINK_SPEED_100M || -+ link_speeds & ETH_LINK_SPEED_100M_HD) -+ speed = ETH_SPEED_NUM_100M; -+ if (link_speeds & ETH_LINK_SPEED_1G) -+ speed = ETH_SPEED_NUM_1G; -+ if (link_speeds & ETH_LINK_SPEED_10G) -+ speed = ETH_SPEED_NUM_10G; -+ if (link_speeds & ETH_LINK_SPEED_25G) -+ speed = ETH_SPEED_NUM_25G; -+ if (link_speeds & ETH_LINK_SPEED_40G) -+ speed = ETH_SPEED_NUM_40G; -+ if (link_speeds & ETH_LINK_SPEED_50G) -+ speed = ETH_SPEED_NUM_50G; -+ if (link_speeds & ETH_LINK_SPEED_100G) -+ speed = ETH_SPEED_NUM_100G; -+ if (link_speeds & ETH_LINK_SPEED_200G) -+ speed = ETH_SPEED_NUM_200G; -+ -+ return speed; -+} -+ -+static uint8_t -+hns3_get_link_duplex(uint32_t link_speeds) -+{ -+ if ((link_speeds & ETH_LINK_SPEED_10M_HD) || -+ (link_speeds & ETH_LINK_SPEED_100M_HD)) -+ return ETH_LINK_HALF_DUPLEX; -+ else -+ return ETH_LINK_FULL_DUPLEX; -+} -+ - static int - hns3_set_copper_port_link_speed(struct hns3_hw *hw, - struct hns3_set_link_speed_cfg *cfg) -@@ -5298,6 +5416,9 @@ hns3_set_copper_port_link_speed(struct hns3_hw *hw, - HNS3_PHY_LINK_SPEED_100M_BIT | - HNS3_PHY_LINK_SPEED_100M_HD_BIT | - HNS3_PHY_LINK_SPEED_1000M_BIT; -+ } else { -+ req->speed = cfg->speed; -+ req->duplex = cfg->duplex; - } - - return hns3_cmd_send(hw, desc, HNS3_PHY_PARAM_CFG_BD_NUM); -@@ -5358,7 +5479,7 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw, - return 0; - } - -- return 0; -+ return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex); - } - - static int -@@ -5397,13 +5518,18 @@ hns3_apply_link_speed(struct hns3_hw *hw) - { - struct rte_eth_conf *conf = &hw->data->dev_conf; - struct hns3_set_link_speed_cfg cfg; -+ int ret; - - memset(&cfg, 0, sizeof(struct hns3_set_link_speed_cfg)); - cfg.autoneg = (conf->link_speeds == ETH_LINK_SPEED_AUTONEG) ? - ETH_LINK_AUTONEG : ETH_LINK_FIXED; - if (cfg.autoneg != ETH_LINK_AUTONEG) { -- hns3_err(hw, "device doesn't support to force link speed."); -- return -EOPNOTSUPP; -+ ret = hns3_check_port_speed(hw, conf->link_speeds); -+ if (ret) -+ return ret; -+ -+ cfg.speed = hns3_get_link_speed(conf->link_speeds); -+ cfg.duplex = hns3_get_link_duplex(conf->link_speeds); - } - - return hns3_set_port_link_speed(hw, &cfg); --- -2.7.4 - diff --git a/0117-net-hns3-rename-Rx-burst-function.patch b/0117-net-hns3-rename-Rx-burst-function.patch deleted file mode 100644 index 58d4024..0000000 --- a/0117-net-hns3-rename-Rx-burst-function.patch +++ /dev/null @@ -1,106 +0,0 @@ -From a9baef6c5022ca2b1c78822076ea7a00a1fe4733 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 15 Apr 2021 16:35:21 +0800 -Subject: [PATCH 117/189] net/hns3: rename Rx burst function - -Currently, user could use runtime config "rx_func_hint=simple" to -select the hns3_recv_pkts API, but the API's name get from -rte_eth_rx_burst_mode_get is "Scalar" which has not reflected "simple". - -So this patch renames hns3_recv_pkts to hns3_recv_pkts_simple, and -also change it's name which gets from rte_eth_rx_burst_mode_get to -"Scalar Simple" to maintain conceptual consistency. - -Fixes: 521ab3e93361 ("net/hns3: add simple Rx path") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) -Acked-by: Ferruh Yigit ---- - drivers/net/hns3/hns3_rxtx.c | 18 ++++++++++-------- - drivers/net/hns3/hns3_rxtx.h | 4 ++-- - 2 files changed, 12 insertions(+), 10 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 43f8c64..4873c9c 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2017,7 +2017,7 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) - }; - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - -- if (dev->rx_pkt_burst == hns3_recv_pkts || -+ if (dev->rx_pkt_burst == hns3_recv_pkts_simple || - dev->rx_pkt_burst == hns3_recv_scattered_pkts || - dev->rx_pkt_burst == hns3_recv_pkts_vec || - dev->rx_pkt_burst == hns3_recv_pkts_vec_sve) { -@@ -2389,7 +2389,9 @@ hns3_rx_ptp_timestamp_handle(struct hns3_rx_queue *rxq, struct rte_mbuf *mbuf, - } - - uint16_t --hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) -+hns3_recv_pkts_simple(void *rx_queue, -+ struct rte_mbuf **rx_pkts, -+ uint16_t nb_pkts) - { - volatile struct hns3_desc *rx_ring; /* RX ring (desc) */ - volatile struct hns3_desc *rxdp; /* pointer of the current desc */ -@@ -2772,10 +2774,10 @@ hns3_rx_burst_mode_get(struct rte_eth_dev *dev, __rte_unused uint16_t queue_id, - eth_rx_burst_t pkt_burst; - const char *info; - } burst_infos[] = { -- { hns3_recv_pkts, "Scalar" }, -+ { hns3_recv_pkts_simple, "Scalar Simple" }, - { hns3_recv_scattered_pkts, "Scalar Scattered" }, -- { hns3_recv_pkts_vec, "Vector Neon" }, -- { hns3_recv_pkts_vec_sve, "Vector Sve" }, -+ { hns3_recv_pkts_vec, "Vector Neon" }, -+ { hns3_recv_pkts_vec_sve, "Vector Sve" }, - }; - - eth_rx_burst_t pkt_burst = dev->rx_pkt_burst; -@@ -2833,14 +2835,14 @@ hns3_get_rx_function(struct rte_eth_dev *dev) - if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_SVE && sve_allowed) - return hns3_recv_pkts_vec_sve; - if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_SIMPLE && simple_allowed) -- return hns3_recv_pkts; -+ return hns3_recv_pkts_simple; - if (hns->rx_func_hint == HNS3_IO_FUNC_HINT_COMMON) - return hns3_recv_scattered_pkts; - - if (vec_allowed) - return hns3_recv_pkts_vec; - if (simple_allowed) -- return hns3_recv_pkts; -+ return hns3_recv_pkts_simple; - - return hns3_recv_scattered_pkts; - } -@@ -4517,7 +4519,7 @@ hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset) - rxdp = &rxq->rx_ring[desc_id]; - bd_base_info = rte_le_to_cpu_32(rxdp->rx.bd_base_info); - dev = &rte_eth_devices[rxq->port_id]; -- if (dev->rx_pkt_burst == hns3_recv_pkts || -+ if (dev->rx_pkt_burst == hns3_recv_pkts_simple || - dev->rx_pkt_burst == hns3_recv_scattered_pkts) { - if (offset >= rxq->nb_rx_desc - rxq->rx_free_hold) - return RTE_ETH_RX_DESC_UNAVAIL; -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 44d0ca7..5067c92 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -683,8 +683,8 @@ int hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id); - int hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id); - int hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id); - int hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id); --uint16_t hns3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, -- uint16_t nb_pkts); -+uint16_t hns3_recv_pkts_simple(void *rx_queue, struct rte_mbuf **rx_pkts, -+ uint16_t nb_pkts); - uint16_t hns3_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, - uint16_t nb_pkts); - uint16_t hns3_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, --- -2.7.4 - diff --git a/0118-net-hns3-remove-unused-macros.patch b/0118-net-hns3-remove-unused-macros.patch deleted file mode 100644 index b0c5645..0000000 --- a/0118-net-hns3-remove-unused-macros.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 9db649c5eb45a4739fc76e5613b8d5c5cd9f9275 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Mon, 19 Apr 2021 16:13:31 +0800 -Subject: [PATCH 118/189] net/hns3: remove unused macros - -'HNS3_RXD_TSIND_S' and 'HNS3_RXD_TSIND_M' is unused, which should -be deleted. - -This patch fixed it. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.h | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 5067c92..d25edc4 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -104,8 +104,6 @@ - #define HNS3_RXD_LUM_B 9 - #define HNS3_RXD_CRCP_B 10 - #define HNS3_RXD_L3L4P_B 11 --#define HNS3_RXD_TSIND_S 12 --#define HNS3_RXD_TSIND_M (0x7 << HNS3_RXD_TSIND_S) - - #define HNS3_RXD_TS_VLD_B 14 - #define HNS3_RXD_LKBK_B 15 --- -2.7.4 - diff --git a/0119-net-hns3-support-RAS-process-in-Kunpeng-930.patch b/0119-net-hns3-support-RAS-process-in-Kunpeng-930.patch deleted file mode 100644 index fdeb45f..0000000 --- a/0119-net-hns3-support-RAS-process-in-Kunpeng-930.patch +++ /dev/null @@ -1,603 +0,0 @@ -From 9a12486ffd05e3940cd533ac5ba03ba641c864f2 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Mon, 19 Apr 2021 15:36:44 +0800 -Subject: [PATCH 119/189] net/hns3: support RAS process in Kunpeng 930 - -Kunpeng 930 uses a new RAS exception reporting solution. -The reset type and exception status are reported through -firmware. The driver modifies the corresponding code to -adapt to the new solution. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 9 +- - drivers/net/hns3/hns3_cmd.h | 2 + - drivers/net/hns3/hns3_ethdev.c | 11 +- - drivers/net/hns3/hns3_ethdev.h | 23 ++- - drivers/net/hns3/hns3_ethdev_vf.c | 3 +- - drivers/net/hns3/hns3_intr.c | 296 +++++++++++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_intr.h | 70 +++++++++ - 7 files changed, 399 insertions(+), 15 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 15bf781..f3588ab 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -237,7 +237,12 @@ hns3_is_special_opcode(uint16_t opcode) - HNS3_OPC_STATS_MAC, - HNS3_OPC_STATS_MAC_ALL, - HNS3_OPC_QUERY_32_BIT_REG, -- HNS3_OPC_QUERY_64_BIT_REG}; -+ HNS3_OPC_QUERY_64_BIT_REG, -+ HNS3_OPC_QUERY_CLEAR_MPF_RAS_INT, -+ HNS3_OPC_QUERY_CLEAR_PF_RAS_INT, -+ HNS3_OPC_QUERY_CLEAR_ALL_MPF_MSIX_INT, -+ HNS3_OPC_QUERY_CLEAR_ALL_PF_MSIX_INT, -+ HNS3_OPC_QUERY_ALL_ERR_INFO,}; - uint32_t i; - - for (i = 0; i < ARRAY_SIZE(spec_opcode); i++) -@@ -449,6 +454,8 @@ hns3_parse_capability(struct hns3_hw *hw, - if (hns3_get_bit(caps, HNS3_CAPS_UDP_TUNNEL_CSUM_B)) - hns3_set_bit(hw->capability, - HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, 1); -+ if (hns3_get_bit(caps, HNS3_CAPS_RAS_IMP_B)) -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_RAS_IMP_B, 1); - } - - static uint32_t -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index a24063b..70aed7b 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -252,6 +252,8 @@ enum hns3_opcode_type { - HNS3_OPC_QUERY_MSIX_INT_STS_BD_NUM = 0x1513, - HNS3_OPC_QUERY_CLEAR_ALL_MPF_MSIX_INT = 0x1514, - HNS3_OPC_QUERY_CLEAR_ALL_PF_MSIX_INT = 0x1515, -+ HNS3_OPC_QUERY_ALL_ERR_BD_NUM = 0x1516, -+ HNS3_OPC_QUERY_ALL_ERR_INFO = 0x1517, - HNS3_OPC_IGU_EGU_TNL_INT_EN = 0x1803, - HNS3_OPC_IGU_COMMON_INT_EN = 0x1806, - HNS3_OPC_TM_QCN_MEM_INT_CFG = 0x1A14, -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 1d09b5b..893b357 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -324,10 +324,8 @@ hns3_interrupt_handler(void *param) - hns3_warn(hw, "received interrupt: vector0_int_stat:0x%x " - "ras_int_stat:0x%x cmdq_int_stat:0x%x", - vector0_int, ras_int, cmdq_int); -- hns3_handle_msix_error(hns, &hw->reset.request); -- hns3_handle_ras_error(hns, &hw->reset.request); - hns3_handle_mac_tnl(hw); -- hns3_schedule_reset(hns); -+ hns3_handle_error(hns); - } else if (event_cause == HNS3_VECTOR0_EVENT_RST) { - hns3_warn(hw, "received reset interrupt"); - hns3_schedule_reset(hns); -@@ -6284,12 +6282,15 @@ hns3_is_reset_pending(struct hns3_adapter *hns) - - hns3_check_event_cause(hns, NULL); - reset = hns3_get_reset_level(hns, &hw->reset.pending); -- if (hw->reset.level != HNS3_NONE_RESET && hw->reset.level < reset) { -+ -+ if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET && -+ hw->reset.level < reset) { - hns3_warn(hw, "High level reset %d is pending", reset); - return true; - } - reset = hns3_get_reset_level(hns, &hw->reset.request); -- if (hw->reset.level != HNS3_NONE_RESET && hw->reset.level < reset) { -+ if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET && -+ hw->reset.level < reset) { - hns3_warn(hw, "High level reset %d is request", reset); - return true; - } -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 8b6c0d2..4a855de 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -306,8 +306,9 @@ enum hns3_reset_stage { - }; - - enum hns3_reset_level { -- HNS3_NONE_RESET, -+ HNS3_FLR_RESET, /* A VF perform FLR reset */ - HNS3_VF_FUNC_RESET, /* A VF function reset */ -+ - /* - * All VFs under a PF perform function reset. - * Kernel PF driver use mailbox to inform DPDK VF to do reset, the value -@@ -315,6 +316,7 @@ enum hns3_reset_level { - * same. - */ - HNS3_VF_PF_FUNC_RESET = 2, -+ - /* - * All VFs under a PF perform FLR reset. - * Kernel PF driver use mailbox to inform DPDK VF to do reset, the value -@@ -328,14 +330,23 @@ enum hns3_reset_level { - * In PF FLR, the register state of VF is not reliable, VF's driver - * should not access the registers of the VF device. - */ -- HNS3_VF_FULL_RESET = 3, -- HNS3_FLR_RESET, /* A VF perform FLR reset */ -+ HNS3_VF_FULL_RESET, -+ - /* All VFs under the rootport perform a global or IMP reset */ - HNS3_VF_RESET, -- HNS3_FUNC_RESET, /* A PF function reset */ -+ -+ /* -+ * The enumeration value of HNS3_FUNC_RESET/HNS3_GLOBAL_RESET/ -+ * HNS3_IMP_RESET/HNS3_NONE_RESET are also used by firmware, and -+ * can not be changed. -+ */ -+ -+ HNS3_FUNC_RESET = 5, /* A PF function reset */ -+ - /* All PFs under the rootport perform a global reset */ - HNS3_GLOBAL_RESET, - HNS3_IMP_RESET, /* All PFs under the rootport perform a IMP reset */ -+ HNS3_NONE_RESET, - HNS3_MAX_RESET - }; - -@@ -846,6 +857,7 @@ enum { - #define HNS3_DEV_SUPPORT_STASH_B 0x7 - #define HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B 0x9 - #define HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B 0xA -+#define HNS3_DEV_SUPPORT_RAS_IMP_B 0xB - - #define hns3_dev_dcb_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B) -@@ -882,6 +894,9 @@ enum { - #define hns3_dev_outer_udp_cksum_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B) - -+#define hns3_dev_ras_imp_supported(hw) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_RAS_IMP_B) -+ - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index dd8f248..efc614b 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2465,7 +2465,8 @@ hns3vf_is_reset_pending(struct hns3_adapter *hns) - /* Check the registers to confirm whether there is reset pending */ - hns3vf_check_event_cause(hns, NULL); - reset = hns3vf_get_reset_level(hw, &hw->reset.pending); -- if (hw->reset.level != HNS3_NONE_RESET && hw->reset.level < reset) { -+ if (hw->reset.level != HNS3_NONE_RESET && reset != HNS3_NONE_RESET && -+ hw->reset.level < reset) { - hns3_warn(hw, "High level reset %d is pending", reset); - return true; - } -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index ccc90c5..7385c7b 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -23,8 +23,8 @@ - } while (0) - - static const char *reset_string[HNS3_MAX_RESET] = { -- "none", "vf_func", "vf_pf_func", "vf_full", "flr", -- "vf_global", "pf_func", "global", "IMP", -+ "flr", "vf_func", "vf_pf_func", "vf_full", "vf_global", -+ "pf_func", "global", "IMP", "none", - }; - - static const struct hns3_hw_error mac_afifo_tnl_int[] = { -@@ -1384,13 +1384,108 @@ static const struct hns3_hw_error_desc pf_msix_err_tbl[] = { - } - }; - --enum hns3_hw_err_type { -+enum hns3_hw_err_report_type { - MPF_MSIX_ERR, - PF_MSIX_ERR, - MPF_RAS_ERR, - PF_RAS_ERR, - }; - -+static const struct hns3_hw_mod_name hns3_hw_module_name[] = { -+ { -+ .module_name = MODULE_NONE, -+ .msg = "MODULE_NONE" -+ }, { -+ .module_name = MODULE_BIOS_COMMON, -+ .msg = "MODULE_BIOS_COMMON" -+ }, { -+ .module_name = MODULE_GE, -+ .msg = "MODULE_GE" -+ }, { -+ .module_name = MODULE_IGU_EGU, -+ .msg = "MODULE_IGU_EGU" -+ }, { -+ .module_name = MODULE_LGE, -+ .msg = "MODULE_LGE" -+ }, { -+ .module_name = MODULE_NCSI, -+ .msg = "MODULE_NCSI" -+ }, { -+ .module_name = MODULE_PPP, -+ .msg = "MODULE_PPP" -+ }, { -+ .module_name = MODULE_QCN, -+ .msg = "MODULE_QCN" -+ }, { -+ .module_name = MODULE_RCB_RX, -+ .msg = "MODULE_RCB_RX" -+ }, { -+ .module_name = MODULE_RTC, -+ .msg = "MODULE_RTC" -+ }, { -+ .module_name = MODULE_SSU, -+ .msg = "MODULE_SSU" -+ }, { -+ .module_name = MODULE_TM, -+ .msg = "MODULE_TM" -+ }, { -+ .module_name = MODULE_RCB_TX, -+ .msg = "MODULE_RCB_TX" -+ }, { -+ .module_name = MODULE_TXDMA, -+ .msg = "MODULE_TXDMA" -+ }, { -+ .module_name = MODULE_MASTER, -+ .msg = "MODULE_MASTER" -+ }, { -+ .module_name = MODULE_ROH_MAC, -+ .msg = "MODULE_ROH_MAC" -+ } -+}; -+ -+static const struct hns3_hw_err_type hns3_hw_error_type[] = { -+ { -+ .error_type = NONE_ERROR, -+ .msg = "none_error" -+ }, { -+ .error_type = FIFO_ERROR, -+ .msg = "fifo_error" -+ }, { -+ .error_type = MEMORY_ERROR, -+ .msg = "memory_error" -+ }, { -+ .error_type = POISION_ERROR, -+ .msg = "poision_error" -+ }, { -+ .error_type = MSIX_ECC_ERROR, -+ .msg = "msix_ecc_error" -+ }, { -+ .error_type = TQP_INT_ECC_ERROR, -+ .msg = "tqp_int_ecc_error" -+ }, { -+ .error_type = PF_ABNORMAL_INT_ERROR, -+ .msg = "pf_abnormal_int_error" -+ }, { -+ .error_type = MPF_ABNORMAL_INT_ERROR, -+ .msg = "mpf_abnormal_int_error" -+ }, { -+ .error_type = COMMON_ERROR, -+ .msg = "common_error" -+ }, { -+ .error_type = PORT_ERROR, -+ .msg = "port_error" -+ }, { -+ .error_type = ETS_ERROR, -+ .msg = "ets_error" -+ }, { -+ .error_type = NCSI_ERROR, -+ .msg = "ncsi_error" -+ }, { -+ .error_type = GLB_ERROR, -+ .msg = "glb_error" -+ } -+}; -+ - static int - hns3_config_ncsi_hw_err_int(struct hns3_adapter *hns, bool en) - { -@@ -1927,7 +2022,8 @@ hns3_get_hw_error_status(struct hns3_cmd_desc *desc, uint8_t desc_offset, - - static int - hns3_handle_hw_error(struct hns3_adapter *hns, struct hns3_cmd_desc *desc, -- int num, uint64_t *levels, enum hns3_hw_err_type err_type) -+ int num, uint64_t *levels, -+ enum hns3_hw_err_report_type err_type) - { - const struct hns3_hw_error_desc *err = pf_ras_err_tbl; - enum hns3_opcode_type opcode; -@@ -2094,6 +2190,198 @@ hns3_handle_ras_error(struct hns3_adapter *hns, uint64_t *levels) - rte_free(desc); - } - -+static void -+hns3_handle_type_reg_error_data(struct hns3_hw *hw, -+ struct hns3_mod_err_info *mod_err_info, -+ struct hns3_type_reg_err_info *err_info) -+{ -+#define HNS3_ERR_TYPE_MASK 0x7F -+#define HNS3_ERR_TYPE_IS_RAS_OFFSET 7 -+ -+ uint8_t mod_id, total_module, type_id, total_type; -+ uint8_t is_ras; -+ uint8_t i; -+ -+ mod_id = mod_err_info->mod_id; -+ type_id = err_info->type_id & HNS3_ERR_TYPE_MASK; -+ is_ras = err_info->type_id >> HNS3_ERR_TYPE_IS_RAS_OFFSET; -+ -+ total_module = ARRAY_SIZE(hns3_hw_module_name); -+ total_type = ARRAY_SIZE(hns3_hw_error_type); -+ -+ hns3_err(hw, "total_module:%u, total_type:%u", -+ total_module, total_type); -+ -+ if (mod_id < total_module && type_id < total_type) -+ hns3_err(hw, "found %s %s, is %s error.", -+ hns3_hw_module_name[mod_id].msg, -+ hns3_hw_error_type[type_id].msg, -+ is_ras ? "ras" : "msix"); -+ else -+ hns3_err(hw, "unknown module[%u] or type[%u].", -+ mod_id, type_id); -+ -+ hns3_err(hw, "reg_value:"); -+ for (i = 0; i < err_info->reg_num; i++) -+ hns3_err(hw, "0x%08x", err_info->reg[i]); -+} -+ -+static void -+hns3_handle_module_error_data(struct hns3_hw *hw, uint32_t *buf, -+ uint32_t buf_size) -+{ -+ struct hns3_type_reg_err_info *type_reg_err_info; -+ struct hns3_mod_err_info *mod_err_info; -+ struct hns3_sum_err_info *sum_err_info; -+ uint8_t mod_num, reset_type; -+ uint32_t offset = 0; -+ uint8_t err_num; -+ uint8_t i; -+ -+ sum_err_info = (struct hns3_sum_err_info *)&buf[offset++]; -+ mod_num = sum_err_info->mod_num; -+ reset_type = sum_err_info->reset_type; -+ if (reset_type && reset_type != HNS3_NONE_RESET) -+ hns3_atomic_set_bit(reset_type, &hw->reset.request); -+ -+ hns3_err(hw, "reset_type = %s, mod_num = %u.", -+ reset_string[reset_type], mod_num); -+ -+ while (mod_num--) { -+ if (offset >= buf_size) { -+ hns3_err(hw, "offset(%u) exceeds buf's size(%u).", -+ offset, buf_size); -+ return; -+ } -+ mod_err_info = (struct hns3_mod_err_info *)&buf[offset++]; -+ err_num = mod_err_info->err_num; -+ for (i = 0; i < err_num; i++) { -+ if (offset >= buf_size) { -+ hns3_err(hw, -+ "offset(%u) exceeds buf size(%u).", -+ offset, buf_size); -+ return; -+ } -+ -+ type_reg_err_info = (struct hns3_type_reg_err_info *) -+ &buf[offset++]; -+ hns3_handle_type_reg_error_data(hw, mod_err_info, -+ type_reg_err_info); -+ -+ offset += type_reg_err_info->reg_num; -+ } -+ } -+} -+ -+static int -+hns3_query_all_err_bd_num(struct hns3_hw *hw, uint32_t *bd_num) -+{ -+ struct hns3_cmd_desc desc; -+ uint32_t bd_num_data; -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_ALL_ERR_BD_NUM, true); -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) { -+ hns3_err(hw, "failed to query error bd_num, ret = %d.", ret); -+ return ret; -+ } -+ -+ bd_num_data = rte_le_to_cpu_32(desc.data[0]); -+ *bd_num = bd_num_data; -+ if (bd_num_data == 0) { -+ hns3_err(hw, "the value of bd_num is 0!"); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_query_all_err_info(struct hns3_hw *hw, struct hns3_cmd_desc *desc, -+ uint32_t bd_num) -+{ -+ int ret; -+ -+ hns3_cmd_setup_basic_desc(desc, HNS3_OPC_QUERY_ALL_ERR_INFO, true); -+ ret = hns3_cmd_send(hw, desc, bd_num); -+ if (ret) { -+ hns3_err(hw, "failed to query error info, ret = %d.", ret); -+ return ret; -+ } -+ -+ return ret; -+} -+ -+static void -+hns3_handle_hw_error_v2(struct hns3_hw *hw) -+{ -+ uint32_t bd_num, buf_len, i, buf_size; -+ struct hns3_cmd_desc *desc; -+ uint32_t *desc_data; -+ uint32_t *buf; -+ int ret; -+ -+ ret = hns3_query_all_err_bd_num(hw, &bd_num); -+ if (ret) -+ goto out; -+ -+ desc = rte_zmalloc("hns3_ras", bd_num * sizeof(struct hns3_cmd_desc), -+ 0); -+ if (desc == NULL) { -+ hns3_err(hw, "failed to malloc hns3 ras cmd desc."); -+ goto out; -+ } -+ -+ ret = hns3_query_all_err_info(hw, desc, bd_num); -+ if (ret) -+ goto err_desc; -+ -+ buf_len = bd_num * sizeof(struct hns3_cmd_desc) - HNS3_DESC_NO_DATA_LEN; -+ buf_size = buf_len / HNS3_DESC_DATA_UNIT_SIZE; -+ -+ desc_data = rte_zmalloc("hns3_ras", buf_len, 0); -+ if (desc_data == NULL) { -+ hns3_err(hw, "failed to malloc hns3 ras desc data."); -+ goto err_desc; -+ } -+ -+ buf = rte_zmalloc("hns3_ras", buf_len, 0); -+ if (buf == NULL) { -+ hns3_err(hw, "failed to malloc hns3 ras buf data."); -+ goto err_buf_alloc; -+ } -+ -+ memcpy(desc_data, &desc[0].data[0], buf_len); -+ for (i = 0; i < buf_size; i++) -+ buf[i] = rte_le_to_cpu_32(desc_data[i]); -+ -+ hns3_handle_module_error_data(hw, buf, buf_size); -+ rte_free(buf); -+ -+err_buf_alloc: -+ rte_free(desc_data); -+err_desc: -+ rte_free(desc); -+out: -+ return; -+} -+ -+void -+hns3_handle_error(struct hns3_adapter *hns) -+{ -+ struct hns3_hw *hw = &hns->hw; -+ -+ if (hns3_dev_ras_imp_supported(hw)) { -+ hns3_handle_hw_error_v2(hw); -+ hns3_schedule_reset(hns); -+ } else { -+ hns3_handle_msix_error(hns, &hw->reset.request); -+ hns3_handle_ras_error(hns, &hw->reset.request); -+ hns3_schedule_reset(hns); -+ } -+} -+ - int - hns3_reset_init(struct hns3_hw *hw) - { -diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h -index 4a0a731..a140ca1 100644 ---- a/drivers/net/hns3/hns3_intr.h -+++ b/drivers/net/hns3/hns3_intr.h -@@ -81,6 +81,75 @@ - - #define HNS3_RESET_PROCESS_MS 200 - -+#define HNS3_DESC_DATA_MAX 8 -+#define HNS3_REG_NUM_MAX 256 -+#define HNS3_DESC_NO_DATA_LEN 8 -+#define HNS3_DESC_DATA_UNIT_SIZE 4 -+ -+enum hns3_mod_name_list { -+ MODULE_NONE, -+ MODULE_BIOS_COMMON, -+ MODULE_GE, -+ MODULE_IGU_EGU, -+ MODULE_LGE, -+ MODULE_NCSI, -+ MODULE_PPP, -+ MODULE_QCN, -+ MODULE_RCB_RX, -+ MODULE_RTC, -+ MODULE_SSU, -+ MODULE_TM, -+ MODULE_RCB_TX, -+ MODULE_TXDMA, -+ MODULE_MASTER, -+ MODULE_ROH_MAC, -+}; -+ -+enum hns3_err_type_list { -+ NONE_ERROR, -+ FIFO_ERROR, -+ MEMORY_ERROR, -+ POISION_ERROR, -+ MSIX_ECC_ERROR, -+ TQP_INT_ECC_ERROR, -+ PF_ABNORMAL_INT_ERROR, -+ MPF_ABNORMAL_INT_ERROR, -+ COMMON_ERROR, -+ PORT_ERROR, -+ ETS_ERROR, -+ NCSI_ERROR, -+ GLB_ERROR, -+}; -+ -+struct hns3_hw_mod_name { -+ enum hns3_mod_name_list module_name; -+ const char *msg; -+}; -+ -+struct hns3_hw_err_type { -+ enum hns3_err_type_list error_type; -+ const char *msg; -+}; -+ -+struct hns3_sum_err_info { -+ uint8_t reset_type; /* the total reset type */ -+ uint8_t mod_num; /* the modules num encounter error */ -+ uint8_t rsv[2]; -+}; -+ -+struct hns3_mod_err_info { -+ uint8_t mod_id; /* the error module id */ -+ uint8_t err_num; /* the errors num in module */ -+ uint8_t rsv[2]; -+}; -+ -+struct hns3_type_reg_err_info { -+ uint8_t type_id; /* the type id of error */ -+ uint8_t reg_num; /* the related registers num of this error */ -+ uint8_t rsv[2]; -+ uint32_t reg[HNS3_REG_NUM_MAX]; /* the registers value */ -+}; -+ - struct hns3_hw_blk { - const char *name; - int (*enable_err_intr)(struct hns3_adapter *hns, bool en); -@@ -103,6 +172,7 @@ int hns3_enable_hw_error_intr(struct hns3_adapter *hns, bool state); - void hns3_handle_msix_error(struct hns3_adapter *hns, uint64_t *levels); - void hns3_handle_ras_error(struct hns3_adapter *hns, uint64_t *levels); - void hns3_config_mac_tnl_int(struct hns3_hw *hw, bool en); -+void hns3_handle_error(struct hns3_adapter *hns); - - void hns3_intr_unregister(const struct rte_intr_handle *hdl, - rte_intr_callback_fn cb_fn, void *cb_arg); --- -2.7.4 - diff --git a/0120-net-hns3-support-masking-device-capability.patch b/0120-net-hns3-support-masking-device-capability.patch deleted file mode 100644 index 34899b4..0000000 --- a/0120-net-hns3-support-masking-device-capability.patch +++ /dev/null @@ -1,226 +0,0 @@ -From e0e251dbada5ce120c8f7a6d1b517865fcbc29ce Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 15 Apr 2021 11:52:00 +0800 -Subject: [PATCH 120/189] net/hns3: support masking device capability - -This patch supports runtime config of mask device capability, it was -used to mask the capability which queried from firmware. - -The device argument key is "dev_caps_mask" which takes hexadecimal -bitmask where each bit represents whether mask corresponding capability. - -Its main purpose is to debug and avoid problems. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - doc/guides/nics/hns3.rst | 9 ++++++ - drivers/net/hns3/hns3_cmd.c | 67 +++++++++++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_ethdev.c | 24 +++++++++++++- - drivers/net/hns3/hns3_ethdev.h | 4 +++ - drivers/net/hns3/hns3_ethdev_vf.c | 3 +- - 5 files changed, 105 insertions(+), 2 deletions(-) - -diff --git a/doc/guides/nics/hns3.rst b/doc/guides/nics/hns3.rst -index d722509..477f03c 100644 ---- a/doc/guides/nics/hns3.rst -+++ b/doc/guides/nics/hns3.rst -@@ -84,6 +84,15 @@ Runtime Config Options - be first checked, if meets, use the ``vec``. Then, ``simple``, at last - ``common``. - -+- ``dev_caps_mask`` (default ``0``) -+ -+ Used to mask the capability which queried from firmware. -+ This args take hexadecimal bitmask where each bit represents whether mask -+ corresponding capability. eg. If the capability is 0xFFFF queried from -+ firmware, and the args value is 0xF which means the bit0~bit3 should be -+ masked off, then the capability will be 0xFFF0. -+ Its main purpose is to debug and avoid problems. -+ - Driver compilation and testing - ------------------------------ - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index f3588ab..5eb8789 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -416,6 +416,68 @@ hns3_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, int num) - return retval; - } - -+static const char * -+hns3_get_caps_name(uint32_t caps_id) -+{ -+ const struct { -+ enum HNS3_CAPS_BITS caps; -+ const char *name; -+ } dev_caps[] = { -+ { HNS3_CAPS_UDP_GSO_B, "udp_gso" }, -+ { HNS3_CAPS_ATR_B, "atr" }, -+ { HNS3_CAPS_FD_QUEUE_REGION_B, "fd_queue_region" }, -+ { HNS3_CAPS_PTP_B, "ptp" }, -+ { HNS3_CAPS_INT_QL_B, "int_ql" }, -+ { HNS3_CAPS_SIMPLE_BD_B, "simple_bd" }, -+ { HNS3_CAPS_TX_PUSH_B, "tx_push" }, -+ { HNS3_CAPS_PHY_IMP_B, "phy_imp" }, -+ { HNS3_CAPS_TQP_TXRX_INDEP_B, "tqp_txrx_indep" }, -+ { HNS3_CAPS_HW_PAD_B, "hw_pad" }, -+ { HNS3_CAPS_STASH_B, "stash" }, -+ { HNS3_CAPS_UDP_TUNNEL_CSUM_B, "udp_tunnel_csum" }, -+ { HNS3_CAPS_RAS_IMP_B, "ras_imp" }, -+ { HNS3_CAPS_FEC_B, "fec" }, -+ { HNS3_CAPS_PAUSE_B, "pause" }, -+ { HNS3_CAPS_RXD_ADV_LAYOUT_B, "rxd_adv_layout" } -+ }; -+ uint32_t i; -+ -+ for (i = 0; i < RTE_DIM(dev_caps); i++) { -+ if (dev_caps[i].caps == caps_id) -+ return dev_caps[i].name; -+ } -+ -+ return "unknown"; -+} -+ -+static void -+hns3_mask_capability(struct hns3_hw *hw, -+ struct hns3_query_version_cmd *cmd) -+{ -+#define MAX_CAPS_BIT 64 -+ -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ uint64_t caps_org, caps_new, caps_masked; -+ uint32_t i; -+ -+ if (hns->dev_caps_mask == 0) -+ return; -+ -+ memcpy(&caps_org, &cmd->caps[0], sizeof(caps_org)); -+ caps_org = rte_le_to_cpu_64(caps_org); -+ caps_new = caps_org ^ (caps_org & hns->dev_caps_mask); -+ caps_masked = caps_org ^ caps_new; -+ caps_new = rte_cpu_to_le_64(caps_new); -+ memcpy(&cmd->caps[0], &caps_new, sizeof(caps_new)); -+ -+ for (i = 0; i < MAX_CAPS_BIT; i++) { -+ if (!(caps_masked & BIT_ULL(i))) -+ continue; -+ hns3_info(hw, "mask capabiliy: id-%u, name-%s.", -+ i, hns3_get_caps_name(i)); -+ } -+} -+ - static void - hns3_parse_capability(struct hns3_hw *hw, - struct hns3_query_version_cmd *cmd) -@@ -485,6 +547,11 @@ hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw) - return ret; - - hw->fw_version = rte_le_to_cpu_32(resp->firmware); -+ /* -+ * Make sure mask the capability before parse capability because it -+ * may overwrite resp's data. -+ */ -+ hns3_mask_capability(hw, resp); - hns3_parse_capability(hw, resp); - - return 0; -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 893b357..c75aa9c 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -7209,6 +7209,19 @@ hns3_get_io_hint_func_name(uint32_t hint) - } - } - -+static int -+hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) -+{ -+ uint64_t val; -+ -+ RTE_SET_USED(key); -+ -+ val = strtoull(value, NULL, 16); -+ *(uint64_t *)extra_args = val; -+ -+ return 0; -+} -+ - void - hns3_parse_devargs(struct rte_eth_dev *dev) - { -@@ -7216,6 +7229,7 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - uint32_t rx_func_hint = HNS3_IO_FUNC_HINT_NONE; - uint32_t tx_func_hint = HNS3_IO_FUNC_HINT_NONE; - struct hns3_hw *hw = &hns->hw; -+ uint64_t dev_caps_mask = 0; - struct rte_kvargs *kvlist; - - if (dev->device->devargs == NULL) -@@ -7229,6 +7243,8 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - &hns3_parse_io_hint_func, &rx_func_hint); - rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, - &hns3_parse_io_hint_func, &tx_func_hint); -+ rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, -+ &hns3_parse_dev_caps_mask, &dev_caps_mask); - rte_kvargs_free(kvlist); - - if (rx_func_hint != HNS3_IO_FUNC_HINT_NONE) -@@ -7239,6 +7255,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_TX_FUNC_HINT, - hns3_get_io_hint_func_name(tx_func_hint)); - hns->tx_func_hint = tx_func_hint; -+ -+ if (dev_caps_mask != 0) -+ hns3_warn(hw, "parsed %s = 0x%" PRIx64 ".", -+ HNS3_DEVARG_DEV_CAPS_MASK, dev_caps_mask); -+ hns->dev_caps_mask = dev_caps_mask; - } - - static const struct eth_dev_ops hns3_eth_dev_ops = { -@@ -7506,6 +7527,7 @@ RTE_PMD_REGISTER_PCI_TABLE(net_hns3, pci_id_hns3_map); - RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci"); - RTE_PMD_REGISTER_PARAM_STRING(net_hns3, - HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " -- HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common "); -+ HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common " -+ HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> "); - RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE); - RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 4a855de..271eadb 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -833,6 +833,8 @@ struct hns3_adapter { - uint32_t rx_func_hint; - uint32_t tx_func_hint; - -+ uint64_t dev_caps_mask; -+ - struct hns3_ptype_table ptype_tbl __rte_cache_min_aligned; - }; - -@@ -847,6 +849,8 @@ enum { - #define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint" - #define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint" - -+#define HNS3_DEVARG_DEV_CAPS_MASK "dev_caps_mask" -+ - #define HNS3_DEV_SUPPORT_DCB_B 0x0 - #define HNS3_DEV_SUPPORT_COPPER_B 0x1 - #define HNS3_DEV_SUPPORT_UDP_GSO_B 0x2 -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index efc614b..16cc111 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -3075,4 +3075,5 @@ RTE_PMD_REGISTER_PCI_TABLE(net_hns3_vf, pci_id_hns3vf_map); - RTE_PMD_REGISTER_KMOD_DEP(net_hns3_vf, "* igb_uio | vfio-pci"); - RTE_PMD_REGISTER_PARAM_STRING(net_hns3_vf, - HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " -- HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common "); -+ HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common " -+ HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> "); --- -2.7.4 - diff --git a/0121-net-hns3-simplify-Rx-checksum.patch b/0121-net-hns3-simplify-Rx-checksum.patch deleted file mode 100644 index 1f1b83b..0000000 --- a/0121-net-hns3-simplify-Rx-checksum.patch +++ /dev/null @@ -1,302 +0,0 @@ -From d31202d8067fd92a390fc67db148e45f2b719894 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 15 Apr 2021 11:52:01 +0800 -Subject: [PATCH 121/189] net/hns3: simplify Rx checksum - -Currently, the L3L4P/L3E/L4E/OL3E/OL4E fields in Rx descriptor used to -indicate hardware checksum result: -1. L3L4P: indicates hardware has processed L3L4 checksum for this - packet, if this bit is 1 then L3E/L4E/OL3E/OL4E is trustable. -2. L3E: L3 checksum error indication, 1 means with error. -3. L4E: L4 checksum error indication, 1 means with error. -4. OL3E: outer L3 checksum error indication, 1 means with error. -5. OL4E: outer L4 checksum error indication, 1 means with error. - -Driver will set the good checksum flag through packet type and -L3E/L4E/OL3E/OL4E when L3L4P is 1, it runs as follows: -1. If packet type indicates it's tunnel packet: -1.1. If packet type indicates it has inner L3 and L3E is zero, then -mark the IP checksum good. -1.2. If packet type indicates it has inner L4 and L4E is zero, then -mark the L4 checksum good. -1.3. If packet type indicates it has outer L4 and OL4E is zero, then -mark the outer L4 checksum good. -2. If packet type indicates it's not tunnel packet: -2.1. If packet type indicates it has L3 and L3E is zero, then mark the -IP checksum good. -2.2. If packet type indicates it has L4 and L4E is zero, then mark the -L4 checksum good. - -As described above, the good checksum calculation is time consuming, -it impacts the Rx performance. - -By balancing performance and functionality, driver uses the following -scheme to set good checksum flag when L3L4P is 1: -1. If L3E is zero, then mark the IP checksum good. -2. If L4E is zero, then mark the L4 checksum good. - -The performance gains are 3% in small packet iofwd scenarios. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 14 +---- - drivers/net/hns3/hns3_rxtx.h | 103 ++++++++++++++-------------------- - drivers/net/hns3/hns3_rxtx_vec_neon.h | 7 +-- - drivers/net/hns3/hns3_rxtx_vec_sve.c | 6 +- - 4 files changed, 45 insertions(+), 85 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 4873c9c..87416a1 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2402,7 +2402,6 @@ hns3_recv_pkts_simple(void *rx_queue, - struct rte_mbuf *nmb; /* pointer of the new mbuf */ - struct rte_mbuf *rxm; - uint32_t bd_base_info; -- uint32_t cksum_err; - uint32_t l234_info; - uint32_t ol_info; - uint64_t dma_addr; -@@ -2477,8 +2476,7 @@ hns3_recv_pkts_simple(void *rx_queue, - /* Load remained descriptor data and extract necessary fields */ - l234_info = rte_le_to_cpu_32(rxd.rx.l234_info); - ol_info = rte_le_to_cpu_32(rxd.rx.ol_info); -- ret = hns3_handle_bdinfo(rxq, rxm, bd_base_info, -- l234_info, &cksum_err); -+ ret = hns3_handle_bdinfo(rxq, rxm, bd_base_info, l234_info); - if (unlikely(ret)) - goto pkt_err; - -@@ -2487,9 +2485,6 @@ hns3_recv_pkts_simple(void *rx_queue, - if (rxm->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) - rxm->ol_flags |= PKT_RX_IEEE1588_PTP; - -- if (likely(bd_base_info & BIT(HNS3_RXD_L3L4P_B))) -- hns3_rx_set_cksum_flag(rxm, rxm->packet_type, -- cksum_err); - hns3_rxd_to_vlan_tci(rxq, rxm, l234_info, &rxd); - - /* Increment bytes counter */ -@@ -2528,7 +2523,6 @@ hns3_recv_scattered_pkts(void *rx_queue, - struct rte_mbuf *rxm; - struct rte_eth_dev *dev; - uint32_t bd_base_info; -- uint32_t cksum_err; - uint32_t l234_info; - uint32_t gro_size; - uint32_t ol_info; -@@ -2702,17 +2696,13 @@ hns3_recv_scattered_pkts(void *rx_queue, - l234_info = rte_le_to_cpu_32(rxd.rx.l234_info); - ol_info = rte_le_to_cpu_32(rxd.rx.ol_info); - ret = hns3_handle_bdinfo(rxq, first_seg, bd_base_info, -- l234_info, &cksum_err); -+ l234_info); - if (unlikely(ret)) - goto pkt_err; - - first_seg->packet_type = hns3_rx_calc_ptype(rxq, - l234_info, ol_info); - -- if (bd_base_info & BIT(HNS3_RXD_L3L4P_B)) -- hns3_rx_set_cksum_flag(first_seg, -- first_seg->packet_type, -- cksum_err); - hns3_rxd_to_vlan_tci(rxq, first_seg, l234_info, &rxd); - - /* Increment bytes counter */ -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index d25edc4..ac14802 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -539,19 +539,50 @@ enum hns3_cksum_status { - extern uint64_t hns3_timestamp_rx_dynflag; - extern int hns3_timestamp_dynfield_offset; - --static inline int --hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, -- uint32_t bd_base_info, uint32_t l234_info, -- uint32_t *cksum_err) -+static inline void -+hns3_rx_set_cksum_flag(struct hns3_rx_queue *rxq, -+ struct rte_mbuf *rxm, -+ uint32_t l234_info) - { --#define L2E_TRUNC_ERR_FLAG (BIT(HNS3_RXD_L2E_B) | \ -- BIT(HNS3_RXD_TRUNCATE_B)) --#define CHECKSUM_ERR_FLAG (BIT(HNS3_RXD_L3E_B) | \ -+#define HNS3_RXD_CKSUM_ERR_MASK (BIT(HNS3_RXD_L3E_B) | \ - BIT(HNS3_RXD_L4E_B) | \ - BIT(HNS3_RXD_OL3E_B) | \ - BIT(HNS3_RXD_OL4E_B)) - -- uint32_t tmp = 0; -+ if (likely((l234_info & HNS3_RXD_CKSUM_ERR_MASK) == 0)) { -+ rxm->ol_flags |= (PKT_RX_IP_CKSUM_GOOD | PKT_RX_L4_CKSUM_GOOD); -+ return; -+ } -+ -+ if (unlikely(l234_info & BIT(HNS3_RXD_L3E_B))) { -+ rxm->ol_flags |= PKT_RX_IP_CKSUM_BAD; -+ rxq->dfx_stats.l3_csum_errors++; -+ } else { -+ rxm->ol_flags |= PKT_RX_IP_CKSUM_GOOD; -+ } -+ -+ if (unlikely(l234_info & BIT(HNS3_RXD_L4E_B))) { -+ rxm->ol_flags |= PKT_RX_L4_CKSUM_BAD; -+ rxq->dfx_stats.l4_csum_errors++; -+ } else { -+ rxm->ol_flags |= PKT_RX_L4_CKSUM_GOOD; -+ } -+ -+ if (unlikely(l234_info & BIT(HNS3_RXD_OL3E_B))) -+ rxq->dfx_stats.ol3_csum_errors++; -+ -+ if (unlikely(l234_info & BIT(HNS3_RXD_OL4E_B))) { -+ rxm->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD; -+ rxq->dfx_stats.ol4_csum_errors++; -+ } -+} -+ -+static inline int -+hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, -+ uint32_t bd_base_info, uint32_t l234_info) -+{ -+#define L2E_TRUNC_ERR_FLAG (BIT(HNS3_RXD_L2E_B) | \ -+ BIT(HNS3_RXD_TRUNCATE_B)) - - /* - * If packet len bigger than mtu when recv with no-scattered algorithm, -@@ -570,64 +601,12 @@ hns3_handle_bdinfo(struct hns3_rx_queue *rxq, struct rte_mbuf *rxm, - return -EINVAL; - } - -- if (bd_base_info & BIT(HNS3_RXD_L3L4P_B)) { -- if (likely((l234_info & CHECKSUM_ERR_FLAG) == 0)) { -- *cksum_err = 0; -- return 0; -- } -- -- if (unlikely(l234_info & BIT(HNS3_RXD_L3E_B))) { -- rxm->ol_flags |= PKT_RX_IP_CKSUM_BAD; -- rxq->dfx_stats.l3_csum_errors++; -- tmp |= HNS3_L3_CKSUM_ERR; -- } -- -- if (unlikely(l234_info & BIT(HNS3_RXD_L4E_B))) { -- rxm->ol_flags |= PKT_RX_L4_CKSUM_BAD; -- rxq->dfx_stats.l4_csum_errors++; -- tmp |= HNS3_L4_CKSUM_ERR; -- } -- -- if (unlikely(l234_info & BIT(HNS3_RXD_OL3E_B))) { -- rxq->dfx_stats.ol3_csum_errors++; -- tmp |= HNS3_OUTER_L3_CKSUM_ERR; -- } -- -- if (unlikely(l234_info & BIT(HNS3_RXD_OL4E_B))) { -- rxm->ol_flags |= PKT_RX_OUTER_L4_CKSUM_BAD; -- rxq->dfx_stats.ol4_csum_errors++; -- tmp |= HNS3_OUTER_L4_CKSUM_ERR; -- } -- } -- *cksum_err = tmp; -+ if (bd_base_info & BIT(HNS3_RXD_L3L4P_B)) -+ hns3_rx_set_cksum_flag(rxq, rxm, l234_info); - - return 0; - } - --static inline void --hns3_rx_set_cksum_flag(struct rte_mbuf *rxm, const uint64_t packet_type, -- const uint32_t cksum_err) --{ -- if (unlikely((packet_type & RTE_PTYPE_TUNNEL_MASK))) { -- if (likely(packet_type & RTE_PTYPE_INNER_L3_MASK) && -- (cksum_err & HNS3_L3_CKSUM_ERR) == 0) -- rxm->ol_flags |= PKT_RX_IP_CKSUM_GOOD; -- if (likely(packet_type & RTE_PTYPE_INNER_L4_MASK) && -- (cksum_err & HNS3_L4_CKSUM_ERR) == 0) -- rxm->ol_flags |= PKT_RX_L4_CKSUM_GOOD; -- if (likely(packet_type & RTE_PTYPE_L4_MASK) && -- (cksum_err & HNS3_OUTER_L4_CKSUM_ERR) == 0) -- rxm->ol_flags |= PKT_RX_OUTER_L4_CKSUM_GOOD; -- } else { -- if (likely(packet_type & RTE_PTYPE_L3_MASK) && -- (cksum_err & HNS3_L3_CKSUM_ERR) == 0) -- rxm->ol_flags |= PKT_RX_IP_CKSUM_GOOD; -- if (likely(packet_type & RTE_PTYPE_L4_MASK) && -- (cksum_err & HNS3_L4_CKSUM_ERR) == 0) -- rxm->ol_flags |= PKT_RX_L4_CKSUM_GOOD; -- } --} -- - static inline uint32_t - hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, - const uint32_t ol_info) -diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h -index 68f098f..4699a62 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_neon.h -+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h -@@ -98,7 +98,6 @@ hns3_desc_parse_field(struct hns3_rx_queue *rxq, - uint32_t l234_info, ol_info, bd_base_info; - struct rte_mbuf *pkt; - uint32_t retcode = 0; -- uint32_t cksum_err; - uint32_t i; - int ret; - -@@ -111,17 +110,13 @@ hns3_desc_parse_field(struct hns3_rx_queue *rxq, - l234_info = rxdp[i].rx.l234_info; - ol_info = rxdp[i].rx.ol_info; - bd_base_info = rxdp[i].rx.bd_base_info; -- ret = hns3_handle_bdinfo(rxq, pkt, bd_base_info, -- l234_info, &cksum_err); -+ ret = hns3_handle_bdinfo(rxq, pkt, bd_base_info, l234_info); - if (unlikely(ret)) { - retcode |= 1u << i; - continue; - } - - pkt->packet_type = hns3_rx_calc_ptype(rxq, l234_info, ol_info); -- if (likely(bd_base_info & BIT(HNS3_RXD_L3L4P_B))) -- hns3_rx_set_cksum_flag(pkt, pkt->packet_type, -- cksum_err); - - /* Increment bytes counter */ - rxq->basic_stats.bytes += pkt->pkt_len; -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index 2700e6e..bc5577b 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -39,7 +39,6 @@ hns3_desc_parse_field_sve(struct hns3_rx_queue *rxq, - uint32_t bd_vld_num) - { - uint32_t retcode = 0; -- uint32_t cksum_err; - int ret, i; - - for (i = 0; i < (int)bd_vld_num; i++) { -@@ -47,7 +46,7 @@ hns3_desc_parse_field_sve(struct hns3_rx_queue *rxq, - rx_pkts[i]->ol_flags = PKT_RX_RSS_HASH; - - ret = hns3_handle_bdinfo(rxq, rx_pkts[i], key->bd_base_info[i], -- key->l234_info[i], &cksum_err); -+ key->l234_info[i]); - if (unlikely(ret)) { - retcode |= 1u << i; - continue; -@@ -55,9 +54,6 @@ hns3_desc_parse_field_sve(struct hns3_rx_queue *rxq, - - rx_pkts[i]->packet_type = hns3_rx_calc_ptype(rxq, - key->l234_info[i], key->ol_info[i]); -- if (likely(key->bd_base_info[i] & BIT(HNS3_RXD_L3L4P_B))) -- hns3_rx_set_cksum_flag(rx_pkts[i], -- rx_pkts[i]->packet_type, cksum_err); - - /* Increment bytes counter */ - rxq->basic_stats.bytes += rx_pkts[i]->pkt_len; --- -2.7.4 - diff --git a/0122-net-hns3-check-max-SIMD-bitwidth.patch b/0122-net-hns3-check-max-SIMD-bitwidth.patch deleted file mode 100644 index 9421f25..0000000 --- a/0122-net-hns3-check-max-SIMD-bitwidth.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 65e9bf664b7758d9e0e722ce0b4b15869a177f19 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 15 Apr 2021 11:52:02 +0800 -Subject: [PATCH 122/189] net/hns3: check max SIMD bitwidth - -This patch supports check max SIMD bitwidth when choosing NEON and SVE -vector path. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 87416a1..92d377b 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -13,6 +13,7 @@ - #include - #if defined(RTE_ARCH_ARM64) - #include -+#include - #endif - - #include "hns3_ethdev.h" -@@ -2790,6 +2791,8 @@ static bool - hns3_get_default_vec_support(void) - { - #if defined(RTE_ARCH_ARM64) -+ if (rte_vect_get_max_simd_bitwidth() < RTE_VECT_SIMD_128) -+ return false; - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON)) - return true; - #endif -@@ -2800,6 +2803,8 @@ static bool - hns3_get_sve_support(void) - { - #if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_SVE) -+ if (rte_vect_get_max_simd_bitwidth() < RTE_VECT_SIMD_256) -+ return false; - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SVE)) - return true; - #endif --- -2.7.4 - diff --git a/0123-net-hns3-add-compile-time-verification-on-Rx-vector.patch b/0123-net-hns3-add-compile-time-verification-on-Rx-vector.patch deleted file mode 100644 index 97b0935..0000000 --- a/0123-net-hns3-add-compile-time-verification-on-Rx-vector.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 81ac96b3d326444b3ec1dc5e72819056a94b9e2f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 17 Apr 2021 17:54:54 +0800 -Subject: [PATCH 123/189] net/hns3: add compile-time verification on Rx vector - -Rx vector implementation depends on the mbuf fields -(such as rearm_data/rx_descriptor_fields1) layout, this patch adds -compile-time verification for this. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx_vec.c | 22 ++++++++++++++++++++++ - drivers/net/hns3/hns3_rxtx_vec_neon.h | 8 ++++++++ - drivers/net/hns3/hns3_rxtx_vec_sve.c | 6 ++++++ - 3 files changed, 36 insertions(+) - -diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c -index fd7b272..d6636df 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.c -+++ b/drivers/net/hns3/hns3_rxtx_vec.c -@@ -147,6 +147,28 @@ hns3_rxq_vec_setup_rearm_data(struct hns3_rx_queue *rxq) - mb_def.port = rxq->port_id; - rte_mbuf_refcnt_set(&mb_def, 1); - -+ /* compile-time verifies the rearm_data first 8bytes */ -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) < -+ offsetof(struct rte_mbuf, rearm_data)); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) < -+ offsetof(struct rte_mbuf, rearm_data)); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) < -+ offsetof(struct rte_mbuf, rearm_data)); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) < -+ offsetof(struct rte_mbuf, rearm_data)); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) < -+ offsetof(struct rte_mbuf, rearm_data)); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_off) - -+ offsetof(struct rte_mbuf, rearm_data) > 6); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) - -+ offsetof(struct rte_mbuf, rearm_data) > 6); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) - -+ offsetof(struct rte_mbuf, rearm_data) > 6); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) - -+ offsetof(struct rte_mbuf, rearm_data) > 6); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) - -+ offsetof(struct rte_mbuf, rearm_data) > 6); -+ - /* prevent compiler reordering: rearm_data covers previous fields */ - rte_compiler_barrier(); - p = (uintptr_t)&mb_def.rearm_data; -diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h -index 4699a62..35fef12 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_neon.h -+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h -@@ -156,6 +156,14 @@ hns3_recv_burst_vec(struct hns3_rx_queue *__restrict rxq, - 0, 0, 0, /* ignore non-length fields */ - }; - -+ /* compile-time verifies the shuffle mask */ -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, pkt_len) != -+ offsetof(struct rte_mbuf, rx_descriptor_fields1) + 4); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) != -+ offsetof(struct rte_mbuf, rx_descriptor_fields1) + 8); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, hash.rss) != -+ offsetof(struct rte_mbuf, rx_descriptor_fields1) + 12); -+ - for (pos = 0; pos < nb_pkts; pos += HNS3_DEFAULT_DESCS_PER_LOOP, - rxdp += HNS3_DEFAULT_DESCS_PER_LOOP) { - uint64x2x2_t descs[HNS3_DEFAULT_DESCS_PER_LOOP]; -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index bc5577b..e15fd7a 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -118,6 +118,12 @@ hns3_recv_burst_vec_sve(struct hns3_rx_queue *__restrict rxq, - svuint32_t rss_tbl1 = svld1_u32(PG32_256BIT, rss_adjust); - svuint32_t rss_tbl2 = svld1_u32(PG32_256BIT, &rss_adjust[8]); - -+ /* compile-time verifies the xlen_adjust mask */ -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, data_len) != -+ offsetof(struct rte_mbuf, pkt_len) + 4); -+ RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, vlan_tci) != -+ offsetof(struct rte_mbuf, data_len) + 2); -+ - for (pos = 0; pos < nb_pkts; pos += HNS3_SVE_DEFAULT_DESCS_PER_LOOP, - rxdp += HNS3_SVE_DEFAULT_DESCS_PER_LOOP) { - svuint64_t vld_clz, mbp1st, mbp2st, mbuf_init; --- -2.7.4 - diff --git a/0124-net-hns3-remove-redundant-mailbox-response.patch b/0124-net-hns3-remove-redundant-mailbox-response.patch deleted file mode 100644 index 690cb5b..0000000 --- a/0124-net-hns3-remove-redundant-mailbox-response.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 9450e23dc1f006db7bcc28b7452a838a171453a2 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Apr 2021 17:54:55 +0800 -Subject: [PATCH 124/189] net/hns3: remove redundant mailbox response - -Some mbx messages do not need to reply with data. In this case, -it is no need to set the response data address and the response -length. - -This patch removes these redundant codes from mbx messages that do -not need be replied. - -Fixes: a5475d61fa34 ("net/hns3: support VF") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev_vf.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 16cc111..a4577de 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1511,7 +1511,6 @@ static void - hns3vf_request_link_info(struct hns3_hw *hw) - { - struct hns3_vf *vf = HNS3_DEV_HW_TO_VF(hw); -- uint8_t resp_msg; - bool send_req; - int ret; - -@@ -1524,7 +1523,7 @@ hns3vf_request_link_info(struct hns3_hw *hw) - return; - - ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_LINK_STATUS, 0, NULL, 0, false, -- &resp_msg, sizeof(resp_msg)); -+ NULL, 0); - if (ret) { - hns3_err(hw, "failed to fetch link status, ret = %d", ret); - return; -@@ -1756,11 +1755,10 @@ hns3vf_keep_alive_handler(void *param) - struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param; - struct hns3_adapter *hns = eth_dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -- uint8_t respmsg; - int ret; - - ret = hns3_send_mbx_msg(hw, HNS3_MBX_KEEP_ALIVE, 0, NULL, 0, -- false, &respmsg, sizeof(uint8_t)); -+ false, NULL, 0); - if (ret) - hns3_err(hw, "VF sends keeping alive cmd failed(=%d)", - ret); --- -2.7.4 - diff --git a/0125-net-hns3-fix-DCB-mode-check.patch b/0125-net-hns3-fix-DCB-mode-check.patch deleted file mode 100644 index 3900824..0000000 --- a/0125-net-hns3-fix-DCB-mode-check.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 276b4938cbe55ec5deba5d140a6a53f46ea4f399 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Apr 2021 17:54:56 +0800 -Subject: [PATCH 125/189] net/hns3: fix DCB mode check - -Currently, "ONLY DCB" and "DCB+RSS" mode are both supported by HNS3 -PF driver. But the driver verifies only the "DCB+RSS" multiple queues -mode. - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index c75aa9c..7492708 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2239,7 +2239,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) - return -EINVAL; - } - -- if (rx_mq_mode == ETH_MQ_RX_DCB_RSS) { -+ if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { - if (dcb_rx_conf->nb_tcs > pf->tc_max) { - hns3_err(hw, "nb_tcs(%u) > max_tc(%u) driver supported.", - dcb_rx_conf->nb_tcs, pf->tc_max); --- -2.7.4 - diff --git a/0126-net-hns3-fix-VMDq-mode-check.patch b/0126-net-hns3-fix-VMDq-mode-check.patch deleted file mode 100644 index ac44968..0000000 --- a/0126-net-hns3-fix-VMDq-mode-check.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 8732064d03a6d0f46f3120549b31f97990aa81ce Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Apr 2021 17:54:57 +0800 -Subject: [PATCH 126/189] net/hns3: fix VMDq mode check - -HNS3 PF driver only supports RSS, DCB or NONE multiple queues mode. -Currently, driver doesn't verify the VMDq multi-queue mode completely. -This patch fixes the verification for VMDq mode. - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 28 ++++++++++++---------------- - 1 file changed, 12 insertions(+), 16 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7492708..4d63d12 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2222,23 +2222,16 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) - int max_tc = 0; - int i; - -- dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf; -- dcb_tx_conf = &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf; -- -- if (rx_mq_mode == ETH_MQ_RX_VMDQ_DCB_RSS) { -- hns3_err(hw, "ETH_MQ_RX_VMDQ_DCB_RSS is not supported. " -- "rx_mq_mode = %d", rx_mq_mode); -- return -EINVAL; -- } -- -- if (rx_mq_mode == ETH_MQ_RX_VMDQ_DCB || -- tx_mq_mode == ETH_MQ_TX_VMDQ_DCB) { -- hns3_err(hw, "ETH_MQ_RX_VMDQ_DCB and ETH_MQ_TX_VMDQ_DCB " -- "is not supported. rx_mq_mode = %d, tx_mq_mode = %d", -+ if ((rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG) || -+ (tx_mq_mode == ETH_MQ_TX_VMDQ_DCB || -+ tx_mq_mode == ETH_MQ_TX_VMDQ_ONLY)) { -+ hns3_err(hw, "VMDQ is not supported, rx_mq_mode = %d, tx_mq_mode = %d.", - rx_mq_mode, tx_mq_mode); -- return -EINVAL; -+ return -EOPNOTSUPP; - } - -+ dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf; -+ dcb_tx_conf = &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf; - if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { - if (dcb_rx_conf->nb_tcs > pf->tc_max) { - hns3_err(hw, "nb_tcs(%u) > max_tc(%u) driver supported.", -@@ -2297,8 +2290,7 @@ hns3_check_dcb_cfg(struct rte_eth_dev *dev) - return -EOPNOTSUPP; - } - -- /* Check multiple queue mode */ -- return hns3_check_mq_mode(dev); -+ return 0; - } - - static int -@@ -2471,6 +2463,10 @@ hns3_dev_configure(struct rte_eth_dev *dev) - } - - hw->adapter_state = HNS3_NIC_CONFIGURING; -+ ret = hns3_check_mq_mode(dev); -+ if (ret) -+ goto cfg_err; -+ - if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) { - ret = hns3_check_dcb_cfg(dev); - if (ret) --- -2.7.4 - diff --git a/0127-net-hns3-fix-flow-director-lock.patch b/0127-net-hns3-fix-flow-director-lock.patch deleted file mode 100644 index c2d75c6..0000000 --- a/0127-net-hns3-fix-flow-director-lock.patch +++ /dev/null @@ -1,350 +0,0 @@ -From bdd72afbcc9fbd25812b4ba873875eca26f14b4b Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 17 Apr 2021 17:54:58 +0800 -Subject: [PATCH 127/189] net/hns3: fix flow director lock - -Currently, the fdir lock was used to protect concurrent access in -multiple processes, it has the following problems: -1) Lack of protection for fdir reset recover. -2) Only part of data is protected, eg. the filterlist is not protected. - -We use the following scheme: -1) Del the fdir lock. -2) Add a flow lock and provides rte flow driver ops API-level - protection. -3) Declare support RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 4 +- - drivers/net/hns3/hns3_ethdev.h | 4 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 3 +- - drivers/net/hns3/hns3_fdir.c | 28 ++++++------ - drivers/net/hns3/hns3_fdir.h | 3 +- - drivers/net/hns3/hns3_flow.c | 96 ++++++++++++++++++++++++++++++++++++--- - 6 files changed, 111 insertions(+), 27 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 4d63d12..ccafe60 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -7356,8 +7356,8 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - PMD_INIT_LOG(ERR, "Failed to alloc memory for process private"); - return -ENOMEM; - } -- /* initialize flow filter lists */ -- hns3_filterlist_init(eth_dev); -+ -+ hns3_flow_init(eth_dev); - - hns3_set_rxtx_function(eth_dev); - eth_dev->dev_ops = &hns3_eth_dev_ops; -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 271eadb..8191c53 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -5,6 +5,7 @@ - #ifndef _HNS3_ETHDEV_H_ - #define _HNS3_ETHDEV_H_ - -+#include - #include - #include - #include -@@ -624,6 +625,9 @@ struct hns3_hw { - uint8_t udp_cksum_mode; - - struct hns3_port_base_vlan_config port_base_vlan_cfg; -+ -+ pthread_mutex_t flows_lock; /* rte_flow ops lock */ -+ - /* - * PMD setup and configuration is not thread safe. Since it is not - * performance sensitive, it is better to guarantee thread-safety -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index a4577de..a278146 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2911,8 +2911,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - return -ENOMEM; - } - -- /* initialize flow filter lists */ -- hns3_filterlist_init(eth_dev); -+ hns3_flow_init(eth_dev); - - hns3_set_rxtx_function(eth_dev); - eth_dev->dev_ops = &hns3vf_eth_dev_ops; -diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c -index 857cc94..06c9a94 100644 ---- a/drivers/net/hns3/hns3_fdir.c -+++ b/drivers/net/hns3/hns3_fdir.c -@@ -830,7 +830,6 @@ int hns3_fdir_filter_init(struct hns3_adapter *hns) - - fdir_hash_params.socket_id = rte_socket_id(); - TAILQ_INIT(&fdir_info->fdir_list); -- rte_spinlock_init(&fdir_info->flows_lock); - snprintf(fdir_hash_name, RTE_HASH_NAMESIZE, "%s", hns->hw.data->name); - fdir_info->hash_handle = rte_hash_create(&fdir_hash_params); - if (fdir_info->hash_handle == NULL) { -@@ -856,7 +855,6 @@ void hns3_fdir_filter_uninit(struct hns3_adapter *hns) - struct hns3_fdir_info *fdir_info = &pf->fdir; - struct hns3_fdir_rule_ele *fdir_filter; - -- rte_spinlock_lock(&fdir_info->flows_lock); - if (fdir_info->hash_map) { - rte_free(fdir_info->hash_map); - fdir_info->hash_map = NULL; -@@ -865,7 +863,6 @@ void hns3_fdir_filter_uninit(struct hns3_adapter *hns) - rte_hash_free(fdir_info->hash_handle); - fdir_info->hash_handle = NULL; - } -- rte_spinlock_unlock(&fdir_info->flows_lock); - - fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list); - while (fdir_filter) { -@@ -891,10 +888,8 @@ static int hns3_fdir_filter_lookup(struct hns3_fdir_info *fdir_info, - hash_sig_t sig; - int ret; - -- rte_spinlock_lock(&fdir_info->flows_lock); - sig = rte_hash_crc(key, sizeof(*key), 0); - ret = rte_hash_lookup_with_hash(fdir_info->hash_handle, key, sig); -- rte_spinlock_unlock(&fdir_info->flows_lock); - - return ret; - } -@@ -908,11 +903,9 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw, - int ret; - - key = &fdir_filter->fdir_conf.key_conf; -- rte_spinlock_lock(&fdir_info->flows_lock); - sig = rte_hash_crc(key, sizeof(*key), 0); - ret = rte_hash_add_key_with_hash(fdir_info->hash_handle, key, sig); - if (ret < 0) { -- rte_spinlock_unlock(&fdir_info->flows_lock); - hns3_err(hw, "Hash table full? err:%d(%s)!", ret, - strerror(-ret)); - return ret; -@@ -920,7 +913,6 @@ static int hns3_insert_fdir_filter(struct hns3_hw *hw, - - fdir_info->hash_map[ret] = fdir_filter; - TAILQ_INSERT_TAIL(&fdir_info->fdir_list, fdir_filter, entries); -- rte_spinlock_unlock(&fdir_info->flows_lock); - - return ret; - } -@@ -933,11 +925,9 @@ static int hns3_remove_fdir_filter(struct hns3_hw *hw, - hash_sig_t sig; - int ret; - -- rte_spinlock_lock(&fdir_info->flows_lock); - sig = rte_hash_crc(key, sizeof(*key), 0); - ret = rte_hash_del_key_with_hash(fdir_info->hash_handle, key, sig); - if (ret < 0) { -- rte_spinlock_unlock(&fdir_info->flows_lock); - hns3_err(hw, "Delete hash key fail ret=%d", ret); - return ret; - } -@@ -945,7 +935,6 @@ static int hns3_remove_fdir_filter(struct hns3_hw *hw, - fdir_filter = fdir_info->hash_map[ret]; - fdir_info->hash_map[ret] = NULL; - TAILQ_REMOVE(&fdir_info->fdir_list, fdir_filter, entries); -- rte_spinlock_unlock(&fdir_info->flows_lock); - - rte_free(fdir_filter); - -@@ -1000,11 +989,9 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, - rule->location = ret; - node->fdir_conf.location = ret; - -- rte_spinlock_lock(&fdir_info->flows_lock); - ret = hns3_config_action(hw, rule); - if (!ret) - ret = hns3_config_key(hns, rule); -- rte_spinlock_unlock(&fdir_info->flows_lock); - if (ret) { - hns3_err(hw, "Failed to config fdir: %u src_ip:%x dst_ip:%x " - "src_port:%u dst_port:%u ret = %d", -@@ -1029,9 +1016,7 @@ int hns3_clear_all_fdir_filter(struct hns3_adapter *hns) - int ret = 0; - - /* flush flow director */ -- rte_spinlock_lock(&fdir_info->flows_lock); - rte_hash_reset(fdir_info->hash_handle); -- rte_spinlock_unlock(&fdir_info->flows_lock); - - fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list); - while (fdir_filter) { -@@ -1059,6 +1044,17 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) - bool err = false; - int ret; - -+ /* -+ * This API is called in the reset recovery process, the parent function -+ * must hold hw->lock. -+ * There maybe deadlock if acquire hw->flows_lock directly because rte -+ * flow driver ops first acquire hw->flows_lock and then may acquire -+ * hw->lock. -+ * So here first release the hw->lock and then acquire the -+ * hw->flows_lock to avoid deadlock. -+ */ -+ rte_spinlock_unlock(&hw->lock); -+ pthread_mutex_lock(&hw->flows_lock); - TAILQ_FOREACH(fdir_filter, &fdir_info->fdir_list, entries) { - ret = hns3_config_action(hw, &fdir_filter->fdir_conf); - if (!ret) -@@ -1069,6 +1065,8 @@ int hns3_restore_all_fdir_filter(struct hns3_adapter *hns) - break; - } - } -+ pthread_mutex_unlock(&hw->flows_lock); -+ rte_spinlock_lock(&hw->lock); - - if (err) { - hns3_err(hw, "Fail to restore FDIR filter, ret = %d", ret); -diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h -index a5760a3..d64af85 100644 ---- a/drivers/net/hns3/hns3_fdir.h -+++ b/drivers/net/hns3/hns3_fdir.h -@@ -199,7 +199,6 @@ struct hns3_process_private { - * A structure used to define fields of a FDIR related info. - */ - struct hns3_fdir_info { -- rte_spinlock_t flows_lock; - struct hns3_fdir_rule_list fdir_list; - struct hns3_fdir_rule_ele **hash_map; - struct rte_hash *hash_handle; -@@ -220,7 +219,7 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, - struct hns3_fdir_rule *rule, bool del); - int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); - int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); --void hns3_filterlist_init(struct rte_eth_dev *dev); -+void hns3_flow_init(struct rte_eth_dev *dev); - int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); - - #endif /* _HNS3_FDIR_H_ */ -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 3cca416..c07929f 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1214,9 +1214,18 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, - } - - void --hns3_filterlist_init(struct rte_eth_dev *dev) -+hns3_flow_init(struct rte_eth_dev *dev) - { -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_process_private *process_list = dev->process_private; -+ pthread_mutexattr_t attr; -+ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -+ pthread_mutexattr_init(&attr); -+ pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); -+ pthread_mutex_init(&hw->flows_lock, &attr); -+ dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; -+ } - - TAILQ_INIT(&process_list->fdir_list); - TAILQ_INIT(&process_list->filter_rss_list); -@@ -2002,12 +2011,87 @@ hns3_flow_query(struct rte_eth_dev *dev, struct rte_flow *flow, - return 0; - } - -+static int -+hns3_flow_validate_wrap(struct rte_eth_dev *dev, -+ const struct rte_flow_attr *attr, -+ const struct rte_flow_item pattern[], -+ const struct rte_flow_action actions[], -+ struct rte_flow_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ pthread_mutex_lock(&hw->flows_lock); -+ ret = hns3_flow_validate(dev, attr, pattern, actions, error); -+ pthread_mutex_unlock(&hw->flows_lock); -+ -+ return ret; -+} -+ -+static struct rte_flow * -+hns3_flow_create_wrap(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, -+ const struct rte_flow_item pattern[], -+ const struct rte_flow_action actions[], -+ struct rte_flow_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct rte_flow *flow; -+ -+ pthread_mutex_lock(&hw->flows_lock); -+ flow = hns3_flow_create(dev, attr, pattern, actions, error); -+ pthread_mutex_unlock(&hw->flows_lock); -+ -+ return flow; -+} -+ -+static int -+hns3_flow_destroy_wrap(struct rte_eth_dev *dev, struct rte_flow *flow, -+ struct rte_flow_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ pthread_mutex_lock(&hw->flows_lock); -+ ret = hns3_flow_destroy(dev, flow, error); -+ pthread_mutex_unlock(&hw->flows_lock); -+ -+ return ret; -+} -+ -+static int -+hns3_flow_flush_wrap(struct rte_eth_dev *dev, struct rte_flow_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ pthread_mutex_lock(&hw->flows_lock); -+ ret = hns3_flow_flush(dev, error); -+ pthread_mutex_unlock(&hw->flows_lock); -+ -+ return ret; -+} -+ -+static int -+hns3_flow_query_wrap(struct rte_eth_dev *dev, struct rte_flow *flow, -+ const struct rte_flow_action *actions, void *data, -+ struct rte_flow_error *error) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ pthread_mutex_lock(&hw->flows_lock); -+ ret = hns3_flow_query(dev, flow, actions, data, error); -+ pthread_mutex_unlock(&hw->flows_lock); -+ -+ return ret; -+} -+ - static const struct rte_flow_ops hns3_flow_ops = { -- .validate = hns3_flow_validate, -- .create = hns3_flow_create, -- .destroy = hns3_flow_destroy, -- .flush = hns3_flow_flush, -- .query = hns3_flow_query, -+ .validate = hns3_flow_validate_wrap, -+ .create = hns3_flow_create_wrap, -+ .destroy = hns3_flow_destroy_wrap, -+ .flush = hns3_flow_flush_wrap, -+ .query = hns3_flow_query_wrap, - .isolate = NULL, - }; - --- -2.7.4 - diff --git a/0128-net-hns3-move-link-speeds-check-to-configure.patch b/0128-net-hns3-move-link-speeds-check-to-configure.patch deleted file mode 100644 index 32d2548..0000000 --- a/0128-net-hns3-move-link-speeds-check-to-configure.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 96ea5f9a0b53ec1f701d3aec5342cd363871bb15 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Apr 2021 17:54:59 +0800 -Subject: [PATCH 128/189] net/hns3: move link speeds check to configure - -This patch moves the check for "link_speeds" in dev_conf to -dev_configure, so that users know whether "link_speeds" is valid in -advance. - -Fixes: bdaf190f8235 ("net/hns3: support link speed autoneg for PF") -Fixes: 400d307e1a60 ("net/hns3: support fixed link speed") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 57 +++++++++++++++++++++++++++++++++--------- - 1 file changed, 45 insertions(+), 12 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index ccafe60..e2a96c1 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -105,6 +105,7 @@ static int hns3_remove_mc_addr(struct hns3_hw *hw, - static int hns3_restore_fec(struct hns3_hw *hw); - static int hns3_query_dev_fec_info(struct hns3_hw *hw); - static int hns3_do_stop(struct hns3_adapter *hns); -+static int hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds); - - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr) -@@ -2429,6 +2430,46 @@ hns3_refresh_mtu(struct rte_eth_dev *dev, struct rte_eth_conf *conf) - } - - static int -+hns3_check_link_speed(struct hns3_hw *hw, uint32_t link_speeds) -+{ -+ int ret; -+ -+ /* -+ * Some hardware doesn't support auto-negotiation, but users may not -+ * configure link_speeds (default 0), which means auto-negotiation. -+ * In this case, a warning message need to be printed, instead of -+ * an error. -+ */ -+ if (link_speeds == ETH_LINK_SPEED_AUTONEG && -+ hw->mac.support_autoneg == 0) { -+ hns3_warn(hw, "auto-negotiation is not supported, use default fixed speed!"); -+ return 0; -+ } -+ -+ if (link_speeds != ETH_LINK_SPEED_AUTONEG) { -+ ret = hns3_check_port_speed(hw, link_speeds); -+ if (ret) -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int -+hns3_check_dev_conf(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct rte_eth_conf *conf = &dev->data->dev_conf; -+ int ret; -+ -+ ret = hns3_check_mq_mode(dev); -+ if (ret) -+ return ret; -+ -+ return hns3_check_link_speed(hw, conf->link_speeds); -+} -+ -+static int - hns3_dev_configure(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; -@@ -2463,7 +2504,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) - } - - hw->adapter_state = HNS3_NIC_CONFIGURING; -- ret = hns3_check_mq_mode(dev); -+ ret = hns3_check_dev_conf(dev); - if (ret) - goto cfg_err; - -@@ -5464,14 +5505,11 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw, - - /* - * Some hardware doesn't support auto-negotiation, but users may not -- * configure link_speeds (default 0), which means auto-negotiation -- * In this case, a warning message need to be printed, instead of -- * an error. -+ * configure link_speeds (default 0), which means auto-negotiation. -+ * In this case, it should return success. - */ -- if (cfg->autoneg) { -- hns3_warn(hw, "auto-negotiation is not supported."); -+ if (cfg->autoneg) - return 0; -- } - - return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex); - } -@@ -5512,16 +5550,11 @@ hns3_apply_link_speed(struct hns3_hw *hw) - { - struct rte_eth_conf *conf = &hw->data->dev_conf; - struct hns3_set_link_speed_cfg cfg; -- int ret; - - memset(&cfg, 0, sizeof(struct hns3_set_link_speed_cfg)); - cfg.autoneg = (conf->link_speeds == ETH_LINK_SPEED_AUTONEG) ? - ETH_LINK_AUTONEG : ETH_LINK_FIXED; - if (cfg.autoneg != ETH_LINK_AUTONEG) { -- ret = hns3_check_port_speed(hw, conf->link_speeds); -- if (ret) -- return ret; -- - cfg.speed = hns3_get_link_speed(conf->link_speeds); - cfg.duplex = hns3_get_link_duplex(conf->link_speeds); - } --- -2.7.4 - diff --git a/0129-net-hns3-remove-unused-macro.patch b/0129-net-hns3-remove-unused-macro.patch deleted file mode 100644 index 929ea93..0000000 --- a/0129-net-hns3-remove-unused-macro.patch +++ /dev/null @@ -1,31 +0,0 @@ -From fc5b336c4006b92193b36b61363e39a776bad5cb Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Tue, 20 Apr 2021 16:59:48 +0800 -Subject: [PATCH 129/189] net/hns3: remove unused macro - -'HNS3_RXD_LKBK_B' was defined in previous versions but no used. -This patch deleted it. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.h | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index ac14802..92f01ed 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -106,7 +106,6 @@ - #define HNS3_RXD_L3L4P_B 11 - - #define HNS3_RXD_TS_VLD_B 14 --#define HNS3_RXD_LKBK_B 15 - #define HNS3_RXD_GRO_SIZE_S 16 - #define HNS3_RXD_GRO_SIZE_M (0x3fff << HNS3_RXD_GRO_SIZE_S) - --- -2.7.4 - diff --git a/0130-net-hns3-fix-traffic-management-support-check.patch b/0130-net-hns3-fix-traffic-management-support-check.patch deleted file mode 100644 index 053f14c..0000000 --- a/0130-net-hns3-fix-traffic-management-support-check.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 67137c61da758dd22b8a5f9cda9e32fcd9034892 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Tue, 20 Apr 2021 16:59:49 +0800 -Subject: [PATCH 130/189] net/hns3: fix traffic management support check - -params->leaf.cman has enum type which is not isomorphic with boolean -type, however it is used as a boolean expression. - -This patch fixed it. - -Fixes: c09c7847d892 ("net/hns3: support traffic management") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_tm.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index bcae57a..f7bfc25 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -385,7 +385,7 @@ hns3_tm_leaf_node_param_check(struct rte_eth_dev *dev __rte_unused, - return -EINVAL; - } - -- if (params->leaf.cman) { -+ if (params->leaf.cman != RTE_TM_CMAN_TAIL_DROP) { - error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN; - error->message = "congestion management not supported"; - return -EINVAL; --- -2.7.4 - diff --git a/0131-net-hns3-ignore-devargs-parsing-return.patch b/0131-net-hns3-ignore-devargs-parsing-return.patch deleted file mode 100644 index 379f1f7..0000000 --- a/0131-net-hns3-ignore-devargs-parsing-return.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 395f4bf89616e096fc6fd95d7baed7dd3219525b Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Tue, 20 Apr 2021 16:59:50 +0800 -Subject: [PATCH 131/189] net/hns3: ignore devargs parsing return - -In hns3 PMD, as the handler always return 0, the return value -of a function 'rte_kvargs_process' no need to be checked. But -the API definition has return value, so 'void' could be used -to ignore that. - -Fixes: a124f9e9591b ("net/hns3: add runtime config to select IO burst function") - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index e2a96c1..81c67e2 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -7268,11 +7268,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - if (!kvlist) - return; - -- rte_kvargs_process(kvlist, HNS3_DEVARG_RX_FUNC_HINT, -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_RX_FUNC_HINT, - &hns3_parse_io_hint_func, &rx_func_hint); -- rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, - &hns3_parse_io_hint_func, &tx_func_hint); -- rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, - &hns3_parse_dev_caps_mask, &dev_caps_mask); - rte_kvargs_free(kvlist); - --- -2.7.4 - diff --git a/0132-net-hns3-fix-mailbox-error-message.patch b/0132-net-hns3-fix-mailbox-error-message.patch deleted file mode 100644 index c4210f6..0000000 --- a/0132-net-hns3-fix-mailbox-error-message.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 4cdaa8769ca9aa1aa558637606de0434bdd343fb Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 22 Apr 2021 09:55:49 +0800 -Subject: [PATCH 132/189] net/hns3: fix mailbox error message - -The hns3_dev_handle_mbx_msg() could be called under both PF and VF, -but the error messages show VF. - -Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 9955f27..6203af5 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -528,8 +528,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - hns3_handle_promisc_info(hw, req->msg[1]); - break; - default: -- hns3_err(hw, -- "VF received unsupported(%u) mbx msg from PF", -+ hns3_err(hw, "received unsupported(%u) mbx msg", - req->msg[0]); - break; - } --- -2.7.4 - diff --git a/0133-net-hns3-fix-processing-link-status-message-on-PF.patch b/0133-net-hns3-fix-processing-link-status-message-on-PF.patch deleted file mode 100644 index 730ef9e..0000000 --- a/0133-net-hns3-fix-processing-link-status-message-on-PF.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 34cf459a8af7788e68e9614c82a1cbcd38d5f55c Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 22 Apr 2021 09:55:50 +0800 -Subject: [PATCH 133/189] net/hns3: fix processing link status message on PF - -The opcode of the link status notification message reported by the -firmware is zero, it will be filtered out because driver treats it as -already processed message. As a result, the PF can't update the link -status in a timely manner. - -Because only VF can set opcode to zero when processing mailbox message, -we add a judgment to make sure the PF messages will not be filtered out. - -Fixes: dbbbad23e380 ("net/hns3: fix VF handling LSC event in secondary process") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 6203af5..ea6c0c3 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -438,16 +438,19 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) - void - hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - { -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_cmq_ring *crq = &hw->cmq.crq; - struct hns3_mbx_pf_to_vf_cmd *req; - struct hns3_cmd_desc *desc; -+ bool handle_out; - uint8_t opcode; - uint16_t flag; - - rte_spinlock_lock(&hw->cmq.crq.lock); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY || -- !rte_thread_is_intr()) { -+ handle_out = (rte_eal_process_type() != RTE_PROC_PRIMARY || -+ !rte_thread_is_intr()) && hns->is_vf; -+ if (handle_out) { - /* - * Currently, any threads in the primary and secondary processes - * could send mailbox sync request, so it will need to process -@@ -491,7 +494,8 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - continue; - } - -- if (desc->opcode == 0) { -+ handle_out = hns->is_vf && desc->opcode == 0; -+ if (handle_out) { - /* Message already processed by other thread */ - crq->desc[crq->next_to_use].flag = 0; - hns3_mbx_ring_ptr_move_crq(crq); --- -2.7.4 - diff --git a/0134-net-hns3-remove-unused-mailbox-macro-and-struct.patch b/0134-net-hns3-remove-unused-mailbox-macro-and-struct.patch deleted file mode 100644 index c478ffa..0000000 --- a/0134-net-hns3-remove-unused-mailbox-macro-and-struct.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0a74fe6f54d39e5e09e875266efc365d51a4de68 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Thu, 22 Apr 2021 09:55:52 +0800 -Subject: [PATCH 134/189] net/hns3: remove unused mailbox macro and struct - -In hns3_mbx.h, some macro and structure were defined in previous -versions but never used. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.h | 10 ---------- - 1 file changed, 10 deletions(-) - -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index 338c2c2..e84ef6d 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -5,8 +5,6 @@ - #ifndef _HNS3_MBX_H_ - #define _HNS3_MBX_H_ - --#define HNS3_MBX_VF_MSG_DATA_NUM 16 -- - enum HNS3_MBX_OPCODE { - HNS3_MBX_RESET = 0x01, /* (VF -> PF) assert reset */ - HNS3_MBX_ASSERTING_RESET, /* (PF -> VF) PF is asserting reset */ -@@ -80,8 +78,6 @@ enum hns3_mbx_link_fail_subcode { - - #define HNS3_MBX_MAX_MSG_SIZE 16 - #define HNS3_MBX_MAX_RESP_DATA_SIZE 8 --#define HNS3_MBX_RING_MAP_BASIC_MSG_NUM 3 --#define HNS3_MBX_RING_NODE_VARIABLE_NUM 3 - - enum { - HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL = 0, -@@ -147,12 +143,6 @@ struct hns3_vf_bind_vector_msg { - struct hns3_ring_chain_param param[HNS3_MBX_MAX_RING_CHAIN_PARAM_NUM]; - }; - --struct hns3_vf_rst_cmd { -- uint8_t dest_vfid; -- uint8_t vf_rst; -- uint8_t rsv[22]; --}; -- - struct hns3_pf_rst_done_cmd { - uint8_t pf_rst_done; - uint8_t rsv[23]; --- -2.7.4 - diff --git a/0135-net-hns3-fix-typos-on-comments.patch b/0135-net-hns3-fix-typos-on-comments.patch deleted file mode 100644 index 6245b79..0000000 --- a/0135-net-hns3-fix-typos-on-comments.patch +++ /dev/null @@ -1,63 +0,0 @@ -From ccfb6795b2b2336ea29836d1ac8bdadcf6e635be Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Fri, 23 Apr 2021 17:27:38 +0800 -Subject: [PATCH 135/189] net/hns3: fix typos on comments - -This patch fixed wrong word in comments. - -Fixes: f53a793bb7c2 ("net/hns3: add more hardware error types") -Fixes: d51867db65c1 ("net/hns3: add initialization") -Fixes: 411d23b9eafb ("net/hns3: support VLAN") -Fixes: 5f8845f4ba8f ("net/hns3: process MAC interrupt") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 81c67e2..887c008 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -280,7 +280,7 @@ hns3_handle_mac_tnl(struct hns3_hw *hw) - uint32_t status; - int ret; - -- /* query and clear mac tnl interruptions */ -+ /* query and clear mac tnl interrupt */ - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_QUERY_MAC_TNL_INT, true); - ret = hns3_cmd_send(hw, &desc, 1); - if (ret) { -@@ -462,7 +462,7 @@ hns3_vlan_filter_configure(struct hns3_adapter *hns, uint16_t vlan_id, int on) - * When port base vlan enabled, we use port base vlan as the vlan - * filter condition. In this case, we don't update vlan filter table - * when user add new vlan or remove exist vlan, just update the -- * vlan list. The vlan id in vlan list will be writen in vlan filter -+ * vlan list. The vlan id in vlan list will be written in vlan filter - * table until port base vlan disabled - */ - if (hw->port_base_vlan_cfg.state == HNS3_PORT_BASE_VLAN_DISABLE) { -@@ -3983,8 +3983,8 @@ hns3_rx_buffer_calc(struct hns3_hw *hw, struct hns3_pkt_buf_alloc *buf_alloc) - * For different application scenes, the enabled port number, TC number - * and no_drop TC number are different. In order to obtain the better - * performance, software could allocate the buffer size and configure -- * the waterline by tring to decrease the private buffer size according -- * to the order, namely, waterline of valided tc, pfc disabled tc, pfc -+ * the waterline by trying to decrease the private buffer size according -+ * to the order, namely, waterline of valid tc, pfc disabled tc, pfc - * enabled tc. - */ - if (hns3_rx_buf_calc_all(hw, false, buf_alloc)) -@@ -5045,7 +5045,7 @@ hns3_config_all_msix_error(struct hns3_hw *hw, bool enable) - * and belong to a different type from the MSI-x errors processed - * by the network driver. - * -- * Network driver should open the new error report on initialition -+ * Network driver should open the new error report on initialization. - */ - val = hns3_read_dev(hw, HNS3_VECTOR0_OTER_EN_REG); - hns3_set_bit(val, HNS3_VECTOR0_ALL_MSIX_ERR_B, enable ? 1 : 0); --- -2.7.4 - diff --git a/0136-net-hns3-disable-MAC-status-report-interrupt.patch b/0136-net-hns3-disable-MAC-status-report-interrupt.patch deleted file mode 100644 index 231bd23..0000000 --- a/0136-net-hns3-disable-MAC-status-report-interrupt.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 6f262eb7e4f7682a34b53d5c4328fee1a4d817de Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Fri, 23 Apr 2021 17:56:34 +0800 -Subject: [PATCH 136/189] net/hns3: disable MAC status report interrupt - -Disable the MAC status report interrupt which hns3 driver not concern -currently. - -Fixes: 5f8845f4ba8f ("net/hns3: process MAC interrupt") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 887c008..cea7926 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -4892,8 +4892,6 @@ hns3_update_link_status(struct hns3_hw *hw) - if (state != hw->mac.link_status) { - hw->mac.link_status = state; - hns3_warn(hw, "Link status change to %s!", state ? "up" : "down"); -- hns3_config_mac_tnl_int(hw, -- state == ETH_LINK_UP ? true : false); - return true; - } - --- -2.7.4 - diff --git a/0137-net-hns3-fix-handling-link-update.patch b/0137-net-hns3-fix-handling-link-update.patch deleted file mode 100644 index 6dc3f6e..0000000 --- a/0137-net-hns3-fix-handling-link-update.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 2f19fbb0dd817a21194fc0764621fe0ad67b90a7 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 27 Apr 2021 20:17:39 +0800 -Subject: [PATCH 137/189] net/hns3: fix handling link update - -The link fails code should be parsed using the structure -hns3_mbx_vf_to_pf_cmd, else it will parse fail. - -Fixes: 109e4dd1bd7a ("net/hns3: get link state change through mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 11 +++++++++-- - 1 file changed, 9 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index ea6c0c3..3d019b9 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -347,7 +347,7 @@ hns3_link_fail_parse(struct hns3_hw *hw, uint8_t link_fail_code) - - static void - hns3pf_handle_link_change_event(struct hns3_hw *hw, -- struct hns3_mbx_pf_to_vf_cmd *req) -+ struct hns3_mbx_vf_to_pf_cmd *req) - { - #define LINK_STATUS_OFFSET 1 - #define LINK_FAIL_CODE_OFFSET 2 -@@ -513,7 +513,14 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - hns3_handle_asserting_reset(hw, req); - break; - case HNS3_MBX_PUSH_LINK_STATUS: -- hns3pf_handle_link_change_event(hw, req); -+ /* -+ * This message is reported by the firmware and is -+ * reported in 'struct hns3_mbx_vf_to_pf_cmd' format. -+ * Therefore, we should cast the req variable to -+ * 'struct hns3_mbx_vf_to_pf_cmd' and then process it. -+ */ -+ hns3pf_handle_link_change_event(hw, -+ (struct hns3_mbx_vf_to_pf_cmd *)req); - break; - case HNS3_MBX_PUSH_VLAN_INFO: - /* --- -2.7.4 - diff --git a/0138-net-hns3-fix-link-status-when-port-is-stopped.patch b/0138-net-hns3-fix-link-status-when-port-is-stopped.patch deleted file mode 100644 index 393bef4..0000000 --- a/0138-net-hns3-fix-link-status-when-port-is-stopped.patch +++ /dev/null @@ -1,51 +0,0 @@ -From d2fe85e2b088b99decbd4d394071fffbb6d80ff2 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sun, 25 Apr 2021 20:06:28 +0800 -Subject: [PATCH 138/189] net/hns3: fix link status when port is stopped - -When port is stopped, link down should be reported to user. For HNS3 -PF driver, link status comes from link status of hardware. If the port -supports NCSI feature, hardware MAC will not be disabled. At this case, -even if the port is stopped, the link status is still Up. So driver -should set link down when the port is stopped. - -Fixes: 59fad0f32135 ("net/hns3: support link update operation") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index cea7926..eed1a37 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2894,6 +2894,15 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete) - struct rte_eth_link new_link; - int ret; - -+ /* When port is stopped, report link down. */ -+ if (eth_dev->data->dev_started == 0) { -+ new_link.link_autoneg = mac->link_autoneg; -+ new_link.link_duplex = mac->link_duplex; -+ new_link.link_speed = ETH_SPEED_NUM_NONE; -+ new_link.link_status = ETH_LINK_DOWN; -+ goto out; -+ } -+ - do { - ret = hns3_update_port_link_info(eth_dev); - if (ret) { -@@ -2911,6 +2920,7 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete) - memset(&new_link, 0, sizeof(new_link)); - hns3_setup_linkstatus(eth_dev, &new_link); - -+out: - return rte_eth_linkstatus_set(eth_dev, &new_link); - } - --- -2.7.4 - diff --git a/0139-net-hns3-fix-link-speed-when-port-is-down.patch b/0139-net-hns3-fix-link-speed-when-port-is-down.patch deleted file mode 100644 index b266e7d..0000000 --- a/0139-net-hns3-fix-link-speed-when-port-is-down.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 5ebfd9debffcadd8410f92089b4103e888b859b0 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sun, 25 Apr 2021 20:06:29 +0800 -Subject: [PATCH 139/189] net/hns3: fix link speed when port is down - -When the port is link down state, it is meaningless to display the -port link speed. It should be an undefined state. - -Fixes: 59fad0f32135 ("net/hns3: support link update operation") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index eed1a37..8dc9dbe 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2867,16 +2867,18 @@ hns3_setup_linkstatus(struct rte_eth_dev *eth_dev, - case ETH_SPEED_NUM_50G: - case ETH_SPEED_NUM_100G: - case ETH_SPEED_NUM_200G: -- new_link->link_speed = mac->link_speed; -+ if (mac->link_status) -+ new_link->link_speed = mac->link_speed; - break; - default: - if (mac->link_status) - new_link->link_speed = ETH_SPEED_NUM_UNKNOWN; -- else -- new_link->link_speed = ETH_SPEED_NUM_NONE; - break; - } - -+ if (!mac->link_status) -+ new_link->link_speed = ETH_SPEED_NUM_NONE; -+ - new_link->link_duplex = mac->link_duplex; - new_link->link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN; - new_link->link_autoneg = mac->link_autoneg; --- -2.7.4 - diff --git a/0140-net-hns3-support-preferred-burst-size-and-queues-in-.patch b/0140-net-hns3-support-preferred-burst-size-and-queues-in-.patch deleted file mode 100644 index 34fe059..0000000 --- a/0140-net-hns3-support-preferred-burst-size-and-queues-in-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 8ca8c0a70500b13e25d292994ba403729f8671fd Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 28 Apr 2021 15:20:51 +0800 -Subject: [PATCH 140/189] net/hns3: support preferred burst size and queues in - VF - -This patch supports get preferred burst size and queues when call -rte_eth_dev_info_get() API with VF. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 3 --- - drivers/net/hns3/hns3_ethdev.h | 3 +++ - drivers/net/hns3/hns3_ethdev_vf.c | 5 +++++ - 3 files changed, 8 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 8dc9dbe..f532284 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -16,9 +16,6 @@ - #include "hns3_dcb.h" - #include "hns3_mp.h" - --#define HNS3_DEFAULT_PORT_CONF_BURST_SIZE 32 --#define HNS3_DEFAULT_PORT_CONF_QUEUES_NUM 1 -- - #define HNS3_SERVICE_INTERVAL 1000000 /* us */ - #define HNS3_SERVICE_QUICK_INTERVAL 10 - #define HNS3_INVALID_PVID 0xFFFF -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 8191c53..29737c6 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -42,6 +42,9 @@ - #define HNS3_PF_FUNC_ID 0 - #define HNS3_1ST_VF_FUNC_ID 1 - -+#define HNS3_DEFAULT_PORT_CONF_BURST_SIZE 32 -+#define HNS3_DEFAULT_PORT_CONF_QUEUES_NUM 1 -+ - #define HNS3_SW_SHIFT_AND_DISCARD_MODE 0 - #define HNS3_HW_SHIFT_AND_DISCARD_MODE 1 - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index a278146..324c6b1 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1027,6 +1027,11 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - info->reta_size = hw->rss_ind_tbl_size; - info->hash_key_size = HNS3_RSS_KEY_SIZE; - info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; -+ -+ info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -+ info->default_txportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -+ info->default_rxportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -+ info->default_txportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; - info->default_rxportconf.ring_size = HNS3_DEFAULT_RING_DESC; - info->default_txportconf.ring_size = HNS3_DEFAULT_RING_DESC; - --- -2.7.4 - diff --git a/0141-net-hns3-log-time-delta-in-decimal-format.patch b/0141-net-hns3-log-time-delta-in-decimal-format.patch deleted file mode 100644 index fe55181..0000000 --- a/0141-net-hns3-log-time-delta-in-decimal-format.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 8d44b2b715e6fba4454cfbd754eb155b81060a2a Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 28 Apr 2021 15:20:52 +0800 -Subject: [PATCH 141/189] net/hns3: log time delta in decimal format - -If the reset process cost too much time, driver will log one error -message which formats the time delta, but the formatting is using -hexadecimal which was not readable. - -This patch fixes it by formatting in decimal format. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 +- - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f532284..f6f1b3b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6707,7 +6707,7 @@ hns3_reset_service(void *param) - msec = tv_delta.tv_sec * MSEC_PER_SEC + - tv_delta.tv_usec / USEC_PER_MSEC; - if (msec > HNS3_RESET_PROCESS_MS) -- hns3_err(hw, "%d handle long time delta %" PRIx64 -+ hns3_err(hw, "%d handle long time delta %" PRIu64 - " ms time=%ld.%.6ld", - hw->reset.level, msec, - tv.tv_sec, tv.tv_usec); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 324c6b1..8ab3732 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2779,7 +2779,7 @@ hns3vf_reset_service(void *param) - msec = tv_delta.tv_sec * MSEC_PER_SEC + - tv_delta.tv_usec / USEC_PER_MSEC; - if (msec > HNS3_RESET_PROCESS_MS) -- hns3_err(hw, "%d handle long time delta %" PRIx64 -+ hns3_err(hw, "%d handle long time delta %" PRIu64 - " ms time=%ld.%.6ld", - hw->reset.level, msec, tv.tv_sec, tv.tv_usec); - } --- -2.7.4 - diff --git a/0142-net-hns3-fix-time-delta-calculation.patch b/0142-net-hns3-fix-time-delta-calculation.patch deleted file mode 100644 index baac952..0000000 --- a/0142-net-hns3-fix-time-delta-calculation.patch +++ /dev/null @@ -1,315 +0,0 @@ -From 4664bc17d0b90fa8935d6e5e6d0ec41a59c7e955 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 28 Apr 2021 15:20:53 +0800 -Subject: [PATCH 142/189] net/hns3: fix time delta calculation - -Currently, driver uses gettimeofday() API to get the time, and -then calculate the time delta, the delta will be used mainly in -judging timeout process. - -But the time which gets from gettimeofday() API isn't monotonically -increasing. The process may fail if the system time is changed. - -We use the following scheme to fix it: -1. Add hns3_clock_gettime() API which will get the monotonically - increasing time. -2. Add hns3_clock_calctime_ms() API which will get the milliseconds of - the monotonically increasing time. -3. Add hns3_clock_calctime_ms() API which will calc the milliseconds of - a given time. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 46 +++++++++++++++++++++++++++++++++------ - drivers/net/hns3/hns3_ethdev.h | 12 +++------- - drivers/net/hns3/hns3_ethdev_vf.c | 11 +++++----- - drivers/net/hns3/hns3_intr.c | 34 ++++++++++++++--------------- - 4 files changed, 63 insertions(+), 40 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f6f1b3b..bba4d0f 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6343,7 +6343,7 @@ hns3_wait_hardware_ready(struct hns3_adapter *hns) - if (wait_data->result == HNS3_WAIT_SUCCESS) - return 0; - else if (wait_data->result == HNS3_WAIT_TIMEOUT) { -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - hns3_warn(hw, "Reset step4 hardware not ready after reset time=%ld.%.6ld", - tv.tv_sec, tv.tv_usec); - return -ETIME; -@@ -6353,7 +6353,7 @@ hns3_wait_hardware_ready(struct hns3_adapter *hns) - wait_data->hns = hns; - wait_data->check_completion = is_pf_reset_done; - wait_data->end_ms = (uint64_t)HNS3_RESET_WAIT_CNT * -- HNS3_RESET_WAIT_MS + get_timeofday_ms(); -+ HNS3_RESET_WAIT_MS + hns3_clock_gettime_ms(); - wait_data->interval = HNS3_RESET_WAIT_MS * USEC_PER_MSEC; - wait_data->count = HNS3_RESET_WAIT_CNT; - wait_data->result = HNS3_WAIT_REQUEST; -@@ -6392,7 +6392,7 @@ hns3_msix_process(struct hns3_adapter *hns, enum hns3_reset_level reset_level) - struct timeval tv; - uint32_t val; - -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - if (hns3_read_dev(hw, HNS3_GLOBAL_RESET_REG) || - hns3_read_dev(hw, HNS3_FUN_RST_ING)) { - hns3_warn(hw, "Don't process msix during resetting time=%ld.%.6ld", -@@ -6700,12 +6700,11 @@ hns3_reset_service(void *param) - */ - reset_level = hns3_get_reset_level(hns, &hw->reset.pending); - if (reset_level != HNS3_NONE_RESET) { -- gettimeofday(&tv_start, NULL); -+ hns3_clock_gettime(&tv_start); - ret = hns3_reset_process(hns, reset_level); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - timersub(&tv, &tv_start, &tv_delta); -- msec = tv_delta.tv_sec * MSEC_PER_SEC + -- tv_delta.tv_usec / USEC_PER_MSEC; -+ msec = hns3_clock_calctime_ms(&tv_delta); - if (msec > HNS3_RESET_PROCESS_MS) - hns3_err(hw, "%d handle long time delta %" PRIu64 - " ms time=%ld.%.6ld", -@@ -7205,6 +7204,39 @@ hns3_get_module_info(struct rte_eth_dev *dev, - return 0; - } - -+void -+hns3_clock_gettime(struct timeval *tv) -+{ -+#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ -+#define CLOCK_TYPE CLOCK_MONOTONIC_RAW -+#else -+#define CLOCK_TYPE CLOCK_MONOTONIC -+#endif -+#define NSEC_TO_USEC_DIV 1000 -+ -+ struct timespec spec; -+ (void)clock_gettime(CLOCK_TYPE, &spec); -+ -+ tv->tv_sec = spec.tv_sec; -+ tv->tv_usec = spec.tv_nsec / NSEC_TO_USEC_DIV; -+} -+ -+uint64_t -+hns3_clock_calctime_ms(struct timeval *tv) -+{ -+ return (uint64_t)tv->tv_sec * MSEC_PER_SEC + -+ tv->tv_usec / USEC_PER_MSEC; -+} -+ -+uint64_t -+hns3_clock_gettime_ms(void) -+{ -+ struct timeval tv; -+ -+ hns3_clock_gettime(&tv); -+ return hns3_clock_calctime_ms(&tv); -+} -+ - static int - hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) - { -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 29737c6..b65fb39 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1022,15 +1022,9 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) - #define MSEC_PER_SEC 1000L - #define USEC_PER_MSEC 1000L - --static inline uint64_t --get_timeofday_ms(void) --{ -- struct timeval tv; -- -- (void)gettimeofday(&tv, NULL); -- -- return (uint64_t)tv.tv_sec * MSEC_PER_SEC + tv.tv_usec / USEC_PER_MSEC; --} -+void hns3_clock_gettime(struct timeval *tv); -+uint64_t hns3_clock_calctime_ms(struct timeval *tv); -+uint64_t hns3_clock_gettime_ms(void); - - static inline uint64_t - hns3_atomic_test_bit(unsigned int nr, volatile uint64_t *addr) -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 8ab3732..f4d2a9f 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2507,7 +2507,7 @@ hns3vf_wait_hardware_ready(struct hns3_adapter *hns) - hns3_warn(hw, "hardware is ready, delay 1 sec for PF reset complete"); - return -EAGAIN; - } else if (wait_data->result == HNS3_WAIT_TIMEOUT) { -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - hns3_warn(hw, "Reset step4 hardware not ready after reset time=%ld.%.6ld", - tv.tv_sec, tv.tv_usec); - return -ETIME; -@@ -2517,7 +2517,7 @@ hns3vf_wait_hardware_ready(struct hns3_adapter *hns) - wait_data->hns = hns; - wait_data->check_completion = is_vf_reset_done; - wait_data->end_ms = (uint64_t)HNS3VF_RESET_WAIT_CNT * -- HNS3VF_RESET_WAIT_MS + get_timeofday_ms(); -+ HNS3VF_RESET_WAIT_MS + hns3_clock_gettime_ms(); - wait_data->interval = HNS3VF_RESET_WAIT_MS * USEC_PER_MSEC; - wait_data->count = HNS3VF_RESET_WAIT_CNT; - wait_data->result = HNS3_WAIT_REQUEST; -@@ -2772,12 +2772,11 @@ hns3vf_reset_service(void *param) - */ - reset_level = hns3vf_get_reset_level(hw, &hw->reset.pending); - if (reset_level != HNS3_NONE_RESET) { -- gettimeofday(&tv_start, NULL); -+ hns3_clock_gettime(&tv_start); - hns3_reset_process(hns, reset_level); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - timersub(&tv, &tv_start, &tv_delta); -- msec = tv_delta.tv_sec * MSEC_PER_SEC + -- tv_delta.tv_usec / USEC_PER_MSEC; -+ msec = hns3_clock_calctime_ms(&tv_delta); - if (msec > HNS3_RESET_PROCESS_MS) - hns3_err(hw, "%d handle long time delta %" PRIu64 - " ms time=%ld.%.6ld", -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 7385c7b..482541b 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2465,7 +2465,7 @@ hns3_wait_callback(void *param) - * Check if the current time exceeds the deadline - * or a pending reset coming, or reset during close. - */ -- msec = get_timeofday_ms(); -+ msec = hns3_clock_gettime_ms(); - if (msec > data->end_ms || is_reset_pending(hns) || - hw->adapter_state == HNS3_NIC_CLOSING) { - done = false; -@@ -2650,7 +2650,7 @@ hns3_reset_pre(struct hns3_adapter *hns) - __atomic_store_n(&hns->hw.reset.resetting, 1, __ATOMIC_RELAXED); - hw->reset.stage = RESET_STAGE_DOWN; - ret = hw->reset.ops->stop_service(hns); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - if (ret) { - hns3_warn(hw, "Reset step1 down fail=%d time=%ld.%.6ld", - ret, tv.tv_sec, tv.tv_usec); -@@ -2662,7 +2662,7 @@ hns3_reset_pre(struct hns3_adapter *hns) - } - if (hw->reset.stage == RESET_STAGE_PREWAIT) { - ret = hw->reset.ops->prepare_reset(hns); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - if (ret) { - hns3_warn(hw, - "Reset step2 prepare wait fail=%d time=%ld.%.6ld", -@@ -2700,7 +2700,7 @@ hns3_reset_post(struct hns3_adapter *hns) - } - ret = hw->reset.ops->reinit_dev(hns); - rte_spinlock_unlock(&hw->lock); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - if (ret) { - hns3_warn(hw, "Reset step5 devinit fail=%d retries=%d", - ret, hw->reset.retries); -@@ -2718,7 +2718,7 @@ hns3_reset_post(struct hns3_adapter *hns) - rte_spinlock_lock(&hw->lock); - ret = hw->reset.ops->restore_conf(hns); - rte_spinlock_unlock(&hw->lock); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - if (ret) { - hns3_warn(hw, - "Reset step6 restore fail=%d retries=%d", -@@ -2741,7 +2741,7 @@ hns3_reset_post(struct hns3_adapter *hns) - rte_spinlock_lock(&hw->lock); - hw->reset.ops->start_service(hns); - rte_spinlock_unlock(&hw->lock); -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - timersub(&tv, &hw->reset.start_time, &tv_delta); - hns3_warn(hw, "%s reset done fail_cnt:%" PRIx64 - " success_cnt:%" PRIx64 " global_cnt:%" PRIx64 -@@ -2753,10 +2753,9 @@ hns3_reset_post(struct hns3_adapter *hns) - hw->reset.stats.request_cnt, hw->reset.stats.exec_cnt, - hw->reset.stats.merge_cnt); - hns3_warn(hw, -- "%s reset done delta %ld ms time=%ld.%.6ld", -+ "%s reset done delta %" PRIu64 " ms time=%ld.%.6ld", - reset_string[hw->reset.level], -- tv_delta.tv_sec * MSEC_PER_SEC + -- tv_delta.tv_usec / USEC_PER_MSEC, -+ hns3_clock_calctime_ms(&tv_delta), - tv.tv_sec, tv.tv_usec); - hw->reset.level = HNS3_NONE_RESET; - } -@@ -2796,7 +2795,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) - if (hw->reset.level == HNS3_NONE_RESET) { - hw->reset.level = new_level; - hw->reset.stats.exec_cnt++; -- gettimeofday(&hw->reset.start_time, NULL); -+ hns3_clock_gettime(&hw->reset.start_time); - hns3_warn(hw, "Start %s reset time=%ld.%.6ld", - reset_string[hw->reset.level], - hw->reset.start_time.tv_sec, -@@ -2804,7 +2803,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) - } - - if (is_reset_pending(hns)) { -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - hns3_warn(hw, - "%s reset is aborted by high level time=%ld.%.6ld", - reset_string[hw->reset.level], tv.tv_sec, tv.tv_usec); -@@ -2822,7 +2821,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) - ret = hns3_reset_req_hw_reset(hns); - if (ret == -EAGAIN) - return ret; -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - hns3_warn(hw, - "Reset step3 request IMP reset success time=%ld.%.6ld", - tv.tv_sec, tv.tv_usec); -@@ -2833,7 +2832,7 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) - ret = hw->reset.ops->wait_hardware_ready(hns); - if (ret) - goto retry; -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - hns3_warn(hw, "Reset step4 reset wait success time=%ld.%.6ld", - tv.tv_sec, tv.tv_usec); - hw->reset.stage = RESET_STAGE_DEV_INIT; -@@ -2861,12 +2860,11 @@ hns3_reset_process(struct hns3_adapter *hns, enum hns3_reset_level new_level) - rte_spinlock_unlock(&hw->lock); - __atomic_store_n(&hns->hw.reset.resetting, 0, __ATOMIC_RELAXED); - hw->reset.stage = RESET_STAGE_NONE; -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - timersub(&tv, &hw->reset.start_time, &tv_delta); -- hns3_warn(hw, "%s reset fail delta %ld ms time=%ld.%.6ld", -+ hns3_warn(hw, "%s reset fail delta %" PRIu64 " ms time=%ld.%.6ld", - reset_string[hw->reset.level], -- tv_delta.tv_sec * MSEC_PER_SEC + -- tv_delta.tv_usec / USEC_PER_MSEC, -+ hns3_clock_calctime_ms(&tv_delta), - tv.tv_sec, tv.tv_usec); - hw->reset.level = HNS3_NONE_RESET; - } -@@ -2898,7 +2896,7 @@ hns3_reset_abort(struct hns3_adapter *hns) - rte_eal_alarm_cancel(hns3_wait_callback, hw->reset.wait_data); - - if (hw->reset.level != HNS3_NONE_RESET) { -- gettimeofday(&tv, NULL); -+ hns3_clock_gettime(&tv); - hns3_err(hw, "Failed to terminate reset: %s time=%ld.%.6ld", - reset_string[hw->reset.level], tv.tv_sec, tv.tv_usec); - } --- -2.7.4 - diff --git a/0143-net-hns3-select-Tx-prepare-based-on-Tx-offload.patch b/0143-net-hns3-select-Tx-prepare-based-on-Tx-offload.patch deleted file mode 100644 index 0de4aca..0000000 --- a/0143-net-hns3-select-Tx-prepare-based-on-Tx-offload.patch +++ /dev/null @@ -1,110 +0,0 @@ -From 9392190f55c0eeef207370b4fcbc7f7249ee5231 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 28 Apr 2021 15:20:55 +0800 -Subject: [PATCH 143/189] net/hns3: select Tx prepare based on Tx offload - -Tx prepare should be called only when necessary to reduce the impact on -performance. - -For partial TX offload, users need to call rte_eth_tx_prepare() to -invoke the tx_prepare callback of PMDs. In this callback, the PMDs -adjust the packet based on the offloading used by the user. (e.g. For -some PMDs, pseudo-headers need to be calculated when the TX cksum is -offloaded.) - -However, for the users, they cannot grasp all the hardware and PMDs -characteristics. As a result, users cannot decide when they need to -actually call tx_prepare. Therefore, we should assume that the user -calls rte_eth_tx_prepare() when using any Tx offloading to ensure that -related functions work properly. Whether packets need to be adjusted -should be determined by PMDs. They can make judgments in the -dev_configure or queue_setup phase. When the related function is not -used, the pointer of tx_prepare should be set to NULL to reduce the -performance loss caused by invoking rte_eth_tx_repare(). - -In this patch, if tx_prepare is not required for the offloading used by -the users, the tx_prepare pointer will be set to NULL. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 36 +++++++++++++++++++++++++++++++++--- - 1 file changed, 33 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 92d377b..f4df3e2 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4203,17 +4203,45 @@ hns3_tx_check_simple_support(struct rte_eth_dev *dev) - return (offloads == (offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)); - } - -+static bool -+hns3_get_tx_prep_needed(struct rte_eth_dev *dev) -+{ -+#ifdef RTE_LIBRTE_ETHDEV_DEBUG -+ /* always perform tx_prepare when debug */ -+ return true; -+#else -+#define HNS3_DEV_TX_CSKUM_TSO_OFFLOAD_MASK (\ -+ DEV_TX_OFFLOAD_IPV4_CKSUM | \ -+ DEV_TX_OFFLOAD_TCP_CKSUM | \ -+ DEV_TX_OFFLOAD_UDP_CKSUM | \ -+ DEV_TX_OFFLOAD_SCTP_CKSUM | \ -+ DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | \ -+ DEV_TX_OFFLOAD_OUTER_UDP_CKSUM | \ -+ DEV_TX_OFFLOAD_TCP_TSO | \ -+ DEV_TX_OFFLOAD_VXLAN_TNL_TSO | \ -+ DEV_TX_OFFLOAD_GRE_TNL_TSO | \ -+ DEV_TX_OFFLOAD_GENEVE_TNL_TSO) -+ -+ uint64_t tx_offload = dev->data->dev_conf.txmode.offloads; -+ if (tx_offload & HNS3_DEV_TX_CSKUM_TSO_OFFLOAD_MASK) -+ return true; -+ -+ return false; -+#endif -+} -+ - static eth_tx_burst_t - hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - { - struct hns3_adapter *hns = dev->data->dev_private; - bool vec_allowed, sve_allowed, simple_allowed; -- bool vec_support; -+ bool vec_support, tx_prepare_needed; - - vec_support = hns3_tx_check_vec_support(dev) == 0; - vec_allowed = vec_support && hns3_get_default_vec_support(); - sve_allowed = vec_support && hns3_get_sve_support(); - simple_allowed = hns3_tx_check_simple_support(dev); -+ tx_prepare_needed = hns3_get_tx_prep_needed(dev); - - *prep = NULL; - -@@ -4224,7 +4252,8 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_SIMPLE && simple_allowed) - return hns3_xmit_pkts_simple; - if (hns->tx_func_hint == HNS3_IO_FUNC_HINT_COMMON) { -- *prep = hns3_prep_pkts; -+ if (tx_prepare_needed) -+ *prep = hns3_prep_pkts; - return hns3_xmit_pkts; - } - -@@ -4233,7 +4262,8 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - if (simple_allowed) - return hns3_xmit_pkts_simple; - -- *prep = hns3_prep_pkts; -+ if (tx_prepare_needed) -+ *prep = hns3_prep_pkts; - return hns3_xmit_pkts; - } - --- -2.7.4 - diff --git a/0144-net-hns3-fix-MAC-enable-failure-rollback.patch b/0144-net-hns3-fix-MAC-enable-failure-rollback.patch deleted file mode 100644 index 6409e63..0000000 --- a/0144-net-hns3-fix-MAC-enable-failure-rollback.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 16635e5c21b02e649d7babe0db6364bfaba71bc3 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 29 Apr 2021 17:03:59 +0800 -Subject: [PATCH 144/189] net/hns3: fix MAC enable failure rollback - -If driver fails to enable MAC, it does not need to rollback the MAC -configuration. This patch fixes it. - -Fixes: bdaf190f8235 ("net/hns3: support link speed autoneg for PF") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index bba4d0f..f5160ed 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5605,12 +5605,14 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - - ret = hns3_apply_link_speed(hw); - if (ret) -- goto err_config_mac_mode; -+ goto err_set_link_speed; - - return 0; - --err_config_mac_mode: -+err_set_link_speed: - (void)hns3_cfg_mac_mode(hw, false); -+ -+err_config_mac_mode: - hns3_dev_release_mbufs(hns); - /* - * Here is exception handling, hns3_reset_all_tqps will have the --- -2.7.4 - diff --git a/0145-net-hns3-fix-IEEE-1588-PTP-for-scalar-scattered-Rx.patch b/0145-net-hns3-fix-IEEE-1588-PTP-for-scalar-scattered-Rx.patch deleted file mode 100644 index 1969daf..0000000 --- a/0145-net-hns3-fix-IEEE-1588-PTP-for-scalar-scattered-Rx.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 3ac46c2a0e35e79fd2e9f9a8c0b05c71e944caae Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 29 Apr 2021 17:19:03 +0800 -Subject: [PATCH 145/189] net/hns3: fix IEEE 1588 PTP for scalar scattered Rx - -When jumbo frame is enabled, Rx function will choose 'Scalar Scattered' -function which has no PTP handling. - -This patch fixes it by adding PTP handling in 'Scalar Scattered' -function. - -Fixes: 38b539d96eb6 ("net/hns3: support IEEE 1588 PTP") - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index f4df3e2..bc4a9a5 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2654,6 +2654,9 @@ hns3_recv_scattered_pkts(void *rx_queue, - continue; - } - -+ if (unlikely(bd_base_info & BIT(HNS3_RXD_TS_VLD_B))) -+ hns3_rx_ptp_timestamp_handle(rxq, first_seg, rxdp); -+ - /* - * The last buffer of the received packet. packet len from - * buffer description may contains CRC len, packet len should -@@ -2704,6 +2707,9 @@ hns3_recv_scattered_pkts(void *rx_queue, - first_seg->packet_type = hns3_rx_calc_ptype(rxq, - l234_info, ol_info); - -+ if (first_seg->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) -+ rxm->ol_flags |= PKT_RX_IEEE1588_PTP; -+ - hns3_rxd_to_vlan_tci(rxq, first_seg, l234_info, &rxd); - - /* Increment bytes counter */ --- -2.7.4 - diff --git a/0146-net-hns3-remove-some-unused-capabilities.patch b/0146-net-hns3-remove-some-unused-capabilities.patch deleted file mode 100644 index 0882538..0000000 --- a/0146-net-hns3-remove-some-unused-capabilities.patch +++ /dev/null @@ -1,157 +0,0 @@ -From f92b61b4be62100b35e5d3fb7513c12ef1148409 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 14:28:45 +0800 -Subject: [PATCH 146/189] net/hns3: remove some unused capabilities - -This patch deletes some unused capabilities, include: -1. Delete some unused firmware capabilities definition, which are: - UDP_GSO, ATR, INT_QL, SIMPLE_BD, TX_PUSH, FEC and PAUSE. -2. Delete some unused driver capabilities definition, which are: - UDP_GSO, TX_PUSH. -3. Also redefine HNS3_DEV_SUPPORT_* as enum type, and change some of - the values. Note: the HNS3_DEV_SUPPORT_* values is used only inside - the driver, so it's safe to change the values. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 11 ----------- - drivers/net/hns3/hns3_cmd.h | 17 +++++++---------- - drivers/net/hns3/hns3_ethdev.h | 29 +++++++++++------------------ - 3 files changed, 18 insertions(+), 39 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 5eb8789..a43385b 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -423,21 +423,14 @@ hns3_get_caps_name(uint32_t caps_id) - enum HNS3_CAPS_BITS caps; - const char *name; - } dev_caps[] = { -- { HNS3_CAPS_UDP_GSO_B, "udp_gso" }, -- { HNS3_CAPS_ATR_B, "atr" }, - { HNS3_CAPS_FD_QUEUE_REGION_B, "fd_queue_region" }, - { HNS3_CAPS_PTP_B, "ptp" }, -- { HNS3_CAPS_INT_QL_B, "int_ql" }, -- { HNS3_CAPS_SIMPLE_BD_B, "simple_bd" }, -- { HNS3_CAPS_TX_PUSH_B, "tx_push" }, - { HNS3_CAPS_PHY_IMP_B, "phy_imp" }, - { HNS3_CAPS_TQP_TXRX_INDEP_B, "tqp_txrx_indep" }, - { HNS3_CAPS_HW_PAD_B, "hw_pad" }, - { HNS3_CAPS_STASH_B, "stash" }, - { HNS3_CAPS_UDP_TUNNEL_CSUM_B, "udp_tunnel_csum" }, - { HNS3_CAPS_RAS_IMP_B, "ras_imp" }, -- { HNS3_CAPS_FEC_B, "fec" }, -- { HNS3_CAPS_PAUSE_B, "pause" }, - { HNS3_CAPS_RXD_ADV_LAYOUT_B, "rxd_adv_layout" } - }; - uint32_t i; -@@ -484,8 +477,6 @@ hns3_parse_capability(struct hns3_hw *hw, - { - uint32_t caps = rte_le_to_cpu_32(cmd->caps[0]); - -- if (hns3_get_bit(caps, HNS3_CAPS_UDP_GSO_B)) -- hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_UDP_GSO_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_FD_QUEUE_REGION_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, - 1); -@@ -502,8 +493,6 @@ hns3_parse_capability(struct hns3_hw *hw, - hns3_warn(hw, "ignore PTP capability due to lack of " - "rxd advanced layout capability."); - } -- if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B)) -- hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_TQP_TXRX_INDEP_B)) -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 70aed7b..ac74e4d 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -306,22 +306,19 @@ struct hns3_rx_priv_buff_cmd { - #define HNS3_FW_VERSION_BYTE0_M GENMASK(7, 0) - - enum HNS3_CAPS_BITS { -- HNS3_CAPS_UDP_GSO_B, -- HNS3_CAPS_ATR_B, -- HNS3_CAPS_FD_QUEUE_REGION_B, -+ /* -+ * The following capability index definitions must be the same as those -+ * of the firmware. -+ */ -+ HNS3_CAPS_FD_QUEUE_REGION_B = 2, - HNS3_CAPS_PTP_B, -- HNS3_CAPS_INT_QL_B, -- HNS3_CAPS_SIMPLE_BD_B, -- HNS3_CAPS_TX_PUSH_B, -- HNS3_CAPS_PHY_IMP_B, -+ HNS3_CAPS_PHY_IMP_B = 7, - HNS3_CAPS_TQP_TXRX_INDEP_B, - HNS3_CAPS_HW_PAD_B, - HNS3_CAPS_STASH_B, - HNS3_CAPS_UDP_TUNNEL_CSUM_B, - HNS3_CAPS_RAS_IMP_B, -- HNS3_CAPS_FEC_B, -- HNS3_CAPS_PAUSE_B, -- HNS3_CAPS_RXD_ADV_LAYOUT_B, -+ HNS3_CAPS_RXD_ADV_LAYOUT_B = 15, - }; - - enum HNS3_API_CAP_BITS { -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index b65fb39..a57b20f 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -858,17 +858,17 @@ enum { - - #define HNS3_DEVARG_DEV_CAPS_MASK "dev_caps_mask" - --#define HNS3_DEV_SUPPORT_DCB_B 0x0 --#define HNS3_DEV_SUPPORT_COPPER_B 0x1 --#define HNS3_DEV_SUPPORT_UDP_GSO_B 0x2 --#define HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B 0x3 --#define HNS3_DEV_SUPPORT_PTP_B 0x4 --#define HNS3_DEV_SUPPORT_TX_PUSH_B 0x5 --#define HNS3_DEV_SUPPORT_INDEP_TXRX_B 0x6 --#define HNS3_DEV_SUPPORT_STASH_B 0x7 --#define HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B 0x9 --#define HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B 0xA --#define HNS3_DEV_SUPPORT_RAS_IMP_B 0xB -+enum { -+ HNS3_DEV_SUPPORT_DCB_B, -+ HNS3_DEV_SUPPORT_COPPER_B, -+ HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, -+ HNS3_DEV_SUPPORT_PTP_B, -+ HNS3_DEV_SUPPORT_INDEP_TXRX_B, -+ HNS3_DEV_SUPPORT_STASH_B, -+ HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, -+ HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, -+ HNS3_DEV_SUPPORT_RAS_IMP_B, -+}; - - #define hns3_dev_dcb_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B) -@@ -877,10 +877,6 @@ enum { - #define hns3_dev_copper_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_COPPER_B) - --/* Support UDP GSO offload */ --#define hns3_dev_udp_gso_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_UDP_GSO_B) -- - /* Support the queue region action rule of flow directory */ - #define hns3_dev_fd_queue_region_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B) -@@ -889,9 +885,6 @@ enum { - #define hns3_dev_ptp_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_PTP_B) - --#define hns3_dev_tx_push_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TX_PUSH_B) -- - /* Support to Independently enable/disable/reset Tx or Rx queues */ - #define hns3_dev_indep_txrx_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_INDEP_TXRX_B) --- -2.7.4 - diff --git a/0147-net-hns3-refactor-optimised-register-write.patch b/0147-net-hns3-refactor-optimised-register-write.patch deleted file mode 100644 index b3a0390..0000000 --- a/0147-net-hns3-refactor-optimised-register-write.patch +++ /dev/null @@ -1,39 +0,0 @@ -From b1c34695f2af22dfea670f424d35eb4d65376678 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 14:28:46 +0800 -Subject: [PATCH 147/189] net/hns3: refactor optimised register write - -This patch modifies hns3_write_reg_opt() API implementation because -the rte_write32() already uses rte_io_wmb(). - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index a57b20f..091512e 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -980,13 +980,13 @@ static inline void hns3_write_reg(void *base, uint32_t reg, uint32_t value) - } - - /* -- * The optimized function for writing registers used in the '.rx_pkt_burst' and -- * '.tx_pkt_burst' ops implementation function. -+ * The optimized function for writing registers reduces one address addition -+ * calculation, it was used in the '.rx_pkt_burst' and '.tx_pkt_burst' ops -+ * implementation function. - */ - static inline void hns3_write_reg_opt(volatile void *addr, uint32_t value) - { -- rte_io_wmb(); -- rte_write32_relaxed(rte_cpu_to_le_32(value), addr); -+ rte_write32(rte_cpu_to_le_32(value), addr); - } - - static inline uint32_t hns3_read_reg(void *base, uint32_t reg) --- -2.7.4 - diff --git a/0148-net-hns3-use-existing-macro-to-get-array-size.patch b/0148-net-hns3-use-existing-macro-to-get-array-size.patch deleted file mode 100644 index d137cb5..0000000 --- a/0148-net-hns3-use-existing-macro-to-get-array-size.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 89b2b315c94308c77bdd662fa564c9d4a43bd647 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 14:28:47 +0800 -Subject: [PATCH 148/189] net/hns3: use existing macro to get array size - -This patch uses RTE_DIM() instead of ARRAY_SIZE(). - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 4 ++-- - drivers/net/hns3/hns3_ethdev.h | 2 -- - drivers/net/hns3/hns3_flow.c | 18 +++++++++--------- - drivers/net/hns3/hns3_intr.c | 4 ++-- - 4 files changed, 13 insertions(+), 15 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index a43385b..5f4d74d 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -245,7 +245,7 @@ hns3_is_special_opcode(uint16_t opcode) - HNS3_OPC_QUERY_ALL_ERR_INFO,}; - uint32_t i; - -- for (i = 0; i < ARRAY_SIZE(spec_opcode); i++) -+ for (i = 0; i < RTE_DIM(spec_opcode); i++) - if (spec_opcode[i] == opcode) - return true; - -@@ -276,7 +276,7 @@ hns3_cmd_convert_err_code(uint16_t desc_ret) - - uint32_t i; - -- for (i = 0; i < ARRAY_SIZE(hns3_cmdq_status); i++) -+ for (i = 0; i < RTE_DIM(hns3_cmdq_status); i++) - if (hns3_cmdq_status[i].imp_errcode == desc_ret) - return hns3_cmdq_status[i].linux_errcode; - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 091512e..00fedf0 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1001,8 +1001,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) - #define hns3_read_dev(a, reg) \ - hns3_read_reg((a)->io_base, (reg)) - --#define ARRAY_SIZE(x) RTE_DIM(x) -- - #define NEXT_ITEM_OF_ACTION(act, actions, index) \ - do { \ - act = (actions) + (index); \ -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index c07929f..1513992 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1054,37 +1054,37 @@ hns3_parse_normal(const struct rte_flow_item *item, struct hns3_fdir_rule *rule, - case RTE_FLOW_ITEM_TYPE_ETH: - ret = hns3_parse_eth(item, rule, error); - step_mngr->items = L2_next_items; -- step_mngr->count = ARRAY_SIZE(L2_next_items); -+ step_mngr->count = RTE_DIM(L2_next_items); - break; - case RTE_FLOW_ITEM_TYPE_VLAN: - ret = hns3_parse_vlan(item, rule, error); - step_mngr->items = L2_next_items; -- step_mngr->count = ARRAY_SIZE(L2_next_items); -+ step_mngr->count = RTE_DIM(L2_next_items); - break; - case RTE_FLOW_ITEM_TYPE_IPV4: - ret = hns3_parse_ipv4(item, rule, error); - step_mngr->items = L3_next_items; -- step_mngr->count = ARRAY_SIZE(L3_next_items); -+ step_mngr->count = RTE_DIM(L3_next_items); - break; - case RTE_FLOW_ITEM_TYPE_IPV6: - ret = hns3_parse_ipv6(item, rule, error); - step_mngr->items = L3_next_items; -- step_mngr->count = ARRAY_SIZE(L3_next_items); -+ step_mngr->count = RTE_DIM(L3_next_items); - break; - case RTE_FLOW_ITEM_TYPE_TCP: - ret = hns3_parse_tcp(item, rule, error); - step_mngr->items = L4_next_items; -- step_mngr->count = ARRAY_SIZE(L4_next_items); -+ step_mngr->count = RTE_DIM(L4_next_items); - break; - case RTE_FLOW_ITEM_TYPE_UDP: - ret = hns3_parse_udp(item, rule, error); - step_mngr->items = L4_next_items; -- step_mngr->count = ARRAY_SIZE(L4_next_items); -+ step_mngr->count = RTE_DIM(L4_next_items); - break; - case RTE_FLOW_ITEM_TYPE_SCTP: - ret = hns3_parse_sctp(item, rule, error); - step_mngr->items = L4_next_items; -- step_mngr->count = ARRAY_SIZE(L4_next_items); -+ step_mngr->count = RTE_DIM(L4_next_items); - break; - default: - return rte_flow_error_set(error, ENOTSUP, -@@ -1188,7 +1188,7 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, - "Fdir not supported in VF"); - - step_mngr.items = first_items; -- step_mngr.count = ARRAY_SIZE(first_items); -+ step_mngr.count = RTE_DIM(first_items); - for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { - if (item->type == RTE_FLOW_ITEM_TYPE_VOID) - continue; -@@ -1202,7 +1202,7 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, - if (ret) - return ret; - step_mngr.items = tunnel_next_items; -- step_mngr.count = ARRAY_SIZE(tunnel_next_items); -+ step_mngr.count = RTE_DIM(tunnel_next_items); - } else { - ret = hns3_parse_normal(item, rule, &step_mngr, error); - if (ret) -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 482541b..e216788 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2206,8 +2206,8 @@ hns3_handle_type_reg_error_data(struct hns3_hw *hw, - type_id = err_info->type_id & HNS3_ERR_TYPE_MASK; - is_ras = err_info->type_id >> HNS3_ERR_TYPE_IS_RAS_OFFSET; - -- total_module = ARRAY_SIZE(hns3_hw_module_name); -- total_type = ARRAY_SIZE(hns3_hw_error_type); -+ total_module = RTE_DIM(hns3_hw_module_name); -+ total_type = RTE_DIM(hns3_hw_error_type); - - hns3_err(hw, "total_module:%u, total_type:%u", - total_module, total_type); --- -2.7.4 - diff --git a/0149-net-hns3-improve-IO-path-data-cache-usage.patch b/0149-net-hns3-improve-IO-path-data-cache-usage.patch deleted file mode 100644 index 4b8d033..0000000 --- a/0149-net-hns3-improve-IO-path-data-cache-usage.patch +++ /dev/null @@ -1,259 +0,0 @@ -From 73fce35c11863c8cccc5444f054e5820f303e9bd Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 14:28:48 +0800 -Subject: [PATCH 149/189] net/hns3: improve IO path data cache usage - -This patch improves data cache usage by: -1. Rearrange the rxq frequency accessed fields in the IO path to the - first 128B. -2. Rearrange the txq frequency accessed fields in the IO path to the - first 64B. -3. Make sure ptype table align cacheline size which is 128B instead of - min cacheline size which is 64B because the L1/L2 is 64B and L3 is - 128B on Kunpeng ARM platform. - -The performance gains are 1.5% in 64B packet macfwd scenarios. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 4 +- - drivers/net/hns3/hns3_rxtx.h | 126 ++++++++++++++++++++++++----------------- - 2 files changed, 77 insertions(+), 53 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 00fedf0..c70950a 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -738,7 +738,7 @@ struct hns3_ptype_table { - * descriptor, it functions only when firmware report the capability of - * HNS3_CAPS_RXD_ADV_LAYOUT_B and driver enabled it. - */ -- uint32_t ptype[HNS3_PTYPE_NUM] __rte_cache_min_aligned; -+ uint32_t ptype[HNS3_PTYPE_NUM] __rte_cache_aligned; - }; - - #define HNS3_FIXED_MAX_TQP_NUM_MODE 0 -@@ -842,7 +842,7 @@ struct hns3_adapter { - - uint64_t dev_caps_mask; - -- struct hns3_ptype_table ptype_tbl __rte_cache_min_aligned; -+ struct hns3_ptype_table ptype_tbl __rte_cache_aligned; - }; - - enum { -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 92f01ed..811be96 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -289,22 +289,14 @@ struct hns3_rx_bd_errors_stats { - }; - - struct hns3_rx_queue { -- void *io_base; - volatile void *io_head_reg; -- struct hns3_adapter *hns; - struct hns3_ptype_table *ptype_tbl; - struct rte_mempool *mb_pool; - struct hns3_desc *rx_ring; -- uint64_t rx_ring_phys_addr; /* RX ring DMA address */ -- const struct rte_memzone *mz; - struct hns3_entry *sw_ring; -- struct rte_mbuf *pkt_first_seg; -- struct rte_mbuf *pkt_last_seg; - -- uint16_t queue_id; - uint16_t port_id; - uint16_t nb_rx_desc; -- uint16_t rx_buf_len; - /* - * threshold for the number of BDs waited to passed to hardware. If the - * number exceeds the threshold, driver will pass these BDs to hardware. -@@ -318,8 +310,6 @@ struct hns3_rx_queue { - /* 4 if DEV_RX_OFFLOAD_KEEP_CRC offload set, 0 otherwise */ - uint8_t crc_len; - -- bool rx_deferred_start; /* don't start this queue in dev start */ -- bool configured; /* indicate if rx queue has been configured */ - /* - * Indicate whether ignore the outer VLAN field in the Rx BD reported - * by the Hardware. Because the outer VLAN is the PVID if the PVID is -@@ -331,23 +321,45 @@ struct hns3_rx_queue { - * driver does not need to perform PVID-related operation in Rx. At this - * point, the pvid_sw_discard_en will be false. - */ -- bool pvid_sw_discard_en; -- bool ptype_en; /* indicate if the ptype field enabled */ -- bool enabled; /* indicate if Rx queue has been enabled */ -+ uint8_t pvid_sw_discard_en:1; -+ uint8_t ptype_en:1; /* indicate if the ptype field enabled */ -+ -+ uint64_t mbuf_initializer; /* value to init mbufs used with vector rx */ -+ /* offset_table: used for vector, to solve execute re-order problem */ -+ uint8_t offset_table[HNS3_VECTOR_RX_OFFSET_TABLE_LEN + 1]; -+ -+ uint16_t bulk_mbuf_num; /* indicate bulk_mbuf valid nums */ - - struct hns3_rx_basic_stats basic_stats; -+ -+ struct rte_mbuf *pkt_first_seg; -+ struct rte_mbuf *pkt_last_seg; -+ -+ struct rte_mbuf *bulk_mbuf[HNS3_BULK_ALLOC_MBUF_NUM]; -+ - /* DFX statistics that driver does not need to discard packets */ - struct hns3_rx_dfx_stats dfx_stats; - /* Error statistics that driver needs to discard packets */ - struct hns3_rx_bd_errors_stats err_stats; - -- struct rte_mbuf *bulk_mbuf[HNS3_BULK_ALLOC_MBUF_NUM]; -- uint16_t bulk_mbuf_num; -- -- /* offset_table: used for vector, to solve execute re-order problem */ -- uint8_t offset_table[HNS3_VECTOR_RX_OFFSET_TABLE_LEN + 1]; -- uint64_t mbuf_initializer; /* value to init mbufs used with vector rx */ - struct rte_mbuf fake_mbuf; /* fake mbuf used with vector rx */ -+ -+ -+ /* -+ * The following fields are not accessed in the I/O path, so they are -+ * placed at the end. -+ */ -+ void *io_base; -+ struct hns3_adapter *hns; -+ uint64_t rx_ring_phys_addr; /* RX ring DMA address */ -+ const struct rte_memzone *mz; -+ -+ uint16_t queue_id; -+ uint16_t rx_buf_len; -+ -+ bool configured; /* indicate if rx queue has been configured */ -+ bool rx_deferred_start; /* don't start this queue in dev start */ -+ bool enabled; /* indicate if Rx queue has been enabled */ - }; - - struct hns3_tx_basic_stats { -@@ -407,16 +419,10 @@ struct hns3_tx_dfx_stats { - }; - - struct hns3_tx_queue { -- void *io_base; - volatile void *io_tail_reg; -- struct hns3_adapter *hns; - struct hns3_desc *tx_ring; -- uint64_t tx_ring_phys_addr; /* TX ring DMA address */ -- const struct rte_memzone *mz; - struct hns3_entry *sw_ring; - -- uint16_t queue_id; -- uint16_t port_id; - uint16_t nb_tx_desc; - /* - * index of next BD whose corresponding rte_mbuf can be released by -@@ -432,21 +438,12 @@ struct hns3_tx_queue { - uint16_t tx_free_thresh; - - /* -- * For better performance in tx datapath, releasing mbuf in batches is -- * required. -- * Only checking the VLD bit of the last descriptor in a batch of the -- * thresh descriptors does not mean that these descriptors are all sent -- * by hardware successfully. So we need to check that the VLD bits of -- * all descriptors are cleared. and then free all mbufs in the batch. -- * - tx_rs_thresh -- * Number of mbufs released at a time. -- * -- * - free -- * Tx mbuf free array used for preserving temporarily address of mbuf -- * released back to mempool, when releasing mbuf in batches. -+ * The minimum length of the packet supported by hardware in the Tx -+ * direction. - */ -- uint16_t tx_rs_thresh; -- struct rte_mbuf **free; -+ uint8_t min_tx_pkt_len; -+ -+ uint8_t max_non_tso_bd_num; /* max BD number of one non-TSO packet */ - - /* - * tso mode. -@@ -464,7 +461,7 @@ struct hns3_tx_queue { - * checksum of packets that need TSO, so network driver software - * not need to recalculate it. - */ -- uint8_t tso_mode; -+ uint16_t tso_mode:1; - /* - * udp checksum mode. - * value range: -@@ -480,16 +477,10 @@ struct hns3_tx_queue { - * In this mode, HW does not have the preceding problems and can - * directly calculate the checksum of these UDP packets. - */ -- uint8_t udp_cksum_mode; -- /* -- * The minimum length of the packet supported by hardware in the Tx -- * direction. -- */ -- uint32_t min_tx_pkt_len; -+ uint16_t udp_cksum_mode:1; - -- uint8_t max_non_tso_bd_num; /* max BD number of one non-TSO packet */ -- bool tx_deferred_start; /* don't start this queue in dev start */ -- bool configured; /* indicate if tx queue has been configured */ -+ uint16_t simple_bd_enable:1; -+ uint16_t tx_push_enable:1; /* check whether the tx push is enabled */ - /* - * Indicate whether add the vlan_tci of the mbuf to the inner VLAN field - * of Tx BD. Because the outer VLAN will always be the PVID when the -@@ -502,11 +493,44 @@ struct hns3_tx_queue { - * PVID-related operations in Tx. And pvid_sw_shift_en will be false at - * this point. - */ -- bool pvid_sw_shift_en; -- bool enabled; /* indicate if Tx queue has been enabled */ -+ uint16_t pvid_sw_shift_en:1; -+ -+ /* -+ * For better performance in tx datapath, releasing mbuf in batches is -+ * required. -+ * Only checking the VLD bit of the last descriptor in a batch of the -+ * thresh descriptors does not mean that these descriptors are all sent -+ * by hardware successfully. So we need to check that the VLD bits of -+ * all descriptors are cleared. and then free all mbufs in the batch. -+ * - tx_rs_thresh -+ * Number of mbufs released at a time. -+ * -+ * - free -+ * Tx mbuf free array used for preserving temporarily address of mbuf -+ * released back to mempool, when releasing mbuf in batches. -+ */ -+ uint16_t tx_rs_thresh; -+ struct rte_mbuf **free; - - struct hns3_tx_basic_stats basic_stats; - struct hns3_tx_dfx_stats dfx_stats; -+ -+ -+ /* -+ * The following fields are not accessed in the I/O path, so they are -+ * placed at the end. -+ */ -+ void *io_base; -+ struct hns3_adapter *hns; -+ uint64_t tx_ring_phys_addr; /* TX ring DMA address */ -+ const struct rte_memzone *mz; -+ -+ uint16_t port_id; -+ uint16_t queue_id; -+ -+ bool configured; /* indicate if tx queue has been configured */ -+ bool tx_deferred_start; /* don't start this queue in dev start */ -+ bool enabled; /* indicate if Tx queue has been enabled */ - }; - - #define HNS3_GET_TX_QUEUE_PEND_BD_NUM(txq) \ --- -2.7.4 - diff --git a/0150-net-hns3-log-flow-director-configuration.patch b/0150-net-hns3-log-flow-director-configuration.patch deleted file mode 100644 index dc5d53e..0000000 --- a/0150-net-hns3-log-flow-director-configuration.patch +++ /dev/null @@ -1,63 +0,0 @@ -From e1dc71a6850185aef917b37495c41a6da8017cee Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 14:28:49 +0800 -Subject: [PATCH 150/189] net/hns3: log flow director configuration - -The rte flow interface does not support the API of the capability -set. Therefore, fdir configuration logs are added to facilitate -debugging. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_fdir.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c -index 06c9a94..06dd51b 100644 ---- a/drivers/net/hns3/hns3_fdir.c -+++ b/drivers/net/hns3/hns3_fdir.c -@@ -336,6 +336,8 @@ int hns3_init_fd_config(struct hns3_adapter *hns) - BIT(INNER_IP_PROTO) | BIT(INNER_IP_TOS) | - BIT(INNER_SRC_IP) | BIT(INNER_DST_IP) | - BIT(INNER_SRC_PORT) | BIT(INNER_DST_PORT); -+ hns3_dbg(hw, "fdir tuple: inner"); - - /* If use max 400bit key, we can support tuples for ether type */ - if (pf->fdir.fd_cfg.max_key_length == MAX_KEY_LENGTH) { -@@ -345,6 +347,9 @@ int hns3_init_fd_config(struct hns3_adapter *hns) - BIT(OUTER_DST_PORT) | BIT(INNER_VLAN_TAG2) | - BIT(OUTER_TUN_VNI) | BIT(OUTER_TUN_FLOW_ID) | - BIT(OUTER_ETH_TYPE) | BIT(OUTER_IP_PROTO); -+ hns3_dbg(hw, "fdir tuple more: inner outer"); - } - - /* roce_type is used to filter roce frames -@@ -352,6 +357,7 @@ int hns3_init_fd_config(struct hns3_adapter *hns) - */ - key_cfg->meta_data_active = BIT(DST_VPORT) | BIT(TUNNEL_PACKET) | - BIT(VLAN_NUMBER); -+ hns3_dbg(hw, "fdir meta data: dst_vport tunnel_packet vlan_number"); - - ret = hns3_get_fd_allocation(hw, - &pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], -@@ -361,6 +367,13 @@ int hns3_init_fd_config(struct hns3_adapter *hns) - if (ret) - return ret; - -+ hns3_dbg(hw, "fdir: stage1 stage2", -+ pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_1], -+ pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_1], -+ pf->fdir.fd_cfg.rule_num[HNS3_FD_STAGE_2], -+ pf->fdir.fd_cfg.cnt_num[HNS3_FD_STAGE_2]); -+ - return hns3_set_fd_key_config(hns); - } - --- -2.7.4 - diff --git a/0151-net-hns3-fix-vector-Rx-burst-limitation.patch b/0151-net-hns3-fix-vector-Rx-burst-limitation.patch deleted file mode 100644 index e59039c..0000000 --- a/0151-net-hns3-fix-vector-Rx-burst-limitation.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 2cd4eb1717633e841cb1e20ba123a20adf550638 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 14:28:50 +0800 -Subject: [PATCH 151/189] net/hns3: fix vector Rx burst limitation - -Currently, driver uses the macro HNS3_DEFAULT_RX_BURST whose value is -32 to limit the vector Rx burst size, as a result, the burst size -can't exceed 32. - -This patch fixes this problem by support big burst size. -Also adjust HNS3_DEFAULT_RX_BURST to 64 as it performs better than 32. - -Fixes: a3d4f4d291d7 ("net/hns3: support NEON Rx") -Fixes: 952ebacce4f2 ("net/hns3: support SVE Rx") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.h | 2 +- - drivers/net/hns3/hns3_rxtx_vec.c | 36 ++++++++++++++++++++++++++++-------- - drivers/net/hns3/hns3_rxtx_vec.h | 3 +++ - drivers/net/hns3/hns3_rxtx_vec_sve.c | 32 ++++++++++++++++++++++++++------ - 4 files changed, 58 insertions(+), 15 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 811be96..a42ab71 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -20,7 +20,7 @@ - #define HNS3_DEFAULT_TX_RS_THRESH 32 - #define HNS3_TX_FAST_FREE_AHEAD 64 - --#define HNS3_DEFAULT_RX_BURST 32 -+#define HNS3_DEFAULT_RX_BURST 64 - #if (HNS3_DEFAULT_RX_BURST > 64) - #error "PMD HNS3: HNS3_DEFAULT_RX_BURST must <= 64\n" - #endif -diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c -index d6636df..5fdc1d5 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.c -+++ b/drivers/net/hns3/hns3_rxtx_vec.c -@@ -108,14 +108,13 @@ hns3_recv_pkts_vec(void *__restrict rx_queue, - { - struct hns3_rx_queue *rxq = rx_queue; - struct hns3_desc *rxdp = &rxq->rx_ring[rxq->next_to_use]; -- uint64_t bd_err_mask; /* bit mask indicate whick pkts is error */ -+ uint64_t pkt_err_mask; /* bit mask indicate whick pkts is error */ - uint16_t nb_rx; - -- nb_pkts = RTE_MIN(nb_pkts, HNS3_DEFAULT_RX_BURST); -- nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, HNS3_DEFAULT_DESCS_PER_LOOP); -- - rte_prefetch_non_temporal(rxdp); - -+ nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, HNS3_DEFAULT_DESCS_PER_LOOP); -+ - if (rxq->rx_rearm_nb > HNS3_DEFAULT_RXQ_REARM_THRESH) - hns3_rxq_rearm_mbuf(rxq); - -@@ -128,10 +127,31 @@ hns3_recv_pkts_vec(void *__restrict rx_queue, - rte_prefetch0(rxq->sw_ring[rxq->next_to_use + 2].mbuf); - rte_prefetch0(rxq->sw_ring[rxq->next_to_use + 3].mbuf); - -- bd_err_mask = 0; -- nb_rx = hns3_recv_burst_vec(rxq, rx_pkts, nb_pkts, &bd_err_mask); -- if (unlikely(bd_err_mask)) -- nb_rx = hns3_rx_reassemble_pkts(rx_pkts, nb_rx, bd_err_mask); -+ if (likely(nb_pkts <= HNS3_DEFAULT_RX_BURST)) { -+ pkt_err_mask = 0; -+ nb_rx = hns3_recv_burst_vec(rxq, rx_pkts, nb_pkts, -+ &pkt_err_mask); -+ nb_rx = hns3_rx_reassemble_pkts(rx_pkts, nb_rx, pkt_err_mask); -+ return nb_rx; -+ } -+ -+ nb_rx = 0; -+ while (nb_pkts > 0) { -+ uint16_t ret, n; -+ -+ n = RTE_MIN(nb_pkts, HNS3_DEFAULT_RX_BURST); -+ pkt_err_mask = 0; -+ ret = hns3_recv_burst_vec(rxq, &rx_pkts[nb_rx], n, -+ &pkt_err_mask); -+ nb_pkts -= ret; -+ nb_rx += hns3_rx_reassemble_pkts(&rx_pkts[nb_rx], ret, -+ pkt_err_mask); -+ if (ret < n) -+ break; -+ -+ if (rxq->rx_rearm_nb > HNS3_DEFAULT_RXQ_REARM_THRESH) -+ hns3_rxq_rearm_mbuf(rxq); -+ } - - return nb_rx; - } -diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h -index 35d9903..872ba22 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.h -+++ b/drivers/net/hns3/hns3_rxtx_vec.h -@@ -71,6 +71,9 @@ hns3_rx_reassemble_pkts(struct rte_mbuf **rx_pkts, - uint16_t count, i; - uint64_t mask; - -+ if (likely(pkt_err_mask == 0)) -+ return nb_pkts; -+ - count = 0; - for (i = 0; i < nb_pkts; i++) { - mask = ((uint64_t)1u) << i; -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index e15fd7a..be9a4ff 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -292,12 +292,11 @@ hns3_recv_pkts_vec_sve(void *__restrict rx_queue, - { - struct hns3_rx_queue *rxq = rx_queue; - struct hns3_desc *rxdp = &rxq->rx_ring[rxq->next_to_use]; -- uint64_t bd_err_mask; /* bit mask indicate whick pkts is error */ -+ uint64_t pkt_err_mask; /* bit mask indicate whick pkts is error */ - uint16_t nb_rx; - - rte_prefetch_non_temporal(rxdp); - -- nb_pkts = RTE_MIN(nb_pkts, HNS3_DEFAULT_RX_BURST); - nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, HNS3_SVE_DEFAULT_DESCS_PER_LOOP); - - if (rxq->rx_rearm_nb > HNS3_DEFAULT_RXQ_REARM_THRESH) -@@ -309,10 +308,31 @@ hns3_recv_pkts_vec_sve(void *__restrict rx_queue, - - hns3_rx_prefetch_mbuf_sve(&rxq->sw_ring[rxq->next_to_use]); - -- bd_err_mask = 0; -- nb_rx = hns3_recv_burst_vec_sve(rxq, rx_pkts, nb_pkts, &bd_err_mask); -- if (unlikely(bd_err_mask)) -- nb_rx = hns3_rx_reassemble_pkts(rx_pkts, nb_rx, bd_err_mask); -+ if (likely(nb_pkts <= HNS3_DEFAULT_RX_BURST)) { -+ pkt_err_mask = 0; -+ nb_rx = hns3_recv_burst_vec_sve(rxq, rx_pkts, nb_pkts, -+ &pkt_err_mask); -+ nb_rx = hns3_rx_reassemble_pkts(rx_pkts, nb_rx, pkt_err_mask); -+ return nb_rx; -+ } -+ -+ nb_rx = 0; -+ while (nb_pkts > 0) { -+ uint16_t ret, n; -+ -+ n = RTE_MIN(nb_pkts, HNS3_DEFAULT_RX_BURST); -+ pkt_err_mask = 0; -+ ret = hns3_recv_burst_vec_sve(rxq, &rx_pkts[nb_rx], n, -+ &pkt_err_mask); -+ nb_pkts -= ret; -+ nb_rx += hns3_rx_reassemble_pkts(&rx_pkts[nb_rx], ret, -+ pkt_err_mask); -+ if (ret < n) -+ break; -+ -+ if (rxq->rx_rearm_nb > HNS3_DEFAULT_RXQ_REARM_THRESH) -+ hns3_rxq_rearm_mbuf_sve(rxq); -+ } - - return nb_rx; - } --- -2.7.4 - diff --git a/0152-net-hns3-remove-read-when-enabling-TM-QCN-error-even.patch b/0152-net-hns3-remove-read-when-enabling-TM-QCN-error-even.patch deleted file mode 100644 index ef7023a..0000000 --- a/0152-net-hns3-remove-read-when-enabling-TM-QCN-error-even.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 44d86d6218b9da9d8218a629011ddd432a27a67c Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 17:04:02 +0800 -Subject: [PATCH 152/189] net/hns3: remove read when enabling TM QCN error - event - -According to the HW manual, the read operation is unnecessary when -enabling TM QCN error event, so remove it. - -Fixes: f53a793bb7c2 ("net/hns3: add more hardware error types") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_intr.c | 9 +-------- - 1 file changed, 1 insertion(+), 8 deletions(-) - -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index e216788..87afce2 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1782,14 +1782,7 @@ enable_tm_err_intr(struct hns3_adapter *hns, bool en) - } - - /* configure TM QCN hw errors */ -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_TM_QCN_MEM_INT_CFG, true); -- ret = hns3_cmd_send(hw, &desc, 1); -- if (ret) { -- hns3_err(hw, "fail to read TM QCN CFG status, ret = %d\n", ret); -- return ret; -- } -- -- hns3_cmd_reuse_desc(&desc, false); -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_TM_QCN_MEM_INT_CFG, false); - if (en) - desc.data[1] = rte_cpu_to_le_32(HNS3_TM_QCN_MEM_ERR_INT_EN); - --- -2.7.4 - diff --git a/0153-net-hns3-remove-unused-VMDq-code.patch b/0153-net-hns3-remove-unused-VMDq-code.patch deleted file mode 100644 index 91e8b18..0000000 --- a/0153-net-hns3-remove-unused-VMDq-code.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 4a924045f23a81a07b59233f7bc12c1e38daa234 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 17:04:03 +0800 -Subject: [PATCH 153/189] net/hns3: remove unused VMDq code - -VMDq is not supported yet, so remove the unused code. - -Fixes: d51867db65c1 ("net/hns3: add initialization") -Fixes: 1265b5372d9d ("net/hns3: add some definitions for data structure and macro") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 2 -- - drivers/net/hns3/hns3_ethdev.c | 4 ---- - drivers/net/hns3/hns3_ethdev.h | 1 - - drivers/net/hns3/hns3_ethdev_vf.c | 2 -- - 4 files changed, 9 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index ac74e4d..a249a7a 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -457,8 +457,6 @@ struct hns3_umv_spc_alc_cmd { - #define HNS3_CFG_RD_LEN_BYTES 16 - #define HNS3_CFG_RD_LEN_UNIT 4 - --#define HNS3_CFG_VMDQ_S 0 --#define HNS3_CFG_VMDQ_M GENMASK(7, 0) - #define HNS3_CFG_TC_NUM_S 8 - #define HNS3_CFG_TC_NUM_M GENMASK(15, 8) - #define HNS3_CFG_TQP_DESC_N_S 16 -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f5160ed..44e6c5b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2791,8 +2791,6 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - .offloads = 0, - }; - -- info->vmdq_queue_num = 0; -- - info->reta_size = hw->rss_ind_tbl_size; - info->hash_key_size = HNS3_RSS_KEY_SIZE; - info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; -@@ -3072,8 +3070,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) - req = (struct hns3_cfg_param_cmd *)desc[0].data; - - /* get the configuration */ -- cfg->vmdq_vport_num = hns3_get_field(rte_le_to_cpu_32(req->param[0]), -- HNS3_CFG_VMDQ_M, HNS3_CFG_VMDQ_S); - cfg->tc_num = hns3_get_field(rte_le_to_cpu_32(req->param[0]), - HNS3_CFG_TC_NUM_M, HNS3_CFG_TC_NUM_S); - cfg->tqp_desc_num = hns3_get_field(rte_le_to_cpu_32(req->param[0]), -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index c70950a..53dc498 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -155,7 +155,6 @@ struct hns3_tc_queue_info { - }; - - struct hns3_cfg { -- uint8_t vmdq_vport_num; - uint8_t tc_num; - uint16_t tqp_desc_num; - uint16_t rx_buf_len; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index f4d2a9f..c4419fb 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1022,8 +1022,6 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - .offloads = 0, - }; - -- info->vmdq_queue_num = 0; -- - info->reta_size = hw->rss_ind_tbl_size; - info->hash_key_size = HNS3_RSS_KEY_SIZE; - info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; --- -2.7.4 - diff --git a/0154-net-hns3-increase-readability-in-logs.patch b/0154-net-hns3-increase-readability-in-logs.patch deleted file mode 100644 index 7a0ec42..0000000 --- a/0154-net-hns3-increase-readability-in-logs.patch +++ /dev/null @@ -1,131 +0,0 @@ -From c693525d0f4a24e9717d80d13a9690ae1b4dc01d Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 30 Apr 2021 17:04:04 +0800 -Subject: [PATCH 154/189] net/hns3: increase readability in logs - -Some logs format u64 variables, mostly using hexadecimal which was not -readable. -This patch formats most u64 variables in decimal, and add '0x' prefix -to the ones that are not adjusted. - -Fixes: c37ca66f2b27 ("net/hns3: support RSS") -Fixes: 2790c6464725 ("net/hns3: support device reset") -Fixes: 8839c5e202f3 ("net/hns3: support device stats") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_flow.c | 2 +- - drivers/net/hns3/hns3_intr.c | 20 ++++++++++---------- - drivers/net/hns3/hns3_stats.c | 8 ++++---- - 3 files changed, 15 insertions(+), 15 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 1513992..15ecaf4 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1556,7 +1556,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, - hw->rss_info.conf.types; - if (flow_types != rss_flow_conf.types) - hns3_warn(hw, "modified RSS types based on hardware support, " -- "requested:%" PRIx64 " configured:%" PRIx64, -+ "requested:0x%" PRIx64 " configured:0x%" PRIx64, - rss_flow_conf.types, flow_types); - /* Update the useful flow types */ - rss_flow_conf.types = flow_types; -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 87afce2..0140260 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2570,7 +2570,7 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) - if (merge_cnt != hw->reset.stats.merge_cnt) - hns3_warn(hw, - "No need to do low-level reset after %s reset. " -- "merge cnt: %" PRIx64 " total merge cnt: %" PRIx64, -+ "merge cnt: %" PRIu64 " total merge cnt: %" PRIu64, - reset_string[hw->reset.level], - hw->reset.stats.merge_cnt - merge_cnt, - hw->reset.stats.merge_cnt); -@@ -2590,7 +2590,7 @@ hns3_reset_err_handle(struct hns3_adapter *hns) - hw->reset.attempts = 0; - hw->reset.stats.fail_cnt++; - hns3_warn(hw, "%s reset fail because new Reset is pending " -- "attempts:%" PRIx64, -+ "attempts:%" PRIu64, - reset_string[hw->reset.level], - hw->reset.stats.fail_cnt); - hw->reset.level = HNS3_NONE_RESET; -@@ -2617,10 +2617,10 @@ hns3_reset_err_handle(struct hns3_adapter *hns) - reset_fail: - hw->reset.attempts = 0; - hw->reset.stats.fail_cnt++; -- hns3_warn(hw, "%s reset fail fail_cnt:%" PRIx64 " success_cnt:%" PRIx64 -- " global_cnt:%" PRIx64 " imp_cnt:%" PRIx64 -- " request_cnt:%" PRIx64 " exec_cnt:%" PRIx64 -- " merge_cnt:%" PRIx64 "adapter_state:%d", -+ hns3_warn(hw, "%s reset fail fail_cnt:%" PRIu64 " success_cnt:%" PRIu64 -+ " global_cnt:%" PRIu64 " imp_cnt:%" PRIu64 -+ " request_cnt:%" PRIu64 " exec_cnt:%" PRIu64 -+ " merge_cnt:%" PRIu64 "adapter_state:%d", - reset_string[hw->reset.level], hw->reset.stats.fail_cnt, - hw->reset.stats.success_cnt, hw->reset.stats.global_cnt, - hw->reset.stats.imp_cnt, hw->reset.stats.request_cnt, -@@ -2736,10 +2736,10 @@ hns3_reset_post(struct hns3_adapter *hns) - rte_spinlock_unlock(&hw->lock); - hns3_clock_gettime(&tv); - timersub(&tv, &hw->reset.start_time, &tv_delta); -- hns3_warn(hw, "%s reset done fail_cnt:%" PRIx64 -- " success_cnt:%" PRIx64 " global_cnt:%" PRIx64 -- " imp_cnt:%" PRIx64 " request_cnt:%" PRIx64 -- " exec_cnt:%" PRIx64 " merge_cnt:%" PRIx64, -+ hns3_warn(hw, "%s reset done fail_cnt:%" PRIu64 -+ " success_cnt:%" PRIu64 " global_cnt:%" PRIu64 -+ " imp_cnt:%" PRIu64 " request_cnt:%" PRIu64 -+ " exec_cnt:%" PRIu64 " merge_cnt:%" PRIu64, - reset_string[hw->reset.level], - hw->reset.stats.fail_cnt, hw->reset.stats.success_cnt, - hw->reset.stats.global_cnt, hw->reset.stats.imp_cnt, -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 1af689f..464a33d 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -1325,7 +1325,7 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, - len = cnt_stats * sizeof(struct rte_eth_xstat); - values_copy = rte_zmalloc("hns3_xstats_values", len, 0); - if (values_copy == NULL) { -- hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed " -+ hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed " - "to store statistics values", len); - return -ENOMEM; - } -@@ -1347,7 +1347,7 @@ hns3_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, - - for (i = 0; i < size; i++) { - if (ids[i] >= cnt_stats) { -- hns3_err(hw, "ids[%u] (%" PRIx64 ") is invalid, " -+ hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, " - "should < %u", i, ids[i], cnt_stats); - rte_free(values_copy); - return -EINVAL; -@@ -1406,7 +1406,7 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - len = cnt_stats * sizeof(struct rte_eth_xstat_name); - names_copy = rte_zmalloc("hns3_xstats_names", len, 0); - if (names_copy == NULL) { -- hns3_err(hw, "Failed to allocate %" PRIx64 " bytes needed " -+ hns3_err(hw, "Failed to allocate 0x%" PRIx64 " bytes needed " - "to store statistics names", len); - return -ENOMEM; - } -@@ -1415,7 +1415,7 @@ hns3_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, - - for (i = 0; i < size; i++) { - if (ids[i] >= cnt_stats) { -- hns3_err(hw, "ids[%u] (%" PRIx64 ") is invalid, " -+ hns3_err(hw, "ids[%u] (%" PRIu64 ") is invalid, " - "should < %u", i, ids[i], cnt_stats); - rte_free(names_copy); - return -EINVAL; --- -2.7.4 - diff --git a/0155-net-hns3-fix-debug-build.patch b/0155-net-hns3-fix-debug-build.patch deleted file mode 100644 index 858297d..0000000 --- a/0155-net-hns3-fix-debug-build.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 9b2deee4ca9c9e1e8b2249bf2c8d4d606aff3669 Mon Sep 17 00:00:00 2001 -From: Thomas Monjalon -Date: Fri, 7 May 2021 14:14:13 +0200 -Subject: [PATCH 155/189] net/hns3: fix debug build -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The variable "dev" is not used in hns3_get_tx_prep_needed() -in the case of RTE_LIBRTE_ETHDEV_DEBUG: -drivers/net/hns3/hns3_rxtx.c:4213:45: error: unused parameter ‘dev’ - -Fixes: d7ec2c076579 ("net/hns3: select Tx prepare based on Tx offload") -Cc: stable@dpdk.org - -Reported-by: David Marchand -Signed-off-by: Thomas Monjalon -Acked-by: David Marchand ---- - drivers/net/hns3/hns3_rxtx.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index bc4a9a5..6aa2887 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4213,6 +4213,7 @@ static bool - hns3_get_tx_prep_needed(struct rte_eth_dev *dev) - { - #ifdef RTE_LIBRTE_ETHDEV_DEBUG -+ RTE_SET_USED(dev); - /* always perform tx_prepare when debug */ - return true; - #else --- -2.7.4 - diff --git a/0156-net-hns3-return-error-on-PCI-config-write-failure.patch b/0156-net-hns3-return-error-on-PCI-config-write-failure.patch deleted file mode 100644 index 6deb162..0000000 --- a/0156-net-hns3-return-error-on-PCI-config-write-failure.patch +++ /dev/null @@ -1,36 +0,0 @@ -From e04c10fe75d5a5015fdb84387eb952fc1c05301f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 7 May 2021 17:08:14 +0800 -Subject: [PATCH 156/189] net/hns3: return error on PCI config write failure - -This patch returns error code when calling rte_pci_write_config() API. - -Fixes: 6dd32ded17d8 ("net/hns3: check PCI config space write") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev_vf.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index c4419fb..182e83b 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -156,9 +156,12 @@ hns3vf_enable_msix(const struct rte_pci_device *device, bool op) - if (ret < 0) { - PMD_INIT_LOG(ERR, "failed to write PCI offset 0x%x", - (pos + PCI_MSIX_FLAGS)); -+ return -ENXIO; - } -+ - return 0; - } -+ - return -ENXIO; - } - --- -2.7.4 - diff --git a/0157-net-hns3-fix-log-on-flow-director-clear.patch b/0157-net-hns3-fix-log-on-flow-director-clear.patch deleted file mode 100644 index 000c162..0000000 --- a/0157-net-hns3-fix-log-on-flow-director-clear.patch +++ /dev/null @@ -1,65 +0,0 @@ -From f3a62e370e72558eb1fe41b540b9aad7036b9679 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 7 May 2021 17:08:15 +0800 -Subject: [PATCH 157/189] net/hns3: fix log on flow director clear - -If clear FDIR rules fail, the error code was logged, but the error code -was useless because it was the sum of all fail code. - -This patch fixes it by log the success cnt and fail cnt. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Fixes: 8eed8acc812e ("net/hns3: add error code to some logs") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_fdir.c | 18 +++++++++++++----- - 1 file changed, 13 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c -index 06dd51b..e87e064 100644 ---- a/drivers/net/hns3/hns3_fdir.c -+++ b/drivers/net/hns3/hns3_fdir.c -@@ -1026,6 +1026,8 @@ int hns3_clear_all_fdir_filter(struct hns3_adapter *hns) - struct hns3_fdir_info *fdir_info = &pf->fdir; - struct hns3_fdir_rule_ele *fdir_filter; - struct hns3_hw *hw = &hns->hw; -+ int succ_cnt = 0; -+ int fail_cnt = 0; - int ret = 0; - - /* flush flow director */ -@@ -1034,17 +1036,23 @@ int hns3_clear_all_fdir_filter(struct hns3_adapter *hns) - fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list); - while (fdir_filter) { - TAILQ_REMOVE(&fdir_info->fdir_list, fdir_filter, entries); -- ret += hns3_fd_tcam_config(hw, true, -- fdir_filter->fdir_conf.location, -- NULL, false); -+ ret = hns3_fd_tcam_config(hw, true, -+ fdir_filter->fdir_conf.location, -+ NULL, false); -+ if (ret == 0) -+ succ_cnt++; -+ else -+ fail_cnt++; - rte_free(fdir_filter); - fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list); - } - -- if (ret) { -- hns3_err(hw, "Fail to delete FDIR filter, ret = %d", ret); -+ if (fail_cnt > 0) { -+ hns3_err(hw, "fail to delete all FDIR filter, success num = %d " -+ "fail num = %d", succ_cnt, fail_cnt); - ret = -EIO; - } -+ - return ret; - } - --- -2.7.4 - diff --git a/0158-net-hns3-clear-hash-map-on-flow-director-clear.patch b/0158-net-hns3-clear-hash-map-on-flow-director-clear.patch deleted file mode 100644 index 2d6e78b..0000000 --- a/0158-net-hns3-clear-hash-map-on-flow-director-clear.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 72f412363f33c14750b3d5250315f67a06259033 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 7 May 2021 17:08:16 +0800 -Subject: [PATCH 158/189] net/hns3: clear hash map on flow director clear - -The fdir hash map hold the pointers of fdir rule elements, it needs to -be set to NULL when clear all fdir rules. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_fdir.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c -index e87e064..8ab5fd6 100644 ---- a/drivers/net/hns3/hns3_fdir.c -+++ b/drivers/net/hns3/hns3_fdir.c -@@ -1033,6 +1033,10 @@ int hns3_clear_all_fdir_filter(struct hns3_adapter *hns) - /* flush flow director */ - rte_hash_reset(fdir_info->hash_handle); - -+ memset(fdir_info->hash_map, 0, -+ sizeof(struct hns3_fdir_rule_ele *) * -+ fdir_info->fd_cfg.rule_num[HNS3_FD_STAGE_1]); -+ - fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list); - while (fdir_filter) { - TAILQ_REMOVE(&fdir_info->fdir_list, fdir_filter, entries); --- -2.7.4 - diff --git a/0159-net-hns3-fix-VF-alive-notification-after-config-rest.patch b/0159-net-hns3-fix-VF-alive-notification-after-config-rest.patch deleted file mode 100644 index 4020951..0000000 --- a/0159-net-hns3-fix-VF-alive-notification-after-config-rest.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 6950c0629725d5659a0e74960ae7ca71865bf32e Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Fri, 7 May 2021 17:08:17 +0800 -Subject: [PATCH 159/189] net/hns3: fix VF alive notification after config - restore - -Currently in the VF reset scenario, the VF performs the set -alive operation before restoring the configuration completed, -which may cause the hardware to work in an abnormal state. - -This patch fix this problem by set VF alive after restoring -the configuration is completed. - -Fixes: a5475d61fa34 ("net/hns3: support VF") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev_vf.c | 19 +++++++++++++------ - 1 file changed, 13 insertions(+), 6 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 182e83b..dbd823f 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1891,12 +1891,6 @@ hns3vf_init_hardware(struct hns3_adapter *hns) - goto err_init_hardware; - } - -- ret = hns3vf_set_alive(hw, true); -- if (ret) { -- PMD_INIT_LOG(ERR, "Failed to VF send alive to PF: %d", ret); -- goto err_init_hardware; -- } -- - return 0; - - err_init_hardware: -@@ -1995,6 +1989,12 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) - - hns3_rss_set_default_args(hw); - -+ ret = hns3vf_set_alive(hw, true); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "Failed to VF send alive to PF: %d", ret); -+ goto err_set_tc_queue; -+ } -+ - return 0; - - err_set_tc_queue: -@@ -2703,6 +2703,13 @@ hns3vf_restore_conf(struct hns3_adapter *hns) - hns3_info(hw, "hns3vf dev restart successful!"); - } else if (hw->adapter_state == HNS3_NIC_STOPPING) - hw->adapter_state = HNS3_NIC_CONFIGURED; -+ -+ ret = hns3vf_set_alive(hw, true); -+ if (ret) { -+ hns3_err(hw, "failed to VF send alive to PF: %d", ret); -+ goto err_vlan_table; -+ } -+ - return 0; - - err_vlan_table: --- -2.7.4 - diff --git a/0160-net-hns3-fix-querying-flow-director-counter-for-out-.patch b/0160-net-hns3-fix-querying-flow-director-counter-for-out-.patch deleted file mode 100644 index b9fb8c3..0000000 --- a/0160-net-hns3-fix-querying-flow-director-counter-for-out-.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 738c66f157c398ce78f3ba7c25f4e096d755ce7f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 7 May 2021 17:08:18 +0800 -Subject: [PATCH 160/189] net/hns3: fix querying flow director counter for out - param - -The hardware doesn't support counting the number of bytes that through -the fdir rule. Therefore, the corresponding out parameters (e.g. -bytes_set/bytes) is set to zero. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_flow.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 15ecaf4..d405820 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -223,6 +223,8 @@ hns3_counter_query(struct rte_eth_dev *dev, struct rte_flow *flow, - } - qc->hits_set = 1; - qc->hits = value; -+ qc->bytes_set = 0; -+ qc->bytes = 0; - - return 0; - } --- -2.7.4 - diff --git a/0161-net-hns3-fix-TM-QCN-error-event-report-by-MSI-X.patch b/0161-net-hns3-fix-TM-QCN-error-event-report-by-MSI-X.patch deleted file mode 100644 index ab61755..0000000 --- a/0161-net-hns3-fix-TM-QCN-error-event-report-by-MSI-X.patch +++ /dev/null @@ -1,54 +0,0 @@ -From dbeadbf0ac1368fa07822b025a3f1bf10a450b43 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 8 May 2021 15:40:57 +0800 -Subject: [PATCH 161/189] net/hns3: fix TM QCN error event report by MSI-X - -The TM QCN error event should report by RAS other than MSIX. - -Also this patch adds fifo int enable configuration before the TM QCN -error event is enabled. - -Fixes: f53a793bb7c2 ("net/hns3: add more hardware error types") -Fixes: 3903c05382c5 ("net/hns3: remove read when enabling TM QCN error event") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_intr.c | 5 ++++- - drivers/net/hns3/hns3_intr.h | 2 ++ - 2 files changed, 6 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 0140260..854cb1d 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1783,8 +1783,11 @@ enable_tm_err_intr(struct hns3_adapter *hns, bool en) - - /* configure TM QCN hw errors */ - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_TM_QCN_MEM_INT_CFG, false); -- if (en) -+ desc.data[0] = rte_cpu_to_le_32(HNS3_TM_QCN_ERR_INT_TYPE); -+ if (en) { -+ desc.data[0] |= rte_cpu_to_le_32(HNS3_TM_QCN_FIFO_INT_EN); - desc.data[1] = rte_cpu_to_le_32(HNS3_TM_QCN_MEM_ERR_INT_EN); -+ } - - ret = hns3_cmd_send(hw, &desc, 1); - if (ret) -diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h -index a140ca1..4dfc807 100644 ---- a/drivers/net/hns3/hns3_intr.h -+++ b/drivers/net/hns3/hns3_intr.h -@@ -77,6 +77,8 @@ - #define HNS3_NCSI_ERR_INT_EN 0x3 - - #define HNS3_TM_SCH_ECC_ERR_INT_EN 0x3 -+#define HNS3_TM_QCN_ERR_INT_TYPE 0x29 -+#define HNS3_TM_QCN_FIFO_INT_EN 0xFFFF00 - #define HNS3_TM_QCN_MEM_ERR_INT_EN 0xFFFFFF - - #define HNS3_RESET_PROCESS_MS 200 --- -2.7.4 - diff --git a/0162-net-hns3-fix-mailbox-message-ID-in-log.patch b/0162-net-hns3-fix-mailbox-message-ID-in-log.patch deleted file mode 100644 index 6b72250..0000000 --- a/0162-net-hns3-fix-mailbox-message-ID-in-log.patch +++ /dev/null @@ -1,33 +0,0 @@ -From e1cf907216bf8fdb15a94a7c9918b1f6772afebb Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Mon, 10 May 2021 21:38:10 +0800 -Subject: [PATCH 162/189] net/hns3: fix mailbox message ID in log - -The mailbox message id is uint8_t, but the unsupported mailbox message -id was logged by uint16. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 3d019b9..0c2e03b 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -540,7 +540,7 @@ hns3_dev_handle_mbx_msg(struct hns3_hw *hw) - break; - default: - hns3_err(hw, "received unsupported(%u) mbx msg", -- req->msg[0]); -+ opcode); - break; - } - --- -2.7.4 - diff --git a/0163-net-hns3-fix-secondary-process-request-start-stop-Rx.patch b/0163-net-hns3-fix-secondary-process-request-start-stop-Rx.patch deleted file mode 100644 index 12dec23..0000000 --- a/0163-net-hns3-fix-secondary-process-request-start-stop-Rx.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 8f2285bfc5a77da72ddaec4faccfbbdef91cd4a8 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Mon, 10 May 2021 21:38:11 +0800 -Subject: [PATCH 163/189] net/hns3: fix secondary process request start/stop - Rx/Tx - -This secondary process should not send request to start/stop Rx/Tx, -this patch fixes it. - -Fixes: 23d4b61fee5d ("net/hns3: support multiple process") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index ed2567a..7d85de3 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -130,7 +130,7 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum hns3_mp_req_type type) - int ret; - int i; - -- if (!hw->secondary_cnt) -+ if (rte_eal_process_type() == RTE_PROC_SECONDARY || !hw->secondary_cnt) - return; - if (type != HNS3_MP_REQ_START_RXTX && type != HNS3_MP_REQ_STOP_RXTX) { - hns3_err(hw, "port %u unknown request (req_type %d)", --- -2.7.4 - diff --git a/0164-net-hns3-fix-ordering-in-secondary-process-initializ.patch b/0164-net-hns3-fix-ordering-in-secondary-process-initializ.patch deleted file mode 100644 index 44e1183..0000000 --- a/0164-net-hns3-fix-ordering-in-secondary-process-initializ.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0bfe64c5063855fb27785c2f73e98cc8f2893e0b Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Mon, 10 May 2021 21:38:12 +0800 -Subject: [PATCH 164/189] net/hns3: fix ordering in secondary process - initialization - -The memory barrier is used to ensure that the response is returned -only after the Tx/Rx function is set, it should place after the Rx/Tx -function is set. - -Fixes: 23d4b61fee5d ("net/hns3: support multiple process") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mp.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index 7d85de3..b5cd5b0 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -86,8 +86,8 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) - case HNS3_MP_REQ_START_RXTX: - PMD_INIT_LOG(INFO, "port %u starting datapath", - dev->data->port_id); -- rte_mb(); - hns3_set_rxtx_function(dev); -+ rte_mb(); - mp_init_msg(dev, &mp_res, param->type); - res->result = 0; - ret = rte_mp_reply(&mp_res, peer); --- -2.7.4 - diff --git a/0165-net-hns3-fail-setting-FEC-if-one-bit-mode-is-not-sup.patch b/0165-net-hns3-fail-setting-FEC-if-one-bit-mode-is-not-sup.patch deleted file mode 100644 index 09b3d96..0000000 --- a/0165-net-hns3-fail-setting-FEC-if-one-bit-mode-is-not-sup.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 6c80dd7d227149ba1e2a06be8a87a2295e5b2e5f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Mon, 10 May 2021 21:38:13 +0800 -Subject: [PATCH 165/189] net/hns3: fail setting FEC if one bit mode is not - supported - -If the FEC mode was not supported, it should return error code. - -This patch also adds a space when log error info. - -Fixes: 9bf2ea8dbc65 ("net/hns3: support FEC") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 44e6c5b..7ecd15b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6988,9 +6988,11 @@ hns3_fec_set(struct rte_eth_dev *dev, uint32_t mode) - return ret; - - /* HNS3 PMD driver only support one bit set mode, e.g. 0x1, 0x4 */ -- if (!is_fec_mode_one_bit_set(mode)) -- hns3_err(hw, "FEC mode(0x%x) not supported in HNS3 PMD," -+ if (!is_fec_mode_one_bit_set(mode)) { -+ hns3_err(hw, "FEC mode(0x%x) not supported in HNS3 PMD, " - "FEC mode should be only one bit set", mode); -+ return -EINVAL; -+ } - - /* - * Check whether the configured mode is within the FEC capability. --- -2.7.4 - diff --git a/0166-net-hns3-fix-Rx-Tx-queue-numbers-check.patch b/0166-net-hns3-fix-Rx-Tx-queue-numbers-check.patch deleted file mode 100644 index 63bbecb..0000000 --- a/0166-net-hns3-fix-Rx-Tx-queue-numbers-check.patch +++ /dev/null @@ -1,68 +0,0 @@ -From cecc7bbcaf74f28a947f653069809bab67be42fe Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 15 May 2021 08:52:33 +0800 -Subject: [PATCH 166/189] net/hns3: fix Rx/Tx queue numbers check - -The Rx/Tx queue numbers should be greater than TC number, this patch adds -this check for PF before updating the mapping between TC and queue. - -Fixes: a951c1ed3ab5 ("net/hns3: support different numbers of Rx and Tx queues") -Fixes: 76d794566d43 ("net/hns3: maximize queue number") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 12 ++++++++++++ - drivers/net/hns3/hns3_ethdev_vf.c | 12 ------------ - 2 files changed, 12 insertions(+), 12 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 49b8be7..f44e2f0 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -727,6 +727,18 @@ hns3_queue_to_tc_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, uint16_t nb_tx_q) - { - int ret; - -+ if (nb_rx_q < hw->num_tc) { -+ hns3_err(hw, "number of Rx queues(%u) is less than number of TC(%u).", -+ nb_rx_q, hw->num_tc); -+ return -EINVAL; -+ } -+ -+ if (nb_tx_q < hw->num_tc) { -+ hns3_err(hw, "number of Tx queues(%u) is less than number of TC(%u).", -+ nb_tx_q, hw->num_tc); -+ return -EINVAL; -+ } -+ - ret = hns3_set_rss_size(hw, nb_rx_q); - if (ret) - return ret; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index dbd823f..7f7da18 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1498,18 +1498,6 @@ hns3vf_set_tc_queue_mapping(struct hns3_adapter *hns, uint16_t nb_rx_q, - { - struct hns3_hw *hw = &hns->hw; - -- if (nb_rx_q < hw->num_tc) { -- hns3_err(hw, "number of Rx queues(%u) is less than tcs(%u).", -- nb_rx_q, hw->num_tc); -- return -EINVAL; -- } -- -- if (nb_tx_q < hw->num_tc) { -- hns3_err(hw, "number of Tx queues(%u) is less than tcs(%u).", -- nb_tx_q, hw->num_tc); -- return -EINVAL; -- } -- - return hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); - } - --- -2.7.4 - diff --git a/0167-net-hns3-fix-requested-FC-mode-rollback.patch b/0167-net-hns3-fix-requested-FC-mode-rollback.patch deleted file mode 100644 index 9614aff..0000000 --- a/0167-net-hns3-fix-requested-FC-mode-rollback.patch +++ /dev/null @@ -1,157 +0,0 @@ -From ce08c5f9d37133ef2e984acb46d0fdf49fed9128 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 15 May 2021 08:52:34 +0800 -Subject: [PATCH 167/189] net/hns3: fix requested FC mode rollback - -Currently, the "requested_fc_mode" lacks rollback when enabling link -FC or PFC fails. -For example, this may result an incorrect FC mode after a reset. - -Fixes: d4fdb71a0e7b ("net/hns3: fix flow control mode") -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 30 ++++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_ethdev.c | 28 ---------------------------- - 2 files changed, 30 insertions(+), 28 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index f44e2f0..3efc2cd 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1760,6 +1760,30 @@ hns3_dcb_cfg_update(struct hns3_adapter *hns) - return ret; - } - -+static void -+hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) -+{ -+ switch (mode) { -+ case RTE_FC_NONE: -+ hw->requested_fc_mode = HNS3_FC_NONE; -+ break; -+ case RTE_FC_RX_PAUSE: -+ hw->requested_fc_mode = HNS3_FC_RX_PAUSE; -+ break; -+ case RTE_FC_TX_PAUSE: -+ hw->requested_fc_mode = HNS3_FC_TX_PAUSE; -+ break; -+ case RTE_FC_FULL: -+ hw->requested_fc_mode = HNS3_FC_FULL; -+ break; -+ default: -+ hw->requested_fc_mode = HNS3_FC_NONE; -+ hns3_warn(hw, "fc_mode(%u) exceeds member scope and is " -+ "configured to RTE_FC_NONE", mode); -+ break; -+ } -+} -+ - /* - * hns3_dcb_pfc_enable - Enable priority flow control - * @dev: pointer to ethernet device -@@ -1772,6 +1796,7 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); - enum hns3_fc_status fc_status = hw->current_fc_status; -+ enum hns3_fc_mode old_fc_mode = hw->requested_fc_mode; - uint8_t hw_pfc_map = hw->dcb_info.hw_pfc_map; - uint8_t pfc_en = hw->dcb_info.pfc_en; - uint8_t priority = pfc_conf->priority; -@@ -1779,6 +1804,7 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - int ret, status; - - pf->pause_time = pfc_conf->fc.pause_time; -+ hns3_get_fc_mode(hw, pfc_conf->fc.mode); - hw->current_fc_status = HNS3_FC_STATUS_PFC; - hw->dcb_info.pfc_en |= BIT(priority); - hw->dcb_info.hw_pfc_map = -@@ -1800,6 +1826,7 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - return 0; - - pfc_setup_fail: -+ hw->requested_fc_mode = old_fc_mode; - hw->current_fc_status = fc_status; - pf->pause_time = pause_time; - hw->dcb_info.pfc_en = pfc_en; -@@ -1822,11 +1849,13 @@ hns3_fc_enable(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ enum hns3_fc_mode old_fc_mode = hw->requested_fc_mode; - enum hns3_fc_status fc_status = hw->current_fc_status; - uint16_t pause_time = pf->pause_time; - int ret; - - pf->pause_time = fc_conf->pause_time; -+ hns3_get_fc_mode(hw, fc_conf->mode); - - /* - * In fact, current_fc_status is HNS3_FC_STATUS_NONE when mode -@@ -1846,6 +1875,7 @@ hns3_fc_enable(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - return 0; - - setup_fc_fail: -+ hw->requested_fc_mode = old_fc_mode; - hw->current_fc_status = fc_status; - pf->pause_time = pause_time; - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7ecd15b..88b2cfd 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6056,30 +6056,6 @@ hns3_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - return 0; - } - --static void --hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) --{ -- switch (mode) { -- case RTE_FC_NONE: -- hw->requested_fc_mode = HNS3_FC_NONE; -- break; -- case RTE_FC_RX_PAUSE: -- hw->requested_fc_mode = HNS3_FC_RX_PAUSE; -- break; -- case RTE_FC_TX_PAUSE: -- hw->requested_fc_mode = HNS3_FC_TX_PAUSE; -- break; -- case RTE_FC_FULL: -- hw->requested_fc_mode = HNS3_FC_FULL; -- break; -- default: -- hw->requested_fc_mode = HNS3_FC_NONE; -- hns3_warn(hw, "fc_mode(%u) exceeds member scope and is " -- "configured to RTE_FC_NONE", mode); -- break; -- } --} -- - static int - hns3_check_fc_autoneg_valid(struct hns3_hw *hw, uint8_t autoneg) - { -@@ -6153,8 +6129,6 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - return -EOPNOTSUPP; - } - -- hns3_get_fc_mode(hw, fc_conf->mode); -- - rte_spinlock_lock(&hw->lock); - ret = hns3_fc_enable(dev, fc_conf); - rte_spinlock_unlock(&hw->lock); -@@ -6201,8 +6175,6 @@ hns3_priority_flow_ctrl_set(struct rte_eth_dev *dev, - return -EOPNOTSUPP; - } - -- hns3_get_fc_mode(hw, pfc_conf->fc.mode); -- - rte_spinlock_lock(&hw->lock); - ret = hns3_dcb_pfc_enable(dev, pfc_conf); - rte_spinlock_unlock(&hw->lock); --- -2.7.4 - diff --git a/0168-net-hns3-remove-meaningless-packet-buffer-rollback.patch b/0168-net-hns3-remove-meaningless-packet-buffer-rollback.patch deleted file mode 100644 index 50e719f..0000000 --- a/0168-net-hns3-remove-meaningless-packet-buffer-rollback.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 30543af4bf517080e505ce6a99e2d0a3c9211445 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 15 May 2021 08:52:35 +0800 -Subject: [PATCH 168/189] net/hns3: remove meaningless packet buffer rollback - -Packet buffer allocation and hardware pause configuration fail normally -when a reset occurs. If the execution fails, rollback of the packet -buffer still fails. So this rollback is meaningless. - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 14 +++++--------- - 1 file changed, 5 insertions(+), 9 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 3efc2cd..1547942 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1543,7 +1543,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - enum hns3_fc_status fc_status = hw->current_fc_status; - enum hns3_fc_mode requested_fc_mode = hw->requested_fc_mode; - uint8_t hw_pfc_map = hw->dcb_info.hw_pfc_map; -- int ret, status; -+ int ret; - - if (pf->tx_sch_mode != HNS3_FLAG_TC_BASE_SCH_MODE && - pf->tx_sch_mode != HNS3_FLAG_VNET_BASE_SCH_MODE) -@@ -1568,7 +1568,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - - ret = hns3_buffer_alloc(hw); - if (ret) -- return ret; -+ goto buffer_alloc_fail; - - hw->current_fc_status = HNS3_FC_STATUS_PFC; - hw->requested_fc_mode = HNS3_FC_FULL; -@@ -1594,10 +1594,9 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - pfc_setup_fail: - hw->requested_fc_mode = requested_fc_mode; - hw->current_fc_status = fc_status; -+ -+buffer_alloc_fail: - hw->dcb_info.hw_pfc_map = hw_pfc_map; -- status = hns3_buffer_alloc(hw); -- if (status) -- hns3_err(hw, "recover packet buffer fail! status = %d", status); - - return ret; - } -@@ -1801,7 +1800,7 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - uint8_t pfc_en = hw->dcb_info.pfc_en; - uint8_t priority = pfc_conf->priority; - uint16_t pause_time = pf->pause_time; -- int ret, status; -+ int ret; - - pf->pause_time = pfc_conf->fc.pause_time; - hns3_get_fc_mode(hw, pfc_conf->fc.mode); -@@ -1831,9 +1830,6 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - pf->pause_time = pause_time; - hw->dcb_info.pfc_en = pfc_en; - hw->dcb_info.hw_pfc_map = hw_pfc_map; -- status = hns3_buffer_alloc(hw); -- if (status) -- hns3_err(hw, "recover packet buffer fail: %d", status); - - return ret; - } --- -2.7.4 - diff --git a/0169-net-hns3-fix-DCB-configuration.patch b/0169-net-hns3-fix-DCB-configuration.patch deleted file mode 100644 index e87a40c..0000000 --- a/0169-net-hns3-fix-DCB-configuration.patch +++ /dev/null @@ -1,198 +0,0 @@ -From c8817a4d8e42476b08fdcfc0a2b931e3d2fecc59 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 15 May 2021 08:52:36 +0800 -Subject: [PATCH 169/189] net/hns3: fix DCB configuration - -Currently, the DCB configuration takes effect in the dev_start stage, and -the mapping between TCs and queues are also updated in this stage. -However, the DCB configuration is delivered in the dev_configure stage. - -If the configuration fails, it should be intercepted in this stage. If -the configuration succeeds, the user should be able to obtain the -corresponding updated information, such as the mapping between TCs and -queues. So this patch moves DCB configuration to dev_configure. - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 35 +++++--------------------- - drivers/net/hns3/hns3_dcb.h | 2 +- - drivers/net/hns3/hns3_ethdev.c | 56 +++++++++++++++++++++++------------------- - 3 files changed, 38 insertions(+), 55 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 1547942..624bf40 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1615,8 +1615,7 @@ hns3_dcb_configure(struct hns3_adapter *hns) - int ret; - - hns3_dcb_cfg_validate(hns, &num_tc, &map_changed); -- if (map_changed || -- __atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED)) { -+ if (map_changed) { - ret = hns3_dcb_info_update(hns, num_tc); - if (ret) { - hns3_err(hw, "dcb info update failed: %d", ret); -@@ -1712,14 +1711,18 @@ hns3_dcb_init(struct hns3_hw *hw) - return 0; - } - --static int -+int - hns3_update_queue_map_configure(struct hns3_adapter *hns) - { - struct hns3_hw *hw = &hns->hw; -+ enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode; - uint16_t nb_rx_q = hw->data->nb_rx_queues; - uint16_t nb_tx_q = hw->data->nb_tx_queues; - int ret; - -+ if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) -+ return 0; -+ - ret = hns3_dcb_update_tc_queue_mapping(hw, nb_rx_q, nb_tx_q); - if (ret) { - hns3_err(hw, "failed to update tc queue mapping, ret = %d.", -@@ -1733,32 +1736,6 @@ hns3_update_queue_map_configure(struct hns3_adapter *hns) - return ret; - } - --int --hns3_dcb_cfg_update(struct hns3_adapter *hns) --{ -- struct hns3_hw *hw = &hns->hw; -- enum rte_eth_rx_mq_mode mq_mode = hw->data->dev_conf.rxmode.mq_mode; -- int ret; -- -- if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) { -- ret = hns3_dcb_configure(hns); -- if (ret) -- hns3_err(hw, "Failed to config dcb: %d", ret); -- } else { -- /* -- * Update queue map without PFC configuration, -- * due to queues reconfigured by user. -- */ -- ret = hns3_update_queue_map_configure(hns); -- if (ret) -- hns3_err(hw, -- "Failed to update queue mapping configure: %d", -- ret); -- } -- -- return ret; --} -- - static void - hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) - { -diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h -index 0d25d3b..279f163 100644 ---- a/drivers/net/hns3/hns3_dcb.h -+++ b/drivers/net/hns3/hns3_dcb.h -@@ -207,7 +207,7 @@ int hns3_dcb_pfc_enable(struct rte_eth_dev *dev, - int hns3_queue_to_tc_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, - uint16_t nb_tx_q); - --int hns3_dcb_cfg_update(struct hns3_adapter *hns); -+int hns3_update_queue_map_configure(struct hns3_adapter *hns); - int hns3_port_shaper_update(struct hns3_hw *hw, uint32_t speed); - int hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate); - int hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate); -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 88b2cfd..351dc59 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2274,24 +2274,6 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) - } - - static int --hns3_check_dcb_cfg(struct rte_eth_dev *dev) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- -- if (!hns3_dev_dcb_supported(hw)) { -- hns3_err(hw, "this port does not support dcb configurations."); -- return -EOPNOTSUPP; -- } -- -- if (hw->current_fc_status == HNS3_FC_STATUS_MAC_PAUSE) { -- hns3_err(hw, "MAC pause enabled, cannot config dcb info."); -- return -EOPNOTSUPP; -- } -- -- return 0; --} -- --static int - hns3_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool en, - enum hns3_ring_type queue_type, uint16_t queue_id) - { -@@ -2427,6 +2409,30 @@ hns3_refresh_mtu(struct rte_eth_dev *dev, struct rte_eth_conf *conf) - } - - static int -+hns3_setup_dcb(struct rte_eth_dev *dev) -+{ -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ int ret; -+ -+ if (!hns3_dev_dcb_supported(hw)) { -+ hns3_err(hw, "this port does not support dcb configurations."); -+ return -EOPNOTSUPP; -+ } -+ -+ if (hw->current_fc_status == HNS3_FC_STATUS_MAC_PAUSE) { -+ hns3_err(hw, "MAC pause enabled, cannot config dcb info."); -+ return -EOPNOTSUPP; -+ } -+ -+ ret = hns3_dcb_configure(hns); -+ if (ret) -+ hns3_err(hw, "failed to config dcb: %d", ret); -+ -+ return ret; -+} -+ -+static int - hns3_check_link_speed(struct hns3_hw *hw, uint32_t link_speeds) - { - int ret; -@@ -2506,7 +2512,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) - goto cfg_err; - - if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) { -- ret = hns3_check_dcb_cfg(dev); -+ ret = hns3_setup_dcb(dev); - if (ret) - goto cfg_err; - } -@@ -5571,14 +5577,14 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - struct hns3_hw *hw = &hns->hw; - int ret; - -- ret = hns3_dcb_cfg_update(hns); -- if (ret) -+ ret = hns3_update_queue_map_configure(hns); -+ if (ret) { -+ hns3_err(hw, "failed to update queue mapping configuration, ret = %d", -+ ret); - return ret; -+ } - -- /* -- * The hns3_dcb_cfg_update may configure TM module, so -- * hns3_tm_conf_update must called later. -- */ -+ /* Note: hns3_tm_conf_update must be called after configuring DCB. */ - ret = hns3_tm_conf_update(hw); - if (ret) { - PMD_INIT_LOG(ERR, "failed to update tm conf, ret = %d.", ret); --- -2.7.4 - diff --git a/0170-net-hns3-fix-DCB-reconfiguration.patch b/0170-net-hns3-fix-DCB-reconfiguration.patch deleted file mode 100644 index 0710014..0000000 --- a/0170-net-hns3-fix-DCB-reconfiguration.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 8e8b04c6f9586cef6a58b6825fee632ebce13c36 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 15 May 2021 08:52:37 +0800 -Subject: [PATCH 170/189] net/hns3: fix DCB reconfiguration - -Whether the enable bit of the pfc ("pfc_en") is changed or not is one of -the conditions for reconfiguring the DCB. Currently, pfc_en is not -rolled back when DCB configuration fails. This patch fixes it. - -Fixes: 62e3ccc2b94c ("net/hns3: support flow control") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 624bf40..8778452 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1543,6 +1543,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - enum hns3_fc_status fc_status = hw->current_fc_status; - enum hns3_fc_mode requested_fc_mode = hw->requested_fc_mode; - uint8_t hw_pfc_map = hw->dcb_info.hw_pfc_map; -+ uint8_t pfc_en = hw->dcb_info.pfc_en; - int ret; - - if (pf->tx_sch_mode != HNS3_FLAG_TC_BASE_SCH_MODE && -@@ -1596,6 +1597,7 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - hw->current_fc_status = fc_status; - - buffer_alloc_fail: -+ hw->dcb_info.pfc_en = pfc_en; - hw->dcb_info.hw_pfc_map = hw_pfc_map; - - return ret; --- -2.7.4 - diff --git a/0171-net-hns3-fix-link-speed-when-VF-device-is-down.patch b/0171-net-hns3-fix-link-speed-when-VF-device-is-down.patch deleted file mode 100644 index 9440716..0000000 --- a/0171-net-hns3-fix-link-speed-when-VF-device-is-down.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 5c44687c2b82e27046dd8c6eb6e3b3c4dc3a7499 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 15 May 2021 08:52:38 +0800 -Subject: [PATCH 171/189] net/hns3: fix link speed when VF device is down - -When the port is link down state, it is meaningless to display the -port link speed. It should be an undefined state. - -Fixes: 59fad0f32135 ("net/hns3: support link update operation") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev_vf.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 7f7da18..030d63a 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2202,16 +2202,18 @@ hns3vf_dev_link_update(struct rte_eth_dev *eth_dev, - case ETH_SPEED_NUM_50G: - case ETH_SPEED_NUM_100G: - case ETH_SPEED_NUM_200G: -- new_link.link_speed = mac->link_speed; -+ if (mac->link_status) -+ new_link.link_speed = mac->link_speed; - break; - default: - if (mac->link_status) - new_link.link_speed = ETH_SPEED_NUM_UNKNOWN; -- else -- new_link.link_speed = ETH_SPEED_NUM_NONE; - break; - } - -+ if (!mac->link_status) -+ new_link.link_speed = ETH_SPEED_NUM_NONE; -+ - new_link.link_duplex = mac->link_duplex; - new_link.link_status = mac->link_status ? ETH_LINK_UP : ETH_LINK_DOWN; - new_link.link_autoneg = --- -2.7.4 - diff --git a/0172-net-bonding-fix-adding-itself-as-its-slave.patch b/0172-net-bonding-fix-adding-itself-as-its-slave.patch deleted file mode 100644 index 553ad5c..0000000 --- a/0172-net-bonding-fix-adding-itself-as-its-slave.patch +++ /dev/null @@ -1,137 +0,0 @@ -From d91cb3a8f42e016965f7e641f1c33763f29fb722 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 15 Apr 2021 15:09:54 +0800 -Subject: [PATCH 172/189] net/bonding: fix adding itself as its slave - -Adding the bond device as its own slave should be forbidden. This -will cause a recursive endless loop in many subsequent operations, -and eventually lead to coredump. - -This problem was found in testpmd, the related logs are as follows: -testpmd> create bonded device 1 0 -Created new bonded device net_bonding_testpmd_0 on (port 4). -testpmd> add bonding slave 4 4 -Segmentation fault (core dumped) - -The call stack is as follows: -0x000000000064eb90 in rte_eth_dev_info_get () -0x00000000006df4b4 in bond_ethdev_info () -0x000000000064eb90 in rte_eth_dev_info_get () -0x00000000006df4b4 in bond_ethdev_info () -0x000000000064eb90 in rte_eth_dev_info_get () -0x0000000000564e58 in eth_dev_info_get_print_err () -0x000000000055e8a4 in init_port_config () -0x000000000052730c in cmd_add_bonding_slave_parsed () -0x0000000000646f60 in cmdline_parse () -0x0000000000645e08 in cmdline_valid_buffer () -0x000000000064956c in rdline_char_in () -0x0000000000645ee0 in cmdline_in () -0x00000000006460a4 in cmdline_interact () -0x0000000000531904 in prompt () -0x000000000051cca8 in main () - -Fixes: 2efb58cbab6e ("bond: new link bonding library") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/bonding/eth_bond_private.h | 2 +- - drivers/net/bonding/rte_eth_bond_api.c | 26 +++++++++++++++++--------- - 2 files changed, 18 insertions(+), 10 deletions(-) - -diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h -index 8f198bd..5c7a552 100644 ---- a/drivers/net/bonding/eth_bond_private.h -+++ b/drivers/net/bonding/eth_bond_private.h -@@ -212,7 +212,7 @@ int - valid_bonded_port_id(uint16_t port_id); - - int --valid_slave_port_id(uint16_t port_id, uint8_t mode); -+valid_slave_port_id(struct bond_dev_private *internals, uint16_t port_id); - - void - deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id); -diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c -index 55c8e31..44775f6 100644 ---- a/drivers/net/bonding/rte_eth_bond_api.c -+++ b/drivers/net/bonding/rte_eth_bond_api.c -@@ -56,19 +56,25 @@ check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev) - } - - int --valid_slave_port_id(uint16_t port_id, uint8_t mode) -+valid_slave_port_id(struct bond_dev_private *internals, uint16_t slave_port_id) - { -- RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1); -+ RTE_ETH_VALID_PORTID_OR_ERR_RET(slave_port_id, -1); - -- /* Verify that port_id refers to a non bonded port */ -- if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0 && -- mode == BONDING_MODE_8023AD) { -+ /* Verify that slave_port_id refers to a non bonded port */ -+ if (check_for_bonded_ethdev(&rte_eth_devices[slave_port_id]) == 0 && -+ internals->mode == BONDING_MODE_8023AD) { - RTE_BOND_LOG(ERR, "Cannot add slave to bonded device in 802.3ad" - " mode as slave is also a bonded device, only " - "physical devices can be support in this mode."); - return -1; - } - -+ if (internals->port_id == slave_port_id) { -+ RTE_BOND_LOG(ERR, -+ "Cannot add the bonded device itself as its slave."); -+ return -1; -+ } -+ - return 0; - } - -@@ -456,7 +462,7 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) - bonded_eth_dev = &rte_eth_devices[bonded_port_id]; - internals = bonded_eth_dev->data->dev_private; - -- if (valid_slave_port_id(slave_port_id, internals->mode) != 0) -+ if (valid_slave_port_id(internals, slave_port_id) != 0) - return -1; - - slave_eth_dev = &rte_eth_devices[slave_port_id]; -@@ -605,13 +611,15 @@ rte_eth_bond_slave_add(uint16_t bonded_port_id, uint16_t slave_port_id) - - int retval; - -- /* Verify that port id's are valid bonded and slave ports */ - if (valid_bonded_port_id(bonded_port_id) != 0) - return -1; - - bonded_eth_dev = &rte_eth_devices[bonded_port_id]; - internals = bonded_eth_dev->data->dev_private; - -+ if (valid_slave_port_id(internals, slave_port_id) != 0) -+ return -1; -+ - rte_spinlock_lock(&internals->lock); - - retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id); -@@ -635,7 +643,7 @@ __eth_bond_slave_remove_lock_free(uint16_t bonded_port_id, - bonded_eth_dev = &rte_eth_devices[bonded_port_id]; - internals = bonded_eth_dev->data->dev_private; - -- if (valid_slave_port_id(slave_port_id, internals->mode) < 0) -+ if (valid_slave_port_id(internals, slave_port_id) < 0) - return -1; - - /* first remove from active slave list */ -@@ -783,7 +791,7 @@ rte_eth_bond_primary_set(uint16_t bonded_port_id, uint16_t slave_port_id) - - internals = rte_eth_devices[bonded_port_id].data->dev_private; - -- if (valid_slave_port_id(slave_port_id, internals->mode) != 0) -+ if (valid_slave_port_id(internals, slave_port_id) != 0) - return -1; - - internals->user_defined_primary_port = 1; --- -2.7.4 - diff --git a/0173-ipc-use-monotonic-clock.patch b/0173-ipc-use-monotonic-clock.patch deleted file mode 100644 index ef75042..0000000 --- a/0173-ipc-use-monotonic-clock.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 5b8e25a80cc320c15477a884ebb5abd15b60a246 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 11 May 2021 18:41:23 +0800 -Subject: [PATCH 173/189] ipc: use monotonic clock -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Currently, the mp uses gettimeofday() API to get the time, and used as -timeout parameter. - -But the time which gets from gettimeofday() API isn't monotonically -increasing. The process may fail if the system time is changed. - -This fixes it by using clock_gettime() API with monotonic attribution. - -Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") -Fixes: f05e26051c15 ("eal: add IPC asynchronous request") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) -Acked-by: Morten Brørup ---- - lib/librte_eal/common/eal_common_proc.c | 27 +++++++++++++-------------- - 1 file changed, 13 insertions(+), 14 deletions(-) - -diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c -index 6d1af3c..dc4a2ef 100644 ---- a/lib/librte_eal/common/eal_common_proc.c -+++ b/lib/librte_eal/common/eal_common_proc.c -@@ -490,14 +490,11 @@ async_reply_handle_thread_unsafe(void *arg) - struct pending_request *req = (struct pending_request *)arg; - enum async_action action; - struct timespec ts_now; -- struct timeval now; - -- if (gettimeofday(&now, NULL) < 0) { -+ if (clock_gettime(CLOCK_MONOTONIC, &ts_now) < 0) { - RTE_LOG(ERR, EAL, "Cannot get current time\n"); - goto no_trigger; - } -- ts_now.tv_nsec = now.tv_usec * 1000; -- ts_now.tv_sec = now.tv_sec; - - action = process_async_request(req, &ts_now); - -@@ -896,6 +893,7 @@ mp_request_sync(const char *dst, struct rte_mp_msg *req, - struct rte_mp_reply *reply, const struct timespec *ts) - { - int ret; -+ pthread_condattr_t attr; - struct rte_mp_msg msg, *tmp; - struct pending_request pending_req, *exist; - -@@ -904,7 +902,9 @@ mp_request_sync(const char *dst, struct rte_mp_msg *req, - strlcpy(pending_req.dst, dst, sizeof(pending_req.dst)); - pending_req.request = req; - pending_req.reply = &msg; -- pthread_cond_init(&pending_req.sync.cond, NULL); -+ pthread_condattr_init(&attr); -+ pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); -+ pthread_cond_init(&pending_req.sync.cond, &attr); - - exist = find_pending_request(dst, req->name); - if (exist) { -@@ -967,8 +967,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, - int dir_fd, ret = -1; - DIR *mp_dir; - struct dirent *ent; -- struct timeval now; -- struct timespec end; -+ struct timespec now, end; - const struct internal_config *internal_conf = - eal_get_internal_configuration(); - -@@ -987,15 +986,15 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, - return -1; - } - -- if (gettimeofday(&now, NULL) < 0) { -+ if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) { - RTE_LOG(ERR, EAL, "Failed to get current time\n"); - rte_errno = errno; - goto end; - } - -- end.tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000; -+ end.tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000; - end.tv_sec = now.tv_sec + ts->tv_sec + -- (now.tv_usec * 1000 + ts->tv_nsec) / 1000000000; -+ (now.tv_nsec + ts->tv_nsec) / 1000000000; - - /* for secondary process, send request to the primary process only */ - if (rte_eal_process_type() == RTE_PROC_SECONDARY) { -@@ -1069,7 +1068,7 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, - int dir_fd, ret = 0; - DIR *mp_dir; - struct dirent *ent; -- struct timeval now; -+ struct timespec now; - struct timespec *end; - bool dummy_used = false; - const struct internal_config *internal_conf = -@@ -1086,7 +1085,7 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, - return -1; - } - -- if (gettimeofday(&now, NULL) < 0) { -+ if (clock_gettime(CLOCK_MONOTONIC, &now) < 0) { - RTE_LOG(ERR, EAL, "Failed to get current time\n"); - rte_errno = errno; - return -1; -@@ -1108,9 +1107,9 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts, - end = ¶m->end; - reply = ¶m->user_reply; - -- end->tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000; -+ end->tv_nsec = (now.tv_nsec + ts->tv_nsec) % 1000000000; - end->tv_sec = now.tv_sec + ts->tv_sec + -- (now.tv_usec * 1000 + ts->tv_nsec) / 1000000000; -+ (now.tv_nsec + ts->tv_nsec) / 1000000000; - reply->nb_sent = 0; - reply->nb_received = 0; - reply->msgs = NULL; --- -2.7.4 - diff --git a/0174-ethdev-add-queue-state-in-queried-queue-information.patch b/0174-ethdev-add-queue-state-in-queried-queue-information.patch deleted file mode 100644 index 8171cfa..0000000 --- a/0174-ethdev-add-queue-state-in-queried-queue-information.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 7516c1b63b53a27215a0206ae1437a3d5d5d0e08 Mon Sep 17 00:00:00 2001 -From: Lijun Ou -Date: Mon, 19 Apr 2021 16:57:30 +0800 -Subject: [PATCH 174/189] ethdev: add queue state in queried queue information - -Currently, upper-layer application could get queue state only -through pointers such as dev->data->tx_queue_state[queue_id], -this is not the recommended way to access it. So this patch -add get queue state when call rte_eth_rx_queue_info_get and -rte_eth_tx_queue_info_get API. - -Note: After add queue_state field, the 'struct rte_eth_rxq_info' size -remains 128B, and the 'struct rte_eth_txq_info' size remains 64B, so -it could be ABI compatible. - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou -Acked-by: Konstantin Ananyev -Acked-by: Thomas Monjalon -Reviewed-by: Ferruh Yigit ---- - devtools/libabigail.abignore | 9 +++++++++ - lib/librte_ethdev/rte_ethdev.c | 3 +++ - lib/librte_ethdev/rte_ethdev.h | 9 +++++++++ - lib/librte_ethdev/rte_ethdev_driver.h | 7 ------- - 4 files changed, 21 insertions(+), 7 deletions(-) - -diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore -index 025f2c0..b649af1 100644 ---- a/devtools/libabigail.abignore -+++ b/devtools/libabigail.abignore -@@ -7,3 +7,12 @@ - symbol_version = INTERNAL - [suppress_variable] - symbol_version = INTERNAL -+; Ignore fields inserted in alignment hole of rte_eth_rxq_info -+[suppress_type] -+ name = rte_eth_rxq_info -+ has_data_member_inserted_at = offset_after(scattered_rx) -+ -+; Ignore fields inserted in cacheline boundary of rte_eth_txq_info -+[suppress_type] -+ name = rte_eth_txq_info -+ has_data_member_inserted_between = {offset_after(nb_desc), end} -diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c -index f311868..87d1b56 100644 ---- a/lib/librte_ethdev/rte_ethdev.c -+++ b/lib/librte_ethdev/rte_ethdev.c -@@ -5023,6 +5023,8 @@ rte_eth_rx_queue_info_get(uint16_t port_id, uint16_t queue_id, - - memset(qinfo, 0, sizeof(*qinfo)); - dev->dev_ops->rxq_info_get(dev, queue_id, qinfo); -+ qinfo->queue_state = dev->data->rx_queue_state[queue_id]; -+ - return 0; - } - -@@ -5063,6 +5065,7 @@ rte_eth_tx_queue_info_get(uint16_t port_id, uint16_t queue_id, - - memset(qinfo, 0, sizeof(*qinfo)); - dev->dev_ops->txq_info_get(dev, queue_id, qinfo); -+ qinfo->queue_state = dev->data->tx_queue_state[queue_id]; - - return 0; - } -diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h -index e89fc50..d9ab66d 100644 ---- a/lib/librte_ethdev/rte_ethdev.h -+++ b/lib/librte_ethdev/rte_ethdev.h -@@ -1562,6 +1562,13 @@ struct rte_eth_dev_info { - }; - - /** -+ * RX/TX queue states -+ */ -+#define RTE_ETH_QUEUE_STATE_STOPPED 0 -+#define RTE_ETH_QUEUE_STATE_STARTED 1 -+#define RTE_ETH_QUEUE_STATE_HAIRPIN 2 -+ -+/** - * Ethernet device RX queue information structure. - * Used to retrieve information about configured queue. - */ -@@ -1569,6 +1576,7 @@ struct rte_eth_rxq_info { - struct rte_mempool *mp; /**< mempool used by that queue. */ - struct rte_eth_rxconf conf; /**< queue config parameters. */ - uint8_t scattered_rx; /**< scattered packets RX supported. */ -+ uint8_t queue_state; /**< one of RTE_ETH_QUEUE_STATE_*. */ - uint16_t nb_desc; /**< configured number of RXDs. */ - uint16_t rx_buf_size; /**< hardware receive buffer size. */ - } __rte_cache_min_aligned; -@@ -1580,6 +1588,7 @@ struct rte_eth_rxq_info { - struct rte_eth_txq_info { - struct rte_eth_txconf conf; /**< queue config parameters. */ - uint16_t nb_desc; /**< configured number of TXDs. */ -+ uint8_t queue_state; /**< one of RTE_ETH_QUEUE_STATE_*. */ - } __rte_cache_min_aligned; - - /* Generic Burst mode flag definition, values can be ORed. */ -diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h -index 0eacfd8..6d928a4 100644 ---- a/lib/librte_ethdev/rte_ethdev_driver.h -+++ b/lib/librte_ethdev/rte_ethdev_driver.h -@@ -920,13 +920,6 @@ struct eth_dev_ops { - }; - - /** -- * RX/TX queue states -- */ --#define RTE_ETH_QUEUE_STATE_STOPPED 0 --#define RTE_ETH_QUEUE_STATE_STARTED 1 --#define RTE_ETH_QUEUE_STATE_HAIRPIN 2 -- --/** - * @internal - * Check if the selected Rx queue is hairpin queue. - * --- -2.7.4 - diff --git a/0175-app-testpmd-fix-queue-stats-mapping-configuration.patch b/0175-app-testpmd-fix-queue-stats-mapping-configuration.patch deleted file mode 100644 index d84fc38..0000000 --- a/0175-app-testpmd-fix-queue-stats-mapping-configuration.patch +++ /dev/null @@ -1,769 +0,0 @@ -From f09441b0cd817ec53d5f059273e3266607de5bcd Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 2 Dec 2020 20:48:55 +0800 -Subject: [PATCH 175/189] app/testpmd: fix queue stats mapping configuration - -Currently, the queue stats mapping has the following problems: -1) Many PMD drivers don't support queue stats mapping. But there is no - failure message after executing the command "set stat_qmap rx 0 2 2". -2) Once queue mapping is set, unrelated and unmapped queues are also - displayed. -3) The configuration result does not take effect or can not be queried - in real time. -4) The mapping arrays, "tx_queue_stats_mappings_array" & - "rx_queue_stats_mappings_array" are global and their sizes are based - on fixed max port and queue size assumptions. -5) These record structures, 'map_port_queue_stats_mapping_registers()' - and its sub functions are redundant for majority of drivers. -6) The display of the queue stats and queue stats mapping is mixed - together. - -Since xstats is used to obtain queue statistics, we have made the -following simplifications and adjustments: -1) If PMD requires and supports queue stats mapping, configure to driver - in real time by calling ethdev API after executing the command "set - stat_qmap rx/tx ...". If not, the command can not be accepted. -2) Based on the above adjustments, these record structures, - 'map_port_queue_stats_mapping_registers()' and its sub functions can - be removed. "tx-queue-stats-mapping" & "rx-queue-stats-mapping" - parameters, and 'parse_queue_stats_mapping_config()' can be removed - too. -3) remove display of queue stats mapping in 'fwd_stats_display()' & - 'nic_stats_display()', and obtain queue stats by xstats. Since the - record structures are removed, 'nic_stats_mapping_display()' can be - deleted. - -Fixes: 4dccdc789bf4 ("app/testpmd: simplify handling of stats mappings error") -Fixes: 013af9b6b64f ("app/testpmd: various updates") -Fixes: ed30d9b691b2 ("app/testpmd: add stats per queue") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Reviewed-by: Ferruh Yigit ---- - app/test-pmd/cmdline.c | 17 ++--- - app/test-pmd/config.c | 144 +++++----------------------------- - app/test-pmd/parameters.c | 107 -------------------------- - app/test-pmd/testpmd.c | 191 +++++----------------------------------------- - app/test-pmd/testpmd.h | 22 ------ - 5 files changed, 46 insertions(+), 435 deletions(-) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 0d2d6aa..2ccbaa0 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -163,7 +163,7 @@ static void cmd_help_long_parsed(void *parsed_result, - "Display:\n" - "--------\n\n" - -- "show port (info|stats|summary|xstats|fdir|stat_qmap|dcb_tc|cap) (port_id|all)\n" -+ "show port (info|stats|summary|xstats|fdir|dcb_tc|cap) (port_id|all)\n" - " Display information for port_id, or all.\n\n" - - "show port port_id (module_eeprom|eeprom)\n" -@@ -177,7 +177,7 @@ static void cmd_help_long_parsed(void *parsed_result, - "show port (port_id) rss-hash [key]\n" - " Display the RSS hash functions and RSS hash key of port\n\n" - -- "clear port (info|stats|xstats|fdir|stat_qmap) (port_id|all)\n" -+ "clear port (info|stats|xstats|fdir) (port_id|all)\n" - " Clear information for port_id, or all.\n\n" - - "show (rxq|txq) info (port_id) (queue_id)\n" -@@ -7555,9 +7555,6 @@ static void cmd_showportall_parsed(void *parsed_result, - RTE_ETH_FOREACH_DEV(i) - fdir_get_infos(i); - #endif -- else if (!strcmp(res->what, "stat_qmap")) -- RTE_ETH_FOREACH_DEV(i) -- nic_stats_mapping_display(i); - else if (!strcmp(res->what, "dcb_tc")) - RTE_ETH_FOREACH_DEV(i) - port_dcb_info_display(i); -@@ -7573,14 +7570,14 @@ cmdline_parse_token_string_t cmd_showportall_port = - TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port"); - cmdline_parse_token_string_t cmd_showportall_what = - TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what, -- "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); -+ "info#summary#stats#xstats#fdir#dcb_tc#cap"); - cmdline_parse_token_string_t cmd_showportall_all = - TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all"); - cmdline_parse_inst_t cmd_showportall = { - .f = cmd_showportall_parsed, - .data = NULL, - .help_str = "show|clear port " -- "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap all", -+ "info|summary|stats|xstats|fdir|dcb_tc|cap all", - .tokens = { - (void *)&cmd_showportall_show, - (void *)&cmd_showportall_port, -@@ -7622,8 +7619,6 @@ static void cmd_showport_parsed(void *parsed_result, - else if (!strcmp(res->what, "fdir")) - fdir_get_infos(res->portnum); - #endif -- else if (!strcmp(res->what, "stat_qmap")) -- nic_stats_mapping_display(res->portnum); - else if (!strcmp(res->what, "dcb_tc")) - port_dcb_info_display(res->portnum); - else if (!strcmp(res->what, "cap")) -@@ -7637,7 +7632,7 @@ cmdline_parse_token_string_t cmd_showport_port = - TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port"); - cmdline_parse_token_string_t cmd_showport_what = - TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what, -- "info#summary#stats#xstats#fdir#stat_qmap#dcb_tc#cap"); -+ "info#summary#stats#xstats#fdir#dcb_tc#cap"); - cmdline_parse_token_num_t cmd_showport_portnum = - TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, RTE_UINT16); - -@@ -7645,7 +7640,7 @@ cmdline_parse_inst_t cmd_showport = { - .f = cmd_showport_parsed, - .data = NULL, - .help_str = "show|clear port " -- "info|summary|stats|xstats|fdir|stat_qmap|dcb_tc|cap " -+ "info|summary|stats|xstats|fdir|dcb_tc|cap " - "", - .tokens = { - (void *)&cmd_showport_show, -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index b51de59..3f6c864 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -183,8 +183,6 @@ nic_stats_display(portid_t port_id) - diff_ns; - uint64_t mpps_rx, mpps_tx, mbps_rx, mbps_tx; - struct rte_eth_stats stats; -- struct rte_port *port = &ports[port_id]; -- uint8_t i; - - static const char *nic_stats_border = "########################"; - -@@ -196,46 +194,12 @@ nic_stats_display(portid_t port_id) - printf("\n %s NIC statistics for port %-2d %s\n", - nic_stats_border, port_id, nic_stats_border); - -- if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) { -- printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " -- "%-"PRIu64"\n", -- stats.ipackets, stats.imissed, stats.ibytes); -- printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); -- printf(" RX-nombuf: %-10"PRIu64"\n", -- stats.rx_nombuf); -- printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " -- "%-"PRIu64"\n", -- stats.opackets, stats.oerrors, stats.obytes); -- } -- else { -- printf(" RX-packets: %10"PRIu64" RX-errors: %10"PRIu64 -- " RX-bytes: %10"PRIu64"\n", -- stats.ipackets, stats.ierrors, stats.ibytes); -- printf(" RX-errors: %10"PRIu64"\n", stats.ierrors); -- printf(" RX-nombuf: %10"PRIu64"\n", -- stats.rx_nombuf); -- printf(" TX-packets: %10"PRIu64" TX-errors: %10"PRIu64 -- " TX-bytes: %10"PRIu64"\n", -- stats.opackets, stats.oerrors, stats.obytes); -- } -- -- if (port->rx_queue_stats_mapping_enabled) { -- printf("\n"); -- for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { -- printf(" Stats reg %2d RX-packets: %10"PRIu64 -- " RX-errors: %10"PRIu64 -- " RX-bytes: %10"PRIu64"\n", -- i, stats.q_ipackets[i], stats.q_errors[i], stats.q_ibytes[i]); -- } -- } -- if (port->tx_queue_stats_mapping_enabled) { -- printf("\n"); -- for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { -- printf(" Stats reg %2d TX-packets: %10"PRIu64 -- " TX-bytes: %10"PRIu64"\n", -- i, stats.q_opackets[i], stats.q_obytes[i]); -- } -- } -+ printf(" RX-packets: %-10"PRIu64" RX-missed: %-10"PRIu64" RX-bytes: " -+ "%-"PRIu64"\n", stats.ipackets, stats.imissed, stats.ibytes); -+ printf(" RX-errors: %-"PRIu64"\n", stats.ierrors); -+ printf(" RX-nombuf: %-10"PRIu64"\n", stats.rx_nombuf); -+ printf(" TX-packets: %-10"PRIu64" TX-errors: %-10"PRIu64" TX-bytes: " -+ "%-"PRIu64"\n", stats.opackets, stats.oerrors, stats.obytes); - - diff_ns = 0; - if (clock_gettime(CLOCK_TYPE_ID, &cur_time) == 0) { -@@ -399,54 +363,6 @@ nic_xstats_clear(portid_t port_id) - } - - void --nic_stats_mapping_display(portid_t port_id) --{ -- struct rte_port *port = &ports[port_id]; -- uint16_t i; -- -- static const char *nic_stats_mapping_border = "########################"; -- -- if (port_id_is_invalid(port_id, ENABLED_WARN)) { -- print_valid_ports(); -- return; -- } -- -- if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) { -- printf("Port id %d - either does not support queue statistic mapping or" -- " no queue statistic mapping set\n", port_id); -- return; -- } -- -- printf("\n %s NIC statistics mapping for port %-2d %s\n", -- nic_stats_mapping_border, port_id, nic_stats_mapping_border); -- -- if (port->rx_queue_stats_mapping_enabled) { -- for (i = 0; i < nb_rx_queue_stats_mappings; i++) { -- if (rx_queue_stats_mappings[i].port_id == port_id) { -- printf(" RX-queue %2d mapped to Stats Reg %2d\n", -- rx_queue_stats_mappings[i].queue_id, -- rx_queue_stats_mappings[i].stats_counter_id); -- } -- } -- printf("\n"); -- } -- -- -- if (port->tx_queue_stats_mapping_enabled) { -- for (i = 0; i < nb_tx_queue_stats_mappings; i++) { -- if (tx_queue_stats_mappings[i].port_id == port_id) { -- printf(" TX-queue %2d mapped to Stats Reg %2d\n", -- tx_queue_stats_mappings[i].queue_id, -- tx_queue_stats_mappings[i].stats_counter_id); -- } -- } -- } -- -- printf(" %s####################################%s\n", -- nic_stats_mapping_border, nic_stats_mapping_border); --} -- --void - rx_queue_infos_display(portid_t port_id, uint16_t queue_id) - { - struct rte_eth_burst_mode mode; -@@ -2573,7 +2489,7 @@ tx_queue_id_is_invalid(queueid_t txq_id) - { - if (txq_id < nb_txq) - return 0; -- printf("Invalid TX queue %d (must be < nb_rxq=%d)\n", txq_id, nb_txq); -+ printf("Invalid TX queue %d (must be < nb_txq=%d)\n", txq_id, nb_txq); - return 1; - } - -@@ -4528,8 +4444,7 @@ tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on) - void - set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value) - { -- uint16_t i; -- uint8_t existing_mapping_found = 0; -+ int ret; - - if (port_id_is_invalid(port_id, ENABLED_WARN)) - return; -@@ -4539,40 +4454,23 @@ set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value) - - if (map_value >= RTE_ETHDEV_QUEUE_STAT_CNTRS) { - printf("map_value not in required range 0..%d\n", -- RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); -+ RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); - return; - } - -- if (!is_rx) { /*then tx*/ -- for (i = 0; i < nb_tx_queue_stats_mappings; i++) { -- if ((tx_queue_stats_mappings[i].port_id == port_id) && -- (tx_queue_stats_mappings[i].queue_id == queue_id)) { -- tx_queue_stats_mappings[i].stats_counter_id = map_value; -- existing_mapping_found = 1; -- break; -- } -- } -- if (!existing_mapping_found) { /* A new additional mapping... */ -- tx_queue_stats_mappings[nb_tx_queue_stats_mappings].port_id = port_id; -- tx_queue_stats_mappings[nb_tx_queue_stats_mappings].queue_id = queue_id; -- tx_queue_stats_mappings[nb_tx_queue_stats_mappings].stats_counter_id = map_value; -- nb_tx_queue_stats_mappings++; -- } -- } -- else { /*rx*/ -- for (i = 0; i < nb_rx_queue_stats_mappings; i++) { -- if ((rx_queue_stats_mappings[i].port_id == port_id) && -- (rx_queue_stats_mappings[i].queue_id == queue_id)) { -- rx_queue_stats_mappings[i].stats_counter_id = map_value; -- existing_mapping_found = 1; -- break; -- } -+ if (!is_rx) { /* tx */ -+ ret = rte_eth_dev_set_tx_queue_stats_mapping(port_id, queue_id, -+ map_value); -+ if (ret) { -+ printf("failed to set tx queue stats mapping.\n"); -+ return; - } -- if (!existing_mapping_found) { /* A new additional mapping... */ -- rx_queue_stats_mappings[nb_rx_queue_stats_mappings].port_id = port_id; -- rx_queue_stats_mappings[nb_rx_queue_stats_mappings].queue_id = queue_id; -- rx_queue_stats_mappings[nb_rx_queue_stats_mappings].stats_counter_id = map_value; -- nb_rx_queue_stats_mappings++; -+ } else { /* rx */ -+ ret = rte_eth_dev_set_rx_queue_stats_mapping(port_id, queue_id, -+ map_value); -+ if (ret) { -+ printf("failed to set rx queue stats mapping.\n"); -+ return; - } - } - } -diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c -index bbb68a5..414a006 100644 ---- a/app/test-pmd/parameters.c -+++ b/app/test-pmd/parameters.c -@@ -176,12 +176,6 @@ usage(char* progname) - "(0 <= N <= value of txd).\n"); - printf(" --txrst=N: set the transmit RS bit threshold of TX rings to N " - "(0 <= N <= value of txd).\n"); -- printf(" --tx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: " -- "tx queues statistics counters mapping " -- "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); -- printf(" --rx-queue-stats-mapping=(port,queue,mapping)[,(port,queue,mapping]: " -- "rx queues statistics counters mapping " -- "(0 <= mapping <= %d).\n", RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); - printf(" --no-flush-rx: Don't flush RX streams before forwarding." - " Used mainly with PCAP drivers.\n"); - printf(" --rxoffs=X[,Y]*: set RX segment offsets for split.\n"); -@@ -300,93 +294,6 @@ parse_fwd_portmask(const char *portmask) - set_fwd_ports_mask((uint64_t) pm); - } - -- --static int --parse_queue_stats_mapping_config(const char *q_arg, int is_rx) --{ -- char s[256]; -- const char *p, *p0 = q_arg; -- char *end; -- enum fieldnames { -- FLD_PORT = 0, -- FLD_QUEUE, -- FLD_STATS_COUNTER, -- _NUM_FLD -- }; -- unsigned long int_fld[_NUM_FLD]; -- char *str_fld[_NUM_FLD]; -- int i; -- unsigned size; -- -- /* reset from value set at definition */ -- is_rx ? (nb_rx_queue_stats_mappings = 0) : (nb_tx_queue_stats_mappings = 0); -- -- while ((p = strchr(p0,'(')) != NULL) { -- ++p; -- if((p0 = strchr(p,')')) == NULL) -- return -1; -- -- size = p0 - p; -- if(size >= sizeof(s)) -- return -1; -- -- snprintf(s, sizeof(s), "%.*s", size, p); -- if (rte_strsplit(s, sizeof(s), str_fld, _NUM_FLD, ',') != _NUM_FLD) -- return -1; -- for (i = 0; i < _NUM_FLD; i++){ -- errno = 0; -- int_fld[i] = strtoul(str_fld[i], &end, 0); -- if (errno != 0 || end == str_fld[i] || int_fld[i] > 255) -- return -1; -- } -- /* Check mapping field is in correct range (0..RTE_ETHDEV_QUEUE_STAT_CNTRS-1) */ -- if (int_fld[FLD_STATS_COUNTER] >= RTE_ETHDEV_QUEUE_STAT_CNTRS) { -- printf("Stats counter not in the correct range 0..%d\n", -- RTE_ETHDEV_QUEUE_STAT_CNTRS - 1); -- return -1; -- } -- -- if (!is_rx) { -- if ((nb_tx_queue_stats_mappings >= -- MAX_TX_QUEUE_STATS_MAPPINGS)) { -- printf("exceeded max number of TX queue " -- "statistics mappings: %hu\n", -- nb_tx_queue_stats_mappings); -- return -1; -- } -- tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].port_id = -- (uint8_t)int_fld[FLD_PORT]; -- tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].queue_id = -- (uint8_t)int_fld[FLD_QUEUE]; -- tx_queue_stats_mappings_array[nb_tx_queue_stats_mappings].stats_counter_id = -- (uint8_t)int_fld[FLD_STATS_COUNTER]; -- ++nb_tx_queue_stats_mappings; -- } -- else { -- if ((nb_rx_queue_stats_mappings >= -- MAX_RX_QUEUE_STATS_MAPPINGS)) { -- printf("exceeded max number of RX queue " -- "statistics mappings: %hu\n", -- nb_rx_queue_stats_mappings); -- return -1; -- } -- rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].port_id = -- (uint8_t)int_fld[FLD_PORT]; -- rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].queue_id = -- (uint8_t)int_fld[FLD_QUEUE]; -- rx_queue_stats_mappings_array[nb_rx_queue_stats_mappings].stats_counter_id = -- (uint8_t)int_fld[FLD_STATS_COUNTER]; -- ++nb_rx_queue_stats_mappings; -- } -- -- } --/* Reassign the rx/tx_queue_stats_mappings pointer to point to this newly populated array rather */ --/* than to the default array (that was set at its definition) */ -- is_rx ? (rx_queue_stats_mappings = rx_queue_stats_mappings_array) : -- (tx_queue_stats_mappings = tx_queue_stats_mappings_array); -- return 0; --} -- - static void - print_invalid_socket_id_error(void) - { -@@ -664,8 +571,6 @@ launch_args_parse(int argc, char** argv) - { "rxht", 1, 0, 0 }, - { "rxwt", 1, 0, 0 }, - { "rxfreet", 1, 0, 0 }, -- { "tx-queue-stats-mapping", 1, 0, 0 }, -- { "rx-queue-stats-mapping", 1, 0, 0 }, - { "no-flush-rx", 0, 0, 0 }, - { "flow-isolate-all", 0, 0, 0 }, - { "rxoffs", 1, 0, 0 }, -@@ -1279,18 +1184,6 @@ launch_args_parse(int argc, char** argv) - else - rte_exit(EXIT_FAILURE, "rxfreet must be >= 0\n"); - } -- if (!strcmp(lgopts[opt_idx].name, "tx-queue-stats-mapping")) { -- if (parse_queue_stats_mapping_config(optarg, TX)) { -- rte_exit(EXIT_FAILURE, -- "invalid TX queue statistics mapping config entered\n"); -- } -- } -- if (!strcmp(lgopts[opt_idx].name, "rx-queue-stats-mapping")) { -- if (parse_queue_stats_mapping_config(optarg, RX)) { -- rte_exit(EXIT_FAILURE, -- "invalid RX queue statistics mapping config entered\n"); -- } -- } - if (!strcmp(lgopts[opt_idx].name, "rxoffs")) { - unsigned int seg_off[MAX_SEGS_BUFFER_SPLIT]; - unsigned int nb_offs; -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index 33fc0fd..33a060d 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -476,15 +476,6 @@ struct rte_fdir_conf fdir_conf = { - - volatile int test_done = 1; /* stop packet forwarding when set to 1. */ - --struct queue_stats_mappings tx_queue_stats_mappings_array[MAX_TX_QUEUE_STATS_MAPPINGS]; --struct queue_stats_mappings rx_queue_stats_mappings_array[MAX_RX_QUEUE_STATS_MAPPINGS]; -- --struct queue_stats_mappings *tx_queue_stats_mappings = tx_queue_stats_mappings_array; --struct queue_stats_mappings *rx_queue_stats_mappings = rx_queue_stats_mappings_array; -- --uint16_t nb_tx_queue_stats_mappings = 0; --uint16_t nb_rx_queue_stats_mappings = 0; -- - /* - * Display zero values by default for xstats - */ -@@ -520,8 +511,6 @@ enum rte_eth_rx_mq_mode rx_mq_mode = ETH_MQ_RX_VMDQ_DCB_RSS; - - /* Forward function declarations */ - static void setup_attached_port(portid_t pi); --static void map_port_queue_stats_mapping_registers(portid_t pi, -- struct rte_port *port); - static void check_all_ports_link_status(uint32_t port_mask); - static int eth_event_callback(portid_t port_id, - enum rte_eth_event_type type, -@@ -1857,8 +1846,6 @@ fwd_stats_display(void) - fwd_cycles += fs->core_cycles; - } - for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { -- uint8_t j; -- - pt_id = fwd_ports_ids[i]; - port = &ports[pt_id]; - -@@ -1881,88 +1868,34 @@ fwd_stats_display(void) - printf("\n %s Forward statistics for port %-2d %s\n", - fwd_stats_border, pt_id, fwd_stats_border); - -- if (!port->rx_queue_stats_mapping_enabled && -- !port->tx_queue_stats_mapping_enabled) { -- printf(" RX-packets: %-14"PRIu64 -- " RX-dropped: %-14"PRIu64 -- "RX-total: %-"PRIu64"\n", -- stats.ipackets, stats.imissed, -- stats.ipackets + stats.imissed); -- -- if (cur_fwd_eng == &csum_fwd_engine) -- printf(" Bad-ipcsum: %-14"PRIu64 -- " Bad-l4csum: %-14"PRIu64 -- "Bad-outer-l4csum: %-14"PRIu64"\n", -- ports_stats[pt_id].rx_bad_ip_csum, -- ports_stats[pt_id].rx_bad_l4_csum, -- ports_stats[pt_id].rx_bad_outer_l4_csum); -- if (stats.ierrors + stats.rx_nombuf > 0) { -- printf(" RX-error: %-"PRIu64"\n", -- stats.ierrors); -- printf(" RX-nombufs: %-14"PRIu64"\n", -- stats.rx_nombuf); -- } -+ printf(" RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64 -+ "RX-total: %-"PRIu64"\n", stats.ipackets, stats.imissed, -+ stats.ipackets + stats.imissed); - -- printf(" TX-packets: %-14"PRIu64 -- " TX-dropped: %-14"PRIu64 -- "TX-total: %-"PRIu64"\n", -- stats.opackets, ports_stats[pt_id].tx_dropped, -- stats.opackets + ports_stats[pt_id].tx_dropped); -- } else { -- printf(" RX-packets: %14"PRIu64 -- " RX-dropped:%14"PRIu64 -- " RX-total:%14"PRIu64"\n", -- stats.ipackets, stats.imissed, -- stats.ipackets + stats.imissed); -- -- if (cur_fwd_eng == &csum_fwd_engine) -- printf(" Bad-ipcsum:%14"PRIu64 -- " Bad-l4csum:%14"PRIu64 -- " Bad-outer-l4csum: %-14"PRIu64"\n", -- ports_stats[pt_id].rx_bad_ip_csum, -- ports_stats[pt_id].rx_bad_l4_csum, -- ports_stats[pt_id].rx_bad_outer_l4_csum); -- if ((stats.ierrors + stats.rx_nombuf) > 0) { -- printf(" RX-error:%"PRIu64"\n", stats.ierrors); -- printf(" RX-nombufs: %14"PRIu64"\n", -- stats.rx_nombuf); -- } -- -- printf(" TX-packets: %14"PRIu64 -- " TX-dropped:%14"PRIu64 -- " TX-total:%14"PRIu64"\n", -- stats.opackets, ports_stats[pt_id].tx_dropped, -- stats.opackets + ports_stats[pt_id].tx_dropped); -+ if (cur_fwd_eng == &csum_fwd_engine) -+ printf(" Bad-ipcsum: %-14"PRIu64 -+ " Bad-l4csum: %-14"PRIu64 -+ "Bad-outer-l4csum: %-14"PRIu64"\n", -+ ports_stats[pt_id].rx_bad_ip_csum, -+ ports_stats[pt_id].rx_bad_l4_csum, -+ ports_stats[pt_id].rx_bad_outer_l4_csum); -+ if (stats.ierrors + stats.rx_nombuf > 0) { -+ printf(" RX-error: %-"PRIu64"\n", stats.ierrors); -+ printf(" RX-nombufs: %-14"PRIu64"\n", stats.rx_nombuf); - } - -+ printf(" TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64 -+ "TX-total: %-"PRIu64"\n", -+ stats.opackets, ports_stats[pt_id].tx_dropped, -+ stats.opackets + ports_stats[pt_id].tx_dropped); -+ - if (record_burst_stats) { - if (ports_stats[pt_id].rx_stream) - pkt_burst_stats_display("RX", - &ports_stats[pt_id].rx_stream->rx_burst_stats); - if (ports_stats[pt_id].tx_stream) - pkt_burst_stats_display("TX", -- &ports_stats[pt_id].tx_stream->tx_burst_stats); -- } -- -- if (port->rx_queue_stats_mapping_enabled) { -- printf("\n"); -- for (j = 0; j < RTE_ETHDEV_QUEUE_STAT_CNTRS; j++) { -- printf(" Stats reg %2d RX-packets:%14"PRIu64 -- " RX-errors:%14"PRIu64 -- " RX-bytes:%14"PRIu64"\n", -- j, stats.q_ipackets[j], -- stats.q_errors[j], stats.q_ibytes[j]); -- } -- printf("\n"); -- } -- if (port->tx_queue_stats_mapping_enabled) { -- for (j = 0; j < RTE_ETHDEV_QUEUE_STAT_CNTRS; j++) { -- printf(" Stats reg %2d TX-packets:%14"PRIu64 -- " TX-bytes:%14" -- PRIu64"\n", -- j, stats.q_opackets[j], -- stats.q_obytes[j]); -- } -+ &ports_stats[pt_id].tx_stream->tx_burst_stats); - } - - printf(" %s--------------------------------%s\n", -@@ -2236,11 +2169,6 @@ start_packet_forwarding(int with_tx_first) - rxtx_config_display(); - - fwd_stats_reset(); -- for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) { -- pt_id = fwd_ports_ids[i]; -- port = &ports[pt_id]; -- map_port_queue_stats_mapping_registers(pt_id, port); -- } - if (with_tx_first) { - port_fwd_begin = tx_only_engine.port_fwd_begin; - if (port_fwd_begin != NULL) { -@@ -3352,84 +3280,6 @@ dev_event_callback(const char *device_name, enum rte_dev_event_type type, - } - } - --static int --set_tx_queue_stats_mapping_registers(portid_t port_id, struct rte_port *port) --{ -- uint16_t i; -- int diag; -- uint8_t mapping_found = 0; -- -- for (i = 0; i < nb_tx_queue_stats_mappings; i++) { -- if ((tx_queue_stats_mappings[i].port_id == port_id) && -- (tx_queue_stats_mappings[i].queue_id < nb_txq )) { -- diag = rte_eth_dev_set_tx_queue_stats_mapping(port_id, -- tx_queue_stats_mappings[i].queue_id, -- tx_queue_stats_mappings[i].stats_counter_id); -- if (diag != 0) -- return diag; -- mapping_found = 1; -- } -- } -- if (mapping_found) -- port->tx_queue_stats_mapping_enabled = 1; -- return 0; --} -- --static int --set_rx_queue_stats_mapping_registers(portid_t port_id, struct rte_port *port) --{ -- uint16_t i; -- int diag; -- uint8_t mapping_found = 0; -- -- for (i = 0; i < nb_rx_queue_stats_mappings; i++) { -- if ((rx_queue_stats_mappings[i].port_id == port_id) && -- (rx_queue_stats_mappings[i].queue_id < nb_rxq )) { -- diag = rte_eth_dev_set_rx_queue_stats_mapping(port_id, -- rx_queue_stats_mappings[i].queue_id, -- rx_queue_stats_mappings[i].stats_counter_id); -- if (diag != 0) -- return diag; -- mapping_found = 1; -- } -- } -- if (mapping_found) -- port->rx_queue_stats_mapping_enabled = 1; -- return 0; --} -- --static void --map_port_queue_stats_mapping_registers(portid_t pi, struct rte_port *port) --{ -- int diag = 0; -- -- diag = set_tx_queue_stats_mapping_registers(pi, port); -- if (diag != 0) { -- if (diag == -ENOTSUP) { -- port->tx_queue_stats_mapping_enabled = 0; -- printf("TX queue stats mapping not supported port id=%d\n", pi); -- } -- else -- rte_exit(EXIT_FAILURE, -- "set_tx_queue_stats_mapping_registers " -- "failed for port id=%d diag=%d\n", -- pi, diag); -- } -- -- diag = set_rx_queue_stats_mapping_registers(pi, port); -- if (diag != 0) { -- if (diag == -ENOTSUP) { -- port->rx_queue_stats_mapping_enabled = 0; -- printf("RX queue stats mapping not supported port id=%d\n", pi); -- } -- else -- rte_exit(EXIT_FAILURE, -- "set_rx_queue_stats_mapping_registers " -- "failed for port id=%d diag=%d\n", -- pi, diag); -- } --} -- - static void - rxtx_port_config(struct rte_port *port) - { -@@ -3526,7 +3376,6 @@ init_port_config(void) - if (ret != 0) - return; - -- map_port_queue_stats_mapping_registers(pid, port); - #if defined RTE_NET_IXGBE && defined RTE_LIBRTE_IXGBE_BYPASS - rte_pmd_ixgbe_bypass_init(pid); - #endif -@@ -3737,8 +3586,6 @@ init_port_dcb_config(portid_t pid, - if (retval != 0) - return retval; - -- map_port_queue_stats_mapping_registers(pid, rte_port); -- - rte_port->dcb_flag = 1; - - return 0; -diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h -index 6b901a8..5f23162 100644 ---- a/app/test-pmd/testpmd.h -+++ b/app/test-pmd/testpmd.h -@@ -206,8 +206,6 @@ struct rte_port { - uint16_t tunnel_tso_segsz; /**< Segmentation offload MSS for tunneled pkts. */ - uint16_t tx_vlan_id;/**< The tag ID */ - uint16_t tx_vlan_id_outer;/**< The outer tag ID */ -- uint8_t tx_queue_stats_mapping_enabled; -- uint8_t rx_queue_stats_mapping_enabled; - volatile uint16_t port_status; /**< port started or not */ - uint8_t need_setup; /**< port just attached */ - uint8_t need_reconfig; /**< need reconfiguring port or not */ -@@ -326,25 +324,6 @@ enum dcb_mode_enable - DCB_ENABLED - }; - --#define MAX_TX_QUEUE_STATS_MAPPINGS 1024 /* MAX_PORT of 32 @ 32 tx_queues/port */ --#define MAX_RX_QUEUE_STATS_MAPPINGS 4096 /* MAX_PORT of 32 @ 128 rx_queues/port */ -- --struct queue_stats_mappings { -- portid_t port_id; -- uint16_t queue_id; -- uint8_t stats_counter_id; --} __rte_cache_aligned; -- --extern struct queue_stats_mappings tx_queue_stats_mappings_array[]; --extern struct queue_stats_mappings rx_queue_stats_mappings_array[]; -- --/* Assign both tx and rx queue stats mappings to the same default values */ --extern struct queue_stats_mappings *tx_queue_stats_mappings; --extern struct queue_stats_mappings *rx_queue_stats_mappings; -- --extern uint16_t nb_tx_queue_stats_mappings; --extern uint16_t nb_rx_queue_stats_mappings; -- - extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ - - /* globals used for configuration */ -@@ -790,7 +769,6 @@ void nic_stats_display(portid_t port_id); - void nic_stats_clear(portid_t port_id); - void nic_xstats_display(portid_t port_id); - void nic_xstats_clear(portid_t port_id); --void nic_stats_mapping_display(portid_t port_id); - void device_infos_display(const char *identifier); - void port_infos_display(portid_t port_id); - void port_summary_display(portid_t port_id); --- -2.7.4 - diff --git a/0176-app-testpmd-fix-bitmap-of-link-speeds-when-force-spe.patch b/0176-app-testpmd-fix-bitmap-of-link-speeds-when-force-spe.patch deleted file mode 100644 index c38659e..0000000 --- a/0176-app-testpmd-fix-bitmap-of-link-speeds-when-force-spe.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 3674253a345d4f953044369ca906212af2f04819 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 14 Apr 2021 11:02:05 +0800 -Subject: [PATCH 176/189] app/testpmd: fix bitmap of link speeds when force - speed - -Currently, when the user sets force link speed through 'link_speeds', -bit(0) of 'link_speeds' is not set to 1(ETH_LINK_SPEED_FIXED), -which conflicts with the definition. - -Fixes: 88fbedcd5e5a ("app/testpmd: move speed and duplex parsing in a function") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Acked-by: Ferruh Yigit -Acked-by: Ajit Khaparde ---- - app/test-pmd/cmdline.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 2ccbaa0..8446ecc 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -1521,6 +1521,9 @@ parse_and_check_speed_duplex(char *speedstr, char *duplexstr, uint32_t *speed) - } - } - -+ if (*speed != ETH_LINK_SPEED_AUTONEG) -+ *speed |= ETH_LINK_SPEED_FIXED; -+ - return 0; - } - --- -2.7.4 - diff --git a/0177-app-testpmd-add-link-autoneg-status-display.patch b/0177-app-testpmd-add-link-autoneg-status-display.patch deleted file mode 100644 index fb8807c..0000000 --- a/0177-app-testpmd-add-link-autoneg-status-display.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 465efdb2120519aba339a2754afaf71e7bf34ec5 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Thu, 15 Apr 2021 14:45:15 +0800 -Subject: [PATCH 177/189] app/testpmd: add link autoneg status display - -This patch adds link autoneg status display in port_infos_display(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Acked-by: Xiaoyun Li ---- - app/test-pmd/config.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index 3f6c864..d4ec3ff 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -618,6 +618,8 @@ port_infos_display(portid_t port_id) - printf("Link speed: %s\n", rte_eth_link_speed_to_str(link.link_speed)); - printf("Link duplex: %s\n", (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex")); -+ printf("Autoneg status: %s\n", (link.link_autoneg == ETH_LINK_AUTONEG) ? -+ ("On") : ("Off")); - - if (!rte_eth_dev_get_mtu(port_id, &mtu)) - printf("MTU: %u\n", mtu); --- -2.7.4 - diff --git a/0178-app-testpmd-support-cleanup-Tx-queue-mbufs.patch b/0178-app-testpmd-support-cleanup-Tx-queue-mbufs.patch deleted file mode 100644 index 8cb49f4..0000000 --- a/0178-app-testpmd-support-cleanup-Tx-queue-mbufs.patch +++ /dev/null @@ -1,152 +0,0 @@ -From 495e9454badc1ee809923d412db13f8e5bae1dca Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 21 Apr 2021 16:45:02 +0800 -Subject: [PATCH 178/189] app/testpmd: support cleanup Tx queue mbufs - -This patch supports cleanup txq mbufs command: -port cleanup (port_id) txq (queue_id) (free_cnt) - -Signed-off-by: Chengwen Feng -Signed-off-by: Lijun Ou -Reviewed-by: Ferruh Yigit ---- - app/test-pmd/cmdline.c | 88 +++++++++++++++++++++++++++++ - doc/guides/testpmd_app_ug/testpmd_funcs.rst | 9 +++ - 2 files changed, 97 insertions(+) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 8446ecc..8832416 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -898,6 +898,9 @@ static void cmd_help_long_parsed(void *parsed_result, - " Register a dynf and Set/clear this flag on Tx. " - "Testpmd will set this value to any Tx packet " - "sent from this port\n\n" -+ -+ "port cleanup (port_id) txq (queue_id) (free_cnt)\n" -+ " Cleanup txq mbufs for a specific Tx queue\n\n" - ); - } - -@@ -2439,6 +2442,90 @@ cmdline_parse_inst_t cmd_config_rss_hash_key = { - }, - }; - -+/* *** cleanup txq mbufs *** */ -+struct cmd_cleanup_txq_mbufs_result { -+ cmdline_fixed_string_t port; -+ cmdline_fixed_string_t keyword; -+ cmdline_fixed_string_t name; -+ uint16_t port_id; -+ uint16_t queue_id; -+ uint32_t free_cnt; -+}; -+ -+static void -+cmd_cleanup_txq_mbufs_parsed(void *parsed_result, -+ __rte_unused struct cmdline *cl, -+ __rte_unused void *data) -+{ -+ struct cmd_cleanup_txq_mbufs_result *res = parsed_result; -+ uint16_t port_id = res->port_id; -+ uint16_t queue_id = res->queue_id; -+ uint32_t free_cnt = res->free_cnt; -+ struct rte_eth_txq_info qinfo; -+ int ret; -+ -+ if (test_done == 0) { -+ printf("Please stop forwarding first\n"); -+ return; -+ } -+ -+ if (rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo)) { -+ printf("Failed to get port %u Tx queue %u info\n", -+ port_id, queue_id); -+ return; -+ } -+ -+ if (qinfo.queue_state != RTE_ETH_QUEUE_STATE_STARTED) { -+ printf("Tx queue %u not started\n", queue_id); -+ return; -+ } -+ -+ ret = rte_eth_tx_done_cleanup(port_id, queue_id, free_cnt); -+ if (ret < 0) { -+ printf("Failed to cleanup mbuf for port %u Tx queue %u " -+ "error desc: %s(%d)\n", -+ port_id, queue_id, strerror(-ret), ret); -+ return; -+ } -+ -+ printf("Cleanup port %u Tx queue %u mbuf nums: %u\n", -+ port_id, queue_id, ret); -+} -+ -+cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_port = -+ TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port, -+ "port"); -+cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_cleanup = -+ TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, keyword, -+ "cleanup"); -+cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_port_id = -+ TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, port_id, -+ RTE_UINT16); -+cmdline_parse_token_string_t cmd_cleanup_txq_mbufs_txq = -+ TOKEN_STRING_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, name, -+ "txq"); -+cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_queue_id = -+ TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, queue_id, -+ RTE_UINT16); -+cmdline_parse_token_num_t cmd_cleanup_txq_mbufs_free_cnt = -+ TOKEN_NUM_INITIALIZER(struct cmd_cleanup_txq_mbufs_result, free_cnt, -+ RTE_UINT32); -+ -+cmdline_parse_inst_t cmd_cleanup_txq_mbufs = { -+ .f = cmd_cleanup_txq_mbufs_parsed, -+ .data = NULL, -+ .help_str = "port cleanup txq ", -+ .tokens = { -+ (void *)&cmd_cleanup_txq_mbufs_port, -+ (void *)&cmd_cleanup_txq_mbufs_cleanup, -+ (void *)&cmd_cleanup_txq_mbufs_port_id, -+ (void *)&cmd_cleanup_txq_mbufs_txq, -+ (void *)&cmd_cleanup_txq_mbufs_queue_id, -+ (void *)&cmd_cleanup_txq_mbufs_free_cnt, -+ NULL, -+ }, -+}; -+ - /* *** configure port rxq/txq ring size *** */ - struct cmd_config_rxtx_ring_size { - cmdline_fixed_string_t port; -@@ -16947,6 +17034,7 @@ cmdline_parse_ctx_t main_ctx[] = { - (cmdline_parse_inst_t *)&cmd_showport_rss_hash, - (cmdline_parse_inst_t *)&cmd_showport_rss_hash_key, - (cmdline_parse_inst_t *)&cmd_config_rss_hash_key, -+ (cmdline_parse_inst_t *)&cmd_cleanup_txq_mbufs, - (cmdline_parse_inst_t *)&cmd_dump, - (cmdline_parse_inst_t *)&cmd_dump_one, - #ifdef RTE_NET_I40E -diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -index 9be4500..de90726 100644 ---- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst -+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -@@ -2415,6 +2415,15 @@ hash of input [IP] packets received on port:: - ipv6-udp-ex ) - -+port cleanup txq mbufs -+~~~~~~~~~~~~~~~~~~~~~~ -+ -+To cleanup txq mbufs currently cached by driver:: -+ -+ testpmd> port cleanup (port_id) txq (queue_id) (free_cnt) -+ -+If the value of ``free_cnt`` is 0, driver should free all cached mbufs. -+ - Device Functions - ---------------- - --- -2.7.4 - diff --git a/0179-app-testpmd-show-link-flow-control-info.patch b/0179-app-testpmd-show-link-flow-control-info.patch deleted file mode 100644 index 0af1255..0000000 --- a/0179-app-testpmd-show-link-flow-control-info.patch +++ /dev/null @@ -1,144 +0,0 @@ -From f67e3735b1020d516340b8a6ab2cf7c396dc9fac Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 21 Apr 2021 17:41:31 +0800 -Subject: [PATCH 179/189] app/testpmd: show link flow control info - -This patch supports the query of the link flow control parameter -on a port. - -The command format is as follows: -show port flow_ctrl - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Acked-by: Xiaoyun Li -Acked-by: Kevin Traynor ---- - app/test-pmd/cmdline.c | 78 +++++++++++++++++++++++++++++ - doc/guides/testpmd_app_ug/testpmd_funcs.rst | 7 +++ - 2 files changed, 85 insertions(+) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 8832416..a64b493 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -254,6 +254,9 @@ static void cmd_help_long_parsed(void *parsed_result, - - "show port (port_id) fec_mode" - " Show fec mode of a port.\n\n" -+ -+ "show port (port_id) flow_ctrl" -+ " Show flow control info of a port.\n\n" - ); - } - -@@ -6935,6 +6938,80 @@ cmdline_parse_inst_t cmd_set_allmulti_mode_one = { - }, - }; - -+/* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */ -+struct cmd_link_flow_ctrl_show { -+ cmdline_fixed_string_t show; -+ cmdline_fixed_string_t port; -+ portid_t port_id; -+ cmdline_fixed_string_t flow_ctrl; -+}; -+ -+cmdline_parse_token_string_t cmd_lfc_show_show = -+ TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, -+ show, "show"); -+cmdline_parse_token_string_t cmd_lfc_show_port = -+ TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, -+ port, "port"); -+cmdline_parse_token_num_t cmd_lfc_show_portid = -+ TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show, -+ port_id, RTE_UINT16); -+cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl = -+ TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show, -+ flow_ctrl, "flow_ctrl"); -+ -+static void -+cmd_link_flow_ctrl_show_parsed(void *parsed_result, -+ __rte_unused struct cmdline *cl, -+ __rte_unused void *data) -+{ -+ struct cmd_link_flow_ctrl_show *res = parsed_result; -+ static const char *info_border = "*********************"; -+ struct rte_eth_fc_conf fc_conf; -+ bool rx_fc_en = false; -+ bool tx_fc_en = false; -+ int ret; -+ -+ ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf); -+ if (ret != 0) { -+ printf("Failed to get current flow ctrl information: err = %d\n", -+ ret); -+ return; -+ } -+ -+ if (fc_conf.mode == RTE_FC_RX_PAUSE || fc_conf.mode == RTE_FC_FULL) -+ rx_fc_en = true; -+ if (fc_conf.mode == RTE_FC_TX_PAUSE || fc_conf.mode == RTE_FC_FULL) -+ tx_fc_en = true; -+ -+ printf("\n%s Flow control infos for port %-2d %s\n", -+ info_border, res->port_id, info_border); -+ printf("FC mode:\n"); -+ printf(" Rx pause: %s\n", rx_fc_en ? "on" : "off"); -+ printf(" Tx pause: %s\n", tx_fc_en ? "on" : "off"); -+ printf("Autoneg: %s\n", fc_conf.autoneg ? "on" : "off"); -+ printf("Pause time: 0x%x\n", fc_conf.pause_time); -+ printf("High waterline: 0x%x\n", fc_conf.high_water); -+ printf("Low waterline: 0x%x\n", fc_conf.low_water); -+ printf("Send XON: %s\n", fc_conf.send_xon ? "on" : "off"); -+ printf("Forward MAC control frames: %s\n", -+ fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); -+ printf("\n%s************** End ***********%s\n", -+ info_border, info_border); -+} -+ -+cmdline_parse_inst_t cmd_link_flow_control_show = { -+ .f = cmd_link_flow_ctrl_show_parsed, -+ .data = NULL, -+ .help_str = "show port flow_ctrl", -+ .tokens = { -+ (void *)&cmd_lfc_show_show, -+ (void *)&cmd_lfc_show_port, -+ (void *)&cmd_lfc_show_portid, -+ (void *)&cmd_lfc_show_flow_ctrl, -+ NULL, -+ }, -+}; -+ - /* *** SETUP ETHERNET LINK FLOW CONTROL *** */ - struct cmd_link_flow_ctrl_set_result { - cmdline_fixed_string_t set; -@@ -16981,6 +17058,7 @@ cmdline_parse_ctx_t main_ctx[] = { - (cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon, - (cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd, - (cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg, -+ (cmdline_parse_inst_t *)&cmd_link_flow_control_show, - (cmdline_parse_inst_t *)&cmd_priority_flow_control_set, - (cmdline_parse_inst_t *)&cmd_config_dcb, - (cmdline_parse_inst_t *)&cmd_read_reg, -diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -index de90726..f0e0423 100644 ---- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst -+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -@@ -1521,6 +1521,13 @@ Where: - - * ``autoneg``: Change the auto-negotiation parameter. - -+show flow control -+~~~~~~~~~~~~~~~~~ -+ -+show the link flow control parameter on a port:: -+ -+ testpmd> show port flow_ctrl -+ - set pfc_ctrl rx - ~~~~~~~~~~~~~~~ - --- -2.7.4 - diff --git a/0180-app-testpmd-support-display-queue-state.patch b/0180-app-testpmd-support-display-queue-state.patch deleted file mode 100644 index d49fd07..0000000 --- a/0180-app-testpmd-support-display-queue-state.patch +++ /dev/null @@ -1,57 +0,0 @@ -From c36dad2a8570ffadd1fd802c85d0566260ff1daf Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 21 Apr 2021 11:24:59 +0800 -Subject: [PATCH 180/189] app/testpmd: support display queue state - -This patch supports display queue state in "show rxq/txq" commands. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) -Reviewed-by: Ferruh Yigit ---- - app/test-pmd/config.c | 15 +++++++++++++++ - 1 file changed, 15 insertions(+) - -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index d4ec3ff..baae44e 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -362,6 +362,19 @@ nic_xstats_clear(portid_t port_id) - } - } - -+static const char * -+get_queue_state_name(uint8_t queue_state) -+{ -+ if (queue_state == RTE_ETH_QUEUE_STATE_STOPPED) -+ return "stopped"; -+ else if (queue_state == RTE_ETH_QUEUE_STATE_STARTED) -+ return "started"; -+ else if (queue_state == RTE_ETH_QUEUE_STATE_HAIRPIN) -+ return "hairpin"; -+ else -+ return "unknown"; -+} -+ - void - rx_queue_infos_display(portid_t port_id, uint16_t queue_id) - { -@@ -392,6 +405,7 @@ rx_queue_infos_display(portid_t port_id, uint16_t queue_id) - (qinfo.conf.rx_deferred_start != 0) ? "on" : "off"); - printf("\nRX scattered packets: %s", - (qinfo.scattered_rx != 0) ? "on" : "off"); -+ printf("\nRx queue state: %s", get_queue_state_name(qinfo.queue_state)); - if (qinfo.rx_buf_size != 0) - printf("\nRX buffer size: %hu", qinfo.rx_buf_size); - printf("\nNumber of RXDs: %hu", qinfo.nb_desc); -@@ -432,6 +446,7 @@ tx_queue_infos_display(portid_t port_id, uint16_t queue_id) - printf("\nTX deferred start: %s", - (qinfo.conf.tx_deferred_start != 0) ? "on" : "off"); - printf("\nNumber of TXDs: %hu", qinfo.nb_desc); -+ printf("\nTx queue state: %s", get_queue_state_name(qinfo.queue_state)); - - if (rte_eth_tx_burst_mode_get(port_id, queue_id, &mode) == 0) - printf("\nBurst mode: %s%s", --- -2.7.4 - diff --git a/0181-app-testpmd-fix-max-queue-number-for-Tx-offloads.patch b/0181-app-testpmd-fix-max-queue-number-for-Tx-offloads.patch deleted file mode 100644 index 99db55c..0000000 --- a/0181-app-testpmd-fix-max-queue-number-for-Tx-offloads.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 91cdc3204aec2d95d138d8fd88a16ea9af123a5f Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Thu, 22 Apr 2021 15:03:31 +0800 -Subject: [PATCH 181/189] app/testpmd: fix max queue number for Tx offloads - -When txq offload is configured, max rxq is used as the max queue. This -patch fixes it. - -Fixes: 74453ac9ef67 ("app/testpmd: fix queue offload configuration") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) -Acked-by: Xiaoyun Li ---- - app/test-pmd/cmdline.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index a64b493..59c4f7e 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -4645,7 +4645,7 @@ cmd_config_queue_tx_offloads(struct rte_port *port) - int k; - - /* Apply queue tx offloads configuration */ -- for (k = 0; k < port->dev_info.max_rx_queues; k++) -+ for (k = 0; k < port->dev_info.max_tx_queues; k++) - port->tx_conf[k].offloads = - port->dev_conf.txmode.offloads; - } --- -2.7.4 - diff --git a/0182-app-testpmd-fix-forward-lcores-number-for-DCB.patch b/0182-app-testpmd-fix-forward-lcores-number-for-DCB.patch deleted file mode 100644 index 5fabbb7..0000000 --- a/0182-app-testpmd-fix-forward-lcores-number-for-DCB.patch +++ /dev/null @@ -1,70 +0,0 @@ -From fd91f2f494b8dd91eda34ffa3d28b6e44d5988aa Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:40 +0800 -Subject: [PATCH 182/189] app/testpmd: fix forward lcores number for DCB - -For the DCB forwarding test, each core is assigned to each traffic class. -Number of forwarding cores for DCB test must be equal or less than number -of total TC. Otherwise, the following problems may occur: -1/ Redundant polling threads will be created when forwarding cores number - is greater than total TC number. -2/ Two cores would try to use a same queue on a port when Rx/Tx queue - number is greater than the used TC number, which is not allowed. - -Fixes: 900550de04a7 ("app/testpmd: add dcb support") -Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/config.c | 19 +++++++++++++++++++ - 1 file changed, 19 insertions(+) - -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index baae44e..075929c 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -3154,6 +3154,21 @@ rss_fwd_config_setup(void) - } - } - -+static uint16_t -+get_fwd_port_total_tc_num(void) -+{ -+ struct rte_eth_dcb_info dcb_info; -+ uint16_t total_tc_num = 0; -+ unsigned int i; -+ -+ for (i = 0; i < nb_fwd_ports; i++) { -+ (void)rte_eth_dev_get_dcb_info(fwd_ports_ids[i], &dcb_info); -+ total_tc_num += dcb_info.nb_tcs; -+ } -+ -+ return total_tc_num; -+} -+ - /** - * For the DCB forwarding test, each core is assigned on each traffic class. - * -@@ -3173,12 +3188,16 @@ dcb_fwd_config_setup(void) - lcoreid_t lc_id; - uint16_t nb_rx_queue, nb_tx_queue; - uint16_t i, j, k, sm_id = 0; -+ uint16_t total_tc_num; - uint8_t tc = 0; - - cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores; - cur_fwd_config.nb_fwd_ports = nb_fwd_ports; - cur_fwd_config.nb_fwd_streams = - (streamid_t) (nb_rxq * cur_fwd_config.nb_fwd_ports); -+ total_tc_num = get_fwd_port_total_tc_num(); -+ if (cur_fwd_config.nb_fwd_lcores > total_tc_num) -+ cur_fwd_config.nb_fwd_lcores = total_tc_num; - - /* reinitialize forwarding streams */ - init_fwd_streams(); --- -2.7.4 - diff --git a/0183-app-testpmd-fix-DCB-forwarding-configuration.patch b/0183-app-testpmd-fix-DCB-forwarding-configuration.patch deleted file mode 100644 index 49b9a4c..0000000 --- a/0183-app-testpmd-fix-DCB-forwarding-configuration.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 670af503ac76c38183c532f3d6163a3a832f51d9 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:41 +0800 -Subject: [PATCH 183/189] app/testpmd: fix DCB forwarding configuration -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -After DCB mode is configured, the operations of port stop and port start -change the value of the global variable "dcb_test", As a result, the -forwarding configuration from DCB to RSS mode, namely, -“dcb_fwd_config_setup()” to "rss_fwd_config_setup()". - -Currently, the 'dcb_flag' field in struct 'rte_port' indicates whether -the port is configured with DCB. And it is sufficient to have -'dcb_config' as a global variable to control the DCB test status. So -this patch deletes the "dcb_test". - -In addition, setting 'dcb_config' at the end of init_port_dcb_config() -in case that ports fail to enter DCB mode. - -Fixes: 900550de04a7 ("app/testpmd: add dcb support") -Fixes: ce8d561418d4 ("app/testpmd: add port configuration settings") -Fixes: 7741e4cf16c0 ("app/testpmd: VMDq and DCB updates") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/testpmd.c | 18 ++++-------------- - app/test-pmd/testpmd.h | 1 - - 2 files changed, 4 insertions(+), 15 deletions(-) - -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index 33a060d..e55d986 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -245,9 +245,6 @@ uint16_t mb_mempool_cache = DEF_MBUF_CACHE; /**< Size of mbuf mempool cache. */ - /* current configuration is in DCB or not,0 means it is not in DCB mode */ - uint8_t dcb_config = 0; - --/* Whether the dcb is in testing status */ --uint8_t dcb_test = 0; -- - /* - * Configurable number of RX/TX queues. - */ -@@ -2141,8 +2138,7 @@ start_packet_forwarding(int with_tx_first) - return; - } - -- -- if(dcb_test) { -+ if (dcb_config) { - for (i = 0; i < nb_fwd_ports; i++) { - pt_id = fwd_ports_ids[i]; - port = &ports[pt_id]; -@@ -2450,8 +2446,6 @@ start_port(portid_t pid) - if (port_id_is_invalid(pid, ENABLED_WARN)) - return 0; - -- if(dcb_config) -- dcb_test = 1; - RTE_ETH_FOREACH_DEV(pi) { - if (pid != pi && pid != (portid_t)RTE_PORT_ALL) - continue; -@@ -2689,11 +2683,6 @@ stop_port(portid_t pid) - portid_t peer_pl[RTE_MAX_ETHPORTS]; - int peer_pi; - -- if (dcb_test) { -- dcb_test = 0; -- dcb_config = 0; -- } -- - if (port_id_is_invalid(pid, ENABLED_WARN)) - return; - -@@ -3519,8 +3508,6 @@ init_port_dcb_config(portid_t pid, - rte_port = &ports[pid]; - - memset(&port_conf, 0, sizeof(struct rte_eth_conf)); -- /* Enter DCB configuration status */ -- dcb_config = 1; - - port_conf.rxmode = rte_port->dev_conf.rxmode; - port_conf.txmode = rte_port->dev_conf.txmode; -@@ -3588,6 +3575,9 @@ init_port_dcb_config(portid_t pid, - - rte_port->dcb_flag = 1; - -+ /* Enter DCB configuration status */ -+ dcb_config = 1; -+ - return 0; - } - -diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h -index 5f23162..303bed8 100644 ---- a/app/test-pmd/testpmd.h -+++ b/app/test-pmd/testpmd.h -@@ -423,7 +423,6 @@ extern uint64_t noisy_lkup_num_reads; - extern uint64_t noisy_lkup_num_reads_writes; - - extern uint8_t dcb_config; --extern uint8_t dcb_test; - - extern uint32_t mbuf_data_size_n; - extern uint16_t mbuf_data_size[MAX_SEGS_BUFFER_SPLIT]; --- -2.7.4 - diff --git a/0184-app-testpmd-fix-DCB-re-configuration.patch b/0184-app-testpmd-fix-DCB-re-configuration.patch deleted file mode 100644 index 419a829..0000000 --- a/0184-app-testpmd-fix-DCB-re-configuration.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 4a7456ce2099cd58f1408449520a9d66e6baa81c Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:42 +0800 -Subject: [PATCH 184/189] app/testpmd: fix DCB re-configuration - -After DCB mode is configured, if we decrease the number of RX and TX -queues, fwd_config_setup() will be called to setup the DCB forwarding -configuration. And forwarding streams are updated based on new queue -numbers in fwd_config_setup(), but the mapping between the TC and -queues obtained by rte_eth_dev_get_dcb_info() is still old queue -numbers (old queue numbers are greater than new queue numbers). -In this case, the segment fault happens. So rte_eth_dev_configure() -should be called again to update the mapping between the TC and -queues before rte_eth_dev_get_dcb_info(). - -Like: -set nbcore 4 -port stop all -port config 0 dcb vt off 4 pfc on -port start all -port stop all -port config all rxq 8 -port config all txq 8 - -Fixes: 900550de04a7 ("app/testpmd: add dcb support") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/config.c | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index 075929c..c3f9431 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -3189,7 +3189,33 @@ dcb_fwd_config_setup(void) - uint16_t nb_rx_queue, nb_tx_queue; - uint16_t i, j, k, sm_id = 0; - uint16_t total_tc_num; -+ struct rte_port *port; - uint8_t tc = 0; -+ portid_t pid; -+ int ret; -+ -+ /* -+ * The fwd_config_setup() is called when the port is RTE_PORT_STARTED -+ * or RTE_PORT_STOPPED. -+ * -+ * Re-configure ports to get updated mapping between tc and queue in -+ * case the queue number of the port is changed. Skip for started ports -+ * since modifying queue number and calling dev_configure need to stop -+ * ports first. -+ */ -+ for (pid = 0; pid < nb_fwd_ports; pid++) { -+ if (port_is_started(pid) == 1) -+ continue; -+ -+ port = &ports[pid]; -+ ret = rte_eth_dev_configure(pid, nb_rxq, nb_txq, -+ &port->dev_conf); -+ if (ret < 0) { -+ printf("Failed to re-configure port %d, ret = %d.\n", -+ pid, ret); -+ return; -+ } -+ } - - cur_fwd_config.nb_fwd_lcores = (lcoreid_t) nb_fwd_lcores; - cur_fwd_config.nb_fwd_ports = nb_fwd_ports; --- -2.7.4 - diff --git a/0185-app-testpmd-check-DCB-info-support-for-configuration.patch b/0185-app-testpmd-check-DCB-info-support-for-configuration.patch deleted file mode 100644 index 5e05e3e..0000000 --- a/0185-app-testpmd-check-DCB-info-support-for-configuration.patch +++ /dev/null @@ -1,48 +0,0 @@ -From f53ebd40c6c205fc06fab74a0f9456551a8656c1 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:43 +0800 -Subject: [PATCH 185/189] app/testpmd: check DCB info support for configuration - -Currently, '.get_dcb_info' must be supported for the port doing DCB -test, or all information in 'rte_eth_dcb_info' are zero. It should be -prevented when user run cmd "port config 0 dcb vt off 4 pfc off". - -This patch adds the check for support of reporting dcb info. - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/cmdline.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 59c4f7e..40a6871 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -3247,6 +3247,7 @@ cmd_config_dcb_parsed(void *parsed_result, - __rte_unused void *data) - { - struct cmd_config_dcb *res = parsed_result; -+ struct rte_eth_dcb_info dcb_info; - portid_t port_id = res->port_id; - struct rte_port *port; - uint8_t pfc_en; -@@ -3269,6 +3270,14 @@ cmd_config_dcb_parsed(void *parsed_result, - printf("nb_cores shouldn't be less than number of TCs.\n"); - return; - } -+ -+ /* Check whether the port supports the report of DCB info. */ -+ ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); -+ if (ret == -ENOTSUP) { -+ printf("rte_eth_dev_get_dcb_info not supported.\n"); -+ return; -+ } -+ - if (!strncmp(res->pfc_en, "on", 2)) - pfc_en = 1; - else --- -2.7.4 - diff --git a/0186-app-testpmd-verify-DCB-config-during-forward-config.patch b/0186-app-testpmd-verify-DCB-config-during-forward-config.patch deleted file mode 100644 index fe08a1a..0000000 --- a/0186-app-testpmd-verify-DCB-config-during-forward-config.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 118f18c9ab370a30a25ef548d1dee2b125bcfc16 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:44 +0800 -Subject: [PATCH 186/189] app/testpmd: verify DCB config during forward config - -Currently, the check for doing DCB test is assigned to -start_packet_forwarding(), which will be called when -run "start" cmd. But fwd_config_setup() is used in many -scenarios, such as, "port config all rxq". - -This patch moves the check from start_packet_forwarding() -to fwd_config_setup(). - -Fixes: 7741e4cf16c0 ("app/testpmd: VMDq and DCB updates") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/config.c | 23 +++++++++++++++++++++-- - app/test-pmd/testpmd.c | 19 ------------------- - 2 files changed, 21 insertions(+), 21 deletions(-) - -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index c3f9431..7af13f6 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -3345,6 +3345,10 @@ icmp_echo_config_setup(void) - void - fwd_config_setup(void) - { -+ struct rte_port *port; -+ portid_t pt_id; -+ unsigned int i; -+ - cur_fwd_config.fwd_eng = cur_fwd_eng; - if (strcmp(cur_fwd_eng->fwd_mode_name, "icmpecho") == 0) { - icmp_echo_config_setup(); -@@ -3352,9 +3356,24 @@ fwd_config_setup(void) - } - - if ((nb_rxq > 1) && (nb_txq > 1)){ -- if (dcb_config) -+ if (dcb_config) { -+ for (i = 0; i < nb_fwd_ports; i++) { -+ pt_id = fwd_ports_ids[i]; -+ port = &ports[pt_id]; -+ if (!port->dcb_flag) { -+ printf("In DCB mode, all forwarding ports must " -+ "be configured in this mode.\n"); -+ return; -+ } -+ } -+ if (nb_fwd_lcores == 1) { -+ printf("In DCB mode,the nb forwarding cores " -+ "should be larger than 1.\n"); -+ return; -+ } -+ - dcb_fwd_config_setup(); -- else -+ } else - rss_fwd_config_setup(); - } - else -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index e55d986..f9155ae 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -2112,9 +2112,7 @@ start_packet_forwarding(int with_tx_first) - { - port_fwd_begin_t port_fwd_begin; - port_fwd_end_t port_fwd_end; -- struct rte_port *port; - unsigned int i; -- portid_t pt_id; - - if (strcmp(cur_fwd_eng->fwd_mode_name, "rxonly") == 0 && !nb_rxq) - rte_exit(EXIT_FAILURE, "rxq are 0, cannot use rxonly fwd mode\n"); -@@ -2137,23 +2135,6 @@ start_packet_forwarding(int with_tx_first) - printf("Packet forwarding already started\n"); - return; - } -- -- if (dcb_config) { -- for (i = 0; i < nb_fwd_ports; i++) { -- pt_id = fwd_ports_ids[i]; -- port = &ports[pt_id]; -- if (!port->dcb_flag) { -- printf("In DCB mode, all forwarding ports must " -- "be configured in this mode.\n"); -- return; -- } -- } -- if (nb_fwd_lcores == 1) { -- printf("In DCB mode,the nb forwarding cores " -- "should be larger than 1.\n"); -- return; -- } -- } - test_done = 0; - - fwd_config_setup(); --- -2.7.4 - diff --git a/0187-app-testpmd-add-forwarding-configuration-to-DCB-conf.patch b/0187-app-testpmd-add-forwarding-configuration-to-DCB-conf.patch deleted file mode 100644 index 9c3b3fd..0000000 --- a/0187-app-testpmd-add-forwarding-configuration-to-DCB-conf.patch +++ /dev/null @@ -1,40 +0,0 @@ -From b7e79c9c712372946ccd9ce66bd3d1b91cd0a9d1 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:45 +0800 -Subject: [PATCH 187/189] app/testpmd: add forwarding configuration to DCB - config - -This patch adds fwd_config_setup() at the end of cmd_config_dcb_parsed() -to update "cur_fwd_config", so that the actual forwarding streams can be -queried by the "show config fwd" cmd. - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/cmdline.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 40a6871..78db462 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -3292,13 +3292,13 @@ cmd_config_dcb_parsed(void *parsed_result, - ret = init_port_dcb_config(port_id, DCB_ENABLED, - (enum rte_eth_nb_tcs)res->num_tcs, - pfc_en); -- -- - if (ret != 0) { - printf("Cannot initialize network ports.\n"); - return; - } - -+ fwd_config_setup(); -+ - cmd_reconfig_device_queue(port_id, 1, 1); - } - --- -2.7.4 - diff --git a/0188-app-testpmd-remove-redundant-forwarding-initializati.patch b/0188-app-testpmd-remove-redundant-forwarding-initializati.patch deleted file mode 100644 index 640ad6b..0000000 --- a/0188-app-testpmd-remove-redundant-forwarding-initializati.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 998201309e193b7203ad6418c184993e0f61fc28 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 14:40:46 +0800 -Subject: [PATCH 188/189] app/testpmd: remove redundant forwarding - initialization - -The fwd_config_setup() is called after init_fwd_streams(). -The fwd_config_setup() will reinitialize forwarding streams. -This patch removes init_fwd_streams() from init_config(). - -Signed-off-by: Huisong Li -Signed-off-by: Lijun Ou -Acked-by: Xiaoyun Li ---- - app/test-pmd/testpmd.c | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index f9155ae..3098df6 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -1559,10 +1559,6 @@ init_config(void) - fwd_lcores[lc_id]->gso_ctx.flag = 0; - } - -- /* Configuration of packet forwarding streams. */ -- if (init_fwd_streams() < 0) -- rte_exit(EXIT_FAILURE, "FAIL from init_fwd_streams()\n"); -- - fwd_config_setup(); - - /* create a gro context for each lcore */ --- -2.7.4 - diff --git a/0189-config-arm-check-SVE-CPU-flag.patch b/0189-config-arm-check-SVE-CPU-flag.patch deleted file mode 100644 index 00a8235..0000000 --- a/0189-config-arm-check-SVE-CPU-flag.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 5108d77df4a599d04d378368247e0d234d01766e Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 21 May 2021 11:33:54 +0800 -Subject: [PATCH 01/26] config/arm: check SVE CPU flag - -If compiled with SVE feature (e.g. "-march=armv8.2-a+sve'), the binary -could not run on non-SVE platform else it will encounter illegal -instruction [1]. - -This patch fixes it by adding 'RTE_CPUFLAG_SVE' to compile_time_cpuflags, -so that rte_cpu_is_supported() will print meaningful log under above -situation. - -[1] http://mails.dpdk.org/archives/dev/2021-May/209124.html - -Signed-off-by: Chengwen Feng -Acked-by: Ruifeng Wang ---- - config/arm/meson.build | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/config/arm/meson.build b/config/arm/meson.build -index 42b4e43..b18acea 100644 ---- a/config/arm/meson.build -+++ b/config/arm/meson.build -@@ -214,6 +214,10 @@ if (cc.get_define('__ARM_NEON', args: machine_args) != '' or - compile_time_cpuflags += ['RTE_CPUFLAG_NEON'] - endif - -+if cc.get_define('__ARM_FEATURE_SVE', args: machine_args) != '' -+ compile_time_cpuflags += ['RTE_CPUFLAG_SVE'] -+endif -+ - if cc.get_define('__ARM_FEATURE_CRC32', args: machine_args) != '' - compile_time_cpuflags += ['RTE_CPUFLAG_CRC32'] - endif --- -2.7.4 - diff --git a/0189-net-fix-compiling-bug-for-20.11-merge.patch b/0189-net-fix-compiling-bug-for-20.11-merge.patch deleted file mode 100644 index d857b83..0000000 --- a/0189-net-fix-compiling-bug-for-20.11-merge.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 2fa098fa0c4986f77f00521bc7ef50948397a6ef Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 10 Jun 2021 15:21:07 +0800 -Subject: [PATCH 189/189] net: fix compiling bug for 20.11 merge - -This patch add byte order support for definition. - -Signed-off-by: Min Hu (Connor) ---- - lib/librte_net/rte_geneve.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/lib/librte_net/rte_geneve.h b/lib/librte_net/rte_geneve.h -index bb67724..3bbc561 100644 ---- a/lib/librte_net/rte_geneve.h -+++ b/lib/librte_net/rte_geneve.h -@@ -12,6 +12,8 @@ - */ - #include - -+#include -+ - #ifdef __cplusplus - extern "C" { - #endif --- -2.7.4 - diff --git a/0190-net-hns3-increase-VF-reset-retry-maximum.patch b/0190-net-hns3-increase-VF-reset-retry-maximum.patch deleted file mode 100644 index ebf60ff..0000000 --- a/0190-net-hns3-increase-VF-reset-retry-maximum.patch +++ /dev/null @@ -1,46 +0,0 @@ -From ef9a1fa57d0e364793481727fecc3833b5a82918 Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Sun, 13 Jun 2021 10:31:51 +0800 -Subject: [PATCH 02/26] net/hns3: increase VF reset retry maximum - -When the device is very busy, VF reset may have to be -retried many times to succeed, leading to the current -max reset fail retry count not enough. - -Modify max reset fail retry count to 30 to enhance -the reliability of reset function. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_intr.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 854cb1d..e8ca6d5 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2582,7 +2582,7 @@ hns3_clear_reset_level(struct hns3_hw *hw, uint64_t *levels) - static bool - hns3_reset_err_handle(struct hns3_adapter *hns) - { --#define MAX_RESET_FAIL_CNT 5 -+#define MAX_RESET_FAIL_CNT 30 - - struct hns3_hw *hw = &hns->hw; - -@@ -2676,7 +2676,7 @@ hns3_reset_pre(struct hns3_adapter *hns) - static int - hns3_reset_post(struct hns3_adapter *hns) - { --#define TIMEOUT_RETRIES_CNT 5 -+#define TIMEOUT_RETRIES_CNT 30 - struct hns3_hw *hw = &hns->hw; - struct timeval tv_delta; - struct timeval tv; --- -2.7.4 - diff --git a/0191-net-hns3-fix-delay-for-waiting-to-stop-Rx-Tx.patch b/0191-net-hns3-fix-delay-for-waiting-to-stop-Rx-Tx.patch deleted file mode 100644 index 58ec457..0000000 --- a/0191-net-hns3-fix-delay-for-waiting-to-stop-Rx-Tx.patch +++ /dev/null @@ -1,69 +0,0 @@ -From 00276e9b4577158de8d920dd58e486a00d6fe27d Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sun, 13 Jun 2021 10:31:52 +0800 -Subject: [PATCH 03/26] net/hns3: fix delay for waiting to stop Rx/Tx - -When the primary process executes dev_stop or is being reset, the packet -sending and receiving functions is changed. In this moment, the primary -process requests secondary processes to change their Rx/Tx functions, and -delays a period of time in case of crashes when queues are still in use. -The delay time depends on the number of queues actually used, instead of -the maximum number of queues supported by the device. - -Fixes: 23d4b61fee5d ("net/hns3: support multiple process") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 4 ++-- - drivers/net/hns3/hns3_ethdev_vf.c | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 351dc59..f34e117 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5892,7 +5892,7 @@ hns3_dev_stop(struct rte_eth_dev *dev) - /* Disable datapath on secondary process. */ - hns3_mp_req_stop_rxtx(dev); - /* Prevent crashes when queues are still in use. */ -- rte_delay_ms(hw->tqps_num); -+ rte_delay_ms(hw->cfg_max_queues); - - rte_spinlock_lock(&hw->lock); - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { -@@ -6508,7 +6508,7 @@ hns3_stop_service(struct hns3_adapter *hns) - rte_wmb(); - /* Disable datapath on secondary process. */ - hns3_mp_req_stop_rxtx(eth_dev); -- rte_delay_ms(hw->tqps_num); -+ rte_delay_ms(hw->cfg_max_queues); - - rte_spinlock_lock(&hw->lock); - if (hns->hw.adapter_state == HNS3_NIC_STARTED || -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 030d63a..1819677 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2107,7 +2107,7 @@ hns3vf_dev_stop(struct rte_eth_dev *dev) - /* Disable datapath on secondary process. */ - hns3_mp_req_stop_rxtx(dev); - /* Prevent crashes when queues are still in use. */ -- rte_delay_ms(hw->tqps_num); -+ rte_delay_ms(hw->cfg_max_queues); - - rte_spinlock_lock(&hw->lock); - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { -@@ -2555,7 +2555,7 @@ hns3vf_stop_service(struct hns3_adapter *hns) - rte_wmb(); - /* Disable datapath on secondary process. */ - hns3_mp_req_stop_rxtx(eth_dev); -- rte_delay_ms(hw->tqps_num); -+ rte_delay_ms(hw->cfg_max_queues); - - rte_spinlock_lock(&hw->lock); - if (hw->adapter_state == HNS3_NIC_STARTED || --- -2.7.4 - diff --git a/0192-net-hns3-fix-fake-queue-rollback.patch b/0192-net-hns3-fix-fake-queue-rollback.patch deleted file mode 100644 index 4c4eb70..0000000 --- a/0192-net-hns3-fix-fake-queue-rollback.patch +++ /dev/null @@ -1,84 +0,0 @@ -From f56028fd10925831f3a0e092d317aef165ef9989 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sun, 13 Jun 2021 10:31:53 +0800 -Subject: [PATCH 04/26] net/hns3: fix fake queue rollback - -When the device supports independent Rx/Tx queues, fake queues do not need -to be created in unequal Rx/Tx queues case. However, dev_configure fails -to be executed on the device supported independent Rx/Tx queues, the -current rollback code logic contains the fake queue. As a result, the fake -queue is created. When dev_configure is successfully called again, these -fake queues still exists and are configured to the hardware. - -Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 11 ++++------- - drivers/net/hns3/hns3_ethdev_vf.c | 11 ++++------- - drivers/net/hns3/hns3_rxtx.c | 3 +++ - 3 files changed, 11 insertions(+), 14 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f34e117..54a2bc7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2497,13 +2497,10 @@ hns3_dev_configure(struct rte_eth_dev *dev) - * work as usual. But these fake queues are imperceptible, and can not - * be used by upper applications. - */ -- if (!hns3_dev_indep_txrx_supported(hw)) { -- ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); -- if (ret) { -- hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", -- ret); -- return ret; -- } -+ ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); -+ if (ret) { -+ hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret); -+ return ret; - } - - hw->adapter_state = HNS3_NIC_CONFIGURING; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 1819677..3631022 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -801,13 +801,10 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - * work as usual. But these fake queues are imperceptible, and can not - * be used by upper applications. - */ -- if (!hns3_dev_indep_txrx_supported(hw)) { -- ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); -- if (ret) { -- hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", -- ret); -- return ret; -- } -+ ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); -+ if (ret) { -+ hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret); -+ return ret; - } - - hw->adapter_state = HNS3_NIC_CONFIGURING; -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 6aa2887..3c645b3 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1617,6 +1617,9 @@ hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q, - uint16_t q; - int ret; - -+ if (hns3_dev_indep_txrx_supported(hw)) -+ return 0; -+ - /* Setup new number of fake RX/TX queues and reconfigure device. */ - rx_need_add_nb_q = hw->cfg_max_queues - nb_rx_q; - tx_need_add_nb_q = hw->cfg_max_queues - nb_tx_q; --- -2.7.4 - diff --git a/0193-net-hns3-fix-VLAN-strip-log.patch b/0193-net-hns3-fix-VLAN-strip-log.patch deleted file mode 100644 index 69a6a99..0000000 --- a/0193-net-hns3-fix-VLAN-strip-log.patch +++ /dev/null @@ -1,49 +0,0 @@ -From dabf2fc6e1ae8d1a4b87f9b8603d5666a8b05efb Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sun, 13 Jun 2021 10:31:54 +0800 -Subject: [PATCH 05/26] net/hns3: fix VLAN strip log - -When the current VLAN stripping is set, the log print always prompts -that the enabling fails, bug if may actually be the disabling failure. - -Fixes: 411d23b9eafb ("net/hns3: support VLAN") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 3 ++- - drivers/net/hns3/hns3_ethdev_vf.c | 3 ++- - 2 files changed, 4 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 54a2bc7..3ecdd68 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -640,7 +640,8 @@ hns3_en_hw_strip_rxvtag(struct hns3_adapter *hns, bool enable) - - ret = hns3_set_vlan_rx_offload_cfg(hns, &rxvlan_cfg); - if (ret) { -- hns3_err(hw, "enable strip rx vtag failed, ret =%d", ret); -+ hns3_err(hw, "%s strip rx vtag failed, ret = %d.", -+ enable ? "enable" : "disable", ret); - return ret; - } - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 3631022..cd59ae2 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1606,7 +1606,8 @@ hns3vf_en_hw_strip_rxvtag(struct hns3_hw *hw, bool enable) - ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, HNS3_MBX_VLAN_RX_OFF_CFG, - &msg_data, sizeof(msg_data), false, NULL, 0); - if (ret) -- hns3_err(hw, "vf enable strip failed, ret =%d", ret); -+ hns3_err(hw, "vf %s strip failed, ret = %d.", -+ enable ? "enable" : "disable", ret); - - return ret; - } --- -2.7.4 - diff --git a/0194-net-hns3-fix-maximum-queues-on-configuration-failure.patch b/0194-net-hns3-fix-maximum-queues-on-configuration-failure.patch deleted file mode 100644 index 52ad265..0000000 --- a/0194-net-hns3-fix-maximum-queues-on-configuration-failure.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 592de3eb443016be571a13fd90cb7cc35bd98679 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sun, 13 Jun 2021 10:31:55 +0800 -Subject: [PATCH 06/26] net/hns3: fix maximum queues on configuration failure - -The "cfg_max_queues" maintains configured max queue numbers from user, -and is equal to the maximum of "nb_rx_queues" and "nb_tx_queues" in -"dev->data". - -From the ethdev layer framework, "nb_rx/tx_queues" in "dev->data" were set -to zero in rte_eth_dev_configure() if ops.dev_configure in PMD fails to be -executed, In addition, if ops.dev_configure in HNS3 PMD failed, the fake -queues are also cleared on a device that does not support independent Rx/Tx -queues. - -Therefore, the "cfg_max_queues" should be also set to zero when -dev_configure fails. - -Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 2 ++ - 2 files changed, 4 insertions(+) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 3ecdd68..45ce54c 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2501,6 +2501,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) - ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); - if (ret) { - hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret); -+ hw->cfg_max_queues = 0; - return ret; - } - -@@ -2549,6 +2550,7 @@ hns3_dev_configure(struct rte_eth_dev *dev) - return 0; - - cfg_err: -+ hw->cfg_max_queues = 0; - (void)hns3_set_fake_rx_or_tx_queues(dev, 0, 0); - hw->adapter_state = HNS3_NIC_INITIALIZED; - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index cd59ae2..cbc3456 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -804,6 +804,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - ret = hns3_set_fake_rx_or_tx_queues(dev, nb_rx_q, nb_tx_q); - if (ret) { - hns3_err(hw, "fail to set Rx/Tx fake queues, ret = %d.", ret); -+ hw->cfg_max_queues = 0; - return ret; - } - -@@ -863,6 +864,7 @@ hns3vf_dev_configure(struct rte_eth_dev *dev) - return 0; - - cfg_err: -+ hw->cfg_max_queues = 0; - (void)hns3_set_fake_rx_or_tx_queues(dev, 0, 0); - hw->adapter_state = HNS3_NIC_INITIALIZED; - --- -2.7.4 - diff --git a/0195-net-hns3-remove-unnecessary-blank-lines.patch b/0195-net-hns3-remove-unnecessary-blank-lines.patch deleted file mode 100644 index 83bb200..0000000 --- a/0195-net-hns3-remove-unnecessary-blank-lines.patch +++ /dev/null @@ -1,64 +0,0 @@ -From c30146c22a93c86c1dcd296eddd99c620b741b8e Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Sun, 13 Jun 2021 10:31:56 +0800 -Subject: [PATCH 07/26] net/hns3: remove unnecessary blank lines - -Delete redundant blank lines to make: -1.Return value judgment follow the function call. -2.No blank lines at the end of a code block defined by braces. - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 45ce54c..a80bc56 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -253,8 +253,8 @@ static void - hns3_clear_all_event_cause(struct hns3_hw *hw) - { - uint32_t vector0_int_stats; -- vector0_int_stats = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); - -+ vector0_int_stats = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); - if (BIT(HNS3_VECTOR0_IMPRESET_INT_B) & vector0_int_stats) - hns3_warn(hw, "Probe during IMP reset interrupt"); - -@@ -3124,7 +3124,6 @@ hns3_parse_cfg(struct hns3_cfg *cfg, struct hns3_cmd_desc *desc) - ext_rss_size_max = hns3_get_field(rte_le_to_cpu_32(req->param[2]), - HNS3_CFG_EXT_RSS_SIZE_M, - HNS3_CFG_EXT_RSS_SIZE_S); -- - /* - * Field ext_rss_size_max obtained from firmware will be more flexible - * for future changes and expansions, which is an exponent of 2, instead -@@ -3843,7 +3842,6 @@ hns3_drop_nopfc_buf_till_fit(struct hns3_hw *hw, - for (i = HNS3_MAX_TC_NUM - 1; i >= 0; i--) { - priv = &buf_alloc->priv_buf[i]; - mask = BIT((uint8_t)i); -- - if (hw->hw_tc_map & mask && - !(hw->dcb_info.hw_pfc_map & mask)) { - /* Clear the no pfc TC private buffer */ -@@ -3929,7 +3927,6 @@ hns3_only_alloc_priv_buff(struct hns3_hw *hw, - COMPENSATE_HALF_MPS_NUM * half_mps; - min_rx_priv = roundup(min_rx_priv, HNS3_BUF_SIZE_UNIT); - rx_priv = rounddown(rx_priv, HNS3_BUF_SIZE_UNIT); -- - if (rx_priv < min_rx_priv) - return false; - -@@ -6294,7 +6291,6 @@ hns3_is_reset_pending(struct hns3_adapter *hns) - - hns3_check_event_cause(hns, NULL); - reset = hns3_get_reset_level(hns, &hw->reset.pending); -- - if (reset != HNS3_NONE_RESET && hw->reset.level != HNS3_NONE_RESET && - hw->reset.level < reset) { - hns3_warn(hw, "High level reset %d is pending", reset); --- -2.7.4 - diff --git a/0196-net-hns3-support-Tx-push-quick-doorbell-for-performa.patch b/0196-net-hns3-support-Tx-push-quick-doorbell-for-performa.patch deleted file mode 100644 index 6c05942..0000000 --- a/0196-net-hns3-support-Tx-push-quick-doorbell-for-performa.patch +++ /dev/null @@ -1,277 +0,0 @@ -From 4c96351a025f35434d6d3e01a31072866cf826d6 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 15 Jun 2021 09:34:29 +0800 -Subject: [PATCH 08/26] net/hns3: support Tx push quick doorbell for - performance - -Kunpeng 930 support Tx push mode which could improve performance. -It works like below: - 1. Add PCIe bar45 which support driver direct write the Tx descriptor - or tail reg to it. - 2. Support three operations: a) direct write one Tx descriptor, b) - direct write two Tx descriptors, c) direct write tail reg. - 3. The original tail reg located at bar23, the above bar45 tail reg - could provide better bandwidth from the hardware perspective. - -The hns3 driver only support direct write tail reg (also have the name -of quick doorbell), the detail: -Considering compatibility, firmware will report Tx push capa if the -hardware support it. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 4 +- - drivers/net/hns3/hns3_ethdev.h | 4 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 4 +- - drivers/net/hns3/hns3_rxtx.c | 73 ++++++++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_rxtx.h | 19 +++++++++ - drivers/net/hns3/hns3_rxtx_vec_neon.h | 2 +- - drivers/net/hns3/hns3_rxtx_vec_sve.c | 2 +- - 7 files changed, 102 insertions(+), 6 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index a80bc56..7283364 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5171,6 +5171,8 @@ hns3_init_pf(struct rte_eth_dev *eth_dev) - goto err_cmd_init; - } - -+ hns3_tx_push_init(eth_dev); -+ - /* - * To ensure that the hardware environment is clean during - * initialization, the driver actively clear the hardware environment -@@ -7415,8 +7417,8 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - "process, ret = %d", ret); - goto err_mp_init_secondary; - } -- - hw->secondary_cnt++; -+ hns3_tx_push_init(eth_dev); - return 0; - } - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 53dc498..f3bc60e 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -862,6 +862,7 @@ enum { - HNS3_DEV_SUPPORT_COPPER_B, - HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B, - HNS3_DEV_SUPPORT_PTP_B, -+ HNS3_DEV_SUPPORT_TX_PUSH_B, - HNS3_DEV_SUPPORT_INDEP_TXRX_B, - HNS3_DEV_SUPPORT_STASH_B, - HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, -@@ -900,6 +901,9 @@ enum { - #define hns3_dev_ras_imp_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_RAS_IMP_B) - -+#define hns3_dev_tx_push_supported(hw) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TX_PUSH_B) -+ - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index cbc3456..2085a29 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1921,6 +1921,8 @@ hns3vf_init_vf(struct rte_eth_dev *eth_dev) - goto err_cmd_init; - } - -+ hns3_tx_push_init(eth_dev); -+ - /* Get VF resource */ - ret = hns3_query_vf_resource(hw); - if (ret) -@@ -2925,8 +2927,8 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - "process, ret = %d", ret); - goto err_mp_init_secondary; - } -- - hw->secondary_cnt++; -+ hns3_tx_push_init(eth_dev); - return 0; - } - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 3c645b3..51b727f 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2895,6 +2895,69 @@ hns3_tx_queue_conf_check(struct hns3_hw *hw, const struct rte_eth_txconf *conf, - return 0; - } - -+static void * -+hns3_tx_push_get_queue_tail_reg(struct rte_eth_dev *dev, uint16_t queue_id) -+{ -+#define HNS3_TX_PUSH_TQP_REGION_SIZE 0x10000 -+#define HNS3_TX_PUSH_QUICK_DOORBELL_OFFSET 64 -+#define HNS3_TX_PUSH_PCI_BAR_INDEX 4 -+ -+ struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(dev->device); -+ uint8_t bar_id = HNS3_TX_PUSH_PCI_BAR_INDEX; -+ -+ /* -+ * If device support Tx push then its PCIe bar45 must exist, and DPDK -+ * framework will mmap the bar45 default in PCI probe stage. -+ * -+ * In the bar45, the first half is for RoCE (RDMA over Converged -+ * Ethernet), and the second half is for NIC, every TQP occupy 64KB. -+ * -+ * The quick doorbell located at 64B offset in the TQP region. -+ */ -+ return (char *)pci_dev->mem_resource[bar_id].addr + -+ (pci_dev->mem_resource[bar_id].len >> 1) + -+ HNS3_TX_PUSH_TQP_REGION_SIZE * queue_id + -+ HNS3_TX_PUSH_QUICK_DOORBELL_OFFSET; -+} -+ -+void -+hns3_tx_push_init(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ volatile uint32_t *reg; -+ uint32_t val; -+ -+ if (!hns3_dev_tx_push_supported(hw)) -+ return; -+ -+ reg = (volatile uint32_t *)hns3_tx_push_get_queue_tail_reg(dev, 0); -+ /* -+ * Because the size of bar45 is about 8GB size, it may take a long time -+ * to do the page fault in Tx process when work with vfio-pci, so use -+ * one read operation to make kernel setup page table mapping for bar45 -+ * in the init stage. -+ * Note: the bar45 is readable but the result is all 1. -+ */ -+ val = *reg; -+ RTE_SET_USED(val); -+} -+ -+static void -+hns3_tx_push_queue_init(struct rte_eth_dev *dev, -+ uint16_t queue_id, -+ struct hns3_tx_queue *txq) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ if (!hns3_dev_tx_push_supported(hw)) { -+ txq->tx_push_enable = false; -+ return; -+ } -+ -+ txq->io_tail_reg = (volatile void *)hns3_tx_push_get_queue_tail_reg(dev, -+ queue_id); -+ txq->tx_push_enable = true; -+} -+ - int - hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - unsigned int socket_id, const struct rte_eth_txconf *conf) -@@ -2986,6 +3049,12 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - memset(&txq->basic_stats, 0, sizeof(struct hns3_tx_basic_stats)); - memset(&txq->dfx_stats, 0, sizeof(struct hns3_tx_dfx_stats)); - -+ /* -+ * Call hns3_tx_push_queue_init after assigned io_tail_reg field because -+ * it may overwrite the io_tail_reg field. -+ */ -+ hns3_tx_push_queue_init(dev, idx, txq); -+ - rte_spinlock_lock(&hw->lock); - dev->data->tx_queues[idx] = txq; - rte_spinlock_unlock(&hw->lock); -@@ -4032,7 +4101,7 @@ hns3_xmit_pkts_simple(void *tx_queue, - hns3_tx_fill_hw_ring(txq, tx_pkts + nb_tx, nb_pkts - nb_tx); - txq->next_to_use += nb_pkts - nb_tx; - -- hns3_write_reg_opt(txq->io_tail_reg, nb_pkts); -+ hns3_write_txq_tail_reg(txq, nb_pkts); - - return nb_pkts; - } -@@ -4149,7 +4218,7 @@ hns3_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) - end_of_tx: - - if (likely(nb_tx)) -- hns3_write_reg_opt(txq->io_tail_reg, nb_hold); -+ hns3_write_txq_tail_reg(txq, nb_hold); - - return nb_tx; - } -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index a42ab71..e01e582 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -419,6 +419,7 @@ struct hns3_tx_dfx_stats { - }; - - struct hns3_tx_queue { -+ /* The io_tail_reg is write-only if working in tx push mode */ - volatile void *io_tail_reg; - struct hns3_desc *tx_ring; - struct hns3_entry *sw_ring; -@@ -659,6 +660,23 @@ hns3_rx_calc_ptype(struct hns3_rx_queue *rxq, const uint32_t l234_info, - return ptype_tbl->l3table[l3id] | ptype_tbl->l4table[l4id]; - } - -+/* -+ * If enable using Tx push feature and also device support it, then use quick -+ * doorbell (bar45) to inform the hardware. -+ * -+ * The other cases (such as: device don't support or user don't enable using) -+ * then use normal doorbell (bar23) to inform the hardware. -+ */ -+static inline void -+hns3_write_txq_tail_reg(struct hns3_tx_queue *txq, uint32_t value) -+{ -+ rte_io_wmb(); -+ if (txq->tx_push_enable) -+ rte_write64_relaxed(rte_cpu_to_le_32(value), txq->io_tail_reg); -+ else -+ rte_write32_relaxed(rte_cpu_to_le_32(value), txq->io_tail_reg); -+} -+ - void hns3_dev_rx_queue_release(void *queue); - void hns3_dev_tx_queue_release(void *queue); - void hns3_free_all_queues(struct rte_eth_dev *dev); -@@ -741,5 +759,6 @@ int hns3_tx_done_cleanup(void *txq, uint32_t free_cnt); - void hns3_enable_rxd_adv_layout(struct hns3_hw *hw); - int hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); - int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); -+void hns3_tx_push_init(struct rte_eth_dev *dev); - - #endif /* _HNS3_RXTX_H_ */ -diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h -index 35fef12..30a7d70 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_neon.h -+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h -@@ -84,7 +84,7 @@ hns3_xmit_fixed_burst_vec(void *__restrict tx_queue, - txq->next_to_use = next_to_use; - txq->tx_bd_ready -= nb_tx; - -- hns3_write_reg_opt(txq->io_tail_reg, nb_tx); -+ hns3_write_txq_tail_reg(txq, nb_tx); - - return nb_tx; - } -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index be9a4ff..c861887 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -475,7 +475,7 @@ hns3_xmit_fixed_burst_vec_sve(void *__restrict tx_queue, - txq->next_to_use += nb_pkts - nb_tx; - - txq->tx_bd_ready -= nb_pkts; -- hns3_write_reg_opt(txq->io_tail_reg, nb_pkts); -+ hns3_write_txq_tail_reg(txq, nb_pkts); - - return nb_pkts; - } --- -2.7.4 - diff --git a/0197-net-hns3-fix-traffic-management.patch b/0197-net-hns3-fix-traffic-management.patch deleted file mode 100644 index 2b77f6a..0000000 --- a/0197-net-hns3-fix-traffic-management.patch +++ /dev/null @@ -1,311 +0,0 @@ -From 78db1dbe9adf7ed0fedd6331dcd3a2c1ee0b85c4 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Mon, 21 Jun 2021 15:38:45 +0800 -Subject: [PATCH 09/26] net/hns3: fix traffic management - -In a multi-TC scenario, if the length of packets destined for different -TCs is different, for example, 64B and 1500B packets destined for TC0 and -TC1 respectively. There is a problem that the bandwidth of the TC to which -large packets are sent is preempted by the TC to which small packets are -sent on the Kunpeng 920 network engine. As a result, the TC bandwidth -accuracy is inaccurate. - -To solve this problem, this patch made the following adjustments: -1/ During initialization, firmware reports the capability bit indicating -whether the TM function is supported. -2/ The command word for configuring TC and port rate limiting is added, -instead of reusing the existing command word. And firmware configured -to the correct module. -3/ When the PF driver is loaded, firmware completes the default -initialization of the TC and port. - -Fixes: c09c7847d892 ("net/hns3: support traffic management") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 5 ++- - drivers/net/hns3/hns3_cmd.h | 4 +++ - drivers/net/hns3/hns3_dcb.c | 4 +-- - drivers/net/hns3/hns3_dcb.h | 2 -- - drivers/net/hns3/hns3_ethdev.h | 4 +++ - drivers/net/hns3/hns3_tm.c | 69 +++++++++++++++++++++++++++++------------- - drivers/net/hns3/hns3_tm.h | 12 ++++++++ - 7 files changed, 74 insertions(+), 26 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 5f4d74d..ab92240 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -431,7 +431,8 @@ hns3_get_caps_name(uint32_t caps_id) - { HNS3_CAPS_STASH_B, "stash" }, - { HNS3_CAPS_UDP_TUNNEL_CSUM_B, "udp_tunnel_csum" }, - { HNS3_CAPS_RAS_IMP_B, "ras_imp" }, -- { HNS3_CAPS_RXD_ADV_LAYOUT_B, "rxd_adv_layout" } -+ { HNS3_CAPS_RXD_ADV_LAYOUT_B, "rxd_adv_layout" }, -+ { HNS3_CAPS_TM_B, "tm_capability" } - }; - uint32_t i; - -@@ -507,6 +508,8 @@ hns3_parse_capability(struct hns3_hw *hw, - HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_RAS_IMP_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_RAS_IMP_B, 1); -+ if (hns3_get_bit(caps, HNS3_CAPS_TM_B)) -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TM_B, 1); - } - - static uint32_t -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index a249a7a..cd58303 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -162,6 +162,9 @@ enum hns3_opcode_type { - HNS3_OPC_TM_INTERNAL_CNT = 0x0851, - HNS3_OPC_TM_INTERNAL_STS_1 = 0x0852, - -+ HNS3_OPC_TM_PORT_LIMIT_RATE = 0x0870, -+ HNS3_OPC_TM_TC_LIMIT_RATE = 0x0871, -+ - /* Mailbox cmd */ - HNS3_OPC_MBX_VF_TO_PF = 0x2001, - -@@ -319,6 +322,7 @@ enum HNS3_CAPS_BITS { - HNS3_CAPS_UDP_TUNNEL_CSUM_B, - HNS3_CAPS_RAS_IMP_B, - HNS3_CAPS_RXD_ADV_LAYOUT_B = 15, -+ HNS3_CAPS_TM_B = 17, - }; - - enum HNS3_API_CAP_BITS { -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 8778452..61a2404 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -415,7 +415,7 @@ hns3_dcb_pg_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, - return hns3_cmd_send(hw, &desc, 1); - } - --int -+static int - hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate) - { - struct hns3_shaper_parameter shaper_parameter; -@@ -551,7 +551,7 @@ hns3_dcb_pri_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, - return hns3_cmd_send(hw, &desc, 1); - } - --int -+static int - hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate) - { - struct hns3_shaper_parameter shaper_parameter; -diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h -index 279f163..1abe649 100644 ---- a/drivers/net/hns3/hns3_dcb.h -+++ b/drivers/net/hns3/hns3_dcb.h -@@ -209,8 +209,6 @@ int hns3_queue_to_tc_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, - - int hns3_update_queue_map_configure(struct hns3_adapter *hns); - int hns3_port_shaper_update(struct hns3_hw *hw, uint32_t speed); --int hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate); --int hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate); - uint8_t hns3_txq_mapped_tc_get(struct hns3_hw *hw, uint16_t txq_no); - - #endif /* _HNS3_DCB_H_ */ -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index f3bc60e..31379fd 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -868,6 +868,7 @@ enum { - HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B, - HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, - HNS3_DEV_SUPPORT_RAS_IMP_B, -+ HNS3_DEV_SUPPORT_TM_B, - }; - - #define hns3_dev_dcb_supported(hw) \ -@@ -904,6 +905,9 @@ enum { - #define hns3_dev_tx_push_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TX_PUSH_B) - -+#define hns3_dev_tm_supported(hw) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TM_B) -+ - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index f7bfc25..81c61ad 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -28,8 +28,12 @@ void - hns3_tm_conf_init(struct rte_eth_dev *dev) - { - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); - -+ if (!hns3_dev_tm_supported(hw)) -+ return; -+ - pf->tm_conf.nb_leaf_nodes_max = max_tx_queues; - pf->tm_conf.nb_nodes_max = 1 + HNS3_MAX_TC_NUM + max_tx_queues; - pf->tm_conf.nb_shaper_profile_max = 1 + HNS3_MAX_TC_NUM; -@@ -50,9 +54,13 @@ void - hns3_tm_conf_uninit(struct rte_eth_dev *dev) - { - struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_tm_shaper_profile *shaper_profile; - struct hns3_tm_node *tm_node; - -+ if (!hns3_dev_tm_supported(hw)) -+ return; -+ - if (pf->tm_conf.nb_queue_node > 0) { - while ((tm_node = TAILQ_FIRST(&pf->tm_conf.queue_list))) { - TAILQ_REMOVE(&pf->tm_conf.queue_list, tm_node, node); -@@ -912,40 +920,39 @@ static int - hns3_tm_config_port_rate(struct hns3_hw *hw, - struct hns3_tm_shaper_profile *shaper_profile) - { -+ struct hns3_port_limit_rate_cmd *cfg; -+ struct hns3_cmd_desc desc; - uint32_t firmware_rate; - uint64_t rate; -+ int ret; - - if (shaper_profile) { - rate = shaper_profile->profile.peak.rate; - firmware_rate = hns3_tm_rate_convert_tm2firmware(rate); - } else { -- firmware_rate = hw->dcb_info.pg_info[0].bw_limit; -+ firmware_rate = hw->max_tm_rate; - } - -- /* -- * The TM shaper topology after device inited: -- * pri0 shaper --->| -- * pri1 shaper --->| -- * ... |----> pg0 shaper ----> port shaper -- * ... | -- * priX shaper --->| -- * -- * Because port shaper rate maybe changed by firmware, to avoid -- * concurrent configure, driver use pg0 shaper to achieve the rate limit -- * of port. -- * -- * The finally port rate = MIN(pg0 shaper rate, port shaper rate) -- */ -- return hns3_pg_shaper_rate_cfg(hw, 0, firmware_rate); -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_TM_PORT_LIMIT_RATE, false); -+ cfg = (struct hns3_port_limit_rate_cmd *)desc.data; -+ cfg->speed = rte_cpu_to_le_32(firmware_rate); -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) -+ hns3_err(hw, "failed to config port rate, ret = %d", ret); -+ -+ return ret; - } - - static int --hns3_tm_config_tc_rate(struct hns3_hw *hw, -- uint8_t tc_no, -+hns3_tm_config_tc_rate(struct hns3_hw *hw, uint8_t tc_no, - struct hns3_tm_shaper_profile *shaper_profile) - { -+ struct hns3_tc_limit_rate_cmd *cfg; -+ struct hns3_cmd_desc desc; - uint32_t firmware_rate; - uint64_t rate; -+ int ret; - - if (shaper_profile) { - rate = shaper_profile->profile.peak.rate; -@@ -954,7 +961,17 @@ hns3_tm_config_tc_rate(struct hns3_hw *hw, - firmware_rate = hw->dcb_info.tc_info[tc_no].bw_limit; - } - -- return hns3_pri_shaper_rate_cfg(hw, tc_no, firmware_rate); -+ hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_TM_TC_LIMIT_RATE, false); -+ cfg = (struct hns3_tc_limit_rate_cmd *)desc.data; -+ cfg->speed = rte_cpu_to_le_32(firmware_rate); -+ cfg->tc_id = tc_no; -+ -+ ret = hns3_cmd_send(hw, &desc, 1); -+ if (ret) -+ hns3_err(hw, "failed to config tc (%u) rate, ret = %d", -+ tc_no, ret); -+ -+ return ret; - } - - static bool -@@ -1227,12 +1244,16 @@ static const struct rte_tm_ops hns3_tm_ops = { - }; - - int --hns3_tm_ops_get(struct rte_eth_dev *dev __rte_unused, -- void *arg) -+hns3_tm_ops_get(struct rte_eth_dev *dev, void *arg) - { -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ - if (arg == NULL) - return -EINVAL; - -+ if (!hns3_dev_tm_supported(hw)) -+ return -EOPNOTSUPP; -+ - *(const void **)arg = &hns3_tm_ops; - - return 0; -@@ -1243,6 +1264,9 @@ hns3_tm_dev_start_proc(struct hns3_hw *hw) - { - struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); - -+ if (!hns3_dev_tm_supported(hw)) -+ return; -+ - if (pf->tm_conf.root && !pf->tm_conf.committed) - hns3_warn(hw, - "please call hierarchy_commit() before starting the port."); -@@ -1289,6 +1313,9 @@ hns3_tm_conf_update(struct hns3_hw *hw) - struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); - struct rte_tm_error error; - -+ if (!hns3_dev_tm_supported(hw)) -+ return 0; -+ - if (pf->tm_conf.root == NULL || !pf->tm_conf.committed) - return 0; - -diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h -index d8de3e4..2286d0e 100644 ---- a/drivers/net/hns3/hns3_tm.h -+++ b/drivers/net/hns3/hns3_tm.h -@@ -9,6 +9,18 @@ - #include - #include - -+struct hns3_port_limit_rate_cmd { -+ uint32_t speed; /* Unit Mbps */ -+ uint32_t rsvd[5]; -+}; -+ -+struct hns3_tc_limit_rate_cmd { -+ uint32_t speed; /* Unit Mbps */ -+ uint8_t tc_id; -+ uint8_t rsvd[3]; -+ uint32_t rsvd1[4]; -+}; -+ - enum hns3_tm_node_type { - HNS3_TM_NODE_TYPE_PORT, - HNS3_TM_NODE_TYPE_TC, --- -2.7.4 - diff --git a/0198-config-arm-fix-SVE-build-with-GCC-8.3.patch b/0198-config-arm-fix-SVE-build-with-GCC-8.3.patch deleted file mode 100644 index 247fef7..0000000 --- a/0198-config-arm-fix-SVE-build-with-GCC-8.3.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 8ae253ae5053753fd8225cc78d34ab5d2c449b5f Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Mon, 28 Jun 2021 10:57:50 +0800 -Subject: [PATCH 12/26] config/arm: fix SVE build with GCC 8.3 - -If the target machine has SVE feature (e.g. "-march=armv8.2-a+sve'), -and the compiler is gcc-8.3, it will produce this error: - In file included from lib/eal/common/eal_common_options.c:38: - lib/eal/arm/include/rte_vect.h:13:10: fatal error: - arm_sve.h: No such file or directory - #include - ^~~~~~~~~~~ - -The root cause is that gcc-8.3 supports SVE (the macro -__ARM_FEATURE_SVE was 1), but it doesn't support SVE ACLE [1]. - -The solution: -a) Detect compiler whether support SVE ACLE, if support then define -RTE_HAS_SVE_ACLE macro. -b) Use the RTE_HAS_SVE_ACLE macro to include SVE header file. - -[1] ACLE: Arm C Language Extensions, the SVE ACLE header file is -, user should include it when writing ACLE SVE code. - -Fixes: 67b68824a82d ("lpm/arm: support SVE") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Acked-by: Ruifeng Wang -Signed-off-by: Thomas Monjalon ---- - config/arm/meson.build | 3 +++ - lib/librte_eal/arm/include/rte_vect.h | 3 +++ - lib/librte_lpm/rte_lpm.h | 4 ++++ - 3 files changed, 10 insertions(+) - -diff --git a/config/arm/meson.build b/config/arm/meson.build -index b18acea..06ecaf3 100644 ---- a/config/arm/meson.build -+++ b/config/arm/meson.build -@@ -216,6 +216,9 @@ endif - - if cc.get_define('__ARM_FEATURE_SVE', args: machine_args) != '' - compile_time_cpuflags += ['RTE_CPUFLAG_SVE'] -+ if (cc.check_header('arm_sve.h')) -+ dpdk_conf.set('RTE_HAS_SVE_ACLE', 1) -+ endif - endif - - if cc.get_define('__ARM_FEATURE_CRC32', args: machine_args) != '' -diff --git a/lib/librte_eal/arm/include/rte_vect.h b/lib/librte_eal/arm/include/rte_vect.h -index a739e6e..4b705ba 100644 ---- a/lib/librte_eal/arm/include/rte_vect.h -+++ b/lib/librte_eal/arm/include/rte_vect.h -@@ -9,6 +9,9 @@ - #include "generic/rte_vect.h" - #include "rte_debug.h" - #include "arm_neon.h" -+#ifdef RTE_HAS_SVE_ACLE -+#include -+#endif - - #ifdef __cplusplus - extern "C" { -diff --git a/lib/librte_lpm/rte_lpm.h b/lib/librte_lpm/rte_lpm.h -index 1afe55c..5eb14c1 100644 ---- a/lib/librte_lpm/rte_lpm.h -+++ b/lib/librte_lpm/rte_lpm.h -@@ -402,7 +402,11 @@ rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], - uint32_t defv); - - #if defined(RTE_ARCH_ARM) -+#ifdef RTE_HAS_SVE_ACLE -+#include "rte_lpm_sve.h" -+#else - #include "rte_lpm_neon.h" -+#endif - #elif defined(RTE_ARCH_PPC_64) - #include "rte_lpm_altivec.h" - #else --- -2.7.4 - diff --git a/0199-net-hns3-fix-Arm-SVE-build-with-GCC-8.3.patch b/0199-net-hns3-fix-Arm-SVE-build-with-GCC-8.3.patch deleted file mode 100644 index e7f72b9..0000000 --- a/0199-net-hns3-fix-Arm-SVE-build-with-GCC-8.3.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 54cda7e32e96a2217e39de257c2dec42bb13a272 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Mon, 28 Jun 2021 10:57:51 +0800 -Subject: [PATCH 13/26] net/hns3: fix Arm SVE build with GCC 8.3 - -If the target machine has SVE feature (e.g. '-march=armv8.2-a+sve'), -and compiler is gcc-8.3, it will fail, the error is arm_sve.h: -no such file or directory. - -The solution: -a. If RTE_HAS_SVE_ACLE defined (it means the minimum instruction set -support SVE ACLE) then compiles it. -b. Else if the compiler support SVE ACLE then compiles it. -c. Otherwise don't compile it. - -Fixes: 8c25b02b082a ("net/hns3: fix enabling SVE Rx/Tx") -Fixes: 952ebacce4f2 ("net/hns3: support SVE Rx") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Acked-by: Ruifeng Wang ---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - drivers/net/hns3/meson.build | 26 ++++++++++++++++++++++---- - 2 files changed, 23 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 51b727f..d8b79c3 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -2811,7 +2811,7 @@ hns3_get_default_vec_support(void) - static bool - hns3_get_sve_support(void) - { --#if defined(RTE_ARCH_ARM64) && defined(__ARM_FEATURE_SVE) -+#if defined(RTE_HAS_SVE_ACLE) - if (rte_vect_get_max_simd_bitwidth() < RTE_VECT_SIMD_256) - return false; - if (rte_cpu_get_flag_enabled(RTE_CPUFLAG_SVE)) -diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build -index 6d78c33..bf602af 100644 ---- a/drivers/net/hns3/meson.build -+++ b/drivers/net/hns3/meson.build -@@ -32,8 +32,26 @@ sources = files('hns3_cmd.c', - deps += ['hash'] - - if arch_subdir == 'arm' and dpdk_conf.get('RTE_ARCH_64') -- sources += files('hns3_rxtx_vec.c') -- if cc.get_define('__ARM_FEATURE_SVE', args: machine_args) != '' -- sources += files('hns3_rxtx_vec_sve.c') -- endif -+ sources += files('hns3_rxtx_vec.c') -+ -+ # compile SVE when: -+ # a. support SVE in minimum instruction set baseline -+ # b. it's not minimum instruction set, but compiler support -+ if dpdk_conf.has('RTE_HAS_SVE_ACLE') -+ sources += files('hns3_rxtx_vec_sve.c') -+ elif cc.has_argument('-march=armv8.2-a+sve') and cc.check_header('arm_sve.h') -+ cflags += ['-DRTE_HAS_SVE_ACLE=1'] -+ sve_cflags = [] -+ foreach flag: cflags -+ if not (flag.startswith('-march=') or flag.startswith('-mcpu=') or flag.startswith('-mtune=')) -+ sve_cflags += flag -+ endif -+ endforeach -+ hns3_sve_lib = static_library('hns3_sve_lib', -+ 'hns3_rxtx_vec_sve.c', -+ dependencies: [static_rte_ethdev], -+ include_directories: includes, -+ c_args: [sve_cflags, '-march=armv8.2-a+sve']) -+ objs += hns3_sve_lib.extract_objects('hns3_rxtx_vec_sve.c') -+ endif - endif --- -2.7.4 - diff --git a/0200-net-hns3-query-basic-info-for-VF.patch b/0200-net-hns3-query-basic-info-for-VF.patch deleted file mode 100644 index 4f7b34e..0000000 --- a/0200-net-hns3-query-basic-info-for-VF.patch +++ /dev/null @@ -1,146 +0,0 @@ -From ad113e20b6f776719d5abbb8b1635639a0998c68 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 10 Jul 2021 09:58:32 +0800 -Subject: [PATCH 14/26] net/hns3: query basic info for VF - -There are some features of VF depend on PF, so it's necessary for VF -to know whether current PF supports. Therefore, the final capability -set of VF will be composed of the capability set of hardware and the -capability set of PF. - -For compatibility reasons, the mailbox HNS3_MBX_GET_TCINFO has been -modified to obatin more basic information about the current PF, including -the communication interface version and current PF capabilities set. - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 1 + - drivers/net/hns3/hns3_ethdev_vf.c | 48 ++++++++++++++++++++++++--------------- - drivers/net/hns3/hns3_mbx.h | 10 +++++++- - 3 files changed, 40 insertions(+), 19 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 31379fd..0ecf812 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -488,6 +488,7 @@ struct hns3_hw { - struct hns3_rx_missed_stats imissed_stats; - uint64_t oerror_stats; - uint32_t fw_version; -+ uint16_t pf_vf_if_version; /* version of communication interface */ - - uint16_t num_msi; - uint16_t total_tqps_num; /* total task queue pairs of this PF */ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 2085a29..bb351be 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1409,26 +1409,38 @@ hns3vf_get_queue_depth(struct hns3_hw *hw) - } - - static int --hns3vf_get_tc_info(struct hns3_hw *hw) -+hns3vf_get_num_tc(struct hns3_hw *hw) - { -- uint8_t resp_msg; -- int ret; -+ uint8_t num_tc = 0; - uint32_t i; - -- ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_TCINFO, 0, NULL, 0, -- true, &resp_msg, sizeof(resp_msg)); -+ for (i = 0; i < HNS3_MAX_TC_NUM; i++) { -+ if (hw->hw_tc_map & BIT(i)) -+ num_tc++; -+ } -+ return num_tc; -+} -+ -+static int -+hns3vf_get_basic_info(struct hns3_hw *hw) -+{ -+ uint8_t resp_msg[HNS3_MBX_MAX_RESP_DATA_SIZE]; -+ struct hns3_basic_info *basic_info; -+ int ret; -+ -+ ret = hns3_send_mbx_msg(hw, HNS3_MBX_GET_BASIC_INFO, 0, NULL, 0, -+ true, resp_msg, sizeof(resp_msg)); - if (ret) { -- hns3_err(hw, "VF request to get TC info from PF failed %d", -- ret); -+ hns3_err(hw, "failed to get basic info from PF, ret = %d.", -+ ret); - return ret; - } - -- hw->hw_tc_map = resp_msg; -+ basic_info = (struct hns3_basic_info *)resp_msg; -+ hw->hw_tc_map = basic_info->hw_tc_map; -+ hw->num_tc = hns3vf_get_num_tc(hw); -+ hw->pf_vf_if_version = basic_info->pf_vf_if_version; - -- for (i = 0; i < HNS3_MAX_TC_NUM; i++) { -- if (hw->hw_tc_map & BIT(i)) -- hw->num_tc++; -- } - - return 0; - } -@@ -1468,6 +1480,11 @@ hns3vf_get_configuration(struct hns3_hw *hw) - - hns3vf_get_push_lsc_cap(hw); - -+ /* Get basic info from PF */ -+ ret = hns3vf_get_basic_info(hw); -+ if (ret) -+ return ret; -+ - /* Get queue configuration from PF */ - ret = hns3vf_get_queue_info(hw); - if (ret) -@@ -1483,12 +1500,7 @@ hns3vf_get_configuration(struct hns3_hw *hw) - if (ret) - return ret; - -- ret = hns3vf_get_port_base_vlan_filter_state(hw); -- if (ret) -- return ret; -- -- /* Get tc configuration from PF */ -- return hns3vf_get_tc_info(hw); -+ return hns3vf_get_port_base_vlan_filter_state(hw); - } - - static int -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index e84ef6d..f6482cc 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -18,7 +18,7 @@ enum HNS3_MBX_OPCODE { - HNS3_MBX_API_NEGOTIATE, /* (VF -> PF) negotiate API version */ - HNS3_MBX_GET_QINFO, /* (VF -> PF) get queue config */ - HNS3_MBX_GET_QDEPTH, /* (VF -> PF) get queue depth */ -- HNS3_MBX_GET_TCINFO, /* (VF -> PF) get TC config */ -+ HNS3_MBX_GET_BASIC_INFO, /* (VF -> PF) get basic info */ - HNS3_MBX_GET_RETA, /* (VF -> PF) get RETA */ - HNS3_MBX_GET_RSS_KEY, /* (VF -> PF) get RSS key */ - HNS3_MBX_GET_MAC_ADDR, /* (VF -> PF) get MAC addr */ -@@ -47,6 +47,14 @@ enum HNS3_MBX_OPCODE { - HNS3_MBX_PUSH_LINK_STATUS = 201, /* (IMP -> PF) get port link status */ - }; - -+struct hns3_basic_info { -+ uint8_t hw_tc_map; -+ uint8_t rsv; -+ uint16_t pf_vf_if_version; -+ /* capabilities of VF dependent on PF */ -+ uint32_t caps; -+}; -+ - /* below are per-VF mac-vlan subcodes */ - enum hns3_mbx_mac_vlan_subcode { - HNS3_MBX_MAC_VLAN_UC_MODIFY = 0, /* modify UC mac addr */ --- -2.7.4 - diff --git a/0201-net-hns3-support-VLAN-filter-state-modify-for-VF.patch b/0201-net-hns3-support-VLAN-filter-state-modify-for-VF.patch deleted file mode 100644 index f039fda..0000000 --- a/0201-net-hns3-support-VLAN-filter-state-modify-for-VF.patch +++ /dev/null @@ -1,169 +0,0 @@ -From 7e819e49263e3195e3b04f9a6c32113a6835d76c Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 10 Jul 2021 09:58:33 +0800 -Subject: [PATCH 15/26] net/hns3: support VLAN filter state modify for VF - -Since the HW limitation for VF, the VLAN filter is default enabled, and -is not allowed to be closed. Now, the limitation has been removed in -Kunpeng930 network engine, so this patch add support for VF to modify the -VLAN filter state. - -A capabilities bit is added to differentiate between different platforms -and achieve compatibility. When the VF runs on an incomatible platform or -an incompatible kernel-mode driver version is used, the VF behavior is -the same as that before. - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 9 ++++++++ - drivers/net/hns3/hns3_ethdev.h | 4 ++++ - drivers/net/hns3/hns3_ethdev_vf.c | 48 ++++++++++++++++++++++++++++++++++++--- - drivers/net/hns3/hns3_mbx.h | 1 + - 4 files changed, 59 insertions(+), 3 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index cd58303..780ab0f 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -325,6 +325,15 @@ enum HNS3_CAPS_BITS { - HNS3_CAPS_TM_B = 17, - }; - -+/* Capabilities of VF dependent on the PF */ -+enum HNS3VF_CAPS_BITS { -+ /* -+ * The following capability index definitions must be the same as those -+ * in kernel side PF. -+ */ -+ HNS3VF_CAPS_VLAN_FLT_MOD_B = 0, -+}; -+ - enum HNS3_API_CAP_BITS { - HNS3_API_CAP_FLEX_RSS_TBL_B, - }; -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 0ecf812..9a59483 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -870,6 +870,7 @@ enum { - HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B, - HNS3_DEV_SUPPORT_RAS_IMP_B, - HNS3_DEV_SUPPORT_TM_B, -+ HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, - }; - - #define hns3_dev_dcb_supported(hw) \ -@@ -909,6 +910,9 @@ enum { - #define hns3_dev_tm_supported(hw) \ - hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TM_B) - -+#define hns3_dev_vf_vlan_flt_supported(hw) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B) -+ - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) - #define HNS3_DEV_PRIVATE_TO_PF(adapter) \ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index bb351be..b62b059 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1408,6 +1408,14 @@ hns3vf_get_queue_depth(struct hns3_hw *hw) - return 0; - } - -+static void -+hns3vf_update_caps(struct hns3_hw *hw, uint32_t caps) -+{ -+ if (hns3_get_bit(caps, HNS3VF_CAPS_VLAN_FLT_MOD_B)) -+ hns3_set_bit(hw->capability, -+ HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, 1); -+} -+ - static int - hns3vf_get_num_tc(struct hns3_hw *hw) - { -@@ -1440,7 +1448,7 @@ hns3vf_get_basic_info(struct hns3_hw *hw) - hw->hw_tc_map = basic_info->hw_tc_map; - hw->num_tc = hns3vf_get_num_tc(hw); - hw->pf_vf_if_version = basic_info->pf_vf_if_version; -- -+ hns3vf_update_caps(hw, basic_info->caps); - - return 0; - } -@@ -1611,6 +1619,26 @@ hns3vf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on) - } - - static int -+hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable) -+{ -+ uint8_t msg_data; -+ int ret; -+ -+ if (!hns3_dev_vf_vlan_flt_supported(hw)) -+ return 0; -+ -+ msg_data = enable ? 1 : 0; -+ ret = hns3_send_mbx_msg(hw, HNS3_MBX_SET_VLAN, -+ HNS3_MBX_ENABLE_VLAN_FILTER, &msg_data, -+ sizeof(msg_data), true, NULL, 0); -+ if (ret) -+ hns3_err(hw, "%s vlan filter failed, ret = %d.", -+ enable ? "enable" : "disable", ret); -+ -+ return ret; -+} -+ -+static int - hns3vf_en_hw_strip_rxvtag(struct hns3_hw *hw, bool enable) - { - uint8_t msg_data; -@@ -1641,6 +1669,19 @@ hns3vf_vlan_offload_set(struct rte_eth_dev *dev, int mask) - } - - tmp_mask = (unsigned int)mask; -+ -+ if (tmp_mask & ETH_VLAN_FILTER_MASK) { -+ rte_spinlock_lock(&hw->lock); -+ /* Enable or disable VLAN filter */ -+ if (dev_conf->rxmode.offloads & DEV_RX_OFFLOAD_VLAN_FILTER) -+ ret = hns3vf_en_vlan_filter(hw, true); -+ else -+ ret = hns3vf_en_vlan_filter(hw, false); -+ rte_spinlock_unlock(&hw->lock); -+ if (ret) -+ return ret; -+ } -+ - /* Vlan stripping setting */ - if (tmp_mask & ETH_VLAN_STRIP_MASK) { - rte_spinlock_lock(&hw->lock); -@@ -1738,9 +1779,10 @@ hns3vf_dev_configure_vlan(struct rte_eth_dev *dev) - } - - /* Apply vlan offload setting */ -- ret = hns3vf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK); -+ ret = hns3vf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK | -+ ETH_VLAN_FILTER_MASK); - if (ret) -- hns3_err(hw, "dev config vlan offload failed, ret =%d", ret); -+ hns3_err(hw, "dev config vlan offload failed, ret = %d.", ret); - - return ret; - } -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index f6482cc..2154c04 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -71,6 +71,7 @@ enum hns3_mbx_vlan_cfg_subcode { - HNS3_MBX_VLAN_TX_OFF_CFG, /* set tx side vlan offload */ - HNS3_MBX_VLAN_RX_OFF_CFG, /* set rx side vlan offload */ - HNS3_MBX_GET_PORT_BASE_VLAN_STATE = 4, /* get port based vlan state */ -+ HNS3_MBX_ENABLE_VLAN_FILTER, /* set vlan filter state */ - }; - - enum hns3_mbx_tbl_cfg_subcode { --- -2.7.4 - diff --git a/0202-net-hns3-support-multiple-TC-MAC-pause.patch b/0202-net-hns3-support-multiple-TC-MAC-pause.patch deleted file mode 100644 index 3eea474..0000000 --- a/0202-net-hns3-support-multiple-TC-MAC-pause.patch +++ /dev/null @@ -1,69 +0,0 @@ -From ec5421783ce5243f8bbad0f28db3d05e31e000d8 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 10 Jul 2021 09:58:34 +0800 -Subject: [PATCH 16/26] net/hns3: support multiple TC MAC pause - -MAC PAUSE can take effect on a single TC or multiple TCs, depending on the -hardware. For example, the Kunpeng 920 supports MAC pause in a single TC, -and the Kunpeng 930 supports MAC pause in multiple TCs. This patch -supports MAC PAUSE in multiple TC for some hardware. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 5 ++++- - drivers/net/hns3/hns3_ethdev.h | 1 + - 2 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7283364..b2ee831 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -3314,6 +3314,7 @@ hns3_get_capability(struct hns3_hw *hw) - pf->tqp_config_mode = HNS3_FIXED_MAX_TQP_NUM_MODE; - hw->rss_info.ipv6_sctp_offload_supported = false; - hw->udp_cksum_mode = HNS3_SPECIAL_PORT_SW_CKSUM_MODE; -+ pf->support_multi_tc_pause = false; - return 0; - } - -@@ -3334,6 +3335,7 @@ hns3_get_capability(struct hns3_hw *hw) - pf->tqp_config_mode = HNS3_FLEX_MAX_TQP_NUM_MODE; - hw->rss_info.ipv6_sctp_offload_supported = true; - hw->udp_cksum_mode = HNS3_SPECIAL_PORT_HW_CKSUM_MODE; -+ pf->support_multi_tc_pause = true; - - return 0; - } -@@ -6100,6 +6102,7 @@ static int - hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); - int ret; - - if (fc_conf->high_water || fc_conf->low_water || -@@ -6129,7 +6132,7 @@ hns3_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf) - return -EOPNOTSUPP; - } - -- if (hw->num_tc > 1) { -+ if (hw->num_tc > 1 && !pf->support_multi_tc_pause) { - hns3_err(hw, "in multi-TC scenarios, MAC pause is not supported."); - return -EOPNOTSUPP; - } -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 9a59483..bdad384 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -783,6 +783,7 @@ struct hns3_pf { - uint8_t prio_tc[HNS3_MAX_USER_PRIO]; /* TC indexed by prio */ - uint16_t pause_time; - bool support_fc_autoneg; /* support FC autonegotiate */ -+ bool support_multi_tc_pause; - - uint16_t wanted_umv_size; - uint16_t max_umv_size; --- -2.7.4 - diff --git a/0203-net-hns3-fix-residual-MAC-address-entry.patch b/0203-net-hns3-fix-residual-MAC-address-entry.patch deleted file mode 100644 index f5a336a..0000000 --- a/0203-net-hns3-fix-residual-MAC-address-entry.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 203d961619952ef99fda300b73c3a3c1edd725d3 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 17 Jul 2021 10:02:49 +0800 -Subject: [PATCH 17/26] net/hns3: fix residual MAC address entry - -Currently, even if we fail to remove the origin MAC address from the HW, -the set_default_mac will go on, and add the new MAC address to the HW. -Eventually cause the original MAC address entry to remain in the HW, and -users may receive unexpected packets. - -This patch make set_default_mac return directly to failure if deleting -the original MAC address fails, simplifying the behavior of the driver -and solving the problem of residual MAC address entry. - -Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 22 +++++++++------------- - 1 file changed, 9 insertions(+), 13 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index b2ee831..ce7aa95 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1748,7 +1748,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - struct rte_ether_addr *oaddr; - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - bool default_addr_setted; -- bool rm_succes = false; - int ret, ret_val; - - /* -@@ -1768,9 +1767,10 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - oaddr); - hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", - mac_str, ret); -- rm_succes = false; -- } else -- rm_succes = true; -+ -+ rte_spinlock_unlock(&hw->lock); -+ return ret; -+ } - } - - ret = hns3_add_uc_addr_common(hw, mac_addr); -@@ -1805,16 +1805,12 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - } - - err_add_uc_addr: -- if (rm_succes) { -- ret_val = hns3_add_uc_addr_common(hw, oaddr); -- if (ret_val) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- oaddr); -- hns3_warn(hw, -- "Failed to restore old uc mac addr(%s): %d", -+ ret_val = hns3_add_uc_addr_common(hw, oaddr); -+ if (ret_val) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); -+ hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", - mac_str, ret_val); -- hw->mac.default_addr_setted = false; -- } -+ hw->mac.default_addr_setted = false; - } - rte_spinlock_unlock(&hw->lock); - --- -2.7.4 - diff --git a/0204-net-hns3-remove-unnecessary-zero-assignments.patch b/0204-net-hns3-remove-unnecessary-zero-assignments.patch deleted file mode 100644 index cc2086d..0000000 --- a/0204-net-hns3-remove-unnecessary-zero-assignments.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 679b37031b1e747b5e03bdd74cd18cd885cb1f9e Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 17 Jul 2021 10:02:50 +0800 -Subject: [PATCH 18/26] net/hns3: remove unnecessary zero assignments - -The output parameter 'cap' was cleared at the function entry, the -latter zero assignment 'cap' fields was unnecessary, so delete them. - -Fixes: c09c7847d892 ("net/hns3: support traffic management") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_tm.c | 18 ------------------ - 1 file changed, 18 deletions(-) - -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index 81c61ad..cd32664 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -134,33 +134,15 @@ hns3_tm_capabilities_get(struct rte_eth_dev *dev, - cap->leaf_nodes_identical = 1; - cap->shaper_n_max = 1 + HNS3_MAX_TC_NUM; - cap->shaper_private_n_max = 1 + HNS3_MAX_TC_NUM; -- cap->shaper_private_dual_rate_n_max = 0; -- cap->shaper_private_rate_min = 0; - cap->shaper_private_rate_max = - hns3_tm_rate_convert_firmware2tm(hw->max_tm_rate); -- cap->shaper_shared_n_max = 0; -- cap->shaper_shared_n_nodes_per_shaper_max = 0; -- cap->shaper_shared_n_shapers_per_node_max = 0; -- cap->shaper_shared_dual_rate_n_max = 0; -- cap->shaper_shared_rate_min = 0; -- cap->shaper_shared_rate_max = 0; - - cap->sched_n_children_max = max_tx_queues; - cap->sched_sp_n_priorities_max = 1; -- cap->sched_wfq_n_children_per_group_max = 0; -- cap->sched_wfq_n_groups_max = 0; - cap->sched_wfq_weight_max = 1; - -- cap->cman_head_drop_supported = 0; -- cap->dynamic_update_mask = 0; - cap->shaper_pkt_length_adjust_min = RTE_TM_ETH_FRAMING_OVERHEAD; - cap->shaper_pkt_length_adjust_max = RTE_TM_ETH_FRAMING_OVERHEAD_FCS; -- cap->cman_wred_context_n_max = 0; -- cap->cman_wred_context_private_n_max = 0; -- cap->cman_wred_context_shared_n_max = 0; -- cap->cman_wred_context_shared_n_nodes_per_context_max = 0; -- cap->cman_wred_context_shared_n_contexts_per_node_max = 0; -- cap->stats_mask = 0; - - return 0; - } --- -2.7.4 - diff --git a/0205-net-hns3-fix-filter-parsing-comment.patch b/0205-net-hns3-fix-filter-parsing-comment.patch deleted file mode 100644 index c109c2a..0000000 --- a/0205-net-hns3-fix-filter-parsing-comment.patch +++ /dev/null @@ -1,89 +0,0 @@ -From 4d98ab6b259c37da13ef2ecba882b39883478b04 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 17 Jul 2021 10:02:51 +0800 -Subject: [PATCH 19/26] net/hns3: fix filter parsing comment - -This patch fixed incorrect comment of hns3_parse_fdir_filter(). - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_flow.c | 59 +++++++++++++++++--------------------------- - 1 file changed, 23 insertions(+), 36 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index d405820..a38bb68 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1134,42 +1134,29 @@ is_tunnel_packet(enum rte_flow_item_type type) - } - - /* -- * Parse the rule to see if it is a IP or MAC VLAN flow director rule. -- * And get the flow director filter info BTW. -- * UDP/TCP/SCTP PATTERN: -- * The first not void item can be ETH or IPV4 or IPV6 -- * The second not void item must be IPV4 or IPV6 if the first one is ETH. -- * The next not void item could be UDP or TCP or SCTP (optional) -- * The next not void item could be RAW (for flexbyte, optional) -- * The next not void item must be END. -- * A Fuzzy Match pattern can appear at any place before END. -- * Fuzzy Match is optional for IPV4 but is required for IPV6 -- * MAC VLAN PATTERN: -- * The first not void item must be ETH. -- * The second not void item must be MAC VLAN. -- * The next not void item must be END. -- * ACTION: -- * The first not void action should be QUEUE or DROP. -- * The second not void optional action should be MARK, -- * mark_id is a uint32_t number. -- * The next not void action should be END. -- * UDP/TCP/SCTP pattern example: -- * ITEM Spec Mask -- * ETH NULL NULL -- * IPV4 src_addr 192.168.1.20 0xFFFFFFFF -- * dst_addr 192.167.3.50 0xFFFFFFFF -- * UDP/TCP/SCTP src_port 80 0xFFFF -- * dst_port 80 0xFFFF -- * END -- * MAC VLAN pattern example: -- * ITEM Spec Mask -- * ETH dst_addr -- {0xAC, 0x7B, 0xA1, {0xFF, 0xFF, 0xFF, -- 0x2C, 0x6D, 0x36} 0xFF, 0xFF, 0xFF} -- * MAC VLAN tci 0x2016 0xEFFF -- * END -- * Other members in mask and spec should set to 0x00. -- * Item->last should be NULL. -+ * Parse the flow director rule. -+ * The supported PATTERN: -+ * case: non-tunnel packet: -+ * ETH : src-mac, dst-mac, ethertype -+ * VLAN: tag1, tag2 -+ * IPv4: src-ip, dst-ip, tos, proto -+ * IPv6: src-ip(last 32 bit addr), dst-ip(last 32 bit addr), proto -+ * UDP : src-port, dst-port -+ * TCP : src-port, dst-port -+ * SCTP: src-port, dst-port, tag -+ * case: tunnel packet: -+ * OUTER-ETH: ethertype -+ * OUTER-L3 : proto -+ * OUTER-L4 : src-port, dst-port -+ * TUNNEL : vni, flow-id(only valid when NVGRE) -+ * INNER-ETH/VLAN/IPv4/IPv6/UDP/TCP/SCTP: same as non-tunnel packet -+ * The supported ACTION: -+ * QUEUE -+ * DROP -+ * COUNT -+ * MARK: the id range [0, 4094] -+ * FLAG -+ * RSS: only valid if firmware support FD_QUEUE_REGION. - */ - static int - hns3_parse_fdir_filter(struct rte_eth_dev *dev, --- -2.7.4 - diff --git a/0206-net-hns3-fix-timing-of-clearing-interrupt-source.patch b/0206-net-hns3-fix-timing-of-clearing-interrupt-source.patch deleted file mode 100644 index 9c9ceb3..0000000 --- a/0206-net-hns3-fix-timing-of-clearing-interrupt-source.patch +++ /dev/null @@ -1,77 +0,0 @@ -From ddd874645976918320694f9095f9a3892eaf4a4c Mon Sep 17 00:00:00 2001 -From: Hongbo Zheng -Date: Sat, 17 Jul 2021 10:02:52 +0800 -Subject: [PATCH 20/26] net/hns3: fix timing of clearing interrupt source - -Currently, the PF/VF does not clear the interrupt source immediately -after receiving the interrupt. As a result, if the second interrupt -task is triggered when processing the first interrupt task, clearing -the interrupt source before exiting will clear the interrupt sources -of the two tasks at the same time. As a result, no interrupt is -triggered for the second task. - -Clearing interrupt source immediately after checking event cause -ensures that: -1. Even if two interrupt tasks are triggered at the same time, they can -be processed. -2. If the second task is triggered during the processing of the first -task and the interrupt source is not cleared, the interrupt is reported -after vector0 is enabled. - -Fixes: a5475d61fa34 ("net/hns3: support VF") -Fixes: 3988ab0eee52 ("net/hns3: add abnormal interrupt process") -Cc: stable@dpdk.org - -Signed-off-by: Hongbo Zheng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 +- - drivers/net/hns3/hns3_ethdev_vf.c | 5 ++--- - 2 files changed, 3 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index ce7aa95..f658e74 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -317,6 +317,7 @@ hns3_interrupt_handler(void *param) - vector0_int = hns3_read_dev(hw, HNS3_VECTOR0_OTHER_INT_STS_REG); - ras_int = hns3_read_dev(hw, HNS3_RAS_PF_OTHER_INT_STS_REG); - cmdq_int = hns3_read_dev(hw, HNS3_VECTOR0_CMDQ_SRC_REG); -+ hns3_clear_event_cause(hw, event_cause, clearval); - /* vector 0 interrupt is shared with reset and mailbox source events. */ - if (event_cause == HNS3_VECTOR0_EVENT_ERR) { - hns3_warn(hw, "received interrupt: vector0_int_stat:0x%x " -@@ -335,7 +336,6 @@ hns3_interrupt_handler(void *param) - vector0_int, ras_int, cmdq_int); - } - -- hns3_clear_event_cause(hw, event_cause, clearval); - /* Enable interrupt if it is not cause by reset */ - hns3_pf_enable_irq0(hw); - } -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index b62b059..9e3b31e 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1116,6 +1116,8 @@ hns3vf_interrupt_handler(void *param) - - /* Read out interrupt causes */ - event_cause = hns3vf_check_event_cause(hns, &clearval); -+ /* Clear interrupt causes */ -+ hns3vf_clear_event_cause(hw, clearval); - - switch (event_cause) { - case HNS3VF_VECTOR0_EVENT_RST: -@@ -1128,9 +1130,6 @@ hns3vf_interrupt_handler(void *param) - break; - } - -- /* Clear interrupt causes */ -- hns3vf_clear_event_cause(hw, clearval); -- - /* Enable interrupt */ - hns3vf_enable_irq0(hw); - } --- -2.7.4 - diff --git a/0207-net-hns3-remove-duplicate-compile-time-check.patch b/0207-net-hns3-remove-duplicate-compile-time-check.patch deleted file mode 100644 index 78ae67f..0000000 --- a/0207-net-hns3-remove-duplicate-compile-time-check.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 41c5bde109b81c37c50d407e9d82eebdd4253b79 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 17 Jul 2021 10:02:53 +0800 -Subject: [PATCH 21/26] net/hns3: remove duplicate compile-time check - -This patch delete duplicate compile-time check. - -Fixes: cb12e988f35f ("net/hns3: add compile-time verification on Rx vector") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx_vec.c | 4 ---- - 1 file changed, 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c -index 5fdc1d5..e37e858 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.c -+++ b/drivers/net/hns3/hns3_rxtx_vec.c -@@ -172,8 +172,6 @@ hns3_rxq_vec_setup_rearm_data(struct hns3_rx_queue *rxq) - offsetof(struct rte_mbuf, rearm_data)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) < - offsetof(struct rte_mbuf, rearm_data)); -- RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) < -- offsetof(struct rte_mbuf, rearm_data)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) < - offsetof(struct rte_mbuf, rearm_data)); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) < -@@ -182,8 +180,6 @@ hns3_rxq_vec_setup_rearm_data(struct hns3_rx_queue *rxq) - offsetof(struct rte_mbuf, rearm_data) > 6); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) - - offsetof(struct rte_mbuf, rearm_data) > 6); -- RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, refcnt) - -- offsetof(struct rte_mbuf, rearm_data) > 6); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, nb_segs) - - offsetof(struct rte_mbuf, rearm_data) > 6); - RTE_BUILD_BUG_ON(offsetof(struct rte_mbuf, port) - --- -2.7.4 - diff --git a/0208-net-hns3-move-speed-auto-negotiation-warning.patch b/0208-net-hns3-move-speed-auto-negotiation-warning.patch deleted file mode 100644 index a011342..0000000 --- a/0208-net-hns3-move-speed-auto-negotiation-warning.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 7c10ec3ea203c6190df96a72f5169a4674b8ea74 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Jul 2021 10:02:54 +0800 -Subject: [PATCH 22/26] net/hns3: move speed auto-negotiation warning - -PF driver prints a warning on device that does not support auto-negotiation -when user does not configure "link_speeds" (default 0), which means -auto-negotiation. Currently, this warning information is printed in -dev_configure stage and a success is returned. Perhaps the user may call -dev_configure multiple times before dev_start for some reason or purpose. -In this case, this message may be printed multiple times. So this patch -moves it to dev_start stage. - -Fixes: cfc9fe48c4d4 ("net/hns3: move link speeds check to configure") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f658e74..c8f283c 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2437,14 +2437,11 @@ hns3_check_link_speed(struct hns3_hw *hw, uint32_t link_speeds) - /* - * Some hardware doesn't support auto-negotiation, but users may not - * configure link_speeds (default 0), which means auto-negotiation. -- * In this case, a warning message need to be printed, instead of -- * an error. -+ * In this case, it should return success. - */ - if (link_speeds == ETH_LINK_SPEED_AUTONEG && -- hw->mac.support_autoneg == 0) { -- hns3_warn(hw, "auto-negotiation is not supported, use default fixed speed!"); -+ hw->mac.support_autoneg == 0) - return 0; -- } - - if (link_speeds != ETH_LINK_SPEED_AUTONEG) { - ret = hns3_check_port_speed(hw, link_speeds); -@@ -5512,10 +5509,13 @@ hns3_set_fiber_port_link_speed(struct hns3_hw *hw, - /* - * Some hardware doesn't support auto-negotiation, but users may not - * configure link_speeds (default 0), which means auto-negotiation. -- * In this case, it should return success. -+ * In this case, a warning message need to be printed, instead of -+ * an error. - */ -- if (cfg->autoneg) -+ if (cfg->autoneg) { -+ hns3_warn(hw, "auto-negotiation is not supported, use default fixed speed!"); - return 0; -+ } - - return hns3_cfg_mac_speed_dup(hw, cfg->speed, cfg->duplex); - } --- -2.7.4 - diff --git a/0209-net-hns3-fix-flow-rule-list-in-multi-process.patch b/0209-net-hns3-fix-flow-rule-list-in-multi-process.patch deleted file mode 100644 index b3f2f97..0000000 --- a/0209-net-hns3-fix-flow-rule-list-in-multi-process.patch +++ /dev/null @@ -1,454 +0,0 @@ -From a1caa97a8ece52a98a5c1d06b397e3e370a65501 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 17 Jul 2021 10:02:55 +0800 -Subject: [PATCH 23/26] net/hns3: fix flow rule list in multi-process - -Currently, hns3 driver saves rte_flow list into the -rte_eth_dev.process_private field, it may cause following problem: -The FDIR/RSS rules cannot be managed in a unified manner because -the management structure is not visible between processes. - -This patch fixes it by moving rte_flow list to struct hns3_hw which is -visible between processes. - -Fixes: fcba820d9b9e ("net/hns3: support flow director") -Fixes: c37ca66f2b27 ("net/hns3: support RSS") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 24 ++------- - drivers/net/hns3/hns3_ethdev.h | 3 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 24 ++------- - drivers/net/hns3/hns3_fdir.h | 7 +-- - drivers/net/hns3/hns3_flow.c | 101 +++++++++++++++++++------------------- - 5 files changed, 60 insertions(+), 99 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index c8f283c..4c2dcee 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5289,6 +5289,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) - hns3_rss_uninit(hns); - (void)hns3_config_gro(hw, false); - hns3_promisc_uninit(hw); -+ hns3_flow_uninit(eth_dev); - hns3_fdir_filter_uninit(hns); - hns3_uninit_umv_space(hw); - hns3_tqp_stats_uninit(hw); -@@ -5915,11 +5916,8 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - struct hns3_hw *hw = &hns->hw; - int ret = 0; - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; -- } - - if (hw->adapter_state == HNS3_NIC_STARTED) - ret = hns3_dev_stop(eth_dev); -@@ -5934,8 +5932,6 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - hns3_uninit_pf(eth_dev); - hns3_free_all_queues(eth_dev); - rte_free(hw->reset.wait_data); -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; - hns3_mp_uninit_primary(); - hns3_warn(hw, "Close port %u finished", hw->data->port_id); - -@@ -7395,15 +7391,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- eth_dev->process_private = (struct hns3_process_private *) -- rte_zmalloc_socket("hns3_filter_list", -- sizeof(struct hns3_process_private), -- RTE_CACHE_LINE_SIZE, eth_dev->device->numa_node); -- if (eth_dev->process_private == NULL) { -- PMD_INIT_LOG(ERR, "Failed to alloc memory for process private"); -- return -ENOMEM; -- } -- - hns3_flow_init(eth_dev); - - hns3_set_rxtx_function(eth_dev); -@@ -7507,8 +7494,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; - eth_dev->tx_descriptor_status = NULL; -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; - return ret; - } - -@@ -7520,11 +7505,8 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; -- } - - if (hw->adapter_state < HNS3_NIC_CLOSING) - hns3_dev_close(eth_dev); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index bdad384..0b5d102 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -630,6 +630,9 @@ struct hns3_hw { - struct hns3_port_base_vlan_config port_base_vlan_cfg; - - pthread_mutex_t flows_lock; /* rte_flow ops lock */ -+ struct hns3_fdir_rule_list flow_fdir_list; /* flow fdir rule list */ -+ struct hns3_rss_filter_list flow_rss_list; /* flow RSS rule list */ -+ struct hns3_flow_mem_list flow_list; - - /* - * PMD setup and configuration is not thread safe. Since it is not -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 9e3b31e..fc088f8 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2071,6 +2071,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev) - (void)hns3_config_gro(hw, false); - (void)hns3vf_set_alive(hw, false); - (void)hns3vf_set_promisc_mode(hw, false, false, false); -+ hns3_flow_uninit(eth_dev); - hns3_tqp_stats_uninit(hw); - hns3vf_disable_irq0(hw); - rte_intr_disable(&pci_dev->intr_handle); -@@ -2186,11 +2187,8 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - struct hns3_hw *hw = &hns->hw; - int ret = 0; - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; -- } - - if (hw->adapter_state == HNS3_NIC_STARTED) - ret = hns3vf_dev_stop(eth_dev); -@@ -2204,8 +2202,6 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - hns3vf_uninit_vf(eth_dev); - hns3_free_all_queues(eth_dev); - rte_free(hw->reset.wait_data); -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; - hns3_mp_uninit_primary(); - hns3_warn(hw, "Close port %u finished", hw->data->port_id); - -@@ -2959,15 +2955,6 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- eth_dev->process_private = (struct hns3_process_private *) -- rte_zmalloc_socket("hns3_filter_list", -- sizeof(struct hns3_process_private), -- RTE_CACHE_LINE_SIZE, eth_dev->device->numa_node); -- if (eth_dev->process_private == NULL) { -- PMD_INIT_LOG(ERR, "Failed to alloc memory for process private"); -- return -ENOMEM; -- } -- - hns3_flow_init(eth_dev); - - hns3_set_rxtx_function(eth_dev); -@@ -3069,8 +3056,6 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - eth_dev->tx_pkt_burst = NULL; - eth_dev->tx_pkt_prepare = NULL; - eth_dev->tx_descriptor_status = NULL; -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; - - return ret; - } -@@ -3083,11 +3068,8 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- rte_free(eth_dev->process_private); -- eth_dev->process_private = NULL; -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) - return 0; -- } - - if (hw->adapter_state < HNS3_NIC_CLOSING) - hns3vf_dev_close(eth_dev); -diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h -index d64af85..d7b31d8 100644 ---- a/drivers/net/hns3/hns3_fdir.h -+++ b/drivers/net/hns3/hns3_fdir.h -@@ -189,12 +189,6 @@ TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele); - TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); - TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); - --struct hns3_process_private { -- struct hns3_fdir_rule_list fdir_list; -- struct hns3_rss_filter_list filter_rss_list; -- struct hns3_flow_mem_list flow_list; --}; -- - /* - * A structure used to define fields of a FDIR related info. - */ -@@ -220,6 +214,7 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, - int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); - int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); - void hns3_flow_init(struct rte_eth_dev *dev); -+void hns3_flow_uninit(struct rte_eth_dev *dev); - int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); - - #endif /* _HNS3_FDIR_H_ */ -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index a38bb68..6c1e727 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1202,54 +1202,34 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, - return hns3_handle_actions(dev, actions, rule, error); - } - --void --hns3_flow_init(struct rte_eth_dev *dev) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct hns3_process_private *process_list = dev->process_private; -- pthread_mutexattr_t attr; -- -- if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -- pthread_mutexattr_init(&attr); -- pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); -- pthread_mutex_init(&hw->flows_lock, &attr); -- dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; -- } -- -- TAILQ_INIT(&process_list->fdir_list); -- TAILQ_INIT(&process_list->filter_rss_list); -- TAILQ_INIT(&process_list->flow_list); --} -- - static void - hns3_filterlist_flush(struct rte_eth_dev *dev) - { -- struct hns3_process_private *process_list = dev->process_private; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_fdir_rule_ele *fdir_rule_ptr; - struct hns3_rss_conf_ele *rss_filter_ptr; - struct hns3_flow_mem *flow_node; - -- fdir_rule_ptr = TAILQ_FIRST(&process_list->fdir_list); -+ fdir_rule_ptr = TAILQ_FIRST(&hw->flow_fdir_list); - while (fdir_rule_ptr) { -- TAILQ_REMOVE(&process_list->fdir_list, fdir_rule_ptr, entries); -+ TAILQ_REMOVE(&hw->flow_fdir_list, fdir_rule_ptr, entries); - rte_free(fdir_rule_ptr); -- fdir_rule_ptr = TAILQ_FIRST(&process_list->fdir_list); -+ fdir_rule_ptr = TAILQ_FIRST(&hw->flow_fdir_list); - } - -- rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); -+ rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); - while (rss_filter_ptr) { -- TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr, -- entries); -+ TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); - rte_free(rss_filter_ptr); -- rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); -+ rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); - } - -- flow_node = TAILQ_FIRST(&process_list->flow_list); -+ flow_node = TAILQ_FIRST(&hw->flow_list); - while (flow_node) { -- TAILQ_REMOVE(&process_list->flow_list, flow_node, entries); -+ TAILQ_REMOVE(&hw->flow_list, flow_node, entries); - rte_free(flow_node->flow); - rte_free(flow_node); -- flow_node = TAILQ_FIRST(&process_list->flow_list); -+ flow_node = TAILQ_FIRST(&hw->flow_list); - } - } - -@@ -1519,7 +1499,6 @@ static int - hns3_config_rss_filter(struct rte_eth_dev *dev, - const struct hns3_rss_conf *conf, bool add) - { -- struct hns3_process_private *process_list = dev->process_private; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_rss_conf_ele *rss_filter_ptr; - struct hns3_hw *hw = &hns->hw; -@@ -1604,7 +1583,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, - * When create a new RSS rule, the old rule will be overlaid and set - * invalid. - */ -- TAILQ_FOREACH(rss_filter_ptr, &process_list->filter_rss_list, entries) -+ TAILQ_FOREACH(rss_filter_ptr, &hw->flow_rss_list, entries) - rss_filter_ptr->filter_info.valid = false; - - rss_config_err: -@@ -1616,7 +1595,6 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, - static int - hns3_clear_rss_filter(struct rte_eth_dev *dev) - { -- struct hns3_process_private *process_list = dev->process_private; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_rss_conf_ele *rss_filter_ptr; - struct hns3_hw *hw = &hns->hw; -@@ -1624,10 +1602,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) - int rss_rule_fail_cnt = 0; /* count for failure of clearing RSS rules */ - int ret = 0; - -- rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); -+ rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); - while (rss_filter_ptr) { -- TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr, -- entries); -+ TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); - ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info, - false); - if (ret) -@@ -1635,7 +1612,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) - else - rss_rule_succ_cnt++; - rte_free(rss_filter_ptr); -- rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); -+ rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); - } - - if (rss_rule_fail_cnt) { -@@ -1739,7 +1716,6 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - const struct rte_flow_action actions[], - struct rte_flow_error *error) - { -- struct hns3_process_private *process_list = dev->process_private; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - const struct hns3_rss_conf *rss_conf; -@@ -1771,7 +1747,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - } - - flow_node->flow = flow; -- TAILQ_INSERT_TAIL(&process_list->flow_list, flow_node, entries); -+ TAILQ_INSERT_TAIL(&hw->flow_list, flow_node, entries); - - act = hns3_find_rss_general_action(pattern, actions); - if (act) { -@@ -1793,8 +1769,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - hns3_rss_conf_copy(&rss_filter_ptr->filter_info, - &rss_conf->conf); - rss_filter_ptr->filter_info.valid = true; -- TAILQ_INSERT_TAIL(&process_list->filter_rss_list, -- rss_filter_ptr, entries); -+ TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries); - - flow->rule = rss_filter_ptr; - flow->filter_type = RTE_ETH_FILTER_HASH; -@@ -1828,8 +1803,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - if (!ret) { - memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule, - sizeof(struct hns3_fdir_rule)); -- TAILQ_INSERT_TAIL(&process_list->fdir_list, -- fdir_rule_ptr, entries); -+ TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries); - flow->rule = fdir_rule_ptr; - flow->filter_type = RTE_ETH_FILTER_FDIR; - -@@ -1844,7 +1818,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, - rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, - "Failed to create flow"); - out: -- TAILQ_REMOVE(&process_list->flow_list, flow_node, entries); -+ TAILQ_REMOVE(&hw->flow_list, flow_node, entries); - rte_free(flow_node); - rte_free(flow); - return NULL; -@@ -1855,13 +1829,13 @@ static int - hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, - struct rte_flow_error *error) - { -- struct hns3_process_private *process_list = dev->process_private; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_fdir_rule_ele *fdir_rule_ptr; - struct hns3_rss_conf_ele *rss_filter_ptr; - struct hns3_flow_mem *flow_node; - enum rte_filter_type filter_type; - struct hns3_fdir_rule fdir_rule; -+ struct hns3_hw *hw = &hns->hw; - int ret; - - if (flow == NULL) -@@ -1884,7 +1858,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, - "Destroy FDIR fail.Try again"); - if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) - hns3_counter_release(dev, fdir_rule.act_cnt.id); -- TAILQ_REMOVE(&process_list->fdir_list, fdir_rule_ptr, entries); -+ TAILQ_REMOVE(&hw->flow_fdir_list, fdir_rule_ptr, entries); - rte_free(fdir_rule_ptr); - fdir_rule_ptr = NULL; - break; -@@ -1897,8 +1871,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, - RTE_FLOW_ERROR_TYPE_HANDLE, - flow, - "Destroy RSS fail.Try again"); -- TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr, -- entries); -+ TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); - rte_free(rss_filter_ptr); - rss_filter_ptr = NULL; - break; -@@ -1908,10 +1881,9 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, - "Unsupported filter type"); - } - -- TAILQ_FOREACH(flow_node, &process_list->flow_list, entries) { -+ TAILQ_FOREACH(flow_node, &hw->flow_list, entries) { - if (flow_node->flow == flow) { -- TAILQ_REMOVE(&process_list->flow_list, flow_node, -- entries); -+ TAILQ_REMOVE(&hw->flow_list, flow_node, entries); - rte_free(flow_node); - flow_node = NULL; - break; -@@ -2115,3 +2087,30 @@ hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type, - - return ret; - } -+ -+void -+hns3_flow_init(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ pthread_mutexattr_t attr; -+ -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ return; -+ -+ pthread_mutexattr_init(&attr); -+ pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); -+ pthread_mutex_init(&hw->flows_lock, &attr); -+ dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; -+ -+ TAILQ_INIT(&hw->flow_fdir_list); -+ TAILQ_INIT(&hw->flow_rss_list); -+ TAILQ_INIT(&hw->flow_list); -+} -+ -+void -+hns3_flow_uninit(struct rte_eth_dev *dev) -+{ -+ struct rte_flow_error error; -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) -+ hns3_flow_flush_wrap(dev, &error); -+} -\ No newline at end of file --- -2.7.4 - diff --git a/0210-net-hns3-fix-Tx-prepare-after-stop.patch b/0210-net-hns3-fix-Tx-prepare-after-stop.patch deleted file mode 100644 index 00d8e16..0000000 --- a/0210-net-hns3-fix-Tx-prepare-after-stop.patch +++ /dev/null @@ -1,39 +0,0 @@ -From c0e77e78921b2b7de78738c8d023bf5a4dac5383 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Jul 2021 10:02:56 +0800 -Subject: [PATCH 24/26] net/hns3: fix Tx prepare after stop - -In some special scenarios, such as TSO scenarios, the user layer may need -to call the tx_pkt_prepare(), and then call tx_pkt_burst() to send packets. -If the return value of tx_pkt_parepare() isn't equal to the numbers of -packets requested to send, warning message may be printed at the user -layer. Currently, tx_pkt_prepare() is assigned to dummy function when -dev_stop() is called in hns3 PMD. At this moment, if user layer continues -to send packets, the warning message will always be printed. So this patch -modifies the address to NULL. - -Fixes: 2790c6464725 ("net/hns3: support device reset") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index d8b79c3..d50cfc6 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4386,7 +4386,7 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - } else { - eth_dev->rx_pkt_burst = hns3_dummy_rxtx_burst; - eth_dev->tx_pkt_burst = hns3_dummy_rxtx_burst; -- eth_dev->tx_pkt_prepare = hns3_dummy_rxtx_burst; -+ eth_dev->tx_pkt_prepare = NULL; - } - } - --- -2.7.4 - diff --git a/0211-net-hns3-disable-PFC-if-not-configured.patch b/0211-net-hns3-disable-PFC-if-not-configured.patch deleted file mode 100644 index 500a333..0000000 --- a/0211-net-hns3-disable-PFC-if-not-configured.patch +++ /dev/null @@ -1,197 +0,0 @@ -From adcff6f726ed3345c9d4ad0182de22d2e57459d8 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 17 Jul 2021 09:04:19 +0800 -Subject: [PATCH 25/26] net/hns3: disable PFC if not configured - -If "dcb_capability_en" in "data->dev_conf" delivered from the dev_configure -does not have the ETH_DCB_PFC_SUPPORT flag, the user wants to disable PFC, -and only enable ETS. Therefore, this patch supports the function of -disabling PFC by the field. In addition, this patch updates -"current_fc_status" of the driver based on the flow control mode requested -by user so as to enable the flow control mode in multi-TC scenarios. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_dcb.c | 112 ++++++++++++++++++-------------------------- - 1 file changed, 45 insertions(+), 67 deletions(-) - -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 61a2404..4d5b00b 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1400,42 +1400,22 @@ hns3_dcb_undrop_tc_map(struct hns3_hw *hw, uint8_t pfc_en) - return pfc_map; - } - --static void --hns3_dcb_cfg_validate(struct hns3_adapter *hns, uint8_t *tc, bool *changed) -+static uint8_t -+hns3_dcb_parse_num_tc(struct hns3_adapter *hns) - { - struct rte_eth_dcb_rx_conf *dcb_rx_conf; - struct hns3_hw *hw = &hns->hw; -- uint16_t nb_rx_q = hw->data->nb_rx_queues; -- uint16_t nb_tx_q = hw->data->nb_tx_queues; -- uint8_t max_tc = 0; -- uint8_t pfc_en; -+ uint8_t max_tc_id = 0; - int i; - - dcb_rx_conf = &hw->data->dev_conf.rx_adv_conf.dcb_rx_conf; - for (i = 0; i < HNS3_MAX_USER_PRIO; i++) { -- if (dcb_rx_conf->dcb_tc[i] != hw->dcb_info.prio_tc[i]) -- *changed = true; -- -- if (dcb_rx_conf->dcb_tc[i] > max_tc) -- max_tc = dcb_rx_conf->dcb_tc[i]; -+ if (dcb_rx_conf->dcb_tc[i] > max_tc_id) -+ max_tc_id = dcb_rx_conf->dcb_tc[i]; - } -- *tc = max_tc + 1; -- if (*tc != hw->dcb_info.num_tc) -- *changed = true; -- -- /* -- * We ensure that dcb information can be reconfigured -- * after the hns3_priority_flow_ctrl_set function called. -- */ -- if (hw->requested_fc_mode != HNS3_FC_FULL) -- *changed = true; -- pfc_en = RTE_LEN2MASK((uint8_t)dcb_rx_conf->nb_tcs, uint8_t); -- if (hw->dcb_info.pfc_en != pfc_en) -- *changed = true; - -- /* tx/rx queue number is reconfigured. */ -- if (nb_rx_q != hw->used_rx_queues || nb_tx_q != hw->used_tx_queues) -- *changed = true; -+ /* Number of TC is equal to max_tc_id plus 1. */ -+ return max_tc_id + 1; - } - - static int -@@ -1567,36 +1547,30 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) - hw->dcb_info.hw_pfc_map = - hns3_dcb_undrop_tc_map(hw, hw->dcb_info.pfc_en); - -- ret = hns3_buffer_alloc(hw); -- if (ret) -- goto buffer_alloc_fail; -- - hw->current_fc_status = HNS3_FC_STATUS_PFC; - hw->requested_fc_mode = HNS3_FC_FULL; -- ret = hns3_dcb_pause_setup_hw(hw); -- if (ret) { -- hns3_err(hw, "setup pfc failed! ret = %d", ret); -- goto pfc_setup_fail; -- } - } else { -- /* -- * Although dcb_capability_en is lack of ETH_DCB_PFC_SUPPORT -- * flag, the DCB information is configured, such as tc numbers. -- * Therefore, refreshing the allocation of packet buffer is -- * necessary. -- */ -- ret = hns3_buffer_alloc(hw); -- if (ret) -- return ret; -+ hw->current_fc_status = HNS3_FC_STATUS_NONE; -+ hw->requested_fc_mode = HNS3_FC_NONE; -+ hw->dcb_info.pfc_en = 0; -+ hw->dcb_info.hw_pfc_map = 0; -+ } -+ -+ ret = hns3_buffer_alloc(hw); -+ if (ret) -+ goto cfg_fail; -+ -+ ret = hns3_dcb_pause_setup_hw(hw); -+ if (ret) { -+ hns3_err(hw, "setup pfc failed! ret = %d", ret); -+ goto cfg_fail; - } - - return 0; - --pfc_setup_fail: -+cfg_fail: - hw->requested_fc_mode = requested_fc_mode; - hw->current_fc_status = fc_status; -- --buffer_alloc_fail: - hw->dcb_info.pfc_en = pfc_en; - hw->dcb_info.hw_pfc_map = hw_pfc_map; - -@@ -1612,23 +1586,20 @@ int - hns3_dcb_configure(struct hns3_adapter *hns) - { - struct hns3_hw *hw = &hns->hw; -- bool map_changed = false; -- uint8_t num_tc = 0; -+ uint8_t num_tc; - int ret; - -- hns3_dcb_cfg_validate(hns, &num_tc, &map_changed); -- if (map_changed) { -- ret = hns3_dcb_info_update(hns, num_tc); -- if (ret) { -- hns3_err(hw, "dcb info update failed: %d", ret); -- return ret; -- } -+ num_tc = hns3_dcb_parse_num_tc(hns); -+ ret = hns3_dcb_info_update(hns, num_tc); -+ if (ret) { -+ hns3_err(hw, "dcb info update failed: %d", ret); -+ return ret; -+ } - -- ret = hns3_dcb_hw_configure(hns); -- if (ret) { -- hns3_err(hw, "dcb sw configure failed: %d", ret); -- return ret; -- } -+ ret = hns3_dcb_hw_configure(hns); -+ if (ret) { -+ hns3_err(hw, "dcb sw configure failed: %d", ret); -+ return ret; - } - - return 0; -@@ -1781,15 +1752,21 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - uint16_t pause_time = pf->pause_time; - int ret; - -- pf->pause_time = pfc_conf->fc.pause_time; -- hns3_get_fc_mode(hw, pfc_conf->fc.mode); -- hw->current_fc_status = HNS3_FC_STATUS_PFC; - hw->dcb_info.pfc_en |= BIT(priority); - hw->dcb_info.hw_pfc_map = - hns3_dcb_undrop_tc_map(hw, hw->dcb_info.pfc_en); - ret = hns3_buffer_alloc(hw); -- if (ret) -- goto pfc_setup_fail; -+ if (ret) { -+ hns3_err(hw, "update packet buffer failed, ret = %d", ret); -+ goto buffer_alloc_fail; -+ } -+ -+ pf->pause_time = pfc_conf->fc.pause_time; -+ hns3_get_fc_mode(hw, pfc_conf->fc.mode); -+ if (hw->requested_fc_mode == HNS3_FC_NONE) -+ hw->current_fc_status = HNS3_FC_STATUS_NONE; -+ else -+ hw->current_fc_status = HNS3_FC_STATUS_PFC; - - /* - * The flow control mode of all UPs will be changed based on -@@ -1807,6 +1784,7 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) - hw->requested_fc_mode = old_fc_mode; - hw->current_fc_status = fc_status; - pf->pause_time = pause_time; -+buffer_alloc_fail: - hw->dcb_info.pfc_en = pfc_en; - hw->dcb_info.hw_pfc_map = hw_pfc_map; - --- -2.7.4 - diff --git a/0212-net-hns3-use-the-correct-HiSilicon-copyright.patch b/0212-net-hns3-use-the-correct-HiSilicon-copyright.patch deleted file mode 100644 index b9d3c63..0000000 --- a/0212-net-hns3-use-the-correct-HiSilicon-copyright.patch +++ /dev/null @@ -1,412 +0,0 @@ -From 7fcab57399496811e5167d475645f6cb4b67692a Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 1 Apr 2021 16:24:52 +0800 -Subject: [PATCH 26/26] net/hns3: use the correct HiSilicon copyright - -According to the suggestion of our legal department, -to standardize the copyright license of our code to -avoid potential copyright risks, we make a unified -modification to the "Hisilicon", which was nonstandard, -in the main modules we maintain. - -We change it to "HiSilicon", which is consistent with -the terms used on the following official website: -https://www.hisilicon.com/en/terms-of-use. - -Fixes: 565829db8b8f ("net/hns3: add build and doc infrastructure") -Fixes: 952ebacce4f2 ("net/hns3: support SVE Rx") -Fixes: e31f123db06b ("net/hns3: support NEON Tx") -Fixes: c09c7847d892 ("net/hns3: support traffic management") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 2 +- - drivers/net/hns3/hns3_cmd.h | 2 +- - drivers/net/hns3/hns3_dcb.c | 2 +- - drivers/net/hns3/hns3_dcb.h | 2 +- - drivers/net/hns3/hns3_ethdev.c | 2 +- - drivers/net/hns3/hns3_ethdev.h | 2 +- - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- - drivers/net/hns3/hns3_fdir.c | 2 +- - drivers/net/hns3/hns3_fdir.h | 2 +- - drivers/net/hns3/hns3_flow.c | 2 +- - drivers/net/hns3/hns3_intr.c | 2 +- - drivers/net/hns3/hns3_intr.h | 2 +- - drivers/net/hns3/hns3_logs.h | 2 +- - drivers/net/hns3/hns3_mbx.c | 2 +- - drivers/net/hns3/hns3_mbx.h | 2 +- - drivers/net/hns3/hns3_mp.c | 2 +- - drivers/net/hns3/hns3_mp.h | 2 +- - drivers/net/hns3/hns3_regs.c | 2 +- - drivers/net/hns3/hns3_regs.h | 2 +- - drivers/net/hns3/hns3_rss.c | 2 +- - drivers/net/hns3/hns3_rss.h | 2 +- - drivers/net/hns3/hns3_rxtx.c | 2 +- - drivers/net/hns3/hns3_rxtx.h | 2 +- - drivers/net/hns3/hns3_rxtx_vec.c | 2 +- - drivers/net/hns3/hns3_rxtx_vec.h | 2 +- - drivers/net/hns3/hns3_rxtx_vec_neon.h | 2 +- - drivers/net/hns3/hns3_rxtx_vec_sve.c | 2 +- - drivers/net/hns3/hns3_stats.c | 2 +- - drivers/net/hns3/hns3_stats.h | 2 +- - drivers/net/hns3/hns3_tm.c | 2 +- - drivers/net/hns3/hns3_tm.h | 2 +- - drivers/net/hns3/meson.build | 2 +- - 32 files changed, 32 insertions(+), 32 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index ab92240..0de1a53 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 780ab0f..88683df 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_CMD_H_ -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index 4d5b00b..b71e2e9 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_dcb.h b/drivers/net/hns3/hns3_dcb.h -index 1abe649..e06ec17 100644 ---- a/drivers/net/hns3/hns3_dcb.h -+++ b/drivers/net/hns3/hns3_dcb.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_DCB_H_ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 4c2dcee..59260c6 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 0b5d102..1b592c8 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_ETHDEV_H_ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index fc088f8..e07eb20 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_fdir.c b/drivers/net/hns3/hns3_fdir.c -index 8ab5fd6..40edd6c 100644 ---- a/drivers/net/hns3/hns3_fdir.c -+++ b/drivers/net/hns3/hns3_fdir.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h -index d7b31d8..3f610f7 100644 ---- a/drivers/net/hns3/hns3_fdir.h -+++ b/drivers/net/hns3/hns3_fdir.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_FDIR_H_ -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 6c1e727..42b1c70 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index e8ca6d5..0b307fd 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_intr.h b/drivers/net/hns3/hns3_intr.h -index 4dfc807..1a0f196 100644 ---- a/drivers/net/hns3/hns3_intr.h -+++ b/drivers/net/hns3/hns3_intr.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_INTR_H_ -diff --git a/drivers/net/hns3/hns3_logs.h b/drivers/net/hns3/hns3_logs.h -index f3fc7b5..072a53b 100644 ---- a/drivers/net/hns3/hns3_logs.h -+++ b/drivers/net/hns3/hns3_logs.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_LOGS_H_ -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 0c2e03b..411c5eb 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index 2154c04..f868e33 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_MBX_H_ -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index b5cd5b0..2a7654d 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h -index 036546a..1a73598 100644 ---- a/drivers/net/hns3/hns3_mp.h -+++ b/drivers/net/hns3/hns3_mp.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_MP_H_ -diff --git a/drivers/net/hns3/hns3_regs.c b/drivers/net/hns3/hns3_regs.c -index 374b9ea..ee5bcdf 100644 ---- a/drivers/net/hns3/hns3_regs.c -+++ b/drivers/net/hns3/hns3_regs.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_regs.h b/drivers/net/hns3/hns3_regs.h -index c9e10be..5812eb3 100644 ---- a/drivers/net/hns3/hns3_regs.h -+++ b/drivers/net/hns3/hns3_regs.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_REGS_H_ -diff --git a/drivers/net/hns3/hns3_rss.c b/drivers/net/hns3/hns3_rss.c -index 858e31a..3a81e90 100644 ---- a/drivers/net/hns3/hns3_rss.c -+++ b/drivers/net/hns3/hns3_rss.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_rss.h b/drivers/net/hns3/hns3_rss.h -index 94668ed..996083b 100644 ---- a/drivers/net/hns3/hns3_rss.h -+++ b/drivers/net/hns3/hns3_rss.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_RSS_H_ -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index d50cfc6..13d9a31 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index e01e582..56c1b80 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_RXTX_H_ -diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c -index e37e858..15a0bd0 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.c -+++ b/drivers/net/hns3/hns3_rxtx_vec.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2020 Hisilicon Limited. -+ * Copyright(c) 2020-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_rxtx_vec.h b/drivers/net/hns3/hns3_rxtx_vec.h -index 872ba22..67c75e4 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.h -+++ b/drivers/net/hns3/hns3_rxtx_vec.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2020 Hisilicon Limited. -+ * Copyright(c) 2020-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_RXTX_VEC_H_ -diff --git a/drivers/net/hns3/hns3_rxtx_vec_neon.h b/drivers/net/hns3/hns3_rxtx_vec_neon.h -index 30a7d70..74c848d 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_neon.h -+++ b/drivers/net/hns3/hns3_rxtx_vec_neon.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2020 Hisilicon Limited. -+ * Copyright(c) 2020-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_RXTX_VEC_NEON_H_ -diff --git a/drivers/net/hns3/hns3_rxtx_vec_sve.c b/drivers/net/hns3/hns3_rxtx_vec_sve.c -index c861887..84a31d8 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec_sve.c -+++ b/drivers/net/hns3/hns3_rxtx_vec_sve.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2020 Hisilicon Limited. -+ * Copyright(c) 2020-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_stats.c b/drivers/net/hns3/hns3_stats.c -index 464a33d..e09dc0d 100644 ---- a/drivers/net/hns3/hns3_stats.c -+++ b/drivers/net/hns3/hns3_stats.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_stats.h b/drivers/net/hns3/hns3_stats.h -index 273be42..de5c40d 100644 ---- a/drivers/net/hns3/hns3_stats.h -+++ b/drivers/net/hns3/hns3_stats.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2018-2019 Hisilicon Limited. -+ * Copyright(c) 2018-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_STATS_H_ -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index cd32664..db5ac78 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2020-2020 Hisilicon Limited. -+ * Copyright(c) 2020-2021 HiSilicon Limited. - */ - - #include -diff --git a/drivers/net/hns3/hns3_tm.h b/drivers/net/hns3/hns3_tm.h -index 2286d0e..83e9cc8 100644 ---- a/drivers/net/hns3/hns3_tm.h -+++ b/drivers/net/hns3/hns3_tm.h -@@ -1,5 +1,5 @@ - /* SPDX-License-Identifier: BSD-3-Clause -- * Copyright(c) 2020-2020 Hisilicon Limited. -+ * Copyright(c) 2020-2021 HiSilicon Limited. - */ - - #ifndef _HNS3_TM_H_ -diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build -index bf602af..881aff6 100644 ---- a/drivers/net/hns3/meson.build -+++ b/drivers/net/hns3/meson.build -@@ -1,5 +1,5 @@ - # SPDX-License-Identifier: BSD-3-Clause --# Copyright(c) 2018-2019 Hisilicon Limited -+# Copyright(c) 2018-2021 Hisilicon Limited - - if not is_linux - build = false --- -2.7.4 - diff --git a/0213-app-testpmd-change-port-link-speed-without-stopping-.patch b/0213-app-testpmd-change-port-link-speed-without-stopping-.patch deleted file mode 100644 index 0e3309f..0000000 --- a/0213-app-testpmd-change-port-link-speed-without-stopping-.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 3e1dae547da0a58b31d551edee18511232ba5716 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 28 Apr 2021 16:36:59 +0800 -Subject: [PATCH 10/26] app/testpmd: change port link speed without stopping - all - -When we use the following cmd to modify the link speed of specified -port: "port config speed xxx duplex xxx", we have to stop -all ports. It's not necessary. - -Fixes: 82113036e4e5 ("ethdev: redesign link speed config") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Acked-by: Ferruh Yigit -Acked-by: Xiaoyun Li ---- - app/test-pmd/cmdline.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 78db462..b69c648 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -1613,13 +1613,13 @@ cmd_config_speed_specific_parsed(void *parsed_result, - struct cmd_config_speed_specific *res = parsed_result; - uint32_t link_speed; - -- if (!all_ports_stopped()) { -- printf("Please stop all ports first\n"); -+ if (port_id_is_invalid(res->id, ENABLED_WARN)) - return; -- } - -- if (port_id_is_invalid(res->id, ENABLED_WARN)) -+ if (!port_is_stopped(res->id)) { -+ printf("Please stop port %d first\n", res->id); - return; -+ } - - if (parse_and_check_speed_duplex(res->value1, res->value2, - &link_speed) < 0) --- -2.7.4 - diff --git a/0214-ethdev-add-dev-configured-flag.patch b/0214-ethdev-add-dev-configured-flag.patch deleted file mode 100644 index 2002bc5..0000000 --- a/0214-ethdev-add-dev-configured-flag.patch +++ /dev/null @@ -1,107 +0,0 @@ -From f38367e915cd94db9dc3e178eeff114e605d1f1c Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 7 Jul 2021 17:53:34 +0800 -Subject: [PATCH 11/26] ethdev: add dev configured flag - -Currently, if dev_configure is not called or fails to be called, users -can still call dev_start successfully. So it is necessary to have a flag -which indicates whether the device is configured, to control whether -dev_start can be called and eliminate dependency on user invocation order. - -The flag stored in "struct rte_eth_dev_data" is more reasonable than - "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the -primary and secondary processes, and can be independently controlled. -However, the secondary process does not make resource allocations and -does not call dev_configure(). These are done by the primary process -and can be obtained or used by the secondary process. So this patch -adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started". - -Signed-off-by: Huisong Li -Reviewed-by: Andrew Rybchenko -Acked-by: Konstantin Ananyev - -libabigail raised a warning on this change. -This change is fine wrt ABI as far as we understand, but we can't -express an exception rule (see libabigail bug #28060) to waive the -changes only in this part of the rte_eth_dev_data struct. -The solution for now is to globally waive any change on the -rte_eth_dev_data structure. - -Signed-off-by: David Marchand ---- - devtools/libabigail.abignore | 7 +++++++ - lib/librte_ethdev/rte_ethdev.c | 11 +++++++++++ - lib/librte_ethdev/rte_ethdev_core.h | 6 +++++- - 3 files changed, 23 insertions(+), 1 deletion(-) - -diff --git a/devtools/libabigail.abignore b/devtools/libabigail.abignore -index b649af1..80eb0ab 100644 ---- a/devtools/libabigail.abignore -+++ b/devtools/libabigail.abignore -@@ -16,3 +16,10 @@ - [suppress_type] - name = rte_eth_txq_info - has_data_member_inserted_between = {offset_after(nb_desc), end} -+ -+; Ignore all changes to rte_eth_dev_data -+; Note: we only cared about dev_configured bit addition, but libabigail -+; seems to wrongly compute bitfields offset. -+; https://sourceware.org/bugzilla/show_bug.cgi?id=28060 -+[suppress_type] -+ name = rte_eth_dev_data -diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c -index 87d1b56..4bed431 100644 ---- a/lib/librte_ethdev/rte_ethdev.c -+++ b/lib/librte_ethdev/rte_ethdev.c -@@ -1543,6 +1543,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, - } - - rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0); -+ dev->data->dev_configured = 1; -+ - return 0; - reset_queues: - eth_dev_rx_queue_config(dev, 0); -@@ -1551,6 +1553,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, - memcpy(&dev->data->dev_conf, &orig_conf, sizeof(dev->data->dev_conf)); - - rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, ret); -+ dev->data->dev_configured = 0; -+ - return ret; - } - -@@ -1687,6 +1691,13 @@ rte_eth_dev_start(uint16_t port_id) - - RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP); - -+ if (dev->data->dev_configured == 0) { -+ RTE_ETHDEV_LOG(INFO, -+ "Device with port_id=%"PRIu16" is not configured.\n", -+ port_id); -+ return -EINVAL; -+ } -+ - if (dev->data->dev_started != 0) { - RTE_ETHDEV_LOG(INFO, - "Device with port_id=%"PRIu16" already started\n", -diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h -index 918a34e..8d97dd1 100644 ---- a/lib/librte_ethdev/rte_ethdev_core.h -+++ b/lib/librte_ethdev/rte_ethdev_core.h -@@ -168,7 +168,11 @@ struct rte_eth_dev_data { - scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */ - all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */ - dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */ -- lro : 1; /**< RX LRO is ON(1) / OFF(0) */ -+ lro : 1, /**< RX LRO is ON(1) / OFF(0) */ -+ dev_configured : 1; -+ /**< Device configuration state: -+ * CONFIGURED(1) / NOT CONFIGURED(0). -+ */ - uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT]; - /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */ - uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT]; --- -2.7.4 - diff --git a/0215-net-hns3-add-start-stop-Tx-datapath-request-for-MP.patch b/0215-net-hns3-add-start-stop-Tx-datapath-request-for-MP.patch deleted file mode 100644 index 386f8e8..0000000 --- a/0215-net-hns3-add-start-stop-Tx-datapath-request-for-MP.patch +++ /dev/null @@ -1,188 +0,0 @@ -From 15c150affb3d486df5e7a4ab55e3ed1cdf8504ef Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Mon, 26 Jul 2021 18:59:39 +0800 -Subject: [PATCH] net/hns3: add start/stop Tx datapath request for MP - -Currently, hns3 PMD has supported start/stop RxTx datapath request message -between the primary and secondary processes. However, there are some cases -only to start/stop Tx datapath. This patch adds start/stop Tx datapath -request for MP. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.h | 4 +++- - drivers/net/hns3/hns3_mp.c | 50 ++++++++++++++++++++++++++++++++++-------- - drivers/net/hns3/hns3_mp.h | 3 +++ - drivers/net/hns3/hns3_rxtx.c | 4 ++-- - drivers/net/hns3/hns3_rxtx.h | 6 +++++ - 5 files changed, 55 insertions(+), 12 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 8e66d9f..2e48ff6 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -699,7 +699,9 @@ struct hns3_vtag_cfg { - /* Request types for IPC. */ - enum hns3_mp_req_type { - HNS3_MP_REQ_START_RXTX = 1, -- HNS3_MP_REQ_STOP_RXTX, -+ HNS3_MP_REQ_STOP_RXTX = 2, -+ HNS3_MP_REQ_START_TX = 3, -+ HNS3_MP_REQ_STOP_TX = 4, - HNS3_MP_REQ_MAX - }; - -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index a8485f5..cd514ac 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -73,6 +73,7 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) - struct hns3_mp_param *res = (struct hns3_mp_param *)mp_res.param; - const struct hns3_mp_param *param = - (const struct hns3_mp_param *)mp_msg->param; -+ eth_tx_prep_t prep = NULL; - struct rte_eth_dev *dev; - int ret; - -@@ -87,19 +88,23 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) - PMD_INIT_LOG(INFO, "port %u starting datapath", - dev->data->port_id); - hns3_set_rxtx_function(dev); -- rte_mb(); -- mp_init_msg(dev, &mp_res, param->type); -- res->result = 0; -- ret = rte_mp_reply(&mp_res, peer); - break; - case HNS3_MP_REQ_STOP_RXTX: - PMD_INIT_LOG(INFO, "port %u stopping datapath", - dev->data->port_id); - hns3_set_rxtx_function(dev); -- rte_mb(); -- mp_init_msg(dev, &mp_res, param->type); -- res->result = 0; -- ret = rte_mp_reply(&mp_res, peer); -+ break; -+ case HNS3_MP_REQ_START_TX: -+ PMD_INIT_LOG(INFO, "port %u starting Tx datapath", -+ dev->data->port_id); -+ dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep); -+ dev->tx_pkt_prepare = prep; -+ break; -+ case HNS3_MP_REQ_STOP_TX: -+ PMD_INIT_LOG(INFO, "port %u stopping Tx datapath", -+ dev->data->port_id); -+ dev->tx_pkt_burst = hns3_dummy_rxtx_burst; -+ dev->tx_pkt_prepare = NULL; - break; - default: - rte_errno = EINVAL; -@@ -107,9 +112,24 @@ mp_secondary_handle(const struct rte_mp_msg *mp_msg, const void *peer) - dev->data->port_id); - return -rte_errno; - } -+ -+ rte_mb(); -+ mp_init_msg(dev, &mp_res, param->type); -+ res->result = 0; -+ ret = rte_mp_reply(&mp_res, peer); -+ - return ret; - } - -+static bool -+mp_req_type_is_valid(enum hns3_mp_req_type type) -+{ -+ return type == HNS3_MP_REQ_START_RXTX || -+ type == HNS3_MP_REQ_STOP_RXTX || -+ type == HNS3_MP_REQ_START_TX || -+ type == HNS3_MP_REQ_STOP_TX; -+} -+ - /* - * Broadcast request of stopping/starting data-path to secondary processes. - * -@@ -132,7 +152,7 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum hns3_mp_req_type type) - - if (rte_eal_process_type() == RTE_PROC_SECONDARY || !hw->secondary_cnt) - return; -- if (type != HNS3_MP_REQ_START_RXTX && type != HNS3_MP_REQ_STOP_RXTX) { -+ if (!mp_req_type_is_valid(type)) { - hns3_err(hw, "port %u unknown request (req_type %d)", - dev->data->port_id, type); - return; -@@ -189,6 +209,18 @@ void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev) - mp_req_on_rxtx(dev, HNS3_MP_REQ_STOP_RXTX); - } - -+void -+hns3_mp_req_stop_tx(struct rte_eth_dev *dev) -+{ -+ mp_req_on_rxtx(dev, HNS3_MP_REQ_STOP_TX); -+} -+ -+void -+hns3_mp_req_start_tx(struct rte_eth_dev *dev) -+{ -+ mp_req_on_rxtx(dev, HNS3_MP_REQ_START_TX); -+} -+ - /* - * Initialize by primary process. - */ -diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h -index 1a73598..e0e4aea 100644 ---- a/drivers/net/hns3/hns3_mp.h -+++ b/drivers/net/hns3/hns3_mp.h -@@ -7,6 +7,9 @@ - - void hns3_mp_req_start_rxtx(struct rte_eth_dev *dev); - void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev); -+void hns3_mp_req_start_tx(struct rte_eth_dev *dev); -+void hns3_mp_req_stop_tx(struct rte_eth_dev *dev); -+ - int hns3_mp_init_primary(void); - void hns3_mp_uninit_primary(void); - int hns3_mp_init_secondary(void); -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index d3fbe08..7d8176f 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -4309,7 +4309,7 @@ hns3_get_tx_prep_needed(struct rte_eth_dev *dev) - #endif - } - --static eth_tx_burst_t -+eth_tx_burst_t - hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - { - struct hns3_adapter *hns = dev->data->dev_private; -@@ -4346,7 +4346,7 @@ hns3_get_tx_function(struct rte_eth_dev *dev, eth_tx_prep_t *prep) - return hns3_xmit_pkts; - } - --static uint16_t -+uint16_t - hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused, - struct rte_mbuf **pkts __rte_unused, - uint16_t pkts_n __rte_unused) -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 56c1b80..141de7a 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -729,6 +729,12 @@ int hns3_tx_burst_mode_get(struct rte_eth_dev *dev, - const uint32_t *hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev); - void hns3_init_rx_ptype_tble(struct rte_eth_dev *dev); - void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev); -+eth_tx_burst_t hns3_get_tx_function(struct rte_eth_dev *dev, -+ eth_tx_prep_t *prep); -+uint16_t hns3_dummy_rxtx_burst(void *dpdk_txq __rte_unused, -+ struct rte_mbuf **pkts __rte_unused, -+ uint16_t pkts_n __rte_unused); -+ - uint32_t hns3_get_tqp_intr_reg_offset(uint16_t tqp_intr_id); - void hns3_set_queue_intr_gl(struct hns3_hw *hw, uint16_t queue_id, - uint8_t gl_idx, uint16_t gl_value); --- -2.7.4 - diff --git a/0216-net-hns3-support-set-link-up-down-for-PF.patch b/0216-net-hns3-support-set-link-up-down-for-PF.patch deleted file mode 100644 index e760176..0000000 --- a/0216-net-hns3-support-set-link-up-down-for-PF.patch +++ /dev/null @@ -1,287 +0,0 @@ -From 0a3e6a5d6e2ab6eec0a16db1d5d5f5d0b75bcf8b Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Mon, 26 Jul 2021 18:59:40 +0800 -Subject: [PATCH] net/hns3: support set link up/down for PF - -This patch adds set link up/down feature. RxTx datapath and link status -will be disabled when dev_set_link_down() is called, and can be enabled by -dev_start() or dev_set_link_up(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 107 ++++++++++++++++++++++++++++++++++++++--- - drivers/net/hns3/hns3_ethdev.h | 11 +++-- - drivers/net/hns3/hns3_rxtx.c | 28 ++++++++++- - drivers/net/hns3/hns3_rxtx.h | 2 + - 4 files changed, 138 insertions(+), 10 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index a374fa7..7d37004 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -103,6 +103,7 @@ static int hns3_restore_fec(struct hns3_hw *hw); - static int hns3_query_dev_fec_info(struct hns3_hw *hw); - static int hns3_do_stop(struct hns3_adapter *hns); - static int hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds); -+static int hns3_cfg_mac_mode(struct hns3_hw *hw, bool enable); - - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr) -@@ -2924,6 +2925,88 @@ hns3_dev_link_update(struct rte_eth_dev *eth_dev, int wait_to_complete) - } - - static int -+hns3_dev_set_link_up(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ /* -+ * The "tx_pkt_burst" will be restored. But the secondary process does -+ * not support the mechanism for notifying the primary process. -+ */ -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ hns3_err(hw, "secondary process does not support to set link up."); -+ return -ENOTSUP; -+ } -+ -+ /* -+ * If device isn't started Rx/Tx function is still disabled, setting -+ * link up is not allowed. But it is probably better to return success -+ * to reduce the impact on the upper layer. -+ */ -+ if (hw->adapter_state != HNS3_NIC_STARTED) { -+ hns3_info(hw, "device isn't started, can't set link up."); -+ return 0; -+ } -+ -+ if (!hw->set_link_down) -+ return 0; -+ -+ rte_spinlock_lock(&hw->lock); -+ ret = hns3_cfg_mac_mode(hw, true); -+ if (ret) { -+ rte_spinlock_unlock(&hw->lock); -+ hns3_err(hw, "failed to set link up, ret = %d", ret); -+ return ret; -+ } -+ -+ hw->set_link_down = false; -+ hns3_start_tx_datapath(dev); -+ rte_spinlock_unlock(&hw->lock); -+ -+ return 0; -+} -+ -+static int -+hns3_dev_set_link_down(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ /* -+ * The "tx_pkt_burst" will be set to dummy function. But the secondary -+ * process does not support the mechanism for notifying the primary -+ * process. -+ */ -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ hns3_err(hw, "secondary process does not support to set link down."); -+ return -ENOTSUP; -+ } -+ -+ /* -+ * If device isn't started or the API has been called, link status is -+ * down, return success. -+ */ -+ if (hw->adapter_state != HNS3_NIC_STARTED || hw->set_link_down) -+ return 0; -+ -+ rte_spinlock_lock(&hw->lock); -+ hns3_stop_tx_datapath(dev); -+ ret = hns3_cfg_mac_mode(hw, false); -+ if (ret) { -+ hns3_start_tx_datapath(dev); -+ rte_spinlock_unlock(&hw->lock); -+ hns3_err(hw, "failed to set link down, ret = %d", ret); -+ return ret; -+ } -+ -+ hw->set_link_down = true; -+ rte_spinlock_unlock(&hw->lock); -+ -+ return 0; -+} -+ -+static int - hns3_parse_func_status(struct hns3_hw *hw, struct hns3_func_status_cmd *status) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -@@ -5576,6 +5659,7 @@ static int - hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - { - struct hns3_hw *hw = &hns->hw; -+ bool link_en; - int ret; - - ret = hns3_update_queue_map_configure(hns); -@@ -5600,7 +5684,8 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - return ret; - } - -- ret = hns3_cfg_mac_mode(hw, true); -+ link_en = hw->set_link_down ? false : true; -+ ret = hns3_cfg_mac_mode(hw, link_en); - if (ret) { - PMD_INIT_LOG(ERR, "failed to enable MAC, ret = %d", ret); - goto err_config_mac_mode; -@@ -5731,6 +5816,7 @@ hns3_dev_start(struct rte_eth_dev *dev) - { - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; -+ bool old_state = hw->set_link_down; - int ret; - - PMD_INIT_FUNC_TRACE(); -@@ -5740,12 +5826,17 @@ hns3_dev_start(struct rte_eth_dev *dev) - rte_spinlock_lock(&hw->lock); - hw->adapter_state = HNS3_NIC_STARTING; - -+ /* -+ * If the dev_set_link_down() API has been called, the "set_link_down" -+ * flag can be cleared by dev_start() API. In addition, the flag should -+ * also be cleared before calling hns3_do_start() so that MAC can be -+ * enabled in dev_start stage. -+ */ -+ hw->set_link_down = false; - ret = hns3_do_start(hns, true); -- if (ret) { -- hw->adapter_state = HNS3_NIC_CONFIGURED; -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ if (ret) -+ goto do_start_fail; -+ - ret = hns3_map_rx_interrupt(dev); - if (ret) - goto map_rx_inter_err; -@@ -5801,6 +5892,8 @@ hns3_dev_start(struct rte_eth_dev *dev) - hns3_stop_all_txqs(dev); - map_rx_inter_err: - (void)hns3_do_stop(hns); -+do_start_fail: -+ hw->set_link_down = old_state; - hw->adapter_state = HNS3_NIC_CONFIGURED; - rte_spinlock_unlock(&hw->lock); - -@@ -7345,6 +7438,8 @@ static const struct eth_dev_ops hns3_eth_dev_ops = { - .mac_addr_set = hns3_set_default_mac_addr, - .set_mc_addr_list = hns3_set_mc_mac_addr_list, - .link_update = hns3_dev_link_update, -+ .dev_set_link_up = hns3_dev_set_link_up, -+ .dev_set_link_down = hns3_dev_set_link_down, - .rss_hash_update = hns3_dev_rss_hash_update, - .rss_hash_conf_get = hns3_dev_rss_hash_conf_get, - .reta_update = hns3_dev_rss_reta_update, -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 2e48ff6..0e4e426 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -481,6 +481,11 @@ struct hns3_hw { - struct hns3_cmq cmq; - struct hns3_mbx_resp_status mbx_resp; /* mailbox response */ - struct hns3_mac mac; -+ /* -+ * This flag indicates dev_set_link_down() API is called, and is cleared -+ * by dev_set_link_up() or dev_start(). -+ */ -+ bool set_link_down; - unsigned int secondary_cnt; /* Number of secondary processes init'd. */ - struct hns3_tqp_stats tqp_stats; - /* Include Mac stats | Rx stats | Tx stats */ -@@ -699,9 +704,9 @@ struct hns3_vtag_cfg { - /* Request types for IPC. */ - enum hns3_mp_req_type { - HNS3_MP_REQ_START_RXTX = 1, -- HNS3_MP_REQ_STOP_RXTX = 2, -- HNS3_MP_REQ_START_TX = 3, -- HNS3_MP_REQ_STOP_TX = 4, -+ HNS3_MP_REQ_STOP_RXTX, -+ HNS3_MP_REQ_START_TX, -+ HNS3_MP_REQ_STOP_TX, - HNS3_MP_REQ_MAX - }; - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 7d8176f..0f222b3 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -20,6 +20,7 @@ - #include "hns3_rxtx.h" - #include "hns3_regs.h" - #include "hns3_logs.h" -+#include "hns3_mp.h" - - #define HNS3_CFG_DESC_NUM(num) ((num) / 8 - 1) - #define HNS3_RX_RING_PREFETCTH_MASK 3 -@@ -4372,6 +4373,7 @@ hns3_trace_rxtx_function(struct rte_eth_dev *dev) - - void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - { -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - struct hns3_adapter *hns = eth_dev->data->dev_private; - eth_tx_prep_t prep = NULL; - -@@ -4379,7 +4381,9 @@ void hns3_set_rxtx_function(struct rte_eth_dev *eth_dev) - __atomic_load_n(&hns->hw.reset.resetting, __ATOMIC_RELAXED) == 0) { - eth_dev->rx_pkt_burst = hns3_get_rx_function(eth_dev); - eth_dev->rx_descriptor_status = hns3_dev_rx_descriptor_status; -- eth_dev->tx_pkt_burst = hns3_get_tx_function(eth_dev, &prep); -+ eth_dev->tx_pkt_burst = hw->set_link_down ? -+ hns3_dummy_rxtx_burst : -+ hns3_get_tx_function(eth_dev, &prep); - eth_dev->tx_pkt_prepare = prep; - eth_dev->tx_descriptor_status = hns3_dev_tx_descriptor_status; - hns3_trace_rxtx_function(eth_dev); -@@ -4703,3 +4707,25 @@ hns3_enable_rxd_adv_layout(struct hns3_hw *hw) - if (hns3_dev_rxd_adv_layout_supported(hw)) - hns3_write_dev(hw, HNS3_RXD_ADV_LAYOUT_EN_REG, 1); - } -+ -+void -+hns3_stop_tx_datapath(struct rte_eth_dev *dev) -+{ -+ dev->tx_pkt_burst = hns3_dummy_rxtx_burst; -+ dev->tx_pkt_prepare = NULL; -+ rte_wmb(); -+ /* Disable tx datapath on secondary process. */ -+ hns3_mp_req_stop_tx(dev); -+ /* Prevent crashes when queues are still in use. */ -+ rte_delay_ms(dev->data->nb_tx_queues); -+} -+ -+void -+hns3_start_tx_datapath(struct rte_eth_dev *dev) -+{ -+ eth_tx_prep_t prep = NULL; -+ -+ dev->tx_pkt_burst = hns3_get_tx_function(dev, &prep); -+ dev->tx_pkt_prepare = prep; -+ hns3_mp_req_start_tx(dev); -+} -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index 141de7a..cd7c21c 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -766,5 +766,7 @@ void hns3_enable_rxd_adv_layout(struct hns3_hw *hw); - int hns3_dev_rx_descriptor_status(void *rx_queue, uint16_t offset); - int hns3_dev_tx_descriptor_status(void *tx_queue, uint16_t offset); - void hns3_tx_push_init(struct rte_eth_dev *dev); -+void hns3_stop_tx_datapath(struct rte_eth_dev *dev); -+void hns3_start_tx_datapath(struct rte_eth_dev *dev); - - #endif /* _HNS3_RXTX_H_ */ --- -2.7.4 - diff --git a/0217-net-hns3-fix-queue-flow-action-validation.patch b/0217-net-hns3-fix-queue-flow-action-validation.patch deleted file mode 100644 index 0c6f67e..0000000 --- a/0217-net-hns3-fix-queue-flow-action-validation.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 15c37af398c3a22b5f46aff8abfc9166f949567c Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Mon, 30 Aug 2021 16:26:49 +0800 -Subject: [PATCH] net/hns3: fix queue flow action validation - -The used_rx_queues only takes effect after device is started, and -its value is incorrect before the device is started. Therefore, it -is not suitable for flow action to use it to verify the queue index -before the device is started. - -E.g. Enable dedicated queue in bonding device will configure a queue -flow action before start its slave devices. The above problem will -make this reasonable flow action configuration fail. - -This patch use the nb_rx_queues from the configuration phase to -achieve verification. - -Fixes: a951c1ed3ab5 ("net/hns3: support different numbers of Rx and Tx queues") -Fixes: f8e7fcbfd0b8 ("net/hns3: support flow action of queue region") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_flow.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index fc77979c5f..841e0b9da3 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -275,10 +275,10 @@ hns3_handle_action_queue(struct rte_eth_dev *dev, - struct hns3_hw *hw = &hns->hw; - - queue = (const struct rte_flow_action_queue *)action->conf; -- if (queue->index >= hw->used_rx_queues) { -+ if (queue->index >= hw->data->nb_rx_queues) { - hns3_err(hw, "queue ID(%u) is greater than number of " - "available queue (%u) in driver.", -- queue->index, hw->used_rx_queues); -+ queue->index, hw->data->nb_rx_queues); - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, - action, "Invalid queue ID in PF"); -@@ -308,8 +308,8 @@ hns3_handle_action_queue_region(struct rte_eth_dev *dev, - - if ((!rte_is_power_of_2(conf->queue_num)) || - conf->queue_num > hw->rss_size_max || -- conf->queue[0] >= hw->used_rx_queues || -- conf->queue[0] + conf->queue_num > hw->used_rx_queues) { -+ conf->queue[0] >= hw->data->nb_rx_queues || -+ conf->queue[0] + conf->queue_num > hw->data->nb_rx_queues) { - return rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_ACTION_CONF, action, - "Invalid start queue ID and queue num! the start queue " --- -2.33.0 - diff --git a/0218-net-hns3-fix-taskqueue-pair-reset-command.patch b/0218-net-hns3-fix-taskqueue-pair-reset-command.patch deleted file mode 100644 index 6576e44..0000000 --- a/0218-net-hns3-fix-taskqueue-pair-reset-command.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 9c5fac6cc28c70fe549e60b3765ddef5a58d76f3 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Mon, 30 Aug 2021 16:26:50 +0800 -Subject: [PATCH] net/hns3: fix taskqueue pair reset command - -This new taskqueue pair reset command is used incorrectly, resulting in -the new command not taking effect. - -This patch fixes the incorrect use. - -Fixes: 6911e7c22c61 ("net/hns3: fix long task queue pairs reset time") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 0f222b37f9..481872e395 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -697,7 +697,7 @@ hns3_reset_rcb_cmd(struct hns3_hw *hw, uint8_t *reset_status) - - hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_CFG_RST_TRIGGER, false); - req = (struct hns3_reset_cmd *)desc.data; -- hns3_set_bit(req->mac_func_reset, HNS3_CFG_RESET_RCB_B, 1); -+ hns3_set_bit(req->fun_reset_rcb, HNS3_CFG_RESET_RCB_B, 1); - - /* - * The start qid should be the global qid of the first tqp of the --- -2.33.0 - diff --git a/0219-net-hns3-fix-Tx-push-capability.patch b/0219-net-hns3-fix-Tx-push-capability.patch deleted file mode 100644 index a89a5f4..0000000 --- a/0219-net-hns3-fix-Tx-push-capability.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 85289d2ec86fa522962d6599521af0a2f604ac52 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Mon, 30 Aug 2021 16:26:51 +0800 -Subject: [PATCH] net/hns3: fix Tx push capability - -This patch fixes Tx push capability to be compatible with Kunpeng 920, -as Tx push is only supported on Kunpeng 930. - -Fixes: 23e317dd1fbf ("net/hns3: support Tx push quick doorbell for performance") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 3 +++ - drivers/net/hns3/hns3_cmd.h | 1 + - 2 files changed, 4 insertions(+) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 928f938536..6a1e634684 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -423,6 +423,7 @@ hns3_get_caps_name(uint32_t caps_id) - } dev_caps[] = { - { HNS3_CAPS_FD_QUEUE_REGION_B, "fd_queue_region" }, - { HNS3_CAPS_PTP_B, "ptp" }, -+ { HNS3_CAPS_TX_PUSH_B, "tx_push" }, - { HNS3_CAPS_PHY_IMP_B, "phy_imp" }, - { HNS3_CAPS_TQP_TXRX_INDEP_B, "tqp_txrx_indep" }, - { HNS3_CAPS_HW_PAD_B, "hw_pad" }, -@@ -492,6 +493,8 @@ hns3_parse_capability(struct hns3_hw *hw, - hns3_warn(hw, "ignore PTP capability due to lack of " - "rxd advanced layout capability."); - } -+ if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B)) -+ hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B)) - hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 1); - if (hns3_get_bit(caps, HNS3_CAPS_TQP_TXRX_INDEP_B)) -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index 88683dfaaa..a4683de0aa 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -315,6 +315,7 @@ enum HNS3_CAPS_BITS { - */ - HNS3_CAPS_FD_QUEUE_REGION_B = 2, - HNS3_CAPS_PTP_B, -+ HNS3_CAPS_TX_PUSH_B = 6, - HNS3_CAPS_PHY_IMP_B = 7, - HNS3_CAPS_TQP_TXRX_INDEP_B, - HNS3_CAPS_HW_PAD_B, --- -2.33.0 - diff --git a/0220-examples-kni-close-port-before-exit.patch b/0220-examples-kni-close-port-before-exit.patch deleted file mode 100644 index 8032bdf..0000000 --- a/0220-examples-kni-close-port-before-exit.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 96fdb80048e279289e012fafe762f5b53e2ecd23 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 14 Sep 2021 14:02:19 +0800 -Subject: [PATCH 01/17] examples/kni: close port before exit - -This patch adds dev_close() step to release network adapter resources -when kni free. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Acked-by: Ferruh Yigit ---- - examples/kni/main.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/examples/kni/main.c b/examples/kni/main.c -index fe93b8618..40e1790c4 100644 ---- a/examples/kni/main.c -+++ b/examples/kni/main.c -@@ -1031,6 +1031,7 @@ kni_free_kni(uint16_t port_id) - if (ret != 0) - RTE_LOG(ERR, APP, "Failed to stop port %d: %s\n", - port_id, rte_strerror(-ret)); -+ rte_eth_dev_close(port_id); - - return 0; - } --- -2.23.0 - diff --git a/0221-net-hns3-fix-residual-MAC-after-setting-default-MAC.patch b/0221-net-hns3-fix-residual-MAC-after-setting-default-MAC.patch deleted file mode 100644 index 73f59f3..0000000 --- a/0221-net-hns3-fix-residual-MAC-after-setting-default-MAC.patch +++ /dev/null @@ -1,141 +0,0 @@ -From 5fcd00f784f9b984bf1f8a084a6be32816585717 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 22 Sep 2021 11:41:51 +0800 -Subject: [PATCH 02/17] net/hns3: fix residual MAC after setting default MAC - -This problem occurs in the following scenarios: -1) reset is encountered when the adapter is running. -2) set a new default MAC address - -After the above two steps, the old default MAC address should be not -take effect. But the current behavior is contrary to that. This is due -to the change of the "default_addr_setted" in hw->mac from 'true' to -'false' after the reset. As a result, the old MAC address is not removed -when the new default MAC address is set. This variable controls whether -to delete the old default MAC address when setting the default MAC -address. It is only used when the mac_addr_set API is called for the -first time. In fact, when a unicast MAC address is deleted, if the -address isn't in the MAC address table, the driver doesn't return -failure. So this patch remove the redundant and troublesome variables to -resolve this problem. - -Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 38 ++++++++++------------------------ - drivers/net/hns3/hns3_ethdev.h | 1 - - 2 files changed, 11 insertions(+), 28 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2fb0c466c..d6228601f 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1651,7 +1651,7 @@ hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - - static int - hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -- uint32_t idx, __rte_unused uint32_t pool) -+ __rte_unused uint32_t idx, __rte_unused uint32_t pool) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -@@ -1682,8 +1682,6 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - return ret; - } - -- if (idx == 0) -- hw->mac.default_addr_setted = true; - rte_spinlock_unlock(&hw->lock); - - return ret; -@@ -1748,30 +1746,19 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct rte_ether_addr *oaddr; - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- bool default_addr_setted; - int ret, ret_val; - -- /* -- * It has been guaranteed that input parameter named mac_addr is valid -- * address in the rte layer of DPDK framework. -- */ -- oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; -- default_addr_setted = hw->mac.default_addr_setted; -- if (default_addr_setted && !!rte_is_same_ether_addr(mac_addr, oaddr)) -- return 0; -- - rte_spinlock_lock(&hw->lock); -- if (default_addr_setted) { -- ret = hns3_remove_uc_addr_common(hw, oaddr); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- oaddr); -- hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", -- mac_str, ret); -+ oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; -+ ret = hns3_remove_uc_addr_common(hw, oaddr); -+ if (ret) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ oaddr); -+ hns3_warn(hw, "Remove old uc mac address(%s) fail: %d", -+ mac_str, ret); - -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -+ rte_spinlock_unlock(&hw->lock); -+ return ret; - } - - ret = hns3_add_uc_addr_common(hw, mac_addr); -@@ -1790,7 +1777,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - - rte_ether_addr_copy(mac_addr, - (struct rte_ether_addr *)hw->mac.mac_addr); -- hw->mac.default_addr_setted = true; - rte_spinlock_unlock(&hw->lock); - - return 0; -@@ -1811,7 +1797,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); - hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", - mac_str, ret_val); -- hw->mac.default_addr_setted = false; - } - rte_spinlock_unlock(&hw->lock); - -@@ -3470,7 +3455,6 @@ hns3_get_board_configuration(struct hns3_hw *hw) - hw->rss_dis_flag = false; - memcpy(hw->mac.mac_addr, cfg.mac_addr, RTE_ETHER_ADDR_LEN); - hw->mac.phy_addr = cfg.phy_addr; -- hw->mac.default_addr_setted = false; - hw->num_tx_desc = cfg.tqp_desc_num; - hw->num_rx_desc = cfg.tqp_desc_num; - hw->dcb_info.num_pg = 1; -@@ -5928,7 +5912,7 @@ hns3_do_stop(struct hns3_adapter *hns) - return ret; - } - } -- hw->mac.default_addr_setted = false; -+ - return 0; - } - -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index ab44894a8..57387e05b 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -188,7 +188,6 @@ enum hns3_media_type { - - struct hns3_mac { - uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; -- bool default_addr_setted; /* whether default addr(mac_addr) is set */ - uint8_t media_type; - uint8_t phy_addr; - uint8_t link_duplex : 1; /* ETH_LINK_[HALF/FULL]_DUPLEX */ --- -2.23.0 - diff --git a/0222-net-hns3-fix-input-parameters-of-MAC-functions.patch b/0222-net-hns3-fix-input-parameters-of-MAC-functions.patch deleted file mode 100644 index 91c7ef6..0000000 --- a/0222-net-hns3-fix-input-parameters-of-MAC-functions.patch +++ /dev/null @@ -1,210 +0,0 @@ -From bc25acd9ac200067f0f1a68c192076a65e4c76e6 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Wed, 22 Sep 2021 11:41:52 +0800 -Subject: [PATCH 03/17] net/hns3: fix input parameters of MAC functions - -When adding multicast and unicast MAC addresses, three descriptors and -one descriptor are required for querying or adding MAC VLAN table, -respectively. This patch uses the number of descriptors as input -parameter to complete this task to make the function more secure. - -Fixes: 7d7f9f80bbfb ("net/hns3: support MAC address related operations") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.h | 3 +- - drivers/net/hns3/hns3_ethdev.c | 88 +++++++++++++++++++--------------- - 2 files changed, 51 insertions(+), 40 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.h b/drivers/net/hns3/hns3_cmd.h -index a4683de0a..81bc9e9d9 100644 ---- a/drivers/net/hns3/hns3_cmd.h -+++ b/drivers/net/hns3/hns3_cmd.h -@@ -923,7 +923,8 @@ enum hns3_mac_vlan_add_resp_code { - HNS3_ADD_MC_OVERFLOW, /* ADD failed for MC overflow */ - }; - --#define HNS3_MC_MAC_VLAN_ADD_DESC_NUM 3 -+#define HNS3_MC_MAC_VLAN_OPS_DESC_NUM 3 -+#define HNS3_UC_MAC_VLAN_OPS_DESC_NUM 1 - - #define HNS3_MAC_VLAN_BIT0_EN_B 0 - #define HNS3_MAC_VLAN_BIT1_EN_B 1 -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index d6228601f..02d68e496 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1427,28 +1427,31 @@ hns3_get_mac_vlan_cmd_status(struct hns3_hw *hw, uint16_t cmdq_resp, - static int - hns3_lookup_mac_vlan_tbl(struct hns3_hw *hw, - struct hns3_mac_vlan_tbl_entry_cmd *req, -- struct hns3_cmd_desc *desc, bool is_mc) -+ struct hns3_cmd_desc *desc, uint8_t desc_num) - { - uint8_t resp_code; - uint16_t retval; - int ret; -+ int i; - -- hns3_cmd_setup_basic_desc(&desc[0], HNS3_OPC_MAC_VLAN_ADD, true); -- if (is_mc) { -- desc[0].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -- memcpy(desc[0].data, req, -- sizeof(struct hns3_mac_vlan_tbl_entry_cmd)); -- hns3_cmd_setup_basic_desc(&desc[1], HNS3_OPC_MAC_VLAN_ADD, -- true); -- desc[1].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -- hns3_cmd_setup_basic_desc(&desc[2], HNS3_OPC_MAC_VLAN_ADD, -+ if (desc_num == HNS3_MC_MAC_VLAN_OPS_DESC_NUM) { -+ for (i = 0; i < desc_num - 1; i++) { -+ hns3_cmd_setup_basic_desc(&desc[i], -+ HNS3_OPC_MAC_VLAN_ADD, true); -+ desc[i].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ if (i == 0) -+ memcpy(desc[i].data, req, -+ sizeof(struct hns3_mac_vlan_tbl_entry_cmd)); -+ } -+ hns3_cmd_setup_basic_desc(&desc[i], HNS3_OPC_MAC_VLAN_ADD, - true); -- ret = hns3_cmd_send(hw, desc, HNS3_MC_MAC_VLAN_ADD_DESC_NUM); - } else { -+ hns3_cmd_setup_basic_desc(&desc[0], HNS3_OPC_MAC_VLAN_ADD, -+ true); - memcpy(desc[0].data, req, - sizeof(struct hns3_mac_vlan_tbl_entry_cmd)); -- ret = hns3_cmd_send(hw, desc, 1); - } -+ ret = hns3_cmd_send(hw, desc, desc_num); - if (ret) { - hns3_err(hw, "lookup mac addr failed for cmd_send, ret =%d.", - ret); -@@ -1464,38 +1467,40 @@ hns3_lookup_mac_vlan_tbl(struct hns3_hw *hw, - static int - hns3_add_mac_vlan_tbl(struct hns3_hw *hw, - struct hns3_mac_vlan_tbl_entry_cmd *req, -- struct hns3_cmd_desc *mc_desc) -+ struct hns3_cmd_desc *desc, uint8_t desc_num) - { - uint8_t resp_code; - uint16_t retval; - int cfg_status; - int ret; -+ int i; - -- if (mc_desc == NULL) { -- struct hns3_cmd_desc desc; -- -- hns3_cmd_setup_basic_desc(&desc, HNS3_OPC_MAC_VLAN_ADD, false); -- memcpy(desc.data, req, -+ if (desc_num == HNS3_UC_MAC_VLAN_OPS_DESC_NUM) { -+ hns3_cmd_setup_basic_desc(desc, HNS3_OPC_MAC_VLAN_ADD, false); -+ memcpy(desc->data, req, - sizeof(struct hns3_mac_vlan_tbl_entry_cmd)); -- ret = hns3_cmd_send(hw, &desc, 1); -- resp_code = (rte_le_to_cpu_32(desc.data[0]) >> 8) & 0xff; -- retval = rte_le_to_cpu_16(desc.retval); -+ ret = hns3_cmd_send(hw, desc, desc_num); -+ resp_code = (rte_le_to_cpu_32(desc->data[0]) >> 8) & 0xff; -+ retval = rte_le_to_cpu_16(desc->retval); - - cfg_status = hns3_get_mac_vlan_cmd_status(hw, retval, resp_code, - HNS3_MAC_VLAN_ADD); - } else { -- hns3_cmd_reuse_desc(&mc_desc[0], false); -- mc_desc[0].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -- hns3_cmd_reuse_desc(&mc_desc[1], false); -- mc_desc[1].flag |= rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -- hns3_cmd_reuse_desc(&mc_desc[2], false); -- mc_desc[2].flag &= rte_cpu_to_le_16(~HNS3_CMD_FLAG_NEXT); -- memcpy(mc_desc[0].data, req, -+ for (i = 0; i < desc_num; i++) { -+ hns3_cmd_reuse_desc(&desc[i], false); -+ if (i == desc_num - 1) -+ desc[i].flag &= -+ rte_cpu_to_le_16(~HNS3_CMD_FLAG_NEXT); -+ else -+ desc[i].flag |= -+ rte_cpu_to_le_16(HNS3_CMD_FLAG_NEXT); -+ } -+ memcpy(desc[0].data, req, - sizeof(struct hns3_mac_vlan_tbl_entry_cmd)); -- mc_desc[0].retval = 0; -- ret = hns3_cmd_send(hw, mc_desc, HNS3_MC_MAC_VLAN_ADD_DESC_NUM); -- resp_code = (rte_le_to_cpu_32(mc_desc[0].data[0]) >> 8) & 0xff; -- retval = rte_le_to_cpu_16(mc_desc[0].retval); -+ desc[0].retval = 0; -+ ret = hns3_cmd_send(hw, desc, desc_num); -+ resp_code = (rte_le_to_cpu_32(desc[0].data[0]) >> 8) & 0xff; -+ retval = rte_le_to_cpu_16(desc[0].retval); - - cfg_status = hns3_get_mac_vlan_cmd_status(hw, retval, resp_code, - HNS3_MAC_VLAN_ADD); -@@ -1540,7 +1545,7 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_mac_vlan_tbl_entry_cmd req; - struct hns3_pf *pf = &hns->pf; -- struct hns3_cmd_desc desc[3]; -+ struct hns3_cmd_desc desc; - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - uint16_t egress_port = 0; - uint8_t vf_id; -@@ -1574,10 +1579,12 @@ hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - * it if the entry is inexistent. Repeated unicast entry - * is not allowed in the mac vlan table. - */ -- ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, false); -+ ret = hns3_lookup_mac_vlan_tbl(hw, &req, &desc, -+ HNS3_UC_MAC_VLAN_OPS_DESC_NUM); - if (ret == -ENOENT) { - if (!hns3_is_umv_space_full(hw)) { -- ret = hns3_add_mac_vlan_tbl(hw, &req, NULL); -+ ret = hns3_add_mac_vlan_tbl(hw, &req, &desc, -+ HNS3_UC_MAC_VLAN_OPS_DESC_NUM); - if (!ret) - hns3_update_umv_space(hw, false); - return ret; -@@ -1867,8 +1874,8 @@ hns3_update_desc_vfid(struct hns3_cmd_desc *desc, uint8_t vfid, bool clr) - static int - hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { -+ struct hns3_cmd_desc desc[HNS3_MC_MAC_VLAN_OPS_DESC_NUM]; - struct hns3_mac_vlan_tbl_entry_cmd req; -- struct hns3_cmd_desc desc[3]; - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - uint8_t vf_id; - int ret; -@@ -1885,7 +1892,8 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - memset(&req, 0, sizeof(req)); - hns3_set_bit(req.entry_type, HNS3_MAC_VLAN_BIT0_EN_B, 0); - hns3_prepare_mac_addr(&req, mac_addr->addr_bytes, true); -- ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, true); -+ ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, -+ HNS3_MC_MAC_VLAN_OPS_DESC_NUM); - if (ret) { - /* This mac addr do not exist, add new entry for it */ - memset(desc[0].data, 0, sizeof(desc[0].data)); -@@ -1899,7 +1907,8 @@ hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - */ - vf_id = HNS3_PF_FUNC_ID; - hns3_update_desc_vfid(desc, vf_id, false); -- ret = hns3_add_mac_vlan_tbl(hw, &req, desc); -+ ret = hns3_add_mac_vlan_tbl(hw, &req, desc, -+ HNS3_MC_MAC_VLAN_OPS_DESC_NUM); - if (ret) { - if (ret == -ENOSPC) - hns3_err(hw, "mc mac vlan table is full"); -@@ -1932,7 +1941,8 @@ hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - memset(&req, 0, sizeof(req)); - hns3_set_bit(req.entry_type, HNS3_MAC_VLAN_BIT0_EN_B, 0); - hns3_prepare_mac_addr(&req, mac_addr->addr_bytes, true); -- ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, true); -+ ret = hns3_lookup_mac_vlan_tbl(hw, &req, desc, -+ HNS3_MC_MAC_VLAN_OPS_DESC_NUM); - if (ret == 0) { - /* - * This mac addr exist, remove this handle's VFID for it. --- -2.23.0 - diff --git a/0223-net-bonding-fix-dedicated-queue-mode-in-vector-burst.patch b/0223-net-bonding-fix-dedicated-queue-mode-in-vector-burst.patch deleted file mode 100644 index 031c285..0000000 --- a/0223-net-bonding-fix-dedicated-queue-mode-in-vector-burst.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 19dc6356916c60f282b6d3046f5d2f1d74d48d35 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 22 Sep 2021 15:09:12 +0800 -Subject: [PATCH 10/17] net/bonding: fix dedicated queue mode in vector burst - -If the vector burst mode is selected, the dedicated queue mode will not -take effect on some PMDs because these PMDs may have some limitations -in vector burst mode. For example, the limit on burst size. Currently, -both hns3 and intel I40E require four alignments when receiving packets -in vector mode. As a result, they can't accept packets if burst size -below four. However, in dedicated queue mode, the burst size of periodic -packets processing is one. - -This patch fixes the above problem by modifying the burst size to 32. -This approach also makes the packet processing of the dedicated queue -mode more reasonable. Currently, if multiple LACP protocol packets are -received in the hardware queue in a cycle, only one LACP packet will be -processed in this cycle, and the left packets will be processed in the -following cycle. After the modification, all the LACP packets will be -processed at one time, which seems more reasonable and closer to the -behavior of the bonding driver when the dedicated queue is not turned on. - -Fixes: 112891cd27e5 ("net/bonding: add dedicated HW queues for LACP control") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/bonding/rte_eth_bond_8023ad.c | 32 ++++++++++++++++------- - 1 file changed, 23 insertions(+), 9 deletions(-) - -diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c -index 67ca0730f..0bcce6652 100644 ---- a/drivers/net/bonding/rte_eth_bond_8023ad.c -+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c -@@ -823,6 +823,27 @@ rx_machine_update(struct bond_dev_private *internals, uint16_t slave_id, - rx_machine(internals, slave_id, NULL); - } - -+static void -+bond_mode_8023ad_dedicated_rxq_process(struct bond_dev_private *internals, -+ uint16_t slave_id) -+{ -+#define DEDICATED_QUEUE_BURST_SIZE 32 -+ struct rte_mbuf *lacp_pkt[DEDICATED_QUEUE_BURST_SIZE]; -+ uint16_t rx_count = rte_eth_rx_burst(slave_id, -+ internals->mode4.dedicated_queues.rx_qid, -+ lacp_pkt, DEDICATED_QUEUE_BURST_SIZE); -+ -+ if (rx_count) { -+ uint16_t i; -+ -+ for (i = 0; i < rx_count; i++) -+ bond_mode_8023ad_handle_slow_pkt(internals, slave_id, -+ lacp_pkt[i]); -+ } else { -+ rx_machine_update(internals, slave_id, NULL); -+ } -+} -+ - static void - bond_mode_8023ad_periodic_cb(void *arg) - { -@@ -911,15 +932,8 @@ bond_mode_8023ad_periodic_cb(void *arg) - - rx_machine_update(internals, slave_id, lacp_pkt); - } else { -- uint16_t rx_count = rte_eth_rx_burst(slave_id, -- internals->mode4.dedicated_queues.rx_qid, -- &lacp_pkt, 1); -- -- if (rx_count == 1) -- bond_mode_8023ad_handle_slow_pkt(internals, -- slave_id, lacp_pkt); -- else -- rx_machine_update(internals, slave_id, NULL); -+ bond_mode_8023ad_dedicated_rxq_process(internals, -+ slave_id); - } - - periodic_machine(internals, slave_id); --- -2.23.0 - diff --git a/0224-net-bonding-fix-RSS-key-length.patch b/0224-net-bonding-fix-RSS-key-length.patch deleted file mode 100644 index fbf9a1e..0000000 --- a/0224-net-bonding-fix-RSS-key-length.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 464bfbd345224ddb04399297988c0d99cbe8acc6 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Wed, 22 Sep 2021 15:09:13 +0800 -Subject: [PATCH 11/17] net/bonding: fix RSS key length - -Currently the hash_key_size information has not been set. So, apps can -not get the key size from dev_info(), this make some problem. - -e.g, in testpmd, the hash_key_size will be checked before configure -or get the hash key: -testpmd> show port 4 rss-hash -dev_info did not provide a valid hash key size -testpmd> show port 4 rss-hash key -dev_info did not provide a valid hash key size -testpmd> port config 4 rss-hash-key ipv4 (hash key) -dev_info did not provide a valid hash key size - -In this patch, the meaning of rss_key_len has been modified. It only -indicated the length of the configured hash key before. Therefore, -its value depends on the user's configuration. This seems unreasonable. -And now, it indicates the minimum hash key length required by the -bonded device. Its value will be the shortest hash key among all slave -drivers. - -Fixes: 734ce47f71e0 ("bonding: support RSS dynamic configuration") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/bonding/rte_eth_bond_api.c | 6 ++++ - drivers/net/bonding/rte_eth_bond_pmd.c | 44 ++++++++++++++++---------- - 2 files changed, 33 insertions(+), 17 deletions(-) - -diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c -index 44775f61e..c751a1242 100644 ---- a/drivers/net/bonding/rte_eth_bond_api.c -+++ b/drivers/net/bonding/rte_eth_bond_api.c -@@ -290,6 +290,7 @@ eth_bond_slave_inherit_dev_info_rx_first(struct bond_dev_private *internals, - struct rte_eth_rxconf *rxconf_i = &internals->default_rxconf; - - internals->reta_size = di->reta_size; -+ internals->rss_key_len = di->hash_key_size; - - /* Inherit Rx offload capabilities from the first slave device */ - internals->rx_offload_capa = di->rx_offload_capa; -@@ -385,6 +386,11 @@ eth_bond_slave_inherit_dev_info_rx_next(struct bond_dev_private *internals, - */ - if (internals->reta_size > di->reta_size) - internals->reta_size = di->reta_size; -+ if (internals->rss_key_len > di->hash_key_size) { -+ RTE_BOND_LOG(WARNING, "slave has different rss key size, " -+ "configuring rss may fail"); -+ internals->rss_key_len = di->hash_key_size; -+ } - - if (!internals->max_rx_pktlen && - di->max_rx_pktlen < internals->candidate_max_rx_pktlen) -diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c -index 057b1ada5..c21df6d6f 100644 ---- a/drivers/net/bonding/rte_eth_bond_pmd.c -+++ b/drivers/net/bonding/rte_eth_bond_pmd.c -@@ -1705,14 +1705,11 @@ slave_configure(struct rte_eth_dev *bonded_eth_dev, - - /* If RSS is enabled for bonding, try to enable it for slaves */ - if (bonded_eth_dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG) { -- if (internals->rss_key_len != 0) { -- slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len = -+ /* rss_key won't be empty if RSS is configured in bonded dev */ -+ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len = - internals->rss_key_len; -- slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = -+ slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = - internals->rss_key; -- } else { -- slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL; -- } - - slave_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = - bonded_eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf; -@@ -2234,6 +2231,7 @@ bond_ethdev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) - dev_info->flow_type_rss_offloads = internals->flow_type_rss_offloads; - - dev_info->reta_size = internals->reta_size; -+ dev_info->hash_key_size = internals->rss_key_len; - - return 0; - } -@@ -3023,13 +3021,15 @@ bond_ethdev_rss_hash_update(struct rte_eth_dev *dev, - if (bond_rss_conf.rss_hf != 0) - dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf = bond_rss_conf.rss_hf; - -- if (bond_rss_conf.rss_key && bond_rss_conf.rss_key_len < -- sizeof(internals->rss_key)) { -- if (bond_rss_conf.rss_key_len == 0) -- bond_rss_conf.rss_key_len = 40; -- internals->rss_key_len = bond_rss_conf.rss_key_len; -+ if (bond_rss_conf.rss_key) { -+ if (bond_rss_conf.rss_key_len < internals->rss_key_len) -+ return -EINVAL; -+ else if (bond_rss_conf.rss_key_len > internals->rss_key_len) -+ RTE_BOND_LOG(WARNING, "rss_key will be truncated"); -+ - memcpy(internals->rss_key, bond_rss_conf.rss_key, - internals->rss_key_len); -+ bond_rss_conf.rss_key_len = internals->rss_key_len; - } - - for (i = 0; i < internals->slave_count; i++) { -@@ -3491,14 +3491,24 @@ bond_ethdev_configure(struct rte_eth_dev *dev) - * Fall back to default RSS key if the key is not specified - */ - if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS) { -- if (dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key != NULL) { -- internals->rss_key_len = -- dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key_len; -- memcpy(internals->rss_key, -- dev->data->dev_conf.rx_adv_conf.rss_conf.rss_key, -+ struct rte_eth_rss_conf *rss_conf = -+ &dev->data->dev_conf.rx_adv_conf.rss_conf; -+ if (rss_conf->rss_key != NULL) { -+ if (internals->rss_key_len > rss_conf->rss_key_len) { -+ RTE_BOND_LOG(ERR, "Invalid rss key length(%u)", -+ rss_conf->rss_key_len); -+ return -EINVAL; -+ } -+ -+ memcpy(internals->rss_key, rss_conf->rss_key, - internals->rss_key_len); - } else { -- internals->rss_key_len = sizeof(default_rss_key); -+ if (internals->rss_key_len > sizeof(default_rss_key)) { -+ RTE_BOND_LOG(ERR, -+ "There is no suitable default hash key"); -+ return -EINVAL; -+ } -+ - memcpy(internals->rss_key, default_rss_key, - internals->rss_key_len); - } --- -2.23.0 - diff --git a/0225-app-testpmd-add-command-to-show-LACP-bonding-info.patch b/0225-app-testpmd-add-command-to-show-LACP-bonding-info.patch deleted file mode 100644 index 380433f..0000000 --- a/0225-app-testpmd-add-command-to-show-LACP-bonding-info.patch +++ /dev/null @@ -1,247 +0,0 @@ -From 992fb12f5a2061144190986a1a82c64f9b324e5b Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Fri, 24 Sep 2021 17:57:20 +0800 -Subject: [PATCH 12/17] app/testpmd: add command to show LACP bonding info - -Add a new cmdline to help diagnostic the bonding mode 4 in testpmd. - -Show the lacp information about the bonded device and its slaves: -show bonding lacp info - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) -Acked-by: Xiaoyun Li ---- - app/test-pmd/cmdline.c | 184 ++++++++++++++++++++ - doc/guides/testpmd_app_ug/testpmd_funcs.rst | 6 + - 2 files changed, 190 insertions(+) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index b69c648bf..5691fab94 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -631,6 +631,9 @@ static void cmd_help_long_parsed(void *parsed_result, - "show bonding config (port_id)\n" - " Show the bonding config for port_id.\n\n" - -+ "show bonding lacp info (port_id)\n" -+ " Show the bonding lacp information for port_id.\n\n" -+ - "set bonding mac_addr (port_id) (address)\n" - " Set the MAC address of a bonded device.\n\n" - -@@ -6040,6 +6043,186 @@ cmdline_parse_inst_t cmd_set_balance_xmit_policy = { - } - }; - -+/* *** SHOW IEEE802.3 BONDING INFORMATION *** */ -+struct cmd_show_bonding_lacp_info_result { -+ cmdline_fixed_string_t show; -+ cmdline_fixed_string_t bonding; -+ cmdline_fixed_string_t lacp; -+ cmdline_fixed_string_t info; -+ portid_t port_id; -+}; -+ -+static void port_param_show(struct port_params *params) -+{ -+ char buf[RTE_ETHER_ADDR_FMT_SIZE]; -+ -+ printf("\t\tsystem priority: %u\n", params->system_priority); -+ rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, ¶ms->system); -+ printf("\t\tsystem mac address: %s\n", buf); -+ printf("\t\tport key: %u\n", params->key); -+ printf("\t\tport priority: %u\n", params->port_priority); -+ printf("\t\tport number: %u\n", params->port_number); -+} -+ -+static void lacp_slave_info_show(struct rte_eth_bond_8023ad_slave_info *info) -+{ -+ char a_state[256] = { 0 }; -+ char p_state[256] = { 0 }; -+ int a_len = 0; -+ int p_len = 0; -+ uint32_t i; -+ -+ static const char * const state[] = { -+ "ACTIVE", -+ "TIMEOUT", -+ "AGGREGATION", -+ "SYNCHRONIZATION", -+ "COLLECTING", -+ "DISTRIBUTING", -+ "DEFAULTED", -+ "EXPIRED" -+ }; -+ static const char * const selection[] = { -+ "UNSELECTED", -+ "STANDBY", -+ "SELECTED" -+ }; -+ -+ for (i = 0; i < RTE_DIM(state); i++) { -+ if ((info->actor_state >> i) & 1) -+ a_len += snprintf(&a_state[a_len], -+ RTE_DIM(a_state) - a_len, "%s ", -+ state[i]); -+ -+ if ((info->partner_state >> i) & 1) -+ p_len += snprintf(&p_state[p_len], -+ RTE_DIM(p_state) - p_len, "%s ", -+ state[i]); -+ } -+ printf("\tAggregator port id: %u\n", info->agg_port_id); -+ printf("\tselection: %s\n", selection[info->selected]); -+ printf("\tActor detail info:\n"); -+ port_param_show(&info->actor); -+ printf("\t\tport state: %s\n", a_state); -+ printf("\tPartner detail info:\n"); -+ port_param_show(&info->partner); -+ printf("\t\tport state: %s\n", p_state); -+ printf("\n"); -+} -+ -+static void lacp_conf_show(struct rte_eth_bond_8023ad_conf *conf) -+{ -+ printf("\tfast period: %u ms\n", conf->fast_periodic_ms); -+ printf("\tslow period: %u ms\n", conf->slow_periodic_ms); -+ printf("\tshort timeout: %u ms\n", conf->short_timeout_ms); -+ printf("\tlong timeout: %u ms\n", conf->long_timeout_ms); -+ printf("\taggregate wait timeout: %u ms\n", -+ conf->aggregate_wait_timeout_ms); -+ printf("\ttx period: %u ms\n", conf->tx_period_ms); -+ printf("\trx marker period: %u ms\n", conf->rx_marker_period_ms); -+ printf("\tupdate timeout: %u ms\n", conf->update_timeout_ms); -+ switch (conf->agg_selection) { -+ case AGG_BANDWIDTH: -+ printf("\taggregation mode: bandwidth\n"); -+ break; -+ case AGG_STABLE: -+ printf("\taggregation mode: stable\n"); -+ break; -+ case AGG_COUNT: -+ printf("\taggregation mode: count\n"); -+ break; -+ default: -+ printf("\taggregation mode: invalid\n"); -+ break; -+ } -+ -+ printf("\n"); -+} -+ -+static void cmd_show_bonding_lacp_info_parsed(void *parsed_result, -+ __rte_unused struct cmdline *cl, -+ __rte_unused void *data) -+{ -+ struct cmd_show_bonding_lacp_info_result *res = parsed_result; -+ struct rte_eth_bond_8023ad_slave_info slave_info; -+ struct rte_eth_bond_8023ad_conf port_conf; -+ portid_t slaves[RTE_MAX_ETHPORTS]; -+ portid_t port_id = res->port_id; -+ int num_active_slaves; -+ int bonding_mode; -+ int i; -+ int ret; -+ -+ bonding_mode = rte_eth_bond_mode_get(port_id); -+ if (bonding_mode != BONDING_MODE_8023AD) { -+ fprintf(stderr, "\tBonding mode is not mode 4\n"); -+ return; -+ } -+ -+ num_active_slaves = rte_eth_bond_active_slaves_get(port_id, slaves, -+ RTE_MAX_ETHPORTS); -+ if (num_active_slaves < 0) { -+ fprintf(stderr, "\tFailed to get active slave list for port = %u\n", -+ port_id); -+ return; -+ } -+ if (num_active_slaves == 0) -+ fprintf(stderr, "\tIEEE802.3 port %u has no active slave\n", -+ port_id); -+ -+ printf("\tIEEE802.3 port: %u\n", port_id); -+ ret = rte_eth_bond_8023ad_conf_get(port_id, &port_conf); -+ if (ret) { -+ fprintf(stderr, "\tGet bonded device %u info failed\n", -+ port_id); -+ return; -+ } -+ lacp_conf_show(&port_conf); -+ -+ for (i = 0; i < num_active_slaves; i++) { -+ ret = rte_eth_bond_8023ad_slave_info(port_id, slaves[i], -+ &slave_info); -+ if (ret) { -+ fprintf(stderr, "\tGet slave device %u info failed\n", -+ slaves[i]); -+ return; -+ } -+ printf("\tSlave Port: %u\n", slaves[i]); -+ lacp_slave_info_show(&slave_info); -+ } -+} -+ -+cmdline_parse_token_string_t cmd_show_bonding_lacp_info_show = -+TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, -+ show, "show"); -+cmdline_parse_token_string_t cmd_show_bonding_lacp_info_bonding = -+TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, -+ bonding, "bonding"); -+cmdline_parse_token_string_t cmd_show_bonding_lacp_info_lacp = -+TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, -+ bonding, "lacp"); -+cmdline_parse_token_string_t cmd_show_bonding_lacp_info_info = -+TOKEN_STRING_INITIALIZER(struct cmd_show_bonding_lacp_info_result, -+ info, "info"); -+cmdline_parse_token_num_t cmd_show_bonding_lacp_info_port_id = -+TOKEN_NUM_INITIALIZER(struct cmd_show_bonding_lacp_info_result, -+ port_id, RTE_UINT16); -+ -+cmdline_parse_inst_t cmd_show_bonding_lacp_info = { -+ .f = cmd_show_bonding_lacp_info_parsed, -+ .help_str = "show bonding lacp info : " -+ "Show bonding IEEE802.3 information for port_id", -+ .data = NULL, -+ .tokens = { -+ (void *)&cmd_show_bonding_lacp_info_show, -+ (void *)&cmd_show_bonding_lacp_info_bonding, -+ (void *)&cmd_show_bonding_lacp_info_lacp, -+ (void *)&cmd_show_bonding_lacp_info_info, -+ (void *)&cmd_show_bonding_lacp_info_port_id, -+ NULL -+ } -+}; -+ - /* *** SHOW NIC BONDING CONFIGURATION *** */ - struct cmd_show_bonding_config_result { - cmdline_fixed_string_t show; -@@ -17027,6 +17210,7 @@ cmdline_parse_ctx_t main_ctx[] = { - #ifdef RTE_NET_BOND - (cmdline_parse_inst_t *) &cmd_set_bonding_mode, - (cmdline_parse_inst_t *) &cmd_show_bonding_config, -+ (cmdline_parse_inst_t *) &cmd_show_bonding_lacp_info, - (cmdline_parse_inst_t *) &cmd_set_bonding_primary, - (cmdline_parse_inst_t *) &cmd_add_bonding_slave, - (cmdline_parse_inst_t *) &cmd_remove_bonding_slave, -diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -index f0e04232a..d5e85b083 100644 ---- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst -+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst -@@ -2609,6 +2609,12 @@ in balance mode with a transmission policy of layer 2+3:: - Active Slaves (3): [1 3 4] - Primary: [3] - -+show bonding lacp info -+~~~~~~~~~~~~~~~~~~~~~~ -+ -+Show information about the Link Bonding device in mode 4 (link-aggregation-802.3ad):: -+ -+ testpmd> show bonding lacp info (port_id) - - Register Functions - ------------------ --- -2.23.0 - diff --git a/0226-app-testpmd-retain-all-original-dev-conf-when-config.patch b/0226-app-testpmd-retain-all-original-dev-conf-when-config.patch deleted file mode 100644 index 3dc1ec4..0000000 --- a/0226-app-testpmd-retain-all-original-dev-conf-when-config.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 65de76da4d8fc270af6bce73334399d0d3c20fa3 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Mon, 11 Oct 2021 17:12:46 +0800 -Subject: [PATCH 13/17] app/testpmd: retain all original dev conf when config - DCB - -When configuring DCB, testpmd retains the rx_mode/tx_mode configuration in -rte_port->dev_conf. But some configurations, such as the link_speed, were -not saved if they were set before configuring DCB. - -Fixes: 1a572499beb6 ("app/testpmd: setup DCB forwarding based on traffic class") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Acked-by: Xiaoyun Li ---- - app/test-pmd/testpmd.c | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index 3098df6c5..0eaa4852d 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -3484,10 +3484,8 @@ init_port_dcb_config(portid_t pid, - - rte_port = &ports[pid]; - -- memset(&port_conf, 0, sizeof(struct rte_eth_conf)); -- -- port_conf.rxmode = rte_port->dev_conf.rxmode; -- port_conf.txmode = rte_port->dev_conf.txmode; -+ /* retain the original device configuration. */ -+ memcpy(&port_conf, &rte_port->dev_conf, sizeof(struct rte_eth_conf)); - - /*set configuration of DCB in vt mode and DCB in non-vt mode*/ - retval = get_eth_dcb_conf(pid, &port_conf, dcb_mode, num_tcs, pfc_en); --- -2.23.0 - diff --git a/0227-net-hns3-remove-similar-macro-function-definitions.patch b/0227-net-hns3-remove-similar-macro-function-definitions.patch deleted file mode 100644 index 076e76c..0000000 --- a/0227-net-hns3-remove-similar-macro-function-definitions.patch +++ /dev/null @@ -1,593 +0,0 @@ -From 637fc8040d4aa52eba9c7c78a5c826f4a13c4da0 Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Sat, 9 Oct 2021 15:48:05 +0800 -Subject: [PATCH 14/17] net/hns3: remove similar macro function definitions - -For different capabilities, we declare different macro functions to -determine whether the capabilities are supported. - -This patch declare a unified macro function to judge capabilities. - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 6 ++--- - drivers/net/hns3/hns3_dcb.c | 4 +-- - drivers/net/hns3/hns3_ethdev.c | 24 +++++++++--------- - drivers/net/hns3/hns3_ethdev.h | 41 ++----------------------------- - drivers/net/hns3/hns3_ethdev_vf.c | 6 ++--- - drivers/net/hns3/hns3_flow.c | 2 +- - drivers/net/hns3/hns3_intr.c | 2 +- - drivers/net/hns3/hns3_ptp.c | 18 +++++++------- - drivers/net/hns3/hns3_rxtx.c | 32 ++++++++++++------------ - drivers/net/hns3/hns3_rxtx_vec.c | 4 +-- - drivers/net/hns3/hns3_tm.c | 10 ++++---- - 11 files changed, 56 insertions(+), 93 deletions(-) - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index cfa943523..6e49108d2 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -619,7 +619,7 @@ hns3_update_dev_lsc_cap(struct hns3_hw *hw, int fw_compact_cmd_result) - static int - hns3_apply_fw_compat_cmd_result(struct hns3_hw *hw, int result) - { -- if (result != 0 && hns3_dev_copper_supported(hw)) { -+ if (result != 0 && hns3_dev_get_support(hw, COPPER)) { - hns3_err(hw, "firmware fails to initialize the PHY, ret = %d.", - result); - return result; -@@ -658,7 +658,7 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) - } - if (revision == PCI_REVISION_ID_HIP09_A) { - struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); -- if (hns3_dev_copper_supported(hw) == 0 || pf->is_tmp_phy) { -+ if (hns3_dev_get_support(hw, COPPER) == 0 || pf->is_tmp_phy) { - PMD_INIT_LOG(ERR, "***use temp phy driver in dpdk***"); - pf->is_tmp_phy = true; - hns3_set_bit(hw->capability, -@@ -676,7 +676,7 @@ hns3_firmware_compat_config(struct hns3_hw *hw, bool is_init) - if (is_init) { - hns3_set_bit(compat, HNS3_LINK_EVENT_REPORT_EN_B, 1); - hns3_set_bit(compat, HNS3_NCSI_ERROR_REPORT_EN_B, 0); -- if (hns3_dev_copper_supported(hw)) -+ if (hns3_dev_get_support(hw, COPPER)) - hns3_set_bit(compat, HNS3_FIRMWARE_PHY_DRIVER_EN_B, 1); - } - req->compat = rte_cpu_to_le_32(compat); -diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c -index b71e2e9ea..8753c340e 100644 ---- a/drivers/net/hns3/hns3_dcb.c -+++ b/drivers/net/hns3/hns3_dcb.c -@@ -918,7 +918,7 @@ hns3_dcb_pri_dwrr_cfg(struct hns3_hw *hw) - if (ret) - return ret; - -- if (!hns3_dev_dcb_supported(hw)) -+ if (!hns3_dev_get_support(hw, DCB)) - return 0; - - ret = hns3_dcb_ets_tc_dwrr_cfg(hw); -@@ -1368,7 +1368,7 @@ hns3_dcb_pause_setup_hw(struct hns3_hw *hw) - } - - /* Only DCB-supported dev supports qset back pressure and pfc cmd */ -- if (!hns3_dev_dcb_supported(hw)) -+ if (!hns3_dev_get_support(hw, DCB)) - return 0; - - ret = hns3_pfc_setup_hw(hw); -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 02d68e496..c5c355d95 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2408,7 +2408,7 @@ hns3_setup_dcb(struct rte_eth_dev *dev) - struct hns3_hw *hw = &hns->hw; - int ret; - -- if (!hns3_dev_dcb_supported(hw)) { -+ if (!hns3_dev_get_support(hw, DCB)) { - hns3_err(hw, "this port does not support dcb configurations."); - return -EOPNOTSUPP; - } -@@ -2746,14 +2746,14 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - DEV_TX_OFFLOAD_MBUF_FAST_FREE | - hns3_txvlan_cap_get(hw)); - -- if (hns3_dev_outer_udp_cksum_supported(hw)) -+ if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) - info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; - -- if (hns3_dev_indep_txrx_supported(hw)) -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) - info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | - RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; - -- if (hns3_dev_ptp_supported(hw)) -+ if (hns3_dev_get_support(hw, PTP)) - info->rx_offload_capa |= DEV_RX_OFFLOAD_TIMESTAMP; - - info->rx_desc_lim = (struct rte_eth_desc_lim) { -@@ -3418,7 +3418,7 @@ hns3_check_media_type(struct hns3_hw *hw, uint8_t media_type) - - switch (media_type) { - case HNS3_MEDIA_TYPE_COPPER: -- if (!hns3_dev_copper_supported(hw)) { -+ if (!hns3_dev_get_support(hw, COPPER)) { - PMD_INIT_LOG(ERR, - "Media type is copper, not supported."); - ret = -EOPNOTSUPP; -@@ -3486,7 +3486,7 @@ hns3_get_board_configuration(struct hns3_hw *hw) - } - - /* Dev does not support DCB */ -- if (!hns3_dev_dcb_supported(hw)) { -+ if (!hns3_dev_get_support(hw, DCB)) { - pf->tc_max = 1; - pf->pfc_max = 0; - } else -@@ -3799,7 +3799,7 @@ hns3_is_rx_buf_ok(struct hns3_hw *hw, struct hns3_pkt_buf_alloc *buf_alloc, - tc_num = hns3_get_tc_num(hw); - aligned_mps = roundup(pf->mps, HNS3_BUF_SIZE_UNIT); - -- if (hns3_dev_dcb_supported(hw)) -+ if (hns3_dev_get_support(hw, DCB)) - shared_buf_min = HNS3_BUF_MUL_BY * aligned_mps + - pf->dv_buf_size; - else -@@ -3816,7 +3816,7 @@ hns3_is_rx_buf_ok(struct hns3_hw *hw, struct hns3_pkt_buf_alloc *buf_alloc, - - shared_buf = rounddown(rx_all - rx_priv, HNS3_BUF_SIZE_UNIT); - buf_alloc->s_buf.buf_size = shared_buf; -- if (hns3_dev_dcb_supported(hw)) { -+ if (hns3_dev_get_support(hw, DCB)) { - buf_alloc->s_buf.self.high = shared_buf - pf->dv_buf_size; - buf_alloc->s_buf.self.low = buf_alloc->s_buf.self.high - - roundup(aligned_mps / HNS3_BUF_DIV_BY, -@@ -3827,7 +3827,7 @@ hns3_is_rx_buf_ok(struct hns3_hw *hw, struct hns3_pkt_buf_alloc *buf_alloc, - buf_alloc->s_buf.self.low = aligned_mps; - } - -- if (hns3_dev_dcb_supported(hw)) { -+ if (hns3_dev_get_support(hw, DCB)) { - hi_thrd = shared_buf - pf->dv_buf_size; - - if (tc_num <= NEED_RESERVE_TC_NUM) -@@ -4033,7 +4033,7 @@ static int - hns3_rx_buffer_calc(struct hns3_hw *hw, struct hns3_pkt_buf_alloc *buf_alloc) - { - /* When DCB is not supported, rx private buffer is not allocated. */ -- if (!hns3_dev_dcb_supported(hw)) { -+ if (!hns3_dev_get_support(hw, DCB)) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_pf *pf = &hns->pf; - uint32_t rx_all = pf->pkt_buf_size; -@@ -4261,7 +4261,7 @@ hns3_buffer_alloc(struct hns3_hw *hw) - return ret; - } - -- if (hns3_dev_dcb_supported(hw)) { -+ if (hns3_dev_get_support(hw, DCB)) { - ret = hns3_rx_priv_wl_config(hw, &pkt_buf); - if (ret) { - PMD_INIT_LOG(ERR, -@@ -6230,7 +6230,7 @@ hns3_priority_flow_ctrl_set(struct rte_eth_dev *dev, - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - int ret; - -- if (!hns3_dev_dcb_supported(hw)) { -+ if (!hns3_dev_get_support(hw, DCB)) { - hns3_err(hw, "This port does not support dcb configurations."); - return -EOPNOTSUPP; - } -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 57387e05b..94fd14bfc 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -883,45 +883,8 @@ enum { - HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B, - }; - --#define hns3_dev_dcb_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_DCB_B) -- --/* Support copper media type */ --#define hns3_dev_copper_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_COPPER_B) -- --/* Support the queue region action rule of flow directory */ --#define hns3_dev_fd_queue_region_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_FD_QUEUE_REGION_B) -- --/* Support PTP timestamp offload */ --#define hns3_dev_ptp_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_PTP_B) -- --/* Support to Independently enable/disable/reset Tx or Rx queues */ --#define hns3_dev_indep_txrx_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_INDEP_TXRX_B) -- --#define hns3_dev_stash_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_STASH_B) -- --#define hns3_dev_rxd_adv_layout_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_RXD_ADV_LAYOUT_B) -- --#define hns3_dev_outer_udp_cksum_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_OUTER_UDP_CKSUM_B) -- --#define hns3_dev_ras_imp_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_RAS_IMP_B) -- --#define hns3_dev_tx_push_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TX_PUSH_B) -- --#define hns3_dev_tm_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_TM_B) -- --#define hns3_dev_vf_vlan_flt_supported(hw) \ -- hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_VF_VLAN_FLT_MOD_B) -+#define hns3_dev_get_support(hw, _name) \ -+ hns3_get_bit((hw)->capability, HNS3_DEV_SUPPORT_##_name##_B) - - #define HNS3_DEV_PRIVATE_TO_HW(adapter) \ - (&((struct hns3_adapter *)adapter)->hw) -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index e07eb2088..d2895b140 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -988,10 +988,10 @@ hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - DEV_TX_OFFLOAD_MBUF_FAST_FREE | - hns3_txvlan_cap_get(hw)); - -- if (hns3_dev_outer_udp_cksum_supported(hw)) -+ if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) - info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; - -- if (hns3_dev_indep_txrx_supported(hw)) -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) - info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | - RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; - -@@ -1623,7 +1623,7 @@ hns3vf_en_vlan_filter(struct hns3_hw *hw, bool enable) - uint8_t msg_data; - int ret; - -- if (!hns3_dev_vf_vlan_flt_supported(hw)) -+ if (!hns3_dev_get_support(hw, VF_VLAN_FLT_MOD)) - return 0; - - msg_data = enable ? 1 : 0; -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index 6844a5dbe..b25fccbca 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -301,7 +301,7 @@ hns3_handle_action_queue_region(struct rte_eth_dev *dev, - struct hns3_hw *hw = &hns->hw; - uint16_t idx; - -- if (!hns3_dev_fd_queue_region_supported(hw)) -+ if (!hns3_dev_get_support(hw, FD_QUEUE_REGION)) - return rte_flow_error_set(error, ENOTSUP, - RTE_FLOW_ERROR_TYPE_ACTION, action, - "Not support config queue region!"); -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 0b307fdd1..3484c76d2 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -2368,7 +2368,7 @@ hns3_handle_error(struct hns3_adapter *hns) - { - struct hns3_hw *hw = &hns->hw; - -- if (hns3_dev_ras_imp_supported(hw)) { -+ if (hns3_dev_get_support(hw, RAS_IMP)) { - hns3_handle_hw_error_v2(hw); - hns3_schedule_reset(hns); - } else { -diff --git a/drivers/net/hns3/hns3_ptp.c b/drivers/net/hns3/hns3_ptp.c -index 146b69db7..14c1ad3e4 100644 ---- a/drivers/net/hns3/hns3_ptp.c -+++ b/drivers/net/hns3/hns3_ptp.c -@@ -61,7 +61,7 @@ hns3_ptp_init(struct hns3_hw *hw) - { - int ret; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return 0; - - ret = hns3_ptp_int_en(hw, true); -@@ -120,7 +120,7 @@ hns3_timesync_enable(struct rte_eth_dev *dev) - struct hns3_pf *pf = &hns->pf; - int ret; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - if (pf->ptp_enable) -@@ -140,7 +140,7 @@ hns3_timesync_disable(struct rte_eth_dev *dev) - struct hns3_pf *pf = &hns->pf; - int ret; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - if (!pf->ptp_enable) -@@ -164,7 +164,7 @@ hns3_timesync_read_rx_timestamp(struct rte_eth_dev *dev, - struct hns3_pf *pf = &hns->pf; - uint64_t ns, sec; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - ns = pf->rx_timestamp & TIME_RX_STAMP_NS_MASK; -@@ -190,7 +190,7 @@ hns3_timesync_read_tx_timestamp(struct rte_eth_dev *dev, - uint64_t ns; - int ts_cnt; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - ts_cnt = hns3_read_dev(hw, HNS3_TX_1588_BACK_TSP_CNT) & -@@ -219,7 +219,7 @@ hns3_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint64_t ns, sec; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - sec = hns3_read_dev(hw, HNS3_CURR_TIME_OUT_L); -@@ -240,7 +240,7 @@ hns3_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts) - uint64_t sec = ts->tv_sec; - uint64_t ns = ts->tv_nsec; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - /* Set the timecounters to a new value. */ -@@ -261,7 +261,7 @@ hns3_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta) - struct timespec cur_time; - uint64_t ns; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - (void)hns3_timesync_read_time(dev, &cur_time); -@@ -280,7 +280,7 @@ hns3_restore_ptp(struct hns3_adapter *hns) - bool en = pf->ptp_enable; - int ret; - -- if (!hns3_dev_ptp_supported(hw)) -+ if (!hns3_dev_get_support(hw, PTP)) - return 0; - - ret = hns3_timesync_configure(hns, en); -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index 80d2614d2..bb1723e29 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -381,7 +381,7 @@ hns3_enable_all_queues(struct hns3_hw *hw, bool en) - int i; - - for (i = 0; i < hw->cfg_max_queues; i++) { -- if (hns3_dev_indep_txrx_supported(hw)) { -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) { - rxq = i < nb_rx_q ? hw->data->rx_queues[i] : NULL; - txq = i < nb_tx_q ? hw->data->tx_queues[i] : NULL; - -@@ -426,7 +426,7 @@ hns3_enable_txq(struct hns3_tx_queue *txq, bool en) - struct hns3_hw *hw = &txq->hns->hw; - uint32_t reg; - -- if (hns3_dev_indep_txrx_supported(hw)) { -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) { - reg = hns3_read_dev(txq, HNS3_RING_TX_EN_REG); - if (en) - reg |= BIT(HNS3_RING_EN_B); -@@ -443,7 +443,7 @@ hns3_enable_rxq(struct hns3_rx_queue *rxq, bool en) - struct hns3_hw *hw = &rxq->hns->hw; - uint32_t reg; - -- if (hns3_dev_indep_txrx_supported(hw)) { -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) { - reg = hns3_read_dev(rxq, HNS3_RING_RX_EN_REG); - if (en) - reg |= BIT(HNS3_RING_EN_B); -@@ -1618,7 +1618,7 @@ hns3_set_fake_rx_or_tx_queues(struct rte_eth_dev *dev, uint16_t nb_rx_q, - uint16_t q; - int ret; - -- if (hns3_dev_indep_txrx_supported(hw)) -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) - return 0; - - /* Setup new number of fake RX/TX queues and reconfigure device. */ -@@ -1862,7 +1862,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - conf->rx_free_thresh : HNS3_DEFAULT_RX_FREE_THRESH; - - rxq->rx_deferred_start = conf->rx_deferred_start; -- if (rxq->rx_deferred_start && !hns3_dev_indep_txrx_supported(hw)) { -+ if (rxq->rx_deferred_start && !hns3_dev_get_support(hw, INDEP_TXRX)) { - hns3_warn(hw, "deferred start is not supported."); - rxq->rx_deferred_start = false; - } -@@ -1898,7 +1898,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - HNS3_PORT_BASE_VLAN_ENABLE; - else - rxq->pvid_sw_discard_en = false; -- rxq->ptype_en = hns3_dev_rxd_adv_layout_supported(hw) ? true : false; -+ rxq->ptype_en = hns3_dev_get_support(hw, RXD_ADV_LAYOUT) ? true : false; - rxq->configured = true; - rxq->io_base = (void *)((char *)hw->io_base + HNS3_TQP_REG_OFFSET + - idx * HNS3_TQP_REG_SIZE); -@@ -2026,7 +2026,7 @@ hns3_dev_supported_ptypes_get(struct rte_eth_dev *dev) - dev->rx_pkt_burst == hns3_recv_scattered_pkts || - dev->rx_pkt_burst == hns3_recv_pkts_vec || - dev->rx_pkt_burst == hns3_recv_pkts_vec_sve) { -- if (hns3_dev_rxd_adv_layout_supported(hw)) -+ if (hns3_dev_get_support(hw, RXD_ADV_LAYOUT)) - return adv_layout_ptypes; - else - return ptypes; -@@ -2928,7 +2928,7 @@ hns3_tx_push_init(struct rte_eth_dev *dev) - volatile uint32_t *reg; - uint32_t val; - -- if (!hns3_dev_tx_push_supported(hw)) -+ if (!hns3_dev_get_support(hw, TX_PUSH)) - return; - - reg = (volatile uint32_t *)hns3_tx_push_get_queue_tail_reg(dev, 0); -@@ -2949,7 +2949,7 @@ hns3_tx_push_queue_init(struct rte_eth_dev *dev, - struct hns3_tx_queue *txq) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- if (!hns3_dev_tx_push_supported(hw)) { -+ if (!hns3_dev_get_support(hw, TX_PUSH)) { - txq->tx_push_enable = false; - return; - } -@@ -2994,7 +2994,7 @@ hns3_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - } - - txq->tx_deferred_start = conf->tx_deferred_start; -- if (txq->tx_deferred_start && !hns3_dev_indep_txrx_supported(hw)) { -+ if (txq->tx_deferred_start && !hns3_dev_get_support(hw, INDEP_TXRX)) { - hns3_warn(hw, "deferred start is not supported."); - txq->tx_deferred_start = false; - } -@@ -4276,7 +4276,7 @@ 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_ptp_supported(hw)) -+ if (hns3_dev_get_support(hw, PTP)) - return false; - - return (offloads == (offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE)); -@@ -4437,7 +4437,7 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id) - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - int ret; - -- if (!hns3_dev_indep_txrx_supported(hw)) -+ if (!hns3_dev_get_support(hw, INDEP_TXRX)) - return -ENOTSUP; - - rte_spinlock_lock(&hw->lock); -@@ -4483,7 +4483,7 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_rx_queue *rxq = dev->data->rx_queues[rx_queue_id]; - -- if (!hns3_dev_indep_txrx_supported(hw)) -+ if (!hns3_dev_get_support(hw, INDEP_TXRX)) - return -ENOTSUP; - - rte_spinlock_lock(&hw->lock); -@@ -4505,7 +4505,7 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id) - struct hns3_tx_queue *txq = dev->data->tx_queues[tx_queue_id]; - int ret; - -- if (!hns3_dev_indep_txrx_supported(hw)) -+ if (!hns3_dev_get_support(hw, INDEP_TXRX)) - return -ENOTSUP; - - rte_spinlock_lock(&hw->lock); -@@ -4531,7 +4531,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_tx_queue *txq = dev->data->tx_queues[tx_queue_id]; - -- if (!hns3_dev_indep_txrx_supported(hw)) -+ if (!hns3_dev_get_support(hw, INDEP_TXRX)) - return -ENOTSUP; - - rte_spinlock_lock(&hw->lock); -@@ -4704,7 +4704,7 @@ hns3_enable_rxd_adv_layout(struct hns3_hw *hw) - * If the hardware support rxd advanced layout, then driver enable it - * default. - */ -- if (hns3_dev_rxd_adv_layout_supported(hw)) -+ if (hns3_dev_get_support(hw, RXD_ADV_LAYOUT)) - hns3_write_dev(hw, HNS3_RXD_ADV_LAYOUT_EN_REG, 1); - } - -diff --git a/drivers/net/hns3/hns3_rxtx_vec.c b/drivers/net/hns3/hns3_rxtx_vec.c -index 15a0bd075..bfe84e833 100644 ---- a/drivers/net/hns3/hns3_rxtx_vec.c -+++ b/drivers/net/hns3/hns3_rxtx_vec.c -@@ -19,7 +19,7 @@ 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_ptp_supported(hw)) -+ if (hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - /* Only support DEV_TX_OFFLOAD_MBUF_FAST_FREE */ -@@ -234,7 +234,7 @@ hns3_rx_check_vec_support(struct rte_eth_dev *dev) - DEV_RX_OFFLOAD_VLAN; - - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- if (hns3_dev_ptp_supported(hw)) -+ if (hns3_dev_get_support(hw, PTP)) - return -ENOTSUP; - - if (dev->data->scattered_rx) -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index db5ac786c..44b607af7 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -31,7 +31,7 @@ hns3_tm_conf_init(struct rte_eth_dev *dev) - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint32_t max_tx_queues = hns3_tm_max_tx_queues_get(dev); - -- if (!hns3_dev_tm_supported(hw)) -+ if (!hns3_dev_get_support(hw, TM)) - return; - - pf->tm_conf.nb_leaf_nodes_max = max_tx_queues; -@@ -58,7 +58,7 @@ hns3_tm_conf_uninit(struct rte_eth_dev *dev) - struct hns3_tm_shaper_profile *shaper_profile; - struct hns3_tm_node *tm_node; - -- if (!hns3_dev_tm_supported(hw)) -+ if (!hns3_dev_get_support(hw, TM)) - return; - - if (pf->tm_conf.nb_queue_node > 0) { -@@ -1233,7 +1233,7 @@ hns3_tm_ops_get(struct rte_eth_dev *dev, void *arg) - if (arg == NULL) - return -EINVAL; - -- if (!hns3_dev_tm_supported(hw)) -+ if (!hns3_dev_get_support(hw, TM)) - return -EOPNOTSUPP; - - *(const void **)arg = &hns3_tm_ops; -@@ -1246,7 +1246,7 @@ hns3_tm_dev_start_proc(struct hns3_hw *hw) - { - struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); - -- if (!hns3_dev_tm_supported(hw)) -+ if (!hns3_dev_get_support(hw, TM)) - return; - - if (pf->tm_conf.root && !pf->tm_conf.committed) -@@ -1295,7 +1295,7 @@ hns3_tm_conf_update(struct hns3_hw *hw) - struct hns3_pf *pf = HNS3_DEV_HW_TO_PF(hw); - struct rte_tm_error error; - -- if (!hns3_dev_tm_supported(hw)) -+ if (!hns3_dev_get_support(hw, TM)) - return 0; - - if (pf->tm_conf.root == NULL || !pf->tm_conf.committed) --- -2.23.0 - diff --git a/0228-net-hns3-fix-interrupt-vector-freeing.patch b/0228-net-hns3-fix-interrupt-vector-freeing.patch deleted file mode 100644 index bf906a5..0000000 --- a/0228-net-hns3-fix-interrupt-vector-freeing.patch +++ /dev/null @@ -1,33 +0,0 @@ -From b00fefaae559f49fbbbc39ec6ec1aaa1f4f5ba39 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Wed, 13 Oct 2021 16:09:08 +0800 -Subject: [PATCH 15/17] net/hns3: fix interrupt vector freeing - -The intr_handle->intr_vec is allocated by rte_zmalloc(), but freed by -free(), this patch fixes it. - -Fixes: 02a7b55657b2 ("net/hns3: support Rx interrupt") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Reviewed-by: Ferruh Yigit ---- - drivers/net/hns3/hns3_ethdev_vf.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index d2895b140..9dfc22d2d 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2355,7 +2355,7 @@ hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) - return 0; - - vf_bind_vector_error: -- free(intr_handle->intr_vec); -+ rte_free(intr_handle->intr_vec); - intr_handle->intr_vec = NULL; - vf_alloc_intr_vec_error: - rte_intr_efd_disable(intr_handle); --- -2.23.0 - diff --git a/0229-net-hns3-add-runtime-config-for-mailbox-limit-time.patch b/0229-net-hns3-add-runtime-config-for-mailbox-limit-time.patch deleted file mode 100644 index 2f9b1db..0000000 --- a/0229-net-hns3-add-runtime-config-for-mailbox-limit-time.patch +++ /dev/null @@ -1,179 +0,0 @@ -From 61c8349bbed069317c59da812598b74d2e076ced Mon Sep 17 00:00:00 2001 -From: Chengchang Tang -Date: Fri, 22 Oct 2021 09:38:40 +0800 -Subject: [PATCH 16/17] net/hns3: add runtime config for mailbox limit time - -Current, the max waiting time for MBX response is 500ms, but in -some scenarios, it is not enough. Since it depends on the response -of the kernel mode driver, and its response time is related to the -scheduling of the system. In this special scenario, most of the -cores are isolated, and only a few cores are used for system -scheduling. When a large number of services are started, the -scheduling of the system will be very busy, and the reply of the -mbx message will time out, which will cause our PMD initialization -to fail. - -This patch add a runtime config to set the max wait time. For the -above scenes, users can adjust the waiting time to a suitable value -by themselves. - -Fixes: 463e748964f5 ("net/hns3: support mailbox") -Cc: stable@dpdk.org - -Signed-off-by: Chengchang Tang -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 32 ++++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_ethdev.h | 3 +++ - drivers/net/hns3/hns3_ethdev_vf.c | 3 ++- - drivers/net/hns3/hns3_mbx.c | 8 +++++--- - drivers/net/hns3/hns3_mbx.h | 1 + - 5 files changed, 42 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index c5c355d95..2ae4cb9b7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -7348,9 +7348,30 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) - return 0; - } - -+static int -+hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) -+{ -+ uint32_t val; -+ -+ RTE_SET_USED(key); -+ -+ val = strtoul(value, NULL, 10); -+ -+ /* -+ * 500ms is empirical value in process of mailbox communication. If -+ * the delay value is set to one lower thanthe empirical value, mailbox -+ * communication may fail. -+ */ -+ if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) -+ *(uint16_t *)extra_args = val; -+ -+ return 0; -+} -+ - void - hns3_parse_devargs(struct rte_eth_dev *dev) - { -+ uint16_t mbx_time_limit_ms = HNS3_MBX_DEF_TIME_LIMIT_MS; - struct hns3_adapter *hns = dev->data->dev_private; - uint32_t rx_func_hint = HNS3_IO_FUNC_HINT_NONE; - uint32_t tx_func_hint = HNS3_IO_FUNC_HINT_NONE; -@@ -7371,6 +7392,9 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - &hns3_parse_io_hint_func, &tx_func_hint); - (void)rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, - &hns3_parse_dev_caps_mask, &dev_caps_mask); -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_MBX_TIME_LIMIT_MS, -+ &hns3_parse_mbx_time_limit, &mbx_time_limit_ms); -+ - rte_kvargs_free(kvlist); - - if (rx_func_hint != HNS3_IO_FUNC_HINT_NONE) -@@ -7386,6 +7410,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - hns3_warn(hw, "parsed %s = 0x%" PRIx64 ".", - HNS3_DEVARG_DEV_CAPS_MASK, dev_caps_mask); - hns->dev_caps_mask = dev_caps_mask; -+ -+ if (mbx_time_limit_ms != HNS3_MBX_DEF_TIME_LIMIT_MS) -+ hns3_warn(hw, "parsed %s = %u.", HNS3_DEVARG_MBX_TIME_LIMIT_MS, -+ mbx_time_limit_ms); -+ hns->mbx_time_limit_ms = mbx_time_limit_ms; - } - - static const struct eth_dev_ops hns3_eth_dev_ops = { -@@ -7642,6 +7671,7 @@ RTE_PMD_REGISTER_KMOD_DEP(net_hns3, "* igb_uio | vfio-pci"); - RTE_PMD_REGISTER_PARAM_STRING(net_hns3, - HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " - HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common " -- HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> "); -+ HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> " -+ HNS3_DEVARG_MBX_TIME_LIMIT_MS "= "); - RTE_LOG_REGISTER(hns3_logtype_init, pmd.net.hns3.init, NOTICE); - RTE_LOG_REGISTER(hns3_logtype_driver, pmd.net.hns3.driver, NOTICE); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 94fd14bfc..84f5a9f29 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -851,6 +851,7 @@ struct hns3_adapter { - uint32_t tx_func_hint; - - uint64_t dev_caps_mask; -+ uint16_t mbx_time_limit_ms; /* wait time for mbx message */ - - struct hns3_ptype_table ptype_tbl __rte_cache_aligned; - }; -@@ -868,6 +869,8 @@ enum { - - #define HNS3_DEVARG_DEV_CAPS_MASK "dev_caps_mask" - -+#define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms" -+ - enum { - HNS3_DEV_SUPPORT_DCB_B, - HNS3_DEV_SUPPORT_COPPER_B, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 9dfc22d2d..29313c2f7 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -3112,4 +3112,5 @@ RTE_PMD_REGISTER_KMOD_DEP(net_hns3_vf, "* igb_uio | vfio-pci"); - RTE_PMD_REGISTER_PARAM_STRING(net_hns3_vf, - HNS3_DEVARG_RX_FUNC_HINT "=vec|sve|simple|common " - HNS3_DEVARG_TX_FUNC_HINT "=vec|sve|simple|common " -- HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> "); -+ HNS3_DEVARG_DEV_CAPS_MASK "=<1-65535> " -+ HNS3_DEVARG_MBX_TIME_LIMIT_MS "= "); -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 411c5ebe9..a4d9afc45 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -61,8 +61,9 @@ static int - hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - uint8_t *resp_data, uint16_t resp_len) - { --#define HNS3_MAX_RETRY_US 500000 - #define HNS3_WAIT_RESP_US 100 -+#define US_PER_MS 1000 -+ uint32_t mbx_time_limit; - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_mbx_resp_status *mbx_resp; - uint32_t wait_time = 0; -@@ -74,7 +75,8 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - return -EINVAL; - } - -- while (wait_time < HNS3_MAX_RETRY_US) { -+ mbx_time_limit = (uint32_t)hns->mbx_time_limit_ms * US_PER_MS; -+ while (wait_time < mbx_time_limit) { - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED)) { - hns3_err(hw, "Don't wait for mbx respone because of " - "disable_cmd"); -@@ -103,7 +105,7 @@ hns3_get_mbx_resp(struct hns3_hw *hw, uint16_t code, uint16_t subcode, - wait_time += HNS3_WAIT_RESP_US; - } - hw->mbx_resp.req_msg_data = 0; -- if (wait_time >= HNS3_MAX_RETRY_US) { -+ if (wait_time >= mbx_time_limit) { - hns3_mbx_proc_timeout(hw, code, subcode); - return -ETIME; - } -diff --git a/drivers/net/hns3/hns3_mbx.h b/drivers/net/hns3/hns3_mbx.h -index f868e33a9..d637bd2b2 100644 ---- a/drivers/net/hns3/hns3_mbx.h -+++ b/drivers/net/hns3/hns3_mbx.h -@@ -87,6 +87,7 @@ enum hns3_mbx_link_fail_subcode { - - #define HNS3_MBX_MAX_MSG_SIZE 16 - #define HNS3_MBX_MAX_RESP_DATA_SIZE 8 -+#define HNS3_MBX_DEF_TIME_LIMIT_MS 500 - - enum { - HNS3_MBX_RESP_MATCHING_SCHEME_OF_ORIGINAL = 0, --- -2.23.0 - diff --git a/0230-net-hns3-fix-mailbox-communication-with-HW.patch b/0230-net-hns3-fix-mailbox-communication-with-HW.patch deleted file mode 100644 index 989fdc2..0000000 --- a/0230-net-hns3-fix-mailbox-communication-with-HW.patch +++ /dev/null @@ -1,39 +0,0 @@ -From a277f7dbaa54e8ea10f41a7dc4dadec5f08b61b3 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Thu, 28 Oct 2021 19:52:30 +0800 -Subject: [PATCH 17/17] net/hns3: fix mailbox communication with HW - -Mailbox is the communication mechanism between SW and HW. There exist -two approaches for SW to recognize mailbox message from HW. One way is -using match_id, the other is to compare the message code. The two -approaches are independent and used in different scenarios. - -But for the second approach, "next_to_use" should be updated and written -to HW register. If it not done, HW do not know the position SW steps, -then, the communication between SW and HW will turn to be failed. - -Fixes: dbbbad23e380 ("net/hns3: fix VF handling LSC event in secondary process") -Cc: stable@dpdk.org - -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_mbx.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index a4d9afc45..3ad85e721 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -435,6 +435,9 @@ hns3_handle_mbx_msg_out_intr(struct hns3_hw *hw) - scan_next: - next_to_use = (next_to_use + 1) % hw->cmq.crq.desc_num; - } -+ -+ crq->next_to_use = next_to_use; -+ hns3_write_dev(hw, HNS3_CMDQ_RX_HEAD_REG, crq->next_to_use); - } - - void --- -2.23.0 - diff --git a/0231-app-testpmd-support-multi-process.patch b/0231-app-testpmd-support-multi-process.patch deleted file mode 100644 index 3ace44b..0000000 --- a/0231-app-testpmd-support-multi-process.patch +++ /dev/null @@ -1,421 +0,0 @@ -From c7a841ce328cda8338494640b103d5182268fd1e Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Wed, 25 Aug 2021 10:06:38 +0800 -Subject: [PATCH] app/testpmd: support multi-process - -This patch adds multi-process support for testpmd. -For example the following commands run two testpmd -processes: - - * the primary process: - -./dpdk-testpmd --proc-type=auto -l 0-1 -- -i \ - --rxq=4 --txq=4 --num-procs=2 --proc-id=0 - - * the secondary process: - -./dpdk-testpmd --proc-type=auto -l 2-3 -- -i \ - --rxq=4 --txq=4 --num-procs=2 --proc-id=1 - -Signed-off-by: Min Hu (Connor) -Signed-off-by: Lijun Ou -Signed-off-by: Andrew Rybchenko -Acked-by: Xiaoyun Li -Acked-by: Ajit Khaparde -Reviewed-by: Ferruh Yigit -Acked-by: Aman Deep Singh ---- - app/test-pmd/cmdline.c | 6 ++ - app/test-pmd/config.c | 20 +++++- - app/test-pmd/parameters.c | 9 +++ - app/test-pmd/testpmd.c | 92 +++++++++++++++++++++++---- - app/test-pmd/testpmd.h | 11 ++++ - doc/guides/testpmd_app_ug/run_app.rst | 84 ++++++++++++++++++++++++ - 6 files changed, 210 insertions(+), 12 deletions(-) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index 5691fab94..b701129d8 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -5441,6 +5441,12 @@ cmd_set_flush_rx_parsed(void *parsed_result, - __rte_unused void *data) - { - struct cmd_set_flush_rx *res = parsed_result; -+ -+ if (num_procs > 1 && (strcmp(res->mode, "on") == 0)) { -+ printf("multi-process doesn't support to flush Rx queues.\n"); -+ return; -+ } -+ - no_flush_rx = (uint8_t)((strcmp(res->mode, "on") == 0) ? 0 : 1); - } - -diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c -index 7af13f65c..0d6639020 100644 ---- a/app/test-pmd/config.c -+++ b/app/test-pmd/config.c -@@ -3117,6 +3117,8 @@ rss_fwd_config_setup(void) - queueid_t rxq; - queueid_t nb_q; - streamid_t sm_id; -+ int start; -+ int end; - - nb_q = nb_rxq; - if (nb_q > nb_txq) -@@ -3134,7 +3136,21 @@ rss_fwd_config_setup(void) - init_fwd_streams(); - - setup_fwd_config_of_each_lcore(&cur_fwd_config); -- rxp = 0; rxq = 0; -+ -+ if (proc_id > 0 && nb_q % num_procs != 0) -+ printf("Warning! queue numbers should be multiple of processes, or packet loss will happen.\n"); -+ -+ /** -+ * In multi-process, All queues are allocated to different -+ * processes based on num_procs and proc_id. For example: -+ * if supports 4 queues(nb_q), 2 processes(num_procs), -+ * the 0~1 queue for primary process. -+ * the 2~3 queue for secondary process. -+ */ -+ start = proc_id * nb_q / num_procs; -+ end = start + nb_q / num_procs; -+ rxp = 0; -+ rxq = start; - for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) { - struct fwd_stream *fs; - -@@ -3151,6 +3167,8 @@ rss_fwd_config_setup(void) - continue; - rxp = 0; - rxq++; -+ if (rxq >= end) -+ rxq = start; - } - } - -diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c -index 414a0068f..c464c42f6 100644 ---- a/app/test-pmd/parameters.c -+++ b/app/test-pmd/parameters.c -@@ -487,6 +487,9 @@ parse_event_printing_config(const char *optarg, int enable) - void - launch_args_parse(int argc, char** argv) - { -+#define PARAM_PROC_ID "proc-id" -+#define PARAM_NUM_PROCS "num-procs" -+ - int n, opt; - char **argvopt; - int opt_idx; -@@ -603,6 +606,8 @@ launch_args_parse(int argc, char** argv) - { "rx-mq-mode", 1, 0, 0 }, - { "record-core-cycles", 0, 0, 0 }, - { "record-burst-stats", 0, 0, 0 }, -+ { PARAM_NUM_PROCS, 1, 0, 0 }, -+ { PARAM_PROC_ID, 1, 0, 0 }, - { 0, 0, 0, 0 }, - }; - -@@ -1359,6 +1364,10 @@ launch_args_parse(int argc, char** argv) - record_core_cycles = 1; - if (!strcmp(lgopts[opt_idx].name, "record-burst-stats")) - record_burst_stats = 1; -+ if (!strcmp(lgopts[opt_idx].name, PARAM_NUM_PROCS)) -+ num_procs = atoi(optarg); -+ if (!strcmp(lgopts[opt_idx].name, PARAM_PROC_ID)) -+ proc_id = atoi(optarg); - break; - case 'h': - usage(argv[0]); -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index 0eaa4852d..983d8827d 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -505,6 +505,61 @@ uint8_t gro_flush_cycles = GRO_DEFAULT_FLUSH_CYCLES; - * hexadecimal bitmask of RX mq mode can be enabled. - */ - enum rte_eth_rx_mq_mode rx_mq_mode = ETH_MQ_RX_VMDQ_DCB_RSS; -+/* -+ * ID of the current process in multi-process, used to -+ * configure the queues to be polled. -+ */ -+int proc_id; -+ -+/* -+ * Number of processes in multi-process, used to -+ * configure the queues to be polled. -+ */ -+unsigned int num_procs = 1; -+ -+static int -+eth_dev_configure_mp(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, -+ const struct rte_eth_conf *dev_conf) -+{ -+ if (is_proc_primary()) -+ return rte_eth_dev_configure(port_id, nb_rx_q, nb_tx_q, -+ dev_conf); -+ return 0; -+} -+ -+static int -+eth_dev_start_mp(uint16_t port_id) -+{ -+ if (is_proc_primary()) -+ return rte_eth_dev_start(port_id); -+ -+ return 0; -+} -+ -+static int -+eth_dev_stop_mp(uint16_t port_id) -+{ -+ if (is_proc_primary()) -+ return rte_eth_dev_stop(port_id); -+ -+ return 0; -+} -+ -+static void -+mempool_free_mp(struct rte_mempool *mp) -+{ -+ if (is_proc_primary()) -+ rte_mempool_free(mp); -+} -+ -+static int -+eth_dev_set_mtu_mp(uint16_t port_id, uint16_t mtu) -+{ -+ if (is_proc_primary()) -+ return rte_eth_dev_set_mtu(port_id, mtu); -+ -+ return 0; -+} - - /* Forward function declarations */ - static void setup_attached_port(portid_t pi); -@@ -964,6 +1019,14 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, - - mb_size = sizeof(struct rte_mbuf) + mbuf_seg_size; - mbuf_poolname_build(socket_id, pool_name, sizeof(pool_name), size_idx); -+ if (!is_proc_primary()) { -+ rte_mp = rte_mempool_lookup(pool_name); -+ if (rte_mp == NULL) -+ rte_exit(EXIT_FAILURE, -+ "Get mbuf pool for socket %u failed: %s\n", -+ socket_id, rte_strerror(rte_errno)); -+ return rte_mp; -+ } - - TESTPMD_LOG(INFO, - "create a new mbuf pool <%s>: n=%u, size=%u, socket=%u\n", -@@ -1969,6 +2032,11 @@ flush_fwd_rx_queues(void) - uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0; - uint64_t timer_period; - -+ if (num_procs > 1) { -+ printf("multi-process not support for flushing fwd Rx queues, skip the below lines and return.\n"); -+ return; -+ } -+ - /* convert to number of cycles */ - timer_period = rte_get_timer_hz(); /* 1 second timeout */ - -@@ -2456,7 +2524,7 @@ start_port(portid_t pid) - return -1; - } - /* configure port */ -- diag = rte_eth_dev_configure(pi, nb_rxq + nb_hairpinq, -+ diag = eth_dev_configure_mp(pi, nb_rxq + nb_hairpinq, - nb_txq + nb_hairpinq, - &(port->dev_conf)); - if (diag != 0) { -@@ -2470,7 +2538,7 @@ start_port(portid_t pid) - return -1; - } - } -- if (port->need_reconfig_queues > 0) { -+ if (port->need_reconfig_queues > 0 && is_proc_primary()) { - port->need_reconfig_queues = 0; - /* setup tx queues */ - for (qi = 0; qi < nb_txq; qi++) { -@@ -2571,7 +2639,7 @@ start_port(portid_t pid) - cnt_pi++; - - /* start port */ -- if (rte_eth_dev_start(pi) < 0) { -+ if (eth_dev_start_mp(pi) < 0) { - printf("Fail to start port %d\n", pi); - - /* Fail to setup rx queue, return */ -@@ -2700,7 +2768,7 @@ stop_port(portid_t pid) - } - } - -- if (rte_eth_dev_stop(pi) != 0) -+ if (eth_dev_stop_mp(pi) != 0) - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); - -@@ -2769,8 +2837,10 @@ close_port(portid_t pid) - continue; - } - -- port_flow_flush(pi); -- rte_eth_dev_close(pi); -+ if (is_proc_primary()) { -+ port_flow_flush(pi); -+ rte_eth_dev_close(pi); -+ } - } - - remove_invalid_ports(); -@@ -3035,7 +3105,7 @@ pmd_test_exit(void) - } - for (i = 0 ; i < RTE_DIM(mempools) ; i++) { - if (mempools[i]) -- rte_mempool_free(mempools[i]); -+ mempool_free_mp(mempools[i]); - } - - printf("\nBye...\n"); -@@ -3482,6 +3552,10 @@ init_port_dcb_config(portid_t pid, - int retval; - uint16_t i; - -+ if (num_procs > 1) { -+ printf("The multi-process feature doesn't support dcb.\n"); -+ return -ENOTSUP; -+ } - rte_port = &ports[pid]; - - /* retain the original device configuration. */ -@@ -3646,10 +3720,6 @@ main(int argc, char** argv) - rte_exit(EXIT_FAILURE, "Cannot init EAL: %s\n", - rte_strerror(rte_errno)); - -- if (rte_eal_process_type() == RTE_PROC_SECONDARY) -- rte_exit(EXIT_FAILURE, -- "Secondary process type not supported.\n"); -- - ret = register_eth_event_callback(); - if (ret != 0) - rte_exit(EXIT_FAILURE, "Cannot register for ethdev events"); -diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h -index 303bed830..122fca29c 100644 ---- a/app/test-pmd/testpmd.h -+++ b/app/test-pmd/testpmd.h -@@ -626,6 +626,17 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf; - - extern enum rte_eth_rx_mq_mode rx_mq_mode; - -+extern struct rte_flow_action_conntrack conntrack_context; -+ -+extern int proc_id; -+extern unsigned int num_procs; -+ -+static inline bool -+is_proc_primary(void) -+{ -+ return rte_eal_process_type() == RTE_PROC_PRIMARY; -+} -+ - static inline unsigned int - lcore_num(void) - { -diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst -index ca67105b7..098cbbd43 100644 ---- a/doc/guides/testpmd_app_ug/run_app.rst -+++ b/doc/guides/testpmd_app_ug/run_app.rst -@@ -529,3 +529,87 @@ The command line options are: - bit 1 - two hairpin ports paired - bit 0 - two hairpin ports loop - The default value is 0. Hairpin will use single port mode and implicit Tx flow mode. -+ -+ -+Testpmd Multi-Process Command-line Options -+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ -+The following are the command-line options for testpmd multi-process support: -+ -+* primary process: -+ -+.. code-block:: console -+ -+ sudo ./dpdk-testpmd -a xxx --proc-type=auto -l 0-1 -- -i --rxq=4 --txq=4 \ -+ --num-procs=2 --proc-id=0 -+ -+* secondary process: -+ -+.. code-block:: console -+ -+ sudo ./dpdk-testpmd -a xxx --proc-type=auto -l 2-3 -- -i --rxq=4 --txq=4 \ -+ --num-procs=2 --proc-id=1 -+ -+The command line options are: -+ -+* ``--num-procs=N`` -+ -+ The number of processes which will be used. -+ -+* ``--proc-id=ID`` -+ -+ The ID of the current process (ID < num-procs). ID should be different in -+ primary process and secondary process, which starts from '0'. -+ -+Calculation rule for queue: -+All queues are allocated to different processes based on ``proc_num`` and -+``proc_id``. -+Calculation rule for the testpmd to allocate queues to each process: -+* start(queue start id) = proc_id * nb_q / num_procs -+ -+* end(queue end id) = start + nb_q / num_procs -+ -+For example, if testpmd is configured to have 4 Tx and Rx queues, -+queues 0 and 1 will be used by the primary process and -+queues 2 and 3 will be used by the secondary process. -+ -+The number of queues should be a multiple of the number of processes. If not, -+redundant queues will exist after queues are allocated to processes. If RSS -+is enabled, packet loss occurs when traffic is sent to all processes at the same -+time. Some traffic goes to redundant queues and cannot be forwarded. -+ -+All the dev ops is supported in primary process. While secondary process is -+not permitted to allocate or release shared memory, so some ops are not supported -+as follows: -+ -+- ``dev_configure`` -+- ``dev_start`` -+- ``dev_stop`` -+- ``rx_queue_setup`` -+- ``tx_queue_setup`` -+- ``rx_queue_release`` -+- ``tx_queue_release`` -+ -+So, any command from testpmd which calls those APIs will not be supported in -+secondary process, like: -+ -+.. code-block:: console -+ -+ port config all rxq|txq|rxd|txd -+ port config rx_offload xxx on/off -+ port config tx_offload xxx on/off -+ -+etc. -+ -+When secondary is running, port in primary is not permitted to be stopped. -+Reconfigure operation is only valid in primary. -+ -+Stats is supported, stats will not change when one quits and starts, as they -+share the same buffer to store the stats. Flow rules are maintained in process -+level: primary and secondary has its own flow list (but one flow list in HW). -+The two can see all the queues, so setting the flow rules for the other is OK. -+But in the testpmd primary process receiving or transmitting packets from the -+queue allocated for secondary process is not permitted, and same for secondary -+process. -+ -+Flow API and RSS are supported. --- -2.23.0 - diff --git a/0232-app-testpmd-fix-key-for-RSS-flow-rule.patch b/0232-app-testpmd-fix-key-for-RSS-flow-rule.patch deleted file mode 100644 index 12167e3..0000000 --- a/0232-app-testpmd-fix-key-for-RSS-flow-rule.patch +++ /dev/null @@ -1,55 +0,0 @@ -From b57927702a58685e46d87960aba25a7b1fa0279e Mon Sep 17 00:00:00 2001 -From: Alvin Zhang -Date: Thu, 21 Jan 2021 17:41:54 +0800 -Subject: [PATCH] app/testpmd: fix key for RSS flow rule - -Since the patch '1848b117' has initialized the variable 'key' in -'struct rte_flow_action_rss' with 'NULL', the PMD cannot get the -RSS key now. Details as bellow: - -testpmd> flow create 0 ingress pattern eth / ipv4 / end actions - rss types ipv4-other end key - 1234567890123456789012345678901234567890FFFFFFFFFFFF123 - 4567890123456789012345678901234567890FFFFFFFFFFFF - queues end / end -Flow rule #1 created -testpmd> show port 0 rss-hash key -RSS functions: - all ipv4-other ip -RSS key: - 4439796BB54C5023B675EA5B124F9F30B8A2C03DDFDC4D02A08C9B3 - 34AF64A4C05C6FA343958D8557D99583AE138C92E81150366 - -This patch sets offset and size of the 'key' variable as the first -parameter of the token 'key'. Later, the address of the RSS key will -be copied to 'key' variable. - -Fixes: 1848b117cca1 ("app/testpmd: fix RSS key for flow API RSS rule") -Cc: stable@dpdk.org - -Signed-off-by: Alvin Zhang -Tested-by: Jun W Zhou -Reviewed-by: Ferruh Yigit ---- - app/test-pmd/cmdline_flow.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c -index 0618611ab1..067e120743 100644 ---- a/app/test-pmd/cmdline_flow.c -+++ b/app/test-pmd/cmdline_flow.c -@@ -3541,7 +3541,10 @@ static const struct token token_list[] = { - .name = "key", - .help = "RSS hash key", - .next = NEXT(action_rss, NEXT_ENTRY(HEX)), -- .args = ARGS(ARGS_ENTRY_ARB(0, 0), -+ .args = ARGS(ARGS_ENTRY_ARB -+ (offsetof(struct action_rss_data, conf) + -+ offsetof(struct rte_flow_action_rss, key), -+ sizeof(((struct rte_flow_action_rss *)0)->key)), - ARGS_ENTRY_ARB - (offsetof(struct action_rss_data, conf) + - offsetof(struct rte_flow_action_rss, key_len), --- -2.33.0 - diff --git a/0233-app-testpmd-release-flows-left-before-port-stop.patch b/0233-app-testpmd-release-flows-left-before-port-stop.patch deleted file mode 100644 index 5695155..0000000 --- a/0233-app-testpmd-release-flows-left-before-port-stop.patch +++ /dev/null @@ -1,40 +0,0 @@ -From b71d309637e90a67f7814604f3a17b696b6304ce Mon Sep 17 00:00:00 2001 -From: Gregory Etelson -Date: Thu, 26 Nov 2020 18:43:02 +0200 -Subject: [PATCH] app/testpmd: release flows left before port stop - -According to RTE flow user guide, PMD will not keep flow rules after -port stop. Application resources that refer to flow rules become -obsolete after port stop and must not be used. -Testpmd maintains linked list of active flows for each port. Entries in -that list are allocated dynamically and must be explicitly released to -prevent memory leak. -The patch releases testpmd port flow_list that holds remaining flows -before port is stopped. - -Cc: stable@dpdk.org - -Signed-off-by: Gregory Etelson -Acked-by: Ori Kam -Acked-by: Ajit Khaparde ---- - app/test-pmd/testpmd.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index 60636830b..7bede14ce 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -2768,6 +2768,9 @@ stop_port(portid_t pid) - } - } - -+ if (port->flow_list) -+ port_flow_flush(pi); -+ - if (eth_dev_stop_mp(pi) != 0) - RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", - pi); --- -2.33.0 - diff --git a/0234-app-testpmd-delete-unused-function.patch b/0234-app-testpmd-delete-unused-function.patch deleted file mode 100644 index 48506c2..0000000 --- a/0234-app-testpmd-delete-unused-function.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 888d05e90f1dd78cd5075048206e573b0e30e40c Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Wed, 10 Nov 2021 16:50:56 +0800 -Subject: [PATCH 01/33] app/testpmd: delete unused function - -Signed-off-by: Min Hu (Connor) ---- - app/test-pmd/testpmd.c | 9 --------- - 1 file changed, 9 deletions(-) - -diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c -index 50a2a5a94..e3b5a165d 100644 ---- a/app/test-pmd/testpmd.c -+++ b/app/test-pmd/testpmd.c -@@ -552,15 +552,6 @@ mempool_free_mp(struct rte_mempool *mp) - rte_mempool_free(mp); - } - --static int --eth_dev_set_mtu_mp(uint16_t port_id, uint16_t mtu) --{ -- if (is_proc_primary()) -- return rte_eth_dev_set_mtu(port_id, mtu); -- -- return 0; --} -- - /* Forward function declarations */ - static void setup_attached_port(portid_t pi); - static void check_all_ports_link_status(uint32_t port_mask); --- -2.33.0 - diff --git a/0235-dmadev-introduce-DMA-device-support.patch b/0235-dmadev-introduce-DMA-device-support.patch deleted file mode 100644 index 227498c..0000000 --- a/0235-dmadev-introduce-DMA-device-support.patch +++ /dev/null @@ -1,7487 +0,0 @@ -From 8f6d527cd1ab3c7f5e6490425795b46cb5ebc42a Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Fri, 12 Nov 2021 09:36:45 +0800 -Subject: [PATCH] dmadev: introduce DMA device support - -Signed-off-by: Min Hu (Connor) ---- - app/test/meson.build | 4 + - app/test/test_dmadev.c | 867 ++++++++++++++++++ - app/test/test_dmadev_api.c | 574 ++++++++++++ - app/test/test_dmadev_api.h | 5 + - doc/api/doxy-api-index.md | 1 + - doc/api/doxy-api.conf.in | 1 + - doc/guides/dmadevs/index.rst | 12 + - doc/guides/index.rst | 1 + - doc/guides/prog_guide/dmadev.rst | 90 ++ - doc/guides/prog_guide/img/dmadev.svg | 283 ++++++ - doc/guides/prog_guide/index.rst | 1 + - drivers/dma/hisilicon/hisi_dmadev.c | 925 +++++++++++++++++++ - drivers/dma/hisilicon/hisi_dmadev.h | 236 +++++ - drivers/dma/hisilicon/meson.build | 19 + - drivers/dma/hisilicon/version.map | 3 + - drivers/dma/meson.build | 13 + - drivers/dma/skeleton/meson.build | 11 + - drivers/dma/skeleton/skeleton_dmadev.c | 596 +++++++++++++ - drivers/dma/skeleton/skeleton_dmadev.h | 61 ++ - drivers/dma/skeleton/version.map | 3 + - drivers/meson.build | 1 + - examples/dma/Makefile | 51 ++ - examples/dma/dmafwd.c | 1105 +++++++++++++++++++++++ - examples/dma/meson.build | 15 + - examples/meson.build | 2 +- - lib/librte_dmadev/meson.build | 5 + - lib/librte_dmadev/rte_dmadev.c | 866 ++++++++++++++++++ - lib/librte_dmadev/rte_dmadev.h | 1138 ++++++++++++++++++++++++ - lib/librte_dmadev/rte_dmadev_core.h | 80 ++ - lib/librte_dmadev/rte_dmadev_pmd.h | 171 ++++ - lib/librte_dmadev/version.map | 31 + - lib/meson.build | 2 +- - 32 files changed, 7171 insertions(+), 2 deletions(-) - create mode 100644 app/test/test_dmadev.c - create mode 100644 app/test/test_dmadev_api.c - create mode 100644 app/test/test_dmadev_api.h - create mode 100644 doc/guides/dmadevs/index.rst - create mode 100644 doc/guides/prog_guide/dmadev.rst - create mode 100644 doc/guides/prog_guide/img/dmadev.svg - create mode 100644 drivers/dma/hisilicon/hisi_dmadev.c - create mode 100644 drivers/dma/hisilicon/hisi_dmadev.h - create mode 100644 drivers/dma/hisilicon/meson.build - create mode 100644 drivers/dma/hisilicon/version.map - create mode 100644 drivers/dma/meson.build - create mode 100644 drivers/dma/skeleton/meson.build - create mode 100644 drivers/dma/skeleton/skeleton_dmadev.c - create mode 100644 drivers/dma/skeleton/skeleton_dmadev.h - create mode 100644 drivers/dma/skeleton/version.map - create mode 100644 examples/dma/Makefile - create mode 100644 examples/dma/dmafwd.c - create mode 100644 examples/dma/meson.build - create mode 100644 lib/librte_dmadev/meson.build - create mode 100644 lib/librte_dmadev/rte_dmadev.c - create mode 100644 lib/librte_dmadev/rte_dmadev.h - create mode 100644 lib/librte_dmadev/rte_dmadev_core.h - create mode 100644 lib/librte_dmadev/rte_dmadev_pmd.h - create mode 100644 lib/librte_dmadev/version.map - -diff --git a/app/test/meson.build b/app/test/meson.build -index 94fd39fec..88bed64ad 100644 ---- a/app/test/meson.build -+++ b/app/test/meson.build -@@ -34,6 +34,8 @@ test_sources = files('commands.c', - 'test_debug.c', - 'test_distributor.c', - 'test_distributor_perf.c', -+ 'test_dmadev.c', -+ 'test_dmadev_api.c', - 'test_eal_flags.c', - 'test_eal_fs.c', - 'test_efd.c', -@@ -151,6 +153,7 @@ test_deps = ['acl', - 'cmdline', - 'cryptodev', - 'distributor', -+ 'dmadev', - 'efd', - 'ethdev', - 'eventdev', -@@ -320,6 +323,7 @@ driver_test_names = [ - 'cryptodev_sw_mvsam_autotest', - 'cryptodev_sw_snow3g_autotest', - 'cryptodev_sw_zuc_autotest', -+ 'dmadev_autotest', - 'eventdev_selftest_octeontx', - 'eventdev_selftest_sw', - 'rawdev_autotest', -diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c -new file mode 100644 -index 000000000..b206db27a ---- /dev/null -+++ b/app/test/test_dmadev.c -@@ -0,0 +1,867 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ * Copyright(c) 2021 Intel Corporation -+ */ -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "test.h" -+#include "test_dmadev_api.h" -+ -+#define ERR_RETURN(...) do { print_err(__func__, __LINE__, __VA_ARGS__); return -1; } while (0) -+ -+#define COPY_LEN 1024 -+ -+static struct rte_mempool *pool; -+static uint16_t id_count; -+ -+static void -+__rte_format_printf(3, 4) -+print_err(const char *func, int lineno, const char *format, ...) -+{ -+ va_list ap; -+ -+ fprintf(stderr, "In %s:%d - ", func, lineno); -+ va_start(ap, format); -+ vfprintf(stderr, format, ap); -+ va_end(ap); -+} -+ -+static int -+runtest(const char *printable, int (*test_fn)(int16_t dev_id, uint16_t vchan), int iterations, -+ int16_t dev_id, uint16_t vchan, bool check_err_stats) -+{ -+ struct rte_dma_stats stats; -+ int i; -+ -+ rte_dma_stats_reset(dev_id, vchan); -+ printf("DMA Dev %d: Running %s Tests %s\n", dev_id, printable, -+ check_err_stats ? " " : "(errors expected)"); -+ for (i = 0; i < iterations; i++) { -+ if (test_fn(dev_id, vchan) < 0) -+ return -1; -+ -+ rte_dma_stats_get(dev_id, 0, &stats); -+ printf("Ops submitted: %"PRIu64"\t", stats.submitted); -+ printf("Ops completed: %"PRIu64"\t", stats.completed); -+ printf("Errors: %"PRIu64"\r", stats.errors); -+ -+ if (stats.completed != stats.submitted) -+ ERR_RETURN("\nError, not all submitted jobs are reported as completed\n"); -+ if (check_err_stats && stats.errors != 0) -+ ERR_RETURN("\nErrors reported during op processing, aborting tests\n"); -+ } -+ printf("\n"); -+ return 0; -+} -+ -+static void -+await_hw(int16_t dev_id, uint16_t vchan) -+{ -+ enum rte_dma_vchan_status st; -+ -+ if (rte_dma_vchan_status(dev_id, vchan, &st) < 0) { -+ /* for drivers that don't support this op, just sleep for 1 millisecond */ -+ rte_delay_us_sleep(1000); -+ return; -+ } -+ -+ /* for those that do, *max* end time is one second from now, but all should be faster */ -+ const uint64_t end_cycles = rte_get_timer_cycles() + rte_get_timer_hz(); -+ while (st == RTE_DMA_VCHAN_ACTIVE && rte_get_timer_cycles() < end_cycles) { -+ rte_pause(); -+ rte_dma_vchan_status(dev_id, vchan, &st); -+ } -+} -+ -+/* run a series of copy tests just using some different options for enqueues and completions */ -+static int -+do_multi_copies(int16_t dev_id, uint16_t vchan, -+ int split_batches, /* submit 2 x 16 or 1 x 32 burst */ -+ int split_completions, /* gather 2 x 16 or 1 x 32 completions */ -+ int use_completed_status) /* use completed or completed_status function */ -+{ -+ struct rte_mbuf *srcs[32], *dsts[32]; -+ enum rte_dma_status_code sc[32]; -+ unsigned int i, j; -+ bool dma_err = false; -+ -+ /* Enqueue burst of copies and hit doorbell */ -+ for (i = 0; i < RTE_DIM(srcs); i++) { -+ uint64_t *src_data; -+ -+ if (split_batches && i == RTE_DIM(srcs) / 2) -+ rte_dma_submit(dev_id, vchan); -+ -+ srcs[i] = rte_pktmbuf_alloc(pool); -+ dsts[i] = rte_pktmbuf_alloc(pool); -+ if (srcs[i] == NULL || dsts[i] == NULL) -+ ERR_RETURN("Error allocating buffers\n"); -+ -+ src_data = rte_pktmbuf_mtod(srcs[i], uint64_t *); -+ for (j = 0; j < COPY_LEN/sizeof(uint64_t); j++) -+ src_data[j] = rte_rand(); -+ -+ if (rte_dma_copy(dev_id, vchan, srcs[i]->buf_iova + srcs[i]->data_off, -+ dsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) != id_count++) -+ ERR_RETURN("Error with rte_dma_copy for buffer %u\n", i); -+ } -+ rte_dma_submit(dev_id, vchan); -+ -+ await_hw(dev_id, vchan); -+ -+ if (split_completions) { -+ /* gather completions in two halves */ -+ uint16_t half_len = RTE_DIM(srcs) / 2; -+ int ret = rte_dma_completed(dev_id, vchan, half_len, NULL, &dma_err); -+ if (ret != half_len || dma_err) -+ ERR_RETURN("Error with rte_dma_completed - first half. ret = %d, expected ret = %u, dma_err = %d\n", -+ ret, half_len, dma_err); -+ -+ ret = rte_dma_completed(dev_id, vchan, half_len, NULL, &dma_err); -+ if (ret != half_len || dma_err) -+ ERR_RETURN("Error with rte_dma_completed - second half. ret = %d, expected ret = %u, dma_err = %d\n", -+ ret, half_len, dma_err); -+ } else { -+ /* gather all completions in one go, using either -+ * completed or completed_status fns -+ */ -+ if (!use_completed_status) { -+ int n = rte_dma_completed(dev_id, vchan, RTE_DIM(srcs), NULL, &dma_err); -+ if (n != RTE_DIM(srcs) || dma_err) -+ ERR_RETURN("Error with rte_dma_completed, %u [expected: %zu], dma_err = %d\n", -+ n, RTE_DIM(srcs), dma_err); -+ } else { -+ int n = rte_dma_completed_status(dev_id, vchan, RTE_DIM(srcs), NULL, sc); -+ if (n != RTE_DIM(srcs)) -+ ERR_RETURN("Error with rte_dma_completed_status, %u [expected: %zu]\n", -+ n, RTE_DIM(srcs)); -+ -+ for (j = 0; j < (uint16_t)n; j++) -+ if (sc[j] != RTE_DMA_STATUS_SUCCESSFUL) -+ ERR_RETURN("Error with rte_dma_completed_status, job %u reports failure [code %u]\n", -+ j, sc[j]); -+ } -+ } -+ -+ /* check for empty */ -+ int ret = use_completed_status ? -+ rte_dma_completed_status(dev_id, vchan, RTE_DIM(srcs), NULL, sc) : -+ rte_dma_completed(dev_id, vchan, RTE_DIM(srcs), NULL, &dma_err); -+ if (ret != 0) -+ ERR_RETURN("Error with completion check - ops unexpectedly returned\n"); -+ -+ for (i = 0; i < RTE_DIM(srcs); i++) { -+ char *src_data, *dst_data; -+ -+ src_data = rte_pktmbuf_mtod(srcs[i], char *); -+ dst_data = rte_pktmbuf_mtod(dsts[i], char *); -+ for (j = 0; j < COPY_LEN; j++) -+ if (src_data[j] != dst_data[j]) -+ ERR_RETURN("Error with copy of packet %u, byte %u\n", i, j); -+ -+ rte_pktmbuf_free(srcs[i]); -+ rte_pktmbuf_free(dsts[i]); -+ } -+ return 0; -+} -+ -+static int -+test_enqueue_copies(int16_t dev_id, uint16_t vchan) -+{ -+ unsigned int i; -+ uint16_t id; -+ -+ /* test doing a single copy */ -+ do { -+ struct rte_mbuf *src, *dst; -+ char *src_data, *dst_data; -+ -+ src = rte_pktmbuf_alloc(pool); -+ dst = rte_pktmbuf_alloc(pool); -+ src_data = rte_pktmbuf_mtod(src, char *); -+ dst_data = rte_pktmbuf_mtod(dst, char *); -+ -+ for (i = 0; i < COPY_LEN; i++) -+ src_data[i] = rte_rand() & 0xFF; -+ -+ id = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), rte_pktmbuf_iova(dst), -+ COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); -+ if (id != id_count) -+ ERR_RETURN("Error with rte_dma_copy, got %u, expected %u\n", -+ id, id_count); -+ -+ /* give time for copy to finish, then check it was done */ -+ await_hw(dev_id, vchan); -+ -+ for (i = 0; i < COPY_LEN; i++) -+ if (dst_data[i] != src_data[i]) -+ ERR_RETURN("Data mismatch at char %u [Got %02x not %02x]\n", i, -+ dst_data[i], src_data[i]); -+ -+ /* now check completion works */ -+ if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1) -+ ERR_RETURN("Error with rte_dma_completed\n"); -+ -+ if (id != id_count) -+ ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", -+ id, id_count); -+ -+ rte_pktmbuf_free(src); -+ rte_pktmbuf_free(dst); -+ -+ /* now check completion returns nothing more */ -+ if (rte_dma_completed(dev_id, 0, 1, NULL, NULL) != 0) -+ ERR_RETURN("Error with rte_dma_completed in empty check\n"); -+ -+ id_count++; -+ -+ } while (0); -+ -+ /* test doing a multiple single copies */ -+ do { -+ const uint16_t max_ops = 4; -+ struct rte_mbuf *src, *dst; -+ char *src_data, *dst_data; -+ uint16_t count; -+ -+ src = rte_pktmbuf_alloc(pool); -+ dst = rte_pktmbuf_alloc(pool); -+ src_data = rte_pktmbuf_mtod(src, char *); -+ dst_data = rte_pktmbuf_mtod(dst, char *); -+ -+ for (i = 0; i < COPY_LEN; i++) -+ src_data[i] = rte_rand() & 0xFF; -+ -+ /* perform the same copy times */ -+ for (i = 0; i < max_ops; i++) -+ if (rte_dma_copy(dev_id, vchan, -+ rte_pktmbuf_iova(src), -+ rte_pktmbuf_iova(dst), -+ COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT) != id_count++) -+ ERR_RETURN("Error with rte_dma_copy\n"); -+ -+ await_hw(dev_id, vchan); -+ -+ count = rte_dma_completed(dev_id, vchan, max_ops * 2, &id, NULL); -+ if (count != max_ops) -+ ERR_RETURN("Error with rte_dma_completed, got %u not %u\n", -+ count, max_ops); -+ -+ if (id != id_count - 1) -+ ERR_RETURN("Error, incorrect job id returned: got %u not %u\n", -+ id, id_count - 1); -+ -+ for (i = 0; i < COPY_LEN; i++) -+ if (dst_data[i] != src_data[i]) -+ ERR_RETURN("Data mismatch at char %u\n", i); -+ -+ rte_pktmbuf_free(src); -+ rte_pktmbuf_free(dst); -+ } while (0); -+ -+ /* test doing multiple copies */ -+ return do_multi_copies(dev_id, vchan, 0, 0, 0) /* enqueue and complete 1 batch at a time */ -+ /* enqueue 2 batches and then complete both */ -+ || do_multi_copies(dev_id, vchan, 1, 0, 0) -+ /* enqueue 1 batch, then complete in two halves */ -+ || do_multi_copies(dev_id, vchan, 0, 1, 0) -+ /* test using completed_status in place of regular completed API */ -+ || do_multi_copies(dev_id, vchan, 0, 0, 1); -+} -+ -+/* Failure handling test cases - global macros and variables for those tests*/ -+#define COMP_BURST_SZ 16 -+#define OPT_FENCE(idx) ((fence && idx == 8) ? RTE_DMA_OP_FLAG_FENCE : 0) -+ -+static int -+test_failure_in_full_burst(int16_t dev_id, uint16_t vchan, bool fence, -+ struct rte_mbuf **srcs, struct rte_mbuf **dsts, unsigned int fail_idx) -+{ -+ /* Test single full batch statuses with failures */ -+ enum rte_dma_status_code status[COMP_BURST_SZ]; -+ struct rte_dma_stats baseline, stats; -+ uint16_t invalid_addr_id = 0; -+ uint16_t idx; -+ uint16_t count, status_count; -+ unsigned int i; -+ bool error = false; -+ int err_count = 0; -+ -+ rte_dma_stats_get(dev_id, vchan, &baseline); /* get a baseline set of stats */ -+ for (i = 0; i < COMP_BURST_SZ; i++) { -+ int id = rte_dma_copy(dev_id, vchan, -+ (i == fail_idx ? 0 : (srcs[i]->buf_iova + srcs[i]->data_off)), -+ dsts[i]->buf_iova + dsts[i]->data_off, -+ COPY_LEN, OPT_FENCE(i)); -+ if (id < 0) -+ ERR_RETURN("Error with rte_dma_copy for buffer %u\n", i); -+ if (i == fail_idx) -+ invalid_addr_id = id; -+ } -+ rte_dma_submit(dev_id, vchan); -+ rte_dma_stats_get(dev_id, vchan, &stats); -+ if (stats.submitted != baseline.submitted + COMP_BURST_SZ) -+ ERR_RETURN("Submitted stats value not as expected, %"PRIu64" not %"PRIu64"\n", -+ stats.submitted, baseline.submitted + COMP_BURST_SZ); -+ -+ await_hw(dev_id, vchan); -+ -+ count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); -+ if (count != fail_idx) -+ ERR_RETURN("Error with rte_dma_completed for failure test. Got returned %u not %u.\n", -+ count, fail_idx); -+ if (!error) -+ ERR_RETURN("Error, missing expected failed copy, %u. has_error is not set\n", -+ fail_idx); -+ if (idx != invalid_addr_id - 1) -+ ERR_RETURN("Error, missing expected failed copy, %u. Got last idx %u, not %u\n", -+ fail_idx, idx, invalid_addr_id - 1); -+ -+ /* all checks ok, now verify calling completed() again always returns 0 */ -+ for (i = 0; i < 10; i++) -+ if (rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error) != 0 -+ || error == false || idx != (invalid_addr_id - 1)) -+ ERR_RETURN("Error with follow-up completed calls for fail idx %u\n", -+ fail_idx); -+ -+ status_count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, -+ &idx, status); -+ /* some HW may stop on error and be restarted after getting error status for single value -+ * To handle this case, if we get just one error back, wait for more completions and get -+ * status for rest of the burst -+ */ -+ if (status_count == 1) { -+ await_hw(dev_id, vchan); -+ status_count += rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ - 1, -+ &idx, &status[1]); -+ } -+ /* check that at this point we have all status values */ -+ if (status_count != COMP_BURST_SZ - count) -+ ERR_RETURN("Error with completed_status calls for fail idx %u. Got %u not %u\n", -+ fail_idx, status_count, COMP_BURST_SZ - count); -+ /* now verify just one failure followed by multiple successful or skipped entries */ -+ if (status[0] == RTE_DMA_STATUS_SUCCESSFUL) -+ ERR_RETURN("Error with status returned for fail idx %u. First status was not failure\n", -+ fail_idx); -+ for (i = 1; i < status_count; i++) -+ /* after a failure in a burst, depending on ordering/fencing, -+ * operations may be successful or skipped because of previous error. -+ */ -+ if (status[i] != RTE_DMA_STATUS_SUCCESSFUL -+ && status[i] != RTE_DMA_STATUS_NOT_ATTEMPTED) -+ ERR_RETURN("Error with status calls for fail idx %u. Status for job %u (of %u) is not successful\n", -+ fail_idx, count + i, COMP_BURST_SZ); -+ -+ /* check the completed + errors stats are as expected */ -+ rte_dma_stats_get(dev_id, vchan, &stats); -+ if (stats.completed != baseline.completed + COMP_BURST_SZ) -+ ERR_RETURN("Completed stats value not as expected, %"PRIu64" not %"PRIu64"\n", -+ stats.completed, baseline.completed + COMP_BURST_SZ); -+ for (i = 0; i < status_count; i++) -+ err_count += (status[i] != RTE_DMA_STATUS_SUCCESSFUL); -+ if (stats.errors != baseline.errors + err_count) -+ ERR_RETURN("'Errors' stats value not as expected, %"PRIu64" not %"PRIu64"\n", -+ stats.errors, baseline.errors + err_count); -+ -+ return 0; -+} -+ -+static int -+test_individual_status_query_with_failure(int16_t dev_id, uint16_t vchan, bool fence, -+ struct rte_mbuf **srcs, struct rte_mbuf **dsts, unsigned int fail_idx) -+{ -+ /* Test gathering batch statuses one at a time */ -+ enum rte_dma_status_code status[COMP_BURST_SZ]; -+ uint16_t invalid_addr_id = 0; -+ uint16_t idx; -+ uint16_t count = 0, status_count = 0; -+ unsigned int j; -+ bool error = false; -+ -+ for (j = 0; j < COMP_BURST_SZ; j++) { -+ int id = rte_dma_copy(dev_id, vchan, -+ (j == fail_idx ? 0 : (srcs[j]->buf_iova + srcs[j]->data_off)), -+ dsts[j]->buf_iova + dsts[j]->data_off, -+ COPY_LEN, OPT_FENCE(j)); -+ if (id < 0) -+ ERR_RETURN("Error with rte_dma_copy for buffer %u\n", j); -+ if (j == fail_idx) -+ invalid_addr_id = id; -+ } -+ rte_dma_submit(dev_id, vchan); -+ await_hw(dev_id, vchan); -+ -+ /* use regular "completed" until we hit error */ -+ while (!error) { -+ uint16_t n = rte_dma_completed(dev_id, vchan, 1, &idx, &error); -+ count += n; -+ if (n > 1 || count >= COMP_BURST_SZ) -+ ERR_RETURN("Error - too many completions got\n"); -+ if (n == 0 && !error) -+ ERR_RETURN("Error, unexpectedly got zero completions after %u completed\n", -+ count); -+ } -+ if (idx != invalid_addr_id - 1) -+ ERR_RETURN("Error, last successful index not as expected, got %u, expected %u\n", -+ idx, invalid_addr_id - 1); -+ -+ /* use completed_status until we hit end of burst */ -+ while (count + status_count < COMP_BURST_SZ) { -+ uint16_t n = rte_dma_completed_status(dev_id, vchan, 1, &idx, -+ &status[status_count]); -+ await_hw(dev_id, vchan); /* allow delay to ensure jobs are completed */ -+ status_count += n; -+ if (n != 1) -+ ERR_RETURN("Error: unexpected number of completions received, %u, not 1\n", -+ n); -+ } -+ -+ /* check for single failure */ -+ if (status[0] == RTE_DMA_STATUS_SUCCESSFUL) -+ ERR_RETURN("Error, unexpected successful DMA transaction\n"); -+ for (j = 1; j < status_count; j++) -+ if (status[j] != RTE_DMA_STATUS_SUCCESSFUL -+ && status[j] != RTE_DMA_STATUS_NOT_ATTEMPTED) -+ ERR_RETURN("Error, unexpected DMA error reported\n"); -+ -+ return 0; -+} -+ -+static int -+test_single_item_status_query_with_failure(int16_t dev_id, uint16_t vchan, -+ struct rte_mbuf **srcs, struct rte_mbuf **dsts, unsigned int fail_idx) -+{ -+ /* When error occurs just collect a single error using "completed_status()" -+ * before going to back to completed() calls -+ */ -+ enum rte_dma_status_code status; -+ uint16_t invalid_addr_id = 0; -+ uint16_t idx; -+ uint16_t count, status_count, count2; -+ unsigned int j; -+ bool error = false; -+ -+ for (j = 0; j < COMP_BURST_SZ; j++) { -+ int id = rte_dma_copy(dev_id, vchan, -+ (j == fail_idx ? 0 : (srcs[j]->buf_iova + srcs[j]->data_off)), -+ dsts[j]->buf_iova + dsts[j]->data_off, -+ COPY_LEN, 0); -+ if (id < 0) -+ ERR_RETURN("Error with rte_dma_copy for buffer %u\n", j); -+ if (j == fail_idx) -+ invalid_addr_id = id; -+ } -+ rte_dma_submit(dev_id, vchan); -+ await_hw(dev_id, vchan); -+ -+ /* get up to the error point */ -+ count = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); -+ if (count != fail_idx) -+ ERR_RETURN("Error with rte_dma_completed for failure test. Got returned %u not %u.\n", -+ count, fail_idx); -+ if (!error) -+ ERR_RETURN("Error, missing expected failed copy, %u. has_error is not set\n", -+ fail_idx); -+ if (idx != invalid_addr_id - 1) -+ ERR_RETURN("Error, missing expected failed copy, %u. Got last idx %u, not %u\n", -+ fail_idx, idx, invalid_addr_id - 1); -+ -+ /* get the error code */ -+ status_count = rte_dma_completed_status(dev_id, vchan, 1, &idx, &status); -+ if (status_count != 1) -+ ERR_RETURN("Error with completed_status calls for fail idx %u. Got %u not %u\n", -+ fail_idx, status_count, COMP_BURST_SZ - count); -+ if (status == RTE_DMA_STATUS_SUCCESSFUL) -+ ERR_RETURN("Error with status returned for fail idx %u. First status was not failure\n", -+ fail_idx); -+ -+ /* delay in case time needed after err handled to complete other jobs */ -+ await_hw(dev_id, vchan); -+ -+ /* get the rest of the completions without status */ -+ count2 = rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, &idx, &error); -+ if (error == true) -+ ERR_RETURN("Error, got further errors post completed_status() call, for failure case %u.\n", -+ fail_idx); -+ if (count + status_count + count2 != COMP_BURST_SZ) -+ ERR_RETURN("Error, incorrect number of completions received, got %u not %u\n", -+ count + status_count + count2, COMP_BURST_SZ); -+ -+ return 0; -+} -+ -+static int -+test_multi_failure(int16_t dev_id, uint16_t vchan, struct rte_mbuf **srcs, struct rte_mbuf **dsts, -+ const unsigned int *fail, size_t num_fail) -+{ -+ /* test having multiple errors in one go */ -+ enum rte_dma_status_code status[COMP_BURST_SZ]; -+ unsigned int i, j; -+ uint16_t count, err_count = 0; -+ bool error = false; -+ -+ /* enqueue and gather completions in one go */ -+ for (j = 0; j < COMP_BURST_SZ; j++) { -+ uintptr_t src = srcs[j]->buf_iova + srcs[j]->data_off; -+ /* set up for failure if the current index is anywhere is the fails array */ -+ for (i = 0; i < num_fail; i++) -+ if (j == fail[i]) -+ src = 0; -+ -+ int id = rte_dma_copy(dev_id, vchan, -+ src, dsts[j]->buf_iova + dsts[j]->data_off, -+ COPY_LEN, 0); -+ if (id < 0) -+ ERR_RETURN("Error with rte_dma_copy for buffer %u\n", j); -+ } -+ rte_dma_submit(dev_id, vchan); -+ await_hw(dev_id, vchan); -+ -+ count = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ, NULL, status); -+ while (count < COMP_BURST_SZ) { -+ await_hw(dev_id, vchan); -+ -+ uint16_t ret = rte_dma_completed_status(dev_id, vchan, COMP_BURST_SZ - count, -+ NULL, &status[count]); -+ if (ret == 0) -+ ERR_RETURN("Error getting all completions for jobs. Got %u of %u\n", -+ count, COMP_BURST_SZ); -+ count += ret; -+ } -+ for (i = 0; i < count; i++) -+ if (status[i] != RTE_DMA_STATUS_SUCCESSFUL) -+ err_count++; -+ -+ if (err_count != num_fail) -+ ERR_RETURN("Error: Invalid number of failed completions returned, %u; expected %zu\n", -+ err_count, num_fail); -+ -+ /* enqueue and gather completions in bursts, but getting errors one at a time */ -+ for (j = 0; j < COMP_BURST_SZ; j++) { -+ uintptr_t src = srcs[j]->buf_iova + srcs[j]->data_off; -+ /* set up for failure if the current index is anywhere is the fails array */ -+ for (i = 0; i < num_fail; i++) -+ if (j == fail[i]) -+ src = 0; -+ -+ int id = rte_dma_copy(dev_id, vchan, -+ src, dsts[j]->buf_iova + dsts[j]->data_off, -+ COPY_LEN, 0); -+ if (id < 0) -+ ERR_RETURN("Error with rte_dma_copy for buffer %u\n", j); -+ } -+ rte_dma_submit(dev_id, vchan); -+ await_hw(dev_id, vchan); -+ -+ count = 0; -+ err_count = 0; -+ while (count + err_count < COMP_BURST_SZ) { -+ count += rte_dma_completed(dev_id, vchan, COMP_BURST_SZ, NULL, &error); -+ if (error) { -+ uint16_t ret = rte_dma_completed_status(dev_id, vchan, 1, -+ NULL, status); -+ if (ret != 1) -+ ERR_RETURN("Error getting error-status for completions\n"); -+ err_count += ret; -+ await_hw(dev_id, vchan); -+ } -+ } -+ if (err_count != num_fail) -+ ERR_RETURN("Error: Incorrect number of failed completions received, got %u not %zu\n", -+ err_count, num_fail); -+ -+ return 0; -+} -+ -+static int -+test_completion_status(int16_t dev_id, uint16_t vchan, bool fence) -+{ -+ const unsigned int fail[] = {0, 7, 14, 15}; -+ struct rte_mbuf *srcs[COMP_BURST_SZ], *dsts[COMP_BURST_SZ]; -+ unsigned int i; -+ -+ for (i = 0; i < COMP_BURST_SZ; i++) { -+ srcs[i] = rte_pktmbuf_alloc(pool); -+ dsts[i] = rte_pktmbuf_alloc(pool); -+ } -+ -+ for (i = 0; i < RTE_DIM(fail); i++) { -+ if (test_failure_in_full_burst(dev_id, vchan, fence, srcs, dsts, fail[i]) < 0) -+ return -1; -+ -+ if (test_individual_status_query_with_failure(dev_id, vchan, fence, -+ srcs, dsts, fail[i]) < 0) -+ return -1; -+ -+ /* test is run the same fenced, or unfenced, but no harm in running it twice */ -+ if (test_single_item_status_query_with_failure(dev_id, vchan, -+ srcs, dsts, fail[i]) < 0) -+ return -1; -+ } -+ -+ if (test_multi_failure(dev_id, vchan, srcs, dsts, fail, RTE_DIM(fail)) < 0) -+ return -1; -+ -+ for (i = 0; i < COMP_BURST_SZ; i++) { -+ rte_pktmbuf_free(srcs[i]); -+ rte_pktmbuf_free(dsts[i]); -+ } -+ return 0; -+} -+ -+static int -+test_completion_handling(int16_t dev_id, uint16_t vchan) -+{ -+ return test_completion_status(dev_id, vchan, false) /* without fences */ -+ || test_completion_status(dev_id, vchan, true); /* with fences */ -+} -+ -+static int -+test_enqueue_fill(int16_t dev_id, uint16_t vchan) -+{ -+ const unsigned int lengths[] = {8, 64, 1024, 50, 100, 89}; -+ struct rte_mbuf *dst; -+ char *dst_data; -+ uint64_t pattern = 0xfedcba9876543210; -+ unsigned int i, j; -+ -+ dst = rte_pktmbuf_alloc(pool); -+ if (dst == NULL) -+ ERR_RETURN("Failed to allocate mbuf\n"); -+ dst_data = rte_pktmbuf_mtod(dst, char *); -+ -+ for (i = 0; i < RTE_DIM(lengths); i++) { -+ /* reset dst_data */ -+ memset(dst_data, 0, rte_pktmbuf_data_len(dst)); -+ -+ /* perform the fill operation */ -+ int id = rte_dma_fill(dev_id, vchan, pattern, -+ rte_pktmbuf_iova(dst), lengths[i], RTE_DMA_OP_FLAG_SUBMIT); -+ if (id < 0) -+ ERR_RETURN("Error with rte_dma_fill\n"); -+ await_hw(dev_id, vchan); -+ -+ if (rte_dma_completed(dev_id, vchan, 1, NULL, NULL) != 1) -+ ERR_RETURN("Error: fill operation failed (length: %u)\n", lengths[i]); -+ /* check the data from the fill operation is correct */ -+ for (j = 0; j < lengths[i]; j++) { -+ char pat_byte = ((char *)&pattern)[j % 8]; -+ if (dst_data[j] != pat_byte) -+ ERR_RETURN("Error with fill operation (lengths = %u): got (%x), not (%x)\n", -+ lengths[i], dst_data[j], pat_byte); -+ } -+ /* check that the data after the fill operation was not written to */ -+ for (; j < rte_pktmbuf_data_len(dst); j++) -+ if (dst_data[j] != 0) -+ ERR_RETURN("Error, fill operation wrote too far (lengths = %u): got (%x), not (%x)\n", -+ lengths[i], dst_data[j], 0); -+ } -+ -+ rte_pktmbuf_free(dst); -+ return 0; -+} -+ -+static int -+test_burst_capacity(int16_t dev_id, uint16_t vchan) -+{ -+#define CAP_TEST_BURST_SIZE 64 -+ const int ring_space = rte_dma_burst_capacity(dev_id, vchan); -+ struct rte_mbuf *src, *dst; -+ int i, j, iter; -+ int cap, ret; -+ bool dma_err; -+ -+ src = rte_pktmbuf_alloc(pool); -+ dst = rte_pktmbuf_alloc(pool); -+ -+ /* to test capacity, we enqueue elements and check capacity is reduced -+ * by one each time - rebaselining the expected value after each burst -+ * as the capacity is only for a burst. We enqueue multiple bursts to -+ * fill up half the ring, before emptying it again. We do this twice to -+ * ensure that we get to test scenarios where we get ring wrap-around -+ */ -+ for (iter = 0; iter < 2; iter++) { -+ for (i = 0; i < (ring_space / (2 * CAP_TEST_BURST_SIZE)) + 1; i++) { -+ cap = rte_dma_burst_capacity(dev_id, vchan); -+ -+ for (j = 0; j < CAP_TEST_BURST_SIZE; j++) { -+ ret = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), -+ rte_pktmbuf_iova(dst), COPY_LEN, 0); -+ if (ret < 0) -+ ERR_RETURN("Error with rte_dmadev_copy\n"); -+ -+ if (rte_dma_burst_capacity(dev_id, vchan) != cap - (j + 1)) -+ ERR_RETURN("Error, ring capacity did not change as expected\n"); -+ } -+ if (rte_dma_submit(dev_id, vchan) < 0) -+ ERR_RETURN("Error, failed to submit burst\n"); -+ -+ if (cap < rte_dma_burst_capacity(dev_id, vchan)) -+ ERR_RETURN("Error, avail ring capacity has gone up, not down\n"); -+ } -+ await_hw(dev_id, vchan); -+ -+ for (i = 0; i < (ring_space / (2 * CAP_TEST_BURST_SIZE)) + 1; i++) { -+ ret = rte_dma_completed(dev_id, vchan, -+ CAP_TEST_BURST_SIZE, NULL, &dma_err); -+ if (ret != CAP_TEST_BURST_SIZE || dma_err) { -+ enum rte_dma_status_code status; -+ -+ rte_dma_completed_status(dev_id, vchan, 1, NULL, &status); -+ ERR_RETURN("Error with rte_dmadev_completed, %u [expected: %u], dma_err = %d, i = %u, iter = %u, status = %u\n", -+ ret, CAP_TEST_BURST_SIZE, dma_err, i, iter, status); -+ } -+ } -+ cap = rte_dma_burst_capacity(dev_id, vchan); -+ if (cap != ring_space) -+ ERR_RETURN("Error, ring capacity has not reset to original value, got %u, expected %u\n", -+ cap, ring_space); -+ } -+ -+ rte_pktmbuf_free(src); -+ rte_pktmbuf_free(dst); -+ -+ return 0; -+} -+ -+static int -+test_dmadev_instance(int16_t dev_id) -+{ -+#define TEST_RINGSIZE 512 -+#define CHECK_ERRS true -+ struct rte_dma_stats stats; -+ struct rte_dma_info info; -+ const struct rte_dma_conf conf = { .nb_vchans = 1}; -+ const struct rte_dma_vchan_conf qconf = { -+ .direction = RTE_DMA_DIR_MEM_TO_MEM, -+ .nb_desc = TEST_RINGSIZE, -+ }; -+ const int vchan = 0; -+ int ret; -+ -+ ret = rte_dma_info_get(dev_id, &info); -+ if (ret != 0) -+ ERR_RETURN("Error with rte_dma_info_get()\n"); -+ -+ printf("\n### Test dmadev instance %u [%s]\n", -+ dev_id, info.dev_name); -+ -+ if (info.max_vchans < 1) -+ ERR_RETURN("Error, no channels available on device id %u\n", dev_id); -+ -+ if (rte_dma_configure(dev_id, &conf) != 0) -+ ERR_RETURN("Error with rte_dma_configure()\n"); -+ -+ if (rte_dma_vchan_setup(dev_id, vchan, &qconf) < 0) -+ ERR_RETURN("Error with queue configuration\n"); -+ -+ ret = rte_dma_info_get(dev_id, &info); -+ if (ret != 0 || info.nb_vchans != 1) -+ ERR_RETURN("Error, no configured queues reported on device id %u\n", dev_id); -+ -+ if (rte_dma_start(dev_id) != 0) -+ ERR_RETURN("Error with rte_dma_start()\n"); -+ -+ if (rte_dma_stats_get(dev_id, vchan, &stats) != 0) -+ ERR_RETURN("Error with rte_dma_stats_get()\n"); -+ -+ if (stats.completed != 0 || stats.submitted != 0 || stats.errors != 0) -+ ERR_RETURN("Error device stats are not all zero: completed = %"PRIu64", " -+ "submitted = %"PRIu64", errors = %"PRIu64"\n", -+ stats.completed, stats.submitted, stats.errors); -+ id_count = 0; -+ -+ /* create a mempool for running tests */ -+ pool = rte_pktmbuf_pool_create("TEST_DMADEV_POOL", -+ TEST_RINGSIZE * 2, /* n == num elements */ -+ 32, /* cache size */ -+ 0, /* priv size */ -+ 2048, /* data room size */ -+ info.numa_node); -+ if (pool == NULL) -+ ERR_RETURN("Error with mempool creation\n"); -+ -+ /* run the test cases, use many iterations to ensure UINT16_MAX id wraparound */ -+ if (runtest("copy", test_enqueue_copies, 640, dev_id, vchan, CHECK_ERRS) < 0) -+ goto err; -+ -+ /* run some burst capacity tests */ -+ if (runtest("burst capacity", test_burst_capacity, 1, dev_id, vchan, CHECK_ERRS) < 0) -+ goto err; -+ -+ /* to test error handling we can provide null pointers for source or dest in copies. This -+ * requires VA mode in DPDK, since NULL(0) is a valid physical address. -+ * We also need hardware that can report errors back. -+ */ -+ if (rte_eal_iova_mode() != RTE_IOVA_VA) -+ printf("DMA Dev %u: DPDK not in VA mode, skipping error handling tests\n", dev_id); -+ else if ((info.dev_capa & RTE_DMA_CAPA_HANDLES_ERRORS) == 0) -+ printf("DMA Dev %u: device does not report errors, skipping error handling tests\n", -+ dev_id); -+ else if (runtest("error handling", test_completion_handling, 1, -+ dev_id, vchan, !CHECK_ERRS) < 0) -+ goto err; -+ -+ if ((info.dev_capa & RTE_DMA_CAPA_OPS_FILL) == 0) -+ printf("DMA Dev %u: No device fill support, skipping fill tests\n", dev_id); -+ else if (runtest("fill", test_enqueue_fill, 1, dev_id, vchan, CHECK_ERRS) < 0) -+ goto err; -+ -+ rte_mempool_free(pool); -+ rte_dma_stop(dev_id); -+ rte_dma_stats_reset(dev_id, vchan); -+ return 0; -+ -+err: -+ rte_mempool_free(pool); -+ rte_dma_stop(dev_id); -+ return -1; -+} -+ -+static int -+test_apis(void) -+{ -+ const char *pmd = "dma_skeleton"; -+ int id; -+ int ret; -+ -+ /* attempt to create skeleton instance - ignore errors due to one being already present */ -+ rte_vdev_init(pmd, NULL); -+ id = rte_dma_get_dev_id_by_name(pmd); -+ if (id < 0) -+ return TEST_SKIPPED; -+ printf("\n### Test dmadev infrastructure using skeleton driver\n"); -+ ret = test_dma_api(id); -+ -+ return ret; -+} -+ -+static int -+test_dma(void) -+{ -+ int i; -+ -+ /* basic sanity on dmadev infrastructure */ -+ if (test_apis() < 0) -+ ERR_RETURN("Error performing API tests\n"); -+ -+ if (rte_dma_count_avail() == 0) -+ return TEST_SKIPPED; -+ -+ RTE_DMA_FOREACH_DEV(i) -+ if (test_dmadev_instance(i) < 0) -+ ERR_RETURN("Error, test failure for device %d\n", i); -+ -+ return 0; -+} -+ -+REGISTER_TEST_COMMAND(dmadev_autotest, test_dma); -diff --git a/app/test/test_dmadev_api.c b/app/test/test_dmadev_api.c -new file mode 100644 -index 000000000..4a181af90 ---- /dev/null -+++ b/app/test/test_dmadev_api.c -@@ -0,0 +1,574 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ */ -+ -+#include -+ -+#include -+#include -+#include -+#include -+ -+extern int test_dma_api(uint16_t dev_id); -+ -+#define DMA_TEST_API_RUN(test) \ -+ testsuite_run_test(test, #test) -+ -+#define TEST_MEMCPY_SIZE 1024 -+#define TEST_WAIT_US_VAL 50000 -+ -+#define TEST_SUCCESS 0 -+#define TEST_FAILED -1 -+ -+static int16_t test_dev_id; -+static int16_t invalid_dev_id; -+ -+static char *src; -+static char *dst; -+ -+static int total; -+static int passed; -+static int failed; -+ -+static int -+testsuite_setup(int16_t dev_id) -+{ -+ test_dev_id = dev_id; -+ invalid_dev_id = -1; -+ -+ src = rte_malloc("dmadev_test_src", TEST_MEMCPY_SIZE, 0); -+ if (src == NULL) -+ return -ENOMEM; -+ dst = rte_malloc("dmadev_test_dst", TEST_MEMCPY_SIZE, 0); -+ if (dst == NULL) { -+ rte_free(src); -+ src = NULL; -+ return -ENOMEM; -+ } -+ -+ total = 0; -+ passed = 0; -+ failed = 0; -+ -+ /* Set dmadev log level to critical to suppress unnecessary output -+ * during API tests. -+ */ -+ rte_log_set_level_pattern("lib.dmadev", RTE_LOG_CRIT); -+ -+ return 0; -+} -+ -+static void -+testsuite_teardown(void) -+{ -+ rte_free(src); -+ src = NULL; -+ rte_free(dst); -+ dst = NULL; -+ /* Ensure the dmadev is stopped. */ -+ rte_dma_stop(test_dev_id); -+ -+ rte_log_set_level_pattern("lib.dmadev", RTE_LOG_INFO); -+} -+ -+static void -+testsuite_run_test(int (*test)(void), const char *name) -+{ -+ int ret = 0; -+ -+ if (test) { -+ ret = test(); -+ if (ret < 0) { -+ failed++; -+ printf("%s Failed\n", name); -+ } else { -+ passed++; -+ printf("%s Passed\n", name); -+ } -+ } -+ -+ total++; -+} -+ -+static int -+test_dma_get_dev_id_by_name(void) -+{ -+ int ret = rte_dma_get_dev_id_by_name("invalid_dmadev_device"); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_is_valid_dev(void) -+{ -+ int ret; -+ ret = rte_dma_is_valid(invalid_dev_id); -+ RTE_TEST_ASSERT(ret == false, "Expected false for invalid dev id"); -+ ret = rte_dma_is_valid(test_dev_id); -+ RTE_TEST_ASSERT(ret == true, "Expected true for valid dev id"); -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_count(void) -+{ -+ uint16_t count = rte_dma_count_avail(); -+ RTE_TEST_ASSERT(count > 0, "Invalid dmadev count %u", count); -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_info_get(void) -+{ -+ struct rte_dma_info info = { 0 }; -+ int ret; -+ -+ ret = rte_dma_info_get(invalid_dev_id, &info); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_info_get(test_dev_id, NULL); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_info_get(test_dev_id, &info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain device info"); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_configure(void) -+{ -+ struct rte_dma_conf conf = { 0 }; -+ struct rte_dma_info info = { 0 }; -+ int ret; -+ -+ /* Check for invalid parameters */ -+ ret = rte_dma_configure(invalid_dev_id, &conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_configure(test_dev_id, NULL); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check for nb_vchans == 0 */ -+ memset(&conf, 0, sizeof(conf)); -+ ret = rte_dma_configure(test_dev_id, &conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check for conf.nb_vchans > info.max_vchans */ -+ ret = rte_dma_info_get(test_dev_id, &info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain device info"); -+ memset(&conf, 0, sizeof(conf)); -+ conf.nb_vchans = info.max_vchans + 1; -+ ret = rte_dma_configure(test_dev_id, &conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check enable silent mode */ -+ memset(&conf, 0, sizeof(conf)); -+ conf.nb_vchans = info.max_vchans; -+ conf.enable_silent = true; -+ ret = rte_dma_configure(test_dev_id, &conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Configure success */ -+ memset(&conf, 0, sizeof(conf)); -+ conf.nb_vchans = info.max_vchans; -+ ret = rte_dma_configure(test_dev_id, &conf); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to configure dmadev, %d", ret); -+ -+ /* Check configure success */ -+ ret = rte_dma_info_get(test_dev_id, &info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain device info"); -+ RTE_TEST_ASSERT_EQUAL(conf.nb_vchans, info.nb_vchans, -+ "Configure nb_vchans not match"); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+check_direction(void) -+{ -+ struct rte_dma_vchan_conf vchan_conf; -+ int ret; -+ -+ /* Check for direction */ -+ memset(&vchan_conf, 0, sizeof(vchan_conf)); -+ vchan_conf.direction = RTE_DMA_DIR_DEV_TO_DEV + 1; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM - 1; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check for direction and dev_capa combination */ -+ memset(&vchan_conf, 0, sizeof(vchan_conf)); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_DEV; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ vchan_conf.direction = RTE_DMA_DIR_DEV_TO_MEM; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ vchan_conf.direction = RTE_DMA_DIR_DEV_TO_DEV; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ return 0; -+} -+ -+static int -+check_port_type(struct rte_dma_info *dev_info) -+{ -+ struct rte_dma_vchan_conf vchan_conf; -+ int ret; -+ -+ /* Check src port type validation */ -+ memset(&vchan_conf, 0, sizeof(vchan_conf)); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM; -+ vchan_conf.nb_desc = dev_info->min_desc; -+ vchan_conf.src_port.port_type = RTE_DMA_PORT_PCIE; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check dst port type validation */ -+ memset(&vchan_conf, 0, sizeof(vchan_conf)); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM; -+ vchan_conf.nb_desc = dev_info->min_desc; -+ vchan_conf.dst_port.port_type = RTE_DMA_PORT_PCIE; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ return 0; -+} -+ -+static int -+test_dma_vchan_setup(void) -+{ -+ struct rte_dma_vchan_conf vchan_conf = { 0 }; -+ struct rte_dma_conf dev_conf = { 0 }; -+ struct rte_dma_info dev_info = { 0 }; -+ int ret; -+ -+ /* Check for invalid parameters */ -+ ret = rte_dma_vchan_setup(invalid_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_vchan_setup(test_dev_id, 0, NULL); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Make sure configure success */ -+ ret = rte_dma_info_get(test_dev_id, &dev_info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain device info"); -+ dev_conf.nb_vchans = dev_info.max_vchans; -+ ret = rte_dma_configure(test_dev_id, &dev_conf); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to configure dmadev, %d", ret); -+ -+ /* Check for invalid vchan */ -+ ret = rte_dma_vchan_setup(test_dev_id, dev_conf.nb_vchans, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check for direction */ -+ ret = check_direction(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to check direction"); -+ -+ /* Check for nb_desc validation */ -+ memset(&vchan_conf, 0, sizeof(vchan_conf)); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM; -+ vchan_conf.nb_desc = dev_info.min_desc - 1; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ vchan_conf.nb_desc = dev_info.max_desc + 1; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check port type */ -+ ret = check_port_type(&dev_info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to check port type"); -+ -+ /* Check vchan setup success */ -+ memset(&vchan_conf, 0, sizeof(vchan_conf)); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM; -+ vchan_conf.nb_desc = dev_info.min_desc; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup vchan, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+setup_one_vchan(void) -+{ -+ struct rte_dma_vchan_conf vchan_conf = { 0 }; -+ struct rte_dma_info dev_info = { 0 }; -+ struct rte_dma_conf dev_conf = { 0 }; -+ int ret; -+ -+ ret = rte_dma_info_get(test_dev_id, &dev_info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain device info, %d", ret); -+ dev_conf.nb_vchans = dev_info.max_vchans; -+ ret = rte_dma_configure(test_dev_id, &dev_conf); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to configure, %d", ret); -+ vchan_conf.direction = RTE_DMA_DIR_MEM_TO_MEM; -+ vchan_conf.nb_desc = dev_info.min_desc; -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup vchan, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_start_stop(void) -+{ -+ struct rte_dma_vchan_conf vchan_conf = { 0 }; -+ struct rte_dma_conf dev_conf = { 0 }; -+ int ret; -+ -+ /* Check for invalid parameters */ -+ ret = rte_dma_start(invalid_dev_id); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_stop(invalid_dev_id); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Setup one vchan for later test */ -+ ret = setup_one_vchan(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup one vchan, %d", ret); -+ -+ ret = rte_dma_start(test_dev_id); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to start, %d", ret); -+ -+ /* Check reconfigure and vchan setup when device started */ -+ ret = rte_dma_configure(test_dev_id, &dev_conf); -+ RTE_TEST_ASSERT(ret == -EBUSY, "Failed to configure, %d", ret); -+ ret = rte_dma_vchan_setup(test_dev_id, 0, &vchan_conf); -+ RTE_TEST_ASSERT(ret == -EBUSY, "Failed to setup vchan, %d", ret); -+ -+ ret = rte_dma_stop(test_dev_id); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to stop, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_stats(void) -+{ -+ struct rte_dma_info dev_info = { 0 }; -+ struct rte_dma_stats stats = { 0 }; -+ int ret; -+ -+ /* Check for invalid parameters */ -+ ret = rte_dma_stats_get(invalid_dev_id, 0, &stats); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_stats_get(invalid_dev_id, 0, NULL); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_stats_reset(invalid_dev_id, 0); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Setup one vchan for later test */ -+ ret = setup_one_vchan(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup one vchan, %d", ret); -+ -+ /* Check for invalid vchan */ -+ ret = rte_dma_info_get(test_dev_id, &dev_info); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to obtain device info, %d", ret); -+ ret = rte_dma_stats_get(test_dev_id, dev_info.max_vchans, &stats); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ ret = rte_dma_stats_reset(test_dev_id, dev_info.max_vchans); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Expected -EINVAL, %d", ret); -+ -+ /* Check for valid vchan */ -+ ret = rte_dma_stats_get(test_dev_id, 0, &stats); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get stats, %d", ret); -+ ret = rte_dma_stats_get(test_dev_id, RTE_DMA_ALL_VCHAN, &stats); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to get all stats, %d", ret); -+ ret = rte_dma_stats_reset(test_dev_id, 0); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to reset stats, %d", ret); -+ ret = rte_dma_stats_reset(test_dev_id, RTE_DMA_ALL_VCHAN); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to reset all stats, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_dump(void) -+{ -+ int ret; -+ -+ /* Check for invalid parameters */ -+ ret = rte_dma_dump(invalid_dev_id, stderr); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Excepted -EINVAL, %d", ret); -+ ret = rte_dma_dump(test_dev_id, NULL); -+ RTE_TEST_ASSERT(ret == -EINVAL, "Excepted -EINVAL, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+static void -+setup_memory(void) -+{ -+ int i; -+ -+ for (i = 0; i < TEST_MEMCPY_SIZE; i++) -+ src[i] = (char)i; -+ memset(dst, 0, TEST_MEMCPY_SIZE); -+} -+ -+static int -+verify_memory(void) -+{ -+ int i; -+ -+ for (i = 0; i < TEST_MEMCPY_SIZE; i++) { -+ if (src[i] == dst[i]) -+ continue; -+ RTE_TEST_ASSERT_EQUAL(src[i], dst[i], -+ "Failed to copy memory, %d %d", src[i], dst[i]); -+ } -+ -+ return 0; -+} -+ -+static int -+test_dma_completed(void) -+{ -+ uint16_t last_idx = 1; -+ bool has_error = true; -+ uint16_t cpl_ret; -+ int ret; -+ -+ /* Setup one vchan for later test */ -+ ret = setup_one_vchan(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup one vchan, %d", ret); -+ -+ ret = rte_dma_start(test_dev_id); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to start, %d", ret); -+ -+ setup_memory(); -+ -+ /* Check enqueue without submit */ -+ ret = rte_dma_copy(test_dev_id, 0, (rte_iova_t)src, (rte_iova_t)dst, -+ TEST_MEMCPY_SIZE, 0); -+ RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to enqueue copy, %d", ret); -+ rte_delay_us_sleep(TEST_WAIT_US_VAL); -+ cpl_ret = rte_dma_completed(test_dev_id, 0, 1, &last_idx, &has_error); -+ RTE_TEST_ASSERT_EQUAL(cpl_ret, 0, "Failed to get completed"); -+ -+ /* Check add submit */ -+ ret = rte_dma_submit(test_dev_id, 0); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to submit, %d", ret); -+ rte_delay_us_sleep(TEST_WAIT_US_VAL); -+ cpl_ret = rte_dma_completed(test_dev_id, 0, 1, &last_idx, &has_error); -+ RTE_TEST_ASSERT_EQUAL(cpl_ret, 1, "Failed to get completed"); -+ RTE_TEST_ASSERT_EQUAL(last_idx, 0, "Last idx should be zero, %u", -+ last_idx); -+ RTE_TEST_ASSERT_EQUAL(has_error, false, "Should have no error"); -+ ret = verify_memory(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to verify memory"); -+ -+ setup_memory(); -+ -+ /* Check for enqueue with submit */ -+ ret = rte_dma_copy(test_dev_id, 0, (rte_iova_t)src, (rte_iova_t)dst, -+ TEST_MEMCPY_SIZE, RTE_DMA_OP_FLAG_SUBMIT); -+ RTE_TEST_ASSERT_EQUAL(ret, 1, "Failed to enqueue copy, %d", ret); -+ rte_delay_us_sleep(TEST_WAIT_US_VAL); -+ cpl_ret = rte_dma_completed(test_dev_id, 0, 1, &last_idx, &has_error); -+ RTE_TEST_ASSERT_EQUAL(cpl_ret, 1, "Failed to get completed"); -+ RTE_TEST_ASSERT_EQUAL(last_idx, 1, "Last idx should be 1, %u", -+ last_idx); -+ RTE_TEST_ASSERT_EQUAL(has_error, false, "Should have no error"); -+ ret = verify_memory(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to verify memory"); -+ -+ /* Stop dmadev to make sure dmadev to a known state */ -+ ret = rte_dma_stop(test_dev_id); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to stop, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+static int -+test_dma_completed_status(void) -+{ -+ enum rte_dma_status_code status[1] = { 1 }; -+ uint16_t last_idx = 1; -+ uint16_t cpl_ret, i; -+ int ret; -+ -+ /* Setup one vchan for later test */ -+ ret = setup_one_vchan(); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to setup one vchan, %d", ret); -+ -+ ret = rte_dma_start(test_dev_id); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to start, %d", ret); -+ -+ /* Check for enqueue with submit */ -+ ret = rte_dma_copy(test_dev_id, 0, (rte_iova_t)src, (rte_iova_t)dst, -+ TEST_MEMCPY_SIZE, RTE_DMA_OP_FLAG_SUBMIT); -+ RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to enqueue copy, %d", ret); -+ rte_delay_us_sleep(TEST_WAIT_US_VAL); -+ cpl_ret = rte_dma_completed_status(test_dev_id, 0, 1, &last_idx, -+ status); -+ RTE_TEST_ASSERT_EQUAL(cpl_ret, 1, "Failed to completed status"); -+ RTE_TEST_ASSERT_EQUAL(last_idx, 0, "Last idx should be zero, %u", -+ last_idx); -+ for (i = 0; i < RTE_DIM(status); i++) -+ RTE_TEST_ASSERT_EQUAL(status[i], 0, -+ "Failed to completed status, %d", status[i]); -+ -+ /* Check do completed status again */ -+ cpl_ret = rte_dma_completed_status(test_dev_id, 0, 1, &last_idx, -+ status); -+ RTE_TEST_ASSERT_EQUAL(cpl_ret, 0, "Failed to completed status"); -+ -+ /* Check for enqueue with submit again */ -+ ret = rte_dma_copy(test_dev_id, 0, (rte_iova_t)src, (rte_iova_t)dst, -+ TEST_MEMCPY_SIZE, RTE_DMA_OP_FLAG_SUBMIT); -+ RTE_TEST_ASSERT_EQUAL(ret, 1, "Failed to enqueue copy, %d", ret); -+ rte_delay_us_sleep(TEST_WAIT_US_VAL); -+ cpl_ret = rte_dma_completed_status(test_dev_id, 0, 1, &last_idx, -+ status); -+ RTE_TEST_ASSERT_EQUAL(cpl_ret, 1, "Failed to completed status"); -+ RTE_TEST_ASSERT_EQUAL(last_idx, 1, "Last idx should be 1, %u", -+ last_idx); -+ for (i = 0; i < RTE_DIM(status); i++) -+ RTE_TEST_ASSERT_EQUAL(status[i], 0, -+ "Failed to completed status, %d", status[i]); -+ -+ /* Stop dmadev to make sure dmadev to a known state */ -+ ret = rte_dma_stop(test_dev_id); -+ RTE_TEST_ASSERT_SUCCESS(ret, "Failed to stop, %d", ret); -+ -+ return TEST_SUCCESS; -+} -+ -+int -+test_dma_api(uint16_t dev_id) -+{ -+ int ret = testsuite_setup(dev_id); -+ if (ret) { -+ printf("testsuite setup fail!\n"); -+ return -1; -+ } -+ -+ /* If the testcase exit successfully, ensure that the test dmadev exist -+ * and the dmadev is in the stopped state. -+ */ -+ DMA_TEST_API_RUN(test_dma_get_dev_id_by_name); -+ DMA_TEST_API_RUN(test_dma_is_valid_dev); -+ DMA_TEST_API_RUN(test_dma_count); -+ DMA_TEST_API_RUN(test_dma_info_get); -+ DMA_TEST_API_RUN(test_dma_configure); -+ DMA_TEST_API_RUN(test_dma_vchan_setup); -+ DMA_TEST_API_RUN(test_dma_start_stop); -+ DMA_TEST_API_RUN(test_dma_stats); -+ DMA_TEST_API_RUN(test_dma_dump); -+ DMA_TEST_API_RUN(test_dma_completed); -+ DMA_TEST_API_RUN(test_dma_completed_status); -+ -+ testsuite_teardown(); -+ -+ printf("Total tests : %d\n", total); -+ printf("Passed : %d\n", passed); -+ printf("Failed : %d\n", failed); -+ -+ if (failed) -+ return -1; -+ -+ return 0; -+}; -diff --git a/app/test/test_dmadev_api.h b/app/test/test_dmadev_api.h -new file mode 100644 -index 000000000..33fbc5bd4 ---- /dev/null -+++ b/app/test/test_dmadev_api.h -@@ -0,0 +1,5 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ */ -+ -+int test_dma_api(uint16_t dev_id); -diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md -index 748514e24..8dc353300 100644 ---- a/doc/api/doxy-api-index.md -+++ b/doc/api/doxy-api-index.md -@@ -21,6 +21,7 @@ The public API headers are grouped by topics: - [compressdev] (@ref rte_compressdev.h), - [compress] (@ref rte_comp.h), - [regexdev] (@ref rte_regexdev.h), -+ [dmadev] (@ref rte_dmadev.h), - [eventdev] (@ref rte_eventdev.h), - [event_eth_rx_adapter] (@ref rte_event_eth_rx_adapter.h), - [event_eth_tx_adapter] (@ref rte_event_eth_tx_adapter.h), -diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in -index 5c883b613..3b2c53426 100644 ---- a/doc/api/doxy-api.conf.in -+++ b/doc/api/doxy-api.conf.in -@@ -35,6 +35,7 @@ INPUT = @TOPDIR@/doc/api/doxy-api-index.md \ - @TOPDIR@/lib/librte_compressdev \ - @TOPDIR@/lib/librte_cryptodev \ - @TOPDIR@/lib/librte_distributor \ -+ @TOPDIR@/lib/librte_dmadev \ - @TOPDIR@/lib/librte_efd \ - @TOPDIR@/lib/librte_ethdev \ - @TOPDIR@/lib/librte_eventdev \ -diff --git a/doc/guides/dmadevs/index.rst b/doc/guides/dmadevs/index.rst -new file mode 100644 -index 000000000..0bce29d76 ---- /dev/null -+++ b/doc/guides/dmadevs/index.rst -@@ -0,0 +1,12 @@ -+.. SPDX-License-Identifier: BSD-3-Clause -+ Copyright 2021 HiSilicon Limited -+ -+DMA Device Drivers -+================== -+ -+The following are a list of DMA device drivers, which can be used from -+an application through DMA API. -+ -+.. toctree:: -+ :maxdepth: 2 -+ :numbered: -diff --git a/doc/guides/index.rst b/doc/guides/index.rst -index 857f0363d..919825992 100644 ---- a/doc/guides/index.rst -+++ b/doc/guides/index.rst -@@ -21,6 +21,7 @@ DPDK documentation - compressdevs/index - vdpadevs/index - regexdevs/index -+ dmadevs/index - eventdevs/index - rawdevs/index - mempool/index -diff --git a/doc/guides/prog_guide/dmadev.rst b/doc/guides/prog_guide/dmadev.rst -new file mode 100644 -index 000000000..32f714786 ---- /dev/null -+++ b/doc/guides/prog_guide/dmadev.rst -@@ -0,0 +1,90 @@ -+.. SPDX-License-Identifier: BSD-3-Clause -+ Copyright 2021 HiSilicon Limited -+ -+DMA Device Library -+================== -+ -+The DMA library provides a DMA device framework for management and provisioning -+of hardware and software DMA poll mode drivers, defining generic API which -+support a number of different DMA operations. -+ -+ -+Design Principles -+----------------- -+ -+The DMA framework provides a generic DMA device framework which supports both -+physical (hardware) and virtual (software) DMA devices, as well as a generic DMA -+API which allows DMA devices to be managed and configured, and supports DMA -+operations to be provisioned on DMA poll mode driver. -+ -+.. _figure_dmadev: -+ -+.. figure:: img/dmadev.* -+ -+The above figure shows the model on which the DMA framework is built on: -+ -+ * The DMA controller could have multiple hardware DMA channels (aka. hardware -+ DMA queues), each hardware DMA channel should be represented by a dmadev. -+ * The dmadev could create multiple virtual DMA channels, each virtual DMA -+ channel represents a different transfer context. -+ * The DMA operation request must be submitted to the virtual DMA channel. -+ -+ -+Device Management -+----------------- -+ -+Device Creation -+~~~~~~~~~~~~~~~ -+ -+Physical DMA controllers are discovered during the PCI probe/enumeration of the -+EAL function which is executed at DPDK initialization, this is based on their -+PCI BDF (bus/bridge, device, function). Specific physical DMA controllers, like -+other physical devices in DPDK can be listed using the EAL command line options. -+ -+The dmadevs are dynamically allocated by using the function -+``rte_dma_pmd_allocate`` based on the number of hardware DMA channels. -+ -+ -+Device Identification -+~~~~~~~~~~~~~~~~~~~~~ -+ -+Each DMA device, whether physical or virtual is uniquely designated by two -+identifiers: -+ -+- A unique device index used to designate the DMA device in all functions -+ exported by the DMA API. -+ -+- A device name used to designate the DMA device in console messages, for -+ administration or debugging purposes. -+ -+ -+Device Features and Capabilities -+-------------------------------- -+ -+DMA devices may support different feature sets. The ``rte_dma_info_get`` API -+can be used to get the device info and supported features. -+ -+Silent mode is a special device capability which does not require the -+application to invoke dequeue APIs. -+ -+ -+Enqueue / Dequeue APIs -+~~~~~~~~~~~~~~~~~~~~~~ -+ -+Enqueue APIs such as ``rte_dma_copy`` and ``rte_dma_fill`` can be used to -+enqueue operations to hardware. If an enqueue is successful, a ``ring_idx`` is -+returned. This ``ring_idx`` can be used by applications to track per operation -+metadata in an application-defined circular ring. -+ -+The ``rte_dma_submit`` API is used to issue doorbell to hardware. -+Alternatively the ``RTE_DMA_OP_FLAG_SUBMIT`` flag can be passed to the enqueue -+APIs to also issue the doorbell to hardware. -+ -+There are two dequeue APIs ``rte_dma_completed`` and -+``rte_dma_completed_status``, these are used to obtain the results of the -+enqueue requests. ``rte_dma_completed`` will return the number of successfully -+completed operations. ``rte_dma_completed_status`` will return the number of -+completed operations along with the status of each operation (filled into the -+``status`` array passed by user). These two APIs can also return the last -+completed operation's ``ring_idx`` which could help user track operations within -+their own application-defined rings. -diff --git a/doc/guides/prog_guide/img/dmadev.svg b/doc/guides/prog_guide/img/dmadev.svg -new file mode 100644 -index 000000000..157d7eb7d ---- /dev/null -+++ b/doc/guides/prog_guide/img/dmadev.svg -@@ -0,0 +1,283 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ virtual DMA channel -+ -+ virtual DMA channel -+ -+ virtual DMA channel -+ -+ -+ dmadev -+ -+ hardware DMA channel -+ -+ hardware DMA channel -+ -+ hardware DMA controller -+ -+ dmadev -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/doc/guides/prog_guide/index.rst b/doc/guides/prog_guide/index.rst -index 45c7dec88..dc60db9be 100644 ---- a/doc/guides/prog_guide/index.rst -+++ b/doc/guides/prog_guide/index.rst -@@ -27,6 +27,7 @@ Programmer's Guide - cryptodev_lib - compressdev - regexdev -+ dmadev - rte_security - rawdev - link_bonding_poll_mode_drv_lib -diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c -new file mode 100644 -index 000000000..cf5bc6dc9 ---- /dev/null -+++ b/drivers/dma/hisilicon/hisi_dmadev.c -@@ -0,0 +1,925 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(C) 2021 HiSilicon Limited -+ */ -+ -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "hisi_dmadev.h" -+ -+RTE_LOG_REGISTER(hisi_dma_logtype, pmd.dma.hisi, INFO); -+#define HISI_DMA_LOG(level, fmt, args...) \ -+ rte_log(RTE_LOG_ ## level, hisi_dma_logtype, \ -+ "%s(): " fmt "\n", __func__, ##args) -+#define HISI_DMA_LOG_RAW(hw, level, fmt, args...) \ -+ rte_log(RTE_LOG_ ## level, hisi_dma_logtype, \ -+ "%s %s(): " fmt "\n", (hw)->data->dev_name, \ -+ __func__, ##args) -+#define HISI_DMA_DEBUG(hw, fmt, args...) \ -+ HISI_DMA_LOG_RAW(hw, DEBUG, fmt, ## args) -+#define HISI_DMA_INFO(hw, fmt, args...) \ -+ HISI_DMA_LOG_RAW(hw, INFO, fmt, ## args) -+#define HISI_DMA_WARN(hw, fmt, args...) \ -+ HISI_DMA_LOG_RAW(hw, WARNING, fmt, ## args) -+#define HISI_DMA_ERR(hw, fmt, args...) \ -+ HISI_DMA_LOG_RAW(hw, ERR, fmt, ## args) -+ -+static uint32_t -+hisi_dma_queue_base(struct hisi_dma_dev *hw) -+{ -+ if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) -+ return HISI_DMA_HIP08_QUEUE_BASE; -+ else -+ return 0; -+} -+ -+static volatile void * -+hisi_dma_queue_regaddr(struct hisi_dma_dev *hw, uint32_t qoff) -+{ -+ uint32_t off = hisi_dma_queue_base(hw) + -+ hw->queue_id * HISI_DMA_QUEUE_REGION_SIZE + qoff; -+ return (volatile void *)((char *)hw->io_base + off); -+} -+ -+static void -+hisi_dma_write_reg(void *base, uint32_t off, uint32_t val) -+{ -+ rte_write32(rte_cpu_to_le_32(val), -+ (volatile void *)((char *)base + off)); -+} -+ -+static void -+hisi_dma_write_dev(struct hisi_dma_dev *hw, uint32_t off, uint32_t val) -+{ -+ hisi_dma_write_reg(hw->io_base, off, val); -+} -+ -+static void -+hisi_dma_write_queue(struct hisi_dma_dev *hw, uint32_t qoff, uint32_t val) -+{ -+ uint32_t off = hisi_dma_queue_base(hw) + -+ hw->queue_id * HISI_DMA_QUEUE_REGION_SIZE + qoff; -+ hisi_dma_write_dev(hw, off, val); -+} -+ -+static uint32_t -+hisi_dma_read_reg(void *base, uint32_t off) -+{ -+ uint32_t val = rte_read32((volatile void *)((char *)base + off)); -+ return rte_le_to_cpu_32(val); -+} -+ -+static uint32_t -+hisi_dma_read_dev(struct hisi_dma_dev *hw, uint32_t off) -+{ -+ return hisi_dma_read_reg(hw->io_base, off); -+} -+ -+static uint32_t -+hisi_dma_read_queue(struct hisi_dma_dev *hw, uint32_t qoff) -+{ -+ uint32_t off = hisi_dma_queue_base(hw) + -+ hw->queue_id * HISI_DMA_QUEUE_REGION_SIZE + qoff; -+ return hisi_dma_read_dev(hw, off); -+} -+ -+static void -+hisi_dma_update_bit(struct hisi_dma_dev *hw, uint32_t off, uint32_t pos, -+ bool set) -+{ -+ uint32_t tmp = hisi_dma_read_dev(hw, off); -+ uint32_t mask = 1u << pos; -+ tmp = set ? tmp | mask : tmp & ~mask; -+ hisi_dma_write_dev(hw, off, tmp); -+} -+ -+static void -+hisi_dma_update_queue_bit(struct hisi_dma_dev *hw, uint32_t qoff, uint32_t pos, -+ bool set) -+{ -+ uint32_t tmp = hisi_dma_read_queue(hw, qoff); -+ uint32_t mask = 1u << pos; -+ tmp = set ? tmp | mask : tmp & ~mask; -+ hisi_dma_write_queue(hw, qoff, tmp); -+} -+ -+static void -+hisi_dma_update_queue_mbit(struct hisi_dma_dev *hw, uint32_t qoff, -+ uint32_t mask, bool set) -+{ -+ uint32_t tmp = hisi_dma_read_queue(hw, qoff); -+ tmp = set ? tmp | mask : tmp & ~mask; -+ hisi_dma_write_queue(hw, qoff, tmp); -+} -+ -+#define hisi_dma_poll_hw_state(hw, val, cond, sleep_us, timeout_us) ({ \ -+ uint32_t timeout = 0; \ -+ while (timeout++ <= (timeout_us)) { \ -+ (val) = hisi_dma_read_queue(hw, HISI_DMA_QUEUE_FSM_REG); \ -+ if (cond) \ -+ break; \ -+ rte_delay_us(sleep_us); \ -+ } \ -+ (cond) ? 0 : -ETIME; \ -+}) -+ -+static int -+hisi_dma_reset_hw(struct hisi_dma_dev *hw) -+{ -+#define POLL_SLEEP_US 100 -+#define POLL_TIMEOUT_US 10000 -+ -+ uint32_t tmp; -+ int ret; -+ -+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG, -+ HISI_DMA_QUEUE_CTRL0_PAUSE_B, true); -+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG, -+ HISI_DMA_QUEUE_CTRL0_EN_B, false); -+ -+ ret = hisi_dma_poll_hw_state(hw, tmp, -+ FIELD_GET(HISI_DMA_QUEUE_FSM_STS_M, tmp) != HISI_DMA_STATE_RUN, -+ POLL_SLEEP_US, POLL_TIMEOUT_US); -+ if (ret) { -+ HISI_DMA_ERR(hw, "disable dma timeout!"); -+ return ret; -+ } -+ -+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL1_REG, -+ HISI_DMA_QUEUE_CTRL1_RESET_B, true); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_TAIL_REG, 0); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_CQ_HEAD_REG, 0); -+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG, -+ HISI_DMA_QUEUE_CTRL0_PAUSE_B, false); -+ -+ ret = hisi_dma_poll_hw_state(hw, tmp, -+ FIELD_GET(HISI_DMA_QUEUE_FSM_STS_M, tmp) == HISI_DMA_STATE_IDLE, -+ POLL_SLEEP_US, POLL_TIMEOUT_US); -+ if (ret) { -+ HISI_DMA_ERR(hw, "reset dma timeout!"); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static void -+hisi_dma_init_hw(struct hisi_dma_dev *hw) -+{ -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_BASE_L_REG, -+ lower_32_bits(hw->sqe_iova)); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_BASE_H_REG, -+ upper_32_bits(hw->sqe_iova)); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_CQ_BASE_L_REG, -+ lower_32_bits(hw->cqe_iova)); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_CQ_BASE_H_REG, -+ upper_32_bits(hw->cqe_iova)); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_DEPTH_REG, -+ hw->sq_depth_mask); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_CQ_DEPTH_REG, hw->cq_depth - 1); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_SQ_TAIL_REG, 0); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_CQ_HEAD_REG, 0); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM0_REG, 0); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM1_REG, 0); -+ hisi_dma_write_queue(hw, HISI_DMA_QUEUE_ERR_INT_NUM2_REG, 0); -+ -+ if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) { -+ hisi_dma_write_queue(hw, HISI_DMA_HIP08_QUEUE_ERR_INT_NUM3_REG, -+ 0); -+ hisi_dma_write_queue(hw, HISI_DMA_HIP08_QUEUE_ERR_INT_NUM4_REG, -+ 0); -+ hisi_dma_write_queue(hw, HISI_DMA_HIP08_QUEUE_ERR_INT_NUM5_REG, -+ 0); -+ hisi_dma_write_queue(hw, HISI_DMA_HIP08_QUEUE_ERR_INT_NUM6_REG, -+ 0); -+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG, -+ HISI_DMA_HIP08_QUEUE_CTRL0_ERR_ABORT_B, false); -+ hisi_dma_update_queue_mbit(hw, HISI_DMA_QUEUE_INT_STATUS_REG, -+ HISI_DMA_HIP08_QUEUE_INT_MASK_M, true); -+ hisi_dma_update_queue_mbit(hw, -+ HISI_DMA_HIP08_QUEUE_INT_MASK_REG, -+ HISI_DMA_HIP08_QUEUE_INT_MASK_M, true); -+ } -+} -+ -+static void -+hisi_dma_init_gbl(void *pci_bar, uint8_t revision) -+{ -+ struct hisi_dma_dev hw; -+ -+ memset(&hw, 0, sizeof(hw)); -+ hw.io_base = pci_bar; -+ -+ if (revision == HISI_DMA_REVISION_HIP08B) -+ hisi_dma_update_bit(&hw, HISI_DMA_HIP08_MODE_REG, -+ HISI_DMA_HIP08_MODE_SEL_B, true); -+} -+ -+static uint8_t -+hisi_dma_reg_layout(uint8_t revision) -+{ -+ if (revision == HISI_DMA_REVISION_HIP08B) -+ return HISI_DMA_REG_LAYOUT_HIP08; -+ else -+ return HISI_DMA_REG_LAYOUT_INVALID; -+} -+ -+static void -+hisi_dma_zero_iomem(struct hisi_dma_dev *hw) -+{ -+ memset(hw->iomz->addr, 0, hw->iomz_sz); -+} -+ -+static int -+hisi_dma_alloc_iomem(struct hisi_dma_dev *hw, uint16_t ring_size, -+ const char *dev_name) -+{ -+ uint32_t sq_size = sizeof(struct hisi_dma_sqe) * ring_size; -+ uint32_t cq_size = sizeof(struct hisi_dma_cqe) * -+ (ring_size + HISI_DMA_CQ_RESERVED); -+ uint32_t status_size = sizeof(uint16_t) * ring_size; -+ char mz_name[RTE_MEMZONE_NAMESIZE]; -+ const struct rte_memzone *iomz; -+ uint32_t total_size; -+ -+ sq_size = RTE_CACHE_LINE_ROUNDUP(sq_size); -+ cq_size = RTE_CACHE_LINE_ROUNDUP(cq_size); -+ status_size = RTE_CACHE_LINE_ROUNDUP(status_size); -+ total_size = sq_size + cq_size + status_size; -+ -+ (void)snprintf(mz_name, sizeof(mz_name), "hisi_dma:%s", dev_name); -+ iomz = rte_memzone_reserve(mz_name, total_size, hw->data->numa_node, -+ RTE_MEMZONE_IOVA_CONTIG); -+ if (iomz == NULL) { -+ HISI_DMA_ERR(hw, "malloc %s iomem fail!", mz_name); -+ return -ENOMEM; -+ } -+ -+ hw->iomz = iomz; -+ hw->iomz_sz = total_size; -+ hw->sqe = iomz->addr; -+ hw->cqe = (void *)((char *)iomz->addr + sq_size); -+ hw->status = (void *)((char *)iomz->addr + sq_size + cq_size); -+ hw->sqe_iova = iomz->iova; -+ hw->cqe_iova = iomz->iova + sq_size; -+ hw->sq_depth_mask = ring_size - 1; -+ hw->cq_depth = ring_size + HISI_DMA_CQ_RESERVED; -+ hisi_dma_zero_iomem(hw); -+ -+ return 0; -+} -+ -+static void -+hisi_dma_free_iomem(struct hisi_dma_dev *hw) -+{ -+ if (hw->iomz != NULL) -+ rte_memzone_free(hw->iomz); -+ -+ hw->iomz = NULL; -+ hw->sqe = NULL; -+ hw->cqe = NULL; -+ hw->status = NULL; -+ hw->sqe_iova = 0; -+ hw->cqe_iova = 0; -+ hw->sq_depth_mask = 0; -+ hw->cq_depth = 0; -+} -+ -+static int -+hisi_dma_info_get(const struct rte_dma_dev *dev, -+ struct rte_dma_info *dev_info, -+ uint32_t info_sz) -+{ -+ RTE_SET_USED(dev); -+ RTE_SET_USED(info_sz); -+ -+ dev_info->dev_capa = RTE_DMA_CAPA_MEM_TO_MEM | -+ RTE_DMA_CAPA_OPS_COPY; -+ dev_info->max_vchans = 1; -+ dev_info->max_desc = HISI_DMA_MAX_DESC_NUM; -+ dev_info->min_desc = HISI_DMA_MIN_DESC_NUM; -+ -+ return 0; -+} -+ -+static int -+hisi_dma_configure(struct rte_dma_dev *dev, -+ const struct rte_dma_conf *conf, -+ uint32_t conf_sz) -+{ -+ RTE_SET_USED(dev); -+ RTE_SET_USED(conf); -+ RTE_SET_USED(conf_sz); -+ return 0; -+} -+ -+static int -+hisi_dma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, -+ const struct rte_dma_vchan_conf *conf, -+ uint32_t conf_sz) -+{ -+ struct hisi_dma_dev *hw = dev->data->dev_private; -+ int ret; -+ -+ RTE_SET_USED(vchan); -+ RTE_SET_USED(conf_sz); -+ -+ if (!rte_is_power_of_2(conf->nb_desc)) { -+ HISI_DMA_ERR(hw, "Number of desc must be power of 2!"); -+ return -EINVAL; -+ } -+ -+ hisi_dma_free_iomem(hw); -+ ret = hisi_dma_alloc_iomem(hw, conf->nb_desc, dev->data->dev_name); -+ if (ret) -+ return ret; -+ -+ return 0; -+} -+ -+static int -+hisi_dma_start(struct rte_dma_dev *dev) -+{ -+ struct hisi_dma_dev *hw = dev->data->dev_private; -+ -+ if (hw->iomz == NULL) { -+ HISI_DMA_ERR(hw, "Vchan was not setup, start fail!\n"); -+ return -EINVAL; -+ } -+ -+ /* Reset the dmadev to a known state, include: -+ * 1) zero iomem, also include status fields. -+ * 2) init hardware register. -+ * 3) init index values to zero. -+ * 4) init running statistics. -+ */ -+ hisi_dma_zero_iomem(hw); -+ hisi_dma_init_hw(hw); -+ hw->ridx = 0; -+ hw->cridx = 0; -+ hw->sq_head = 0; -+ hw->sq_tail = 0; -+ hw->cq_sq_head = 0; -+ hw->cq_head = 0; -+ hw->cqs_completed = 0; -+ hw->cqe_vld = 1; -+ hw->submitted = 0; -+ hw->completed = 0; -+ hw->errors = 0; -+ -+ hisi_dma_update_queue_bit(hw, HISI_DMA_QUEUE_CTRL0_REG, -+ HISI_DMA_QUEUE_CTRL0_EN_B, true); -+ -+ return 0; -+} -+ -+static int -+hisi_dma_stop(struct rte_dma_dev *dev) -+{ -+ return hisi_dma_reset_hw(dev->data->dev_private); -+} -+ -+static int -+hisi_dma_close(struct rte_dma_dev *dev) -+{ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -+ /* The dmadev already stopped */ -+ hisi_dma_free_iomem(dev->data->dev_private); -+ } -+ return 0; -+} -+ -+static int -+hisi_dma_stats_get(const struct rte_dma_dev *dev, uint16_t vchan, -+ struct rte_dma_stats *stats, -+ uint32_t stats_sz) -+{ -+ struct hisi_dma_dev *hw = dev->data->dev_private; -+ -+ RTE_SET_USED(vchan); -+ RTE_SET_USED(stats_sz); -+ stats->submitted = hw->submitted; -+ stats->completed = hw->completed; -+ stats->errors = hw->errors; -+ -+ return 0; -+} -+ -+static int -+hisi_dma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan) -+{ -+ struct hisi_dma_dev *hw = dev->data->dev_private; -+ -+ RTE_SET_USED(vchan); -+ hw->submitted = 0; -+ hw->completed = 0; -+ hw->errors = 0; -+ -+ return 0; -+} -+ -+static void -+hisi_dma_get_dump_range(struct hisi_dma_dev *hw, uint32_t *start, uint32_t *end) -+{ -+ if (hw->reg_layout == HISI_DMA_REG_LAYOUT_HIP08) { -+ *start = HISI_DMA_HIP08_DUMP_START_REG; -+ *end = HISI_DMA_HIP08_DUMP_END_REG; -+ } else { -+ *start = 0; -+ *end = 0; -+ } -+} -+ -+static void -+hisi_dma_dump_common(struct hisi_dma_dev *hw, FILE *f) -+{ -+#define DUMP_REGNUM_PER_LINE 4 -+ -+ uint32_t start, end; -+ uint32_t cnt, i; -+ -+ hisi_dma_get_dump_range(hw, &start, &end); -+ -+ (void)fprintf(f, " common-register:\n"); -+ -+ cnt = 0; -+ for (i = start; i <= end; i += sizeof(uint32_t)) { -+ if (cnt % DUMP_REGNUM_PER_LINE == 0) -+ (void)fprintf(f, " [%4x]:", i); -+ (void)fprintf(f, " 0x%08x", hisi_dma_read_dev(hw, i)); -+ cnt++; -+ if (cnt % DUMP_REGNUM_PER_LINE == 0) -+ (void)fprintf(f, "\n"); -+ } -+ if (cnt % DUMP_REGNUM_PER_LINE) -+ (void)fprintf(f, "\n"); -+} -+ -+static void -+hisi_dma_dump_read_queue(struct hisi_dma_dev *hw, uint32_t qoff, -+ char *buffer, int max_sz) -+{ -+ memset(buffer, 0, max_sz); -+ -+ /* Address-related registers are not printed for security reasons. */ -+ if (qoff == HISI_DMA_QUEUE_SQ_BASE_L_REG || -+ qoff == HISI_DMA_QUEUE_SQ_BASE_H_REG || -+ qoff == HISI_DMA_QUEUE_CQ_BASE_L_REG || -+ qoff == HISI_DMA_QUEUE_CQ_BASE_H_REG) { -+ (void)snprintf(buffer, max_sz, "**********"); -+ return; -+ } -+ -+ (void)snprintf(buffer, max_sz, "0x%08x", hisi_dma_read_queue(hw, qoff)); -+} -+ -+static void -+hisi_dma_dump_queue(struct hisi_dma_dev *hw, FILE *f) -+{ -+#define REG_FMT_LEN 32 -+ char buf[REG_FMT_LEN] = { 0 }; -+ uint32_t i; -+ -+ (void)fprintf(f, " queue-register:\n"); -+ for (i = 0; i < HISI_DMA_QUEUE_REGION_SIZE; ) { -+ hisi_dma_dump_read_queue(hw, i, buf, sizeof(buf)); -+ (void)fprintf(f, " [%2x]: %s", i, buf); -+ i += sizeof(uint32_t); -+ hisi_dma_dump_read_queue(hw, i, buf, sizeof(buf)); -+ (void)fprintf(f, " %s", buf); -+ i += sizeof(uint32_t); -+ hisi_dma_dump_read_queue(hw, i, buf, sizeof(buf)); -+ (void)fprintf(f, " %s", buf); -+ i += sizeof(uint32_t); -+ hisi_dma_dump_read_queue(hw, i, buf, sizeof(buf)); -+ (void)fprintf(f, " %s\n", buf); -+ i += sizeof(uint32_t); -+ } -+} -+ -+static int -+hisi_dma_dump(const struct rte_dma_dev *dev, FILE *f) -+{ -+ struct hisi_dma_dev *hw = dev->data->dev_private; -+ -+ (void)fprintf(f, -+ " revision: 0x%x queue_id: %u ring_size: %u\n" -+ " ridx: %u cridx: %u\n" -+ " sq_head: %u sq_tail: %u cq_sq_head: %u\n" -+ " cq_head: %u cqs_completed: %u cqe_vld: %u\n" -+ " submitted: %" PRIu64 " completed: %" PRIu64 " errors %" -+ PRIu64"\n", -+ hw->revision, hw->queue_id, -+ hw->sq_depth_mask > 0 ? hw->sq_depth_mask + 1 : 0, -+ hw->ridx, hw->cridx, -+ hw->sq_head, hw->sq_tail, hw->cq_sq_head, -+ hw->cq_head, hw->cqs_completed, hw->cqe_vld, -+ hw->submitted, hw->completed, hw->errors); -+ hisi_dma_dump_queue(hw, f); -+ hisi_dma_dump_common(hw, f); -+ -+ return 0; -+} -+ -+static int -+hisi_dma_copy(void *dev_private, uint16_t vchan, -+ rte_iova_t src, rte_iova_t dst, -+ uint32_t length, uint64_t flags) -+{ -+ struct hisi_dma_dev *hw = dev_private; -+ struct hisi_dma_sqe *sqe = &hw->sqe[hw->sq_tail]; -+ -+ RTE_SET_USED(vchan); -+ -+ if (((hw->sq_tail + 1) & hw->sq_depth_mask) == hw->sq_head) -+ return -ENOSPC; -+ -+ sqe->dw0 = rte_cpu_to_le_32(SQE_OPCODE_M2M); -+ sqe->dw1 = 0; -+ sqe->dw2 = 0; -+ sqe->length = rte_cpu_to_le_32(length); -+ sqe->src_addr = rte_cpu_to_le_64(src); -+ sqe->dst_addr = rte_cpu_to_le_64(dst); -+ hw->sq_tail = (hw->sq_tail + 1) & hw->sq_depth_mask; -+ hw->submitted++; -+ -+ if (flags & RTE_DMA_OP_FLAG_FENCE) -+ sqe->dw0 |= rte_cpu_to_le_32(SQE_FENCE_FLAG); -+ if (flags & RTE_DMA_OP_FLAG_SUBMIT) -+ rte_write32(rte_cpu_to_le_32(hw->sq_tail), hw->sq_tail_reg); -+ -+ return hw->ridx++; -+} -+ -+static int -+hisi_dma_submit(void *dev_private, uint16_t vchan) -+{ -+ struct hisi_dma_dev *hw = dev_private; -+ -+ RTE_SET_USED(vchan); -+ rte_write32(rte_cpu_to_le_32(hw->sq_tail), hw->sq_tail_reg); -+ -+ return 0; -+} -+ -+static inline void -+hisi_dma_scan_cq(struct hisi_dma_dev *hw) -+{ -+ volatile struct hisi_dma_cqe *cqe; -+ uint16_t csq_head = hw->cq_sq_head; -+ uint16_t cq_head = hw->cq_head; -+ uint16_t count = 0; -+ uint64_t misc; -+ -+ while (true) { -+ cqe = &hw->cqe[cq_head]; -+ misc = cqe->misc; -+ misc = rte_le_to_cpu_64(misc); -+ if (FIELD_GET(CQE_VALID_B, misc) != hw->cqe_vld) -+ break; -+ -+ csq_head = FIELD_GET(CQE_SQ_HEAD_MASK, misc); -+ if (unlikely(misc & CQE_STATUS_MASK)) -+ hw->status[csq_head] = FIELD_GET(CQE_STATUS_MASK, -+ misc); -+ -+ count++; -+ cq_head++; -+ if (cq_head == hw->cq_depth) { -+ hw->cqe_vld = !hw->cqe_vld; -+ cq_head = 0; -+ } -+ } -+ -+ if (count == 0) -+ return; -+ -+ hw->cq_head = cq_head; -+ hw->cq_sq_head = (csq_head + 1) & hw->sq_depth_mask; -+ hw->cqs_completed += count; -+ if (hw->cqs_completed >= HISI_DMA_CQ_RESERVED) { -+ rte_write32(rte_cpu_to_le_32(cq_head), hw->cq_head_reg); -+ hw->cqs_completed = 0; -+ } -+} -+ -+static inline uint16_t -+hisi_dma_calc_cpls(struct hisi_dma_dev *hw, const uint16_t nb_cpls) -+{ -+ uint16_t cpl_num; -+ -+ if (hw->cq_sq_head >= hw->sq_head) -+ cpl_num = hw->cq_sq_head - hw->sq_head; -+ else -+ cpl_num = hw->sq_depth_mask + 1 - hw->sq_head + hw->cq_sq_head; -+ -+ if (cpl_num > nb_cpls) -+ cpl_num = nb_cpls; -+ -+ return cpl_num; -+} -+ -+static uint16_t -+hisi_dma_completed(void *dev_private, -+ uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, bool *has_error) -+{ -+ struct hisi_dma_dev *hw = dev_private; -+ uint16_t sq_head = hw->sq_head; -+ uint16_t cpl_num, i; -+ -+ RTE_SET_USED(vchan); -+ hisi_dma_scan_cq(hw); -+ -+ cpl_num = hisi_dma_calc_cpls(hw, nb_cpls); -+ for (i = 0; i < cpl_num; i++) { -+ if (hw->status[sq_head]) { -+ *has_error = true; -+ break; -+ } -+ sq_head = (sq_head + 1) & hw->sq_depth_mask; -+ } -+ if (i > 0) { -+ hw->cridx += i; -+ *last_idx = hw->cridx - 1; -+ hw->sq_head = sq_head; -+ } -+ hw->completed += i; -+ -+ return i; -+} -+ -+static enum rte_dma_status_code -+hisi_dma_convert_status(uint16_t status) -+{ -+ switch (status) { -+ case HISI_DMA_STATUS_SUCCESS: -+ return RTE_DMA_STATUS_SUCCESSFUL; -+ case HISI_DMA_STATUS_INVALID_OPCODE: -+ return RTE_DMA_STATUS_INVALID_OPCODE; -+ case HISI_DMA_STATUS_INVALID_LENGTH: -+ return RTE_DMA_STATUS_INVALID_LENGTH; -+ case HISI_DMA_STATUS_USER_ABORT: -+ return RTE_DMA_STATUS_USER_ABORT; -+ case HISI_DMA_STATUS_REMOTE_READ_ERROR: -+ case HISI_DMA_STATUS_AXI_READ_ERROR: -+ return RTE_DMA_STATUS_BUS_READ_ERROR; -+ case HISI_DMA_STATUS_AXI_WRITE_ERROR: -+ return RTE_DMA_STATUS_BUS_WRITE_ERROR; -+ case HISI_DMA_STATUS_DATA_POISON: -+ case HISI_DMA_STATUS_REMOTE_DATA_POISION: -+ return RTE_DMA_STATUS_DATA_POISION; -+ case HISI_DMA_STATUS_SQE_READ_ERROR: -+ case HISI_DMA_STATUS_SQE_READ_POISION: -+ return RTE_DMA_STATUS_DESCRIPTOR_READ_ERROR; -+ case HISI_DMA_STATUS_LINK_DOWN_ERROR: -+ return RTE_DMA_STATUS_DEV_LINK_ERROR; -+ default: -+ return RTE_DMA_STATUS_ERROR_UNKNOWN; -+ } -+} -+ -+static uint16_t -+hisi_dma_completed_status(void *dev_private, -+ uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, enum rte_dma_status_code *status) -+{ -+ struct hisi_dma_dev *hw = dev_private; -+ uint16_t sq_head = hw->sq_head; -+ uint16_t cpl_num, i; -+ -+ RTE_SET_USED(vchan); -+ hisi_dma_scan_cq(hw); -+ -+ cpl_num = hisi_dma_calc_cpls(hw, nb_cpls); -+ for (i = 0; i < cpl_num; i++) { -+ status[i] = hisi_dma_convert_status(hw->status[sq_head]); -+ hw->errors += !!status[i]; -+ hw->status[sq_head] = HISI_DMA_STATUS_SUCCESS; -+ sq_head = (sq_head + 1) & hw->sq_depth_mask; -+ } -+ if (likely(cpl_num > 0)) { -+ hw->cridx += cpl_num; -+ *last_idx = hw->cridx - 1; -+ hw->sq_head = sq_head; -+ } -+ hw->completed += cpl_num; -+ -+ return cpl_num; -+} -+ -+static uint16_t -+hisi_dma_burst_capacity(const void *dev_private, uint16_t vchan) -+{ -+ const struct hisi_dma_dev *hw = dev_private; -+ uint16_t sq_head = hw->sq_head; -+ uint16_t sq_tail = hw->sq_tail; -+ -+ RTE_SET_USED(vchan); -+ -+ return (sq_tail >= sq_head) ? hw->sq_depth_mask - sq_tail + sq_head : -+ sq_head - 1 - sq_tail; -+} -+ -+static void -+hisi_dma_gen_pci_device_name(const struct rte_pci_device *pci_dev, -+ char *name, size_t size) -+{ -+ memset(name, 0, size); -+ (void)snprintf(name, size, "%x:%x.%x", -+ pci_dev->addr.bus, pci_dev->addr.devid, -+ pci_dev->addr.function); -+} -+ -+static void -+hisi_dma_gen_dev_name(const struct rte_pci_device *pci_dev, -+ uint8_t queue_id, char *name, size_t size) -+{ -+ memset(name, 0, size); -+ (void)snprintf(name, size, "%x:%x.%x-ch%u", -+ pci_dev->addr.bus, pci_dev->addr.devid, -+ pci_dev->addr.function, queue_id); -+} -+ -+/** -+ * Hardware queue state machine: -+ * -+ * ----------- dmadev_create ------------------ -+ * | Unknown | ---------------> | IDLE | -+ * ----------- ------------------ -+ * ^ | -+ * | |dev_start -+ * dev_stop| | -+ * | v -+ * ------------------ -+ * | RUN | -+ * ------------------ -+ * -+ */ -+static const struct rte_dma_dev_ops hisi_dmadev_ops = { -+ .dev_info_get = hisi_dma_info_get, -+ .dev_configure = hisi_dma_configure, -+ .dev_start = hisi_dma_start, -+ .dev_stop = hisi_dma_stop, -+ .dev_close = hisi_dma_close, -+ .vchan_setup = hisi_dma_vchan_setup, -+ .stats_get = hisi_dma_stats_get, -+ .stats_reset = hisi_dma_stats_reset, -+ .dev_dump = hisi_dma_dump, -+}; -+ -+static int -+hisi_dma_create(struct rte_pci_device *pci_dev, uint8_t queue_id, -+ uint8_t revision) -+{ -+#define REG_PCI_BAR_INDEX 2 -+ -+ char name[RTE_DEV_NAME_MAX_LEN]; -+ struct rte_dma_dev *dev; -+ struct hisi_dma_dev *hw; -+ int ret; -+ -+ hisi_dma_gen_dev_name(pci_dev, queue_id, name, sizeof(name)); -+ dev = rte_dma_pmd_allocate(name, pci_dev->device.numa_node, -+ sizeof(*hw)); -+ if (dev == NULL) { -+ HISI_DMA_LOG(ERR, "%s allocate dmadev fail!", name); -+ return -EINVAL; -+ } -+ -+ dev->device = &pci_dev->device; -+ dev->dev_ops = &hisi_dmadev_ops; -+ dev->fp_obj->dev_private = dev->data->dev_private; -+ dev->fp_obj->copy = hisi_dma_copy; -+ dev->fp_obj->submit = hisi_dma_submit; -+ dev->fp_obj->completed = hisi_dma_completed; -+ dev->fp_obj->completed_status = hisi_dma_completed_status; -+ dev->fp_obj->burst_capacity = hisi_dma_burst_capacity; -+ -+ hw = dev->data->dev_private; -+ hw->data = dev->data; -+ hw->revision = revision; -+ hw->reg_layout = hisi_dma_reg_layout(revision); -+ hw->io_base = pci_dev->mem_resource[REG_PCI_BAR_INDEX].addr; -+ hw->queue_id = queue_id; -+ hw->sq_tail_reg = hisi_dma_queue_regaddr(hw, -+ HISI_DMA_QUEUE_SQ_TAIL_REG); -+ hw->cq_head_reg = hisi_dma_queue_regaddr(hw, -+ HISI_DMA_QUEUE_CQ_HEAD_REG); -+ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -+ ret = hisi_dma_reset_hw(hw); -+ if (ret) { -+ HISI_DMA_LOG(ERR, "%s init device fail!", name); -+ (void)rte_dma_pmd_release(name); -+ return -EIO; -+ } -+ } -+ -+ dev->state = RTE_DMA_DEV_READY; -+ HISI_DMA_LOG(DEBUG, "%s create dmadev success!", name); -+ -+ return 0; -+} -+ -+static int -+hisi_dma_check_revision(struct rte_pci_device *pci_dev, const char *name, -+ uint8_t *out_revision) -+{ -+ uint8_t revision; -+ int ret; -+ -+ ret = rte_pci_read_config(pci_dev, &revision, 1, -+ HISI_DMA_PCI_REVISION_ID_REG); -+ if (ret != 1) { -+ HISI_DMA_LOG(ERR, "%s read PCI revision failed!", name); -+ return -EINVAL; -+ } -+ if (hisi_dma_reg_layout(revision) == HISI_DMA_REG_LAYOUT_INVALID) { -+ HISI_DMA_LOG(ERR, "%s revision: 0x%x not supported!", -+ name, revision); -+ return -EINVAL; -+ } -+ -+ *out_revision = revision; -+ return 0; -+} -+ -+static int -+hisi_dma_probe(struct rte_pci_driver *pci_drv __rte_unused, -+ struct rte_pci_device *pci_dev) -+{ -+ char name[RTE_DEV_NAME_MAX_LEN] = { 0 }; -+ uint8_t revision; -+ uint8_t i; -+ int ret; -+ -+ hisi_dma_gen_pci_device_name(pci_dev, name, sizeof(name)); -+ -+ if (pci_dev->mem_resource[2].addr == NULL) { -+ HISI_DMA_LOG(ERR, "%s BAR2 is NULL!\n", name); -+ return -ENODEV; -+ } -+ -+ ret = hisi_dma_check_revision(pci_dev, name, &revision); -+ if (ret) -+ return ret; -+ HISI_DMA_LOG(DEBUG, "%s read PCI revision: 0x%x", name, revision); -+ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) -+ hisi_dma_init_gbl(pci_dev->mem_resource[2].addr, revision); -+ -+ for (i = 0; i < HISI_DMA_MAX_HW_QUEUES; i++) { -+ ret = hisi_dma_create(pci_dev, i, revision); -+ if (ret) { -+ HISI_DMA_LOG(ERR, "%s create dmadev %u failed!", -+ name, i); -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+static int -+hisi_dma_remove(struct rte_pci_device *pci_dev) -+{ -+ char name[RTE_DEV_NAME_MAX_LEN]; -+ uint8_t i; -+ int ret; -+ -+ for (i = 0; i < HISI_DMA_MAX_HW_QUEUES; i++) { -+ hisi_dma_gen_dev_name(pci_dev, i, name, sizeof(name)); -+ ret = rte_dma_pmd_release(name); -+ if (ret) -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static const struct rte_pci_id pci_id_hisi_dma_map[] = { -+ { RTE_PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HISI_DMA_DEVICE_ID) }, -+ { .vendor_id = 0, }, /* sentinel */ -+}; -+ -+static struct rte_pci_driver hisi_dma_pmd_drv = { -+ .id_table = pci_id_hisi_dma_map, -+ .drv_flags = RTE_PCI_DRV_NEED_MAPPING, -+ .probe = hisi_dma_probe, -+ .remove = hisi_dma_remove, -+}; -+ -+RTE_PMD_REGISTER_PCI(dma_hisilicon, hisi_dma_pmd_drv); -+RTE_PMD_REGISTER_PCI_TABLE(dma_hisilicon, pci_id_hisi_dma_map); -+RTE_PMD_REGISTER_KMOD_DEP(dma_hisilicon, "vfio-pci"); -diff --git a/drivers/dma/hisilicon/hisi_dmadev.h b/drivers/dma/hisilicon/hisi_dmadev.h -new file mode 100644 -index 000000000..12e209c86 ---- /dev/null -+++ b/drivers/dma/hisilicon/hisi_dmadev.h -@@ -0,0 +1,236 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ */ -+ -+#ifndef HISI_DMADEV_H -+#define HISI_DMADEV_H -+ -+#include -+#include -+ -+#define BIT(x) (1ul << (x)) -+#define BITS_PER_LONG (__SIZEOF_LONG__ * 8) -+#define GENMASK(h, l) \ -+ (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) -+#define BF_SHF(x) (__builtin_ffsll(x) - 1) -+#define FIELD_GET(mask, reg) \ -+ ((typeof(mask))(((reg) & (mask)) >> BF_SHF(mask))) -+ -+#define lower_32_bits(x) ((uint32_t)(x)) -+#define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16)) -+ -+#define PCI_VENDOR_ID_HUAWEI 0x19e5 -+#define HISI_DMA_DEVICE_ID 0xA122 -+#define HISI_DMA_PCI_REVISION_ID_REG 0x08 -+#define HISI_DMA_REVISION_HIP08B 0x21 -+ -+#define HISI_DMA_MAX_HW_QUEUES 4 -+#define HISI_DMA_MAX_DESC_NUM 8192 -+#define HISI_DMA_MIN_DESC_NUM 32 -+ -+/** -+ * The HIP08B(HiSilicon IP08) and later Chip(e.g. HiSilicon IP09) are DMA iEPs, -+ * they have the same pci device id but with different pci revision. -+ * Unfortunately, they have different register layouts, so the layout -+ * enumerations are defined. -+ */ -+enum { -+ HISI_DMA_REG_LAYOUT_INVALID = 0, -+ HISI_DMA_REG_LAYOUT_HIP08 -+}; -+ -+/** -+ * Hardware PCI bar register MAP: -+ * -+ * -------------- -+ * | Misc-reg-0 | -+ * | | -+ * -------------- -> Queue base -+ * | | -+ * | Queue-0 | -+ * | | -+ * -------------- --- -+ * | | ^ -+ * | Queue-1 | Queue region -+ * | | v -+ * -------------- --- -+ * | ... | -+ * | Queue-x | -+ * | ... | -+ * -------------- -+ * | Misc-reg-1 | -+ * -------------- -+ * -+ * As described above, a single queue register is continuous and occupies the -+ * length of queue-region. The global offset for a single queue register is -+ * calculated by: -+ * offset = queue-base + (queue-id * queue-region) + reg-offset-in-region. -+ * -+ * The first part of queue region is basically the same for HIP08 and later chip -+ * register layouts, therefore, HISI_QUEUE_* registers are defined for it. -+ */ -+#define HISI_DMA_QUEUE_SQ_BASE_L_REG 0x0 -+#define HISI_DMA_QUEUE_SQ_BASE_H_REG 0x4 -+#define HISI_DMA_QUEUE_SQ_DEPTH_REG 0x8 -+#define HISI_DMA_QUEUE_SQ_TAIL_REG 0xC -+#define HISI_DMA_QUEUE_CQ_BASE_L_REG 0x10 -+#define HISI_DMA_QUEUE_CQ_BASE_H_REG 0x14 -+#define HISI_DMA_QUEUE_CQ_DEPTH_REG 0x18 -+#define HISI_DMA_QUEUE_CQ_HEAD_REG 0x1C -+#define HISI_DMA_QUEUE_CTRL0_REG 0x20 -+#define HISI_DMA_QUEUE_CTRL0_EN_B 0 -+#define HISI_DMA_QUEUE_CTRL0_PAUSE_B 4 -+#define HISI_DMA_QUEUE_CTRL1_REG 0x24 -+#define HISI_DMA_QUEUE_CTRL1_RESET_B 0 -+#define HISI_DMA_QUEUE_FSM_REG 0x30 -+#define HISI_DMA_QUEUE_FSM_STS_M GENMASK(3, 0) -+#define HISI_DMA_QUEUE_INT_STATUS_REG 0x40 -+#define HISI_DMA_QUEUE_ERR_INT_NUM0_REG 0x84 -+#define HISI_DMA_QUEUE_ERR_INT_NUM1_REG 0x88 -+#define HISI_DMA_QUEUE_ERR_INT_NUM2_REG 0x8C -+#define HISI_DMA_QUEUE_REGION_SIZE 0x100 -+ -+/** -+ * HiSilicon IP08 DMA register and field define: -+ */ -+#define HISI_DMA_HIP08_QUEUE_BASE 0x0 -+#define HISI_DMA_HIP08_QUEUE_CTRL0_ERR_ABORT_B 2 -+#define HISI_DMA_HIP08_QUEUE_INT_MASK_REG 0x44 -+#define HISI_DMA_HIP08_QUEUE_INT_MASK_M GENMASK(14, 0) -+#define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM3_REG 0x90 -+#define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM4_REG 0x94 -+#define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM5_REG 0x98 -+#define HISI_DMA_HIP08_QUEUE_ERR_INT_NUM6_REG 0x48 -+#define HISI_DMA_HIP08_MODE_REG 0x217C -+#define HISI_DMA_HIP08_MODE_SEL_B 0 -+#define HISI_DMA_HIP08_DUMP_START_REG 0x2000 -+#define HISI_DMA_HIP08_DUMP_END_REG 0x2280 -+ -+/** -+ * In fact, there are multiple states, but it need to pay attention to -+ * the following two states for the driver: -+ */ -+enum { -+ HISI_DMA_STATE_IDLE = 0, -+ HISI_DMA_STATE_RUN, -+}; -+ -+/** -+ * Hardware complete status define: -+ */ -+#define HISI_DMA_STATUS_SUCCESS 0x0 -+#define HISI_DMA_STATUS_INVALID_OPCODE 0x1 -+#define HISI_DMA_STATUS_INVALID_LENGTH 0x2 -+#define HISI_DMA_STATUS_USER_ABORT 0x4 -+#define HISI_DMA_STATUS_REMOTE_READ_ERROR 0x10 -+#define HISI_DMA_STATUS_AXI_READ_ERROR 0x20 -+#define HISI_DMA_STATUS_AXI_WRITE_ERROR 0x40 -+#define HISI_DMA_STATUS_DATA_POISON 0x80 -+#define HISI_DMA_STATUS_SQE_READ_ERROR 0x100 -+#define HISI_DMA_STATUS_SQE_READ_POISION 0x200 -+#define HISI_DMA_STATUS_REMOTE_DATA_POISION 0x400 -+#define HISI_DMA_STATUS_LINK_DOWN_ERROR 0x800 -+ -+/** -+ * After scanning the CQ array, the CQ head register needs to be updated. -+ * Updating the register involves write memory barrier operations. -+ * Here use the following method to reduce WMB operations: -+ * a) malloc more CQEs, which correspond to the macro HISI_DMA_CQ_RESERVED. -+ * b) update the CQ head register after accumulated number of completed CQs -+ * is greater than or equal to HISI_DMA_CQ_RESERVED. -+ */ -+#define HISI_DMA_CQ_RESERVED 64 -+ -+struct hisi_dma_sqe { -+ uint32_t dw0; -+#define SQE_FENCE_FLAG BIT(10) -+#define SQE_OPCODE_M2M 0x4 -+ uint32_t dw1; -+ uint32_t dw2; -+ uint32_t length; -+ uint64_t src_addr; -+ uint64_t dst_addr; -+}; -+ -+struct hisi_dma_cqe { -+ uint64_t rsv; -+ uint64_t misc; -+#define CQE_SQ_HEAD_MASK GENMASK(15, 0) -+#define CQE_VALID_B BIT(48) -+#define CQE_STATUS_MASK GENMASK(63, 49) -+}; -+ -+struct hisi_dma_dev { -+ struct hisi_dma_sqe *sqe; -+ volatile struct hisi_dma_cqe *cqe; -+ uint16_t *status; /* the completion status array of SQEs. */ -+ -+ volatile void *sq_tail_reg; /**< register address for doorbell. */ -+ volatile void *cq_head_reg; /**< register address for answer CQ. */ -+ -+ uint16_t sq_depth_mask; /**< SQ depth - 1, the SQ depth is power of 2 */ -+ uint16_t cq_depth; /* CQ depth */ -+ -+ uint16_t ridx; /**< ring index which will assign to the next request. */ -+ /** ring index which returned by hisi_dmadev_completed APIs. */ -+ uint16_t cridx; -+ -+ /** -+ * SQE array management fields: -+ * -+ * ----------------------------------------------------- -+ * | SQE0 | SQE1 | SQE2 | ... | SQEx | ... | SQEn-1 | -+ * ----------------------------------------------------- -+ * ^ ^ ^ -+ * | | | -+ * sq_head cq_sq_head sq_tail -+ * -+ * sq_head: index to the oldest completed request, this filed was -+ * updated by hisi_dmadev_completed* APIs. -+ * sq_tail: index of the next new request, this field was updated by -+ * hisi_dmadev_copy API. -+ * cq_sq_head: next index of index that has been completed by hardware, -+ * this filed was updated by hisi_dmadev_completed* APIs. -+ * -+ * [sq_head, cq_sq_head): the SQEs that hardware already completed. -+ * [cq_sq_head, sq_tail): the SQEs that hardware processing. -+ */ -+ uint16_t sq_head; -+ uint16_t sq_tail; -+ uint16_t cq_sq_head; -+ /** -+ * The driver scans the CQE array, if the valid bit changes, the CQE is -+ * considered valid. -+ * Note: One CQE is corresponding to one or several SQEs, e.g. app -+ * submits two copy requests, the hardware processes the two SQEs, -+ * but it may write back only one CQE and the CQE's sq_head field -+ * indicates the index of the second copy request in the SQE -+ * array. -+ */ -+ uint16_t cq_head; /**< CQ index for next scans. */ -+ /** accumulated number of completed CQs -+ * @see HISI_DMA_CQ_RESERVED -+ */ -+ uint16_t cqs_completed; -+ uint8_t cqe_vld; /**< valid bit for CQE, will change for every round. */ -+ -+ uint64_t submitted; -+ uint64_t completed; -+ uint64_t errors; -+ -+ /** -+ * The following fields are not accessed in the I/O path, so they are -+ * placed at the end. -+ */ -+ struct rte_dma_dev_data *data; -+ uint8_t revision; /**< PCI revision. */ -+ uint8_t reg_layout; /**< hardware register layout. */ -+ void *io_base; -+ uint8_t queue_id; /**< hardware DMA queue index. */ -+ const struct rte_memzone *iomz; -+ uint32_t iomz_sz; -+ rte_iova_t sqe_iova; -+ rte_iova_t cqe_iova; -+}; -+ -+#endif /* HISI_DMADEV_H */ -diff --git a/drivers/dma/hisilicon/meson.build b/drivers/dma/hisilicon/meson.build -new file mode 100644 -index 000000000..c11dc352d ---- /dev/null -+++ b/drivers/dma/hisilicon/meson.build -@@ -0,0 +1,19 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2021 HiSilicon Limited -+ -+if not is_linux -+ build = false -+ reason = 'only supported on Linux' -+ subdir_done() -+endif -+ -+if (arch_subdir != 'x86' and arch_subdir != 'arm') or (not dpdk_conf.get('RTE_ARCH_64')) -+ build = false -+ reason = 'only supported on x86_64 and aarch64' -+ subdir_done() -+endif -+ -+deps += ['bus_pci', 'dmadev'] -+sources = files( -+ 'hisi_dmadev.c' -+) -diff --git a/drivers/dma/hisilicon/version.map b/drivers/dma/hisilicon/version.map -new file mode 100644 -index 000000000..c2e0723b4 ---- /dev/null -+++ b/drivers/dma/hisilicon/version.map -@@ -0,0 +1,3 @@ -+DPDK_22 { -+ local: *; -+}; -diff --git a/drivers/dma/meson.build b/drivers/dma/meson.build -new file mode 100644 -index 000000000..d030069fd ---- /dev/null -+++ b/drivers/dma/meson.build -@@ -0,0 +1,13 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright 2021 HiSilicon Limited -+ -+if is_windows -+ subdir_done() -+endif -+ -+drivers = [ -+ 'hisilicon', -+ 'skeleton' -+] -+std_deps = ['dmadev'] -+config_flag_fmt = 'RTE_LIBRTE_PMD_DMADEV_@0@' -diff --git a/drivers/dma/skeleton/meson.build b/drivers/dma/skeleton/meson.build -new file mode 100644 -index 000000000..defe905e4 ---- /dev/null -+++ b/drivers/dma/skeleton/meson.build -@@ -0,0 +1,11 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2021 HiSilicon Limited -+ -+if is_windows -+ subdir_done() -+endif -+ -+deps += ['dmadev', 'kvargs', 'ring', 'bus_vdev'] -+sources = files( -+ 'skeleton_dmadev.c', -+) -diff --git a/drivers/dma/skeleton/skeleton_dmadev.c b/drivers/dma/skeleton/skeleton_dmadev.c -new file mode 100644 -index 000000000..8bed41f8b ---- /dev/null -+++ b/drivers/dma/skeleton/skeleton_dmadev.c -@@ -0,0 +1,596 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ */ -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+ -+#include "skeleton_dmadev.h" -+ -+RTE_LOG_REGISTER(skeldma_logtype, pmd.dma.skeleton, INFO); -+#define SKELDMA_LOG(level, fmt, args...) \ -+ rte_log(RTE_LOG_ ## level, skeldma_logtype, "%s(): " fmt "\n", \ -+ __func__, ##args) -+ -+/* Count of instances, currently only 1 is supported. */ -+static uint16_t skeldma_count; -+ -+static int -+skeldma_info_get(const struct rte_dma_dev *dev, struct rte_dma_info *dev_info, -+ uint32_t info_sz) -+{ -+#define SKELDMA_MAX_DESC 8192 -+#define SKELDMA_MIN_DESC 32 -+ -+ RTE_SET_USED(dev); -+ RTE_SET_USED(info_sz); -+ -+ dev_info->dev_capa = RTE_DMA_CAPA_MEM_TO_MEM | -+ RTE_DMA_CAPA_SVA | -+ RTE_DMA_CAPA_OPS_COPY; -+ dev_info->max_vchans = 1; -+ dev_info->max_desc = SKELDMA_MAX_DESC; -+ dev_info->min_desc = SKELDMA_MIN_DESC; -+ -+ return 0; -+} -+ -+static int -+skeldma_configure(struct rte_dma_dev *dev, const struct rte_dma_conf *conf, -+ uint32_t conf_sz) -+{ -+ RTE_SET_USED(dev); -+ RTE_SET_USED(conf); -+ RTE_SET_USED(conf_sz); -+ return 0; -+} -+ -+static void * -+cpucopy_thread(void *param) -+{ -+#define SLEEP_THRESHOLD 10000 -+#define SLEEP_US_VAL 10 -+ -+ struct rte_dma_dev *dev = param; -+ struct skeldma_hw *hw = dev->data->dev_private; -+ struct skeldma_desc *desc = NULL; -+ int ret; -+ -+ while (!hw->exit_flag) { -+ ret = rte_ring_dequeue(hw->desc_running, (void **)&desc); -+ if (ret) { -+ hw->zero_req_count++; -+ if (hw->zero_req_count == 0) -+ hw->zero_req_count = SLEEP_THRESHOLD; -+ if (hw->zero_req_count >= SLEEP_THRESHOLD) -+ rte_delay_us_sleep(SLEEP_US_VAL); -+ continue; -+ } -+ -+ hw->zero_req_count = 0; -+ rte_memcpy(desc->dst, desc->src, desc->len); -+ __atomic_add_fetch(&hw->completed_count, 1, __ATOMIC_RELEASE); -+ (void)rte_ring_enqueue(hw->desc_completed, (void *)desc); -+ } -+ -+ return NULL; -+} -+ -+static void -+fflush_ring(struct skeldma_hw *hw, struct rte_ring *ring) -+{ -+ struct skeldma_desc *desc = NULL; -+ while (rte_ring_count(ring) > 0) { -+ (void)rte_ring_dequeue(ring, (void **)&desc); -+ (void)rte_ring_enqueue(hw->desc_empty, (void *)desc); -+ } -+} -+ -+static int -+skeldma_start(struct rte_dma_dev *dev) -+{ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ rte_cpuset_t cpuset; -+ int ret; -+ -+ if (hw->desc_mem == NULL) { -+ SKELDMA_LOG(ERR, "Vchan was not setup, start fail!"); -+ return -EINVAL; -+ } -+ -+ /* Reset the dmadev to a known state, include: -+ * 1) fflush pending/running/completed ring to empty ring. -+ * 2) init ring idx to zero. -+ * 3) init running statistics. -+ * 4) mark cpucopy task exit_flag to false. -+ */ -+ fflush_ring(hw, hw->desc_pending); -+ fflush_ring(hw, hw->desc_running); -+ fflush_ring(hw, hw->desc_completed); -+ hw->ridx = 0; -+ hw->submitted_count = 0; -+ hw->zero_req_count = 0; -+ hw->completed_count = 0; -+ hw->exit_flag = false; -+ -+ rte_mb(); -+ -+ ret = rte_ctrl_thread_create(&hw->thread, "dma_skeleton", NULL, -+ cpucopy_thread, dev); -+ if (ret) { -+ SKELDMA_LOG(ERR, "Start cpucopy thread fail!"); -+ return -EINVAL; -+ } -+ -+ if (hw->lcore_id != -1) { -+ cpuset = rte_lcore_cpuset(hw->lcore_id); -+ ret = pthread_setaffinity_np(hw->thread, sizeof(cpuset), -+ &cpuset); -+ if (ret) -+ SKELDMA_LOG(WARNING, -+ "Set thread affinity lcore = %d fail!", -+ hw->lcore_id); -+ } -+ -+ return 0; -+} -+ -+static int -+skeldma_stop(struct rte_dma_dev *dev) -+{ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ -+ hw->exit_flag = true; -+ rte_delay_ms(1); -+ -+ (void)pthread_cancel(hw->thread); -+ pthread_join(hw->thread, NULL); -+ -+ return 0; -+} -+ -+static int -+vchan_setup(struct skeldma_hw *hw, uint16_t nb_desc) -+{ -+ struct skeldma_desc *desc; -+ struct rte_ring *empty; -+ struct rte_ring *pending; -+ struct rte_ring *running; -+ struct rte_ring *completed; -+ uint16_t i; -+ -+ desc = rte_zmalloc_socket("dma_skelteon_desc", -+ nb_desc * sizeof(struct skeldma_desc), -+ RTE_CACHE_LINE_SIZE, hw->socket_id); -+ if (desc == NULL) { -+ SKELDMA_LOG(ERR, "Malloc dma skeleton desc fail!"); -+ return -ENOMEM; -+ } -+ -+ empty = rte_ring_create("dma_skeleton_desc_empty", nb_desc, -+ hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); -+ pending = rte_ring_create("dma_skeleton_desc_pending", nb_desc, -+ hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); -+ running = rte_ring_create("dma_skeleton_desc_running", nb_desc, -+ hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); -+ completed = rte_ring_create("dma_skeleton_desc_completed", nb_desc, -+ hw->socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); -+ if (empty == NULL || pending == NULL || running == NULL || -+ completed == NULL) { -+ SKELDMA_LOG(ERR, "Create dma skeleton desc ring fail!"); -+ rte_ring_free(empty); -+ rte_ring_free(pending); -+ rte_ring_free(running); -+ rte_ring_free(completed); -+ rte_free(desc); -+ return -ENOMEM; -+ } -+ -+ /* The real usable ring size is *count-1* instead of *count* to -+ * differentiate a free ring from an empty ring. -+ * @see rte_ring_create -+ */ -+ for (i = 0; i < nb_desc - 1; i++) -+ (void)rte_ring_enqueue(empty, (void *)(desc + i)); -+ -+ hw->desc_mem = desc; -+ hw->desc_empty = empty; -+ hw->desc_pending = pending; -+ hw->desc_running = running; -+ hw->desc_completed = completed; -+ -+ return 0; -+} -+ -+static void -+vchan_release(struct skeldma_hw *hw) -+{ -+ if (hw->desc_mem == NULL) -+ return; -+ -+ rte_free(hw->desc_mem); -+ hw->desc_mem = NULL; -+ rte_ring_free(hw->desc_empty); -+ hw->desc_empty = NULL; -+ rte_ring_free(hw->desc_pending); -+ hw->desc_pending = NULL; -+ rte_ring_free(hw->desc_running); -+ hw->desc_running = NULL; -+ rte_ring_free(hw->desc_completed); -+ hw->desc_completed = NULL; -+} -+ -+static int -+skeldma_close(struct rte_dma_dev *dev) -+{ -+ /* The device already stopped */ -+ vchan_release(dev->data->dev_private); -+ return 0; -+} -+ -+static int -+skeldma_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan, -+ const struct rte_dma_vchan_conf *conf, -+ uint32_t conf_sz) -+{ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ -+ RTE_SET_USED(vchan); -+ RTE_SET_USED(conf_sz); -+ -+ if (!rte_is_power_of_2(conf->nb_desc)) { -+ SKELDMA_LOG(ERR, "Number of desc must be power of 2!"); -+ return -EINVAL; -+ } -+ -+ vchan_release(hw); -+ return vchan_setup(hw, conf->nb_desc); -+} -+ -+static int -+skeldma_vchan_status(const struct rte_dma_dev *dev, -+ uint16_t vchan, enum rte_dma_vchan_status *status) -+{ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ -+ RTE_SET_USED(vchan); -+ -+ *status = RTE_DMA_VCHAN_IDLE; -+ if (hw->submitted_count != __atomic_load_n(&hw->completed_count, __ATOMIC_ACQUIRE) -+ || hw->zero_req_count == 0) -+ *status = RTE_DMA_VCHAN_ACTIVE; -+ return 0; -+} -+ -+static int -+skeldma_stats_get(const struct rte_dma_dev *dev, uint16_t vchan, -+ struct rte_dma_stats *stats, uint32_t stats_sz) -+{ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ -+ RTE_SET_USED(vchan); -+ RTE_SET_USED(stats_sz); -+ -+ stats->submitted = hw->submitted_count; -+ stats->completed = hw->completed_count; -+ stats->errors = 0; -+ -+ return 0; -+} -+ -+static int -+skeldma_stats_reset(struct rte_dma_dev *dev, uint16_t vchan) -+{ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ -+ RTE_SET_USED(vchan); -+ -+ hw->submitted_count = 0; -+ hw->completed_count = 0; -+ -+ return 0; -+} -+ -+static int -+skeldma_dump(const struct rte_dma_dev *dev, FILE *f) -+{ -+#define GET_RING_COUNT(ring) ((ring) ? (rte_ring_count(ring)) : 0) -+ -+ struct skeldma_hw *hw = dev->data->dev_private; -+ -+ (void)fprintf(f, -+ " lcore_id: %d\n" -+ " socket_id: %d\n" -+ " desc_empty_ring_count: %u\n" -+ " desc_pending_ring_count: %u\n" -+ " desc_running_ring_count: %u\n" -+ " desc_completed_ring_count: %u\n", -+ hw->lcore_id, hw->socket_id, -+ GET_RING_COUNT(hw->desc_empty), -+ GET_RING_COUNT(hw->desc_pending), -+ GET_RING_COUNT(hw->desc_running), -+ GET_RING_COUNT(hw->desc_completed)); -+ (void)fprintf(f, -+ " next_ring_idx: %u\n" -+ " submitted_count: %" PRIu64 "\n" -+ " completed_count: %" PRIu64 "\n", -+ hw->ridx, hw->submitted_count, hw->completed_count); -+ -+ return 0; -+} -+ -+static inline void -+submit(struct skeldma_hw *hw, struct skeldma_desc *desc) -+{ -+ uint16_t count = rte_ring_count(hw->desc_pending); -+ struct skeldma_desc *pend_desc = NULL; -+ -+ while (count > 0) { -+ (void)rte_ring_dequeue(hw->desc_pending, (void **)&pend_desc); -+ (void)rte_ring_enqueue(hw->desc_running, (void *)pend_desc); -+ count--; -+ } -+ -+ if (desc) -+ (void)rte_ring_enqueue(hw->desc_running, (void *)desc); -+} -+ -+static int -+skeldma_copy(void *dev_private, uint16_t vchan, -+ rte_iova_t src, rte_iova_t dst, -+ uint32_t length, uint64_t flags) -+{ -+ struct skeldma_hw *hw = dev_private; -+ struct skeldma_desc *desc; -+ int ret; -+ -+ RTE_SET_USED(vchan); -+ RTE_SET_USED(flags); -+ -+ ret = rte_ring_dequeue(hw->desc_empty, (void **)&desc); -+ if (ret) -+ return -ENOSPC; -+ desc->src = (void *)(uintptr_t)src; -+ desc->dst = (void *)(uintptr_t)dst; -+ desc->len = length; -+ desc->ridx = hw->ridx; -+ if (flags & RTE_DMA_OP_FLAG_SUBMIT) -+ submit(hw, desc); -+ else -+ (void)rte_ring_enqueue(hw->desc_pending, (void *)desc); -+ hw->submitted_count++; -+ -+ return hw->ridx++; -+} -+ -+static int -+skeldma_submit(void *dev_private, uint16_t vchan) -+{ -+ struct skeldma_hw *hw = dev_private; -+ RTE_SET_USED(vchan); -+ submit(hw, NULL); -+ return 0; -+} -+ -+static uint16_t -+skeldma_completed(void *dev_private, -+ uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, bool *has_error) -+{ -+ struct skeldma_hw *hw = dev_private; -+ struct skeldma_desc *desc = NULL; -+ uint16_t index = 0; -+ uint16_t count; -+ -+ RTE_SET_USED(vchan); -+ RTE_SET_USED(has_error); -+ -+ count = RTE_MIN(nb_cpls, rte_ring_count(hw->desc_completed)); -+ while (index < count) { -+ (void)rte_ring_dequeue(hw->desc_completed, (void **)&desc); -+ if (index == count - 1) -+ *last_idx = desc->ridx; -+ index++; -+ (void)rte_ring_enqueue(hw->desc_empty, (void *)desc); -+ } -+ -+ return count; -+} -+ -+static uint16_t -+skeldma_completed_status(void *dev_private, -+ uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, enum rte_dma_status_code *status) -+{ -+ struct skeldma_hw *hw = dev_private; -+ struct skeldma_desc *desc = NULL; -+ uint16_t index = 0; -+ uint16_t count; -+ -+ RTE_SET_USED(vchan); -+ -+ count = RTE_MIN(nb_cpls, rte_ring_count(hw->desc_completed)); -+ while (index < count) { -+ (void)rte_ring_dequeue(hw->desc_completed, (void **)&desc); -+ if (index == count - 1) -+ *last_idx = desc->ridx; -+ status[index++] = RTE_DMA_STATUS_SUCCESSFUL; -+ (void)rte_ring_enqueue(hw->desc_empty, (void *)desc); -+ } -+ -+ return count; -+} -+ -+static uint16_t -+skeldma_burst_capacity(const void *dev_private, uint16_t vchan) -+{ -+ const struct skeldma_hw *hw = dev_private; -+ -+ RTE_SET_USED(vchan); -+ return rte_ring_count(hw->desc_empty); -+} -+ -+static const struct rte_dma_dev_ops skeldma_ops = { -+ .dev_info_get = skeldma_info_get, -+ .dev_configure = skeldma_configure, -+ .dev_start = skeldma_start, -+ .dev_stop = skeldma_stop, -+ .dev_close = skeldma_close, -+ -+ .vchan_setup = skeldma_vchan_setup, -+ .vchan_status = skeldma_vchan_status, -+ -+ .stats_get = skeldma_stats_get, -+ .stats_reset = skeldma_stats_reset, -+ -+ .dev_dump = skeldma_dump, -+}; -+ -+static int -+skeldma_create(const char *name, struct rte_vdev_device *vdev, int lcore_id) -+{ -+ struct rte_dma_dev *dev; -+ struct skeldma_hw *hw; -+ int socket_id; -+ -+ socket_id = (lcore_id < 0) ? rte_socket_id() : -+ rte_lcore_to_socket_id(lcore_id); -+ dev = rte_dma_pmd_allocate(name, socket_id, sizeof(struct skeldma_hw)); -+ if (dev == NULL) { -+ SKELDMA_LOG(ERR, "Unable to allocate dmadev: %s", name); -+ return -EINVAL; -+ } -+ -+ dev->device = &vdev->device; -+ dev->dev_ops = &skeldma_ops; -+ dev->fp_obj->dev_private = dev->data->dev_private; -+ dev->fp_obj->copy = skeldma_copy; -+ dev->fp_obj->submit = skeldma_submit; -+ dev->fp_obj->completed = skeldma_completed; -+ dev->fp_obj->completed_status = skeldma_completed_status; -+ dev->fp_obj->burst_capacity = skeldma_burst_capacity; -+ -+ hw = dev->data->dev_private; -+ hw->lcore_id = lcore_id; -+ hw->socket_id = socket_id; -+ -+ dev->state = RTE_DMA_DEV_READY; -+ -+ return dev->data->dev_id; -+} -+ -+static int -+skeldma_destroy(const char *name) -+{ -+ return rte_dma_pmd_release(name); -+} -+ -+static int -+skeldma_parse_lcore(const char *key __rte_unused, -+ const char *value, -+ void *opaque) -+{ -+ int lcore_id = atoi(value); -+ if (lcore_id >= 0 && lcore_id < RTE_MAX_LCORE) -+ *(int *)opaque = lcore_id; -+ return 0; -+} -+ -+static void -+skeldma_parse_vdev_args(struct rte_vdev_device *vdev, int *lcore_id) -+{ -+ static const char *const args[] = { -+ SKELDMA_ARG_LCORE, -+ NULL -+ }; -+ -+ struct rte_kvargs *kvlist; -+ const char *params; -+ -+ params = rte_vdev_device_args(vdev); -+ if (params == NULL || params[0] == '\0') -+ return; -+ -+ kvlist = rte_kvargs_parse(params, args); -+ if (!kvlist) -+ return; -+ -+ (void)rte_kvargs_process(kvlist, SKELDMA_ARG_LCORE, -+ skeldma_parse_lcore, lcore_id); -+ SKELDMA_LOG(INFO, "Parse lcore_id = %d", *lcore_id); -+ -+ rte_kvargs_free(kvlist); -+} -+ -+static int -+skeldma_probe(struct rte_vdev_device *vdev) -+{ -+ const char *name; -+ int lcore_id = -1; -+ int ret; -+ -+ name = rte_vdev_device_name(vdev); -+ if (name == NULL) -+ return -EINVAL; -+ -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ SKELDMA_LOG(ERR, "Multiple process not supported for %s", name); -+ return -EINVAL; -+ } -+ -+ /* More than one instance is not supported */ -+ if (skeldma_count > 0) { -+ SKELDMA_LOG(ERR, "Multiple instance not supported for %s", -+ name); -+ return -EINVAL; -+ } -+ -+ skeldma_parse_vdev_args(vdev, &lcore_id); -+ -+ ret = skeldma_create(name, vdev, lcore_id); -+ if (ret >= 0) { -+ SKELDMA_LOG(INFO, "Create %s dmadev with lcore-id %d", -+ name, lcore_id); -+ skeldma_count = 1; -+ } -+ -+ return ret < 0 ? ret : 0; -+} -+ -+static int -+skeldma_remove(struct rte_vdev_device *vdev) -+{ -+ const char *name; -+ int ret; -+ -+ name = rte_vdev_device_name(vdev); -+ if (name == NULL) -+ return -1; -+ -+ ret = skeldma_destroy(name); -+ if (!ret) { -+ skeldma_count = 0; -+ SKELDMA_LOG(INFO, "Remove %s dmadev", name); -+ } -+ -+ return ret; -+} -+ -+static struct rte_vdev_driver skeldma_pmd_drv = { -+ .probe = skeldma_probe, -+ .remove = skeldma_remove, -+}; -+ -+RTE_PMD_REGISTER_VDEV(dma_skeleton, skeldma_pmd_drv); -+RTE_PMD_REGISTER_PARAM_STRING(dma_skeleton, -+ SKELDMA_ARG_LCORE "= "); -diff --git a/drivers/dma/skeleton/skeleton_dmadev.h b/drivers/dma/skeleton/skeleton_dmadev.h -new file mode 100644 -index 000000000..91eb5460f ---- /dev/null -+++ b/drivers/dma/skeleton/skeleton_dmadev.h -@@ -0,0 +1,61 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ */ -+ -+#ifndef SKELETON_DMADEV_H -+#define SKELETON_DMADEV_H -+ -+#include -+ -+#include -+ -+#define SKELDMA_ARG_LCORE "lcore" -+ -+struct skeldma_desc { -+ void *src; -+ void *dst; -+ uint32_t len; -+ uint16_t ridx; /* ring idx */ -+}; -+ -+struct skeldma_hw { -+ int lcore_id; /* cpucopy task affinity core */ -+ int socket_id; -+ pthread_t thread; /* cpucopy task thread */ -+ volatile int exit_flag; /* cpucopy task exit flag */ -+ -+ struct skeldma_desc *desc_mem; -+ -+ /* Descriptor ring state machine: -+ * -+ * ----------- enqueue without submit ----------- -+ * | empty |------------------------------->| pending | -+ * -----------\ ----------- -+ * ^ \------------ | -+ * | | |submit doorbell -+ * | | | -+ * | |enqueue with submit | -+ * |get completed |------------------| | -+ * | | | -+ * | v v -+ * ----------- cpucopy thread working ----------- -+ * |completed|<-------------------------------| running | -+ * ----------- ----------- -+ */ -+ struct rte_ring *desc_empty; -+ struct rte_ring *desc_pending; -+ struct rte_ring *desc_running; -+ struct rte_ring *desc_completed; -+ -+ /* Cache delimiter for dataplane API's operation data */ -+ char cache1 __rte_cache_aligned; -+ uint16_t ridx; /* ring idx */ -+ uint64_t submitted_count; -+ -+ /* Cache delimiter for cpucopy thread's operation data */ -+ char cache2 __rte_cache_aligned; -+ volatile uint32_t zero_req_count; -+ uint64_t completed_count; -+}; -+ -+#endif /* SKELETON_DMADEV_H */ -diff --git a/drivers/dma/skeleton/version.map b/drivers/dma/skeleton/version.map -new file mode 100644 -index 000000000..c2e0723b4 ---- /dev/null -+++ b/drivers/dma/skeleton/version.map -@@ -0,0 +1,3 @@ -+DPDK_22 { -+ local: *; -+}; -diff --git a/drivers/meson.build b/drivers/meson.build -index f9febc579..996df2210 100644 ---- a/drivers/meson.build -+++ b/drivers/meson.build -@@ -16,6 +16,7 @@ subdirs = [ - 'vdpa', # depends on common, bus and mempool. - 'event', # depends on common, bus, mempool and net. - 'baseband', # depends on common and bus. -+ 'dma' - ] - - disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'), -diff --git a/examples/dma/Makefile b/examples/dma/Makefile -new file mode 100644 -index 000000000..59af6478b ---- /dev/null -+++ b/examples/dma/Makefile -@@ -0,0 +1,51 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2019 Intel Corporation -+ -+# binary name -+APP = dmafwd -+ -+# all source are stored in SRCS-y -+SRCS-y := dmafwd.c -+ -+PKGCONF ?= pkg-config -+ -+# Build using pkg-config variables if possible -+ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0) -+$(error "no installation of DPDK found") -+endif -+ -+all: shared -+.PHONY: shared static -+shared: build/$(APP)-shared -+ ln -sf $(APP)-shared build/$(APP) -+static: build/$(APP)-static -+ ln -sf $(APP)-static build/$(APP) -+ -+PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null) -+CFLAGS += -O3 $(shell $(PKGCONF) --cflags libdpdk) -+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk) -+LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk) -+ -+ifeq ($(MAKECMDGOALS),static) -+# check for broken pkg-config -+ifeq ($(shell echo $(LDFLAGS_STATIC) | grep 'whole-archive.*l:lib.*no-whole-archive'),) -+$(warning "pkg-config output list does not contain drivers between 'whole-archive'/'no-whole-archive' flags.") -+$(error "Cannot generate statically-linked binaries with this version of pkg-config") -+endif -+endif -+ -+CFLAGS += -DALLOW_EXPERIMENTAL_API -+ -+build/$(APP)-shared: $(SRCS-y) Makefile $(PC_FILE) | build -+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) -+ -+build/$(APP)-static: $(SRCS-y) Makefile $(PC_FILE) | build -+ $(CC) $(CFLAGS) $(SRCS-y) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC) -+ -+build: -+ @mkdir -p $@ -+ -+.PHONY: clean -+clean: -+ rm -f build/$(APP) build/$(APP)-static build/$(APP)-shared -+ test -d build && rmdir -p build || true -diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c -new file mode 100644 -index 000000000..9ff2593bb ---- /dev/null -+++ b/examples/dma/dmafwd.c -@@ -0,0 +1,1105 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2019-2021 Intel Corporation -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+ -+/* size of ring used for software copying between rx and tx. */ -+#define RTE_LOGTYPE_DMA RTE_LOGTYPE_USER1 -+#define MAX_PKT_BURST 32 -+#define MEMPOOL_CACHE_SIZE 512 -+#define MIN_POOL_SIZE 65536U -+#define CMD_LINE_OPT_MAC_UPDATING "mac-updating" -+#define CMD_LINE_OPT_NO_MAC_UPDATING "no-mac-updating" -+#define CMD_LINE_OPT_PORTMASK "portmask" -+#define CMD_LINE_OPT_NB_QUEUE "nb-queue" -+#define CMD_LINE_OPT_COPY_TYPE "copy-type" -+#define CMD_LINE_OPT_RING_SIZE "ring-size" -+#define CMD_LINE_OPT_BATCH_SIZE "dma-batch-size" -+#define CMD_LINE_OPT_FRAME_SIZE "max-frame-size" -+#define CMD_LINE_OPT_STATS_INTERVAL "stats-interval" -+ -+/* configurable number of RX/TX ring descriptors */ -+#define RX_DEFAULT_RINGSIZE 1024 -+#define TX_DEFAULT_RINGSIZE 1024 -+ -+/* max number of RX queues per port */ -+#define MAX_RX_QUEUES_COUNT 8 -+ -+struct rxtx_port_config { -+ /* common config */ -+ uint16_t rxtx_port; -+ uint16_t nb_queues; -+ /* for software copy mode */ -+ struct rte_ring *rx_to_tx_ring; -+ /* for dmadev HW copy mode */ -+ uint16_t dmadev_ids[MAX_RX_QUEUES_COUNT]; -+}; -+ -+/* Configuring ports and number of assigned lcores in struct. 8< */ -+struct rxtx_transmission_config { -+ struct rxtx_port_config ports[RTE_MAX_ETHPORTS]; -+ uint16_t nb_ports; -+ uint16_t nb_lcores; -+}; -+/* >8 End of configuration of ports and number of assigned lcores. */ -+ -+/* per-port statistics struct */ -+struct dma_port_statistics { -+ uint64_t rx[RTE_MAX_ETHPORTS]; -+ uint64_t tx[RTE_MAX_ETHPORTS]; -+ uint64_t tx_dropped[RTE_MAX_ETHPORTS]; -+ uint64_t copy_dropped[RTE_MAX_ETHPORTS]; -+}; -+struct dma_port_statistics port_statistics; -+struct total_statistics { -+ uint64_t total_packets_dropped; -+ uint64_t total_packets_tx; -+ uint64_t total_packets_rx; -+ uint64_t total_submitted; -+ uint64_t total_completed; -+ uint64_t total_failed; -+}; -+ -+typedef enum copy_mode_t { -+#define COPY_MODE_SW "sw" -+ COPY_MODE_SW_NUM, -+#define COPY_MODE_DMA "hw" -+ COPY_MODE_DMA_NUM, -+ COPY_MODE_INVALID_NUM, -+ COPY_MODE_SIZE_NUM = COPY_MODE_INVALID_NUM -+} copy_mode_t; -+ -+/* mask of enabled ports */ -+static uint32_t dma_enabled_port_mask; -+ -+/* number of RX queues per port */ -+static uint16_t nb_queues = 1; -+ -+/* MAC updating enabled by default. */ -+static int mac_updating = 1; -+ -+/* hardare copy mode enabled by default. */ -+static copy_mode_t copy_mode = COPY_MODE_DMA_NUM; -+ -+/* size of descriptor ring for hardware copy mode or -+ * rte_ring for software copy mode -+ */ -+static unsigned short ring_size = 2048; -+ -+/* interval, in seconds, between stats prints */ -+static unsigned short stats_interval = 1; -+/* global mbuf arrays for tracking DMA bufs */ -+#define MBUF_RING_SIZE 2048 -+#define MBUF_RING_MASK (MBUF_RING_SIZE - 1) -+struct dma_bufs { -+ struct rte_mbuf *bufs[MBUF_RING_SIZE]; -+ struct rte_mbuf *copies[MBUF_RING_SIZE]; -+ uint16_t sent; -+}; -+static struct dma_bufs dma_bufs[RTE_DMADEV_DEFAULT_MAX]; -+ -+/* global transmission config */ -+struct rxtx_transmission_config cfg; -+ -+/* configurable number of RX/TX ring descriptors */ -+static uint16_t nb_rxd = RX_DEFAULT_RINGSIZE; -+static uint16_t nb_txd = TX_DEFAULT_RINGSIZE; -+ -+static volatile bool force_quit; -+ -+static uint32_t dma_batch_sz = MAX_PKT_BURST; -+static uint32_t max_frame_size = RTE_ETHER_MAX_LEN; -+ -+/* ethernet addresses of ports */ -+static struct rte_ether_addr dma_ports_eth_addr[RTE_MAX_ETHPORTS]; -+ -+static struct rte_eth_dev_tx_buffer *tx_buffer[RTE_MAX_ETHPORTS]; -+struct rte_mempool *dma_pktmbuf_pool; -+ -+/* Print out statistics for one port. */ -+static void -+print_port_stats(uint16_t port_id) -+{ -+ printf("\nStatistics for port %u ------------------------------" -+ "\nPackets sent: %34"PRIu64 -+ "\nPackets received: %30"PRIu64 -+ "\nPackets dropped on tx: %25"PRIu64 -+ "\nPackets dropped on copy: %23"PRIu64, -+ port_id, -+ port_statistics.tx[port_id], -+ port_statistics.rx[port_id], -+ port_statistics.tx_dropped[port_id], -+ port_statistics.copy_dropped[port_id]); -+} -+ -+/* Print out statistics for one dmadev device. */ -+static void -+print_dmadev_stats(uint32_t dev_id, struct rte_dma_stats stats) -+{ -+ printf("\nDMA channel %u", dev_id); -+ printf("\n\t Total submitted ops: %"PRIu64"", stats.submitted); -+ printf("\n\t Total completed ops: %"PRIu64"", stats.completed); -+ printf("\n\t Total failed ops: %"PRIu64"", stats.errors); -+} -+ -+static void -+print_total_stats(struct total_statistics *ts) -+{ -+ printf("\nAggregate statistics ===============================" -+ "\nTotal packets Tx: %22"PRIu64" [pkt/s]" -+ "\nTotal packets Rx: %22"PRIu64" [pkt/s]" -+ "\nTotal packets dropped: %17"PRIu64" [pkt/s]", -+ ts->total_packets_tx / stats_interval, -+ ts->total_packets_rx / stats_interval, -+ ts->total_packets_dropped / stats_interval); -+ -+ if (copy_mode == COPY_MODE_DMA_NUM) { -+ printf("\nTotal submitted ops: %19"PRIu64" [ops/s]" -+ "\nTotal completed ops: %19"PRIu64" [ops/s]" -+ "\nTotal failed ops: %22"PRIu64" [ops/s]", -+ ts->total_submitted / stats_interval, -+ ts->total_completed / stats_interval, -+ ts->total_failed / stats_interval); -+ } -+ -+ printf("\n====================================================\n"); -+} -+ -+/* Print out statistics on packets dropped. */ -+static void -+print_stats(char *prgname) -+{ -+ struct total_statistics ts, delta_ts; -+ struct rte_dma_stats stats = {0}; -+ uint32_t i, port_id, dev_id; -+ char status_string[255]; /* to print at the top of the output */ -+ int status_strlen; -+ -+ const char clr[] = { 27, '[', '2', 'J', '\0' }; -+ const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' }; -+ -+ status_strlen = snprintf(status_string, sizeof(status_string), -+ "%s, ", prgname); -+ status_strlen += snprintf(status_string + status_strlen, -+ sizeof(status_string) - status_strlen, -+ "Worker Threads = %d, ", -+ rte_lcore_count() > 2 ? 2 : 1); -+ status_strlen += snprintf(status_string + status_strlen, -+ sizeof(status_string) - status_strlen, -+ "Copy Mode = %s,\n", copy_mode == COPY_MODE_SW_NUM ? -+ COPY_MODE_SW : COPY_MODE_DMA); -+ status_strlen += snprintf(status_string + status_strlen, -+ sizeof(status_string) - status_strlen, -+ "Updating MAC = %s, ", mac_updating ? -+ "enabled" : "disabled"); -+ status_strlen += snprintf(status_string + status_strlen, -+ sizeof(status_string) - status_strlen, -+ "Rx Queues = %d, ", nb_queues); -+ status_strlen += snprintf(status_string + status_strlen, -+ sizeof(status_string) - status_strlen, -+ "Ring Size = %d", ring_size); -+ -+ memset(&ts, 0, sizeof(struct total_statistics)); -+ -+ while (!force_quit) { -+ /* Sleep for "stats_interval" seconds each round - init sleep allows reading -+ * messages from app startup. -+ */ -+ sleep(stats_interval); -+ -+ /* Clear screen and move to top left */ -+ printf("%s%s", clr, topLeft); -+ -+ memset(&delta_ts, 0, sizeof(struct total_statistics)); -+ -+ printf("%s\n", status_string); -+ -+ for (i = 0; i < cfg.nb_ports; i++) { -+ port_id = cfg.ports[i].rxtx_port; -+ print_port_stats(port_id); -+ -+ delta_ts.total_packets_dropped += -+ port_statistics.tx_dropped[port_id] -+ + port_statistics.copy_dropped[port_id]; -+ delta_ts.total_packets_tx += -+ port_statistics.tx[port_id]; -+ delta_ts.total_packets_rx += -+ port_statistics.rx[port_id]; -+ -+ if (copy_mode == COPY_MODE_DMA_NUM) { -+ uint32_t j; -+ -+ for (j = 0; j < cfg.ports[i].nb_queues; j++) { -+ dev_id = cfg.ports[i].dmadev_ids[j]; -+ rte_dma_stats_get(dev_id, 0, &stats); -+ print_dmadev_stats(dev_id, stats); -+ -+ delta_ts.total_submitted += stats.submitted; -+ delta_ts.total_completed += stats.completed; -+ delta_ts.total_failed += stats.errors; -+ } -+ } -+ } -+ -+ delta_ts.total_packets_tx -= ts.total_packets_tx; -+ delta_ts.total_packets_rx -= ts.total_packets_rx; -+ delta_ts.total_packets_dropped -= ts.total_packets_dropped; -+ delta_ts.total_submitted -= ts.total_submitted; -+ delta_ts.total_completed -= ts.total_completed; -+ delta_ts.total_failed -= ts.total_failed; -+ -+ printf("\n"); -+ print_total_stats(&delta_ts); -+ -+ fflush(stdout); -+ -+ ts.total_packets_tx += delta_ts.total_packets_tx; -+ ts.total_packets_rx += delta_ts.total_packets_rx; -+ ts.total_packets_dropped += delta_ts.total_packets_dropped; -+ ts.total_submitted += delta_ts.total_submitted; -+ ts.total_completed += delta_ts.total_completed; -+ ts.total_failed += delta_ts.total_failed; -+ } -+} -+ -+static void -+update_mac_addrs(struct rte_mbuf *m, uint32_t dest_portid) -+{ -+ struct rte_ether_hdr *eth; -+ void *tmp; -+ -+ eth = rte_pktmbuf_mtod(m, struct rte_ether_hdr *); -+ -+ /* 02:00:00:00:00:xx - overwriting 2 bytes of source address but -+ * it's acceptable cause it gets overwritten by rte_ether_addr_copy -+ */ -+ tmp = ð->d_addr.addr_bytes[0]; -+ *((uint64_t *)tmp) = 0x000000000002 + ((uint64_t)dest_portid << 40); -+ -+ /* src addr */ -+ rte_ether_addr_copy(&dma_ports_eth_addr[dest_portid], ð->s_addr); -+} -+ -+/* Perform packet copy there is a user-defined function. 8< */ -+static inline void -+pktmbuf_metadata_copy(const struct rte_mbuf *src, struct rte_mbuf *dst) -+{ -+ dst->data_off = src->data_off; -+ memcpy(&dst->rx_descriptor_fields1, &src->rx_descriptor_fields1, -+ offsetof(struct rte_mbuf, buf_len) - -+ offsetof(struct rte_mbuf, rx_descriptor_fields1)); -+} -+ -+/* Copy packet data */ -+static inline void -+pktmbuf_sw_copy(struct rte_mbuf *src, struct rte_mbuf *dst) -+{ -+ rte_memcpy(rte_pktmbuf_mtod(dst, char *), -+ rte_pktmbuf_mtod(src, char *), src->data_len); -+} -+/* >8 End of perform packet copy there is a user-defined function. */ -+ -+static uint32_t -+dma_enqueue_packets(struct rte_mbuf *pkts[], struct rte_mbuf *pkts_copy[], -+ uint32_t nb_rx, uint16_t dev_id) -+{ -+ struct dma_bufs *dma = &dma_bufs[dev_id]; -+ int ret; -+ uint32_t i; -+ -+ for (i = 0; i < nb_rx; i++) { -+ /* Perform data copy */ -+ ret = rte_dma_copy(dev_id, 0, -+ rte_pktmbuf_iova(pkts[i]), -+ rte_pktmbuf_iova(pkts_copy[i]), -+ rte_pktmbuf_data_len(pkts[i]), 0); -+ -+ if (ret < 0) -+ break; -+ -+ dma->bufs[ret & MBUF_RING_MASK] = pkts[i]; -+ dma->copies[ret & MBUF_RING_MASK] = pkts_copy[i]; -+ } -+ -+ ret = i; -+ return ret; -+} -+ -+static inline uint32_t -+dma_enqueue(struct rte_mbuf *pkts[], struct rte_mbuf *pkts_copy[], -+ uint32_t num, uint32_t step, uint16_t dev_id) -+{ -+ uint32_t i, k, m, n; -+ -+ k = 0; -+ for (i = 0; i < num; i += m) { -+ -+ m = RTE_MIN(step, num - i); -+ n = dma_enqueue_packets(pkts + i, pkts_copy + i, m, dev_id); -+ k += n; -+ if (n > 0) -+ rte_dma_submit(dev_id, 0); -+ -+ /* don't try to enqueue more if HW queue is full */ -+ if (n != m) -+ break; -+ } -+ -+ return k; -+} -+ -+static inline uint32_t -+dma_dequeue(struct rte_mbuf *src[], struct rte_mbuf *dst[], uint32_t num, -+ uint16_t dev_id) -+{ -+ struct dma_bufs *dma = &dma_bufs[dev_id]; -+ uint16_t nb_dq, filled; -+ /* Dequeue the mbufs from DMA device. Since all memory -+ * is DPDK pinned memory and therefore all addresses should -+ * be valid, we don't check for copy errors -+ */ -+ nb_dq = rte_dma_completed(dev_id, 0, num, NULL, NULL); -+ -+ /* Return early if no work to do */ -+ if (unlikely(nb_dq == 0)) -+ return nb_dq; -+ -+ /* Populate pkts_copy with the copies bufs from dma->copies for tx */ -+ for (filled = 0; filled < nb_dq; filled++) { -+ src[filled] = dma->bufs[(dma->sent + filled) & MBUF_RING_MASK]; -+ dst[filled] = dma->copies[(dma->sent + filled) & MBUF_RING_MASK]; -+ } -+ dma->sent += nb_dq; -+ -+ return filled; -+ -+} -+ -+/* Receive packets on one port and enqueue to dmadev or rte_ring. 8< */ -+static void -+dma_rx_port(struct rxtx_port_config *rx_config) -+{ -+ int32_t ret; -+ uint32_t nb_rx, nb_enq, i, j; -+ struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; -+ struct rte_mbuf *pkts_burst_copy[MAX_PKT_BURST]; -+ -+ for (i = 0; i < rx_config->nb_queues; i++) { -+ -+ nb_rx = rte_eth_rx_burst(rx_config->rxtx_port, i, -+ pkts_burst, MAX_PKT_BURST); -+ -+ if (nb_rx == 0) -+ continue; -+ -+ port_statistics.rx[rx_config->rxtx_port] += nb_rx; -+ -+ ret = rte_mempool_get_bulk(dma_pktmbuf_pool, -+ (void *)pkts_burst_copy, nb_rx); -+ -+ if (unlikely(ret < 0)) -+ rte_exit(EXIT_FAILURE, -+ "Unable to allocate memory.\n"); -+ -+ for (j = 0; j < nb_rx; j++) -+ pktmbuf_metadata_copy(pkts_burst[j], -+ pkts_burst_copy[j]); -+ -+ if (copy_mode == COPY_MODE_DMA_NUM) { -+ /* enqueue packets for hardware copy */ -+ nb_enq = dma_enqueue(pkts_burst, pkts_burst_copy, -+ nb_rx, dma_batch_sz, rx_config->dmadev_ids[i]); -+ -+ /* free any not enqueued packets. */ -+ rte_mempool_put_bulk(dma_pktmbuf_pool, -+ (void *)&pkts_burst[nb_enq], -+ nb_rx - nb_enq); -+ rte_mempool_put_bulk(dma_pktmbuf_pool, -+ (void *)&pkts_burst_copy[nb_enq], -+ nb_rx - nb_enq); -+ -+ port_statistics.copy_dropped[rx_config->rxtx_port] += -+ (nb_rx - nb_enq); -+ -+ /* get completed copies */ -+ nb_rx = dma_dequeue(pkts_burst, pkts_burst_copy, -+ MAX_PKT_BURST, rx_config->dmadev_ids[i]); -+ } else { -+ /* Perform packet software copy, free source packets */ -+ for (j = 0; j < nb_rx; j++) -+ pktmbuf_sw_copy(pkts_burst[j], -+ pkts_burst_copy[j]); -+ } -+ -+ rte_mempool_put_bulk(dma_pktmbuf_pool, -+ (void *)pkts_burst, nb_rx); -+ -+ nb_enq = rte_ring_enqueue_burst(rx_config->rx_to_tx_ring, -+ (void *)pkts_burst_copy, nb_rx, NULL); -+ -+ /* Free any not enqueued packets. */ -+ rte_mempool_put_bulk(dma_pktmbuf_pool, -+ (void *)&pkts_burst_copy[nb_enq], -+ nb_rx - nb_enq); -+ -+ port_statistics.copy_dropped[rx_config->rxtx_port] += -+ (nb_rx - nb_enq); -+ } -+} -+/* >8 End of receive packets on one port and enqueue to dmadev or rte_ring. */ -+ -+/* Transmit packets from dmadev/rte_ring for one port. 8< */ -+static void -+dma_tx_port(struct rxtx_port_config *tx_config) -+{ -+ uint32_t i, j, nb_dq, nb_tx; -+ struct rte_mbuf *mbufs[MAX_PKT_BURST]; -+ -+ for (i = 0; i < tx_config->nb_queues; i++) { -+ -+ /* Dequeue the mbufs from rx_to_tx_ring. */ -+ nb_dq = rte_ring_dequeue_burst(tx_config->rx_to_tx_ring, -+ (void *)mbufs, MAX_PKT_BURST, NULL); -+ if (nb_dq == 0) -+ continue; -+ -+ /* Update macs if enabled */ -+ if (mac_updating) { -+ for (j = 0; j < nb_dq; j++) -+ update_mac_addrs(mbufs[j], -+ tx_config->rxtx_port); -+ } -+ -+ nb_tx = rte_eth_tx_burst(tx_config->rxtx_port, 0, -+ (void *)mbufs, nb_dq); -+ -+ port_statistics.tx[tx_config->rxtx_port] += nb_tx; -+ -+ /* Free any unsent packets. */ -+ if (unlikely(nb_tx < nb_dq)) -+ rte_mempool_put_bulk(dma_pktmbuf_pool, -+ (void *)&mbufs[nb_tx], nb_dq - nb_tx); -+ } -+} -+/* >8 End of transmitting packets from dmadev. */ -+ -+/* Main rx processing loop for dmadev. */ -+static void -+rx_main_loop(void) -+{ -+ uint16_t i; -+ uint16_t nb_ports = cfg.nb_ports; -+ -+ RTE_LOG(INFO, DMA, "Entering main rx loop for copy on lcore %u\n", -+ rte_lcore_id()); -+ -+ while (!force_quit) -+ for (i = 0; i < nb_ports; i++) -+ dma_rx_port(&cfg.ports[i]); -+} -+ -+/* Main tx processing loop for hardware copy. */ -+static void -+tx_main_loop(void) -+{ -+ uint16_t i; -+ uint16_t nb_ports = cfg.nb_ports; -+ -+ RTE_LOG(INFO, DMA, "Entering main tx loop for copy on lcore %u\n", -+ rte_lcore_id()); -+ -+ while (!force_quit) -+ for (i = 0; i < nb_ports; i++) -+ dma_tx_port(&cfg.ports[i]); -+} -+ -+/* Main rx and tx loop if only one worker lcore available */ -+static void -+rxtx_main_loop(void) -+{ -+ uint16_t i; -+ uint16_t nb_ports = cfg.nb_ports; -+ -+ RTE_LOG(INFO, DMA, "Entering main rx and tx loop for copy on" -+ " lcore %u\n", rte_lcore_id()); -+ -+ while (!force_quit) -+ for (i = 0; i < nb_ports; i++) { -+ dma_rx_port(&cfg.ports[i]); -+ dma_tx_port(&cfg.ports[i]); -+ } -+} -+ -+/* Start processing for each lcore. 8< */ -+static void start_forwarding_cores(void) -+{ -+ uint32_t lcore_id = rte_lcore_id(); -+ -+ RTE_LOG(INFO, DMA, "Entering %s on lcore %u\n", -+ __func__, rte_lcore_id()); -+ -+ if (cfg.nb_lcores == 1) { -+ lcore_id = rte_get_next_lcore(lcore_id, true, true); -+ rte_eal_remote_launch((lcore_function_t *)rxtx_main_loop, -+ NULL, lcore_id); -+ } else if (cfg.nb_lcores > 1) { -+ lcore_id = rte_get_next_lcore(lcore_id, true, true); -+ rte_eal_remote_launch((lcore_function_t *)rx_main_loop, -+ NULL, lcore_id); -+ -+ lcore_id = rte_get_next_lcore(lcore_id, true, true); -+ rte_eal_remote_launch((lcore_function_t *)tx_main_loop, NULL, -+ lcore_id); -+ } -+} -+/* >8 End of starting to processfor each lcore. */ -+ -+/* Display usage */ -+static void -+dma_usage(const char *prgname) -+{ -+ printf("%s [EAL options] -- -p PORTMASK [-q NQ]\n" -+ " -b --dma-batch-size: number of requests per DMA batch\n" -+ " -f --max-frame-size: max frame size\n" -+ " -p --portmask: hexadecimal bitmask of ports to configure\n" -+ " -q NQ: number of RX queues per port (default is 1)\n" -+ " --[no-]mac-updating: Enable or disable MAC addresses updating (enabled by default)\n" -+ " When enabled:\n" -+ " - The source MAC address is replaced by the TX port MAC address\n" -+ " - The destination MAC address is replaced by 02:00:00:00:00:TX_PORT_ID\n" -+ " -c --copy-type CT: type of copy: sw|hw\n" -+ " -s --ring-size RS: size of dmadev descriptor ring for hardware copy mode or rte_ring for software copy mode\n" -+ " -i --stats-interval SI: interval, in seconds, between stats prints (default is 1)\n", -+ prgname); -+} -+ -+static int -+dma_parse_portmask(const char *portmask) -+{ -+ char *end = NULL; -+ unsigned long pm; -+ -+ /* Parse hexadecimal string */ -+ pm = strtoul(portmask, &end, 16); -+ if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) -+ return 0; -+ -+ return pm; -+} -+ -+static copy_mode_t -+dma_parse_copy_mode(const char *copy_mode) -+{ -+ if (strcmp(copy_mode, COPY_MODE_SW) == 0) -+ return COPY_MODE_SW_NUM; -+ else if (strcmp(copy_mode, COPY_MODE_DMA) == 0) -+ return COPY_MODE_DMA_NUM; -+ -+ return COPY_MODE_INVALID_NUM; -+} -+ -+/* Parse the argument given in the command line of the application */ -+static int -+dma_parse_args(int argc, char **argv, unsigned int nb_ports) -+{ -+ static const char short_options[] = -+ "b:" /* dma batch size */ -+ "c:" /* copy type (sw|hw) */ -+ "f:" /* max frame size */ -+ "p:" /* portmask */ -+ "q:" /* number of RX queues per port */ -+ "s:" /* ring size */ -+ "i:" /* interval, in seconds, between stats prints */ -+ ; -+ -+ static const struct option lgopts[] = { -+ {CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1}, -+ {CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0}, -+ {CMD_LINE_OPT_PORTMASK, required_argument, NULL, 'p'}, -+ {CMD_LINE_OPT_NB_QUEUE, required_argument, NULL, 'q'}, -+ {CMD_LINE_OPT_COPY_TYPE, required_argument, NULL, 'c'}, -+ {CMD_LINE_OPT_RING_SIZE, required_argument, NULL, 's'}, -+ {CMD_LINE_OPT_BATCH_SIZE, required_argument, NULL, 'b'}, -+ {CMD_LINE_OPT_FRAME_SIZE, required_argument, NULL, 'f'}, -+ {CMD_LINE_OPT_STATS_INTERVAL, required_argument, NULL, 'i'}, -+ {NULL, 0, 0, 0} -+ }; -+ -+ const unsigned int default_port_mask = (1 << nb_ports) - 1; -+ int opt, ret; -+ char **argvopt; -+ int option_index; -+ char *prgname = argv[0]; -+ -+ dma_enabled_port_mask = default_port_mask; -+ argvopt = argv; -+ -+ while ((opt = getopt_long(argc, argvopt, short_options, -+ lgopts, &option_index)) != EOF) { -+ -+ switch (opt) { -+ case 'b': -+ dma_batch_sz = atoi(optarg); -+ if (dma_batch_sz > MAX_PKT_BURST) { -+ printf("Invalid dma batch size, %s.\n", optarg); -+ dma_usage(prgname); -+ return -1; -+ } -+ break; -+ case 'f': -+ max_frame_size = atoi(optarg); -+ if (max_frame_size > RTE_ETHER_MAX_JUMBO_FRAME_LEN) { -+ printf("Invalid max frame size, %s.\n", optarg); -+ dma_usage(prgname); -+ return -1; -+ } -+ break; -+ -+ /* portmask */ -+ case 'p': -+ dma_enabled_port_mask = dma_parse_portmask(optarg); -+ if (dma_enabled_port_mask & ~default_port_mask || -+ dma_enabled_port_mask <= 0) { -+ printf("Invalid portmask, %s, suggest 0x%x\n", -+ optarg, default_port_mask); -+ dma_usage(prgname); -+ return -1; -+ } -+ break; -+ -+ case 'q': -+ nb_queues = atoi(optarg); -+ if (nb_queues == 0 || nb_queues > MAX_RX_QUEUES_COUNT) { -+ printf("Invalid RX queues number %s. Max %u\n", -+ optarg, MAX_RX_QUEUES_COUNT); -+ dma_usage(prgname); -+ return -1; -+ } -+ break; -+ -+ case 'c': -+ copy_mode = dma_parse_copy_mode(optarg); -+ if (copy_mode == COPY_MODE_INVALID_NUM) { -+ printf("Invalid copy type. Use: sw, hw\n"); -+ dma_usage(prgname); -+ return -1; -+ } -+ break; -+ -+ case 's': -+ ring_size = atoi(optarg); -+ if (ring_size == 0) { -+ printf("Invalid ring size, %s.\n", optarg); -+ dma_usage(prgname); -+ return -1; -+ } -+ /* ring_size must be less-than or equal to MBUF_RING_SIZE -+ * to avoid overwriting bufs -+ */ -+ if (ring_size > MBUF_RING_SIZE) { -+ printf("Max ring_size is %d, setting ring_size to max", -+ MBUF_RING_SIZE); -+ ring_size = MBUF_RING_SIZE; -+ } -+ break; -+ -+ case 'i': -+ stats_interval = atoi(optarg); -+ if (stats_interval == 0) { -+ printf("Invalid stats interval, setting to 1\n"); -+ stats_interval = 1; /* set to default */ -+ } -+ break; -+ -+ /* long options */ -+ case 0: -+ break; -+ -+ default: -+ dma_usage(prgname); -+ return -1; -+ } -+ } -+ -+ printf("MAC updating %s\n", mac_updating ? "enabled" : "disabled"); -+ if (optind >= 0) -+ argv[optind - 1] = prgname; -+ -+ ret = optind - 1; -+ optind = 1; /* reset getopt lib */ -+ return ret; -+} -+ -+/* check link status, return true if at least one port is up */ -+static int -+check_link_status(uint32_t port_mask) -+{ -+ uint16_t portid; -+ struct rte_eth_link link; -+ int ret, link_status = 0; -+ char link_status_text[RTE_ETH_LINK_MAX_STR_LEN]; -+ -+ printf("\nChecking link status\n"); -+ RTE_ETH_FOREACH_DEV(portid) { -+ if ((port_mask & (1 << portid)) == 0) -+ continue; -+ -+ memset(&link, 0, sizeof(link)); -+ ret = rte_eth_link_get(portid, &link); -+ if (ret < 0) { -+ printf("Port %u link get failed: err=%d\n", -+ portid, ret); -+ continue; -+ } -+ -+ /* Print link status */ -+ rte_eth_link_to_str(link_status_text, -+ sizeof(link_status_text), &link); -+ printf("Port %d %s\n", portid, link_status_text); -+ -+ if (link.link_status) -+ link_status = 1; -+ } -+ return link_status; -+} -+ -+/* Configuration of device. 8< */ -+static void -+configure_dmadev_queue(uint32_t dev_id) -+{ -+ struct rte_dma_info info; -+ struct rte_dma_conf dev_config = { .nb_vchans = 1 }; -+ struct rte_dma_vchan_conf qconf = { -+ .direction = RTE_DMA_DIR_MEM_TO_MEM, -+ .nb_desc = ring_size -+ }; -+ uint16_t vchan = 0; -+ -+ if (rte_dma_configure(dev_id, &dev_config) != 0) -+ rte_exit(EXIT_FAILURE, "Error with rte_dma_configure()\n"); -+ -+ if (rte_dma_vchan_setup(dev_id, vchan, &qconf) != 0) { -+ printf("Error with queue configuration\n"); -+ rte_panic(); -+ } -+ rte_dma_info_get(dev_id, &info); -+ if (info.nb_vchans != 1) { -+ printf("Error, no configured queues reported on device id %u\n", dev_id); -+ rte_panic(); -+ } -+ if (rte_dma_start(dev_id) != 0) -+ rte_exit(EXIT_FAILURE, "Error with rte_dma_start()\n"); -+} -+/* >8 End of configuration of device. */ -+ -+/* Using dmadev API functions. 8< */ -+static void -+assign_dmadevs(void) -+{ -+ uint16_t nb_dmadev = 0; -+ int16_t dev_id = rte_dma_next_dev(0); -+ uint32_t i, j; -+ -+ for (i = 0; i < cfg.nb_ports; i++) { -+ for (j = 0; j < cfg.ports[i].nb_queues; j++) { -+ if (dev_id == -1) -+ goto end; -+ -+ cfg.ports[i].dmadev_ids[j] = dev_id; -+ configure_dmadev_queue(cfg.ports[i].dmadev_ids[j]); -+ dev_id = rte_dma_next_dev(dev_id + 1); -+ ++nb_dmadev; -+ } -+ } -+end: -+ if (nb_dmadev < cfg.nb_ports * cfg.ports[0].nb_queues) -+ rte_exit(EXIT_FAILURE, -+ "Not enough dmadevs (%u) for all queues (%u).\n", -+ nb_dmadev, cfg.nb_ports * cfg.ports[0].nb_queues); -+ RTE_LOG(INFO, DMA, "Number of used dmadevs: %u.\n", nb_dmadev); -+} -+/* >8 End of using dmadev API functions. */ -+ -+/* Assign ring structures for packet exchanging. 8< */ -+static void -+assign_rings(void) -+{ -+ uint32_t i; -+ -+ for (i = 0; i < cfg.nb_ports; i++) { -+ char ring_name[RTE_RING_NAMESIZE]; -+ -+ snprintf(ring_name, sizeof(ring_name), "rx_to_tx_ring_%u", i); -+ /* Create ring for inter core communication */ -+ cfg.ports[i].rx_to_tx_ring = rte_ring_create( -+ ring_name, ring_size, -+ rte_socket_id(), RING_F_SP_ENQ | RING_F_SC_DEQ); -+ -+ if (cfg.ports[i].rx_to_tx_ring == NULL) -+ rte_exit(EXIT_FAILURE, "Ring create failed: %s\n", -+ rte_strerror(rte_errno)); -+ } -+} -+/* >8 End of assigning ring structures for packet exchanging. */ -+ -+/* -+ * Initializes a given port using global settings and with the RX buffers -+ * coming from the mbuf_pool passed as a parameter. -+ */ -+static inline void -+port_init(uint16_t portid, struct rte_mempool *mbuf_pool, uint16_t nb_queues) -+{ -+ /* Configuring port to use RSS for multiple RX queues. 8< */ -+ static const struct rte_eth_conf port_conf = { -+ .rxmode = { -+ .mq_mode = RTE_ETH_MQ_RX_RSS, -+ }, -+ .rx_adv_conf = { -+ .rss_conf = { -+ .rss_key = NULL, -+ .rss_hf = RTE_ETH_RSS_PROTO_MASK, -+ } -+ } -+ }; -+ /* >8 End of configuring port to use RSS for multiple RX queues. */ -+ -+ struct rte_eth_rxconf rxq_conf; -+ struct rte_eth_txconf txq_conf; -+ struct rte_eth_conf local_port_conf = port_conf; -+ struct rte_eth_dev_info dev_info; -+ int ret, i; -+ -+ if (max_frame_size > local_port_conf.rxmode.mtu) -+ local_port_conf.rxmode.mtu = max_frame_size; -+ -+ /* Skip ports that are not enabled */ -+ if ((dma_enabled_port_mask & (1 << portid)) == 0) { -+ printf("Skipping disabled port %u\n", portid); -+ return; -+ } -+ -+ /* Init port */ -+ printf("Initializing port %u... ", portid); -+ fflush(stdout); -+ ret = rte_eth_dev_info_get(portid, &dev_info); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, "Cannot get device info: %s, port=%u\n", -+ rte_strerror(-ret), portid); -+ -+ local_port_conf.rx_adv_conf.rss_conf.rss_hf &= -+ dev_info.flow_type_rss_offloads; -+ ret = rte_eth_dev_configure(portid, nb_queues, 1, &local_port_conf); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, "Cannot configure device:" -+ " err=%d, port=%u\n", ret, portid); -+ -+ ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd, -+ &nb_txd); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, -+ "Cannot adjust number of descriptors: err=%d, port=%u\n", -+ ret, portid); -+ -+ rte_eth_macaddr_get(portid, &dma_ports_eth_addr[portid]); -+ -+ /* Init RX queues */ -+ rxq_conf = dev_info.default_rxconf; -+ rxq_conf.offloads = local_port_conf.rxmode.offloads; -+ for (i = 0; i < nb_queues; i++) { -+ ret = rte_eth_rx_queue_setup(portid, i, nb_rxd, -+ rte_eth_dev_socket_id(portid), &rxq_conf, -+ mbuf_pool); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, -+ "rte_eth_rx_queue_setup:err=%d,port=%u, queue_id=%u\n", -+ ret, portid, i); -+ } -+ -+ /* Init one TX queue on each port */ -+ txq_conf = dev_info.default_txconf; -+ txq_conf.offloads = local_port_conf.txmode.offloads; -+ ret = rte_eth_tx_queue_setup(portid, 0, nb_txd, -+ rte_eth_dev_socket_id(portid), -+ &txq_conf); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, -+ "rte_eth_tx_queue_setup:err=%d,port=%u\n", -+ ret, portid); -+ -+ /* Initialize TX buffers */ -+ tx_buffer[portid] = rte_zmalloc_socket("tx_buffer", -+ RTE_ETH_TX_BUFFER_SIZE(MAX_PKT_BURST), 0, -+ rte_eth_dev_socket_id(portid)); -+ if (tx_buffer[portid] == NULL) -+ rte_exit(EXIT_FAILURE, -+ "Cannot allocate buffer for tx on port %u\n", -+ portid); -+ -+ rte_eth_tx_buffer_init(tx_buffer[portid], MAX_PKT_BURST); -+ -+ ret = rte_eth_tx_buffer_set_err_callback(tx_buffer[portid], -+ rte_eth_tx_buffer_count_callback, -+ &port_statistics.tx_dropped[portid]); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, -+ "Cannot set error callback for tx buffer on port %u\n", -+ portid); -+ -+ /* Start device. 8< */ -+ ret = rte_eth_dev_start(portid); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, -+ "rte_eth_dev_start:err=%d, port=%u\n", -+ ret, portid); -+ /* >8 End of starting device. */ -+ -+ /* RX port is set in promiscuous mode. 8< */ -+ rte_eth_promiscuous_enable(portid); -+ /* >8 End of RX port is set in promiscuous mode. */ -+ -+ printf("Port %u, MAC address: " RTE_ETHER_ADDR_PRT_FMT "\n\n", -+ portid, -+ RTE_ETHER_ADDR_BYTES(&dma_ports_eth_addr[portid])); -+ -+ cfg.ports[cfg.nb_ports].rxtx_port = portid; -+ cfg.ports[cfg.nb_ports++].nb_queues = nb_queues; -+} -+ -+/* Get a device dump for each device being used by the application */ -+static void -+dmadev_dump(void) -+{ -+ uint32_t i, j; -+ -+ if (copy_mode != COPY_MODE_DMA_NUM) -+ return; -+ -+ for (i = 0; i < cfg.nb_ports; i++) -+ for (j = 0; j < cfg.ports[i].nb_queues; j++) -+ rte_dma_dump(cfg.ports[i].dmadev_ids[j], stdout); -+} -+ -+static void -+signal_handler(int signum) -+{ -+ if (signum == SIGINT || signum == SIGTERM) { -+ printf("\n\nSignal %d received, preparing to exit...\n", -+ signum); -+ force_quit = true; -+ } else if (signum == SIGUSR1) { -+ dmadev_dump(); -+ } -+} -+ -+int -+main(int argc, char **argv) -+{ -+ int ret; -+ uint16_t nb_ports, portid; -+ uint32_t i; -+ unsigned int nb_mbufs; -+ size_t sz; -+ -+ /* Init EAL. 8< */ -+ ret = rte_eal_init(argc, argv); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, "Invalid EAL arguments\n"); -+ /* >8 End of init EAL. */ -+ argc -= ret; -+ argv += ret; -+ -+ force_quit = false; -+ signal(SIGINT, signal_handler); -+ signal(SIGTERM, signal_handler); -+ signal(SIGUSR1, signal_handler); -+ -+ nb_ports = rte_eth_dev_count_avail(); -+ if (nb_ports == 0) -+ rte_exit(EXIT_FAILURE, "No Ethernet ports - bye\n"); -+ -+ /* Parse application arguments (after the EAL ones) */ -+ ret = dma_parse_args(argc, argv, nb_ports); -+ if (ret < 0) -+ rte_exit(EXIT_FAILURE, "Invalid DMA arguments\n"); -+ -+ /* Allocates mempool to hold the mbufs. 8< */ -+ nb_mbufs = RTE_MAX(nb_ports * (nb_queues * (nb_rxd + nb_txd + -+ 4 * MAX_PKT_BURST + ring_size) + ring_size + -+ rte_lcore_count() * MEMPOOL_CACHE_SIZE), -+ MIN_POOL_SIZE); -+ -+ /* Create the mbuf pool */ -+ sz = max_frame_size + RTE_PKTMBUF_HEADROOM; -+ sz = RTE_MAX(sz, (size_t)RTE_MBUF_DEFAULT_BUF_SIZE); -+ dma_pktmbuf_pool = rte_pktmbuf_pool_create("mbuf_pool", nb_mbufs, -+ MEMPOOL_CACHE_SIZE, 0, sz, rte_socket_id()); -+ if (dma_pktmbuf_pool == NULL) -+ rte_exit(EXIT_FAILURE, "Cannot init mbuf pool\n"); -+ /* >8 End of allocates mempool to hold the mbufs. */ -+ -+ /* Initialize each port. 8< */ -+ cfg.nb_ports = 0; -+ RTE_ETH_FOREACH_DEV(portid) -+ port_init(portid, dma_pktmbuf_pool, nb_queues); -+ /* >8 End of initializing each port. */ -+ -+ /* Initialize port xstats */ -+ memset(&port_statistics, 0, sizeof(port_statistics)); -+ -+ /* Assigning each port resources. 8< */ -+ while (!check_link_status(dma_enabled_port_mask) && !force_quit) -+ sleep(1); -+ -+ /* Check if there is enough lcores for all ports. */ -+ cfg.nb_lcores = rte_lcore_count() - 1; -+ if (cfg.nb_lcores < 1) -+ rte_exit(EXIT_FAILURE, -+ "There should be at least one worker lcore.\n"); -+ -+ if (copy_mode == COPY_MODE_DMA_NUM) -+ assign_dmadevs(); -+ -+ assign_rings(); -+ /* >8 End of assigning each port resources. */ -+ -+ start_forwarding_cores(); -+ /* main core prints stats while other cores forward */ -+ print_stats(argv[0]); -+ -+ /* force_quit is true when we get here */ -+ rte_eal_mp_wait_lcore(); -+ -+ uint32_t j; -+ for (i = 0; i < cfg.nb_ports; i++) { -+ printf("Closing port %d\n", cfg.ports[i].rxtx_port); -+ ret = rte_eth_dev_stop(cfg.ports[i].rxtx_port); -+ if (ret != 0) -+ RTE_LOG(ERR, DMA, "rte_eth_dev_stop: err=%s, port=%u\n", -+ rte_strerror(-ret), cfg.ports[i].rxtx_port); -+ -+ rte_eth_dev_close(cfg.ports[i].rxtx_port); -+ if (copy_mode == COPY_MODE_DMA_NUM) { -+ for (j = 0; j < cfg.ports[i].nb_queues; j++) { -+ printf("Stopping dmadev %d\n", -+ cfg.ports[i].dmadev_ids[j]); -+ rte_dma_stop(cfg.ports[i].dmadev_ids[j]); -+ } -+ } else /* copy_mode == COPY_MODE_SW_NUM */ -+ rte_ring_free(cfg.ports[i].rx_to_tx_ring); -+ } -+ -+ /* clean up the EAL */ -+ rte_eal_cleanup(); -+ -+ printf("Bye...\n"); -+ return 0; -+} -diff --git a/examples/dma/meson.build b/examples/dma/meson.build -new file mode 100644 -index 000000000..f70b5d349 ---- /dev/null -+++ b/examples/dma/meson.build -@@ -0,0 +1,15 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2019-2021 Intel Corporation -+ -+# meson file, for building this example as part of a main DPDK build. -+# -+# To build this example as a standalone application with an already-installed -+# DPDK instance, use 'make' -+ -+allow_experimental_apis = true -+ -+deps += 'dmadev' -+ -+sources = files( -+ 'dmafwd.c' -+) -diff --git a/examples/meson.build b/examples/meson.build -index 46ec80919..6c57db163 100644 ---- a/examples/meson.build -+++ b/examples/meson.build -@@ -12,7 +12,7 @@ execinfo = cc.find_library('execinfo', required: false) - all_examples = [ - 'bbdev_app', 'bond', - 'cmdline', -- 'distributor', 'ethtool', -+ 'distributor', 'dma', 'ethtool', - 'eventdev_pipeline', - 'fips_validation', 'flow_classify', - 'flow_filtering', 'helloworld', -diff --git a/lib/librte_dmadev/meson.build b/lib/librte_dmadev/meson.build -new file mode 100644 -index 000000000..8d2ed5261 ---- /dev/null -+++ b/lib/librte_dmadev/meson.build -@@ -0,0 +1,5 @@ -+# SPDX-License-Identifier: BSD-3-Clause -+# Copyright(c) 2021 HiSilicon Limited. -+ -+sources = files('rte_dmadev.c') -+headers = files('rte_dmadev.h', 'rte_dmadev_core.h', 'rte_dmadev_pmd.h') -diff --git a/lib/librte_dmadev/rte_dmadev.c b/lib/librte_dmadev/rte_dmadev.c -new file mode 100644 -index 000000000..7097fe41a ---- /dev/null -+++ b/lib/librte_dmadev/rte_dmadev.c -@@ -0,0 +1,866 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ * Copyright(c) 2021 Intel Corporation -+ */ -+ -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "rte_dmadev.h" -+#include "rte_dmadev_pmd.h" -+ -+static int16_t dma_devices_max; -+ -+struct rte_dma_fp_object *rte_dma_fp_objs; -+static struct rte_dma_dev *rte_dma_devices; -+static struct { -+ /* Hold the dev_max information of the primary process. This field is -+ * set by the primary process and is read by the secondary process. -+ */ -+ int16_t dev_max; -+ struct rte_dma_dev_data data[0]; -+} *dma_devices_shared_data; -+ -+RTE_LOG_REGISTER(rte_dma_logtype, lib.dma, INFO); -+#define RTE_DMA_LOG(level, ...) \ -+ rte_log(RTE_LOG_ ## level, rte_dma_logtype, RTE_FMT("dma: " \ -+ RTE_FMT_HEAD(__VA_ARGS__,) "\n", RTE_FMT_TAIL(__VA_ARGS__,))) -+ -+int -+rte_dma_dev_max(size_t dev_max) -+{ -+ /* This function may be called before rte_eal_init(), so no rte library -+ * function can be called in this function. -+ */ -+ if (dev_max == 0 || dev_max > INT16_MAX) -+ return -EINVAL; -+ -+ if (dma_devices_max > 0) -+ return -EINVAL; -+ -+ dma_devices_max = dev_max; -+ -+ return 0; -+} -+ -+int16_t -+rte_dma_next_dev(int16_t start_dev_id) -+{ -+ int16_t dev_id = start_dev_id; -+ while (dev_id < dma_devices_max && rte_dma_devices[dev_id].state == RTE_DMA_DEV_UNUSED) -+ dev_id++; -+ -+ if (dev_id < dma_devices_max) -+ return dev_id; -+ -+ return -1; -+} -+ -+static int -+dma_check_name(const char *name) -+{ -+ size_t name_len; -+ -+ if (name == NULL) { -+ RTE_DMA_LOG(ERR, "Name can't be NULL"); -+ return -EINVAL; -+ } -+ -+ name_len = strnlen(name, RTE_DEV_NAME_MAX_LEN); -+ if (name_len == 0) { -+ RTE_DMA_LOG(ERR, "Zero length DMA device name"); -+ return -EINVAL; -+ } -+ if (name_len >= RTE_DEV_NAME_MAX_LEN) { -+ RTE_DMA_LOG(ERR, "DMA device name is too long"); -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+ -+static int16_t -+dma_find_free_id(void) -+{ -+ int16_t i; -+ -+ if (rte_dma_devices == NULL || dma_devices_shared_data == NULL) -+ return -1; -+ -+ for (i = 0; i < dma_devices_max; i++) { -+ if (dma_devices_shared_data->data[i].dev_name[0] == '\0') -+ return i; -+ } -+ -+ return -1; -+} -+ -+static struct rte_dma_dev* -+dma_find_by_name(const char *name) -+{ -+ int16_t i; -+ -+ if (rte_dma_devices == NULL) -+ return NULL; -+ -+ for (i = 0; i < dma_devices_max; i++) { -+ if ((rte_dma_devices[i].state != RTE_DMA_DEV_UNUSED) && -+ (!strcmp(name, rte_dma_devices[i].data->dev_name))) -+ return &rte_dma_devices[i]; -+ } -+ -+ return NULL; -+} -+ -+static void dma_fp_object_dummy(struct rte_dma_fp_object *obj); -+ -+static int -+dma_fp_data_prepare(void) -+{ -+ size_t size; -+ void *ptr; -+ int i; -+ -+ if (rte_dma_fp_objs != NULL) -+ return 0; -+ -+ /* Fast-path object must align cacheline, but the return value of malloc -+ * may not be aligned to the cache line. Therefore, extra memory is -+ * applied for realignment. -+ * note: We do not call posix_memalign/aligned_alloc because it is -+ * version dependent on libc. -+ */ -+ size = dma_devices_max * sizeof(struct rte_dma_fp_object) + -+ RTE_CACHE_LINE_SIZE; -+ ptr = malloc(size); -+ if (ptr == NULL) -+ return -ENOMEM; -+ memset(ptr, 0, size); -+ -+ rte_dma_fp_objs = RTE_PTR_ALIGN(ptr, RTE_CACHE_LINE_SIZE); -+ for (i = 0; i < dma_devices_max; i++) -+ dma_fp_object_dummy(&rte_dma_fp_objs[i]); -+ -+ return 0; -+} -+ -+static int -+dma_dev_data_prepare(void) -+{ -+ size_t size; -+ -+ if (rte_dma_devices != NULL) -+ return 0; -+ -+ size = dma_devices_max * sizeof(struct rte_dma_dev); -+ rte_dma_devices = malloc(size); -+ if (rte_dma_devices == NULL) -+ return -ENOMEM; -+ memset(rte_dma_devices, 0, size); -+ -+ return 0; -+} -+ -+static int -+dma_shared_data_prepare(void) -+{ -+ const char *mz_name = "rte_dma_dev_data"; -+ const struct rte_memzone *mz; -+ size_t size; -+ -+ if (dma_devices_shared_data != NULL) -+ return 0; -+ -+ size = sizeof(*dma_devices_shared_data) + -+ sizeof(struct rte_dma_dev_data) * dma_devices_max; -+ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) -+ mz = rte_memzone_reserve(mz_name, size, rte_socket_id(), 0); -+ else -+ mz = rte_memzone_lookup(mz_name); -+ if (mz == NULL) -+ return -ENOMEM; -+ -+ dma_devices_shared_data = mz->addr; -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -+ memset(dma_devices_shared_data, 0, size); -+ dma_devices_shared_data->dev_max = dma_devices_max; -+ } else { -+ dma_devices_max = dma_devices_shared_data->dev_max; -+ } -+ -+ return 0; -+} -+ -+static int -+dma_data_prepare(void) -+{ -+ int ret; -+ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -+ if (dma_devices_max == 0) -+ dma_devices_max = RTE_DMADEV_DEFAULT_MAX; -+ ret = dma_fp_data_prepare(); -+ if (ret) -+ return ret; -+ ret = dma_dev_data_prepare(); -+ if (ret) -+ return ret; -+ ret = dma_shared_data_prepare(); -+ if (ret) -+ return ret; -+ } else { -+ ret = dma_shared_data_prepare(); -+ if (ret) -+ return ret; -+ ret = dma_fp_data_prepare(); -+ if (ret) -+ return ret; -+ ret = dma_dev_data_prepare(); -+ if (ret) -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static struct rte_dma_dev * -+dma_allocate_primary(const char *name, int numa_node, size_t private_data_size) -+{ -+ struct rte_dma_dev *dev; -+ void *dev_private; -+ int16_t dev_id; -+ int ret; -+ -+ ret = dma_data_prepare(); -+ if (ret < 0) { -+ RTE_DMA_LOG(ERR, "Cannot initialize dmadevs data"); -+ return NULL; -+ } -+ -+ dev = dma_find_by_name(name); -+ if (dev != NULL) { -+ RTE_DMA_LOG(ERR, "DMA device already allocated"); -+ return NULL; -+ } -+ -+ dev_private = rte_zmalloc_socket(name, private_data_size, -+ RTE_CACHE_LINE_SIZE, numa_node); -+ if (dev_private == NULL) { -+ RTE_DMA_LOG(ERR, "Cannot allocate private data"); -+ return NULL; -+ } -+ -+ dev_id = dma_find_free_id(); -+ if (dev_id < 0) { -+ RTE_DMA_LOG(ERR, "Reached maximum number of DMA devices"); -+ rte_free(dev_private); -+ return NULL; -+ } -+ -+ dev = &rte_dma_devices[dev_id]; -+ dev->data = &dma_devices_shared_data->data[dev_id]; -+ rte_strscpy(dev->data->dev_name, name, sizeof(dev->data->dev_name)); -+ dev->data->dev_id = dev_id; -+ dev->data->numa_node = numa_node; -+ dev->data->dev_private = dev_private; -+ -+ return dev; -+} -+ -+static struct rte_dma_dev * -+dma_attach_secondary(const char *name) -+{ -+ struct rte_dma_dev *dev; -+ int16_t i; -+ int ret; -+ -+ ret = dma_data_prepare(); -+ if (ret < 0) { -+ RTE_DMA_LOG(ERR, "Cannot initialize dmadevs data"); -+ return NULL; -+ } -+ -+ for (i = 0; i < dma_devices_max; i++) { -+ if (!strcmp(dma_devices_shared_data->data[i].dev_name, name)) -+ break; -+ } -+ if (i == dma_devices_max) { -+ RTE_DMA_LOG(ERR, -+ "Device %s is not driven by the primary process", -+ name); -+ return NULL; -+ } -+ -+ dev = &rte_dma_devices[i]; -+ dev->data = &dma_devices_shared_data->data[i]; -+ -+ return dev; -+} -+ -+static struct rte_dma_dev * -+dma_allocate(const char *name, int numa_node, size_t private_data_size) -+{ -+ struct rte_dma_dev *dev; -+ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) -+ dev = dma_allocate_primary(name, numa_node, private_data_size); -+ else -+ dev = dma_attach_secondary(name); -+ -+ if (dev) { -+ dev->fp_obj = &rte_dma_fp_objs[dev->data->dev_id]; -+ dma_fp_object_dummy(dev->fp_obj); -+ } -+ -+ return dev; -+} -+ -+static void -+dma_release(struct rte_dma_dev *dev) -+{ -+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) { -+ rte_free(dev->data->dev_private); -+ memset(dev->data, 0, sizeof(struct rte_dma_dev_data)); -+ } -+ -+ dma_fp_object_dummy(dev->fp_obj); -+ memset(dev, 0, sizeof(struct rte_dma_dev)); -+} -+ -+struct rte_dma_dev * -+rte_dma_pmd_allocate(const char *name, int numa_node, size_t private_data_size) -+{ -+ struct rte_dma_dev *dev; -+ -+ if (dma_check_name(name) != 0 || private_data_size == 0) -+ return NULL; -+ -+ dev = dma_allocate(name, numa_node, private_data_size); -+ if (dev == NULL) -+ return NULL; -+ -+ dev->state = RTE_DMA_DEV_REGISTERED; -+ -+ return dev; -+} -+ -+int -+rte_dma_pmd_release(const char *name) -+{ -+ struct rte_dma_dev *dev; -+ -+ if (dma_check_name(name) != 0) -+ return -EINVAL; -+ -+ dev = dma_find_by_name(name); -+ if (dev == NULL) -+ return -EINVAL; -+ -+ if (dev->state == RTE_DMA_DEV_READY) -+ return rte_dma_close(dev->data->dev_id); -+ -+ dma_release(dev); -+ return 0; -+} -+ -+int -+rte_dma_get_dev_id_by_name(const char *name) -+{ -+ struct rte_dma_dev *dev; -+ -+ if (dma_check_name(name) != 0) -+ return -EINVAL; -+ -+ dev = dma_find_by_name(name); -+ if (dev == NULL) -+ return -EINVAL; -+ -+ return dev->data->dev_id; -+} -+ -+bool -+rte_dma_is_valid(int16_t dev_id) -+{ -+ return (dev_id >= 0) && (dev_id < dma_devices_max) && -+ rte_dma_devices != NULL && -+ rte_dma_devices[dev_id].state != RTE_DMA_DEV_UNUSED; -+} -+ -+uint16_t -+rte_dma_count_avail(void) -+{ -+ uint16_t count = 0; -+ uint16_t i; -+ -+ if (rte_dma_devices == NULL) -+ return count; -+ -+ for (i = 0; i < dma_devices_max; i++) { -+ if (rte_dma_devices[i].state != RTE_DMA_DEV_UNUSED) -+ count++; -+ } -+ -+ return count; -+} -+ -+int -+rte_dma_info_get(int16_t dev_id, struct rte_dma_info *dev_info) -+{ -+ const struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id) || dev_info == NULL) -+ return -EINVAL; -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_info_get, -ENOTSUP); -+ memset(dev_info, 0, sizeof(struct rte_dma_info)); -+ ret = (*dev->dev_ops->dev_info_get)(dev, dev_info, -+ sizeof(struct rte_dma_info)); -+ if (ret != 0) -+ return ret; -+ -+ dev_info->dev_name = dev->data->dev_name; -+ dev_info->numa_node = dev->device->numa_node; -+ dev_info->nb_vchans = dev->data->dev_conf.nb_vchans; -+ -+ return 0; -+} -+ -+int -+rte_dma_configure(int16_t dev_id, const struct rte_dma_conf *dev_conf) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ struct rte_dma_info dev_info; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id) || dev_conf == NULL) -+ return -EINVAL; -+ -+ if (dev->data->dev_started != 0) { -+ RTE_DMA_LOG(ERR, -+ "Device %d must be stopped to allow configuration", -+ dev_id); -+ return -EBUSY; -+ } -+ -+ ret = rte_dma_info_get(dev_id, &dev_info); -+ if (ret != 0) { -+ RTE_DMA_LOG(ERR, "Device %d get device info fail", dev_id); -+ return -EINVAL; -+ } -+ if (dev_conf->nb_vchans == 0) { -+ RTE_DMA_LOG(ERR, -+ "Device %d configure zero vchans", dev_id); -+ return -EINVAL; -+ } -+ if (dev_conf->nb_vchans > dev_info.max_vchans) { -+ RTE_DMA_LOG(ERR, -+ "Device %d configure too many vchans", dev_id); -+ return -EINVAL; -+ } -+ if (dev_conf->enable_silent && -+ !(dev_info.dev_capa & RTE_DMA_CAPA_SILENT)) { -+ RTE_DMA_LOG(ERR, "Device %d don't support silent", dev_id); -+ return -EINVAL; -+ } -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP); -+ ret = (*dev->dev_ops->dev_configure)(dev, dev_conf, -+ sizeof(struct rte_dma_conf)); -+ if (ret == 0) -+ memcpy(&dev->data->dev_conf, dev_conf, -+ sizeof(struct rte_dma_conf)); -+ -+ return ret; -+} -+ -+int -+rte_dma_start(int16_t dev_id) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id)) -+ return -EINVAL; -+ -+ if (dev->data->dev_conf.nb_vchans == 0) { -+ RTE_DMA_LOG(ERR, "Device %d must be configured first", dev_id); -+ return -EINVAL; -+ } -+ -+ if (dev->data->dev_started != 0) { -+ RTE_DMA_LOG(WARNING, "Device %d already started", dev_id); -+ return 0; -+ } -+ -+ if (dev->dev_ops->dev_start == NULL) -+ goto mark_started; -+ -+ ret = (*dev->dev_ops->dev_start)(dev); -+ if (ret != 0) -+ return ret; -+ -+mark_started: -+ dev->data->dev_started = 1; -+ return 0; -+} -+ -+int -+rte_dma_stop(int16_t dev_id) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id)) -+ return -EINVAL; -+ -+ if (dev->data->dev_started == 0) { -+ RTE_DMA_LOG(WARNING, "Device %d already stopped", dev_id); -+ return 0; -+ } -+ -+ if (dev->dev_ops->dev_stop == NULL) -+ goto mark_stopped; -+ -+ ret = (*dev->dev_ops->dev_stop)(dev); -+ if (ret != 0) -+ return ret; -+ -+mark_stopped: -+ dev->data->dev_started = 0; -+ return 0; -+} -+ -+int -+rte_dma_close(int16_t dev_id) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id)) -+ return -EINVAL; -+ -+ /* Device must be stopped before it can be closed */ -+ if (dev->data->dev_started == 1) { -+ RTE_DMA_LOG(ERR, -+ "Device %d must be stopped before closing", dev_id); -+ return -EBUSY; -+ } -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP); -+ ret = (*dev->dev_ops->dev_close)(dev); -+ if (ret == 0) -+ dma_release(dev); -+ -+ return ret; -+} -+ -+int -+rte_dma_vchan_setup(int16_t dev_id, uint16_t vchan, -+ const struct rte_dma_vchan_conf *conf) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ struct rte_dma_info dev_info; -+ bool src_is_dev, dst_is_dev; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id) || conf == NULL) -+ return -EINVAL; -+ -+ if (dev->data->dev_started != 0) { -+ RTE_DMA_LOG(ERR, -+ "Device %d must be stopped to allow configuration", -+ dev_id); -+ return -EBUSY; -+ } -+ -+ ret = rte_dma_info_get(dev_id, &dev_info); -+ if (ret != 0) { -+ RTE_DMA_LOG(ERR, "Device %d get device info fail", dev_id); -+ return -EINVAL; -+ } -+ if (dev->data->dev_conf.nb_vchans == 0) { -+ RTE_DMA_LOG(ERR, "Device %d must be configured first", dev_id); -+ return -EINVAL; -+ } -+ if (vchan >= dev_info.nb_vchans) { -+ RTE_DMA_LOG(ERR, "Device %d vchan out range!", dev_id); -+ return -EINVAL; -+ } -+ if (conf->direction != RTE_DMA_DIR_MEM_TO_MEM && -+ conf->direction != RTE_DMA_DIR_MEM_TO_DEV && -+ conf->direction != RTE_DMA_DIR_DEV_TO_MEM && -+ conf->direction != RTE_DMA_DIR_DEV_TO_DEV) { -+ RTE_DMA_LOG(ERR, "Device %d direction invalid!", dev_id); -+ return -EINVAL; -+ } -+ if (conf->direction == RTE_DMA_DIR_MEM_TO_MEM && -+ !(dev_info.dev_capa & RTE_DMA_CAPA_MEM_TO_MEM)) { -+ RTE_DMA_LOG(ERR, -+ "Device %d don't support mem2mem transfer", dev_id); -+ return -EINVAL; -+ } -+ if (conf->direction == RTE_DMA_DIR_MEM_TO_DEV && -+ !(dev_info.dev_capa & RTE_DMA_CAPA_MEM_TO_DEV)) { -+ RTE_DMA_LOG(ERR, -+ "Device %d don't support mem2dev transfer", dev_id); -+ return -EINVAL; -+ } -+ if (conf->direction == RTE_DMA_DIR_DEV_TO_MEM && -+ !(dev_info.dev_capa & RTE_DMA_CAPA_DEV_TO_MEM)) { -+ RTE_DMA_LOG(ERR, -+ "Device %d don't support dev2mem transfer", dev_id); -+ return -EINVAL; -+ } -+ if (conf->direction == RTE_DMA_DIR_DEV_TO_DEV && -+ !(dev_info.dev_capa & RTE_DMA_CAPA_DEV_TO_DEV)) { -+ RTE_DMA_LOG(ERR, -+ "Device %d don't support dev2dev transfer", dev_id); -+ return -EINVAL; -+ } -+ if (conf->nb_desc < dev_info.min_desc || -+ conf->nb_desc > dev_info.max_desc) { -+ RTE_DMA_LOG(ERR, -+ "Device %d number of descriptors invalid", dev_id); -+ return -EINVAL; -+ } -+ src_is_dev = conf->direction == RTE_DMA_DIR_DEV_TO_MEM || -+ conf->direction == RTE_DMA_DIR_DEV_TO_DEV; -+ if ((conf->src_port.port_type == RTE_DMA_PORT_NONE && src_is_dev) || -+ (conf->src_port.port_type != RTE_DMA_PORT_NONE && !src_is_dev)) { -+ RTE_DMA_LOG(ERR, "Device %d source port type invalid", dev_id); -+ return -EINVAL; -+ } -+ dst_is_dev = conf->direction == RTE_DMA_DIR_MEM_TO_DEV || -+ conf->direction == RTE_DMA_DIR_DEV_TO_DEV; -+ if ((conf->dst_port.port_type == RTE_DMA_PORT_NONE && dst_is_dev) || -+ (conf->dst_port.port_type != RTE_DMA_PORT_NONE && !dst_is_dev)) { -+ RTE_DMA_LOG(ERR, -+ "Device %d destination port type invalid", dev_id); -+ return -EINVAL; -+ } -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vchan_setup, -ENOTSUP); -+ return (*dev->dev_ops->vchan_setup)(dev, vchan, conf, -+ sizeof(struct rte_dma_vchan_conf)); -+} -+ -+int -+rte_dma_stats_get(int16_t dev_id, uint16_t vchan, struct rte_dma_stats *stats) -+{ -+ const struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ -+ if (!rte_dma_is_valid(dev_id) || stats == NULL) -+ return -EINVAL; -+ -+ if (vchan >= dev->data->dev_conf.nb_vchans && -+ vchan != RTE_DMA_ALL_VCHAN) { -+ RTE_DMA_LOG(ERR, -+ "Device %d vchan %u out of range", dev_id, vchan); -+ return -EINVAL; -+ } -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_get, -ENOTSUP); -+ memset(stats, 0, sizeof(struct rte_dma_stats)); -+ return (*dev->dev_ops->stats_get)(dev, vchan, stats, -+ sizeof(struct rte_dma_stats)); -+} -+ -+int -+rte_dma_stats_reset(int16_t dev_id, uint16_t vchan) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ -+ if (!rte_dma_is_valid(dev_id)) -+ return -EINVAL; -+ -+ if (vchan >= dev->data->dev_conf.nb_vchans && -+ vchan != RTE_DMA_ALL_VCHAN) { -+ RTE_DMA_LOG(ERR, -+ "Device %d vchan %u out of range", dev_id, vchan); -+ return -EINVAL; -+ } -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->stats_reset, -ENOTSUP); -+ return (*dev->dev_ops->stats_reset)(dev, vchan); -+} -+ -+int -+rte_dma_vchan_status(int16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status) -+{ -+ struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ -+ if (!rte_dma_is_valid(dev_id)) -+ return -EINVAL; -+ -+ if (vchan >= dev->data->dev_conf.nb_vchans) { -+ RTE_DMA_LOG(ERR, "Device %u vchan %u out of range\n", dev_id, vchan); -+ return -EINVAL; -+ } -+ -+ RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vchan_status, -ENOTSUP); -+ return (*dev->dev_ops->vchan_status)(dev, vchan, status); -+} -+ -+static const char * -+dma_capability_name(uint64_t capability) -+{ -+ static const struct { -+ uint64_t capability; -+ const char *name; -+ } capa_names[] = { -+ { RTE_DMA_CAPA_MEM_TO_MEM, "mem2mem" }, -+ { RTE_DMA_CAPA_MEM_TO_DEV, "mem2dev" }, -+ { RTE_DMA_CAPA_DEV_TO_MEM, "dev2mem" }, -+ { RTE_DMA_CAPA_DEV_TO_DEV, "dev2dev" }, -+ { RTE_DMA_CAPA_SVA, "sva" }, -+ { RTE_DMA_CAPA_SILENT, "silent" }, -+ { RTE_DMA_CAPA_HANDLES_ERRORS, "handles_errors" }, -+ { RTE_DMA_CAPA_OPS_COPY, "copy" }, -+ { RTE_DMA_CAPA_OPS_COPY_SG, "copy_sg" }, -+ { RTE_DMA_CAPA_OPS_FILL, "fill" }, -+ }; -+ -+ const char *name = "unknown"; -+ uint32_t i; -+ -+ for (i = 0; i < RTE_DIM(capa_names); i++) { -+ if (capability == capa_names[i].capability) { -+ name = capa_names[i].name; -+ break; -+ } -+ } -+ -+ return name; -+} -+ -+static void -+dma_dump_capability(FILE *f, uint64_t dev_capa) -+{ -+ uint64_t capa; -+ -+ (void)fprintf(f, " dev_capa: 0x%" PRIx64 " -", dev_capa); -+ while (dev_capa > 0) { -+ capa = 1ull << __builtin_ctzll(dev_capa); -+ (void)fprintf(f, " %s", dma_capability_name(capa)); -+ dev_capa &= ~capa; -+ } -+ (void)fprintf(f, "\n"); -+} -+ -+int -+rte_dma_dump(int16_t dev_id, FILE *f) -+{ -+ const struct rte_dma_dev *dev = &rte_dma_devices[dev_id]; -+ struct rte_dma_info dev_info; -+ int ret; -+ -+ if (!rte_dma_is_valid(dev_id) || f == NULL) -+ return -EINVAL; -+ -+ ret = rte_dma_info_get(dev_id, &dev_info); -+ if (ret != 0) { -+ RTE_DMA_LOG(ERR, "Device %d get device info fail", dev_id); -+ return -EINVAL; -+ } -+ -+ (void)fprintf(f, "DMA Dev %d, '%s' [%s]\n", -+ dev->data->dev_id, -+ dev->data->dev_name, -+ dev->data->dev_started ? "started" : "stopped"); -+ dma_dump_capability(f, dev_info.dev_capa); -+ (void)fprintf(f, " max_vchans_supported: %u\n", dev_info.max_vchans); -+ (void)fprintf(f, " nb_vchans_configured: %u\n", dev_info.nb_vchans); -+ (void)fprintf(f, " silent_mode: %s\n", -+ dev->data->dev_conf.enable_silent ? "on" : "off"); -+ -+ if (dev->dev_ops->dev_dump != NULL) -+ return (*dev->dev_ops->dev_dump)(dev, f); -+ -+ return 0; -+} -+ -+static int -+dummy_copy(__rte_unused void *dev_private, __rte_unused uint16_t vchan, -+ __rte_unused rte_iova_t src, __rte_unused rte_iova_t dst, -+ __rte_unused uint32_t length, __rte_unused uint64_t flags) -+{ -+ RTE_DMA_LOG(ERR, "copy is not configured or not supported."); -+ return -EINVAL; -+} -+ -+static int -+dummy_copy_sg(__rte_unused void *dev_private, __rte_unused uint16_t vchan, -+ __rte_unused const struct rte_dma_sge *src, -+ __rte_unused const struct rte_dma_sge *dst, -+ __rte_unused uint16_t nb_src, __rte_unused uint16_t nb_dst, -+ __rte_unused uint64_t flags) -+{ -+ RTE_DMA_LOG(ERR, "copy_sg is not configured or not supported."); -+ return -EINVAL; -+} -+ -+static int -+dummy_fill(__rte_unused void *dev_private, __rte_unused uint16_t vchan, -+ __rte_unused uint64_t pattern, __rte_unused rte_iova_t dst, -+ __rte_unused uint32_t length, __rte_unused uint64_t flags) -+{ -+ RTE_DMA_LOG(ERR, "fill is not configured or not supported."); -+ return -EINVAL; -+} -+ -+static int -+dummy_submit(__rte_unused void *dev_private, __rte_unused uint16_t vchan) -+{ -+ RTE_DMA_LOG(ERR, "submit is not configured or not supported."); -+ return -EINVAL; -+} -+ -+static uint16_t -+dummy_completed(__rte_unused void *dev_private, __rte_unused uint16_t vchan, -+ __rte_unused const uint16_t nb_cpls, -+ __rte_unused uint16_t *last_idx, __rte_unused bool *has_error) -+{ -+ RTE_DMA_LOG(ERR, "completed is not configured or not supported."); -+ return 0; -+} -+ -+static uint16_t -+dummy_completed_status(__rte_unused void *dev_private, -+ __rte_unused uint16_t vchan, -+ __rte_unused const uint16_t nb_cpls, -+ __rte_unused uint16_t *last_idx, -+ __rte_unused enum rte_dma_status_code *status) -+{ -+ RTE_DMA_LOG(ERR, -+ "completed_status is not configured or not supported."); -+ return 0; -+} -+ -+static uint16_t -+dummy_burst_capacity(__rte_unused const void *dev_private, -+ __rte_unused uint16_t vchan) -+{ -+ RTE_DMA_LOG(ERR, "burst_capacity is not configured or not supported."); -+ return 0; -+} -+ -+static void -+dma_fp_object_dummy(struct rte_dma_fp_object *obj) -+{ -+ obj->dev_private = NULL; -+ obj->copy = dummy_copy; -+ obj->copy_sg = dummy_copy_sg; -+ obj->fill = dummy_fill; -+ obj->submit = dummy_submit; -+ obj->completed = dummy_completed; -+ obj->completed_status = dummy_completed_status; -+ obj->burst_capacity = dummy_burst_capacity; -+} -diff --git a/lib/librte_dmadev/rte_dmadev.h b/lib/librte_dmadev/rte_dmadev.h -new file mode 100644 -index 000000000..9942c6ec2 ---- /dev/null -+++ b/lib/librte_dmadev/rte_dmadev.h -@@ -0,0 +1,1138 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ * Copyright(c) 2021 Intel Corporation -+ * Copyright(c) 2021 Marvell International Ltd -+ * Copyright(c) 2021 SmartShare Systems -+ */ -+ -+#ifndef RTE_DMADEV_H -+#define RTE_DMADEV_H -+ -+/** -+ * @file rte_dmadev.h -+ * -+ * DMA (Direct Memory Access) device API. -+ * -+ * The DMA framework is built on the following model: -+ * -+ * --------------- --------------- --------------- -+ * | virtual DMA | | virtual DMA | | virtual DMA | -+ * | channel | | channel | | channel | -+ * --------------- --------------- --------------- -+ * | | | -+ * ------------------ | -+ * | | -+ * ------------ ------------ -+ * | dmadev | | dmadev | -+ * ------------ ------------ -+ * | | -+ * ------------------ ------------------ -+ * | HW DMA channel | | HW DMA channel | -+ * ------------------ ------------------ -+ * | | -+ * -------------------------------- -+ * | -+ * --------------------- -+ * | HW DMA Controller | -+ * --------------------- -+ * -+ * The DMA controller could have multiple HW-DMA-channels (aka. HW-DMA-queues), -+ * each HW-DMA-channel should be represented by a dmadev. -+ * -+ * The dmadev could create multiple virtual DMA channels, each virtual DMA -+ * channel represents a different transfer context. The DMA operation request -+ * must be submitted to the virtual DMA channel. e.g. Application could create -+ * virtual DMA channel 0 for memory-to-memory transfer scenario, and create -+ * virtual DMA channel 1 for memory-to-device transfer scenario. -+ * -+ * This framework uses 'int16_t dev_id' as the device identifier of a dmadev, -+ * and 'uint16_t vchan' as the virtual DMA channel identifier in one dmadev. -+ * -+ * The functions exported by the dmadev API to setup a device designated by its -+ * device identifier must be invoked in the following order: -+ * - rte_dma_configure() -+ * - rte_dma_vchan_setup() -+ * - rte_dma_start() -+ * -+ * Then, the application can invoke dataplane functions to process jobs. -+ * -+ * If the application wants to change the configuration (i.e. invoke -+ * rte_dma_configure() or rte_dma_vchan_setup()), it must invoke -+ * rte_dma_stop() first to stop the device and then do the reconfiguration -+ * before invoking rte_dma_start() again. The dataplane functions should not -+ * be invoked when the device is stopped. -+ * -+ * Finally, an application can close a dmadev by invoking the rte_dma_close() -+ * function. -+ * -+ * The dataplane APIs include two parts: -+ * The first part is the submission of operation requests: -+ * - rte_dma_copy() -+ * - rte_dma_copy_sg() -+ * - rte_dma_fill() -+ * - rte_dma_submit() -+ * -+ * These APIs could work with different virtual DMA channels which have -+ * different contexts. -+ * -+ * The first three APIs are used to submit the operation request to the virtual -+ * DMA channel, if the submission is successful, a positive -+ * ring_idx <= UINT16_MAX is returned, otherwise a negative number is returned. -+ * -+ * The last API is used to issue doorbell to hardware, and also there are flags -+ * (@see RTE_DMA_OP_FLAG_SUBMIT) parameter of the first three APIs could do the -+ * same work. -+ * @note When enqueuing a set of jobs to the device, having a separate submit -+ * outside a loop makes for clearer code than having a check for the last -+ * iteration inside the loop to set a special submit flag. However, for cases -+ * where one item alone is to be submitted or there is a small set of jobs to -+ * be submitted sequentially, having a submit flag provides a lower-overhead -+ * way of doing the submission while still keeping the code clean. -+ * -+ * The second part is to obtain the result of requests: -+ * - rte_dma_completed() -+ * - return the number of operation requests completed successfully. -+ * - rte_dma_completed_status() -+ * - return the number of operation requests completed. -+ * -+ * @note If the dmadev works in silent mode (@see RTE_DMA_CAPA_SILENT), -+ * application does not invoke the above two completed APIs. -+ * -+ * About the ring_idx which enqueue APIs (e.g. rte_dma_copy(), rte_dma_fill()) -+ * return, the rules are as follows: -+ * - ring_idx for each virtual DMA channel are independent. -+ * - For a virtual DMA channel, the ring_idx is monotonically incremented, -+ * when it reach UINT16_MAX, it wraps back to zero. -+ * - This ring_idx can be used by applications to track per-operation -+ * metadata in an application-defined circular ring. -+ * - The initial ring_idx of a virtual DMA channel is zero, after the -+ * device is stopped, the ring_idx needs to be reset to zero. -+ * -+ * One example: -+ * - step-1: start one dmadev -+ * - step-2: enqueue a copy operation, the ring_idx return is 0 -+ * - step-3: enqueue a copy operation again, the ring_idx return is 1 -+ * - ... -+ * - step-101: stop the dmadev -+ * - step-102: start the dmadev -+ * - step-103: enqueue a copy operation, the ring_idx return is 0 -+ * - ... -+ * - step-x+0: enqueue a fill operation, the ring_idx return is 65535 -+ * - step-x+1: enqueue a copy operation, the ring_idx return is 0 -+ * - ... -+ * -+ * The DMA operation address used in enqueue APIs (i.e. rte_dma_copy(), -+ * rte_dma_copy_sg(), rte_dma_fill()) is defined as rte_iova_t type. -+ * -+ * The dmadev supports two types of address: memory address and device address. -+ * -+ * - memory address: the source and destination address of the memory-to-memory -+ * transfer type, or the source address of the memory-to-device transfer type, -+ * or the destination address of the device-to-memory transfer type. -+ * @note If the device support SVA (@see RTE_DMA_CAPA_SVA), the memory address -+ * can be any VA address, otherwise it must be an IOVA address. -+ * -+ * - device address: the source and destination address of the device-to-device -+ * transfer type, or the source address of the device-to-memory transfer type, -+ * or the destination address of the memory-to-device transfer type. -+ * -+ * About MT-safe, all the functions of the dmadev API implemented by a PMD are -+ * lock-free functions which assume to not be invoked in parallel on different -+ * logical cores to work on the same target dmadev object. -+ * @note Different virtual DMA channels on the same dmadev *DO NOT* support -+ * parallel invocation because these virtual DMA channels share the same -+ * HW-DMA-channel. -+ */ -+ -+#include -+ -+#include -+#include -+#include -+#include -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+/** Maximum number of devices if rte_dma_dev_max() is not called. */ -+#define RTE_DMADEV_DEFAULT_MAX 64 -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Configure the maximum number of dmadevs. -+ * @note This function can be invoked before the primary process rte_eal_init() -+ * to change the maximum number of dmadevs. If not invoked, the maximum number -+ * of dmadevs is @see RTE_DMADEV_DEFAULT_MAX -+ * -+ * @param dev_max -+ * maximum number of dmadevs. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_dev_max(size_t dev_max); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Get the device identifier for the named DMA device. -+ * -+ * @param name -+ * DMA device name. -+ * -+ * @return -+ * Returns DMA device identifier on success. -+ * - <0: Failure to find named DMA device. -+ */ -+__rte_experimental -+int rte_dma_get_dev_id_by_name(const char *name); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Check whether the dev_id is valid. -+ * -+ * @param dev_id -+ * DMA device index. -+ * -+ * @return -+ * - If the device index is valid (true) or not (false). -+ */ -+__rte_experimental -+bool rte_dma_is_valid(int16_t dev_id); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Get the total number of DMA devices that have been successfully -+ * initialised. -+ * -+ * @return -+ * The total number of usable DMA devices. -+ */ -+__rte_experimental -+uint16_t rte_dma_count_avail(void); -+ -+/** -+ * Iterates over valid dmadev instances. -+ * -+ * @param start_dev_id -+ * The id of the next possible dmadev. -+ * @return -+ * Next valid dmadev, UINT16_MAX if there is none. -+ */ -+__rte_experimental -+int16_t rte_dma_next_dev(int16_t start_dev_id); -+ -+/** Utility macro to iterate over all available dmadevs */ -+#define RTE_DMA_FOREACH_DEV(p) \ -+ for (p = rte_dma_next_dev(0); \ -+ p != -1; \ -+ p = rte_dma_next_dev(p + 1)) -+ -+ -+/**@{@name DMA capability -+ * @see struct rte_dma_info::dev_capa -+ */ -+/** Support memory-to-memory transfer */ -+#define RTE_DMA_CAPA_MEM_TO_MEM RTE_BIT64(0) -+/** Support memory-to-device transfer. */ -+#define RTE_DMA_CAPA_MEM_TO_DEV RTE_BIT64(1) -+/** Support device-to-memory transfer. */ -+#define RTE_DMA_CAPA_DEV_TO_MEM RTE_BIT64(2) -+/** Support device-to-device transfer. */ -+#define RTE_DMA_CAPA_DEV_TO_DEV RTE_BIT64(3) -+/** Support SVA which could use VA as DMA address. -+ * If device support SVA then application could pass any VA address like memory -+ * from rte_malloc(), rte_memzone(), malloc, stack memory. -+ * If device don't support SVA, then application should pass IOVA address which -+ * from rte_malloc(), rte_memzone(). -+ */ -+#define RTE_DMA_CAPA_SVA RTE_BIT64(4) -+/** Support work in silent mode. -+ * In this mode, application don't required to invoke rte_dma_completed*() -+ * API. -+ * @see struct rte_dma_conf::silent_mode -+ */ -+#define RTE_DMA_CAPA_SILENT RTE_BIT64(5) -+/** Supports error handling -+ * -+ * With this bit set, invalid input addresses will be reported as operation failures -+ * to the user but other operations can continue. -+ * Without this bit set, invalid data is not handled by either HW or driver, so user -+ * must ensure that all memory addresses are valid and accessible by HW. -+ */ -+#define RTE_DMA_CAPA_HANDLES_ERRORS RTE_BIT64(6) -+/** Support copy operation. -+ * This capability start with index of 32, so that it could leave gap between -+ * normal capability and ops capability. -+ */ -+#define RTE_DMA_CAPA_OPS_COPY RTE_BIT64(32) -+/** Support scatter-gather list copy operation. */ -+#define RTE_DMA_CAPA_OPS_COPY_SG RTE_BIT64(33) -+/** Support fill operation. */ -+#define RTE_DMA_CAPA_OPS_FILL RTE_BIT64(34) -+/**@}*/ -+ -+/** -+ * A structure used to retrieve the information of a DMA device. -+ * -+ * @see rte_dma_info_get -+ */ -+struct rte_dma_info { -+ const char *dev_name; /**< Unique device name. */ -+ /** Device capabilities (RTE_DMA_CAPA_*). */ -+ uint64_t dev_capa; -+ /** Maximum number of virtual DMA channels supported. */ -+ uint16_t max_vchans; -+ /** Maximum allowed number of virtual DMA channel descriptors. */ -+ uint16_t max_desc; -+ /** Minimum allowed number of virtual DMA channel descriptors. */ -+ uint16_t min_desc; -+ /** Maximum number of source or destination scatter-gather entry -+ * supported. -+ * If the device does not support COPY_SG capability, this value can be -+ * zero. -+ * If the device supports COPY_SG capability, then rte_dma_copy_sg() -+ * parameter nb_src/nb_dst should not exceed this value. -+ */ -+ uint16_t max_sges; -+ /** NUMA node connection, -1 if unknown. */ -+ int16_t numa_node; -+ /** Number of virtual DMA channel configured. */ -+ uint16_t nb_vchans; -+}; -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Retrieve information of a DMA device. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param[out] dev_info -+ * A pointer to a structure of type *rte_dma_info* to be filled with the -+ * information of the device. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_info_get(int16_t dev_id, struct rte_dma_info *dev_info); -+ -+/** -+ * A structure used to configure a DMA device. -+ * -+ * @see rte_dma_configure -+ */ -+struct rte_dma_conf { -+ /** The number of virtual DMA channels to set up for the DMA device. -+ * This value cannot be greater than the field 'max_vchans' of struct -+ * rte_dma_info which get from rte_dma_info_get(). -+ */ -+ uint16_t nb_vchans; -+ /** Indicates whether to enable silent mode. -+ * false-default mode, true-silent mode. -+ * This value can be set to true only when the SILENT capability is -+ * supported. -+ * -+ * @see RTE_DMA_CAPA_SILENT -+ */ -+ bool enable_silent; -+}; -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Configure a DMA device. -+ * -+ * This function must be invoked first before any other function in the -+ * API. This function can also be re-invoked when a device is in the -+ * stopped state. -+ * -+ * @param dev_id -+ * The identifier of the device to configure. -+ * @param dev_conf -+ * The DMA device configuration structure encapsulated into rte_dma_conf -+ * object. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_configure(int16_t dev_id, const struct rte_dma_conf *dev_conf); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Start a DMA device. -+ * -+ * The device start step is the last one and consists of setting the DMA -+ * to start accepting jobs. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_start(int16_t dev_id); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Stop a DMA device. -+ * -+ * The device can be restarted with a call to rte_dma_start(). -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_stop(int16_t dev_id); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Close a DMA device. -+ * -+ * The device cannot be restarted after this call. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_close(int16_t dev_id); -+ -+/** -+ * DMA transfer direction defines. -+ * -+ * @see struct rte_dma_vchan_conf::direction -+ */ -+enum rte_dma_direction { -+ /** DMA transfer direction - from memory to memory. -+ * -+ * @see struct rte_dma_vchan_conf::direction -+ */ -+ RTE_DMA_DIR_MEM_TO_MEM, -+ /** DMA transfer direction - from memory to device. -+ * In a typical scenario, the SoCs are installed on host servers as -+ * iNICs through the PCIe interface. In this case, the SoCs works in -+ * EP(endpoint) mode, it could initiate a DMA move request from memory -+ * (which is SoCs memory) to device (which is host memory). -+ * -+ * @see struct rte_dma_vchan_conf::direction -+ */ -+ RTE_DMA_DIR_MEM_TO_DEV, -+ /** DMA transfer direction - from device to memory. -+ * In a typical scenario, the SoCs are installed on host servers as -+ * iNICs through the PCIe interface. In this case, the SoCs works in -+ * EP(endpoint) mode, it could initiate a DMA move request from device -+ * (which is host memory) to memory (which is SoCs memory). -+ * -+ * @see struct rte_dma_vchan_conf::direction -+ */ -+ RTE_DMA_DIR_DEV_TO_MEM, -+ /** DMA transfer direction - from device to device. -+ * In a typical scenario, the SoCs are installed on host servers as -+ * iNICs through the PCIe interface. In this case, the SoCs works in -+ * EP(endpoint) mode, it could initiate a DMA move request from device -+ * (which is host memory) to the device (which is another host memory). -+ * -+ * @see struct rte_dma_vchan_conf::direction -+ */ -+ RTE_DMA_DIR_DEV_TO_DEV, -+}; -+ -+/** -+ * DMA access port type defines. -+ * -+ * @see struct rte_dma_port_param::port_type -+ */ -+enum rte_dma_port_type { -+ RTE_DMA_PORT_NONE, -+ RTE_DMA_PORT_PCIE, /**< The DMA access port is PCIe. */ -+}; -+ -+/** -+ * A structure used to descript DMA access port parameters. -+ * -+ * @see struct rte_dma_vchan_conf::src_port -+ * @see struct rte_dma_vchan_conf::dst_port -+ */ -+struct rte_dma_port_param { -+ /** The device access port type. -+ * -+ * @see enum rte_dma_port_type -+ */ -+ enum rte_dma_port_type port_type; -+ RTE_STD_C11 -+ union { -+ /** PCIe access port parameters. -+ * -+ * The following model shows SoC's PCIe module connects to -+ * multiple PCIe hosts and multiple endpoints. The PCIe module -+ * has an integrated DMA controller. -+ * -+ * If the DMA wants to access the memory of host A, it can be -+ * initiated by PF1 in core0, or by VF0 of PF0 in core0. -+ * -+ * \code{.unparsed} -+ * System Bus -+ * | ----------PCIe module---------- -+ * | Bus -+ * | Interface -+ * | ----- ------------------ -+ * | | | | PCIe Core0 | -+ * | | | | | ----------- -+ * | | | | PF-0 -- VF-0 | | Host A | -+ * | | |--------| |- VF-1 |--------| Root | -+ * | | | | PF-1 | | Complex | -+ * | | | | PF-2 | ----------- -+ * | | | ------------------ -+ * | | | -+ * | | | ------------------ -+ * | | | | PCIe Core1 | -+ * | | | | | ----------- -+ * | | | | PF-0 -- VF-0 | | Host B | -+ * |-----| |--------| PF-1 -- VF-0 |--------| Root | -+ * | | | | |- VF-1 | | Complex | -+ * | | | | PF-2 | ----------- -+ * | | | ------------------ -+ * | | | -+ * | | | ------------------ -+ * | |DMA| | | ------ -+ * | | | | |--------| EP | -+ * | | |--------| PCIe Core2 | ------ -+ * | | | | | ------ -+ * | | | | |--------| EP | -+ * | | | | | ------ -+ * | ----- ------------------ -+ * -+ * \endcode -+ * -+ * @note If some fields can not be supported by the -+ * hardware/driver, then the driver ignores those fields. -+ * Please check driver-specific documentation for limitations -+ * and capablites. -+ */ -+ __extension__ -+ struct { -+ uint64_t coreid : 4; /**< PCIe core id used. */ -+ uint64_t pfid : 8; /**< PF id used. */ -+ uint64_t vfen : 1; /**< VF enable bit. */ -+ uint64_t vfid : 16; /**< VF id used. */ -+ /** The pasid filed in TLP packet. */ -+ uint64_t pasid : 20; -+ /** The attributes filed in TLP packet. */ -+ uint64_t attr : 3; -+ /** The processing hint filed in TLP packet. */ -+ uint64_t ph : 2; -+ /** The steering tag filed in TLP packet. */ -+ uint64_t st : 16; -+ } pcie; -+ }; -+ uint64_t reserved[2]; /**< Reserved for future fields. */ -+}; -+ -+/** -+ * A structure used to configure a virtual DMA channel. -+ * -+ * @see rte_dma_vchan_setup -+ */ -+struct rte_dma_vchan_conf { -+ /** Transfer direction -+ * -+ * @see enum rte_dma_direction -+ */ -+ enum rte_dma_direction direction; -+ /** Number of descriptor for the virtual DMA channel */ -+ uint16_t nb_desc; -+ /** 1) Used to describes the device access port parameter in the -+ * device-to-memory transfer scenario. -+ * 2) Used to describes the source device access port parameter in the -+ * device-to-device transfer scenario. -+ * -+ * @see struct rte_dma_port_param -+ */ -+ struct rte_dma_port_param src_port; -+ /** 1) Used to describes the device access port parameter in the -+ * memory-to-device transfer scenario. -+ * 2) Used to describes the destination device access port parameter in -+ * the device-to-device transfer scenario. -+ * -+ * @see struct rte_dma_port_param -+ */ -+ struct rte_dma_port_param dst_port; -+}; -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Allocate and set up a virtual DMA channel. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. The value must be in the range -+ * [0, nb_vchans - 1] previously supplied to rte_dma_configure(). -+ * @param conf -+ * The virtual DMA channel configuration structure encapsulated into -+ * rte_dma_vchan_conf object. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_vchan_setup(int16_t dev_id, uint16_t vchan, -+ const struct rte_dma_vchan_conf *conf); -+ -+/** -+ * A structure used to retrieve statistics. -+ * -+ * @see rte_dma_stats_get -+ */ -+struct rte_dma_stats { -+ /** Count of operations which were submitted to hardware. */ -+ uint64_t submitted; -+ /** Count of operations which were completed, including successful and -+ * failed completions. -+ */ -+ uint64_t completed; -+ /** Count of operations which failed to complete. */ -+ uint64_t errors; -+}; -+ -+/** -+ * Special ID, which is used to represent all virtual DMA channels. -+ * -+ * @see rte_dma_stats_get -+ * @see rte_dma_stats_reset -+ */ -+#define RTE_DMA_ALL_VCHAN 0xFFFFu -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Retrieve basic statistics of a or all virtual DMA channel(s). -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * If equal RTE_DMA_ALL_VCHAN means all channels. -+ * @param[out] stats -+ * The basic statistics structure encapsulated into rte_dma_stats -+ * object. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_stats_get(int16_t dev_id, uint16_t vchan, -+ struct rte_dma_stats *stats); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Reset basic statistics of a or all virtual DMA channel(s). -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * If equal RTE_DMA_ALL_VCHAN means all channels. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_stats_reset(int16_t dev_id, uint16_t vchan); -+ -+/** -+ * device vchannel status -+ * -+ * Enum with the options for the channel status, either idle, active or halted due to error -+ * @see rte_dma_vchan_status -+ */ -+enum rte_dma_vchan_status { -+ RTE_DMA_VCHAN_IDLE, /**< not processing, awaiting ops */ -+ RTE_DMA_VCHAN_ACTIVE, /**< currently processing jobs */ -+ RTE_DMA_VCHAN_HALTED_ERROR, /**< not processing due to error, cannot accept new ops */ -+}; -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Determine if all jobs have completed on a device channel. -+ * This function is primarily designed for testing use, as it allows a process to check if -+ * all jobs are completed, without actually gathering completions from those jobs. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * @param[out] status -+ * The vchan status -+ * @return -+ * 0 - call completed successfully -+ * < 0 - error code indicating there was a problem calling the API -+ */ -+__rte_experimental -+int -+rte_dma_vchan_status(int16_t dev_id, uint16_t vchan, enum rte_dma_vchan_status *status); -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Dump DMA device info. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param f -+ * The file to write the output to. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+int rte_dma_dump(int16_t dev_id, FILE *f); -+ -+/** -+ * DMA transfer result status code defines. -+ * -+ * @see rte_dma_completed_status -+ */ -+enum rte_dma_status_code { -+ /** The operation completed successfully. */ -+ RTE_DMA_STATUS_SUCCESSFUL, -+ /** The operation failed to complete due abort by user. -+ * This is mainly used when processing dev_stop, user could modidy the -+ * descriptors (e.g. change one bit to tell hardware abort this job), -+ * it allows outstanding requests to be complete as much as possible, -+ * so reduce the time to stop the device. -+ */ -+ RTE_DMA_STATUS_USER_ABORT, -+ /** The operation failed to complete due to following scenarios: -+ * The jobs in a particular batch are not attempted because they -+ * appeared after a fence where a previous job failed. In some HW -+ * implementation it's possible for jobs from later batches would be -+ * completed, though, so report the status from the not attempted jobs -+ * before reporting those newer completed jobs. -+ */ -+ RTE_DMA_STATUS_NOT_ATTEMPTED, -+ /** The operation failed to complete due invalid source address. */ -+ RTE_DMA_STATUS_INVALID_SRC_ADDR, -+ /** The operation failed to complete due invalid destination address. */ -+ RTE_DMA_STATUS_INVALID_DST_ADDR, -+ /** The operation failed to complete due invalid source or destination -+ * address, cover the case that only knows the address error, but not -+ * sure which address error. -+ */ -+ RTE_DMA_STATUS_INVALID_ADDR, -+ /** The operation failed to complete due invalid length. */ -+ RTE_DMA_STATUS_INVALID_LENGTH, -+ /** The operation failed to complete due invalid opcode. -+ * The DMA descriptor could have multiple format, which are -+ * distinguished by the opcode field. -+ */ -+ RTE_DMA_STATUS_INVALID_OPCODE, -+ /** The operation failed to complete due bus read error. */ -+ RTE_DMA_STATUS_BUS_READ_ERROR, -+ /** The operation failed to complete due bus write error. */ -+ RTE_DMA_STATUS_BUS_WRITE_ERROR, -+ /** The operation failed to complete due bus error, cover the case that -+ * only knows the bus error, but not sure which direction error. -+ */ -+ RTE_DMA_STATUS_BUS_ERROR, -+ /** The operation failed to complete due data poison. */ -+ RTE_DMA_STATUS_DATA_POISION, -+ /** The operation failed to complete due descriptor read error. */ -+ RTE_DMA_STATUS_DESCRIPTOR_READ_ERROR, -+ /** The operation failed to complete due device link error. -+ * Used to indicates that the link error in the memory-to-device/ -+ * device-to-memory/device-to-device transfer scenario. -+ */ -+ RTE_DMA_STATUS_DEV_LINK_ERROR, -+ /** The operation failed to complete due lookup page fault. */ -+ RTE_DMA_STATUS_PAGE_FAULT, -+ /** The operation failed to complete due unknown reason. -+ * The initial value is 256, which reserves space for future errors. -+ */ -+ RTE_DMA_STATUS_ERROR_UNKNOWN = 0x100, -+}; -+ -+/** -+ * A structure used to hold scatter-gather DMA operation request entry. -+ * -+ * @see rte_dma_copy_sg -+ */ -+struct rte_dma_sge { -+ rte_iova_t addr; /**< The DMA operation address. */ -+ uint32_t length; /**< The DMA operation length. */ -+}; -+ -+#include "rte_dmadev_core.h" -+ -+/**@{@name DMA operation flag -+ * @see rte_dma_copy() -+ * @see rte_dma_copy_sg() -+ * @see rte_dma_fill() -+ */ -+/** Fence flag. -+ * It means the operation with this flag must be processed only after all -+ * previous operations are completed. -+ * If the specify DMA HW works in-order (it means it has default fence between -+ * operations), this flag could be NOP. -+ */ -+#define RTE_DMA_OP_FLAG_FENCE RTE_BIT64(0) -+/** Submit flag. -+ * It means the operation with this flag must issue doorbell to hardware after -+ * enqueued jobs. -+ */ -+#define RTE_DMA_OP_FLAG_SUBMIT RTE_BIT64(1) -+/** Write data to low level cache hint. -+ * Used for performance optimization, this is just a hint, and there is no -+ * capability bit for this, driver should not return error if this flag was set. -+ */ -+#define RTE_DMA_OP_FLAG_LLC RTE_BIT64(2) -+/**@}*/ -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Enqueue a copy operation onto the virtual DMA channel. -+ * -+ * This queues up a copy operation to be performed by hardware, if the 'flags' -+ * parameter contains RTE_DMA_OP_FLAG_SUBMIT then trigger doorbell to begin -+ * this operation, otherwise do not trigger doorbell. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * @param src -+ * The address of the source buffer. -+ * @param dst -+ * The address of the destination buffer. -+ * @param length -+ * The length of the data to be copied. -+ * @param flags -+ * An flags for this operation. -+ * @see RTE_DMA_OP_FLAG_* -+ * -+ * @return -+ * - 0..UINT16_MAX: index of enqueued job. -+ * - -ENOSPC: if no space left to enqueue. -+ * - other values < 0 on failure. -+ */ -+__rte_experimental -+static inline int -+rte_dma_copy(int16_t dev_id, uint16_t vchan, rte_iova_t src, rte_iova_t dst, -+ uint32_t length, uint64_t flags) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id) || length == 0) -+ return -EINVAL; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->copy, -ENOTSUP); -+#endif -+ -+ return (*obj->copy)(obj->dev_private, vchan, src, dst, length, flags); -+} -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Enqueue a scatter-gather list copy operation onto the virtual DMA channel. -+ * -+ * This queues up a scatter-gather list copy operation to be performed by -+ * hardware, if the 'flags' parameter contains RTE_DMA_OP_FLAG_SUBMIT then -+ * trigger doorbell to begin this operation, otherwise do not trigger doorbell. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * @param src -+ * The pointer of source scatter-gather entry array. -+ * @param dst -+ * The pointer of destination scatter-gather entry array. -+ * @param nb_src -+ * The number of source scatter-gather entry. -+ * @see struct rte_dma_info::max_sges -+ * @param nb_dst -+ * The number of destination scatter-gather entry. -+ * @see struct rte_dma_info::max_sges -+ * @param flags -+ * An flags for this operation. -+ * @see RTE_DMA_OP_FLAG_* -+ * -+ * @return -+ * - 0..UINT16_MAX: index of enqueued job. -+ * - -ENOSPC: if no space left to enqueue. -+ * - other values < 0 on failure. -+ */ -+__rte_experimental -+static inline int -+rte_dma_copy_sg(int16_t dev_id, uint16_t vchan, struct rte_dma_sge *src, -+ struct rte_dma_sge *dst, uint16_t nb_src, uint16_t nb_dst, -+ uint64_t flags) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id) || src == NULL || dst == NULL || -+ nb_src == 0 || nb_dst == 0) -+ return -EINVAL; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->copy_sg, -ENOTSUP); -+#endif -+ -+ return (*obj->copy_sg)(obj->dev_private, vchan, src, dst, nb_src, -+ nb_dst, flags); -+} -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Enqueue a fill operation onto the virtual DMA channel. -+ * -+ * This queues up a fill operation to be performed by hardware, if the 'flags' -+ * parameter contains RTE_DMA_OP_FLAG_SUBMIT then trigger doorbell to begin -+ * this operation, otherwise do not trigger doorbell. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * @param pattern -+ * The pattern to populate the destination buffer with. -+ * @param dst -+ * The address of the destination buffer. -+ * @param length -+ * The length of the destination buffer. -+ * @param flags -+ * An flags for this operation. -+ * @see RTE_DMA_OP_FLAG_* -+ * -+ * @return -+ * - 0..UINT16_MAX: index of enqueued job. -+ * - -ENOSPC: if no space left to enqueue. -+ * - other values < 0 on failure. -+ */ -+__rte_experimental -+static inline int -+rte_dma_fill(int16_t dev_id, uint16_t vchan, uint64_t pattern, -+ rte_iova_t dst, uint32_t length, uint64_t flags) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id) || length == 0) -+ return -EINVAL; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->fill, -ENOTSUP); -+#endif -+ -+ return (*obj->fill)(obj->dev_private, vchan, pattern, dst, length, -+ flags); -+} -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Trigger hardware to begin performing enqueued operations. -+ * -+ * This API is used to write the "doorbell" to the hardware to trigger it -+ * to begin the operations previously enqueued by rte_dma_copy/fill(). -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * -+ * @return -+ * 0 on success. Otherwise negative value is returned. -+ */ -+__rte_experimental -+static inline int -+rte_dma_submit(int16_t dev_id, uint16_t vchan) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id)) -+ return -EINVAL; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->submit, -ENOTSUP); -+#endif -+ -+ return (*obj->submit)(obj->dev_private, vchan); -+} -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Return the number of operations that have been successfully completed. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * @param nb_cpls -+ * The maximum number of completed operations that can be processed. -+ * @param[out] last_idx -+ * The last completed operation's ring_idx. -+ * If not required, NULL can be passed in. -+ * @param[out] has_error -+ * Indicates if there are transfer error. -+ * If not required, NULL can be passed in. -+ * -+ * @return -+ * The number of operations that successfully completed. This return value -+ * must be less than or equal to the value of nb_cpls. -+ */ -+__rte_experimental -+static inline uint16_t -+rte_dma_completed(int16_t dev_id, uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, bool *has_error) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ uint16_t idx; -+ bool err; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id) || nb_cpls == 0) -+ return 0; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->completed, 0); -+#endif -+ -+ /* Ensure the pointer values are non-null to simplify drivers. -+ * In most cases these should be compile time evaluated, since this is -+ * an inline function. -+ * - If NULL is explicitly passed as parameter, then compiler knows the -+ * value is NULL -+ * - If address of local variable is passed as parameter, then compiler -+ * can know it's non-NULL. -+ */ -+ if (last_idx == NULL) -+ last_idx = &idx; -+ if (has_error == NULL) -+ has_error = &err; -+ -+ *has_error = false; -+ return (*obj->completed)(obj->dev_private, vchan, nb_cpls, last_idx, -+ has_error); -+} -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Return the number of operations that have been completed, and the operations -+ * result may succeed or fail. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * @param nb_cpls -+ * Indicates the size of status array. -+ * @param[out] last_idx -+ * The last completed operation's ring_idx. -+ * If not required, NULL can be passed in. -+ * @param[out] status -+ * This is a pointer to an array of length 'nb_cpls' that holds the completion -+ * status code of each operation. -+ * @see enum rte_dma_status_code -+ * -+ * @return -+ * The number of operations that completed. This return value must be less -+ * than or equal to the value of nb_cpls. -+ * If this number is greater than zero (assuming n), then n values in the -+ * status array are also set. -+ */ -+__rte_experimental -+static inline uint16_t -+rte_dma_completed_status(int16_t dev_id, uint16_t vchan, -+ const uint16_t nb_cpls, uint16_t *last_idx, -+ enum rte_dma_status_code *status) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ uint16_t idx; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id) || nb_cpls == 0 || status == NULL) -+ return 0; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->completed_status, 0); -+#endif -+ -+ if (last_idx == NULL) -+ last_idx = &idx; -+ -+ return (*obj->completed_status)(obj->dev_private, vchan, nb_cpls, -+ last_idx, status); -+} -+ -+/** -+ * @warning -+ * @b EXPERIMENTAL: this API may change without prior notice. -+ * -+ * Check remaining capacity in descriptor ring for the current burst. -+ * -+ * @param dev_id -+ * The identifier of the device. -+ * @param vchan -+ * The identifier of virtual DMA channel. -+ * -+ * @return -+ * - Remaining space in the descriptor ring for the current burst. -+ * - 0 on error -+ */ -+__rte_experimental -+static inline uint16_t -+rte_dma_burst_capacity(int16_t dev_id, uint16_t vchan) -+{ -+ struct rte_dma_fp_object *obj = &rte_dma_fp_objs[dev_id]; -+ -+#ifdef RTE_DMADEV_DEBUG -+ if (!rte_dma_is_valid(dev_id)) -+ return 0; -+ RTE_FUNC_PTR_OR_ERR_RET(*obj->burst_capacity, 0); -+#endif -+ return (*obj->burst_capacity)(obj->dev_private, vchan); -+} -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#endif /* RTE_DMADEV_H */ -diff --git a/lib/librte_dmadev/rte_dmadev_core.h b/lib/librte_dmadev/rte_dmadev_core.h -new file mode 100644 -index 000000000..e42d8739a ---- /dev/null -+++ b/lib/librte_dmadev/rte_dmadev_core.h -@@ -0,0 +1,80 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ * Copyright(c) 2021 Intel Corporation -+ */ -+ -+#ifndef RTE_DMADEV_CORE_H -+#define RTE_DMADEV_CORE_H -+ -+/** -+ * @file -+ * -+ * DMA Device internal header. -+ * -+ * This header contains internal data types which are used by dataplane inline -+ * function. -+ * -+ * Applications should not use these functions directly. -+ */ -+ -+/** @internal Used to enqueue a copy operation. */ -+typedef int (*rte_dma_copy_t)(void *dev_private, uint16_t vchan, -+ rte_iova_t src, rte_iova_t dst, -+ uint32_t length, uint64_t flags); -+ -+/** @internal Used to enqueue a scatter-gather list copy operation. */ -+typedef int (*rte_dma_copy_sg_t)(void *dev_private, uint16_t vchan, -+ const struct rte_dma_sge *src, -+ const struct rte_dma_sge *dst, -+ uint16_t nb_src, uint16_t nb_dst, -+ uint64_t flags); -+ -+/** @internal Used to enqueue a fill operation. */ -+typedef int (*rte_dma_fill_t)(void *dev_private, uint16_t vchan, -+ uint64_t pattern, rte_iova_t dst, -+ uint32_t length, uint64_t flags); -+ -+/** @internal Used to trigger hardware to begin working. */ -+typedef int (*rte_dma_submit_t)(void *dev_private, uint16_t vchan); -+ -+/** @internal Used to return number of successful completed operations. */ -+typedef uint16_t (*rte_dma_completed_t)(void *dev_private, -+ uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, bool *has_error); -+ -+/** @internal Used to return number of completed operations. */ -+typedef uint16_t (*rte_dma_completed_status_t)(void *dev_private, -+ uint16_t vchan, const uint16_t nb_cpls, -+ uint16_t *last_idx, enum rte_dma_status_code *status); -+ -+/** @internal Used to check the remaining space in descriptor ring. */ -+typedef uint16_t (*rte_dma_burst_capacity_t)(const void *dev_private, uint16_t vchan); -+ -+/** -+ * @internal -+ * Fast-path dmadev functions and related data are hold in a flat array. -+ * One entry per dmadev. -+ * -+ * This structure occupy exactly 128B which reserve space for future IO -+ * functions. -+ * -+ * The 'dev_private' field was placed in the first cache line to optimize -+ * performance because the PMD driver mainly depends on this field. -+ */ -+struct rte_dma_fp_object { -+ /** PMD-specific private data. The driver should copy -+ * rte_dma_dev.data->dev_private to this field during initialization. -+ */ -+ void *dev_private; -+ rte_dma_copy_t copy; -+ rte_dma_copy_sg_t copy_sg; -+ rte_dma_fill_t fill; -+ rte_dma_submit_t submit; -+ rte_dma_completed_t completed; -+ rte_dma_completed_status_t completed_status; -+ rte_dma_burst_capacity_t burst_capacity; -+} __rte_aligned(128); -+ -+extern struct rte_dma_fp_object *rte_dma_fp_objs; -+ -+#endif /* RTE_DMADEV_CORE_H */ -diff --git a/lib/librte_dmadev/rte_dmadev_pmd.h b/lib/librte_dmadev/rte_dmadev_pmd.h -new file mode 100644 -index 000000000..5316ad5b5 ---- /dev/null -+++ b/lib/librte_dmadev/rte_dmadev_pmd.h -@@ -0,0 +1,171 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(c) 2021 HiSilicon Limited -+ */ -+ -+#ifndef RTE_DMADEV_PMD_H -+#define RTE_DMADEV_PMD_H -+ -+/** -+ * @file -+ * -+ * DMA Device PMD interface -+ * -+ * Driver facing interface for a DMA device. These are not to be called directly -+ * by any application. -+ */ -+ -+#include "rte_dmadev.h" -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+struct rte_dma_dev; -+ -+/** @internal Used to get device information of a device. */ -+typedef int (*rte_dma_info_get_t)(const struct rte_dma_dev *dev, -+ struct rte_dma_info *dev_info, -+ uint32_t info_sz); -+ -+/** @internal Used to configure a device. */ -+typedef int (*rte_dma_configure_t)(struct rte_dma_dev *dev, -+ const struct rte_dma_conf *dev_conf, -+ uint32_t conf_sz); -+ -+/** @internal Used to start a configured device. */ -+typedef int (*rte_dma_start_t)(struct rte_dma_dev *dev); -+ -+/** @internal Used to stop a configured device. */ -+typedef int (*rte_dma_stop_t)(struct rte_dma_dev *dev); -+ -+/** @internal Used to close a configured device. */ -+typedef int (*rte_dma_close_t)(struct rte_dma_dev *dev); -+ -+/** @internal Used to allocate and set up a virtual DMA channel. */ -+typedef int (*rte_dma_vchan_setup_t)(struct rte_dma_dev *dev, uint16_t vchan, -+ const struct rte_dma_vchan_conf *conf, -+ uint32_t conf_sz); -+ -+/** @internal Used to retrieve basic statistics. */ -+typedef int (*rte_dma_stats_get_t)(const struct rte_dma_dev *dev, -+ uint16_t vchan, struct rte_dma_stats *stats, -+ uint32_t stats_sz); -+ -+/** @internal Used to reset basic statistics. */ -+typedef int (*rte_dma_stats_reset_t)(struct rte_dma_dev *dev, uint16_t vchan); -+ -+/** @internal Used to check if a virtual channel has finished all jobs. */ -+typedef int (*rte_dma_vchan_status_t)(const struct rte_dma_dev *dev, uint16_t vchan, -+ enum rte_dma_vchan_status *status); -+ -+/** @internal Used to dump internal information. */ -+typedef int (*rte_dma_dump_t)(const struct rte_dma_dev *dev, FILE *f); -+ -+/** -+ * DMA device operations function pointer table. -+ * -+ * @see struct rte_dma_dev:dev_ops -+ */ -+struct rte_dma_dev_ops { -+ rte_dma_info_get_t dev_info_get; -+ rte_dma_configure_t dev_configure; -+ rte_dma_start_t dev_start; -+ rte_dma_stop_t dev_stop; -+ rte_dma_close_t dev_close; -+ -+ rte_dma_vchan_setup_t vchan_setup; -+ -+ rte_dma_stats_get_t stats_get; -+ rte_dma_stats_reset_t stats_reset; -+ -+ rte_dma_vchan_status_t vchan_status; -+ rte_dma_dump_t dev_dump; -+}; -+ -+/** -+ * @internal -+ * The data part, with no function pointers, associated with each DMA device. -+ * -+ * This structure is safe to place in shared memory to be common among different -+ * processes in a multi-process configuration. -+ * -+ * @see struct rte_dma_dev::data -+ */ -+struct rte_dma_dev_data { -+ char dev_name[RTE_DEV_NAME_MAX_LEN]; /**< Unique identifier name */ -+ int16_t dev_id; /**< Device [external] identifier. */ -+ int16_t numa_node; /**< Local NUMA memory ID. -1 if unknown. */ -+ void *dev_private; /**< PMD-specific private data. */ -+ struct rte_dma_conf dev_conf; /**< DMA device configuration. */ -+ __extension__ -+ uint8_t dev_started : 1; /**< Device state: STARTED(1)/STOPPED(0). */ -+ uint64_t reserved[2]; /**< Reserved for future fields */ -+} __rte_cache_aligned; -+ -+/** -+ * Possible states of a DMA device. -+ * -+ * @see struct rte_dma_dev::state -+ */ -+enum rte_dma_dev_state { -+ RTE_DMA_DEV_UNUSED = 0, /**< Device is unused. */ -+ /** Device is registered, but not ready to be used. */ -+ RTE_DMA_DEV_REGISTERED, -+ /** Device is ready for use. This is set by the PMD. */ -+ RTE_DMA_DEV_READY, -+}; -+ -+/** -+ * @internal -+ * The generic data structure associated with each DMA device. -+ */ -+struct rte_dma_dev { -+ /** Device info which supplied during device initialization. */ -+ struct rte_device *device; -+ struct rte_dma_dev_data *data; /**< Pointer to shared device data. */ -+ /**< Fast-path functions and related data. */ -+ struct rte_dma_fp_object *fp_obj; -+ /** Functions implemented by PMD. */ -+ const struct rte_dma_dev_ops *dev_ops; -+ enum rte_dma_dev_state state; /**< Flag indicating the device state. */ -+ uint64_t reserved[2]; /**< Reserved for future fields. */ -+} __rte_cache_aligned; -+ -+/** -+ * @internal -+ * Allocate a new dmadev slot for an DMA device and return the pointer to that -+ * slot for the driver to use. -+ * -+ * @param name -+ * DMA device name. -+ * @param numa_node -+ * Driver's private data's NUMA node. -+ * @param private_data_size -+ * Driver's private data size. -+ * -+ * @return -+ * A pointer to the DMA device slot case of success, -+ * NULL otherwise. -+ */ -+__rte_internal -+struct rte_dma_dev *rte_dma_pmd_allocate(const char *name, int numa_node, -+ size_t private_data_size); -+ -+/** -+ * @internal -+ * Release the specified dmadev. -+ * -+ * @param name -+ * DMA device name. -+ * -+ * @return -+ * - 0 on success, negative on error. -+ */ -+__rte_internal -+int rte_dma_pmd_release(const char *name); -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#endif /* RTE_DMADEV_PMD_H */ -diff --git a/lib/librte_dmadev/version.map b/lib/librte_dmadev/version.map -new file mode 100644 -index 000000000..7031d6b33 ---- /dev/null -+++ b/lib/librte_dmadev/version.map -@@ -0,0 +1,31 @@ -+EXPERIMENTAL { -+ global: -+ -+ rte_dma_close; -+ rte_dma_configure; -+ rte_dma_count_avail; -+ rte_dma_dev_max; -+ rte_dma_dump; -+ rte_dma_get_dev_id_by_name; -+ rte_dma_info_get; -+ rte_dma_is_valid; -+ rte_dma_next_dev; -+ rte_dma_start; -+ rte_dma_stats_get; -+ rte_dma_stats_reset; -+ rte_dma_stop; -+ rte_dma_vchan_setup; -+ rte_dma_vchan_status; -+ -+ local: *; -+}; -+ -+INTERNAL { -+ global: -+ -+ rte_dma_fp_objs; -+ rte_dma_pmd_allocate; -+ rte_dma_pmd_release; -+ -+ local: *; -+}; -diff --git a/lib/meson.build b/lib/meson.build -index ed00f8914..86106240d 100644 ---- a/lib/meson.build -+++ b/lib/meson.build -@@ -25,7 +25,7 @@ libraries = [ - 'gro', 'gso', 'ip_frag', 'jobstats', - 'kni', 'latencystats', 'lpm', 'member', - 'power', 'pdump', 'rawdev', 'regexdev', -- 'rib', 'reorder', 'sched', 'security', 'stack', 'vhost', -+ 'rib', 'reorder', 'sched', 'security', 'stack', 'vhost', 'dmadev', - # ipsec lib depends on net, crypto and security - 'ipsec', - #fib lib depends on rib --- -2.23.0 - diff --git a/0236-net-hns3-rename-multicast-address-function.patch b/0236-net-hns3-rename-multicast-address-function.patch deleted file mode 100644 index cf3067b..0000000 --- a/0236-net-hns3-rename-multicast-address-function.patch +++ /dev/null @@ -1,75 +0,0 @@ -From d7faa4a4fee44a2fdaa003e3ab8df477d710f76c Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:52 +0800 -Subject: [PATCH 03/33] net/hns3: rename multicast address function - -This patch renames hns3_add_mc_addr() to hns3_add_mc_mac_addr(). - -Signed-off-by: Huisong Li ---- - drivers/net/hns3/hns3_ethdev.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2ae4cb9b7..b67386b1f 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -95,8 +95,8 @@ static int hns3_vlan_pvid_configure(struct hns3_adapter *hns, uint16_t pvid, - static int hns3_update_link_info(struct rte_eth_dev *eth_dev); - static bool hns3_update_link_status(struct hns3_hw *hw); - --static int hns3_add_mc_addr(struct hns3_hw *hw, -- struct rte_ether_addr *mac_addr); -+static int hns3_add_mc_mac_addr(struct hns3_hw *hw, -+ struct rte_ether_addr *mac_addr); - static int hns3_remove_mc_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); - static int hns3_restore_fec(struct hns3_hw *hw); -@@ -1630,7 +1630,7 @@ hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - } - } - -- ret = hns3_add_mc_addr(hw, mac_addr); -+ ret = hns3_add_mc_mac_addr(hw, mac_addr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); -@@ -1826,7 +1826,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - continue; - if (rte_is_multicast_ether_addr(addr)) - ret = del ? hns3_remove_mc_addr(hw, addr) : -- hns3_add_mc_addr(hw, addr); -+ hns3_add_mc_mac_addr(hw, addr); - else - ret = del ? hns3_remove_uc_addr_common(hw, addr) : - hns3_add_uc_addr_common(hw, addr); -@@ -1872,7 +1872,7 @@ hns3_update_desc_vfid(struct hns3_cmd_desc *desc, uint8_t vfid, bool clr) - } - - static int --hns3_add_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) -+hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { - struct hns3_cmd_desc desc[HNS3_MC_MAC_VLAN_OPS_DESC_NUM]; - struct hns3_mac_vlan_tbl_entry_cmd req; -@@ -2156,7 +2156,7 @@ hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - /* Add mc mac addresses */ - for (i = 0; i < add_addr_num; i++) { - addr = &add_addr_list[i]; -- ret = hns3_add_mc_addr(hw, addr); -+ ret = hns3_add_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -2188,7 +2188,7 @@ hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - if (del) - ret = hns3_remove_mc_addr(hw, addr); - else -- ret = hns3_add_mc_addr(hw, addr); -+ ret = hns3_add_mc_mac_addr(hw, addr); - if (ret) { - err = ret; - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, --- -2.33.0 - diff --git a/0237-net-hns3-rename-unicast-address-function.patch b/0237-net-hns3-rename-unicast-address-function.patch deleted file mode 100644 index 14441af..0000000 --- a/0237-net-hns3-rename-unicast-address-function.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 5182a373038fc21368ffb61450e5e63d63471d4f Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:53 +0800 -Subject: [PATCH 04/33] net/hns3: rename unicast address function - -This patch renames hns3_add_uc_addr() to hns3_add_uc_mac_addr(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index b67386b1f..83472a83b 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1540,7 +1540,7 @@ hns3_remove_mac_vlan_tbl(struct hns3_hw *hw, - } - - static int --hns3_add_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) -+hns3_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_mac_vlan_tbl_entry_cmd req; -@@ -1678,7 +1678,7 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - if (rte_is_multicast_ether_addr(mac_addr)) - ret = hns3_add_mc_addr_common(hw, mac_addr); - else -- ret = hns3_add_uc_addr_common(hw, mac_addr); -+ ret = hns3_add_uc_mac_addr(hw, mac_addr); - - if (ret) { - rte_spinlock_unlock(&hw->lock); -@@ -1768,7 +1768,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - return ret; - } - -- ret = hns3_add_uc_addr_common(hw, mac_addr); -+ ret = hns3_add_uc_mac_addr(hw, mac_addr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); -@@ -1799,7 +1799,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - } - - err_add_uc_addr: -- ret_val = hns3_add_uc_addr_common(hw, oaddr); -+ ret_val = hns3_add_uc_mac_addr(hw, oaddr); - if (ret_val) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); - hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", -@@ -1829,7 +1829,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - hns3_add_mc_mac_addr(hw, addr); - else - ret = del ? hns3_remove_uc_addr_common(hw, addr) : -- hns3_add_uc_addr_common(hw, addr); -+ hns3_add_uc_mac_addr(hw, addr); - - if (ret) { - err = ret; --- -2.33.0 - diff --git a/0238-net-hns3-rename-multicast-address-removal-function.patch b/0238-net-hns3-rename-multicast-address-removal-function.patch deleted file mode 100644 index 15f1279..0000000 --- a/0238-net-hns3-rename-multicast-address-removal-function.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 11e3b4820eba69f93a623565609fa3e48de6dbdb Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:54 +0800 -Subject: [PATCH 05/33] net/hns3: rename multicast address removal function - -This patch renames hns3_remove_mc_addr() to hns3_remove_mc_mac_addr(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 83472a83b..e0ec99811 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -97,8 +97,8 @@ static bool hns3_update_link_status(struct hns3_hw *hw); - - static int hns3_add_mc_mac_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); --static int hns3_remove_mc_addr(struct hns3_hw *hw, -- struct rte_ether_addr *mac_addr); -+static int hns3_remove_mc_mac_addr(struct hns3_hw *hw, -+ struct rte_ether_addr *mac_addr); - static int hns3_restore_fec(struct hns3_hw *hw); - static int hns3_query_dev_fec_info(struct hns3_hw *hw); - static int hns3_do_stop(struct hns3_adapter *hns); -@@ -1646,7 +1646,7 @@ hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - int ret; - -- ret = hns3_remove_mc_addr(hw, mac_addr); -+ ret = hns3_remove_mc_mac_addr(hw, mac_addr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); -@@ -1825,7 +1825,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - if (rte_is_zero_ether_addr(addr)) - continue; - if (rte_is_multicast_ether_addr(addr)) -- ret = del ? hns3_remove_mc_addr(hw, addr) : -+ ret = del ? hns3_remove_mc_mac_addr(hw, addr) : - hns3_add_mc_mac_addr(hw, addr); - else - ret = del ? hns3_remove_uc_addr_common(hw, addr) : -@@ -1921,7 +1921,7 @@ hns3_add_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - } - - static int --hns3_remove_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) -+hns3_remove_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { - struct hns3_mac_vlan_tbl_entry_cmd req; - struct hns3_cmd_desc desc[3]; -@@ -2145,7 +2145,7 @@ hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - for (i = 0; i < rm_addr_num; i++) { - num = rm_addr_num - i - 1; - addr = &rm_addr_list[num]; -- ret = hns3_remove_mc_addr(hw, addr); -+ ret = hns3_remove_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -2186,7 +2186,7 @@ hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - if (!rte_is_multicast_ether_addr(addr)) - continue; - if (del) -- ret = hns3_remove_mc_addr(hw, addr); -+ ret = hns3_remove_mc_mac_addr(hw, addr); - else - ret = hns3_add_mc_mac_addr(hw, addr); - if (ret) { --- -2.33.0 - diff --git a/0239-net-hns3-extract-common-interface-to-check-duplicate.patch b/0239-net-hns3-extract-common-interface-to-check-duplicate.patch deleted file mode 100644 index e8d00ea..0000000 --- a/0239-net-hns3-extract-common-interface-to-check-duplicate.patch +++ /dev/null @@ -1,114 +0,0 @@ -From e7ad3ead98f61e7f759293ad05dfe48627c72e2c Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:55 +0800 -Subject: [PATCH 06/33] net/hns3: extract common interface to check duplicates - -Extract a common interface for PF and VF to check whether the configured -multicast MAC address from rte_eth_dev_mac_addr_add() is the same as the -multicast MAC address from rte_eth_dev_set_mc_addr_list(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 25 ++++++++++++++++++------- - drivers/net/hns3/hns3_ethdev.h | 4 ++++ - drivers/net/hns3/hns3_ethdev_vf.c | 16 ++-------------- - 3 files changed, 24 insertions(+), 21 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index e0ec99811..f1346ee9f 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1609,27 +1609,38 @@ hns3_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static int --hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) -+bool -+hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) - { - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - struct rte_ether_addr *addr; -- int ret; - int i; - - for (i = 0; i < hw->mc_addrs_num; i++) { - addr = &hw->mc_addrs[i]; -- /* Check if there are duplicate addresses */ -- if (rte_is_same_ether_addr(addr, mac_addr)) { -+ /* Check if there are duplicate addresses in mc_addrs[] */ -+ if (rte_is_same_ether_addr(addr, mc_addr)) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -+ addr); - hns3_err(hw, "failed to add mc mac addr, same addrs" - "(%s) is added by the set_mc_mac_addr_list " - "API", mac_str); -- return -EINVAL; -+ return true; - } - } - -+ return false; -+} -+ -+static int -+hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) -+{ -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ int ret; -+ -+ if (hns3_find_duplicate_mc_addr(hw, mac_addr)) -+ return -EINVAL; -+ - ret = hns3_add_mc_mac_addr(hw, mac_addr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 84f5a9f29..a97406198 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1049,6 +1049,10 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); - void hns3_parse_devargs(struct rte_eth_dev *dev); - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); -+ -+bool hns3_find_duplicate_mc_addr(struct hns3_hw *hw, -+ struct rte_ether_addr *mc_addr); -+ - int hns3_restore_ptp(struct hns3_adapter *hns); - int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, - struct rte_eth_conf *conf); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 29313c2f7..f60849606 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -208,22 +208,10 @@ static int - hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct rte_ether_addr *addr; - int ret; -- int i; - -- for (i = 0; i < hw->mc_addrs_num; i++) { -- addr = &hw->mc_addrs[i]; -- /* Check if there are duplicate addresses */ -- if (rte_is_same_ether_addr(addr, mac_addr)) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to add mc mac addr, same addrs" -- "(%s) is added by the set_mc_mac_addr_list " -- "API", mac_str); -- return -EINVAL; -- } -- } -+ if (hns3_find_duplicate_mc_addr(hw, mac_addr)) -+ return -EINVAL; - - ret = hns3vf_add_mc_mac_addr(hw, mac_addr); - if (ret) { --- -2.33.0 - diff --git a/0240-net-hns3-remove-redundant-multicast-MAC-interface.patch b/0240-net-hns3-remove-redundant-multicast-MAC-interface.patch deleted file mode 100644 index f23b4e1..0000000 --- a/0240-net-hns3-remove-redundant-multicast-MAC-interface.patch +++ /dev/null @@ -1,117 +0,0 @@ -From b84b0e518dc64f3aada5b30511db1c6f6fdb0694 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:56 +0800 -Subject: [PATCH 07/33] net/hns3: remove redundant multicast MAC interface - -This patch removes hns3_add_mc_addr_common() in PF and -hns3vf_add_mc_addr_common() in VF. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 31 ++++++++----------------------- - drivers/net/hns3/hns3_ethdev_vf.c | 30 ++++++++---------------------- - 2 files changed, 16 insertions(+), 45 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index f1346ee9f..7f4419c54 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1632,25 +1632,6 @@ hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) - return false; - } - --static int --hns3_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- if (hns3_find_duplicate_mc_addr(hw, mac_addr)) -- return -EINVAL; -- -- ret = hns3_add_mc_mac_addr(hw, mac_addr); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to add mc mac addr(%s), ret = %d", -- mac_str, ret); -- } -- return ret; --} -- - static int - hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { -@@ -1686,11 +1667,15 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - * using the rte_eth_dev_mac_addr_add API function to set MC mac address - * may affect the specifications of UC mac addresses. - */ -- if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hns3_add_mc_addr_common(hw, mac_addr); -- else -+ if (rte_is_multicast_ether_addr(mac_addr)) { -+ if (hns3_find_duplicate_mc_addr(hw, mac_addr)) { -+ rte_spinlock_unlock(&hw->lock); -+ return -EINVAL; -+ } -+ ret = hns3_add_mc_mac_addr(hw, mac_addr); -+ } else { - ret = hns3_add_uc_mac_addr(hw, mac_addr); -- -+ } - if (ret) { - rte_spinlock_unlock(&hw->lock); - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index f60849606..92673d29b 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -204,25 +204,6 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static int --hns3vf_add_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- if (hns3_find_duplicate_mc_addr(hw, mac_addr)) -- return -EINVAL; -- -- ret = hns3vf_add_mc_mac_addr(hw, mac_addr); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to add mc mac addr(%s), ret = %d", -- mac_str, ret); -- } -- return ret; --} -- - static int - hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, -@@ -243,10 +224,15 @@ hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - * using the rte_eth_dev_mac_addr_add API function to set MC mac address - * may affect the specifications of UC mac addresses. - */ -- if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hns3vf_add_mc_addr_common(hw, mac_addr); -- else -+ if (rte_is_multicast_ether_addr(mac_addr)) { -+ if (hns3_find_duplicate_mc_addr(hw, mac_addr)) { -+ rte_spinlock_unlock(&hw->lock); -+ return -EINVAL; -+ } -+ ret = hns3vf_add_mc_mac_addr(hw, mac_addr); -+ } else { - ret = hns3vf_add_uc_mac_addr(hw, mac_addr); -+ } - - rte_spinlock_unlock(&hw->lock); - if (ret) { --- -2.33.0 - diff --git a/0241-net-hns3-rename-unicast-address-removal-function.patch b/0241-net-hns3-rename-unicast-address-removal-function.patch deleted file mode 100644 index 03175c3..0000000 --- a/0241-net-hns3-rename-unicast-address-removal-function.patch +++ /dev/null @@ -1,66 +0,0 @@ -From d89d75e54b10a18d40306e3dcc8921275cc9b81b Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:57 +0800 -Subject: [PATCH 08/33] net/hns3: rename unicast address removal function - -This patch renames hns3_remove_uc_addr_common() to -hns3_remove_uc_mac_addr() in PF. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 7f4419c54..485995a43 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1691,7 +1691,7 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - } - - static int --hns3_remove_uc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) -+hns3_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { - struct hns3_mac_vlan_tbl_entry_cmd req; - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -@@ -1732,7 +1732,7 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - if (rte_is_multicast_ether_addr(mac_addr)) - ret = hns3_remove_mc_addr_common(hw, mac_addr); - else -- ret = hns3_remove_uc_addr_common(hw, mac_addr); -+ ret = hns3_remove_uc_mac_addr(hw, mac_addr); - rte_spinlock_unlock(&hw->lock); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -@@ -1753,7 +1753,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - - rte_spinlock_lock(&hw->lock); - oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; -- ret = hns3_remove_uc_addr_common(hw, oaddr); -+ ret = hns3_remove_uc_mac_addr(hw, oaddr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - oaddr); -@@ -1785,7 +1785,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - return 0; - - err_pause_addr_cfg: -- ret_val = hns3_remove_uc_addr_common(hw, mac_addr); -+ ret_val = hns3_remove_uc_mac_addr(hw, mac_addr); - if (ret_val) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); -@@ -1824,7 +1824,7 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - ret = del ? hns3_remove_mc_mac_addr(hw, addr) : - hns3_add_mc_mac_addr(hw, addr); - else -- ret = del ? hns3_remove_uc_addr_common(hw, addr) : -+ ret = del ? hns3_remove_uc_mac_addr(hw, addr) : - hns3_add_uc_mac_addr(hw, addr); - - if (ret) { --- -2.33.0 - diff --git a/0242-net-hns3-remove-redundant-multicast-removal-interfac.patch b/0242-net-hns3-remove-redundant-multicast-removal-interfac.patch deleted file mode 100644 index f2aa98c..0000000 --- a/0242-net-hns3-remove-redundant-multicast-removal-interfac.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 3e96668301de4168ef51a6b43535b851c25290da Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:58 +0800 -Subject: [PATCH 09/33] net/hns3: remove redundant multicast removal interface - -This patch removes redundant hns3_remove_mc_addr_common(), which can be -replaced by hns3_remove_mc_mac_addr(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 18 +----------------- - 1 file changed, 1 insertion(+), 17 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 485995a43..a2d365a28 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1632,22 +1632,6 @@ hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) - return false; - } - --static int --hns3_remove_mc_addr_common(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- ret = hns3_remove_mc_mac_addr(hw, mac_addr); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to remove mc mac addr(%s), ret = %d", -- mac_str, ret); -- } -- return ret; --} -- - static int - hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, __rte_unused uint32_t pool) -@@ -1730,7 +1714,7 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - rte_spinlock_lock(&hw->lock); - - if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hns3_remove_mc_addr_common(hw, mac_addr); -+ ret = hns3_remove_mc_mac_addr(hw, mac_addr); - else - ret = hns3_remove_uc_mac_addr(hw, mac_addr); - rte_spinlock_unlock(&hw->lock); --- -2.33.0 - diff --git a/0243-net-hns3-add-HW-ops-structure-to-operate-hardware.patch b/0243-net-hns3-add-HW-ops-structure-to-operate-hardware.patch deleted file mode 100644 index 36f62c9..0000000 --- a/0243-net-hns3-add-HW-ops-structure-to-operate-hardware.patch +++ /dev/null @@ -1,106 +0,0 @@ -From ce3a4cda823aabc34c9166022b0cdb102723ef2a Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:19:59 +0800 -Subject: [PATCH 10/33] net/hns3: add HW ops structure to operate hardware - -This patch adds hns3_hw_ops structure to operate hardware in PF and VF -driver. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 10 ++++++++++ - drivers/net/hns3/hns3_ethdev.h | 13 +++++++++++++ - drivers/net/hns3/hns3_ethdev_vf.c | 10 ++++++++++ - 3 files changed, 33 insertions(+) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index a2d365a28..48c6483e1 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -7478,6 +7478,15 @@ static const struct hns3_reset_ops hns3_reset_ops = { - .start_service = hns3_start_service, - }; - -+static void -+hns3_init_hw_ops(struct hns3_hw *hw) -+{ -+ hw->ops.add_mc_mac_addr = hns3_add_mc_mac_addr; -+ hw->ops.del_mc_mac_addr = hns3_remove_mc_mac_addr; -+ hw->ops.add_uc_mac_addr = hns3_add_uc_mac_addr; -+ hw->ops.del_uc_mac_addr = hns3_remove_uc_mac_addr; -+} -+ - static int - hns3_dev_init(struct rte_eth_dev *eth_dev) - { -@@ -7530,6 +7539,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - goto err_init_reset; - hw->reset.ops = &hns3_reset_ops; - -+ hns3_init_hw_ops(hw); - ret = hns3_init_pf(eth_dev); - if (ret) { - PMD_INIT_LOG(ERR, "Failed to init pf: %d", ret); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index a97406198..73947e194 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -428,6 +428,17 @@ struct hns3_reset_data { - struct hns3_wait_data *wait_data; - }; - -+struct hns3_hw_ops { -+ int (*add_mc_mac_addr)(struct hns3_hw *hw, -+ struct rte_ether_addr *mac_addr); -+ int (*del_mc_mac_addr)(struct hns3_hw *hw, -+ struct rte_ether_addr *mac_addr); -+ int (*add_uc_mac_addr)(struct hns3_hw *hw, -+ struct rte_ether_addr *mac_addr); -+ int (*del_uc_mac_addr)(struct hns3_hw *hw, -+ struct rte_ether_addr *mac_addr); -+}; -+ - #define HNS3_INTR_MAPPING_VEC_RSV_ONE 0 - #define HNS3_INTR_MAPPING_VEC_ALL 1 - -@@ -638,6 +649,8 @@ struct hns3_hw { - struct hns3_rss_filter_list flow_rss_list; /* flow RSS rule list */ - struct hns3_flow_mem_list flow_list; - -+ struct hns3_hw_ops ops; -+ - /* - * PMD setup and configuration is not thread safe. Since it is not - * performance sensitive, it is better to guarantee thread-safety -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 92673d29b..1020b42e1 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2920,6 +2920,15 @@ static const struct hns3_reset_ops hns3vf_reset_ops = { - .start_service = hns3vf_start_service, - }; - -+static void -+hns3vf_init_hw_ops(struct hns3_hw *hw) -+{ -+ hw->ops.add_mc_mac_addr = hns3vf_add_mc_mac_addr; -+ hw->ops.del_mc_mac_addr = hns3vf_remove_mc_mac_addr; -+ hw->ops.add_uc_mac_addr = hns3vf_add_uc_mac_addr; -+ hw->ops.del_uc_mac_addr = hns3vf_remove_uc_mac_addr; -+} -+ - static int - hns3vf_dev_init(struct rte_eth_dev *eth_dev) - { -@@ -2964,6 +2973,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - goto err_init_reset; - hw->reset.ops = &hns3vf_reset_ops; - -+ hns3vf_init_hw_ops(hw); - ret = hns3vf_init_vf(eth_dev); - if (ret) { - PMD_INIT_LOG(ERR, "Failed to init vf: %d", ret); --- -2.33.0 - diff --git a/0244-net-hns3-use-HW-ops-to-config-MAC-features.patch b/0244-net-hns3-use-HW-ops-to-config-MAC-features.patch deleted file mode 100644 index 2529e4d..0000000 --- a/0244-net-hns3-use-HW-ops-to-config-MAC-features.patch +++ /dev/null @@ -1,213 +0,0 @@ -From 6e06ab138687a620035dbc3643c115d2199f5058 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:20:00 +0800 -Subject: [PATCH 11/33] net/hns3: use HW ops to config MAC features - -This patch uses APIs in hns3_hw_ops to configure MAC related features. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 32 +++++++++++++++---------------- - drivers/net/hns3/hns3_ethdev_vf.c | 27 +++++++++++++------------- - 2 files changed, 30 insertions(+), 29 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 48c6483e1..00016d58e 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1656,9 +1656,9 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - rte_spinlock_unlock(&hw->lock); - return -EINVAL; - } -- ret = hns3_add_mc_mac_addr(hw, mac_addr); -+ ret = hw->ops.add_mc_mac_addr(hw, mac_addr); - } else { -- ret = hns3_add_uc_mac_addr(hw, mac_addr); -+ ret = hw->ops.add_uc_mac_addr(hw, mac_addr); - } - if (ret) { - rte_spinlock_unlock(&hw->lock); -@@ -1714,9 +1714,9 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - rte_spinlock_lock(&hw->lock); - - if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hns3_remove_mc_mac_addr(hw, mac_addr); -+ ret = hw->ops.del_mc_mac_addr(hw, mac_addr); - else -- ret = hns3_remove_uc_mac_addr(hw, mac_addr); -+ ret = hw->ops.del_uc_mac_addr(hw, mac_addr); - rte_spinlock_unlock(&hw->lock); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -@@ -1737,7 +1737,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - - rte_spinlock_lock(&hw->lock); - oaddr = (struct rte_ether_addr *)hw->mac.mac_addr; -- ret = hns3_remove_uc_mac_addr(hw, oaddr); -+ ret = hw->ops.del_uc_mac_addr(hw, oaddr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - oaddr); -@@ -1748,7 +1748,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - return ret; - } - -- ret = hns3_add_uc_mac_addr(hw, mac_addr); -+ ret = hw->ops.add_uc_mac_addr(hw, mac_addr); - if (ret) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); -@@ -1769,7 +1769,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - return 0; - - err_pause_addr_cfg: -- ret_val = hns3_remove_uc_mac_addr(hw, mac_addr); -+ ret_val = hw->ops.del_uc_mac_addr(hw, mac_addr); - if (ret_val) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); -@@ -1779,7 +1779,7 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - } - - err_add_uc_addr: -- ret_val = hns3_add_uc_mac_addr(hw, oaddr); -+ ret_val = hw->ops.add_uc_mac_addr(hw, oaddr); - if (ret_val) { - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, oaddr); - hns3_warn(hw, "Failed to restore old uc mac addr(%s): %d", -@@ -1805,11 +1805,11 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - if (rte_is_zero_ether_addr(addr)) - continue; - if (rte_is_multicast_ether_addr(addr)) -- ret = del ? hns3_remove_mc_mac_addr(hw, addr) : -- hns3_add_mc_mac_addr(hw, addr); -+ ret = del ? ops->del_mc_mac_addr(hw, addr) : -+ ops->add_mc_mac_addr(hw, addr); - else -- ret = del ? hns3_remove_uc_mac_addr(hw, addr) : -- hns3_add_uc_mac_addr(hw, addr); -+ ret = del ? ops->del_uc_mac_addr(hw, addr) : -+ ops->add_uc_mac_addr(hw, addr); - - if (ret) { - err = ret; -@@ -2125,7 +2125,7 @@ hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - for (i = 0; i < rm_addr_num; i++) { - num = rm_addr_num - i - 1; - addr = &rm_addr_list[num]; -- ret = hns3_remove_mc_mac_addr(hw, addr); -+ ret = hw->ops.del_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -2136,7 +2136,7 @@ hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - /* Add mc mac addresses */ - for (i = 0; i < add_addr_num; i++) { - addr = &add_addr_list[i]; -- ret = hns3_add_mc_mac_addr(hw, addr); -+ ret = hw->ops.add_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -2166,9 +2166,9 @@ hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - if (!rte_is_multicast_ether_addr(addr)) - continue; - if (del) -- ret = hns3_remove_mc_mac_addr(hw, addr); -+ ret = hw->ops.del_mc_mac_addr(hw, addr); - else -- ret = hns3_add_mc_mac_addr(hw, addr); -+ ret = hw->ops.add_mc_mac_addr(hw, addr); - if (ret) { - err = ret; - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 1020b42e1..f9c5e3b4f 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -229,9 +229,9 @@ hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - rte_spinlock_unlock(&hw->lock); - return -EINVAL; - } -- ret = hns3vf_add_mc_mac_addr(hw, mac_addr); -+ ret = hw->ops.add_mc_mac_addr(hw, mac_addr); - } else { -- ret = hns3vf_add_uc_mac_addr(hw, mac_addr); -+ ret = hw->ops.add_uc_mac_addr(hw, mac_addr); - } - - rte_spinlock_unlock(&hw->lock); -@@ -257,9 +257,9 @@ hns3vf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - rte_spinlock_lock(&hw->lock); - - if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hns3vf_remove_mc_mac_addr(hw, mac_addr); -+ ret = hw->ops.del_mc_mac_addr(hw, mac_addr); - else -- ret = hns3vf_remove_uc_mac_addr(hw, mac_addr); -+ ret = hw->ops.del_uc_mac_addr(hw, mac_addr); - - rte_spinlock_unlock(&hw->lock); - if (ret) { -@@ -326,9 +326,10 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, - static int - hns3vf_configure_mac_addr(struct hns3_adapter *hns, bool del) - { -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - struct hns3_hw *hw = &hns->hw; -+ struct hns3_hw_ops *ops = &hw->ops; - struct rte_ether_addr *addr; -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - int err = 0; - int ret; - int i; -@@ -338,11 +339,11 @@ hns3vf_configure_mac_addr(struct hns3_adapter *hns, bool del) - if (rte_is_zero_ether_addr(addr)) - continue; - if (rte_is_multicast_ether_addr(addr)) -- ret = del ? hns3vf_remove_mc_mac_addr(hw, addr) : -- hns3vf_add_mc_mac_addr(hw, addr); -+ ret = del ? ops->del_mc_mac_addr(hw, addr) : -+ ops->add_mc_mac_addr(hw, addr); - else -- ret = del ? hns3vf_remove_uc_mac_addr(hw, addr) : -- hns3vf_add_uc_mac_addr(hw, addr); -+ ret = del ? ops->del_uc_mac_addr(hw, addr) : -+ ops->add_uc_mac_addr(hw, addr); - - if (ret) { - err = ret; -@@ -484,7 +485,7 @@ hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev, - for (i = 0; i < cur_addr_num; i++) { - num = cur_addr_num - i - 1; - addr = &hw->mc_addrs[num]; -- ret = hns3vf_remove_mc_mac_addr(hw, addr); -+ ret = hw->ops.del_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -496,7 +497,7 @@ hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev, - set_addr_num = (int)nb_mc_addr; - for (i = 0; i < set_addr_num; i++) { - addr = &mc_addr_set[i]; -- ret = hns3vf_add_mc_mac_addr(hw, addr); -+ ret = hw->ops.add_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; -@@ -525,9 +526,9 @@ hns3vf_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - if (!rte_is_multicast_ether_addr(addr)) - continue; - if (del) -- ret = hns3vf_remove_mc_mac_addr(hw, addr); -+ ret = hw->ops.del_mc_mac_addr(hw, addr); - else -- ret = hns3vf_add_mc_mac_addr(hw, addr); -+ ret = hw->ops.add_mc_mac_addr(hw, addr); - if (ret) { - err = ret; - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, --- -2.33.0 - diff --git a/0245-net-hns3-unify-MAC-and-multicast-address-configurati.patch b/0245-net-hns3-unify-MAC-and-multicast-address-configurati.patch deleted file mode 100644 index 7319dd1..0000000 --- a/0245-net-hns3-unify-MAC-and-multicast-address-configurati.patch +++ /dev/null @@ -1,251 +0,0 @@ -From 67d013484d9b521fd174e8485f7ebed333195bca Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:20:01 +0800 -Subject: [PATCH 12/33] net/hns3: unify MAC and multicast address configuration - -Currently, the interface logic for adding and deleting all MAC address -and multicast address in PF and VF driver is the same. This patch -extracts two common interfaces to configure them separately. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 32 ++++++------- - drivers/net/hns3/hns3_ethdev.h | 2 + - drivers/net/hns3/hns3_ethdev_vf.c | 77 +++---------------------------- - 3 files changed, 25 insertions(+), 86 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 00016d58e..bdd29220a 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1790,17 +1790,20 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - return ret; - } - --static int -+int - hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - { - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - struct hns3_hw *hw = &hns->hw; -+ struct hns3_hw_ops *ops = &hw->ops; - struct rte_ether_addr *addr; -- int err = 0; -- int ret; -+ uint16_t mac_addrs_capa; -+ int ret = 0; - int i; - -- for (i = 0; i < HNS3_UC_MACADDR_NUM; i++) { -+ mac_addrs_capa = -+ hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM; -+ for (i = 0; i < mac_addrs_capa; i++) { - addr = &hw->data->mac_addrs[i]; - if (rte_is_zero_ether_addr(addr)) - continue; -@@ -1812,15 +1815,14 @@ hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) - ops->add_uc_mac_addr(hw, addr); - - if (ret) { -- err = ret; - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to %s mac addr(%s) index:%d " -- "ret = %d.", del ? "remove" : "restore", -- mac_str, i, ret); -+ addr); -+ hns3_err(hw, "failed to %s mac addr(%s) index:%d ret = %d.", -+ del ? "remove" : "restore", mac_str, i, ret); - } - } -- return err; -+ -+ return ret; - } - - static void -@@ -2151,14 +2153,13 @@ hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - return 0; - } - --static int -+int - hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - { - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - struct hns3_hw *hw = &hns->hw; - struct rte_ether_addr *addr; -- int err = 0; -- int ret; -+ int ret = 0; - int i; - - for (i = 0; i < hw->mc_addrs_num; i++) { -@@ -2170,14 +2171,13 @@ hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) - else - ret = hw->ops.add_mc_mac_addr(hw, addr); - if (ret) { -- err = ret; - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - addr); -- hns3_dbg(hw, "%s mc mac addr: %s failed for pf: ret = %d", -+ hns3_dbg(hw, "failed to %s mc mac addr: %s ret = %d", - del ? "Remove" : "Restore", mac_str, ret); - } - } -- return err; -+ return ret; - } - - static int -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 73947e194..942e8419c 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1065,6 +1065,8 @@ void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); - - bool hns3_find_duplicate_mc_addr(struct hns3_hw *hw, - struct rte_ether_addr *mc_addr); -+int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del); -+int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del); - - int hns3_restore_ptp(struct hns3_adapter *hns); - int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index f9c5e3b4f..cce4d3450 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -323,40 +323,6 @@ hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, - return ret; - } - --static int --hns3vf_configure_mac_addr(struct hns3_adapter *hns, bool del) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct hns3_hw *hw = &hns->hw; -- struct hns3_hw_ops *ops = &hw->ops; -- struct rte_ether_addr *addr; -- int err = 0; -- int ret; -- int i; -- -- for (i = 0; i < HNS3_VF_UC_MACADDR_NUM; i++) { -- addr = &hw->data->mac_addrs[i]; -- if (rte_is_zero_ether_addr(addr)) -- continue; -- if (rte_is_multicast_ether_addr(addr)) -- ret = del ? ops->del_mc_mac_addr(hw, addr) : -- ops->add_mc_mac_addr(hw, addr); -- else -- ret = del ? ops->del_uc_mac_addr(hw, addr) : -- ops->add_uc_mac_addr(hw, addr); -- -- if (ret) { -- err = ret; -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to %s mac addr(%s) index:%d " -- "ret = %d.", del ? "remove" : "restore", -- mac_str, i, ret); -- } -- } -- return err; --} -- - static int - hns3vf_add_mc_mac_addr(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr) -@@ -511,35 +477,6 @@ hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev, - return 0; - } - --static int --hns3vf_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct hns3_hw *hw = &hns->hw; -- struct rte_ether_addr *addr; -- int err = 0; -- int ret; -- int i; -- -- for (i = 0; i < hw->mc_addrs_num; i++) { -- addr = &hw->mc_addrs[i]; -- if (!rte_is_multicast_ether_addr(addr)) -- continue; -- if (del) -- ret = hw->ops.del_mc_mac_addr(hw, addr); -- else -- ret = hw->ops.add_mc_mac_addr(hw, addr); -- if (ret) { -- err = ret; -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "Failed to %s mc mac addr: %s for vf: %d", -- del ? "Remove" : "Restore", mac_str, ret); -- } -- } -- return err; --} -- - static int - hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, - bool en_uc_pmc, bool en_mc_pmc) -@@ -2077,7 +2014,7 @@ hns3vf_do_stop(struct hns3_adapter *hns) - hns3_dev_release_mbufs(hns); - - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) { -- hns3vf_configure_mac_addr(hns, true); -+ hns3_configure_all_mac_addr(hns, true); - ret = hns3_reset_all_tqps(hns); - if (ret) { - hns3_err(hw, "failed to reset all queues ret = %d", -@@ -2172,7 +2109,7 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - hns3_reset_abort(hns); - hw->adapter_state = HNS3_NIC_CLOSED; - rte_eal_alarm_cancel(hns3vf_keep_alive_handler, eth_dev); -- hns3vf_configure_all_mc_mac_addr(hns, true); -+ hns3_configure_all_mc_mac_addr(hns, true); - hns3vf_remove_all_vlan_table(hns); - hns3vf_uninit_vf(eth_dev); - hns3_free_all_queues(eth_dev); -@@ -2598,7 +2535,7 @@ hns3vf_stop_service(struct hns3_adapter *hns) - * required to delete the entries. - */ - if (__atomic_load_n(&hw->reset.disable_cmd, __ATOMIC_RELAXED) == 0) -- hns3vf_configure_all_mc_mac_addr(hns, true); -+ hns3_configure_all_mc_mac_addr(hns, true); - rte_spinlock_unlock(&hw->lock); - - return 0; -@@ -2684,11 +2621,11 @@ hns3vf_restore_conf(struct hns3_adapter *hns) - if (ret) - return ret; - -- ret = hns3vf_configure_mac_addr(hns, false); -+ ret = hns3_configure_all_mac_addr(hns, false); - if (ret) - return ret; - -- ret = hns3vf_configure_all_mc_mac_addr(hns, false); -+ ret = hns3_configure_all_mc_mac_addr(hns, false); - if (ret) - goto err_mc_mac; - -@@ -2729,9 +2666,9 @@ hns3vf_restore_conf(struct hns3_adapter *hns) - return 0; - - err_vlan_table: -- hns3vf_configure_all_mc_mac_addr(hns, true); -+ hns3_configure_all_mc_mac_addr(hns, true); - err_mc_mac: -- hns3vf_configure_mac_addr(hns, true); -+ hns3_configure_all_mac_addr(hns, true); - return ret; - } - --- -2.33.0 - diff --git a/0246-net-hns3-unify-MAC-address-add-and-remove.patch b/0246-net-hns3-unify-MAC-address-add-and-remove.patch deleted file mode 100644 index d6b4a5d..0000000 --- a/0246-net-hns3-unify-MAC-address-add-and-remove.patch +++ /dev/null @@ -1,177 +0,0 @@ -From f1e4c77136cc5d65606ad07cd7204c0994c14904 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:20:02 +0800 -Subject: [PATCH 13/33] net/hns3: unify MAC address add and remove - -The code logic of adding and removing MAC address in PF and VF is the -same. -This patch extracts two common interfaces to add and remove them -separately. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 11 ++--- - drivers/net/hns3/hns3_ethdev.h | 5 ++- - drivers/net/hns3/hns3_ethdev_vf.c | 70 +------------------------------ - 3 files changed, 9 insertions(+), 77 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index bdd29220a..bf49d5f75 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1609,7 +1609,7 @@ hns3_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --bool -+static bool - hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) - { - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -@@ -1632,7 +1632,7 @@ hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) - return false; - } - --static int -+int - hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, __rte_unused uint32_t pool) - { -@@ -1660,17 +1660,14 @@ hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - } else { - ret = hw->ops.add_uc_mac_addr(hw, mac_addr); - } -+ rte_spinlock_unlock(&hw->lock); - if (ret) { -- rte_spinlock_unlock(&hw->lock); - hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, - mac_addr); - hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str, - ret); -- return ret; - } - -- rte_spinlock_unlock(&hw->lock); -- - return ret; - } - -@@ -1702,7 +1699,7 @@ hns3_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static void -+void - hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 942e8419c..276ac8b54 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1063,10 +1063,11 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - void hns3_parse_devargs(struct rte_eth_dev *dev); - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); - --bool hns3_find_duplicate_mc_addr(struct hns3_hw *hw, -- struct rte_ether_addr *mc_addr); - int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del); - int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del); -+int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -+ __rte_unused uint32_t idx, __rte_unused uint32_t pool); -+void hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx); - - int hns3_restore_ptp(struct hns3_adapter *hns); - int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index cce4d3450..fb7eda21d 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -204,72 +204,6 @@ hns3vf_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static int --hns3vf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -- __rte_unused uint32_t idx, -- __rte_unused uint32_t pool) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- rte_spinlock_lock(&hw->lock); -- -- /* -- * In hns3 network engine adding UC and MC mac address with different -- * commands with firmware. We need to determine whether the input -- * address is a UC or a MC address to call different commands. -- * By the way, it is recommended calling the API function named -- * rte_eth_dev_set_mc_addr_list to set the MC mac address, because -- * using the rte_eth_dev_mac_addr_add API function to set MC mac address -- * may affect the specifications of UC mac addresses. -- */ -- if (rte_is_multicast_ether_addr(mac_addr)) { -- if (hns3_find_duplicate_mc_addr(hw, mac_addr)) { -- rte_spinlock_unlock(&hw->lock); -- return -EINVAL; -- } -- ret = hw->ops.add_mc_mac_addr(hw, mac_addr); -- } else { -- ret = hw->ops.add_uc_mac_addr(hw, mac_addr); -- } -- -- rte_spinlock_unlock(&hw->lock); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str, -- ret); -- } -- -- return ret; --} -- --static void --hns3vf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- /* index will be checked by upper level rte interface */ -- struct rte_ether_addr *mac_addr = &dev->data->mac_addrs[idx]; -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- rte_spinlock_lock(&hw->lock); -- -- if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hw->ops.del_mc_mac_addr(hw, mac_addr); -- else -- ret = hw->ops.del_uc_mac_addr(hw, mac_addr); -- -- rte_spinlock_unlock(&hw->lock); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to remove mac addr(%s), ret = %d", -- mac_str, ret); -- } --} -- - static int - hns3vf_set_default_mac_addr(struct rte_eth_dev *dev, - struct rte_ether_addr *mac_addr) -@@ -2831,8 +2765,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { - .txq_info_get = hns3_txq_info_get, - .rx_burst_mode_get = hns3_rx_burst_mode_get, - .tx_burst_mode_get = hns3_tx_burst_mode_get, -- .mac_addr_add = hns3vf_add_mac_addr, -- .mac_addr_remove = hns3vf_remove_mac_addr, -+ .mac_addr_add = hns3_add_mac_addr, -+ .mac_addr_remove = hns3_remove_mac_addr, - .mac_addr_set = hns3vf_set_default_mac_addr, - .set_mc_addr_list = hns3vf_set_mc_mac_addr_list, - .link_update = hns3vf_dev_link_update, --- -2.33.0 - diff --git a/0247-net-hns3-unify-multicast-address-check.patch b/0247-net-hns3-unify-multicast-address-check.patch deleted file mode 100644 index 0cb7785..0000000 --- a/0247-net-hns3-unify-multicast-address-check.patch +++ /dev/null @@ -1,157 +0,0 @@ -From 35da8e628f28e84f1f7b1dff10a984a44bae44e0 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:20:03 +0800 -Subject: [PATCH 14/33] net/hns3: unify multicast address check - -This patch uniforms a common function to check multicast address -validity for PF and VF. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 12 ++++-- - drivers/net/hns3/hns3_ethdev.h | 4 +- - drivers/net/hns3/hns3_ethdev_vf.c | 66 +------------------------------ - 3 files changed, 12 insertions(+), 70 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index bf49d5f75..97129c428 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1947,13 +1947,15 @@ hns3_remove_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static int -+int - hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - struct rte_ether_addr *mc_addr_set, - uint32_t nb_mc_addr) - { -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; - struct rte_ether_addr *addr; -+ uint16_t mac_addrs_capa; - uint32_t i; - uint32_t j; - -@@ -1993,12 +1995,14 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - * Check if there are duplicate addresses between mac_addrs - * and mc_addr_set - */ -- for (j = 0; j < HNS3_UC_MACADDR_NUM; j++) { -+ mac_addrs_capa = hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : -+ HNS3_UC_MACADDR_NUM; -+ for (j = 0; j < mac_addrs_capa; j++) { - if (rte_is_same_ether_addr(addr, - &hw->data->mac_addrs[j])) { - hns3_ether_format_addr(mac_str, -- RTE_ETHER_ADDR_FMT_SIZE, -- addr); -+ RTE_ETHER_ADDR_FMT_SIZE, -+ addr); - hns3_err(hw, "failed to set mc mac addr, " - "addrs invalid. addrs(%s) has already " - "configured in mac_addr add API", -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 276ac8b54..1606a6407 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1062,7 +1062,9 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); - void hns3_parse_devargs(struct rte_eth_dev *dev); - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); -- -+int hns3_set_mc_addr_chk_param(struct hns3_hw *hw, -+ struct rte_ether_addr *mc_addr_set, -+ uint32_t nb_mc_addr); - int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del); - int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del); - int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index fb7eda21d..835e783c3 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -299,70 +299,6 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, - return ret; - } - --static int --hns3vf_set_mc_addr_chk_param(struct hns3_hw *hw, -- struct rte_ether_addr *mc_addr_set, -- uint32_t nb_mc_addr) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct rte_ether_addr *addr; -- uint32_t i; -- uint32_t j; -- -- if (nb_mc_addr > HNS3_MC_MACADDR_NUM) { -- hns3_err(hw, "failed to set mc mac addr, nb_mc_addr(%u) " -- "invalid. valid range: 0~%d", -- nb_mc_addr, HNS3_MC_MACADDR_NUM); -- return -EINVAL; -- } -- -- /* Check if input mac addresses are valid */ -- for (i = 0; i < nb_mc_addr; i++) { -- addr = &mc_addr_set[i]; -- if (!rte_is_multicast_ether_addr(addr)) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, -- "failed to set mc mac addr, addr(%s) invalid.", -- mac_str); -- return -EINVAL; -- } -- -- /* Check if there are duplicate addresses */ -- for (j = i + 1; j < nb_mc_addr; j++) { -- if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) { -- hns3_ether_format_addr(mac_str, -- RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to set mc mac addr, " -- "addrs invalid. two same addrs(%s).", -- mac_str); -- return -EINVAL; -- } -- } -- -- /* -- * Check if there are duplicate addresses between mac_addrs -- * and mc_addr_set -- */ -- for (j = 0; j < HNS3_VF_UC_MACADDR_NUM; j++) { -- if (rte_is_same_ether_addr(addr, -- &hw->data->mac_addrs[j])) { -- hns3_ether_format_addr(mac_str, -- RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to set mc mac addr, " -- "addrs invalid. addrs(%s) has already " -- "configured in mac_addr add API", -- mac_str); -- return -EINVAL; -- } -- } -- } -- -- return 0; --} -- - static int - hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev, - struct rte_ether_addr *mc_addr_set, -@@ -376,7 +312,7 @@ hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev, - int ret; - int i; - -- ret = hns3vf_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr); -+ ret = hns3_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr); - if (ret) - return ret; - --- -2.33.0 - diff --git a/0248-net-hns3-refactor-multicast-MAC-address-set-for-PF.patch b/0248-net-hns3-refactor-multicast-MAC-address-set-for-PF.patch deleted file mode 100644 index 0679a9e..0000000 --- a/0248-net-hns3-refactor-multicast-MAC-address-set-for-PF.patch +++ /dev/null @@ -1,171 +0,0 @@ -From 4696316a47ed084bdfddc5a7fd12ad743643b602 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:20:04 +0800 -Subject: [PATCH 15/33] net/hns3: refactor multicast MAC address set for PF - -Currently, when configuring a group of multicast MAC addresses, the PF -driver reorder mc_addr array in hw struct to remove multicast MAC -addresses that are not in mc_addr_set array from user and then adds new -multicast MAC addresses. Actually, it can be simplified by removing all -previous MAC addresses and then adding new MAC addresses. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 112 ++++----------------------------- - 1 file changed, 11 insertions(+), 101 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 97129c428..dd239f6e7 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2015,94 +2015,15 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - return 0; - } - --static void --hns3_set_mc_addr_calc_addr(struct hns3_hw *hw, -- struct rte_ether_addr *mc_addr_set, -- int mc_addr_num, -- struct rte_ether_addr *reserved_addr_list, -- int *reserved_addr_num, -- struct rte_ether_addr *add_addr_list, -- int *add_addr_num, -- struct rte_ether_addr *rm_addr_list, -- int *rm_addr_num) --{ -- struct rte_ether_addr *addr; -- int current_addr_num; -- int reserved_num = 0; -- int add_num = 0; -- int rm_num = 0; -- int num; -- int i; -- int j; -- bool same_addr; -- -- /* Calculate the mc mac address list that should be removed */ -- current_addr_num = hw->mc_addrs_num; -- for (i = 0; i < current_addr_num; i++) { -- addr = &hw->mc_addrs[i]; -- same_addr = false; -- for (j = 0; j < mc_addr_num; j++) { -- if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) { -- same_addr = true; -- break; -- } -- } -- -- if (!same_addr) { -- rte_ether_addr_copy(addr, &rm_addr_list[rm_num]); -- rm_num++; -- } else { -- rte_ether_addr_copy(addr, -- &reserved_addr_list[reserved_num]); -- reserved_num++; -- } -- } -- -- /* Calculate the mc mac address list that should be added */ -- for (i = 0; i < mc_addr_num; i++) { -- addr = &mc_addr_set[i]; -- same_addr = false; -- for (j = 0; j < current_addr_num; j++) { -- if (rte_is_same_ether_addr(addr, &hw->mc_addrs[j])) { -- same_addr = true; -- break; -- } -- } -- -- if (!same_addr) { -- rte_ether_addr_copy(addr, &add_addr_list[add_num]); -- add_num++; -- } -- } -- -- /* Reorder the mc mac address list maintained by driver */ -- for (i = 0; i < reserved_num; i++) -- rte_ether_addr_copy(&reserved_addr_list[i], &hw->mc_addrs[i]); -- -- for (i = 0; i < rm_num; i++) { -- num = reserved_num + i; -- rte_ether_addr_copy(&rm_addr_list[i], &hw->mc_addrs[num]); -- } -- -- *reserved_addr_num = reserved_num; -- *add_addr_num = add_num; -- *rm_addr_num = rm_num; --} -- - static int - hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - struct rte_ether_addr *mc_addr_set, - uint32_t nb_mc_addr) - { - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct rte_ether_addr reserved_addr_list[HNS3_MC_MACADDR_NUM]; -- struct rte_ether_addr add_addr_list[HNS3_MC_MACADDR_NUM]; -- struct rte_ether_addr rm_addr_list[HNS3_MC_MACADDR_NUM]; - struct rte_ether_addr *addr; -- int reserved_addr_num; -- int add_addr_num; -- int rm_addr_num; -- int mc_addr_num; -+ int cur_addr_num; -+ int set_addr_num; - int num; - int ret; - int i; -@@ -2113,40 +2034,29 @@ hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - return ret; - - rte_spinlock_lock(&hw->lock); -- -- /* -- * Calculate the mc mac address lists those should be removed and be -- * added, Reorder the mc mac address list maintained by driver. -- */ -- mc_addr_num = (int)nb_mc_addr; -- hns3_set_mc_addr_calc_addr(hw, mc_addr_set, mc_addr_num, -- reserved_addr_list, &reserved_addr_num, -- add_addr_list, &add_addr_num, -- rm_addr_list, &rm_addr_num); -- -- /* Remove mc mac addresses */ -- for (i = 0; i < rm_addr_num; i++) { -- num = rm_addr_num - i - 1; -- addr = &rm_addr_list[num]; -+ cur_addr_num = hw->mc_addrs_num; -+ for (i = 0; i < cur_addr_num; i++) { -+ num = cur_addr_num - i - 1; -+ addr = &hw->mc_addrs[num]; - ret = hw->ops.del_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; - } -+ - hw->mc_addrs_num--; - } - -- /* Add mc mac addresses */ -- for (i = 0; i < add_addr_num; i++) { -- addr = &add_addr_list[i]; -+ set_addr_num = (int)nb_mc_addr; -+ for (i = 0; i < set_addr_num; i++) { -+ addr = &mc_addr_set[i]; - ret = hw->ops.add_mc_mac_addr(hw, addr); - if (ret) { - rte_spinlock_unlock(&hw->lock); - return ret; - } - -- num = reserved_addr_num + i; -- rte_ether_addr_copy(addr, &hw->mc_addrs[num]); -+ rte_ether_addr_copy(addr, &hw->mc_addrs[hw->mc_addrs_num]); - hw->mc_addrs_num++; - } - rte_spinlock_unlock(&hw->lock); --- -2.33.0 - diff --git a/0249-net-hns3-unify-multicast-MAC-address-set-list.patch b/0249-net-hns3-unify-multicast-MAC-address-set-list.patch deleted file mode 100644 index 8b2f04d..0000000 --- a/0249-net-hns3-unify-multicast-MAC-address-set-list.patch +++ /dev/null @@ -1,132 +0,0 @@ -From bbe20957bf59a4c2467b768865daa02c74ef907c Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Fri, 22 Oct 2021 17:20:05 +0800 -Subject: [PATCH 16/33] net/hns3: unify multicast MAC address set list - -This patch removes hns3vf_set_mc_mac_addr_list() and uses -hns3_set_mc_mac_addr_list() to do this. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 4 +-- - drivers/net/hns3/hns3_ethdev.h | 7 ++--- - drivers/net/hns3/hns3_ethdev_vf.c | 50 +------------------------------ - 3 files changed, 6 insertions(+), 55 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index dd239f6e7..85c50ce67 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1947,7 +1947,7 @@ hns3_remove_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --int -+static int - hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - struct rte_ether_addr *mc_addr_set, - uint32_t nb_mc_addr) -@@ -2015,7 +2015,7 @@ hns3_set_mc_addr_chk_param(struct hns3_hw *hw, - return 0; - } - --static int -+int - hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - struct rte_ether_addr *mc_addr_set, - uint32_t nb_mc_addr) -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 1606a6407..1f1364304 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -1062,15 +1062,14 @@ void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); - void hns3_parse_devargs(struct rte_eth_dev *dev); - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); --int hns3_set_mc_addr_chk_param(struct hns3_hw *hw, -- struct rte_ether_addr *mc_addr_set, -- uint32_t nb_mc_addr); - int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del); - int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del); - int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, - __rte_unused uint32_t idx, __rte_unused uint32_t pool); - void hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx); -- -+int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, -+ struct rte_ether_addr *mc_addr_set, -+ uint32_t nb_mc_addr); - int hns3_restore_ptp(struct hns3_adapter *hns); - int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, - struct rte_eth_conf *conf); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 835e783c3..095f635cc 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -299,54 +299,6 @@ hns3vf_remove_mc_mac_addr(struct hns3_hw *hw, - return ret; - } - --static int --hns3vf_set_mc_mac_addr_list(struct rte_eth_dev *dev, -- struct rte_ether_addr *mc_addr_set, -- uint32_t nb_mc_addr) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct rte_ether_addr *addr; -- int cur_addr_num; -- int set_addr_num; -- int num; -- int ret; -- int i; -- -- ret = hns3_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr); -- if (ret) -- return ret; -- -- rte_spinlock_lock(&hw->lock); -- cur_addr_num = hw->mc_addrs_num; -- for (i = 0; i < cur_addr_num; i++) { -- num = cur_addr_num - i - 1; -- addr = &hw->mc_addrs[num]; -- ret = hw->ops.del_mc_mac_addr(hw, addr); -- if (ret) { -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -- -- hw->mc_addrs_num--; -- } -- -- set_addr_num = (int)nb_mc_addr; -- for (i = 0; i < set_addr_num; i++) { -- addr = &mc_addr_set[i]; -- ret = hw->ops.add_mc_mac_addr(hw, addr); -- if (ret) { -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -- -- rte_ether_addr_copy(addr, &hw->mc_addrs[hw->mc_addrs_num]); -- hw->mc_addrs_num++; -- } -- rte_spinlock_unlock(&hw->lock); -- -- return 0; --} -- - static int - hns3vf_set_promisc_mode(struct hns3_hw *hw, bool en_bc_pmc, - bool en_uc_pmc, bool en_mc_pmc) -@@ -2704,7 +2656,7 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { - .mac_addr_add = hns3_add_mac_addr, - .mac_addr_remove = hns3_remove_mac_addr, - .mac_addr_set = hns3vf_set_default_mac_addr, -- .set_mc_addr_list = hns3vf_set_mc_mac_addr_list, -+ .set_mc_addr_list = hns3_set_mc_mac_addr_list, - .link_update = hns3vf_dev_link_update, - .rss_hash_update = hns3_dev_rss_hash_update, - .rss_hash_conf_get = hns3_dev_rss_hash_conf_get, --- -2.33.0 - diff --git a/0250-bonding-show-Tx-policy-for-802.3AD-mode.patch b/0250-bonding-show-Tx-policy-for-802.3AD-mode.patch deleted file mode 100644 index 1d8a3a7..0000000 --- a/0250-bonding-show-Tx-policy-for-802.3AD-mode.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 6ae8a77985dd6a896c304fa1c344980747e88e66 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Mon, 25 Oct 2021 11:15:11 +0800 -Subject: [PATCH 17/33] bonding: show Tx policy for 802.3AD mode - -As balance xmit policy is supported in bonding mode 4(802.3AD). This -patch adds balance xmit policy show in testpmd commands for mode 4. Like: -testpmd> show bonding config 2 - Bonding mode: 4 - Balance Xmit Policy: BALANCE_XMIT_POLICY_LAYER34 - IEEE802.3AD Aggregator Mode: stable - Slaves (2): [0 1] - Active Slaves (2): [1 0] - Primary: [1] - -Signed-off-by: Min Hu (Connor) -Acked-by: Ferruh Yigit ---- - app/test-pmd/cmdline.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c -index b701129d8..66e3815de 100644 ---- a/app/test-pmd/cmdline.c -+++ b/app/test-pmd/cmdline.c -@@ -6257,7 +6257,8 @@ static void cmd_show_bonding_config_parsed(void *parsed_result, - } else - printf("\tBonding mode: %d\n", bonding_mode); - -- if (bonding_mode == BONDING_MODE_BALANCE) { -+ if (bonding_mode == BONDING_MODE_BALANCE || -+ bonding_mode == BONDING_MODE_8023AD) { - int balance_xmit_policy; - - balance_xmit_policy = rte_eth_bond_xmit_policy_get(port_id); --- -2.33.0 - diff --git a/0251-net-hns3-fix-secondary-process-reference-count.patch b/0251-net-hns3-fix-secondary-process-reference-count.patch deleted file mode 100644 index 9e378fd..0000000 --- a/0251-net-hns3-fix-secondary-process-reference-count.patch +++ /dev/null @@ -1,116 +0,0 @@ -From 1058a9cd1fa03e94b7e8634f1f26902ed9a376b1 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 2 Nov 2021 09:38:26 +0800 -Subject: [PATCH 18/33] net/hns3: fix secondary process reference count - -The "secondary_cnt" will be increased when a secondary process -initialized. But the value of this variable is not decreased when the -secondary process exits, which causes the primary process senses that -the secondary process still exists. As a result, the primary process -fails to send messages to the secondary process after the secondary -process exits. - -Fixes: 23d4b61fee5d ("net/hns3: support multiple process") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 10 +++++++--- - drivers/net/hns3/hns3_ethdev_vf.c | 10 +++++++--- - drivers/net/hns3/hns3_mp.c | 4 +++- - 3 files changed, 17 insertions(+), 7 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 85c50ce67..31d027836 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5894,8 +5894,10 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - struct hns3_hw *hw = &hns->hw; - int ret = 0; - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); - return 0; -+ } - - if (hw->adapter_state == HNS3_NIC_STARTED) - ret = hns3_dev_stop(eth_dev); -@@ -7421,7 +7423,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - "process, ret = %d", ret); - goto err_mp_init_secondary; - } -- hw->secondary_cnt++; -+ __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); - hns3_tx_push_init(eth_dev); - return 0; - } -@@ -7524,8 +7526,10 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); - return 0; -+ } - - if (hw->adapter_state < HNS3_NIC_CLOSING) - hns3_dev_close(eth_dev); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 095f635cc..76721b0d7 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1921,8 +1921,10 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - struct hns3_hw *hw = &hns->hw; - int ret = 0; - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); - return 0; -+ } - - if (hw->adapter_state == HNS3_NIC_STARTED) - ret = hns3vf_dev_stop(eth_dev); -@@ -2710,7 +2712,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - "process, ret = %d", ret); - goto err_mp_init_secondary; - } -- hw->secondary_cnt++; -+ __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); - hns3_tx_push_init(eth_dev); - return 0; - } -@@ -2812,8 +2814,10 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) - - PMD_INIT_FUNC_TRACE(); - -- if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); - return 0; -+ } - - if (hw->adapter_state < HNS3_NIC_CLOSING) - hns3vf_dev_close(eth_dev); -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index 4891c6e4f..184acfe02 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -150,8 +150,10 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum hns3_mp_req_type type) - int ret; - int i; - -- if (rte_eal_process_type() == RTE_PROC_SECONDARY || !hw->secondary_cnt) -+ if (rte_eal_process_type() == RTE_PROC_SECONDARY || -+ __atomic_load_n(&hw->secondary_cnt, __ATOMIC_RELAXED) == 0) - return; -+ - if (!mp_req_type_is_valid(type)) { - hns3_err(hw, "port %u unknown request (req_type %d)", - dev->data->port_id, type); --- -2.33.0 - diff --git a/0252-net-hns3-fix-multi-process-action-register-and-unreg.patch b/0252-net-hns3-fix-multi-process-action-register-and-unreg.patch deleted file mode 100644 index ccbbe81..0000000 --- a/0252-net-hns3-fix-multi-process-action-register-and-unreg.patch +++ /dev/null @@ -1,166 +0,0 @@ -From c4ae016e0b548882c5f777cd1782b8661a34f252 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 2 Nov 2021 09:38:27 +0800 -Subject: [PATCH 19/33] net/hns3: fix multi-process action register and - unregister - -The multi-process has the following problems: -1) After a port in primary process is closed, the mp action of the - process is unregistered. Which will cause that other device in the - primary process cannot respond to requests from secondary processes. -2) Because variable "hns3_inited" is set to true without returning an - initial value, the mp action cannot be registered again after it is - unregistered. -3) The mp action of primary and secondary process need to be registered - only once regardless of port numbers in the process. That's what - variable "hns3_inited" does. But the variable is difficult to - understand. - -This patch adds a hns3_process_local_data structure to resolve above -problems. - -Fixes: 9570b1fdbdad ("net/hns3: check multi-process action register result") -Fixes: 23d4b61fee5d ("net/hns3: support multiple process") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 2 ++ - drivers/net/hns3/hns3_ethdev_vf.c | 2 ++ - drivers/net/hns3/hns3_mp.c | 37 ++++++++++++++++++------------- - drivers/net/hns3/hns3_mp.h | 7 ++++++ - 4 files changed, 33 insertions(+), 15 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 31d027836..2f2d2a605 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -7424,6 +7424,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - goto err_mp_init_secondary; - } - __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ process_data.eth_dev_cnt++; - hns3_tx_push_init(eth_dev); - return 0; - } -@@ -7435,6 +7436,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - ret); - goto err_mp_init_primary; - } -+ process_data.eth_dev_cnt++; - - hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = false; -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 76721b0d7..108bd61d5 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -2713,6 +2713,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - goto err_mp_init_secondary; - } - __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ process_data.eth_dev_cnt++; - hns3_tx_push_init(eth_dev); - return 0; - } -@@ -2724,6 +2725,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - ret); - goto err_mp_init_primary; - } -+ process_data.eth_dev_cnt++; - - hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = true; -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index 184acfe02..753b93f09 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -12,7 +12,8 @@ - #include "hns3_rxtx.h" - #include "hns3_mp.h" - --static bool hns3_inited; -+/* local data for primary or secondary process. */ -+struct hns3_process_local_data process_data; - - /* - * Initialize IPC message. -@@ -230,14 +231,15 @@ int hns3_mp_init_primary(void) - { - int ret; - -- if (!hns3_inited) { -- /* primary is allowed to not support IPC */ -- ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); -- if (ret && rte_errno != ENOTSUP) -- return ret; -+ if (process_data.init_done) -+ return 0; - -- hns3_inited = true; -- } -+ /* primary is allowed to not support IPC */ -+ ret = rte_mp_action_register(HNS3_MP_NAME, mp_primary_handle); -+ if (ret && rte_errno != ENOTSUP) -+ return ret; -+ -+ process_data.init_done = true; - - return 0; - } -@@ -247,8 +249,12 @@ int hns3_mp_init_primary(void) - */ - void hns3_mp_uninit_primary(void) - { -- if (hns3_inited) -+ process_data.eth_dev_cnt--; -+ -+ if (process_data.eth_dev_cnt == 0) { - rte_mp_action_unregister(HNS3_MP_NAME); -+ process_data.init_done = false; -+ } - } - - /* -@@ -258,13 +264,14 @@ int hns3_mp_init_secondary(void) - { - int ret; - -- if (!hns3_inited) { -- ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); -- if (ret) -- return ret; -+ if (process_data.init_done) -+ return 0; - -- hns3_inited = true; -- } -+ ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); -+ if (ret) -+ return ret; -+ -+ process_data.init_done = true; - - return 0; - } -diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h -index e0e4aeaf6..b49532f98 100644 ---- a/drivers/net/hns3/hns3_mp.h -+++ b/drivers/net/hns3/hns3_mp.h -@@ -5,6 +5,13 @@ - #ifndef _HNS3_MP_H_ - #define _HNS3_MP_H_ - -+/* Local data for primary or secondary process. */ -+struct hns3_process_local_data { -+ bool init_done; /* Process action register completed flag. */ -+ int eth_dev_cnt; /* Ethdev count under the current process. */ -+}; -+extern struct hns3_process_local_data process_data; -+ - void hns3_mp_req_start_rxtx(struct rte_eth_dev *dev); - void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev); - void hns3_mp_req_start_tx(struct rte_eth_dev *dev); --- -2.33.0 - diff --git a/0253-net-hns3-unregister-MP-action-on-close-for-secondary.patch b/0253-net-hns3-unregister-MP-action-on-close-for-secondary.patch deleted file mode 100644 index cf5888e..0000000 --- a/0253-net-hns3-unregister-MP-action-on-close-for-secondary.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 9bc0df6a4fa9b3ea1decc519c778e48a27037589 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 2 Nov 2021 09:38:28 +0800 -Subject: [PATCH 20/33] net/hns3: unregister MP action on close for secondary - -This patch fixes lack of unregistering MP action for secondary process -when PMD is closed. - -Fixes: 9570b1fdbdad ("net/hns3: check multi-process action register result") -Fixes: 23d4b61fee5d ("net/hns3: support multiple process") - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 6 ++++-- - drivers/net/hns3/hns3_ethdev_vf.c | 6 ++++-- - drivers/net/hns3/hns3_mp.c | 5 +---- - drivers/net/hns3/hns3_mp.h | 2 +- - 4 files changed, 10 insertions(+), 9 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 2f2d2a605..b4f375bf2 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5896,6 +5896,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ hns3_mp_uninit(); - return 0; - } - -@@ -5912,7 +5913,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - hns3_uninit_pf(eth_dev); - hns3_free_all_queues(eth_dev); - rte_free(hw->reset.wait_data); -- hns3_mp_uninit_primary(); -+ hns3_mp_uninit(); - hns3_warn(hw, "Close port %u finished", hw->data->port_id); - - return ret; -@@ -7507,7 +7508,7 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - rte_free(hw->reset.wait_data); - - err_init_reset: -- hns3_mp_uninit_primary(); -+ hns3_mp_uninit(); - - err_mp_init_primary: - err_mp_init_secondary: -@@ -7530,6 +7531,7 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ hns3_mp_uninit(); - return 0; - } - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 108bd61d5..ac0dcbe36 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1923,6 +1923,7 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ hns3_mp_uninit(); - return 0; - } - -@@ -1938,7 +1939,7 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - hns3vf_uninit_vf(eth_dev); - hns3_free_all_queues(eth_dev); - rte_free(hw->reset.wait_data); -- hns3_mp_uninit_primary(); -+ hns3_mp_uninit(); - hns3_warn(hw, "Close port %u finished", hw->data->port_id); - - return ret; -@@ -2794,7 +2795,7 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - rte_free(hw->reset.wait_data); - - err_init_reset: -- hns3_mp_uninit_primary(); -+ hns3_mp_uninit(); - - err_mp_init_primary: - err_mp_init_secondary: -@@ -2818,6 +2819,7 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ hns3_mp_uninit(); - return 0; - } - -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index 753b93f09..2ecb16861 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -244,10 +244,7 @@ int hns3_mp_init_primary(void) - return 0; - } - --/* -- * Un-initialize by primary process. -- */ --void hns3_mp_uninit_primary(void) -+void hns3_mp_uninit(void) - { - process_data.eth_dev_cnt--; - -diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h -index b49532f98..5738ab74a 100644 ---- a/drivers/net/hns3/hns3_mp.h -+++ b/drivers/net/hns3/hns3_mp.h -@@ -18,7 +18,7 @@ void hns3_mp_req_start_tx(struct rte_eth_dev *dev); - void hns3_mp_req_stop_tx(struct rte_eth_dev *dev); - - int hns3_mp_init_primary(void); --void hns3_mp_uninit_primary(void); -+void hns3_mp_uninit(void); - int hns3_mp_init_secondary(void); - - #endif /* _HNS3_MP_H_ */ --- -2.33.0 - diff --git a/0254-net-hns3-refactor-multi-process-initialization.patch b/0254-net-hns3-refactor-multi-process-initialization.patch deleted file mode 100644 index 485d7bf..0000000 --- a/0254-net-hns3-refactor-multi-process-initialization.patch +++ /dev/null @@ -1,300 +0,0 @@ -From 8388c42414d8f33ba97b01cbe4bf4e945a9819b4 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Tue, 2 Nov 2021 09:38:29 +0800 -Subject: [PATCH 21/33] net/hns3: refactor multi-process initialization - -Currently, the logic of the PF and VF initialization codes for multiple -process is the same. A common function can be extracted to initialize -and unload multiple process. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 34 +++++------------ - drivers/net/hns3/hns3_ethdev_vf.c | 33 +++++----------- - drivers/net/hns3/hns3_mp.c | 62 ++++++++++++++++++++++++------- - drivers/net/hns3/hns3_mp.h | 6 +-- - 4 files changed, 68 insertions(+), 67 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index b4f375bf2..ecf912a9f 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -5895,8 +5895,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - int ret = 0; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - return 0; - } - -@@ -5913,7 +5912,7 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) - hns3_uninit_pf(eth_dev); - hns3_free_all_queues(eth_dev); - rte_free(hw->reset.wait_data); -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - hns3_warn(hw, "Close port %u finished", hw->data->port_id); - - return ret; -@@ -7417,28 +7416,15 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - hns3_set_rxtx_function(eth_dev); - eth_dev->dev_ops = &hns3_eth_dev_ops; - eth_dev->rx_queue_count = hns3_rx_queue_count; -+ ret = hns3_mp_init(eth_dev); -+ if (ret) -+ goto err_mp_init; -+ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- ret = hns3_mp_init_secondary(); -- if (ret) { -- PMD_INIT_LOG(ERR, "Failed to init for secondary " -- "process, ret = %d", ret); -- goto err_mp_init_secondary; -- } -- __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -- process_data.eth_dev_cnt++; - hns3_tx_push_init(eth_dev); - return 0; - } - -- ret = hns3_mp_init_primary(); -- if (ret) { -- PMD_INIT_LOG(ERR, -- "Failed to init for primary process, ret = %d", -- ret); -- goto err_mp_init_primary; -- } -- process_data.eth_dev_cnt++; -- - hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = false; - hw->data = eth_dev->data; -@@ -7508,10 +7494,9 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) - rte_free(hw->reset.wait_data); - - err_init_reset: -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - --err_mp_init_primary: --err_mp_init_secondary: -+err_mp_init: - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->rx_descriptor_status = NULL; -@@ -7530,8 +7515,7 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) - PMD_INIT_FUNC_TRACE(); - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - return 0; - } - -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index ac0dcbe36..1e0cb1b63 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -1922,8 +1922,7 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - int ret = 0; - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - return 0; - } - -@@ -1939,7 +1938,7 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - hns3vf_uninit_vf(eth_dev); - hns3_free_all_queues(eth_dev); - rte_free(hw->reset.wait_data); -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - hns3_warn(hw, "Close port %u finished", hw->data->port_id); - - return ret; -@@ -2706,28 +2705,15 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - hns3_set_rxtx_function(eth_dev); - eth_dev->dev_ops = &hns3vf_eth_dev_ops; - eth_dev->rx_queue_count = hns3_rx_queue_count; -+ ret = hns3_mp_init(eth_dev); -+ if (ret) -+ goto err_mp_init; -+ - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -- ret = hns3_mp_init_secondary(); -- if (ret) { -- PMD_INIT_LOG(ERR, "Failed to init for secondary " -- "process, ret = %d", ret); -- goto err_mp_init_secondary; -- } -- __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -- process_data.eth_dev_cnt++; - hns3_tx_push_init(eth_dev); - return 0; - } - -- ret = hns3_mp_init_primary(); -- if (ret) { -- PMD_INIT_LOG(ERR, -- "Failed to init for primary process, ret = %d", -- ret); -- goto err_mp_init_primary; -- } -- process_data.eth_dev_cnt++; -- - hw->adapter_state = HNS3_NIC_UNINITIALIZED; - hns->is_vf = true; - hw->data = eth_dev->data; -@@ -2795,10 +2781,9 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) - rte_free(hw->reset.wait_data); - - err_init_reset: -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - --err_mp_init_primary: --err_mp_init_secondary: -+err_mp_init: - eth_dev->dev_ops = NULL; - eth_dev->rx_pkt_burst = NULL; - eth_dev->rx_descriptor_status = NULL; -@@ -2819,7 +2804,7 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) - - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -- hns3_mp_uninit(); -+ hns3_mp_uninit(eth_dev); - return 0; - } - -diff --git a/drivers/net/hns3/hns3_mp.c b/drivers/net/hns3/hns3_mp.c -index 2ecb16861..63d22bcd3 100644 ---- a/drivers/net/hns3/hns3_mp.c -+++ b/drivers/net/hns3/hns3_mp.c -@@ -13,7 +13,7 @@ - #include "hns3_mp.h" - - /* local data for primary or secondary process. */ --struct hns3_process_local_data process_data; -+static struct hns3_process_local_data process_data; - - /* - * Initialize IPC message. -@@ -227,7 +227,8 @@ hns3_mp_req_start_tx(struct rte_eth_dev *dev) - /* - * Initialize by primary process. - */ --int hns3_mp_init_primary(void) -+static int -+hns3_mp_init_primary(void) - { - int ret; - -@@ -244,20 +245,11 @@ int hns3_mp_init_primary(void) - return 0; - } - --void hns3_mp_uninit(void) --{ -- process_data.eth_dev_cnt--; -- -- if (process_data.eth_dev_cnt == 0) { -- rte_mp_action_unregister(HNS3_MP_NAME); -- process_data.init_done = false; -- } --} -- - /* - * Initialize by secondary process. - */ --int hns3_mp_init_secondary(void) -+static int -+hns3_mp_init_secondary(void) - { - int ret; - -@@ -265,10 +257,52 @@ int hns3_mp_init_secondary(void) - return 0; - - ret = rte_mp_action_register(HNS3_MP_NAME, mp_secondary_handle); -- if (ret) -+ if (ret && rte_errno != ENOTSUP) - return ret; - - process_data.init_done = true; - - return 0; - } -+ -+int -+hns3_mp_init(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ int ret; -+ -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) { -+ ret = hns3_mp_init_secondary(); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "Failed to init for secondary process, ret = %d", -+ ret); -+ return ret; -+ } -+ __atomic_fetch_add(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ } else { -+ ret = hns3_mp_init_primary(); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "Failed to init for primary process, ret = %d", -+ ret); -+ return ret; -+ } -+ } -+ -+ process_data.eth_dev_cnt++; -+ -+ return 0; -+} -+ -+void hns3_mp_uninit(struct rte_eth_dev *dev) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ -+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) -+ __atomic_fetch_sub(&hw->secondary_cnt, 1, __ATOMIC_RELAXED); -+ -+ process_data.eth_dev_cnt--; -+ if (process_data.eth_dev_cnt == 0) { -+ rte_mp_action_unregister(HNS3_MP_NAME); -+ process_data.init_done = false; -+ } -+} -diff --git a/drivers/net/hns3/hns3_mp.h b/drivers/net/hns3/hns3_mp.h -index 5738ab74a..a74221d08 100644 ---- a/drivers/net/hns3/hns3_mp.h -+++ b/drivers/net/hns3/hns3_mp.h -@@ -10,15 +10,13 @@ struct hns3_process_local_data { - bool init_done; /* Process action register completed flag. */ - int eth_dev_cnt; /* Ethdev count under the current process. */ - }; --extern struct hns3_process_local_data process_data; - - void hns3_mp_req_start_rxtx(struct rte_eth_dev *dev); - void hns3_mp_req_stop_rxtx(struct rte_eth_dev *dev); - void hns3_mp_req_start_tx(struct rte_eth_dev *dev); - void hns3_mp_req_stop_tx(struct rte_eth_dev *dev); - --int hns3_mp_init_primary(void); --void hns3_mp_uninit(void); --int hns3_mp_init_secondary(void); -+int hns3_mp_init(struct rte_eth_dev *dev); -+void hns3_mp_uninit(struct rte_eth_dev *dev); - - #endif /* _HNS3_MP_H_ */ --- -2.33.0 - diff --git a/0255-usertools-devbind-add-Kunpeng-DMA.patch b/0255-usertools-devbind-add-Kunpeng-DMA.patch deleted file mode 100644 index 51919c6..0000000 --- a/0255-usertools-devbind-add-Kunpeng-DMA.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 62c1169fb30dd7407c35377364a7da2336ac1c24 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Tue, 2 Nov 2021 20:37:43 +0800 -Subject: [PATCH 22/33] usertools/devbind: add Kunpeng DMA - -Add Kunpeng DMA device ID to dmadev category. - -Signed-off-by: Chengwen Feng ---- - usertools/dpdk-devbind.py | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - mode change 100755 => 100644 usertools/dpdk-devbind.py - -diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py -old mode 100755 -new mode 100644 -index c2ede3d4d..8af3089ae ---- a/usertools/dpdk-devbind.py -+++ b/usertools/dpdk-devbind.py -@@ -45,6 +45,8 @@ - octeontx2_ree = {'Class': '08', 'Vendor': '177d', 'Device': 'a0f4', - 'SVendor': None, 'SDevice': None} - -+hisilicon_dma = {'Class': '08', 'Vendor': '19e5', 'Device': 'a122', -+ 'SVendor': None, 'SDevice': None} - intel_ioat_bdw = {'Class': '08', 'Vendor': '8086', - 'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f', - 'SVendor': None, 'SDevice': None} -@@ -62,7 +64,8 @@ - network_devices = [network_class, cavium_pkx, avp_vnic, ifpga_class] - baseband_devices = [acceleration_class] - crypto_devices = [encryption_class, intel_processor_class] --eventdev_devices = [cavium_sso, cavium_tim, octeontx2_sso] -+dma_devices = [hisilicon_dma] -+eventdev_devices = [cavium_sso, cavium_tim, intel_dlb, octeontx2_sso] - mempool_devices = [cavium_fpa, octeontx2_npa] - compress_devices = [cavium_zip] - regex_devices = [octeontx2_ree] --- -2.33.0 - diff --git a/0256-kni-check-error-code-of-allmulticast-mode-switch.patch b/0256-kni-check-error-code-of-allmulticast-mode-switch.patch deleted file mode 100644 index 276d880..0000000 --- a/0256-kni-check-error-code-of-allmulticast-mode-switch.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 72387188c6847df9a88d77c5428604db88441617 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Fri, 23 Apr 2021 16:12:42 +0800 -Subject: [PATCH 23/33] kni: check error code of allmulticast mode switch - -Some drivers may return errcode when switch allmulticast mode, -so it's necessary to check the return code. - -Fixes: b34801d1aa2e ("kni: support allmulticast mode set") -Cc: stable@dpdk.org - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) -Acked-by: Ferruh Yigit ---- - lib/librte_kni/rte_kni.c | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) - -diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c -index 837d0217d..54ea792fc 100644 ---- a/lib/librte_kni/rte_kni.c -+++ b/lib/librte_kni/rte_kni.c -@@ -514,6 +514,8 @@ kni_config_promiscusity(uint16_t port_id, uint8_t to_on) - static int - kni_config_allmulticast(uint16_t port_id, uint8_t to_on) - { -+ int ret; -+ - if (!rte_eth_dev_is_valid_port(port_id)) { - RTE_LOG(ERR, KNI, "Invalid port id %d\n", port_id); - return -EINVAL; -@@ -523,11 +525,16 @@ kni_config_allmulticast(uint16_t port_id, uint8_t to_on) - port_id, to_on); - - if (to_on) -- rte_eth_allmulticast_enable(port_id); -+ ret = rte_eth_allmulticast_enable(port_id); - else -- rte_eth_allmulticast_disable(port_id); -+ ret = rte_eth_allmulticast_disable(port_id); -+ if (ret != 0) -+ RTE_LOG(ERR, KNI, -+ "Failed to %s allmulticast mode for port %u: %s\n", -+ to_on ? "enable" : "disable", port_id, -+ rte_strerror(-ret)); - -- return 0; -+ return ret; - } - - int --- -2.33.0 - diff --git a/0257-net-hns3-simplify-queue-DMA-address-arithmetic.patch b/0257-net-hns3-simplify-queue-DMA-address-arithmetic.patch deleted file mode 100644 index 1b7aadc..0000000 --- a/0257-net-hns3-simplify-queue-DMA-address-arithmetic.patch +++ /dev/null @@ -1,42 +0,0 @@ -From cc6216dd998af8500649b7eeb520af2b80abdb90 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:42:58 +0800 -Subject: [PATCH 24/33] net/hns3: simplify queue DMA address arithmetic - -The patch obtains the upper 32 bits of the Rx/Tx queue DMA address in one -step instead of two steps. - -Fixes: bba636698316 ("net/hns3: support Rx/Tx and related operations") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index bb1723e29..b63024997 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -310,7 +310,7 @@ hns3_init_rx_queue_hw(struct hns3_rx_queue *rxq) - - hns3_write_dev(rxq, HNS3_RING_RX_BASEADDR_L_REG, (uint32_t)dma_addr); - hns3_write_dev(rxq, HNS3_RING_RX_BASEADDR_H_REG, -- (uint32_t)((dma_addr >> 31) >> 1)); -+ (uint32_t)(dma_addr >> 32)); - - hns3_write_dev(rxq, HNS3_RING_RX_BD_LEN_REG, - hns3_buf_size2type(rx_buf_len)); -@@ -325,7 +325,7 @@ hns3_init_tx_queue_hw(struct hns3_tx_queue *txq) - - hns3_write_dev(txq, HNS3_RING_TX_BASEADDR_L_REG, (uint32_t)dma_addr); - hns3_write_dev(txq, HNS3_RING_TX_BASEADDR_H_REG, -- (uint32_t)((dma_addr >> 31) >> 1)); -+ (uint32_t)(dma_addr >> 32)); - - hns3_write_dev(txq, HNS3_RING_TX_BD_NUM_REG, - HNS3_CFG_DESC_NUM(txq->nb_tx_desc)); --- -2.33.0 - diff --git a/0258-net-hns3-remove-redundant-function-declaration.patch b/0258-net-hns3-remove-redundant-function-declaration.patch deleted file mode 100644 index ae7f6cb..0000000 --- a/0258-net-hns3-remove-redundant-function-declaration.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0527eaf2489c1657ccf02a9e71f4e684eec5da77 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:42:59 +0800 -Subject: [PATCH 25/33] net/hns3: remove redundant function declaration - -This patch removes a redundant function declaration for -hns3_rx_check_vec_support(). - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.h | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.h b/drivers/net/hns3/hns3_rxtx.h -index cd7c21c1d..4c8b88352 100644 ---- a/drivers/net/hns3/hns3_rxtx.h -+++ b/drivers/net/hns3/hns3_rxtx.h -@@ -712,7 +712,6 @@ uint16_t hns3_recv_pkts_vec_sve(void *rx_queue, struct rte_mbuf **rx_pkts, - int hns3_rx_burst_mode_get(struct rte_eth_dev *dev, - __rte_unused uint16_t queue_id, - struct rte_eth_burst_mode *mode); --int hns3_rx_check_vec_support(struct rte_eth_dev *dev); - uint16_t hns3_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts, - uint16_t nb_pkts); - uint16_t hns3_xmit_pkts_simple(void *tx_queue, struct rte_mbuf **tx_pkts, --- -2.33.0 - diff --git a/0259-net-hns3-modify-an-indent-alignment.patch b/0259-net-hns3-modify-an-indent-alignment.patch deleted file mode 100644 index 992a318..0000000 --- a/0259-net-hns3-modify-an-indent-alignment.patch +++ /dev/null @@ -1,30 +0,0 @@ -From e3b6924c495f721af74a89c001dbb2497dfbcc1d Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:43:00 +0800 -Subject: [PATCH 26/33] net/hns3: modify an indent alignment - -This patch modifies some code alignment issues to make the code style -more consistent. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_rxtx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index b63024997..d5aa72c8f 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -1895,7 +1895,7 @@ hns3_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t nb_desc, - */ - if (hns->is_vf || hw->vlan_mode == HNS3_SW_SHIFT_AND_DISCARD_MODE) - rxq->pvid_sw_discard_en = hw->port_base_vlan_cfg.state == -- HNS3_PORT_BASE_VLAN_ENABLE; -+ HNS3_PORT_BASE_VLAN_ENABLE; - else - rxq->pvid_sw_discard_en = false; - rxq->ptype_en = hns3_dev_get_support(hw, RXD_ADV_LAYOUT) ? true : false; --- -2.33.0 - diff --git a/0260-net-hns3-use-unsigned-integer-for-bitwise-operations.patch b/0260-net-hns3-use-unsigned-integer-for-bitwise-operations.patch deleted file mode 100644 index a19cd64..0000000 --- a/0260-net-hns3-use-unsigned-integer-for-bitwise-operations.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 36c73d69efda51972d64318ef8cb1c7fefde482f Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:43:01 +0800 -Subject: [PATCH 27/33] net/hns3: use unsigned integer for bitwise operations - -Bitwise operations should be used only with unsigned integer. This patch -modifies some code that does not meet this rule. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index ecf912a9f..03f6da5bc 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -2104,7 +2104,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) - int max_tc = 0; - int i; - -- if ((rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG) || -+ if (((uint32_t)rx_mq_mode & ETH_MQ_RX_VMDQ_FLAG) || - (tx_mq_mode == ETH_MQ_TX_VMDQ_DCB || - tx_mq_mode == ETH_MQ_TX_VMDQ_ONLY)) { - hns3_err(hw, "VMDQ is not supported, rx_mq_mode = %d, tx_mq_mode = %d.", -@@ -2114,7 +2114,7 @@ hns3_check_mq_mode(struct rte_eth_dev *dev) - - dcb_rx_conf = &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf; - dcb_tx_conf = &dev->data->dev_conf.tx_adv_conf.dcb_tx_conf; -- if (rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { -+ if ((uint32_t)rx_mq_mode & ETH_MQ_RX_DCB_FLAG) { - if (dcb_rx_conf->nb_tcs > pf->tc_max) { - hns3_err(hw, "nb_tcs(%u) > max_tc(%u) driver supported.", - dcb_rx_conf->nb_tcs, pf->tc_max); --- -2.33.0 - diff --git a/0261-net-hns3-extract-common-code-to-its-own-file.patch b/0261-net-hns3-extract-common-code-to-its-own-file.patch deleted file mode 100644 index cfc72d6..0000000 --- a/0261-net-hns3-extract-common-code-to-its-own-file.patch +++ /dev/null @@ -1,1143 +0,0 @@ -From 78bf7630d452218688fa2760ab847ea06e2c01f5 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:43:02 +0800 -Subject: [PATCH 28/33] net/hns3: extract common code to its own file - -This patch extracts a common file to store the common code for PF and VF -driver. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_cmd.c | 2 +- - drivers/net/hns3/hns3_common.c | 426 +++++++++++++++++++++++++++++ - drivers/net/hns3/hns3_common.h | 48 ++++ - drivers/net/hns3/hns3_ethdev.c | 430 +----------------------------- - drivers/net/hns3/hns3_ethdev.h | 28 +- - drivers/net/hns3/hns3_ethdev_vf.c | 1 + - drivers/net/hns3/hns3_intr.c | 2 +- - drivers/net/hns3/hns3_mbx.c | 2 +- - drivers/net/hns3/hns3_rxtx.c | 2 +- - drivers/net/hns3/meson.build | 4 +- - 10 files changed, 484 insertions(+), 461 deletions(-) - create mode 100644 drivers/net/hns3/hns3_common.c - create mode 100644 drivers/net/hns3/hns3_common.h - -diff --git a/drivers/net/hns3/hns3_cmd.c b/drivers/net/hns3/hns3_cmd.c -index 6e49108d2..94cb10c4f 100644 ---- a/drivers/net/hns3/hns3_cmd.c -+++ b/drivers/net/hns3/hns3_cmd.c -@@ -5,7 +5,7 @@ - #include - #include - --#include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_regs.h" - #include "hns3_intr.h" - #include "hns3_logs.h" -diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c -new file mode 100644 -index 000000000..85316d342 ---- /dev/null -+++ b/drivers/net/hns3/hns3_common.c -@@ -0,0 +1,426 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(C) 2021 HiSilicon Limited -+ */ -+ -+#include -+ -+#include "hns3_logs.h" -+#include "hns3_common.h" -+ -+static int -+hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) -+{ -+ uint32_t hint = HNS3_IO_FUNC_HINT_NONE; -+ -+ RTE_SET_USED(key); -+ -+ if (strcmp(value, "vec") == 0) -+ hint = HNS3_IO_FUNC_HINT_VEC; -+ else if (strcmp(value, "sve") == 0) -+ hint = HNS3_IO_FUNC_HINT_SVE; -+ else if (strcmp(value, "simple") == 0) -+ hint = HNS3_IO_FUNC_HINT_SIMPLE; -+ else if (strcmp(value, "common") == 0) -+ hint = HNS3_IO_FUNC_HINT_COMMON; -+ -+ /* If the hint is valid then update output parameters */ -+ if (hint != HNS3_IO_FUNC_HINT_NONE) -+ *(uint32_t *)extra_args = hint; -+ -+ return 0; -+} -+ -+static const char * -+hns3_get_io_hint_func_name(uint32_t hint) -+{ -+ switch (hint) { -+ case HNS3_IO_FUNC_HINT_VEC: -+ return "vec"; -+ case HNS3_IO_FUNC_HINT_SVE: -+ return "sve"; -+ case HNS3_IO_FUNC_HINT_SIMPLE: -+ return "simple"; -+ case HNS3_IO_FUNC_HINT_COMMON: -+ return "common"; -+ default: -+ return "none"; -+ } -+} -+ -+static int -+hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) -+{ -+ uint64_t val; -+ -+ RTE_SET_USED(key); -+ -+ val = strtoull(value, NULL, 16); -+ *(uint64_t *)extra_args = val; -+ -+ return 0; -+} -+ -+static int -+hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) -+{ -+ uint32_t val; -+ -+ RTE_SET_USED(key); -+ -+ val = strtoul(value, NULL, 10); -+ if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) -+ *(uint16_t *)extra_args = val; -+ -+ return 0; -+} -+ -+void -+hns3_parse_devargs(struct rte_eth_dev *dev) -+{ -+ uint16_t mbx_time_limit_ms = HNS3_MBX_DEF_TIME_LIMIT_MS; -+ struct hns3_adapter *hns = dev->data->dev_private; -+ uint32_t rx_func_hint = HNS3_IO_FUNC_HINT_NONE; -+ uint32_t tx_func_hint = HNS3_IO_FUNC_HINT_NONE; -+ struct hns3_hw *hw = &hns->hw; -+ uint64_t dev_caps_mask = 0; -+ struct rte_kvargs *kvlist; -+ -+ if (dev->device->devargs == NULL) -+ return; -+ -+ kvlist = rte_kvargs_parse(dev->device->devargs->args, NULL); -+ if (!kvlist) -+ return; -+ -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_RX_FUNC_HINT, -+ &hns3_parse_io_hint_func, &rx_func_hint); -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, -+ &hns3_parse_io_hint_func, &tx_func_hint); -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, -+ &hns3_parse_dev_caps_mask, &dev_caps_mask); -+ (void)rte_kvargs_process(kvlist, HNS3_DEVARG_MBX_TIME_LIMIT_MS, -+ &hns3_parse_mbx_time_limit, &mbx_time_limit_ms); -+ -+ rte_kvargs_free(kvlist); -+ -+ if (rx_func_hint != HNS3_IO_FUNC_HINT_NONE) -+ hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_RX_FUNC_HINT, -+ hns3_get_io_hint_func_name(rx_func_hint)); -+ hns->rx_func_hint = rx_func_hint; -+ if (tx_func_hint != HNS3_IO_FUNC_HINT_NONE) -+ hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_TX_FUNC_HINT, -+ hns3_get_io_hint_func_name(tx_func_hint)); -+ hns->tx_func_hint = tx_func_hint; -+ -+ if (dev_caps_mask != 0) -+ hns3_warn(hw, "parsed %s = 0x%" PRIx64 ".", -+ HNS3_DEVARG_DEV_CAPS_MASK, dev_caps_mask); -+ hns->dev_caps_mask = dev_caps_mask; -+} -+ -+void -+hns3_clock_gettime(struct timeval *tv) -+{ -+#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ -+#define CLOCK_TYPE CLOCK_MONOTONIC_RAW -+#else -+#define CLOCK_TYPE CLOCK_MONOTONIC -+#endif -+#define NSEC_TO_USEC_DIV 1000 -+ -+ struct timespec spec; -+ (void)clock_gettime(CLOCK_TYPE, &spec); -+ -+ tv->tv_sec = spec.tv_sec; -+ tv->tv_usec = spec.tv_nsec / NSEC_TO_USEC_DIV; -+} -+ -+uint64_t -+hns3_clock_calctime_ms(struct timeval *tv) -+{ -+ return (uint64_t)tv->tv_sec * MSEC_PER_SEC + -+ tv->tv_usec / USEC_PER_MSEC; -+} -+ -+uint64_t -+hns3_clock_gettime_ms(void) -+{ -+ struct timeval tv; -+ -+ hns3_clock_gettime(&tv); -+ return hns3_clock_calctime_ms(&tv); -+} -+ -+void hns3_ether_format_addr(char *buf, uint16_t size, -+ const struct rte_ether_addr *ether_addr) -+{ -+ snprintf(buf, size, "%02X:**:**:**:%02X:%02X", -+ ether_addr->addr_bytes[0], -+ ether_addr->addr_bytes[4], -+ ether_addr->addr_bytes[5]); -+} -+ -+static int -+hns3_set_mc_addr_chk_param(struct hns3_hw *hw, -+ struct rte_ether_addr *mc_addr_set, -+ uint32_t nb_mc_addr) -+{ -+ struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ struct rte_ether_addr *addr; -+ uint16_t mac_addrs_capa; -+ uint32_t i; -+ uint32_t j; -+ -+ if (nb_mc_addr > HNS3_MC_MACADDR_NUM) { -+ hns3_err(hw, "failed to set mc mac addr, nb_mc_addr(%u) " -+ "invalid. valid range: 0~%d", -+ nb_mc_addr, HNS3_MC_MACADDR_NUM); -+ return -EINVAL; -+ } -+ -+ /* Check if input mac addresses are valid */ -+ for (i = 0; i < nb_mc_addr; i++) { -+ addr = &mc_addr_set[i]; -+ if (!rte_is_multicast_ether_addr(addr)) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ addr); -+ hns3_err(hw, -+ "failed to set mc mac addr, addr(%s) invalid.", -+ mac_str); -+ return -EINVAL; -+ } -+ -+ /* Check if there are duplicate addresses */ -+ for (j = i + 1; j < nb_mc_addr; j++) { -+ if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) { -+ hns3_ether_format_addr(mac_str, -+ RTE_ETHER_ADDR_FMT_SIZE, -+ addr); -+ hns3_err(hw, "failed to set mc mac addr, " -+ "addrs invalid. two same addrs(%s).", -+ mac_str); -+ return -EINVAL; -+ } -+ } -+ -+ /* -+ * Check if there are duplicate addresses between mac_addrs -+ * and mc_addr_set -+ */ -+ mac_addrs_capa = hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : -+ HNS3_UC_MACADDR_NUM; -+ for (j = 0; j < mac_addrs_capa; j++) { -+ if (rte_is_same_ether_addr(addr, -+ &hw->data->mac_addrs[j])) { -+ hns3_ether_format_addr(mac_str, -+ RTE_ETHER_ADDR_FMT_SIZE, -+ addr); -+ hns3_err(hw, "failed to set mc mac addr, " -+ "addrs invalid. addrs(%s) has already " -+ "configured in mac_addr add API", -+ mac_str); -+ return -EINVAL; -+ } -+ } -+ } -+ -+ return 0; -+} -+ -+int -+hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, -+ struct rte_ether_addr *mc_addr_set, -+ uint32_t nb_mc_addr) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ struct rte_ether_addr *addr; -+ int cur_addr_num; -+ int set_addr_num; -+ int num; -+ int ret; -+ int i; -+ -+ /* Check if input parameters are valid */ -+ ret = hns3_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr); -+ if (ret) -+ return ret; -+ -+ rte_spinlock_lock(&hw->lock); -+ cur_addr_num = hw->mc_addrs_num; -+ for (i = 0; i < cur_addr_num; i++) { -+ num = cur_addr_num - i - 1; -+ addr = &hw->mc_addrs[num]; -+ ret = hw->ops.del_mc_mac_addr(hw, addr); -+ if (ret) { -+ rte_spinlock_unlock(&hw->lock); -+ return ret; -+ } -+ -+ hw->mc_addrs_num--; -+ } -+ -+ set_addr_num = (int)nb_mc_addr; -+ for (i = 0; i < set_addr_num; i++) { -+ addr = &mc_addr_set[i]; -+ ret = hw->ops.add_mc_mac_addr(hw, addr); -+ if (ret) { -+ rte_spinlock_unlock(&hw->lock); -+ return ret; -+ } -+ -+ rte_ether_addr_copy(addr, &hw->mc_addrs[hw->mc_addrs_num]); -+ hw->mc_addrs_num++; -+ } -+ rte_spinlock_unlock(&hw->lock); -+ -+ return 0; -+} -+ -+int -+hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) -+{ -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ struct hns3_hw *hw = &hns->hw; -+ struct rte_ether_addr *addr; -+ int ret = 0; -+ int i; -+ -+ for (i = 0; i < hw->mc_addrs_num; i++) { -+ addr = &hw->mc_addrs[i]; -+ if (!rte_is_multicast_ether_addr(addr)) -+ continue; -+ if (del) -+ ret = hw->ops.del_mc_mac_addr(hw, addr); -+ else -+ ret = hw->ops.add_mc_mac_addr(hw, addr); -+ if (ret) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ addr); -+ hns3_dbg(hw, "failed to %s mc mac addr: %s ret = %d", -+ del ? "Remove" : "Restore", mac_str, ret); -+ } -+ } -+ return ret; -+} -+ -+int -+hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) -+{ -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ struct hns3_hw *hw = &hns->hw; -+ struct hns3_hw_ops *ops = &hw->ops; -+ struct rte_ether_addr *addr; -+ uint16_t mac_addrs_capa; -+ int ret = 0; -+ int i; -+ -+ mac_addrs_capa = -+ hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM; -+ for (i = 0; i < mac_addrs_capa; i++) { -+ addr = &hw->data->mac_addrs[i]; -+ if (rte_is_zero_ether_addr(addr)) -+ continue; -+ if (rte_is_multicast_ether_addr(addr)) -+ ret = del ? ops->del_mc_mac_addr(hw, addr) : -+ ops->add_mc_mac_addr(hw, addr); -+ else -+ ret = del ? ops->del_uc_mac_addr(hw, addr) : -+ ops->add_uc_mac_addr(hw, addr); -+ -+ if (ret) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ addr); -+ hns3_err(hw, "failed to %s mac addr(%s) index:%d ret = %d.", -+ del ? "remove" : "restore", mac_str, i, ret); -+ } -+ } -+ -+ return ret; -+} -+ -+static bool -+hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) -+{ -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ struct rte_ether_addr *addr; -+ int i; -+ -+ for (i = 0; i < hw->mc_addrs_num; i++) { -+ addr = &hw->mc_addrs[i]; -+ /* Check if there are duplicate addresses in mc_addrs[] */ -+ if (rte_is_same_ether_addr(addr, mc_addr)) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ addr); -+ hns3_err(hw, "failed to add mc mac addr, same addrs" -+ "(%s) is added by the set_mc_mac_addr_list " -+ "API", mac_str); -+ return true; -+ } -+ } -+ -+ return false; -+} -+ -+int -+hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -+ __rte_unused uint32_t idx, __rte_unused uint32_t pool) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ int ret; -+ -+ rte_spinlock_lock(&hw->lock); -+ -+ /* -+ * In hns3 network engine adding UC and MC mac address with different -+ * commands with firmware. We need to determine whether the input -+ * address is a UC or a MC address to call different commands. -+ * By the way, it is recommended calling the API function named -+ * rte_eth_dev_set_mc_addr_list to set the MC mac address, because -+ * using the rte_eth_dev_mac_addr_add API function to set MC mac address -+ * may affect the specifications of UC mac addresses. -+ */ -+ if (rte_is_multicast_ether_addr(mac_addr)) { -+ if (hns3_find_duplicate_mc_addr(hw, mac_addr)) { -+ rte_spinlock_unlock(&hw->lock); -+ return -EINVAL; -+ } -+ ret = hw->ops.add_mc_mac_addr(hw, mac_addr); -+ } else { -+ ret = hw->ops.add_uc_mac_addr(hw, mac_addr); -+ } -+ rte_spinlock_unlock(&hw->lock); -+ if (ret) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ mac_addr); -+ hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str, -+ ret); -+ } -+ -+ return ret; -+} -+ -+void -+hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) -+{ -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ /* index will be checked by upper level rte interface */ -+ struct rte_ether_addr *mac_addr = &dev->data->mac_addrs[idx]; -+ char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -+ int ret; -+ -+ rte_spinlock_lock(&hw->lock); -+ -+ if (rte_is_multicast_ether_addr(mac_addr)) -+ ret = hw->ops.del_mc_mac_addr(hw, mac_addr); -+ else -+ ret = hw->ops.del_uc_mac_addr(hw, mac_addr); -+ rte_spinlock_unlock(&hw->lock); -+ if (ret) { -+ hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -+ mac_addr); -+ hns3_err(hw, "failed to remove mac addr(%s), ret = %d", mac_str, -+ ret); -+ } -+} -diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h -new file mode 100644 -index 000000000..094a0bc5f ---- /dev/null -+++ b/drivers/net/hns3/hns3_common.h -@@ -0,0 +1,48 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(C) 2021 HiSilicon Limited -+ */ -+ -+#ifndef _HNS3_COMMON_H_ -+#define _HNS3_COMMON_H_ -+ -+#include -+ -+#include "hns3_ethdev.h" -+ -+enum { -+ HNS3_IO_FUNC_HINT_NONE = 0, -+ HNS3_IO_FUNC_HINT_VEC, -+ HNS3_IO_FUNC_HINT_SVE, -+ HNS3_IO_FUNC_HINT_SIMPLE, -+ HNS3_IO_FUNC_HINT_COMMON -+}; -+ -+#define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint" -+#define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint" -+ -+#define HNS3_DEVARG_DEV_CAPS_MASK "dev_caps_mask" -+ -+#define HNS3_DEVARG_MBX_TIME_LIMIT_MS "mbx_time_limit_ms" -+ -+#define MSEC_PER_SEC 1000L -+#define USEC_PER_MSEC 1000L -+ -+void hns3_clock_gettime(struct timeval *tv); -+uint64_t hns3_clock_calctime_ms(struct timeval *tv); -+uint64_t hns3_clock_gettime_ms(void); -+ -+void hns3_parse_devargs(struct rte_eth_dev *dev); -+ -+int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del); -+int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del); -+int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -+ __rte_unused uint32_t idx, __rte_unused uint32_t pool); -+ -+void hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx); -+int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, -+ struct rte_ether_addr *mc_addr_set, -+ uint32_t nb_mc_addr); -+void hns3_ether_format_addr(char *buf, uint16_t size, -+ const struct rte_ether_addr *ether_addr); -+ -+#endif /* _HNS3_COMMON_H_ */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 03f6da5bc..818835391 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -6,9 +6,9 @@ - #include - #include - #include --#include - - #include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_logs.h" - #include "hns3_rxtx.h" - #include "hns3_intr.h" -@@ -105,14 +105,6 @@ static int hns3_do_stop(struct hns3_adapter *hns); - static int hns3_check_port_speed(struct hns3_hw *hw, uint32_t link_speeds); - static int hns3_cfg_mac_mode(struct hns3_hw *hw, bool enable); - --void hns3_ether_format_addr(char *buf, uint16_t size, -- const struct rte_ether_addr *ether_addr) --{ -- snprintf(buf, size, "%02X:**:**:**:%02X:%02X", -- ether_addr->addr_bytes[0], -- ether_addr->addr_bytes[4], -- ether_addr->addr_bytes[5]); --} - - static void - hns3_pf_disable_irq0(struct hns3_hw *hw) -@@ -1609,68 +1601,6 @@ hns3_add_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static bool --hns3_find_duplicate_mc_addr(struct hns3_hw *hw, struct rte_ether_addr *mc_addr) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct rte_ether_addr *addr; -- int i; -- -- for (i = 0; i < hw->mc_addrs_num; i++) { -- addr = &hw->mc_addrs[i]; -- /* Check if there are duplicate addresses in mc_addrs[] */ -- if (rte_is_same_ether_addr(addr, mc_addr)) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to add mc mac addr, same addrs" -- "(%s) is added by the set_mc_mac_addr_list " -- "API", mac_str); -- return true; -- } -- } -- -- return false; --} -- --int --hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -- __rte_unused uint32_t idx, __rte_unused uint32_t pool) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- rte_spinlock_lock(&hw->lock); -- -- /* -- * In hns3 network engine adding UC and MC mac address with different -- * commands with firmware. We need to determine whether the input -- * address is a UC or a MC address to call different commands. -- * By the way, it is recommended calling the API function named -- * rte_eth_dev_set_mc_addr_list to set the MC mac address, because -- * using the rte_eth_dev_mac_addr_add API function to set MC mac address -- * may affect the specifications of UC mac addresses. -- */ -- if (rte_is_multicast_ether_addr(mac_addr)) { -- if (hns3_find_duplicate_mc_addr(hw, mac_addr)) { -- rte_spinlock_unlock(&hw->lock); -- return -EINVAL; -- } -- ret = hw->ops.add_mc_mac_addr(hw, mac_addr); -- } else { -- ret = hw->ops.add_uc_mac_addr(hw, mac_addr); -- } -- rte_spinlock_unlock(&hw->lock); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to add mac addr(%s), ret = %d", mac_str, -- ret); -- } -- -- return ret; --} -- - static int - hns3_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - { -@@ -1699,30 +1629,6 @@ hns3_remove_uc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --void --hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- /* index will be checked by upper level rte interface */ -- struct rte_ether_addr *mac_addr = &dev->data->mac_addrs[idx]; -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- int ret; -- -- rte_spinlock_lock(&hw->lock); -- -- if (rte_is_multicast_ether_addr(mac_addr)) -- ret = hw->ops.del_mc_mac_addr(hw, mac_addr); -- else -- ret = hw->ops.del_uc_mac_addr(hw, mac_addr); -- rte_spinlock_unlock(&hw->lock); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- mac_addr); -- hns3_err(hw, "failed to remove mac addr(%s), ret = %d", mac_str, -- ret); -- } --} -- - static int - hns3_set_default_mac_addr(struct rte_eth_dev *dev, - struct rte_ether_addr *mac_addr) -@@ -1787,41 +1693,6 @@ hns3_set_default_mac_addr(struct rte_eth_dev *dev, - return ret; - } - --int --hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct hns3_hw *hw = &hns->hw; -- struct hns3_hw_ops *ops = &hw->ops; -- struct rte_ether_addr *addr; -- uint16_t mac_addrs_capa; -- int ret = 0; -- int i; -- -- mac_addrs_capa = -- hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : HNS3_UC_MACADDR_NUM; -- for (i = 0; i < mac_addrs_capa; i++) { -- addr = &hw->data->mac_addrs[i]; -- if (rte_is_zero_ether_addr(addr)) -- continue; -- if (rte_is_multicast_ether_addr(addr)) -- ret = del ? ops->del_mc_mac_addr(hw, addr) : -- ops->add_mc_mac_addr(hw, addr); -- else -- ret = del ? ops->del_uc_mac_addr(hw, addr) : -- ops->add_uc_mac_addr(hw, addr); -- -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to %s mac addr(%s) index:%d ret = %d.", -- del ? "remove" : "restore", mac_str, i, ret); -- } -- } -- -- return ret; --} -- - static void - hns3_update_desc_vfid(struct hns3_cmd_desc *desc, uint8_t vfid, bool clr) - { -@@ -1947,150 +1818,6 @@ hns3_remove_mc_mac_addr(struct hns3_hw *hw, struct rte_ether_addr *mac_addr) - return ret; - } - --static int --hns3_set_mc_addr_chk_param(struct hns3_hw *hw, -- struct rte_ether_addr *mc_addr_set, -- uint32_t nb_mc_addr) --{ -- struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct rte_ether_addr *addr; -- uint16_t mac_addrs_capa; -- uint32_t i; -- uint32_t j; -- -- if (nb_mc_addr > HNS3_MC_MACADDR_NUM) { -- hns3_err(hw, "failed to set mc mac addr, nb_mc_addr(%u) " -- "invalid. valid range: 0~%d", -- nb_mc_addr, HNS3_MC_MACADDR_NUM); -- return -EINVAL; -- } -- -- /* Check if input mac addresses are valid */ -- for (i = 0; i < nb_mc_addr; i++) { -- addr = &mc_addr_set[i]; -- if (!rte_is_multicast_ether_addr(addr)) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, -- "failed to set mc mac addr, addr(%s) invalid.", -- mac_str); -- return -EINVAL; -- } -- -- /* Check if there are duplicate addresses */ -- for (j = i + 1; j < nb_mc_addr; j++) { -- if (rte_is_same_ether_addr(addr, &mc_addr_set[j])) { -- hns3_ether_format_addr(mac_str, -- RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to set mc mac addr, " -- "addrs invalid. two same addrs(%s).", -- mac_str); -- return -EINVAL; -- } -- } -- -- /* -- * Check if there are duplicate addresses between mac_addrs -- * and mc_addr_set -- */ -- mac_addrs_capa = hns->is_vf ? HNS3_VF_UC_MACADDR_NUM : -- HNS3_UC_MACADDR_NUM; -- for (j = 0; j < mac_addrs_capa; j++) { -- if (rte_is_same_ether_addr(addr, -- &hw->data->mac_addrs[j])) { -- hns3_ether_format_addr(mac_str, -- RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_err(hw, "failed to set mc mac addr, " -- "addrs invalid. addrs(%s) has already " -- "configured in mac_addr add API", -- mac_str); -- return -EINVAL; -- } -- } -- } -- -- return 0; --} -- --int --hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, -- struct rte_ether_addr *mc_addr_set, -- uint32_t nb_mc_addr) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct rte_ether_addr *addr; -- int cur_addr_num; -- int set_addr_num; -- int num; -- int ret; -- int i; -- -- /* Check if input parameters are valid */ -- ret = hns3_set_mc_addr_chk_param(hw, mc_addr_set, nb_mc_addr); -- if (ret) -- return ret; -- -- rte_spinlock_lock(&hw->lock); -- cur_addr_num = hw->mc_addrs_num; -- for (i = 0; i < cur_addr_num; i++) { -- num = cur_addr_num - i - 1; -- addr = &hw->mc_addrs[num]; -- ret = hw->ops.del_mc_mac_addr(hw, addr); -- if (ret) { -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -- -- hw->mc_addrs_num--; -- } -- -- set_addr_num = (int)nb_mc_addr; -- for (i = 0; i < set_addr_num; i++) { -- addr = &mc_addr_set[i]; -- ret = hw->ops.add_mc_mac_addr(hw, addr); -- if (ret) { -- rte_spinlock_unlock(&hw->lock); -- return ret; -- } -- -- rte_ether_addr_copy(addr, &hw->mc_addrs[hw->mc_addrs_num]); -- hw->mc_addrs_num++; -- } -- rte_spinlock_unlock(&hw->lock); -- -- return 0; --} -- --int --hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del) --{ -- char mac_str[RTE_ETHER_ADDR_FMT_SIZE]; -- struct hns3_hw *hw = &hns->hw; -- struct rte_ether_addr *addr; -- int ret = 0; -- int i; -- -- for (i = 0; i < hw->mc_addrs_num; i++) { -- addr = &hw->mc_addrs[i]; -- if (!rte_is_multicast_ether_addr(addr)) -- continue; -- if (del) -- ret = hw->ops.del_mc_mac_addr(hw, addr); -- else -- ret = hw->ops.add_mc_mac_addr(hw, addr); -- if (ret) { -- hns3_ether_format_addr(mac_str, RTE_ETHER_ADDR_FMT_SIZE, -- addr); -- hns3_dbg(hw, "failed to %s mc mac addr: %s ret = %d", -- del ? "Remove" : "Restore", mac_str, ret); -- } -- } -- return ret; --} -- - static int - hns3_check_mq_mode(struct rte_eth_dev *dev) - { -@@ -7155,161 +6882,6 @@ hns3_get_module_info(struct rte_eth_dev *dev, - return 0; - } - --void --hns3_clock_gettime(struct timeval *tv) --{ --#ifdef CLOCK_MONOTONIC_RAW /* Defined in glibc bits/time.h */ --#define CLOCK_TYPE CLOCK_MONOTONIC_RAW --#else --#define CLOCK_TYPE CLOCK_MONOTONIC --#endif --#define NSEC_TO_USEC_DIV 1000 -- -- struct timespec spec; -- (void)clock_gettime(CLOCK_TYPE, &spec); -- -- tv->tv_sec = spec.tv_sec; -- tv->tv_usec = spec.tv_nsec / NSEC_TO_USEC_DIV; --} -- --uint64_t --hns3_clock_calctime_ms(struct timeval *tv) --{ -- return (uint64_t)tv->tv_sec * MSEC_PER_SEC + -- tv->tv_usec / USEC_PER_MSEC; --} -- --uint64_t --hns3_clock_gettime_ms(void) --{ -- struct timeval tv; -- -- hns3_clock_gettime(&tv); -- return hns3_clock_calctime_ms(&tv); --} -- --static int --hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) --{ -- uint32_t hint = HNS3_IO_FUNC_HINT_NONE; -- -- RTE_SET_USED(key); -- -- if (strcmp(value, "vec") == 0) -- hint = HNS3_IO_FUNC_HINT_VEC; -- else if (strcmp(value, "sve") == 0) -- hint = HNS3_IO_FUNC_HINT_SVE; -- else if (strcmp(value, "simple") == 0) -- hint = HNS3_IO_FUNC_HINT_SIMPLE; -- else if (strcmp(value, "common") == 0) -- hint = HNS3_IO_FUNC_HINT_COMMON; -- -- /* If the hint is valid then update output parameters */ -- if (hint != HNS3_IO_FUNC_HINT_NONE) -- *(uint32_t *)extra_args = hint; -- -- return 0; --} -- --static const char * --hns3_get_io_hint_func_name(uint32_t hint) --{ -- switch (hint) { -- case HNS3_IO_FUNC_HINT_VEC: -- return "vec"; -- case HNS3_IO_FUNC_HINT_SVE: -- return "sve"; -- case HNS3_IO_FUNC_HINT_SIMPLE: -- return "simple"; -- case HNS3_IO_FUNC_HINT_COMMON: -- return "common"; -- default: -- return "none"; -- } --} -- --static int --hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) --{ -- uint64_t val; -- -- RTE_SET_USED(key); -- -- val = strtoull(value, NULL, 16); -- *(uint64_t *)extra_args = val; -- -- return 0; --} -- --static int --hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) --{ -- uint32_t val; -- -- RTE_SET_USED(key); -- -- val = strtoul(value, NULL, 10); -- -- /* -- * 500ms is empirical value in process of mailbox communication. If -- * the delay value is set to one lower thanthe empirical value, mailbox -- * communication may fail. -- */ -- if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) -- *(uint16_t *)extra_args = val; -- -- return 0; --} -- --void --hns3_parse_devargs(struct rte_eth_dev *dev) --{ -- uint16_t mbx_time_limit_ms = HNS3_MBX_DEF_TIME_LIMIT_MS; -- struct hns3_adapter *hns = dev->data->dev_private; -- uint32_t rx_func_hint = HNS3_IO_FUNC_HINT_NONE; -- uint32_t tx_func_hint = HNS3_IO_FUNC_HINT_NONE; -- struct hns3_hw *hw = &hns->hw; -- uint64_t dev_caps_mask = 0; -- struct rte_kvargs *kvlist; -- -- if (dev->device->devargs == NULL) -- return; -- -- kvlist = rte_kvargs_parse(dev->device->devargs->args, NULL); -- if (!kvlist) -- return; -- -- (void)rte_kvargs_process(kvlist, HNS3_DEVARG_RX_FUNC_HINT, -- &hns3_parse_io_hint_func, &rx_func_hint); -- (void)rte_kvargs_process(kvlist, HNS3_DEVARG_TX_FUNC_HINT, -- &hns3_parse_io_hint_func, &tx_func_hint); -- (void)rte_kvargs_process(kvlist, HNS3_DEVARG_DEV_CAPS_MASK, -- &hns3_parse_dev_caps_mask, &dev_caps_mask); -- (void)rte_kvargs_process(kvlist, HNS3_DEVARG_MBX_TIME_LIMIT_MS, -- &hns3_parse_mbx_time_limit, &mbx_time_limit_ms); -- -- rte_kvargs_free(kvlist); -- -- if (rx_func_hint != HNS3_IO_FUNC_HINT_NONE) -- hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_RX_FUNC_HINT, -- hns3_get_io_hint_func_name(rx_func_hint)); -- hns->rx_func_hint = rx_func_hint; -- if (tx_func_hint != HNS3_IO_FUNC_HINT_NONE) -- hns3_warn(hw, "parsed %s = %s.", HNS3_DEVARG_TX_FUNC_HINT, -- hns3_get_io_hint_func_name(tx_func_hint)); -- hns->tx_func_hint = tx_func_hint; -- -- if (dev_caps_mask != 0) -- hns3_warn(hw, "parsed %s = 0x%" PRIx64 ".", -- HNS3_DEVARG_DEV_CAPS_MASK, dev_caps_mask); -- hns->dev_caps_mask = dev_caps_mask; -- -- if (mbx_time_limit_ms != HNS3_MBX_DEF_TIME_LIMIT_MS) -- hns3_warn(hw, "parsed %s = %u.", HNS3_DEVARG_MBX_TIME_LIMIT_MS, -- mbx_time_limit_ms); -- hns->mbx_time_limit_ms = mbx_time_limit_ms; --} -- - static const struct eth_dev_ops hns3_eth_dev_ops = { - .dev_configure = hns3_dev_configure, - .dev_start = hns3_dev_start, -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 1f1364304..96671159b 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -6,7 +6,6 @@ - #define _HNS3_ETHDEV_H_ - - #include --#include - #include - #include - #include -@@ -869,14 +868,6 @@ struct hns3_adapter { - struct hns3_ptype_table ptype_tbl __rte_cache_aligned; - }; - --enum { -- HNS3_IO_FUNC_HINT_NONE = 0, -- HNS3_IO_FUNC_HINT_VEC, -- HNS3_IO_FUNC_HINT_SVE, -- HNS3_IO_FUNC_HINT_SIMPLE, -- HNS3_IO_FUNC_HINT_COMMON --}; -- - #define HNS3_DEVARG_RX_FUNC_HINT "rx_func_hint" - #define HNS3_DEVARG_TX_FUNC_HINT "tx_func_hint" - -@@ -1011,13 +1002,6 @@ static inline uint32_t hns3_read_reg(void *base, uint32_t reg) - } \ - } while (0) - --#define MSEC_PER_SEC 1000L --#define USEC_PER_MSEC 1000L -- --void hns3_clock_gettime(struct timeval *tv); --uint64_t hns3_clock_calctime_ms(struct timeval *tv); --uint64_t hns3_clock_gettime_ms(void); -- - static inline uint64_t - hns3_atomic_test_bit(unsigned int nr, volatile uint64_t *addr) - { -@@ -1054,22 +1038,12 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, - bool hns3_is_reset_pending(struct hns3_adapter *hns); - bool hns3vf_is_reset_pending(struct hns3_adapter *hns); - void hns3_update_linkstatus_and_event(struct hns3_hw *hw, bool query); --void hns3_ether_format_addr(char *buf, uint16_t size, -- const struct rte_ether_addr *ether_addr); - int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, - struct rte_eth_dev_info *info); - void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); --void hns3_parse_devargs(struct rte_eth_dev *dev); - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); --int hns3_configure_all_mc_mac_addr(struct hns3_adapter *hns, bool del); --int hns3_configure_all_mac_addr(struct hns3_adapter *hns, bool del); --int hns3_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, -- __rte_unused uint32_t idx, __rte_unused uint32_t pool); --void hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx); --int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, -- struct rte_ether_addr *mc_addr_set, -- uint32_t nb_mc_addr); -+ - int hns3_restore_ptp(struct hns3_adapter *hns); - int hns3_mbuf_dyn_rx_timestamp_register(struct rte_eth_dev *dev, - struct rte_eth_conf *conf); -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 1e0cb1b63..c234e74b8 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -10,6 +10,7 @@ - #include - - #include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_logs.h" - #include "hns3_rxtx.h" - #include "hns3_regs.h" -diff --git a/drivers/net/hns3/hns3_intr.c b/drivers/net/hns3/hns3_intr.c -index 3484c76d2..66dc50908 100644 ---- a/drivers/net/hns3/hns3_intr.c -+++ b/drivers/net/hns3/hns3_intr.c -@@ -8,7 +8,7 @@ - #include - #include - --#include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_logs.h" - #include "hns3_intr.h" - #include "hns3_regs.h" -diff --git a/drivers/net/hns3/hns3_mbx.c b/drivers/net/hns3/hns3_mbx.c -index 3ad85e721..04ae9aced 100644 ---- a/drivers/net/hns3/hns3_mbx.c -+++ b/drivers/net/hns3/hns3_mbx.c -@@ -5,7 +5,7 @@ - #include - #include - --#include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_regs.h" - #include "hns3_logs.h" - #include "hns3_intr.h" -diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c -index d5aa72c8f..2e41bb1b5 100644 ---- a/drivers/net/hns3/hns3_rxtx.c -+++ b/drivers/net/hns3/hns3_rxtx.c -@@ -16,7 +16,7 @@ - #include - #endif - --#include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_rxtx.h" - #include "hns3_regs.h" - #include "hns3_logs.h" -diff --git a/drivers/net/hns3/meson.build b/drivers/net/hns3/meson.build -index 881aff6de..dd49e38c4 100644 ---- a/drivers/net/hns3/meson.build -+++ b/drivers/net/hns3/meson.build -@@ -27,7 +27,9 @@ sources = files('hns3_cmd.c', - 'hns3_stats.c', - 'hns3_mp.c', - 'hns3_tm.c', -- 'hns3_ptp.c') -+ 'hns3_ptp.c', -+ 'hns3_common.c', -+) - - deps += ['hash'] - --- -2.33.0 - diff --git a/0262-net-hns3-move-declarations-in-flow-header-file.patch b/0262-net-hns3-move-declarations-in-flow-header-file.patch deleted file mode 100644 index 01c286a..0000000 --- a/0262-net-hns3-move-declarations-in-flow-header-file.patch +++ /dev/null @@ -1,191 +0,0 @@ -From f50d0076e2e9dad6e94fcc64108fb52592bf5c00 Mon Sep 17 00:00:00 2001 -From: "Min Hu (Connor)" -Date: Sat, 6 Nov 2021 09:43:03 +0800 -Subject: [PATCH 29/33] net/hns3: move declarations in flow header file - -This patch adds a hns3_flow.h to make the code easier to maintain. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_ethdev.c | 1 + - drivers/net/hns3/hns3_ethdev.h | 1 + - drivers/net/hns3/hns3_ethdev_vf.c | 1 + - drivers/net/hns3/hns3_fdir.h | 31 ---------------------- - drivers/net/hns3/hns3_flow.c | 1 + - drivers/net/hns3/hns3_flow.h | 44 +++++++++++++++++++++++++++++++ - 6 files changed, 48 insertions(+), 31 deletions(-) - create mode 100644 drivers/net/hns3/hns3_flow.h - -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 818835391..5a826c7aa 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -15,6 +15,7 @@ - #include "hns3_regs.h" - #include "hns3_dcb.h" - #include "hns3_mp.h" -+#include "hns3_flow.h" - - #define HNS3_SERVICE_INTERVAL 1000000 /* us */ - #define HNS3_SERVICE_QUICK_INTERVAL 10 -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 96671159b..960f781e1 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -17,6 +17,7 @@ - #include "hns3_fdir.h" - #include "hns3_stats.h" - #include "hns3_tm.h" -+#include "hns3_flow.h" - - /* Vendor ID */ - #define PCI_VENDOR_ID_HUAWEI 0x19e5 -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index c234e74b8..84ae26987 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -17,6 +17,7 @@ - #include "hns3_intr.h" - #include "hns3_dcb.h" - #include "hns3_mp.h" -+#include "hns3_flow.h" - - #define HNS3VF_KEEP_ALIVE_INTERVAL 2000000 /* us */ - #define HNS3VF_SERVICE_INTERVAL 1000000 /* us */ -diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h -index 3f610f7b1..f9efff3b5 100644 ---- a/drivers/net/hns3/hns3_fdir.h -+++ b/drivers/net/hns3/hns3_fdir.h -@@ -5,8 +5,6 @@ - #ifndef _HNS3_FDIR_H_ - #define _HNS3_FDIR_H_ - --#include -- - struct hns3_fd_key_cfg { - uint8_t key_sel; - uint8_t inner_sipv6_word_en; -@@ -124,14 +122,6 @@ struct hns3_fd_ad_data { - uint16_t rule_id; - }; - --struct hns3_flow_counter { -- LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ -- uint32_t shared:1; /* Share counter ID with other flow rules. */ -- uint32_t ref_cnt:31; /* Reference counter. */ -- uint16_t id; /* Counter ID. */ -- uint64_t hits; /* Number of packets matched by the rule. */ --}; -- - #define HNS3_RULE_FLAG_FDID 0x1 - #define HNS3_RULE_FLAG_VF_ID 0x2 - #define HNS3_RULE_FLAG_COUNTER 0x4 -@@ -173,21 +163,7 @@ struct hns3_fdir_rule_ele { - struct hns3_fdir_rule fdir_conf; - }; - --/* rss filter list structure */ --struct hns3_rss_conf_ele { -- TAILQ_ENTRY(hns3_rss_conf_ele) entries; -- struct hns3_rss_conf filter_info; --}; -- --/* hns3_flow memory list structure */ --struct hns3_flow_mem { -- TAILQ_ENTRY(hns3_flow_mem) entries; -- struct rte_flow *flow; --}; -- - TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele); --TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); --TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); - - /* - * A structure used to define fields of a FDIR related info. -@@ -199,11 +175,6 @@ struct hns3_fdir_info { - struct hns3_fd_cfg fd_cfg; - }; - --struct rte_flow { -- enum rte_filter_type filter_type; -- void *rule; -- uint32_t counter_id; --}; - struct hns3_adapter; - - int hns3_init_fd_config(struct hns3_adapter *hns); -@@ -213,8 +184,6 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, - struct hns3_fdir_rule *rule, bool del); - int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); - int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); --void hns3_flow_init(struct rte_eth_dev *dev); --void hns3_flow_uninit(struct rte_eth_dev *dev); - int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); - - #endif /* _HNS3_FDIR_H_ */ -diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c -index b25fccbca..73ef91ce9 100644 ---- a/drivers/net/hns3/hns3_flow.c -+++ b/drivers/net/hns3/hns3_flow.c -@@ -8,6 +8,7 @@ - - #include "hns3_ethdev.h" - #include "hns3_logs.h" -+#include "hns3_flow.h" - - /* Default default keys */ - static uint8_t hns3_hash_key[] = { -diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h -new file mode 100644 -index 000000000..2eb451b72 ---- /dev/null -+++ b/drivers/net/hns3/hns3_flow.h -@@ -0,0 +1,44 @@ -+/* SPDX-License-Identifier: BSD-3-Clause -+ * Copyright(C) 2021 HiSilicon Limited -+ */ -+ -+#ifndef _HNS3_FLOW_H_ -+#define _HNS3_FLOW_H_ -+ -+#include -+ -+struct hns3_flow_counter { -+ LIST_ENTRY(hns3_flow_counter) next; /* Pointer to the next counter. */ -+ uint32_t shared:1; /* Share counter ID with other flow rules. */ -+ uint32_t ref_cnt:31; /* Reference counter. */ -+ uint16_t id; /* Counter ID. */ -+ uint64_t hits; /* Number of packets matched by the rule. */ -+}; -+ -+struct rte_flow { -+ enum rte_filter_type filter_type; -+ void *rule; -+ uint32_t counter_id; -+}; -+ -+/* rss filter list structure */ -+struct hns3_rss_conf_ele { -+ TAILQ_ENTRY(hns3_rss_conf_ele) entries; -+ struct hns3_rss_conf filter_info; -+}; -+ -+/* hns3_flow memory list structure */ -+struct hns3_flow_mem { -+ TAILQ_ENTRY(hns3_flow_mem) entries; -+ struct rte_flow *flow; -+}; -+ -+TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); -+TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); -+ -+int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, -+ const struct rte_flow_ops **ops); -+void hns3_flow_init(struct rte_eth_dev *dev); -+void hns3_flow_uninit(struct rte_eth_dev *dev); -+ -+#endif /* _HNS3_FLOW_H_ */ --- -2.33.0 - diff --git a/0263-net-hns3-remove-magic-numbers.patch b/0263-net-hns3-remove-magic-numbers.patch deleted file mode 100644 index 7e5bb3f..0000000 --- a/0263-net-hns3-remove-magic-numbers.patch +++ /dev/null @@ -1,53 +0,0 @@ -From b96b2ca6d5b510d372137ef4b3ef66b762434c92 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:43:04 +0800 -Subject: [PATCH 30/33] net/hns3: remove magic numbers - -Removing magic numbers with macros. - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_common.c | 4 ++-- - drivers/net/hns3/hns3_common.h | 3 +++ - 2 files changed, 5 insertions(+), 2 deletions(-) - -diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c -index 85316d342..c306e0b0e 100644 ---- a/drivers/net/hns3/hns3_common.c -+++ b/drivers/net/hns3/hns3_common.c -@@ -54,7 +54,7 @@ hns3_parse_dev_caps_mask(const char *key, const char *value, void *extra_args) - - RTE_SET_USED(key); - -- val = strtoull(value, NULL, 16); -+ val = strtoull(value, NULL, HNS3_CONVERT_TO_HEXADECIMAL); - *(uint64_t *)extra_args = val; - - return 0; -@@ -67,7 +67,7 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) - - RTE_SET_USED(key); - -- val = strtoul(value, NULL, 10); -+ val = strtoul(value, NULL, HNS3_CONVERT_TO_DECIMAL); - if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) - *(uint16_t *)extra_args = val; - -diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h -index 094a0bc5f..68f9b1b96 100644 ---- a/drivers/net/hns3/hns3_common.h -+++ b/drivers/net/hns3/hns3_common.h -@@ -9,6 +9,9 @@ - - #include "hns3_ethdev.h" - -+#define HNS3_CONVERT_TO_DECIMAL 10 -+#define HNS3_CONVERT_TO_HEXADECIMAL 16 -+ - enum { - HNS3_IO_FUNC_HINT_NONE = 0, - HNS3_IO_FUNC_HINT_VEC, --- -2.33.0 - diff --git a/0264-net-hns3-mark-unchecked-return-of-snprintf.patch b/0264-net-hns3-mark-unchecked-return-of-snprintf.patch deleted file mode 100644 index 2734b5f..0000000 --- a/0264-net-hns3-mark-unchecked-return-of-snprintf.patch +++ /dev/null @@ -1,38 +0,0 @@ -From dee0abb3ec0a868c1f213165bd88c7a26c4ee253 Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Sat, 6 Nov 2021 09:43:05 +0800 -Subject: [PATCH 31/33] net/hns3: mark unchecked return of snprintf - -Fixing the return value of the function to clear static warning. - -Fixes: 1181500b2fc5 ("net/hns3: adjust MAC address logging") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_common.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c -index c306e0b0e..9a47fbfbd 100644 ---- a/drivers/net/hns3/hns3_common.c -+++ b/drivers/net/hns3/hns3_common.c -@@ -154,10 +154,10 @@ hns3_clock_gettime_ms(void) - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr) - { -- snprintf(buf, size, "%02X:**:**:**:%02X:%02X", -- ether_addr->addr_bytes[0], -- ether_addr->addr_bytes[4], -- ether_addr->addr_bytes[5]); -+ (void)snprintf(buf, size, "%02X:**:**:**:%02X:%02X", -+ ether_addr->addr_bytes[0], -+ ether_addr->addr_bytes[4], -+ ether_addr->addr_bytes[5]); - } - - static int --- -2.33.0 - diff --git a/0265-net-hns3-remove-PF-VF-duplicate-code.patch b/0265-net-hns3-remove-PF-VF-duplicate-code.patch deleted file mode 100644 index a350f76..0000000 --- a/0265-net-hns3-remove-PF-VF-duplicate-code.patch +++ /dev/null @@ -1,1256 +0,0 @@ -From aa098540a3a8b20e94c4c8b71256663d2e85dd27 Mon Sep 17 00:00:00 2001 -From: Chengwen Feng -Date: Sat, 6 Nov 2021 09:43:06 +0800 -Subject: [PATCH 32/33] net/hns3: remove PF/VF duplicate code - -This patch remove PF/VF duplicate code of: -1. get firmware version. -2. get device info. -3. rx interrupt related functions. - -Signed-off-by: Chengwen Feng -Signed-off-by: Min Hu (Connor) ---- - drivers/net/hns3/hns3_common.c | 339 +++++++++++++++++++++++++++++- - drivers/net/hns3/hns3_common.h | 10 + - drivers/net/hns3/hns3_ethdev.c | 314 +-------------------------- - drivers/net/hns3/hns3_ethdev.h | 15 +- - drivers/net/hns3/hns3_ethdev_vf.c | 323 +--------------------------- - drivers/net/hns3/hns3_tm.c | 2 +- - 6 files changed, 364 insertions(+), 639 deletions(-) - -diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c -index 9a47fbfbd..eac2aa104 100644 ---- a/drivers/net/hns3/hns3_common.c -+++ b/drivers/net/hns3/hns3_common.c -@@ -3,9 +3,154 @@ - */ - - #include -+#include -+#include -+#include - --#include "hns3_logs.h" - #include "hns3_common.h" -+#include "hns3_logs.h" -+#include "hns3_regs.h" -+#include "hns3_rxtx.h" -+ -+int -+hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, -+ size_t fw_size) -+{ -+ struct hns3_adapter *hns = eth_dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ uint32_t version = hw->fw_version; -+ int ret; -+ -+ ret = snprintf(fw_version, fw_size, "%lu.%lu.%lu.%lu", -+ hns3_get_field(version, HNS3_FW_VERSION_BYTE3_M, -+ HNS3_FW_VERSION_BYTE3_S), -+ hns3_get_field(version, HNS3_FW_VERSION_BYTE2_M, -+ HNS3_FW_VERSION_BYTE2_S), -+ hns3_get_field(version, HNS3_FW_VERSION_BYTE1_M, -+ HNS3_FW_VERSION_BYTE1_S), -+ hns3_get_field(version, HNS3_FW_VERSION_BYTE0_M, -+ HNS3_FW_VERSION_BYTE0_S)); -+ if (ret < 0) -+ return -EINVAL; -+ -+ ret += 1; /* add the size of '\0' */ -+ if (fw_size < (size_t)ret) -+ return ret; -+ else -+ return 0; -+} -+ -+int -+hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) -+{ -+ struct hns3_adapter *hns = eth_dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ uint16_t queue_num = hw->tqps_num; -+ -+ /* -+ * In interrupt mode, 'max_rx_queues' is set based on the number of -+ * MSI-X interrupt resources of the hardware. -+ */ -+ if (hw->data->dev_conf.intr_conf.rxq == 1) -+ queue_num = hw->intr_tqps_num; -+ -+ info->max_rx_queues = queue_num; -+ info->max_tx_queues = hw->tqps_num; -+ info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */ -+ info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; -+ info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; -+ info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; -+ info->rx_offload_capa = (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | -+ RTE_ETH_RX_OFFLOAD_TCP_CKSUM | -+ RTE_ETH_RX_OFFLOAD_UDP_CKSUM | -+ RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | -+ RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -+ RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM | -+ RTE_ETH_RX_OFFLOAD_SCATTER | -+ RTE_ETH_RX_OFFLOAD_VLAN_STRIP | -+ RTE_ETH_RX_OFFLOAD_VLAN_FILTER | -+ RTE_ETH_RX_OFFLOAD_RSS_HASH | -+ RTE_ETH_RX_OFFLOAD_TCP_LRO); -+ info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | -+ RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | -+ RTE_ETH_TX_OFFLOAD_TCP_CKSUM | -+ RTE_ETH_TX_OFFLOAD_UDP_CKSUM | -+ RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | -+ RTE_ETH_TX_OFFLOAD_MULTI_SEGS | -+ RTE_ETH_TX_OFFLOAD_TCP_TSO | -+ RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | -+ RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | -+ RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | -+ RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | -+ RTE_ETH_TX_OFFLOAD_VLAN_INSERT); -+ -+ if (!hw->port_base_vlan_cfg.state) -+ info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_QINQ_INSERT; -+ -+ if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) -+ info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM; -+ -+ if (hns3_dev_get_support(hw, INDEP_TXRX)) -+ info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | -+ RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; -+ info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP; -+ -+ if (hns3_dev_get_support(hw, PTP)) -+ info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP; -+ -+ info->rx_desc_lim = (struct rte_eth_desc_lim) { -+ .nb_max = HNS3_MAX_RING_DESC, -+ .nb_min = HNS3_MIN_RING_DESC, -+ .nb_align = HNS3_ALIGN_RING_DESC, -+ }; -+ -+ info->tx_desc_lim = (struct rte_eth_desc_lim) { -+ .nb_max = HNS3_MAX_RING_DESC, -+ .nb_min = HNS3_MIN_RING_DESC, -+ .nb_align = HNS3_ALIGN_RING_DESC, -+ .nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT, -+ .nb_mtu_seg_max = hw->max_non_tso_bd_num, -+ }; -+ -+ info->default_rxconf = (struct rte_eth_rxconf) { -+ .rx_free_thresh = HNS3_DEFAULT_RX_FREE_THRESH, -+ /* -+ * If there are no available Rx buffer descriptors, incoming -+ * packets are always dropped by hardware based on hns3 network -+ * engine. -+ */ -+ .rx_drop_en = 1, -+ .offloads = 0, -+ }; -+ info->default_txconf = (struct rte_eth_txconf) { -+ .tx_rs_thresh = HNS3_DEFAULT_TX_RS_THRESH, -+ .offloads = 0, -+ }; -+ -+ info->reta_size = hw->rss_ind_tbl_size; -+ info->hash_key_size = HNS3_RSS_KEY_SIZE; -+ info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; -+ -+ info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -+ info->default_txportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -+ info->default_rxportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -+ info->default_txportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -+ info->default_rxportconf.ring_size = HNS3_DEFAULT_RING_DESC; -+ info->default_txportconf.ring_size = HNS3_DEFAULT_RING_DESC; -+ -+ /* -+ * Next is the PF/VF difference section. -+ */ -+ if (!hns->is_vf) { -+ info->max_mac_addrs = HNS3_UC_MACADDR_NUM; -+ info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_KEEP_CRC; -+ info->speed_capa = hns3_get_speed_capa(hw); -+ } else { -+ info->max_mac_addrs = HNS3_VF_UC_MACADDR_NUM; -+ } -+ -+ return 0; -+} - - static int - hns3_parse_io_hint_func(const char *key, const char *value, void *extra_args) -@@ -68,6 +213,12 @@ hns3_parse_mbx_time_limit(const char *key, const char *value, void *extra_args) - RTE_SET_USED(key); - - val = strtoul(value, NULL, HNS3_CONVERT_TO_DECIMAL); -+ -+ /* -+ * 500ms is empirical value in process of mailbox communication. If -+ * the delay value is set to one lower thanthe empirical value, mailbox -+ * communication may fail. -+ */ - if (val > HNS3_MBX_DEF_TIME_LIMIT_MS && val <= UINT16_MAX) - *(uint16_t *)extra_args = val; - -@@ -116,6 +267,11 @@ hns3_parse_devargs(struct rte_eth_dev *dev) - hns3_warn(hw, "parsed %s = 0x%" PRIx64 ".", - HNS3_DEVARG_DEV_CAPS_MASK, dev_caps_mask); - hns->dev_caps_mask = dev_caps_mask; -+ -+ if (mbx_time_limit_ms != HNS3_MBX_DEF_TIME_LIMIT_MS) -+ hns3_warn(hw, "parsed %s = %u.", HNS3_DEVARG_MBX_TIME_LIMIT_MS, -+ mbx_time_limit_ms); -+ hns->mbx_time_limit_ms = mbx_time_limit_ms; - } - - void -@@ -424,3 +580,184 @@ hns3_remove_mac_addr(struct rte_eth_dev *dev, uint32_t idx) - ret); - } - } -+ -+int -+hns3_init_ring_with_vector(struct hns3_hw *hw) -+{ -+ uint16_t vec; -+ int ret; -+ int i; -+ -+ /* -+ * In hns3 network engine, vector 0 is always the misc interrupt of this -+ * function, vector 1~N can be used respectively for the queues of the -+ * function. Tx and Rx queues with the same number share the interrupt -+ * vector. In the initialization clearing the all hardware mapping -+ * relationship configurations between queues and interrupt vectors is -+ * needed, so some error caused by the residual configurations, such as -+ * the unexpected Tx interrupt, can be avoid. -+ */ -+ vec = hw->num_msi - 1; /* vector 0 for misc interrupt, not for queue */ -+ if (hw->intr.mapping_mode == HNS3_INTR_MAPPING_VEC_RSV_ONE) -+ vec = vec - 1; /* the last interrupt is reserved */ -+ hw->intr_tqps_num = RTE_MIN(vec, hw->tqps_num); -+ for (i = 0; i < hw->intr_tqps_num; i++) { -+ /* -+ * Set gap limiter/rate limiter/quanity limiter algorithm -+ * configuration for interrupt coalesce of queue's interrupt. -+ */ -+ hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_RX, -+ HNS3_TQP_INTR_GL_DEFAULT); -+ hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_TX, -+ HNS3_TQP_INTR_GL_DEFAULT); -+ hns3_set_queue_intr_rl(hw, i, HNS3_TQP_INTR_RL_DEFAULT); -+ /* -+ * QL(quantity limiter) is not used currently, just set 0 to -+ * close it. -+ */ -+ hns3_set_queue_intr_ql(hw, i, HNS3_TQP_INTR_QL_DEFAULT); -+ -+ ret = hw->ops.bind_ring_with_vector(hw, vec, false, -+ HNS3_RING_TYPE_TX, i); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "fail to unbind TX ring(%d) with " -+ "vector: %u, ret=%d", i, vec, ret); -+ return ret; -+ } -+ -+ ret = hw->ops.bind_ring_with_vector(hw, vec, false, -+ HNS3_RING_TYPE_RX, i); -+ if (ret) { -+ PMD_INIT_LOG(ERR, "fail to unbind RX ring(%d) with " -+ "vector: %u, ret=%d", i, vec, ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+int -+hns3_map_rx_interrupt(struct rte_eth_dev *dev) -+{ -+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -+ struct rte_intr_handle *intr_handle = pci_dev->intr_handle; -+ struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -+ uint16_t base = RTE_INTR_VEC_ZERO_OFFSET; -+ uint16_t vec = RTE_INTR_VEC_ZERO_OFFSET; -+ uint32_t intr_vector; -+ uint16_t q_id; -+ int ret; -+ -+ /* -+ * hns3 needs a separate interrupt to be used as event interrupt which -+ * could not be shared with task queue pair, so KERNEL drivers need -+ * support multiple interrupt vectors. -+ */ -+ if (dev->data->dev_conf.intr_conf.rxq == 0 || -+ !rte_intr_cap_multiple(intr_handle)) -+ return 0; -+ -+ rte_intr_disable(intr_handle); -+ intr_vector = hw->used_rx_queues; -+ /* creates event fd for each intr vector when MSIX is used */ -+ if (rte_intr_efd_enable(intr_handle, intr_vector)) -+ return -EINVAL; -+ -+ /* Allocate vector list */ -+ if (rte_intr_vec_list_alloc(intr_handle, "intr_vec", -+ hw->used_rx_queues)) { -+ hns3_err(hw, "failed to allocate %u rx_queues intr_vec", -+ hw->used_rx_queues); -+ ret = -ENOMEM; -+ goto alloc_intr_vec_error; -+ } -+ -+ if (rte_intr_allow_others(intr_handle)) { -+ vec = RTE_INTR_VEC_RXTX_OFFSET; -+ base = RTE_INTR_VEC_RXTX_OFFSET; -+ } -+ -+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -+ ret = hw->ops.bind_ring_with_vector(hw, vec, true, -+ HNS3_RING_TYPE_RX, q_id); -+ if (ret) -+ goto bind_vector_error; -+ -+ if (rte_intr_vec_list_index_set(intr_handle, q_id, vec)) -+ goto bind_vector_error; -+ /* -+ * If there are not enough efds (e.g. not enough interrupt), -+ * remaining queues will be bond to the last interrupt. -+ */ -+ if (vec < base + rte_intr_nb_efd_get(intr_handle) - 1) -+ vec++; -+ } -+ rte_intr_enable(intr_handle); -+ return 0; -+ -+bind_vector_error: -+ rte_intr_vec_list_free(intr_handle); -+alloc_intr_vec_error: -+ rte_intr_efd_disable(intr_handle); -+ return ret; -+} -+ -+void -+hns3_unmap_rx_interrupt(struct rte_eth_dev *dev) -+{ -+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -+ struct rte_intr_handle *intr_handle = pci_dev->intr_handle; -+ struct hns3_adapter *hns = dev->data->dev_private; -+ struct hns3_hw *hw = &hns->hw; -+ uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; -+ uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET; -+ uint16_t q_id; -+ -+ if (dev->data->dev_conf.intr_conf.rxq == 0) -+ return; -+ -+ /* unmap the ring with vector */ -+ if (rte_intr_allow_others(intr_handle)) { -+ vec = RTE_INTR_VEC_RXTX_OFFSET; -+ base = RTE_INTR_VEC_RXTX_OFFSET; -+ } -+ if (rte_intr_dp_is_en(intr_handle)) { -+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -+ (void)hw->ops.bind_ring_with_vector(hw, vec, false, -+ HNS3_RING_TYPE_RX, -+ q_id); -+ if (vec < base + rte_intr_nb_efd_get(intr_handle) - 1) -+ vec++; -+ } -+ } -+ /* Clean datapath event and queue/vec mapping */ -+ rte_intr_efd_disable(intr_handle); -+ rte_intr_vec_list_free(intr_handle); -+} -+ -+int -+hns3_restore_rx_interrupt(struct hns3_hw *hw) -+{ -+ struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -+ struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -+ struct rte_intr_handle *intr_handle = pci_dev->intr_handle; -+ uint16_t q_id; -+ int ret; -+ -+ if (dev->data->dev_conf.intr_conf.rxq == 0) -+ return 0; -+ -+ if (rte_intr_dp_is_en(intr_handle)) { -+ for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -+ ret = hw->ops.bind_ring_with_vector(hw, -+ rte_intr_vec_list_index_get(intr_handle, -+ q_id), -+ true, HNS3_RING_TYPE_RX, q_id); -+ if (ret) -+ return ret; -+ } -+ } -+ -+ return 0; -+} -diff --git a/drivers/net/hns3/hns3_common.h b/drivers/net/hns3/hns3_common.h -index 68f9b1b96..0dbb1c041 100644 ---- a/drivers/net/hns3/hns3_common.h -+++ b/drivers/net/hns3/hns3_common.h -@@ -30,6 +30,11 @@ enum { - #define MSEC_PER_SEC 1000L - #define USEC_PER_MSEC 1000L - -+int hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, -+ size_t fw_size); -+int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, -+ struct rte_eth_dev_info *info); -+ - void hns3_clock_gettime(struct timeval *tv); - uint64_t hns3_clock_calctime_ms(struct timeval *tv); - uint64_t hns3_clock_gettime_ms(void); -@@ -48,4 +53,9 @@ int hns3_set_mc_mac_addr_list(struct rte_eth_dev *dev, - void hns3_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *ether_addr); - -+int hns3_init_ring_with_vector(struct hns3_hw *hw); -+int hns3_map_rx_interrupt(struct rte_eth_dev *dev); -+void hns3_unmap_rx_interrupt(struct rte_eth_dev *dev); -+int hns3_restore_rx_interrupt(struct hns3_hw *hw); -+ - #endif /* _HNS3_COMMON_H_ */ -diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c -index 5a826c7aa..77efb3146 100644 ---- a/drivers/net/hns3/hns3_ethdev.c -+++ b/drivers/net/hns3/hns3_ethdev.c -@@ -1929,62 +1929,6 @@ hns3_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, bool en, - return 0; - } - --static int --hns3_init_ring_with_vector(struct hns3_hw *hw) --{ -- uint16_t vec; -- int ret; -- int i; -- -- /* -- * In hns3 network engine, vector 0 is always the misc interrupt of this -- * function, vector 1~N can be used respectively for the queues of the -- * function. Tx and Rx queues with the same number share the interrupt -- * vector. In the initialization clearing the all hardware mapping -- * relationship configurations between queues and interrupt vectors is -- * needed, so some error caused by the residual configurations, such as -- * the unexpected Tx interrupt, can be avoid. -- */ -- vec = hw->num_msi - 1; /* vector 0 for misc interrupt, not for queue */ -- if (hw->intr.mapping_mode == HNS3_INTR_MAPPING_VEC_RSV_ONE) -- vec = vec - 1; /* the last interrupt is reserved */ -- hw->intr_tqps_num = RTE_MIN(vec, hw->tqps_num); -- for (i = 0; i < hw->intr_tqps_num; i++) { -- /* -- * Set gap limiter/rate limiter/quanity limiter algorithm -- * configuration for interrupt coalesce of queue's interrupt. -- */ -- hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_RX, -- HNS3_TQP_INTR_GL_DEFAULT); -- hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_TX, -- HNS3_TQP_INTR_GL_DEFAULT); -- hns3_set_queue_intr_rl(hw, i, HNS3_TQP_INTR_RL_DEFAULT); -- /* -- * QL(quantity limiter) is not used currently, just set 0 to -- * close it. -- */ -- hns3_set_queue_intr_ql(hw, i, HNS3_TQP_INTR_QL_DEFAULT); -- -- ret = hns3_bind_ring_with_vector(hw, vec, false, -- HNS3_RING_TYPE_TX, i); -- if (ret) { -- PMD_INIT_LOG(ERR, "PF fail to unbind TX ring(%d) with " -- "vector: %u, ret=%d", i, vec, ret); -- return ret; -- } -- -- ret = hns3_bind_ring_with_vector(hw, vec, false, -- HNS3_RING_TYPE_RX, i); -- if (ret) { -- PMD_INIT_LOG(ERR, "PF fail to unbind RX ring(%d) with " -- "vector: %u, ret=%d", i, vec, ret); -- return ret; -- } -- } -- -- return 0; --} -- - static int - hns3_refresh_mtu(struct rte_eth_dev *dev, struct rte_eth_conf *conf) - { -@@ -2299,7 +2243,7 @@ hns3_get_firber_port_speed_capa(uint32_t supported_speed) - return speed_capa; - } - --static uint32_t -+uint32_t - hns3_get_speed_capa(struct hns3_hw *hw) - { - struct hns3_mac *mac = &hw->mac; -@@ -2318,132 +2262,6 @@ hns3_get_speed_capa(struct hns3_hw *hw) - return speed_capa; - } - --int --hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) --{ -- struct hns3_adapter *hns = eth_dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- uint16_t queue_num = hw->tqps_num; -- -- /* -- * In interrupt mode, 'max_rx_queues' is set based on the number of -- * MSI-X interrupt resources of the hardware. -- */ -- if (hw->data->dev_conf.intr_conf.rxq == 1) -- queue_num = hw->intr_tqps_num; -- -- info->max_rx_queues = queue_num; -- info->max_tx_queues = hw->tqps_num; -- info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */ -- info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; -- info->max_mac_addrs = HNS3_UC_MACADDR_NUM; -- info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; -- info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; -- info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | -- DEV_RX_OFFLOAD_TCP_CKSUM | -- DEV_RX_OFFLOAD_UDP_CKSUM | -- DEV_RX_OFFLOAD_SCTP_CKSUM | -- DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | -- DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | -- DEV_RX_OFFLOAD_KEEP_CRC | -- DEV_RX_OFFLOAD_SCATTER | -- DEV_RX_OFFLOAD_VLAN_STRIP | -- DEV_RX_OFFLOAD_VLAN_FILTER | -- DEV_RX_OFFLOAD_JUMBO_FRAME | -- DEV_RX_OFFLOAD_RSS_HASH | -- DEV_RX_OFFLOAD_TCP_LRO); -- info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | -- DEV_TX_OFFLOAD_IPV4_CKSUM | -- DEV_TX_OFFLOAD_TCP_CKSUM | -- DEV_TX_OFFLOAD_UDP_CKSUM | -- DEV_TX_OFFLOAD_SCTP_CKSUM | -- DEV_TX_OFFLOAD_MULTI_SEGS | -- DEV_TX_OFFLOAD_TCP_TSO | -- DEV_TX_OFFLOAD_VXLAN_TNL_TSO | -- DEV_TX_OFFLOAD_GRE_TNL_TSO | -- DEV_TX_OFFLOAD_GENEVE_TNL_TSO | -- DEV_TX_OFFLOAD_MBUF_FAST_FREE | -- hns3_txvlan_cap_get(hw)); -- -- if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) -- info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; -- -- if (hns3_dev_get_support(hw, INDEP_TXRX)) -- info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | -- RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; -- -- if (hns3_dev_get_support(hw, PTP)) -- info->rx_offload_capa |= DEV_RX_OFFLOAD_TIMESTAMP; -- -- info->rx_desc_lim = (struct rte_eth_desc_lim) { -- .nb_max = HNS3_MAX_RING_DESC, -- .nb_min = HNS3_MIN_RING_DESC, -- .nb_align = HNS3_ALIGN_RING_DESC, -- }; -- -- info->tx_desc_lim = (struct rte_eth_desc_lim) { -- .nb_max = HNS3_MAX_RING_DESC, -- .nb_min = HNS3_MIN_RING_DESC, -- .nb_align = HNS3_ALIGN_RING_DESC, -- .nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT, -- .nb_mtu_seg_max = hw->max_non_tso_bd_num, -- }; -- -- info->speed_capa = hns3_get_speed_capa(hw); -- info->default_rxconf = (struct rte_eth_rxconf) { -- .rx_free_thresh = HNS3_DEFAULT_RX_FREE_THRESH, -- /* -- * If there are no available Rx buffer descriptors, incoming -- * packets are always dropped by hardware based on hns3 network -- * engine. -- */ -- .rx_drop_en = 1, -- .offloads = 0, -- }; -- info->default_txconf = (struct rte_eth_txconf) { -- .tx_rs_thresh = HNS3_DEFAULT_TX_RS_THRESH, -- .offloads = 0, -- }; -- -- info->reta_size = hw->rss_ind_tbl_size; -- info->hash_key_size = HNS3_RSS_KEY_SIZE; -- info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; -- -- info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -- info->default_txportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -- info->default_rxportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -- info->default_txportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -- info->default_rxportconf.ring_size = HNS3_DEFAULT_RING_DESC; -- info->default_txportconf.ring_size = HNS3_DEFAULT_RING_DESC; -- -- return 0; --} -- --static int --hns3_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, -- size_t fw_size) --{ -- struct hns3_adapter *hns = eth_dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- uint32_t version = hw->fw_version; -- int ret; -- -- ret = snprintf(fw_version, fw_size, "%lu.%lu.%lu.%lu", -- hns3_get_field(version, HNS3_FW_VERSION_BYTE3_M, -- HNS3_FW_VERSION_BYTE3_S), -- hns3_get_field(version, HNS3_FW_VERSION_BYTE2_M, -- HNS3_FW_VERSION_BYTE2_S), -- hns3_get_field(version, HNS3_FW_VERSION_BYTE1_M, -- HNS3_FW_VERSION_BYTE1_S), -- hns3_get_field(version, HNS3_FW_VERSION_BYTE0_M, -- HNS3_FW_VERSION_BYTE0_S)); -- ret += 1; /* add the size of '\0' */ -- if (fw_size < (uint32_t)ret) -- return ret; -- else -- return 0; --} -- - static int - hns3_update_port_link_info(struct rte_eth_dev *eth_dev) - { -@@ -5322,99 +5140,6 @@ hns3_do_start(struct hns3_adapter *hns, bool reset_queue) - return ret; - } - --static int --hns3_map_rx_interrupt(struct rte_eth_dev *dev) --{ -- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- uint16_t base = RTE_INTR_VEC_ZERO_OFFSET; -- uint16_t vec = RTE_INTR_VEC_ZERO_OFFSET; -- uint32_t intr_vector; -- uint16_t q_id; -- int ret; -- -- /* -- * hns3 needs a separate interrupt to be used as event interrupt which -- * could not be shared with task queue pair, so KERNEL drivers need -- * support multiple interrupt vectors. -- */ -- if (dev->data->dev_conf.intr_conf.rxq == 0 || -- !rte_intr_cap_multiple(intr_handle)) -- return 0; -- -- rte_intr_disable(intr_handle); -- intr_vector = hw->used_rx_queues; -- /* creates event fd for each intr vector when MSIX is used */ -- if (rte_intr_efd_enable(intr_handle, intr_vector)) -- return -EINVAL; -- -- if (intr_handle->intr_vec == NULL) { -- intr_handle->intr_vec = -- rte_zmalloc("intr_vec", -- hw->used_rx_queues * sizeof(int), 0); -- if (intr_handle->intr_vec == NULL) { -- hns3_err(hw, "failed to allocate %u rx_queues intr_vec", -- hw->used_rx_queues); -- ret = -ENOMEM; -- goto alloc_intr_vec_error; -- } -- } -- -- if (rte_intr_allow_others(intr_handle)) { -- vec = RTE_INTR_VEC_RXTX_OFFSET; -- base = RTE_INTR_VEC_RXTX_OFFSET; -- } -- -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- ret = hns3_bind_ring_with_vector(hw, vec, true, -- HNS3_RING_TYPE_RX, q_id); -- if (ret) -- goto bind_vector_error; -- intr_handle->intr_vec[q_id] = vec; -- /* -- * If there are not enough efds (e.g. not enough interrupt), -- * remaining queues will be bond to the last interrupt. -- */ -- if (vec < base + intr_handle->nb_efd - 1) -- vec++; -- } -- rte_intr_enable(intr_handle); -- return 0; -- --bind_vector_error: -- rte_free(intr_handle->intr_vec); -- intr_handle->intr_vec = NULL; --alloc_intr_vec_error: -- rte_intr_efd_disable(intr_handle); -- return ret; --} -- --static int --hns3_restore_rx_interrupt(struct hns3_hw *hw) --{ -- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; -- uint16_t q_id; -- int ret; -- -- if (dev->data->dev_conf.intr_conf.rxq == 0) -- return 0; -- -- if (rte_intr_dp_is_en(intr_handle)) { -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- ret = hns3_bind_ring_with_vector(hw, -- intr_handle->intr_vec[q_id], true, -- HNS3_RING_TYPE_RX, q_id); -- if (ret) -- return ret; -- } -- } -- -- return 0; --} -- - static void - hns3_restore_filter(struct rte_eth_dev *dev) - { -@@ -5545,42 +5270,6 @@ hns3_do_stop(struct hns3_adapter *hns) - return 0; - } - --static void --hns3_unmap_rx_interrupt(struct rte_eth_dev *dev) --{ -- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; -- struct hns3_adapter *hns = dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; -- uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET; -- uint16_t q_id; -- -- if (dev->data->dev_conf.intr_conf.rxq == 0) -- return; -- -- /* unmap the ring with vector */ -- if (rte_intr_allow_others(intr_handle)) { -- vec = RTE_INTR_VEC_RXTX_OFFSET; -- base = RTE_INTR_VEC_RXTX_OFFSET; -- } -- if (rte_intr_dp_is_en(intr_handle)) { -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- (void)hns3_bind_ring_with_vector(hw, vec, false, -- HNS3_RING_TYPE_RX, -- q_id); -- if (vec < base + intr_handle->nb_efd - 1) -- vec++; -- } -- } -- /* Clean datapath event and queue/vec mapping */ -- rte_intr_efd_disable(intr_handle); -- if (intr_handle->intr_vec) { -- rte_free(intr_handle->intr_vec); -- intr_handle->intr_vec = NULL; -- } --} -- - static int - hns3_dev_stop(struct rte_eth_dev *dev) - { -@@ -6971,6 +6660,7 @@ hns3_init_hw_ops(struct hns3_hw *hw) - hw->ops.del_mc_mac_addr = hns3_remove_mc_mac_addr; - hw->ops.add_uc_mac_addr = hns3_add_uc_mac_addr; - hw->ops.del_uc_mac_addr = hns3_remove_uc_mac_addr; -+ hw->ops.bind_ring_with_vector = hns3_bind_ring_with_vector; - } - - static int -diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h -index 960f781e1..09287c3c1 100644 ---- a/drivers/net/hns3/hns3_ethdev.h -+++ b/drivers/net/hns3/hns3_ethdev.h -@@ -437,6 +437,9 @@ struct hns3_hw_ops { - struct rte_ether_addr *mac_addr); - int (*del_uc_mac_addr)(struct hns3_hw *hw, - struct rte_ether_addr *mac_addr); -+ int (*bind_ring_with_vector)(struct hns3_hw *hw, uint16_t vector_id, -+ bool en, enum hns3_ring_type queue_type, -+ uint16_t queue_id); - }; - - #define HNS3_INTR_MAPPING_VEC_RSV_ONE 0 -@@ -1032,6 +1035,7 @@ hns3_test_and_clear_bit(unsigned int nr, volatile uint64_t *addr) - return __atomic_fetch_and(addr, ~mask, __ATOMIC_RELAXED) & mask; - } - -+uint32_t hns3_get_speed_capa(struct hns3_hw *hw); - int hns3_buffer_alloc(struct hns3_hw *hw); - int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, - enum rte_filter_type filter_type, -@@ -1039,8 +1043,6 @@ int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, - bool hns3_is_reset_pending(struct hns3_adapter *hns); - bool hns3vf_is_reset_pending(struct hns3_adapter *hns); - void hns3_update_linkstatus_and_event(struct hns3_hw *hw, bool query); --int hns3_dev_infos_get(struct rte_eth_dev *eth_dev, -- struct rte_eth_dev_info *info); - void hns3vf_update_link_status(struct hns3_hw *hw, uint8_t link_status, - uint32_t link_speed, uint8_t link_duplex); - void hns3vf_update_push_lsc_cap(struct hns3_hw *hw, bool supported); -@@ -1072,13 +1074,4 @@ is_reset_pending(struct hns3_adapter *hns) - return ret; - } - --static inline uint64_t --hns3_txvlan_cap_get(struct hns3_hw *hw) --{ -- if (hw->port_base_vlan_cfg.state) -- return DEV_TX_OFFLOAD_VLAN_INSERT; -- else -- return DEV_TX_OFFLOAD_VLAN_INSERT | DEV_TX_OFFLOAD_QINQ_INSERT; --} -- - #endif /* _HNS3_ETHDEV_H_ */ -diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c -index 84ae26987..4cec0949a 100644 ---- a/drivers/net/hns3/hns3_ethdev_vf.c -+++ b/drivers/net/hns3/hns3_ethdev_vf.c -@@ -422,7 +422,7 @@ hns3vf_restore_promisc(struct hns3_adapter *hns) - } - - static int --hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id, -+hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint16_t vector_id, - bool mmap, enum hns3_ring_type queue_type, - uint16_t queue_id) - { -@@ -434,7 +434,7 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id, - memset(&bind_msg, 0, sizeof(bind_msg)); - code = mmap ? HNS3_MBX_MAP_RING_TO_VECTOR : - HNS3_MBX_UNMAP_RING_TO_VECTOR; -- bind_msg.vector_id = vector_id; -+ bind_msg.vector_id = (uint8_t)vector_id; - - if (queue_type == HNS3_RING_TYPE_RX) - bind_msg.param[0].int_gl_index = HNS3_RING_GL_RX; -@@ -454,62 +454,6 @@ hns3vf_bind_ring_with_vector(struct hns3_hw *hw, uint8_t vector_id, - return ret; - } - --static int --hns3vf_init_ring_with_vector(struct hns3_hw *hw) --{ -- uint16_t vec; -- int ret; -- int i; -- -- /* -- * In hns3 network engine, vector 0 is always the misc interrupt of this -- * function, vector 1~N can be used respectively for the queues of the -- * function. Tx and Rx queues with the same number share the interrupt -- * vector. In the initialization clearing the all hardware mapping -- * relationship configurations between queues and interrupt vectors is -- * needed, so some error caused by the residual configurations, such as -- * the unexpected Tx interrupt, can be avoid. -- */ -- vec = hw->num_msi - 1; /* vector 0 for misc interrupt, not for queue */ -- if (hw->intr.mapping_mode == HNS3_INTR_MAPPING_VEC_RSV_ONE) -- vec = vec - 1; /* the last interrupt is reserved */ -- hw->intr_tqps_num = RTE_MIN(vec, hw->tqps_num); -- for (i = 0; i < hw->intr_tqps_num; i++) { -- /* -- * Set gap limiter/rate limiter/quanity limiter algorithm -- * configuration for interrupt coalesce of queue's interrupt. -- */ -- hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_RX, -- HNS3_TQP_INTR_GL_DEFAULT); -- hns3_set_queue_intr_gl(hw, i, HNS3_RING_GL_TX, -- HNS3_TQP_INTR_GL_DEFAULT); -- hns3_set_queue_intr_rl(hw, i, HNS3_TQP_INTR_RL_DEFAULT); -- /* -- * QL(quantity limiter) is not used currently, just set 0 to -- * close it. -- */ -- hns3_set_queue_intr_ql(hw, i, HNS3_TQP_INTR_QL_DEFAULT); -- -- ret = hns3vf_bind_ring_with_vector(hw, vec, false, -- HNS3_RING_TYPE_TX, i); -- if (ret) { -- PMD_INIT_LOG(ERR, "VF fail to unbind TX ring(%d) with " -- "vector: %u, ret=%d", i, vec, ret); -- return ret; -- } -- -- ret = hns3vf_bind_ring_with_vector(hw, vec, false, -- HNS3_RING_TYPE_RX, i); -- if (ret) { -- PMD_INIT_LOG(ERR, "VF fail to unbind RX ring(%d) with " -- "vector: %u, ret=%d", i, vec, ret); -- return ret; -- } -- } -- -- return 0; --} -- - static int - hns3vf_dev_configure(struct rte_eth_dev *dev) - { -@@ -677,103 +621,6 @@ hns3vf_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) - return 0; - } - --static int --hns3vf_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) --{ -- struct hns3_adapter *hns = eth_dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- uint16_t q_num = hw->tqps_num; -- -- /* -- * In interrupt mode, 'max_rx_queues' is set based on the number of -- * MSI-X interrupt resources of the hardware. -- */ -- if (hw->data->dev_conf.intr_conf.rxq == 1) -- q_num = hw->intr_tqps_num; -- -- info->max_rx_queues = q_num; -- info->max_tx_queues = hw->tqps_num; -- info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */ -- info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; -- info->max_mac_addrs = HNS3_VF_UC_MACADDR_NUM; -- info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; -- info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; -- -- info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | -- DEV_RX_OFFLOAD_UDP_CKSUM | -- DEV_RX_OFFLOAD_TCP_CKSUM | -- DEV_RX_OFFLOAD_SCTP_CKSUM | -- DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | -- DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | -- DEV_RX_OFFLOAD_SCATTER | -- DEV_RX_OFFLOAD_VLAN_STRIP | -- DEV_RX_OFFLOAD_VLAN_FILTER | -- DEV_RX_OFFLOAD_JUMBO_FRAME | -- DEV_RX_OFFLOAD_RSS_HASH | -- DEV_RX_OFFLOAD_TCP_LRO); -- info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | -- DEV_TX_OFFLOAD_IPV4_CKSUM | -- DEV_TX_OFFLOAD_TCP_CKSUM | -- DEV_TX_OFFLOAD_UDP_CKSUM | -- DEV_TX_OFFLOAD_SCTP_CKSUM | -- DEV_TX_OFFLOAD_MULTI_SEGS | -- DEV_TX_OFFLOAD_TCP_TSO | -- DEV_TX_OFFLOAD_VXLAN_TNL_TSO | -- DEV_TX_OFFLOAD_GRE_TNL_TSO | -- DEV_TX_OFFLOAD_GENEVE_TNL_TSO | -- DEV_TX_OFFLOAD_MBUF_FAST_FREE | -- hns3_txvlan_cap_get(hw)); -- -- if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) -- info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; -- -- if (hns3_dev_get_support(hw, INDEP_TXRX)) -- info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | -- RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; -- -- info->rx_desc_lim = (struct rte_eth_desc_lim) { -- .nb_max = HNS3_MAX_RING_DESC, -- .nb_min = HNS3_MIN_RING_DESC, -- .nb_align = HNS3_ALIGN_RING_DESC, -- }; -- -- info->tx_desc_lim = (struct rte_eth_desc_lim) { -- .nb_max = HNS3_MAX_RING_DESC, -- .nb_min = HNS3_MIN_RING_DESC, -- .nb_align = HNS3_ALIGN_RING_DESC, -- .nb_seg_max = HNS3_MAX_TSO_BD_PER_PKT, -- .nb_mtu_seg_max = hw->max_non_tso_bd_num, -- }; -- -- info->default_rxconf = (struct rte_eth_rxconf) { -- .rx_free_thresh = HNS3_DEFAULT_RX_FREE_THRESH, -- /* -- * If there are no available Rx buffer descriptors, incoming -- * packets are always dropped by hardware based on hns3 network -- * engine. -- */ -- .rx_drop_en = 1, -- .offloads = 0, -- }; -- info->default_txconf = (struct rte_eth_txconf) { -- .tx_rs_thresh = HNS3_DEFAULT_TX_RS_THRESH, -- .offloads = 0, -- }; -- -- info->reta_size = hw->rss_ind_tbl_size; -- info->hash_key_size = HNS3_RSS_KEY_SIZE; -- info->flow_type_rss_offloads = HNS3_ETH_RSS_SUPPORT; -- -- info->default_rxportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -- info->default_txportconf.burst_size = HNS3_DEFAULT_PORT_CONF_BURST_SIZE; -- info->default_rxportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -- info->default_txportconf.nb_queues = HNS3_DEFAULT_PORT_CONF_QUEUES_NUM; -- info->default_rxportconf.ring_size = HNS3_DEFAULT_RING_DESC; -- info->default_txportconf.ring_size = HNS3_DEFAULT_RING_DESC; -- -- return 0; --} -- - static void - hns3vf_clear_event_cause(struct hns3_hw *hw, uint32_t regclr) - { -@@ -1662,7 +1509,7 @@ hns3vf_init_hardware(struct hns3_adapter *hns) - * some error caused by the residual configurations, such as the - * unexpected interrupt, can be avoid. - */ -- ret = hns3vf_init_ring_with_vector(hw); -+ ret = hns3_init_ring_with_vector(hw); - if (ret) { - PMD_INIT_LOG(ERR, "Failed to init ring intr vector: %d", ret); - goto err_init_hardware; -@@ -1849,41 +1696,6 @@ hns3vf_do_stop(struct hns3_adapter *hns) - return 0; - } - --static void --hns3vf_unmap_rx_interrupt(struct rte_eth_dev *dev) --{ -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; -- uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; -- uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET; -- uint16_t q_id; -- -- if (dev->data->dev_conf.intr_conf.rxq == 0) -- return; -- -- /* unmap the ring with vector */ -- if (rte_intr_allow_others(intr_handle)) { -- vec = RTE_INTR_VEC_RXTX_OFFSET; -- base = RTE_INTR_VEC_RXTX_OFFSET; -- } -- if (rte_intr_dp_is_en(intr_handle)) { -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- (void)hns3vf_bind_ring_with_vector(hw, vec, false, -- HNS3_RING_TYPE_RX, -- q_id); -- if (vec < base + intr_handle->nb_efd - 1) -- vec++; -- } -- } -- /* Clean datapath event and queue/vec mapping */ -- rte_intr_efd_disable(intr_handle); -- if (intr_handle->intr_vec) { -- rte_free(intr_handle->intr_vec); -- intr_handle->intr_vec = NULL; -- } --} -- - static int - hns3vf_dev_stop(struct rte_eth_dev *dev) - { -@@ -1905,7 +1717,7 @@ hns3vf_dev_stop(struct rte_eth_dev *dev) - if (__atomic_load_n(&hw->reset.resetting, __ATOMIC_RELAXED) == 0) { - hns3_stop_tqps(hw); - hns3vf_do_stop(hns); -- hns3vf_unmap_rx_interrupt(dev); -+ hns3_unmap_rx_interrupt(dev); - hw->adapter_state = HNS3_NIC_CONFIGURED; - } - hns3_rx_scattered_reset(dev); -@@ -1946,31 +1758,6 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) - return ret; - } - --static int --hns3vf_fw_version_get(struct rte_eth_dev *eth_dev, char *fw_version, -- size_t fw_size) --{ -- struct hns3_adapter *hns = eth_dev->data->dev_private; -- struct hns3_hw *hw = &hns->hw; -- uint32_t version = hw->fw_version; -- int ret; -- -- ret = snprintf(fw_version, fw_size, "%lu.%lu.%lu.%lu", -- hns3_get_field(version, HNS3_FW_VERSION_BYTE3_M, -- HNS3_FW_VERSION_BYTE3_S), -- hns3_get_field(version, HNS3_FW_VERSION_BYTE2_M, -- HNS3_FW_VERSION_BYTE2_S), -- hns3_get_field(version, HNS3_FW_VERSION_BYTE1_M, -- HNS3_FW_VERSION_BYTE1_S), -- hns3_get_field(version, HNS3_FW_VERSION_BYTE0_M, -- HNS3_FW_VERSION_BYTE0_S)); -- ret += 1; /* add the size of '\0' */ -- if (fw_size < (uint32_t)ret) -- return ret; -- else -- return 0; --} -- - static int - hns3vf_dev_link_update(struct rte_eth_dev *eth_dev, - __rte_unused int wait_to_complete) -@@ -2032,99 +1819,6 @@ hns3vf_do_start(struct hns3_adapter *hns, bool reset_queue) - return ret; - } - --static int --hns3vf_map_rx_interrupt(struct rte_eth_dev *dev) --{ -- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; -- struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); -- uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; -- uint8_t vec = RTE_INTR_VEC_ZERO_OFFSET; -- uint32_t intr_vector; -- uint16_t q_id; -- int ret; -- -- /* -- * hns3 needs a separate interrupt to be used as event interrupt which -- * could not be shared with task queue pair, so KERNEL drivers need -- * support multiple interrupt vectors. -- */ -- if (dev->data->dev_conf.intr_conf.rxq == 0 || -- !rte_intr_cap_multiple(intr_handle)) -- return 0; -- -- rte_intr_disable(intr_handle); -- intr_vector = hw->used_rx_queues; -- /* It creates event fd for each intr vector when MSIX is used */ -- if (rte_intr_efd_enable(intr_handle, intr_vector)) -- return -EINVAL; -- -- if (intr_handle->intr_vec == NULL) { -- intr_handle->intr_vec = -- rte_zmalloc("intr_vec", -- hw->used_rx_queues * sizeof(int), 0); -- if (intr_handle->intr_vec == NULL) { -- hns3_err(hw, "Failed to allocate %u rx_queues" -- " intr_vec", hw->used_rx_queues); -- ret = -ENOMEM; -- goto vf_alloc_intr_vec_error; -- } -- } -- -- if (rte_intr_allow_others(intr_handle)) { -- vec = RTE_INTR_VEC_RXTX_OFFSET; -- base = RTE_INTR_VEC_RXTX_OFFSET; -- } -- -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- ret = hns3vf_bind_ring_with_vector(hw, vec, true, -- HNS3_RING_TYPE_RX, q_id); -- if (ret) -- goto vf_bind_vector_error; -- intr_handle->intr_vec[q_id] = vec; -- /* -- * If there are not enough efds (e.g. not enough interrupt), -- * remaining queues will be bond to the last interrupt. -- */ -- if (vec < base + intr_handle->nb_efd - 1) -- vec++; -- } -- rte_intr_enable(intr_handle); -- return 0; -- --vf_bind_vector_error: -- rte_free(intr_handle->intr_vec); -- intr_handle->intr_vec = NULL; --vf_alloc_intr_vec_error: -- rte_intr_efd_disable(intr_handle); -- return ret; --} -- --static int --hns3vf_restore_rx_interrupt(struct hns3_hw *hw) --{ -- struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; -- struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; -- uint16_t q_id; -- int ret; -- -- if (dev->data->dev_conf.intr_conf.rxq == 0) -- return 0; -- -- if (rte_intr_dp_is_en(intr_handle)) { -- for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { -- ret = hns3vf_bind_ring_with_vector(hw, -- intr_handle->intr_vec[q_id], true, -- HNS3_RING_TYPE_RX, q_id); -- if (ret) -- return ret; -- } -- } -- -- return 0; --} -- - static void - hns3vf_restore_filter(struct rte_eth_dev *dev) - { -@@ -2150,7 +1844,7 @@ hns3vf_dev_start(struct rte_eth_dev *dev) - rte_spinlock_unlock(&hw->lock); - return ret; - } -- ret = hns3vf_map_rx_interrupt(dev); -+ ret = hns3_map_rx_interrupt(dev); - if (ret) - goto map_rx_inter_err; - -@@ -2467,7 +2161,7 @@ hns3vf_restore_conf(struct hns3_adapter *hns) - if (ret) - goto err_vlan_table; - -- ret = hns3vf_restore_rx_interrupt(hw); -+ ret = hns3_restore_rx_interrupt(hw); - if (ret) - goto err_vlan_table; - -@@ -2641,8 +2335,8 @@ static const struct eth_dev_ops hns3vf_eth_dev_ops = { - .xstats_reset = hns3_dev_xstats_reset, - .xstats_get_by_id = hns3_dev_xstats_get_by_id, - .xstats_get_names_by_id = hns3_dev_xstats_get_names_by_id, -- .dev_infos_get = hns3vf_dev_infos_get, -- .fw_version_get = hns3vf_fw_version_get, -+ .dev_infos_get = hns3_dev_infos_get, -+ .fw_version_get = hns3_fw_version_get, - .rx_queue_setup = hns3_rx_queue_setup, - .tx_queue_setup = hns3_tx_queue_setup, - .rx_queue_release = hns3_dev_rx_queue_release, -@@ -2691,6 +2385,7 @@ hns3vf_init_hw_ops(struct hns3_hw *hw) - hw->ops.del_mc_mac_addr = hns3vf_remove_mc_mac_addr; - hw->ops.add_uc_mac_addr = hns3vf_add_uc_mac_addr; - hw->ops.del_uc_mac_addr = hns3vf_remove_uc_mac_addr; -+ hw->ops.bind_ring_with_vector = hns3vf_bind_ring_with_vector; - } - - static int -diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c -index 44b607af7..e1089b6bd 100644 ---- a/drivers/net/hns3/hns3_tm.c -+++ b/drivers/net/hns3/hns3_tm.c -@@ -4,7 +4,7 @@ - - #include - --#include "hns3_ethdev.h" -+#include "hns3_common.h" - #include "hns3_dcb.h" - #include "hns3_logs.h" - #include "hns3_tm.h" --- -2.33.0 - diff --git a/0266-app-testpmd-remove-unused-header-file.patch b/0266-app-testpmd-remove-unused-header-file.patch deleted file mode 100644 index 4b9b71b..0000000 --- a/0266-app-testpmd-remove-unused-header-file.patch +++ /dev/null @@ -1,252 +0,0 @@ -From 11bcfb49be7f092d8d20d88dfdc5358196d3ecca Mon Sep 17 00:00:00 2001 -From: Huisong Li -Date: Mon, 25 Oct 2021 14:39:22 +0800 -Subject: [PATCH 33/33] app/testpmd: remove unused header file - -This patch removes unused "rte_eth_bond.h" header file. - -Fixes: 2950a769315e ("bond: testpmd support") -Cc: stable@dpdk.org - -Signed-off-by: Huisong Li -Signed-off-by: Min Hu (Connor) -Reviewed-by: Ferruh Yigit ---- - app/test-pmd/parameters.c | 3 - - drivers/net/hns3/hns3_common.c | 101 +++++++++++++++++---------------- - drivers/net/hns3/hns3_flow.h | 5 +- - 3 files changed, 55 insertions(+), 54 deletions(-) - -diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c -index c464c42f6..2a69df5b7 100644 ---- a/app/test-pmd/parameters.c -+++ b/app/test-pmd/parameters.c -@@ -39,9 +39,6 @@ - #include - #include - #include --#ifdef RTE_NET_BOND --#include --#endif - #include - - #include "testpmd.h" -diff --git a/drivers/net/hns3/hns3_common.c b/drivers/net/hns3/hns3_common.c -index eac2aa104..0328f2beb 100644 ---- a/drivers/net/hns3/hns3_common.c -+++ b/drivers/net/hns3/hns3_common.c -@@ -4,7 +4,7 @@ - - #include - #include --#include -+#include - #include - - #include "hns3_common.h" -@@ -60,43 +60,42 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - info->min_rx_bufsize = HNS3_MIN_BD_BUF_SIZE; - info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD; - info->max_lro_pkt_size = HNS3_MAX_LRO_SIZE; -- info->rx_offload_capa = (RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | -- RTE_ETH_RX_OFFLOAD_TCP_CKSUM | -- RTE_ETH_RX_OFFLOAD_UDP_CKSUM | -- RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | -- RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM | -- RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM | -- RTE_ETH_RX_OFFLOAD_SCATTER | -- RTE_ETH_RX_OFFLOAD_VLAN_STRIP | -- RTE_ETH_RX_OFFLOAD_VLAN_FILTER | -- RTE_ETH_RX_OFFLOAD_RSS_HASH | -- RTE_ETH_RX_OFFLOAD_TCP_LRO); -- info->tx_offload_capa = (RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | -- RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | -- RTE_ETH_TX_OFFLOAD_TCP_CKSUM | -- RTE_ETH_TX_OFFLOAD_UDP_CKSUM | -- RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | -- RTE_ETH_TX_OFFLOAD_MULTI_SEGS | -- RTE_ETH_TX_OFFLOAD_TCP_TSO | -- RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO | -- RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO | -- RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO | -- RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE | -- RTE_ETH_TX_OFFLOAD_VLAN_INSERT); -+ info->rx_offload_capa = (DEV_RX_OFFLOAD_IPV4_CKSUM | -+ DEV_RX_OFFLOAD_TCP_CKSUM | -+ DEV_RX_OFFLOAD_UDP_CKSUM | -+ DEV_RX_OFFLOAD_SCTP_CKSUM | -+ DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM | -+ DEV_RX_OFFLOAD_OUTER_UDP_CKSUM | -+ DEV_RX_OFFLOAD_SCATTER | -+ DEV_RX_OFFLOAD_VLAN_STRIP | -+ DEV_RX_OFFLOAD_VLAN_FILTER | -+ DEV_RX_OFFLOAD_RSS_HASH | -+ DEV_RX_OFFLOAD_TCP_LRO); -+ info->tx_offload_capa = (DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM | -+ DEV_TX_OFFLOAD_IPV4_CKSUM | -+ DEV_TX_OFFLOAD_TCP_CKSUM | -+ DEV_TX_OFFLOAD_UDP_CKSUM | -+ DEV_TX_OFFLOAD_SCTP_CKSUM | -+ DEV_TX_OFFLOAD_MULTI_SEGS | -+ DEV_TX_OFFLOAD_TCP_TSO | -+ DEV_TX_OFFLOAD_VXLAN_TNL_TSO | -+ DEV_TX_OFFLOAD_GRE_TNL_TSO | -+ DEV_TX_OFFLOAD_GENEVE_TNL_TSO | -+ DEV_TX_OFFLOAD_MBUF_FAST_FREE | -+ DEV_TX_OFFLOAD_VLAN_INSERT); - - if (!hw->port_base_vlan_cfg.state) -- info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_QINQ_INSERT; -+ info->tx_offload_capa |= DEV_TX_OFFLOAD_QINQ_INSERT; - - if (hns3_dev_get_support(hw, OUTER_UDP_CKSUM)) -- info->tx_offload_capa |= RTE_ETH_TX_OFFLOAD_OUTER_UDP_CKSUM; -+ info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_UDP_CKSUM; - - if (hns3_dev_get_support(hw, INDEP_TXRX)) - info->dev_capa = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP | - RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP; -- info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP; - - if (hns3_dev_get_support(hw, PTP)) -- info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_TIMESTAMP; -+ info->rx_offload_capa |= DEV_RX_OFFLOAD_TIMESTAMP; - - info->rx_desc_lim = (struct rte_eth_desc_lim) { - .nb_max = HNS3_MAX_RING_DESC, -@@ -143,7 +142,7 @@ hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info) - */ - if (!hns->is_vf) { - info->max_mac_addrs = HNS3_UC_MACADDR_NUM; -- info->rx_offload_capa |= RTE_ETH_RX_OFFLOAD_KEEP_CRC; -+ info->rx_offload_capa |= DEV_RX_OFFLOAD_KEEP_CRC; - info->speed_capa = hns3_get_speed_capa(hw); - } else { - info->max_mac_addrs = HNS3_VF_UC_MACADDR_NUM; -@@ -641,7 +640,7 @@ int - hns3_map_rx_interrupt(struct rte_eth_dev *dev) - { - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = pci_dev->intr_handle; -+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - uint16_t base = RTE_INTR_VEC_ZERO_OFFSET; - uint16_t vec = RTE_INTR_VEC_ZERO_OFFSET; -@@ -664,13 +663,16 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev) - if (rte_intr_efd_enable(intr_handle, intr_vector)) - return -EINVAL; - -- /* Allocate vector list */ -- if (rte_intr_vec_list_alloc(intr_handle, "intr_vec", -- hw->used_rx_queues)) { -- hns3_err(hw, "failed to allocate %u rx_queues intr_vec", -- hw->used_rx_queues); -- ret = -ENOMEM; -- goto alloc_intr_vec_error; -+ if (intr_handle->intr_vec == NULL) { -+ intr_handle->intr_vec = -+ rte_zmalloc("intr_vec", -+ hw->used_rx_queues * sizeof(int), 0); -+ if (intr_handle->intr_vec == NULL) { -+ hns3_err(hw, "failed to allocate %u rx_queues intr_vec", -+ hw->used_rx_queues); -+ ret = -ENOMEM; -+ goto alloc_intr_vec_error; -+ } - } - - if (rte_intr_allow_others(intr_handle)) { -@@ -683,21 +685,20 @@ hns3_map_rx_interrupt(struct rte_eth_dev *dev) - HNS3_RING_TYPE_RX, q_id); - if (ret) - goto bind_vector_error; -- -- if (rte_intr_vec_list_index_set(intr_handle, q_id, vec)) -- goto bind_vector_error; -+ intr_handle->intr_vec[q_id] = vec; - /* - * If there are not enough efds (e.g. not enough interrupt), - * remaining queues will be bond to the last interrupt. - */ -- if (vec < base + rte_intr_nb_efd_get(intr_handle) - 1) -+ if (vec < base + intr_handle->nb_efd - 1) - vec++; - } - rte_intr_enable(intr_handle); - return 0; - - bind_vector_error: -- rte_intr_vec_list_free(intr_handle); -+ rte_free(intr_handle->intr_vec); -+ intr_handle->intr_vec = NULL; - alloc_intr_vec_error: - rte_intr_efd_disable(intr_handle); - return ret; -@@ -707,7 +708,7 @@ void - hns3_unmap_rx_interrupt(struct rte_eth_dev *dev) - { - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = pci_dev->intr_handle; -+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - struct hns3_adapter *hns = dev->data->dev_private; - struct hns3_hw *hw = &hns->hw; - uint8_t base = RTE_INTR_VEC_ZERO_OFFSET; -@@ -727,13 +728,16 @@ hns3_unmap_rx_interrupt(struct rte_eth_dev *dev) - (void)hw->ops.bind_ring_with_vector(hw, vec, false, - HNS3_RING_TYPE_RX, - q_id); -- if (vec < base + rte_intr_nb_efd_get(intr_handle) - 1) -+ if (vec < base + intr_handle->nb_efd - 1) - vec++; - } - } - /* Clean datapath event and queue/vec mapping */ - rte_intr_efd_disable(intr_handle); -- rte_intr_vec_list_free(intr_handle); -+ if (intr_handle->intr_vec) { -+ rte_free(intr_handle->intr_vec); -+ intr_handle->intr_vec = NULL; -+ } - } - - int -@@ -741,7 +745,7 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw) - { - struct rte_eth_dev *dev = &rte_eth_devices[hw->data->port_id]; - struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); -- struct rte_intr_handle *intr_handle = pci_dev->intr_handle; -+ struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - uint16_t q_id; - int ret; - -@@ -751,9 +755,8 @@ hns3_restore_rx_interrupt(struct hns3_hw *hw) - if (rte_intr_dp_is_en(intr_handle)) { - for (q_id = 0; q_id < hw->used_rx_queues; q_id++) { - ret = hw->ops.bind_ring_with_vector(hw, -- rte_intr_vec_list_index_get(intr_handle, -- q_id), -- true, HNS3_RING_TYPE_RX, q_id); -+ intr_handle->intr_vec[q_id], true, -+ HNS3_RING_TYPE_RX, q_id); - if (ret) - return ret; - } -diff --git a/drivers/net/hns3/hns3_flow.h b/drivers/net/hns3/hns3_flow.h -index 2eb451b72..d679e5928 100644 ---- a/drivers/net/hns3/hns3_flow.h -+++ b/drivers/net/hns3/hns3_flow.h -@@ -36,8 +36,9 @@ struct hns3_flow_mem { - TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); - TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); - --int hns3_dev_flow_ops_get(struct rte_eth_dev *dev, -- const struct rte_flow_ops **ops); -+int hns3_dev_filter_ctrl(struct rte_eth_dev *dev, -+ enum rte_filter_type filter_type, -+ enum rte_filter_op filter_op, void *arg); - void hns3_flow_init(struct rte_eth_dev *dev); - void hns3_flow_uninit(struct rte_eth_dev *dev); - --- -2.33.0 - diff --git a/0267-usertools-add-Intel-DLB-device-binding.patch b/0267-usertools-add-Intel-DLB-device-binding.patch deleted file mode 100644 index 72112bb..0000000 --- a/0267-usertools-add-Intel-DLB-device-binding.patch +++ /dev/null @@ -1,31 +0,0 @@ -From dfbf3715354e41c8751972d2bcb04a8f5a6961dd Mon Sep 17 00:00:00 2001 -From: speech_white -Date: Fri, 10 Dec 2021 09:20:28 +0800 -Subject: [PATCH] usertools: add Intel DLB device binding - -Fix execution failure to add DLB to usertools/dpdk-devbind.py - -Signed-off-by: speech_white ---- - usertools/dpdk-devbind.py | 2 ++ - 1 file changed, 2 insertions(+) - mode change 100644 => 100755 usertools/dpdk-devbind.py - -diff --git a/usertools/dpdk-devbind.py b/usertools/dpdk-devbind.py -old mode 100644 -new mode 100755 -index 8af3089ae..9b063dae9 ---- a/usertools/dpdk-devbind.py -+++ b/usertools/dpdk-devbind.py -@@ -47,6 +47,8 @@ - - hisilicon_dma = {'Class': '08', 'Vendor': '19e5', 'Device': 'a122', - 'SVendor': None, 'SDevice': None} -+intel_dlb = {'Class': '0b', 'Vendor': '8086', 'Device': '270b,2710,2714', -+ 'SVendor': None, 'SDevice': None} - intel_ioat_bdw = {'Class': '08', 'Vendor': '8086', - 'Device': '6f20,6f21,6f22,6f23,6f24,6f25,6f26,6f27,6f2e,6f2f', - 'SVendor': None, 'SDevice': None} --- -2.23.0 - diff --git a/add-igb-uio.patch b/add-igb-uio.patch new file mode 100644 index 0000000..3e31860 --- /dev/null +++ b/add-igb-uio.patch @@ -0,0 +1,927 @@ +From b46793510b200c4120f03963252f7f54d23f6f8b Mon Sep 17 00:00:00 2001 +From: Changsheng Wu +Date: Sat, 18 Dec 2021 19:07:58 +0800 +Subject: [PATCH] add igb_uio + +--- + kernel/linux/igb_uio/Kbuild | 2 + + kernel/linux/igb_uio/compat.h | 154 +++++++ + kernel/linux/igb_uio/igb_uio.c | 674 +++++++++++++++++++++++++++++++ + kernel/linux/igb_uio/meson.build | 27 ++ + kernel/linux/meson.build | 2 +- + meson_options.txt | 2 +- + 6 files changed, 859 insertions(+), 2 deletions(-) + create mode 100644 kernel/linux/igb_uio/Kbuild + create mode 100644 kernel/linux/igb_uio/compat.h + create mode 100644 kernel/linux/igb_uio/igb_uio.c + create mode 100644 kernel/linux/igb_uio/meson.build + +diff --git a/kernel/linux/igb_uio/Kbuild b/kernel/linux/igb_uio/Kbuild +new file mode 100644 +index 0000000000..3ab85c4116 +--- /dev/null ++++ b/kernel/linux/igb_uio/Kbuild +@@ -0,0 +1,2 @@ ++ccflags-y := $(MODULE_CFLAGS) ++obj-m := igb_uio.o +diff --git a/kernel/linux/igb_uio/compat.h b/kernel/linux/igb_uio/compat.h +new file mode 100644 +index 0000000000..8dbb896ae1 +--- /dev/null ++++ b/kernel/linux/igb_uio/compat.h +@@ -0,0 +1,154 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * Minimal wrappers to allow compiling igb_uio on older kernels. ++ */ ++ ++#ifndef RHEL_RELEASE_VERSION ++#define RHEL_RELEASE_VERSION(a, b) (((a) << 8) + (b)) ++#endif ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) ++#define pci_cfg_access_lock pci_block_user_cfg_access ++#define pci_cfg_access_unlock pci_unblock_user_cfg_access ++#endif ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0) ++#define HAVE_PTE_MASK_PAGE_IOMAP ++#endif ++ ++#ifndef PCI_MSIX_ENTRY_SIZE ++#define PCI_MSIX_ENTRY_SIZE 16 ++#define PCI_MSIX_ENTRY_VECTOR_CTRL 12 ++#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 ++#endif ++ ++/* ++ * for kernels < 2.6.38 and backported patch that moves MSI-X entry definition ++ * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not ++ * PCI_MSIX_ENTRY_CTRL_MASKBIT ++ */ ++#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT ++#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 ++#endif ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \ ++ (!(defined(RHEL_RELEASE_CODE) && \ ++ RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9))) ++ ++static int pci_num_vf(struct pci_dev *dev) ++{ ++ struct iov { ++ int pos; ++ int nres; ++ u32 cap; ++ u16 ctrl; ++ u16 total; ++ u16 initial; ++ u16 nr_virtfn; ++ } *iov = (struct iov *)dev->sriov; ++ ++ if (!dev->is_physfn) ++ return 0; ++ ++ return iov->nr_virtfn; ++} ++ ++#endif /* < 2.6.34 */ ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39) && \ ++ (!(defined(RHEL_RELEASE_CODE) && \ ++ RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 4))) ++ ++#define kstrtoul strict_strtoul ++ ++#endif /* < 2.6.39 */ ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 3, 0) && \ ++ (!(defined(RHEL_RELEASE_CODE) && \ ++ RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(6, 3))) ++ ++/* Check if INTX works to control irq's. ++ * Set's INTX_DISABLE flag and reads it back ++ */ ++static bool pci_intx_mask_supported(struct pci_dev *pdev) ++{ ++ bool mask_supported = false; ++ uint16_t orig, new; ++ ++ pci_block_user_cfg_access(pdev); ++ pci_read_config_word(pdev, PCI_COMMAND, &orig); ++ pci_write_config_word(pdev, PCI_COMMAND, ++ orig ^ PCI_COMMAND_INTX_DISABLE); ++ pci_read_config_word(pdev, PCI_COMMAND, &new); ++ ++ if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) { ++ dev_err(&pdev->dev, "Command register changed from " ++ "0x%x to 0x%x: driver or hardware bug?\n", orig, new); ++ } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) { ++ mask_supported = true; ++ pci_write_config_word(pdev, PCI_COMMAND, orig); ++ } ++ pci_unblock_user_cfg_access(pdev); ++ ++ return mask_supported; ++} ++ ++static bool pci_check_and_mask_intx(struct pci_dev *pdev) ++{ ++ bool pending; ++ uint32_t status; ++ ++ pci_block_user_cfg_access(pdev); ++ pci_read_config_dword(pdev, PCI_COMMAND, &status); ++ ++ /* interrupt is not ours, goes to out */ ++ pending = (((status >> 16) & PCI_STATUS_INTERRUPT) != 0); ++ if (pending) { ++ uint16_t old, new; ++ ++ old = status; ++ if (status != 0) ++ new = old & (~PCI_COMMAND_INTX_DISABLE); ++ else ++ new = old | PCI_COMMAND_INTX_DISABLE; ++ ++ if (old != new) ++ pci_write_config_word(pdev, PCI_COMMAND, new); ++ } ++ pci_unblock_user_cfg_access(pdev); ++ ++ return pending; ++} ++ ++#endif /* < 3.3.0 */ ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0) ++#define HAVE_PCI_IS_BRIDGE_API 1 ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) ++#define HAVE_MSI_LIST_IN_GENERIC_DEVICE 1 ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ++#define HAVE_PCI_MSI_MASK_IRQ 1 ++#endif ++ ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0) ++#define HAVE_ALLOC_IRQ_VECTORS 1 ++#endif ++ ++static inline bool igbuio_kernel_is_locked_down(void) ++{ ++#ifdef CONFIG_LOCK_DOWN_KERNEL ++#ifdef CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT ++ return kernel_is_locked_down(NULL); ++#elif defined(CONFIG_EFI_SECURE_BOOT_LOCK_DOWN) ++ return kernel_is_locked_down(); ++#else ++ return false; ++#endif ++#else ++ return false; ++#endif ++} +diff --git a/kernel/linux/igb_uio/igb_uio.c b/kernel/linux/igb_uio/igb_uio.c +new file mode 100644 +index 0000000000..ea439d131d +--- /dev/null ++++ b/kernel/linux/igb_uio/igb_uio.c +@@ -0,0 +1,674 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/*- ++ * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. ++ */ ++ ++#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/** ++ * These enum and macro definitions are copied from the ++ * file rte_pci_dev_features.h ++ */ ++enum rte_intr_mode { ++ RTE_INTR_MODE_NONE = 0, ++ RTE_INTR_MODE_LEGACY, ++ RTE_INTR_MODE_MSI, ++ RTE_INTR_MODE_MSIX ++}; ++#define RTE_INTR_MODE_NONE_NAME "none" ++#define RTE_INTR_MODE_LEGACY_NAME "legacy" ++#define RTE_INTR_MODE_MSI_NAME "msi" ++#define RTE_INTR_MODE_MSIX_NAME "msix" ++ ++ ++#include "compat.h" ++ ++/** ++ * A structure describing the private information for a uio device. ++ */ ++struct rte_uio_pci_dev { ++ struct uio_info info; ++ struct pci_dev *pdev; ++ enum rte_intr_mode mode; ++ atomic_t refcnt; ++}; ++ ++static int wc_activate; ++static char *intr_mode; ++static enum rte_intr_mode igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; ++/* sriov sysfs */ ++static ssize_t ++show_max_vfs(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ return snprintf(buf, 10, "%u\n", dev_num_vf(dev)); ++} ++ ++static ssize_t ++store_max_vfs(struct device *dev, struct device_attribute *attr, ++ const char *buf, size_t count) ++{ ++ int err = 0; ++ unsigned long max_vfs; ++ struct pci_dev *pdev = to_pci_dev(dev); ++ ++ if (0 != kstrtoul(buf, 0, &max_vfs)) ++ return -EINVAL; ++ ++ if (0 == max_vfs) ++ pci_disable_sriov(pdev); ++ else if (0 == pci_num_vf(pdev)) ++ err = pci_enable_sriov(pdev, max_vfs); ++ else /* do nothing if change max_vfs number */ ++ err = -EINVAL; ++ ++ return err ? err : count; ++} ++ ++static DEVICE_ATTR(max_vfs, S_IRUGO | S_IWUSR, show_max_vfs, store_max_vfs); ++ ++static struct attribute *dev_attrs[] = { ++ &dev_attr_max_vfs.attr, ++ NULL, ++}; ++ ++static const struct attribute_group dev_attr_grp = { ++ .attrs = dev_attrs, ++}; ++ ++#ifndef HAVE_PCI_MSI_MASK_IRQ ++/* ++ * It masks the msix on/off of generating MSI-X messages. ++ */ ++static void ++igbuio_msix_mask_irq(struct msi_desc *desc, s32 state) ++{ ++ u32 mask_bits = desc->masked; ++ unsigned int offset = desc->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + ++ PCI_MSIX_ENTRY_VECTOR_CTRL; ++ ++ if (state != 0) ++ mask_bits &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT; ++ else ++ mask_bits |= PCI_MSIX_ENTRY_CTRL_MASKBIT; ++ ++ if (mask_bits != desc->masked) { ++ writel(mask_bits, desc->mask_base + offset); ++ readl(desc->mask_base); ++ desc->masked = mask_bits; ++ } ++} ++ ++/* ++ * It masks the msi on/off of generating MSI messages. ++ */ ++static void ++igbuio_msi_mask_irq(struct pci_dev *pdev, struct msi_desc *desc, int32_t state) ++{ ++ u32 mask_bits = desc->masked; ++ u32 offset = desc->irq - pdev->irq; ++ u32 mask = 1 << offset; ++ ++ if (!desc->msi_attrib.maskbit) ++ return; ++ ++ if (state != 0) ++ mask_bits &= ~mask; ++ else ++ mask_bits |= mask; ++ ++ if (mask_bits != desc->masked) { ++ pci_write_config_dword(pdev, desc->mask_pos, mask_bits); ++ desc->masked = mask_bits; ++ } ++} ++ ++static void ++igbuio_mask_irq(struct pci_dev *pdev, enum rte_intr_mode mode, s32 irq_state) ++{ ++ struct msi_desc *desc; ++ struct list_head *msi_list; ++ ++#ifdef HAVE_MSI_LIST_IN_GENERIC_DEVICE ++ msi_list = &pdev->dev.msi_list; ++#else ++ msi_list = &pdev->msi_list; ++#endif ++ ++ if (mode == RTE_INTR_MODE_MSIX) { ++ list_for_each_entry(desc, msi_list, list) ++ igbuio_msix_mask_irq(desc, irq_state); ++ } else if (mode == RTE_INTR_MODE_MSI) { ++ list_for_each_entry(desc, msi_list, list) ++ igbuio_msi_mask_irq(pdev, desc, irq_state); ++ } ++} ++#endif ++ ++/** ++ * This is the irqcontrol callback to be registered to uio_info. ++ * It can be used to disable/enable interrupt from user space processes. ++ * ++ * @param info ++ * pointer to uio_info. ++ * @param irq_state ++ * state value. 1 to enable interrupt, 0 to disable interrupt. ++ * ++ * @return ++ * - On success, 0. ++ * - On failure, a negative value. ++ */ ++static int ++igbuio_pci_irqcontrol(struct uio_info *info, s32 irq_state) ++{ ++ struct rte_uio_pci_dev *udev = info->priv; ++ struct pci_dev *pdev = udev->pdev; ++ ++#ifdef HAVE_PCI_MSI_MASK_IRQ ++ struct irq_data *irq = irq_get_irq_data(udev->info.irq); ++#endif ++ ++ pci_cfg_access_lock(pdev); ++ ++ if (udev->mode == RTE_INTR_MODE_MSIX || udev->mode == RTE_INTR_MODE_MSI) { ++#ifdef HAVE_PCI_MSI_MASK_IRQ ++ if (irq_state == 1) ++ pci_msi_unmask_irq(irq); ++ else ++ pci_msi_mask_irq(irq); ++#else ++ igbuio_mask_irq(pdev, udev->mode, irq_state); ++#endif ++ } ++ ++ if (udev->mode == RTE_INTR_MODE_LEGACY) ++ pci_intx(pdev, !!irq_state); ++ ++ pci_cfg_access_unlock(pdev); ++ ++ return 0; ++} ++ ++/** ++ * This is interrupt handler which will check if the interrupt is for the right device. ++ * If yes, disable it here and will be enable later. ++ */ ++static irqreturn_t ++igbuio_pci_irqhandler(int irq, void *dev_id) ++{ ++ struct rte_uio_pci_dev *udev = (struct rte_uio_pci_dev *)dev_id; ++ struct uio_info *info = &udev->info; ++ ++ /* Legacy mode need to mask in hardware */ ++ if (udev->mode == RTE_INTR_MODE_LEGACY && ++ !pci_check_and_mask_intx(udev->pdev)) ++ return IRQ_NONE; ++ ++ uio_event_notify(info); ++ ++ /* Message signal mode, no share IRQ and automasked */ ++ return IRQ_HANDLED; ++} ++ ++static int ++igbuio_pci_enable_interrupts(struct rte_uio_pci_dev *udev) ++{ ++ int err = 0; ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ struct msix_entry msix_entry; ++#endif ++ ++ switch (igbuio_intr_mode_preferred) { ++ case RTE_INTR_MODE_MSIX: ++ /* Only 1 msi-x vector needed */ ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ msix_entry.entry = 0; ++ if (pci_enable_msix(udev->pdev, &msix_entry, 1) == 0) { ++ dev_dbg(&udev->pdev->dev, "using MSI-X"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = msix_entry.vector; ++ udev->mode = RTE_INTR_MODE_MSIX; ++ break; ++ } ++#else ++ if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSIX) == 1) { ++ dev_dbg(&udev->pdev->dev, "using MSI-X"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = pci_irq_vector(udev->pdev, 0); ++ udev->mode = RTE_INTR_MODE_MSIX; ++ break; ++ } ++#endif ++ ++ /* falls through - to MSI */ ++ case RTE_INTR_MODE_MSI: ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ if (pci_enable_msi(udev->pdev) == 0) { ++ dev_dbg(&udev->pdev->dev, "using MSI"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = udev->pdev->irq; ++ udev->mode = RTE_INTR_MODE_MSI; ++ break; ++ } ++#else ++ if (pci_alloc_irq_vectors(udev->pdev, 1, 1, PCI_IRQ_MSI) == 1) { ++ dev_dbg(&udev->pdev->dev, "using MSI"); ++ udev->info.irq_flags = IRQF_NO_THREAD; ++ udev->info.irq = pci_irq_vector(udev->pdev, 0); ++ udev->mode = RTE_INTR_MODE_MSI; ++ break; ++ } ++#endif ++ /* falls through - to INTX */ ++ case RTE_INTR_MODE_LEGACY: ++ if (pci_intx_mask_supported(udev->pdev)) { ++ dev_dbg(&udev->pdev->dev, "using INTX"); ++ udev->info.irq_flags = IRQF_SHARED | IRQF_NO_THREAD; ++ udev->info.irq = udev->pdev->irq; ++ udev->mode = RTE_INTR_MODE_LEGACY; ++ break; ++ } ++ dev_notice(&udev->pdev->dev, "PCI INTX mask not supported\n"); ++ /* falls through - to no IRQ */ ++ case RTE_INTR_MODE_NONE: ++ udev->mode = RTE_INTR_MODE_NONE; ++ udev->info.irq = UIO_IRQ_NONE; ++ break; ++ ++ default: ++ dev_err(&udev->pdev->dev, "invalid IRQ mode %u", ++ igbuio_intr_mode_preferred); ++ udev->info.irq = UIO_IRQ_NONE; ++ err = -EINVAL; ++ } ++ ++ if (udev->info.irq != UIO_IRQ_NONE) ++ err = request_irq(udev->info.irq, igbuio_pci_irqhandler, ++ udev->info.irq_flags, udev->info.name, ++ udev); ++ dev_info(&udev->pdev->dev, "uio device registered with irq %ld\n", ++ udev->info.irq); ++ ++ return err; ++} ++ ++static void ++igbuio_pci_disable_interrupts(struct rte_uio_pci_dev *udev) ++{ ++ if (udev->info.irq) { ++ free_irq(udev->info.irq, udev); ++ udev->info.irq = 0; ++ } ++ ++#ifndef HAVE_ALLOC_IRQ_VECTORS ++ if (udev->mode == RTE_INTR_MODE_MSIX) ++ pci_disable_msix(udev->pdev); ++ if (udev->mode == RTE_INTR_MODE_MSI) ++ pci_disable_msi(udev->pdev); ++#else ++ if (udev->mode == RTE_INTR_MODE_MSIX || ++ udev->mode == RTE_INTR_MODE_MSI) ++ pci_free_irq_vectors(udev->pdev); ++#endif ++} ++ ++ ++/** ++ * This gets called while opening uio device file. ++ */ ++static int ++igbuio_pci_open(struct uio_info *info, struct inode *inode) ++{ ++ struct rte_uio_pci_dev *udev = info->priv; ++ struct pci_dev *dev = udev->pdev; ++ int err; ++ ++ if (atomic_inc_return(&udev->refcnt) != 1) ++ return 0; ++ ++ /* set bus master, which was cleared by the reset function */ ++ pci_set_master(dev); ++ ++ /* enable interrupts */ ++ err = igbuio_pci_enable_interrupts(udev); ++ if (err) { ++ atomic_dec(&udev->refcnt); ++ dev_err(&dev->dev, "Enable interrupt fails\n"); ++ } ++ return err; ++} ++ ++static int ++igbuio_pci_release(struct uio_info *info, struct inode *inode) ++{ ++ struct rte_uio_pci_dev *udev = info->priv; ++ struct pci_dev *dev = udev->pdev; ++ ++ if (atomic_dec_and_test(&udev->refcnt)) { ++ /* disable interrupts */ ++ igbuio_pci_disable_interrupts(udev); ++ ++ /* stop the device from further DMA */ ++ pci_clear_master(dev); ++ } ++ ++ return 0; ++} ++ ++/* Remap pci resources described by bar #pci_bar in uio resource n. */ ++static int ++igbuio_pci_setup_iomem(struct pci_dev *dev, struct uio_info *info, ++ int n, int pci_bar, const char *name) ++{ ++ unsigned long addr, len; ++ void *internal_addr; ++ ++ if (n >= ARRAY_SIZE(info->mem)) ++ return -EINVAL; ++ ++ addr = pci_resource_start(dev, pci_bar); ++ len = pci_resource_len(dev, pci_bar); ++ if (addr == 0 || len == 0) ++ return -1; ++ if (wc_activate == 0) { ++ internal_addr = ioremap(addr, len); ++ if (internal_addr == NULL) ++ return -1; ++ } else { ++ internal_addr = NULL; ++ } ++ info->mem[n].name = name; ++ info->mem[n].addr = addr; ++ info->mem[n].internal_addr = internal_addr; ++ info->mem[n].size = len; ++ info->mem[n].memtype = UIO_MEM_PHYS; ++ return 0; ++} ++ ++/* Get pci port io resources described by bar #pci_bar in uio resource n. */ ++static int ++igbuio_pci_setup_ioport(struct pci_dev *dev, struct uio_info *info, ++ int n, int pci_bar, const char *name) ++{ ++ unsigned long addr, len; ++ ++ if (n >= ARRAY_SIZE(info->port)) ++ return -EINVAL; ++ ++ addr = pci_resource_start(dev, pci_bar); ++ len = pci_resource_len(dev, pci_bar); ++ if (addr == 0 || len == 0) ++ return -EINVAL; ++ ++ info->port[n].name = name; ++ info->port[n].start = addr; ++ info->port[n].size = len; ++ info->port[n].porttype = UIO_PORT_X86; ++ ++ return 0; ++} ++ ++/* Unmap previously ioremap'd resources */ ++static void ++igbuio_pci_release_iomem(struct uio_info *info) ++{ ++ int i; ++ ++ for (i = 0; i < MAX_UIO_MAPS; i++) { ++ if (info->mem[i].internal_addr) ++ iounmap(info->mem[i].internal_addr); ++ } ++} ++ ++static int ++igbuio_setup_bars(struct pci_dev *dev, struct uio_info *info) ++{ ++ int i, iom, iop, ret; ++ unsigned long flags; ++ static const char *bar_names[PCI_STD_RESOURCE_END + 1] = { ++ "BAR0", ++ "BAR1", ++ "BAR2", ++ "BAR3", ++ "BAR4", ++ "BAR5", ++ }; ++ ++ iom = 0; ++ iop = 0; ++ ++ for (i = 0; i < ARRAY_SIZE(bar_names); i++) { ++ if (pci_resource_len(dev, i) != 0 && ++ pci_resource_start(dev, i) != 0) { ++ flags = pci_resource_flags(dev, i); ++ if (flags & IORESOURCE_MEM) { ++ ret = igbuio_pci_setup_iomem(dev, info, iom, ++ i, bar_names[i]); ++ if (ret != 0) ++ return ret; ++ iom++; ++ } else if (flags & IORESOURCE_IO) { ++ ret = igbuio_pci_setup_ioport(dev, info, iop, ++ i, bar_names[i]); ++ if (ret != 0) ++ return ret; ++ iop++; ++ } ++ } ++ } ++ ++ return (iom != 0 || iop != 0) ? ret : -ENOENT; ++} ++ ++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0) ++static int __devinit ++#else ++static int ++#endif ++igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) ++{ ++ struct rte_uio_pci_dev *udev; ++ dma_addr_t map_dma_addr; ++ void *map_addr; ++ int err; ++ ++#ifdef HAVE_PCI_IS_BRIDGE_API ++ if (pci_is_bridge(dev)) { ++ dev_warn(&dev->dev, "Ignoring PCI bridge device\n"); ++ return -ENODEV; ++ } ++#endif ++ ++ udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL); ++ if (!udev) ++ return -ENOMEM; ++ ++ /* ++ * enable device: ask low-level code to enable I/O and ++ * memory ++ */ ++ err = pci_enable_device(dev); ++ if (err != 0) { ++ dev_err(&dev->dev, "Cannot enable PCI device\n"); ++ goto fail_free; ++ } ++ ++ /* enable bus mastering on the device */ ++ pci_set_master(dev); ++ ++ /* remap IO memory */ ++ err = igbuio_setup_bars(dev, &udev->info); ++ if (err != 0) ++ goto fail_release_iomem; ++ ++ /* set 64-bit DMA mask */ ++ err = pci_set_dma_mask(dev, DMA_BIT_MASK(64)); ++ if (err != 0) { ++ dev_err(&dev->dev, "Cannot set DMA mask\n"); ++ goto fail_release_iomem; ++ } ++ ++ err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(64)); ++ if (err != 0) { ++ dev_err(&dev->dev, "Cannot set consistent DMA mask\n"); ++ goto fail_release_iomem; ++ } ++ ++ /* fill uio infos */ ++ udev->info.name = "igb_uio"; ++ udev->info.version = "0.1"; ++ udev->info.irqcontrol = igbuio_pci_irqcontrol; ++ udev->info.open = igbuio_pci_open; ++ udev->info.release = igbuio_pci_release; ++ udev->info.priv = udev; ++ udev->pdev = dev; ++ atomic_set(&udev->refcnt, 0); ++ ++ err = sysfs_create_group(&dev->dev.kobj, &dev_attr_grp); ++ if (err != 0) ++ goto fail_release_iomem; ++ ++ /* register uio driver */ ++ err = uio_register_device(&dev->dev, &udev->info); ++ if (err != 0) ++ goto fail_remove_group; ++ ++ pci_set_drvdata(dev, udev); ++ ++ /* ++ * Doing a harmless dma mapping for attaching the device to ++ * the iommu identity mapping if kernel boots with iommu=pt. ++ * Note this is not a problem if no IOMMU at all. ++ */ ++ map_addr = dma_alloc_coherent(&dev->dev, 1024, &map_dma_addr, ++ GFP_KERNEL); ++ if (map_addr) ++ memset(map_addr, 0, 1024); ++ ++ if (!map_addr) ++ dev_info(&dev->dev, "dma mapping failed\n"); ++ else { ++ dev_info(&dev->dev, "mapping 1K dma=%#llx host=%p\n", ++ (unsigned long long)map_dma_addr, map_addr); ++ ++ dma_free_coherent(&dev->dev, 1024, map_addr, map_dma_addr); ++ dev_info(&dev->dev, "unmapping 1K dma=%#llx host=%p\n", ++ (unsigned long long)map_dma_addr, map_addr); ++ } ++ ++ return 0; ++ ++fail_remove_group: ++ sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); ++fail_release_iomem: ++ igbuio_pci_release_iomem(&udev->info); ++ pci_disable_device(dev); ++fail_free: ++ kfree(udev); ++ ++ return err; ++} ++ ++static void ++igbuio_pci_remove(struct pci_dev *dev) ++{ ++ struct rte_uio_pci_dev *udev = pci_get_drvdata(dev); ++ ++ igbuio_pci_release(&udev->info, NULL); ++ ++ sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp); ++ uio_unregister_device(&udev->info); ++ igbuio_pci_release_iomem(&udev->info); ++ pci_disable_device(dev); ++ pci_set_drvdata(dev, NULL); ++ kfree(udev); ++} ++ ++static int ++igbuio_config_intr_mode(char *intr_str) ++{ ++ if (!intr_str) { ++ pr_info("Use MSIX interrupt by default\n"); ++ return 0; ++ } ++ ++ if (!strcmp(intr_str, RTE_INTR_MODE_MSIX_NAME)) { ++ igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; ++ pr_info("Use MSIX interrupt\n"); ++ } else if (!strcmp(intr_str, RTE_INTR_MODE_MSI_NAME)) { ++ igbuio_intr_mode_preferred = RTE_INTR_MODE_MSI; ++ pr_info("Use MSI interrupt\n"); ++ } else if (!strcmp(intr_str, RTE_INTR_MODE_LEGACY_NAME)) { ++ igbuio_intr_mode_preferred = RTE_INTR_MODE_LEGACY; ++ pr_info("Use legacy interrupt\n"); ++ } else { ++ pr_info("Error: bad parameter - %s\n", intr_str); ++ return -EINVAL; ++ } ++ ++ return 0; ++} ++ ++static struct pci_driver igbuio_pci_driver = { ++ .name = "igb_uio", ++ .id_table = NULL, ++ .probe = igbuio_pci_probe, ++ .remove = igbuio_pci_remove, ++}; ++ ++static int __init ++igbuio_pci_init_module(void) ++{ ++ int ret; ++ ++ if (igbuio_kernel_is_locked_down()) { ++ pr_err("Not able to use module, kernel lock down is enabled\n"); ++ return -EINVAL; ++ } ++ ++ if (wc_activate != 0) ++ pr_info("wc_activate is set\n"); ++ ++ ret = igbuio_config_intr_mode(intr_mode); ++ if (ret < 0) ++ return ret; ++ ++ return pci_register_driver(&igbuio_pci_driver); ++} ++ ++static void __exit ++igbuio_pci_exit_module(void) ++{ ++ pci_unregister_driver(&igbuio_pci_driver); ++} ++ ++module_init(igbuio_pci_init_module); ++module_exit(igbuio_pci_exit_module); ++ ++module_param(intr_mode, charp, S_IRUGO); ++MODULE_PARM_DESC(intr_mode, ++"igb_uio interrupt mode (default=msix):\n" ++" " RTE_INTR_MODE_MSIX_NAME " Use MSIX interrupt\n" ++" " RTE_INTR_MODE_MSI_NAME " Use MSI interrupt\n" ++" " RTE_INTR_MODE_LEGACY_NAME " Use Legacy interrupt\n" ++"\n"); ++ ++module_param(wc_activate, int, 0); ++MODULE_PARM_DESC(wc_activate, ++"Activate support for write combining (WC) (default=0)\n" ++" 0 - disable\n" ++" other - enable\n"); ++ ++MODULE_DESCRIPTION("UIO driver for Intel IGB PCI cards"); ++MODULE_LICENSE("GPL"); ++MODULE_AUTHOR("Intel Corporation"); +diff --git a/kernel/linux/igb_uio/meson.build b/kernel/linux/igb_uio/meson.build +new file mode 100644 +index 0000000000..ff8f97ca23 +--- /dev/null ++++ b/kernel/linux/igb_uio/meson.build +@@ -0,0 +1,27 @@ ++# SPDX-License-Identifier: BSD-3-Clause ++# Copyright(c) 2018 Luca Boccassi ++ ++# For SUSE build check function arguments of ndo_tx_timeout API ++# Ref: https://jira.devtools.intel.com/browse/DPDK-29263 ++kmod_cflags = '' ++ ++igb_uio_mkfile = custom_target('igb_uio_makefile', ++ output: 'Makefile', ++ command: ['touch', '@OUTPUT@']) ++ ++igb_uio_sources = files( ++ 'igb_uio.c', ++ 'Kbuild', ++) ++ ++custom_target('igb_uio', ++ input: igb_uio_sources, ++ output: 'igb_uio.ko', ++ command: ['make', '-j4', '-C', kernel_build_dir, ++ 'M=' + meson.current_build_dir(), ++ 'src=' + meson.current_source_dir(), ++ 'modules'] + cross_args, ++ depends: igb_uio_mkfile, ++ install: install, ++ install_dir: kernel_install_dir, ++ build_by_default: get_option('enable_kmods')) +diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build +index 0637452e95..3230368f14 100644 +--- a/kernel/linux/meson.build ++++ b/kernel/linux/meson.build +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: BSD-3-Clause + # Copyright(c) 2018 Intel Corporation + +-subdirs = ['kni'] ++subdirs = ['kni', 'igb_uio'] + + kernel_build_dir = get_option('kernel_dir') + kernel_source_dir = get_option('kernel_dir') +diff --git a/meson_options.txt b/meson_options.txt +index 7c220ad68d..d2e172facd 100644 +--- a/meson_options.txt ++++ b/meson_options.txt +@@ -18,7 +18,7 @@ option('enable_drivers', type: 'string', value: '', description: + 'Comma-separated list of drivers to build. If unspecified, build all drivers.') + option('enable_driver_sdk', type: 'boolean', value: false, description: + 'Install headers to build drivers.') +-option('enable_kmods', type: 'boolean', value: false, description: ++option('enable_kmods', type: 'boolean', value: true, description: + 'build kernel modules') + option('examples', type: 'string', value: '', description: + 'Comma-separated list of examples to build by default') +-- +2.27.0 diff --git a/dpdk-20.11.tar.xz b/dpdk-20.11.tar.xz deleted file mode 100644 index b022fc5..0000000 Binary files a/dpdk-20.11.tar.xz and /dev/null differ diff --git a/dpdk-21.11.tar.xz b/dpdk-21.11.tar.xz new file mode 100644 index 0000000..5b1b7fe Binary files /dev/null and b/dpdk-21.11.tar.xz differ diff --git a/dpdk.spec b/dpdk.spec index 6fd7bc4..90e1916 100644 --- a/dpdk.spec +++ b/dpdk.spec @@ -1,279 +1,12 @@ Name: dpdk -Version: 20.11 -Release: 10 +Version: 21.11 +Release: 1 Packager: packaging@6wind.com URL: http://dpdk.org -%global source_version 20.11 +%global source_version 21.11 Source: https://git.dpdk.org/dpdk/snapshot/%{name}-%{version}.tar.xz -Patch0: 0001-net-hns3-adjust-MAC-address-logging.patch -Patch1: 0002-net-hns3-fix-FEC-state-query.patch -Patch2: 0003-net-hns3-fix-build-with-SVE.patch -Patch3: 0004-net-hns3-fix-interception-with-flow-director.patch -Patch4: 0005-net-hns3-fix-xstats-with-id-and-names.patch -Patch5: 0006-net-hns3-fix-error-code-in-xstats.patch -Patch6: 0007-net-hns3-fix-Rx-Tx-errors-stats.patch -Patch7: 0008-net-hns3-fix-crash-with-multi-process.patch -Patch8: 0009-net-hns3-remove-unnecessary-memset.patch -Patch9: 0010-net-hns3-fix-jumbo-frame-flag-condition-for-MTU-set.patch -Patch10: 0011-net-hns3-use-C11-atomics-builtins-for-resetting.patch -Patch11: 0012-net-hns3-support-traffic-management.patch -Patch12: 0013-net-hns3-fix-VF-query-link-status-in-dev-init.patch -Patch13: 0014-net-hns3-use-new-opcode-for-clearing-hardware-resour.patch -Patch14: 0015-net-hns3-fix-register-length-when-dumping-registers.patch -Patch15: 0016-net-hns3-fix-data-overwriting-during-register-dump.patch -Patch16: 0017-net-hns3-fix-dump-register-out-of-range.patch -Patch17: 0018-net-hns3-remove-unused-assignment-for-RSS-key.patch -Patch18: 0019-net-hns3-encapsulate-DFX-stats-in-datapath.patch -Patch19: 0020-net-hns3-move-queue-stats-to-xstats.patch -Patch20: 0021-net-hns3-refactor-converting-descriptor-error.patch -Patch21: 0022-net-hns3-refactor-flow-checks-into-own-functions.patch -Patch22: 0023-net-hns3-reconstruct-Rx-interrupt-map.patch -Patch23: 0024-net-hns3-extract-common-checks-for-flow-director.patch -Patch24: 0025-net-hns3-refactor-reset-event-report-function.patch -Patch25: 0026-net-hns3-fix-memory-leak-on-secondary-process-exit.patch -Patch26: 0027-net-hns3-fix-interrupt-resources-in-Rx-interrupt-mod.patch -Patch27: 0028-net-hns3-rename-RSS-functions.patch -Patch28: 0029-net-hns3-adjust-some-comments.patch -Patch29: 0030-net-hns3-remove-unnecessary-parentheses.patch -Patch30: 0031-net-hns3-adjust-format-specifier-for-enum.patch -Patch31: 0032-net-hns3-support-LSC-event-report.patch -Patch32: 0033-net-hns3-fix-query-order-of-link-status-and-link-inf.patch -Patch33: 0034-net-hns3-fix-link-status-change-from-firmware.patch -Patch34: 0035-net-hns3-fix-RSS-indirection-table-size.patch -Patch35: 0036-net-hns3-constrain-TM-peak-rate.patch -Patch36: 0037-net-hns3-remove-MPLS-from-supported-flow-items.patch -Patch37: 0038-net-hns3-fix-stats-flip-overflow.patch -Patch38: 0039-net-hns3-use-C11-atomics.patch -Patch39: 0040-net-hns3-fix-flow-director-rule-residue-on-malloc-fa.patch -Patch40: 0041-net-hns3-fix-firmware-exceptions-by-concurrent-comma.patch -Patch41: 0042-net-hns3-fix-VF-reset-on-mailbox-failure.patch -Patch42: 0043-net-hns3-validate-requested-maximum-Rx-frame-length.patch -Patch43: 0044-drivers-net-redefine-array-size-macros.patch -Patch44: 0045-net-hns3-support-module-EEPROM-dump.patch -Patch45: 0046-net-hns3-add-more-registers-to-dump.patch -Patch46: 0047-net-hns3-implement-Tx-mbuf-free-on-demand.patch -Patch47: 0048-net-hns3-add-bytes-stats.patch -Patch48: 0049-net-hns3-add-imissed-packet-stats.patch -Patch49: 0050-net-hns3-encapsulate-port-shaping-interface.patch -Patch50: 0051-net-hns3-fix-device-capabilities-for-copper-media-ty.patch -Patch51: 0052-net-hns3-support-PF-device-with-copper-PHYs.patch -Patch52: 0053-net-hns3-support-Rx-descriptor-advanced-layout.patch -Patch53: 0054-net-hns3-fix-HW-buffer-size-on-MTU-update.patch -Patch54: 0055-net-hns3-remove-unused-parameter-markers.patch -Patch55: 0056-net-hns3-fix-mbuf-leakage.patch -Patch56: 0057-net-hns3-process-MAC-interrupt.patch -Patch57: 0058-net-hns3-fix-imprecise-statistics.patch -Patch58: 0059-net-hns3-add-runtime-config-to-select-IO-burst-funct.patch -Patch59: 0060-net-hns3-support-outer-UDP-checksum.patch -Patch60: 0061-net-hns3-adjust-format-of-RAS-related-structures.patch -Patch61: 0062-net-hns3-delete-redundant-xstats-RAS-statistics.patch -Patch62: 0063-net-hns3-support-imissed-stats-for-PF-VF.patch -Patch63: 0064-net-hns3-support-oerrors-stats-in-PF.patch -Patch64: 0065-net-hns3-support-Tx-descriptor-status-query.patch -Patch65: 0066-net-hns3-support-Rx-descriptor-status-query.patch -Patch66: 0067-net-hns3-fix-reporting-undefined-speed.patch -Patch67: 0068-net-hns3-fix-build-for-SVE-path.patch -Patch68: 0069-net-hns3-fix-processing-Tx-offload-flags.patch -Patch69: 0070-net-hns3-fix-Tx-checksum-for-UDP-packets-with-specia.patch -Patch70: 0071-net-hns3-fix-link-update-when-failed-to-get-link-inf.patch -Patch71: 0072-net-hns3-fix-long-task-queue-pairs-reset-time.patch -Patch72: 0073-net-hns3-fix-MTU-config-complexity.patch -Patch73: 0074-net-hns3-support-IEEE-1588-PTP.patch -Patch74: 0075-ethdev-validate-input-in-register-info.patch -Patch75: 0076-net-hns3-support-wait-in-link-update.patch -Patch76: 0077-net-hns3-fix-some-function-names-for-copper-media-ty.patch -Patch77: 0078-net-hns3-fix-setting-default-MAC-address-in-bonding-.patch -Patch78: 0079-net-hns3-fix-FLR-miss-detection.patch -Patch79: 0080-net-hns3-fix-rollback-after-setting-PVID-failure.patch -Patch80: 0081-net-hns3-fix-flow-control-exception.patch -Patch81: 0082-net-hns3-fix-flow-counter-value.patch -Patch82: 0083-net-hns3-fix-VF-mailbox-head-field.patch -Patch83: 0084-net-hns3-support-get-device-version-when-dump-regist.patch -Patch84: 0085-net-hns3-delete-redundant-blank-line.patch -Patch85: 0086-net-hns3-fix-code-style.patch -Patch86: 0087-net-hns3-refactor-VF-LSC-event-report.patch -Patch87: 0088-net-hns3-refactor-PF-LSC-event-report.patch -Patch88: 0089-net-hns3-log-selected-datapath.patch -Patch89: 0090-net-hns3-simplify-selecting-Rx-Tx-function.patch -Patch90: 0091-net-hns3-fix-rollback-in-PF-init.patch -Patch91: 0092-net-hns3-fix-concurrent-interrupt-handling.patch -Patch92: 0093-net-hns3-fix-some-packet-types.patch -Patch93: 0094-net-hns3-fix-timing-in-resetting-queues.patch -Patch94: 0095-net-hns3-fix-queue-state-when-concurrent-with-reset.patch -Patch95: 0096-net-hns3-fix-configure-FEC-when-concurrent-with-rese.patch -Patch96: 0097-net-hns3-delete-mailbox-arq-ring.patch -Patch97: 0098-net-hns3-fix-possible-mismatched-response-of-mailbox.patch -Patch98: 0099-net-hns3-fix-VF-handling-LSC-event-in-secondary-proc.patch -Patch99: 0100-net-hns3-fix-timing-in-mailbox.patch -Patch100: 0101-net-hns3-fix-use-of-command-status-enumeration.patch -Patch101: 0102-net-hns3-fix-verification-of-NEON-support.patch -Patch102: 0103-net-hns3-fix-missing-outer-L4-UDP-flag-for-VXLAN.patch -Patch103: 0104-net-hns3-add-reporting-tunnel-GRE-packet-type.patch -Patch104: 0105-net-hns3-fix-PTP-capability-report.patch -Patch105: 0106-net-hns3-list-supported-ptypes-for-advanced-Rx-descr.patch -Patch106: 0107-net-hns3-remove-VLAN-QinQ-ptypes-from-support-list.patch -Patch107: 0108-net-hns3-fix-supported-speed-of-copper-ports.patch -Patch108: 0109-net-hns3-add-1000M-speed-bit-for-copper-PHYs.patch -Patch109: 0110-net-hns3-fix-flow-control-mode.patch -Patch110: 0111-net-hns3-fix-firmware-compatibility-configuration.patch -Patch111: 0112-net-hns3-obtain-supported-speed-for-fiber-port.patch -Patch112: 0113-net-hns3-report-speed-capability-for-PF.patch -Patch113: 0114-net-hns3-support-link-speed-autoneg-for-PF.patch -Patch114: 0115-net-hns3-support-flow-control-autoneg-for-copper-por.patch -Patch115: 0116-net-hns3-support-fixed-link-speed.patch -Patch116: 0117-net-hns3-rename-Rx-burst-function.patch -Patch117: 0118-net-hns3-remove-unused-macros.patch -Patch118: 0119-net-hns3-support-RAS-process-in-Kunpeng-930.patch -Patch119: 0120-net-hns3-support-masking-device-capability.patch -Patch120: 0121-net-hns3-simplify-Rx-checksum.patch -Patch121: 0122-net-hns3-check-max-SIMD-bitwidth.patch -Patch122: 0123-net-hns3-add-compile-time-verification-on-Rx-vector.patch -Patch123: 0124-net-hns3-remove-redundant-mailbox-response.patch -Patch124: 0125-net-hns3-fix-DCB-mode-check.patch -Patch125: 0126-net-hns3-fix-VMDq-mode-check.patch -Patch126: 0127-net-hns3-fix-flow-director-lock.patch -Patch127: 0128-net-hns3-move-link-speeds-check-to-configure.patch -Patch128: 0129-net-hns3-remove-unused-macro.patch -Patch129: 0130-net-hns3-fix-traffic-management-support-check.patch -Patch130: 0131-net-hns3-ignore-devargs-parsing-return.patch -Patch131: 0132-net-hns3-fix-mailbox-error-message.patch -Patch132: 0133-net-hns3-fix-processing-link-status-message-on-PF.patch -Patch133: 0134-net-hns3-remove-unused-mailbox-macro-and-struct.patch -Patch134: 0135-net-hns3-fix-typos-on-comments.patch -Patch135: 0136-net-hns3-disable-MAC-status-report-interrupt.patch -Patch136: 0137-net-hns3-fix-handling-link-update.patch -Patch137: 0138-net-hns3-fix-link-status-when-port-is-stopped.patch -Patch138: 0139-net-hns3-fix-link-speed-when-port-is-down.patch -Patch139: 0140-net-hns3-support-preferred-burst-size-and-queues-in-.patch -Patch140: 0141-net-hns3-log-time-delta-in-decimal-format.patch -Patch141: 0142-net-hns3-fix-time-delta-calculation.patch -Patch142: 0143-net-hns3-select-Tx-prepare-based-on-Tx-offload.patch -Patch143: 0144-net-hns3-fix-MAC-enable-failure-rollback.patch -Patch144: 0145-net-hns3-fix-IEEE-1588-PTP-for-scalar-scattered-Rx.patch -Patch145: 0146-net-hns3-remove-some-unused-capabilities.patch -Patch146: 0147-net-hns3-refactor-optimised-register-write.patch -Patch147: 0148-net-hns3-use-existing-macro-to-get-array-size.patch -Patch148: 0149-net-hns3-improve-IO-path-data-cache-usage.patch -Patch149: 0150-net-hns3-log-flow-director-configuration.patch -Patch150: 0151-net-hns3-fix-vector-Rx-burst-limitation.patch -Patch151: 0152-net-hns3-remove-read-when-enabling-TM-QCN-error-even.patch -Patch152: 0153-net-hns3-remove-unused-VMDq-code.patch -Patch153: 0154-net-hns3-increase-readability-in-logs.patch -Patch154: 0155-net-hns3-fix-debug-build.patch -Patch155: 0156-net-hns3-return-error-on-PCI-config-write-failure.patch -Patch156: 0157-net-hns3-fix-log-on-flow-director-clear.patch -Patch157: 0158-net-hns3-clear-hash-map-on-flow-director-clear.patch -Patch158: 0159-net-hns3-fix-VF-alive-notification-after-config-rest.patch -Patch159: 0160-net-hns3-fix-querying-flow-director-counter-for-out-.patch -Patch160: 0161-net-hns3-fix-TM-QCN-error-event-report-by-MSI-X.patch -Patch161: 0162-net-hns3-fix-mailbox-message-ID-in-log.patch -Patch162: 0163-net-hns3-fix-secondary-process-request-start-stop-Rx.patch -Patch163: 0164-net-hns3-fix-ordering-in-secondary-process-initializ.patch -Patch164: 0165-net-hns3-fail-setting-FEC-if-one-bit-mode-is-not-sup.patch -Patch165: 0166-net-hns3-fix-Rx-Tx-queue-numbers-check.patch -Patch166: 0167-net-hns3-fix-requested-FC-mode-rollback.patch -Patch167: 0168-net-hns3-remove-meaningless-packet-buffer-rollback.patch -Patch168: 0169-net-hns3-fix-DCB-configuration.patch -Patch169: 0170-net-hns3-fix-DCB-reconfiguration.patch -Patch170: 0171-net-hns3-fix-link-speed-when-VF-device-is-down.patch -Patch171: 0172-net-bonding-fix-adding-itself-as-its-slave.patch -Patch172: 0173-ipc-use-monotonic-clock.patch -Patch173: 0174-ethdev-add-queue-state-in-queried-queue-information.patch -Patch174: 0175-app-testpmd-fix-queue-stats-mapping-configuration.patch -Patch175: 0176-app-testpmd-fix-bitmap-of-link-speeds-when-force-spe.patch -Patch176: 0177-app-testpmd-add-link-autoneg-status-display.patch -Patch177: 0178-app-testpmd-support-cleanup-Tx-queue-mbufs.patch -Patch178: 0179-app-testpmd-show-link-flow-control-info.patch -Patch179: 0180-app-testpmd-support-display-queue-state.patch -Patch180: 0181-app-testpmd-fix-max-queue-number-for-Tx-offloads.patch -Patch181: 0182-app-testpmd-fix-forward-lcores-number-for-DCB.patch -Patch182: 0183-app-testpmd-fix-DCB-forwarding-configuration.patch -Patch183: 0184-app-testpmd-fix-DCB-re-configuration.patch -Patch184: 0185-app-testpmd-check-DCB-info-support-for-configuration.patch -Patch185: 0186-app-testpmd-verify-DCB-config-during-forward-config.patch -Patch186: 0187-app-testpmd-add-forwarding-configuration-to-DCB-conf.patch -Patch187: 0188-app-testpmd-remove-redundant-forwarding-initializati.patch -Patch188: 0189-net-fix-compiling-bug-for-20.11-merge.patch -Patch189: 0189-config-arm-check-SVE-CPU-flag.patch -Patch190: 0190-net-hns3-increase-VF-reset-retry-maximum.patch -Patch191: 0191-net-hns3-fix-delay-for-waiting-to-stop-Rx-Tx.patch -Patch192: 0192-net-hns3-fix-fake-queue-rollback.patch -Patch193: 0193-net-hns3-fix-VLAN-strip-log.patch -Patch194: 0194-net-hns3-fix-maximum-queues-on-configuration-failure.patch -Patch195: 0195-net-hns3-remove-unnecessary-blank-lines.patch -Patch196: 0196-net-hns3-support-Tx-push-quick-doorbell-for-performa.patch -Patch197: 0197-net-hns3-fix-traffic-management.patch -Patch198: 0198-config-arm-fix-SVE-build-with-GCC-8.3.patch -Patch199: 0199-net-hns3-fix-Arm-SVE-build-with-GCC-8.3.patch -Patch200: 0200-net-hns3-query-basic-info-for-VF.patch -Patch201: 0201-net-hns3-support-VLAN-filter-state-modify-for-VF.patch -Patch202: 0202-net-hns3-support-multiple-TC-MAC-pause.patch -Patch203: 0203-net-hns3-fix-residual-MAC-address-entry.patch -Patch204: 0204-net-hns3-remove-unnecessary-zero-assignments.patch -Patch205: 0205-net-hns3-fix-filter-parsing-comment.patch -Patch206: 0206-net-hns3-fix-timing-of-clearing-interrupt-source.patch -Patch207: 0207-net-hns3-remove-duplicate-compile-time-check.patch -Patch208: 0208-net-hns3-move-speed-auto-negotiation-warning.patch -Patch209: 0209-net-hns3-fix-flow-rule-list-in-multi-process.patch -Patch210: 0210-net-hns3-fix-Tx-prepare-after-stop.patch -Patch211: 0211-net-hns3-disable-PFC-if-not-configured.patch -Patch212: 0212-net-hns3-use-the-correct-HiSilicon-copyright.patch -Patch213: 0213-app-testpmd-change-port-link-speed-without-stopping-.patch -Patch214: 0214-ethdev-add-dev-configured-flag.patch -Patch215: 0215-net-hns3-add-start-stop-Tx-datapath-request-for-MP.patch -Patch216: 0216-net-hns3-support-set-link-up-down-for-PF.patch -Patch217: 0217-net-hns3-fix-queue-flow-action-validation.patch -Patch218: 0218-net-hns3-fix-taskqueue-pair-reset-command.patch -Patch219: 0219-net-hns3-fix-Tx-push-capability.patch -Patch220: 0220-examples-kni-close-port-before-exit.patch -Patch221: 0221-net-hns3-fix-residual-MAC-after-setting-default-MAC.patch -Patch222: 0222-net-hns3-fix-input-parameters-of-MAC-functions.patch -Patch223: 0223-net-bonding-fix-dedicated-queue-mode-in-vector-burst.patch -Patch224: 0224-net-bonding-fix-RSS-key-length.patch -Patch225: 0225-app-testpmd-add-command-to-show-LACP-bonding-info.patch -Patch226: 0226-app-testpmd-retain-all-original-dev-conf-when-config.patch -Patch227: 0227-net-hns3-remove-similar-macro-function-definitions.patch -Patch228: 0228-net-hns3-fix-interrupt-vector-freeing.patch -Patch229: 0229-net-hns3-add-runtime-config-for-mailbox-limit-time.patch -Patch230: 0230-net-hns3-fix-mailbox-communication-with-HW.patch -Patch231: 0231-app-testpmd-support-multi-process.patch -Patch232: 0232-app-testpmd-fix-key-for-RSS-flow-rule.patch -Patch233: 0233-app-testpmd-release-flows-left-before-port-stop.patch -Patch234: 0234-app-testpmd-delete-unused-function.patch -Patch235: 0235-dmadev-introduce-DMA-device-support.patch -Patch236: 0236-net-hns3-rename-multicast-address-function.patch -Patch237: 0237-net-hns3-rename-unicast-address-function.patch -Patch238: 0238-net-hns3-rename-multicast-address-removal-function.patch -Patch239: 0239-net-hns3-extract-common-interface-to-check-duplicate.patch -Patch240: 0240-net-hns3-remove-redundant-multicast-MAC-interface.patch -Patch241: 0241-net-hns3-rename-unicast-address-removal-function.patch -Patch242: 0242-net-hns3-remove-redundant-multicast-removal-interfac.patch -Patch243: 0243-net-hns3-add-HW-ops-structure-to-operate-hardware.patch -Patch244: 0244-net-hns3-use-HW-ops-to-config-MAC-features.patch -Patch245: 0245-net-hns3-unify-MAC-and-multicast-address-configurati.patch -Patch246: 0246-net-hns3-unify-MAC-address-add-and-remove.patch -Patch247: 0247-net-hns3-unify-multicast-address-check.patch -Patch248: 0248-net-hns3-refactor-multicast-MAC-address-set-for-PF.patch -Patch249: 0249-net-hns3-unify-multicast-MAC-address-set-list.patch -Patch250: 0250-bonding-show-Tx-policy-for-802.3AD-mode.patch -Patch251: 0251-net-hns3-fix-secondary-process-reference-count.patch -Patch252: 0252-net-hns3-fix-multi-process-action-register-and-unreg.patch -Patch253: 0253-net-hns3-unregister-MP-action-on-close-for-secondary.patch -Patch254: 0254-net-hns3-refactor-multi-process-initialization.patch -Patch255: 0255-usertools-devbind-add-Kunpeng-DMA.patch -Patch256: 0256-kni-check-error-code-of-allmulticast-mode-switch.patch -Patch257: 0257-net-hns3-simplify-queue-DMA-address-arithmetic.patch -Patch258: 0258-net-hns3-remove-redundant-function-declaration.patch -Patch259: 0259-net-hns3-modify-an-indent-alignment.patch -Patch260: 0260-net-hns3-use-unsigned-integer-for-bitwise-operations.patch -Patch261: 0261-net-hns3-extract-common-code-to-its-own-file.patch -Patch262: 0262-net-hns3-move-declarations-in-flow-header-file.patch -Patch263: 0263-net-hns3-remove-magic-numbers.patch -Patch264: 0264-net-hns3-mark-unchecked-return-of-snprintf.patch -Patch265: 0265-net-hns3-remove-PF-VF-duplicate-code.patch -Patch266: 0266-app-testpmd-remove-unused-header-file.patch -Patch267: 0267-usertools-add-Intel-DLB-device-binding.patch +Patch0: add-igb-uio.patch Summary: Data Plane Development Kit core Group: System Environment/Libraries @@ -288,7 +21,7 @@ ExclusiveArch: i686 x86_64 aarch64 %global target x86_64-%{machine}-linux-gcc %endif -BuildRequires: meson ninja-build gcc +BuildRequires: meson ninja-build gcc diffutils python3-pyelftools python-pyelftools BuildRequires: kernel-devel numactl-devel BuildRequires: libpcap libpcap-devel BuildRequires: uname-build-checks @@ -347,7 +80,9 @@ cd - mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d echo "%{_bindir}/%{name}" > $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf echo "/usr/local/bin/%{name}" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf -echo "lib64/%{name}" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf +echo "/lib64/%{name}" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf +echo "/usr/local/lib64" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf +echo "/usr/local/include" >> $RPM_BUILD_ROOT/etc/ld.so.conf.d/%{name}-%{_arch}.conf mkdir -p $RPM_BUILD_ROOT/usr/share/dpdk/%{target} ln -fs %{buildroot}/usr/local/include %{buildroot}/usr/share/dpdk/%{target}/include ln -fs %{buildroot}/usr/local/lib64 %{buildroot}/usr/share/dpdk/%{target}/lib @@ -375,10 +110,10 @@ mkdir -p $RPM_BUILD_ROOT/usr/bin cp ./%{target}/app/dpdk-pdump $RPM_BUILD_ROOT/usr/bin strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko +strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/igb_uio.ko %define _unpackaged_files_terminate_build 0 - - +%define _build_id_links none %files /usr/local/bin/*.py @@ -386,17 +121,19 @@ strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko /lib64/librte*.so* %{_sbindir}/dpdk-devbind %config(noreplace) /etc/ld.so.conf.d/* +/usr/local/lib64/* +%exclude /usr/local/lib64/*.a +/usr/local/bin/* +%exclude /usr/local/bin/dpdk-test* +%exclude /usr/local/bin/dpdk-pdump %files devel %dir /usr/local/include/ /usr/local/include/*.h /usr/local/include/generic/*.h /usr/local/share/dpdk/examples/* -/usr/local/lib64/* -/usr/local/bin/* -%dir /usr/share/dpdk/%{target}/ /usr/share/dpdk/%{target}/include/* -/usr/share/dpdk/%{target}/lib/* +/usr/local/lib64/*.a %files doc @@ -412,8 +149,12 @@ strip -g $RPM_BUILD_ROOT/lib/modules/${namer}/extra/dpdk/rte_kni.ko /usr/sbin/depmod %changelog +* Fri Dec 17 2021 jiangheng - 21.11-1 +- update to 21.11 + * Sat Dec 17 2021 Min Hu - 20.11-10 - sync patches ranges from versoin 9 t0 17 from master branch + * Mon Sep 13 2021 chenchen - 20.11-9 - del rpath from some binaries and bin - add debug package to strip