From: Juan Zhou zhoujuan51@h-partners.com
The first two patches support more netdev speed, the third adds check for resource values and adjusts the invalid ones, and last patch renames the RoCE interrupts.
Chengchang Tang (2): RDMA/hns: Fix port active speed RDMA/hns: Rename the interrupts
Haoyue Xu (1): RDMA/core:Add support more netdev speed
Junxian Huang (1): RDMA/hns: Add check and adjust for function resource values
drivers/infiniband/core/verbs.c | 13 ++- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 123 +++++++++++++++++++-- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 37 +++++++ drivers/infiniband/hw/hns/hns_roce_main.c | 7 +- 4 files changed, 168 insertions(+), 12 deletions(-)
From: Haoyue Xu xuhaoyue1@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8HZAQ
--------------------------------------------------------------------------
Add support for 100G and 200G speed display in RDMA.
Signed-off-by: Haoyue Xu xuhaoyue1@hisilicon.com Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/core/verbs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index 4fcabe5a84be..d1220dae586b 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -1822,8 +1822,9 @@ int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u16 *speed, u8 *width) netdev_speed = lksettings.base.speed; } else { netdev_speed = SPEED_1000; - pr_warn("%s speed is unknown, defaulting to %d\n", netdev->name, - netdev_speed); + if (rc) + pr_warn("%s speed is unknown, defaulting to %d\n", + netdev->name, netdev_speed); }
if (netdev_speed <= SPEED_1000) { @@ -1841,9 +1842,15 @@ int ib_get_eth_speed(struct ib_device *dev, u8 port_num, u16 *speed, u8 *width) } else if (netdev_speed <= SPEED_40000) { *width = IB_WIDTH_4X; *speed = IB_SPEED_FDR10; - } else { + } else if (netdev_speed <= SPEED_100000) { *width = IB_WIDTH_4X; *speed = IB_SPEED_EDR; + } else if (netdev_speed <= SPEED_200000) { + *width = IB_WIDTH_4X; + *speed = IB_SPEED_HDR; + } else { + *width = IB_WIDTH_4X; + *speed = IB_SPEED_NDR; }
return 0;
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8HZAQ
--------------------------------------------------------------------------
HW supports a variety of different speed, but the current speed is fixed.
The real speed should be queried from ethernet.
Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver") Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 9881e84782bd..83ecff014924 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -318,6 +318,7 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num, unsigned long flags; enum ib_mtu mtu; u8 port; + int ret;
port = port_num - 1;
@@ -330,8 +331,10 @@ static int hns_roce_query_port(struct ib_device *ib_dev, u8 port_num, IB_PORT_BOOT_MGMT_SUP; props->max_msg_sz = HNS_ROCE_MAX_MSG_LEN; props->pkey_tbl_len = 1; - props->active_width = IB_WIDTH_4X; - props->active_speed = 1; + ret = ib_get_eth_speed(ib_dev, port_num, &props->active_speed, + &props->active_width); + if (ret) + ibdev_warn(ib_dev, "failed to get speed, ret = %d.\n", ret);
spin_lock_irqsave(&hr_dev->iboe.lock, flags);
From: Junxian Huang huangjunxian6@hisilicon.com
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8H7RB
--------------------------------------------------------------------------
Currently, RoCE driver gets function resource values from firmware without validity check. As these resources are mostly related to memory, an invalid value may lead to serious consequence such as kernel panic.
This patch adds check for these resource values and adjusts the invalid ones.
Fixes: 74e1531c3e24 ("RDMA/hns: Reserve the resource for the VFs") Signed-off-by: Junxian Huang huangjunxian6@hisilicon.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 116 ++++++++++++++++++++- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 37 +++++++ 2 files changed, 149 insertions(+), 4 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 183e9eea5f61..26b49f4f06b9 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -1901,6 +1901,98 @@ static int hns_roce_config_global_param(struct hns_roce_dev *hr_dev) return hns_roce_cmq_send(hr_dev, &desc, 1); }
+static const struct hns_roce_bt_num { + u32 res_offset; + u32 min; + u32 max; + enum hns_roce_res_invalid_flag invalid_flag; + enum hns_roce_res_revision revision; + bool vf_support; +} bt_num_table[] = { + {RES_OFFSET_IN_CAPS(qpc_bt_num), 1, + MAX_QPC_BT_NUM, QPC_BT_NUM_INVALID_FLAG, RES_FOR_ALL, true}, + {RES_OFFSET_IN_CAPS(srqc_bt_num), 1, + MAX_SRQC_BT_NUM, SRQC_BT_NUM_INVALID_FLAG, RES_FOR_ALL, true}, + {RES_OFFSET_IN_CAPS(cqc_bt_num), 1, + MAX_CQC_BT_NUM, CQC_BT_NUM_INVALID_FLAG, RES_FOR_ALL, true}, + {RES_OFFSET_IN_CAPS(mpt_bt_num), 1, + MAX_MPT_BT_NUM, MPT_BT_NUM_INVALID_FLAG, RES_FOR_ALL, true}, + {RES_OFFSET_IN_CAPS(sl_num), 1, + MAX_SL_NUM, QID_NUM_INVALID_FLAG, RES_FOR_ALL, true}, + {RES_OFFSET_IN_CAPS(sccc_bt_num), 1, + MAX_SCCC_BT_NUM, SCCC_BT_NUM_INVALID_FLAG, RES_FOR_ALL, true}, + {RES_OFFSET_IN_CAPS(qpc_timer_bt_num), 1, + MAX_QPC_TIMER_BT_NUM, QPC_TIMER_BT_NUM_INVALID_FLAG, + RES_FOR_ALL, false}, + {RES_OFFSET_IN_CAPS(cqc_timer_bt_num), 1, + MAX_CQC_TIMER_BT_NUM, CQC_TIMER_BT_NUM_INVALID_FLAG, + RES_FOR_ALL, false}, + {RES_OFFSET_IN_CAPS(gmv_bt_num), 1, + MAX_GMV_BT_NUM, GMV_BT_NUM_INVALID_FLAG, + RES_FOR_HIP09, true}, + {RES_OFFSET_IN_CAPS(smac_bt_num), 1, + MAX_SMAC_BT_NUM, SMAC_BT_NUM_INVALID_FLAG, + RES_FOR_HIP08, true}, + {RES_OFFSET_IN_CAPS(sgid_bt_num), 1, + MAX_SGID_BT_NUM, SGID_BT_NUM_INVALID_FLAG, + RES_FOR_HIP08, true}, +}; + +static inline bool check_res_is_supported(struct hns_roce_dev *hr_dev, + const struct hns_roce_bt_num *bt_num_entry) +{ + if (!bt_num_entry->vf_support && hr_dev->is_vf) + return false; + + if (bt_num_entry->revision == RES_FOR_HIP09 && + hr_dev->pci_dev->revision <= PCI_REVISION_ID_HIP08) + return false; + + if (bt_num_entry->revision == RES_FOR_HIP08 && + hr_dev->pci_dev->revision >= PCI_REVISION_ID_HIP09) + return false; + + return true; +} + +static inline void adjust_eqc_bt_num(struct hns_roce_caps *caps, + u16 *invalid_flag) +{ + if (caps->eqc_bt_num < caps->num_comp_vectors + caps->num_aeq_vectors || + caps->eqc_bt_num > MAX_EQC_BT_NUM) { + caps->eqc_bt_num = caps->eqc_bt_num > MAX_EQC_BT_NUM ? + MAX_EQC_BT_NUM : caps->num_comp_vectors + + caps->num_aeq_vectors; + *invalid_flag |= 1 << EQC_BT_NUM_INVALID_FLAG; + } +} + +static u16 adjust_res_caps(struct hns_roce_dev *hr_dev) +{ + struct hns_roce_caps *caps = &hr_dev->caps; + u16 invalid_flag = 0; + u32 min, max; + u32 *res; + int i; + + for (i = 0; i < ARRAY_SIZE(bt_num_table); i++) { + if (!check_res_is_supported(hr_dev, &bt_num_table[i])) + continue; + + res = (u32 *)((void *)caps + bt_num_table[i].res_offset); + min = bt_num_table[i].min; + max = bt_num_table[i].max; + if (*res < min || *res > max) { + *res = *res < min ? min : max; + invalid_flag |= 1 << bt_num_table[i].invalid_flag; + } + } + + adjust_eqc_bt_num(caps, &invalid_flag); + + return invalid_flag; +} + static int load_func_res_caps(struct hns_roce_dev *hr_dev, bool is_vf) { struct hns_roce_cmq_desc desc[2]; @@ -1981,11 +2073,19 @@ static int hns_roce_query_pf_resource(struct hns_roce_dev *hr_dev) }
ret = load_pf_timer_res_caps(hr_dev); - if (ret) + if (ret) { dev_err(dev, "failed to load pf timer resource, ret = %d.\n", ret); + return ret; + }
- return ret; + ret = adjust_res_caps(hr_dev); + if (ret) + dev_warn(dev, + "invalid resource values have been adjusted, invalid_flag = 0x%x.\n", + ret); + + return 0; }
static int hns_roce_query_vf_resource(struct hns_roce_dev *hr_dev) @@ -1994,10 +2094,18 @@ static int hns_roce_query_vf_resource(struct hns_roce_dev *hr_dev) int ret;
ret = load_func_res_caps(hr_dev, true); - if (ret) + if (ret) { dev_err(dev, "failed to load vf res caps, ret = %d.\n", ret); + return ret; + }
- return ret; + ret = adjust_res_caps(hr_dev); + if (ret) + dev_warn(dev, + "invalid resource values have been adjusted, invalid_flag = 0x%x.\n", + ret); + + return 0; }
static int __hns_roce_set_vf_switch_param(struct hns_roce_dev *hr_dev, diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h index 01a70ea86af1..7cdad3d04022 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h @@ -1028,6 +1028,43 @@ struct hns_roce_func_clear { #define CFG_GLOBAL_PARAM_1US_CYCLES CMQ_REQ_FIELD_LOC(9, 0) #define CFG_GLOBAL_PARAM_UDP_PORT CMQ_REQ_FIELD_LOC(31, 16)
+enum hns_roce_res_invalid_flag { + QPC_BT_NUM_INVALID_FLAG, + SRQC_BT_NUM_INVALID_FLAG, + CQC_BT_NUM_INVALID_FLAG, + MPT_BT_NUM_INVALID_FLAG, + EQC_BT_NUM_INVALID_FLAG, + SMAC_BT_NUM_INVALID_FLAG, + SGID_BT_NUM_INVALID_FLAG, + QID_NUM_INVALID_FLAG, + SCCC_BT_NUM_INVALID_FLAG, + GMV_BT_NUM_INVALID_FLAG, + QPC_TIMER_BT_NUM_INVALID_FLAG, + CQC_TIMER_BT_NUM_INVALID_FLAG, +}; + +enum hns_roce_res_revision { + RES_FOR_HIP08, + RES_FOR_HIP09, + RES_FOR_ALL, +}; + +#define RES_OFFSET_IN_CAPS(res) \ + (offsetof(struct hns_roce_caps, res)) + +#define MAX_QPC_BT_NUM 2048 +#define MAX_SRQC_BT_NUM 512 +#define MAX_CQC_BT_NUM 512 +#define MAX_MPT_BT_NUM 512 +#define MAX_EQC_BT_NUM 512 +#define MAX_SMAC_BT_NUM 256 +#define MAX_SGID_BT_NUM 256 +#define MAX_SL_NUM 8 +#define MAX_SCCC_BT_NUM 512 +#define MAX_GMV_BT_NUM 256 +#define MAX_QPC_TIMER_BT_NUM 1728 +#define MAX_CQC_TIMER_BT_NUM 1600 + /* * Fields of HNS_ROCE_OPC_QUERY_PF_RES, HNS_ROCE_OPC_QUERY_VF_RES * and HNS_ROCE_OPC_ALLOC_VF_RES
driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8LM94
--------------------------------------------------------------------------
Now, different devices may have the same interrupt name, which makes it difficult for users to distinguish between these interrupts.
Modify the naming style to be consistent with our network devices. Before: "hns-aeq-0" "hns-ceq-0" ...
Now: "hns-0000:35:00.0-aeq-0" "hns-0000:35:00.0-ceq-0" ...
Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 26b49f4f06b9..ee0c4dcfad68 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -7151,15 +7151,16 @@ static int __hns_roce_request_irq(struct hns_roce_dev *hr_dev, int irq_num, /* irq contains: abnormal + AEQ + CEQ */ for (j = 0; j < other_num; j++) snprintf((char *)hr_dev->irq_names[j], HNS_ROCE_INT_NAME_LEN, - "hns-abn-%d", j); + "hns-%s-abn-%d", pci_name(hr_dev->pci_dev), j);
for (j = other_num; j < (other_num + aeq_num); j++) snprintf((char *)hr_dev->irq_names[j], HNS_ROCE_INT_NAME_LEN, - "hns-aeq-%d", j - other_num); + "hns-%s-aeq-%d", pci_name(hr_dev->pci_dev), j - other_num);
for (j = (other_num + aeq_num); j < irq_num; j++) snprintf((char *)hr_dev->irq_names[j], HNS_ROCE_INT_NAME_LEN, - "hns-ceq-%d", j - other_num - aeq_num); + "hns-%s-ceq-%d", pci_name(hr_dev->pci_dev), + j - other_num - aeq_num);
for (j = 0; j < irq_num; j++) { if (j < other_num)