From: Chiqijun chiqijun@huawei.com
driver inclusion category: feature bugzilla: 4472
-----------------------------------------------------------------------
Add support for X86 Arch. Add the best default interrupt aggregation parameter and LRO parameter on x86 platform.
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Zengweiliang zengweiliang.zengweiliang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/huawei/Kconfig | 1 - drivers/net/ethernet/huawei/hinic/hinic_hwif.c | 10 ++++++++++ drivers/net/ethernet/huawei/hinic/hinic_hwif.h | 4 ++++ drivers/net/ethernet/huawei/hinic/hinic_lld.c | 17 ++++++++++++++++- drivers/net/ethernet/huawei/hinic/hinic_main.c | 6 ++++++ .../net/ethernet/huawei/hinic/hinic_nic_cfg.h | 14 ++++++++++++++ 6 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/huawei/Kconfig b/drivers/net/ethernet/huawei/Kconfig index dc48e5163531..c1a95ae4058b 100644 --- a/drivers/net/ethernet/huawei/Kconfig +++ b/drivers/net/ethernet/huawei/Kconfig @@ -5,7 +5,6 @@ config NET_VENDOR_HUAWEI bool "Huawei devices" default y - depends on ARM64 ---help--- If you have a network (Ethernet) card belonging to this class, say Y. Note that the answer to this question doesn't directly affect the diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hwif.c b/drivers/net/ethernet/huawei/hinic/hinic_hwif.c index 1fc0fa57f313..b267084d3672 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hwif.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hwif.c @@ -368,7 +368,12 @@ void hinic_free_db_addr(void *hwdev, void __iomem *db_base, hwif = ((struct hinic_hwdev *)hwdev)->hwif; idx = DB_IDX(db_base, hwif->db_base);
+#if defined(__aarch64__) /* No need to unmap */ +#else + if (dwqe_base && hwif->chip_mode == CHIP_MODE_NORMAL) + io_mapping_unmap(dwqe_base); +#endif
free_db_idx(hwif, idx); } @@ -398,7 +403,12 @@ int hinic_alloc_db_addr(void *hwdev, void __iomem **db_base,
offset = ((u64)idx) << PAGE_SHIFT;
+#if defined(__aarch64__) *dwqe_base = hwif->dwqe_mapping + offset; +#else + *dwqe_base = io_mapping_map_wc(hwif->dwqe_mapping, offset, + HINIC_DB_PAGE_SIZE); +#endif
if (!(*dwqe_base)) { hinic_free_db_addr(hwdev, *db_base, NULL); diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hwif.h b/drivers/net/ethernet/huawei/hinic/hinic_hwif.h index 9cd2ad8c5962..3a58a44b6bfe 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hwif.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_hwif.h @@ -58,7 +58,11 @@ struct hinic_hwif { u64 db_base_phy; u8 __iomem *db_base;
+#if defined(__aarch64__) void __iomem *dwqe_mapping; +#else + struct io_mapping *dwqe_mapping; +#endif struct hinic_free_db_area free_db_area;
struct hinic_func_attr attr; diff --git a/drivers/net/ethernet/huawei/hinic/hinic_lld.c b/drivers/net/ethernet/huawei/hinic/hinic_lld.c index 2ad6d2d23207..20e3b0bde8ef 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_lld.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_lld.c @@ -114,7 +114,11 @@ struct hinic_pcidev { u64 db_base_phy; void __iomem *db_base;
+#if defined(__aarch64__) void __iomem *dwqe_mapping; +#else + struct io_mapping *dwqe_mapping; +#endif /* lock for attach/detach uld */ struct mutex pdev_mutex; struct hinic_sriov_info sriov_info; @@ -1874,9 +1878,15 @@ static int mapping_bar(struct pci_dev *pdev, struct hinic_pcidev *pci_adapter)
dwqe_addr = pci_adapter->db_base_phy + db_dwqe_size;
+#if defined(__aarch64__) /* arm do not support call ioremap_wc() */ pci_adapter->dwqe_mapping = __ioremap(dwqe_addr, db_dwqe_size, __pgprot(PROT_DEVICE_nGnRnE)); +#else + pci_adapter->dwqe_mapping = io_mapping_create_wc(dwqe_addr, + db_dwqe_size); + +#endif if (!pci_adapter->dwqe_mapping) { sdk_err(&pci_adapter->pcidev->dev, "Failed to io_mapping_create_wc\n"); goto mapping_dwqe_err; @@ -1898,8 +1908,13 @@ static int mapping_bar(struct pci_dev *pdev, struct hinic_pcidev *pci_adapter)
static void unmapping_bar(struct hinic_pcidev *pci_adapter) { - if (pci_adapter->chip_mode == CHIP_MODE_NORMAL) + if (pci_adapter->chip_mode == CHIP_MODE_NORMAL) { +#if defined(__aarch64__) iounmap(pci_adapter->dwqe_mapping); +#else + io_mapping_free(pci_adapter->dwqe_mapping); +#endif + }
iounmap(pci_adapter->db_base); iounmap(pci_adapter->intr_reg_base); diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c b/drivers/net/ethernet/huawei/hinic/hinic_main.c index dd67d903f739..d78a5e3678b1 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c @@ -2908,7 +2908,13 @@ static void adaptive_configuration_init(struct hinic_nic_dev *nic_dev)
nic_dev->env_info.os = HINIC_OS_HUAWEI;
+#if defined(__aarch64__) nic_dev->env_info.cpu = HINIC_CPU_ARM_GENERIC; +#elif defined(__x86_64__) + nic_dev->env_info.cpu = HINIC_CPU_X86_GENERIC; +#else + nic_dev->env_info.cpu = HINIC_CPU_UNKNOWN; +#endif
nic_info(&nic_dev->pdev->dev, "Board type %u, OS type %u, CPU type %u\n", diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h index e0979df6e209..243265072710 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h @@ -56,6 +56,7 @@ #define HINIC_LRO_RX_TIMER_DEFAULT_PG_10GE 10 #define HINIC_LRO_RX_TIMER_DEFAULT_PG_100GE 8
+#if defined(__aarch64__) #define HINIC_LOWEST_LATENCY 1 #define HINIC_RX_RATE_LOW 400000 #define HINIC_RX_COAL_TIME_LOW 20 @@ -67,6 +68,19 @@ #define HINIC_TX_RATE_THRESH 35000 #define HINIC_RX_RATE_LOW_VM 400000 #define HINIC_RX_PENDING_LIMIT_HIGH_VM 50 +#else +#define HINIC_LOWEST_LATENCY 1 +#define HINIC_RX_RATE_LOW 400000 +#define HINIC_RX_COAL_TIME_LOW 16 +#define HINIC_RX_PENDING_LIMIT_LOW 2 +#define HINIC_RX_RATE_HIGH 1000000 +#define HINIC_RX_COAL_TIME_HIGH 225 +#define HINIC_RX_PENDING_LIMIT_HIGH 8 +#define HINIC_RX_RATE_THRESH 50000 +#define HINIC_TX_RATE_THRESH 50000 +#define HINIC_RX_RATE_LOW_VM 100000 +#define HINIC_RX_PENDING_LIMIT_HIGH_VM 87 +#endif
enum hinic_board_type { HINIC_BOARD_UNKNOWN = 0,
From: Chiqijun chiqijun@huawei.com
driver inclusion category: feature bugzilla: 4472
-----------------------------------------------------------------------
The previous hinic driver supports up to 64 queues, and the 1822 card provides a template for configuring 128 queues, so the driver needs to support 128 queues.
Signed-off-by: Chiqijun chiqijun@huawei.com Reviewed-by: Zengweiliang zengweiliang.zengweiliang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/huawei/hinic/hinic_cfg.h | 2 +- .../huawei/hinic/hinic_mgmt_interface.h | 2 +- .../net/ethernet/huawei/hinic/hinic_nic_cfg.c | 4 +- .../net/ethernet/huawei/hinic/hinic_nic_cfg.h | 2 +- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 57 +------------------ drivers/net/ethernet/huawei/hinic/hinic_wq.c | 2 +- 6 files changed, 8 insertions(+), 61 deletions(-)
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_cfg.h b/drivers/net/ethernet/huawei/hinic/hinic_cfg.h index 212a9946137c..28b9c0c4b93e 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_cfg.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_cfg.h @@ -55,7 +55,7 @@ enum { #define L2NIC_SQ_DEPTH (4 * K_UNIT) #define L2NIC_RQ_DEPTH (4 * K_UNIT)
-#define HINIC_CFG_MAX_QP 64 +#define HINIC_CFG_MAX_QP 128
/* RDMA */ #define RDMA_RSVD_QPS 2 diff --git a/drivers/net/ethernet/huawei/hinic/hinic_mgmt_interface.h b/drivers/net/ethernet/huawei/hinic/hinic_mgmt_interface.h index 8673cf545266..700642469732 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_mgmt_interface.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_mgmt_interface.h @@ -462,7 +462,7 @@ struct hinic_set_rq_iq_mapping {
u16 func_id; u16 rsvd1; - u8 map[HINIC_MAX_NUM_RQ]; + u8 map[64]; u32 num_rqs; u32 rq_depth; }; diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c index 7dfedbd01eed..fb94588daa30 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.c @@ -1444,7 +1444,7 @@ int hinic_dcb_set_rq_iq_mapping(void *hwdev, u32 num_rqs, u8 *map) u16 out_size = sizeof(rq_iq_mapping); int err;
- if (!hwdev || !map || num_rqs > HINIC_MAX_NUM_RQ) + if (!hwdev || num_rqs > HINIC_MAX_NUM_RQ) return -EINVAL;
dev = hwdev; @@ -1459,8 +1459,6 @@ int hinic_dcb_set_rq_iq_mapping(void *hwdev, u32 num_rqs, u8 *map) rq_iq_mapping.num_rqs = num_rqs; rq_iq_mapping.rq_depth = (u16)ilog2(nic_io->rq_depth);
- memcpy(rq_iq_mapping.map, map, num_rqs); - err = l2nic_msg_to_mgmt_sync(hwdev, HINIC_PORT_CMD_SET_RQ_IQ_MAP, &rq_iq_mapping, sizeof(rq_iq_mapping), &rq_iq_mapping, &out_size); diff --git a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h index 243265072710..3d98c5a7246c 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_nic_cfg.h @@ -36,7 +36,7 @@
#define HINIC_RSS_KEY_SIZE 40
-#define HINIC_MAX_NUM_RQ 64 +#define HINIC_MAX_NUM_RQ 128
#define HINIC_MIN_MTU_SIZE 256 #define HINIC_MAX_JUMBO_FRAME_SIZE 9600 diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c index 8494e2128a54..c8cbcdfd5883 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c @@ -1016,51 +1016,6 @@ static void hinic_rss_deinit(struct hinic_nic_dev *nic_dev) hinic_rss_cfg(nic_dev->hwdev, 0, nic_dev->rss_tmpl_idx, 0, prio_tc); }
-/* In rx, iq means cos */ -static u8 hinic_get_iqmap_by_tc(u8 *prio_tc, u8 num_iq, u8 tc) -{ - u8 i, map = 0; - - for (i = 0; i < num_iq; i++) { - if (prio_tc[i] == tc) - map |= (u8)(1U << ((num_iq - 1) - i)); - } - - return map; -} - -static u8 hinic_get_tcid_by_rq(u32 *indir_tbl, u8 num_tcs, u16 rq_id) -{ - u16 tc_group_size; - int i; - - tc_group_size = HINIC_RSS_INDIR_SIZE / num_tcs; - for (i = 0; i < HINIC_RSS_INDIR_SIZE; i++) { - if (indir_tbl[i] == rq_id) - return (u8)(i / tc_group_size); - } - - return 0xFF; /* Invalid TC */ -} - -#define HINIC_NUM_IQ_PER_FUNC 8 -static void hinic_get_rq2iq_map(struct hinic_nic_dev *nic_dev, - u16 num_rq, u8 num_tcs, u8 *prio_tc, - u32 *indir_tbl, u8 *map) -{ - u16 qid; - u8 tc_id; - - if (!num_tcs) - num_tcs = 1; - - for (qid = 0; qid < num_rq; qid++) { - tc_id = hinic_get_tcid_by_rq(indir_tbl, num_tcs, qid); - map[qid] = hinic_get_iqmap_by_tc(prio_tc, - HINIC_NUM_IQ_PER_FUNC, tc_id); - } -} - int hinic_set_hw_rss_parameters(struct net_device *netdev, u8 rss_en, u8 num_tc, u8 *prio_tc) { @@ -1125,7 +1080,7 @@ int hinic_set_hw_rss_parameters(struct net_device *netdev, u8 rss_en, u8 num_tc, return err; }
-static int hinic_rss_init(struct hinic_nic_dev *nic_dev, u8 *rq2iq_map) +static int hinic_rss_init(struct hinic_nic_dev *nic_dev) { struct net_device *netdev = nic_dev->netdev; u32 *indir_tbl; @@ -1162,9 +1117,6 @@ static int hinic_rss_init(struct hinic_nic_dev *nic_dev, u8 *rq2iq_map) return err; }
- hinic_get_rq2iq_map(nic_dev, nic_dev->num_qps, num_tc, - prio_tc, indir_tbl, rq2iq_map); - kfree(indir_tbl); return 0; } @@ -1181,13 +1133,10 @@ int hinic_update_hw_tc_map(struct net_device *netdev, u8 num_tc, u8 *prio_tc) int hinic_rx_configure(struct net_device *netdev) { struct hinic_nic_dev *nic_dev = netdev_priv(netdev); - u8 rq2iq_map[HINIC_MAX_NUM_RQ]; int err;
- /* Set all rq mapping to all iq in default */ - memset(rq2iq_map, 0xFF, sizeof(rq2iq_map)); if (test_bit(HINIC_RSS_ENABLE, &nic_dev->flags)) { - err = hinic_rss_init(nic_dev, rq2iq_map); + err = hinic_rss_init(nic_dev); if (err) { nicif_err(nic_dev, drv, netdev, "Failed to init rss\n"); return -EFAULT; @@ -1196,7 +1145,7 @@ int hinic_rx_configure(struct net_device *netdev)
err = hinic_dcb_set_rq_iq_mapping(nic_dev->hwdev, hinic_func_max_qnum(nic_dev->hwdev), - rq2iq_map); + NULL); if (err) { nicif_err(nic_dev, drv, netdev, "Failed to set rq_iq mapping\n"); goto set_rq_cos_mapping_err; diff --git a/drivers/net/ethernet/huawei/hinic/hinic_wq.c b/drivers/net/ethernet/huawei/hinic/hinic_wq.c index 06401a654629..4d8180c6b271 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_wq.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_wq.c @@ -32,7 +32,7 @@ #include "hinic_wq.h" #include "hinic_qe_def.h"
-#define WQS_MAX_NUM_BLOCKS 128 +#define WQS_MAX_NUM_BLOCKS 256 #define WQS_FREE_BLOCKS_SIZE(wqs) (WQS_MAX_NUM_BLOCKS * \ sizeof((wqs)->free_blocks[0]))