Bohong Lin (2): net: hns3: cae clear warnings net: hns3: change version to 1.9.35.0
Colin Ian King (1): net: hns3: make array spec_opcode static const, makes object smaller
Gao Xun (1): RDMA/hns:security review update
Greg Kroah-Hartman (1): net: hns3: no need to check return value of debugfs_create functions
Guangbin Huang (21): net: hns3: delete blank lines and space for cleanup net: hns: modify print function used in hclge_init_ae_dev() net: hns: remove unnecessary newline net: hns3: optimize code of hclge_init_kdump_kernel_config() function net: hns3: optimize local variable of hclge_set_loopback() function net: hns3: optimize code of hns3_parse_vlan_tag() function net: hns: replace goto with return in function hclge_set_vf_uc_mac_addr net: hns3: modify print format in hns3_set_ringpa() net: hns3: replace goto with return in function hns3_set_ringparam() net: hns3: modify code of hclge_mac_phy_link_status_wait() function net: hns3: add error process in hclge_mac_link_status_wait() function net: hns3: support query vf ring and vector map relation net: hns3: modify error process of hclge_phy_link_status_wait() net: hns3: move struct hclge_mdio_cfg_cmd declaration net: hns3: rename variable flag in hnae3_unregister_client() net: hns3: modify return value in hns3_dbg_cmd_write net: hns: replace space with tab for cleanup net: hns3: delete unnecessary judgement in hns3_get_stats() net: hns3: optimize parameter of hclge_phy_link_status_wait() function net: hns3: optimize parameter of hclge_set_phy_loopback() function net: hns3: modify timing of reading register in hclge_reset_wait()
Guojia Liao (6): net: hns3: opmitize the table entry restore when resetting net: hns3: delete some useless function and definication net: hns3: delete some useless repeated printing net: hns3: fix bug that PF set VF mac didn't work net: hns3: do not schedule the periodical task when reset fail net: hns3: fix port base vlan add fail when concurrent with reset
Huazhong Tan (10): net: hns3: sync some code from net-next part1 net: hns3: split hclge_reset() into preparing and rebuilding part net: hns3: split hclgevf_reset() into preparing and rebuilding part net: hns3: refactor the precedure of PF FLR net: hns3: enlarge HCLGE_RESET_WAIT_CNT net: hns3: modify hclge_func_reset_sync_vf()'s return type to void net: hns3: refactor the procedure of VF FLR net: hns3: refactor the notification scheme of PF reset net: hns3: modify the location of updating the hardware reset done counter net: hns3: set VF's default reset_type to HNAE3_NONE_RESET
Jian Shen (5): net: hns3: refine mac address configure for PF net: hns3: use mutex vport_lock intead of spin lock umv_lock net: hns3: refine mac address configure for VF net: hns3: refactor the promisc mode setting net: hns3: skip mac speed and duplex modification checking for fibre port support autoneg
Junxin Chen (5): net: fix bug and change version to 1.9.33.0 net: hns3: add protect for parameters and remove unused functions net: hns3: fix bug when parameter check net: hns3: fix compile error when CONFIG_HNS3_DCB is not set net: hns3: clear devil number for hns3_cae
Shengzui You (2): net: hns3: update hns3 version to 1.9.35.1 net: hns3: Remove the function of vf check mac address
Yonglong Liu (4): net: hns3: modify the irq name of tqp vectors net: hns3: modify the irq name of misc vectors net: hns3: add enabled tc numbers and dwrr weight info in debugfs net: hns3: fix missing help info for qs shaper in debugfs
Yu'an Wang (12): hac: sec: add initial configuration in sec_engine_init acc: Remove uacce mode 1 logic below hisilicon uacce: Remove uacce mode 1 relatives qm: fix wrong number of sg elements after dma map zip: use offset fields in sqe to avoid SG_SPLIT qm: remove invalid addr print hpre: optimize key process before free hpre: add likely and unlikey in result judgement sec: change sec_control reg config rde: optimize debug regs clear logic qm: fixup compilation dependency qm: fix the way judge whether q stop in user space
Yufeng Mo (1): net: hns3: support of dump mac id and loopback status in debugfs
Zhao Weibo (6): RDMA/hns:remove useless header in cmd RDMA/hns: handle device err after device state to UNIT RDMA/hns: avoid potential overflow of RDMA/hns: Add roce dfx of arm_cnt RDMA/hns: fix the bug of out-of-bonds-read in post send RDMA/hns: some robust optimize in rdfx
fengsheng (2): drivers : sysctl remove rcu_lock drivers : sysctl fixup some param dont check the legitimacy
gaoxun (1): net: hns3: cae security review
liuzhongzhu (1): net: hns3: Add "mac table" information query function
zhuweijia (1): net: hns3: cae io_param definition updated
drivers/crypto/hisilicon/Kconfig | 1 - drivers/crypto/hisilicon/hpre/hpre_crypto.c | 96 +- drivers/crypto/hisilicon/hpre/hpre_main.c | 64 +- drivers/crypto/hisilicon/qm.c | 513 +++---- drivers/crypto/hisilicon/qm.h | 1 - drivers/crypto/hisilicon/rde/rde_main.c | 217 ++- drivers/crypto/hisilicon/sec2/sec_main.c | 54 +- drivers/crypto/hisilicon/sgl.c | 29 +- drivers/crypto/hisilicon/zip/zip_crypto.c | 102 +- drivers/crypto/hisilicon/zip/zip_main.c | 50 +- drivers/infiniband/hw/hns/Makefile | 9 +- drivers/infiniband/hw/hns/hns_roce_cmd.c | 1 - drivers/infiniband/hw/hns/hns_roce_device.h | 4 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 53 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 +- drivers/infiniband/hw/hns/hns_roce_main.c | 10 +- drivers/infiniband/hw/hns/hns_roce_mr.c | 14 +- .../hw/hns/roce-customer/hns_hw_v2_test.c | 61 - .../hw/hns/roce-customer/hns_hw_v2_test.h | 10 - .../hw/hns/roce-customer/hns_roce_test.c | 18 - .../hw/hns/roce-customer/hns_roce_test.h | 8 - .../infiniband/hw/hns/roce-customer/rdfx_common.h | 2 +- .../infiniband/hw/hns/roce-customer/rdfx_entry.c | 8 +- .../infiniband/hw/hns/roce-customer/rdfx_hw_v2.c | 16 +- .../infiniband/hw/hns/roce-customer/rdfx_intf.c | 7 +- .../infiniband/hw/hns/roce-customer/rdfx_main.c | 22 +- .../infiniband/hw/hns/roce-customer/rdfx_sysfs.c | 39 +- drivers/net/ethernet/hisilicon/hns3/Makefile | 27 +- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 6 + drivers/net/ethernet/hisilicon/hns3/hnae3.c | 6 +- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 26 +- .../hisilicon/hns3/hns-customer/hns3_ext.c | 603 --------- .../hisilicon/hns3/hns-customer/hns3_ext.h | 102 -- .../hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c | 996 -------------- .../hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h | 142 -- .../hns3/hns-customer/hns3pf/hclge_main_it.c | 20 +- .../hns3/hns-customer/hns3pf/hclge_main_it.h | 2 - .../hisilicon/hns3/hns3_cae/hns3_cae_checksum.c | 19 +- .../hisilicon/hns3/hns3_cae/hns3_cae_checksum.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_cmd.c | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_common.c | 116 -- .../hisilicon/hns3/hns3_cae/hns3_cae_common.h | 25 - .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.c | 62 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.h | 36 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c | 17 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dfx.c | 40 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dfx.h | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_ext.c | 426 ------ .../hisilicon/hns3/hns3_cae/hns3_cae_ext.h | 68 - .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c | 56 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_gro.c | 24 +- .../hisilicon/hns3/hns3_cae/hns3_cae_gro.h | 7 +- .../hns3/hns3_cae/hns3_cae_hilink_param.c | 16 +- .../hns3/hns3_cae/hns3_cae_hilink_param.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_init.c | 35 +- .../hisilicon/hns3/hns3_cae/hns3_cae_irq.c | 16 +- .../hisilicon/hns3/hns3_cae/hns3_cae_irq.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.c | 35 - .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.h | 36 - .../hisilicon/hns3/hns3_cae/hns3_cae_led.c | 8 +- .../hisilicon/hns3/hns3_cae/hns3_cae_led.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.c | 71 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mac.c | 20 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mac.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c | 63 - .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h | 30 - .../hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c | 45 +- .../hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.c | 741 ---------- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.h | 67 - .../hisilicon/hns3/hns3_cae/hns3_cae_port.c | 22 +- .../hisilicon/hns3/hns3_cae/hns3_cae_port.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.c | 40 +- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c | 43 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h | 10 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qos.c | 138 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qos.h | 19 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qres.c | 35 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qres.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.c | 27 +- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_rss.c | 47 +- .../hisilicon/hns3/hns3_cae/hns3_cae_rss.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_stat.c | 48 +- .../hisilicon/hns3/hns3_cae/hns3_cae_stat.h | 4 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c | 235 ++-- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h | 24 +- .../hisilicon/hns3/hns3_cae/hns3_cae_version.c | 34 +- .../hisilicon/hns3/hns3_cae/hns3_cae_version.h | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_vlan.c | 20 +- .../hisilicon/hns3/hns3_cae/hns3_cae_vlan.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c | 28 +- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h | 4 +- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 24 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 243 +--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 12 +- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 14 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 2 + .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 240 +++- .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h | 17 + .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 1424 ++++++++++++++------ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 58 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 226 +++- .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 11 + .../ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h | 11 - .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 474 +++++-- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 32 +- drivers/soc/hisilicon/sysctl/sysctl_drv.c | 2 +- drivers/soc/hisilicon/sysctl/sysctl_local_ras.c | 31 +- drivers/uacce/dummy_drv/dummy_wd_dev.c | 1 - drivers/uacce/dummy_drv/dummy_wd_v2.c | 1 - drivers/uacce/uacce.c | 512 +------ include/linux/uacce.h | 10 +- include/uapi/linux/uacce.h | 6 +- 121 files changed, 3192 insertions(+), 6445 deletions(-) delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.c delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.h delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_roce_test.c delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_roce_test.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h
From: zhuweijia zhuweijia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA --------------------------------
This patch updated param definition in cae module;
Signed-off-by: zhuweijia zhuweijia@huawei.com Reviewed-by: xuyi xuyi9@huawei.com Reviewed-by: liuyumin liuyumin1@huawei.com Reviewed-by: zhongzhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h index ab14486..9789327 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h @@ -42,7 +42,7 @@ struct hns3_cfg_xsfp { struct hns3_xsfp_info { u8 light_module_status; u16 eeprom_len; - u8 sfp_info[STD_XSFP_INFO_MAX_SIZE + 1]; + u8 sfp_info[STD_XSFP_INFO_MAX_SIZE]; };
int hns3_xsfp_cfg(struct hns3_nic_priv *net_priv, void *buf_in,
From: gaoxun gaoxun3@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA ---------------------------------------------------------- This patch is dedicated to solve some review issues: 1.bool type variables are initialized at declaration; 2.Pointer variables are properly initialized at declaration 3.Certain prevailing input paraemeters, 'priv' in specific, of pointer type whose associated memory is not expected to be modified in principle, is specified as a pointer to const data type; 4.Handle functions in cae_ext are renamed to present the code in a straightforward while informative manner;
Signed-off-by: gaoxun gaoxun3@huawei.com Reviewed-by: dengweiwei dengweiwei@huawei.com Reviewed-by:chenjunxin chenjunxin1@huawei.com Reviewed-by:youshengzui youshengzui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_checksum.c | 19 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_checksum.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_cmd.c | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_common.c | 19 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_common.h | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.c | 48 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.h | 11 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c | 17 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dfx.c | 32 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_dfx.h | 6 +- .../hisilicon/hns3/hns3_cae/hns3_cae_ext.c | 138 ++++++++++----------- .../hisilicon/hns3/hns3_cae/hns3_cae_ext.h | 2 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c | 56 ++++----- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_gro.c | 24 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_gro.h | 7 +- .../hns3/hns3_cae/hns3_cae_hilink_param.c | 16 ++- .../hns3/hns3_cae/hns3_cae_hilink_param.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_init.c | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_irq.c | 16 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_irq.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.c | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_led.c | 8 +- .../hisilicon/hns3/hns3_cae/hns3_cae_led.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.c | 27 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.h | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mac.c | 20 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_mac.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c | 45 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h | 5 +- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.c | 24 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_port.c | 18 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_port.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.c | 33 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c | 42 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h | 18 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_qos.c | 134 ++++++++++---------- .../hisilicon/hns3/hns3_cae/hns3_cae_qos.h | 19 +-- .../hisilicon/hns3/hns3_cae/hns3_cae_qres.c | 29 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_qres.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.c | 28 ++--- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.h | 7 +- .../hisilicon/hns3/hns3_cae/hns3_cae_rss.c | 47 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_rss.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_stat.c | 48 +++---- .../hisilicon/hns3/hns3_cae/hns3_cae_stat.h | 4 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c | 133 +++++++++----------- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h | 22 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_version.c | 32 +++-- .../hisilicon/hns3/hns3_cae/hns3_cae_version.h | 9 +- .../hisilicon/hns3/hns3_cae/hns3_cae_vlan.c | 20 ++- .../hisilicon/hns3/hns3_cae/hns3_cae_vlan.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c | 26 ++-- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 64 files changed, 628 insertions(+), 673 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index e153848..24a5846 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.30.0" +#define HNAE3_MOD_VERSION "1.9.32.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c index d29ea16..ef41194 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.c @@ -15,7 +15,7 @@
static int hns3_cae_chs_set(struct hclge_dev *hdev, u8 chs_type, u8 enable) { - struct hns3_cae_chs_cmd_param *recv; + struct hns3_cae_chs_cmd_param *recv = NULL; struct hclge_desc desc; int ret;
@@ -58,7 +58,7 @@ static int hns3_cae_chs_set(struct hclge_dev *hdev, u8 chs_type, u8 enable)
static int hns3_cae_chs_get(struct hclge_dev *hdev, u8 chs_type, u8 *enable) { - struct hns3_cae_chs_cmd_param *recv; + struct hns3_cae_chs_cmd_param *recv = NULL; struct hclge_desc desc; u8 inner_sctp_en; u8 inner_tcp_en; @@ -109,17 +109,17 @@ static int hns3_cae_chs_get(struct hclge_dev *hdev, u8 chs_type, u8 *enable) return ret; }
-int hns3_cae_chs_cfg(struct hns3_nic_priv *net_priv, void *buf_in, +int hns3_cae_chs_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_chs_param *in_info; - struct hclge_vport *vport; - struct hclge_dev *hdev; - u8 *out_info; - bool check; + struct hns3_cae_chs_param *in_info = + (struct hns3_cae_chs_param *)buf_in; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; + u8 *out_info = NULL; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_chs_param); u8 is_set;
- check = !buf_in || in_size < sizeof(struct hns3_cae_chs_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -127,7 +127,6 @@ int hns3_cae_chs_cfg(struct hns3_nic_priv *net_priv, void *buf_in,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - in_info = (struct hns3_cae_chs_param *)buf_in; out_info = (u8 *)buf_out; is_set = in_info->is_set;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h index b890d755..7a4c230 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_checksum.h @@ -43,6 +43,7 @@ struct hns3_cae_chs_param { u8 is_enable; };
-int hns3_cae_chs_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_chs_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c index 4c93fac..345d351 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_cmd.c @@ -166,8 +166,8 @@ void hns3_cae_cmd_setup_basic_desc(struct hclge_desc *desc, **/ int hns3_cae_cmd_send(struct hclge_dev *hdev, struct hclge_desc *desc, int num) { - struct hclge_desc *desc_to_use; - struct hclge_cmq_ring *csq; + struct hclge_desc *desc_to_use = NULL; + struct hclge_cmq_ring *csq = NULL; bool complete = false; u32 timeout = 0; int handle = 0; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c index 34abfec..1c49f93 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c @@ -18,13 +18,13 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_common.h"
-static int hns3_cae_write_reg_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_write_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct reg_param *in_buf = (struct reg_param *)buf_in; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int ret;
@@ -52,7 +52,7 @@ static int hns3_cae_write_reg_cfg(struct hns3_nic_priv *net_priv, return 0; }
-static int hns3_cae_read_reg_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_read_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { @@ -61,10 +61,9 @@ static int hns3_cae_read_reg_cfg(struct hns3_nic_priv *net_priv, struct reg_param *in_buf = (struct reg_param *)buf_in; struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; + bool check = !buf_out || out_size < sizeof(struct reg_param); int ret;
- check = !buf_out || out_size < sizeof(struct reg_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -92,14 +91,14 @@ static int hns3_cae_read_reg_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_reg_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_reg_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { + bool check = !buf_in || in_size < sizeof(struct reg_param); struct reg_param *mode_param = (struct reg_param *)buf_in; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct reg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h index deb0de9..c9af908 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h @@ -20,6 +20,6 @@ struct reg_ret_param { u32 value[REG_RDATA_NUM]; };
-int hns3_cae_reg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size); +int hns3_cae_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c index 7abd5ff..fa6c6b4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c @@ -19,7 +19,7 @@
struct hns3_cae_dcb_info dcb_all_info[MAX_DEV_LISTED];
-static int check_and_set_curr_dev(struct hns3_nic_priv *net_priv) +static int check_and_set_curr_dev(const struct hns3_nic_priv *net_priv) { int i;
@@ -36,22 +36,22 @@ static int check_and_set_curr_dev(struct hns3_nic_priv *net_priv) return i; }
-int hns3_cae_dcb_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_dcb_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_dcb_cfg_param *out_info = NULL; - struct hns3_cae_dcb_cfg_param *in_info = NULL; + struct hns3_cae_dcb_cfg_param *out_info = + (struct hns3_cae_dcb_cfg_param *)buf_out; + struct hns3_cae_dcb_cfg_param *in_info = + (struct hns3_cae_dcb_cfg_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_dcb_cfg_param); int curr_dev_idx; - bool check;
- check = !buf_in || in_size < sizeof(struct hns3_cae_dcb_cfg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- in_info = (struct hns3_cae_dcb_cfg_param *)buf_in; - out_info = (struct hns3_cae_dcb_cfg_param *)buf_out; curr_dev_idx = check_and_set_curr_dev(net_priv); if (curr_dev_idx < 0) { pr_err("Exceed MAX_DEV_LISTED: %d\n", MAX_DEV_LISTED); @@ -155,21 +155,22 @@ static int hns3_cae_cfg_pause_param(struct hclge_dev *hdev, return 0; }
-int hns3_cae_dcb_pfc_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_pfc_cfg_param *out_info = NULL; - struct hns3_cae_pfc_cfg_param *in_info = NULL; + struct hns3_cae_pfc_cfg_param *out_info = + (struct hns3_cae_pfc_cfg_param *)buf_out; + struct hns3_cae_pfc_cfg_param *in_info = + (struct hns3_cae_pfc_cfg_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_pfc_cfg_param); struct hclge_vport *vport = NULL; struct net_device *ndev = NULL; struct hnae3_handle *h = NULL; struct hclge_dev *hdev = NULL; int curr_dev_idx; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_pfc_cfg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -184,8 +185,6 @@ int hns3_cae_dcb_pfc_cfg(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(h); ndev = h->netdev; hdev = vport->back; - in_info = (struct hns3_cae_pfc_cfg_param *)buf_in; - out_info = (struct hns3_cae_pfc_cfg_param *)buf_out;
if (!in_info->is_read && !dcb_all_info[curr_dev_idx].dcb_cfg_info.dcb_en) { @@ -311,25 +310,28 @@ static void hns3_cae_enable_ets_cfg(struct hclge_dev *hdev, } }
-int hns3_cae_dcb_ets_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define BYTELEN 4 - struct hns3_cae_ets_cfg_param *out_info = NULL; - struct hns3_cae_ets_cfg_param *in_info = NULL; + struct hns3_cae_ets_cfg_param *out_info = + (struct hns3_cae_ets_cfg_param *)buf_out; + struct hns3_cae_ets_cfg_param *in_info = + (struct hns3_cae_ets_cfg_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_cae_ets_cfg_param) || + !buf_out || + out_size < sizeof(struct hns3_cae_ets_cfg_param); struct hclge_vport *vport = NULL; struct net_device *ndev = NULL; struct hclge_dev *hdev = NULL; struct hnae3_handle *h = NULL; struct hclge_desc desc; int curr_dev_idx; - bool check; int ret; int i;
- check = !buf_in || in_size < sizeof(struct hns3_cae_ets_cfg_param) || - !buf_out || out_size < sizeof(struct hns3_cae_ets_cfg_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; @@ -344,8 +346,6 @@ int hns3_cae_dcb_ets_cfg(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(h); ndev = h->netdev; hdev = vport->back; - in_info = (struct hns3_cae_ets_cfg_param *)buf_in; - out_info = (struct hns3_cae_ets_cfg_param *)buf_out;
if (!in_info->is_read && !dcb_all_info[curr_dev_idx].dcb_cfg_info.dcb_en) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h index 86154c5..c9437f5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h @@ -51,18 +51,19 @@ struct hns3_cae_ets_cfg_param { };
struct hns3_cae_dcb_info { - struct hns3_nic_priv *net_priv; + const struct hns3_nic_priv *net_priv; struct hns3_cae_pfc_cfg_param pfc_cfg_info; struct hns3_cae_dcb_cfg_param dcb_cfg_info; struct hns3_cae_ets_cfg_param ets_cfg_info; };
-int hns3_cae_dcb_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_dcb_ets_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_dcb_pfc_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c index 2cf633a..fb7aafc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.c @@ -13,12 +13,12 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_dcqcn.h"
-static int hns3_dcqcn_rw(struct hns3_nic_priv *net_priv, +static int hns3_dcqcn_rw(const struct hns3_nic_priv *net_priv, u32 offset, u32 *data, u32 rw_type) { struct hnae3_handle *h = net_priv->ae_handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int ret;
@@ -55,7 +55,7 @@ static int hns3_dcqcn_rw(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, +int hns3_nic_dcqcn(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define SCC_TEMP_CFG0 0x6000 @@ -64,16 +64,15 @@ int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, #define SCC_TEMP_CFG3 0x600c struct hnae3_handle *h = net_priv->ae_handle; struct hclge_vport *vport = container_of(h, struct hclge_vport, nic); + bool check = !buf_in || in_size < sizeof(struct cfg_dcqcn_param); struct cfg_dcqcn_param *parm_out = buf_out; struct cfg_dcqcn_param *parm_in = buf_in; struct cfg_dcqcn_param tempbuffer = {0}; struct hclge_dev *hdev = vport->back; u32 tempoutbuff; u32 offset; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct cfg_dcqcn_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -226,7 +225,7 @@ int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_dcqcn_get_msg_cnt(struct hns3_nic_priv *net_priv, +int hns3_dcqcn_get_msg_cnt(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { @@ -235,10 +234,10 @@ int hns3_dcqcn_get_msg_cnt(struct hns3_nic_priv *net_priv, struct dcqcn_statistic_param *statistic_parm_out = buf_out; struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; + bool check = !buf_out || + out_size < sizeof(struct dcqcn_statistic_param); int ret;
- check = !buf_out || out_size < sizeof(struct dcqcn_statistic_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h index 3ec9336..435f222 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcqcn.h @@ -51,9 +51,10 @@ struct dcqcn_statistic_param { #define HIARM_DCQCN_READ_CFG_MODE 30 #define HIARM_DCQCN_WRITE_CFG_MODE 31
-int hns3_nic_dcqcn(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_dcqcn_get_msg_cnt(struct hns3_nic_priv *net_priv, +int hns3_nic_dcqcn(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_dcqcn_get_msg_cnt(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c index c901243..6346c9a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c @@ -80,24 +80,24 @@ static int hns3_cae_get_chip_and_mac_id(struct hnae3_handle *handle, return 0; }
-int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HNS3_CAE_MAC_MODE_ADDR 0x10000000U #define HNS3_CAE_MAC_MAP_ADDR 0x10000008U - struct hns3_cae_dfx_param *out_info = NULL; + struct hns3_cae_dfx_param *out_info = + (struct hns3_cae_dfx_param *)buf_out; struct hns3_cae_reg_param reg_info; struct hnae3_handle *handle = NULL; struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; u32 chip_id; u32 mac_id; - bool check; + bool check = !buf_out || out_size < sizeof(struct hns3_cae_dfx_param); int ret; int i;
- check = !buf_out || out_size < sizeof(struct hns3_cae_dfx_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -106,7 +106,6 @@ int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, handle = net_priv->ae_handle; vport = hns3_cae_get_vport(handle); hdev = vport->back; - out_info = (struct hns3_cae_dfx_param *)buf_out;
ret = hns3_cae_get_chip_and_mac_id(handle, &chip_id, &mac_id); if (ret) @@ -139,18 +138,19 @@ int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_read_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_reg_param *out_info = NULL; - struct hns3_cae_reg_param *in_info = NULL; + struct hns3_cae_reg_param *out_info = + (struct hns3_cae_reg_param *)buf_out; + struct hns3_cae_reg_param *in_info = + (struct hns3_cae_reg_param *)buf_in; struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_reg_param); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_reg_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -159,9 +159,6 @@ int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
- in_info = (struct hns3_cae_reg_param *)buf_in; - out_info = (struct hns3_cae_reg_param *)buf_out; - if (in_info->is_read) { check = !buf_out || out_size < sizeof(struct hns3_cae_reg_param); @@ -186,18 +183,18 @@ int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_event_injection(struct hns3_nic_priv *net_priv, +int hns3_cae_event_injection(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_event_param *in_info = NULL; + struct hns3_cae_event_param *in_info = + (struct hns3_cae_event_param *)buf_in; struct hns3_cae_reg_param reg_info; struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_event_param); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_event_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -206,7 +203,6 @@ int hns3_cae_event_injection(struct hns3_nic_priv *net_priv, vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
- in_info = (struct hns3_cae_event_param *)buf_in; reg_info.addr = in_info->addr; reg_info.bit_width = 32; reg_info.is_read = false; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h index 27f9d5c..8d8edb8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h @@ -35,13 +35,13 @@ struct hns3_cae_event_param {
#define HNS3_CAE_MAX_MAC_NUMBER 0x8
-int hns3_cae_get_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_read_dfx_info(struct hns3_nic_priv *net_priv, +int hns3_cae_read_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_event_injection(struct hns3_nic_priv *net_priv, +int hns3_cae_event_injection(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c index 5afb3ea..c3b963c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c @@ -5,17 +5,17 @@ #include "hns3_cae_ext.h" #include "hns3_ext.h"
-static int hns3_ext_test_disable_netclk(struct hns3_nic_priv *net_priv) +static int hns3_disable_netclk(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_disable_clock(netdev); }
-static int hns3_get_cpu_affinity(struct hns3_nic_priv *priv) +static int hns3_get_cpu_affinity(const struct hns3_nic_priv *priv) { - struct hns3_enet_tqp_vector *tqp_vector; - struct hnae3_handle *h; + struct hns3_enet_tqp_vector *tqp_vector = NULL; + struct hnae3_handle *h = NULL; int i;
if (!priv) { @@ -42,9 +42,9 @@ static int hns3_get_cpu_affinity(struct hns3_nic_priv *priv) return 0; }
-static int hns3_ext_test_affi(struct hns3_nic_priv *net_priv, void *in) +static int hns3_affi(const struct hns3_nic_priv *net_priv, void *in) { - struct hns3_cpumask_param *cpumask_param; + struct hns3_cpumask_param *cpumask_param = NULL; cpumask_var_t cpumask_new; int ret;
@@ -77,7 +77,7 @@ static int hns3_ext_test_affi(struct hns3_nic_priv *net_priv, void *in) return ret; }
-static int hns3_ext_test_get_chipid(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_chipid(const struct hns3_nic_priv *net_priv, void *out) { u32 chip_id; int ret; @@ -89,14 +89,14 @@ static int hns3_ext_test_get_chipid(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_match_check(struct hns3_nic_priv *net_priv) +static int hns3_match_check(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_netdev_match_check(netdev); }
-static int hns3_ext_test_set_led(struct hns3_nic_priv *net_priv, void *in) +static int hns3_set_led(const struct hns3_nic_priv *net_priv, void *in) { struct hns3_led_state_para *para = (struct hns3_led_state_para *)in; struct net_device *netdev = net_priv->netdev; @@ -104,8 +104,8 @@ static int hns3_ext_test_set_led(struct hns3_nic_priv *net_priv, void *in) return nic_set_led(netdev, para->type, para->status); }
-static int hns3_ext_test_get_sfp_info(struct hns3_nic_priv *net_priv, void *in, - void *out) +static int hns3_get_sfp_info(const struct hns3_nic_priv *net_priv, void *in, + void *out) { struct hns3_priv_sfp_info_para *para_in = (struct hns3_priv_sfp_info_para *)in; @@ -120,8 +120,8 @@ static int hns3_ext_test_get_sfp_info(struct hns3_nic_priv *net_priv, void *in, return ret; }
-static int hns3_ext_test_get_sfp_present(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_sfp_present(const struct hns3_nic_priv *net_priv, + void *out) { struct net_device *netdev = net_priv->netdev; u32 present; @@ -134,7 +134,7 @@ static int hns3_ext_test_get_sfp_present(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_set_sfp_state(struct hns3_nic_priv *net_priv, void *in) +static int hns3_set_sfp_state(const struct hns3_nic_priv *net_priv, void *in) { struct net_device *netdev = net_priv->netdev; bool en = *(bool *)in; @@ -142,14 +142,14 @@ static int hns3_ext_test_set_sfp_state(struct hns3_nic_priv *net_priv, void *in) return nic_set_sfp_state(netdev, en); }
-static int hns3_ext_test_clean_stats64(struct hns3_nic_priv *net_priv) +static int hns3_clean_stats64(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_clean_stats64(netdev, NULL); }
-static int hns3_ext_test_get_chip_num(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_chip_num(const struct hns3_nic_priv *net_priv, void *out) { u32 chip_num; int ret; @@ -161,7 +161,7 @@ static int hns3_ext_test_get_chip_num(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_get_port_num(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_port_num(const struct hns3_nic_priv *net_priv, void *out) { u32 port_num; int ret; @@ -173,15 +173,15 @@ static int hns3_ext_test_get_port_num(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_disable_net_lane(struct hns3_nic_priv *net_priv) +static int hns3_disable_net_lane(const struct hns3_nic_priv *net_priv) { struct net_device *netdev = net_priv->netdev;
return nic_disable_net_lane(netdev); }
-static int hns3_ext_test_get_lane_status(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_lane_status(const struct hns3_nic_priv *net_priv, + void *out) { u32 lane_status; int ret; @@ -193,7 +193,7 @@ static int hns3_ext_test_get_lane_status(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_set_mac_state(struct hns3_nic_priv *net_priv, void *in) +static int hns3_set_mac_state(const struct hns3_nic_priv *net_priv, void *in) { struct net_device *netdev = net_priv->netdev; int enable = *(int *)in; @@ -201,8 +201,8 @@ static int hns3_ext_test_set_mac_state(struct hns3_nic_priv *net_priv, void *in) return nic_set_mac_state(netdev, enable); }
-static int hns3_ext_test_set_pfc_storm_para(struct hns3_nic_priv *net_priv, - void *in) +static int hns3_set_pfc_storm_para(const struct hns3_nic_priv *net_priv, + void *in) { struct hns3_pfc_storm_para *para = (struct hns3_pfc_storm_para *)in; struct net_device *netdev = net_priv->netdev; @@ -212,13 +212,13 @@ static int hns3_ext_test_set_pfc_storm_para(struct hns3_nic_priv *net_priv, para->recovery_period_ms); }
-static int hns3_ext_test_get_pfc_storm_para(struct hns3_nic_priv *net_priv, - void *in, void *out) +static int hns3_get_pfc_storm_para(const struct hns3_nic_priv *net_priv, + void *in, void *out) { struct hns3_pfc_storm_para *para_in = (struct hns3_pfc_storm_para *)in; struct net_device *netdev = net_priv->netdev; struct hns3_pfc_storm_para *para_out = - (struct hns3_pfc_storm_para *)out; + (struct hns3_pfc_storm_para *)out; u32 recovery_period_ms; u32 period_ms; u32 enable; @@ -240,9 +240,9 @@ static int hns3_ext_test_get_pfc_storm_para(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_get_phy_reg(struct hns3_nic_priv *net_priv, - void *in, void *out, - enum phy_type phy_type) +static int hns3_get_phy_reg(const struct hns3_nic_priv *net_priv, + void *in, void *out, + enum phy_type phy_type) { struct hns3_phy_para *para_out = (struct hns3_phy_para *)out; struct hns3_phy_para *para_in = (struct hns3_phy_para *)in; @@ -268,8 +268,8 @@ static int hns3_ext_test_get_phy_reg(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_set_phy_reg(struct hns3_nic_priv *net_priv, - void *in, enum phy_type phy_type) +static int hns3_set_phy_reg(const struct hns3_nic_priv *net_priv, void *in, + enum phy_type phy_type) { struct hns3_phy_para *para = (struct hns3_phy_para *)in; struct net_device *netdev = net_priv->netdev; @@ -284,7 +284,7 @@ static int hns3_ext_test_set_phy_reg(struct hns3_nic_priv *net_priv, para->data); }
-static int hns3_ext_test_get_macid(struct hns3_nic_priv *net_priv, void *out) +static int hns3_get_macid(const struct hns3_nic_priv *net_priv, void *out) { u32 mac_id; int ret; @@ -296,8 +296,8 @@ static int hns3_ext_test_get_macid(struct hns3_nic_priv *net_priv, void *out) return ret; }
-static int hns3_ext_test_get_hilink_ref_los(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_hilink_ref_los(const struct hns3_nic_priv *net_priv, + void *out) { u32 status; int ret; @@ -309,8 +309,7 @@ static int hns3_ext_test_get_hilink_ref_los(struct hns3_nic_priv *net_priv, return ret; }
-static int hns3_ext_test_get_port_type(struct hns3_nic_priv *net_priv, - void *out) +static int hns3_get_port_type(const struct hns3_nic_priv *net_priv, void *out) { u32 wire_type; int ret; @@ -322,100 +321,97 @@ static int hns3_ext_test_get_port_type(struct hns3_nic_priv *net_priv, return ret; }
-int hns3_ext_interface_test(struct hns3_nic_priv *net_priv, +int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct cmd_ext_driver_param *ext_param_out; - struct cmd_ext_driver_param *ext_param_in; - bool check; - void *out; - void *in; + struct cmd_ext_driver_param *ext_param_out = + (struct cmd_ext_driver_param *)buf_out; + struct cmd_ext_driver_param *ext_param_in = + (struct cmd_ext_driver_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct cmd_ext_driver_param) || + !buf_out || out_size < sizeof(struct cmd_ext_driver_param); + void *out = NULL; + void *in = NULL; int ret;
- check = !buf_in || in_size < sizeof(struct cmd_ext_driver_param) || - !buf_out || out_size < sizeof(struct cmd_ext_driver_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- ext_param_in = (struct cmd_ext_driver_param *)buf_in; - ext_param_out = (struct cmd_ext_driver_param *)buf_out; in = ext_param_in->buf; out = ext_param_out->buf;
switch (ext_param_in->op_code) { case EXT_AFFI_MASK: - ret = hns3_ext_test_affi(net_priv, in); + ret = hns3_affi(net_priv, in); break; case EXT_DISABLE_NET_CLK: - ret = hns3_ext_test_disable_netclk(net_priv); + ret = hns3_disable_netclk(net_priv); break; case EXT_GET_CHIP_ID: - ret = hns3_ext_test_get_chipid(net_priv, out); + ret = hns3_get_chipid(net_priv, out); break; case EXT_NET_MATCH_CHECK: - ret = hns3_ext_test_match_check(net_priv); + ret = hns3_match_check(net_priv); break; case EXT_SET_LED: - ret = hns3_ext_test_set_led(net_priv, in); + ret = hns3_set_led(net_priv, in); break; case EXT_GET_SFP_INFO: - ret = hns3_ext_test_get_sfp_info(net_priv, in, out); + ret = hns3_get_sfp_info(net_priv, in, out); break; case EXT_GET_SFP_PRESENT: - ret = hns3_ext_test_get_sfp_present(net_priv, out); + ret = hns3_get_sfp_present(net_priv, out); break; case EXT_SET_SFP_STATE: - ret = hns3_ext_test_set_sfp_state(net_priv, in); + ret = hns3_set_sfp_state(net_priv, in); break; case EXT_CLEAN_STATS64: - ret = hns3_ext_test_clean_stats64(net_priv); + ret = hns3_clean_stats64(net_priv); break; case EXT_GET_CHIP_NUM: - ret = hns3_ext_test_get_chip_num(net_priv, out); + ret = hns3_get_chip_num(net_priv, out); break; case EXT_GET_PORT_NUM: - ret = hns3_ext_test_get_port_num(net_priv, out); + ret = hns3_get_port_num(net_priv, out); break; case EXT_DISABLE_NET_LANE: - ret = hns3_ext_test_disable_net_lane(net_priv); + ret = hns3_disable_net_lane(net_priv); break; case EXT_GET_LANE_STATUS: - ret = hns3_ext_test_get_lane_status(net_priv, out); + ret = hns3_get_lane_status(net_priv, out); break; case EXT_SET_MAC_STATE: - ret = hns3_ext_test_set_mac_state(net_priv, in); + ret = hns3_set_mac_state(net_priv, in); break; case EXT_SET_PFC_STORM_PARA: - ret = hns3_ext_test_set_pfc_storm_para(net_priv, in); + ret = hns3_set_pfc_storm_para(net_priv, in); break; case EXT_GET_PFC_STORM_PARA: - ret = hns3_ext_test_get_pfc_storm_para(net_priv, in, out); + ret = hns3_get_pfc_storm_para(net_priv, in, out); break; case EXT_GET_PHY_REG: - ret = hns3_ext_test_get_phy_reg(net_priv, in, out, - PHY_TYPE_1512); + ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_1512); break; case EXT_SET_PHY_REG: - ret = hns3_ext_test_set_phy_reg(net_priv, in, PHY_TYPE_1512); + ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_1512); break; case EXT_GET_MAC_ID: - ret = hns3_ext_test_get_macid(net_priv, out); + ret = hns3_get_macid(net_priv, out); break; case EXT_GET_HILINK_REF_LOS: - ret = hns3_ext_test_get_hilink_ref_los(net_priv, out); + ret = hns3_get_hilink_ref_los(net_priv, out); break; case EXT_GET_8211_PHY_REG: - ret = hns3_ext_test_get_phy_reg(net_priv, in, out, - PHY_TYPE_8211); + ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_8211); break; case EXT_SET_8211_PHY_REG: - ret = hns3_ext_test_set_phy_reg(net_priv, in, PHY_TYPE_8211); + ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_8211); break; case EXT_GET_PORT_TYPE: - ret = hns3_ext_test_get_port_type(net_priv, out); + ret = hns3_get_port_type(net_priv, out); break; default: ret = -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h index 28df48a..aca4988 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h @@ -61,7 +61,7 @@ struct cmd_ext_driver_param { u8 buf[1024]; };
-int hns3_ext_interface_test(struct hns3_nic_priv *net_priv, +int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c index 516dc2e..21e0341 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.c @@ -22,10 +22,10 @@ static int hns3_cae_send_generic_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_get_fd_mode_cmd *mode_cfg; - struct hclge_get_fd_mode_cmd *req; + struct hclge_get_fd_mode_cmd *mode_cfg = NULL; + struct hclge_get_fd_mode_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = false; int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_MODE_CTRL, @@ -63,14 +63,13 @@ static int hns3_cae_send_generic_cmd(struct hclge_dev *hdev, u8 *buf_in, static int hns3_cae_send_allocate_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { - struct hclge_get_fd_allocation_cmd *allocation_cfg; - struct hclge_get_fd_allocation_cmd *req; + struct hclge_get_fd_allocation_cmd *allocation_cfg = NULL; + struct hclge_get_fd_allocation_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_out || + out_size < sizeof(struct hclge_get_fd_allocation_cmd); int ret;
- check = !buf_out || - out_size < sizeof(struct hclge_get_fd_allocation_cmd); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -102,10 +101,10 @@ static int hns3_cae_send_key_cfg_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_set_fd_key_config_cmd *key_cfg_data; - struct hclge_set_fd_key_config_cmd *req; + struct hclge_set_fd_key_config_cmd *key_cfg_data = NULL; + struct hclge_set_fd_key_config_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = false; int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_KEY_CONFIG, @@ -157,13 +156,13 @@ static int hns3_cae_send_tcam_op_cmd(struct hclge_dev *hdev, u8 *buf_in, #define HNS3_CAE_FD_TCAM_BD_NUM 3 struct fd_param *param = (struct fd_param *)buf_in; struct hclge_desc desc[HNS3_CAE_FD_TCAM_BD_NUM]; - struct hclge_fd_tcam_config_1_cmd *req1; - struct hclge_fd_tcam_config_2_cmd *req2; - struct hclge_fd_tcam_config_3_cmd *req3; - struct hclge_fd_tcam_data *tcam_data; - struct hclge_desc *pdesc; - bool check; - u8 *buf; + struct hclge_fd_tcam_config_1_cmd *req1 = NULL; + struct hclge_fd_tcam_config_2_cmd *req2 = NULL; + struct hclge_fd_tcam_config_3_cmd *req3 = NULL; + struct hclge_fd_tcam_data *tcam_data = NULL; + struct hclge_desc *pdesc = NULL; + bool check = false; + u8 *buf = NULL; int ret; int i;
@@ -228,10 +227,10 @@ static int hns3_cae_send_ad_op_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_fd_ad_config_cmd *ad_data; - struct hclge_fd_ad_config_cmd *req; + struct hclge_fd_ad_config_cmd *ad_data = NULL; + struct hclge_fd_ad_config_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = false; int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_AD_OP, @@ -271,10 +270,10 @@ static int hns3_cae_send_cnt_op_cmd(struct hclge_dev *hdev, u8 *buf_in, u32 in_size, u8 *buf_out, u32 out_size) { struct fd_param *param = (struct fd_param *)buf_in; - struct hclge_fd_cnt_op_cmd *cnt_data; - struct hclge_fd_cnt_op_cmd *req; + struct hclge_fd_cnt_op_cmd *cnt_data = NULL; + struct hclge_fd_cnt_op_cmd *req = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_out || out_size < sizeof(struct hclge_fd_cnt_op_cmd); int ret;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_FD_CNT_OP, true); @@ -282,7 +281,6 @@ static int hns3_cae_send_cnt_op_cmd(struct hclge_dev *hdev, u8 *buf_in, req->stage = param->stage; req->cnt_idx = param->idx;
- check = !buf_out || out_size < sizeof(struct hclge_fd_cnt_op_cmd); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -300,17 +298,17 @@ static int hns3_cae_send_cnt_op_cmd(struct hclge_dev *hdev, u8 *buf_in, return 0; }
-int hns3_cae_fd_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_fd_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { + bool check = !buf_in || in_size < sizeof(struct fd_param); struct hnae3_handle *handle = net_priv->ae_handle; struct hclge_vport *vport = hns3_cae_get_vport(handle); struct fd_param *param = (struct fd_param *)buf_in; struct hclge_dev *hdev = vport->back; int ret = -1; - bool check;
- check = !buf_in || in_size < sizeof(struct fd_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h index 1d69139..9e2053b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_fd.h @@ -31,7 +31,8 @@ struct hclge_fd_tcam_data { u8 tcam_data[52]; };
-int hns3_cae_fd_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_fd_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c index 6395078..afda7fe 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.c @@ -11,20 +11,19 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_gro.h"
-int hns3_gro_age_handle(struct hns3_nic_priv *net_priv, +int hns3_gro_age_handle(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hnae3_handle *h = net_priv->ae_handle; - struct hns3_cae_gro_age_config_cmd *req; - struct hclge_vport *vport; - struct gro_param *param; + struct hns3_cae_gro_age_config_cmd *req = NULL; + struct hclge_vport *vport = NULL; + struct gro_param *param = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - struct hclge_dev *hdev; - bool check; + bool check = !buf_in || in_size < sizeof(struct gro_param); int ret;
- check = !buf_in || in_size < sizeof(struct gro_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -61,12 +60,13 @@ int hns3_gro_age_handle(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_gro_dump_bd_buff_size(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_gro_dump_bd_buff_size(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hclge_vport *vport; - struct hnae3_handle *h; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hnae3_handle *h = NULL; + struct hclge_dev *hdev = NULL;
if (!buf_out || out_size < sizeof(u16)) { pr_err("input param buf_out error in %s function\n", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h index 9427c7e..49a9548 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_gro.h @@ -16,9 +16,10 @@ struct gro_param { u32 age_cnt; };
-int hns3_gro_age_handle(struct hns3_nic_priv *net_priv, +int hns3_gro_age_handle(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_gro_dump_bd_buff_size(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_gro_dump_bd_buff_size(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c index bc99c20..6aa003f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.c @@ -168,28 +168,26 @@ static int hns3_get_hilink_ffe(struct hclge_dev *hdev, return ret; }
-int hns3_get_hilink_param(struct hns3_nic_priv *net_priv, +int hns3_get_hilink_param(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); struct hclge_vport *vport = hns3_cae_get_vport(handle); - struct hns3_hilink_param *hns3_param_out = NULL; - struct hns3_hilink_param *hns3_param_in = NULL; + struct hns3_hilink_param *hns3_param_out = + (struct hns3_hilink_param *)buf_out; + struct hns3_hilink_param *hns3_param_in = + (struct hns3_hilink_param *)buf_in; struct hclge_dev *hdev = vport->back; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_hilink_param) || + !buf_out || out_size < sizeof(struct hns3_hilink_param); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_hilink_param) || - !buf_out || out_size < sizeof(struct hns3_hilink_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- hns3_param_in = (struct hns3_hilink_param *)buf_in; - hns3_param_out = (struct hns3_hilink_param *)buf_out; - memset(hns3_param_out->ctle_param, 0x0, sizeof(hns3_param_out->ctle_param)); memset(hns3_param_out->dfe_param, 0x0, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h index 81acfa7..507311c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_hilink_param.h @@ -45,7 +45,7 @@ struct hns3_hilink_param { struct hns3_ffe_data ffe_param[HILINK_LANE_MAX_NUM]; };
-int hns3_get_hilink_param(struct hns3_nic_priv *net_priv, +int hns3_get_hilink_param(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c index cc18001..96f0bb0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c @@ -59,8 +59,9 @@ int g_hns3_cae_init_flag; int g_hns3_cae_ref_cnt;
-typedef int (*driv_module) (struct hns3_nic_priv *nic_dev, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +typedef int (*driv_module) (const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
struct drv_module_handle { enum driver_cmd_type driv_cmd_name; @@ -77,7 +78,7 @@ static void free_buff_in(void *buf_in)
static int alloc_buff_in(struct msg_module *nt_msg, u32 in_size, void **buf_in) { - void *msg_buf; + void *msg_buf = NULL;
if (!in_size) return 0; @@ -469,7 +470,7 @@ static int if_hns3_cae_exist(void) static int hns3_cae_k_init(void) { int ret; - struct device *pdevice; + struct device *pdevice = NULL;
if (g_hns3_cae_init_flag) { g_hns3_cae_ref_cnt++; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c index c939136..27a37ef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.c @@ -20,24 +20,24 @@ struct hns3_irq_lli_param { u16 tqp_nums; };
-int hns3_irq_lli_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_irq_lli_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_irq_lli_param *in_info = NULL; - struct hns3_irq_lli_param *out_info = NULL; + struct hns3_irq_lli_param *in_info = + (struct hns3_irq_lli_param *)buf_in; + struct hns3_irq_lli_param *out_info = + (struct hns3_irq_lli_param *)buf_out; struct hnae3_handle *handle = NULL; int is_get; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_irq_lli_param);
- check = !buf_in || in_size < sizeof(struct hns3_irq_lli_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
handle = net_priv->ae_handle; - in_info = (struct hns3_irq_lli_param *)buf_in; - out_info = (struct hns3_irq_lli_param *)buf_out; is_get = in_info->is_get;
if (is_get) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h index a58db86..30b9806 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_irq.h @@ -4,6 +4,7 @@ #ifndef __HNS3_CAE_IRQ_H__ #define __HNS3_CAE_IRQ_H__
-int hns3_irq_lli_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_irq_lli_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c index 1d675f8..57f25e0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c @@ -8,7 +8,7 @@ #include "hns3_enet.h" #include "hns3_cae_lamp.h"
-int hns3_lamp_cfg(struct hns3_nic_priv *net_priv, +int hns3_lamp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct net_device *netdev = net_priv->netdev; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h index 78eeb8a..2d8069f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h @@ -26,7 +26,7 @@ struct hns3_lamp_signal { u8 activity; };
-int hns3_lamp_cfg(struct hns3_nic_priv *net_priv, +int hns3_lamp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); int nic_get_led_signal(struct net_device *ndev, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c index 863b27f..75edb14 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.c @@ -8,19 +8,19 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_led.h"
-int hns3_led_cfg_ncl_info(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_led_cfg_ncl_info(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); struct hclge_vport *vport = hns3_cae_get_vport(handle); struct led_statistic_param *parm_out = buf_out; struct hclge_dev *hdev = vport->back; struct hclge_desc desc = {0}; - bool check; + bool check = !buf_out || out_size < sizeof(struct led_statistic_param); int index; int ret;
- check = !buf_out || out_size < sizeof(struct led_statistic_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h index 0b2b735..4a6a50b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_led.h @@ -10,6 +10,7 @@ struct led_statistic_param { u32 data[6]; };
-int hns3_led_cfg_ncl_info(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_led_cfg_ncl_info(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c index df0b8ff..fd923ae 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c @@ -15,23 +15,27 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_lib.h"
-int hns3_cae_common_cmd_send(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define MAX_DESC_DATA_LEN 6 - struct cmd_desc_param *param_in; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct cmd_desc_param *param_in = (struct cmd_desc_param *)buf_in; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_in || in_size < sizeof(struct cmd_desc_param); int ret; int i;
- check = !buf_in || in_size < sizeof(struct cmd_desc_param); + if (check) { + pr_err("input param buf_in error in %s function\n", __func__); + return -EFAULT; + } + vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
- param_in = (struct cmd_desc_param *)buf_in; hns3_cae_cmd_setup_basic_desc(&desc, param_in->fw_dw_opcode, param_in->is_read); for (i = 0; i < MAX_DESC_DATA_LEN; i++) @@ -59,18 +63,17 @@ int hns3_cae_common_cmd_send(struct hns3_nic_priv *net_priv, void *buf_in, return 0; }
-int hns3_m7_cmd_handle(struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_m7_cmd_handle(const struct hns3_nic_priv *nic_dev, void *buf_in, + u32 in_size, void *buf_out, u32 out_size) { struct hclge_vport *vport = hns3_cae_get_vport(nic_dev->ae_handle); struct m7_cmd_para *cmd_para = (struct m7_cmd_para *)buf_in; struct hclge_dev *hdev = vport->back; struct hclge_desc *desc = NULL; u32 bd_size; - bool check; + bool check = !buf_in || in_size < sizeof(struct m7_cmd_para); int ret;
- check = !buf_in || in_size < sizeof(struct m7_cmd_para); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h index 61ae1af6..236b5a8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h @@ -134,9 +134,10 @@ struct m7_cmd_para { void *bd_data; };
-int hns3_cae_common_cmd_send(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
-int hns3_m7_cmd_handle(struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, - void *buf_out, u32 out_size); +int hns3_m7_cmd_handle(const struct hns3_nic_priv *nic_dev, void *buf_in, + u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c index 09dacf0db..acbb684 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.c @@ -14,31 +14,27 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_mac.h"
-int hns3_cae_mac_loop_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_mac_loop_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hns3_cae_cfg_serdes_mode_cmd *req1 = NULL; struct hns3_cae_cfg_mac_mode_cmd *req2 = NULL; - struct hns3_cae_loop_param *out_info = NULL; - struct hns3_cae_loop_param *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_loop_param *out_info = + (struct hns3_cae_loop_param *)buf_out; + struct hns3_cae_loop_param *in_info = + (struct hns3_cae_loop_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_loop_param); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_loop_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_loop_param *)buf_in; - out_info = (struct hns3_cae_loop_param *)buf_out; - req1 = (struct hns3_cae_cfg_serdes_mode_cmd *)&desc.data[0]; req2 = (struct hns3_cae_cfg_mac_mode_cmd *)&desc.data[0];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h index a5faf4c..3ab73ca 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mac.h @@ -31,7 +31,7 @@ struct hns3_cae_cfg_serdes_mode_cmd { u8 rsv[21]; };
-int hns3_cae_mac_loop_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_mac_loop_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c index a7b2e23..5b9c86a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c @@ -19,7 +19,7 @@ #include "hns3_ext.h" #include "hns3_cae_mactbl.h"
-int hns3_cae_opt_mactbl(struct hns3_nic_priv *net_priv, +int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { @@ -30,11 +30,10 @@ int hns3_cae_opt_mactbl(struct hns3_nic_priv *net_priv, struct hns3_mac_tbl_para *in = (struct hns3_mac_tbl_para *)buf_in; struct net_device *netdev = net_priv->netdev; struct hnae3_handle *h = NULL; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_mac_tbl_para) || + !buf_out || out_size < sizeof(struct hns3_mac_tbl_para); int ret;
- check = !buf_in || in_size < sizeof(struct hns3_mac_tbl_para) || - !buf_out || out_size < sizeof(struct hns3_mac_tbl_para); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h index 16570b4..a96c380 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h @@ -23,7 +23,7 @@ struct hns3_mac_tbl_para { u8 result; };
-int hns3_cae_opt_mactbl(struct hns3_nic_priv *net_priv, +int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c index 4bb55c6..cda7164 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.c @@ -6,18 +6,18 @@ #include "hns3_cae_pfc_storm.h" #include "hns3_enet.h"
-static int hns3_cae_set_pfc_storm_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_set_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size) { - struct cmd_pfc_storm_param *prelude_in; - struct net_device *netdev; - struct hclge_vport *vport; - struct hnae3_handle *h; - struct hclge_dev *hdev; + struct cmd_pfc_storm_param *prelude_in = + (struct cmd_pfc_storm_param *)buf_in; + struct net_device *netdev = NULL; + struct hclge_vport *vport = NULL; + struct hnae3_handle *h = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int ret;
- prelude_in = (struct cmd_pfc_storm_param *)buf_in; netdev = net_priv->netdev; h = hns3_get_handle(netdev); vport = hns3_cae_get_vport(h); @@ -41,16 +41,18 @@ static int hns3_cae_set_pfc_storm_cfg(struct hns3_nic_priv *net_priv, return 0; }
-static int hns3_cae_get_pfc_storm_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, - u32 out_size) +static int hns3_cae_get_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, + void *buf_out, u32 out_size) { - struct cmd_pfc_storm_param *prelude_in; - struct cmd_pfc_storm_param *info_dstn; - struct net_device *netdev; - struct hclge_vport *vport; - struct hnae3_handle *h; - struct hclge_dev *hdev; + struct cmd_pfc_storm_param *prelude_in = + (struct cmd_pfc_storm_param *)buf_in; + struct cmd_pfc_storm_param *info_dstn = + (struct cmd_pfc_storm_param *)buf_out; + struct net_device *netdev = NULL; + struct hclge_vport *vport = NULL; + struct hnae3_handle *h = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int check; int ret; @@ -61,8 +63,6 @@ static int hns3_cae_get_pfc_storm_cfg(struct hns3_nic_priv *net_priv, return -EFAULT; }
- prelude_in = (struct cmd_pfc_storm_param *)buf_in; - info_dstn = (struct cmd_pfc_storm_param *)buf_out; netdev = net_priv->netdev; h = hns3_get_handle(netdev); vport = hns3_cae_get_vport(h); @@ -89,10 +89,12 @@ static int hns3_cae_get_pfc_storm_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_pfc_storm_cfg(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct cmd_pfc_storm_param *para_in; + struct cmd_pfc_storm_param *para_in = + (struct cmd_pfc_storm_param *)buf_in; int check; int ret;
@@ -102,7 +104,6 @@ int hns3_cae_pfc_storm_cfg(struct hns3_nic_priv *net_priv, void *buf_in, return -EFAULT; }
- para_in = (struct cmd_pfc_storm_param *)buf_in; if (para_in->op_code == SET_PFC_STORM_PARA) { ret = hns3_cae_set_pfc_storm_cfg(net_priv, buf_in, in_size); } else if (para_in->op_code == GET_PFC_STORM_PARA) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h index ea6d0e918..ff0cc35 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pfc_storm.h @@ -24,5 +24,6 @@ struct cmd_pfc_storm_param { }; };
-int hns3_cae_pfc_storm_cfg(struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_pfc_storm_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c index dffc58e..3d04966 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c @@ -182,7 +182,7 @@ struct kthread_info { int tid; struct task_struct *task; int stop; - struct hns3_nic_priv *net_priv; + const struct hns3_nic_priv *net_priv; struct hns3_cae_pkt_cfg_info *in_info; struct hns3_cae_pkt_result_info *out_info; }; @@ -332,7 +332,7 @@ void __fill_the_pkt_head(struct net_device *netdev, u8 *payload, struct hns3_cae_pkt_cfg_info *in_info) { struct in_ifaddr *ifa_list = NULL; - u8 *pkt_payload; + u8 *pkt_payload = NULL; u32 vlan_tag; size_t count; int i; @@ -493,11 +493,11 @@ static int __hns3_cae_change_send_queue(int cur_queue, return queue_id; }
-int __hns3_cae_send_pkt(struct hns3_nic_priv *net_priv, +int __hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, struct hns3_cae_pkt_cfg_info *in_info, struct hns3_cae_pkt_result_info *out_info) { - struct hnae3_handle *handle; + struct hnae3_handle *handle = NULL; struct sk_buff *skb = NULL; u8 *payload = NULL; int pkt_len; @@ -626,7 +626,7 @@ int __hns3_cae_new_task(void *arg) }
int hns3_cae_create_new_thread(int tid, - struct hns3_nic_priv *net_priv, + const struct hns3_nic_priv *net_priv, struct hns3_cae_pkt_cfg_info *in_info, struct hns3_cae_pkt_result_info *out_info) { @@ -700,18 +700,18 @@ void hns3_cae_stop_new_thread(int tid) mutex_unlock(&pkt_mutex[tid]); }
-int hns3_cae_send_pkt(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_pkt_result_info *out_info; - struct hns3_cae_pkt_cfg_info *in_info; + struct hns3_cae_pkt_result_info *out_info = + (struct hns3_cae_pkt_result_info *)buf_out; + struct hns3_cae_pkt_cfg_info *in_info = + (struct hns3_cae_pkt_cfg_info *)buf_in; struct hnae3_handle *handle = NULL; int queue_id; int tid;
- in_info = (struct hns3_cae_pkt_cfg_info *)buf_in; - out_info = (struct hns3_cae_pkt_result_info *)buf_out; - if (!in_info || in_size < sizeof(struct hns3_cae_pkt_cfg_info) || !out_info || out_size < sizeof(struct hns3_cae_pkt_result_info)) { pr_err("input parameter error in %s function\n", __func__); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h index 4d3eff3..ea68c18 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h @@ -59,7 +59,7 @@ struct hns3_cae_pkt_result_info { int num; };
-int hns3_cae_send_pkt(struct hns3_nic_priv *net_priv, void *buf_in, +int hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); void hns3_cae_pkt_init(void); void hns3_cae_pkt_destroy(void); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c index a55e827..78d270e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c @@ -20,8 +20,8 @@ void fill_port_info(struct hclge_port_info *get_port_info_out, struct hclge_desc *port_desc, u32 bd_num) { - u8 *dest_data; - u8 *tmp_buff; + u8 *dest_data = NULL; + u8 *tmp_buff = NULL; u32 i;
dest_data = (u8 *)get_port_info_out; @@ -55,16 +55,18 @@ void fill_port_info(struct hclge_port_info *get_port_info_out, } }
-int hns3_get_port_info(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_get_port_info(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); struct hclge_vport *vport = hns3_cae_get_vport(handle); - struct hclge_port_info *get_port_info_out; + struct hclge_port_info *get_port_info_out = + (struct hclge_port_info *)buf_out; struct hclge_dev *hdev = vport->back; - struct hclge_desc *port_desc; + struct hclge_desc *port_desc = NULL; struct hclge_desc desc = {0}; - __le32 *desc_data; + __le32 *desc_data = NULL; u32 bd_num; int ret; u32 i; @@ -72,8 +74,6 @@ int hns3_get_port_info(struct hns3_nic_priv *net_priv, if (!buf_out || out_size < sizeof(struct hclge_port_info)) return -ENODEV;
- get_port_info_out = (struct hclge_port_info *)buf_out; - get_port_info_out->gpio_insert = 0;
hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_QUERY_PORTINFO_BD_NUM, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h index 66c7bb9..37cfdae 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.h @@ -87,7 +87,7 @@ struct hclge_lsport_info { u32 portinfo[6]; };
-int hns3_get_port_info(struct hns3_nic_priv *net_priv, +int hns3_get_port_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c index f641ba4..b9e8d1f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c @@ -4,20 +4,19 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_promisc.h"
-int hns3_read_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_read_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_promisc_cfg_cmd *req; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_promisc_cfg_cmd *req = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - u8 *out_buf; - bool check; + u8 *out_buf = NULL; + bool check = !buf_out || out_size < sizeof(u8); u8 enable; int ret;
- check = !buf_out || out_size < sizeof(u8); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; @@ -42,19 +41,18 @@ int hns3_read_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, return 0; }
-int hns3_set_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct promisc_mode_param *mode_param; - struct hclge_promisc_cfg_cmd *req; - struct hclge_vport *vport; - struct hclge_dev *hdev; + bool check = !buf_in || in_size < sizeof(struct promisc_mode_param); + struct promisc_mode_param *mode_param = NULL; + struct hclge_promisc_cfg_cmd *req = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct promisc_mode_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -103,15 +101,14 @@ int hns3_set_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, return ret; }
-int hns3_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct promisc_mode_param *mode_param; - bool check; + bool check = !buf_in || in_size < sizeof(struct promisc_mode_param); + struct promisc_mode_param *mode_param = NULL; int ret;
- check = !buf_in || in_size < sizeof(struct promisc_mode_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h index 1328fe1..51d4743 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.h @@ -26,7 +26,7 @@ struct promisc_mode_param { u8 type; };
-int hns3_promisc_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c index ffbd51d..a984107 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c @@ -3,9 +3,9 @@
#include "hns3_cae_qinfo.h"
-int hns3_get_q_rx_fbd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -16,9 +16,9 @@ int hns3_get_q_rx_fbd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_ebd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -29,9 +29,9 @@ int hns3_get_q_rx_ebd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_fbd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -40,9 +40,9 @@ int hns3_get_q_tx_fbd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_ebd(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -51,9 +51,9 @@ int hns3_get_q_tx_ebd(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_tail(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -64,9 +64,9 @@ int hns3_get_q_rx_tail(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_head(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num; int tqps_num;
@@ -77,9 +77,9 @@ int hns3_get_q_rx_head(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_tail(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -88,9 +88,9 @@ int hns3_get_q_tx_tail(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_head(struct hns3_nic_priv *net_priv, int ring_id) +int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -99,11 +99,13 @@ int hns3_get_q_tx_head(struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_cae_qinfo_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct qinfo_param *out_info; + struct qinfo_param *out_info = (struct qinfo_param *)buf_out; + bool check = !buf_in || in_size < sizeof(int) || !buf_out || + out_size < sizeof(struct qinfo_param); int tqps_num; int ring_id; int rx_head; @@ -114,17 +116,13 @@ int hns3_cae_qinfo_cfg(struct hns3_nic_priv *net_priv, int tx_tail; int tx_ebd; int tx_fbd; - bool check;
- check = !buf_in || in_size < sizeof(int) || - !buf_out || out_size < sizeof(struct qinfo_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
tqps_num = net_priv->ae_handle->kinfo.num_tqps; - out_info = (struct qinfo_param *)buf_out; ring_id = *((int *)buf_in);
if (ring_id >= tqps_num || ring_id < 0) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h index 3bce38ef..46ab594 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h @@ -25,15 +25,15 @@ struct qinfo_param { int rx_fbd; };
-int hns3_get_q_rx_fbd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_ebd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_fbd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_ebd(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_tail(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_head(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_tail(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_head(struct hns3_nic_priv *net_priv, int ring_id); -int hns3_cae_qinfo_cfg(struct hns3_nic_priv *net_priv, +int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id); +int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c index 7f7c4f9..ffd9e3f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c @@ -7,10 +7,10 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_qos.h"
-struct hclge_dev *get_val_hdev(struct hns3_nic_priv *net_priv) +struct hclge_dev *get_val_hdev(const struct hns3_nic_priv *net_priv) { - struct hnae3_handle *handle; - struct hclge_vport *vport; + struct hnae3_handle *handle = NULL; + struct hclge_vport *vport = NULL;
handle = net_priv->ae_handle; vport = hns3_cae_get_vport(handle); @@ -20,7 +20,7 @@ struct hclge_dev *get_val_hdev(struct hns3_nic_priv *net_priv) int hns3_cmd_rx_priv_wl_config(struct hclge_dev *hdev, u16 tc, u32 high, u32 low, u32 en) { - struct hclge_rx_priv_wl_buf *req; + struct hclge_rx_priv_wl_buf *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; int idx; @@ -61,15 +61,16 @@ int hns3_cmd_rx_priv_wl_config(struct hclge_dev *hdev, u16 tc, return 0; }
-int hns3_cae_rx_priv_buff_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_priv_buff_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_rx_priv_buff_wl_param *in_info; - bool check; + struct hns3_rx_priv_buff_wl_param *in_info = + (struct hns3_rx_priv_buff_wl_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_rx_priv_buff_wl_param);
- check = !buf_in || in_size < sizeof(struct hns3_rx_priv_buff_wl_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -80,7 +81,7 @@ int hns3_cae_rx_priv_buff_wl_cfg(struct hns3_nic_priv *net_priv, "This device is not support this cmd!\n"); return -EPERM; } - in_info = (struct hns3_rx_priv_buff_wl_param *)buf_in; + pr_err("wl is_set param, tc_no = 0x%x, hight = 0x%x, low = 0x%x\n", in_info->tc_no, in_info->high_wl, in_info->low_wl);
@@ -92,7 +93,7 @@ int hns3_cmd_common_thrd_config(struct hclge_dev *hdev, u16 tc, u32 high, u32 low, u32 en) { #define HNS3_CAE_THRD_ALLOC_BD_NUM 2 - struct hclge_rx_com_thrd *req; + struct hclge_rx_com_thrd *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; int idx; @@ -134,15 +135,16 @@ int hns3_cmd_common_thrd_config(struct hclge_dev *hdev, u16 tc, return 0; }
-int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_thrd_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_rx_priv_buff_wl_param *in_info; - bool check; + struct hns3_rx_priv_buff_wl_param *in_info = + (struct hns3_rx_priv_buff_wl_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_rx_priv_buff_wl_param);
- check = !buf_in || in_size < sizeof(struct hns3_rx_priv_buff_wl_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -153,7 +155,7 @@ int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, "This device is not support this cmd!\n"); return -EPERM; } - in_info = (struct hns3_rx_priv_buff_wl_param *)buf_in; + pr_info("common thrd is_set param, tc_no = 0x%x, hight = 0x%x, low = 0x%x\n", in_info->tc_no, in_info->high_wl, in_info->low_wl);
@@ -165,7 +167,7 @@ int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, int hns3_cmd_common_wl_config(struct hclge_dev *hdev, u32 high, u32 low, u32 en) { enum hclge_cmd_status status; - struct hclge_rx_com_wl *req; + struct hclge_rx_com_wl *req = NULL; struct hclge_desc desc;
req = (struct hclge_rx_com_wl *)desc.data; @@ -184,20 +186,22 @@ int hns3_cmd_common_wl_config(struct hclge_dev *hdev, u32 high, u32 low, u32 en) return 0; }
-int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_rx_priv_buff_wl_param *out_info; - struct hns3_rx_priv_buff_wl_param *in_info; + struct hns3_rx_priv_buff_wl_param *out_info = + (struct hns3_rx_priv_buff_wl_param *)buf_out; + struct hns3_rx_priv_buff_wl_param *in_info = + (struct hns3_rx_priv_buff_wl_param *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_rx_priv_buff_wl_param); enum hclge_cmd_status status; - struct hclge_rx_com_wl *req; - struct hclge_vport *vport; + struct hclge_rx_com_wl *req = NULL; + struct hclge_vport *vport = NULL; struct hclge_desc desc; - struct hclge_dev *hdev; - bool check; + struct hclge_dev *hdev = NULL;
- check = !buf_in || in_size < sizeof(struct hns3_rx_priv_buff_wl_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -205,8 +209,6 @@ int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - out_info = (struct hns3_rx_priv_buff_wl_param *)buf_out; - in_info = (struct hns3_rx_priv_buff_wl_param *)buf_in;
if (in_info->is_read == IS_WRITE) { status = hns3_cmd_common_wl_config(hdev, in_info->high_wl, @@ -237,22 +239,23 @@ int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv, return status; }
-int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_rx_priv_buff_cmd *recv; - struct hns3_rx_buff_param *out_info; - struct hns3_rx_buff_param *in_info; + struct hclge_rx_priv_buff_cmd *recv = NULL; + struct hns3_rx_buff_param *out_info = + (struct hns3_rx_buff_param *)buf_out; + struct hns3_rx_buff_param *in_info = + (struct hns3_rx_buff_param *)buf_in; enum hclge_cmd_status status; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; - bool check; + bool check = !buf_in || in_size < sizeof(struct hns3_rx_buff_param) || + !buf_out || out_size < sizeof(struct hns3_rx_buff_param); int i;
- check = !buf_in || in_size < sizeof(struct hns3_rx_buff_param) || - !buf_out || out_size < sizeof(struct hns3_rx_buff_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; @@ -260,8 +263,6 @@ int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - out_info = (struct hns3_rx_buff_param *)buf_out; - in_info = (struct hns3_rx_buff_param *)buf_in;
if (in_info->is_read == IS_READ) { hns3_cae_cmd_setup_basic_desc(&desc, @@ -283,22 +284,23 @@ int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_tx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_tx_buff_alloc_cmd *recv; - struct hns3_tx_buff_param *out_info; - struct hns3_tx_buff_param *in_info; + struct hclge_tx_buff_alloc_cmd *recv = NULL; + struct hns3_tx_buff_param *out_info = + (struct hns3_tx_buff_param *)buf_out; + struct hns3_tx_buff_param *in_info = + (struct hns3_tx_buff_param *)buf_in; enum hclge_cmd_status status; - struct hclge_vport *vport; + struct hclge_vport *vport = NULL; struct hclge_desc desc; - struct hclge_dev *hdev; - bool check; + struct hclge_dev *hdev = NULL; + bool check = !buf_in || in_size < sizeof(struct hns3_tx_buff_param) || + !buf_out || out_size < sizeof(struct hns3_tx_buff_param); int i;
- check = !buf_in || in_size < sizeof(struct hns3_tx_buff_param) || - !buf_out || out_size < sizeof(struct hns3_tx_buff_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; @@ -306,8 +308,6 @@ int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv,
vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back; - out_info = (struct hns3_tx_buff_param *)buf_out; - in_info = (struct hns3_tx_buff_param *)buf_in;
if (in_info->is_read == IS_READ) { hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_TX_BUFF_ALLOC, @@ -326,29 +326,28 @@ int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_show_comm_thres(struct hns3_nic_priv *net_priv, +int hns3_cae_show_comm_thres(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HNS3_CAE_THRD_ALLOC_BD_NUM 2 struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_total_priv_wl_param *out_info; - struct hclge_rx_com_thrd *req; + struct hns3_total_priv_wl_param *out_info = + (struct hns3_total_priv_wl_param *)buf_out; + struct hclge_rx_com_thrd *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; - bool check; + bool check = !buf_out || + out_size < sizeof(struct hns3_total_priv_wl_param); int idx; int i; int j;
- check = !buf_out || out_size < sizeof(struct hns3_total_priv_wl_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- out_info = (struct hns3_total_priv_wl_param *)buf_out; - for (i = 0; i < HNS3_CAE_THRD_ALLOC_BD_NUM; i++) { hns3_cae_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_RX_COM_THRD_ALLOC, @@ -378,29 +377,28 @@ int hns3_cae_show_comm_thres(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_show_rx_priv_wl(struct hns3_nic_priv *net_priv, +int hns3_cae_show_rx_priv_wl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HNS3_CAE_WL_ALLOC_BD_NUM 2 struct hclge_dev *hdev = get_val_hdev(net_priv); - struct hns3_total_priv_wl_param *out_info; - struct hclge_rx_priv_wl_buf *req; + struct hns3_total_priv_wl_param *out_info = + (struct hns3_total_priv_wl_param *)buf_out; + struct hclge_rx_priv_wl_buf *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc[2]; - bool check; + bool check = !buf_out || + out_size < sizeof(struct hns3_total_priv_wl_param); int idx; int i; int j;
- check = !buf_out || out_size < sizeof(struct hns3_total_priv_wl_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- out_info = (struct hns3_total_priv_wl_param *)buf_out; - for (i = 0; i < HNS3_CAE_WL_ALLOC_BD_NUM; i++) { hns3_cae_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_RX_PRIV_WL_ALLOC, @@ -430,19 +428,19 @@ int hns3_cae_show_rx_priv_wl(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_qcn_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define HCLGE_OPC_QCN_CFG 0x1A01 - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; struct hclge_desc desc; int qcn_bypass; u32 qcn_cfg; - bool check; + bool check = !buf_in || in_size < sizeof(int); int ret;
- check = !buf_in || in_size < sizeof(int); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h index 074ec29..125ca69 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.h @@ -43,28 +43,29 @@ enum opt_type { #define HNS3_QOS_QCN_BYPASS_MASK 0x20000 #define HNS3_QCN_SHAP_BYPASS_OFF 17
-int hns3_cae_rx_priv_buff_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_priv_buff_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_common_thrd_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_thrd_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_common_wl_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_common_wl_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_tx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_tx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_rx_buff_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rx_buff_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_show_rx_priv_wl(struct hns3_nic_priv *net_priv, +int hns3_cae_show_rx_priv_wl(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_show_comm_thres(struct hns3_nic_priv *net_priv, +int hns3_cae_show_comm_thres(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_qcn_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c index a3ed7eaa..fb37c73 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c @@ -3,10 +3,10 @@
#include "hns3_cae_qres.h"
-int hns3_get_qres_rx_value(struct hns3_nic_priv *net_priv, int ring_id, +int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id, enum param_type type) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int tqps_num; int num;
@@ -51,10 +51,10 @@ int hns3_get_qres_rx_value(struct hns3_nic_priv *net_priv, int ring_id, return num; }
-int hns3_get_qres_tx_value(struct hns3_nic_priv *net_priv, int ring_id, +int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id, enum param_type type) { - struct hns3_enet_ring *ring; + struct hns3_enet_ring *ring = NULL; int num;
ring = &net_priv->ring[ring_id]; @@ -97,7 +97,7 @@ int hns3_get_qres_tx_value(struct hns3_nic_priv *net_priv, int ring_id, return num; }
-void fill_queue_info(struct hns3_nic_priv *net_priv, +void fill_queue_info(const struct hns3_nic_priv *net_priv, struct qres_param *out_info, int ring_id) { /* rx info */ @@ -133,27 +133,26 @@ void fill_queue_info(struct hns3_nic_priv *net_priv, TX_SOFTWARE_TAIL_TYPE); }
-int hns3_cae_qres_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_qres_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct qres_bufin_param *qres_in_param; - struct hns3_enet_ring *ring; - struct qres_param *out_info; + struct qres_bufin_param *qres_in_param = + (struct qres_bufin_param *)buf_in; + struct qres_param *out_info = (struct qres_param *)buf_out; + struct hns3_enet_ring *ring = NULL; + bool check = !buf_in || in_size < sizeof(struct qres_bufin_param) || + !buf_out || out_size < sizeof(struct qres_param); int bd_index; int tqps_num; int ring_id; - bool check;
- check = !buf_in || in_size < sizeof(struct qres_bufin_param) || - !buf_out || out_size < sizeof(struct qres_param); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
tqps_num = net_priv->ae_handle->kinfo.num_tqps; - out_info = (struct qres_param *)buf_out; - qres_in_param = (struct qres_bufin_param *)buf_in; ring_id = qres_in_param->queue_id; bd_index = qres_in_param->BD_id;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h index 4920bd3..08b11ad 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.h @@ -64,7 +64,7 @@ enum qres_queue_type { TYPE_TX, };
-int hns3_cae_qres_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_qres_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c index 44dbb0b..1c95f65 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c @@ -12,18 +12,18 @@ #include "hclge_main.h" #include "hns3_cae_reset.h"
-int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_nic_reset(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define MIN_DOG_INTVAL 12 struct hnae3_handle *h = net_priv->ae_handle; - struct reset_param *reset_info; + struct reset_param *reset_info = (struct reset_param *)buf_in; enum hnae3_reset_type rst_type; - struct hclge_vport *vport; - struct hclge_dev *hdev; - bool check; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; + bool check = !buf_in || in_size < sizeof(struct reset_param);
- check = !buf_in || in_size < sizeof(struct reset_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -31,7 +31,6 @@ int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv,
vport = container_of(h, struct hclge_vport, nic); hdev = vport->back; - reset_info = (struct reset_param *)buf_in; rst_type = HNAE3_NONE_RESET;
if (test_bit(HCLGE_STATE_REMOVING, &hdev->state)) { @@ -61,24 +60,21 @@ int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_nic_timeout_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { + struct tx_timeout_param *out_info = + (struct tx_timeout_param *)buf_out; + struct tx_timeout_param *in_info = (struct tx_timeout_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct tx_timeout_param); struct net_device *netdev = net_priv->netdev; - struct tx_timeout_param *in_info; - struct tx_timeout_param *out_info; - bool check;
- check = !buf_in || in_size < sizeof(struct tx_timeout_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- in_info = (struct tx_timeout_param *)buf_in; - out_info = (struct tx_timeout_param *)buf_out; - if (in_info->wr_flag) { netdev->watchdog_timeo = (in_info->tx_timeout_size) * HZ; } else { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h index 68487b1..3439dd3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.h @@ -13,9 +13,10 @@ struct tx_timeout_param { u16 tx_timeout_size; };
-int hns3_cae_nic_reset(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_nic_timeout_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_nic_reset(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c index 3c0db59..f263156 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.c @@ -22,7 +22,7 @@ static int hclge_set_rss_algo_key(struct hclge_dev *hdev, const u8 hfunc, const u8 *key) { - struct hclge_rss_config_cmd *req; + struct hclge_rss_config_cmd *req = NULL; enum hclge_cmd_status status; struct hclge_desc desc; int key_offset; @@ -54,31 +54,26 @@ static int hclge_set_rss_algo_key(struct hclge_dev *hdev, return 0; }
-static int hns3_cae_set_rss_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_set_rss_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_rss_config_cmd *in_info; + struct hclge_rss_config_cmd *in_info = + (struct hclge_rss_config_cmd *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hclge_rss_config_cmd); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; + u8 *key = vport->rss_hash_key; enum hclge_cmd_status status; - struct hclge_vport *vport; - struct hclge_dev *hdev; u8 hash_config; - bool check; - u8 *key;
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - key = vport->rss_hash_key; - - check = !buf_in || in_size < sizeof(struct hclge_rss_config_cmd); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- in_info = (struct hclge_rss_config_cmd *)buf_in; hash_config = - ((u8)(vport->rss_algo) & (HASH_ALG_MASK)) | in_info->hash_config; + ((u8)(vport->rss_algo) & (HASH_ALG_MASK)) | in_info->hash_config; status = hclge_set_rss_algo_key(hdev, hash_config, key); if (status) { dev_err(&hdev->pdev->dev, @@ -90,27 +85,23 @@ static int hns3_cae_set_rss_cfg(struct hns3_nic_priv *net_priv, return 0; }
-static int hns3_cae_get_rss_cfg(struct hns3_nic_priv *net_priv, +static int hns3_cae_get_rss_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hclge_rss_config_cmd *req; + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + bool check = !buf_out || out_size < sizeof(u8); + struct hclge_rss_config_cmd *req = NULL; + struct hclge_dev *hdev = vport->back; enum hclge_cmd_status status; u8 *out_buf = (u8 *)buf_out; - struct hclge_vport *vport; - struct hclge_dev *hdev; struct hclge_desc desc; - bool check;
- check = !buf_out || out_size < sizeof(u8); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - hns3_cae_cmd_setup_basic_desc(&desc, HCLGE_OPC_RSS_GENERIC_CONFIG, true); status = hns3_cae_cmd_send(hdev, &desc, 1); @@ -125,14 +116,14 @@ static int hns3_cae_get_rss_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_rss_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_rss_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct rss_config *mode_param; - bool check; + bool check = !buf_in || in_size < sizeof(struct rss_config); + struct rss_config *mode_param = NULL; int ret;
- check = !buf_in || in_size < sizeof(struct rss_config); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h index 67c0242..584970b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_rss.h @@ -13,7 +13,7 @@ struct rss_config { u8 is_read; };
-int hns3_cae_rss_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_rss_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c index a6dba8d..ea69639 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.c @@ -102,16 +102,16 @@ static int hns3_get_stat_val(struct ring_stats *r_stats, char *val_name, return HCLGE_STATUS_SUCCESS; }
-static int hns3_read_stat_mode_cfg(struct hns3_nic_priv *nic_dev, +static int hns3_read_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct stat_sw_mode_param *stat_sw_param; - struct hnae3_knic_private_info *kinfo; + struct stat_sw_mode_param *stat_sw_param = NULL; + struct hnae3_knic_private_info *kinfo = NULL; u64 *ret_data = (u64 *)buf_out; - struct hnae3_handle *handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hnae3_handle *handle = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; u64 *val = NULL; u32 ring_idx; int ret; @@ -151,15 +151,15 @@ static int hns3_read_stat_mode_cfg(struct hns3_nic_priv *nic_dev, return HCLGE_STATUS_SUCCESS; }
-static int hns3_set_stat_mode_cfg(struct hns3_nic_priv *nic_dev, +static int hns3_set_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct stat_sw_mode_param *stat_sw_param; - struct hnae3_knic_private_info *kinfo; - struct hnae3_handle *handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct stat_sw_mode_param *stat_sw_param = NULL; + struct hnae3_knic_private_info *kinfo = NULL; + struct hnae3_handle *handle = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; u64 *val = NULL; u32 ring_idx; int ret; @@ -194,14 +194,14 @@ static int hns3_set_stat_mode_cfg(struct hns3_nic_priv *nic_dev, return HCLGE_STATUS_SUCCESS; }
-int hns3_stat_mode_cfg(struct hns3_nic_priv *nic_dev, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct stat_sw_mode_param *mode_param; - bool check; + struct stat_sw_mode_param *mode_param = NULL; + bool check = !buf_in || in_size < sizeof(struct stat_sw_mode_param); int ret;
- check = !buf_in || in_size < sizeof(struct stat_sw_mode_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; @@ -218,17 +218,17 @@ int hns3_stat_mode_cfg(struct hns3_nic_priv *nic_dev, return ret; }
-int hns3_cae_clean_stats(struct hns3_nic_priv *net_priv, +int hns3_cae_clean_stats(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { struct net_device *netdev = net_priv->netdev; - struct hnae3_knic_private_info *kinfo; - struct hnae3_handle *handle; - struct hns3_enet_ring *ring; - struct hclge_vport *vport; - struct hclge_dev *hdev; - struct hclge_tqp *tqp; + struct hnae3_knic_private_info *kinfo = NULL; + struct hnae3_handle *handle = NULL; + struct hns3_enet_ring *ring = NULL; + struct hclge_vport *vport = NULL; + struct hclge_dev *hdev = NULL; + struct hclge_tqp *tqp = NULL; int i;
handle = net_priv->ae_handle; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h index f8c19c5..a54ef8e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_stat.h @@ -43,10 +43,10 @@ struct ring_stats_name { u32 stats_namd_id; };
-int hns3_stat_mode_cfg(struct hns3_nic_priv *nic_dev, +int hns3_stat_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_clean_stats(struct hns3_nic_priv *net_priv, +int hns3_cae_clean_stats(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c index c5ec226..b3a89e2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c @@ -455,27 +455,25 @@ static int hns3_cae_tm_operate_nic_regs(struct hclge_dev *hdev, return 0; }
-int hns3_cae_queue_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_queue_cfg_info *out_info = NULL; - struct hns3_cae_queue_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_queue_cfg_info *out_info = + (struct hns3_cae_queue_cfg_info *)buf_out; + struct hns3_cae_queue_cfg_info *in_info = + (struct hns3_cae_queue_cfg_info *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_cae_queue_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; - bool check;
- check = !buf_in || in_size < sizeof(struct hns3_cae_queue_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_queue_cfg_info *)buf_in; - out_info = (struct hns3_cae_queue_cfg_info *)buf_out; is_read = in_info->is_read;
if (is_read) { @@ -547,32 +545,30 @@ static int hns3_cae_qs_set_new_map(int tc, u32 map, return 0; }
-int hns3_cae_qs_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_qs_cfg_info *out_info = NULL; - struct hns3_cae_qs_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_qs_cfg_info *out_info = + (struct hns3_cae_qs_cfg_info *)buf_out; + struct hns3_cae_qs_cfg_info *in_info = + (struct hns3_cae_qs_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_qs_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; int offset; u32 bp_map; - bool check; u16 qs_id; int gp_id; int ret; int tc;
- check = !buf_in || in_size < sizeof(struct hns3_cae_qs_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_qs_cfg_info *)buf_in; - out_info = (struct hns3_cae_qs_cfg_info *)buf_out; is_read = in_info->is_read; qs_id = in_info->qs_id; gp_id = qs_id / 32; @@ -694,29 +690,27 @@ static int hns3_cae_pri_pg_set_map(struct hclge_dev *hdev, return 0; }
-int hns3_cae_pri_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_pri_cfg_info *out_info = NULL; - struct hns3_cae_pri_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_pri_cfg_info *out_info = + (struct hns3_cae_pri_cfg_info *)buf_out; + struct hns3_cae_pri_cfg_info *in_info = + (struct hns3_cae_pri_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_pri_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; u16 pri_id; int cur_pg; - bool check; u8 bitmap;
- check = !buf_in || in_size < sizeof(struct hns3_cae_pri_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_pri_cfg_info *)buf_in; - out_info = (struct hns3_cae_pri_cfg_info *)buf_out; is_read = in_info->is_read;
pri_id = in_info->pri_id; @@ -824,27 +818,24 @@ int hns3_cae_pri_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_pg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_pg_cfg_info *out_info = NULL; - struct hns3_cae_pg_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_pg_cfg_info *out_info = + (struct hns3_cae_pg_cfg_info *)buf_out; + struct hns3_cae_pg_cfg_info *in_info = + (struct hns3_cae_pg_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_pg_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; int is_read; - bool check; u16 pg_id;
- check = !buf_in || in_size < sizeof(struct hns3_cae_pg_cfg_info); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_pg_cfg_info *)buf_in; - out_info = (struct hns3_cae_pg_cfg_info *)buf_out; is_read = in_info->is_read; pg_id = in_info->pg_id;
@@ -925,27 +916,25 @@ int hns3_cae_pg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, return 0; }
-int hns3_cae_port_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_port_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { - struct hns3_cae_port_cfg_info *out_info = NULL; - struct hns3_cae_port_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_port_cfg_info *out_info = + (struct hns3_cae_port_cfg_info *)buf_out; + struct hns3_cae_port_cfg_info *in_info = + (struct hns3_cae_port_cfg_info *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_port_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; u16 port_id; int is_read; - bool check;
- check = !buf_in || in_size < sizeof(struct hns3_cae_port_cfg_info); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_port_cfg_info *)buf_in; - out_info = (struct hns3_cae_port_cfg_info *)buf_out; is_read = in_info->is_read; port_id = in_info->port_id;
@@ -975,33 +964,33 @@ int hns3_cae_port_cfg(struct hns3_nic_priv *net_priv, return 0; }
-int hns3_cae_ets_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) +int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) { #define HNS3_TM_ETS_PORT_SHAPING 0x10820850 - struct hns3_cae_ets_cfg_info *out_info = NULL; - struct hns3_cae_ets_cfg_info *in_info = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; + struct hns3_cae_ets_cfg_info *out_info = + (struct hns3_cae_ets_cfg_info *)buf_out; + struct hns3_cae_ets_cfg_info *in_info = + (struct hns3_cae_ets_cfg_info *)buf_in; + bool check = !buf_in || + in_size < sizeof(struct hns3_cae_ets_cfg_info) || + !buf_out || + out_size < sizeof(struct hns3_cae_ets_cfg_info); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; u8 weight[MAX_TC_NUM]; int is_read; - bool check; u16 tc_id; u8 mac_id; u64 value; u64 addr;
- check = !buf_in || in_size < sizeof(struct hns3_cae_ets_cfg_info) || - !buf_out || out_size < sizeof(struct hns3_cae_ets_cfg_info); if (check) { pr_err("input parameter error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_ets_cfg_info *)buf_in; - out_info = (struct hns3_cae_ets_cfg_info *)buf_out; is_read = in_info->is_read; tc_id = in_info->tc_id; mac_id = in_info->mac_id; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h index 6a533d0..43627c6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h @@ -96,19 +96,21 @@ struct hns3_cae_ets_cfg_info { u8 flag; };
-int hns3_cae_queue_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_qs_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_pri_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_pg_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size); -int hns3_cae_port_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size); +int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_port_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_ets_cfg(struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c index 53e1354..42809f1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c @@ -18,7 +18,7 @@ static int hns3_cae_get_commit_id(struct hnae3_handle *handle, u8 *commit_id, { #define COMMIT_ID_LEN 8 struct hclge_vport *vport = hns3_cae_get_vport(handle); - struct hns3_cae_commit_id_param *resp; + struct hns3_cae_commit_id_param *resp = NULL; struct hclge_dev *hdev = vport->back; struct hclge_desc desc; int ret, i; @@ -40,28 +40,26 @@ static int hns3_cae_get_commit_id(struct hnae3_handle *handle, u8 *commit_id, return 0; }
-int hns3_cae_get_fw_ver(struct hns3_nic_priv *nic_dev, void *buf_in, +int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct hns3_cae_firmware_ver_param *out_buf; - struct hnae3_handle *handle; - struct hclge_vport *vport; - struct hclge_dev *hdev; - bool check; + struct hns3_cae_firmware_ver_param *out_buf = + (struct hns3_cae_firmware_ver_param *)buf_out; + bool check = !buf_out || + out_size < sizeof(struct hns3_cae_firmware_ver_param); + + struct hnae3_handle *handle = nic_dev->ae_handle; + struct hclge_vport *vport = + container_of(handle, struct hclge_vport, nic); + struct hclge_dev *hdev = vport->back; + u32 fw_ver;
- check = !buf_out || - out_size < sizeof(struct hns3_cae_firmware_ver_param); if (check) { pr_err("input param buf_out error in %s function\n", __func__); return -EFAULT; }
- handle = nic_dev->ae_handle; - vport = container_of(handle, struct hclge_vport, nic); - hdev = vport->back; - out_buf = (struct hns3_cae_firmware_ver_param *)buf_out; - if (hns3_cae_get_commit_id(handle, out_buf->commit_id, &out_buf->ncl_version)) return -EFAULT; @@ -75,9 +73,9 @@ int hns3_cae_get_fw_ver(struct hns3_nic_priv *nic_dev, void *buf_in, return 0; }
-int hns3_cae_get_driver_ver(struct hns3_nic_priv *nic_dev, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_cae_get_driver_ver(const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, + void *buf_out, u32 out_size) { if (!buf_out || out_size < strlen(HNS3_CAE_MOD_VERSION)) return -ENOMEM; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index b1e04e9..a6a07c7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.30.0" +#define HNS3_CAE_MOD_VERSION "1.9.32.0"
#define CMT_ID_LEN 8 #define RESV_LEN 3 @@ -24,9 +24,10 @@ struct hns3_cae_firmware_ver_param { u32 ncl_version; };
-int hns3_cae_get_fw_ver(struct hns3_nic_priv *nic_dev, void *buf_in, +int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size); -int hns3_cae_get_driver_ver(struct hns3_nic_priv *nic_dev, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); +int hns3_cae_get_driver_ver(const struct hns3_nic_priv *nic_dev, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c index 53186f8..c626a51 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.c @@ -14,31 +14,27 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_vlan.h"
-int hns3_cae_upmapping_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_upmapping_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { #define HCLGE_OPC_VLANUP_MAPPING_VF_TX_CFG 0x0F10 #define HCLGE_OPC_VLANUP_MAPPING_PORT_TX_CFG 0x0F11 - struct hns3_cae_vlanup_param *out_info; - struct hns3_cae_vlanup_param *in_info; - struct hclge_vport *vport; - struct hclge_dev *hdev; + struct hns3_cae_vlanup_param *out_info = + (struct hns3_cae_vlanup_param *)buf_out; + struct hns3_cae_vlanup_param *in_info = + (struct hns3_cae_vlanup_param *)buf_in; + bool check = !buf_in || in_size < sizeof(struct hns3_cae_vlanup_param); + struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); + struct hclge_dev *hdev = vport->back; struct hclge_desc desc; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cae_vlanup_param); if (check) { pr_err("input param buf_in error in %s function\n", __func__); return -EFAULT; }
- vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - in_info = (struct hns3_cae_vlanup_param *)buf_in; - out_info = (struct hns3_cae_vlanup_param *)buf_out; - if (in_info->is_read) { check = !buf_out || out_size < sizeof(struct hns3_cae_vlanup_param); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h index f983dbf..54739fb 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_vlan.h @@ -34,7 +34,7 @@ struct hns3_cae_vlanup_param { u8 module; };
-int hns3_cae_upmapping_cfg(struct hns3_nic_priv *net_priv, +int hns3_cae_upmapping_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c index ef26cb9..9862e4a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c @@ -18,7 +18,7 @@ static int hns3_get_sfp_present(struct hnae3_handle *handle, u32 *present) { struct hclge_vport *vport = hns3_cae_get_vport(handle); struct hclge_dev *hdev = vport->back; - struct hclge_sfp_present_cmd *resp; + struct hclge_sfp_present_cmd *resp = NULL; struct hclge_desc desc; int ret;
@@ -42,7 +42,7 @@ static int _hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, struct hclge_dev *hdev = vport->back; struct hclge_sfp_info *resp = NULL; u32 data_length; - u8 *temp_data; + u8 *temp_data = NULL; u32 temp_len; int ret; u32 i; @@ -98,7 +98,7 @@ static int hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, u16 offset, u16 size, u16 *outlen) { u16 tmp_size; - u8 *tmp_buff; + u8 *tmp_buff = NULL; u16 tmp_outlen; int ret;
@@ -144,26 +144,20 @@ int hns3_set_sfp_state(struct hnae3_handle *handle, bool en) return ret; }
-int hns3_xsfp_cfg(struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, - void *buf_out, u32 out_size) +int hns3_xsfp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, + u32 in_size, void *buf_out, u32 out_size) { - struct hns3_xsfp_info *xsfp_info_out; - struct hnae3_handle *handle; - struct hns3_cfg_xsfp *param; + struct hns3_xsfp_info *xsfp_info_out = (struct hns3_xsfp_info *)buf_out; + bool check = !buf_in || in_size < sizeof(struct hns3_cfg_xsfp) || + !buf_out || out_size < sizeof(struct hns3_xsfp_info); + struct hnae3_handle *handle = hns3_get_handle(net_priv->netdev); + struct hns3_cfg_xsfp *param = (struct hns3_cfg_xsfp *)buf_in; u32 sfp_present = 0; - bool check; int ret;
- check = !buf_in || in_size < sizeof(struct hns3_cfg_xsfp) || - !buf_out || out_size < sizeof(struct hns3_xsfp_info); if (check) return -ENODEV;
- handle = hns3_get_handle(net_priv->netdev); - - param = (struct hns3_cfg_xsfp *)buf_in; - xsfp_info_out = (struct hns3_xsfp_info *)buf_out; - ret = hns3_get_sfp_present(handle, &sfp_present); if (ret) { pr_err("nic_get_sfp_present error.\n"); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h index 9789327..afcf21b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.h @@ -45,7 +45,7 @@ struct hns3_xsfp_info { u8 sfp_info[STD_XSFP_INFO_MAX_SIZE]; };
-int hns3_xsfp_cfg(struct hns3_nic_priv *net_priv, void *buf_in, +int hns3_xsfp_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 152571d..17d7c09 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.30.0" +#define HNS3_MOD_VERSION "1.9.32.0"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 04b15f4..20729a2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.30.0" +#define HCLGE_MOD_VERSION "1.9.32.0" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 5986540..47c9f16 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.30.0" +#define HCLGEVF_MOD_VERSION "1.9.32.0" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, AM_SINGLE_PORT_MAX_TRANS config through bios. When hardware error occurs, this config will be cleared by resetting. So we should also add config in engine initialization. Besides, we should extrally add SAA enable config to avoid silent error.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/sec2/sec_main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 50bf595..0cadd6a 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -35,6 +35,8 @@ #define SEC_MASTER_GLOBAL_CTRL_SHUTDOWN 0x1 #define SEC_MASTER_TRANS_RETURN 0x300150 #define SEC_MASTER_TRANS_RETURN_RW 0x3 +#define SEC_AM_CFG_SIG_PORT_MAX_TRANS 0x300014 +#define SEC_SINGLE_PORT_MAX_TRANS 0x2060
#define SEC_CORE_INT_SOURCE 0x301010 #define SEC_CORE_INT_MASK 0x301000 @@ -75,6 +77,9 @@ #define SEC_RAS_NFE_ENB_MSK 0x177 #define SEC_RAS_DISABLE 0x0
+#define SEC_SAA_EN_REG 0x270 +#define SEC_SAA_EN 0x17F + #define SEC_MEM_START_INIT_REG 0x0100 #define SEC_MEM_INIT_DONE_REG 0x0104
@@ -470,6 +475,13 @@ static int sec_engine_init(struct hisi_sec *hisi_sec) void *base = qm->io_base + SEC_ENGINE_PF_CFG_OFF + SEC_ACC_COMMON_REG_OFF;
+ /* config sec single port max outstanding */ + writel(SEC_SINGLE_PORT_MAX_TRANS, + qm->io_base + SEC_AM_CFG_SIG_PORT_MAX_TRANS); + + /* config sec saa enable */ + writel(SEC_SAA_EN, base + SEC_SAA_EN_REG); + /* disable clock gate control */ reg = readl_relaxed(base + SEC_CONTROL_REG); reg &= ~BIT(3);
From: Zhao Weibo zhaoweibo3@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
-----------------------------------------
There is a useless header in hns_roce_cmd.c.Remove it. There is missing space in hns_roce_hw_v2.h and rdfx_common.h.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Signed-off-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_cmd.c | 1 - drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 2 +- drivers/infiniband/hw/hns/roce-customer/rdfx_common.h | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_cmd.c b/drivers/infiniband/hw/hns/hns_roce_cmd.c index 0569e2f..dc2c4ec 100644 --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c @@ -32,7 +32,6 @@
#include <linux/dmapool.h> #include <linux/platform_device.h> -#include "hns_roce_common.h" #include "hns_roce_device.h" #include "hns_roce_cmd.h"
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h index d9d3752..ba81aa6 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.h +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.h @@ -497,7 +497,7 @@ struct hns_roce_srq_context { #define SRQC_BYTE_60_SRQ_DB_RECORD_ADDR_S 1 #define SRQC_BYTE_60_SRQ_DB_RECORD_ADDR_M GENMASK(31, 1)
-enum{ +enum { V2_MPT_ST_VALID = 0x1, V2_MPT_ST_FREE = 0x2, }; diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_common.h b/drivers/infiniband/hw/hns/roce-customer/rdfx_common.h index a7181b2..589888e 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_common.h +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_common.h @@ -36,7 +36,7 @@ struct rdfx_hw_sys_attr {
#define HW_ATTRS_LIST_MEMBER(file_name)(&g_sysfs_roce_##file_name##_attr.attr)
-enum{ +enum { RECV_RDMA_WITH_IMM, RECV_SEND, RECV_SEND_WITH_IMM,
From: fengsheng fengsheng5@huawei.com
driver inclusion category: Bugfix bugzilla: NA CVE: NA
sysctl: fixup rcu critical area using ioremap which might sleep.
Signed-off-by: fengsheng fengsheng5@huawei.com Reviewed-by: zhangmu zhangmu1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/soc/hisilicon/sysctl/sysctl_drv.c | 2 +- drivers/soc/hisilicon/sysctl/sysctl_local_ras.c | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/drivers/soc/hisilicon/sysctl/sysctl_drv.c b/drivers/soc/hisilicon/sysctl/sysctl_drv.c index 3a45b0e..8bb6a9f 100644 --- a/drivers/soc/hisilicon/sysctl/sysctl_drv.c +++ b/drivers/soc/hisilicon/sysctl/sysctl_drv.c @@ -48,7 +48,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define DEBUG
-#define SYSCTL_DRIVER_VERSION "1.9.31.0" +#define SYSCTL_DRIVER_VERSION "1.9.32.0"
unsigned int g_sysctrl_debug;
diff --git a/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c b/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c index 0e38e82..d09ab42 100644 --- a/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c +++ b/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c @@ -302,9 +302,7 @@ static int sysctl_hest_hisi_parse_ghes(struct acpi_hest_header *hest_hdr, void * return -ENOMEM; }
- mutex_lock(&hisi_ghes_mutex); - list_add_rcu(&sysctl_ghes->list, &hisi_ghes_list); - mutex_unlock(&hisi_ghes_mutex); + list_add(&sysctl_ghes->list, &hisi_ghes_list);
return 0; } @@ -458,15 +456,12 @@ static int sysctl_hisi_error_handler(struct work_struct *work) struct ghes *sysctl_ghes = NULL; (void)work;
- rcu_read_lock(); - list_for_each_entry_rcu(sysctl_ghes, &hisi_ghes_list, list) { + list_for_each_entry(sysctl_ghes, &hisi_ghes_list, list) { if (!sysctl_ghes_proc(sysctl_ghes)) ret = NOTIFY_OK; } - rcu_read_unlock();
return ret; - }
/* acpi hisi hest init */ @@ -547,15 +542,10 @@ static void his_ghes_list_free(void) struct ghes *node = NULL; struct ghes *tmp_node = NULL;
- rcu_read_lock(); - list_for_each_entry_rcu(node, &hisi_ghes_list, list) { + list_for_each_entry(node, &hisi_ghes_list, list) { if (!node) continue;
- mutex_lock(&hisi_ghes_mutex); - list_del_rcu(&node->list); - mutex_unlock(&hisi_ghes_mutex); - apei_unmap_generic_address(&node->generic->error_status_address);
if (sysctl_is_hest_type_generic_v2(node)) @@ -581,16 +571,14 @@ static void his_ghes_list_free(void) kfree(tmp_node); tmp_node = NULL; } - - rcu_read_unlock(); }
void hip_sysctl_local_ras_exit(void) { + unregister_acpi_hed_notifier(&g_sysctl_ghes_hisi_notifier_hed); sysctl_proc_exit(); sysctl_tdh_deinit(); his_ghes_list_free(); - unregister_acpi_hed_notifier(&g_sysctl_ghes_hisi_notifier_hed);
pr_info("[INFO] hip sysctl local ras exit.\n"); }
From: Bohong Lin linbohong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
------------------------------------------------------------------
This patch is used to clear warnings for hns3 cae.
Signed-off-by: Bohong Lin linbohong@huawei.com Reviewed-by: Weiwei Deng dengweiwei@huawei.com Reviewed-by:Junxin Chen chenjunxin1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c | 6 +++--- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c index fa6c6b4..8d037f4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c @@ -330,7 +330,7 @@ int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, struct hclge_desc desc; int curr_dev_idx; int ret; - int i; + u32 i;
if (check) { pr_err("input parameter error in %s function\n", __func__); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c index 6346c9a..253972b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c @@ -96,7 +96,7 @@ int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, u32 mac_id; bool check = !buf_out || out_size < sizeof(struct hns3_cae_dfx_param); int ret; - int i; + u32 i;
if (check) { pr_err("input param buf_out error in %s function\n", __func__); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c index 96f0bb0..ad84900 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c @@ -147,7 +147,7 @@ static int copy_buf_out_to_user(struct msg_module *nt_msg, u32 out_size,
static int hns3_cae_netdev_match_check(struct net_device *netdev) { - struct ethtool_drvinfo drv_info; + struct ethtool_drvinfo drv_info = {0};
if (netdev->ethtool_ops->get_drvinfo) netdev->ethtool_ops->get_drvinfo(netdev, &drv_info); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c index ffd9e3f..0a98155 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c @@ -433,12 +433,12 @@ int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, u32 out_size) { #define HCLGE_OPC_QCN_CFG 0x1A01 + bool check = !buf_in || in_size < sizeof(32); struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; struct hclge_desc desc; - int qcn_bypass; + u32 qcn_bypass; u32 qcn_cfg; - bool check = !buf_in || in_size < sizeof(int); int ret;
if (check) { @@ -446,7 +446,7 @@ int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, return -EFAULT; }
- qcn_bypass = *(int *)(buf_in); + qcn_bypass = *(u32 *)(buf_in); vport = hns3_cae_get_vport(net_priv->ae_handle); hdev = vport->back;
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c index b3a89e2..1a3efcf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c @@ -509,9 +509,9 @@ static int hns3_cae_qs_set_new_map(int tc, u32 map, struct hns3_cae_qs_cfg_info *in_info) { u32 bp_map = map; + u16 offset; u16 qs_id; int gp_id; - int offset;
qs_id = in_info->qs_id; gp_id = qs_id / 32; @@ -557,7 +557,7 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); struct hclge_dev *hdev = vport->back; int is_read; - int offset; + u16 offset; u32 bp_map; u16 qs_id; int gp_id;
From: Junxin Chen chenjunxin1@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
----------------------------------
This patch fixes bug for hns3_cae_pkt and change version to 1.9.33.0
Signed-off-by: Junxin Chen chenjunxin1@huawei.com Reviewed-by: Zhaohui Zhong zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c | 2 ++ drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 24a5846..126923f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.32.0" +#define HNAE3_MOD_VERSION "1.9.33.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c index 3d04966..19ffa95 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c @@ -418,6 +418,7 @@ void __fill_the_pkt_head(struct net_device *netdev, u8 *payload, dev_err(&netdev->dev, "pkt_len(=%d) of ipv4 trace route pkt must big than %d.\n", in_info->pkt_len, IPV4_TRACEROUTE_PKT_LEN); + kfree(pkt_payload); return; }
@@ -436,6 +437,7 @@ void __fill_the_pkt_head(struct net_device *netdev, u8 *payload, dev_err(&netdev->dev, "pkt_len(=%d) of ipv6 extension pkt must big than %d.\n", in_info->pkt_len, IPV6_EXTENSION_PKT_LEN); + kfree(pkt_payload); return; } memcpy(payload, in_info->dst_mac, ETH_ALEN); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index a6a07c7..6360546 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.32.0" +#define HNS3_CAE_MOD_VERSION "1.9.33.0"
#define CMT_ID_LEN 8 #define RESV_LEN 3 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 17d7c09..a4cf1a8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.32.0" +#define HNS3_MOD_VERSION "1.9.33.0"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 20729a2..ed14bd8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.32.0" +#define HCLGE_MOD_VERSION "1.9.33.0" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 47c9f16..92bbe15 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.32.0" +#define HCLGEVF_MOD_VERSION "1.9.33.0" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095
From: Jian Shen shenjian15@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, the HNS3 driver sync and unsync mac address in function hns3_set_rx_mode(). For PF, it adds and deletes mac address directly in the path of dev_set_rx_mode(). If failed, it won't retry until next calling of hns3_set_rx_mode(). On the other hand, if request add and remove a same address many times at a short interval, each request must be done one by one, can't be merged. This patch refines it by recording the mac address in hns3_set_rx_mode(), and updating mac address in the service task. If failed, it will retry by the next calling of periodical service task. It also uses some state to mask each mac address in the mac list, which can help merge configure request for a same address.
Signed-off-by: Jian Shen shenjian15@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 + .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 381 ++++++++++++++++++++- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 12 + 3 files changed, 378 insertions(+), 18 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 886bf4c..2e148de 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -548,6 +548,9 @@ static int hns3_nic_uc_unsync(struct net_device *netdev, { struct hnae3_handle *h = hns3_get_handle(netdev);
+ if (ether_addr_equal(addr, netdev->dev_addr)) + return 0; + if (h->ae_algo->ops->rm_uc_addr) return h->ae_algo->ops->rm_uc_addr(h, addr);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 85a3608..3993d4d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -68,6 +68,8 @@ static int hclge_resume_vf_rate(struct hclge_dev *hdev); static void hclge_reset_vf_rate(struct hclge_dev *hdev);
+static void hclge_sync_mac_table(struct hclge_dev *hdev); + struct hnae3_ae_algo ae_algo;
static struct workqueue_struct *hclge_wq; @@ -1711,6 +1713,7 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) INIT_LIST_HEAD(&vport->vlan_list); INIT_LIST_HEAD(&vport->uc_mac_list); INIT_LIST_HEAD(&vport->mc_mac_list); + spin_lock_init(&vport->mac_list_lock);
if (i == 0) ret = hclge_vport_setup(vport, tqp_main_vport); @@ -4044,6 +4047,7 @@ static void hclge_periodical_service_task(struct hclge_dev *hdev) * updated when it is triggered by mbx. */ hclge_update_link_status(hdev); + hclge_sync_mac_table(hdev);
if (time_is_after_jiffies(hdev->last_serv_processed + HZ)) { delta = jiffies - hdev->last_serv_processed; @@ -7350,12 +7354,106 @@ static void hclge_update_umv_space(struct hclge_vport *vport, bool is_free) spin_unlock(&hdev->umv_lock); }
+static struct hclge_vport_mac_addr_cfg * +hclge_find_mac_node(struct list_head *list, const u8 *mac_addr) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + if (ether_addr_equal(mac_addr, mac_node->mac_addr)) + return mac_node; + } + return NULL; +} + +static void hclge_mac_node_convert(struct hclge_vport_mac_addr_cfg *mac_node, + enum HCLGE_MAC_ADDR_STATE state) +{ + switch (state) { + /* from set_rx_mode or tmp_add_list */ + case HCLGE_MAC_TO_ADD: + if (mac_node->state == HCLGE_MAC_TO_DEL || + mac_node->state == HCLGE_MAC_DEL_FAIL) + mac_node->state = HCLGE_MAC_ACTIVE; + break; + /* only from set_rx_mode */ + case HCLGE_MAC_TO_DEL: + if (mac_node->state == HCLGE_MAC_TO_ADD) { + list_del(&mac_node->node); + kfree(mac_node); + } else { + mac_node->state = HCLGE_MAC_TO_DEL; + } + break; + /* only from tmp_add_list, the mac_node->state won't be + * HCLGE_MAC_ACTIVE/HCLGE_MAC_DEL_FAIL/HCLGE_MAC_ADD_FAIL + */ + case HCLGE_MAC_DEL_FAIL: + if (mac_node->state == HCLGE_MAC_TO_ADD) + mac_node->state = HCLGE_MAC_ACTIVE; + break; + /* only from tmp_add_list, the mac_node->state won't be + * HCLGE_MAC_ACTIVE/HCLGE_MAC_DEL_FAIL/HCLGE_MAC_ADD_FAIL + */ + case HCLGE_MAC_ACTIVE: + if (mac_node->state == HCLGE_MAC_TO_ADD) + mac_node->state = HCLGE_MAC_ACTIVE; + + break; + } +} + +static int hclge_update_mac_list(struct hnae3_handle *handle, + enum HCLGE_MAC_ADDR_STATE state, + enum HCLGE_MAC_ADDR_TYPE mac_type, + const unsigned char *addr) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_vport_mac_addr_cfg *mac_node; + struct list_head *list; + + list = (mac_type == HCLGE_MAC_ADDR_UC) ? + &vport->uc_mac_list : &vport->mc_mac_list; + + set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, &vport->state); + + /* if the mac addr is already in the mac list, no need to add a new + * one into it, just check the mac addr state, convert it to a new + * new state, or just remove it, or do nothing. + */ + mac_node = hclge_find_mac_node(list, addr); + if (mac_node) { + hclge_mac_node_convert(mac_node, state); + return 0; + } + + /* if this address is never added, unnecessary to delete */ + if (state == HCLGE_MAC_TO_DEL) + return -ENOENT; + + mac_node = kzalloc(sizeof(*mac_node), GFP_ATOMIC); + if (!mac_node) + return -ENOMEM; + + mac_node->state = state; + ether_addr_copy(mac_node->mac_addr, addr); + list_add_tail(&mac_node->node, list); + + return 0; +} + static int hclge_add_uc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); + int ret; + + spin_lock_bh(&vport->mac_list_lock); + ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_UC, + addr); + spin_unlock_bh(&vport->mac_list_lock);
- return hclge_add_uc_addr_common(vport, addr); + return ret; }
int hclge_add_uc_addr_common(struct hclge_vport *vport, @@ -7425,8 +7523,14 @@ static int hclge_rm_uc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); + int ret;
- return hclge_rm_uc_addr_common(vport, addr); + spin_lock_bh(&vport->mac_list_lock); + ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_UC, + addr); + spin_unlock_bh(&vport->mac_list_lock); + + return ret; }
int hclge_rm_uc_addr_common(struct hclge_vport *vport, @@ -7459,8 +7563,14 @@ static int hclge_add_mc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); + int ret;
- return hclge_add_mc_addr_common(vport, addr); + spin_lock_bh(&vport->mac_list_lock); + ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_MC, + addr); + spin_unlock_bh(&vport->mac_list_lock); + + return ret; }
int hclge_add_mc_addr_common(struct hclge_vport *vport, @@ -7502,8 +7612,14 @@ static int hclge_rm_mc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); + int ret; + + spin_lock_bh(&vport->mac_list_lock); + ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_MC, + addr); + spin_unlock_bh(&vport->mac_list_lock);
- return hclge_rm_mc_addr_common(vport, addr); + return ret; }
int hclge_rm_mc_addr_common(struct hclge_vport *vport, @@ -7551,6 +7667,199 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport, return status; }
+static void hclge_sync_mac_list(struct hclge_vport *vport, + struct list_head *list, + int (*sync)(struct hclge_vport *, + const unsigned char *)) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + int ret; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + ret = sync(vport, mac_node->mac_addr); + if (!ret) { + mac_node->state = HCLGE_MAC_ACTIVE; + } else { + set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, + &vport->state); + break; + } + } +} + +static void hclge_unsync_mac_list(struct hclge_vport *vport, + struct list_head *list, + int (*unsync)(struct hclge_vport *, + const unsigned char *)) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + int ret; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + ret = unsync(vport, mac_node->mac_addr); + if (!ret || ret == -ENOENT) { + list_del(&mac_node->node); + kfree(mac_node); + } else { + mac_node->state = HCLGE_MAC_DEL_FAIL; + set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, + &vport->state); + break; + } + } +} + +static void hclge_sync_from_add_list(struct list_head *add_list, + struct list_head *mac_list) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp, *new_node; + + list_for_each_entry_safe(mac_node, tmp, add_list, node) { + /* if the mac address from tmp_add_list is not in the + * uc/mc_mac_list, it means have received a TO_DEL request + * during the time window of adding the mac address into mac + * table. if mac_node state is ACTIVE, then change it to TO_DEL, + * then it will be removed at next time. else it must be TO_ADD + * or ADD_FAIL, this address hasn't been added into mac table, + * so just remove the mac node. + */ + new_node = hclge_find_mac_node(mac_list, mac_node->mac_addr); + if (new_node) { + hclge_mac_node_convert(new_node, mac_node->state); + list_del(&mac_node->node); + kfree(mac_node); + } else if (mac_node->state == HCLGE_MAC_ACTIVE) { + mac_node->state = HCLGE_MAC_TO_DEL; + list_del(&mac_node->node); + list_add_tail(&mac_node->node, mac_list); + } else { + list_del(&mac_node->node); + kfree(mac_node); + } + } +} + +static void hclge_sync_from_del_list(struct list_head *del_list, + struct list_head *mac_list) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp, *new_node; + + list_for_each_entry_safe(mac_node, tmp, del_list, node) { + new_node = hclge_find_mac_node(mac_list, mac_node->mac_addr); + if (new_node) { + hclge_mac_node_convert(new_node, mac_node->state); + } else { + list_del(&mac_node->node); + list_add_tail(&mac_node->node, mac_list); + } + } +} + +static void hclge_rollback_add_list(struct list_head *add_list) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + + list_for_each_entry_safe(mac_node, tmp, add_list, node) { + list_del(&mac_node->node); + kfree(mac_node); + } +} + +static void hclge_rollback_del_list(struct list_head *del_list, + struct list_head *mac_list) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + + list_for_each_entry_safe(mac_node, tmp, del_list, node) { + list_del(&mac_node->node); + list_add_tail(&mac_node->node, mac_list); + } +} + +static void hclge_sync_vport_mac_table(struct hclge_vport *vport, + enum HCLGE_MAC_ADDR_TYPE mac_type) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp, *new_node; + struct list_head tmp_add_list, tmp_del_list; + struct list_head *list; + + INIT_LIST_HEAD(&tmp_add_list); + INIT_LIST_HEAD(&tmp_del_list); + + /* move the mac addr to the tmp_add_list and tmp_del_list, then + * we can add/delete these mac addr outside the spin lock + */ + list = (mac_type == HCLGE_MAC_ADDR_UC) ? + &vport->uc_mac_list : &vport->mc_mac_list; + + spin_lock_bh(&vport->mac_list_lock); + + list_for_each_entry_safe(mac_node, tmp, list, node) { + switch (mac_node->state) { + case HCLGE_MAC_TO_DEL: + case HCLGE_MAC_DEL_FAIL: + list_del(&mac_node->node); + list_add_tail(&mac_node->node, &tmp_del_list); + break; + case HCLGE_MAC_TO_ADD: + new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC); + if (!new_node) + goto clear_tmp_list; + ether_addr_copy(new_node->mac_addr, mac_node->mac_addr); + new_node->state = mac_node->state; + list_add_tail(&new_node->node, &tmp_add_list); + break; + default: + break; + } + } + + spin_unlock_bh(&vport->mac_list_lock); + + /* delete first, in order to get max mac table space for adding */ + if (mac_type == HCLGE_MAC_ADDR_UC) { + hclge_unsync_mac_list(vport, &tmp_del_list, + hclge_rm_uc_addr_common); + hclge_sync_mac_list(vport, &tmp_add_list, + hclge_add_uc_addr_common); + } else { + hclge_unsync_mac_list(vport, &tmp_del_list, + hclge_rm_mc_addr_common); + hclge_sync_mac_list(vport, &tmp_add_list, + hclge_add_mc_addr_common); + } + + /* if some mac addresses were added/deleted fail, move back to the + * mac_list, and retry at next time. + */ + spin_lock_bh(&vport->mac_list_lock); + + hclge_sync_from_del_list(&tmp_del_list, list); + hclge_sync_from_add_list(&tmp_add_list, list); + + spin_unlock_bh(&vport->mac_list_lock); + return; + +clear_tmp_list: + hclge_rollback_del_list(&tmp_del_list, list); + hclge_rollback_add_list(&tmp_add_list); + + spin_unlock_bh(&vport->mac_list_lock); +} + +static void hclge_sync_mac_table(struct hclge_dev *hdev) +{ + struct hclge_vport *vport = &hdev->vport[0]; + + if (hdev->serv_processed_cnt % HCLGE_MAC_TBL_SYNC_INTERVAL && + !test_and_clear_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, + &vport->state)) + return; + + hclge_sync_vport_mac_table(vport, HCLGE_MAC_ADDR_UC); + hclge_sync_vport_mac_table(vport, HCLGE_MAC_ADDR_MC); +} + void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, enum HCLGE_MAC_ADDR_TYPE mac_type) { @@ -7626,23 +7935,59 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, } }
+/* remove all mac address when uninitailize */ +static void hclge_uninit_mac_list(struct hclge_vport *vport, + enum HCLGE_MAC_ADDR_TYPE mac_type) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + struct list_head tmp_del_list, *list; + + INIT_LIST_HEAD(&tmp_del_list); + + list = (mac_type == HCLGE_MAC_ADDR_UC) ? + &vport->uc_mac_list : &vport->mc_mac_list; + + spin_lock_bh(&vport->mac_list_lock); + + list_for_each_entry_safe(mac_node, tmp, list, node) { + switch (mac_node->state) { + case HCLGE_MAC_TO_DEL: + case HCLGE_MAC_DEL_FAIL: + case HCLGE_MAC_ACTIVE: + list_del(&mac_node->node); + list_add_tail(&mac_node->node, &tmp_del_list); + break; + case HCLGE_MAC_TO_ADD: + list_del(&mac_node->node); + kfree(mac_node); + break; + } + } + + spin_unlock_bh(&vport->mac_list_lock); + + if (mac_type == HCLGE_MAC_ADDR_UC) + hclge_unsync_mac_list(vport, &tmp_del_list, + hclge_rm_uc_addr_common); + else + hclge_unsync_mac_list(vport, &tmp_del_list, + hclge_rm_mc_addr_common); + + list_for_each_entry_safe(mac_node, tmp, &tmp_del_list, node) { + list_del(&mac_node->node); + kfree(mac_node); + } +} + static void hclge_uninit_vport_mac_table(struct hclge_dev *hdev) { - struct hclge_vport_mac_addr_cfg *mac, *tmp; struct hclge_vport *vport; int i;
for (i = 0; i < hdev->num_alloc_vport; i++) { vport = &hdev->vport[i]; - list_for_each_entry_safe(mac, tmp, &vport->uc_mac_list, node) { - list_del(&mac->node); - kfree(mac); - } - - list_for_each_entry_safe(mac, tmp, &vport->mc_mac_list, node) { - list_del(&mac->node); - kfree(mac); - } + hclge_uninit_mac_list(vport, HCLGE_MAC_ADDR_UC); + hclge_uninit_mac_list(vport, HCLGE_MAC_ADDR_MC); } }
@@ -7823,18 +8168,18 @@ static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p, }
if ((!is_first || is_kdump_kernel()) && - hclge_rm_uc_addr(handle, hdev->hw.mac.mac_addr)) + hclge_rm_uc_addr_common(vport, hdev->hw.mac.mac_addr)) dev_warn(&hdev->pdev->dev, "remove old uc mac address fail.\n");
- ret = hclge_add_uc_addr(handle, new_addr); + ret = hclge_add_uc_addr_common(vport, new_addr); if (ret) { dev_err(&hdev->pdev->dev, "add uc mac address fail, ret =%d.\n", ret);
if (!is_first && - hclge_add_uc_addr(handle, hdev->hw.mac.mac_addr)) + hclge_add_uc_addr_common(vport, hdev->hw.mac.mac_addr)) dev_err(&hdev->pdev->dev, "restore uc mac address fail.\n");
@@ -9933,6 +10278,7 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) hclge_reset_vf_rate(hdev); hclge_misc_affinity_teardown(hdev); hclge_state_uninit(hdev); + hclge_uninit_vport_mac_table(hdev);
if (mac->phydev) mdiobus_unregister(mac->mdio_bus); @@ -9950,7 +10296,6 @@ static void hclge_uninit_ae_dev(struct hnae3_ae_dev *ae_dev) hclge_misc_irq_uninit(hdev); hclge_pci_uninit(hdev); mutex_destroy(&hdev->vport_lock); - hclge_uninit_vport_mac_table(hdev); hclge_uninit_vport_vlan_table(hdev); ae_dev->priv = NULL; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index ed14bd8..3508e61 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -635,9 +635,17 @@ struct hclge_fd_ad_data { u16 rule_id; };
+enum HCLGE_MAC_ADDR_STATE { + HCLGE_MAC_TO_ADD, + HCLGE_MAC_TO_DEL, + HCLGE_MAC_DEL_FAIL, + HCLGE_MAC_ACTIVE +}; + struct hclge_vport_mac_addr_cfg { struct list_head node; int hd_tbl_status; + enum HCLGE_MAC_ADDR_STATE state; u8 mac_addr[ETH_ALEN]; };
@@ -866,8 +874,11 @@ struct hclge_rss_tuple_cfg { u8 ipv6_fragment_en; };
+#define HCLGE_MAC_TBL_SYNC_INTERVAL 3U + enum HCLGE_VPORT_STATE { HCLGE_VPORT_STATE_ALIVE, + HCLGE_VPORT_STATE_MAC_TBL_CHANGE, HCLGE_VPORT_STATE_MAX };
@@ -933,6 +944,7 @@ struct hclge_vport { u32 trusted; u16 promisc_enable;
+ spinlock_t mac_list_lock; /* protect mac address need to add/detele */ struct list_head uc_mac_list; /* Store VF unicast table */ struct list_head mc_mac_list; /* Store VF multicast table */ };
From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, the HNS3 would remove all vlan/uc mac/mc mac table entry no matter what kind of reset had triggered, and restore them after reset done.
Based on the analysis of different kind of reset, the entry table removing and restoring will take some change as below: 1.IMP/GLOBAL reseet HW would clear all hw table when resetting. -PF need to restore the table entry in sw list after reset done. -VF need to send a message to PF, request to restore table entry. 2.PF function reset/PF FLR reset/VF function reset In this case, reset as a status change and the table entry had no change. -So PF and VF needn't to take any operation on the table entry. 3.VF FLR reset PF would get a message when VF was in FLR status. Due to PF didn't know what kink of VF FLR status(init/uninit/reset). so PF would clear VF table entry and reclaim resources of table entry. -If VF init, PF would clear all the sw list avoid the sw list leftover. -If VF uninit, PF do nothing after clear VF table entry. -If VF reset, VF would send a message to PF, and request to restore the table entry in sw list.
Signed-off-by: Guojia Liao liaoguojia@huawei.com Signed-off-by: Jian Shen shenjian15@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 6 + drivers/net/ethernet/hisilicon/hns3/hnae3.h | 3 - drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 80 ------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 236 ++++++++++++++++----- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 3 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 58 +++-- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 47 +++- 7 files changed, 279 insertions(+), 154 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index e18e301..7b85b8d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -45,6 +45,7 @@ enum HCLGE_MBX_OPCODE { HCLGE_MBX_GET_MEDIA_TYPE, /* (VF -> PF) get media type */ HCLGE_MBX_PUSH_PROMISC_INFO, /* (PF -> VF) push vf promisc info */ HCLGE_MBX_VF_UNINIT, /* (VF -> PF) vf is unintializing */ + HCLGE_MBX_HANDLE_VF_TBL, /* (VF -> PF) store/clear hw table */
HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf flr status */ HCLGE_MBX_PUSH_LINK_STATUS, /* (M7 -> PF) get port link status */ @@ -70,6 +71,11 @@ enum hclge_mbx_vlan_cfg_subcode { HCLGE_MBX_GET_PORT_BASE_VLAN_STATE, /* get port based vlan state */ };
+enum hclge_mbx_tbl_cfg_subcode { + HCLGE_MBX_HW_TBL_RESTORE, + HCLGE_MBX_VPORT_LIST_CLEAR, +}; + #define HCLGE_MBX_MAX_MSG_SIZE 14 #define HCLGE_MBX_MAX_RESP_DATA_SIZE 8 #define HCLGE_MBX_MAX_RING_CHAIN_PARAM_NUM 4 diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 126923f..261a2c1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -357,8 +357,6 @@ struct hnae3_ae_dev { * Set vlan filter config of Ports * set_vf_vlan_filter() * Set vlan filter config of vf - * restore_vlan_table() - * Restore vlan filter entries after reset * enable_hw_strip_rxvtag() * Enable/disable hardware strip vlan tag of packets received * set_gro_en @@ -536,7 +534,6 @@ struct hnae3_ae_ops { void (*set_timer_task)(struct hnae3_handle *handle, bool enable); int (*mac_connect_phy)(struct hnae3_handle *handle); void (*mac_disconnect_phy)(struct hnae3_handle *handle); - void (*restore_vlan_table)(struct hnae3_handle *handle); bool (*reset_done)(struct hnae3_handle *handle, bool done); void (*handle_imp_error)(struct hnae3_handle *handle); #ifdef CONFIG_HNS3_TEST diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 2e148de..3c306a8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -3981,17 +3981,6 @@ static void hns3_uninit_phy(struct net_device *netdev) h->ae_algo->ops->mac_disconnect_phy(h); }
-static int hns3_restore_fd_rules(struct net_device *netdev) -{ - struct hnae3_handle *h = hns3_get_handle(netdev); - int ret = 0; - - if (h->ae_algo->ops->restore_fd_rules) - ret = h->ae_algo->ops->restore_fd_rules(h); - - return ret; -} - static void hns3_del_all_fd_rules(struct net_device *netdev, bool clear_list) { struct hnae3_handle *h = hns3_get_handle(netdev); @@ -4237,35 +4226,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) return hns3_nic_set_real_num_queue(ndev); }
-static int hns3_recover_hw_addr(struct net_device *ndev) -{ - struct netdev_hw_addr_list *list; - struct netdev_hw_addr *ha, *tmp; - int ret = 0; - - netif_addr_lock_bh(ndev); - /* go through and sync uc_addr entries to the device */ - list = &ndev->uc; - list_for_each_entry_safe(ha, tmp, &list->list, list) { - ret = hns3_nic_uc_sync(ndev, ha->addr); - if (ret) - goto out; - } - - /* go through and sync mc_addr entries to the device */ - list = &ndev->mc; - list_for_each_entry_safe(ha, tmp, &list->list, list) - if (ha->refcount > 1) { - ret = hns3_nic_mc_sync(ndev, ha->addr); - if (ret) - goto out; - } - -out: - netif_addr_unlock_bh(ndev); - return ret; -} - static void hns3_remove_hw_addr(struct net_device *netdev) { struct netdev_hw_addr_list *list; @@ -4446,7 +4406,6 @@ static void hns3_restore_coal(struct hns3_nic_priv *priv)
static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) { - struct hnae3_ae_dev *ae_dev = pci_get_drvdata(handle->pdev); struct hnae3_knic_private_info *kinfo = &handle->kinfo; struct net_device *ndev = kinfo->netdev; struct hns3_nic_priv *priv = netdev_priv(ndev); @@ -4454,15 +4413,6 @@ static int hns3_reset_notify_down_enet(struct hnae3_handle *handle) if (test_and_set_bit(HNS3_NIC_STATE_RESETTING, &priv->state)) return 0;
- /* it is cumbersome for hardware to pick-and-choose entries for deletion - * from table space. Hence, for function reset software intervention is - * required to delete the entries - */ - if (hns3_dev_ongoing_func_reset(ae_dev)) { - hns3_remove_hw_addr(ndev); - hns3_del_all_fd_rules(ndev, false); - } - if (!netif_running(ndev)) return 0;
@@ -4554,33 +4504,6 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) return ret; }
-static int hns3_reset_notify_restore_enet(struct hnae3_handle *handle) -{ - struct net_device *netdev = handle->kinfo.netdev; - bool vlan_filter_enable; - int ret; - - ret = hns3_init_mac_addr(netdev); - if (ret) - return ret; - - ret = hns3_recover_hw_addr(netdev); - if (ret) - return ret; - - ret = hns3_update_promisc_mode(netdev, handle->netdev_flags); - if (ret) - return ret; - - vlan_filter_enable = netdev->flags & IFF_PROMISC ? false : true; - hns3_enable_vlan_filter(netdev, vlan_filter_enable); - - if (handle->ae_algo->ops->restore_vlan_table) - handle->ae_algo->ops->restore_vlan_table(handle); - - return hns3_restore_fd_rules(netdev); -} - static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle) { struct net_device *netdev = handle->kinfo.netdev; @@ -4630,9 +4553,6 @@ static int hns3_reset_notify(struct hnae3_handle *handle, case HNAE3_UNINIT_CLIENT: ret = hns3_reset_notify_uninit_enet(handle); break; - case HNAE3_RESTORE_CLIENT: - ret = hns3_reset_notify_restore_enet(handle); - break; default: break; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3993d4d..c75e24e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -69,6 +69,7 @@ static void hclge_reset_vf_rate(struct hclge_dev *hdev);
static void hclge_sync_mac_table(struct hclge_dev *hdev); +static int hclge_restore_hw_table(struct hclge_dev *hdev);
struct hnae3_ae_algo ae_algo;
@@ -3741,7 +3742,11 @@ static int hclge_reset_stack(struct hclge_dev *hdev) if (ret) return ret;
- return hclge_notify_client(hdev, HNAE3_RESTORE_CLIENT); + /* imp rest and global reset need to restore PF tbl */ + if (hdev->reset_type == HNAE3_IMP_RESET || + hdev->reset_type == HNAE3_GLOBAL_RESET) + return hclge_restore_hw_table(hdev); + return 0; }
static void hclge_reset(struct hclge_dev *hdev) @@ -7555,6 +7560,8 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport, ret = hclge_remove_mac_vlan_tbl(vport, &req); if (!ret) hclge_update_umv_space(vport, true); + else if (ret == -ENOENT) + ret = 0;
return ret; } @@ -7654,13 +7661,7 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport, /* Not all the vfid is zero, update the vfid */ status = hclge_add_mac_vlan_tbl(vport, &req, desc);
- } else { - /* Maybe this mac address is in mta table, but it cannot be - * deleted here because an entry of mta represents an address - * range rather than a specific address. the delete action to - * all entries will take effect in update_mta_status called by - * hns3_nic_set_rx_mode. - */ + } else if (status == -ENOENT) { status = 0; }
@@ -7874,7 +7875,7 @@ void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, return;
mac_cfg->hd_tbl_status = true; - memcpy(mac_cfg->mac_addr, mac_addr, ETH_ALEN); + ether_addr_copy(mac_cfg->mac_addr, mac_addr);
list = (mac_type == HCLGE_MAC_ADDR_UC) ? &vport->uc_mac_list : &vport->mc_mac_list; @@ -7883,27 +7884,16 @@ void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, }
void hclge_rm_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, - bool is_write_tbl, enum HCLGE_MAC_ADDR_TYPE mac_type) { struct hclge_vport_mac_addr_cfg *mac_cfg, *tmp; struct list_head *list; - bool uc_flag, mc_flag;
list = (mac_type == HCLGE_MAC_ADDR_UC) ? &vport->uc_mac_list : &vport->mc_mac_list;
- uc_flag = is_write_tbl && mac_type == HCLGE_MAC_ADDR_UC; - mc_flag = is_write_tbl && mac_type == HCLGE_MAC_ADDR_MC; - list_for_each_entry_safe(mac_cfg, tmp, list, node) { if (ether_addr_equal(mac_cfg->mac_addr, mac_addr)) { - if (uc_flag && mac_cfg->hd_tbl_status) - hclge_rm_uc_addr_common(vport, mac_addr); - - if (mc_flag && mac_cfg->hd_tbl_status) - hclge_rm_mc_addr_common(vport, mac_addr); - list_del(&mac_cfg->node); kfree(mac_cfg); break; @@ -8149,12 +8139,54 @@ static void hclge_get_mac_addr(struct hnae3_handle *handle, u8 *p) ether_addr_copy(p, hdev->hw.mac.mac_addr); }
+/* use new node to replace old node in the list, if old address is still in + * mac table, add it to list tail, and try to remove in service task + */ +static void hclge_replace_mac_node(struct list_head *list, const u8 *old_addr, + const u8 *new_addr, bool keep_old) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *new_node; + + mac_node = hclge_find_mac_node(list, old_addr); + if (!mac_node) { + new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC); + if (!new_node) + return; + new_node->state = HCLGE_MAC_ACTIVE; + ether_addr_copy(new_node->mac_addr, new_addr); + list_add_tail(&new_node->node, list); + return; + } + + mac_node->state = HCLGE_MAC_ACTIVE; + ether_addr_copy(mac_node->mac_addr, new_addr); + if (keep_old) { + new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC); + if (!new_node) + return; + new_node->state = HCLGE_MAC_TO_DEL; + ether_addr_copy(new_node->mac_addr, old_addr); + list_add_tail(&new_node->node, list); + } +} + +static void hclge_modify_mac_node_state(struct list_head *list, const u8 *addr, + enum HCLGE_MAC_ADDR_STATE state) +{ + struct hclge_vport_mac_addr_cfg *mac_node; + + mac_node = hclge_find_mac_node(list, addr); + if (mac_node) + mac_node->state = state; +} + static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p, bool is_first) { const unsigned char *new_addr = (const unsigned char *)p; struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; + bool old_mac_removed = true; int ret;
/* mac addr check */ @@ -8168,9 +8200,11 @@ static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p, }
if ((!is_first || is_kdump_kernel()) && - hclge_rm_uc_addr_common(vport, hdev->hw.mac.mac_addr)) + hclge_rm_uc_addr_common(vport, hdev->hw.mac.mac_addr)) { dev_warn(&hdev->pdev->dev, "remove old uc mac address fail.\n"); + old_mac_removed = false; + }
ret = hclge_add_uc_addr_common(vport, new_addr); if (ret) { @@ -8178,14 +8212,38 @@ static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p, "add uc mac address fail, ret =%d.\n", ret);
- if (!is_first && - hclge_add_uc_addr_common(vport, hdev->hw.mac.mac_addr)) - dev_err(&hdev->pdev->dev, - "restore uc mac address fail.\n"); + if (!is_first) { + ret = hclge_add_uc_addr_common(vport, + hdev->hw.mac.mac_addr); + if (ret) { + old_mac_removed = true; + dev_err(&hdev->pdev->dev, + "restore uc mac address fail.\n"); + } else { + old_mac_removed = false; + } + } + + /* if old dev addr restore failed, add to the uc mac list, + * and try to restore it in service task + */ + if (old_mac_removed) + hclge_modify_mac_node_state(&vport->uc_mac_list, + hdev->hw.mac.mac_addr, + HCLGE_MAC_TO_ADD);
return -EIO; }
+ /* new dev addr add success, replace the old dev addr in uc mac list. + * if old dev addr delete fail, keep it in the mac list, and try to del + * it in service task. + */ + spin_lock_bh(&vport->mac_list_lock); + hclge_replace_mac_node(&vport->uc_mac_list, hdev->hw.mac.mac_addr, + new_addr, !old_mac_removed); + spin_unlock_bh(&vport->mac_list_lock); + ret = hclge_pause_addr_cfg(hdev, new_addr); if (ret) { dev_err(&hdev->pdev->dev, @@ -8420,8 +8478,8 @@ static int hclge_set_vlan_filter_hw(struct hclge_dev *hdev, __be16 proto, if (is_kill && !test_and_clear_bit(vport_id, hdev->vlan_table[vlan_id])) { dev_err(&hdev->pdev->dev, - "Delete port vlan failed, vport %u is not in vlan %u\n", - vport_id, vlan_id); + "Delete port vlan failed, vlan %u is not in vport %u\n", + vlan_id, vport_id); return -EINVAL; }
@@ -8670,6 +8728,9 @@ static void hclge_add_vport_vlan_table(struct hclge_vport *vport, u16 vlan_id, { struct hclge_vport_vlan_cfg *vlan;
+ if (!list_empty(&vport->vlan_list) && !vlan_id) + return; + vlan = kzalloc(sizeof(*vlan), GFP_KERNEL); if (!vlan) return; @@ -8732,6 +8793,9 @@ void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list) struct hclge_dev *hdev = vport->back;
list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) { + if (!vlan->vlan_id) + continue; + if (vlan->hd_tbl_status) hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), @@ -8763,42 +8827,101 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev) } }
-void hclge_restore_vlan_table(struct hnae3_handle *handle) +void hclge_restore_vport_vlan_table(struct hclge_vport *vport) { - struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport_vlan_cfg *vlan, *tmp; struct hclge_dev *hdev = vport->back; u16 vlan_proto; u16 state, vlan_id; - int i; + int ret;
- for (i = 0; i < hdev->num_alloc_vport; i++) { - vport = &hdev->vport[i]; - vlan_proto = vport->port_base_vlan_cfg.vlan_info.vlan_proto; - vlan_id = vport->port_base_vlan_cfg.vlan_info.vlan_tag; - state = vport->port_base_vlan_cfg.state; + vlan_proto = vport->port_base_vlan_cfg.vlan_info.vlan_proto; + vlan_id = vport->port_base_vlan_cfg.vlan_info.vlan_tag; + state = vport->port_base_vlan_cfg.state;
- if (state != HNAE3_PORT_BASE_VLAN_DISABLE) { - hclge_set_vlan_filter_hw(hdev, htons(vlan_proto), - vport->vport_id, vlan_id, - false); - continue; - } + if (state != HNAE3_PORT_BASE_VLAN_DISABLE) { + clear_bit(vport->vport_id, hdev->vlan_table[vlan_id]); + hclge_set_vlan_filter_hw(hdev, htons(vlan_proto), + vport->vport_id, vlan_id, + false); + return; + }
- list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) { - int ret; + list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) { + ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), + vport->vport_id, + vlan->vlan_id, false); + if (ret) + break; + vlan->hd_tbl_status = true; + } +}
- if (!vlan->hd_tbl_status) - continue; - ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), - vport->vport_id, - vlan->vlan_id, false); - if (ret) - break; +void hclge_restore_vport_mac_table(struct hclge_vport *vport) +{ + struct hclge_vport_mac_addr_cfg *mac_cfg, *tmp; + int ret; + + list_for_each_entry_safe(mac_cfg, tmp, &vport->uc_mac_list, node) { + ret = hclge_add_uc_addr_common(vport, mac_cfg->mac_addr); + if (!ret) + mac_cfg->hd_tbl_status = true; + else if (ret == -ENOSPC) + break; + } + + list_for_each_entry_safe(mac_cfg, tmp, &vport->mc_mac_list, node) { + ret = hclge_add_mc_addr_common(vport, mac_cfg->mac_addr); + if (!ret) + mac_cfg->hd_tbl_status = true; + } +} + +/* For global reset and imp reset, hardware will clear the mac table, + * so we change the mac address state from ACTIVE to TO_ADD, then they + * can be restored in the service task after reset complete. Furtherly, + * the mac addresses with state TO_DEL or DEL_FAIL are unnecessary to + * be restored after reset, so just remove these mac nodes from mac_list. + */ +static void hclge_mac_node_convert_for_reset(struct list_head *list) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + if (mac_node->state == HCLGE_MAC_ACTIVE) { + mac_node->state = HCLGE_MAC_TO_ADD; + } else if (mac_node->state == HCLGE_MAC_TO_DEL || + mac_node->state == HCLGE_MAC_DEL_FAIL) { + list_del(&mac_node->node); + kfree(mac_node); } } }
+static void hclge_restore_pf_mac_table(struct hclge_vport *vport) +{ + /* move the mac addr to the tmp_add_list and tmp_del_list, then + * we can add/delete these mac addr outside the spin lock + */ + spin_lock_bh(&vport->mac_list_lock); + + hclge_mac_node_convert_for_reset(&vport->uc_mac_list); + hclge_mac_node_convert_for_reset(&vport->mc_mac_list); + + spin_unlock_bh(&vport->mac_list_lock); +} + +static int hclge_restore_hw_table(struct hclge_dev *hdev) +{ + struct hclge_vport *vport = &hdev->vport[0]; + struct hnae3_handle *handle = &vport->nic; + + hclge_restore_pf_mac_table(vport); + hclge_restore_vport_vlan_table(vport); + + return hclge_restore_fd_entries(handle); +} + int hclge_en_hw_strip_rxvtag(struct hnae3_handle *handle, bool enable) { struct hclge_vport *vport = hclge_get_vport(handle); @@ -8992,7 +9115,7 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto, }
if (!ret) { - if (is_kill) + if (is_kill && vlan_id != 0) hclge_rm_vport_vlan_table(vport, vlan_id, false); else hclge_add_vport_vlan_table(vport, vlan_id, @@ -10168,8 +10291,14 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) set_bit(HCLGE_STATE_DOWN, &hdev->state);
hclge_stats_clear(hdev); - memset(hdev->vlan_table, 0, sizeof(hdev->vlan_table)); - memset(hdev->vf_vlan_full, 0, sizeof(hdev->vf_vlan_full)); + /* NOTE: pf reset needn't to clear or restore pf and vf table entry. + * so here should not clean table in memory. + */ + if (hdev->reset_type == HNAE3_IMP_RESET || + hdev->reset_type == HNAE3_GLOBAL_RESET) { + memset(hdev->vlan_table, 0, sizeof(hdev->vlan_table)); + memset(hdev->vf_vlan_full, 0, sizeof(hdev->vf_vlan_full)); + }
ret = hclge_cmd_init(hdev); if (ret) { @@ -11082,7 +11211,6 @@ struct hnae3_ae_ops hclge_ops = { .set_timer_task = hclge_set_timer_task, .mac_connect_phy = hclge_mac_connect_phy, .mac_disconnect_phy = hclge_mac_disconnect_phy, - .restore_vlan_table = hclge_restore_vlan_table, .reset_done = hclge_reset_done, .handle_imp_error = hclge_handle_imp_error, .get_vf_config = hclge_get_vf_config, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 3508e61..cfb9ba2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -1002,11 +1002,12 @@ int hclge_notify_client(struct hclge_dev *hdev, void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, enum HCLGE_MAC_ADDR_TYPE mac_type); void hclge_rm_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, - bool is_write_tbl, enum HCLGE_MAC_ADDR_TYPE mac_type); void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, enum HCLGE_MAC_ADDR_TYPE mac_type); void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list); +void hclge_restore_vport_vlan_table(struct hclge_vport *vport); +void hclge_restore_vport_mac_table(struct hclge_vport *vport); int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, struct hclge_vlan_info *vlan_info); int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index d979f82..fc746ea 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -279,15 +279,22 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, !ether_addr_equal(mac_addr, vport->mac)) return -EPERM;
- hclge_rm_uc_addr_common(vport, old_addr); - status = hclge_add_uc_addr_common(vport, mac_addr); - if (status) { - hclge_add_uc_addr_common(vport, old_addr); + if (is_zero_ether_addr(old_addr)) { + status = hclge_add_uc_addr_common(vport, mac_addr); + if (!status) + hclge_add_vport_mac_table(vport, mac_addr, + HCLGE_MAC_ADDR_UC); } else { - hclge_rm_vport_mac_table(vport, old_addr, - false, HCLGE_MAC_ADDR_UC); - hclge_add_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_UC); + hclge_rm_uc_addr_common(vport, old_addr); + status = hclge_add_uc_addr_common(vport, mac_addr); + if (status) { + hclge_add_uc_addr_common(vport, old_addr); + } else { + hclge_rm_vport_mac_table(vport, old_addr, + HCLGE_MAC_ADDR_UC); + hclge_add_vport_mac_table(vport, mac_addr, + HCLGE_MAC_ADDR_UC); + } } } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_ADD) { status = hclge_add_uc_addr_common(vport, mac_addr); @@ -299,7 +306,7 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, status = hclge_rm_uc_addr_common(vport, mac_addr); if (!status) { hclge_rm_vport_mac_table(vport, mac_addr, - false, HCLGE_MAC_ADDR_UC); + HCLGE_MAC_ADDR_UC); } } else { dev_err(&hdev->pdev->dev, @@ -326,7 +333,7 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, status = hclge_rm_mc_addr_common(vport, mac_addr); if (!status) hclge_rm_vport_mac_table(vport, mac_addr, - false, HCLGE_MAC_ADDR_MC); + HCLGE_MAC_ADDR_MC); } else { dev_err(&hdev->pdev->dev, "failed to set mcast mac addr, unknown subcode %u\n", @@ -645,6 +652,26 @@ static void hclge_handle_ncsi_error(struct hclge_dev *hdev) ae_dev->ops->reset_event(hdev->pdev, NULL); }
+static void hclge_handle_vf_tbl(struct hclge_vport *vport, + struct hclge_mbx_vf_to_pf_cmd *mbx_req) +{ + struct hclge_dev *hdev = vport->back; + struct hclge_vf_vlan_cfg *msg_cmd; + + msg_cmd = (struct hclge_vf_vlan_cfg *)&mbx_req->msg; + if (msg_cmd->subcode == HCLGE_MBX_HW_TBL_RESTORE) { + hclge_restore_vport_mac_table(vport); + hclge_restore_vport_vlan_table(vport); + } else if (msg_cmd->subcode == HCLGE_MBX_VPORT_LIST_CLEAR) { + hclge_rm_vport_all_mac_table(vport, true, HCLGE_MAC_ADDR_UC); + hclge_rm_vport_all_mac_table(vport, true, HCLGE_MAC_ADDR_MC); + hclge_rm_vport_all_vlan_table(vport, true); + } else { + dev_warn(&hdev->pdev->dev, "Invalid cmd(%u)\n", + msg_cmd->subcode); + } +} + void hclge_mbx_handler(struct hclge_dev *hdev) { struct hclge_cmq_ring *crq = &hdev->hw.cmq.crq; @@ -652,6 +679,7 @@ void hclge_mbx_handler(struct hclge_dev *hdev) struct hclge_mbx_vf_to_pf_cmd *req; struct hclge_vport *vport; struct hclge_desc *desc; + bool is_del = false; unsigned int flag; int ret = 0;
@@ -767,11 +795,12 @@ void hclge_mbx_handler(struct hclge_dev *hdev) break; case HCLGE_MBX_GET_VF_FLR_STATUS: case HCLGE_MBX_VF_UNINIT: - hclge_rm_vport_all_mac_table(vport, true, + is_del = req->msg.code == HCLGE_MBX_VF_UNINIT; + hclge_rm_vport_all_mac_table(vport, is_del, HCLGE_MAC_ADDR_UC); - hclge_rm_vport_all_mac_table(vport, true, + hclge_rm_vport_all_mac_table(vport, is_del, HCLGE_MAC_ADDR_MC); - hclge_rm_vport_all_vlan_table(vport, true); + hclge_rm_vport_all_vlan_table(vport, is_del); break; case HCLGE_MBX_GET_MEDIA_TYPE: hclge_get_vf_media_type(vport, &resp_msg); @@ -785,6 +814,9 @@ void hclge_mbx_handler(struct hclge_dev *hdev) case HCLGE_MBX_NCSI_ERROR: hclge_handle_ncsi_error(hdev); break; + case HCLGE_MBX_HANDLE_VF_TBL: + hclge_handle_vf_tbl(vport, req); + break; default: dev_err(&hdev->pdev->dev, "un-supported mailbox message, code = %u\n", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index aad348a..57ac897 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -15,6 +15,7 @@ #define HCLGEVF_RESET_MAX_FAIL_CNT 5
static int hclgevf_reset_hdev(struct hclgevf_dev *hdev); +static int hclgevf_restore_hw_table(struct hclgevf_dev *hdev); static struct hnae3_ae_algo ae_algovf;
static struct workqueue_struct *hclgevf_wq; @@ -1253,10 +1254,12 @@ static int hclgevf_set_mac_addr(struct hnae3_handle *handle, void *p, }
hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST, 0); - send_msg.subcode = is_first ? HCLGE_MBX_MAC_VLAN_UC_ADD : - HCLGE_MBX_MAC_VLAN_UC_MODIFY; + send_msg.subcode = HCLGE_MBX_MAC_VLAN_UC_MODIFY; ether_addr_copy(send_msg.data, new_mac_addr); - ether_addr_copy(&send_msg.data[ETH_ALEN], old_mac_addr); + if (is_first) + eth_zero_addr(&send_msg.data[ETH_ALEN]); + else + ether_addr_copy(&send_msg.data[ETH_ALEN], old_mac_addr); status = hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0); if (!status) ether_addr_copy(hdev->hw.mac.mac_addr, new_mac_addr); @@ -2719,6 +2722,28 @@ static int hclgevf_pci_reset(struct hclgevf_dev *hdev) return ret; }
+static int hclgevf_clear_vport_list(struct hclgevf_dev *hdev) +{ + struct hclge_vf_to_pf_msg send_msg; + + hclgevf_build_send_msg(&send_msg, HCLGE_MBX_HANDLE_VF_TBL, + HCLGE_MBX_VPORT_LIST_CLEAR); + return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); +} + +static int hclgevf_restore_hw_table(struct hclgevf_dev *hdev) +{ + struct hclge_vf_to_pf_msg send_msg; + + if (hdev->reset_type == HNAE3_VF_RESET || + hdev->reset_type == HNAE3_FLR_RESET) { + hclgevf_build_send_msg(&send_msg, HCLGE_MBX_HANDLE_VF_TBL, + HCLGE_MBX_HW_TBL_RESTORE); + return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); + } + return 0; +} + static int hclgevf_reset_hdev(struct hclgevf_dev *hdev) { struct pci_dev *pdev = hdev->pdev; @@ -2755,6 +2780,14 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev) return ret; }
+ /* VF_RESET & VF_FLR_RESET need to request to restore hw table */ + ret = hclgevf_restore_hw_table(hdev); + if (ret) { + dev_err(&hdev->pdev->dev, + "failed(%d) to restore hw table\n", ret); + return ret; + } + dev_info(&hdev->pdev->dev, "Reset done\n");
return 0; @@ -2826,6 +2859,14 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev) goto err_config; }
+ /* ensure vf tbl list as empty before init*/ + ret = hclgevf_clear_vport_list(hdev); + if (ret) { + dev_err(&pdev->dev, + "failed(%d) to clear tbl list configuration\n", ret); + goto err_config; + } + ret = hclgevf_init_vlan_config(hdev); if (ret) { dev_err(&hdev->pdev->dev,
From: Jian Shen shenjian15@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, there is a time window for protect share_umv_size between checking umv space and doing mac configuration in the lin function hclge_add_uc_addr_common(). It should be extented.
On the other hand, for the mac address configuration is not configured directly in the path of hns3_set_rx_mode any more, so it's unnecessary to use spin lock to protect the share_umv_size. Another exist mutex vport_lock is designed to protect the share resource between each vport can replace it.
This patch uses mutex vport_lock intead of spin lock umv_lock to protect share_umv_size, and adjusts the mutex region.
Signed-off-by: Jian Shen shenjian15@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 32 ++++++++++++++-------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 - 2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index c75e24e..24c6498 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -7301,7 +7301,6 @@ static int hclge_init_umv_space(struct hclge_dev *hdev) "Alloc umv space failed, want %u, get %u\n", hdev->wanted_umv_size, allocated_size);
- spin_lock_init(&hdev->umv_lock); hdev->max_umv_size = allocated_size; hdev->priv_umv_size = hdev->max_umv_size / (hdev->num_alloc_vport + 1); hdev->share_umv_size = hdev->priv_umv_size + @@ -7320,21 +7319,25 @@ static void hclge_reset_umv_space(struct hclge_dev *hdev) vport->used_umv_num = 0; }
- spin_lock(&hdev->umv_lock); + mutex_lock(&hdev->vport_lock); hdev->share_umv_size = hdev->priv_umv_size + hdev->max_umv_size % (hdev->num_alloc_vport + 1); - spin_unlock(&hdev->umv_lock); + mutex_unlock(&hdev->vport_lock); }
-static bool hclge_is_umv_space_full(struct hclge_vport *vport) +static bool hclge_is_umv_space_full(struct hclge_vport *vport, bool need_lock) { struct hclge_dev *hdev = vport->back; bool is_full;
- spin_lock(&hdev->umv_lock); + if (need_lock) + mutex_lock(&hdev->vport_lock); + is_full = (vport->used_umv_num >= hdev->priv_umv_size && hdev->share_umv_size == 0); - spin_unlock(&hdev->umv_lock); + + if (need_lock) + mutex_unlock(&hdev->vport_lock);
return is_full; } @@ -7343,7 +7346,6 @@ static void hclge_update_umv_space(struct hclge_vport *vport, bool is_free) { struct hclge_dev *hdev = vport->back;
- spin_lock(&hdev->umv_lock); if (is_free) { if (vport->used_umv_num > hdev->priv_umv_size) hdev->share_umv_size++; @@ -7356,7 +7358,6 @@ static void hclge_update_umv_space(struct hclge_vport *vport, bool is_free) hdev->share_umv_size--; vport->used_umv_num++; } - spin_unlock(&hdev->umv_lock); }
static struct hclge_vport_mac_addr_cfg * @@ -7497,12 +7498,16 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport, */ ret = hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false); if (ret == -ENOENT) { - if (!hclge_is_umv_space_full(vport)) { + mutex_lock(&hdev->vport_lock); + if (!hclge_is_umv_space_full(vport, false)) { ret = hclge_add_mac_vlan_tbl(vport, &req, NULL); if (!ret) hclge_update_umv_space(vport, false); + + mutex_unlock(&hdev->vport_lock); return ret; } + mutex_unlock(&hdev->vport_lock);
dev_err(&hdev->pdev->dev, "UC MAC table full(%u)\n", hdev->priv_umv_size); @@ -7558,10 +7563,13 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport, hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0); hclge_prepare_mac_addr(&req, addr, false); ret = hclge_remove_mac_vlan_tbl(vport, &req); - if (!ret) + if (!ret) { + mutex_lock(&hdev->vport_lock); hclge_update_umv_space(vport, true); - else if (ret == -ENOENT) + mutex_unlock(&hdev->vport_lock); + } else if (ret == -ENOENT) { ret = 0; + }
return ret; } @@ -10207,7 +10215,7 @@ static int hclge_set_vf_spoofchk(struct hnae3_handle *handle, int vf, dev_warn(&hdev->pdev->dev, "vf %d vlan table is full, enable spoof check may cause its packet send fail\n", vf); - else if (enable && hclge_is_umv_space_full(vport)) + else if (enable && hclge_is_umv_space_full(vport, true)) dev_warn(&hdev->pdev->dev, "vf %d mac table is full, enable spoof check may cause its packet send fail\n", vf); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index cfb9ba2..68ea032 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -832,7 +832,6 @@ struct hclge_dev { u16 priv_umv_size; /* unicast mac vlan space shared by PF and its VFs */ u16 share_umv_size; - spinlock_t umv_lock; /* protect share_umv_size */
DECLARE_KFIFO(mac_tnl_log, struct hclge_mac_tnl_stats, HCLGE_MAC_TNL_LOG_SIZE);
From: Jian Shen shenjian15@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, the HNS3 driver sync and unsync mac address in function hns3_set_rx_mode(). For VF, it sends mailbox messages to PF to request adding or deleting mac address in the path of function hns3_set_rx_mode(), no matter the address is configured success. This patch refines it by sending the mac address configure request in the service task of VF, and adding or deleting these mac addresses in the service task. Either is failed, it will retry in the next schedule of service task.
Signed-off-by: Jian Shen shenjian15@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 1 - drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 - drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 1 - drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 9 - .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 177 ++++++++------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 18 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 80 ++++--- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 241 ++++++++++++++++----- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 26 +++ 9 files changed, 351 insertions(+), 203 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index 7b85b8d..a4dd3aef 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -72,7 +72,6 @@ enum hclge_mbx_vlan_cfg_subcode { };
enum hclge_mbx_tbl_cfg_subcode { - HCLGE_MBX_HW_TBL_RESTORE, HCLGE_MBX_VPORT_LIST_CLEAR, };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 261a2c1..92854cc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -232,7 +232,6 @@ struct hnae3_ae_dev { struct list_head node; u32 flag; unsigned long hw_err_reset_req; - enum hnae3_reset_type reset_type; void *priv; };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 3c306a8..9c79f46d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2143,7 +2143,6 @@ static int hns3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
ae_dev->pdev = pdev; ae_dev->flag = ent->driver_data; - ae_dev->reset_type = HNAE3_NONE_RESET; hns3_get_dev_capability(pdev, ae_dev); pci_set_drvdata(pdev, ae_dev);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index a4cf1a8..98cd8a1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -575,15 +575,6 @@ static inline void hns3_write_reg(void __iomem *base, u32 reg, u32 value) writel(value, reg_addr + reg); }
-static inline bool hns3_dev_ongoing_func_reset(struct hnae3_ae_dev *ae_dev) -{ - return (ae_dev && (ae_dev->reset_type == HNAE3_FUNC_RESET || - ae_dev->reset_type == HNAE3_FLR_RESET || - ae_dev->reset_type == HNAE3_VF_FUNC_RESET || - ae_dev->reset_type == HNAE3_VF_FULL_RESET || - ae_dev->reset_type == HNAE3_VF_PF_FUNC_RESET)); -} - #define hns3_read_dev(a, reg) \ hns3_read_reg((a)->io_base, (reg))
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 24c6498..02f35fc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3756,10 +3756,6 @@ static void hclge_reset(struct hclge_dev *hdev) enum hnae3_reset_type reset_level; int ret;
- /* Initialize ae_dev reset status as well, in case enet layer wants to - * know if device is undergoing reset - */ - ae_dev->reset_type = hdev->reset_type; hdev->rst_stats.reset_cnt++; /* perform reset of the stack & ae device for a client */ ret = hclge_notify_roce_client(hdev, HNAE3_DOWN_CLIENT); @@ -3827,7 +3823,6 @@ static void hclge_reset(struct hclge_dev *hdev) hdev->last_reset_time = jiffies; hdev->rst_stats.reset_fail_cnt = 0; hdev->rst_stats.reset_done_cnt++; - ae_dev->reset_type = HNAE3_NONE_RESET;
/* if default_reset_request has a higher level reset request, * it should be handled as soon as possible. since some errors @@ -6985,8 +6980,17 @@ static void hclge_ae_stop(struct hnae3_handle *handle)
int hclge_vport_start(struct hclge_vport *vport) { + struct hclge_dev *hdev = vport->back; + set_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); vport->last_active_jiffies = jiffies; + + /* when received vport start mbx, it means the VF is start now */ + if (test_and_clear_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state) || + test_and_clear_bit(vport->vport_id, hdev->need_restore_vf_table)) { + hclge_restore_mac_table_common(vport); + hclge_restore_vport_vlan_table(vport); + } return 0; }
@@ -7409,12 +7413,11 @@ static void hclge_mac_node_convert(struct hclge_vport_mac_addr_cfg *mac_node, } }
-static int hclge_update_mac_list(struct hnae3_handle *handle, - enum HCLGE_MAC_ADDR_STATE state, - enum HCLGE_MAC_ADDR_TYPE mac_type, - const unsigned char *addr) +int hclge_update_mac_list(struct hclge_vport *vport, + enum HCLGE_MAC_ADDR_STATE state, + enum HCLGE_MAC_ADDR_TYPE mac_type, + const unsigned char *addr) { - struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_vport_mac_addr_cfg *mac_node; struct list_head *list;
@@ -7455,7 +7458,7 @@ static int hclge_add_uc_addr(struct hnae3_handle *handle, int ret;
spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_UC, + ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_UC, addr); spin_unlock_bh(&vport->mac_list_lock);
@@ -7536,7 +7539,7 @@ static int hclge_rm_uc_addr(struct hnae3_handle *handle, int ret;
spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_UC, + ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_UC, addr); spin_unlock_bh(&vport->mac_list_lock);
@@ -7581,7 +7584,7 @@ static int hclge_add_mc_addr(struct hnae3_handle *handle, int ret;
spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_MC, + ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_MC, addr); spin_unlock_bh(&vport->mac_list_lock);
@@ -7630,7 +7633,7 @@ static int hclge_rm_mc_addr(struct hnae3_handle *handle, int ret;
spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(handle, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_MC, + ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_MC, addr); spin_unlock_bh(&vport->mac_list_lock);
@@ -7856,79 +7859,81 @@ static void hclge_sync_vport_mac_table(struct hclge_vport *vport, spin_unlock_bh(&vport->mac_list_lock); }
-static void hclge_sync_mac_table(struct hclge_dev *hdev) -{ - struct hclge_vport *vport = &hdev->vport[0]; - - if (hdev->serv_processed_cnt % HCLGE_MAC_TBL_SYNC_INTERVAL && - !test_and_clear_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, - &vport->state)) - return; - - hclge_sync_vport_mac_table(vport, HCLGE_MAC_ADDR_UC); - hclge_sync_vport_mac_table(vport, HCLGE_MAC_ADDR_MC); -} - -void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, - enum HCLGE_MAC_ADDR_TYPE mac_type) +static bool hclge_need_sync_mac_table(struct hclge_vport *vport) { - struct hclge_vport_mac_addr_cfg *mac_cfg; - struct list_head *list; - - if (!vport->vport_id) - return; - - mac_cfg = kzalloc(sizeof(*mac_cfg), GFP_KERNEL); - if (!mac_cfg) - return; + struct hclge_dev *hdev = vport->back; + bool time_up;
- mac_cfg->hd_tbl_status = true; - ether_addr_copy(mac_cfg->mac_addr, mac_addr); + if (test_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state)) + return false;
- list = (mac_type == HCLGE_MAC_ADDR_UC) ? - &vport->uc_mac_list : &vport->mc_mac_list; + time_up = !(hdev->serv_processed_cnt % HCLGE_MAC_TBL_SYNC_INTERVAL); + if (time_up || + test_and_clear_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, &vport->state)) + return true;
- list_add_tail(&mac_cfg->node, list); + return false; }
-void hclge_rm_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, - enum HCLGE_MAC_ADDR_TYPE mac_type) +static void hclge_sync_mac_table(struct hclge_dev *hdev) { - struct hclge_vport_mac_addr_cfg *mac_cfg, *tmp; - struct list_head *list; + struct hclge_vport *vport = &hdev->vport[0]; + int i;
- list = (mac_type == HCLGE_MAC_ADDR_UC) ? - &vport->uc_mac_list : &vport->mc_mac_list; + for (i = 0; i < hdev->num_alloc_vport; i++) { + vport = &hdev->vport[i];
- list_for_each_entry_safe(mac_cfg, tmp, list, node) { - if (ether_addr_equal(mac_cfg->mac_addr, mac_addr)) { - list_del(&mac_cfg->node); - kfree(mac_cfg); - break; - } + if (!hclge_need_sync_mac_table(vport)) + continue; + + hclge_sync_vport_mac_table(vport, HCLGE_MAC_ADDR_UC); + hclge_sync_vport_mac_table(vport, HCLGE_MAC_ADDR_MC); } }
void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, enum HCLGE_MAC_ADDR_TYPE mac_type) { + int (*unsync)(struct hclge_vport *vport, const unsigned char *addr); struct hclge_vport_mac_addr_cfg *mac_cfg, *tmp; struct list_head *list; + int ret;
- list = (mac_type == HCLGE_MAC_ADDR_UC) ? - &vport->uc_mac_list : &vport->mc_mac_list; + if (mac_type == HCLGE_MAC_ADDR_UC) { + list = &vport->uc_mac_list; + unsync = hclge_rm_uc_addr_common; + } else { + list = &vport->mc_mac_list; + unsync = hclge_rm_mc_addr_common; + }
- list_for_each_entry_safe(mac_cfg, tmp, list, node) { - if (mac_type == HCLGE_MAC_ADDR_UC && mac_cfg->hd_tbl_status) - hclge_rm_uc_addr_common(vport, mac_cfg->mac_addr); + if (!is_del_list) + set_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state);
- if (mac_type == HCLGE_MAC_ADDR_MC && mac_cfg->hd_tbl_status) - hclge_rm_mc_addr_common(vport, mac_cfg->mac_addr); + list_for_each_entry_safe(mac_cfg, tmp, list, node) { + if (mac_cfg->state == HCLGE_MAC_TO_ADD) { + if (is_del_list) { + list_del(&mac_cfg->node); + kfree(mac_cfg); + } + continue; + }
- mac_cfg->hd_tbl_status = false; - if (is_del_list) { - list_del(&mac_cfg->node); - kfree(mac_cfg); + ret = unsync(vport, mac_cfg->mac_addr); + if (!ret || ret == -ENOENT) { + /* clear all mac addr from hardware, but remain these + * mac addr in the mac list, and restore them after + * vf reset finished. + */ + if (!is_del_list && + mac_cfg->state == HCLGE_MAC_ACTIVE) { + mac_cfg->state = HCLGE_MAC_TO_ADD; + } else { + list_del(&mac_cfg->node); + kfree(mac_cfg); + } + } else if (is_del_list) { + mac_cfg->state = HCLGE_MAC_TO_DEL; } } } @@ -8150,8 +8155,8 @@ static void hclge_get_mac_addr(struct hnae3_handle *handle, u8 *p) /* use new node to replace old node in the list, if old address is still in * mac table, add it to list tail, and try to remove in service task */ -static void hclge_replace_mac_node(struct list_head *list, const u8 *old_addr, - const u8 *new_addr, bool keep_old) +void hclge_replace_mac_node(struct list_head *list, const u8 *old_addr, + const u8 *new_addr, bool keep_old) { struct hclge_vport_mac_addr_cfg *mac_node, *new_node;
@@ -8178,8 +8183,8 @@ static void hclge_replace_mac_node(struct list_head *list, const u8 *old_addr, } }
-static void hclge_modify_mac_node_state(struct list_head *list, const u8 *addr, - enum HCLGE_MAC_ADDR_STATE state) +void hclge_modify_mac_node_state(struct list_head *list, const u8 *addr, + enum HCLGE_MAC_ADDR_STATE state) { struct hclge_vport_mac_addr_cfg *mac_node;
@@ -8865,26 +8870,6 @@ void hclge_restore_vport_vlan_table(struct hclge_vport *vport) } }
-void hclge_restore_vport_mac_table(struct hclge_vport *vport) -{ - struct hclge_vport_mac_addr_cfg *mac_cfg, *tmp; - int ret; - - list_for_each_entry_safe(mac_cfg, tmp, &vport->uc_mac_list, node) { - ret = hclge_add_uc_addr_common(vport, mac_cfg->mac_addr); - if (!ret) - mac_cfg->hd_tbl_status = true; - else if (ret == -ENOSPC) - break; - } - - list_for_each_entry_safe(mac_cfg, tmp, &vport->mc_mac_list, node) { - ret = hclge_add_mc_addr_common(vport, mac_cfg->mac_addr); - if (!ret) - mac_cfg->hd_tbl_status = true; - } -} - /* For global reset and imp reset, hardware will clear the mac table, * so we change the mac address state from ACTIVE to TO_ADD, then they * can be restored in the service task after reset complete. Furtherly, @@ -8906,6 +8891,13 @@ static void hclge_mac_node_convert_for_reset(struct list_head *list) } }
+void hclge_restore_mac_table_common(struct hclge_vport *vport) +{ + hclge_mac_node_convert_for_reset(&vport->uc_mac_list); + hclge_mac_node_convert_for_reset(&vport->mc_mac_list); + clear_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state); +} + static void hclge_restore_pf_mac_table(struct hclge_vport *vport) { /* move the mac addr to the tmp_add_list and tmp_del_list, then @@ -8913,8 +8905,7 @@ static void hclge_restore_pf_mac_table(struct hclge_vport *vport) */ spin_lock_bh(&vport->mac_list_lock);
- hclge_mac_node_convert_for_reset(&vport->uc_mac_list); - hclge_mac_node_convert_for_reset(&vport->mc_mac_list); + hclge_restore_mac_table_common(vport);
spin_unlock_bh(&vport->mac_list_lock); } @@ -8924,6 +8915,8 @@ static int hclge_restore_hw_table(struct hclge_dev *hdev) struct hclge_vport *vport = &hdev->vport[0]; struct hnae3_handle *handle = &vport->nic;
+ bitmap_set(hdev->need_restore_vf_table, 0, hdev->num_alloc_vport); + hclge_restore_pf_mac_table(vport); hclge_restore_vport_vlan_table(vport);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 68ea032..05ab6c1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -644,7 +644,6 @@ enum HCLGE_MAC_ADDR_STATE {
struct hclge_vport_mac_addr_cfg { struct list_head node; - int hd_tbl_status; enum HCLGE_MAC_ADDR_STATE state; u8 mac_addr[ETH_ALEN]; }; @@ -815,6 +814,8 @@ struct hclge_dev { unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)]; unsigned long vf_vlan_full[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
+ unsigned long need_restore_vf_table[BITS_TO_LONGS(HCLGE_VPORT_NUM)]; + struct hclge_fd_cfg fd_cfg; struct hlist_head fd_rule_list; spinlock_t fd_rule_lock; /* protect fd_rule_list and fd_bmap */ @@ -878,6 +879,7 @@ struct hclge_rss_tuple_cfg { enum HCLGE_VPORT_STATE { HCLGE_VPORT_STATE_ALIVE, HCLGE_VPORT_STATE_MAC_TBL_CHANGE, + HCLGE_VPORT_STATE_BLOCK_CONFIG, /* blocking mac configuration */ HCLGE_VPORT_STATE_MAX };
@@ -998,15 +1000,19 @@ int hclge_set_vlan_filter(struct hnae3_handle *handle, __be16 proto, u16 hclge_covert_handle_qid_global(struct hnae3_handle *handle, u16 queue_id); int hclge_notify_client(struct hclge_dev *hdev, enum hnae3_reset_notify_type type); -void hclge_add_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, - enum HCLGE_MAC_ADDR_TYPE mac_type); -void hclge_rm_vport_mac_table(struct hclge_vport *vport, const u8 *mac_addr, - enum HCLGE_MAC_ADDR_TYPE mac_type); +int hclge_update_mac_list(struct hclge_vport *vport, + enum HCLGE_MAC_ADDR_STATE state, + enum HCLGE_MAC_ADDR_TYPE mac_type, + const unsigned char *addr); +void hclge_replace_mac_node(struct list_head *list, const u8 *old_addr, + const u8 *new_addr, bool keep_old); +void hclge_modify_mac_node_state(struct list_head *list, const u8 *addr, + enum HCLGE_MAC_ADDR_STATE state); void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, enum HCLGE_MAC_ADDR_TYPE mac_type); void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list); +void hclge_restore_mac_table_common(struct hclge_vport *vport); void hclge_restore_vport_vlan_table(struct hclge_vport *vport); -void hclge_restore_vport_mac_table(struct hclge_vport *vport); int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, struct hclge_vlan_info *vlan_info); int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index fc746ea..e93e8d7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -263,13 +263,38 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport) HCLGE_MBX_PUSH_PROMISC_INFO, dest_vfid); }
+static int hclge_modify_vf_mac_addr(struct hclge_vport *vport, + const u8 *old_addr, const u8 *new_addr) +{ + bool old_mac_removed = true; + int ret; + + ret = hclge_rm_uc_addr_common(vport, old_addr); + if (ret) + old_mac_removed = false; + + ret = hclge_add_uc_addr_common(vport, new_addr); + if (ret) { + ret = hclge_add_uc_addr_common(vport, old_addr); + if (ret) + hclge_modify_mac_node_state(&vport->uc_mac_list, + old_addr, HCLGE_MAC_TO_ADD); + return -EIO; + + } else { + hclge_replace_mac_node(&vport->uc_mac_list, old_addr, new_addr, + !old_mac_removed); + } + return ret; +} + static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, struct hclge_mbx_vf_to_pf_cmd *mbx_req) { #define HCLGE_MBX_VF_OLD_MAC_ADDR_OFFSET 6 const u8 *mac_addr = (const u8 *)(mbx_req->msg.data); struct hclge_dev *hdev = vport->back; - int status; + int status = 0;
if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_MODIFY) { const u8 *old_addr = (const u8 *) @@ -282,32 +307,22 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, if (is_zero_ether_addr(old_addr)) { status = hclge_add_uc_addr_common(vport, mac_addr); if (!status) - hclge_add_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_UC); + hclge_update_mac_list(vport, HCLGE_MAC_ACTIVE, + HCLGE_MAC_ADDR_UC, + mac_addr); + else + hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, + HCLGE_MAC_ADDR_UC, + mac_addr); } else { - hclge_rm_uc_addr_common(vport, old_addr); - status = hclge_add_uc_addr_common(vport, mac_addr); - if (status) { - hclge_add_uc_addr_common(vport, old_addr); - } else { - hclge_rm_vport_mac_table(vport, old_addr, - HCLGE_MAC_ADDR_UC); - hclge_add_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_UC); - } + hclge_modify_vf_mac_addr(vport, old_addr, mac_addr); } } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_ADD) { - status = hclge_add_uc_addr_common(vport, mac_addr); - if (!status) { - hclge_add_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_UC); - } + hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, + HCLGE_MAC_ADDR_UC, mac_addr); } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_UC_REMOVE) { - status = hclge_rm_uc_addr_common(vport, mac_addr); - if (!status) { - hclge_rm_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_UC); - } + hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, + HCLGE_MAC_ADDR_UC, mac_addr); } else { dev_err(&hdev->pdev->dev, "failed to set unicast mac addr, unknown subcode %u\n", @@ -322,18 +337,14 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, { const u8 *mac_addr = (const u8 *)(mbx_req->msg.data); struct hclge_dev *hdev = vport->back; - int status; + int status = 0;
if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_ADD) { - status = hclge_add_mc_addr_common(vport, mac_addr); - if (!status) - hclge_add_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_MC); + hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, + HCLGE_MAC_ADDR_MC, mac_addr); } else if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_REMOVE) { - status = hclge_rm_mc_addr_common(vport, mac_addr); - if (!status) - hclge_rm_vport_mac_table(vport, mac_addr, - HCLGE_MAC_ADDR_MC); + hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, + HCLGE_MAC_ADDR_MC, mac_addr); } else { dev_err(&hdev->pdev->dev, "failed to set mcast mac addr, unknown subcode %u\n", @@ -659,10 +670,7 @@ static void hclge_handle_vf_tbl(struct hclge_vport *vport, struct hclge_vf_vlan_cfg *msg_cmd;
msg_cmd = (struct hclge_vf_vlan_cfg *)&mbx_req->msg; - if (msg_cmd->subcode == HCLGE_MBX_HW_TBL_RESTORE) { - hclge_restore_vport_mac_table(vport); - hclge_restore_vport_vlan_table(vport); - } else if (msg_cmd->subcode == HCLGE_MBX_VPORT_LIST_CLEAR) { + if (msg_cmd->subcode == HCLGE_MBX_VPORT_LIST_CLEAR) { hclge_rm_vport_all_mac_table(vport, true, HCLGE_MAC_ADDR_UC); hclge_rm_vport_all_mac_table(vport, true, HCLGE_MAC_ADDR_MC); hclge_rm_vport_all_vlan_table(vport, true); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 57ac897..c52b070 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -15,7 +15,6 @@ #define HCLGEVF_RESET_MAX_FAIL_CNT 5
static int hclgevf_reset_hdev(struct hclgevf_dev *hdev); -static int hclgevf_restore_hw_table(struct hclgevf_dev *hdev); static struct hnae3_ae_algo ae_algovf;
static struct workqueue_struct *hclgevf_wq; @@ -1267,54 +1266,206 @@ static int hclgevf_set_mac_addr(struct hnae3_handle *handle, void *p, return status; }
-static int hclgevf_add_uc_addr(struct hnae3_handle *handle, - const unsigned char *addr) +static struct hclgevf_mac_addr_node * +hclgevf_find_mac_node(struct list_head *list, const u8 *mac_addr) +{ + struct hclgevf_mac_addr_node *mac_node, *tmp; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + if (ether_addr_equal(mac_addr, mac_node->mac_addr)) + return mac_node; + } + return NULL; +} + +static int hclgevf_update_mac_list(struct hnae3_handle *handle, + enum HCLGEVF_MAC_ADDR_STATE state, + enum HCLGEVF_MAC_ADDR_TYPE mac_type, + const unsigned char *addr) { struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); - struct hclge_vf_to_pf_msg send_msg; + struct hclgevf_mac_addr_node *mac_node; + struct list_head *list;
- hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST, - HCLGE_MBX_MAC_VLAN_UC_ADD); - ether_addr_copy(send_msg.data, addr); - return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); + list = (mac_type == HCLGEVF_MAC_ADDR_UC) ? + &hdev->mac_table.uc_mac_list : &hdev->mac_table.mc_mac_list; + + spin_lock_bh(&hdev->mac_table.mac_list_lock); + + mac_node = kzalloc(sizeof(*mac_node), GFP_ATOMIC); + if (!mac_node) { + spin_unlock_bh(&hdev->mac_table.mac_list_lock); + return -ENOMEM; + } + + mac_node->state = state; + ether_addr_copy(mac_node->mac_addr, addr); + list_add_tail(&mac_node->node, list); + + spin_unlock_bh(&hdev->mac_table.mac_list_lock); + return 0; +} + +static int hclgevf_add_uc_addr(struct hnae3_handle *handle, + const unsigned char *addr) +{ + return hclgevf_update_mac_list(handle, HCLGEVF_MAC_TO_ADD, + HCLGEVF_MAC_ADDR_UC, addr); }
static int hclgevf_rm_uc_addr(struct hnae3_handle *handle, const unsigned char *addr) { - struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); - struct hclge_vf_to_pf_msg send_msg; - - hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST, - HCLGE_MBX_MAC_VLAN_UC_REMOVE); - ether_addr_copy(send_msg.data, addr); - return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); + return hclgevf_update_mac_list(handle, HCLGEVF_MAC_TO_DEL, + HCLGEVF_MAC_ADDR_UC, addr); }
static int hclgevf_add_mc_addr(struct hnae3_handle *handle, const unsigned char *addr) { - struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); - struct hclge_vf_to_pf_msg send_msg; - - hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_MULTICAST, - HCLGE_MBX_MAC_VLAN_MC_ADD); - ether_addr_copy(send_msg.data, addr); - return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); + return hclgevf_update_mac_list(handle, HCLGEVF_MAC_TO_ADD, + HCLGEVF_MAC_ADDR_MC, addr); }
static int hclgevf_rm_mc_addr(struct hnae3_handle *handle, const unsigned char *addr) { - struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + return hclgevf_update_mac_list(handle, HCLGEVF_MAC_TO_DEL, + HCLGEVF_MAC_ADDR_MC, addr); +} + +static int hclgevf_add_del_mac_addr(struct hclgevf_dev *hdev, + struct hclgevf_mac_addr_node *mac_node, + enum HCLGEVF_MAC_ADDR_TYPE mac_type) +{ struct hclge_vf_to_pf_msg send_msg; + u8 code, subcode; + + if (mac_type == HCLGEVF_MAC_ADDR_UC) { + code = HCLGE_MBX_SET_UNICAST; + if (mac_node->state == HCLGEVF_MAC_TO_ADD) + subcode = HCLGE_MBX_MAC_VLAN_UC_ADD; + else + subcode = HCLGE_MBX_MAC_VLAN_UC_REMOVE; + } else { + code = HCLGE_MBX_SET_MULTICAST; + if (mac_node->state == HCLGEVF_MAC_TO_ADD) + subcode = HCLGE_MBX_MAC_VLAN_MC_ADD; + else + subcode = HCLGE_MBX_MAC_VLAN_MC_REMOVE; + }
- hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_MULTICAST, - HCLGE_MBX_MAC_VLAN_MC_REMOVE); - ether_addr_copy(send_msg.data, addr); + hclgevf_build_send_msg(&send_msg, code, subcode); + ether_addr_copy(send_msg.data, mac_node->mac_addr); return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); }
+static void hclgevf_config_mac_list(struct hclgevf_dev *hdev, + struct list_head *list, + enum HCLGEVF_MAC_ADDR_TYPE mac_type) +{ + struct hclgevf_mac_addr_node *mac_node, *tmp; + int ret; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + ret = hclgevf_add_del_mac_addr(hdev, mac_node, mac_type); + if (ret) { + dev_err(&hdev->pdev->dev, + "request configure mac %pM failed, state=%d, ret=%d\n", + mac_node->mac_addr, mac_node->state, ret); + mac_node->state = HCLGEVF_MAC_REQ_FAIL; + return; + } + mac_node->state = HCLGEVF_MAC_REQ_SUC; + } +} + +static void hclgevf_sync_from_tmp_list(struct list_head *tmp_list, + struct list_head *mac_list) +{ + struct hclgevf_mac_addr_node *mac_node, *tmp, *new_node; + + list_for_each_entry_safe(mac_node, tmp, tmp_list, node) { + new_node = hclgevf_find_mac_node(mac_list, mac_node->mac_addr); + if (new_node) { + if (mac_node->state == HCLGEVF_MAC_REQ_SUC) { + list_del(&new_node->node); + kfree(new_node); + } + } + list_del(&mac_node->node); + kfree(mac_node); + } +} + +static void hclgevf_clear_list(struct list_head *list) +{ + struct hclgevf_mac_addr_node *mac_node, *tmp; + + list_for_each_entry_safe(mac_node, tmp, list, node) { + list_del(&mac_node->node); + kfree(mac_node); + } +} + +/* For PF handle VF's the mac configure request asynchronously, so VF + * is unware that whether the mac address is exist in the mac table. + * VF has to record the mac address from set_rx_mode, and send request + * one by one. After finish all request, then update the mac address + * state in mac list. + */ +static void hclgevf_sync_mac_list(struct hclgevf_dev *hdev, + enum HCLGEVF_MAC_ADDR_TYPE mac_type) +{ + struct hclgevf_mac_addr_node *mac_node, *tmp, *new_node; + struct list_head tmp_list, *list; + + INIT_LIST_HEAD(&tmp_list); + + list = (mac_type == HCLGEVF_MAC_ADDR_UC) ? + &hdev->mac_table.uc_mac_list : &hdev->mac_table.mc_mac_list; + + spin_lock_bh(&hdev->mac_table.mac_list_lock); + + list_for_each_entry_safe(mac_node, tmp, list, node) { + new_node = kzalloc(sizeof(*new_node), GFP_ATOMIC); + if (!new_node) { + hclgevf_clear_list(&tmp_list); + spin_unlock_bh(&hdev->mac_table.mac_list_lock); + return; + } + ether_addr_copy(new_node->mac_addr, mac_node->mac_addr); + new_node->state = mac_node->state; + list_add_tail(&new_node->node, &tmp_list); + } + + spin_unlock_bh(&hdev->mac_table.mac_list_lock); + + hclgevf_config_mac_list(hdev, &tmp_list, mac_type); + + spin_lock_bh(&hdev->mac_table.mac_list_lock); + + hclgevf_sync_from_tmp_list(&tmp_list, list); + + spin_unlock_bh(&hdev->mac_table.mac_list_lock); +} + +static void hclgevf_sync_mac_table(struct hclgevf_dev *hdev) +{ + hclgevf_sync_mac_list(hdev, HCLGEVF_MAC_ADDR_UC); + hclgevf_sync_mac_list(hdev, HCLGEVF_MAC_ADDR_MC); +} + +static void hclgevf_uninit_mac_list(struct hclgevf_dev *hdev) +{ + spin_lock_bh(&hdev->mac_table.mac_list_lock); + + hclgevf_clear_list(&hdev->mac_table.uc_mac_list); + hclgevf_clear_list(&hdev->mac_table.mc_mac_list); + + spin_unlock_bh(&hdev->mac_table.mac_list_lock); +} + static int hclgevf_set_vlan_filter(struct hnae3_handle *handle, __be16 proto, u16 vlan_id, bool is_kill) @@ -1555,10 +1706,6 @@ static int hclgevf_reset_stack(struct hclgevf_dev *hdev) if (ret) return ret;
- ret = hclgevf_notify_client(hdev, HNAE3_RESTORE_CLIENT); - if (ret) - return ret; - /* clear handshake status with IMP */ hclgevf_reset_handshake(hdev, false);
@@ -1643,13 +1790,8 @@ static void hclgevf_reset_err_handle(struct hclgevf_dev *hdev)
static int hclgevf_reset(struct hclgevf_dev *hdev) { - struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); int ret;
- /* Initialize ae_dev reset status as well, in case enet layer wants to - * know if device is undergoing reset - */ - ae_dev->reset_type = hdev->reset_type; hdev->rst_stats.rst_cnt++; rtnl_lock();
@@ -1694,7 +1836,6 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
rtnl_unlock();
- ae_dev->reset_type = HNAE3_NONE_RESET; hdev->rst_stats.rst_done_cnt++; hdev->rst_stats.rst_fail_cnt = 0;
@@ -1973,6 +2114,8 @@ static void hclgevf_periodical_service_task(struct hclgevf_dev *hdev)
hclgevf_sync_vlan_filter(hdev);
+ hclgevf_sync_mac_table(hdev); + hdev->last_serv_processed = jiffies;
out: @@ -2333,6 +2476,10 @@ static void hclgevf_state_init(struct hclgevf_dev *hdev)
mutex_init(&hdev->mbx_resp.mbx_mutex);
+ spin_lock_init(&hdev->mac_table.mac_list_lock); + INIT_LIST_HEAD(&hdev->mac_table.uc_mac_list); + INIT_LIST_HEAD(&hdev->mac_table.mc_mac_list); + /* bring the device down */ set_bit(HCLGEVF_STATE_DOWN, &hdev->state); } @@ -2731,19 +2878,6 @@ static int hclgevf_clear_vport_list(struct hclgevf_dev *hdev) return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); }
-static int hclgevf_restore_hw_table(struct hclgevf_dev *hdev) -{ - struct hclge_vf_to_pf_msg send_msg; - - if (hdev->reset_type == HNAE3_VF_RESET || - hdev->reset_type == HNAE3_FLR_RESET) { - hclgevf_build_send_msg(&send_msg, HCLGE_MBX_HANDLE_VF_TBL, - HCLGE_MBX_HW_TBL_RESTORE); - return hclgevf_send_mbx_msg(hdev, &send_msg, false, NULL, 0); - } - return 0; -} - static int hclgevf_reset_hdev(struct hclgevf_dev *hdev) { struct pci_dev *pdev = hdev->pdev; @@ -2780,14 +2914,6 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev) return ret; }
- /* VF_RESET & VF_FLR_RESET need to request to restore hw table */ - ret = hclgevf_restore_hw_table(hdev); - if (ret) { - dev_err(&hdev->pdev->dev, - "failed(%d) to restore hw table\n", ret); - return ret; - } - dev_info(&hdev->pdev->dev, "Reset done\n");
return 0; @@ -2911,6 +3037,7 @@ static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev)
hclgevf_pci_uninit(hdev); hclgevf_cmd_uninit(hdev); + hclgevf_uninit_mac_list(hdev); }
static int hclgevf_init_ae_dev(struct hnae3_ae_dev *ae_dev) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 92bbe15..cb62472 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -236,6 +236,30 @@ struct hclgevf_rst_stats { u32 rst_fail_cnt; /* the number of VF reset fail */ };
+enum HCLGEVF_MAC_ADDR_TYPE { + HCLGEVF_MAC_ADDR_UC, + HCLGEVF_MAC_ADDR_MC +}; + +enum HCLGEVF_MAC_ADDR_STATE { + HCLGEVF_MAC_TO_ADD, + HCLGEVF_MAC_TO_DEL, + HCLGEVF_MAC_REQ_SUC, /* send request mbx success */ + HCLGEVF_MAC_REQ_FAIL, /* send request mbx fail */ +}; + +struct hclgevf_mac_addr_node { + struct list_head node; + enum HCLGEVF_MAC_ADDR_STATE state; + u8 mac_addr[ETH_ALEN]; +}; + +struct hclgevf_mac_table_cfg { + spinlock_t mac_list_lock; /* protect mac address need to add/detele */ + struct list_head uc_mac_list; + struct list_head mc_mac_list; +}; + struct hclgevf_dev { struct pci_dev *pdev; struct hnae3_ae_dev *ae_dev; @@ -283,6 +307,8 @@ struct hclgevf_dev {
unsigned long vlan_del_fail_bmap[BITS_TO_LONGS(VLAN_N_VID)];
+ struct hclgevf_mac_table_cfg mac_table; + bool mbx_event_pending; struct hclgevf_mbx_resp_status mbx_resp; /* mailbox response */ struct hclgevf_mbx_arq_ring arq; /* mailbox async rx queue */
From: Jian Shen shenjian15@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
As the HNS3 driver doesn't update the mac address directly in function hns3_set_rx_mode() now, it can't know whether the mac table is full from __dev_uc_sync() and __dev_mc_sync(), so it's senseless to handle the overflow promisc here.
This patch removes the handle of overflow promisc from function hns3_set_rx_mode(), and updates the promisc mode in the service task.
This patch also fixes a vlan id restore twice issue, and add debugfs support for query mac list, So it need to be split before upstream.
Signed-off-by: Jian Shen shenjian15@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 4 + drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 33 ++-- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 51 +++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 208 ++++++++++++++------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 6 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 7 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 26 +++ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + 11 files changed, 244 insertions(+), 97 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 92854cc..ad1274e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -272,6 +272,8 @@ struct hnae3_ae_dev { * Set loopback * set_promisc_mode * Set promisc mode + * request_update_promisc_mode + * request to hclge(vf) to update promisc mode * set_mtu() * set mtu * get_pauseparam() @@ -402,6 +404,7 @@ struct hnae3_ae_ops {
int (*set_promisc_mode)(struct hnae3_handle *handle, bool en_uc_pmc, bool en_mc_pmc); + void (*request_update_promisc_mode)(struct hnae3_handle *handle); int (*set_mtu)(struct hnae3_handle *handle, int new_mtu);
void (*get_pauseparam)(struct hnae3_handle *handle, @@ -646,6 +649,7 @@ struct hnae3_unic_private_info { #define HNAE3_VLAN_FLTR BIT(5) /* enable vlan filter */ #define HNAE3_UPE (HNAE3_USER_UPE | HNAE3_OVERFLOW_UPE) #define HNAE3_MPE (HNAE3_USER_MPE | HNAE3_OVERFLOW_MPE) +#define HNAE3_OVERFLOW_UMPE (HNAE3_OVERFLOW_UPE | HNAE3_OVERFLOW_MPE)
struct hnae3_handle { struct hnae3_client *client; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index c8681c5..0babf50 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -260,6 +260,8 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump m7 info\n"); dev_info(&h->pdev->dev, "dump ncl_config <offset> <length>(in hex)\n"); dev_info(&h->pdev->dev, "dump mac tnl status\n"); + dev_info(&h->pdev->dev, "dump uc mac list <func id>\n"); + dev_info(&h->pdev->dev, "dump mc mac list <func id>\n");
memset(printf_buf, 0, HNS3_DBG_BUF_LEN); strncat(printf_buf, "dump reg [[bios common] [ssu <port_id>]", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 9c79f46d..2b22c0e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -598,34 +598,25 @@ static void hns3_nic_set_rx_mode(struct net_device *netdev) { struct hnae3_handle *h = hns3_get_handle(netdev); u8 new_flags; - int ret;
new_flags = hns3_get_netdev_flags(netdev);
- ret = __dev_uc_sync(netdev, hns3_nic_uc_sync, hns3_nic_uc_unsync); - if (ret) { - netdev_err(netdev, "sync uc address fail\n"); - if (ret == -ENOSPC) - new_flags |= HNAE3_OVERFLOW_UPE; - } - - if (netdev->flags & IFF_MULTICAST) { - ret = __dev_mc_sync(netdev, hns3_nic_mc_sync, - hns3_nic_mc_unsync); - if (ret) { - netdev_err(netdev, "sync mc address fail\n"); - if (ret == -ENOSPC) - new_flags |= HNAE3_OVERFLOW_MPE; - } - } + __dev_uc_sync(netdev, hns3_nic_uc_sync, hns3_nic_uc_unsync); + __dev_mc_sync(netdev, hns3_nic_mc_sync, hns3_nic_mc_unsync);
/* User mode Promisc mode enable and vlan filtering is disabled to - * let all packets in. MAC-VLAN Table overflow Promisc enabled and - * vlan fitering is enabled + * let all packets in. */ - hns3_enable_vlan_filter(netdev, new_flags & HNAE3_VLAN_FLTR); h->netdev_flags = new_flags; - hns3_update_promisc_mode(netdev, new_flags); + hns3_request_update_promisc_mode(h); +} + +void hns3_request_update_promisc_mode(struct hnae3_handle *handle) +{ + const struct hnae3_ae_ops *ops = handle->ae_algo->ops; + + if (ops->request_update_promisc_mode) + ops->request_update_promisc_mode(handle); }
int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 98cd8a1..c194ab9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -648,6 +648,7 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector,
void hns3_enable_vlan_filter(struct net_device *netdev, bool enable); int hns3_update_promisc_mode(struct net_device *netdev, u8 promisc_flags); +void hns3_request_update_promisc_mode(struct hnae3_handle *handle);
#ifdef CONFIG_HNS3_DCB void hns3_dcbnl_setup(struct hnae3_handle *handle); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index feffd1d..37ce34b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -104,7 +104,7 @@ static int hns3_lp_setup(struct net_device *ndev, enum hnae3_loop loop, bool en) h->ae_algo->ops->set_promisc_mode(h, true, true); } else { /* recover promisc mode before loopback test */ - hns3_update_promisc_mode(ndev, h->netdev_flags); + hns3_request_update_promisc_mode(h); vlan_filter_enable = ndev->flags & IFF_PROMISC ? false : true; hns3_enable_vlan_filter(ndev, vlan_filter_enable); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 635b4f0..f756721 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1279,6 +1279,49 @@ static void hclge_dbg_dump_qs_shaper(struct hclge_dev *hdev, hclge_dbg_dump_qs_shaper_single(hdev, qsid); }
+static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf, + bool is_unicast) +{ + struct hclge_vport_mac_addr_cfg *mac_node, *tmp; + struct hclge_vport *vport; + struct list_head *list; + u32 func_id; + int ret; + + ret = kstrtouint(cmd_buf, 0, &func_id); + if (ret < 0) { + dev_err(&hdev->pdev->dev, + "dump mac list: bad command string, ret=%d\n", ret); + return -EINVAL; + } + + if (func_id >= hdev->num_alloc_vport) { + dev_err(&hdev->pdev->dev, + "function id(%u) is out of range(0-%u)\n", func_id, + hdev->num_alloc_vport - 1); + return -EINVAL; + } + + vport = &hdev->vport[func_id]; + + list = is_unicast ? &vport->uc_mac_list : &vport->mc_mac_list; + + dev_info(&hdev->pdev->dev, "vport %u %s mac list:\n", + func_id, is_unicast ? "uc" : "mc"); + dev_info(&hdev->pdev->dev, "mac address state\n"); + + spin_lock_bh(&vport->mac_list_lock); + + list_for_each_entry_safe(mac_node, tmp, list, node) { + dev_info(&hdev->pdev->dev, "%pM %d\n", + mac_node->mac_addr, mac_node->state); + } + + spin_unlock_bh(&vport->mac_list_lock); + + return 0; +} + int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) { #define DUMP_REG "dump reg" @@ -1318,6 +1361,14 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) } else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) { hclge_dbg_dump_qs_shaper(hdev, &cmd_buf[sizeof("dump qs shaper")]); + } else if (strncmp(cmd_buf, "dump uc mac list", 16) == 0) { + hclge_dbg_dump_mac_list(hdev, + &cmd_buf[sizeof("dump uc mac list")], + true); + } else if (strncmp(cmd_buf, "dump mc mac list", 16) == 0) { + hclge_dbg_dump_mac_list(hdev, + &cmd_buf[sizeof("dump mc mac list")], + false); } else { dev_info(&hdev->pdev->dev, "unknown command\n"); return -EINVAL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 02f35fc..2f0025a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -70,6 +70,7 @@
static void hclge_sync_mac_table(struct hclge_dev *hdev); static int hclge_restore_hw_table(struct hclge_dev *hdev); +static void hclge_sync_promisc_mode(struct hclge_dev *hdev);
struct hnae3_ae_algo ae_algo;
@@ -3738,15 +3739,7 @@ static int hclge_reset_stack(struct hclge_dev *hdev) if (ret) return ret;
- ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT); - if (ret) - return ret; - - /* imp rest and global reset need to restore PF tbl */ - if (hdev->reset_type == HNAE3_IMP_RESET || - hdev->reset_type == HNAE3_GLOBAL_RESET) - return hclge_restore_hw_table(hdev); - return 0; + return hclge_notify_client(hdev, HNAE3_INIT_CLIENT); }
static void hclge_reset(struct hclge_dev *hdev) @@ -4048,6 +4041,7 @@ static void hclge_periodical_service_task(struct hclge_dev *hdev) */ hclge_update_link_status(hdev); hclge_sync_mac_table(hdev); + hclge_sync_promisc_mode(hdev);
if (time_is_after_jiffies(hdev->last_serv_processed + HZ)) { delta = jiffies - hdev->last_serv_processed; @@ -4797,7 +4791,8 @@ static int hclge_cmd_set_promisc_mode(struct hclge_dev *hdev, ret = hclge_cmd_send(&hdev->hw, &desc, 1); if (ret) dev_err(&hdev->pdev->dev, - "Set promisc mode fail, status is %d.\n", ret); + "Set vport %d promisc mode fail, ret = %d.\n", + param->vf_id, ret);
return ret; } @@ -4847,6 +4842,14 @@ static int hclge_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc, en_bc_pmc); }
+static void hclge_request_update_promisc_mode(struct hnae3_handle *handle) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + + set_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state); +} + static int hclge_get_fd_mode(struct hclge_dev *hdev, u8 *fd_mode) { struct hclge_get_fd_mode_cmd *req; @@ -6985,11 +6988,13 @@ int hclge_vport_start(struct hclge_vport *vport) set_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); vport->last_active_jiffies = jiffies;
- /* when received vport start mbx, it means the VF is start now */ - if (test_and_clear_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state) || - test_and_clear_bit(vport->vport_id, hdev->need_restore_vf_table)) { - hclge_restore_mac_table_common(vport); - hclge_restore_vport_vlan_table(vport); + if (test_and_clear_bit(vport->vport_id, hdev->vport_config_block)) { + if (vport->vport_id) { + hclge_restore_mac_table_common(vport); + hclge_restore_vport_vlan_table(vport); + } else { + hclge_restore_hw_table(hdev); + } } return 0; } @@ -7426,6 +7431,8 @@ int hclge_update_mac_list(struct hclge_vport *vport,
set_bit(HCLGE_VPORT_STATE_MAC_TBL_CHANGE, &vport->state);
+ spin_lock_bh(&vport->mac_list_lock); + /* if the mac addr is already in the mac list, no need to add a new * one into it, just check the mac addr state, convert it to a new * new state, or just remove it, or do nothing. @@ -7433,21 +7440,28 @@ int hclge_update_mac_list(struct hclge_vport *vport, mac_node = hclge_find_mac_node(list, addr); if (mac_node) { hclge_mac_node_convert(mac_node, state); + spin_unlock_bh(&vport->mac_list_lock); return 0; }
/* if this address is never added, unnecessary to delete */ - if (state == HCLGE_MAC_TO_DEL) + if (state == HCLGE_MAC_TO_DEL) { + spin_unlock_bh(&vport->mac_list_lock); return -ENOENT; + }
mac_node = kzalloc(sizeof(*mac_node), GFP_ATOMIC); - if (!mac_node) + if (!mac_node) { + spin_unlock_bh(&vport->mac_list_lock); return -ENOMEM; + }
mac_node->state = state; ether_addr_copy(mac_node->mac_addr, addr); list_add_tail(&mac_node->node, list);
+ spin_unlock_bh(&vport->mac_list_lock); + return 0; }
@@ -7455,14 +7469,9 @@ static int hclge_add_uc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); - int ret; - - spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_UC, - addr); - spin_unlock_bh(&vport->mac_list_lock);
- return ret; + return hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_UC, + addr); }
int hclge_add_uc_addr_common(struct hclge_vport *vport, @@ -7512,8 +7521,9 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport, } mutex_unlock(&hdev->vport_lock);
- dev_err(&hdev->pdev->dev, "UC MAC table full(%u)\n", - hdev->priv_umv_size); + if (!(vport->overflow_promisc_flags & HNAE3_OVERFLOW_UPE)) + dev_err(&hdev->pdev->dev, "UC MAC table full(%u)\n", + hdev->priv_umv_size);
return -ENOSPC; } @@ -7536,14 +7546,9 @@ static int hclge_rm_uc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); - int ret;
- spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_UC, - addr); - spin_unlock_bh(&vport->mac_list_lock); - - return ret; + return hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_UC, + addr); }
int hclge_rm_uc_addr_common(struct hclge_vport *vport, @@ -7581,14 +7586,9 @@ static int hclge_add_mc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); - int ret;
- spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_MC, - addr); - spin_unlock_bh(&vport->mac_list_lock); - - return ret; + return hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, HCLGE_MAC_ADDR_MC, + addr); }
int hclge_add_mc_addr_common(struct hclge_vport *vport, @@ -7620,8 +7620,11 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport, return status; status = hclge_add_mac_vlan_tbl(vport, &req, desc);
- if (status == -ENOSPC) + /* if already overflow, not to print each time */ + if (status == -ENOSPC && + !(vport->overflow_promisc_flags & HNAE3_OVERFLOW_MPE)) { dev_err(&hdev->pdev->dev, "mc mac vlan table is full\n"); + }
return status; } @@ -7630,14 +7633,9 @@ static int hclge_rm_mc_addr(struct hnae3_handle *handle, const unsigned char *addr) { struct hclge_vport *vport = hclge_get_vport(handle); - int ret; - - spin_lock_bh(&vport->mac_list_lock); - ret = hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_MC, - addr); - spin_unlock_bh(&vport->mac_list_lock);
- return ret; + return hclge_update_mac_list(vport, HCLGE_MAC_TO_DEL, HCLGE_MAC_ADDR_MC, + addr); }
int hclge_rm_mc_addr_common(struct hclge_vport *vport, @@ -7721,12 +7719,16 @@ static void hclge_unsync_mac_list(struct hclge_vport *vport, } }
-static void hclge_sync_from_add_list(struct list_head *add_list, +static bool hclge_sync_from_add_list(struct list_head *add_list, struct list_head *mac_list) { struct hclge_vport_mac_addr_cfg *mac_node, *tmp, *new_node; + bool all_added = true;
list_for_each_entry_safe(mac_node, tmp, add_list, node) { + if (mac_node->state == HCLGE_MAC_TO_ADD) + all_added = false; + /* if the mac address from tmp_add_list is not in the * uc/mc_mac_list, it means have received a TO_DEL request * during the time window of adding the mac address into mac @@ -7749,6 +7751,7 @@ static void hclge_sync_from_add_list(struct list_head *add_list, kfree(mac_node); } } + return all_added; }
static void hclge_sync_from_del_list(struct list_head *del_list, @@ -7788,12 +7791,30 @@ static void hclge_rollback_del_list(struct list_head *del_list, } }
+static void hclge_update_overflow_flags(struct hclge_vport *vport, + enum HCLGE_MAC_ADDR_TYPE mac_type, + bool is_all_added) +{ + if (mac_type == HCLGE_MAC_ADDR_UC) { + if (is_all_added) + vport->overflow_promisc_flags &= ~HNAE3_OVERFLOW_UPE; + else + vport->overflow_promisc_flags |= HNAE3_OVERFLOW_UPE; + } else { + if (is_all_added) + vport->overflow_promisc_flags &= ~HNAE3_OVERFLOW_MPE; + else + vport->overflow_promisc_flags |= HNAE3_OVERFLOW_MPE; + } +} + static void hclge_sync_vport_mac_table(struct hclge_vport *vport, enum HCLGE_MAC_ADDR_TYPE mac_type) { struct hclge_vport_mac_addr_cfg *mac_node, *tmp, *new_node; struct list_head tmp_add_list, tmp_del_list; struct list_head *list; + bool all_added;
INIT_LIST_HEAD(&tmp_add_list); INIT_LIST_HEAD(&tmp_del_list); @@ -7847,9 +7868,12 @@ static void hclge_sync_vport_mac_table(struct hclge_vport *vport, spin_lock_bh(&vport->mac_list_lock);
hclge_sync_from_del_list(&tmp_del_list, list); - hclge_sync_from_add_list(&tmp_add_list, list); + all_added = hclge_sync_from_add_list(&tmp_add_list, list);
spin_unlock_bh(&vport->mac_list_lock); + + hclge_update_overflow_flags(vport, mac_type, all_added); + return;
clear_tmp_list: @@ -7864,7 +7888,7 @@ static bool hclge_need_sync_mac_table(struct hclge_vport *vport) struct hclge_dev *hdev = vport->back; bool time_up;
- if (test_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state)) + if (test_bit(vport->vport_id, hdev->vport_config_block)) return false;
time_up = !(hdev->serv_processed_cnt % HCLGE_MAC_TBL_SYNC_INTERVAL); @@ -7896,7 +7920,8 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, { int (*unsync)(struct hclge_vport *vport, const unsigned char *addr); struct hclge_vport_mac_addr_cfg *mac_cfg, *tmp; - struct list_head *list; + struct hclge_dev *hdev = vport->back; + struct list_head tmp_del_list, *list; int ret;
if (mac_type == HCLGE_MAC_ADDR_UC) { @@ -7907,18 +7932,33 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, unsync = hclge_rm_mc_addr_common; }
+ INIT_LIST_HEAD(&tmp_del_list); + if (!is_del_list) - set_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state); + set_bit(vport->vport_id, hdev->vport_config_block); + + spin_lock_bh(&vport->mac_list_lock);
list_for_each_entry_safe(mac_cfg, tmp, list, node) { - if (mac_cfg->state == HCLGE_MAC_TO_ADD) { + switch (mac_cfg->state) { + case HCLGE_MAC_TO_DEL: + case HCLGE_MAC_DEL_FAIL: + case HCLGE_MAC_ACTIVE: + list_del(&mac_cfg->node); + list_add_tail(&mac_cfg->node, &tmp_del_list); + break; + case HCLGE_MAC_TO_ADD: if (is_del_list) { list_del(&mac_cfg->node); kfree(mac_cfg); } - continue; + break; } + }
+ spin_unlock_bh(&vport->mac_list_lock); + + list_for_each_entry_safe(mac_cfg, tmp, &tmp_del_list, node) { ret = unsync(vport, mac_cfg->mac_addr); if (!ret || ret == -ENOENT) { /* clear all mac addr from hardware, but remain these @@ -7936,6 +7976,12 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, mac_cfg->state = HCLGE_MAC_TO_DEL; } } + + spin_lock_bh(&vport->mac_list_lock); + + hclge_sync_from_del_list(&tmp_del_list, list); + + spin_unlock_bh(&vport->mac_list_lock); }
/* remove all mac address when uninitailize */ @@ -8240,10 +8286,13 @@ static int hclge_set_mac_addr(struct hnae3_handle *handle, void *p, /* if old dev addr restore failed, add to the uc mac list, * and try to restore it in service task */ - if (old_mac_removed) + if (old_mac_removed) { + spin_lock_bh(&vport->mac_list_lock); hclge_modify_mac_node_state(&vport->uc_mac_list, hdev->hw.mac.mac_addr, HCLGE_MAC_TO_ADD); + spin_unlock_bh(&vport->mac_list_lock); + }
return -EIO; } @@ -8893,19 +8942,10 @@ static void hclge_mac_node_convert_for_reset(struct list_head *list)
void hclge_restore_mac_table_common(struct hclge_vport *vport) { - hclge_mac_node_convert_for_reset(&vport->uc_mac_list); - hclge_mac_node_convert_for_reset(&vport->mc_mac_list); - clear_bit(HCLGE_VPORT_STATE_BLOCK_CONFIG, &vport->state); -} - -static void hclge_restore_pf_mac_table(struct hclge_vport *vport) -{ - /* move the mac addr to the tmp_add_list and tmp_del_list, then - * we can add/delete these mac addr outside the spin lock - */ spin_lock_bh(&vport->mac_list_lock);
- hclge_restore_mac_table_common(vport); + hclge_mac_node_convert_for_reset(&vport->uc_mac_list); + hclge_mac_node_convert_for_reset(&vport->mc_mac_list);
spin_unlock_bh(&vport->mac_list_lock); } @@ -8915,10 +8955,9 @@ static int hclge_restore_hw_table(struct hclge_dev *hdev) struct hclge_vport *vport = &hdev->vport[0]; struct hnae3_handle *handle = &vport->nic;
- bitmap_set(hdev->need_restore_vf_table, 0, hdev->num_alloc_vport); - - hclge_restore_pf_mac_table(vport); + hclge_restore_mac_table_common(vport); hclge_restore_vport_vlan_table(vport); + set_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state);
return hclge_restore_fd_entries(handle); } @@ -10299,6 +10338,8 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) hdev->reset_type == HNAE3_GLOBAL_RESET) { memset(hdev->vlan_table, 0, sizeof(hdev->vlan_table)); memset(hdev->vf_vlan_full, 0, sizeof(hdev->vf_vlan_full)); + bitmap_set(hdev->vport_config_block, 0, hdev->num_alloc_vport); + hclge_reset_umv_space(hdev); }
ret = hclge_cmd_init(hdev); @@ -10313,8 +10354,6 @@ static int hclge_reset_ae_dev(struct hnae3_ae_dev *ae_dev) return ret; }
- hclge_reset_umv_space(hdev); - ret = hclge_mac_init(hdev); if (ret) { dev_err(&pdev->dev, "Mac init error, ret = %d\n", ret); @@ -11126,6 +11165,30 @@ static void hclge_reset_vf_rate(struct hclge_dev *hdev) } }
+static void hclge_sync_promisc_mode(struct hclge_dev *hdev) +{ + struct hclge_vport *vport = &hdev->vport[0]; + struct hnae3_handle *handle = &vport->nic; + u8 tmp_flags = 0; + int ret; + + if (vport->last_promisc_flags != vport->overflow_promisc_flags) { + set_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state); + vport->last_promisc_flags = vport->overflow_promisc_flags; + } + + if (test_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state)) { + tmp_flags = handle->netdev_flags | vport->last_promisc_flags; + ret = hclge_set_promisc_mode(handle, tmp_flags & HNAE3_UPE, + tmp_flags & HNAE3_MPE); + if (!ret) { + clear_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state); + hclge_enable_vlan_filter(handle, + tmp_flags & HNAE3_VLAN_FLTR); + } + } +} + struct hnae3_ae_ops hclge_ops = { .init_ae_dev = hclge_init_ae_dev, .uninit_ae_dev = hclge_uninit_ae_dev, @@ -11138,6 +11201,7 @@ struct hnae3_ae_ops hclge_ops = { .get_vector = hclge_get_vector, .put_vector = hclge_put_vector, .set_promisc_mode = hclge_set_promisc_mode, + .request_update_promisc_mode = hclge_request_update_promisc_mode, .set_loopback = hclge_set_loopback, .start = hclge_ae_start, .stop = hclge_ae_stop, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 05ab6c1..0040d6d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -221,6 +221,7 @@ enum HCLGE_DEV_STATE { HCLGE_STATE_STATISTICS_UPDATING, HCLGE_STATE_CMD_DISABLE, HCLGE_STATE_LINK_UPDATING, + HCLGE_STATE_PROMISC_CHANGED, HCLGE_STATE_MAX };
@@ -814,7 +815,7 @@ struct hclge_dev { unsigned long vlan_table[VLAN_N_VID][BITS_TO_LONGS(HCLGE_VPORT_NUM)]; unsigned long vf_vlan_full[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
- unsigned long need_restore_vf_table[BITS_TO_LONGS(HCLGE_VPORT_NUM)]; + unsigned long vport_config_block[BITS_TO_LONGS(HCLGE_VPORT_NUM)];
struct hclge_fd_cfg fd_cfg; struct hlist_head fd_rule_list; @@ -879,7 +880,6 @@ struct hclge_rss_tuple_cfg { enum HCLGE_VPORT_STATE { HCLGE_VPORT_STATE_ALIVE, HCLGE_VPORT_STATE_MAC_TBL_CHANGE, - HCLGE_VPORT_STATE_BLOCK_CONFIG, /* blocking mac configuration */ HCLGE_VPORT_STATE_MAX };
@@ -944,6 +944,8 @@ struct hclge_vport { u32 max_tx_rate; u32 trusted; u16 promisc_enable; + u8 overflow_promisc_flags; + u8 last_promisc_flags;
spinlock_t mac_list_lock; /* protect mac address need to add/detele */ struct list_head uc_mac_list; /* Store VF unicast table */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index e93e8d7..7636411 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -276,14 +276,19 @@ static int hclge_modify_vf_mac_addr(struct hclge_vport *vport, ret = hclge_add_uc_addr_common(vport, new_addr); if (ret) { ret = hclge_add_uc_addr_common(vport, old_addr); - if (ret) + if (ret) { + spin_lock_bh(&vport->mac_list_lock); hclge_modify_mac_node_state(&vport->uc_mac_list, old_addr, HCLGE_MAC_TO_ADD); + spin_unlock_bh(&vport->mac_list_lock); + } return -EIO;
} else { + spin_lock_bh(&vport->mac_list_lock); hclge_replace_mac_node(&vport->uc_mac_list, old_addr, new_addr, !old_mac_removed); + spin_unlock_bh(&vport->mac_list_lock); } return ret; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index c52b070..aa6541e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1160,6 +1160,27 @@ static int hclgevf_set_promisc_mode(struct hnae3_handle *handle, bool en_uc_pmc, en_bc_pmc); }
+static void hclgevf_request_update_promisc_mode(struct hnae3_handle *handle) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + + set_bit(HCLGEVF_STATE_PROMISC_CHANGED, &hdev->state); +} + +static void hclgevf_sync_promisc_mode(struct hclgevf_dev *hdev) +{ + struct hnae3_handle *handle = &hdev->nic; + bool en_uc_pmc = handle->netdev_flags & HNAE3_UPE; + bool en_mc_pmc = handle->netdev_flags & HNAE3_MPE; + int ret; + + if (test_bit(HCLGEVF_STATE_PROMISC_CHANGED, &hdev->state)) { + ret = hclgevf_set_promisc_mode(handle, en_uc_pmc, en_mc_pmc); + if (!ret) + clear_bit(HCLGEVF_STATE_PROMISC_CHANGED, &hdev->state); + } +} + static int hclgevf_tqp_enable(struct hclgevf_dev *hdev, unsigned int tqp_id, int stream_id, bool enable) { @@ -2116,6 +2137,8 @@ static void hclgevf_periodical_service_task(struct hclgevf_dev *hdev)
hclgevf_sync_mac_table(hdev);
+ hclgevf_sync_promisc_mode(hdev); + hdev->last_serv_processed = jiffies;
out: @@ -2914,6 +2937,8 @@ static int hclgevf_reset_hdev(struct hclgevf_dev *hdev) return ret; }
+ set_bit(HCLGEVF_STATE_PROMISC_CHANGED, &hdev->state); + dev_info(&hdev->pdev->dev, "Reset done\n");
return 0; @@ -3420,6 +3445,7 @@ void hclgevf_update_port_base_vlan_info(struct hclgevf_dev *hdev, u16 state, .set_timer_task = hclgevf_set_timer_task, .get_link_mode = hclgevf_get_link_mode, .set_promisc_mode = hclgevf_set_promisc_mode, + .request_update_promisc_mode = hclgevf_request_update_promisc_mode, };
static struct hnae3_ae_algo ae_algovf = { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index cb62472..2d30c61 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -150,6 +150,7 @@ enum hclgevf_states { HCLGEVF_STATE_MBX_HANDLING, HCLGEVF_STATE_CMD_DISABLE, HCLGEVF_STATE_LINK_UPDATING, + HCLGEVF_STATE_PROMISC_CHANGED, };
#define HCLGEVF_MPF_ENBALE 1
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch merges back some code from net-next about below patches: net: hns3: add support for configuring VF MAC from the host net: hns3: add support for spoof check setting net: hns3: add support for setting VF trust net: hns3: add support for configuring bandwidth of VF on the host net: hns3: add support for setting VF link status on the host net: hns3: support tx-scatter-gather-fraglist feature net: hns3: fix spelling mistake "undeflow" -> "underflow"
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 8 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 59 +++-- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 252 ++++++++++----------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 16 +- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 33 ++- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 12 - 8 files changed, 200 insertions(+), 184 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index ad1274e..c7ac3f8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -364,6 +364,10 @@ struct hnae3_ae_dev { * Enable/disable HW GRO * add_arfs_entry * Check the 5-tuples of flow, and create flow director rule + * get_vf_config + * Get the VF configuration setting by the host + * set_vf_link_state + * Set VF link status * set_vf_spoofchk * Enable/disable spoof check for specified vf * set_vf_trust @@ -371,6 +375,8 @@ struct hnae3_ae_dev { * it can enable promisc mode * set_vf_rate * Set the max tx rate of specified vf. + * set_vf_mac + * Configure the default MAC for specified VF */ struct hnae3_ae_ops { int (*init_ae_dev)(struct hnae3_ae_dev *ae_dev); @@ -551,10 +557,10 @@ struct hnae3_ae_ops { int link_state); int (*set_vf_spoofchk)(struct hnae3_handle *handle, int vf, bool enable); - int (*set_vf_mac)(struct hnae3_handle *handle, int vf, u8 *p); int (*set_vf_trust)(struct hnae3_handle *handle, int vf, bool enable); int (*set_vf_rate)(struct hnae3_handle *handle, int vf, int min_tx_rate, int max_tx_rate, bool force); + int (*set_vf_mac)(struct hnae3_handle *handle, int vf, u8 *p); };
struct hnae3_dcb_ops { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 2b22c0e..573cc0b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1259,15 +1259,13 @@ static bool hns3_skb_need_linearized(struct sk_buff *skb, unsigned int *bd_size, for (i = 0; i < HNS3_MAX_NON_TSO_BD_NUM - 1U; i++) tot_len += bd_size[i];
- /* ensure the first 8 frags is greater than mss + header the first - * 7 frags is greater than mss. - */ + /* ensure the first 8 frags is greater than mss + header */ if (tot_len + bd_size[HNS3_MAX_NON_TSO_BD_NUM - 1U] < skb_shinfo(skb)->gso_size + hns3_gso_hdr_len(skb)) return true;
- /* ensure the remaining continuous 7 buffer is greater than mss - * except the last 7 frags. + /* ensure every continuous 7 buffer is greater than mss + * except the last one. */ for (i = 0; i < bd_num - HNS3_MAX_NON_TSO_BD_NUM; i++) { tot_len -= bd_size[i]; @@ -1494,6 +1492,16 @@ static int hns3_nic_net_set_mac_address(struct net_device *netdev, void *p) return 0; }
+ /* For VF device, if there is a perm_addr, then the user will not + * be allowed to change the address. + */ + if (!hns3_is_phys_func(h->pdev) && + !is_zero_ether_addr(netdev->perm_addr)) { + netdev_err(netdev, "has permanent MAC %pM, user MAC %pM not allow\n", + netdev->perm_addr, mac_addr->sa_data); + return -EPERM; + } + ret = h->ae_algo->ops->set_mac_addr(h, mac_addr->sa_data, false); if (ret) { netdev_err(netdev, "set_mac_address fail, ret=%d!\n", ret); @@ -2007,6 +2015,18 @@ static int hns3_nic_set_vf_link_state(struct net_device *ndev, int vf, return h->ae_algo->ops->set_vf_link_state(h, vf, link_state); }
+static int hns3_nic_set_vf_rate(struct net_device *ndev, int vf, + int min_tx_rate, int max_tx_rate) +{ + struct hnae3_handle *h = hns3_get_handle(ndev); + + if (!h->ae_algo->ops->set_vf_rate) + return -EOPNOTSUPP; + + return h->ae_algo->ops->set_vf_rate(h, vf, min_tx_rate, max_tx_rate, + false); +} + static int hns3_nic_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) { struct hnae3_handle *h = hns3_get_handle(netdev); @@ -2014,28 +2034,16 @@ static int hns3_nic_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) if (!h->ae_algo->ops->set_vf_mac) return -EOPNOTSUPP;
- if (is_broadcast_ether_addr(mac) || - is_multicast_ether_addr(mac)) { + if (is_multicast_ether_addr(mac)) { netdev_err(netdev, - "Set VF MAC error! invalid mac:%pM.\n", mac); + "Invalid MAC:%pM specified. Could not set MAC\n", + mac); return -EINVAL; }
return h->ae_algo->ops->set_vf_mac(h, vf_id, mac); }
-static int hns3_nic_set_vf_rate(struct net_device *ndev, int vf, - int min_tx_rate, int max_tx_rate) -{ - struct hnae3_handle *h = hns3_get_handle(ndev); - - if (!h->ae_algo->ops->set_vf_rate) - return -EOPNOTSUPP; - - return h->ae_algo->ops->set_vf_rate(h, vf, min_tx_rate, max_tx_rate, - false); -} - struct net_device_ops hns3_nic_netdev_ops = { .ndo_open = hns3_nic_net_open, .ndo_stop = hns3_nic_net_stop, @@ -2061,8 +2069,8 @@ struct net_device_ops hns3_nic_netdev_ops = { #endif .ndo_get_vf_config = hns3_nic_get_vf_config, .ndo_set_vf_link_state = hns3_nic_set_vf_link_state, - .ndo_set_vf_mac = hns3_nic_set_vf_mac, .ndo_set_vf_rate = hns3_nic_set_vf_rate, + .ndo_set_vf_mac = hns3_nic_set_vf_mac, };
bool hns3_is_phys_func(struct pci_dev *pdev) @@ -3934,16 +3942,17 @@ static int hns3_init_mac_addr(struct net_device *netdev) u8 mac_addr_temp[ETH_ALEN]; int ret = 0;
- if (h->ae_algo->ops->get_mac_addr) { + if (h->ae_algo->ops->get_mac_addr) h->ae_algo->ops->get_mac_addr(h, mac_addr_temp); - ether_addr_copy(netdev->dev_addr, mac_addr_temp); - }
/* Check if the MAC address is valid, if not get a random one */ - if (!is_valid_ether_addr(netdev->dev_addr)) { + if (!is_valid_ether_addr(mac_addr_temp)) { eth_hw_addr_random(netdev); dev_warn(priv->dev, "using random MAC address %pM\n", netdev->dev_addr); + } else { + ether_addr_copy(netdev->dev_addr, mac_addr_temp); + ether_addr_copy(netdev->perm_addr, mac_addr_temp); }
if (h->ae_algo->ops->set_mac_addr) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index 3af3b06..d017d9a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -98,7 +98,7 @@ .reset_level = HNAE3_GLOBAL_RESET }, { .int_msk = BIT(1), .msg = "rx_stp_fifo_overflow", .reset_level = HNAE3_GLOBAL_RESET }, - { .int_msk = BIT(2), .msg = "rx_stp_fifo_undeflow", + { .int_msk = BIT(2), .msg = "rx_stp_fifo_underflow", .reset_level = HNAE3_GLOBAL_RESET }, { .int_msk = BIT(3), .msg = "tx_buf_overflow", .reset_level = HNAE3_GLOBAL_RESET }, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2f0025a..5e21b38 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -65,8 +65,6 @@ static void hclge_rfs_filter_expire(struct hclge_dev *hdev); static void hclge_clear_arfs_rules(struct hnae3_handle *handle); static int hclge_set_default_loopback(struct hclge_dev *hdev); -static int hclge_resume_vf_rate(struct hclge_dev *hdev); -static void hclge_reset_vf_rate(struct hclge_dev *hdev);
static void hclge_sync_mac_table(struct hclge_dev *hdev); static int hclge_restore_hw_table(struct hclge_dev *hdev); @@ -1708,7 +1706,7 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) for (i = 0; i < num_vport; i++) { vport->back = hdev; vport->vport_id = i; - vport->link_state = IFLA_VF_LINK_STATE_AUTO; + vport->vf_info.link_state = IFLA_VF_LINK_STATE_AUTO; vport->mps = HCLGE_MAC_DEFAULT_FRAME; vport->port_base_vlan_cfg.state = HNAE3_PORT_BASE_VLAN_DISABLE; vport->rxvlan_cfg.rx_vlan_offload_en = true; @@ -2945,7 +2943,7 @@ static struct hclge_vport *hclge_get_vf_vport(struct hclge_dev *hdev, int vf) return NULL; }
- /* vf start from 1 in vport */ + /* VF start from 1 in vport */ vf += HCLGE_VF_VPORT_START_NUM; return &hdev->vport[vf]; } @@ -2961,15 +2959,15 @@ static int hclge_get_vf_config(struct hnae3_handle *handle, int vf, return -EINVAL;
ivf->vf = vf; - ivf->linkstate = vport->link_state; - ivf->spoofchk = vport->spoofchk; - ivf->trusted = vport->trusted; + ivf->linkstate = vport->vf_info.link_state; + ivf->spoofchk = vport->vf_info.spoofchk; + ivf->trusted = vport->vf_info.trusted; ivf->min_tx_rate = 0; - ivf->max_tx_rate = vport->max_tx_rate; + ivf->max_tx_rate = vport->vf_info.max_tx_rate; ivf->vlan = vport->port_base_vlan_cfg.vlan_info.vlan_tag; ivf->vlan_proto = htons(vport->port_base_vlan_cfg.vlan_info.vlan_proto); ivf->qos = vport->port_base_vlan_cfg.vlan_info.qos; - ether_addr_copy(ivf->mac, vport->mac); + ether_addr_copy(ivf->mac, vport->vf_info.mac);
return 0; } @@ -2984,7 +2982,7 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf, if (!vport) return -EINVAL;
- vport->link_state = link_state; + vport->vf_info.link_state = link_state;
return 0; } @@ -8100,20 +8098,14 @@ static bool hclge_check_vf_mac_exist(struct hclge_vport *vport, int vf_idx, req.egress_port = cpu_to_le16(egress_port); hclge_prepare_mac_addr(&req, mac_addr, false);
- if (hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false) != -ENOENT) { - dev_info(&hdev->pdev->dev, "Specified MAC(=%pM) exists!\n", - mac_addr); + if (hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false) != -ENOENT) return true; - }
+ vf_idx += HCLGE_VF_VPORT_START_NUM; for (i = hdev->num_vmdq_vport + 1; i < hdev->num_alloc_vport; i++) if (i != vf_idx && - ether_addr_equal(mac_addr, hdev->vport[i].mac)) { - dev_info(&hdev->pdev->dev, - "Specified MAC(=%pM) is same as vport%d, no change committed!\n", - mac_addr, i); + ether_addr_equal(mac_addr, hdev->vport[i].vf_info.mac)) return true; - }
return false; } @@ -8124,27 +8116,29 @@ static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back;
- if (hclge_check_vf_mac_exist(vport, vf + HCLGE_VF_VPORT_START_NUM, - mac_addr)) - return -EEXIST; - vport = hclge_get_vf_vport(hdev, vf); if (!vport) return -EINVAL;
- if (ether_addr_equal(mac_addr, vport->mac)) { + if (ether_addr_equal(mac_addr, vport->vf_info.mac)) { dev_info(&hdev->pdev->dev, "Specified MAC(=%pM) is same as before, no change committed!\n", - vport->mac); + mac_addr); return 0; }
- ether_addr_copy(vport->mac, mac_addr); + if (hclge_check_vf_mac_exist(vport, vf, mac_addr)) { + dev_err(&hdev->pdev->dev, "Specified MAC(=%pM) exists!\n", + mac_addr); + return -EEXIST; + } + + ether_addr_copy(vport->vf_info.mac, mac_addr); dev_info(&hdev->pdev->dev, - "VF %d has been set to %pM. Please reload/reset VF\n", - vf, vport->mac); + "MAC of VF %d has been set to %pM, and it will be reinitialized!\n", + vf, mac_addr);
- return 0; + return hclge_inform_reset_assert_to_vf(vport); }
static int hclge_add_mgr_tbl(struct hclge_dev *hdev, @@ -8404,7 +8398,7 @@ static int hclge_set_vf_vlan_common(struct hclge_dev *hdev, u16 vfid, * new vlan, because tx packets with these vlan id will be dropped. */ if (test_bit(vfid, hdev->vf_vlan_full) && !is_kill) { - if (vport->spoofchk && vlan) { + if (vport->vf_info.spoofchk && vlan) { dev_err(&hdev->pdev->dev, "Can't add vlan due to spoof check is on and vf vlan table is full\n"); return -EPERM; @@ -10240,7 +10234,7 @@ static int hclge_set_vf_spoofchk(struct hnae3_handle *handle, int vf, if (!vport) return -EINVAL;
- if (vport->spoofchk == new_spoofchk) + if (vport->vf_info.spoofchk == new_spoofchk) return 0;
if (enable && test_bit(vport->vport_id, hdev->vf_vlan_full)) @@ -10256,7 +10250,7 @@ static int hclge_set_vf_spoofchk(struct hnae3_handle *handle, int vf, if (ret) return ret;
- vport->spoofchk = new_spoofchk; + vport->vf_info.spoofchk = new_spoofchk; return 0; }
@@ -10272,12 +10266,13 @@ static int hclge_reset_vport_spoofchk(struct hclge_dev *hdev) /* resume the vf spoof check state after reset */ for (i = 0; i < hdev->num_alloc_vport; i++) { ret = hclge_set_vf_spoofchk_hw(hdev, vport->vport_id, - vport->spoofchk); + vport->vf_info.spoofchk); if (ret) return ret;
vport++; } + return 0; }
@@ -10293,21 +10288,113 @@ static int hclge_set_vf_trust(struct hnae3_handle *handle, int vf, bool enable) if (!vport) return -EINVAL;
- if (vport->trusted == new_trusted) + if (vport->vf_info.trusted == new_trusted) return 0;
/* Disable promisc mode for VF if it is not trusted any more. */ - if (!enable && vport->promisc_enable) { + if (!enable && vport->vf_info.promisc_enable) { en_bc_pmc = hdev->pdev->revision != 0x20; ret = hclge_set_vport_promisc_mode(vport, false, false, en_bc_pmc); if (ret) return ret; - vport->promisc_enable = 0; + vport->vf_info.promisc_enable = 0; hclge_inform_vf_promisc_info(vport); }
- vport->trusted = new_trusted; + vport->vf_info.trusted = new_trusted; + + return 0; +} + +static void hclge_reset_vf_rate(struct hclge_dev *hdev) +{ + int ret; + int vf; + + /* reset vf rate to default value */ + for (vf = HCLGE_VF_VPORT_START_NUM; vf < hdev->num_alloc_vport; vf++) { + struct hclge_vport *vport = &hdev->vport[vf]; + + vport->vf_info.max_tx_rate = 0; + ret = hclge_tm_qs_shaper_cfg(vport, vport->vf_info.max_tx_rate); + if (ret) + dev_err(&hdev->pdev->dev, + "vf%d failed to reset to default, ret=%d\n", + vf - HCLGE_VF_VPORT_START_NUM, ret); + } +} + +static int hclge_vf_rate_param_check(struct hclge_dev *hdev, int vf, + int min_tx_rate, int max_tx_rate) +{ + if (min_tx_rate != 0 || + max_tx_rate < 0 || max_tx_rate > hdev->hw.mac.max_speed) { + dev_err(&hdev->pdev->dev, + "min_tx_rate:%d [0], max_tx_rate:%d [0, %u]\n", + min_tx_rate, max_tx_rate, hdev->hw.mac.max_speed); + return -EINVAL; + } + + return 0; +} + +static int hclge_set_vf_rate(struct hnae3_handle *handle, int vf, + int min_tx_rate, int max_tx_rate, bool force) +{ + struct hclge_vport *vport = hclge_get_vport(handle); + struct hclge_dev *hdev = vport->back; + int ret; + + ret = hclge_vf_rate_param_check(hdev, vf, min_tx_rate, max_tx_rate); + if (ret) + return ret; + + vport = hclge_get_vf_vport(hdev, vf); + if (!vport) + return -EINVAL; + + if (!force && max_tx_rate == vport->vf_info.max_tx_rate) + return 0; + + ret = hclge_tm_qs_shaper_cfg(vport, max_tx_rate); + if (ret) + return ret; + + vport->vf_info.max_tx_rate = max_tx_rate; + + return 0; +} + +static int hclge_resume_vf_rate(struct hclge_dev *hdev) +{ + struct hnae3_handle *handle = &hdev->vport->nic; + struct hclge_vport *vport; + int ret; + int vf; + + /* resume the vf max_tx_rate after reset */ + for (vf = 0; vf < pci_num_vf(hdev->pdev); vf++) { + vport = hclge_get_vf_vport(hdev, vf); + if (!vport) + return -EINVAL; + + /* zero means max rate, after reset, firmware already set it to + * max rate, so just continue. + */ + if (!vport->vf_info.max_tx_rate) + continue; + + ret = hclge_set_vf_rate(handle, vf, 0, + vport->vf_info.max_tx_rate, true); + if (ret) { + dev_err(&hdev->pdev->dev, + "vf%d failed to resume tx_rate:%u, ret=%d\n", + vf, vport->vf_info.max_tx_rate, ret); + return ret; + } + } + return 0; }
@@ -11074,97 +11161,6 @@ static int hclge_gro_en(struct hnae3_handle *handle, bool enable) return hclge_config_gro(hdev, enable); }
-static int hclge_vf_rate_param_check(struct hclge_dev *hdev, int vf, - int min_tx_rate, int max_tx_rate) -{ - if (min_tx_rate != 0 || - max_tx_rate < 0 || max_tx_rate > hdev->hw.mac.max_speed) { - dev_err(&hdev->pdev->dev, - "min_tx_rate:%d [0], max_tx_rate:%d [0, %u]\n", - min_tx_rate, max_tx_rate, hdev->hw.mac.max_speed); - return -EINVAL; - } - - return 0; -} - -static int hclge_set_vf_rate(struct hnae3_handle *handle, int vf, - int min_tx_rate, int max_tx_rate, bool force) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - int ret; - - ret = hclge_vf_rate_param_check(hdev, vf, min_tx_rate, max_tx_rate); - if (ret) - return ret; - - vport = hclge_get_vf_vport(hdev, vf); - if (!vport) - return -EINVAL; - - if (!force && max_tx_rate == vport->max_tx_rate) - return 0; - - ret = hclge_tm_qs_shaper_cfg(vport, max_tx_rate); - if (ret) - return ret; - - vport->max_tx_rate = max_tx_rate; - - return 0; -} - -static int hclge_resume_vf_rate(struct hclge_dev *hdev) -{ - struct hnae3_handle *handle = &hdev->vport->nic; - struct hclge_vport *vport; - int ret; - int vf; - - /* resume the vf max_tx_rate after reset */ - for (vf = 0; vf < pci_num_vf(hdev->pdev); vf++) { - vport = hclge_get_vf_vport(hdev, vf); - if (!vport) - return -EINVAL; - - /* zero means max rate, after reset, firmware already set it to - * max rate, so just continue. - */ - if (!vport->max_tx_rate) - continue; - - ret = hclge_set_vf_rate(handle, vf, 0, vport->max_tx_rate, - true); - if (ret) { - dev_err(&hdev->pdev->dev, - "vf%d failed to resume tx_rate:%u, ret=%d\n", - vf, vport->max_tx_rate, ret); - return ret; - } - } - - return 0; -} - -static void hclge_reset_vf_rate(struct hclge_dev *hdev) -{ - int ret; - int vf; - - /* reset vf rate to default value */ - for (vf = HCLGE_VF_VPORT_START_NUM; vf < hdev->num_alloc_vport; vf++) { - struct hclge_vport *vport = &hdev->vport[vf]; - - vport->max_tx_rate = 0; - ret = hclge_tm_qs_shaper_cfg(vport, vport->max_tx_rate); - if (ret) - dev_err(&hdev->pdev->dev, - "vf%d failed to reset to default, ret=%d\n", - vf - HCLGE_VF_VPORT_START_NUM, ret); - } -} - static void hclge_sync_promisc_mode(struct hclge_dev *hdev) { struct hclge_vport *vport = &hdev->vport[0]; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 0040d6d..a82c6fc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -905,6 +905,15 @@ struct hclge_port_base_vlan_config { struct hclge_vlan_info vlan_info; };
+struct hclge_vf_info { + int link_state; + u8 mac[ETH_ALEN]; + u32 spoofchk; + u32 max_tx_rate; + u32 trusted; + u16 promisc_enable; +}; + struct hclge_vport { u16 alloc_tqps; /* Allocated Tx/Rx queues */
@@ -936,16 +945,11 @@ struct hclge_vport {
unsigned long state; unsigned long last_active_jiffies; - int link_state; - u8 mac[ETH_ALEN]; int mps; /* Max packet size */
- u32 spoofchk; - u32 max_tx_rate; - u32 trusted; - u16 promisc_enable; u8 overflow_promisc_flags; u8 last_promisc_flags; + struct hclge_vf_info vf_info;
spinlock_t mac_list_lock; /* protect mac address need to add/detele */ struct list_head uc_mac_list; /* Store VF unicast table */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 7636411..8f302fa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -240,14 +240,14 @@ static int hclge_set_vf_promisc_mode(struct hclge_vport *vport, bool en_mc = req->msg.en_mc ? true : false; int ret;
- if (!vport->trusted) { + if (!vport->vf_info.trusted) { en_uc = false; en_mc = false; }
ret = hclge_set_vport_promisc_mode(vport, en_uc, en_mc, en_bc);
- vport->promisc_enable = (en_uc || en_mc) ? 1 : 0; + vport->vf_info.promisc_enable = (en_uc || en_mc) ? 1 : 0;
return ret; } @@ -257,10 +257,10 @@ void hclge_inform_vf_promisc_info(struct hclge_vport *vport) u8 dest_vfid = (u8)vport->vport_id; u8 msg_data[2];
- memcpy(&msg_data[0], &vport->promisc_enable, sizeof(u16)); + memcpy(&msg_data[0], &vport->vf_info.promisc_enable, sizeof(u16));
- (void)hclge_send_mbx_msg(vport, msg_data, sizeof(msg_data), - HCLGE_MBX_PUSH_PROMISC_INFO, dest_vfid); + hclge_send_mbx_msg(vport, msg_data, sizeof(msg_data), + HCLGE_MBX_PUSH_PROMISC_INFO, dest_vfid); }
static int hclge_modify_vf_mac_addr(struct hclge_vport *vport, @@ -305,9 +305,19 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, const u8 *old_addr = (const u8 *) (&mbx_req->msg.data[HCLGE_MBX_VF_OLD_MAC_ADDR_OFFSET]);
- if (!is_zero_ether_addr(vport->mac) && - !ether_addr_equal(mac_addr, vport->mac)) - return -EPERM; + /* If VF MAC has been configured by the host then it + * cannot be overridden by the MAC specified by the VM. + */ + if (!is_zero_ether_addr(vport->vf_info.mac) && + !ether_addr_equal(mac_addr, vport->vf_info.mac)) { + status = -EPERM; + goto out; + } + + if (!is_valid_ether_addr(mac_addr)) { + status = -EINVAL; + goto out; + }
if (is_zero_ether_addr(old_addr)) { status = hclge_add_uc_addr_common(vport, mac_addr); @@ -334,6 +344,8 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, mbx_req->msg.subcode); return -EIO; } + +out: return status; }
@@ -467,7 +479,7 @@ static void hclge_get_vf_queue_info(struct hclge_vport *vport, static void hclge_get_vf_mac_addr(struct hclge_vport *vport, struct hclge_respond_to_vf_msg *resp_msg) { - ether_addr_copy(resp_msg->data, vport->mac); + ether_addr_copy(resp_msg->data, vport->vf_info.mac); resp_msg->len = ETH_ALEN; }
@@ -507,6 +519,7 @@ static int hclge_get_link_info(struct hclge_vport *vport, { #define HCLGE_VF_LINK_STATE_UP 1U #define HCLGE_VF_LINK_STATE_DOWN 0U + struct hclge_dev *hdev = vport->back; u16 link_status; u8 msg_data[8]; @@ -514,7 +527,7 @@ static int hclge_get_link_info(struct hclge_vport *vport, u16 duplex;
/* mac.link can only be 0 or 1 */ - switch (vport->link_state) { + switch (vport->vf_info.link_state) { case IFLA_VF_LINK_STATE_ENABLE: link_status = HCLGE_VF_LINK_STATE_UP; break; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c index 62b0206..fbc39a2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c @@ -46,7 +46,7 @@ static int hclge_shaper_para_calc(u32 ir, u8 shaper_level, #define DIVISOR_CLK (1000 * 8) #define DIVISOR_IR_B_126 (126 * DIVISOR_CLK)
- const u16 tick_array[HCLGE_SHAPER_LVL_CNT] = { + static const u16 tick_array[HCLGE_SHAPER_LVL_CNT] = { 6 * 256, /* Prioriy level */ 6 * 32, /* Prioriy group level */ 6 * 8, /* Port level */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index aa6541e..c61e3c1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1259,20 +1259,8 @@ static int hclgevf_set_mac_addr(struct hnae3_handle *handle, void *p, u8 *old_mac_addr = (u8 *)hdev->hw.mac.mac_addr; struct hclge_vf_to_pf_msg send_msg; u8 *new_mac_addr = (u8 *)p; - u8 host_mac_addr[ETH_ALEN]; int status;
- status = hclgevf_get_host_mac_addr(hdev, host_mac_addr); - if (status) - return status; - - if (!is_first && hdev->has_pf_mac) { - dev_err(&hdev->pdev->dev, - "has host VF mac %pM, user MAC %pM not allow\n", - old_mac_addr, p); - return -EPERM; - } - hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST, 0); send_msg.subcode = HCLGE_MBX_MAC_VLAN_UC_MODIFY; ether_addr_copy(send_msg.data, new_mac_addr);
From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Hns3 had refine mac address configure for VF, and function hns3_remove_hw_addr was useless.
This patch also delete some useless definication in set vf mac addr.
Fixes: 74500eb0024 ("net: hns3: refine mac address configure for VF")
Signed-off-by: Guojia Liao liaoguojia@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 25 ---------------------- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 3 +-- 2 files changed, 1 insertion(+), 27 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 573cc0b..ae7a3d1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -40,7 +40,6 @@ } while (0)
static void hns3_clear_all_ring(struct hnae3_handle *h, bool force); -static void hns3_remove_hw_addr(struct net_device *netdev);
const char hns3_driver_name[] = "hns3"; char hns3_driver_version[] = VERMAGIC_STRING; @@ -4153,8 +4152,6 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset) struct hns3_nic_priv *priv = netdev_priv(netdev); int ret;
- hns3_remove_hw_addr(netdev); - if (netdev->reg_state != NETREG_UNINITIALIZED) unregister_netdev(netdev);
@@ -4225,28 +4222,6 @@ static int hns3_client_setup_tc(struct hnae3_handle *handle, u8 tc) return hns3_nic_set_real_num_queue(ndev); }
-static void hns3_remove_hw_addr(struct net_device *netdev) -{ - struct netdev_hw_addr_list *list; - struct netdev_hw_addr *ha, *tmp; - - hns3_nic_uc_unsync(netdev, netdev->dev_addr); - - netif_addr_lock_bh(netdev); - /* go through and unsync uc_addr entries to the device */ - list = &netdev->uc; - list_for_each_entry_safe(ha, tmp, &list->list, list) - hns3_nic_uc_unsync(netdev, ha->addr); - - /* go through and unsync mc_addr entries to the device */ - list = &netdev->mc; - list_for_each_entry_safe(ha, tmp, &list->list, list) - if (ha->refcount > 1) - hns3_nic_mc_unsync(netdev, ha->addr); - - netif_addr_unlock_bh(netdev); -} - static void hns3_clear_tx_ring(struct hns3_enet_ring *ring) { while (ring->next_to_clean != ring->next_to_use) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 8f302fa..31b174d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -354,7 +354,6 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, { const u8 *mac_addr = (const u8 *)(mbx_req->msg.data); struct hclge_dev *hdev = vport->back; - int status = 0;
if (mbx_req->msg.subcode == HCLGE_MBX_MAC_VLAN_MC_ADD) { hclge_update_mac_list(vport, HCLGE_MAC_TO_ADD, @@ -369,7 +368,7 @@ static int hclge_set_vf_mc_mac_addr(struct hclge_vport *vport, return -EIO; }
- return status; + return 0; }
int hclge_push_vf_port_base_vlan_info(struct hclge_vport *vport, u8 vfid,
From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, hns3 had got two print to announces Unicast and Multicast table was full. So we delete one of them.
Fixes: c074500eb002 ("net: hns3: refine mac address configure for VF")
Signed-off-by: Guojia Liao liaoguojia@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 5e21b38..814669d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -7030,17 +7030,11 @@ static int hclge_get_mac_vlan_cmd_status(struct hclge_vport *vport, }
if (op == HCLGE_MAC_VLAN_ADD) { - if ((!resp_code) || (resp_code == 1)) { + if (!resp_code || resp_code == 1) return 0; - } else if (resp_code == HCLGE_ADD_UC_OVERFLOW) { - dev_err(&hdev->pdev->dev, - "add mac addr failed for uc_overflow.\n"); - return -ENOSPC; - } else if (resp_code == HCLGE_ADD_MC_OVERFLOW) { - dev_err(&hdev->pdev->dev, - "add mac addr failed for mc_overflow.\n"); + else if (resp_code == HCLGE_ADD_UC_OVERFLOW || + resp_code == HCLGE_ADD_MC_OVERFLOW) return -ENOSPC; - }
dev_err(&hdev->pdev->dev, "add mac addr failed for undefined, code=%u.\n",
From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
When PF set VF mac address, we need to sync the mac address to netdev. But we just forgot this point after optimize the code at patch "refine mac address configure for VF".
This patch fix it.
Fixes: c074500eb002 ("net: hns3: refine mac address configure for VF")
Signed-off-by: Guojia Liao liaoguojia@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index ae7a3d1..6cde7a6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -4453,6 +4453,9 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) goto err_init_irq_fail; }
+ if (!hns3_is_phys_func(handle->pdev)) + hns3_init_mac_addr(netdev); + ret = hns3_client_start(handle); if (ret) { dev_err(priv->dev, "hns3_client_start fail! ret=%d\n", ret); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index c61e3c1..ea41414 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1264,7 +1264,7 @@ static int hclgevf_set_mac_addr(struct hnae3_handle *handle, void *p, hclgevf_build_send_msg(&send_msg, HCLGE_MBX_SET_UNICAST, 0); send_msg.subcode = HCLGE_MBX_MAC_VLAN_UC_MODIFY; ether_addr_copy(send_msg.data, new_mac_addr); - if (is_first) + if (is_first && !hdev->has_pf_mac) eth_zero_addr(&send_msg.data[ETH_ALEN]); else ether_addr_copy(&send_msg.data[ETH_ALEN], old_mac_addr);
From: liuzhongzhu liuzhongzhu@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
This patch prints mac table information.
debugfs command: echo dump mac tbl > cmd
Sample Command: root@(none)# echo dump mac tbl > cmd
Signed-off-by: liuzhongzhu liuzhongzhu@huawei.com Signed-off-by: Peng Li lipeng321@huawei.com Signed-off-by: Yonglong Liu liuyonglong@huawei.com Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 1 + .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 130 +++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h | 17 +++ 3 files changed, 148 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 0babf50..8cb4b3b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -255,6 +255,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump qos pause cfg\n"); dev_info(&h->pdev->dev, "dump qos pri map\n"); dev_info(&h->pdev->dev, "dump qos buf cfg\n"); + dev_info(&h->pdev->dev, "dump mac tbl\n"); dev_info(&h->pdev->dev, "dump mng tbl\n"); dev_info(&h->pdev->dev, "dump reset info\n"); dev_info(&h->pdev->dev, "dump m7 info\n"); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index f756721..9bc30f7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -831,6 +831,134 @@ static void hclge_dbg_dump_qos_buf_cfg(struct hclge_dev *hdev) "dump qos buf cfg fail(0x%x), ret = %d\n", cmd, ret); }
+static void hclge_dbg_dump_mac_table(struct hclge_dev *hdev) +{ + struct hclge_mac_vlan_idx_rd_cmd *mac_rd_cmd; + struct hclge_mac_vlan_idx_rd_mc *mc_mac_tbl; + char printf_buf[HCLGE_DBG_BUF_LEN]; + struct hclge_desc desc[3]; + u32 mc_tbl_idx, i; + int ret, len; + int j; + + len = sizeof(struct hclge_mac_vlan_idx_rd_mc) * HCLGE_DBG_MAC_TBL_MAX; + mc_mac_tbl = kzalloc(len, GFP_KERNEL); + if (!mc_mac_tbl) { + dev_err(&hdev->pdev->dev, "mc_mac_tbl alloc memory failed\n"); + return; + } + + memset(printf_buf, 0, HCLGE_DBG_BUF_LEN); + dev_info(&hdev->pdev->dev, "Unicast tab:\n"); + strncat(printf_buf, "|index |mac_addr drivers/net/ethernet/hisilicon/hns3/|vlan_id drivers/net/ethernet/hisilicon/hns3/|VMDq1 |", + HCLGE_DBG_BUF_LEN - 1); + strncat(printf_buf, "U_M drivers/net/ethernet/hisilicon/hns3/|mac_en |in_port |E_type |E_Port\n", + HCLGE_DBG_BUF_LEN - strlen(printf_buf) - 1); + + dev_info(&hdev->pdev->dev, "%s", printf_buf); + + mc_tbl_idx = 0; + for (i = 0; i < HCLGE_DBG_MAC_TBL_MAX; i++) { + /* Prevent long-term occupation of the command channel. */ + if ((i % HCLGE_DBG_SCAN_STEP) == 0) + msleep(HCLGE_DBG_PAUSE_TIME); + + hclge_cmd_setup_basic_desc(&desc[0], HCLGE_PPP_MAC_VLAN_IDX_RD, + true); + desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); + hclge_cmd_setup_basic_desc(&desc[1], HCLGE_PPP_MAC_VLAN_IDX_RD, + true); + desc[1].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); + hclge_cmd_setup_basic_desc(&desc[2], HCLGE_PPP_MAC_VLAN_IDX_RD, + true); + + mac_rd_cmd = (struct hclge_mac_vlan_idx_rd_cmd *)desc[0].data; + + mac_rd_cmd->index = cpu_to_le32(i); + ret = hclge_cmd_send(&hdev->hw, desc, 3); + if (ret) { + dev_err(&hdev->pdev->dev, + "call hclge_cmd_send fail, ret = %d\n", ret); + kfree(mc_mac_tbl); + return; + } + + if (mac_rd_cmd->resp_code) + continue; + + if (mac_rd_cmd->entry_type == HCLGE_DBG_MAC_MC_TBL) { + mc_mac_tbl[mc_tbl_idx].index = i; + memcpy(mc_mac_tbl[mc_tbl_idx].mac_addr, + mac_rd_cmd->mac_addr, ETH_ALEN); + memcpy(mc_mac_tbl[mc_tbl_idx].mg_vf_mb, + desc[1].data, 24); + memcpy(&mc_mac_tbl[mc_tbl_idx].mg_vf_mb[24], + desc[2].data, 8); + mc_tbl_idx++; + + continue; + } + + memset(printf_buf, 0, HCLGE_DBG_BUF_LEN); + snprintf(printf_buf, HCLGE_DBG_BUF_LEN, + "|%04u |%02x:%02x:%02x:%02x:%02x:%02x |", + i, mac_rd_cmd->mac_addr[0], mac_rd_cmd->mac_addr[1], + mac_rd_cmd->mac_addr[2], mac_rd_cmd->mac_addr[3], + mac_rd_cmd->mac_addr[4], mac_rd_cmd->mac_addr[5]); + + snprintf(printf_buf + strlen(printf_buf), + HCLGE_DBG_BUF_LEN - strlen(printf_buf), + "%04u |%u |%u |%u |%u |", + le16_to_cpu(mac_rd_cmd->vlan_tag), + mac_rd_cmd->entry_type & HCLGE_DBG_MAC_TBL_EN_TYPE, + mac_rd_cmd->entry_type & HCLGE_DBG_MAC_TBL_MC_TYPE, + mac_rd_cmd->mc_mac_en & HCLGE_DBG_MAC_TBL_MAC_EN, + le16_to_cpu(mac_rd_cmd->port) & + HCLGE_DBG_MAC_TBL_IN_PORT); + snprintf(printf_buf + strlen(printf_buf), + HCLGE_DBG_BUF_LEN - strlen(printf_buf), + "%lu |%04x\n", + le16_to_cpu(mac_rd_cmd->egress_port) & + HCLGE_DBG_MAC_TBL_E_PORT_B, + le16_to_cpu(mac_rd_cmd->egress_port) & + HCLGE_DBG_MAC_TBL_E_PORT); + + dev_info(&hdev->pdev->dev, "%s", printf_buf); + } + + if (mc_tbl_idx > 0) { + dev_info(&hdev->pdev->dev, + "Multicast tab: entry number = %u\n", mc_tbl_idx); + memset(printf_buf, 0, HCLGE_DBG_BUF_LEN); + strncat(printf_buf, "|index |mac_addr |UM_MC_RDATA\n", + HCLGE_DBG_BUF_LEN - 1); + dev_info(&hdev->pdev->dev, "%s", printf_buf); + } + + for (i = 0; i < mc_tbl_idx; i++) { + memset(printf_buf, 0, HCLGE_DBG_BUF_LEN); + snprintf(printf_buf, HCLGE_DBG_BUF_LEN, + "|%04u |%02x:%02x:%02x:%02x:%02x:%02x |", + mc_mac_tbl[i].index, mc_mac_tbl[i].mac_addr[0], + mc_mac_tbl[i].mac_addr[1], mc_mac_tbl[i].mac_addr[2], + mc_mac_tbl[i].mac_addr[3], mc_mac_tbl[i].mac_addr[4], + mc_mac_tbl[i].mac_addr[5]); + + for (j = 31; j >= 3; j -= 4) + snprintf(printf_buf + strlen(printf_buf), + HCLGE_DBG_BUF_LEN - strlen(printf_buf), + "%02x%02x%02x%02x:", mc_mac_tbl[i].mg_vf_mb[j], + mc_mac_tbl[i].mg_vf_mb[j - 1], + mc_mac_tbl[i].mg_vf_mb[j - 2], + mc_mac_tbl[i].mg_vf_mb[j - 3]); + + printf_buf[strlen(printf_buf) - 1] = '\n'; + dev_info(&hdev->pdev->dev, "%s", printf_buf); + } + + kfree(mc_mac_tbl); +} + static void hclge_dbg_dump_mng_table(struct hclge_dev *hdev) { struct hclge_mac_ethertype_idx_rd_cmd *req0; @@ -1343,6 +1471,8 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) hclge_dbg_dump_qos_pri_map(hdev); } else if (strncmp(cmd_buf, "dump qos buf cfg", 16) == 0) { hclge_dbg_dump_qos_buf_cfg(hdev); + } else if (strncmp(cmd_buf, "dump mac tbl", 12) == 0) { + hclge_dbg_dump_mac_table(hdev); } else if (strncmp(cmd_buf, "dump mng tbl", 12) == 0) { hclge_dbg_dump_mng_table(hdev); } else if (strncmp(cmd_buf, DUMP_REG, strlen(DUMP_REG)) == 0) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h index 390796a..9062508 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.h @@ -10,6 +10,14 @@
#define HCLGE_DBG_BUF_LEN 256 #define HCLGE_DBG_MNG_TBL_MAX 64 +#define HCLGE_DBG_MAC_TBL_MAX 4223 +#define HCLGE_DBG_MAC_MC_TBL 2 +#define HCLGE_DBG_MAC_TBL_EN_TYPE 0x01 +#define HCLGE_DBG_MAC_TBL_MC_TYPE 0x02 +#define HCLGE_DBG_MAC_TBL_MAC_EN 0x01 +#define HCLGE_DBG_MAC_TBL_IN_PORT 0x07 +#define HCLGE_DBG_MAC_TBL_E_PORT 0x3FF +#define HCLGE_DBG_MAC_TBL_E_PORT_B BIT(11)
#define HCLGE_DBG_MNG_VLAN_MASK_B BIT(0) #define HCLGE_DBG_MNG_MAC_MASK_B BIT(1) @@ -36,6 +44,9 @@
#define HCLGE_DBG_DFX_SSU_2_OFFSET 12
+#define HCLGE_DBG_SCAN_STEP 100 +#define HCLGE_DBG_PAUSE_TIME 50 + #pragma pack(1)
struct hclge_qos_pri_map_cmd { @@ -73,6 +84,12 @@ struct hclge_dbg_reg_common_msg { enum hclge_opcode_type cmd; };
+struct hclge_mac_vlan_idx_rd_mc { + u32 index; + u8 mac_addr[ETH_ALEN]; + u8 mg_vf_mb[32]; +}; + #define HCLGE_DBG_MAX_DFX_MSG_LEN 60 struct hclge_dbg_dfx_message { int flag;
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
hclge_reset() is a little bloated, and the process of PF FLR will be separated from the reset task later. So this patch splits hclge_reset() into hclge_reset_prepare() and hclge_reset_rebuild(), then FLR can also reuse these two functions.
BTW, since hclge_clear_reset_cause() and hclge_reset_prepare_up() will not affect the device, so in hclge_reset_rebuild(), these function are called without rtnl_lock.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 65 ++++++++++++---------- 1 file changed, 36 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 814669d..48517cd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3740,56 +3740,51 @@ static int hclge_reset_stack(struct hclge_dev *hdev) return hclge_notify_client(hdev, HNAE3_INIT_CLIENT); }
-static void hclge_reset(struct hclge_dev *hdev) +static int hclge_reset_prepare(struct hclge_dev *hdev) { - struct hnae3_handle *handle = &hdev->vport[0].nic; - struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); - enum hnae3_reset_type reset_level; int ret;
hdev->rst_stats.reset_cnt++; /* perform reset of the stack & ae device for a client */ ret = hclge_notify_roce_client(hdev, HNAE3_DOWN_CLIENT); if (ret) - goto err_reset; + return ret;
ret = hclge_reset_prepare_down(hdev); if (ret) - goto err_reset; + return ret;
rtnl_lock(); ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); - if (ret) - goto err_reset_lock; - rtnl_unlock(); - - ret = hclge_reset_prepare_wait(hdev); if (ret) - goto err_reset; + return ret;
- if (hclge_reset_wait(hdev)) - goto err_reset; + return hclge_reset_prepare_wait(hdev); +}
- hdev->rst_stats.hw_reset_done_cnt++; +static int hclge_reset_rebuild(struct hclge_dev *hdev) +{ + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); + struct hnae3_handle *handle = &hdev->vport[0].nic; + enum hnae3_reset_type reset_level; + int ret;
ret = hclge_notify_roce_client(hdev, HNAE3_UNINIT_CLIENT); if (ret) - goto err_reset; + return ret;
rtnl_lock(); - ret = hclge_reset_stack(hdev); + rtnl_unlock(); if (ret) - goto err_reset_lock; + return ret;
hclge_clear_reset_cause(hdev);
ret = hclge_reset_prepare_up(hdev); if (ret) - goto err_reset_lock; - - rtnl_unlock(); + return ret;
ret = hclge_notify_roce_client(hdev, HNAE3_INIT_CLIENT); /* ignore RoCE notify error if it fails HCLGE_RESET_MAX_FAIL_CNT - 1 @@ -3797,19 +3792,17 @@ static void hclge_reset(struct hclge_dev *hdev) */ if (ret && hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1) - goto err_reset; + return ret;
rtnl_lock(); - ret = hclge_notify_client(hdev, HNAE3_UP_CLIENT); - if (ret) - goto err_reset_lock; - rtnl_unlock(); + if (ret) + return ret;
ret = hclge_notify_roce_client(hdev, HNAE3_UP_CLIENT); if (ret) - goto err_reset; + return ret;
hdev->last_reset_time = jiffies; hdev->rst_stats.reset_fail_cnt = 0; @@ -3827,10 +3820,24 @@ static void hclge_reset(struct hclge_dev *hdev) if (handle && handle->ae_algo->ops->reset_done) handle->ae_algo->ops->reset_done(handle, true);
+ return 0; +} + +static void hclge_reset(struct hclge_dev *hdev) +{ + if (hclge_reset_prepare(hdev)) + goto err_reset; + + if (hclge_reset_wait(hdev)) + goto err_reset; + + hdev->rst_stats.hw_reset_done_cnt++; + + if (hclge_reset_rebuild(hdev)) + goto err_reset; + return;
-err_reset_lock: - rtnl_unlock(); err_reset: if (hclge_reset_err_handle(hdev)) hclge_reset_task_schedule(hdev);
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
hclgevf_reset() is a little bloated, and the process of VF FLR will be separated from the reset task later. So this patch splits hclgevf_reset() into hclgevf_reset_prepare() and hclge_reset_rebuild(), then FLR can also reuse these two functions. Also moves HNAE3_UP_CLIENT into hclgevf_reset_stack().
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 60 +++++++++++++--------- 1 file changed, 36 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index ea41414..0d031a7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1718,7 +1718,8 @@ static int hclgevf_reset_stack(struct hclgevf_dev *hdev) /* clear handshake status with IMP */ hclgevf_reset_handshake(hdev, false);
- return 0; + /* bring up the nic to enable TX/RX again */ + return hclgevf_notify_client(hdev, HNAE3_UP_CLIENT); }
static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev) @@ -1797,21 +1798,48 @@ static void hclgevf_reset_err_handle(struct hclgevf_dev *hdev) } }
-static int hclgevf_reset(struct hclgevf_dev *hdev) +static int hclgevf_reset_prepare(struct hclgevf_dev *hdev) { int ret;
hdev->rst_stats.rst_cnt++; - rtnl_lock();
+ rtnl_lock(); /* bring down the nic to stop any ongoing TX/RX */ ret = hclgevf_notify_client(hdev, HNAE3_DOWN_CLIENT); + rtnl_unlock(); if (ret) - goto err_reset_lock; + return ret; + + return hclgevf_reset_prepare_wait(hdev); +} + +static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) +{ + int ret;
+ rtnl_lock(); + /* now, re-initialize the nic client and ae device */ + ret = hclgevf_reset_stack(hdev); rtnl_unlock(); + if (ret) { + dev_err(&hdev->pdev->dev, + "fail to reset VF stack, ret=%d\n", ret); + return ret; + } + + hdev->last_reset_time = jiffies; + hdev->rst_stats.rst_done_cnt++; + hdev->rst_stats.rst_fail_cnt = 0;
- ret = hclgevf_reset_prepare_wait(hdev); + return 0; +} + +static int hclgevf_reset(struct hclgevf_dev *hdev) +{ + int ret; + + ret = hclgevf_reset_prepare(hdev); if (ret) goto err_reset;
@@ -1829,28 +1857,12 @@ static int hclgevf_reset(struct hclgevf_dev *hdev)
hdev->rst_stats.hw_rst_done_cnt++;
- rtnl_lock(); - - /* now, re-initialize the nic client and ae device */ - ret = hclgevf_reset_stack(hdev); - if (ret) { - dev_err(&hdev->pdev->dev, "failed to reset VF stack\n"); - goto err_reset_lock; - } - - /* bring up the nic to enable TX/RX again */ - ret = hclgevf_notify_client(hdev, HNAE3_UP_CLIENT); + ret = hclgevf_reset_rebuild(hdev); if (ret) - goto err_reset_lock; - - rtnl_unlock(); - - hdev->rst_stats.rst_done_cnt++; - hdev->rst_stats.rst_fail_cnt = 0; + goto err_reset;
return ret; -err_reset_lock: - rtnl_unlock(); + err_reset: hclgevf_reset_err_handle(hdev);
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, the actual work of PF FLR is handled in the reset task, which is asynchronous. So in some case, if the preparing and rebuilding are not done, then the PF FLR will trigger some problems, for example, makes hardware go into chaos.
So this patch separates the process of PF FLR from reset task, and adds a semaphore to serialize this reset and others.
When FLR's preparing fails, if there has other higher level reset pending or failing times less than the HCLGE_FLR_RETRY_CNT, this preparing should be retried, otherwise PF and its VF may get into wrong state.
BTW, while the hardware reports misc interrupt during pcie_flr(), the driver can not receive this interrupt anymore, so disable it when hclge_flr_prepare() return, and re-enable it when enter hclge_flr_done().
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 85 +++++++++++----------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 + 2 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 48517cd..d0c9705 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3289,8 +3289,6 @@ static int hclge_reset_wait(struct hclge_dev *hdev) reg = HCLGE_FUN_RST_ING; reg_bit = HCLGE_FUN_RST_ING_B; break; - case HNAE3_FLR_RESET: - break; default: dev_err(&hdev->pdev->dev, "Wait for unsupported reset type: %d\n", @@ -3298,20 +3296,6 @@ static int hclge_reset_wait(struct hclge_dev *hdev) return -EINVAL; }
- if (hdev->reset_type == HNAE3_FLR_RESET) { - while (!test_bit(HNAE3_FLR_DONE, &hdev->flr_state) && - cnt++ < HCLGE_RESET_WAIT_CNT) - msleep(HCLGE_RESET_WATI_MS); - - if (!test_bit(HNAE3_FLR_DONE, &hdev->flr_state)) { - dev_err(&hdev->pdev->dev, - "flr wait timeout: %u\n", cnt); - return -EBUSY; - } - - return 0; - } - do { msleep(HCLGE_RESET_WATI_MS); val = hclge_read_dev(&hdev->hw, reg); @@ -3470,12 +3454,6 @@ static void hclge_do_reset(struct hclge_dev *hdev) set_bit(HNAE3_FUNC_RESET, &hdev->reset_pending); hclge_reset_task_schedule(hdev); break; - case HNAE3_FLR_RESET: - dev_info(&pdev->dev, "FLR requested\n"); - /* schedule again to check later */ - set_bit(HNAE3_FLR_RESET, &hdev->reset_pending); - hclge_reset_task_schedule(hdev); - break; default: dev_warn(&pdev->dev, "Unsupported reset type: %d\n", hdev->reset_type); @@ -3609,10 +3587,6 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev) ret = hclge_func_reset_sync_vf(hdev); if (ret) return ret; - - set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); - set_bit(HNAE3_FLR_DOWN, &hdev->flr_state); - hdev->rst_stats.flr_rst_cnt++; break; case HNAE3_IMP_RESET: if (handle && handle->ae_algo->ops->handle_imp_error) @@ -4009,12 +3983,13 @@ static void hclge_reset_service_task(struct hclge_dev *hdev) return; }
- if (test_and_set_bit(HCLGE_STATE_RST_HANDLING, &hdev->state)) - return; + down(&hdev->reset_sem); + set_bit(HCLGE_STATE_RST_HANDLING, &hdev->state);
hclge_reset_subtask(hdev);
clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state); + up(&hdev->reset_sem); }
static void hclge_update_vport_alive(struct hclge_dev *hdev) @@ -9947,30 +9922,53 @@ static void hclge_state_uninit(struct hclge_dev *hdev)
static void hclge_flr_prepare(struct hnae3_ae_dev *ae_dev) { -#define HCLGE_FLR_WAIT_MS 100 -#define HCLGE_FLR_WAIT_CNT 50 - struct hclge_dev *hdev = ae_dev->priv; - int cnt = 0; +#define HCLGE_FLR_RETRY_WAIT_MS 500 +#define HCLGE_FLR_RETRY_CNT 5
- clear_bit(HNAE3_FLR_DOWN, &hdev->flr_state); - clear_bit(HNAE3_FLR_DONE, &hdev->flr_state); - set_bit(HNAE3_FLR_RESET, &hdev->default_reset_request); - hclge_reset_event(hdev->pdev, NULL); + struct hclge_dev *hdev = ae_dev->priv; + int retry_cnt = 0; + int ret;
- while (!test_bit(HNAE3_FLR_DOWN, &hdev->flr_state) && - cnt++ < HCLGE_FLR_WAIT_CNT) - msleep(HCLGE_FLR_WAIT_MS); +retry: + down(&hdev->reset_sem); + set_bit(HCLGE_STATE_RST_HANDLING, &hdev->state); + hdev->reset_type = HNAE3_FLR_RESET; + ret = hclge_reset_prepare(hdev); + if (ret) { + dev_err(&hdev->pdev->dev, "fail to prepare FLR, ret=%d\n", + ret); + if (hdev->reset_pending || + retry_cnt++ < HCLGE_FLR_RETRY_CNT) { + dev_err(&hdev->pdev->dev, + "reset_pending:0x%lx, retry_cnt:%d\n", + hdev->reset_pending, retry_cnt); + clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state); + up(&hdev->reset_sem); + msleep(HCLGE_FLR_RETRY_WAIT_MS); + goto retry; + } + }
- if (!test_bit(HNAE3_FLR_DOWN, &hdev->flr_state)) - dev_err(&hdev->pdev->dev, - "flr wait down timeout: %d\n", cnt); + /* disable misc vector before FLR done */ + hclge_enable_vector(&hdev->misc_vector, false); + set_bit(HCLGE_STATE_CMD_DISABLE, &hdev->state); + hdev->rst_stats.flr_rst_cnt++; }
static void hclge_flr_done(struct hnae3_ae_dev *ae_dev) { struct hclge_dev *hdev = ae_dev->priv; + int ret; + + hclge_enable_vector(&hdev->misc_vector, true);
- set_bit(HNAE3_FLR_DONE, &hdev->flr_state); + ret = hclge_reset_rebuild(hdev); + if (ret) + dev_err(&hdev->pdev->dev, "fail to rebuild, ret=%d\n", ret); + + hdev->reset_type = HNAE3_NONE_RESET; + clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state); + up(&hdev->reset_sem); }
static void hclge_clear_resetting_state(struct hclge_dev *hdev) @@ -10013,6 +10011,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev)
mutex_init(&hdev->vport_lock); spin_lock_init(&hdev->fd_rule_lock); + sema_init(&hdev->reset_sem, 1);
ret = hclge_pci_init(hdev); if (ret) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index a82c6fc..b64f6c9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -730,6 +730,7 @@ struct hclge_dev { unsigned long reset_request; /* reset has been requested */ unsigned long reset_pending; /* client rst is pending to be served */ struct hclge_rst_stats rst_stats; + struct semaphore reset_sem; /* protect reset process */ u32 reset_fail_cnt; u32 fw_version; u16 num_vmdq_vport; /* Num vmdq vport this PF has set up */
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
When the load of firmware is high, its reset task may takes more time(which will be as long as 35 seconds). So this patch modifies HCLGE_RESET_WAIT_CNT to match the firmware's.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index d0c9705..4762939 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3272,7 +3272,8 @@ static int hclge_notify_roce_client(struct hclge_dev *hdev, static int hclge_reset_wait(struct hclge_dev *hdev) { #define HCLGE_RESET_WATI_MS 100 -#define HCLGE_RESET_WAIT_CNT 300 +#define HCLGE_RESET_WAIT_CNT 350 + u32 val, reg, reg_bit; u32 cnt = 0;
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
When synchronizes with VFs fail before PF function reset, PF driver should go on its function reset, otherwise it can not run normally anymore. So, hclge_func_reset_sync_vf() should not affect the processing of PF reset, this patch modifies its return type to void.
Also, synchronizes some codes from kernel-dev branch.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Jian Shen shenjian15@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 33 ++++++++-------------- 1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 4762939..4168567 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -37,7 +37,8 @@
#define HCLGE_RESET_MAX_FAIL_CNT 5 #define HCLGE_RESET_SYNC_TIME 100 -#define HCLGE_RESET_SYNC_CNT 300 +#define HCLGE_PF_RESET_SYNC_TIME 20 +#define HCLGE_PF_RESET_SYNC_CNT 1500
#define HCLGE_LINK_STATUS_MS 10
@@ -3373,7 +3374,7 @@ static void hclge_mailbox_service_task(struct hclge_dev *hdev) clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state); }
-static int hclge_func_reset_sync_vf(struct hclge_dev *hdev) +static void hclge_func_reset_sync_vf(struct hclge_dev *hdev) { struct hclge_pf_rst_sync_cmd *req; struct hclge_desc desc; @@ -3393,21 +3394,19 @@ static int hclge_func_reset_sync_vf(struct hclge_dev *hdev) */ if (ret == -EOPNOTSUPP) { msleep(HCLGE_RESET_SYNC_TIME); - return 0; + return; } else if (ret) { dev_err(&hdev->pdev->dev, "sync with VF fail %d!\n", ret); - return ret; + return; } else if (req->all_vf_ready) { - return 0; + return; } - msleep(HCLGE_RESET_SYNC_TIME); - cnt++; + msleep(HCLGE_PF_RESET_SYNC_TIME); hclge_cmd_reuse_desc(&desc, true); - } while (cnt < HCLGE_RESET_SYNC_CNT); + } while (cnt++ < HCLGE_PF_RESET_SYNC_CNT);
- dev_err(&hdev->pdev->dev, "sync with VF timeout!\n"); - return -ETIME; + dev_warn(&hdev->pdev->dev, "sync with VF timeout!\n"); }
int hclge_func_reset_cmd(struct hclge_dev *hdev, int func_id) @@ -3559,12 +3558,7 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev)
switch (hdev->reset_type) { case HNAE3_FUNC_RESET: - /* to confirm whether all running VF is ready - * before request PF reset - */ - ret = hclge_func_reset_sync_vf(hdev); - if (ret) - return ret; + hclge_func_reset_sync_vf(hdev);
ret = hclge_func_reset_cmd(hdev, 0); if (ret) { @@ -3582,12 +3576,7 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev) hdev->rst_stats.pf_rst_cnt++; break; case HNAE3_FLR_RESET: - /* to confirm whether all running VF is ready - * before request PF reset - */ - ret = hclge_func_reset_sync_vf(hdev); - if (ret) - return ret; + hclge_func_reset_sync_vf(hdev); break; case HNAE3_IMP_RESET: if (handle && handle->ae_algo->ops->handle_imp_error)
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, the actual work of VF FLR is handled in the reset task, which is asynchronous. So in some case, if the preparing and rebuilding are not done, then the VF FLR will trigger some problems, for example, makes hardware go into chaos.
So this patch separates the process of VF FLR from reset task, and adds a semaphore to serialize this reset and others.
When FLR's preparing fails, if there has other higher level reset pending or failing times less than the HCLGE_FLR_RETRY_CNT, this preparing should be retried, otherwise it will get into a wrong state.
BTW, while the hardware reports misc interrupt during pcie_flr(), the driver can not receive this interrupt anymore, so disable it when hclgevf_flr_prepare() return, and re-enable it when enter hclgevf_flr_done().
Avoid declaring internal function hclgevf_enable_vector(), this patch also moves its definition forward, and removes unused enum hnae3_flr_state.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Jian Shen shenjian15@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 5 - .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 120 ++++++++++----------- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + 3 files changed, 59 insertions(+), 67 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index c7ac3f8..001515c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -164,11 +164,6 @@ enum hnae3_reset_type { HNAE3_MAX_RESET, };
-enum hnae3_flr_state { - HNAE3_FLR_DOWN, - HNAE3_FLR_DONE, -}; - enum hnae3_port_base_vlan_state { HNAE3_PORT_BASE_VLAN_DISABLE, HNAE3_PORT_BASE_VLAN_ENABLE, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 0d031a7..cacb08f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1606,32 +1606,6 @@ static int hclgevf_notify_client(struct hclgevf_dev *hdev, return ret; }
-static void hclgevf_flr_done(struct hnae3_ae_dev *ae_dev) -{ - struct hclgevf_dev *hdev = ae_dev->priv; - - set_bit(HNAE3_FLR_DONE, &hdev->flr_state); -} - -static int hclgevf_flr_poll_timeout(struct hclgevf_dev *hdev, - unsigned long delay_us, - unsigned long wait_cnt) -{ - unsigned long cnt = 0; - - while (!test_bit(HNAE3_FLR_DONE, &hdev->flr_state) && - cnt++ < wait_cnt) - usleep_range(delay_us, delay_us * 2); - - if (!test_bit(HNAE3_FLR_DONE, &hdev->flr_state)) { - dev_err(&hdev->pdev->dev, - "flr wait timeout\n"); - return -ETIMEDOUT; - } - - return 0; -} - static int hclgevf_reset_wait(struct hclgevf_dev *hdev) { #define HCLGEVF_RESET_WAIT_US 20000 @@ -1646,11 +1620,7 @@ static int hclgevf_reset_wait(struct hclgevf_dev *hdev) val = hclgevf_read_dev(&hdev->hw, HCLGEVF_RST_ING); dev_info(&hdev->pdev->dev, "checking vf resetting status: %x\n", val);
- if (hdev->reset_type == HNAE3_FLR_RESET) - return hclgevf_flr_poll_timeout(hdev, - HCLGEVF_RESET_WAIT_US, - HCLGEVF_RESET_WAIT_CNT); - else if (hdev->reset_type == HNAE3_VF_RESET) + if (hdev->reset_type == HNAE3_VF_RESET) ret = readl_poll_timeout(hdev->hw.io_base + HCLGEVF_VF_RST_ING, val, !(val & HCLGEVF_VF_RST_ING_BIT), @@ -1725,21 +1695,15 @@ static int hclgevf_reset_stack(struct hclgevf_dev *hdev) static int hclgevf_reset_prepare_wait(struct hclgevf_dev *hdev) { #define HCLGEVF_RESET_SYNC_TIME 100 - struct hclge_vf_to_pf_msg send_msg; + int ret = 0;
- hclgevf_build_send_msg(&send_msg, HCLGE_MBX_RESET, 0); - switch (hdev->reset_type) { - case HNAE3_VF_FUNC_RESET: + if (hdev->reset_type == HNAE3_VF_FUNC_RESET) { + struct hclge_vf_to_pf_msg send_msg; + + hclgevf_build_send_msg(&send_msg, HCLGE_MBX_RESET, 0); ret = hclgevf_send_mbx_msg(hdev, &send_msg, true, NULL, 0); hdev->rst_stats.vf_func_rst_cnt++; - break; - case HNAE3_FLR_RESET: - set_bit(HNAE3_FLR_DOWN, &hdev->flr_state); - hdev->rst_stats.flr_rst_cnt++; - break; - default: - break; }
set_bit(HCLGEVF_STATE_CMD_DISABLE, &hdev->state); @@ -1933,25 +1897,60 @@ static void hclgevf_set_def_reset_request(struct hnae3_ae_dev *ae_dev, set_bit(rst_type, &hdev->default_reset_request); }
+static void hclgevf_enable_vector(struct hclgevf_misc_vector *vector, bool en) +{ + writel(en ? 1 : 0, vector->addr); +} + static void hclgevf_flr_prepare(struct hnae3_ae_dev *ae_dev) { -#define HCLGEVF_FLR_WAIT_MS 100 -#define HCLGEVF_FLR_WAIT_CNT 50 +#define HCLGEVF_FLR_RETRY_WAIT_MS 500 +#define HCLGEVF_FLR_RETRY_CNT 5 + struct hclgevf_dev *hdev = ae_dev->priv; - int cnt = 0; + int retry_cnt = 0; + int ret;
- clear_bit(HNAE3_FLR_DOWN, &hdev->flr_state); - clear_bit(HNAE3_FLR_DONE, &hdev->flr_state); - set_bit(HNAE3_FLR_RESET, &hdev->default_reset_request); - hclgevf_reset_event(hdev->pdev, NULL); +retry: + down(&hdev->reset_sem); + set_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state); + hdev->reset_type = HNAE3_FLR_RESET; + ret = hclgevf_reset_prepare(hdev); + if (ret) { + dev_err(&hdev->pdev->dev, "fail to prepare FLR, ret=%d\n", + ret); + if (hdev->reset_pending || + retry_cnt++ < HCLGEVF_FLR_RETRY_CNT) { + dev_err(&hdev->pdev->dev, + "reset_pending:0x%lx, retry_cnt:%d\n", + hdev->reset_pending, retry_cnt); + clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state); + up(&hdev->reset_sem); + msleep(HCLGEVF_FLR_RETRY_WAIT_MS); + goto retry; + } + }
- while (!test_bit(HNAE3_FLR_DOWN, &hdev->flr_state) && - cnt++ < HCLGEVF_FLR_WAIT_CNT) - msleep(HCLGEVF_FLR_WAIT_MS); + /* disable misc vector before FLR done */ + hclgevf_enable_vector(&hdev->misc_vector, false); + hdev->rst_stats.flr_rst_cnt++; +}
- if (!test_bit(HNAE3_FLR_DOWN, &hdev->flr_state)) - dev_err(&hdev->pdev->dev, - "flr wait down timeout: %d\n", cnt); +static void hclgevf_flr_done(struct hnae3_ae_dev *ae_dev) +{ + struct hclgevf_dev *hdev = ae_dev->priv; + int ret; + + hclgevf_enable_vector(&hdev->misc_vector, true); + + ret = hclgevf_reset_rebuild(hdev); + if (ret) + dev_warn(&hdev->pdev->dev, "fail to rebuild, ret=%d\n", + ret); + + hdev->reset_type = HNAE3_NONE_RESET; + clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state); + up(&hdev->reset_sem); }
static u32 hclgevf_get_fw_version(struct hnae3_handle *handle) @@ -2008,8 +2007,8 @@ static void hclgevf_reset_service_task(struct hclgevf_dev *hdev) if (!test_and_clear_bit(HCLGEVF_STATE_RST_SERVICE_SCHED, &hdev->state)) return;
- if (test_and_set_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state)) - return; + down(&hdev->reset_sem); + set_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state);
if (test_and_clear_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state)) { @@ -2070,6 +2069,7 @@ static void hclgevf_reset_service_task(struct hclgevf_dev *hdev) }
clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state); + up(&hdev->reset_sem); }
static void hclgevf_mailbox_service_task(struct hclgevf_dev *hdev) @@ -2217,11 +2217,6 @@ static enum hclgevf_evt_cause hclgevf_check_evt_cause(struct hclgevf_dev *hdev, return HCLGEVF_VECTOR0_EVENT_OTHER; }
-static void hclgevf_enable_vector(struct hclgevf_misc_vector *vector, bool en) -{ - writel(en ? 1 : 0, vector->addr); -} - static irqreturn_t hclgevf_misc_irq_handle(int irq, void *data) { enum hclgevf_evt_cause event_cause; @@ -2498,6 +2493,7 @@ static void hclgevf_state_init(struct hclgevf_dev *hdev) INIT_DELAYED_WORK(&hdev->service_task, hclgevf_service_task);
mutex_init(&hdev->mbx_resp.mbx_mutex); + sema_init(&hdev->reset_sem, 1);
spin_lock_init(&hdev->mac_table.mac_list_lock); INIT_LIST_HEAD(&hdev->mac_table.uc_mac_list); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 2d30c61..0b0f781 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -280,6 +280,7 @@ struct hclgevf_dev { unsigned long reset_state; /* requested, pending */ struct hclgevf_rst_stats rst_stats; u32 reset_attempts; + struct semaphore reset_sem; /* protect reset process */
u32 fw_version; u16 num_tqps; /* num task queue pairs of this PF */
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
hclge_reset_prepare_down() is only used to inform VF that PF is going to do function, then using hclge_func_reset_sync_vf() in hclge_reset_prepare_wait() to query whether VF is ready before asserting PF function reset. To make the code more readable, this patch uses a new function hclge_function_reset_notify_vf to do this job.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 42 ++++++++++------------ 1 file changed, 19 insertions(+), 23 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 4168567..b9f4441 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3520,23 +3520,6 @@ static void hclge_clear_reset_cause(struct hclge_dev *hdev) hclge_enable_vector(&hdev->misc_vector, true); }
-static int hclge_reset_prepare_down(struct hclge_dev *hdev) -{ - int ret = 0; - - switch (hdev->reset_type) { - case HNAE3_FUNC_RESET: - /* fall through */ - case HNAE3_FLR_RESET: - ret = hclge_set_all_vf_rst(hdev, true); - break; - default: - break; - } - - return ret; -} - static void hclge_reset_handshake(struct hclge_dev *hdev, bool enable) { u32 reg_val; @@ -3550,6 +3533,19 @@ static void hclge_reset_handshake(struct hclge_dev *hdev, bool enable) hclge_write_dev(&hdev->hw, HCLGE_NIC_CSQ_DEPTH_REG, reg_val); }
+static int hclge_func_reset_notify_vf(struct hclge_dev *hdev) +{ + int ret; + + ret = hclge_set_all_vf_rst(hdev, true); + if (ret) + return ret; + + hclge_func_reset_sync_vf(hdev); + + return ret; +} + static int hclge_reset_prepare_wait(struct hclge_dev *hdev) { struct hnae3_handle *handle = &hdev->vport[0].nic; @@ -3558,7 +3554,9 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev)
switch (hdev->reset_type) { case HNAE3_FUNC_RESET: - hclge_func_reset_sync_vf(hdev); + ret = hclge_func_reset_notify_vf(hdev); + if (ret) + return ret;
ret = hclge_func_reset_cmd(hdev, 0); if (ret) { @@ -3576,7 +3574,9 @@ static int hclge_reset_prepare_wait(struct hclge_dev *hdev) hdev->rst_stats.pf_rst_cnt++; break; case HNAE3_FLR_RESET: - hclge_func_reset_sync_vf(hdev); + ret = hclge_func_reset_notify_vf(hdev); + if (ret) + return ret; break; case HNAE3_IMP_RESET: if (handle && handle->ae_algo->ops->handle_imp_error) @@ -3714,10 +3714,6 @@ static int hclge_reset_prepare(struct hclge_dev *hdev) if (ret) return ret;
- ret = hclge_reset_prepare_down(hdev); - if (ret) - return ret; - rtnl_lock(); ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); rtnl_unlock();
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
When calling hclge_reset_rebuild(), it means the hardware reset has already been done, so this patch updates hw_reset_done_cnt at the beginning of hclge_reset_rebuild().
Fixes: ab90cbea0164 ("net: hns3: split hclge_reset() into preparing and rebuilding part")
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index b9f4441..46607c8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3730,6 +3730,8 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) enum hnae3_reset_type reset_level; int ret;
+ hdev->rst_stats.hw_reset_done_cnt++; + ret = hclge_notify_roce_client(hdev, HNAE3_UNINIT_CLIENT); if (ret) return ret; @@ -3791,8 +3793,6 @@ static void hclge_reset(struct hclge_dev *hdev) if (hclge_reset_wait(hdev)) goto err_reset;
- hdev->rst_stats.hw_reset_done_cnt++; - if (hclge_reset_rebuild(hdev)) goto err_reset;
From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
We need to update some port info and to config some configurations to HW in a periodical task per second, by setting registers from driver to WH. If reset had fail, HW will not response the CMD and driver will generate a warning print. In this case, the periodical task shouldn't schedule. This patch fixes it.
Fixes: b6345c9bd4f6 ("net: hns3: make hclgevf_service use delayed workqueue")
Signed-off-by: Guojia Liao liaoguojia@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 7 ++++++- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 + drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 6 +++++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + 4 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 46607c8..657642a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2697,7 +2697,8 @@ static void hclge_reset_task_schedule(struct hclge_dev *hdev)
void hclge_task_schedule(struct hclge_dev *hdev, unsigned long delay_time) { - if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state)) + if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) && + !test_bit(HCLGE_STATE_RST_FAIL, &hdev->state)) mod_delayed_work_on(cpumask_first(&hdev->affinity_mask), hclge_wq, &hdev->service_task, delay_time); @@ -3633,6 +3634,8 @@ static bool hclge_reset_err_handle(struct hclge_dev *hdev)
hclge_dbg_dump_rst_info(hdev);
+ set_bit(HCLGE_STATE_RST_FAIL, &hdev->state); + return false; }
@@ -3769,6 +3772,7 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) hdev->last_reset_time = jiffies; hdev->rst_stats.reset_fail_cnt = 0; hdev->rst_stats.reset_done_cnt++; + clear_bit(HCLGE_STATE_RST_FAIL, &hdev->state);
/* if default_reset_request has a higher level reset request, * it should be handled as soon as possible. since some errors @@ -9891,6 +9895,7 @@ static void hclge_state_init(struct hclge_dev *hdev) set_bit(HCLGE_STATE_DOWN, &hdev->state); clear_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state); clear_bit(HCLGE_STATE_RST_HANDLING, &hdev->state); + clear_bit(HCLGE_STATE_RST_FAIL, &hdev->state); clear_bit(HCLGE_STATE_MBX_SERVICE_SCHED, &hdev->state); clear_bit(HCLGE_STATE_MBX_HANDLING, &hdev->state); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index b64f6c9..5af7da7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -222,6 +222,7 @@ enum HCLGE_DEV_STATE { HCLGE_STATE_CMD_DISABLE, HCLGE_STATE_LINK_UPDATING, HCLGE_STATE_PROMISC_CHANGED, + HCLGE_STATE_RST_FAIL, HCLGE_STATE_MAX };
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index cacb08f..3b063bd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1758,6 +1758,7 @@ static void hclgevf_reset_err_handle(struct hclgevf_dev *hdev) set_bit(HCLGEVF_RESET_PENDING, &hdev->reset_state); hclgevf_reset_task_schedule(hdev); } else { + set_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state); hclgevf_dump_rst_info(hdev); } } @@ -1795,6 +1796,7 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) hdev->last_reset_time = jiffies; hdev->rst_stats.rst_done_cnt++; hdev->rst_stats.rst_fail_cnt = 0; + clear_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state);
return 0; } @@ -1994,7 +1996,8 @@ void hclgevf_mbx_task_schedule(struct hclgevf_dev *hdev) static void hclgevf_task_schedule(struct hclgevf_dev *hdev, unsigned long delay) { - if (!test_bit(HCLGEVF_STATE_REMOVING, &hdev->state)) + if (!test_bit(HCLGEVF_STATE_REMOVING, &hdev->state) && + !test_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state)) mod_delayed_work(hclgevf_wq, &hdev->service_task, delay); }
@@ -2489,6 +2492,7 @@ static void hclgevf_state_init(struct hclgevf_dev *hdev) { clear_bit(HCLGEVF_STATE_MBX_SERVICE_SCHED, &hdev->state); clear_bit(HCLGEVF_STATE_MBX_HANDLING, &hdev->state); + clear_bit(HCLGEVF_STATE_RST_FAIL, &hdev->state);
INIT_DELAYED_WORK(&hdev->service_task, hclgevf_service_task);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 0b0f781..be0cd41 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -151,6 +151,7 @@ enum hclgevf_states { HCLGEVF_STATE_CMD_DISABLE, HCLGEVF_STATE_LINK_UPDATING, HCLGEVF_STATE_PROMISC_CHANGED, + HCLGEVF_STATE_RST_FAIL, };
#define HCLGEVF_MPF_ENBALE 1
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
This patch deletes some unnecessary blank lines, and deletes one space to make code align to preceding line.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 -- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 9bc30f7..2dfeada 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -501,7 +501,7 @@ static void hclge_dbg_dump_tm(struct hclge_dev *hdev)
nq_to_qs_map = (struct hclge_nq_to_qs_link_cmd *)desc.data; dev_info(&hdev->pdev->dev, "NQ_TO_QS nq_id: %u\n", - le16_to_cpu(nq_to_qs_map->nq_id)); + le16_to_cpu(nq_to_qs_map->nq_id)); dev_info(&hdev->pdev->dev, "NQ_TO_QS qset_id: 0x%x\n", le16_to_cpu(nq_to_qs_map->qset_id));
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 657642a..a93ee10 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2765,7 +2765,6 @@ static void hclge_update_link_status(struct hclge_dev *hdev) return;
state = hclge_get_mac_phy_link(hdev); - if (state != hdev->hw.mac.link) { for (i = 0; i < hdev->num_vmdq_vport + 1; i++) { handle = &hdev->vport[i].nic; @@ -3926,7 +3925,6 @@ static void hclge_reset_subtask(struct hclge_dev *hdev) */ hdev->last_reset_time = jiffies; hdev->reset_type = hclge_get_reset_level(ae_dev, &hdev->reset_pending); - if (hdev->reset_type != HNAE3_NONE_RESET) hclge_reset(hdev);
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 31b174d..79cc4e8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -83,7 +83,6 @@ static int hclge_gen_resp_to_vf(struct hclge_vport *vport, status, vf_to_pf_req->mbx_src_vfid, vf_to_pf_req->msg.code, vf_to_pf_req->msg.subcode);
- return status; }
@@ -111,7 +110,6 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len, "PF failed(=%d) to send mailbox message(vfid:%u, opcode:%u) to VF\n", status, dest_vfid, mbx_opcode);
- return status; }
From: Yonglong Liu liuyonglong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
After rename the net devices, can not grep the irq numbers by the net device name, because the driver request the irq resources only when the vector resource changed, and rename operation did not change the vector resources, so the irq name keeps the previous net device name.
This patch modifies the tqp irq names as "pci driver name"-"pci name" -"TxRx"-"index".
Fixes: ec7fb686187f ("net: hns3: optimize vector handle")
Signed-off-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 6cde7a6..35e8c32 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -134,17 +134,20 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv)
if (tqp_vectors->tx_group.ring && tqp_vectors->rx_group.ring) { snprintf(tqp_vectors->name, HNAE3_INT_NAME_LEN, - "%s-%s-%d", priv->netdev->name, "TxRx", - txrx_int_idx++); + "%s-%s-%s-%d", hns3_driver_name, + pci_name(priv->ae_handle->pdev), + "TxRx", txrx_int_idx++); txrx_int_idx++; } else if (tqp_vectors->rx_group.ring) { snprintf(tqp_vectors->name, HNAE3_INT_NAME_LEN, - "%s-%s-%d", priv->netdev->name, "Rx", - rx_int_idx++); + "%s-%s-%s-%d", hns3_driver_name, + pci_name(priv->ae_handle->pdev), + "Rx", rx_int_idx++); } else if (tqp_vectors->tx_group.ring) { snprintf(tqp_vectors->name, HNAE3_INT_NAME_LEN, - "%s-%s-%d", priv->netdev->name, "Tx", - tx_int_idx++); + "%s-%s-%s-%d", hns3_driver_name, + pci_name(priv->ae_handle->pdev), + "Tx", tx_int_idx++); } else { /* Skip this unused q_vector */ continue;
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
This patch replaces pr_info with another printing function dev_info to add device information printing.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index a93ee10..433e31b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -10145,7 +10145,8 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) hclge_state_init(hdev); hdev->last_reset_time = jiffies;
- pr_info("%s driver initialization finished.\n", HCLGE_DRIVER_NAME); + dev_info(&hdev->pdev->dev, "%s driver initialization finished.\n", + HCLGE_DRIVER_NAME);
hclge_task_schedule(hdev, round_jiffies_relative(HZ));
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
The char length of line is less than 80, no newline is required.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 433e31b..4edec73 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -10135,8 +10135,7 @@ static int hclge_init_ae_dev(struct hnae3_ae_dev *ae_dev) reset_level = hclge_get_reset_level(ae_dev, &ae_dev->hw_err_reset_req); hclge_set_def_reset_request(ae_dev, reset_level); - mod_timer(&hdev->reset_timer, - jiffies + HCLGE_RESET_INTERVAL); + mod_timer(&hdev->reset_timer, jiffies + HCLGE_RESET_INTERVAL); }
/* Enable MISC vector(vector0) */
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch modifies one code logic in hclge_init_kdump_kernel_config() function to reduce the indentation level, and it does not affect the original process logic of the code.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 4edec73..3e17d11 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1365,15 +1365,16 @@ static void hclge_init_kdump_kernel_config(struct hclge_dev *hdev) #define HCLGE_MIN_TX_DESC 64 #define HCLGE_MIN_RX_DESC 64
- if (is_kdump_kernel()) { - dev_info(&hdev->pdev->dev, - "Running kdump kernel. Using minimal resources\n"); + if (!is_kdump_kernel()) + return;
- /* minimal queue pairs equals to the number of vports */ - hdev->num_tqps = hdev->num_vmdq_vport + hdev->num_req_vfs + 1; - hdev->num_tx_desc = HCLGE_MIN_TX_DESC; - hdev->num_rx_desc = HCLGE_MIN_RX_DESC; - } + dev_info(&hdev->pdev->dev, + "Running kdump kernel. Using minimal resources\n"); + + /* minimal queue pairs equals to the number of vports */ + hdev->num_tqps = hdev->num_vmdq_vport + hdev->num_req_vfs + 1; + hdev->num_tx_desc = HCLGE_MIN_TX_DESC; + hdev->num_rx_desc = HCLGE_MIN_RX_DESC; }
static int hclge_configure(struct hclge_dev *hdev)
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
This patch deletes redundant initialization of variable ret, and modify the varibale name "value" to "switch_param" for clearer meaning.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3e17d11..72b47c0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6783,9 +6783,7 @@ static int hclge_set_loopback(struct hnae3_handle *handle, struct phy_device *phydev = handle->netdev->phydev; struct hnae3_knic_private_info *kinfo; struct hclge_dev *hdev = vport->back; - int ret = 0; - u8 value; - int i; + int i, ret;
/* Loopback can be enabled in three places: SSU, MAC, and serdes. By * default, SSU loopback is enabled, so if the SMAC and the DMAC are @@ -6793,8 +6791,9 @@ static int hclge_set_loopback(struct hnae3_handle *handle, * is disabled, packets can reach MAC even if SMAC is the same as DMAC. */ if (hdev->pdev->revision >= 0x21) { - value = en ? 0 : BIT(HCLGE_SWITCH_ALW_LPBK_B); - ret = hclge_config_switch_param(hdev, PF_VPORT_ID, value, + u8 switch_param = en ? 0 : BIT(HCLGE_SWITCH_ALW_LPBK_B); + + ret = hclge_config_switch_param(hdev, PF_VPORT_ID, switch_param, HCLGE_SWITCH_ALW_LPBK_MASK); if (ret) return ret;
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch modifies the logic of two code in function hns3_parse_vlan_tag() to reduce the indentation level. It does not affect the original function of the code.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 35e8c32..35a607b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2858,21 +2858,19 @@ static bool hns3_parse_vlan_tag(struct hns3_enet_ring *ring, switch (hnae3_get_field(l234info, HNS3_RXD_STRP_TAGP_M, HNS3_RXD_STRP_TAGP_S)) { case HNS3_STRP_OUTER_VLAN: - if (handle->port_base_vlan_state == - HNAE3_PORT_BASE_VLAN_DISABLE) { - *vlan_tag = le16_to_cpu(desc->rx.ot_vlan_tag); - return true; - } + if (handle->port_base_vlan_state != + HNAE3_PORT_BASE_VLAN_DISABLE) + return false;
- return false; + *vlan_tag = le16_to_cpu(desc->rx.ot_vlan_tag); + return true; case HNS3_STRP_INNER_VLAN: - if (handle->port_base_vlan_state == - HNAE3_PORT_BASE_VLAN_DISABLE) { - *vlan_tag = le16_to_cpu(desc->rx.vlan_tag); - return true; - } + if (handle->port_base_vlan_state != + HNAE3_PORT_BASE_VLAN_DISABLE) + return false;
- return false; + *vlan_tag = le16_to_cpu(desc->rx.vlan_tag); + return true; case HNS3_STRP_BOTH: if (handle->port_base_vlan_state == HNAE3_PORT_BASE_VLAN_DISABLE)
From: Yonglong Liu liuyonglong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
The misc irq of all the net devices have the same name, so it's hard to find the right misc irq of the net device.
This patch modifies the misc irq names as "hclge/hclgevf"-misc- "pci name".And now the irq name is not related to net device name anymore, so change the HNAE3_INT_NAME_LEN to 32 bytes, and that is enough.
Signed-off-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 3 +-- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h | 2 ++ drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + 5 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 001515c..5f45272 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -578,8 +578,7 @@ struct hnae3_ae_algo { const struct pci_device_id *pdev_id_table; };
-#define HNAE3_INT_NAME_EXT_LEN 32 /* Max extra information length */ -#define HNAE3_INT_NAME_LEN (IFNAMSIZ + HNAE3_INT_NAME_EXT_LEN) +#define HNAE3_INT_NAME_LEN 32 #define HNAE3_ITR_COUNTDOWN_START 100
struct hnae3_tc_info { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h index 92caaec..7c4a739 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h @@ -6,6 +6,7 @@ #include <linux/etherdevice.h> #include <linux/types.h> #include <linux/io.h> +#include "hnae3.h"
#define HCLGE_CMDQ_TX_TIMEOUT 30000 #define HCLGE_DESC_DATA_LEN 6 @@ -63,6 +64,7 @@ enum hclge_cmd_status { struct hclge_misc_vector { u8 __iomem *addr; int vector_irq; + char name[HNAE3_INT_NAME_LEN]; };
struct hclge_cmq { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 72b47c0..3ca0925 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3199,8 +3199,10 @@ static int hclge_misc_irq_init(struct hclge_dev *hdev) hclge_get_misc_vector(hdev);
/* this would be explicitly freed in the end */ + snprintf(hdev->misc_vector.name, HNAE3_INT_NAME_LEN, "%s-misc-%s", + HCLGE_NAME, pci_name(hdev->pdev)); ret = request_irq(hdev->misc_vector.vector_irq, hclge_misc_irq_handle, - 0, "hclge_misc", hdev); + 0, hdev->misc_vector.name, hdev); if (ret) { hclge_free_vector(hdev, 0); dev_err(&hdev->pdev->dev, "request misc irq(%d) fail\n", diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index 3b063bd..fe3f2e7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2587,8 +2587,10 @@ static int hclgevf_misc_irq_init(struct hclgevf_dev *hdev)
hclgevf_get_misc_vector(hdev);
+ snprintf(hdev->misc_vector.name, HNAE3_INT_NAME_LEN, "%s-misc-%s", + HCLGEVF_NAME, pci_name(hdev->pdev)); ret = request_irq(hdev->misc_vector.vector_irq, hclgevf_misc_irq_handle, - 0, "hclgevf_cmd", hdev); + 0, hdev->misc_vector.name, hdev); if (ret) { dev_err(&hdev->pdev->dev, "VF failed to request misc irq(%d)\n", hdev->misc_vector.vector_irq); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index be0cd41..f4ae63e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -226,6 +226,7 @@ struct hclgevf_rss_cfg { struct hclgevf_misc_vector { u8 __iomem *addr; int vector_irq; + char name[HNAE3_INT_NAME_LEN]; };
struct hclgevf_rst_stats {
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch deletes goto and replaces with return in function hclge_set_vf_uc_mac_addr() to optimize code.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index 79cc4e8..d0395a5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -307,15 +307,11 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, * cannot be overridden by the MAC specified by the VM. */ if (!is_zero_ether_addr(vport->vf_info.mac) && - !ether_addr_equal(mac_addr, vport->vf_info.mac)) { - status = -EPERM; - goto out; - } + !ether_addr_equal(mac_addr, vport->vf_info.mac)) + return -EPERM;
- if (!is_valid_ether_addr(mac_addr)) { - status = -EINVAL; - goto out; - } + if (!is_valid_ether_addr(mac_addr)) + return -EINVAL;
if (is_zero_ether_addr(old_addr)) { status = hclge_add_uc_addr_common(vport, mac_addr); @@ -342,8 +338,6 @@ static int hclge_set_vf_uc_mac_addr(struct hclge_vport *vport, mbx_req->msg.subcode); return -EIO; } - -out: return status; }
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch modifies some printing format %d into %u in hns3_set_ringpa() function as those printing data are unsigned type.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 37ce34b..9dcc33e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -981,7 +981,7 @@ static int hns3_set_ringparam(struct net_device *ndev, }
netdev_info(ndev, - "Changing Tx/Rx ring depth from %d/%d to %d/%d\n", + "Changing Tx/Rx ring depth from %u/%u to %u/%u\n", old_tx_desc_num, old_rx_desc_num, new_tx_desc_num, new_rx_desc_num);
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch deletes goto and replace with return in function hns3_set_ringparam(), as the code should return directly if failed.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 9dcc33e..71d3fb6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -976,8 +976,7 @@ static int hns3_set_ringparam(struct net_device *ndev, if (!tmp_rings) { netdev_err(ndev, "backup ring param failed by allocating memory fail\n"); - ret = -ENOMEM; - goto out; + return -ENOMEM; }
netdev_info(ndev, @@ -1006,9 +1005,8 @@ static int hns3_set_ringparam(struct net_device *ndev,
kfree(tmp_rings);
-out: if (if_running) - ndev->netdev_ops->ndo_open(ndev); + ret = ndev->netdev_ops->ndo_open(ndev);
return ret; }
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
As some caller do not want to execute hclge_phy_link_status_wait() in hclge_mac_phy_link_status_wait() function, this patch adds a parameter for hclge_mac_phy_link_status_wait() to decide, and optimize other code in this function.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 3ca0925..dc12141 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6560,25 +6560,21 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret) return -EBUSY; }
-static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en) +static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en, + bool is_phy) { #define HCLGE_LINK_STATUS_DOWN 0 #define HCLGE_LINK_STATUS_UP 1
struct phy_device *phydev = hdev->hw.mac.phydev; int link_ret; - int ret;
- if (en) - link_ret = HCLGE_LINK_STATUS_UP; - else - link_ret = HCLGE_LINK_STATUS_DOWN; + link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN;
- if (phydev) + if (is_phy) hclge_phy_link_status_wait(hdev, phydev, link_ret);
- ret = hclge_mac_link_status_wait(hdev, link_ret); - return ret; + return hclge_mac_link_status_wait(hdev, link_ret); }
static int hclge_set_app_loopback(struct hclge_dev *hdev, bool en) @@ -6692,7 +6688,7 @@ static int hclge_set_serdes_loopback(struct hclge_dev *hdev, bool en,
hclge_cfg_mac_mode(hdev, en);
- ret = hclge_mac_phy_link_status_wait(hdev, en); + ret = hclge_mac_phy_link_status_wait(hdev, en, false); if (ret) dev_err(&hdev->pdev->dev, "serdes loopback config mac mode timeout\n"); @@ -6749,7 +6745,7 @@ static int hclge_set_phy_loopback(struct hclge_dev *hdev,
hclge_cfg_mac_mode(hdev, en);
- ret = hclge_mac_phy_link_status_wait(hdev, en); + ret = hclge_mac_phy_link_status_wait(hdev, en, true); if (ret) dev_err(&hdev->pdev->dev, "phy loopback config mac mode timeout\n");
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch adds error process in hclge_mac_link_status_wait() function, if failed to get mac link status then return result directly.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index dc12141..5bb1979 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6553,8 +6553,11 @@ static int hclge_mac_link_status_wait(struct hclge_dev *hdev, int link_ret)
do { ret = hclge_get_mac_link_status(hdev); - if (ret == link_ret) + if (ret < 0) + return ret; + else if (ret == link_ret) return 0; + msleep(HCLGE_LINK_STATUS_MS); } while (++i < HCLGE_MAC_LINK_STATUS_NUM); return -EBUSY;
From: Yonglong Liu liuyonglong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Sometimes we want to see the actual tc numbers that enabled and want to see the dwrr weight of each tc, so adds these information to debugfs.
Signed-off-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Yunsheng Lin linyunsheng@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 2dfeada..8225da8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -321,8 +321,9 @@ static void hclge_title_idx_print(struct hclge_dev *hdev, bool flag, int index, char *false_buf) { if (flag) - dev_info(&hdev->pdev->dev, "%s(%d): %s\n", title_buf, index, - true_buf); + dev_info(&hdev->pdev->dev, "%s(%d): %s weight: %u\n", + title_buf, index, true_buf, + hdev->tm_info.pg_info[0].tc_dwrr[index]); else dev_info(&hdev->pdev->dev, "%s(%d): %s\n", title_buf, index, false_buf); @@ -350,7 +351,8 @@ static void hclge_dbg_dump_tc(struct hclge_dev *hdev)
ets_weight = (struct hclge_ets_tc_weight_cmd *)desc.data;
- dev_info(&hdev->pdev->dev, "dump tc\n"); + dev_info(&hdev->pdev->dev, "dump tc: %u tc enabled\n", + hdev->tm_info.num_tc); dev_info(&hdev->pdev->dev, "weight_offset: %u\n", ets_weight->weight_offset);
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Previously, VF can not query map relation between ring and vector. This patch adds a new mailbox opcode in PF driver to query map relation between vf ring and vector, and VF can query this map relation by sending mailbox message to PF.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h | 1 + .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 91 ++++++++++++++++++++++ 2 files changed, 92 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h index a4dd3aef..a2af24b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hclge_mbx.h @@ -46,6 +46,7 @@ enum HCLGE_MBX_OPCODE { HCLGE_MBX_PUSH_PROMISC_INFO, /* (PF -> VF) push vf promisc info */ HCLGE_MBX_VF_UNINIT, /* (VF -> PF) vf is unintializing */ HCLGE_MBX_HANDLE_VF_TBL, /* (VF -> PF) store/clear hw table */ + HCLGE_MBX_GET_RING_VECTOR_MAP, /* (VF -> PF) get ring-to-vector map */
HCLGE_MBX_GET_VF_FLR_STATUS = 200, /* (M7 -> PF) get vf flr status */ HCLGE_MBX_PUSH_LINK_STATUS, /* (M7 -> PF) get port link status */ diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index d0395a5..bc86207 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -230,6 +230,89 @@ static int hclge_map_unmap_ring_to_vf_vector(struct hclge_vport *vport, bool en, return ret; }
+static int hclge_query_ring_vector_map(struct hclge_vport *vport, + struct hnae3_ring_chain_node *ring_chain, + struct hclge_desc *desc) +{ + struct hclge_ctrl_vector_chain_cmd *req = + (struct hclge_ctrl_vector_chain_cmd *)desc->data; + struct hclge_dev *hdev = vport->back; + u16 tqp_type_and_id; + int status; + + hclge_cmd_setup_basic_desc(desc, HCLGE_OPC_ADD_RING_TO_VECTOR, true); + + tqp_type_and_id = le16_to_cpu(req->tqp_type_and_id[0]); + hnae3_set_field(tqp_type_and_id, HCLGE_INT_TYPE_M, HCLGE_INT_TYPE_S, + hnae3_get_bit(ring_chain->flag, HNAE3_RING_TYPE_B)); + hnae3_set_field(tqp_type_and_id, HCLGE_TQP_ID_M, HCLGE_TQP_ID_S, + ring_chain->tqp_index); + req->tqp_type_and_id[0] = cpu_to_le16(tqp_type_and_id); + req->vfid = vport->vport_id; + + status = hclge_cmd_send(&hdev->hw, desc, 1); + if (status) + dev_err(&hdev->pdev->dev, + "Get VF ring vector map info fail, status is %d.\n", + status); + + return status; +} + +static int hclge_get_vf_ring_vector_map(struct hclge_vport *vport, + struct hclge_mbx_vf_to_pf_cmd *req, + struct hclge_respond_to_vf_msg *resp) +{ +#define HCLGE_LIMIT_RING_NUM 1 +#define HCLGE_RING_TYPE_OFFSET 0 +#define HCLGE_TQP_INDEX_OFFSET 1 +#define HCLGE_INT_GL_INDEX_OFFSET 2 +#define HCLGE_VECTOR_ID_OFFSET 3 +#define HCLGE_RING_VECTOR_MAP_INFO_LEN 4 + struct hnae3_ring_chain_node ring_chain; + struct hclge_dev *hdev = vport->back; + struct hclge_desc desc; + struct hclge_ctrl_vector_chain_cmd *data = + (struct hclge_ctrl_vector_chain_cmd *)desc.data; + u16 tqp_type_and_id; + u8 int_gl_index; + int ret; + + if (req->msg.param[0].tqp_index >= vport->nic.kinfo.rss_size) { + dev_err(&hdev->pdev->dev, "tqp index(%u) is out of range(0-%u)\n", + req->msg.param[0].tqp_index, + vport->nic.kinfo.rss_size - 1); + return -EINVAL; + } + + req->msg.ring_num = HCLGE_LIMIT_RING_NUM; + + memset(&ring_chain, 0, sizeof(ring_chain)); + ret = hclge_get_ring_chain_from_mbx(req, &ring_chain, vport); + if (ret) + return ret; + + ret = hclge_query_ring_vector_map(vport, &ring_chain, &desc); + if (ret) { + hclge_free_vector_ring_chain(&ring_chain); + return ret; + } + + tqp_type_and_id = le16_to_cpu(data->tqp_type_and_id[0]); + int_gl_index = hnae3_get_field(tqp_type_and_id, + HCLGE_INT_GL_IDX_M, HCLGE_INT_GL_IDX_S); + + resp->data[HCLGE_RING_TYPE_OFFSET] = req->msg.param[0].ring_type; + resp->data[HCLGE_TQP_INDEX_OFFSET] = req->msg.param[0].tqp_index; + resp->data[HCLGE_INT_GL_INDEX_OFFSET] = int_gl_index; + resp->data[HCLGE_VECTOR_ID_OFFSET] = data->int_vector_id; + resp->len = HCLGE_RING_VECTOR_MAP_INFO_LEN; + + hclge_free_vector_ring_chain(&ring_chain); + + return ret; +} + static int hclge_set_vf_promisc_mode(struct hclge_vport *vport, struct hclge_mbx_vf_to_pf_cmd *req) { @@ -735,6 +818,14 @@ void hclge_mbx_handler(struct hclge_dev *hdev) ret = hclge_map_unmap_ring_to_vf_vector(vport, false, req); break; + case HCLGE_MBX_GET_RING_VECTOR_MAP: + ret = hclge_get_vf_ring_vector_map(vport, req, + &resp_msg); + if (ret) + dev_err(&hdev->pdev->dev, + "PF fail(%d) to get VF ring vector map\n", + ret); + break; case HCLGE_MBX_SET_PROMISC_MODE: ret = hclge_set_vf_promisc_mode(vport, req); if (ret)
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch modifies printing level from warn to err if read phy status failed in hclge_phy_link_status_wait() function, adds printing the return status ret, and return directly if read phy status failed.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 5bb1979..8401f51 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6534,9 +6534,11 @@ static void hclge_phy_link_status_wait(struct hclge_dev *hdev,
do { ret = phy_read_status(phydev); - if (ret) - dev_warn(&hdev->pdev->dev, - "phy update link status fail\n"); + if (ret) { + dev_err(&hdev->pdev->dev, + "phy update link status fail, ret = %d\n", ret); + return; + }
if (phydev->link == link_ret) break;
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
As struct hclge_mdio_cfg_cmd is only used in hclge_mdio.c, this patch move its declaration from hclge_mdio.h to hclge_mdio.c.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c | 11 +++++++++++ drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c index 4dd8b42..f31b2e5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.c @@ -28,6 +28,17 @@ enum hclge_mdio_c22_op_seq {
#define HCLGE_MDIO_STA_B 0
+struct hclge_mdio_cfg_cmd { + u8 ctrl_bit; + u8 phyid; + u8 phyad; + u8 rsvd; + __le16 reserve; + __le16 data_wr; + __le16 data_rd; + __le16 sta; +}; + static int hclge_mdio_write(struct mii_bus *bus, int phyid, int regnum, u16 data) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h index 787fa9c6..ef095d9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mdio.h @@ -4,17 +4,6 @@ #ifndef __HCLGE_MDIO_H #define __HCLGE_MDIO_H
-struct hclge_mdio_cfg_cmd { - u8 ctrl_bit; - u8 phyid; - u8 phyad; - u8 rsvd; - __le16 reserve; - __le16 data_wr; - __le16 data_rd; - __le16 sta; -}; - int hclge_mac_mdio_config(struct hclge_dev *hdev); int hclge_mac_connect_phy(struct hnae3_handle *handle); void hclge_mac_disconnect_phy(struct hnae3_handle *handle);
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
This patch renames the variable flag into existed, as the meaning of existed is clearer.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index bbc14b6..4afa509 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -140,7 +140,7 @@ void hnae3_unregister_client(struct hnae3_client *client) { struct hnae3_client *client_tmp; struct hnae3_ae_dev *ae_dev; - bool flag = false; + bool existed = false;
if (!client) return; @@ -149,12 +149,12 @@ void hnae3_unregister_client(struct hnae3_client *client) /* one system should only have one client for every type */ list_for_each_entry(client_tmp, &hnae3_client_list, node) { if (client_tmp->type == client->type) { - flag = true; + existed = true; break; } }
- if (!flag) { + if (!existed) { mutex_unlock(&hnae3_common_lock); return; }
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch modifies return value from 0 to -ENOSPC when buffer size is greater than limit value, as in this case means the string buffer is lllegal.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 8cb4b3b..d8b506e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -330,7 +330,7 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer, return 0;
if (count > HNS3_DBG_WRITE_LEN) - return 0; + return -ENOSPC;
cmd_buf = kzalloc(count + 1, GFP_KERNEL); if (!cmd_buf)
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
This patch replaces space with tab to align code in hns3_features_check() function.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 35a607b..74499a5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1574,7 +1574,7 @@ static netdev_features_t hns3_features_check(struct sk_buff *skb, struct net_device *dev, netdev_features_t features) { -#define HNS3_MAX_HDR_LEN 480U +#define HNS3_MAX_HDR_LEN 480U #define HNS3_MAX_L4_HDR_LEN 60U
size_t len;
From: Colin Ian King colin.king@canonical.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Don't populate the array spec_opcode on the stack but instead make it static const. Makes the object code smaller by 48 bytes.
Before: text data bss dec hex filename 6914 1040 128 8082 1f92 hns3/hns3vf/hclgevf_cmd.o
After: text data bss dec hex filename 6866 1040 128 8034 1f62 hns3/hns3vf/hclgevf_cmd.o
(gcc version 9.2.1, amd64)
Signed-off-by: Colin Ian King colin.king@canonical.com Signed-off-by: David S. Miller davem@davemloft.net Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c index fc3a6a90..286d229 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_cmd.c @@ -75,7 +75,7 @@ static bool hclgevf_cmd_csq_done(struct hclgevf_hw *hw)
static bool hclgevf_is_special_opcode(u16 opcode) { - u16 spec_opcode[] = {0x30, 0x31, 0x32}; + static const u16 spec_opcode[] = {0x30, 0x31, 0x32}; int i;
for (i = 0; i < ARRAY_SIZE(spec_opcode); i++) {
From: Greg Kroah-Hartman gregkh@linuxfoundation.org
driver inclusion category: bugfix bugzilla: NA CVE: NA
When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this.
Cc: Yisen Zhuang yisen.zhuang@huawei.com Cc: Salil Mehta salil.mehta@huawei.com Cc: "David S. Miller" davem@davemloft.net Cc: netdev@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org Signed-off-by: David S. Miller davem@davemloft.net Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index d8b506e..f758dda 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -382,20 +382,11 @@ static ssize_t hns3_dbg_cmd_write(struct file *filp, const char __user *buffer, void hns3_dbg_init(struct hnae3_handle *handle) { const char *name = pci_name(handle->pdev); - struct dentry *pfile;
handle->hnae3_dbgfs = debugfs_create_dir(name, hns3_dbgfs_root); - if (!handle->hnae3_dbgfs) - return;
- pfile = debugfs_create_file("cmd", 0600, handle->hnae3_dbgfs, handle, - &hns3_dbg_cmd_fops); - if (!pfile) { - debugfs_remove_recursive(handle->hnae3_dbgfs); - handle->hnae3_dbgfs = NULL; - dev_warn(&handle->pdev->dev, "create file for %s fail\n", - name); - } + debugfs_create_file("cmd", 0600, handle->hnae3_dbgfs, handle, + &hns3_dbg_cmd_fops); }
void hns3_dbg_uninit(struct hnae3_handle *handle) @@ -407,10 +398,6 @@ void hns3_dbg_uninit(struct hnae3_handle *handle) void hns3_dbg_register_debugfs(const char *debugfs_dir_name) { hns3_dbgfs_root = debugfs_create_dir(debugfs_dir_name, NULL); - if (!hns3_dbgfs_root) { - pr_warn("Register debugfs for %s fail\n", debugfs_dir_name); - return; - } }
void hns3_dbg_unregister_debugfs(void)
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch deletes unnecessary INITED state judgement in hns3_get_stats() function.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 71d3fb6..a75879e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -509,11 +509,9 @@ static void hns3_get_stats(struct net_device *netdev, struct ethtool_stats *stats, u64 *data) { struct hnae3_handle *h = hns3_get_handle(netdev); - struct hns3_nic_priv *priv = h->priv; u64 *p = data;
- if (!test_bit(HNS3_NIC_STATE_INITED, &priv->state) || - hns3_nic_resetting(netdev)) { + if (hns3_nic_resetting(netdev)) { netdev_err(netdev, "dev resetting, could not get stats\n"); return; }
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch deletes the parameter phydev of hclge_phy_link_status_wait() function for optimization, as it can be gotten by hdev->hw.mac.phydev.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 8401f51..a92de09 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6525,10 +6525,11 @@ static int hclge_config_switch_param(struct hclge_dev *hdev, int vfid, u8 value, }
static void hclge_phy_link_status_wait(struct hclge_dev *hdev, - struct phy_device *phydev, int link_ret) + int link_ret) { #define HCLGE_PHY_LINK_STATUS_NUM 200
+ struct phy_device *phydev = hdev->hw.mac.phydev; int i = 0; int ret;
@@ -6571,13 +6572,12 @@ static int hclge_mac_phy_link_status_wait(struct hclge_dev *hdev, bool en, #define HCLGE_LINK_STATUS_DOWN 0 #define HCLGE_LINK_STATUS_UP 1
- struct phy_device *phydev = hdev->hw.mac.phydev; int link_ret;
link_ret = en ? HCLGE_LINK_STATUS_UP : HCLGE_LINK_STATUS_DOWN;
if (is_phy) - hclge_phy_link_status_wait(hdev, phydev, link_ret); + hclge_phy_link_status_wait(hdev, link_ret);
return hclge_mac_link_status_wait(hdev, link_ret); }
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
This patch deletes the parameter phydev of hclge_set_phy_loopback() function for optimization, as it can be gotten by hdev->hw.mac.phydev.
The variable phydev should be checked whether null pointer before use.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index a92de09..bfad236 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -6733,11 +6733,14 @@ static int hclge_disable_phy_loopback(struct hclge_dev *hdev, return ret; }
-static int hclge_set_phy_loopback(struct hclge_dev *hdev, - struct phy_device *phydev, bool en) +static int hclge_set_phy_loopback(struct hclge_dev *hdev, bool en) { + struct phy_device *phydev = hdev->hw.mac.phydev; int ret;
+ if (!phydev) + return -ENOTSUPP; + if (en) ret = hclge_enable_phy_loopback(hdev, phydev); else @@ -6783,7 +6786,6 @@ static int hclge_set_loopback(struct hnae3_handle *handle, enum hnae3_loop loop_mode, bool en) { struct hclge_vport *vport = hclge_get_vport(handle); - struct phy_device *phydev = handle->netdev->phydev; struct hnae3_knic_private_info *kinfo; struct hclge_dev *hdev = vport->back; int i, ret; @@ -6811,8 +6813,7 @@ static int hclge_set_loopback(struct hnae3_handle *handle, ret = hclge_set_serdes_loopback(hdev, en, loop_mode); break; case HNAE3_LOOP_PHY: - if (phydev) - ret = hclge_set_phy_loopback(hdev, phydev, en); + ret = hclge_set_phy_loopback(hdev, en); break; default: ret = -ENOTSUPP;
From: Yufeng Mo moyufeng@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
The MAC id and loopback status information are obtained from the hardware, which will be helpful for debugging. This patch adds support for these two items in debugfs.
Signed-off-by: Yufeng Mo moyufeng@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 1 + .../ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 49 ++++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 3 ++ .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 1 + 4 files changed, 54 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index f758dda..d3bda46 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -261,6 +261,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump m7 info\n"); dev_info(&h->pdev->dev, "dump ncl_config <offset> <length>(in hex)\n"); dev_info(&h->pdev->dev, "dump mac tnl status\n"); + dev_info(&h->pdev->dev, "dump loopback\n"); dev_info(&h->pdev->dev, "dump uc mac list <func id>\n"); dev_info(&h->pdev->dev, "dump mc mac list <func id>\n");
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 8225da8..ebccce1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1313,6 +1313,51 @@ static void hclge_dbg_dump_ncl_config(struct hclge_dev *hdev, } }
+static void hclge_dbg_dump_loopback(struct hclge_dev *hdev, + const char *cmd_buf) +{ + struct hclge_config_mac_mode_cmd *req_app; + struct hclge_serdes_lb_cmd *req_serdes; + struct hclge_desc desc; + u8 loopback_en; + int ret; + + req_app = (struct hclge_config_mac_mode_cmd *)desc.data; + req_serdes = (struct hclge_serdes_lb_cmd *)desc.data; + + dev_info(&hdev->pdev->dev, "mac id: %u\n", hdev->hw.mac.mac_id); + + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_MAC_MODE, true); + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "failed to dump app loopback status, ret=%d\n", ret); + return; + } + + loopback_en = hnae3_get_bit(le32_to_cpu(req_app->txrx_pad_fcs_loop_en), + HCLGE_MAC_APP_LP_B); + dev_info(&hdev->pdev->dev, "app loopback: %s\n", + loopback_en ? "on" : "off"); + + hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SERDES_LOOPBACK, true); + ret = hclge_cmd_send(&hdev->hw, &desc, 1); + if (ret) { + dev_err(&hdev->pdev->dev, + "failed to dump serdes loopback status, ret=%d\n", ret); + return; + } + + loopback_en = req_serdes->enable & HCLGE_CMD_SERDES_SERIAL_INNER_LOOP_B; + dev_info(&hdev->pdev->dev, "serdes serial loopback: %s\n", + loopback_en ? "on" : "off"); + + loopback_en = req_serdes->enable & + HCLGE_CMD_SERDES_PARALLEL_INNER_LOOP_B; + dev_info(&hdev->pdev->dev, "serdes parallel loopback: %s\n", + loopback_en ? "on" : "off"); +} + /* hclge_dbg_dump_mac_tnl_status: print message about mac tnl interrupt * @hdev: pointer to struct hclge_dev */ @@ -1455,6 +1500,7 @@ static int hclge_dbg_dump_mac_list(struct hclge_dev *hdev, const char *cmd_buf, int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) { #define DUMP_REG "dump reg" +#define DUMP_LOOPBACK "dump loopback"
struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; @@ -1490,6 +1536,9 @@ int hclge_dbg_run_cmd(struct hnae3_handle *handle, const char *cmd_buf) &cmd_buf[sizeof("dump ncl_config")]); } else if (strncmp(cmd_buf, "dump mac tnl status", 19) == 0) { hclge_dbg_dump_mac_tnl_status(hdev); + } else if (strncmp(cmd_buf, DUMP_LOOPBACK, + strlen(DUMP_LOOPBACK)) == 0) { + hclge_dbg_dump_loopback(hdev, &cmd_buf[sizeof(DUMP_LOOPBACK)]); } else if (strncmp(cmd_buf, "dump qs shaper", 14) == 0) { hclge_dbg_dump_qs_shaper(hdev, &cmd_buf[sizeof("dump qs shaper")]); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index bfad236..2e1fbcc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -826,6 +826,8 @@ static void hclge_get_mac_stat(struct hnae3_handle *handle, static int hclge_parse_func_status(struct hclge_dev *hdev, struct hclge_func_status_cmd *status) { +#define HCLGE_MAC_ID_MASK 0xF + if (!(status->pf_state & HCLGE_PF_STATE_DONE)) return -EINVAL;
@@ -835,6 +837,7 @@ static int hclge_parse_func_status(struct hclge_dev *hdev, else hdev->flag &= ~HCLGE_FLAG_MAIN;
+ hdev->hw.mac.mac_id = status->mac_id & HCLGE_MAC_ID_MASK; return 0; }
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 5af7da7..2e3c0bf 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -256,6 +256,7 @@ enum HCLGE_MAC_DUPLEX { #define QUERY_ACTIVE_SPEED 1
struct hclge_mac { + u8 mac_id; u8 phy_addr; u8 flag; u8 media_type; /* port media type, e.g. fibre/copper/backplane */
From: Guangbin Huang huangguangbin2@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In order to get register status earlier, this patch modifies the code timing to read register firstly and then go to sleep to wait.
Signed-off-by: Guangbin Huang huangguangbin2@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 2e1fbcc..33f7045 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -3304,11 +3304,12 @@ static int hclge_reset_wait(struct hclge_dev *hdev) return -EINVAL; }
- do { + val = hclge_read_dev(&hdev->hw, reg); + while (hnae3_get_bit(val, reg_bit) && cnt < HCLGE_RESET_WAIT_CNT) { msleep(HCLGE_RESET_WATI_MS); val = hclge_read_dev(&hdev->hw, reg); cnt++; - } while (hnae3_get_bit(val, reg_bit) && cnt < HCLGE_RESET_WAIT_CNT); + }
if (cnt >= HCLGE_RESET_WAIT_CNT) { dev_warn(&hdev->pdev->dev,
From: Jian Shen shenjian15@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
For some boards the fibre port supports autoneg, and the firmware handles the autoneg speed and user speed separately.
step 1: user disables autoneg, and set the mac speed A, the driver will update the mac speed to A. step 2: user enables autoneg, and the negotiated speed is B, the driver will update the mac speed to B. step 3: user disable the autoneg, and set the mac speed B, the driver will discard the set mac speed B command, because the speed is not changed by step 2. But for firmware, it will change the mac speed to A by step 1 when received disable autoneg command. In this case, the port can't link up.
This patch fixes it by skip mac speed and duplex modification checking for fibre port support autoneg.
Fixes: 22f48e24a23d ("net: hns3: add autoneg and change speed support for fibre port")
Signed-off-by: Jian Shen shenjian15@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 33f7045..0ff69b0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -2481,10 +2481,12 @@ static int hclge_cfg_mac_speed_dup_hw(struct hclge_dev *hdev, int speed,
int hclge_cfg_mac_speed_dup(struct hclge_dev *hdev, int speed, u8 duplex) { + struct hclge_mac *mac = &hdev->hw.mac; int ret;
duplex = hclge_check_speed_dup(duplex, speed); - if (hdev->hw.mac.speed == speed && hdev->hw.mac.duplex == duplex) + if (!mac->support_autoneg && mac->speed == speed && + mac->duplex == duplex) return 0;
ret = hclge_cfg_mac_speed_dup_hw(hdev, speed, duplex);
From: Guojia Liao liaoguojia@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
Currently, Port base vlan is initiated by PF and configured to its VFs, by using command "ip link set <pf name> vf <vf id> vlan <vlan id>". When a global reset was triggered, the hardware vlan table and the soft recorded vlan information will be cleared by PF, and restored them until VFs were ready. There is a short time window between the table had been cleared and before table restored. If configured a new port base vlan tag at this moment, driver will check the soft recorded vlan information, and find there hasn't the old tag in it, which causing a warning print.
Due to the port base vlan is managed by PF, so the VFs's port base vlan restoring should be handled by PF when PF was ready.
This patch fixes it.
Signed-off-by: Guojia Liao liaoguojia@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 75 +++++++++++++++------- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 3 + 2 files changed, 56 insertions(+), 22 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 0ff69b0..e7bcc92 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -1714,6 +1714,7 @@ static int hclge_alloc_vport(struct hclge_dev *hdev) vport->vf_info.link_state = IFLA_VF_LINK_STATE_AUTO; vport->mps = HCLGE_MAC_DEFAULT_FRAME; vport->port_base_vlan_cfg.state = HNAE3_PORT_BASE_VLAN_DISABLE; + vport->port_base_vlan_cfg.tbl_sta = true; vport->rxvlan_cfg.rx_vlan_offload_en = true; INIT_LIST_HEAD(&vport->vlan_list); INIT_LIST_HEAD(&vport->uc_mac_list); @@ -6966,7 +6967,7 @@ int hclge_vport_start(struct hclge_vport *vport) set_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state); vport->last_active_jiffies = jiffies;
- if (test_and_clear_bit(vport->vport_id, hdev->vport_config_block)) { + if (test_bit(vport->vport_id, hdev->vport_config_block)) { if (vport->vport_id) { hclge_restore_mac_table_common(vport); hclge_restore_vport_vlan_table(vport); @@ -6974,6 +6975,8 @@ int hclge_vport_start(struct hclge_vport *vport) hclge_restore_hw_table(hdev); } } + clear_bit(vport->vport_id, hdev->vport_config_block); + return 0; }
@@ -8857,33 +8860,52 @@ void hclge_uninit_vport_vlan_table(struct hclge_dev *hdev) } }
-void hclge_restore_vport_vlan_table(struct hclge_vport *vport) +void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev) { - struct hclge_vport_vlan_cfg *vlan, *tmp; - struct hclge_dev *hdev = vport->back; + struct hclge_vlan_info *vlan_info; + struct hclge_vport *vport; u16 vlan_proto; - u16 state, vlan_id; + u16 vlan_id; + u16 state; + int vf_id; int ret;
- vlan_proto = vport->port_base_vlan_cfg.vlan_info.vlan_proto; - vlan_id = vport->port_base_vlan_cfg.vlan_info.vlan_tag; - state = vport->port_base_vlan_cfg.state; + /* PF should restore all vfs port base vlan */ + for (vf_id = 0; vf_id < hdev->num_alloc_vfs; vf_id++) { + vport = &hdev->vport[vf_id + HCLGE_VF_VPORT_START_NUM]; + vlan_info = vport->port_base_vlan_cfg.tbl_sta ? + &vport->port_base_vlan_cfg.vlan_info : + &vport->port_base_vlan_cfg.old_vlan_info;
- if (state != HNAE3_PORT_BASE_VLAN_DISABLE) { - clear_bit(vport->vport_id, hdev->vlan_table[vlan_id]); - hclge_set_vlan_filter_hw(hdev, htons(vlan_proto), - vport->vport_id, vlan_id, - false); - return; + vlan_id = vlan_info->vlan_tag; + vlan_proto = vlan_info->vlan_proto; + state = vport->port_base_vlan_cfg.state; + + if (state != HNAE3_PORT_BASE_VLAN_DISABLE) { + clear_bit(vport->vport_id, hdev->vlan_table[vlan_id]); + ret = hclge_set_vlan_filter_hw(hdev, htons(vlan_proto), + vport->vport_id, + vlan_id, false); + vport->port_base_vlan_cfg.tbl_sta = ret == 0; + } } +}
- list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) { - ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), - vport->vport_id, - vlan->vlan_id, false); - if (ret) - break; - vlan->hd_tbl_status = true; +void hclge_restore_vport_vlan_table(struct hclge_vport *vport) +{ + struct hclge_vport_vlan_cfg *vlan, *tmp; + struct hclge_dev *hdev = vport->back; + int ret; + + if (vport->port_base_vlan_cfg.state == HNAE3_PORT_BASE_VLAN_DISABLE) { + list_for_each_entry_safe(vlan, tmp, &vport->vlan_list, node) { + ret = hclge_set_vlan_filter_hw(hdev, htons(ETH_P_8021Q), + vport->vport_id, + vlan->vlan_id, false); + if (ret) + break; + vlan->hd_tbl_status = true; + } } }
@@ -8924,6 +8946,7 @@ static int hclge_restore_hw_table(struct hclge_dev *hdev) struct hnae3_handle *handle = &vport->nic;
hclge_restore_mac_table_common(vport); + hclge_restore_vport_port_base_vlan_config(hdev); hclge_restore_vport_vlan_table(vport); set_bit(HCLGE_STATE_PROMISC_CHANGED, &hdev->state);
@@ -8964,6 +8987,7 @@ static int hclge_update_vlan_filter_entries(struct hclge_vport *vport, new_info->vlan_tag, false); } + vport->port_base_vlan_cfg.tbl_sta = false;
ret = hclge_set_vlan_filter_hw(hdev, htons(old_info->vlan_proto), vport->vport_id, old_info->vlan_tag, @@ -8997,7 +9021,7 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, false); if (ret) return ret; - + vport->port_base_vlan_cfg.tbl_sta = false; /* remove old VLAN tag */ ret = hclge_set_vlan_filter_hw(hdev, htons(old_vlan_info->vlan_proto), @@ -9023,9 +9047,16 @@ int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, nic->port_base_vlan_state = HNAE3_PORT_BASE_VLAN_ENABLE;
update: + vport->port_base_vlan_cfg.old_vlan_info.vlan_tag = + old_vlan_info->vlan_tag; + vport->port_base_vlan_cfg.old_vlan_info.qos = + old_vlan_info->qos; + vport->port_base_vlan_cfg.old_vlan_info.vlan_proto = + old_vlan_info->vlan_proto; vport->port_base_vlan_cfg.vlan_info.vlan_tag = vlan_info->vlan_tag; vport->port_base_vlan_cfg.vlan_info.qos = vlan_info->qos; vport->port_base_vlan_cfg.vlan_info.vlan_proto = vlan_info->vlan_proto; + vport->port_base_vlan_cfg.tbl_sta = true;
return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 2e3c0bf..9632f24 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -905,7 +905,9 @@ struct hclge_vlan_info {
struct hclge_port_base_vlan_config { u16 state; + bool tbl_sta; struct hclge_vlan_info vlan_info; + struct hclge_vlan_info old_vlan_info; };
struct hclge_vf_info { @@ -1021,6 +1023,7 @@ void hclge_rm_vport_all_mac_table(struct hclge_vport *vport, bool is_del_list, enum HCLGE_MAC_ADDR_TYPE mac_type); void hclge_rm_vport_all_vlan_table(struct hclge_vport *vport, bool is_del_list); void hclge_restore_mac_table_common(struct hclge_vport *vport); +void hclge_restore_vport_port_base_vlan_config(struct hclge_dev *hdev); void hclge_restore_vport_vlan_table(struct hclge_vport *vport); int hclge_update_port_base_vlan_cfg(struct hclge_vport *vport, u16 state, struct hclge_vlan_info *vlan_info);
From: Huazhong Tan tanhuazhong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
reset_type means what kind of reset the driver is handling now, so after initializing or reset, the reset_type of VF should be set to HNAE3_NONE_RESET, otherwise, this unknown default value may be a little misleading when the device is running.
Signed-off-by: Huazhong Tan tanhuazhong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index fe3f2e7..f758a0c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2071,6 +2071,7 @@ static void hclgevf_reset_service_task(struct hclgevf_dev *hdev) hclgevf_reset_task_schedule(hdev); }
+ hdev->reset_type = HNAE3_NONE_RESET; clear_bit(HCLGEVF_STATE_RST_HANDLING, &hdev->state); up(&hdev->reset_sem); } @@ -2976,6 +2977,7 @@ static int hclgevf_init_hdev(struct hclgevf_dev *hdev)
hclgevf_state_init(hdev); hdev->reset_level = HNAE3_VF_FUNC_RESET; + hdev->reset_type = HNAE3_NONE_RESET;
ret = hclgevf_misc_irq_init(hdev); if (ret)
From: Yonglong Liu liuyonglong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
HNS3 driver can dump qs shaper configs via debugfs, but missing help info in debugfs for this operation.
Fixes: 584d21b6f3b0 ("net: hns3: add support of configuring bandwidth of VF on the host")
Signed-off-by: Yonglong Liu liuyonglong@huawei.com Reviewed-by: Peng Li lipeng321@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index d3bda46..e018029 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -262,6 +262,7 @@ static void hns3_dbg_help(struct hnae3_handle *h) dev_info(&h->pdev->dev, "dump ncl_config <offset> <length>(in hex)\n"); dev_info(&h->pdev->dev, "dump mac tnl status\n"); dev_info(&h->pdev->dev, "dump loopback\n"); + dev_info(&h->pdev->dev, "dump qs shaper [qs id]\n"); dev_info(&h->pdev->dev, "dump uc mac list <func id>\n"); dev_info(&h->pdev->dev, "dump mc mac list <func id>\n");
From: Bohong Lin linbohong@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
----------------------------------
This patch change version to 1.9.35.0
Signed-off-by: Bohong Lin linbohong@huawei.com Reviewed-by: Zhaohui Zhong zhongzhaohui@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Reviewed-by: chen junxin chenjunxin1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 5f45272..ae94323 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.33.0" +#define HNAE3_MOD_VERSION "1.9.35.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index 6360546..76f594f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.33.0" +#define HNS3_CAE_MOD_VERSION "1.9.35.0"
#define CMT_ID_LEN 8 #define RESV_LEN 3 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index c194ab9..2bcbc1a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.33.0" +#define HNS3_MOD_VERSION "1.9.35.0"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 9632f24..7a7470f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.33.0" +#define HCLGE_MOD_VERSION "1.9.35.0" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index f4ae63e..e8ae830 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.33.0" +#define HCLGEVF_MOD_VERSION "1.9.35.0" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095
From: Zhao Weibo zhaoweibo3@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
-------------------------------
After changing device state to HNS_ROCE_DEVICE_STATE_UNINIT handle device err and let usr to poll cq.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Signed-off-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 8afbe4e..41b4011 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -7330,6 +7330,7 @@ static void __hns_roce_hw_v2_uninit_instance(struct hnae3_handle *handle, handle->priv = NULL;
hr_dev->state = HNS_ROCE_DEVICE_STATE_UNINIT; + hns_roce_handle_device_err(hr_dev);
hns_roce_exit(hr_dev); kfree(hr_dev->priv); @@ -7487,7 +7488,6 @@ static int hns_roce_hw_v2_reset_notify_down(struct hnae3_handle *handle) hns_roce_v2_reset_notify_user(hr_dev);
hr_dev->state = HNS_ROCE_DEVICE_STATE_RST_DOWN; - hns_roce_handle_device_err(hr_dev);
return 0; }
From: Zhao Weibo zhaoweibo3@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
-------------------------------
add brackets to avoid overflow while doing the calculation.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Signed-off-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 6 +++--- drivers/infiniband/hw/hns/hns_roce_mr.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 41b4011..637f68d 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -6472,7 +6472,7 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev, *(eq->bt_l0 + i) = eq->l1_dma[i];
for (j = 0; j < bt_chk_sz / BA_BYTE_LEN; j++) { - idx = i * bt_chk_sz / BA_BYTE_LEN + j; + idx = i * (bt_chk_sz / BA_BYTE_LEN) + j; if (eq_buf_cnt + 1 < ba_num) { size = buf_chk_sz; } else { @@ -6520,7 +6520,7 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev, eq->l1_dma[i]);
for (j = 0; j < bt_chk_sz / BA_BYTE_LEN; j++) { - idx = i * bt_chk_sz / BA_BYTE_LEN + j; + idx = i * (bt_chk_sz / BA_BYTE_LEN) + j; dma_free_coherent(dev, buf_chk_sz, eq->buf[idx], eq->buf_dma[idx]); } @@ -6547,7 +6547,7 @@ static int hns_roce_mhop_alloc_eq(struct hns_roce_dev *hr_dev, if (i == record_i && j >= record_j) break;
- idx = i * bt_chk_sz / BA_BYTE_LEN + j; + idx = i * (bt_chk_sz / BA_BYTE_LEN) + j; dma_free_coherent(dev, buf_chk_sz, eq->buf[idx], eq->buf_dma[idx]); diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index 4208770..a2c1142 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -324,7 +324,7 @@ static void hns_roce_loop_free(struct hns_roce_dev *hr_dev, if (i == loop_i && j >= loop_j) break;
- bt_idx = i * pbl_bt_sz / BA_BYTE_LEN + j; + bt_idx = i * (pbl_bt_sz / BA_BYTE_LEN) + j; dma_free_coherent(dev, pbl_bt_sz, mr->pbl_bt_l2[bt_idx], mr->pbl_l2_dma_addr[bt_idx]); @@ -336,7 +336,7 @@ static void hns_roce_loop_free(struct hns_roce_dev *hr_dev, mr->pbl_l1_dma_addr[i]);
for (j = 0; j < pbl_bt_sz / BA_BYTE_LEN; j++) { - bt_idx = i * pbl_bt_sz / BA_BYTE_LEN + j; + bt_idx = i * (pbl_bt_sz / BA_BYTE_LEN) + j; dma_free_coherent(dev, pbl_bt_sz, mr->pbl_bt_l2[bt_idx], mr->pbl_l2_dma_addr[bt_idx]); @@ -461,7 +461,7 @@ static int pbl_3hop_alloc(struct hns_roce_dev *hr_dev, int npages, *(mr->pbl_bt_l0 + i) = mr->pbl_l1_dma_addr[i];
for (j = 0; j < pbl_bt_sz / BA_BYTE_LEN; j++) { - bt_idx = i * pbl_bt_sz / BA_BYTE_LEN + j; + bt_idx = i * (pbl_bt_sz / BA_BYTE_LEN) + j;
if (pbl_bt_cnt + 1 < pbl_last_bt_num) { size = pbl_bt_sz;
From: Zhao Weibo zhaoweibo3@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
------------------------------
This patch add a way of querying arm_cnt in rdfx.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Signed-off-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c index 768e4f2..322b107 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c @@ -372,9 +372,9 @@ static int show_cq_detail(struct rdfx_cq_info *rdfx_cq) pr_info("\n"); pr_info("arm_cnt:\n"); pr_info("IB_CQ_SOLICITED : 0x%x\n", - atomic_read(&rdfx_cq->rcqe_cnt[0])); + atomic_read(&rdfx_cq->arm_cnt[0])); pr_info("IB_CQ_NEXT_COMP : 0x%x\n", - atomic_read(&rdfx_cq->rcqe_cnt[1])); + atomic_read(&rdfx_cq->arm_cnt[1])); pr_info("CQ_CI : 0x%x\n", atomic_read(&rdfx_cq->ci));
return 0; @@ -400,6 +400,10 @@ static void show_valid_cqn(struct list_head *head) static inline int rdfx_show_cq_detail(u32 cqn, struct rdfx_info *rdfx) { struct rdfx_cq_info *rdfx_cq = NULL; + struct hns_roce_dev *hr_dev; + struct hns_roce_cq *cq; + + hr_dev = (struct hns_roce_dev *)rdfx->priv;
pr_info("***************** CQ(0x%x) INFO *****************\n", cqn); pr_info("alloc_cq_cnt : 0x%x\n", @@ -409,6 +413,11 @@ static inline int rdfx_show_cq_detail(u32 cqn, struct rdfx_info *rdfx) pr_info("top_cq_index : 0x%x\n", atomic_read(&rdfx->cq.top_cq_index));
+ cq = radix_tree_lookup(&hr_dev->cq_table.tree, + cqn & (hr_dev->caps.num_cqs - 1)); + if (cq) + pr_info("arm_sn_cnt : 0x%x\n", cq->arm_sn); + list_for_each_entry(rdfx_cq, &rdfx->cq.list, list) { if (cqn == rdfx_cq->cqn) return show_cq_detail(rdfx_cq);
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
In this patch, we try to update logic of uacce mode. In qm.c, we delete use_dma_api judgement branch, because the value of use_dma_api is always true. In hpre_main.c sec_main.c rde_main.c and zip_main.c, we update related logic of uacce_mode, because the changes of uacce.c and qm.c.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Hui Tang tanghui20@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/hpre/hpre_main.c | 17 +- drivers/crypto/hisilicon/qm.c | 306 +++++++++--------------------- drivers/crypto/hisilicon/qm.h | 1 - drivers/crypto/hisilicon/rde/rde_main.c | 15 +- drivers/crypto/hisilicon/sec2/sec_main.c | 24 +-- drivers/crypto/hisilicon/zip/zip_main.c | 28 +-- 6 files changed, 96 insertions(+), 295 deletions(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 78c3204..866a4be 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -227,7 +227,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp) return -EINVAL;
ret = kstrtou32(val, 10, &n); - if (ret != 0 || n > UACCE_MODE_NOIOMMU) + if (ret != 0 || (n != UACCE_MODE_NOIOMMU && n != UACCE_MODE_NOUACCE)) return -EINVAL;
return param_set_int(val, kp); @@ -244,7 +244,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp)
static int uacce_mode = UACCE_MODE_NOUACCE; module_param_cb(uacce_mode, &uacce_mode_ops, &uacce_mode, 0444); -MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 1, 2"); +MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 2"); static inline void hpre_add_to_list(struct hpre *hpre) { mutex_lock(&hpre_list_lock); @@ -588,7 +588,7 @@ static ssize_t hpre_ctrl_debug_read(struct file *filp, char __user *buf, return -EINVAL; } spin_unlock_irq(&file->lock); - ret = sprintf(tbuf, "%u\n", val); + ret = snprintf(tbuf, HPRE_DBGFS_VAL_MAX_LEN, "%u\n", val); return simple_read_from_buffer(buf, count, pos, tbuf, ret); }
@@ -819,20 +819,9 @@ static int hpre_qm_pre_init(struct hisi_qm *qm, struct pci_dev *pdev) qm->algs = "rsa\ndh\n"; switch (uacce_mode) { case UACCE_MODE_NOUACCE: - qm->use_dma_api = true; qm->use_uacce = false; break; - case UACCE_MODE_UACCE: -#ifdef CONFIG_IOMMU_SVA - qm->use_dma_api = true; - qm->use_sva = true; -#else - qm->use_dma_api = false; -#endif - qm->use_uacce = true; - break; case UACCE_MODE_NOIOMMU: - qm->use_dma_api = true; qm->use_uacce = true; break; default: diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 9018c21..0ffdf64 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -905,7 +905,7 @@ static ssize_t qm_debug_read(struct file *filp, char __user *buf, return -EINVAL; } mutex_unlock(&file->lock); - ret = sprintf(tbuf, "%u\n", val); + ret = snprintf(tbuf, TEMPBUFFER_LEN, "%u\n", val);
return simple_read_from_buffer(buf, count, pos, tbuf, ret); } @@ -1205,23 +1205,21 @@ static struct hisi_qp *hisi_qm_create_qp_nolock(struct hisi_qm *qm, qp->qm = qm;
/* allocate qp dma memory, uacce uses dus region for this */ - if (qm->use_dma_api) { - qp->qdma.size = qm->sqe_size * QM_Q_DEPTH + - sizeof(struct cqe) * QM_Q_DEPTH; - /* one more page for device or qp statuses */ - qp->qdma.size = PAGE_ALIGN(qp->qdma.size) + PAGE_SIZE; - qp->qdma.va = dma_alloc_coherent(dev, qp->qdma.size, - &qp->qdma.dma, - GFP_KERNEL); - if (!qp->qdma.va) { - ret = -ENOMEM; - goto err_clear_bit; - } - - dev_dbg(dev, "allocate qp dma buf(va=%pK, dma=%pad, size=%zx)\n", - qp->qdma.va, &qp->qdma.dma, qp->qdma.size); + qp->qdma.size = qm->sqe_size * QM_Q_DEPTH + + sizeof(struct cqe) * QM_Q_DEPTH; + /* one more page for device or qp statuses */ + qp->qdma.size = PAGE_ALIGN(qp->qdma.size) + PAGE_SIZE; + qp->qdma.va = dma_alloc_coherent(dev, qp->qdma.size, + &qp->qdma.dma, + GFP_KERNEL); + if (!qp->qdma.va) { + ret = -ENOMEM; + goto err_clear_bit; }
+ dev_dbg(dev, "allocate qp dma buf(va=%pK, dma=%pad, size=%zx)\n", + qp->qdma.va, &qp->qdma.dma, qp->qdma.size); + qp->qp_id = qp_id; qp->alg_type = alg_type; qp->c_flag = 1; @@ -1276,7 +1274,7 @@ void hisi_qm_release_qp(struct hisi_qp *qp) up_write(&qm->qps_lock); return; } - if (qm->use_dma_api && qdma->va) + if (qdma->va) dma_free_coherent(dev, qdma->size, qdma->va, qdma->dma);
dev_dbg(dev, "release qp %d\n", qp->qp_id); @@ -1297,19 +1295,14 @@ static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid) dma_addr_t sqc_dma; int ret;
- if (qm->use_dma_api) { - sqc = kzalloc(sizeof(struct qm_sqc), GFP_KERNEL); - if (!sqc) - return -ENOMEM; - sqc_dma = dma_map_single(dev, sqc, sizeof(struct qm_sqc), - DMA_TO_DEVICE); - if (dma_mapping_error(dev, sqc_dma)) { - kfree(sqc); - return -ENOMEM; - } - } else { - sqc = qm->reserve; - sqc_dma = qm->reserve_dma; + sqc = kzalloc(sizeof(struct qm_sqc), GFP_KERNEL); + if (!sqc) + return -ENOMEM; + sqc_dma = dma_map_single(dev, sqc, sizeof(struct qm_sqc), + DMA_TO_DEVICE); + if (dma_mapping_error(dev, sqc_dma)) { + kfree(sqc); + return -ENOMEM; }
INIT_QC_COMMON(sqc, qp->sqe_dma, pasid); @@ -1324,13 +1317,8 @@ static int qm_sq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid) sqc->w13 = cpu_to_le16(QM_MK_SQC_W13(0, 1, qp->alg_type));
ret = qm_mb(qm, QM_MB_CMD_SQC, sqc_dma, qp_id, 0); - if (qm->use_dma_api) { - dma_unmap_single(dev, sqc_dma, sizeof(struct qm_sqc), - DMA_TO_DEVICE); - kfree(sqc); - } else { - memset(sqc, 0, sizeof(struct qm_sqc)); - } + dma_unmap_single(dev, sqc_dma, sizeof(struct qm_sqc), DMA_TO_DEVICE); + kfree(sqc);
return ret; } @@ -1344,20 +1332,15 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid) dma_addr_t cqc_dma; int ret;
- if (qm->use_dma_api) { - cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL); - if (!cqc) - return -ENOMEM; + cqc = kzalloc(sizeof(struct qm_cqc), GFP_KERNEL); + if (!cqc) + return -ENOMEM;
- cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc), - DMA_TO_DEVICE); - if (dma_mapping_error(dev, cqc_dma)) { - kfree(cqc); - return -ENOMEM; - } - } else { - cqc = qm->reserve; - cqc_dma = qm->reserve_dma; + cqc_dma = dma_map_single(dev, cqc, sizeof(struct qm_cqc), + DMA_TO_DEVICE); + if (dma_mapping_error(dev, cqc_dma)) { + kfree(cqc); + return -ENOMEM; }
INIT_QC_COMMON(cqc, qp->cqe_dma, pasid); @@ -1373,13 +1356,8 @@ static int qm_cq_ctx_cfg(struct hisi_qp *qp, int qp_id, int pasid) qp->c_flag << QM_CQ_FLAG_SHIFT);
ret = qm_mb(qm, QM_MB_CMD_CQC, cqc_dma, qp_id, 0); - if (qm->use_dma_api) { - dma_unmap_single(dev, cqc_dma, sizeof(struct qm_cqc), - DMA_TO_DEVICE); - kfree(cqc); - } else { - memset(cqc, 0, sizeof(struct qm_cqc)); - } + dma_unmap_single(dev, cqc_dma, sizeof(struct qm_cqc), DMA_TO_DEVICE); + kfree(cqc);
return ret; } @@ -1614,9 +1592,6 @@ int hisi_qm_get_free_qp_num(struct hisi_qm *qm) ret++; up_read(&qm->qps_lock);
- if (!qm->use_dma_api) - ret = (ret == qm->qp_num) ? 1 : 0; - return ret; } EXPORT_SYMBOL_GPL(hisi_qm_get_free_qp_num); @@ -1729,25 +1704,21 @@ static int hisi_qm_uacce_mmap(struct uacce_queue *q, qm->phys_base >> PAGE_SHIFT, sz, pgprot_noncached(vma->vm_page_prot)); case UACCE_QFRT_DUS: - if (qm->use_dma_api) { - if (sz != qp->qdma.size) { - dev_err(dev, "wrong queue size %ld vs %ld\n", - sz, qp->qdma.size); - return -EINVAL; - } - - /* dma_mmap_coherent() requires vm_pgoff as 0 - * restore vm_pfoff to initial value for mmap() - */ - vm_pgoff = vma->vm_pgoff; - vma->vm_pgoff = 0; - ret = dma_mmap_coherent(dev, vma, qp->qdma.va, - qp->qdma.dma, sz); - vma->vm_pgoff = vm_pgoff; - return ret; + if (sz != qp->qdma.size) { + dev_err(dev, "wrong queue size %ld vs %ld\n", + sz, qp->qdma.size); + return -EINVAL; } - return -EINVAL;
+ /* dma_mmap_coherent() requires vm_pgoff as 0 + * restore vm_pfoff to initial value for mmap() + */ + vm_pgoff = vma->vm_pgoff; + vma->vm_pgoff = 0; + ret = dma_mmap_coherent(dev, vma, qp->qdma.va, + qp->qdma.dma, sz); + vma->vm_pgoff = vm_pgoff; + return ret; default: return -EINVAL; } @@ -1755,58 +1726,16 @@ static int hisi_qm_uacce_mmap(struct uacce_queue *q,
static int hisi_qm_uacce_start_queue(struct uacce_queue *q) { - int ret; - struct hisi_qm *qm = q->uacce->priv; struct hisi_qp *qp = q->priv;
- dev_dbg(&q->uacce->dev, "uacce queue start\n"); - - /* without SVA, iommu api should be called after user mmap dko */ - if (!qm->use_dma_api) { - qm->qdma.dma = q->qfrs[UACCE_QFRT_DKO]->iova; - qm->qdma.va = q->qfrs[UACCE_QFRT_DKO]->kaddr; - qm->qdma.size = q->qfrs[UACCE_QFRT_DKO]->nr_pages >> PAGE_SHIFT; - dev_dbg(&q->uacce->dev, - "use dko space: va=%pK, dma=%lx, size=%llx\n", - qm->qdma.va, (unsigned long)qm->qdma.dma, - qm->size); - ret = __hisi_qm_start(qm); - if (ret) - return ret; - - qp->qdma.dma = q->qfrs[UACCE_QFRT_DUS]->iova; - qp->qdma.va = q->qfrs[UACCE_QFRT_DUS]->kaddr; - qp->qdma.size = q->qfrs[UACCE_QFRT_DUS]->nr_pages >> PAGE_SHIFT; - } - - ret = hisi_qm_start_qp(qp, qp->pasid); - if (ret && !qm->use_dma_api) { - ret = hisi_qm_stop(qm, QM_NORMAL); - if (ret) { - dev_dbg(&q->uacce->dev, "Stop qm failed!\n"); - return ret; - } - } - - return ret; + return hisi_qm_start_qp(qp, qp->pasid); }
static void hisi_qm_uacce_stop_queue(struct uacce_queue *q) { - struct hisi_qm *qm = q->uacce->priv; struct hisi_qp *qp = q->priv;
hisi_qm_stop_qp(qp); - - if (!qm->use_dma_api) { - /* - * In uacce_mode=1, we flush qm sqc here. - * In uacce_fops_release, the working flow is stop_queue -> - * unmap memory -> put_queue. Before unmapping memory, we - * should flush sqc back to memory. - */ - hisi_qm_cache_wb(qm); - } }
static int qm_set_sqctype(struct uacce_queue *q, u16 type) @@ -1910,24 +1839,16 @@ static int qm_register_uacce(struct hisi_qm *qm) else uacce->api_ver = HISI_QM_API_VER2_BASE;
- if (qm->use_dma_api) { - /* - * Noiommu, SVA, and crypto-only modes are all using dma api. - * So we don't use uacce to allocate memory. We allocate it - * by ourself with the UACCE_DEV_DRVMAP_DUS flag. - */ - if (qm->use_sva) { - uacce->flags = UACCE_DEV_SVA | UACCE_DEV_DRVMAP_DUS; - } else { - uacce->flags = UACCE_DEV_NOIOMMU | - UACCE_DEV_DRVMAP_DUS; - if (qm->ver == QM_HW_V1) - uacce->api_ver = HISI_QM_API_VER_BASE - UACCE_API_VER_NOIOMMU_SUBFIX; - else - uacce->api_ver = HISI_QM_API_VER2_BASE - UACCE_API_VER_NOIOMMU_SUBFIX; - } + if (qm->use_sva) { + uacce->flags = UACCE_DEV_SVA; + } else { + uacce->flags = UACCE_DEV_NOIOMMU; + if (qm->ver == QM_HW_V1) + uacce->api_ver = HISI_QM_API_VER_BASE + UACCE_API_VER_NOIOMMU_SUBFIX; + else + uacce->api_ver = HISI_QM_API_VER2_BASE + UACCE_API_VER_NOIOMMU_SUBFIX; }
for (i = 0; i < UACCE_QFRT_MAX; i++) @@ -2031,9 +1952,7 @@ int hisi_qm_init(struct hisi_qm *qm) atomic_set(&qm->status.flags, QM_INIT); INIT_WORK(&qm->work, qm_work_process);
- dev_dbg(dev, "init qm %s with %s\n", - pdev->is_physfn ? "pf" : "vf", - qm->use_dma_api ? "dma api" : "iommu api"); + dev_dbg(dev, "init qm %s\n", pdev->is_physfn ? "pf" : "vf");
return 0;
@@ -2072,7 +1991,7 @@ void hisi_qm_uninit(struct hisi_qm *qm) return; } /* qm hardware buffer free on put_queue if no dma api */ - if (qm->use_dma_api && qm->qdma.va) { + if (qm->qdma.va) { hisi_qm_cache_wb(qm); dma_free_coherent(dev, qm->qdma.size, qm->qdma.va, qm->qdma.dma); @@ -2190,19 +2109,14 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm) dma_addr_t eqc_dma; int ret;
- if (qm->use_dma_api) { - eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL); - if (!eqc) - return -ENOMEM; - eqc_dma = dma_map_single(dev, eqc, sizeof(struct qm_eqc), - DMA_TO_DEVICE); - if (dma_mapping_error(dev, eqc_dma)) { - kfree(eqc); - return -ENOMEM; - } - } else { - eqc = qm->reserve; - eqc_dma = qm->reserve_dma; + eqc = kzalloc(sizeof(struct qm_eqc), GFP_KERNEL); + if (!eqc) + return -ENOMEM; + eqc_dma = dma_map_single(dev, eqc, sizeof(struct qm_eqc), + DMA_TO_DEVICE); + if (dma_mapping_error(dev, eqc_dma)) { + kfree(eqc); + return -ENOMEM; }
eqc->base_l = cpu_to_le32(lower_32_bits(qm->eqe_dma)); @@ -2211,12 +2125,8 @@ static int qm_eq_ctx_cfg(struct hisi_qm *qm) eqc->dw3 = cpu_to_le32(QM_EQE_AEQE_SIZE); eqc->dw6 = cpu_to_le32((QM_EQ_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT)); ret = qm_mb(qm, QM_MB_CMD_EQC, eqc_dma, 0, 0); - if (qm->use_dma_api) { - dma_unmap_single(dev, eqc_dma, sizeof(struct qm_eqc), - DMA_TO_DEVICE); - kfree(eqc); - } else - memset(eqc, 0, sizeof(struct qm_eqc)); + dma_unmap_single(dev, eqc_dma, sizeof(struct qm_eqc), DMA_TO_DEVICE); + kfree(eqc);
return ret; } @@ -2228,31 +2138,22 @@ static int qm_aeq_ctx_cfg(struct hisi_qm *qm) dma_addr_t aeqc_dma; int ret;
- if (qm->use_dma_api) { - aeqc = kzalloc(sizeof(struct qm_aeqc), GFP_KERNEL); - if (!aeqc) - return -ENOMEM; - aeqc_dma = dma_map_single(dev, aeqc, sizeof(struct qm_aeqc), - DMA_TO_DEVICE); - if (dma_mapping_error(dev, aeqc_dma)) { - kfree(aeqc); - return -ENOMEM; - } - } else { - aeqc = qm->reserve; - aeqc_dma = qm->reserve_dma; + aeqc = kzalloc(sizeof(struct qm_aeqc), GFP_KERNEL); + if (!aeqc) + return -ENOMEM; + aeqc_dma = dma_map_single(dev, aeqc, sizeof(struct qm_aeqc), + DMA_TO_DEVICE); + if (dma_mapping_error(dev, aeqc_dma)) { + kfree(aeqc); + return -ENOMEM; }
aeqc->base_l = cpu_to_le32(lower_32_bits(qm->aeqe_dma)); aeqc->base_h = cpu_to_le32(upper_32_bits(qm->aeqe_dma)); aeqc->dw6 = cpu_to_le32((QM_Q_DEPTH - 1) | (1 << QM_EQC_PHASE_SHIFT)); ret = qm_mb(qm, QM_MB_CMD_AEQC, aeqc_dma, 0, 0); - if (qm->use_dma_api) { - dma_unmap_single(dev, aeqc_dma, sizeof(struct qm_aeqc), - DMA_TO_DEVICE); - kfree(aeqc); - } else - memset(aeqc, 0, sizeof(struct qm_aeqc)); + dma_unmap_single(dev, aeqc_dma, sizeof(struct qm_aeqc), DMA_TO_DEVICE); + kfree(aeqc);
return ret; } @@ -2279,9 +2180,6 @@ static int __hisi_qm_start(struct hisi_qm *qm) struct device *dev = &pdev->dev; size_t off = 0; int ret; -#ifdef CONFIG_CRYPTO_QM_UACCE - size_t dko_size; -#endif
#define QM_INIT_BUF(qm, type, num) do { \ (qm)->type = ((qm)->qdma.va + (off)); \ @@ -2324,20 +2222,6 @@ static int __hisi_qm_start(struct hisi_qm *qm) qm->sqc, (unsigned long)qm->sqc_dma, qm->cqc, (unsigned long)qm->cqc_dma);
-#ifdef CONFIG_CRYPTO_QM_UACCE - /* check if the size exceed the DKO boundary */ - if (qm->use_uacce && !qm->use_dma_api) { - WARN_ON(qm->uacce.qf_pg_start[UACCE_QFRT_DKO] == UACCE_QFR_NA); - dko_size = qm->uacce.qf_pg_start[UACCE_QFRT_DUS] - - qm->uacce.qf_pg_start[UACCE_QFRT_DKO]; - dko_size <<= PAGE_SHIFT; - dev_dbg(&qm->pdev->dev, - "kernel-only buffer used (0x%lx/0x%lx)\n", off, - dko_size); - if (off > dko_size) - return -EINVAL; - } -#endif ret = qm_eq_aeq_ctx_cfg(qm); if (ret) return ret; @@ -2445,20 +2329,11 @@ int hisi_qm_start(struct hisi_qm *qm) QM_V2_DOORBELL_OFFSET / PAGE_SIZE; else mmio_page_nr = QM_DOORBELL_PAGE_NR; - if (qm->use_uacce && qm->use_dma_api) { - uacce->qf_pg_start[UACCE_QFRT_MMIO] = 0; - uacce->qf_pg_start[UACCE_QFRT_DKO] = UACCE_QFR_NA; - uacce->qf_pg_start[UACCE_QFRT_DUS] = mmio_page_nr; - uacce->qf_pg_start[UACCE_QFRT_SS] = mmio_page_nr + - dus_page_nr; - } else if (qm->use_uacce) { + + if (qm->use_uacce) { uacce->qf_pg_start[UACCE_QFRT_MMIO] = 0; - uacce->qf_pg_start[UACCE_QFRT_DKO] = mmio_page_nr; - uacce->qf_pg_start[UACCE_QFRT_DUS] = mmio_page_nr + - dko_page_nr; - uacce->qf_pg_start[UACCE_QFRT_SS] = mmio_page_nr + - dko_page_nr + - dus_page_nr; + uacce->qf_pg_start[UACCE_QFRT_DUS] = mmio_page_nr; + uacce->qf_pg_start[UACCE_QFRT_SS] = mmio_page_nr + dus_page_nr; } #endif
@@ -2474,16 +2349,7 @@ int hisi_qm_start(struct hisi_qm *qm) } }
- if (!qm->use_dma_api) { - /* - * without SVA, qm have to be started after user region is - * mapped - */ - dev_dbg(&qm->pdev->dev, "qm delay start\n"); - atomic_set(&qm->status.flags, QM_START); - up_write(&qm->qps_lock); - return 0; - } else if (!qm->qdma.va) { + if (!qm->qdma.va) { qm->qdma.size = QMC_ALIGN(sizeof(struct qm_eqe) * QM_EQ_DEPTH) + QMC_ALIGN(sizeof(struct qm_aeqe) * QM_Q_DEPTH) + QMC_ALIGN(sizeof(struct qm_sqc) * qm->qp_num) + diff --git a/drivers/crypto/hisilicon/qm.h b/drivers/crypto/hisilicon/qm.h index e360796..24b3609 100644 --- a/drivers/crypto/hisilicon/qm.h +++ b/drivers/crypto/hisilicon/qm.h @@ -287,7 +287,6 @@ struct hisi_qm { u32 msi_mask;
const char *algs; - bool use_dma_api; /* use dma or iommu api api */ bool use_uacce; /* register to uacce */ bool use_sva;
diff --git a/drivers/crypto/hisilicon/rde/rde_main.c b/drivers/crypto/hisilicon/rde/rde_main.c index c3385f0..590969a 100644 --- a/drivers/crypto/hisilicon/rde/rde_main.c +++ b/drivers/crypto/hisilicon/rde/rde_main.c @@ -250,7 +250,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp) return -EINVAL;
ret = kstrtou32(val, FORMAT_DECIMAL, &n); - if (ret != 0 || n > UACCE_MODE_NOIOMMU) + if (ret != 0 || (n != UACCE_MODE_NOIOMMU && n != UACCE_MODE_NOUACCE)) return -EINVAL;
return param_set_int(val, kp); @@ -268,7 +268,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp)
static int uacce_mode = UACCE_MODE_NOUACCE; module_param_cb(uacce_mode, &uacce_mode_ops, &uacce_mode, 0444); -MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 1, 2"); +MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 2");
static const struct pci_device_id hisi_rde_dev_ids[] = { {PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, HRDE_PCI_DEVICE_ID)}, @@ -791,20 +791,9 @@ static int hisi_rde_qm_pre_init(struct hisi_qm *qm, struct pci_dev *pdev)
switch (uacce_mode) { case UACCE_MODE_NOUACCE: - qm->use_dma_api = true; qm->use_uacce = false; break; - case UACCE_MODE_UACCE: -#ifdef CONFIG_IOMMU_SVA - qm->use_dma_api = true; - qm->use_sva = true; -#else - qm->use_dma_api = false; -#endif - qm->use_uacce = true; - break; case UACCE_MODE_NOIOMMU: - qm->use_dma_api = true; qm->use_uacce = true; break; default: diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 0cadd6a..53e6d27 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -313,7 +313,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp) return -EINVAL;
ret = kstrtou32(val, FORMAT_DECIMAL, &n); - if (ret != 0 || n > UACCE_MODE_NOIOMMU) + if (ret != 0 || (n != UACCE_MODE_NOIOMMU && n != UACCE_MODE_NOUACCE)) return -EINVAL;
return param_set_int(val, kp); @@ -405,7 +405,7 @@ static int fusion_tmout_nsec_set(const char *val, const struct kernel_param *kp)
static int uacce_mode = UACCE_MODE_NOUACCE; module_param_cb(uacce_mode, &uacce_mode_ops, &uacce_mode, 0444); -MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 1, 2"); +MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 2");
static int ctx_q_num = CTX_Q_NUM_DEF; module_param_cb(ctx_q_num, &ctx_q_num_ops, &ctx_q_num, 0444); @@ -1023,20 +1023,9 @@ static int hisi_sec_qm_init(struct hisi_qm *qm, struct pci_dev *pdev)
switch (uacce_mode) { case UACCE_MODE_NOUACCE: - qm->use_dma_api = true; qm->use_uacce = false; break; - case UACCE_MODE_UACCE: -#ifdef CONFIG_IOMMU_SVA - qm->use_dma_api = true; - qm->use_sva = true; -#else - qm->use_dma_api = false; -#endif - qm->use_uacce = true; - break; case UACCE_MODE_NOIOMMU: - qm->use_dma_api = true; qm->use_uacce = true; break; default: @@ -1783,10 +1772,6 @@ static int __init hisi_sec_init(void) pr_err("Failed to register pci driver.\n"); goto err_pci; } -#ifndef CONFIG_IOMMU_SVA - if (uacce_mode == UACCE_MODE_UACCE) - return 0; -#endif
if (list_empty(&hisi_sec_list)) { pr_err("no device!\n"); @@ -1814,12 +1799,7 @@ static int __init hisi_sec_init(void)
static void __exit hisi_sec_exit(void) { -#ifndef CONFIG_IOMMU_SVA - if (uacce_mode != UACCE_MODE_UACCE) - hisi_sec_unregister_from_crypto(fusion_limit); -#else hisi_sec_unregister_from_crypto(fusion_limit); -#endif pci_unregister_driver(&hisi_sec_pci_driver); hisi_sec_unregister_debugfs(); if (sec_wq) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index 5b4a5c1..d23b66b 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -331,7 +331,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp) return -EINVAL;
ret = kstrtou32(val, FORMAT_DECIMAL, &n); - if (ret != 0 || n > UACCE_MODE_NOIOMMU) + if (ret != 0 || (n != UACCE_MODE_NOIOMMU && n != UACCE_MODE_NOUACCE)) return -EINVAL;
return param_set_int(val, kp); @@ -348,7 +348,7 @@ static int uacce_mode_set(const char *val, const struct kernel_param *kp)
static int uacce_mode = UACCE_MODE_NOUACCE; module_param_cb(uacce_mode, &uacce_mode_ops, &uacce_mode, 0444); -MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 1, 2"); +MODULE_PARM_DESC(uacce_mode, "Mode of UACCE can be 0(default), 2");
static const struct pci_device_id hisi_zip_dev_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_ZIP_PF) }, @@ -580,7 +580,7 @@ static ssize_t hisi_zip_ctrl_debug_read(struct file *filp, char __user *buf, return -EINVAL; } spin_unlock(&file->lock); - ret = sprintf(tbuf, "%u\n", val); + ret = snprintf(tbuf, HZIP_BUF_SIZE, "%u\n", val); return simple_read_from_buffer(buf, count, pos, tbuf, ret); }
@@ -867,21 +867,9 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
switch (uacce_mode) { case UACCE_MODE_NOUACCE: - qm->use_dma_api = true; qm->use_uacce = false; break; - case UACCE_MODE_UACCE: -#ifdef CONFIG_IOMMU_SVA - qm->use_dma_api = true; - qm->use_sva = true; -#else - qm->use_dma_api = false; - qm->use_sva = false; -#endif - qm->use_uacce = true; - break; case UACCE_MODE_NOIOMMU: - qm->use_dma_api = true; qm->use_uacce = true; break; default: @@ -930,10 +918,6 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (ret) dev_err(&pdev->dev, "Failed to init debugfs (%d)!\n", ret);
-#ifndef CONFIG_IOMMU_SVA - if (uacce_mode == UACCE_MODE_UACCE) - return 0; -#endif ret = hisi_zip_register_to_crypto(); if (ret < 0) { pr_err("Failed to register driver to crypto.\n"); @@ -1111,13 +1095,7 @@ static void hisi_zip_remove(struct pci_dev *pdev) if (qm->fun_type == QM_HW_PF && hisi_zip->ctrl->num_vfs != 0) (void)hisi_zip_sriov_disable(pdev);
-#ifndef CONFIG_IOMMU_SVA - if (uacce_mode != UACCE_MODE_UACCE) - hisi_zip_unregister_from_crypto(); -#else hisi_zip_unregister_from_crypto(); -#endif - hisi_zip_debugfs_exit(hisi_zip); hisi_qm_stop(qm, QM_NORMAL);
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
To be simple, in this patch we try to remove uacce mode 1 related logic of uacce.c. Because in open mainline ,we do not use this mode, mode 0 is used for kernel and mode 2 is used for user. At the same time, we update correspondingheader file uacce.h. We also delete UACCE_QFRT_DKO in dummy_wd_dev.c and dummy_wd_v2.c
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Hui Tang tanghui20@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/uacce/dummy_drv/dummy_wd_dev.c | 1 - drivers/uacce/dummy_drv/dummy_wd_v2.c | 1 - drivers/uacce/uacce.c | 512 ++------------------------------- include/linux/uacce.h | 10 +- include/uapi/linux/uacce.h | 6 +- 5 files changed, 33 insertions(+), 497 deletions(-)
diff --git a/drivers/uacce/dummy_drv/dummy_wd_dev.c b/drivers/uacce/dummy_drv/dummy_wd_dev.c index 6bcd39c..fa684c8 100644 --- a/drivers/uacce/dummy_drv/dummy_wd_dev.c +++ b/drivers/uacce/dummy_drv/dummy_wd_dev.c @@ -325,7 +325,6 @@ static int dummy_wd_probe(struct platform_device *pdev) uacce->api_ver = "dummy_v1"; uacce->flags = UACCE_DEV_NOIOMMU; uacce->qf_pg_start[UACCE_QFRT_MMIO] = 0; - uacce->qf_pg_start[UACCE_QFRT_DKO] = UACCE_QFR_NA; uacce->qf_pg_start[UACCE_QFRT_DUS] = UACCE_QFR_NA; uacce->qf_pg_start[UACCE_QFRT_SS] = 1;
diff --git a/drivers/uacce/dummy_drv/dummy_wd_v2.c b/drivers/uacce/dummy_drv/dummy_wd_v2.c index 065e0a7..7c5c486 100644 --- a/drivers/uacce/dummy_drv/dummy_wd_v2.c +++ b/drivers/uacce/dummy_drv/dummy_wd_v2.c @@ -458,7 +458,6 @@ static int dummy_wd2_probe(struct platform_device *pdev) uacce->api_ver = "dummy_v2"; uacce->flags = 0; uacce->qf_pg_start[UACCE_QFRT_MMIO] = 0; - uacce->qf_pg_start[UACCE_QFRT_DKO] = UACCE_QFR_NA; uacce->qf_pg_start[UACCE_QFRT_DUS] = 1; uacce->qf_pg_start[UACCE_QFRT_SS] = 2;
diff --git a/drivers/uacce/uacce.c b/drivers/uacce/uacce.c index 7cfd50d..35c7218 100644 --- a/drivers/uacce/uacce.c +++ b/drivers/uacce/uacce.c @@ -7,52 +7,32 @@ #include <linux/dma-mapping.h> #include <linux/file.h> #include <linux/idr.h> -#include <linux/irqdomain.h> #include <linux/list.h> #include <linux/module.h> #include <linux/poll.h> -#include <linux/sched/signal.h> #include <linux/slab.h> #include <linux/uacce.h> #include <linux/wait.h>
-/* - * This will set the page mapping to user space without page fault. - * - * fixme: make it as a config item when it is mature - * If this is ok in practice, we can change the queue lock to semaphore - */ -#define CONFIG_UACCE_FIX_MMAP - static struct class *uacce_class; static DEFINE_IDR(uacce_idr); static dev_t uacce_devt;
-/* lock to protect all queues management */ -#ifdef CONFIG_UACCE_FIX_MMAP static DECLARE_RWSEM(uacce_qs_lock); #define uacce_qs_rlock() down_read(&uacce_qs_lock) #define uacce_qs_runlock() up_read(&uacce_qs_lock) #define uacce_qs_wlock() down_write(&uacce_qs_lock) #define uacce_qs_wunlock() up_write(&uacce_qs_lock) -#else -static DEFINE_RWLOCK(uacce_qs_lock); -#define uacce_qs_rlock() read_lock_irq(&uacce_qs_lock) -#define uacce_qs_runlock() read_unlock_irq(&uacce_qs_lock) -#define uacce_qs_wlock() write_lock_irq(&uacce_qs_lock) -#define uacce_qs_wunlock() write_unlock_irq(&uacce_qs_lock) -#endif
#define UACCE_RESET_DELAY_MS 10 #define UACCE_FROM_CDEV_ATTR(dev) container_of(dev, struct uacce, dev)
static const struct file_operations uacce_fops; -static long uacce_put_queue(struct uacce_queue *q); +static void uacce_put_queue(struct uacce_queue *q);
/* match with enum uacce_qfrt */ static const char *const qfrt_str[] = { "mmio", - "dko", "dus", "ss", "invalid" @@ -144,12 +124,7 @@ static void uacce_hw_err_destroy(struct uacce *uacce)
const char *uacce_qfrt_str(struct uacce_qfile_region *qfr) { - enum uacce_qfrt type = qfr->type; - - if (type > UACCE_QFRT_INVALID) - type = UACCE_QFRT_INVALID; - - return qfrt_str[type]; + return qfrt_str[qfr->type]; } EXPORT_SYMBOL_GPL(uacce_qfrt_str);
@@ -220,7 +195,6 @@ static bool uacce_q_avail_mmap(struct uacce_queue *q, unsigned int type) break; case UACCE_Q_STARTED: switch (type) { - case UACCE_QFRT_DKO: /* fix me: ss map should be done before start queue */ case UACCE_QFRT_SS: avail = true; @@ -240,183 +214,6 @@ static bool uacce_q_avail_mmap(struct uacce_queue *q, unsigned int type) return avail; }
-static inline int uacce_iommu_map_qfr(struct uacce_queue *q, - struct uacce_qfile_region *qfr) -{ - struct device *dev = q->uacce->pdev; - struct iommu_domain *domain = iommu_get_domain_for_dev(dev); - int i, j, ret; - - if (!domain) - return -ENODEV; - - for (i = 0; i < qfr->nr_pages; i++) { - ret = iommu_map(domain, qfr->iova + i * PAGE_SIZE, - page_to_phys(qfr->pages[i]), - PAGE_SIZE, qfr->prot | q->uacce->prot); - if (ret) { - dev_err(dev, "iommu_map page %i fail %d\n", i, ret); - goto err_with_map_pages; - } - get_page(qfr->pages[i]); - } - - return 0; - -err_with_map_pages: - for (j = i - 1; j >= 0; j--) { - iommu_unmap(domain, qfr->iova + j * PAGE_SIZE, PAGE_SIZE); - put_page(qfr->pages[j]); - } - return ret; -} - -static inline void uacce_iommu_unmap_qfr(struct uacce_queue *q, - struct uacce_qfile_region *qfr) -{ - struct device *dev = q->uacce->pdev; - struct iommu_domain *domain = iommu_get_domain_for_dev(dev); - int i; - - if (!domain || !qfr) - return; - - for (i = qfr->nr_pages - 1; i >= 0; i--) { - iommu_unmap(domain, qfr->iova + i * PAGE_SIZE, PAGE_SIZE); - put_page(qfr->pages[i]); - } -} - -static int uacce_queue_map_qfr(struct uacce_queue *q, - struct uacce_qfile_region *qfr) -{ - /* Only IOMMU mode does this map */ - if (!(qfr->flags & UACCE_QFRF_MAP) || (qfr->flags & UACCE_QFRF_DMA)) - return 0; - - dev_dbg(&q->uacce->dev, "queue map %s qfr(npage=%ld, iova=%pK)\n", - uacce_qfrt_str(qfr), qfr->nr_pages, (void *)qfr->iova); - - return uacce_iommu_map_qfr(q, qfr); -} - -static void uacce_queue_unmap_qfr(struct uacce_queue *q, - struct uacce_qfile_region *qfr) -{ - if (!(qfr->flags & UACCE_QFRF_MAP) || (qfr->flags & UACCE_QFRF_DMA)) - return; - - dev_dbg(&q->uacce->dev, "queue map %s qfr(npage=%ld, iova=%pK)\n", - uacce_qfrt_str(qfr), qfr->nr_pages, (void *)qfr->iova); - - uacce_iommu_unmap_qfr(q, qfr); -} - -#ifndef CONFIG_UACCE_FIX_MMAP -static vm_fault_t uacce_shm_vm_fault(struct vm_fault *vmf) -{ - struct vm_area_struct *vma = vmf->vma; - struct uacce_qfile_region *qfr; - pgoff_t page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT; - vm_fault_t ret; - - uacce_qs_rlock(); - - qfr = vma->vm_private_data; - if (!qfr) { - pr_info("this page is not valid to user space\n"); - ret = VM_FAULT_SIGBUS; - goto out; - } - - pr_debug("uacce: fault on %s qfr page %ld/%ld\n", uacce_qfrt_str(qfr), - page_offset, qfr->nr_pages); - - if (page_offset >= qfr->nr_pages) { - ret = VM_FAULT_SIGBUS; - goto out; - } - - get_page(qfr->pages[page_offset]); - vmf->page = qfr->pages[page_offset]; - ret = 0; - -out: - uacce_qs_runlock(); - return ret; -} - -static const struct vm_operations_struct uacce_shm_vm_ops = { - .fault = uacce_shm_vm_fault, -}; -#endif - -static int uacce_qfr_alloc_pages(struct uacce_qfile_region *qfr) -{ - gfp_t gfp_mask = GFP_ATOMIC | __GFP_ZERO; - int i, j; - - qfr->pages = kcalloc(qfr->nr_pages, sizeof(*qfr->pages), gfp_mask); - if (!qfr->pages) - return -ENOMEM; - - for (i = 0; i < qfr->nr_pages; i++) { - qfr->pages[i] = alloc_page(gfp_mask); - if (!qfr->pages[i]) - goto err_with_pages; - } - - return 0; - -err_with_pages: - for (j = i - 1; j >= 0; j--) - put_page(qfr->pages[j]); - - kfree(qfr->pages); - return -ENOMEM; -} - -static void uacce_qfr_free_pages(struct uacce_qfile_region *qfr) -{ - int i; - - for (i = 0; i < qfr->nr_pages; i++) - put_page(qfr->pages[i]); - - kfree(qfr->pages); -} - -static inline int uacce_queue_mmap_qfr(struct uacce_queue *q, - struct uacce_qfile_region *qfr, - struct vm_area_struct *vma) -{ -#ifdef CONFIG_UACCE_FIX_MMAP - int i, ret; - - if (qfr->nr_pages) - dev_dbg(q->uacce->pdev, "mmap qfr (page ref=%d)\n", - page_ref_count(qfr->pages[0])); - for (i = 0; i < qfr->nr_pages; i++) { - get_page(qfr->pages[i]); - ret = remap_pfn_range(vma, vma->vm_start + i * PAGE_SIZE, - page_to_pfn(qfr->pages[i]), PAGE_SIZE, - vma->vm_page_prot); - if (ret) { - dev_err(q->uacce->pdev, - "remap_pfm_range fail(nr_pgs=%lx)!\n", - qfr->nr_pages); - return ret; - } - } - -#else - vma->vm_private_data = qfr; - vma->vm_ops = &uacce_shm_vm_ops; -#endif - - return 0; -} - static void uacce_free_dma_buffers(struct uacce_queue *q) { struct uacce_qfile_region *qfr = q->qfrs[UACCE_QFRT_SS]; @@ -603,31 +400,18 @@ static int uacce_mmap_region(u32 flags, struct uacce_queue *q, struct uacce_qfile_region *qfr) { struct uacce *uacce = q->uacce; - int ret; + int ret = 0;
if (flags & UACCE_QFRF_SELFMT) return uacce->ops->mmap(q, vma, qfr);
- /* map to device */ - if (!(flags & UACCE_QFRF_SELFMT)) { - ret = uacce_queue_map_qfr(q, qfr); - if (ret) - return ret; - } - /* mmap to user space */ if (flags & UACCE_QFRF_MMAP) { if (flags & UACCE_QFRF_DMA) ret = uacce_mmap_dma_buffers(q, vma); - else - ret = uacce_queue_mmap_qfr(q, qfr, vma); - if (ret) { - uacce_queue_unmap_qfr(q, qfr); - return ret; - } }
- return 0; + return ret; }
static struct @@ -662,14 +446,7 @@ uacce_qfile_region *uacce_create_region(struct uacce_queue *q, uacce_free_dma_buffers(q); goto err_with_qfr; } - } else if (!(flags & UACCE_QFRF_SELFMT)) { - ret = uacce_qfr_alloc_pages(qfr); - if (ret) { - dev_err(uacce->pdev, "alloc page fail!\n"); - goto err_with_qfr; - } } - ret = uacce_mmap_region(flags, q, vma, qfr); if (ret) { dev_err(uacce->pdev, "uacce mmap region fail!\n"); @@ -681,8 +458,6 @@ uacce_qfile_region *uacce_create_region(struct uacce_queue *q, err_with_pages: if (flags & UACCE_QFRF_DMA) uacce_free_dma_buffers(q); - else if (!(flags & UACCE_QFRF_SELFMT)) - uacce_qfr_free_pages(qfr); err_with_qfr: kfree(qfr); q->qfrs[type] = NULL; @@ -698,20 +473,9 @@ uacce_qfile_region *uacce_create_region(struct uacce_queue *q, static void uacce_destroy_region(struct uacce_queue *q, struct uacce_qfile_region *qfr) { - struct uacce *uacce = q->uacce; - - if (qfr->flags & UACCE_QFRF_DMA) { + if (qfr->flags & UACCE_QFRF_DMA) uacce_free_dma_buffers(q); - } else if (qfr->pages) { - if (qfr->flags & UACCE_QFRF_KMAP && qfr->kaddr) { - dev_dbg(uacce->pdev, "vunmap qfr %s\n", - uacce_qfrt_str(qfr)); - vunmap(qfr->kaddr); - qfr->kaddr = NULL; - }
- uacce_qfr_free_pages(qfr); - } if (qfr != &noiommu_ss_default_qfr) kfree(qfr); } @@ -753,10 +517,6 @@ static long uacce_cmd_share_qfr(struct uacce_queue *src, int fd) goto out_with_fd; }
- ret = uacce_queue_map_qfr(tgt, src->qfrs[UACCE_QFRT_SS]); - if (ret) - goto out_with_fd; - /* In No-IOMMU mode, taget queue uses default SS qfr */ if (src->qfrs[UACCE_QFRT_SS]->flags & UACCE_QFRF_DMA) { tgt->qfrs[UACCE_QFRT_SS] = &noiommu_ss_default_qfr; @@ -774,51 +534,18 @@ static long uacce_cmd_share_qfr(struct uacce_queue *src, int fd) static int uacce_start_queue(struct uacce_queue *q) { struct device *dev = &q->uacce->dev; - struct uacce_qfile_region *qfr; - int ret, i, j; - - /* - * map KMAP qfr to kernel - * vmap should be done in non-spinlocked context! - */ - for (i = 0; i < UACCE_QFRT_MAX; i++) { - qfr = q->qfrs[i]; - if (qfr && (qfr->flags & UACCE_QFRF_KMAP) && !qfr->kaddr) { - qfr->kaddr = vmap(qfr->pages, qfr->nr_pages, VM_MAP, - PAGE_KERNEL); - if (!qfr->kaddr) { - ret = -ENOMEM; - dev_err(dev, "fail to kmap %s qfr(%ld pages)\n", - uacce_qfrt_str(qfr), qfr->nr_pages); - goto err_with_vmap; - } - - dev_dbg(dev, "kernel vmap %s qfr(%ld pages) to %pK\n", - uacce_qfrt_str(qfr), qfr->nr_pages, - qfr->kaddr); - } - } + int ret;
ret = q->uacce->ops->start_queue(q); if (ret < 0) { dev_err(dev, "uacce fails to start queue!\n"); - goto err_with_vmap; + return ret; }
dev_dbg(&q->uacce->dev, "uacce queue state switch to STARTED\n"); q->state = UACCE_Q_STARTED;
return 0; - -err_with_vmap: - for (j = i - 1; j >= 0; j--) { - qfr = q->qfrs[j]; - if (qfr && qfr->kaddr) { - vunmap(qfr->kaddr); - qfr->kaddr = NULL; - } - } - return ret; }
static long uacce_get_ss_dma(struct uacce_queue *q, void __user *arg) @@ -888,7 +615,7 @@ static long uacce_fops_unl_ioctl(struct file *filep, ret = uacce_get_ss_dma(q, (void __user *)arg); return ret; case UACCE_CMD_PUT_Q: - ret = uacce_put_queue(q); + uacce_put_queue(q); break; default: uacce_qs_wunlock(); @@ -934,7 +661,7 @@ static int uacce_dev_open_check(struct uacce *uacce) return -EBUSY; }
-static int uacce_queue_drain(struct uacce_queue *q) +static void uacce_queue_drain(struct uacce_queue *q) { struct uacce_qfile_region *qfr; bool is_to_free_region; @@ -955,7 +682,7 @@ static int uacce_queue_drain(struct uacce_queue *q) continue;
is_to_free_region = false; - uacce_queue_unmap_qfr(q, qfr); + if (i == UACCE_QFRT_SS && !(qfr->flags & UACCE_QFRF_DMA)) { list_del(&q->list); if (list_empty(&qfr->qs)) @@ -983,15 +710,13 @@ static int uacce_queue_drain(struct uacce_queue *q) */ kfree(q); atomic_dec(&uacce->ref); - - return 0; }
/* * While user space releases a queue, all the relatives on the queue * should be released imediately by this putting. */ -static long uacce_put_queue(struct uacce_queue *q) +static void uacce_put_queue(struct uacce_queue *q) { struct uacce *uacce = q->uacce;
@@ -1006,8 +731,10 @@ static long uacce_put_queue(struct uacce_queue *q) uacce->ops->put_queue(q);
q->state = UACCE_Q_ZOMBIE; - - return 0; + q->filep->private_data = NULL; + uacce_queue_drain(q); + if (module_refcount(uacce->pdev->driver->owner) > 0) + module_put(uacce->pdev->driver->owner); }
static int uacce_get_queue(struct uacce *uacce, struct file *filep) @@ -1022,7 +749,6 @@ static int uacce_get_queue(struct uacce *uacce, struct file *filep) IOMMU_SVA_FEAT_IOPF, NULL); if (ret) { dev_err(uacce->pdev, "iommu SVA binds fail!\n"); - module_put(uacce->pdev->driver->owner); return ret; } } @@ -1037,6 +763,7 @@ static int uacce_get_queue(struct uacce *uacce, struct file *filep) q->pasid = pasid; q->uacce = uacce; q->mm = current->mm; + q->filep = filep; memset(q->qfrs, 0, sizeof(q->qfrs)); INIT_LIST_HEAD(&q->list); init_waitqueue_head(&q->wait); @@ -1053,7 +780,6 @@ static int uacce_get_queue(struct uacce *uacce, struct file *filep) if (uacce->flags & UACCE_DEV_PASID) iommu_sva_unbind_device(uacce->pdev, pasid); #endif - module_put(uacce->pdev->driver->owner); return ret; }
@@ -1073,16 +799,9 @@ static int uacce_fops_open(struct inode *inode, struct file *filep) return -EINVAL; }
- if (!try_module_get(uacce->pdev->driver->owner)) { - dev_err(uacce->pdev, "uacce try to get module(%s) fail!\n", - uacce->pdev->driver->name); - return -ENODEV; - } ret = uacce_dev_open_check(uacce); - if (ret) { - module_put(uacce->pdev->driver->owner); + if (ret) return ret; - }
ret = uacce_get_queue(uacce, filep); if (ret) { @@ -1090,6 +809,13 @@ static int uacce_fops_open(struct inode *inode, struct file *filep) return ret; }
+ if (!try_module_get(uacce->pdev->driver->owner)) { + uacce_put_queue(filep->private_data); + dev_err(uacce->pdev, "uacce try to get module(%s) fail!\n", + uacce->pdev->driver->name); + return -ENODEV; + } + return 0; }
@@ -1097,7 +823,6 @@ static int uacce_fops_release(struct inode *inode, struct file *filep) { struct uacce_queue *q; struct uacce *uacce; - int ret = 0;
uacce_qs_wlock();
@@ -1109,7 +834,7 @@ static int uacce_fops_release(struct inode *inode, struct file *filep) * fall into this logic as the task exits to prevent hardware * resources leaking. */ - ret = uacce_queue_drain(q); + uacce_queue_drain(q); filep->private_data = NULL; }
@@ -1118,7 +843,7 @@ static int uacce_fops_release(struct inode *inode, struct file *filep) if (q) module_put(uacce->pdev->driver->owner);
- return ret; + return 0; }
static enum uacce_qfrt uacce_get_region_type(struct uacce *uacce, @@ -1143,14 +868,6 @@ static enum uacce_qfrt uacce_get_region_type(struct uacce *uacce, } break;
- case UACCE_QFRT_DKO: - if ((uacce->flags & UACCE_DEV_PASID) || - (uacce->flags & UACCE_DEV_NOIOMMU)) { - dev_err(&uacce->dev, "No DKO as device has PASID or no IOMMU!\n"); - return UACCE_QFRT_INVALID; - } - break; - case UACCE_QFRT_DUS: break;
@@ -1238,36 +955,12 @@ static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma)
switch (type) { case UACCE_QFRT_MMIO: + case UACCE_QFRT_DUS: flags = UACCE_QFRF_SELFMT; break; - case UACCE_QFRT_SS: - flags = UACCE_QFRF_MAP | UACCE_QFRF_MMAP; - - if (uacce->flags & UACCE_DEV_NOIOMMU) - flags |= UACCE_QFRF_DMA; - break; - - case UACCE_QFRT_DKO: - flags = UACCE_QFRF_MAP | UACCE_QFRF_KMAP; - - if (uacce->flags & UACCE_DEV_NOIOMMU) - flags |= UACCE_QFRF_DMA; - break; - - case UACCE_QFRT_DUS: - if (q->uacce->flags & UACCE_DEV_DRVMAP_DUS) { - flags = UACCE_QFRF_SELFMT; - break; - } - - flags = UACCE_QFRF_MAP | UACCE_QFRF_MMAP; - if (q->uacce->flags & UACCE_DEV_KMAP_DUS) - flags |= UACCE_QFRF_KMAP; - if (q->uacce->flags & UACCE_DEV_NOIOMMU) - flags |= UACCE_QFRF_DMA; + flags = UACCE_QFRF_MMAP | UACCE_QFRF_DMA; break; - default: WARN_ON(&uacce->dev); break; @@ -1279,10 +972,6 @@ static int uacce_fops_mmap(struct file *filep, struct vm_area_struct *vma) goto out_with_lock; }
- if (type == UACCE_QFRT_SS && !(qfr->flags & UACCE_QFRF_DMA)) { - INIT_LIST_HEAD(&qfr->qs); - list_add(&q->list, &q->qfrs[type]->qs); - } uacce_qs_wunlock();
return 0; @@ -1554,143 +1243,6 @@ static int uacce_default_start_queue(struct uacce_queue *q) return 0; }
-#ifndef CONFIG_IOMMU_SVA2 -static int uacce_dev_match(struct device *dev, void *data) -{ - if (dev->parent == data) - return -EBUSY; - - return 0; -} - -/* Borrowed from VFIO */ -static bool uacce_iommu_has_sw_msi(struct iommu_group *group, - phys_addr_t *base) -{ - struct iommu_resv_region *region, *next; - struct list_head group_resv_regions; - bool ret = false; - - INIT_LIST_HEAD(&group_resv_regions); - iommu_get_group_resv_regions(group, &group_resv_regions); - list_for_each_entry(region, &group_resv_regions, list) { - pr_debug("uacce: find a resv region (%d) on %llx\n", - region->type, region->start); - - /* - * The presence of any 'real' MSI regions should take - * precedence over the software-managed one if the - * IOMMU driver happens to advertise both types. - */ - if (region->type == IOMMU_RESV_MSI) { - ret = false; - break; - } - - if (region->type == IOMMU_RESV_SW_MSI) { - *base = region->start; - ret = true; - } - } - list_for_each_entry_safe(region, next, &group_resv_regions, list) - kfree(region); - return ret; -} - -static int uacce_set_iommu_domain(struct uacce *uacce) -{ - struct device *dev = uacce->pdev; - struct iommu_domain *domain; - struct iommu_group *group; - phys_addr_t resv_msi_base = 0; - bool resv_msi; - int ret; - - if (uacce->flags & UACCE_DEV_NOIOMMU) - return 0; - - /* - * We don't support multiple register for the same dev in RFC version , - * will add it in formal version - */ - ret = class_for_each_device(uacce_class, NULL, dev, uacce_dev_match); - if (ret) { - dev_err(dev, "no matching device in uacce class!\n"); - return ret; - } - - /* allocate and attach a unmanged domain */ - domain = iommu_domain_alloc(dev->bus); - if (!domain) { - dev_err(dev, "fail to allocate domain on its bus\n"); - return -ENODEV; - } - - ret = iommu_attach_device(domain, dev); - if (ret) { - dev_err(dev, "iommu attach device failing!\n"); - goto err_with_domain; - } - - if (iommu_capable(dev->bus, IOMMU_CAP_CACHE_COHERENCY)) { - uacce->prot |= IOMMU_CACHE; - dev_dbg(dev, "Enable uacce with c-coherent capa\n"); - } else { - dev_dbg(dev, "Enable uacce without c-coherent capa\n"); - } - - group = iommu_group_get(dev); - if (!group) { - dev_err(dev, "fail to get iommu group!\n"); - ret = -EINVAL; - goto err_with_domain; - } - - resv_msi = uacce_iommu_has_sw_msi(group, &resv_msi_base); - iommu_group_put(group); - - if (resv_msi) { - if (!irq_domain_check_msi_remap() && - !iommu_capable(dev->bus, IOMMU_CAP_INTR_REMAP)) { - dev_err(dev, "No interrupt remapping support!\n"); - ret = -EPERM; - goto err_with_domain; - } - - dev_dbg(dev, "Set resv msi %llx on iommu domain!\n", - (u64)resv_msi_base); - ret = iommu_get_msi_cookie(domain, resv_msi_base); - if (ret) { - dev_err(dev, "fail to get msi cookie from domain!\n"); - goto err_with_domain; - } - } - - return 0; - -err_with_domain: - iommu_domain_free(domain); - return ret; -} - -static void uacce_unset_iommu_domain(struct uacce *uacce) -{ - struct device *dev = uacce->pdev; - struct iommu_domain *domain; - - if (uacce->flags & UACCE_DEV_NOIOMMU) - return; - - domain = iommu_get_domain_for_dev(dev); - if (domain) { - iommu_detach_device(domain, dev); - iommu_domain_free(domain); - } else { - dev_err(dev, "no domain attached to device\n"); - } -} -#endif - /** * uacce_register - register an accelerator * @uacce: the accelerator structure @@ -1729,12 +1281,6 @@ int uacce_register(struct uacce *uacce) uacce->ops->get_available_instances = uacce_default_get_available_instances;
-#ifndef CONFIG_IOMMU_SVA2 - ret = uacce_set_iommu_domain(uacce); - if (ret) - return ret; -#endif - ret = uacce_create_chrdev(uacce); if (ret) { dev_err(dev, "uacce creates cdev fail!\n"); @@ -1779,8 +1325,6 @@ int uacce_unregister(struct uacce *uacce)
#ifdef CONFIG_IOMMU_SVA2 iommu_sva_shutdown_device(uacce->pdev); -#else - uacce_unset_iommu_domain(uacce); #endif uacce_hw_err_destroy(uacce); uacce_destroy_chrdev(uacce); diff --git a/include/linux/uacce.h b/include/linux/uacce.h index a91114b..4171a5b 100644 --- a/include/linux/uacce.h +++ b/include/linux/uacce.h @@ -13,11 +13,9 @@ struct uacce_queue; struct uacce;
-#define UACCE_QFRF_MAP BIT(0) /* map to current queue */ -#define UACCE_QFRF_MMAP BIT(1) /* map to user space */ -#define UACCE_QFRF_KMAP BIT(2) /* map to kernel space */ -#define UACCE_QFRF_DMA BIT(3) /* use dma api for the region */ -#define UACCE_QFRF_SELFMT BIT(4) /* self maintained qfr */ +#define UACCE_QFRF_MMAP BIT(0) /* map to user space */ +#define UACCE_QFRF_DMA BIT(1) /* use dma api for the region */ +#define UACCE_QFRF_SELFMT BIT(2) /* self maintained qfr */
struct uacce_hw_err { struct list_head list; @@ -40,7 +38,6 @@ struct uacce_dma_slice { struct uacce_qfile_region { enum uacce_qfrt type; unsigned long iova; /* iova share between user and device space */ - struct page **pages; unsigned long nr_pages; int prot; unsigned int flags; @@ -103,6 +100,7 @@ struct uacce_queue { struct mm_struct *mm; struct uacce_qfile_region *qfrs[UACCE_QFRT_MAX]; struct fasync_struct *async_queue; + struct file *filep; enum uacce_q_state state; };
diff --git a/include/uapi/linux/uacce.h b/include/uapi/linux/uacce.h index 886e213..7137274 100644 --- a/include/uapi/linux/uacce.h +++ b/include/uapi/linux/uacce.h @@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */ /* Copyright (c) 2018-2019 HiSilicon Limited. */ #ifndef _UAPIUUACCE_H #define _UAPIUUACCE_H @@ -30,15 +30,12 @@ #define UACCE_DEV_NOIOMMU (1 << 0) #define UACCE_DEV_PASID (1 << 1) #define UACCE_DEV_FAULT_FROM_DEV (1 << 2) -#define UACCE_DEV_KMAP_DUS (1 << 3) -#define UACCE_DEV_DRVMAP_DUS (1 << 4)
#define UACCE_DEV_SVA (UACCE_DEV_PASID | UACCE_DEV_FAULT_FROM_DEV) #define UACCE_DEV_SHARE_DOMAIN (0)
/* uacce mode of the driver */ #define UACCE_MODE_NOUACCE 0 /* don't use uacce */ -#define UACCE_MODE_UACCE 1 /* use uacce exclusively */ #define UACCE_MODE_NOIOMMU 2 /* use uacce noiommu mode */
#define UACCE_API_VER_NOIOMMU_SUBFIX "_noiommu" @@ -46,7 +43,6 @@ #define UACCE_QFR_NA ((unsigned long)-1) enum uacce_qfrt { UACCE_QFRT_MMIO = 0, /* device mmio region */ - UACCE_QFRT_DKO, /* device kernel-only */ UACCE_QFRT_DUS, /* device user share */ UACCE_QFRT_SS, /* static share memory */ UACCE_QFRT_MAX,
From: Shengzui You youshengzui@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
-----------------------------
This patch is used to modify hns3 version to 1.9.35.1
Signed-off-by: Shengzui You youshengzui@huawei.com Reviewed-by: Weiwei Deng dengweiwei@huawei.com Reviewed-by: Zhaohui Zhong zhongzhaohui@huawei.com Reviewed-by: Junxing Chen chenjunxin1@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index ae94323..534f0db 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.35.0" +#define HNAE3_MOD_VERSION "1.9.35.1"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index 76f594f..ac02e15 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.35.0" +#define HNS3_CAE_MOD_VERSION "1.9.35.1"
#define CMT_ID_LEN 8 #define RESV_LEN 3 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 2bcbc1a..f2483d4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.35.0" +#define HNS3_MOD_VERSION "1.9.35.1"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 7a7470f..c7ad6fd 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.35.0" +#define HCLGE_MOD_VERSION "1.9.35.1" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index e8ae830..5ae3aa2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.35.0" +#define HCLGEVF_MOD_VERSION "1.9.35.1" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095
From: Shengzui You youshengzui@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
---------------------------------
This patch is used to remove the function of vf check mac address
Signed-off-by: Shengzui You youshengzui@huawei.com Reviewed-by: Weiwei Deng dengweiwei@huawei.com Reviewed-by: Zhaohui Zhong zhongzhaohui@huawei.com Reviewed-by: Junxing Chen chenjunxin1@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 40 ++-------------------- 1 file changed, 3 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index e7bcc92..7af8711 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -8057,36 +8057,6 @@ static int hclge_get_mac_ethertype_cmd_status(struct hclge_dev *hdev, return return_status; }
-static bool hclge_check_vf_mac_exist(struct hclge_vport *vport, int vf_idx, - u8 *mac_addr) -{ - struct hclge_mac_vlan_tbl_entry_cmd req; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u16 egress_port = 0; - int i; - - if (is_zero_ether_addr(mac_addr)) - return false; - - memset(&req, 0, sizeof(req)); - hnae3_set_field(egress_port, HCLGE_MAC_EPORT_VFID_M, - HCLGE_MAC_EPORT_VFID_S, vport->vport_id); - req.egress_port = cpu_to_le16(egress_port); - hclge_prepare_mac_addr(&req, mac_addr, false); - - if (hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false) != -ENOENT) - return true; - - vf_idx += HCLGE_VF_VPORT_START_NUM; - for (i = hdev->num_vmdq_vport + 1; i < hdev->num_alloc_vport; i++) - if (i != vf_idx && - ether_addr_equal(mac_addr, hdev->vport[i].vf_info.mac)) - return true; - - return false; -} - static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, u8 *mac_addr) { @@ -8104,18 +8074,14 @@ static int hclge_set_vf_mac(struct hnae3_handle *handle, int vf, return 0; }
- if (hclge_check_vf_mac_exist(vport, vf, mac_addr)) { - dev_err(&hdev->pdev->dev, "Specified MAC(=%pM) exists!\n", - mac_addr); - return -EEXIST; - } - ether_addr_copy(vport->vf_info.mac, mac_addr); dev_info(&hdev->pdev->dev, "MAC of VF %d has been set to %pM, and it will be reinitialized!\n", vf, mac_addr); + if (test_bit(HCLGE_VPORT_STATE_ALIVE, &vport->state)) + return hclge_inform_reset_assert_to_vf(vport);
- return hclge_inform_reset_assert_to_vf(vport); + return 0; }
static int hclge_add_mgr_tbl(struct hclge_dev *hdev,
From: Zhao Weibo zhaoweibo3@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
----------------------------------------
There may be a out-of-bonds-read if qp type is RC in post send.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Signed-off-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 637f68d..5a112f5 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -334,13 +334,13 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, #endif { struct hns_roce_dev *hr_dev = to_hr_dev(ibqp->device); - struct hns_roce_ah *ah = to_hr_ah(ud_wr(wr)->ah); struct hns_roce_v2_ud_send_wqe *ud_sq_wqe; struct hns_roce_v2_rc_send_wqe *rc_sq_wqe; struct hns_roce_qp *qp = to_hr_qp(ibqp); struct hns_roce_v2_wqe_data_seg *dseg; struct hns_roce_wqe_frmr_seg *fseg; struct device *dev = hr_dev->dev; + struct hns_roce_ah *ah = NULL; struct hns_roce_v2_db sq_db; unsigned int sge_ind; unsigned int owner_bit; @@ -414,6 +414,7 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
/* Corresponding to the QP type, wqe process separately */ if (ibqp->qp_type == IB_QPT_GSI || ibqp->qp_type == IB_QPT_UD) { + ah = to_hr_ah(ud_wr(wr)->ah); ud_sq_wqe = wqe; memset(ud_sq_wqe, 0, sizeof(*ud_sq_wqe));
From: Zhao Weibo zhaoweibo3@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
--------------------------------
This patch add some robust optimize in rdfx.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Signed-off-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c | 8 +++++--- drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c index a2453b3..52cb9f7 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_entry.c @@ -54,7 +54,7 @@ void rdfx_cp_rq_wqe_buf(struct hns_roce_dev *hr_dev,
#ifdef CONFIG_KERNEL_419 static void rdfx_change_sq_buf(const struct ib_send_wr *wr, int atomic_en, - void *dfx_qp_buf, void *dfx_hns_wqe_sge, + void *dfx_qp_buf, const void *dfx_hns_wqe_sge, struct rdfx_sq_info *sq, struct hns_roce_dev *hr_dev, struct hns_roce_qp *qp) @@ -88,10 +88,12 @@ static void rdfx_change_sq_buf(struct ib_send_wr *wr, int atomic_en,
atomic_set(&sq->head, (int)qp->sq.head); sq->head_addr = - (u64)get_send_wqe(qp, qp->sq.head & (qp->sq.wqe_cnt - 1)); + (u64)get_send_wqe(qp, qp->sq.head & + (unsigned int)(qp->sq.wqe_cnt - 1)); atomic_set(&sq->tail, (int)qp->sq.tail); sq->tail_addr = - (u64)get_send_wqe(qp, qp->sq.tail & (qp->sq.wqe_cnt - 1)); + (u64)get_send_wqe(qp, qp->sq.tail & + (unsigned int)(qp->sq.wqe_cnt - 1)); }
#ifdef CONFIG_KERNEL_419 diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c index 322b107..283705a 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c @@ -211,7 +211,7 @@ static int show_cqe(struct rdfx_cq_info *rdfx_cq, int cqe_index) return 0; }
-static inline int rdfx_convert_str(char *str, u32 *val) +static inline int rdfx_convert_str(const char *str, u32 *val) { long long convert_val;
@@ -224,7 +224,7 @@ static inline int rdfx_convert_str(char *str, u32 *val) return 0; }
-static inline int rdfx_show_qp_wqe(char *sq_rq, void *buf, u32 qpn, +static inline int rdfx_show_qp_wqe(const char *sq_rq, void *buf, u32 qpn, struct rdfx_info *rdfx) { struct rdfx_qp_info *rdfx_qp; @@ -401,7 +401,7 @@ static inline int rdfx_show_cq_detail(u32 cqn, struct rdfx_info *rdfx) { struct rdfx_cq_info *rdfx_cq = NULL; struct hns_roce_dev *hr_dev; - struct hns_roce_cq *cq; + struct hns_roce_cq *cq = NULL;
hr_dev = (struct hns_roce_dev *)rdfx->priv;
@@ -414,7 +414,7 @@ static inline int rdfx_show_cq_detail(u32 cqn, struct rdfx_info *rdfx) atomic_read(&rdfx->cq.top_cq_index));
cq = radix_tree_lookup(&hr_dev->cq_table.tree, - cqn & (hr_dev->caps.num_cqs - 1)); + cqn & (u32)(hr_dev->caps.num_cqs - 1)); if (cq) pr_info("arm_sn_cnt : 0x%x\n", cq->arm_sn);
From: Gao Xun gaoxun3@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
--------------------------------
This patch is dedicated to improve the reliability of code.
Reviewed-by: Hu Chunzhi huchunzhi@huawei.com Reviewed-by: Wang Lin wanglin137@huawei.com Reviewed-by: Zhao Weibo zhaoweibo3@huawei.com Signed-off-by: Gao Xun gaoxun3@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/infiniband/hw/hns/Makefile | 9 +--- drivers/infiniband/hw/hns/hns_roce_device.h | 4 +- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 42 --------------- drivers/infiniband/hw/hns/hns_roce_main.c | 10 +++- drivers/infiniband/hw/hns/hns_roce_mr.c | 8 --- .../hw/hns/roce-customer/hns_hw_v2_test.c | 61 ---------------------- .../hw/hns/roce-customer/hns_hw_v2_test.h | 10 ---- .../hw/hns/roce-customer/hns_roce_test.c | 18 ------- .../hw/hns/roce-customer/hns_roce_test.h | 8 --- .../infiniband/hw/hns/roce-customer/rdfx_hw_v2.c | 16 +++--- .../infiniband/hw/hns/roce-customer/rdfx_intf.c | 7 ++- .../infiniband/hw/hns/roce-customer/rdfx_main.c | 22 ++++++-- .../infiniband/hw/hns/roce-customer/rdfx_sysfs.c | 22 ++++---- 13 files changed, 55 insertions(+), 182 deletions(-) delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.c delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.h delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_roce_test.c delete mode 100644 drivers/infiniband/hw/hns/roce-customer/hns_roce_test.h
diff --git a/drivers/infiniband/hw/hns/Makefile b/drivers/infiniband/hw/hns/Makefile index 5c383dd..2a499e8 100644 --- a/drivers/infiniband/hw/hns/Makefile +++ b/drivers/infiniband/hw/hns/Makefile @@ -11,20 +11,15 @@ ifeq ($(CONFIG_INFINIBAND_HNS_DFX), m) ccflags-y += -DCONFIG_INFINIBAND_HNS_DFX endif
-ifeq ($(CONFIG_INFINIBAND_HNS_TEST), m) - ccflags-y += -DCONFIG_INFINIBAND_HNS_TEST -endif - obj-$(CONFIG_INFINIBAND_HNS) += hns-roce.o hns-roce-objs := hns_roce_main.o hns_roce_cmd.o hns_roce_pd.o \ hns_roce_ah.o hns_roce_hem.o hns_roce_mr.o hns_roce_qp.o \ hns_roce_sysfs.o \ - hns_roce_cq.o hns_roce_alloc.o hns_roce_db.o hns_roce_srq.o hns_roce_restrack.o -hns-roce-$(CONFIG_INFINIBAND_HNS_TEST) += roce-customer/rdfx_intf.o roce-customer/rdfx_entry.o roce-customer/hns_roce_test.o + hns_roce_cq.o hns_roce_alloc.o hns_roce_db.o hns_roce_srq.o hns_roce_restrack.o \ + roce-customer/rdfx_intf.o roce-customer/rdfx_entry.o obj-$(CONFIG_INFINIBAND_HNS_HIP06) += hns-roce-hw-v1.o hns-roce-hw-v1-objs := hns_roce_hw_v1.o obj-$(CONFIG_INFINIBAND_HNS_HIP08) += hns-roce-hw-v2.o hns-roce-hw-v2-objs := hns_roce_hw_v2.o hns_roce_hw_v2_dfx.o hns_roce_hw_sysfs_v2.o -hns-roce-hw-v2-$(CONFIG_INFINIBAND_HNS_TEST) += roce-customer/hns_hw_v2_test.o obj-$(CONFIG_INFINIBAND_HNS_DFX) += hns-roce-cae.o hns-roce-cae-$(CONFIG_INFINIBAND_HNS_DFX) := roce-customer/rdfx_sysfs.o roce-customer/rdfx_hw_v2.o roce-customer/rdfx_main.o diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h index 5905d3b..2be69a6 100644 --- a/drivers/infiniband/hw/hns/hns_roce_device.h +++ b/drivers/infiniband/hw/hns/hns_roce_device.h @@ -1569,7 +1569,7 @@ enum { RDFX_FUNC_REG_UMM_MR, RDFX_FUNC_DEREG_UMM_MR, }; -void alloc_rdfx_info(struct hns_roce_dev *hr_dev); +int alloc_rdfx_info(struct hns_roce_dev *hr_dev); void rdfx_set_dev_name(struct hns_roce_dev *hr_dev); void free_rdfx_info(struct hns_roce_dev *hr_dev); void rdfx_func_cnt(struct hns_roce_dev *hr_dev, int func); @@ -1625,7 +1625,7 @@ void rdfx_cp_cqe_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, void rdfx_set_rdfx_cq_ci(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq); #else -#define alloc_rdfx_info(hr_dev) +#define alloc_rdfx_info(hr_dev) (0) #define rdfx_set_dev_name(hr_dev) #define free_rdfx_info(hr_dev) #define rdfx_func_cnt(hr_dev, func) diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 5a112f5..b77fef6 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c @@ -47,9 +47,6 @@ #include "hns_roce_hem.h" #include "hns_roce_hw_v2.h"
-#ifdef CONFIG_INFINIBAND_HNS_TEST -#include "hns_hw_v2_test.h" -#endif static int loopback;
static bool qp_lock = true; @@ -374,8 +371,6 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, }
v2_spin_lock_irqsave(qp_lock, &qp->sq.lock, &flags); - rdfx_func_cnt(hr_dev, RDFX_FUNC_POST_SEND); - rdfx_get_rdfx_qp(hr_dev, ibqp->qp_num);
if (hr_dev->state >= HNS_ROCE_DEVICE_STATE_RST_DOWN) { *bad_wr = wr; @@ -681,8 +676,6 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, if (ret) goto out; } - - rdfx_cp_sq_wqe_buf(hr_dev, qp, ind, wqe, rc_sq_wqe, wr); hns_roce_dfx_record_post_send_wqe(qp, wr);
ind++; @@ -727,8 +720,6 @@ static int hns_roce_v2_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, qp->sq_next_wqe = ind; qp->next_sge = sge_ind; } - rdfx_inc_sq_db_cnt(hr_dev, ibqp->qp_num); - rdfx_put_rdfx_qp(hr_dev, ibqp->qp_num); qp->dfx_cnt[HNS_ROCE_QP_DFX_POST_SEND]++;
v2_spin_unlock_irqrestore(qp_lock, &qp->sq.lock, &flags); @@ -776,9 +767,6 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, return -EINVAL; }
- rdfx_func_cnt(hr_dev, RDFX_FUNC_POST_RECV); - rdfx_get_rdfx_qp(hr_dev, ibqp->qp_num); - for (nreq = 0; wr; ++nreq, wr = wr->next) { if (hns_roce_wq_overflow(&hr_qp->rq, nreq, hr_qp->ibqp.recv_cq)) { @@ -823,9 +811,6 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, }
hr_qp->rq.wrid[ind] = wr->wr_id; - - rdfx_cp_rq_wqe_buf(hr_dev, hr_qp, ind, wqe, wr); - ind = (ind + 1) & (hr_qp->rq.wqe_cnt - 1); }
@@ -842,11 +827,8 @@ static int hns_roce_v2_post_recv(struct ib_qp *ibqp, struct ib_recv_wr *wr, } else { *hr_qp->rdb.db_record = hr_qp->rq.head & 0xffff; } - - rdfx_inc_rq_db_cnt(hr_dev, hr_qp->qpn); }
- rdfx_put_rdfx_qp(hr_dev, hr_qp->qpn); hr_qp->dfx_cnt[HNS_ROCE_QP_DFX_POST_RECV]++;
v2_spin_unlock_irqrestore(qp_lock, &hr_qp->rq.lock, &flags); @@ -3110,9 +3092,6 @@ static void hns_roce_v2_write_cqc(struct hns_roce_dev *hr_dev, unsigned int cq_period = HNS_ROCE_V2_CQ_DEFAULT_INTERVAL; unsigned int cq_max_cnt = HNS_ROCE_V2_CQ_DEFAULT_BURST_NUM;
-#ifdef CONFIG_INFINIBAND_HNS_TEST - test_set_cqc_param(&cq_period, &cq_max_cnt); -#endif cq_context = mb_buf; memset(cq_context, 0, sizeof(*cq_context));
@@ -3194,9 +3173,6 @@ static int hns_roce_v2_req_notify_cq(struct ib_cq *ibcq, doorbell[0] = 0; doorbell[1] = 0;
- rdfx_func_cnt(to_hr_dev(ibcq->device), RDFX_FUNC_REQ_NOTIFY_CQ); - rdfx_inc_arm_cq_cnt(to_hr_dev(ibcq->device), hr_cq, flags); - notification_flag = (flags & IB_CQ_SOLICITED_MASK) == IB_CQ_SOLICITED ? V2_CQ_DB_REQ_NOT : V2_CQ_DB_REQ_NOT_SOL; /* @@ -3597,24 +3573,14 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries,
v2_spin_lock_irqsave(cq_lock, &hr_cq->lock, &flags);
- rdfx_func_cnt(hr_dev, RDFX_FUNC_POLL_CQ); - rdfx_get_rdfx_cq(hr_dev, hr_cq->cqn); - if (hr_dev->state == HNS_ROCE_DEVICE_STATE_UNINIT) { hns_roce_v2_poll_sw_cq(hr_cq, num_entries, wc, &npolled); goto out; }
for (npolled = 0; npolled < num_entries; ++npolled) { - rdfx_cp_cqe_buf(hr_dev, hr_cq, - get_sw_cqe_v2(hr_cq, hr_cq->cons_index)); - if (hns_roce_v2_poll_one(hr_cq, &cur_qp, wc + npolled)) break; - - rdfx_set_cqe_info(hr_dev, hr_cq, - get_cqe_v2(hr_cq, (hr_cq->cons_index - 1) & - (hr_cq->ib_cq.cqe))); }
if (npolled) { @@ -3623,10 +3589,7 @@ static int hns_roce_v2_poll_cq(struct ib_cq *ibcq, int num_entries, hns_roce_v2_cq_set_ci(hr_cq, hr_cq->cons_index); }
- rdfx_set_rdfx_cq_ci(hr_dev, hr_cq); - out: - rdfx_put_rdfx_cq(hr_dev, hr_cq->cqn); v2_spin_unlock_irqrestore(cq_lock, &hr_cq->lock, &flags);
return npolled; @@ -5971,8 +5934,6 @@ static int hns_roce_v2_ceq_int(struct hns_roce_dev *hr_dev,
if (eq->cons_index > EQ_DEPTH_COEFF * eq->entries - 1) eq->cons_index = 0; - - rdfx_inc_ceqe_cnt(hr_dev, eq->eqn); }
set_eq_cons_index_v2(eq); @@ -6208,9 +6169,6 @@ static void hns_roce_config_eqc(struct hns_roce_dev *hr_dev, eqc = mb_buf; memset(eqc, 0, sizeof(struct hns_roce_eq_context));
-#ifdef CONFIG_INFINIBAND_HNS_TEST - test_set_eq_param(eq->type_flag, &eq_period, &eq_max_cnt, &eq_arm_st); -#endif if (eq_period * HNS_ROCE_CLOCK_ADJUST > 0xFFFF) { dev_info(hr_dev->dev, "Config eq_period param(0x%x) out of range for config_eqc, adjusted to 65.\n", eq_period); diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index cc57726..74f05e8 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -1398,10 +1398,14 @@ int hns_roce_init(struct hns_roce_dev *hr_dev) int ret; struct device *dev = hr_dev->dev;
- alloc_rdfx_info(hr_dev); - + ret = alloc_rdfx_info(hr_dev); + if (ret) { + dev_err(dev, "Alloc RoCE DFX failed(%d)!\n", ret); + return ret; + } ret = hns_roce_reset(hr_dev); if (ret) { + free_rdfx_info(hr_dev); dev_err(dev, "Reset RoCE engine failed(%d)!\n", ret); return ret; } @@ -1509,6 +1513,8 @@ int hns_roce_init(struct hns_roce_dev *hr_dev) dev_err(dev, "Dereset RoCE engine failed!\n"); }
+ free_rdfx_info(hr_dev); + return ret; } EXPORT_SYMBOL_GPL(hns_roce_init); diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index a2c1142..0802454 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c @@ -39,10 +39,6 @@ #include "hns_roce_cmd.h" #include "hns_roce_hem.h"
-#ifdef CONFIG_INFINIBAND_HNS_TEST -#include "hns_roce_test.h" -#endif - u32 hw_index_to_key(unsigned long ind) { return (u32)(ind >> 24) | (ind << 8); @@ -1013,10 +1009,6 @@ struct ib_mr *hns_roce_get_dma_mr(struct ib_pd *pd, int acc) goto err_free; }
-#ifdef CONFIG_INFINIBAND_HNS_TEST - test_set_mr_access(mr); -#endif - ret = hns_roce_mr_enable(to_hr_dev(pd->device), mr); if (ret) goto err_mr; diff --git a/drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.c b/drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.c deleted file mode 100644 index 46779a64..00000000 --- a/drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.c +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#include <linux/module.h> - -#include "hns_roce_device.h" -#include "hnae3.h" -#include "hns_roce_hw_v2.h" -#include "hns_hw_v2_test.h" - -unsigned int hr_cq_period = 0xa; -module_param(hr_cq_period, uint, 0644); -MODULE_PARM_DESC(hr_cq_period, "timeout of cqe to ceqe"); - -unsigned int hr_cq_max_cnt = 0x1; -module_param(hr_cq_max_cnt, uint, 0644); -MODULE_PARM_DESC(hr_cq_max_cnt, "max cnt of cqe to ceqe"); - -unsigned int hr_ceq_period = 0x1; -module_param(hr_ceq_period, uint, 0644); -MODULE_PARM_DESC(hr_ceq_period, "timeout of ceqe to int"); - -unsigned int hr_aeq_period = 0x1; -module_param(hr_aeq_period, uint, 0644); -MODULE_PARM_DESC(hr_aeq_period, "timeout of aeqe to int"); - -unsigned int hr_ceq_max_cnt = 0x1; -module_param(hr_ceq_max_cnt, uint, 0644); -MODULE_PARM_DESC(hr_ceq_max_cnt, "max cnt of ceqe to int"); - -unsigned int hr_aeq_max_cnt = 0x1; -module_param(hr_aeq_max_cnt, uint, 0644); -MODULE_PARM_DESC(hr_aeq_max_cnt, "max cnt of aeqe to int"); - -unsigned int hr_ceq_arm_st = HNS_ROCE_V2_EQ_ALWAYS_ARMED; -module_param(hr_ceq_arm_st, uint, 0644); -MODULE_PARM_DESC(hr_ceq_arm_st, "arm state of ceq"); - -unsigned int hr_aeq_arm_st = HNS_ROCE_V2_EQ_ALWAYS_ARMED; -module_param(hr_aeq_arm_st, uint, 0644); -MODULE_PARM_DESC(hr_aeq_arm_st, "arm state of aeq"); - -void test_set_cqc_param(unsigned int *period, unsigned int *max_cnt) -{ - *period = hr_cq_period; - *max_cnt = hr_cq_max_cnt; -} - -void test_set_eq_param(int eq_type, unsigned int *eq_period, - unsigned int *eq_max_cnt, unsigned int *eq_arm_st) -{ - if (eq_type == HNS_ROCE_AEQ) { - *eq_period = hr_aeq_period; - *eq_max_cnt = hr_aeq_max_cnt; - *eq_arm_st = hr_aeq_arm_st; - } else { - *eq_period = hr_ceq_period; - *eq_max_cnt = hr_ceq_max_cnt; - *eq_arm_st = hr_ceq_arm_st; - } -} diff --git a/drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.h b/drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.h deleted file mode 100644 index 7642869..00000000 --- a/drivers/infiniband/hw/hns/roce-customer/hns_hw_v2_test.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef _HNS_HW_V2_TEST_H -#define _HNS_HW_V2_TEST_H - -void test_set_cqc_param(unsigned int *period, unsigned int *max_cnt); -void test_set_eq_param(int eq_type, unsigned int *eq_period, - unsigned int *eq_max_cnt, unsigned int *eq_arm_st); - -#endif diff --git a/drivers/infiniband/hw/hns/roce-customer/hns_roce_test.c b/drivers/infiniband/hw/hns/roce-customer/hns_roce_test.c deleted file mode 100644 index 4624d0b..00000000 --- a/drivers/infiniband/hw/hns/roce-customer/hns_roce_test.c +++ /dev/null @@ -1,18 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#include <linux/module.h> - -#include "hns_roce_device.h" -#include "hns_roce_test.h" - -unsigned int int_mr_access = 7; -module_param(int_mr_access, uint, 0644); -MODULE_PARM_DESC(int_mr_access, "Mr access for ft test"); - -void test_set_mr_access(struct hns_roce_mr *mr) -{ - if (mr->key > 0) - mr->access = int_mr_access; -} - diff --git a/drivers/infiniband/hw/hns/roce-customer/hns_roce_test.h b/drivers/infiniband/hw/hns/roce-customer/hns_roce_test.h deleted file mode 100644 index 527efa3..00000000 --- a/drivers/infiniband/hw/hns/roce-customer/hns_roce_test.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef _HNS_ROCE_TEST_H -#define _HNS_ROCE_TEST_H - -void test_set_mr_access(struct hns_roce_mr *mr); - -#endif diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c index aed4a13..08f5d237 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_hw_v2.c @@ -214,9 +214,9 @@ static int rdfx_v2_pkt_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_cmq_desc desc_cnp_rx = {0}; struct rdfx_query_cnp_rx_cnt *resp_cnp_rx = (struct rdfx_query_cnp_rx_cnt *)desc_cnp_rx.data; - int ret; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; + int ret; int i;
if (!parg_getopt(buf, "c", str)) @@ -355,7 +355,7 @@ static int rdfx_v2_ceqc_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_dev *hr_dev; long long convert_val; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; u32 ceqn = 0; int ret;
@@ -433,7 +433,7 @@ static int rdfx_v2_aeqc_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_dev *hr_dev; long long convert_val; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; u32 aeqn = 0; int ret;
@@ -534,7 +534,7 @@ static int rdfx_v2_qpc_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_dev *hr_dev; long long convert_val; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; u32 qpn = 0; u64 bt0_ba = 0; u64 bt1_ba = 0; @@ -637,7 +637,7 @@ static int rdfx_v2_cqc_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_dev *hr_dev; long long convert_val; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; u64 bt0_ba = 0; u64 bt1_ba = 0; u32 cqn = 0; @@ -740,7 +740,7 @@ static int rdfx_v2_srqc_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_dev *hr_dev; long long convert_val; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; u64 bt0_ba = 0; u64 bt1_ba = 0; u32 srqn = 0; @@ -843,7 +843,7 @@ static int rdfx_v2_mpt_store(const char *p_buf, struct rdfx_info *rdfx) struct hns_roce_dev *hr_dev; long long convert_val; char *buf = (char *)p_buf; - char str[DEF_OPT_STR_LEN]; + char str[DEF_OPT_STR_LEN] = {0}; u64 bt0_ba = 0; u64 bt1_ba = 0; int key; diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_intf.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_intf.c index a7c7592..7561e0ef 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_intf.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_intf.c @@ -80,13 +80,13 @@ static void mr_release(struct kref *ref) kfree(rdfx_mr); }
-void alloc_rdfx_info(struct hns_roce_dev *hr_dev) +int alloc_rdfx_info(struct hns_roce_dev *hr_dev) { struct rdfx_info *rdfx;
rdfx = kzalloc(sizeof(*rdfx), GFP_KERNEL); if (ZERO_OR_NULL_PTR(rdfx)) - return; + return -ENOMEM;
hr_dev->dfx_priv = rdfx; rdfx->priv = hr_dev; @@ -104,6 +104,7 @@ void alloc_rdfx_info(struct hns_roce_dev *hr_dev) spin_lock_init(&rdfx->mr.mr_lock); spin_lock_init(&rdfx->eq.eq_lock);
+ return 0; }
void rdfx_set_dev_name(struct hns_roce_dev *hr_dev) @@ -173,6 +174,8 @@ void free_rdfx_info(struct hns_roce_dev *hr_dev) { struct rdfx_info *rdfx = (struct rdfx_info *)hr_dev->dfx_priv;
+ if (!rdfx) + return; rdfx_clean_list(rdfx); kfree(rdfx); hr_dev->dfx_priv = NULL; diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c index a28bc0f..3d7d863 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_main.c @@ -76,12 +76,15 @@ int parg_getopt(char *input, char *optstring, char *parg) p++; cnt++; } - if (cnt >= DEF_OPT_STR_LEN) + if (cnt >= DEF_OPT_STR_LEN) { + kfree(_input); return -EINVAL; + } *p = '\0'; p -= cnt; strcpy(parg, p); kfree(_input); + return 0; }
@@ -196,7 +199,7 @@ struct rdfx_info *rdfx_find_rdfx_info(char *dev_name) int i;
if (!strlen(dev_name)) - return rdfx_top_info_list[0].rdfx; + return NULL;
for (i = 0; i < MAX_IB_DEV; i++) { if (!rdfx_top_info_list[i].dev) @@ -284,8 +287,11 @@ static void rdfx_add_device(struct ib_device *ib_dev)
ops = (rdfx_top_info_list[i].rdfx)->ops; ret = ops->add_sysfs(rdfx_top_info_list[i].rdfx); - if (ret) + if (ret) { + rdfx_top_info_list[i].rdfx = NULL; + rdfx_top_info_list[i].dev = NULL; pr_err("rdfx add hw sysfs failed\n"); + } }
static void rdfx_remove_device(struct ib_device *ib_dev, void *client_data) @@ -324,8 +330,16 @@ static int __init rdfx_init(void)
/*default content:/sys/class */ drv_class = class_create(THIS_MODULE, DFX_DEVICE_NAME); + if (IS_ERR(drv_class)) { + pr_err("rdfx register client failed\n"); + goto class_create_failed; + } drv_device = device_create(drv_class, NULL, MKDEV(major, 0), NULL, DFX_DEVICE_NAME); + if (IS_ERR(drv_device)) { + pr_err("rdfx register device failed\n"); + goto device_regist_failed; + }
memset(rdfx_top_info_list, 0, sizeof(rdfx_top_info_list));
@@ -348,7 +362,9 @@ static int __init rdfx_init(void) ib_unregister_client(&rdfx_client); register_client_failed: device_unregister(drv_device); +device_regist_failed: class_destroy(drv_class); +class_create_failed: unregister_chrdev(major, DFX_DEVICE_NAME);
return ret; diff --git a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c index 283705a..25f7396 100644 --- a/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c +++ b/drivers/infiniband/hw/hns/roce-customer/rdfx_sysfs.c @@ -39,8 +39,8 @@ static int rdfx_pd_store(const char *p_buf) char *buf = (char *)p_buf; struct rdfx_info *rdfx; long long convert_val; - char dev_name[DEF_OPT_STR_LEN]; - char str[DEF_OPT_STR_LEN]; + char dev_name[DEF_OPT_STR_LEN] = {0}; + char str[DEF_OPT_STR_LEN] = {0}; u32 pdn = 0;
parg_getopt(buf, "d:", dev_name); @@ -121,14 +121,14 @@ static int show_qp_detail(struct rdfx_qp_info *rdfx_qp)
pr_info("\n"); - pr_info("sig_wqe_cnt bd_cnt inline_cnt\n"); + pr_info("sig_wqe_cnt db_cnt inline_cnt\n"); pr_info(" 0x%x 0x%x 0x%x\n", atomic_read(&rdfx_qp->sq.sig_wqe_cnt), atomic_read(&rdfx_qp->sq.db_cnt), atomic_read(&rdfx_qp->sq.inline_cnt)); pr_info("\n"); pr_info("***************** RQ INFO *****************\n"); - pr_info("rq_wqe_cnt bd_cnt inline_cnt\n"); + pr_info("rq_wqe_cnt db_cnt inline_cnt\n"); pr_info(" 0x%x 0x%x 0x%x\n", atomic_read(&rdfx_qp->rq.rq_wqe_cnt), atomic_read(&rdfx_qp->rq.db_cnt), @@ -432,8 +432,8 @@ static int rdfx_cq_store(const char *p_buf) struct rdfx_cq_info *rdfx_cq = NULL; struct rdfx_info *rdfx; char *buf = (char *)p_buf; - char dev_name[DEF_OPT_STR_LEN]; - char str[DEF_OPT_STR_LEN]; + char dev_name[DEF_OPT_STR_LEN] = {0}; + char str[DEF_OPT_STR_LEN] = {0}; u32 cqe_index = 0; u32 cqn = 0;
@@ -482,8 +482,8 @@ static int rdfx_mr_store(const char *p_buf) char *buf = (char *)p_buf; struct rdfx_info *rdfx; long long convert_val; - char dev_name[DEF_OPT_STR_LEN]; - char str[DEF_OPT_STR_LEN]; + char dev_name[DEF_OPT_STR_LEN] = {0}; + char str[DEF_OPT_STR_LEN] = {0}; u32 key;
parg_getopt(buf, "d:", dev_name); @@ -534,8 +534,8 @@ static int rdfx_eq_store(const char *p_buf) long long convert_val; char *buf = (char *)p_buf; struct rdfx_info *rdfx; - char dev_name[DEF_OPT_STR_LEN]; - char str[DEF_OPT_STR_LEN]; + char dev_name[DEF_OPT_STR_LEN] = {0}; + char str[DEF_OPT_STR_LEN] = {0}; u32 ceqn;
parg_getopt(buf, "d:", dev_name); @@ -566,7 +566,7 @@ static int roce_dev_store(const char *p_buf) { char *buf = (char *)p_buf; struct rdfx_info *rdfx; - char dev_name[DEF_OPT_STR_LEN]; + char dev_name[DEF_OPT_STR_LEN] = {0}; int i;
parg_getopt(buf, "d:", dev_name);
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
1. use sgl API to get sgl dma addr and len Use sgl API to get sgl dma addr and len, this will help to avoid compile error in some platforms. So NEED_SG_DMA_LENGTH can be removed here, which can only be selected by arch code. 2. Fix issue with wrong number of sg elements after dma map We fill the hardware scatter gather list assuming it will need the same number of elements at the original scatterlist. If an IOMMU is involved, then it may well need fewer. The return value of dma_map_sg tells us how many. Probably never caused visible problems as the hardware won't get to the elements that are incorrect before it finds enough space. 3.Remove useless MODULE macros As we already merge hardware sgl into hisi_qm module, remove useless MODULE macros
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/sgl.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/drivers/crypto/hisilicon/sgl.c b/drivers/crypto/hisilicon/sgl.c index 523dab7..badb95d 100644 --- a/drivers/crypto/hisilicon/sgl.c +++ b/drivers/crypto/hisilicon/sgl.c @@ -56,11 +56,7 @@ struct hisi_acc_sgl_pool { struct hisi_acc_sgl_pool *hisi_acc_create_sgl_pool(struct device *dev, u32 count, u32 sge_nr) { - u32 sgl_size; - u32 block_size; - u32 sgl_num_per_block; - u32 block_num; - u32 remain_sgl; + u32 sgl_size, block_size, sgl_num_per_block, block_num, remain_sgl; struct hisi_acc_sgl_pool *pool; struct mem_block *block; u32 i, j; @@ -172,8 +168,8 @@ static struct hisi_acc_hw_sgl *acc_get_sgl(struct hisi_acc_sgl_pool *pool, static void sg_map_to_hw_sg(struct scatterlist *sgl, struct acc_hw_sge *hw_sge) { - hw_sge->buf = sgl->dma_address; - hw_sge->len = cpu_to_le32(sgl->dma_length); + hw_sge->buf = sg_dma_address(sgl); + hw_sge->len = cpu_to_le32(sg_dma_len(sgl)); }
static void inc_hw_sgl_sge(struct hisi_acc_hw_sgl *hw_sgl) @@ -210,20 +206,21 @@ struct hisi_acc_hw_sgl * dma_addr_t curr_sgl_dma = 0; struct acc_hw_sge *curr_hw_sge; struct scatterlist *sg; - int i, ret, sg_n; + int i, sg_n, sg_n_mapped;
if (!dev || !sgl || !pool || !hw_sgl_dma) return ERR_PTR(-EINVAL);
sg_n = sg_nents(sgl); - if (sg_n > pool->sge_nr) { - dev_err(dev, "the number of entries in input scatterlist is bigger than SGL pool setting.\n"); + + sg_n_mapped = dma_map_sg(dev, sgl, sg_n, DMA_BIDIRECTIONAL); + if (!sg_n_mapped) { + dev_err(dev, "DMA mapping for SG error!\n"); return ERR_PTR(-EINVAL); }
- ret = dma_map_sg(dev, sgl, sg_n, DMA_BIDIRECTIONAL); - if (!ret) { - dev_err(dev, "DMA mapping for SG error!\n"); + if (sg_n_mapped > pool->sge_nr) { + dev_err(dev, "the number of entries in input scatterlist is bigger than SGL pool setting.\n"); return ERR_PTR(-EINVAL); }
@@ -236,7 +233,7 @@ struct hisi_acc_hw_sgl * curr_hw_sgl->entry_length_in_sgl = cpu_to_le16(pool->sge_nr); curr_hw_sge = curr_hw_sgl->sge_entries;
- for_each_sg(sgl, sg, sg_n, i) { + for_each_sg(sgl, sg, sg_n_mapped, i) { sg_map_to_hw_sg(sg, curr_hw_sge); inc_hw_sgl_sge(curr_hw_sgl); curr_hw_sge++; @@ -272,7 +269,3 @@ void hisi_acc_sg_buf_unmap(struct device *dev, struct scatterlist *sgl, hw_sgl->entry_length_in_sgl = 0; } EXPORT_SYMBOL_GPL(hisi_acc_sg_buf_unmap); - -MODULE_LICENSE("GPL v2"); -MODULE_AUTHOR("Zhou Wang wangzhou1@hisilicon.com"); -MODULE_DESCRIPTION("HiSilicon Accelerator SGL support");
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
In this patch, we try to use the offset fields in sqe to avoid split scatterlists. We can configure sgl offset fields in ZIP sqe to let ZIP engine read/write sgl data with skipped data. Hence no need to splite the sgl.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/Kconfig | 1 - drivers/crypto/hisilicon/zip/zip_crypto.c | 102 ++++++++---------------------- drivers/crypto/hisilicon/zip/zip_main.c | 3 - 3 files changed, 28 insertions(+), 78 deletions(-)
diff --git a/drivers/crypto/hisilicon/Kconfig b/drivers/crypto/hisilicon/Kconfig index 2060344..95cb605 100644 --- a/drivers/crypto/hisilicon/Kconfig +++ b/drivers/crypto/hisilicon/Kconfig @@ -28,7 +28,6 @@ config CRYPTO_DEV_HISI_ZIP tristate "Support for HISI ZIP Driver" depends on ARM64 && ACPI select CRYPTO_DEV_HISI_QM - select SG_SPLIT help Support for HiSilicon HIP08 ZIP Driver.
diff --git a/drivers/crypto/hisilicon/zip/zip_crypto.c b/drivers/crypto/hisilicon/zip/zip_crypto.c index eec79ae9..b2965ba 100644 --- a/drivers/crypto/hisilicon/zip/zip_crypto.c +++ b/drivers/crypto/hisilicon/zip/zip_crypto.c @@ -5,12 +5,13 @@ #include <linux/dma-mapping.h> #include <linux/scatterlist.h> #include "zip.h" -#ifndef CONFIG_SG_SPLIT -#include <../lib/sg_split.c> -#endif
/* hisi_zip_sqe dw3 */ #define HZIP_BD_STATUS_M GENMASK(7, 0) +/* hisi_zip_sqe dw7 */ +#define HZIP_IN_SGE_DATA_OFFSET_M GENMASK(23, 0) +/* hisi_zip_sqe dw8 */ +#define HZIP_OUT_SGE_DATA_OFFSET_M GENMASK(23, 0) /* hisi_zip_sqe dw9 */ #define HZIP_REQ_TYPE_M GENMASK(7, 0) #define HZIP_ALG_TYPE_ZLIB 0x02 @@ -66,10 +67,8 @@ enum {
struct hisi_zip_req { struct acomp_req *req; - struct scatterlist *src; - struct scatterlist *dst; - size_t slen; - size_t dlen; + u32 sskip; + u32 dskip; struct hisi_acc_hw_sgl *hw_src; struct hisi_acc_hw_sgl *hw_dst; dma_addr_t dma_src; @@ -139,13 +138,15 @@ static void hisi_zip_config_tag(struct hisi_zip_sqe *sqe, u32 tag)
static void hisi_zip_fill_sqe(struct hisi_zip_sqe *sqe, u8 req_type, dma_addr_t s_addr, dma_addr_t d_addr, u32 slen, - u32 dlen) + u32 dlen, u32 sskip, u32 dskip) { memset(sqe, 0, sizeof(struct hisi_zip_sqe));
- sqe->input_data_length = slen; + sqe->input_data_length = slen - sskip; + sqe->dw7 = FIELD_PREP(HZIP_IN_SGE_DATA_OFFSET_M, sskip); + sqe->dw8 = FIELD_PREP(HZIP_OUT_SGE_DATA_OFFSET_M, dskip); sqe->dw9 = FIELD_PREP(HZIP_REQ_TYPE_M, req_type); - sqe->dest_avail_out = dlen; + sqe->dest_avail_out = dlen - dskip; sqe->source_addr_l = lower_32_bits(s_addr); sqe->source_addr_h = upper_32_bits(s_addr); sqe->dest_addr_l = lower_32_bits(d_addr); @@ -348,11 +349,6 @@ static void hisi_zip_remove_req(struct hisi_zip_qp_ctx *qp_ctx, { struct hisi_zip_req_q *req_q = &qp_ctx->req_q;
- if (qp_ctx->qp->alg_type == HZIP_ALG_TYPE_COMP) - kfree(req->dst); - else - kfree(req->src); - write_lock(&req_q->req_lock); clear_bit(req->req_id, req_q->req_bitmap); memset(req, 0, sizeof(struct hisi_zip_req)); @@ -379,8 +375,8 @@ static void hisi_zip_acomp_cb(struct hisi_qp *qp, void *data) } dlen = sqe->produced;
- hisi_acc_sg_buf_unmap(dev, req->src, req->hw_src); - hisi_acc_sg_buf_unmap(dev, req->dst, req->hw_dst); + hisi_acc_sg_buf_unmap(dev, acomp_req->src, req->hw_src); + hisi_acc_sg_buf_unmap(dev, acomp_req->dst, req->hw_dst);
head_size = (qp->alg_type == 0) ? TO_HEAD_SIZE(qp->req_type) : 0; acomp_req->dlen = dlen + head_size; @@ -484,20 +480,6 @@ static int get_comp_head_size(struct scatterlist *src, u8 req_type) } }
-static int get_sg_skip_bytes(struct scatterlist *sgl, size_t bytes, - size_t remains, struct scatterlist **out) -{ -#define SPLIT_NUM 2 - size_t split_sizes[SPLIT_NUM]; - int out_mapped_nents[SPLIT_NUM]; - - split_sizes[0] = bytes; - split_sizes[1] = remains; - - return sg_split(sgl, 0, 0, SPLIT_NUM, split_sizes, out, - out_mapped_nents, GFP_KERNEL); -} - static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, struct hisi_zip_qp_ctx *qp_ctx, size_t head_size, bool is_comp) @@ -505,32 +487,7 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, struct hisi_zip_req_q *req_q = &qp_ctx->req_q; struct hisi_zip_req *q = req_q->q; struct hisi_zip_req *req_cache; - struct scatterlist *out[SPLIT_NUM]; - struct scatterlist *sgl; - size_t len; - u16 req_id; - int ret; - - /* - * remove/add zlib/gzip head, as hardware operations do not include - * comp head. so split req->src to get sgl without heads in acomp, or - * add comp head to req->dst ahead of that hardware output compressed - * data in sgl splited from req->dst without comp head. - */ - if (is_comp) { - sgl = req->dst; - len = req->dlen - head_size; - } else { - sgl = req->src; - len = req->slen - head_size; - } - - ret = get_sg_skip_bytes(sgl, head_size, len, out); - if (ret) - return ERR_PTR(ret); - - /* sgl for comp head is useless, so free it now */ - kfree(out[0]); + int req_id;
write_lock(&req_q->req_lock);
@@ -538,7 +495,6 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, if (req_id >= req_q->size) { write_unlock(&req_q->req_lock); dev_dbg(&qp_ctx->qp->qm->pdev->dev, "req cache is full!\n"); - kfree(out[1]); return ERR_PTR(-EBUSY); } set_bit(req_id, req_q->req_bitmap); @@ -546,16 +502,13 @@ static struct hisi_zip_req *hisi_zip_create_req(struct acomp_req *req, req_cache = q + req_id; req_cache->req_id = req_id; req_cache->req = req; + if (is_comp) { - req_cache->src = req->src; - req_cache->dst = out[1]; - req_cache->slen = req->slen; - req_cache->dlen = req->dlen - head_size; + req_cache->sskip = 0; + req_cache->dskip = head_size; } else { - req_cache->src = out[1]; - req_cache->dst = req->dst; - req_cache->slen = req->slen - head_size; - req_cache->dlen = req->dlen; + req_cache->sskip = head_size; + req_cache->dskip = 0; }
write_unlock(&req_q->req_lock); @@ -567,6 +520,7 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, struct hisi_zip_qp_ctx *qp_ctx) { struct hisi_zip_sqe *zip_sqe = &qp_ctx->zip_sqe; + struct acomp_req *a_req = req->req; struct hisi_qp *qp = qp_ctx->qp; struct device *dev = &qp->qm->pdev->dev; struct hisi_acc_sgl_pool *pool = qp_ctx->sgl_pool; @@ -574,10 +528,10 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, dma_addr_t output; int ret;
- if (!req->src || !req->slen || !req->dst || !req->dlen) + if (!a_req->src || !a_req->slen || !a_req->dst || !a_req->dlen) return -EINVAL;
- req->hw_src = hisi_acc_sg_buf_map_to_hw_sgl(dev, req->src, pool, + req->hw_src = hisi_acc_sg_buf_map_to_hw_sgl(dev, a_req->src, pool, req->req_id << 1, &input); if (IS_ERR(req->hw_src)) { dev_err(dev, "the src map to hw SGL failed!\n"); @@ -585,7 +539,7 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, } req->dma_src = input;
- req->hw_dst = hisi_acc_sg_buf_map_to_hw_sgl(dev, req->dst, pool, + req->hw_dst = hisi_acc_sg_buf_map_to_hw_sgl(dev, a_req->dst, pool, (req->req_id << 1) + 1, &output); if (IS_ERR(req->hw_dst)) { @@ -595,8 +549,8 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, } req->dma_dst = output;
- hisi_zip_fill_sqe(zip_sqe, qp->req_type, input, output, req->slen, - req->dlen); + hisi_zip_fill_sqe(zip_sqe, qp->req_type, input, output, a_req->slen, + a_req->dlen, req->sskip, req->dskip); hisi_zip_config_buf_type(zip_sqe, HZIP_SGL); hisi_zip_config_tag(zip_sqe, req->req_id);
@@ -610,10 +564,10 @@ static int hisi_zip_do_work(struct hisi_zip_req *req, return -EINPROGRESS;
err_unmap_output: - hisi_acc_sg_buf_unmap(dev, req->dst, req->hw_dst); + hisi_acc_sg_buf_unmap(dev, a_req->dst, req->hw_dst); err_unmap_input: - hisi_acc_sg_buf_unmap(dev, req->src, req->hw_src); - return ret; + hisi_acc_sg_buf_unmap(dev, a_req->src, req->hw_src); + return ret; }
static int hisi_zip_acompress(struct acomp_req *acomp_req) diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index d23b66b..5625ca3 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -787,9 +787,6 @@ static void hisi_zip_log_hw_error(struct hisi_qm *qm, u32 err_sts) ((err_val >> HZIP_SRAM_ECC_ERR_NUM_SHIFT) & 0xFF)); - dev_err(dev, "hisi-zip multi ecc sram addr=0x%x\n", - (err_val >> - HZIP_SRAM_ECC_ERR_ADDR_SHIFT)); } } err++;
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch, we try to delete invalid addr print, such as qp dma buf addr info, which we should not expose to others.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Mingqiang Ling lingmingqiang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/qm.c | 29 +++-------------------------- drivers/crypto/hisilicon/sec2/sec_main.c | 2 -- 2 files changed, 3 insertions(+), 28 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 0ffdf64..46d9669 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -376,8 +376,7 @@ static int qm_mb(struct hisi_qm *qm, u8 cmd, dma_addr_t dma_addr, u16 queue, struct qm_mailbox mailbox; int ret = 0;
- dev_dbg(&qm->pdev->dev, "QM mailbox request to q%u: %u-%llx\n", queue, - cmd, dma_addr); + dev_dbg(&qm->pdev->dev, "QM mailbox request to q%u: %u\n", queue, cmd);
mailbox.w0 = cpu_to_le16(cmd | (op ? 0x1 << QM_MB_OP_SHIFT : 0) | @@ -1217,8 +1216,7 @@ static struct hisi_qp *hisi_qm_create_qp_nolock(struct hisi_qm *qm, goto err_clear_bit; }
- dev_dbg(dev, "allocate qp dma buf(va=%pK, dma=%pad, size=%zx)\n", - qp->qdma.va, &qp->qdma.dma, qp->qdma.size); + dev_dbg(dev, "allocate qp dma buf size=%zx\n", qp->qdma.size);
qp->qp_id = qp_id; qp->alg_type = alg_type; @@ -1379,7 +1377,6 @@ static int hisi_qm_start_qp_nolock(struct hisi_qp *qp, unsigned long arg) { struct hisi_qm *qm = qp->qm; struct device *dev = &qm->pdev->dev; - enum qm_hw_ver ver = qm->ver; int qp_id = qp->qp_id; int pasid = arg; size_t off = 0; @@ -1408,13 +1405,6 @@ static int hisi_qm_start_qp_nolock(struct hisi_qp *qp, unsigned long arg) QP_INIT_BUF(qp, sqe, qm->sqe_size * QM_Q_DEPTH); QP_INIT_BUF(qp, cqe, sizeof(struct cqe) * QM_Q_DEPTH);
- dev_dbg(dev, "init qp buffer(v%d):\n" - " sqe (%pK, %lx)\n" - " cqe (%pK, %lx)\n", - ver, - qp->sqe, (unsigned long)qp->sqe_dma, - qp->cqe, (unsigned long)qp->cqe_dma); - ret = qm_qp_ctx_cfg(qp, qp_id, pasid); if (ret) return ret; @@ -2176,8 +2166,6 @@ static int qm_eq_aeq_ctx_cfg(struct hisi_qm *qm)
static int __hisi_qm_start(struct hisi_qm *qm) { - struct pci_dev *pdev = qm->pdev; - struct device *dev = &pdev->dev; size_t off = 0; int ret;
@@ -2212,16 +2200,6 @@ static int __hisi_qm_start(struct hisi_qm *qm) qm->reserve_dma = qm->qdma.dma + off; off += PAGE_SIZE;
- dev_dbg(dev, "init qm buffer:\n" - " eqe (%pK, %lx)\n" - " aeqe (%pK, %lx)\n" - " sqc (%pK, %lx)\n" - " cqc (%pK, %lx)\n", - qm->eqe, (unsigned long)qm->eqe_dma, - qm->aeqe, (unsigned long)qm->aeqe_dma, - qm->sqc, (unsigned long)qm->sqc_dma, - qm->cqc, (unsigned long)qm->cqc_dma); - ret = qm_eq_aeq_ctx_cfg(qm); if (ret) return ret; @@ -2357,8 +2335,7 @@ int hisi_qm_start(struct hisi_qm *qm) qm->qdma.va = dma_alloc_coherent(dev, qm->qdma.size, &qm->qdma.dma, GFP_ATOMIC | __GFP_ZERO); - dev_dbg(dev, "allocate qm dma buf(va=%pK, dma=%pad, size=%zx)\n", - qm->qdma.va, &qm->qdma.dma, qm->qdma.size); + dev_dbg(dev, "allocate qm dma buf size=%zx\n", qm->qdma.size); if (!qm->qdma.va) { ret = -ENOMEM; goto err_unlock; diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 53e6d27..49f97ec 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -959,8 +959,6 @@ static void hisi_sec_log_hw_error(struct hisi_qm *qm, u32 err_sts) err_val = readl(qm->io_base + SEC_CORE_ECC_INFO); dev_err(dev, "hisi-sec multi ecc sram num=0x%x\n", SEC_ECC_NUM(err_val)); - dev_err(dev, "hisi-sec multi ecc sram addr=0x%x\n", - SEC_ECC_ADDR(err_val)); } }
From: Junxin Chen chenjunxin1@huawei.com
driver inclusion category: feature bugzilla: NA CVE: NA
----------------------------------
Add protect for hns3_cae and remove some functions, and change version to 1.9.36.0.
Signed-off-by: Junxin Chen chenjunxin1@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/Makefile | 25 +- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- .../hisilicon/hns3/hns-customer/hns3_ext.c | 603 ------------- .../hisilicon/hns3/hns-customer/hns3_ext.h | 102 --- .../hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c | 996 --------------------- .../hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h | 142 --- .../hns3/hns-customer/hns3pf/hclge_main_it.c | 20 +- .../hns3/hns-customer/hns3pf/hclge_main_it.h | 2 - .../hisilicon/hns3/hns3_cae/hns3_cae_common.c | 115 --- .../hisilicon/hns3/hns3_cae/hns3_cae_common.h | 25 - .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.c | 12 - .../hisilicon/hns3/hns3_cae/hns3_cae_ext.c | 422 --------- .../hisilicon/hns3/hns3_cae/hns3_cae_ext.h | 68 -- .../hisilicon/hns3/hns3_cae/hns3_cae_init.c | 24 +- .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.c | 35 - .../hisilicon/hns3/hns3_cae/hns3_cae_lamp.h | 36 - .../hisilicon/hns3/hns3_cae/hns3_cae_lib.c | 50 -- .../hisilicon/hns3/hns3_cae/hns3_cae_lib.h | 2 - .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c | 62 -- .../hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h | 30 - .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.c | 743 --------------- .../hisilicon/hns3/hns3_cae/hns3_cae_pkt.h | 67 -- .../hisilicon/hns3/hns3_cae/hns3_cae_port.c | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_promisc.c | 7 + .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c | 17 +- .../hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h | 8 - .../hisilicon/hns3/hns3_cae/hns3_cae_qres.c | 12 +- .../hisilicon/hns3/hns3_cae/hns3_cae_reset.c | 3 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c | 98 +- .../ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h | 2 + .../hisilicon/hns3/hns3_cae/hns3_cae_version.c | 4 +- .../hisilicon/hns3/hns3_cae/hns3_cae_version.h | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- .../ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 36 files changed, 116 insertions(+), 3632 deletions(-) delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c delete mode 100644 drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h
diff --git a/drivers/net/ethernet/hisilicon/hns3/Makefile b/drivers/net/ethernet/hisilicon/hns3/Makefile index 8568a8b..a17983c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/Makefile +++ b/drivers/net/ethernet/hisilicon/hns3/Makefile @@ -31,8 +31,7 @@ obj-$(CONFIG_HNS3) += hnae3.o HNS3_OBJS = hns3_enet.o \ hns3_ethtool.o \ hns3_debugfs.o -HNS3_OBJS_IT = hns-customer/hns3_enet_it.o \ - hns-customer/hns3_ext.o +HNS3_OBJS_IT = hns-customer/hns3_enet_it.o obj-$(CONFIG_HNS3_ENET) += hns3.o hns3-objs = $(HNS3_OBJS) $(HNS3_OBJS_IT)
@@ -49,11 +48,8 @@ HCLGE_OBJ = hns3pf/hclge_main.o \
HCLGE_OBJ_IT_MAIN = hns-customer/hns3pf/hclge_main_it.o -HCLGE_OBJ_IT_EXPORT = hns-customer/hns3pf/hclge_ext.o - - obj-$(CONFIG_HNS3_HCLGE) += hclge.o -hclge-objs := $(HCLGE_OBJ) $(HCLGE_OBJ_IT_MAIN) $(HCLGE_OBJ_IT_EXPORT) +hclge-objs := $(HCLGE_OBJ) $(HCLGE_OBJ_IT_MAIN) hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o #### compile hclgevf.ko obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o @@ -63,25 +59,20 @@ hclgevf-objs := hns3vf/hclgevf_main.o hns3vf/hclgevf_cmd.o hns3vf/hclgevf_mbx.o #add rally code HNS3_CAE_OBJS_PRIM = hns3_cae/hns3_cae_init.o \ hns3_cae/hns3_cae_lib.o \ - hns3_cae/hns3_cae_common.o \ hns3_cae/hns3_cae_dcb.o \ - hns3_cae/hns3_cae_lamp.o \ - hns3_cae/hns3_cae_dcqcn.o \ - hns3_cae/hns3_cae_mactbl.o \ - hns3_cae/hns3_cae_version.o \ - hns3_cae/hns3_cae_reset.o \ - hns3_cae/hns3_cae_pfc_storm.o \ - hns3_cae/hns3_cae_cmd.o + hns3_cae/hns3_cae_dcqcn.o \ + hns3_cae/hns3_cae_version.o \ + hns3_cae/hns3_cae_reset.o \ + hns3_cae/hns3_cae_pfc_storm.o \ + hns3_cae/hns3_cae_cmd.o #add test code HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \ - hns3_cae/hns3_cae_ext.o \ hns3_cae/hns3_cae_fd.o \ hns3_cae/hns3_cae_hilink_param.o \ hns3_cae/hns3_cae_checksum.o \ hns3_cae/hns3_cae_irq.o \ hns3_cae/hns3_cae_gro.o \ hns3_cae/hns3_cae_mac.o \ - hns3_cae/hns3_cae_pkt.o \ hns3_cae/hns3_cae_port.o \ hns3_cae/hns3_cae_promisc.o \ hns3_cae/hns3_cae_qinfo.o \ @@ -92,6 +83,6 @@ HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \ hns3_cae/hns3_cae_tm.o \ hns3_cae/hns3_cae_vlan.o \ hns3_cae/hns3_cae_xsfp.o \ - hns3_cae/hns3_cae_led.o + hns3_cae/hns3_cae_led.o obj-$(CONFIG_HNS3_CAE) += hns3_cae.o hns3_cae-objs := $(HNS3_CAE_OBJS_PRIM) $(HNS3_CAE_OBJS_EXT) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 534f0db..eea9d59 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.35.1" +#define HNAE3_MOD_VERSION "1.9.36.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.c deleted file mode 100644 index 83e147a..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.c +++ /dev/null @@ -1,603 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#ifdef CONFIG_HNS3_TEST -#include <linux/dma-mapping.h> -#include <linux/etherdevice.h> -#include <linux/interrupt.h> -#include <linux/if_vlan.h> -#include <linux/ip.h> -#include <linux/ipv6.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/skbuff.h> -#include <linux/sctp.h> -#include <linux/vermagic.h> -#include <net/gre.h> -#include <net/pkt_cls.h> -#include <net/vxlan.h> -#include "hns3_ext.h" - -extern const char hns3_driver_name[]; - -int nic_netdev_match_check(struct net_device *netdev) -{ - struct ethtool_drvinfo drv_info; - - if (!netdev) - return -EINVAL; - - if (netdev->ethtool_ops && netdev->ethtool_ops->get_drvinfo) - netdev->ethtool_ops->get_drvinfo(netdev, &drv_info); - - if (!strncmp(drv_info.driver, hns3_driver_name, - strlen(hns3_driver_name))) - return 0; - - return -EINVAL; -} -EXPORT_SYMBOL(nic_netdev_match_check); - -void nic_chip_recover_handler(struct net_device *netdev, - enum hnae3_event_type_custom event_t) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(netdev)) - return; - - dev_info(&netdev->dev, "reset type is %d!!\n", event_t); - - if (event_t == HNAE3_PPU_POISON_CUSTOM) - event_t = HNAE3_FUNC_RESET_CUSTOM; - - if (event_t != HNAE3_FUNC_RESET_CUSTOM && - event_t != HNAE3_GLOBAL_RESET_CUSTOM && - event_t != HNAE3_IMP_RESET_CUSTOM) { - dev_err(&netdev->dev, "reset type err!!\n"); - return; - } - - h = hns3_get_handle(netdev); - if (h->ae_algo->ops->priv_ops) - h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_RESET, &event_t, 0); -} -EXPORT_SYMBOL(nic_chip_recover_handler); - -int nic_clean_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats) -{ - struct hns3_nic_priv *priv; - struct hnae3_handle *h; - struct hnae3_knic_private_info *kinfo; - struct hns3_enet_ring *ring; - int i; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - priv = netdev_priv(ndev); - h = hns3_get_handle(ndev); - kinfo = &h->kinfo; - - if (h->ae_algo->ops->priv_ops) - h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_CLEAN_STATS64, stats, - 0); - - for (i = 0; i < kinfo->num_tqps; i++) { - ring = &priv->ring[i]; - memset(&ring->stats, 0, sizeof(struct ring_stats)); - ring = &priv->ring[i + kinfo->num_tqps]; - memset(&ring->stats, 0, sizeof(struct ring_stats)); - } - - memset(&ndev->stats, 0, sizeof(struct net_device_stats)); - return 0; -} -EXPORT_SYMBOL(nic_clean_stats64); - -int nic_get_chipid(struct net_device *ndev, u32 *chip_id) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!chip_id) - return -EINVAL; - - h = hns3_get_handle(ndev); - - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_CHIPID, - chip_id, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_chipid); - -int nic_get_mac_id(struct net_device *ndev, u32 *mac_id) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!mac_id) - return -EINVAL; - - h = hns3_get_handle(ndev); - - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_MAC_ID, - mac_id, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_mac_id); - -int nic_get_sfpinfo(struct net_device *ndev, u8 *buff, u16 size, u16 *outlen) -{ - struct hns3_sfp_info_para para; - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!buff || !outlen) - return -EINVAL; - - para.buff = buff; - para.outlen = outlen; - para.offset = 0; - para.size = size; - h = hns3_get_handle(ndev); - - if (h->ae_algo->ops->priv_ops) { - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_SFPINFO, - ¶, 0); - } else { - return -EOPNOTSUPP; - } -} -EXPORT_SYMBOL(nic_get_sfpinfo); - -int nic_get_sfp_present(struct net_device *ndev, int *present) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!present) - return -EINVAL; - - h = hns3_get_handle(ndev); - - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_PRESENT, - present, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_sfp_present); - -int nic_set_sfp_state(struct net_device *ndev, bool en) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_SFP_STATE, - &en, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_set_sfp_state); - -int nic_get_chip_num(struct net_device *ndev, u32 *chip_num) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!chip_num) - return -EINVAL; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_CHIP_NUM, - chip_num, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_chip_num); - -int nic_get_port_num_per_chip(struct net_device *ndev, u32 *port_num) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!port_num) - return -EINVAL; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_PORT_NUM, - port_num, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_port_num_per_chip); - -int nic_set_led(struct net_device *ndev, int type, int status) -{ - struct hns3_led_state_para para; - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - para.status = status; - para.type = type; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_LED, ¶, - 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_set_led); - -int nic_get_led_signal(struct net_device *ndev, struct hns3_lamp_signal *signal) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!signal) - return -EINVAL; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_LED_SIGNAL, - signal, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_led_signal); - -int nic_disable_net_lane(struct net_device *ndev) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_DISABLE_LANE, - NULL, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_disable_net_lane); - -int nic_get_net_lane_status(struct net_device *ndev, u32 *status) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!status) - return -EINVAL; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_GET_LANE_STATUS, - status, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_net_lane_status); - -int nic_set_mac_state(struct net_device *ndev, int enable) -{ - struct hnae3_handle *h; - bool en; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - h = hns3_get_handle(ndev); - en = !!enable; - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_MAC_STATE, - &en, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_set_mac_state); - -int nic_set_cpu_affinity(struct net_device *netdev, cpumask_t *affinity_mask) -{ - struct hns3_enet_tqp_vector *tqp_vector; - struct hns3_nic_priv *priv; - int ret; - u16 i; - - if (!netdev || !affinity_mask) { - pr_err("Invalid input param when set ethernet cpu affinity\n"); - return -EINVAL; - } - - if (nic_netdev_match_check(netdev)) - return -ENODEV; - - priv = netdev_priv(netdev); - if (test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) { - dev_err(&netdev->dev, - "ethernet is down, not support cpu affinity set\n"); - return -EOPNOTSUPP; - } - - for (i = 0; i < priv->vector_num; i++) { - tqp_vector = &priv->tqp_vector[i]; - if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED) - continue; - - tqp_vector->affinity_mask = *affinity_mask; - - ret = irq_set_affinity_hint(tqp_vector->vector_irq, NULL); - if (ret) { - dev_err(&netdev->dev, - "reset affinity hint fail, ret = %d\n", ret); - return ret; - } - - ret = irq_set_affinity_hint(tqp_vector->vector_irq, - &tqp_vector->affinity_mask); - if (ret) { - dev_err(&netdev->dev, - "set affinity hint fail, ret = %d\n", ret); - return ret; - } - } - - dev_info(&netdev->dev, "set nic cpu affinity %*pb succeed\n", - cpumask_pr_args(affinity_mask)); - - return 0; -} -EXPORT_SYMBOL(nic_set_cpu_affinity); - -int nic_disable_clock(struct net_device *ndev) -{ - struct hnae3_handle *h; - u32 en; - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - en = 0; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_CONFIG_CLOCK, - &en, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_disable_clock); - -int nic_set_pfc_storm_para(struct net_device *ndev, int dir, int enable, - int period_ms, int times, int recovery_period_ms) -{ - struct hns3_pfc_storm_para para; - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - para.dir = dir; - para.enable = enable; - para.period_ms = period_ms; - para.times = times; - para.recovery_period_ms = recovery_period_ms; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_SET_PFC_STORM_PARA, - ¶, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_set_pfc_storm_para); - -int nic_get_pfc_storm_para(struct net_device *ndev, int dir, int *enable, - int *period_ms, int *times, int *recovery_period_ms) -{ - struct hns3_pfc_storm_para para; - struct hnae3_handle *h; - int ret; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!enable || !period_ms || !times || !recovery_period_ms) { - pr_err("get pfc storm para failed because invalid input param.\n"); - return -EINVAL; - } - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) { - para.dir = dir; - ret = h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_GET_PFC_STORM_PARA, - ¶, 0); - if (!ret) { - *enable = para.enable; - *period_ms = para.period_ms; - *times = para.times; - *recovery_period_ms = para.recovery_period_ms; - return 0; - } else { - return ret; - } - } else { - return -EOPNOTSUPP; - } -} -EXPORT_SYMBOL(nic_get_pfc_storm_para); - -int nic_get_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 *data) -{ - struct hns3_phy_para para; - struct hnae3_handle *h; - int ret; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - para.page_select_addr = page_select_addr; - para.page = page; - para.reg_addr = reg_addr; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) { - ret = h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_GET_PHY_REG, - ¶, 0); - if (!ret) { - *data = para.data; - return 0; - } else { - return ret; - } - } else { - return -EOPNOTSUPP; - } -} -EXPORT_SYMBOL(nic_get_phy_reg); - -int nic_set_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 data) -{ - struct hns3_phy_para para; - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - para.page_select_addr = page_select_addr; - para.page = page; - para.reg_addr = reg_addr; - para.data = data; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_SET_PHY_REG, - ¶, 0); - - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_set_phy_reg); - -int nic_get_hilink_ref_los(struct net_device *ndev, u32 *status) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!status) - return -EINVAL; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_GET_HILINK_REF_LOS, - status, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_hilink_ref_los); - -int nic_get_8211_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 *data) -{ - struct hns3_phy_para phy_para; - struct hnae3_handle *h; - int ret; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - phy_para.page_select_addr = page_select_addr; - phy_para.page = page; - phy_para.reg_addr = reg_addr; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) { - ret = h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_GET_8211_PHY_REG, - &phy_para, 0); - if (!ret) { - *data = phy_para.data; - return 0; - } else { - return ret; - } - } else { - return -EOPNOTSUPP; - } -} -EXPORT_SYMBOL(nic_get_8211_phy_reg); - -int nic_set_8211_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 data) -{ - struct hns3_phy_para phy_para; - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - phy_para.page_select_addr = page_select_addr; - phy_para.page = page; - phy_para.reg_addr = reg_addr; - phy_para.data = data; - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_SET_8211_PHY_REG, - &phy_para, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_set_8211_phy_reg); - -int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type) -{ - struct hnae3_handle *h; - - if (nic_netdev_match_check(ndev)) - return -ENODEV; - - if (!wire_type) - return -EINVAL; - - h = hns3_get_handle(ndev); - if (h->ae_algo->ops->priv_ops) - return h->ae_algo->ops->priv_ops(h, - HNS3_EXT_OPC_GET_PORT_TYPE, - wire_type, 0); - else - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(nic_get_port_wire_type); -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.h deleted file mode 100644 index 3d18f10..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3_ext.h +++ /dev/null @@ -1,102 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2017 Hisilicon Limited. */ - -#ifndef __HNS3_EXT_H -#define __HNS3_EXT_H -#include <linux/types.h> -#include "hns3_enet.h" -#include "hnae3.h" -#include "hclge_main_it.h" - -enum hns3_ext_op_code { - HNS3_EXT_OPC_CLEAN_STATS64 = 0, - HNS3_EXT_OPC_GET_CHIPID, - HNS3_EXT_OPC_GET_SFPINFO, - HNS3_EXT_OPC_SET_SFP_STATE, - HNS3_EXT_OPC_GET_CHIP_NUM, - HNS3_EXT_OPC_GET_PORT_NUM, - HNS3_EXT_OPC_SET_LED, - HNS3_EXT_OPC_GET_PRESENT, - HNS3_EXT_OPC_DISABLE_LANE, - HNS3_EXT_OPC_GET_LANE_STATUS, - HNS3_EXT_OPC_GET_LED_SIGNAL, - HNS3_EXT_OPC_SET_MAC_STATE, - HNS3_EXT_OPC_CONFIG_CLOCK, - HNS3_EXT_OPC_GET_PFC_STORM_PARA, - HNS3_EXT_OPC_SET_PFC_STORM_PARA, - HNS3_EXT_OPC_GET_PHY_REG, - HNS3_EXT_OPC_SET_PHY_REG, - HNS3_EXT_OPC_GET_MAC_ID, - HNS3_EXT_OPC_OPT_MAC_TABLE, - HNS3_EXT_OPC_RESET, - HNS3_EXT_OPC_GET_HILINK_REF_LOS, - HNS3_EXT_OPC_GET_8211_PHY_REG, - HNS3_EXT_OPC_SET_8211_PHY_REG, - HNS3_EXT_OPC_GET_PORT_TYPE, -}; - -struct hns3_sfp_info_para { - u8 *buff; - u16 offset; - u16 size; - u16 *outlen; -}; - -struct hns3_led_state_para { - u32 type; - u32 status; -}; - -struct hns3_pfc_storm_para { - u32 dir; - u32 enable; - u32 period_ms; - u32 times; - u32 recovery_period_ms; -}; - -struct hns3_phy_para { - u32 page_select_addr; - u32 reg_addr; - u16 page; - u16 data; -}; - -struct hns3_lamp_signal { - u8 error; - u8 locate; - u8 activity; -}; - -int nic_get_chipid(struct net_device *ndev, u32 *chip_id); -int nic_netdev_match_check(struct net_device *netdev); -int nic_get_sfpinfo(struct net_device *ndev, u8 *buff, u16 size, u16 *outlen); -int nic_get_sfp_present(struct net_device *ndev, int *present); -int nic_set_sfp_state(struct net_device *ndev, bool en); -int nic_clean_stats64(struct net_device *netdev, - struct rtnl_link_stats64 *stats); -int nic_get_chip_num(struct net_device *ndev, u32 *chip_num); -int nic_get_port_num_per_chip(struct net_device *ndev, u32 *port_num); -int nic_set_led(struct net_device *ndev, int type, int status); -int nic_disable_net_lane(struct net_device *ndev); -int nic_get_net_lane_status(struct net_device *ndev, u32 *status); -int nic_set_cpu_affinity(struct net_device *netdev, cpumask_t *affinity_mask); -int nic_set_mac_state(struct net_device *ndev, int enable); -int nic_disable_clock(struct net_device *ndev); -int nic_set_pfc_storm_para(struct net_device *ndev, int dir, int enable, - int period_ms, int times, int recovery_period_ms); -int nic_get_pfc_storm_para(struct net_device *ndev, int dir, int *enable, - int *period_ms, int *times, int *recovery_period_ms); -int nic_get_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 *data); -int nic_set_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 data); -int nic_get_mac_id(struct net_device *ndev, u32 *mac_id); -int nic_get_hilink_ref_los(struct net_device *ndev, u32 *status); -int nic_get_8211_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 *data); -int nic_set_8211_phy_reg(struct net_device *ndev, u32 page_select_addr, - u16 page, u32 reg_addr, u16 data); -int nic_get_port_wire_type(struct net_device *ndev, u32 *wire_type); - -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c deleted file mode 100644 index 0863771..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.c +++ /dev/null @@ -1,996 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#ifdef CONFIG_IT_VALIDATION -#include <linux/dma-mapping.h> -#include <linux/etherdevice.h> -#include <linux/interrupt.h> -#include <linux/if_vlan.h> -#include <linux/ip.h> -#include <linux/ipv6.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/skbuff.h> -#include <linux/sctp.h> -#include <linux/vermagic.h> -#include <net/gre.h> -#include <net/pkt_cls.h> -#include <net/vxlan.h> -#include "hclge_main.h" -#include "hnae3.h" -#include "hclge_cmd.h" -#include "hclge_ext.h" - -#define BD0_DATA_LEN 20 -#define BD1_DATA_LEN 24 - -void hclge_reset_task_schedule_it(struct hclge_dev *hdev) -{ - if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) && - !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state)) - mod_delayed_work_on(cpumask_first(&hdev->affinity_mask), - system_wq, &hdev->service_task, 0); -} - -#ifdef CONFIG_HNS3_TEST -static int hclge_clean_stats64(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hnae3_knic_private_info *kinfo = NULL; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; - struct hclge_tqp *tqp = NULL; - int i; - - kinfo = &handle->kinfo; - vport = hclge_get_vport(handle); - hdev = vport->back; - - for (i = 0; i < kinfo->num_tqps; i++) { - tqp = container_of(kinfo->tqp[i], struct hclge_tqp, q); - memset(&tqp->tqp_stats, 0, sizeof(struct hlcge_tqp_stats)); - } - memset(&hdev->mac_stats, 0, sizeof(struct hclge_mac_stats)); - return 0; -} - -static int hclge_get_chipid(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_chip_id_cmd *resp = NULL; - struct hclge_desc desc; - u32 *chip_id; - int ret; - - chip_id = (u32 *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CHIP_ID_GET, true); - resp = (struct hclge_chip_id_cmd *)(desc.data); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get chip id failed %d\n", ret); - return ret; - } - *chip_id = resp->chip_id; - return 0; -} - -static int hclge_get_mac_id(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 *mac_id; - int ret; - - mac_id = (u32 *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CHIP_ID_GET, true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get mac id failed, ret = %d\n", ret); - return ret; - } - - *mac_id = desc.data[1]; - return 0; -} - -static int _hclge_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, - u16 offset, u16 size, u16 *outlen) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_desc desc[HCLGE_SFP_INFO_LEN]; - struct hclge_dev *hdev = vport->back; - struct hclge_sfp_info *resp = NULL; - u8 *temp_data = NULL; - u32 temp_len; - u32 data_len; - int ret; - u32 i; - u32 j; - - memset(desc, 0x0, sizeof(desc)); - - for (i = 0; i < HCLGE_SFP_INFO_LEN; i++) { - hclge_cmd_setup_basic_desc(&desc[i], - HCLGE_OPC_SFP_GET_INFO, true); - if (i == 0) - desc[0].data[0] = offset | (size << 16); - if (i < HCLGE_SFP_INFO_LEN - 1) - desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); - else - desc[i].flag &= ~(cpu_to_le16(HCLGE_CMD_FLAG_NEXT)); - } - - ret = hclge_cmd_send(&hdev->hw, desc, HCLGE_SFP_INFO_LEN); - if (ret) { - dev_err(&hdev->pdev->dev, - "get spf information cmd failed %d\n", ret); - return ret; - } - - for (i = 0; i < HCLGE_SFP_INFO_LEN; i++) { - resp = (struct hclge_sfp_info *)desc[i].data; - if (i == 0) { - *outlen = (resp[i].sfpinfo[0] >> 16) & 0xFFFF; - temp_len = *outlen; - data_len = - (temp_len > BD0_DATA_LEN) ? BD0_DATA_LEN : temp_len; - temp_data = (u8 *)&resp->sfpinfo[1]; - } else { - data_len = - (temp_len > BD1_DATA_LEN) ? BD1_DATA_LEN : temp_len; - temp_data = (u8 *)&resp->sfpinfo[0]; - } - - for (j = 0; j < data_len; j++) - *buff++ = *temp_data++; - - temp_len -= data_len; - if (temp_len == 0) - break; - } - return 0; -} - -static int hclge_get_sfpinfo(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_sfp_info_para *para; - u16 tmp_size; - u8 *tmp_buff; - u16 tmp_outlen; - int ret; - para = (struct hclge_sfp_info_para *)data; - tmp_buff = para->buff; - - while (para->size) { - WARN_ON_ONCE(!tmp_buff); - if (para->size > HCLGE_SFP_INFO_SIZE) - tmp_size = HCLGE_SFP_INFO_SIZE; - else - tmp_size = para->size; - ret = _hclge_get_sfpinfo(handle, tmp_buff, para->offset, - tmp_size, &tmp_outlen); - if (ret) - return ret; - para->offset += tmp_size; - para->size -= tmp_size; - tmp_buff += tmp_size; - *para->outlen += tmp_outlen; - if (tmp_size != tmp_outlen) - break; - } - - return 0; -} - -static int hclge_set_sfp_state(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_sfp_enable_cmd *req = NULL; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - int ret; - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SFP_SET_STATUS, false); - req = (struct hclge_sfp_enable_cmd *)desc.data; - req->set_sfp_enable_flag = *(bool *)data; - - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) - dev_err(&hdev->pdev->dev, - "set spf on/off cmd failed %d\n", ret); - - return ret; -} - -static int hclge_get_chip_num(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - u32 *chip_num = (u32 *)data; - struct hclge_desc desc; - int ret; - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_GET_CHIP_NUM, true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get chip number failed %d\n", ret); - return ret; - } - *chip_num = desc.data[0]; - return 0; -} - -static int hclge_get_port_num(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 *port_num; - int ret; - - port_num = (u32 *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_GET_PORT_NUM, true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get port number failed %d\n", ret); - return ret; - } - *port_num = desc.data[0]; - return 0; -} - -static int hclge_set_led(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_led_state *para; - struct hclge_desc desc; - int ret; - - para = (struct hclge_led_state *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SET_LED, false); - desc.data[0] = para->type; - desc.data[1] = para->status; - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get set led failed %d\n", ret); - return ret; - } - - return 0; -} - -static int hclge_get_led_signal(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_lamp_signal *signal; - struct hclge_desc desc; - int ret; - - signal = (struct hclge_lamp_signal *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SET_LED, true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "hclge get led signal failed %d\n", ret); - return ret; - } - - signal->error = desc.data[2] & 0xFF; - signal->locate = (desc.data[2] >> 8) & 0xFF; - signal->activity = (desc.data[2] >> 16) & 0xFF; - - return 0; -} - -static int hclge_get_sfp_present(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_sfp_present_cmd *resp = NULL; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 *present; - int ret = 0; - - present = (u32 *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SFP_GET_PRESENT, true); - resp = (struct hclge_sfp_present_cmd *)desc.data; - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get spf present failed %d\n", ret); - return ret; - } - - *present = resp->sfp_present; - return 0; -} - -static int hclge_disable_net_lane(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - int ret = 0; - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_DISABLE_NET_LANE, false); - desc.data[0] = 0; - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "disable net lane failed %d\n", ret); - return ret; - } - return 0; -} - -static int hclge_get_net_lane_status(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 *status; - int ret = 0; - - status = (u32 *)data; - desc.data[0] = 0; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_DISABLE_NET_LANE, true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get lane status failed %d\n", ret); - return ret; - } - *status = desc.data[0]; - return 0; -} - -static void hclge_set_phy_state(struct hnae3_handle *handle, bool enable) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct phy_device *phydev = hdev->hw.mac.phydev; - - if (!phydev) - return; - - if (enable) - phy_start(phydev); - else - phy_stop(phydev); -} - -static int hclge_set_mac_state(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_config_mac_mode_cmd *req = NULL; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 loop_en = 0; - bool enable; - int ret; - - enable = *(bool *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_MAC_MODE, false); - hnae3_set_bit(loop_en, HCLGE_MAC_TX_EN_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_RX_EN_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_PAD_TX_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_PAD_RX_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_1588_TX_B, 0); - hnae3_set_bit(loop_en, HCLGE_MAC_1588_RX_B, 0); - hnae3_set_bit(loop_en, HCLGE_MAC_APP_LP_B, 0); - hnae3_set_bit(loop_en, HCLGE_MAC_LINE_LP_B, 0); - hnae3_set_bit(loop_en, HCLGE_MAC_FCS_TX_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_RX_FCS_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_RX_FCS_STRIP_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_TX_OVERSIZE_TRUNCATE_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_RX_OVERSIZE_TRUNCATE_B, enable); - hnae3_set_bit(loop_en, HCLGE_MAC_TX_UNDER_MIN_ERR_B, enable); - req = (struct hclge_config_mac_mode_cmd *)desc.data; - req->txrx_pad_fcs_loop_en = cpu_to_le32(loop_en); - - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) - dev_err(&hdev->pdev->dev, - "set mac state %x fail, ret = %d.\n", enable, ret); - hclge_set_phy_state(handle, enable); - return ret; -} - -static int hclge_config_nic_clock(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - u32 nic_clock_en = *(u32 *)data; - struct hclge_desc desc; - int ret = 0; - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CONFIG_NIC_CLOCK, false); - desc.data[0] = nic_clock_en; - - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) - dev_err(&hdev->pdev->dev, - "config_nic_clock %x fail, ret = %d.\n", - nic_clock_en, ret); - return ret; -} - -static int hclge_set_pfc_storm_para(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_pfc_storm_para *para; - struct hclge_desc desc; - int ret = 0; - - para = (struct hclge_pfc_storm_para *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_PAUSE_STORM_PARA, - false); - desc.data[0] = para->dir; - desc.data[1] = para->enable; - desc.data[2] = para->period_ms; - desc.data[3] = para->times; - desc.data[4] = para->recovery_period_ms; - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "set pfc storm para failed %d\n", - ret); - return ret; - } - return 0; -} - -static int hclge_get_pfc_storm_para(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_pfc_storm_para *para; - struct hclge_desc desc; - int ret = 0; - - para = (struct hclge_pfc_storm_para *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_PAUSE_STORM_PARA, true); - desc.data[0] = para->dir; - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "get pfc storm para failed %d\n", - ret); - return ret; - } - para->enable = desc.data[1]; - para->period_ms = desc.data[2]; - para->times = desc.data[3]; - para->recovery_period_ms = desc.data[4]; - return 0; -} - -enum hclge_phy_op_code { - PHY_OP_READ, - PHY_OP_WRITE, - PHY_OP_MAX, -}; - -static int hclge_phy_need_page_select(struct hclge_dev *hdev, - enum hclge_phy_op_code opt_type, - struct hclge_phy_para *para, - u16 *cur_page) -{ - struct hclge_mac *mac = &hdev->hw.mac; - struct mii_bus *mdio_bus = mac->mdio_bus; - u32 phyid = mac->phy_addr; - int ret; - - /* no need to change page when page param is 0 */ - if (opt_type != PHY_OP_READ || para->page != 0) { - ret = mdio_bus->read(mdio_bus, phyid, para->page_select_addr); - if (ret < 0) { - dev_err(&hdev->pdev->dev, - "record current phy %d reg page failed.\n", - phyid); - return ret; - } - *cur_page = ret; - if (para->page != *cur_page) - return 1; - else - return 0; - } - - return 0; -} - -static int hclge_check_phy_opt_param(struct hclge_dev *hdev, - struct mii_bus *mdio_bus, - struct phy_device *phydev, - enum hclge_phy_op_code opt_type) -{ - if (!phydev) { - dev_err(&hdev->pdev->dev, "this net dev has no phy."); - return -EINVAL; - } - - if (!mdio_bus) { - dev_err(&hdev->pdev->dev, "this net dev has no mdio bus."); - return -EINVAL; - } - - if (opt_type >= PHY_OP_MAX) { - dev_err(&hdev->pdev->dev, "unsupported phy operate type %d.", - opt_type); - return -EINVAL; - } - - return 0; -} - -static int hclge_mdio_bus_opt(struct hclge_phy_para *para, - struct hclge_dev *hdev, - struct mii_bus *mdio_bus, u32 phyid, - enum hclge_phy_op_code opt_type) -{ - int op_ret; - - if (opt_type == PHY_OP_READ) { - op_ret = mdio_bus->read(mdio_bus, phyid, para->reg_addr); - if (op_ret < 0) { - dev_err(&hdev->pdev->dev, - "read phy %u page %d reg %d failed.\n", - phyid, para->page, para->reg_addr); - } else { - para->data = (u16)op_ret; - op_ret = 0; - } - } else { - op_ret = mdio_bus->write(mdio_bus, phyid, para->reg_addr, - para->data); - if (op_ret < 0) { - dev_err(&hdev->pdev->dev, - "write phy %u page %d reg %d failed.\n", - phyid, para->page, para->reg_addr); - } - } - - return op_ret; -} - -static int hclge_phy_reg_opt(struct hnae3_handle *handle, void *data, - enum hclge_phy_op_code opt_type) -{ - struct hclge_phy_para *para = (struct hclge_phy_para *)data; - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_mac *mac = &hdev->hw.mac; - struct mii_bus *mdio_bus = mac->mdio_bus; - u32 phyid = mac->phy_addr; - int need_page_select; - u16 cur_page; - int op_ret; - int ret; - - ret = hclge_check_phy_opt_param(hdev, mdio_bus, mac->phydev, opt_type); - if (ret < 0) - return ret; - - /* operate flow: - * 1 record current page address - * 2 jump to operated page - * 3 operate register(read or write) - * 4 come back to the page recorded in the first step. - */ - mutex_lock(&mdio_bus->mdio_lock); - - /* check if page select is needed and record current page address */ - ret = hclge_phy_need_page_select(hdev, opt_type, para, &cur_page); - if (ret < 0) { - mutex_unlock(&mdio_bus->mdio_lock); - return ret; - } - need_page_select = ret; - - /* jump to operated page */ - if (need_page_select) { - ret = mdio_bus->write(mdio_bus, phyid, para->page_select_addr, - para->page); - if (ret < 0) { - mutex_unlock(&mdio_bus->mdio_lock); - dev_err(&hdev->pdev->dev, - "change phy %d page %d to page %d failed.\n", - phyid, cur_page, para->page); - return ret; - } - } - - /* operate register(read or write) */ - op_ret = hclge_mdio_bus_opt(para, hdev, mdio_bus, phyid, opt_type); - - /* come back to the page recorded in the first step. */ - if (need_page_select) { - ret = mdio_bus->write(mdio_bus, phyid, para->page_select_addr, - cur_page); - if (ret < 0) { - mutex_unlock(&mdio_bus->mdio_lock); - dev_err(&hdev->pdev->dev, - "restore phy %d reg page %u failed.\n", - phyid, cur_page); - return ret; - } - } - - mutex_unlock(&mdio_bus->mdio_lock); - - return op_ret; -} - -static int hclge_get_phy_reg(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - return hclge_phy_reg_opt(handle, data, PHY_OP_READ); -} - -static int hclge_set_phy_reg(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - return hclge_phy_reg_opt(handle, data, PHY_OP_WRITE); -} - -static int hclge_8211_phy_indirect_opt(struct hclge_phy_para *para, - struct hclge_dev *hdev, - struct mii_bus *mdio_bus, - u32 phyid, - enum hclge_phy_op_code opt_type) -{ - u32 indirect_reg_data; - int op_ret; - - /* select indirect page 0xa43 */ - op_ret = mdio_bus->write(mdio_bus, phyid, para->page_select_addr, - HCLGE_8211_PHY_INDIRECT_PAGE); - if (op_ret < 0) { - dev_err(&hdev->pdev->dev, - "change phy %d indirect page 0xa43 failed.\n", phyid); - return op_ret; - } - /* ndirect access address = page_no*16 + 2*(reg_no%16) */ - indirect_reg_data = (para->page << 4) + ((para->reg_addr % 16) << 1); - op_ret = mdio_bus->write(mdio_bus, phyid, - HCLGE_8211_PHY_INDIRECT_REG, - indirect_reg_data); - if (op_ret < 0) { - dev_err(&hdev->pdev->dev, - "write phy %d indirect reg failed.\n", phyid); - return op_ret; - } - - if (opt_type == PHY_OP_READ) { - op_ret = mdio_bus->read(mdio_bus, phyid, - HCLGE_8211_PHY_INDIRECT_DATA); - if (op_ret < 0) { - dev_err(&hdev->pdev->dev, - "read phy %d indirect data failed.\n", phyid); - } else { - para->data = (u16)op_ret; - op_ret = 0; - } - } else { - op_ret = mdio_bus->write(mdio_bus, phyid, - HCLGE_8211_PHY_INDIRECT_DATA, - para->data); - if (op_ret < 0) { - dev_err(&hdev->pdev->dev, - "write phy %d indirect data failed.\n", phyid); - } - } - - return op_ret; -} - -static int hclge_8211_phy_reg_opt(struct hnae3_handle *handle, void *data, - enum hclge_phy_op_code opt_type) -{ - struct hclge_phy_para *para = (struct hclge_phy_para *)data; - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_mac *mac = &hdev->hw.mac; - struct mii_bus *mdio_bus = mac->mdio_bus; - u32 phyid = mac->phy_addr; - u16 save_page; - int ret; - - ret = hclge_check_phy_opt_param(hdev, mdio_bus, mac->phydev, opt_type); - if (ret < 0) - return ret; - - mutex_lock(&mdio_bus->mdio_lock); - ret = mdio_bus->read(mdio_bus, phyid, para->page_select_addr); - if (ret < 0) { - dev_err(&hdev->pdev->dev, - "record phy %d reg page failed.\n", - phyid); - mutex_unlock(&mdio_bus->mdio_lock); - return ret; - } - save_page = ret; - ret = hclge_8211_phy_indirect_opt(para, hdev, mdio_bus, phyid, - opt_type); - if (ret) - dev_err(&hdev->pdev->dev, - "8211 phy %d indirect access failed.\n", phyid); - ret = mdio_bus->write(mdio_bus, phyid, para->page_select_addr, - save_page); - if (ret < 0) - dev_err(&hdev->pdev->dev, - "restore phy %d reg page %u failed.\n", - phyid, save_page); - mutex_unlock(&mdio_bus->mdio_lock); - - return ret; -} - -static int hclge_8211_phy_need_indirect_access(u16 page) -{ - if (page >= HCLGE_8211_PHY_INDIRECT_RANGE1_S && - page <= HCLGE_8211_PHY_INDIRECT_RANGE1_E) - return true; - else if (page >= HCLGE_8211_PHY_INDIRECT_RANGE2_S && - page <= HCLGE_8211_PHY_INDIRECT_RANGE2_E) - return true; - else - return false; -} - - -static int hclge_opt_lookup_mac_tbl(struct hclge_vport *vport, - unsigned char *addr) -{ - u32 low_val = addr[4] | (addr[5] << 8); - struct hclge_mac_vlan_tbl_entry_cmd req = {0}; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u8 resp_code; - u32 high_val; - u16 retval; - int ret; - - high_val = addr[2] << 16 | (addr[3] << 24) | (addr[0]) | (addr[1] << 8); - hnae3_set_bit(req.flags, HCLGE_MAC_VLAN_BIT0_EN_B, 1); - req.mac_addr_hi32 = cpu_to_le32(high_val); - req.mac_addr_lo16 = cpu_to_le16(low_val & 0xffff); - - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_MAC_VLAN_ADD, true); - memcpy(desc.data, &req, sizeof(struct hclge_mac_vlan_tbl_entry_cmd)); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "lookup mac addr failed for cmd_send, ret = %d.\n", - ret); - return ret; - } - - resp_code = (le32_to_cpu(desc.data[0]) >> 8) & 0xff; - retval = le16_to_cpu(desc.retval); - if (retval) { - dev_err(&hdev->pdev->dev, - "cmdq execute failed for %s, retval = %d.\n", - __func__, retval); - return -EIO; - } - - if (!resp_code) { - return 0; - } else if (resp_code == 1) { - dev_dbg(&hdev->pdev->dev, "lookup mac addr failed for miss.\n"); - return -ENOENT; - } - - dev_err(&hdev->pdev->dev, - "lookup mac addr failed for undefined, code = %d.\n", - resp_code); - return -EIO; -} - -static int hclge_opt_mac_table(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_mac_table_para *info = (struct hclge_mac_table_para *)data; - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = NULL; - int ret; - - if (!info || !vport) - return -EIO; - - hdev = vport->back; - switch (info->op_cmd) { - case HCLGE_OPT_TABLE_LOOKUP: - ret = hclge_opt_lookup_mac_tbl(vport, info->mac_addr); - if (ret == -ENOENT) { - return ret; - } else if (ret) { - dev_err(&hdev->pdev->dev, - "ext lookup uc mac address(%pM) fail, ret = %d.\n", - info->mac_addr, ret); - return -EIO; - } - break; - case HCLGE_OPT_TABLE_ADD: - ret = hclge_add_uc_addr_common(vport, info->mac_addr); - if (ret == -ENOSPC) { - return ret; - } else if (ret) { - dev_err(&hdev->pdev->dev, - "ext add uc mac address(%pM) fail, ret = %d.\n", - info->mac_addr, ret); - return -EIO; - } - break; - case HCLGE_OPT_TABLE_DEL: - ret = hclge_rm_uc_addr_common(vport, info->mac_addr); - if (ret == -ENOENT) { - return ret; - } else if (ret) { - dev_warn(&hdev->pdev->dev, - "ext remove uc mac address(%pM) fail, ret = %d.\n", - info->mac_addr, ret); - return -EIO; - } - break; - default: - dev_err(&hdev->pdev->dev, "ext opcode error.\n"); - return -EIO; - } - - return ret; -} - -static int hclge_set_reset_task(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - u32 *reset_level = (u32 *)data; - - dev_warn(&hdev->pdev->dev, "reset level is %d\n", *reset_level); - - /* request reset & schedule reset task */ - set_bit(*reset_level, &hdev->reset_request); - hclge_reset_task_schedule_it(hdev); - return 0; -} - -static int hclge_get_hilink_ref_los(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 *hilink_ref_los_status; - int ret; - - hilink_ref_los_status = (u32 *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_CFG_GET_HILINK_REF_LOS, - true); - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "get hilink ref los failed, ret = %d\n", ret); - return ret; - } - - *hilink_ref_los_status = desc.data[0]; - return 0; -} - -static int hclge_get_8211_phy_reg(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_phy_para *para = (struct hclge_phy_para *)data; - - if (hclge_8211_phy_need_indirect_access(para->page)) - return hclge_8211_phy_reg_opt(handle, data, PHY_OP_READ); - else - return hclge_phy_reg_opt(handle, data, PHY_OP_READ); -} - -static int hclge_set_8211_phy_reg(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_phy_para *para = (struct hclge_phy_para *)data; - - if (hclge_8211_phy_need_indirect_access(para->page)) - return hclge_8211_phy_reg_opt(handle, data, PHY_OP_WRITE); - else - return hclge_phy_reg_opt(handle, data, PHY_OP_WRITE); -} - -static int hclge_get_port_wire_type(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - struct hclge_sfp_info_cmd *resp = NULL; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - u32 *wire_type; - int ret; - - wire_type = (u32 *)data; - hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_SFP_GET_PORT_INFO, true); - resp = (struct hclge_sfp_info_cmd *)desc.data; - resp->query_type = PORT_QUERY_TYPE_SFP; - - ret = hclge_cmd_send(&hdev->hw, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, - "get port info failed, ret = %d\n", ret); - return ret; - } - - *wire_type = resp->module_type; - return 0; -} - -static struct hclge_ext_func hclge_ext_func_arr[] = { - {HCLGE_EXT_OPC_CLEAN_STATS64, hclge_clean_stats64}, - {HCLGE_EXT_OPC_GET_CHIPID, hclge_get_chipid}, - {HCLGE_EXT_OPC_GET_SFPINFO, hclge_get_sfpinfo}, - {HCLGE_EXT_OPC_SET_SFP_STATE, hclge_set_sfp_state}, - {HCLGE_EXT_OPC_GET_CHIP_NUM, hclge_get_chip_num}, - {HCLGE_EXT_OPC_GET_PORT_NUM, hclge_get_port_num}, - {HCLGE_EXT_OPC_SET_LED, hclge_set_led}, - {HCLGE_EXT_OPC_GET_PRESENT, hclge_get_sfp_present}, - {HCLGE_EXT_OPC_DISABLE_LANE, hclge_disable_net_lane}, - {HCLGE_EXT_OPC_GET_LANE_STATUS, hclge_get_net_lane_status}, - {HCLGE_EXT_OPC_GET_LED_SIGNAL, hclge_get_led_signal}, - {HCLGE_EXT_OPC_SET_MAC_STATE, hclge_set_mac_state}, - {HCLGE_EXT_OPC_CONFIG_CLOCK, hclge_config_nic_clock}, - {HCLGE_EXT_OPC_GET_PFC_STORM_PARA, hclge_get_pfc_storm_para}, - {HCLGE_EXT_OPC_SET_PFC_STORM_PARA, hclge_set_pfc_storm_para}, - {HCLGE_EXT_OPC_GET_PHY_REG, hclge_get_phy_reg}, - {HCLGE_EXT_OPC_SET_PHY_REG, hclge_set_phy_reg}, - {HCLGE_EXT_OPC_GET_MAC_ID, hclge_get_mac_id}, - {HCLGE_EXT_OPC_OPT_MAC_TABLE, hclge_opt_mac_table}, - {HCLGE_EXT_OPC_RESET, hclge_set_reset_task}, - {HCLGE_EXT_OPC_GET_HILINK_REF_LOS, hclge_get_hilink_ref_los}, - {HCLGE_EXT_OPC_GET_8211_PHY_REG, hclge_get_8211_phy_reg}, - {HCLGE_EXT_OPC_SET_8211_PHY_REG, hclge_set_8211_phy_reg}, - {HCLGE_EXT_OPC_GET_PORT_TYPE, hclge_get_port_wire_type}, -}; - -int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode, - void *data, int length) -{ - struct hclge_vport *vport = hclge_get_vport(handle); - int cmd_num = ARRAY_SIZE(hclge_ext_func_arr); - struct hclge_dev *hdev = vport->back; - - if (opcode >= cmd_num) { - dev_err(&hdev->pdev->dev, "not support opcode %d.\n", opcode); - return -EOPNOTSUPP; - } - - if (opcode != hclge_ext_func_arr[opcode].opcode) { - dev_err(&hdev->pdev->dev, "opcode %d is not equals %d.\n", - opcode, hclge_ext_func_arr[opcode].opcode); - return -EINVAL; - } - - return hclge_ext_func_arr[opcode].priv_ops(handle, opcode, data, - length); -} -#endif -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h deleted file mode 100644 index 74d7b0f..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_ext.h +++ /dev/null @@ -1,142 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2017 Hisilicon Limited. */ - -#ifndef __HCLGE_EXT_H -#define __HCLGE_EXT_H -#include <linux/types.h> -#include "hnae3.h" - -#ifdef CONFIG_IT_VALIDATION -#define HCLGE_SFP_INFO_LEN 6 -#define HCLGE_SFP_INFO_SIZE 140 -#define HCLGE_8211_PHY_INDIRECT_PAGE 0xa43 -#define HCLGE_8211_PHY_INDIRECT_REG 0x1b -#define HCLGE_8211_PHY_INDIRECT_DATA 0x1c -#define HCLGE_8211_PHY_INDIRECT_RANGE1_S 0xDC0 -#define HCLGE_8211_PHY_INDIRECT_RANGE1_E 0xDCF -#define HCLGE_8211_PHY_INDIRECT_RANGE2_S 0xDE0 -#define HCLGE_8211_PHY_INDIRECT_RANGE2_E 0xDF0 - -#define HCLGE_OPC_CONFIG_NIC_CLOCK 0x0060 - -#define PORT_QUERY_TYPE_SFP 1 - -struct hclge_chip_id_cmd { - u32 chip_id; - u32 rsv[5]; -}; - -struct hclge_sfp_info_para { - u8 *buff; - u16 offset; - u16 size; - u16 *outlen; -}; - -struct hclge_sfp_info { - u32 sfpinfo[6]; -}; - -struct hclge_led_state { - u32 type; - u32 status; -}; - -struct hclge_pfc_storm_para { - u32 dir; - u32 enable; - u32 period_ms; - u32 times; - u32 recovery_period_ms; -}; - -struct hclge_phy_para { - u32 page_select_addr; - u32 reg_addr; - u16 page; - u16 data; -}; - -struct hclge_sfp_enable_cmd { - u32 set_sfp_enable_flag; - u32 rsv[5]; -}; - -struct hclge_sfp_present_cmd { - u32 sfp_present; - u32 rsv[5]; -}; - -struct hclge_lamp_signal { - u8 error; - u8 locate; - u8 activity; -}; - -struct hclge_mac_table_para { - u8 op_cmd; - u8 mac_addr[ETH_ALEN]; -}; - -enum hclge_ext_op_code { - HCLGE_EXT_OPC_CLEAN_STATS64 = 0, - HCLGE_EXT_OPC_GET_CHIPID, - HCLGE_EXT_OPC_GET_SFPINFO, - HCLGE_EXT_OPC_SET_SFP_STATE, - HCLGE_EXT_OPC_GET_CHIP_NUM, - HCLGE_EXT_OPC_GET_PORT_NUM, - HCLGE_EXT_OPC_SET_LED, - HCLGE_EXT_OPC_GET_PRESENT, - HCLGE_EXT_OPC_DISABLE_LANE, - HCLGE_EXT_OPC_GET_LANE_STATUS, - HCLGE_EXT_OPC_GET_LED_SIGNAL, - HCLGE_EXT_OPC_SET_MAC_STATE, - HCLGE_EXT_OPC_CONFIG_CLOCK, - HCLGE_EXT_OPC_GET_PFC_STORM_PARA, - HCLGE_EXT_OPC_SET_PFC_STORM_PARA, - HCLGE_EXT_OPC_GET_PHY_REG, - HCLGE_EXT_OPC_SET_PHY_REG, - HCLGE_EXT_OPC_GET_MAC_ID, - HCLGE_EXT_OPC_OPT_MAC_TABLE, - HCLGE_EXT_OPC_RESET, - HCLGE_EXT_OPC_GET_HILINK_REF_LOS, - HCLGE_EXT_OPC_GET_8211_PHY_REG, - HCLGE_EXT_OPC_SET_8211_PHY_REG, - HCLGE_EXT_OPC_GET_PORT_TYPE, -}; - -enum hclge_opt_table_code { - HCLGE_OPT_TABLE_LOOKUP, - HCLGE_OPT_TABLE_ADD, - HCLGE_OPT_TABLE_DEL, -}; - -struct hclge_ext_func { - int opcode; - int (*priv_ops)(struct hnae3_handle *handle, int opcode, - void *data, int length); -}; - -enum hclge_ext_opcode_type { - /* misc command */ - HCLGE_OPC_CHIP_ID_GET = 0x7003, - HCLGE_OPC_IMP_COMMIT_ID_GET = 0x7004, - HCLGE_OPC_GET_CHIP_NUM = 0x7005, - HCLGE_OPC_GET_PORT_NUM = 0x7006, - HCLGE_OPC_SET_LED = 0x7007, - HCLGE_OPC_DISABLE_NET_LANE = 0x7008, - HCLGE_OPC_CFG_PAUSE_STORM_PARA = 0x7019, - HCLGE_OPC_CFG_GET_HILINK_REF_LOS = 0x701B, - /*SFP command */ - HCLGE_OPC_SFP_GET_INFO = 0x7100, - HCLGE_OPC_SFP_GET_PRESENT = 0x7101, - HCLGE_OPC_SFP_SET_STATUS = 0x7102, - HCLGE_OPC_SFP_GET_PORT_INFO = 0x7104, -}; - -int hclge_ext_ops_handle(struct hnae3_handle *handle, int opcode, - void *data, int length); -void hclge_reset_task_schedule_it(struct hclge_dev *hdev); -#endif -#endif - diff --git a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.c b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.c index fcb4401..b8cab16 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.c @@ -17,7 +17,6 @@ #include "hclge_cmd.h" #include "hclge_main.h" #include "hnae3.h" -#include "hclge_ext.h" #include "hclge_main_it.h"
#ifdef CONFIG_IT_VALIDATION @@ -46,17 +45,16 @@ int nic_unregister_event(void) } EXPORT_SYMBOL(nic_unregister_event);
-void nic_call_event(struct net_device *netdev, - enum hnae3_event_type_custom event_t) +static void nic_call_event(struct net_device *netdev, + enum hnae3_event_type_custom event_t) { if (nic_event_call) { nic_event_call(netdev, event_t); netdev_info(netdev, "report event %d\n", event_t); } } -EXPORT_SYMBOL(nic_call_event);
-void hclge_handle_imp_error_it(struct hnae3_handle *handle) +static void hclge_handle_imp_error_it(struct hnae3_handle *handle) { struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; @@ -85,6 +83,14 @@ void hclge_handle_imp_error_it(struct hnae3_handle *handle)
}
+static void hclge_reset_task_schedule_it(struct hclge_dev *hdev) +{ + if (!test_bit(HCLGE_STATE_REMOVING, &hdev->state) && + !test_and_set_bit(HCLGE_STATE_RST_SERVICE_SCHED, &hdev->state)) + mod_delayed_work_on(cpumask_first(&hdev->affinity_mask), + system_wq, &hdev->service_task, 0); +} + void hclge_reset_event_it(struct pci_dev *pdev, struct hnae3_handle *handle) { struct hnae3_ae_dev *ae_dev = pci_get_drvdata(pdev); @@ -168,10 +174,6 @@ bool hclge_reset_done_it(struct hnae3_handle *handle, bool done)
int hclge_init_it(void) { -#ifdef CONFIG_HNS3_TEST - hclge_ops.priv_ops = hclge_ext_ops_handle; -#endif - hclge_ops.reset_event = hclge_reset_event_it; hclge_ops.reset_done = hclge_reset_done_it; hclge_ops.handle_imp_error = hclge_handle_imp_error_it; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.h b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.h index e20e4b5..cd1636e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns-customer/hns3pf/hclge_main_it.h @@ -48,7 +48,5 @@ typedef void (*nic_event_fn_t) (struct net_device *netdev, */ int nic_unregister_event(void);
-void nic_call_event(struct net_device *netdev, - enum hnae3_event_type_custom event_t); int hclge_init(void); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c deleted file mode 100644 index 1c49f93..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.c +++ /dev/null @@ -1,115 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#include <linux/init.h> -#include <linux/interrupt.h> -#include <linux/kernel.h> -#include <linux/module.h> -#include <linux/netdevice.h> -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/phy_fixed.h> -#include <linux/platform_device.h> - -#include "hclge_cmd.h" -#include "hclge_main.h" -#include "hnae3.h" -#include "hns3_enet.h" -#include "hns3_cae_cmd.h" -#include "hns3_cae_common.h" - -static int hns3_cae_write_reg_cfg(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size) -{ - struct reg_param *in_buf = (struct reg_param *)buf_in; - struct hclge_vport *vport = NULL; - struct hclge_dev *hdev = NULL; - struct hclge_desc desc; - int ret; - - vport = hns3_cae_get_vport(net_priv->ae_handle); - hdev = vport->back; - - if (in_buf->bits_width == 64) { - hns3_cae_cmd_setup_basic_desc(&desc, CMDQ_64_COM_CMD_OPCODE, - false); - desc.data[0] = in_buf->addr; - desc.data[1] = in_buf->data[0]; - } else { - hns3_cae_cmd_setup_basic_desc(&desc, CMDQ_32_COM_CMD_OPCODE, - false); - desc.data[0] = in_buf->addr; - desc.data[2] = in_buf->data[0]; - } - ret = hns3_cae_cmd_send(hdev, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "%s fail, ret is %d.\n", __func__, - ret); - return ret; - } - - return 0; -} - -static int hns3_cae_read_reg_cfg(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size) -{ - struct hclge_vport *vport = hns3_cae_get_vport(net_priv->ae_handle); - struct reg_ret_param *out_buf = (struct reg_ret_param *)buf_out; - struct reg_param *in_buf = (struct reg_param *)buf_in; - struct hclge_dev *hdev = vport->back; - struct hclge_desc desc; - bool check = !buf_out || out_size < sizeof(struct reg_param); - int ret; - - if (check) { - pr_err("input param buf_out error in %s function\n", __func__); - return -EFAULT; - } - - if (in_buf->bits_width == 64) - hns3_cae_cmd_setup_basic_desc(&desc, - CMDQ_64_COM_CMD_OPCODE, true); - else - hns3_cae_cmd_setup_basic_desc(&desc, - CMDQ_32_COM_CMD_OPCODE, true); - - desc.data[0] = in_buf->addr; - ret = hns3_cae_cmd_send(hdev, &desc, 1); - if (ret) { - dev_err(&hdev->pdev->dev, "%s fail, ret is %d.\n", __func__, - ret); - return ret; - } - - out_buf->value[0] = desc.data[0]; - if (in_buf->bits_width == 64) - out_buf->value[1] = desc.data[1]; - - return 0; -} - -int hns3_cae_reg_cfg(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, - u32 out_size) -{ - bool check = !buf_in || in_size < sizeof(struct reg_param); - struct reg_param *mode_param = (struct reg_param *)buf_in; - int ret; - - if (check) { - pr_err("input param buf_in error in %s function\n", __func__); - return -EFAULT; - } - - if (mode_param->is_read == 1) - ret = hns3_cae_read_reg_cfg(net_priv, buf_in, in_size, - buf_out, out_size); - else - ret = hns3_cae_write_reg_cfg(net_priv, buf_in, in_size, - buf_out, out_size); - - return ret; -} diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h deleted file mode 100644 index c9af908..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_common.h +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2019 Hisilicon Limited. */ - -#ifndef __HNS3_CAE_COMMON_H -#define __HNS3_CAE_COMMON_H - -#define REG_RDATA_NUM 2 - -#define CMDQ_32_COM_CMD_OPCODE 0xfffd -#define CMDQ_64_COM_CMD_OPCODE 0xffff - -struct reg_param { - u32 addr; - u32 data[REG_RDATA_NUM]; - u8 bits_width; - u8 is_read; -}; - -struct reg_ret_param { - u32 value[REG_RDATA_NUM]; -}; - -int hns3_cae_reg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c index 8d037f4..e3cfa5c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.c @@ -220,13 +220,7 @@ int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, dcb_all_info[curr_dev_idx].pfc_cfg_info.prien = in_info->prien; if (ndev->dcbnl_ops->ieee_setpfc) { -#ifdef CONFIG_EXT_TEST - rtnl_lock(); -#endif ret = ndev->dcbnl_ops->ieee_setpfc(ndev, &pfc); -#ifdef CONFIG_EXT_TEST - rtnl_unlock(); -#endif if (ret) return ret; } @@ -397,13 +391,7 @@ int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, curr_dev_idx);
if (ndev->dcbnl_ops->ieee_setets) { -#ifdef CONFIG_EXT_TEST - rtnl_lock(); -#endif ret = ndev->dcbnl_ops->ieee_setets(ndev, &ets); -#ifdef CONFIG_EXT_TEST - rtnl_unlock(); -#endif if (ret) return ret; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c deleted file mode 100644 index c3b963c..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.c +++ /dev/null @@ -1,422 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#if (defined CONFIG_EXT_TEST) && (defined CONFIG_IT_VALIDATION) -#include "hns3_cae_ext.h" -#include "hns3_ext.h" - -static int hns3_disable_netclk(const struct hns3_nic_priv *net_priv) -{ - struct net_device *netdev = net_priv->netdev; - - return nic_disable_clock(netdev); -} - -static int hns3_get_cpu_affinity(const struct hns3_nic_priv *priv) -{ - struct hns3_enet_tqp_vector *tqp_vector = NULL; - struct hnae3_handle *h = NULL; - int i; - - if (!priv) { - pr_err("invalid input param when get cpu affinity\n"); - return -EINVAL; - } - - h = priv->ae_handle; - if (nic_netdev_match_check(priv->netdev)) - return -ENODEV; - - pr_info("%s : %d irq total.\n", h->pdev->driver->name, - priv->vector_num); - for (i = 0; i < priv->vector_num; i++) { - tqp_vector = &priv->tqp_vector[i]; - if (tqp_vector->irq_init_flag != HNS3_VECTOR_INITED) - continue; - - pr_err("irq %d ==> cpu affinity: %*pb\n", - tqp_vector->vector_irq, - cpumask_pr_args(&tqp_vector->affinity_mask)); - } - - return 0; -} - -static int hns3_affi(const struct hns3_nic_priv *net_priv, void *in) -{ - struct hns3_cpumask_param *cpumask_param = NULL; - cpumask_var_t cpumask_new; - int ret; - - cpumask_param = (struct hns3_cpumask_param *)in; - - if (cpumask_param->affi_exec_flag != HNS3_AFFI_GET_BIT) { - if (!alloc_cpumask_var(&cpumask_new, GFP_KERNEL)) - return -ENOMEM; - - ret = cpumask_parse(cpumask_param->mask, cpumask_new); - if (ret) { - pr_err("parse cpu affinity from user fail, ret = %d\n", - ret); - return ret; - } - - ret = nic_set_cpu_affinity(net_priv->netdev, cpumask_new); - if (ret) { - pr_err("set cpu affinity fail, ret = %d\n", ret); - return ret; - } - } else { - ret = hns3_get_cpu_affinity(net_priv); - if (ret) { - pr_err("get cpu affinity fail, ret = %d\n", ret); - return ret; - } - } - - return ret; -} - -static int hns3_get_chipid(const struct hns3_nic_priv *net_priv, void *out) -{ - u32 chip_id; - int ret; - - ret = nic_get_chipid(net_priv->netdev, &chip_id); - if (!ret) - *(u32 *)out = chip_id; - - return ret; -} - -static int hns3_match_check(const struct hns3_nic_priv *net_priv) -{ - struct net_device *netdev = net_priv->netdev; - - return nic_netdev_match_check(netdev); -} - -static int hns3_set_led(const struct hns3_nic_priv *net_priv, void *in) -{ - struct hns3_led_state_para *para = (struct hns3_led_state_para *)in; - struct net_device *netdev = net_priv->netdev; - - return nic_set_led(netdev, para->type, para->status); -} - -static int hns3_get_sfp_info(const struct hns3_nic_priv *net_priv, void *in, - void *out) -{ - struct hns3_priv_sfp_info_para *para_in = - (struct hns3_priv_sfp_info_para *)in; - struct hns3_priv_sfp_info_para *para_out = - (struct hns3_priv_sfp_info_para *)out; - struct net_device *netdev = net_priv->netdev; - int ret; - - ret = nic_get_sfpinfo(netdev, para_out->buff, para_in->size, - ¶_out->outlen); - - return ret; -} - -static int hns3_get_sfp_present(const struct hns3_nic_priv *net_priv, - void *out) -{ - struct net_device *netdev = net_priv->netdev; - u32 present; - int ret; - - ret = nic_get_sfp_present(netdev, &present); - if (!ret) - *(u32 *)out = present; - - return ret; -} - -static int hns3_set_sfp_state(const struct hns3_nic_priv *net_priv, void *in) -{ - struct net_device *netdev = net_priv->netdev; - bool en = *(bool *)in; - - return nic_set_sfp_state(netdev, en); -} - -static int hns3_clean_stats64(const struct hns3_nic_priv *net_priv) -{ - struct net_device *netdev = net_priv->netdev; - - return nic_clean_stats64(netdev, NULL); -} - -static int hns3_get_chip_num(const struct hns3_nic_priv *net_priv, void *out) -{ - u32 chip_num; - int ret; - - ret = nic_get_chip_num(net_priv->netdev, &chip_num); - if (!ret) - *(u32 *)out = chip_num; - - return ret; -} - -static int hns3_get_port_num(const struct hns3_nic_priv *net_priv, void *out) -{ - u32 port_num; - int ret; - - ret = nic_get_port_num_per_chip(net_priv->netdev, &port_num); - if (!ret) - *(u32 *)out = port_num; - - return ret; -} - -static int hns3_disable_net_lane(const struct hns3_nic_priv *net_priv) -{ - struct net_device *netdev = net_priv->netdev; - - return nic_disable_net_lane(netdev); -} - -static int hns3_get_lane_status(const struct hns3_nic_priv *net_priv, - void *out) -{ - u32 lane_status; - int ret; - - ret = nic_get_net_lane_status(net_priv->netdev, &lane_status); - if (!ret) - *(u32 *)out = lane_status; - - return ret; -} - -static int hns3_set_mac_state(const struct hns3_nic_priv *net_priv, void *in) -{ - struct net_device *netdev = net_priv->netdev; - int enable = *(int *)in; - - return nic_set_mac_state(netdev, enable); -} - -static int hns3_set_pfc_storm_para(const struct hns3_nic_priv *net_priv, - void *in) -{ - struct hns3_pfc_storm_para *para = (struct hns3_pfc_storm_para *)in; - struct net_device *netdev = net_priv->netdev; - - return nic_set_pfc_storm_para(netdev, para->dir, para->enable, - para->period_ms, para->times, - para->recovery_period_ms); -} - -static int hns3_get_pfc_storm_para(const struct hns3_nic_priv *net_priv, - void *in, void *out) -{ - struct hns3_pfc_storm_para *para_in = (struct hns3_pfc_storm_para *)in; - struct net_device *netdev = net_priv->netdev; - struct hns3_pfc_storm_para *para_out = - (struct hns3_pfc_storm_para *)out; - u32 recovery_period_ms; - u32 period_ms; - u32 enable; - u32 times; - u32 dir; - int ret; - - dir = para_in->dir; - ret = nic_get_pfc_storm_para(netdev, dir, &enable, &period_ms, - ×, &recovery_period_ms); - if (!ret) { - para_out->dir = dir; - para_out->enable = enable; - para_out->period_ms = period_ms; - para_out->times = times; - para_out->recovery_period_ms = recovery_period_ms; - } - - return ret; -} - -static int hns3_get_phy_reg(const struct hns3_nic_priv *net_priv, - void *in, void *out, - enum phy_type phy_type) -{ - struct hns3_phy_para *para_out = (struct hns3_phy_para *)out; - struct hns3_phy_para *para_in = (struct hns3_phy_para *)in; - u32 page_select_addr = para_in->page_select_addr; - struct net_device *netdev = net_priv->netdev; - u32 reg_addr = para_in->reg_addr; - u16 page = para_in->page; - u16 data; - int ret; - - if (phy_type == PHY_TYPE_8211) - ret = nic_get_8211_phy_reg(netdev, page_select_addr, page, - reg_addr, &data); - else - ret = nic_get_phy_reg(netdev, page_select_addr, page, reg_addr, - &data); - if (!ret) { - para_out->page = page; - para_out->reg_addr = reg_addr; - para_out->data = data; - } - - return ret; -} - -static int hns3_set_phy_reg(const struct hns3_nic_priv *net_priv, void *in, - enum phy_type phy_type) -{ - struct hns3_phy_para *para = (struct hns3_phy_para *)in; - struct net_device *netdev = net_priv->netdev; - - if (phy_type == PHY_TYPE_8211) - return nic_set_8211_phy_reg(netdev, para->page_select_addr, - para->page, para->reg_addr, - para->data); - else - return nic_set_phy_reg(netdev, para->page_select_addr, - para->page, para->reg_addr, - para->data); -} - -static int hns3_get_macid(const struct hns3_nic_priv *net_priv, void *out) -{ - u32 mac_id; - int ret; - - ret = nic_get_mac_id(net_priv->netdev, &mac_id); - if (!ret) - *(u32 *)out = mac_id; - - return ret; -} - -static int hns3_get_hilink_ref_los(const struct hns3_nic_priv *net_priv, - void *out) -{ - u32 status; - int ret; - - ret = nic_get_hilink_ref_los(net_priv->netdev, &status); - if (!ret) - *(u32 *)out = status; - - return ret; -} - -static int hns3_get_port_type(const struct hns3_nic_priv *net_priv, void *out) -{ - u32 wire_type; - int ret; - - ret = nic_get_port_wire_type(net_priv->netdev, &wire_type); - if (!ret) - *(u32 *)out = wire_type; - - return ret; -} - -int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size) -{ - struct cmd_ext_driver_param *ext_param_out = - (struct cmd_ext_driver_param *)buf_out; - struct cmd_ext_driver_param *ext_param_in = - (struct cmd_ext_driver_param *)buf_in; - bool check = !buf_in || in_size < sizeof(struct cmd_ext_driver_param) || - !buf_out || out_size < sizeof(struct cmd_ext_driver_param); - void *out = NULL; - void *in = NULL; - int ret; - - if (check) { - pr_err("input parameter error in %s function\n", __func__); - return -EFAULT; - } - - in = ext_param_in->buf; - out = ext_param_out->buf; - - switch (ext_param_in->op_code) { - case EXT_AFFI_MASK: - ret = hns3_affi(net_priv, in); - break; - case EXT_DISABLE_NET_CLK: - ret = hns3_disable_netclk(net_priv); - break; - case EXT_GET_CHIP_ID: - ret = hns3_get_chipid(net_priv, out); - break; - case EXT_NET_MATCH_CHECK: - ret = hns3_match_check(net_priv); - break; - case EXT_SET_LED: - ret = hns3_set_led(net_priv, in); - break; - case EXT_GET_SFP_INFO: - ret = hns3_get_sfp_info(net_priv, in, out); - break; - case EXT_GET_SFP_PRESENT: - ret = hns3_get_sfp_present(net_priv, out); - break; - case EXT_SET_SFP_STATE: - ret = hns3_set_sfp_state(net_priv, in); - break; - case EXT_CLEAN_STATS64: - ret = hns3_clean_stats64(net_priv); - break; - case EXT_GET_CHIP_NUM: - ret = hns3_get_chip_num(net_priv, out); - break; - case EXT_GET_PORT_NUM: - ret = hns3_get_port_num(net_priv, out); - break; - case EXT_DISABLE_NET_LANE: - ret = hns3_disable_net_lane(net_priv); - break; - case EXT_GET_LANE_STATUS: - ret = hns3_get_lane_status(net_priv, out); - break; - case EXT_SET_MAC_STATE: - ret = hns3_set_mac_state(net_priv, in); - break; - case EXT_SET_PFC_STORM_PARA: - ret = hns3_set_pfc_storm_para(net_priv, in); - break; - case EXT_GET_PFC_STORM_PARA: - ret = hns3_get_pfc_storm_para(net_priv, in, out); - break; - case EXT_GET_PHY_REG: - ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_1512); - break; - case EXT_SET_PHY_REG: - ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_1512); - break; - case EXT_GET_MAC_ID: - ret = hns3_get_macid(net_priv, out); - break; - case EXT_GET_HILINK_REF_LOS: - ret = hns3_get_hilink_ref_los(net_priv, out); - break; - case EXT_GET_8211_PHY_REG: - ret = hns3_get_phy_reg(net_priv, in, out, PHY_TYPE_8211); - break; - case EXT_SET_8211_PHY_REG: - ret = hns3_set_phy_reg(net_priv, in, PHY_TYPE_8211); - break; - case EXT_GET_PORT_TYPE: - ret = hns3_get_port_type(net_priv, out); - break; - default: - ret = -EFAULT; - } - - return ret; -} -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h deleted file mode 100644 index aca4988..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_ext.h +++ /dev/null @@ -1,68 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2019 Hisilicon Limited. */ - -#ifndef __HNS3_CAE_EXT_H -#define __HNS3_CAE_EXT_H - -#include "hnae3.h" -#include "hns3_enet.h" - -#define HNS3_AFFI_SET_BIT BIT(0) -#define HNS3_AFFI_GET_BIT BIT(1) - -#define HNS3_AFFI_MAX_LEN 34 - -enum ext_op_code { - EXT_AFFI_MASK = 0, - EXT_DISABLE_NET_CLK, - EXT_GET_CHIP_ID, - EXT_NET_MATCH_CHECK, - EXT_SET_LED, - EXT_GET_SFP_INFO, - EXT_GET_SFP_PRESENT, - EXT_SET_SFP_STATE, - EXT_CLEAN_STATS64, - EXT_GET_CHIP_NUM, - EXT_GET_PORT_NUM, - EXT_DISABLE_NET_LANE, - EXT_GET_LANE_STATUS, - EXT_SET_MAC_STATE, - EXT_SET_PFC_STORM_PARA, - EXT_GET_PFC_STORM_PARA, - EXT_GET_PHY_REG, - EXT_SET_PHY_REG, - EXT_GET_MAC_ID, - EXT_GET_HILINK_REF_LOS, - EXT_GET_8211_PHY_REG, - EXT_SET_8211_PHY_REG, - EXT_GET_PORT_TYPE, -}; - -enum phy_type { - PHY_TYPE_8211 = 0, - PHY_TYPE_1512, -}; - -struct hns3_cpumask_param { - u32 affi_exec_flag; - char mask[HNS3_AFFI_MAX_LEN]; -}; - -struct hns3_priv_sfp_info_para { - u8 buff[768]; - u16 offset; - u16 size; - u16 outlen; -}; - -struct cmd_ext_driver_param { - u32 op_code; - u32 judge_class; - u8 buf[1024]; -}; - -int hns3_ext_interface_test(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size); - -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c index ad84900..c012c7e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_init.c @@ -20,7 +20,6 @@ #include "hns3_cae_cmd.h" #include "hns3_cae_tm.h" #include "hns3_cae_dcb.h" -#include "hns3_cae_pkt.h" #include "hns3_cae_mac.h" #include "hns3_cae_dfx.h" #include "hns3_cae_vlan.h" @@ -29,12 +28,9 @@ #include "hns3_cae_promisc.h" #include "hns3_cae_fd.h" #include "hns3_cae_rss.h" -#include "hns3_cae_common.h" #include "hns3_cae_qres.h" #include "hns3_cae_stat.h" #include "hns3_cae_irq.h" -#include "hns3_cae_lamp.h" -#include "hns3_cae_ext.h" #include "hns3_cae_pfc_storm.h" #include "hns3_cae_xsfp.h" #include "hns3_cae_port.h" @@ -44,7 +40,6 @@ #include "hns3_cae_dcqcn.h" #include "hns3_cae_reset.h" #include "hns3_cae_gro.h" -#include "hns3_cae_mactbl.h" #include "hns3_cae_led.h"
#define MAX_MSG_OUT_SIZE (1024U * 2048U) @@ -153,7 +148,7 @@ static int hns3_cae_netdev_match_check(struct net_device *netdev) netdev->ethtool_ops->get_drvinfo(netdev, &drv_info);
if (!strncmp(drv_info.driver, hns3_driver_name, - strlen(hns3_driver_name))) + strlen(hns3_driver_name) + 1)) return 0;
netdev_err(netdev, "match hns3 driver name(%s) failed\n", @@ -243,7 +238,6 @@ struct drv_module_handle driv_module_cmd_handle[] = { {DFX_INFO_CMD, hns3_cae_get_dfx_info}, {DFX_READ_CMD, hns3_cae_read_dfx_info}, {EVENT_INJECTION_CMD, hns3_cae_event_injection}, - {SEND_PKT, hns3_cae_send_pkt}, {RX_PRIV_BUFF_WL_CFG, hns3_cae_rx_priv_buff_wl_cfg}, {RX_COMMON_THRD_CFG, hns3_cae_common_thrd_cfg}, {RX_COMMON_WL_CFG, hns3_cae_common_wl_cfg}, @@ -257,26 +251,16 @@ struct drv_module_handle driv_module_cmd_handle[] = { {GET_BD_BUFF_SIZE, hns3_gro_dump_bd_buff_size}, {PROMISC_MODE_CFG, hns3_promisc_mode_cfg}, {QINFO_CFG, hns3_cae_qinfo_cfg}, -#ifdef CONFIG_IT_VALIDATION - {MACTABLE_CFG, hns3_cae_opt_mactbl}, -#endif {CLEAN_STATS, hns3_cae_clean_stats}, {FD_CFG, hns3_cae_fd_cfg}, {RSS_GENERIC_CFG, hns3_cae_rss_cfg}, - {REG_CFG, hns3_cae_reg_cfg}, {COM_REG_CFG, hns3_cae_common_cmd_send}, {GRO_CFG, hns3_gro_age_handle}, - {M7_CMD_MODE_CFG, hns3_m7_cmd_handle}, {QRES_CFG, hns3_cae_qres_cfg}, {STAT_CFG, hns3_stat_mode_cfg}, {IRQ_CFG, hns3_irq_lli_cfg}, {VLAN_UPMAPPING, hns3_cae_upmapping_cfg}, -#ifdef CONFIG_EXT_TEST - {LAMP_CFG, hns3_lamp_cfg}, - {EXTERN_INTERFACE_CFG, hns3_ext_interface_test}, -#else {EXTERN_INTERFACE_CFG, hns3_cae_pfc_storm_cfg}, -#endif {XSFP_CFG, hns3_xsfp_cfg}, {SHOW_PORT_INFO, hns3_get_port_info}, {SHOW_HILINK_PARAM, hns3_get_hilink_param}, @@ -342,7 +326,6 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd, pr_err("alloc out buffer failed\n"); goto out_free_buf_in; } -#ifndef CONFIG_EXT_TEST /** * After decoupling with driver, the scenario of hns driver unregister * must be considered. In this scenario, driver unregister may happened @@ -352,7 +335,6 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd, * code yet, so we don't need lock. */ rtnl_lock(); -#endif ret = hns3_cae_k_get_netdev_by_ifname(nt_msg.device_name, &nic_dev); if (ret) { pr_err("can not get the netdevice correctly\n"); @@ -380,18 +362,14 @@ static long hns3_cae_k_unlocked_ioctl(struct file *pfile, unsigned int cmd, ret = -EINVAL; goto out_invalid; } -#ifndef CONFIG_EXT_TEST rtnl_unlock(); -#endif ret = copy_buf_out_to_user(&nt_msg, out_size, buf_out); if (ret) pr_err("copy buf to user failed\n"); goto out_free_buf_out;
out_invalid: -#ifndef CONFIG_EXT_TEST rtnl_unlock(); -#endif out_free_buf_out: free_buff_out(buf_out); out_free_buf_in: diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c deleted file mode 100644 index 57f25e0..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.c +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#ifdef CONFIG_EXT_TEST -#include "hclge_cmd.h" -#include "hnae3.h" -#include "hclge_main.h" -#include "hns3_enet.h" -#include "hns3_cae_lamp.h" - -int hns3_lamp_cfg(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, u32 out_size) -{ - struct net_device *netdev = net_priv->netdev; - struct hns3_lamp_signal *signal = NULL; - struct hns3_lamp_param *param = NULL; - int ret = -1; - - if (!buf_in || in_size < sizeof(struct hns3_lamp_param)) - return -ENODEV; - - param = (struct hns3_lamp_param *)buf_in; - signal = (struct hns3_lamp_signal *)buf_out; - - if (param->op_type == LAMP_OP_GET_SGPIO) { - if (!buf_out || out_size < sizeof(struct hns3_lamp_signal)) - return -ENODEV; - ret = nic_get_led_signal(netdev, signal); - } else if (param->op_type == LAMP_OP_SET_TYPE) { - ret = nic_set_led(netdev, param->type, param->status); - } - - return ret; -} -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h deleted file mode 100644 index 2d8069f..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lamp.h +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2019 Hisilicon Limited. */ - -#ifndef __HNS3_CAE_LAMP_H__ -#define __HNS3_CAE_LAMP_H__ -#include "hclge_cmd.h" -#include "hnae3.h" -#include "hclge_main.h" -#include "hns3_enet.h" - -enum hns3_lamp_spgio_e { - LAMP_OP_GET_SGPIO = 0, - LAMP_OP_SET_TYPE, - LAMP_OP_UNKNOWN -}; - -struct hns3_lamp_param { - u32 op_type; - u32 type; - u32 status; -}; - -struct hns3_lamp_signal { - u8 error; - u8 locate; - u8 activity; -}; - -int hns3_lamp_cfg(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size); -int nic_get_led_signal(struct net_device *ndev, - struct hns3_lamp_signal *signal); -int nic_set_led(struct net_device *ndev, int type, int status); - -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c index fd923ae..d5d9b48 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.c @@ -63,53 +63,3 @@ int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, return 0; }
-int hns3_m7_cmd_handle(const struct hns3_nic_priv *nic_dev, void *buf_in, - u32 in_size, void *buf_out, u32 out_size) -{ - struct hclge_vport *vport = hns3_cae_get_vport(nic_dev->ae_handle); - struct m7_cmd_para *cmd_para = (struct m7_cmd_para *)buf_in; - struct hclge_dev *hdev = vport->back; - struct hclge_desc *desc = NULL; - u32 bd_size; - bool check = !buf_in || in_size < sizeof(struct m7_cmd_para); - int ret; - - if (check) { - pr_err("input param buf_in error in %s function\n", __func__); - return -EFAULT; - } - - bd_size = sizeof(struct hclge_desc) * cmd_para->bd_count; - desc = kzalloc(bd_size, GFP_KERNEL); - if (ZERO_OR_NULL_PTR(desc)) { - pr_err("desc kzalloc failed in m7_cmd_handle function\n"); - return -ENOMEM; - } - if (copy_from_user((void *)desc, cmd_para->bd_data, bd_size)) { - pr_err("copy from user failed in m7_cmd_handle function\n"); - kfree(desc); - return -EFAULT; - } - - ret = hns3_cae_cmd_send(hdev, desc, cmd_para->bd_count); - if (ret) { - dev_err(&hdev->pdev->dev, - "generic cmd send fail, ret is %d.\n", ret); - kfree(desc); - return ret; - } - - if (desc->flag & HCLGE_CMD_FLAG_WR) { - if (!buf_out || out_size < bd_size) { - pr_err("input param buf_out error in %s function\n", - __func__); - kfree(desc); - return -EFAULT; - } - memcpy(buf_out, desc, bd_size); - } - - kfree(desc); - - return 0; -} diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h index 236b5a8..749bf40 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_lib.h @@ -138,6 +138,4 @@ int hns3_cae_common_cmd_send(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size);
-int hns3_m7_cmd_handle(const struct hns3_nic_priv *nic_dev, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c deleted file mode 100644 index 5b9c86a..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#ifdef CONFIG_IT_VALIDATION -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/netdevice.h> -#include <linux/phy_fixed.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/of.h> -#include <linux/of_address.h> - -#include "hclge_cmd.h" -#include "hnae3.h" -#include "hclge_main.h" -#include "hns3_enet.h" -#include "hns3_ext.h" -#include "hns3_cae_mactbl.h" - -int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size) -{ -#ifndef CONFIG_HNS3_TEST - return -EOPNOTSUPP; -#else - struct hns3_mac_tbl_para *out = (struct hns3_mac_tbl_para *)buf_out; - struct hns3_mac_tbl_para *in = (struct hns3_mac_tbl_para *)buf_in; - struct net_device *netdev = net_priv->netdev; - struct hnae3_handle *h = NULL; - bool check = !buf_in || in_size < sizeof(struct hns3_mac_tbl_para) || - !buf_out || out_size < sizeof(struct hns3_mac_tbl_para); - int ret; - - if (check) { - pr_err("input parameter error in %s function\n", __func__); - return -EFAULT; - } - - h = hns3_get_handle(netdev); - if (!h->ae_algo->ops->priv_ops) - return -EOPNOTSUPP; - - out->op_cmd = in->op_cmd; - memcpy(out->mac_addr, in->mac_addr, sizeof(in->mac_addr)); - ret = h->ae_algo->ops->priv_ops(h, HNS3_EXT_OPC_OPT_MAC_TABLE, in, 0); - if (!ret) { - out->result = HNS3_MACTBL_RESULT_SUCCESS; - return 0; - } else if (ret == -ENOENT) { - out->result = HNS3_MACTBL_RESULT_NOEXIST; - return 0; - } - - out->result = HNS3_MACTBL_RESULT_FAIL; - - return ret; -#endif -} -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h deleted file mode 100644 index a96c380..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_mactbl.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2019 Hisilicon Limited. */ - -#ifndef __HNS3_CAE_MACTBL_H__ -#define __HNS3_CAE_MACTBL_H__ - -enum hns3_mac_table_code { - HNS3_MACTBL_OPT_TABLE_LOOKUP, - HNS3_MACTBL_OPT_TABLE_ADD, - HNS3_MACTBL_OPT_TABLE_DEL, -}; - -enum hns3_mac_result_code { - HNS3_MACTBL_RESULT_SUCCESS, - HNS3_MACTBL_RESULT_FAIL, - HNS3_MACTBL_RESULT_NOEXIST, - HNS3_MACTBL_RESULT_NOSPACE -}; - -struct hns3_mac_tbl_para { - u8 op_cmd; - u8 mac_addr[6]; - u8 result; -}; - -int hns3_cae_opt_mactbl(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, - void *buf_out, u32 out_size); - -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c deleted file mode 100644 index 19ffa95..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.c +++ /dev/null @@ -1,743 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -// Copyright (c) 2016-2017 Hisilicon Limited. - -#include <linux/kernel.h> -#include <linux/list.h> -#include <linux/inetdevice.h> -#include <linux/of.h> -#include <linux/of_address.h> -#include <linux/of_net.h> -#include <linux/if_ether.h> -#include <linux/if_vlan.h> -#include <linux/ip.h> -#include <linux/ipv6.h> -#include <linux/kthread.h> - -#include "hns3_enet.h" -#include "hns3_cae_pkt.h" - -#define DEFAULT_PAGE_SIZE 4096 -#define DEFAULT_TCP_MSS 1460 -#define DEFAULT_MIN_PKT_LEN 60 -#define NEXTHDR_HOP 0 - -u8 pkt_head_table[HNS3_CAE_PKT_TYPE_MAX][128] = { - /* ARP */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0xee, 0x08, 0x06, 0x00, 0x01, - 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0xee, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* TCP */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0xee, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0xfd, - 0xe4, 0x33, 0xc0, 0xa8, 0x0a, 0x0a, 0xc0, 0xa8, - 0x0a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* TCP_DSCP */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0xee, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0xfd, - 0xe4, 0x33, 0xc0, 0xa8, 0x0a, 0x0a, 0xc0, 0xa8, - 0x0a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* PAUSE */ - { - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x06, 0x88, 0x08, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* PAUSE_ERR */ - { - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x06, 0x88, 0x08, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* PFC */ - { - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x06, 0x88, 0x08, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* PFC_ERR */ - { - 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x06, 0x88, 0x08, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* IPV4 */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x02, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, 0x40, 0xfd, - 0x75, 0x8b, 0xc0, 0xa8, 0x0a, 0x0a, 0xc0, 0xa8, - 0x0a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - /* IPV4_LOOSE_OPTION */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x03, 0x08, 0x00, - 0x46, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x06, 0x00, 0x00, 0xc0, 0xa8, 0x0a, 0x0b, - 0xc0, 0xa8, 0x0a, 0x0a, - 0x83, 0x00, 0x04, 0x00, - 0x00, 0x64, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x19, 0x09, 0x00, 0x00 - }, - /* IPV4_TRACEROUTE_OPTION */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x03, 0x08, 0x00, - 0x48, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x06, 0x00, 0x00, 0xc0, 0xa8, 0x0a, 0x0b, - 0xc0, 0xa8, 0x0a, 0x0a, - 0x52, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xc0, 0x00, 0x00, 0x01, - 0x00, 0x64, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x19, 0x09, 0x00, 0x00 - }, - /* IPV6 */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x02, 0x86, 0xdd, 0x60, 0x00, - 0x00, 0x00, 0x05, 0xdc, 0x3b, 0xff, 0xfe, 0xc0, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x00, 0xc0, 0xa8, 0x0a, 0x0b, 0xfe, 0xc0, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x00, 0xc0, 0x55, 0x01, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - }, - /* ipv6_extension_routing */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x03, 0x86, 0xdd, - 0x60, 0x00, 0x00, 0x00, 0x05, 0xdc, 0x2b, 0xff, - 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x0a, 0x0b, - 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x0a, 0x0a, - 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x16, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x21, - 0x16, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x22, - 0x00, 0x64, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x15, 0x99, 0x00, 0x00 - }, - /* IPV4+SCTP */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x02, 0x08, 0x00, - 0x45, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x84, 0x00, 0x00, 0x80, 0x05, 0x7a, 0xb5, - 0x80, 0x05, 0x7a, 0xab, - 0x00, 0x64, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, - }, - /* IPV6+SCTP */ - { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xaa, - 0xbb, 0xcc, 0xdd, 0x02, 0x86, 0xdd, - 0x60, 0x00, 0x00, 0x00, 0x00, 0x4a, 0x84, 0xff, - 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x00, 0x00, 0x00, 0x80, 0x05, 0x7a, 0xb5, - 0xfe, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x00, 0x00, 0x00, 0x80, 0x05, 0x7a, 0xab, - 0x00, 0x64, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, - }, -}; - -#define MAX_KTHREAD_NUM 16 -struct kthread_info { - int tid; - struct task_struct *task; - int stop; - const struct hns3_nic_priv *net_priv; - struct hns3_cae_pkt_cfg_info *in_info; - struct hns3_cae_pkt_result_info *out_info; -}; - -struct kthread_info *kthread_table[MAX_KTHREAD_NUM] = {0}; - -/* This mutexes are created for packets send */ -struct mutex pkt_mutex[MAX_KTHREAD_NUM]; - -int is_send_thread(int tid) -{ - return (tid % 2 == 0); -} - -int __get_tid(int queue_id, int is_send) -{ - if (is_send) - return (queue_id * 2) % MAX_KTHREAD_NUM; - else - return (queue_id * 2 + 1) % MAX_KTHREAD_NUM; -} - -void fill_skb_head(struct sk_buff *skb, int mss) -{ - struct ipv6hdr *ip6_hdr = NULL; - int protocol; - - skb->network_header = ETH_HLEN; - if (skb->protocol == htons(ETH_P_8021Q)) { - skb->network_header += VLAN_HLEN; - protocol = vlan_get_protocol(skb); - } else { - protocol = skb->protocol; - } - if (protocol == htons(ETH_P_IP)) - skb->transport_header = skb->network_header + - ip_hdr(skb)->ihl * 4; - if (protocol == htons(ETH_P_IPV6)) { - ip6_hdr = (struct ipv6hdr *)skb_network_header(skb); - skb->transport_header = skb->network_header + - sizeof(struct ipv6hdr); - if (ip6_hdr->nexthdr == NEXTHDR_HOP) - skb->transport_header += (skb_transport_header(skb)[1] + - 1) << 3; - skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; - } - - skb_shinfo(skb)->gso_size = mss; -} - -static struct sk_buff *__hns_assemble_skb(struct net_device *ndev, - const void *data, int length, - int queue_id, int mss) -{ - const struct ethhdr *ethhead = (const struct ethhdr *)data; - const char *head_data = (const char *)data; - struct sk_buff *skb = NULL; - struct page *p = NULL; - void *buff = NULL; - int proc_length; - int bnum = 0; - - if (mss <= 0) { - pr_err("mss(=%d) of packet is invalid\n", mss); - return NULL; - } - - /* allocate test skb */ - skb = alloc_skb(256, GFP_KERNEL); - if (!skb) - return NULL; - - skb->protocol = ethhead->h_proto; - skb->queue_mapping = queue_id; - skb->dev = ndev; - skb_reset_mac_header(skb); - - if (length <= 256) { - skb_put(skb, length); - memcpy(&skb->data[0], head_data, length); - } else { - skb_put(skb, 256); - memcpy(&skb->data[0], head_data, 256); - proc_length = length - 256; - while (proc_length > DEFAULT_PAGE_SIZE) { - p = dev_alloc_pages(get_order(DEFAULT_PAGE_SIZE)); - if (!p) { - dev_kfree_skb_any(skb); - return NULL; - } - - buff = page_address(p); - memcpy(buff, head_data + length - proc_length, - DEFAULT_PAGE_SIZE); - skb_add_rx_frag(skb, bnum, p, 0, DEFAULT_PAGE_SIZE, - DEFAULT_PAGE_SIZE); - proc_length -= DEFAULT_PAGE_SIZE; - bnum++; - } - p = dev_alloc_pages(get_order(DEFAULT_PAGE_SIZE)); - if (!p) { - dev_kfree_skb_any(skb); - return NULL; - } - - buff = page_address(p); - memcpy(buff, head_data + length - proc_length, proc_length); - skb_add_rx_frag(skb, bnum, p, 0, proc_length, - DEFAULT_PAGE_SIZE); - } - - fill_skb_head(skb, mss); - - return skb; -} - -void hns3_cae_pkt_type_deal(u8 *payload, struct hns3_cae_pkt_cfg_info *in_info, - struct in_ifaddr *ifa_list, - u8 *pkt_payload, u32 head_len) -{ - u8 payload_data; - int i; - - /* DST_MAC */ - memcpy(payload, in_info->dst_mac, ETH_ALEN); - payload[16] = in_info->pkt_len / 256; - payload[17] = in_info->pkt_len % 256; - - /* checksum */ - memcpy(payload + 24, &in_info->pkt_checksum, 2); - - /* SRC_IP */ - if (ifa_list) - memcpy(payload + 26, &ifa_list->ifa_address, 4); - - /* DST_IP */ - memcpy(payload + 30, in_info->dst_ip, 4); - - /* payload */ - payload_data = in_info->pkt_payload_flag == 1 ? 0xFF : 0; - for (i = 0; i < in_info->pkt_len; i++) - pkt_payload[i] = payload_data; - memcpy(payload + head_len, pkt_payload, in_info->pkt_len - head_len); -} - -void __fill_the_pkt_head(struct net_device *netdev, u8 *payload, - struct hns3_cae_pkt_cfg_info *in_info) -{ - struct in_ifaddr *ifa_list = NULL; - u8 *pkt_payload = NULL; - u32 vlan_tag; - size_t count; - int i; - - pkt_payload = kzalloc((in_info->pkt_len) * sizeof(u8), GFP_KERNEL); - if (ZERO_OR_NULL_PTR(pkt_payload)) - return; - - count = in_info->pkt_len > 128 ? 128 : in_info->pkt_len; - memcpy(payload, pkt_head_table[in_info->type], count); - memcpy(payload + 6, netdev->dev_addr, ETH_ALEN); - ifa_list = (struct in_ifaddr *)netdev->ip_ptr->ifa_list; - - switch (in_info->type) { - case HNS3_CAE_PKT_TYPE_ARP: - memcpy(payload + 22, netdev->dev_addr, ETH_ALEN); - - if (ifa_list) - memcpy(payload + 28, &ifa_list->ifa_address, 4); - - memcpy(payload + 32, in_info->dst_mac, ETH_ALEN); - memcpy(payload + 38, in_info->dst_ip, 4); - break; - case HNS3_CAE_PKT_TYPE_TCP: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - payload[16] = in_info->pkt_len / 256; - payload[17] = in_info->pkt_len % 256; - - if (ifa_list) - memcpy(payload + 26, &ifa_list->ifa_address, 4); - - memcpy(payload + 30, in_info->dst_ip, 4); - break; - case HNS3_CAE_PKT_TYPE_TCP_DSCP: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - payload[15] = (in_info->dscp << 2); - payload[16] = in_info->pkt_len / 256; - payload[17] = in_info->pkt_len % 256; - - if (ifa_list) - memcpy(payload + 26, &ifa_list->ifa_address, 4); - - memcpy(payload + 30, in_info->dst_ip, 4); - break; - case HNS3_CAE_PKT_TYPE_PAUSE: - memcpy(payload + 16, &in_info->pause_time, 2); - break; - case HNS3_CAE_PKT_TYPE_PAUSE_ERR: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - memcpy(payload + 12, &in_info->eth_type, 2); - memcpy(payload + 14, &in_info->pause_code, 2); - memcpy(payload + 16, &in_info->pause_time, 2); - break; - case HNS3_CAE_PKT_TYPE_PFC: - payload[17] = in_info->priority; - for (i = 0; i < 8; i++) { - if ((in_info->priority >> i) & 0x01) - memcpy(payload + 18 + i * 2, - &in_info->pause_time, 2); - } - break; - case HNS3_CAE_PKT_TYPE_PFC_ERR: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - memcpy(payload + 12, &in_info->eth_type, 2); - memcpy(payload + 14, &in_info->pause_code, 2); - payload[17] = in_info->priority; - for (i = 0; i < 8; i++) { - if ((in_info->priority >> i) & 0x01) - memcpy(payload + 18 + i * 2, - &in_info->pause_time, 2); - } - break; - case HNS3_CAE_PKT_TYPE_IPV4: - hns3_cae_pkt_type_deal(payload, in_info, ifa_list, pkt_payload, - 34); - break; - case HNS3_CAE_PKT_TYPE_IPV4_LOOSESRCROUTE_OPTION: - hns3_cae_pkt_type_deal(payload, in_info, ifa_list, pkt_payload, - 58); - break; - case HNS3_CAE_PKT_TYPE_IPV4_TRACEROUTE_OPTION: - if (in_info->pkt_len < IPV4_TRACEROUTE_PKT_LEN) { - dev_err(&netdev->dev, - "pkt_len(=%d) of ipv4 trace route pkt must big than %d.\n", - in_info->pkt_len, IPV4_TRACEROUTE_PKT_LEN); - kfree(pkt_payload); - return; - } - - hns3_cae_pkt_type_deal(payload, in_info, ifa_list, pkt_payload, - IPV4_TRACEROUTE_PKT_LEN); - break; - case HNS3_CAE_PKT_TYPE_IPV6: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - memcpy(payload + 22, in_info->pkt_inet6_addr, 16); - - hns3_cae_pkt_type_deal(payload, in_info, ifa_list, pkt_payload, - 54); - break; - case HNS3_CAE_PKT_TYPE_IPV6_EXTENSION_ROUTING: - if (in_info->pkt_len < IPV6_EXTENSION_PKT_LEN) { - dev_err(&netdev->dev, - "pkt_len(=%d) of ipv6 extension pkt must big than %d.\n", - in_info->pkt_len, IPV6_EXTENSION_PKT_LEN); - kfree(pkt_payload); - return; - } - memcpy(payload, in_info->dst_mac, ETH_ALEN); - memcpy(payload + 22, in_info->pkt_inet6_addr, 16); - - hns3_cae_pkt_type_deal(payload, in_info, ifa_list, pkt_payload, - IPV6_EXTENSION_PKT_LEN); - break; - case HNS3_CAE_PKT_TYPE_SCTP4: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - - /* SRC_IP */ - if (ifa_list) - memcpy(payload + 26, &ifa_list->ifa_address, 4); - - memcpy(payload + 30, in_info->dst_ip, 4); - /* checksum */ - memcpy(payload + 42, &in_info->pkt_checksum_sctp, 4); - break; - case HNS3_CAE_PKT_TYPE_SCTP6: - memcpy(payload, in_info->dst_mac, ETH_ALEN); - memcpy(payload + 22, in_info->pkt_inet6_addr, 16); - /* checksum */ - memcpy(payload + 62, &in_info->pkt_checksum_sctp, 4); - break; - default: - break; - } - - if (in_info->vlan_tag) { - memmove(payload + 16, payload + 12, 48); - vlan_tag = htonl(in_info->vlan_tag); - memcpy(payload + 12, &vlan_tag, sizeof(vlan_tag)); - } - - kfree(pkt_payload); -} - -#define MAX_PKTS_NUM_ONCE 50 - -static int __hns3_cae_change_send_queue(int cur_queue, - struct hns3_cae_pkt_cfg_info *in_info, - u8 *payload) -{ - int queue_id = cur_queue; - - queue_id++; - if (queue_id >= in_info->queue_id + in_info->multi_queue) - queue_id = in_info->queue_id; - - /* use last ip for different queue */ - if (in_info->multi_queue > 1) - payload[33] = queue_id % 255; - - return queue_id; -} - -int __hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, - struct hns3_cae_pkt_cfg_info *in_info, - struct hns3_cae_pkt_result_info *out_info) -{ - struct hnae3_handle *handle = NULL; - struct sk_buff *skb = NULL; - u8 *payload = NULL; - int pkt_len; - int ret = 0; - int i; - int change_flag; - int total_len; - int tid; - int queue_id = in_info->queue_id; - struct net_device *netdev = net_priv->netdev; - - handle = net_priv->ae_handle; - if (queue_id >= handle->kinfo.num_tqps || - queue_id + in_info->multi_queue - 1 >= handle->kinfo.num_tqps || - queue_id < 0) { - pr_err("%s,%d:queue(%d) or multi_queue(%d) is invalid\n", - __func__, __LINE__, - in_info->queue_id, in_info->multi_queue); - return -EINVAL; - } - - pkt_len = in_info->pkt_len; - if (pkt_len < MIN_PKT_LEN) { - dev_err(&netdev->dev, "pkt_len(=%d) is invalid\n", pkt_len); - return -EINVAL; - } - - payload = kzalloc(pkt_len, GFP_KERNEL); - if (ZERO_OR_NULL_PTR(payload)) - return -ENOMEM; - - __fill_the_pkt_head(netdev, payload, in_info); - tid = __get_tid(queue_id, 1); - total_len = 0; - change_flag = MAX_PKTS_NUM_ONCE; - for (i = 0; i < in_info->num; i++) { -skb_again: - if (in_info->multi_queue > 1) { - change_flag--; - if (change_flag <= 0) { - change_flag = MAX_PKTS_NUM_ONCE; - queue_id = - __hns3_cae_change_send_queue(queue_id, - in_info, - payload); - } - } - - skb = __hns_assemble_skb(netdev, payload, pkt_len, - queue_id, in_info->mss); - if (!skb) { - ret = -1; - goto out; - } - -send_again: - if (in_info->new_thread && kthread_table[tid]) { - if (kthread_table[tid]->stop) { - dev_kfree_skb_any(skb); - break; - } - } - - ret = netdev->netdev_ops->ndo_start_xmit(skb, netdev); - if (ret == NETDEV_TX_BUSY) { - if (in_info->multi_queue > 1) { - dev_kfree_skb_any(skb); - change_flag = 0; - goto skb_again; - } - - if (in_info->wait_all_finish) { - schedule(); - goto send_again; - } - - dev_kfree_skb_any(skb); - break; - } - total_len += pkt_len; - } - - out_info->num = i; - out_info->total_len = total_len; -out: - kfree(payload); - return ret; -} - -void hns3_cae_pkt_init(void) -{ - int i; - - for (i = 0; i < MAX_KTHREAD_NUM; i++) - mutex_init(&pkt_mutex[i]); -} - -void hns3_cae_pkt_destroy(void) -{ - int i; - - for (i = 0; i < MAX_KTHREAD_NUM; i++) - mutex_destroy(&pkt_mutex[i]); -} - -int __hns3_cae_new_task(void *arg) -{ - struct kthread_info *info = (struct kthread_info *)arg; - int tid = info->tid; - - if (is_send_thread(tid)) { - __hns3_cae_send_pkt(info->net_priv, - info->in_info, info->out_info); - pr_err("send pkt %d, the total len = %d\n", - info->out_info->num, info->out_info->total_len); - } - - mutex_lock(&pkt_mutex[tid]); - kfree(info->in_info); - kfree(info->out_info); - kfree(info); - kthread_table[tid] = NULL; - mutex_unlock(&pkt_mutex[tid]); - - return 0; -} - -int hns3_cae_create_new_thread(int tid, - const struct hns3_nic_priv *net_priv, - struct hns3_cae_pkt_cfg_info *in_info, - struct hns3_cae_pkt_result_info *out_info) -{ - char name[] = "hns3_cae_pkt00"; - int ret; - - if (kthread_table[tid]) { - pr_err("%s,%d:the thread[%d] is busy!\n", __func__, __LINE__, - tid); - return -EINVAL; - } - - kthread_table[tid] = kzalloc(sizeof(*kthread_table[0]), GFP_KERNEL); - if (ZERO_OR_NULL_PTR(kthread_table[tid])) { - pr_err("%s,%d:thread[%d] mem alloc failed\n", __func__, - __LINE__, tid); - return -ENOMEM; - } - - kthread_table[tid]->tid = tid; - kthread_table[tid]->net_priv = net_priv; - kthread_table[tid]->in_info = kzalloc(sizeof(*in_info), GFP_KERNEL); - if (ZERO_OR_NULL_PTR(kthread_table[tid]->in_info)) { - pr_err("%s,%d:thread[%d] in info alloc failed\n", __func__, - __LINE__, tid); - ret = -ENOMEM; - goto err_in_info_alloc; - } - - kthread_table[tid]->out_info = kzalloc(sizeof(*out_info), GFP_KERNEL); - if (ZERO_OR_NULL_PTR(kthread_table[tid]->out_info)) { - pr_err("%s,%d:thread[%d] out info alloc failed\n", __func__, - __LINE__, tid); - ret = -ENOMEM; - goto err_out_info_alloc; - } - - memcpy(kthread_table[tid]->in_info, in_info, sizeof(*in_info)); - - name[strlen(name) - 2] = tid / 10 + '0'; - name[strlen(name) - 1] = tid % 10 + '0'; - kthread_table[tid]->task = - kthread_run(__hns3_cae_new_task, kthread_table[tid], "%s", name); - if (IS_ERR(kthread_table[tid]->task)) { - pr_err("%s,%d:thread[%d] alloc failed\n", __func__, __LINE__, - tid); - ret = -EAGAIN; - goto err_kthread_alloc; - } - - return 0; - -err_kthread_alloc: - kfree(kthread_table[tid]->out_info); - -err_out_info_alloc: - kfree(kthread_table[tid]->in_info); - -err_in_info_alloc: - kfree(kthread_table[tid]); - kthread_table[tid] = NULL; - - return ret; -} - -void hns3_cae_stop_new_thread(int tid) -{ - mutex_lock(&pkt_mutex[tid]); - if (kthread_table[tid]) - kthread_table[tid]->stop = 1; - mutex_unlock(&pkt_mutex[tid]); -} - -int hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, - void *buf_in, u32 in_size, void *buf_out, - u32 out_size) -{ - struct hns3_cae_pkt_result_info *out_info = - (struct hns3_cae_pkt_result_info *)buf_out; - struct hns3_cae_pkt_cfg_info *in_info = - (struct hns3_cae_pkt_cfg_info *)buf_in; - struct hnae3_handle *handle = NULL; - int queue_id; - int tid; - - if (!in_info || in_size < sizeof(struct hns3_cae_pkt_cfg_info) || - !out_info || out_size < sizeof(struct hns3_cae_pkt_result_info)) { - pr_err("input parameter error in %s function\n", __func__); - return -EFAULT; - } - - handle = net_priv->ae_handle; - queue_id = in_info->queue_id; - if (queue_id >= handle->kinfo.num_tqps || queue_id < 0) { - pr_err("%s,%d:queue(%d) is invalid\n", __func__, __LINE__, - in_info->queue_id); - return -EINVAL; - } - - memset(out_info, 0, sizeof(*out_info)); - tid = __get_tid(in_info->queue_id, 1); - if (in_info->stop_thread) { - hns3_cae_stop_new_thread(tid); - return 0; - } - - if (in_info->new_thread) - return hns3_cae_create_new_thread(tid, net_priv, in_info, - out_info); - - return __hns3_cae_send_pkt(net_priv, in_info, out_info); -} diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h deleted file mode 100644 index ea68c18..00000000 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_pkt.h +++ /dev/null @@ -1,67 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* Copyright (c) 2016-2019 Hisilicon Limited. */ - -#ifndef __HNS3_CAE_PKT_H__ -#define __HNS3_CAE_PKT_H__ - -#include <linux/types.h> - -#define IP_ADDR_LEN 4 -#define IP6_ADDR_LEN 10 -#define MIN_PKT_LEN 64 -#define IPV4_TRACEROUTE_PKT_LEN 66 -#define IPV6_EXTENSION_PKT_LEN 114 - -enum PKT_TYPE { - HNS3_CAE_PKT_TYPE_ARP = 0, - HNS3_CAE_PKT_TYPE_TCP, - HNS3_CAE_PKT_TYPE_TCP_DSCP, - HNS3_CAE_PKT_TYPE_PAUSE, - HNS3_CAE_PKT_TYPE_PAUSE_ERR, - HNS3_CAE_PKT_TYPE_PFC, - HNS3_CAE_PKT_TYPE_PFC_ERR, - HNS3_CAE_PKT_TYPE_IPV4, - HNS3_CAE_PKT_TYPE_IPV4_LOOSESRCROUTE_OPTION, - HNS3_CAE_PKT_TYPE_IPV4_TRACEROUTE_OPTION, - HNS3_CAE_PKT_TYPE_IPV6, - HNS3_CAE_PKT_TYPE_IPV6_EXTENSION_ROUTING, - HNS3_CAE_PKT_TYPE_SCTP4, - HNS3_CAE_PKT_TYPE_SCTP6, - HNS3_CAE_PKT_TYPE_MAX, -}; - -struct hns3_cae_pkt_cfg_info { - int queue_id; - int type; - int pkt_len; - int num; - int mss; - int new_thread; - int stop_thread; - int wait_all_finish; - u32 vlan_tag; - u16 pause_time; - u16 eth_type; - u16 pause_code; - u8 priority; - u8 dscp; - u8 dst_mac[ETH_ALEN]; - u8 dst_ip[IP_ADDR_LEN]; - int multi_queue; - int pkt_payload_flag; - u16 pkt_checksum; - u32 pkt_checksum_sctp; - u16 pkt_inet6_addr[IP6_ADDR_LEN]; -}; - -struct hns3_cae_pkt_result_info { - int total_len; - int num; -}; - -int hns3_cae_send_pkt(const struct hns3_nic_priv *net_priv, void *buf_in, - u32 in_size, void *buf_out, u32 out_size); -void hns3_cae_pkt_init(void); -void hns3_cae_pkt_destroy(void); - -#endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c index 78d270e..cd568e2 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_port.c @@ -17,8 +17,8 @@ #define BD_NUM_6 6 #define BD_NUM_7 7
-void fill_port_info(struct hclge_port_info *get_port_info_out, - struct hclge_desc *port_desc, u32 bd_num) +static void fill_port_info(struct hclge_port_info *get_port_info_out, + struct hclge_desc *port_desc, u32 bd_num) { u8 *dest_data = NULL; u8 *tmp_buff = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c index b9e8d1f..a337eab 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_promisc.c @@ -45,6 +45,7 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { +#define PROMISC_EN_MAX_VAL 0x1 bool check = !buf_in || in_size < sizeof(struct promisc_mode_param); struct promisc_mode_param *mode_param = NULL; struct hclge_promisc_cfg_cmd *req = NULL; @@ -76,16 +77,22 @@ int hns3_set_promisc_mode_cfg(const struct hns3_nic_priv *nic_dev, switch (mode_param->type) { case HNS3_UNICAST: req->flag &= ~BIT(HNS3_CAE_UC_PROMISC_EN_B); + if (mode_param->uc > PROMISC_EN_MAX_VAL) + return -EINVAL; req->flag |= (mode_param->uc << HNS3_CAE_UC_PROMISC_EN_B) | HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; break; case HNS3_MULTICAST: req->flag &= ~BIT(HNS3_CAE_MC_PROMISC_EN_B); + if (mode_param->mc > PROMISC_EN_MAX_VAL) + return -EINVAL; req->flag |= (mode_param->mc << HNS3_CAE_MC_PROMISC_EN_B) | HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; break; case HNS3_BROADCAST: req->flag &= ~BIT(HNS3_CAE_BC_PROMISC_EN_B); + if (mode_param->bc > PROMISC_EN_MAX_VAL) + return -EINVAL; req->flag |= (mode_param->bc << HNS3_CAE_BC_PROMISC_EN_B) | HCLGE_PROMISC_TX_EN_B | HCLGE_PROMISC_RX_EN_B; break; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c index a984107..a55b8f3c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.c @@ -3,7 +3,7 @@
#include "hns3_cae_qinfo.h"
-int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -16,7 +16,7 @@ int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -29,7 +29,7 @@ int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -40,7 +40,7 @@ int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -51,7 +51,7 @@ int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -64,7 +64,7 @@ int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -77,7 +77,7 @@ int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -88,7 +88,7 @@ int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id) return num; }
-int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id) +static int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id) { struct hns3_enet_ring *ring = NULL; int num; @@ -146,5 +146,6 @@ int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, out_info->tx_tail = tx_tail; out_info->tx_ebd = tx_ebd; out_info->tx_fbd = tx_fbd; + return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h index 46ab594..8e1f697 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qinfo.h @@ -25,14 +25,6 @@ struct qinfo_param { int rx_fbd; };
-int hns3_get_q_rx_fbd(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_ebd(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_fbd(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_ebd(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_tail(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_rx_head(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_tail(const struct hns3_nic_priv *net_priv, int ring_id); -int hns3_get_q_tx_head(const struct hns3_nic_priv *net_priv, int ring_id); int hns3_cae_qinfo_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c index fb37c73..17fece5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qres.c @@ -3,8 +3,8 @@
#include "hns3_cae_qres.h"
-int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id, - enum param_type type) +static int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, + int ring_id, enum param_type type) { struct hns3_enet_ring *ring = NULL; int tqps_num; @@ -51,8 +51,8 @@ int hns3_get_qres_rx_value(const struct hns3_nic_priv *net_priv, int ring_id, return num; }
-int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id, - enum param_type type) +static int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, + int ring_id, enum param_type type) { struct hns3_enet_ring *ring = NULL; int num; @@ -97,8 +97,8 @@ int hns3_get_qres_tx_value(const struct hns3_nic_priv *net_priv, int ring_id, return num; }
-void fill_queue_info(const struct hns3_nic_priv *net_priv, - struct qres_param *out_info, int ring_id) +static void fill_queue_info(const struct hns3_nic_priv *net_priv, + struct qres_param *out_info, int ring_id) { /* rx info */ out_info->qid = ring_id; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c index 1c95f65..947bc55 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_reset.c @@ -64,8 +64,7 @@ int hns3_cae_nic_timeout_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size) { - struct tx_timeout_param *out_info = - (struct tx_timeout_param *)buf_out; + struct tx_timeout_param *out_info = (struct tx_timeout_param *)buf_out; struct tx_timeout_param *in_info = (struct tx_timeout_param *)buf_in; bool check = !buf_in || in_size < sizeof(struct tx_timeout_param); struct net_device *netdev = net_priv->netdev; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c index 1a3efcf..8d75917 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.c @@ -20,8 +20,9 @@ static int hns3_cae_tm_schd_mode_set(struct hclge_dev *hdev, { struct hclge_desc desc;
+ if (mode > HCLGE_SCH_MODE_DWRR) + return -EINVAL; hns3_cae_cmd_setup_basic_desc(&desc, opcode, false); - if (mode == HCLGE_SCH_MODE_DWRR) desc.data[1] = 1; else @@ -48,7 +49,7 @@ static int hns3_cae_tm_schd_mode_get(struct hclge_dev *hdev, return ret; }
-int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id) +static int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id) { struct hclge_nq_to_qs_link_cmd *map = NULL; struct hclge_desc desc; @@ -61,7 +62,7 @@ int hns3_cae_tm_q_to_qs_set(struct hclge_dev *hdev, u16 q_id, u16 qs_id) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id) +static int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id) { struct hclge_nq_to_qs_link_cmd *map = NULL; struct hclge_desc desc; @@ -78,7 +79,7 @@ int hns3_cae_tm_q_to_qs_get(struct hclge_dev *hdev, u16 q_id, u16 *qs_id) return ret; }
-int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri) +static int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri) { struct hclge_qs_to_pri_link_cmd *map = NULL; struct hclge_desc desc; @@ -93,7 +94,7 @@ int hns3_cae_tm_qs_to_pri_set(struct hclge_dev *hdev, u16 qs_id, u8 pri) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri) +static int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri) { struct hclge_qs_to_pri_link_cmd *map = NULL; struct hclge_desc desc; @@ -109,7 +110,7 @@ int hns3_cae_tm_qs_to_pri_get(struct hclge_dev *hdev, u16 qs_id, u8 *pri) return ret; }
-int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr) +static int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr) { struct hclge_qs_weight_cmd *weight = NULL; struct hclge_desc desc; @@ -122,7 +123,8 @@ int hns3_cae_tm_qs_weight_set(struct hclge_dev *hdev, u16 qs_id, u8 dwrr) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev, u16 qs_id, u8 *dwrr) +static int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev, + u16 qs_id, u8 *dwrr) { struct hclge_qs_weight_cmd *weight = NULL; struct hclge_desc desc; @@ -138,7 +140,8 @@ int hns3_cae_tm_qs_weight_get(struct hclge_dev *hdev, u16 qs_id, u8 *dwrr) return ret; }
-int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev, u8 pri_id, u8 dwrr) +static int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev, + u8 pri_id, u8 dwrr) { struct hclge_priority_weight_cmd *weight = NULL; struct hclge_desc desc; @@ -151,7 +154,8 @@ int hns3_cae_tm_pri_weight_set(struct hclge_dev *hdev, u8 pri_id, u8 dwrr) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev, u8 pri_id, u8 *dwrr) +static int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev, + u8 pri_id, u8 *dwrr) { struct hclge_priority_weight_cmd *weight = NULL; struct hclge_desc desc; @@ -167,7 +171,8 @@ int hns3_cae_tm_pri_weight_get(struct hclge_dev *hdev, u8 pri_id, u8 *dwrr) return ret; }
-int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev, u8 pg_id, u8 bitmap) +static int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev, + u8 pg_id, u8 bitmap) { struct hclge_pg_to_pri_link_cmd *map = NULL; struct hclge_desc desc; @@ -181,8 +186,8 @@ int hns3_cae_tm_pri_pg_bitmap_set(struct hclge_dev *hdev, u8 pg_id, u8 bitmap) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id, - u8 *bitmap) +static int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id, + u8 *bitmap) { struct hclge_pg_to_pri_link_cmd *map = NULL; struct hclge_desc desc; @@ -200,8 +205,8 @@ int hns3_cae_tm_pri_pg_bitmap_get(struct hclge_dev *hdev, u8 pg_id, return 0; }
-int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id, - u32 map) +static int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id, + u32 map) { struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd = NULL; struct hclge_desc desc; @@ -217,8 +222,8 @@ int hns3_cae_tm_qs_bp_bitmap_set(struct hclge_dev *hdev, u8 tc, u8 gp_id, return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id, - u32 *map) +static int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id, + u32 *map) { struct hclge_bp_to_qs_map_cmd *bp_to_qs_map_cmd = NULL; struct hclge_desc desc; @@ -237,9 +242,9 @@ int hns3_cae_tm_qs_bp_bitmap_get(struct hclge_dev *hdev, u8 tc, u8 gp_id, return 0; }
-int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev, - enum hclge_shap_bucket bucket, u8 pri_id, - u32 shaper) +static int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev, + enum hclge_shap_bucket bucket, + u8 pri_id, u32 shaper) { struct hclge_pri_shapping_cmd *shap_cfg_cmd = NULL; enum hclge_opcode_type opcode; @@ -255,9 +260,9 @@ int hns3_cae_tm_pri_shapping_set(struct hclge_dev *hdev, return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev, - enum hclge_shap_bucket bucket, u8 pri_id, - u32 *shaper) +static int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev, + enum hclge_shap_bucket bucket, + u8 pri_id, u32 *shaper) { struct hclge_pri_shapping_cmd *shap_cfg_cmd = NULL; enum hclge_opcode_type opcode; @@ -275,7 +280,7 @@ int hns3_cae_tm_pri_shapping_get(struct hclge_dev *hdev, return ret; }
-int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr) +static int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr) { struct hclge_pg_weight_cmd *weight = NULL; struct hclge_desc desc; @@ -288,7 +293,7 @@ int hns3_cae_tm_pg_weight_set(struct hclge_dev *hdev, u8 pg_id, u8 dwrr) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr) +static int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr) { struct hclge_pg_weight_cmd *weight = NULL; struct hclge_desc desc; @@ -304,9 +309,9 @@ int hns3_cae_tm_pg_weight_get(struct hclge_dev *hdev, u8 pg_id, u8 *dwrr) return ret; }
-int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev, - enum hclge_shap_bucket bucket, u8 pg_id, - u32 shaper) +static int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev, + enum hclge_shap_bucket bucket, + u8 pg_id, u32 shaper) { struct hclge_pg_shapping_cmd *shap_cfg_cmd = NULL; enum hclge_opcode_type opcode; @@ -322,9 +327,9 @@ int hns3_cae_tm_pg_shapping_set(struct hclge_dev *hdev, return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev, - enum hclge_shap_bucket bucket, u8 pg_id, - u32 *shaper) +static int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev, + enum hclge_shap_bucket bucket, + u8 pg_id, u32 *shaper) { struct hclge_pg_shapping_cmd *shap_cfg_cmd = NULL; enum hclge_opcode_type opcode; @@ -343,7 +348,7 @@ int hns3_cae_tm_pg_shapping_get(struct hclge_dev *hdev, return ret; }
-int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper) +static int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper) { struct hclge_port_shapping_cmd *shap_cfg_cmd = NULL; enum hclge_opcode_type opcode; @@ -357,7 +362,7 @@ int hns3_cae_tm_port_shapping_set(struct hclge_dev *hdev, u32 shaper) return hns3_cae_cmd_send(hdev, &desc, 1); }
-int hns3_cae_tm_port_shapping_get(struct hclge_dev *hdev, u32 *shaper) +static int hns3_cae_tm_port_shapping_get(struct hclge_dev *hdev, u32 *shaper) { struct hclge_port_shapping_cmd *shap_cfg_cmd = NULL; enum hclge_opcode_type opcode; @@ -474,8 +479,9 @@ int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, return -EFAULT; }
+ if (in_info->queue_id >= MAX_QUEUE_ID) + return -EINVAL; is_read = in_info->is_read; - if (is_read) { check = !buf_out || out_size < sizeof(struct hns3_cae_queue_cfg_info); @@ -492,6 +498,8 @@ int hns3_cae_queue_cfg(const struct hns3_nic_priv *net_priv, return -1; } } else { + if (in_info->qs >= MAX_QSET_ID) + return -EINVAL; if (hns3_cae_tm_q_to_qs_set(hdev, in_info->queue_id, in_info->qs)) { pr_err("%s,%d:set queue(%d) to qs(%d) failed!\n", @@ -571,6 +579,8 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv,
is_read = in_info->is_read; qs_id = in_info->qs_id; + if (qs_id >= MAX_QSET_ID) + return -EINVAL; gp_id = qs_id / 32; offset = qs_id % 32;
@@ -618,7 +628,6 @@ int hns3_cae_qs_cfg(const struct hns3_nic_priv *net_priv, __func__, __LINE__, qs_id, ret); return -1; } - } else { if ((in_info->flag & HNS3_TM_QSET_MAPPING_FLAG) && hns3_cae_tm_qs_to_pri_set(hdev, qs_id, in_info->pri)) { @@ -661,6 +670,10 @@ static int hns3_cae_pri_pg_set_map(struct hclge_dev *hdev, u8 bitmap = map; u16 pri_id = in_info->pri_id;
+ if (pri_id >= MAX_TC_NUM) + return -EINVAL; + if (in_info->pg >= MAX_PG_NUM) + return -EINVAL; /* clear old map */ if (in_info->pg != cur_pg) { bitmap &= ~BIT(pri_id); @@ -712,8 +725,9 @@ int hns3_cae_pri_cfg(const struct hns3_nic_priv *net_priv, }
is_read = in_info->is_read; - pri_id = in_info->pri_id; + if (pri_id >= MAX_TC_NUM) + return -EINVAL;
for (cur_pg = 0; cur_pg < MAX_PG_NUM; cur_pg++) { bitmap = 0; @@ -838,6 +852,8 @@ int hns3_cae_pg_cfg(const struct hns3_nic_priv *net_priv, void *buf_in,
is_read = in_info->is_read; pg_id = in_info->pg_id; + if (pg_id >= MAX_PG_NUM) + return -EINVAL;
if (is_read) { check = !buf_out || @@ -969,6 +985,7 @@ int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv, u32 out_size) { #define HNS3_TM_ETS_PORT_SHAPING 0x10820850 +#define HNS3_TM_MAC_ID_MASK 0x7 struct hns3_cae_ets_cfg_info *out_info = (struct hns3_cae_ets_cfg_info *)buf_out; struct hns3_cae_ets_cfg_info *in_info = @@ -993,7 +1010,16 @@ int hns3_cae_ets_cfg(const struct hns3_nic_priv *net_priv,
is_read = in_info->is_read; tc_id = in_info->tc_id; - mac_id = in_info->mac_id; + if (tc_id >= MAX_TC_NUM) { + pr_err("tc id(%d) is invalid in %s function\n", tc_id, __func__); + return -EFAULT; + } + mac_id = in_info->mac_id & HNS3_TM_MAC_ID_MASK; + if (mac_id & 0x1) { + pr_err("mac id(%d) is invalid in %s function\n", mac_id, __func__); + return -EFAULT; + } + addr = (u64)HNS3_TM_ETS_PORT_SHAPING + ((u64)mac_id << 20); out_info->tc_id = tc_id; out_info->mac_id = mac_id; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h index 43627c6..9f636e8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_tm.h @@ -9,6 +9,8 @@ #define MAX_QUEUE_NUM 16 #define MAX_PG_NUM 4 #define MAX_TC_NUM 8 +#define MAX_QUEUE_ID 1024 +#define MAX_QSET_ID 1024 #define HNS3_CAE_QS_ID_MSK (BIT(10) - 1) #define HCLGE_OPC_TM_PORT_SCH_MODE_CFG 0x0811
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c index 42809f1..99e11a4 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.c @@ -52,7 +52,6 @@ int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, struct hclge_vport *vport = container_of(handle, struct hclge_vport, nic); struct hclge_dev *hdev = vport->back; - u32 fw_ver;
if (check) { @@ -65,10 +64,9 @@ int hns3_cae_get_fw_ver(const struct hns3_nic_priv *nic_dev, void *buf_in, return -EFAULT;
fw_ver = hdev->fw_version; - out_buf->imp_ver = fw_ver; - if (!fw_ver) return -EFAULT; + out_buf->imp_ver = fw_ver;
return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index ac02e15..a3eb1b1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.35.1" +#define HNS3_CAE_MOD_VERSION "1.9.36.0"
#define CMT_ID_LEN 8 #define RESV_LEN 3 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c index 9862e4a..9332093 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_xsfp.c @@ -124,7 +124,7 @@ static int hns3_get_sfpinfo(struct hnae3_handle *handle, u8 *buff, u16 offset, return 0; }
-int hns3_set_sfp_state(struct hnae3_handle *handle, bool en) +static int hns3_set_sfp_state(struct hnae3_handle *handle, bool en) { struct hclge_vport *vport = hns3_cae_get_vport(handle); struct hclge_sfp_enable_cmd *req = NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index f2483d4..6e21df8 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.35.1" +#define HNS3_MOD_VERSION "1.9.36.0"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index c7ad6fd..44e0713 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.35.1" +#define HCLGE_MOD_VERSION "1.9.36.0" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 5ae3aa2..3423d40 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.35.1" +#define HCLGEVF_MOD_VERSION "1.9.36.0" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095
From: fengsheng fengsheng5@huawei.com
driver inclusion category: Bugfix bugzilla: NA CVE: NA
1. the variable : sysctl_subctrl_tdh_priv[chip_id] add legitimacy check. 2. the param of sysctl_tdh_mem_access_open: chip_id add legitimacy check.
Signed-off-by: fengsheng fengsheng5@huawei.com Reviewed-by: zhangmu zhangmu1@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/soc/hisilicon/sysctl/sysctl_drv.c | 2 +- drivers/soc/hisilicon/sysctl/sysctl_local_ras.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/soc/hisilicon/sysctl/sysctl_drv.c b/drivers/soc/hisilicon/sysctl/sysctl_drv.c index 8bb6a9f..660d15a 100644 --- a/drivers/soc/hisilicon/sysctl/sysctl_drv.c +++ b/drivers/soc/hisilicon/sysctl/sysctl_drv.c @@ -48,7 +48,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define DEBUG
-#define SYSCTL_DRIVER_VERSION "1.9.32.0" +#define SYSCTL_DRIVER_VERSION "1.9.38.0"
unsigned int g_sysctrl_debug;
diff --git a/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c b/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c index d09ab42..0ad5756 100644 --- a/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c +++ b/drivers/soc/hisilicon/sysctl/sysctl_local_ras.c @@ -90,6 +90,9 @@ static int sysctl_tdh_reset(u8 chip_id) return SYSCTL_ERR_PARAM; }
+ if (!sysctl_subctrl_tdh_priv[chip_id]) + return SYSCTL_ERR_PARAM; + addr = sysctl_subctrl_tdh_priv[chip_id] + SUBCTRL_TDH_RESET_OFFSET; writel(0x3, addr);
@@ -105,6 +108,9 @@ static int sysctl_tdh_unreset(u8 chip_id) return SYSCTL_ERR_PARAM; }
+ if (!sysctl_subctrl_tdh_priv[chip_id]) + return SYSCTL_ERR_PARAM; + addr = sysctl_subctrl_tdh_priv[chip_id] + SUBCTRL_TDH_UNRESET_OFFSET; writel(0x3, addr);
@@ -115,6 +121,11 @@ static int sysctl_tdh_mem_access_open(u8 chip_id) { void __iomem *addr;
+ if (chip_id >= CHIP_ID_NUM_MAX) { + pr_err("err chip id %u %s\n", chip_id, __func__); + return SYSCTL_ERR_PARAM; + } + if (!sysctl_tdh_priv[chip_id]) return SYSCTL_ERR_PARAM;
From: Junxin Chen chenjunxin1@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
----------------------------------
When we check arrays, we both check its value and its size, this patch fixes a bug when getting size of type.
Signed-off-by: Junxin Chen chenjunxin1@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c index 0a98155..fb872de 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_qos.c @@ -433,7 +433,7 @@ int hns3_cae_qcn_cfg(const struct hns3_nic_priv *net_priv, u32 out_size) { #define HCLGE_OPC_QCN_CFG 0x1A01 - bool check = !buf_in || in_size < sizeof(32); + bool check = !buf_in || in_size < sizeof(u32); struct hclge_vport *vport = NULL; struct hclge_dev *hdev = NULL; struct hclge_desc desc;
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch, we try to optimize key process before free of hpre module. 1、for DH algorithm, we use para g to compute public key, para g is public, so we need not clear it before free. 2、for RSA algorithm, we should use memzero_explicit to clear prikey. It will be optimized, when memset follows free. 3、For standard RSA algorithm, we use one buf to store public and prikey, to consider performance, we just clear prikey buf.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index a43f82e..803b611 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -559,7 +559,6 @@ static void hpre_dh_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all) hisi_qm_stop_qp(ctx->qp);
if (ctx->dh.g) { - memzero_explicit(ctx->dh.g, sz); dma_free_coherent(dev, sz, ctx->dh.g, ctx->dh.dma_g); ctx->dh.g = NULL; } @@ -893,7 +892,7 @@ static int hpre_rsa_setkey_crt(struct hpre_ctx *ctx, struct rsa_key *rsa_key)
free_key: offset = hlf_ksz * HPRE_CRT_PRMS; - memset(ctx->rsa.crt_prikey, 0, offset); + memzero_explicit(ctx->rsa.crt_prikey, offset); dma_free_coherent(dev, hlf_ksz * HPRE_CRT_PRMS, ctx->rsa.crt_prikey, ctx->rsa.dma_crt_prikey); ctx->rsa.crt_prikey = NULL; @@ -926,7 +925,7 @@ static void hpre_rsa_clear_ctx(struct hpre_ctx *ctx, bool is_clear_all) }
if (ctx->rsa.prikey) { - memzero_explicit(ctx->rsa.prikey, ctx->key_sz << 1); + memzero_explicit(ctx->rsa.prikey, ctx->key_sz); dma_free_coherent(dev, ctx->key_sz << 1, ctx->rsa.prikey, ctx->rsa.dma_prikey); ctx->rsa.prikey = NULL;
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch ,we try to integrate some optimization points: 1.We add likely and unlikely in result judgement to improve performance. 2.Follow hpre module, we remove device judgement of sec/rde module. 3.We remove invalid blank line and replace print interface.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Mingqiang Ling lingmingqiang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 91 ++++++++++++++--------------- drivers/crypto/hisilicon/hpre/hpre_main.c | 33 ++++++----- drivers/crypto/hisilicon/qm.c | 3 +- drivers/crypto/hisilicon/rde/rde_main.c | 25 ++------ drivers/crypto/hisilicon/sec2/sec_main.c | 6 -- drivers/crypto/hisilicon/zip/zip_main.c | 19 +++--- 6 files changed, 80 insertions(+), 97 deletions(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c index 803b611..aadc975 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c @@ -123,7 +123,7 @@ static int hpre_add_req_to_ctx(struct hpre_asym_request *hpre_req)
ctx = hpre_req->ctx; id = hpre_alloc_req_id(ctx); - if (id < 0) + if (unlikely(id < 0)) return -EINVAL;
ctx->req_list[id] = hpre_req; @@ -190,7 +190,7 @@ static int hpre_get_data_dma_addr(struct hpre_asym_request *hpre_req, } *tmp = dma_map_single(dev, sg_virt(data), len, dma_dir); - if (dma_mapping_error(dev, *tmp)) { + if (unlikely(dma_mapping_error(dev, *tmp))) { dev_err(dev, "dma map data err!\n"); return -ENOMEM; } @@ -208,11 +208,11 @@ static int hpre_prepare_dma_buf(struct hpre_asym_request *hpre_req, int shift;
shift = ctx->key_sz - len; - if (shift < 0) + if (unlikely(shift < 0)) return -EINVAL;
ptr = dma_alloc_coherent(dev, ctx->key_sz, tmp, GFP_KERNEL); - if (!ptr) + if (unlikely(!ptr)) return -ENOMEM;
if (is_src) { @@ -241,7 +241,7 @@ static int hpre_hw_data_init(struct hpre_asym_request *hpre_req, else ret = hpre_prepare_dma_buf(hpre_req, data, len, is_src, &tmp); - if (ret) + if (unlikely(ret)) return ret;
if (is_src) @@ -262,7 +262,7 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, dma_addr_t tmp;
tmp = le64_to_cpu(sqe->in); - if (!tmp) + if (unlikely(!tmp)) return;
if (src) { @@ -275,7 +275,7 @@ static void hpre_hw_data_clr_all(struct hpre_ctx *ctx, }
tmp = le64_to_cpu(sqe->out); - if (!tmp) + if (unlikely(!tmp)) return;
if (req->dst) { @@ -308,8 +308,7 @@ static int hpre_alg_res_post_hf(struct hpre_ctx *ctx, struct hpre_sqe *sqe,
done = (le32_to_cpu(sqe->dw0) >> HPRE_SQE_DONE_SHIFT) & HREE_SQE_DONE_MASK; - - if (err == HPRE_NO_HW_ERR && done == HPRE_HW_TASK_DONE) + if (likely(err == HPRE_NO_HW_ERR && done == HPRE_HW_TASK_DONE)) return 0;
return -EINVAL; @@ -456,31 +455,29 @@ static int hpre_dh_compute_value(struct kpp_request *req) int ret;
ret = hpre_msg_request_set(ctx, req, false); - if (ret) + if (unlikely(ret)) return ret;
if (req->src) { ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 1); - if (ret) + if (unlikely(ret)) goto clear_all; }
ret = hpre_hw_data_init(hpre_req, req->dst, req->dst_len, 0, 1); - if (ret) + if (unlikely(ret)) goto clear_all;
if (ctx->crt_g2_mode && !req->src) - msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) - | HPRE_ALG_DH_G2); + msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) | HPRE_ALG_DH_G2); else - msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) - | HPRE_ALG_DH); + msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) | HPRE_ALG_DH); do { ret = hisi_qp_send(ctx->qp, msg); } while (ret == -EBUSY && ctr++ < HPRE_TRY_SEND_TIMES);
/* success */ - if (!ret) + if (likely(!ret)) return -EINPROGRESS;
clear_all: @@ -520,12 +517,12 @@ static int hpre_dh_set_params(struct hpre_ctx *ctx, struct dh *params) return -EINVAL;
if (hpre_is_dh_params_length_valid(params->p_size << - HPRE_BITS_2_BYTES_SHIFT)) + HPRE_BITS_2_BYTES_SHIFT)) return -EINVAL;
sz = ctx->key_sz = params->p_size; ctx->dh.xa_p = dma_alloc_coherent(dev, sz << 1, - &ctx->dh.dma_xa_p, GFP_KERNEL); + &ctx->dh.dma_xa_p, GFP_KERNEL); if (!ctx->dh.xa_p) return -ENOMEM;
@@ -669,22 +666,22 @@ static int hpre_rsa_enc(struct akcipher_request *req) return ret; }
- if (!ctx->rsa.pubkey) + if (unlikely(!ctx->rsa.pubkey)) return -EINVAL;
ret = hpre_msg_request_set(ctx, req, true); - if (ret) + if (unlikely(ret)) return ret;
msg->dw0 |= cpu_to_le32(HPRE_ALG_NC_NCRT); msg->key = cpu_to_le64((u64)ctx->rsa.dma_pubkey);
ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 0); - if (ret) + if (unlikely(ret)) goto clear_all;
ret = hpre_hw_data_init(hpre_req, req->dst, req->dst_len, 0, 0); - if (ret) + if (unlikely(ret)) goto clear_all;
do { @@ -692,7 +689,7 @@ static int hpre_rsa_enc(struct akcipher_request *req) } while (ret == -EBUSY && ctr++ < HPRE_TRY_SEND_TIMES);
/* success */ - if (!ret) + if (likely(!ret)) return -EINPROGRESS;
clear_all: @@ -721,29 +718,29 @@ static int hpre_rsa_dec(struct akcipher_request *req) return ret; }
- if (!ctx->rsa.prikey) + if (unlikely(!ctx->rsa.prikey)) return -EINVAL;
ret = hpre_msg_request_set(ctx, req, true); - if (ret) + if (unlikely(ret)) return ret;
if (ctx->crt_g2_mode) { msg->key = cpu_to_le64((u64)ctx->rsa.dma_crt_prikey); - msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) - | HPRE_ALG_NC_CRT); + msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) | + HPRE_ALG_NC_CRT); } else { msg->key = cpu_to_le64((u64)ctx->rsa.dma_prikey); - msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) - | HPRE_ALG_NC_NCRT); + msg->dw0 = cpu_to_le32(le32_to_cpu(msg->dw0) | + HPRE_ALG_NC_NCRT); }
ret = hpre_hw_data_init(hpre_req, req->src, req->src_len, 1, 0); - if (ret) + if (unlikely(ret)) goto clear_all;
ret = hpre_hw_data_init(hpre_req, req->dst, req->dst_len, 0, 0); - if (ret) + if (unlikely(ret)) goto clear_all;
do { @@ -751,7 +748,7 @@ static int hpre_rsa_dec(struct akcipher_request *req) } while (ret == -EBUSY && ctr++ < HPRE_TRY_SEND_TIMES);
/* success */ - if (!ret) + if (likely(!ret)) return -EINPROGRESS;
clear_all: @@ -829,17 +826,17 @@ static int hpre_rsa_set_d(struct hpre_ctx *ctx, const char *value, return 0; }
-static int hpre_crt_para_get(char *para, const char *raw, - unsigned int raw_sz, unsigned int para_size) +static int hpre_crt_para_get(char *para, size_t para_sz, + const char *raw, size_t raw_sz) { const char *ptr = raw; size_t len = raw_sz;
hpre_rsa_drop_leading_zeros(&ptr, &len); - if (!len || len > para_size) + if (!len || len > para_sz) return -EINVAL;
- memcpy(para + para_size - len, ptr, len); + memcpy(para + para_sz - len, ptr, len);
return 0; } @@ -857,32 +854,32 @@ static int hpre_rsa_setkey_crt(struct hpre_ctx *ctx, struct rsa_key *rsa_key) if (!ctx->rsa.crt_prikey) return -ENOMEM;
- ret = hpre_crt_para_get(ctx->rsa.crt_prikey, rsa_key->dq, - rsa_key->dq_sz, hlf_ksz); + ret = hpre_crt_para_get(ctx->rsa.crt_prikey, hlf_ksz, + rsa_key->dq, rsa_key->dq_sz); if (ret) goto free_key;
offset = hlf_ksz; - ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, rsa_key->dp, - rsa_key->dp_sz, hlf_ksz); + ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, + rsa_key->dp, rsa_key->dp_sz); if (ret) goto free_key;
offset = hlf_ksz * HPRE_CRT_Q; - ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, - rsa_key->q, rsa_key->q_sz, hlf_ksz); + ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, + rsa_key->q, rsa_key->q_sz); if (ret) goto free_key;
offset = hlf_ksz * HPRE_CRT_P; - ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, - rsa_key->p, rsa_key->p_sz, hlf_ksz); + ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, + rsa_key->p, rsa_key->p_sz); if (ret) goto free_key;
offset = hlf_ksz * HPRE_CRT_INV; - ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, - rsa_key->qinv, rsa_key->qinv_sz, hlf_ksz); + ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, + rsa_key->qinv, rsa_key->qinv_sz); if (ret) goto free_key;
diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index 866a4be..ffb8671 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -17,6 +17,7 @@ #define HPRE_DISABLE 0 #define HPRE_VF_NUM 63 #define HPRE_QUEUE_NUM_V2 1024 +#define HPRE_QUEUE_NUM_V1 4096 #define HPRE_QM_ABNML_INT_MASK 0x100004 #define HPRE_CTRL_CNT_CLR_CE_BIT BIT(0) #define HPRE_COMM_CNT_CLR_CE 0x0 @@ -131,18 +132,18 @@ struct hpre_hw_error { };
static const struct hpre_hw_error hpre_hw_errors[] = { - { .int_msk = BIT(0), .msg = "hpre_ecc_1bitt_err" }, - { .int_msk = BIT(1), .msg = "hpre_ecc_2bit_err" }, - { .int_msk = BIT(2), .msg = "hpre_data_wr_err" }, - { .int_msk = BIT(3), .msg = "hpre_data_rd_err" }, - { .int_msk = BIT(4), .msg = "hpre_bd_rd_err" }, - { .int_msk = BIT(5), .msg = "hpre_ooo_2bit_ecc_err" }, - { .int_msk = BIT(6), .msg = "hpre_cltr1_htbt_tm_out_err" }, - { .int_msk = BIT(7), .msg = "hpre_cltr2_htbt_tm_out_err" }, - { .int_msk = BIT(8), .msg = "hpre_cltr3_htbt_tm_out_err" }, - { .int_msk = BIT(9), .msg = "hpre_cltr4_htbt_tm_out_err" }, - { .int_msk = GENMASK(10, 15), .msg = "hpre_ooo_rdrsp_err" }, - { .int_msk = GENMASK(16, 21), .msg = "hpre_ooo_wrrsp_err" }, + { .int_msk = BIT(0), .msg = "core_ecc_1bit_err_int_set" }, + { .int_msk = BIT(1), .msg = "core_ecc_2bit_err_int_set" }, + { .int_msk = BIT(2), .msg = "dat_wb_poison_int_set" }, + { .int_msk = BIT(3), .msg = "dat_rd_poison_int_set" }, + { .int_msk = BIT(4), .msg = "bd_rd_poison_int_set" }, + { .int_msk = BIT(5), .msg = "ooo_ecc_2bit_err_int_set" }, + { .int_msk = BIT(6), .msg = "cluster1_shb_timeout_int_set" }, + { .int_msk = BIT(7), .msg = "cluster2_shb_timeout_int_set" }, + { .int_msk = BIT(8), .msg = "cluster3_shb_timeout_int_set" }, + { .int_msk = BIT(9), .msg = "cluster4_shb_timeout_int_set" }, + { .int_msk = GENMASK(15, 10), .msg = "ooo_rdrsp_err_int_set" }, + { .int_msk = GENMASK(21, 16), .msg = "ooo_wrrsp_err_int_set" }, { /* sentinel */ } };
@@ -353,7 +354,7 @@ static int hpre_set_cluster(struct hisi_qm *qm) static int hpre_set_user_domain_and_cache(struct hpre *hpre) { struct hisi_qm *qm = &hpre->qm; - struct device *dev = &qm->pdev->dev; + struct pci_dev *pdev = qm->pdev; u32 val; int ret;
@@ -387,19 +388,19 @@ static int hpre_set_user_domain_and_cache(struct hpre *hpre) HPRE_REG_RD_INTVRL_US, HPRE_REG_RD_TMOUT_US); if (ret) { - dev_err(dev, "read rd channel timeout fail!\n"); + pci_err(pdev, "read rd channel timeout fail!\n"); return -ETIMEDOUT; }
ret = hpre_set_cluster(qm); if (ret) { - dev_err(dev, "set hpre cluster err!\n"); + pci_err(pdev, "set hpre cluster err!\n"); return -ETIMEDOUT; }
ret = hpre_cfg_by_dsm(qm); if (ret) - dev_err(dev, "acpi_evaluate_dsm err.\n"); + pci_err(pdev, "acpi_evaluate_dsm err.\n");
/* disable FLR triggered by BME(bus master enable) */ val = readl(hpre->qm.io_base + QM_PEH_AXUSER_CFG); diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 46d9669..945cf34 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -1518,7 +1518,7 @@ int hisi_qp_send(struct hisi_qp *qp, const void *msg)
if (unlikely(atomic_read(&qp->qp_status.flags) == QP_STOP || atomic_read(&qp->qm->status.flags) == QM_STOP) || - qp->is_resetting == true) { + qp->is_resetting) { dev_info_ratelimited(&qp->qm->pdev->dev, "QM resetting...\n"); return -EAGAIN; } @@ -1708,6 +1708,7 @@ static int hisi_qm_uacce_mmap(struct uacce_queue *q, ret = dma_mmap_coherent(dev, vma, qp->qdma.va, qp->qdma.dma, sz); vma->vm_pgoff = vm_pgoff; + return ret; default: return -EINVAL; diff --git a/drivers/crypto/hisilicon/rde/rde_main.c b/drivers/crypto/hisilicon/rde/rde_main.c index 590969a..c375d9f 100644 --- a/drivers/crypto/hisilicon/rde/rde_main.c +++ b/drivers/crypto/hisilicon/rde/rde_main.c @@ -840,31 +840,31 @@ static int hisi_rde_probe(struct pci_dev *pdev, const struct pci_device_id *id) qm = &hisi_rde->qm; ret = hisi_rde_qm_pre_init(qm, pdev); if (ret) { - dev_err(&pdev->dev, "Pre init qm failed!\n"); + pci_err(pdev, "Pre init qm failed!\n"); return ret; }
ret = hisi_qm_init(qm); if (ret) { - dev_err(&pdev->dev, "Init qm failed!\n"); + pci_err(pdev, "Init qm failed!\n"); return ret; }
ret = hisi_rde_pf_probe_init(hisi_rde); if (ret) { - dev_err(&pdev->dev, "Init pf failed!\n"); + pci_err(pdev, "Init pf failed!\n"); goto err_qm_uninit; }
ret = hisi_qm_start(qm); if (ret) { - dev_err(&pdev->dev, "Start qm failed!\n"); + pci_err(pdev, "Start qm failed!\n"); goto err_qm_uninit; }
ret = hisi_rde_debugfs_init(hisi_rde); if (ret) - dev_warn(&pdev->dev, "Init debugfs failed!\n"); + pci_warn(pdev, "Init debugfs failed!\n");
hisi_rde_add_to_list(hisi_rde); hisi_rde->rde_list_lock = &hisi_rde_list_lock; @@ -1234,23 +1234,10 @@ static int __init hisi_rde_init(void)
ret = pci_register_driver(&hisi_rde_pci_driver); if (ret < 0) { + hisi_rde_unregister_debugfs(); pr_err("Register pci driver failed.\n"); - goto err_pci; }
- if (list_empty(&hisi_rde_list)) { - pr_err("No rde device.\n"); - ret = -ENODEV; - goto err_probe_device; - } - - return 0; - -err_probe_device: - pci_unregister_driver(&hisi_rde_pci_driver); -err_pci: - hisi_rde_unregister_debugfs(); - return ret; }
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index 49f97ec..b2bf9c6 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -1771,12 +1771,6 @@ static int __init hisi_sec_init(void) goto err_pci; }
- if (list_empty(&hisi_sec_list)) { - pr_err("no device!\n"); - ret = -ENODEV; - goto err_probe_device; - } - pr_info("hisi_sec: register to crypto\n"); ret = hisi_sec_register_to_crypto(fusion_limit); if (ret < 0) { diff --git a/drivers/crypto/hisilicon/zip/zip_main.c b/drivers/crypto/hisilicon/zip/zip_main.c index 5625ca3..5e40fbf 100644 --- a/drivers/crypto/hisilicon/zip/zip_main.c +++ b/drivers/crypto/hisilicon/zip/zip_main.c @@ -450,7 +450,7 @@ static void hisi_zip_hw_error_set_state(struct hisi_zip *hisi_zip, bool state)
if (qm->ver == QM_HW_V1) { writel(HZIP_CORE_INT_DISABLE, qm->io_base + HZIP_CORE_INT_MASK); - dev_info(&qm->pdev->dev, "ZIP v%d does not support hw error handle\n", + pci_info(qm->pdev, "ZIP v%d cannot support hw error handle!\n", qm->ver); return; } @@ -461,7 +461,6 @@ static void hisi_zip_hw_error_set_state(struct hisi_zip *hisi_zip, bool state) writel(HZIP_CORE_INT_RAS_NFE_ENABLE, hisi_zip->qm.io_base + HZIP_CORE_INT_RAS_NFE_ENB);
- val = readl(hisi_zip->qm.io_base + HZIP_SOFT_CTRL_ZIP_CONTROL); if (state) { /* clear ZIP hw error source if having */ @@ -654,7 +653,7 @@ static int hisi_zip_core_debug_init(struct hisi_zip_ctrl *ctrl) ret = snprintf(buf, HZIP_BUF_SIZE, "comp_core%d", i); else ret = snprintf(buf, HZIP_BUF_SIZE, - "decomp_core%d", i - HZIP_COMP_CORE_NUM); + "decomp_core%d", i - HZIP_COMP_CORE_NUM); if (ret < 0) return -EINVAL;
@@ -876,14 +875,16 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id)
ret = hisi_qm_init(qm); if (ret) { - dev_err(&pdev->dev, "Failed to init qm!\n"); + pci_err(pdev, "Failed to init qm (%d)!\n", ret); goto err_remove_from_list; }
if (qm->fun_type == QM_HW_PF) { ret = hisi_zip_pf_probe_init(hisi_zip); - if (ret) + if (ret) { + pci_err(pdev, "Failed to init pf probe (%d)!\n", ret); goto err_remove_from_list; + }
qm->qp_base = HZIP_PF_DEF_Q_BASE; qm->qp_num = pf_q_num; @@ -908,16 +909,18 @@ static int hisi_zip_probe(struct pci_dev *pdev, const struct pci_device_id *id) }
ret = hisi_qm_start(qm); - if (ret) + if (ret) { + pci_err(pdev, "Failed to start qm (%d)!\n", ret); goto err_qm_uninit; + }
ret = hisi_zip_debugfs_init(hisi_zip); if (ret) - dev_err(&pdev->dev, "Failed to init debugfs (%d)!\n", ret); + pci_err(pdev, "Failed to init debugfs (%d)!\n", ret);
ret = hisi_zip_register_to_crypto(); if (ret < 0) { - pr_err("Failed to register driver to crypto.\n"); + pci_err(pdev, "Failed to register driver to crypto!\n"); goto err_qm_stop; } return 0;
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch, we try to change sec_control reg config: We delete sec clock gate to keep default config. Then we should use sec base addr, instead of qm io_base, to config sec_control reg.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Mingqiang Ling lingmingqiang@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/sec2/sec_main.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c b/drivers/crypto/hisilicon/sec2/sec_main.c index b2bf9c6..ba5c478 100644 --- a/drivers/crypto/hisilicon/sec2/sec_main.c +++ b/drivers/crypto/hisilicon/sec2/sec_main.c @@ -85,6 +85,7 @@
#define SEC_CONTROL_REG 0x0200 #define SEC_TRNG_EN_SHIFT 8 +#define SEC_CLK_GATE_DISABLE (~BIT(3)) #define SEC_AXI_SHUTDOWN_ENABLE BIT(12) #define SEC_AXI_SHUTDOWN_DISABLE 0xFFFFEFFF #define SEC_WR_MSI_PORT 0xFFFE @@ -484,7 +485,7 @@ static int sec_engine_init(struct hisi_sec *hisi_sec)
/* disable clock gate control */ reg = readl_relaxed(base + SEC_CONTROL_REG); - reg &= ~BIT(3); + reg &= SEC_CLK_GATE_DISABLE; writel(reg, base + SEC_CONTROL_REG);
writel(0x1, base + SEC_MEM_START_INIT_REG); @@ -514,11 +515,6 @@ static int sec_engine_init(struct hisi_sec *hisi_sec) writel(SEC_BD_ERR_CHK_EN1, base + SEC_BD_ERR_CHK_EN_REG1); writel(SEC_BD_ERR_CHK_EN3, base + SEC_BD_ERR_CHK_EN_REG3);
- /* enable clock gate control */ - reg = readl_relaxed(base + SEC_CONTROL_REG); - reg |= BIT(3); - writel(reg, base + SEC_CONTROL_REG); - /* config endian */ reg = readl_relaxed(base + SEC_CONTROL_REG); reg |= sec_get_endian(hisi_sec); @@ -927,7 +923,7 @@ static void hisi_sec_open_master_ooo(struct hisi_qm *qm) void *base = qm->io_base + SEC_ENGINE_PF_CFG_OFF + SEC_ACC_COMMON_REG_OFF;
- val = readl(qm->io_base + SEC_CONTROL_REG); + val = readl(base + SEC_CONTROL_REG); writel(val & SEC_AXI_SHUTDOWN_DISABLE, base + SEC_CONTROL_REG); writel(val | SEC_AXI_SHUTDOWN_ENABLE, base + SEC_CONTROL_REG); }
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch, we try to optimize debug regs clear logic. We add hisi_rde_debug_regs_clear interface and this interface will be called only in probe and remove, which can keep value of debug regs. Otherwise, we optimize print interface of hpre_probe and add qp_num print of hisi_qm_create_qp_nolock.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/hpre/hpre_main.c | 14 ++- drivers/crypto/hisilicon/qm.c | 4 +- drivers/crypto/hisilicon/rde/rde_main.c | 177 ++++++++++++++++-------------- 3 files changed, 109 insertions(+), 86 deletions(-)
diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c b/drivers/crypto/hisilicon/hpre/hpre_main.c index ffb8671..6a3bce2 100644 --- a/drivers/crypto/hisilicon/hpre/hpre_main.c +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c @@ -923,13 +923,17 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id) return ret;
ret = hisi_qm_init(qm); - if (ret) + if (ret) { + pci_err(pdev, "Failed to init qm (%d)!\n", ret); return ret; + }
if (pdev->is_physfn) { ret = hpre_pf_probe_init(hpre); - if (ret) + if (ret) { + pci_err(pdev, "Failed to init pf probe (%d)!\n", ret); goto err_with_qm_init; + } } else if (qm->fun_type == QM_HW_VF && qm->ver == QM_HW_V2) { /* v2 starts to support get vft by mailbox */ ret = hisi_qm_get_vft(qm, &qm->qp_base, &qm->qp_num); @@ -938,12 +942,14 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id) }
ret = hisi_qm_start(qm); - if (ret) + if (ret) { + pci_err(pdev, "Failed to start qm (%d)!\n", ret); goto err_with_err_init; + }
ret = hpre_debugfs_init(hpre); if (ret) - dev_warn(&pdev->dev, "init debugfs fail!\n"); + pci_warn(pdev, "init debugfs fail!\n");
hpre_add_to_list(hpre);
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 945cf34..ec70383 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -1195,7 +1195,9 @@ static struct hisi_qp *hisi_qm_create_qp_nolock(struct hisi_qm *qm,
qp_id = find_first_zero_bit(qm->qp_bitmap, qm->qp_num); if (qp_id >= qm->qp_num) { - dev_info_ratelimited(&qm->pdev->dev, "QM all queues are busy!\n"); + dev_info_ratelimited(&qm->pdev->dev, + "All %u queues of QM are busy!\n", + qm->qp_num); ret = -EBUSY; goto err_free_qp; } diff --git a/drivers/crypto/hisilicon/rde/rde_main.c b/drivers/crypto/hisilicon/rde/rde_main.c index c375d9f..453657a 100644 --- a/drivers/crypto/hisilicon/rde/rde_main.c +++ b/drivers/crypto/hisilicon/rde/rde_main.c @@ -45,6 +45,7 @@ #define HRDE_INT_MSK 0x310314 #define HRDE_INT_ENABLE 0x0 #define HRDE_INT_DISABLE 0x3ffff +#define HRDE_BD_PREFETCH BIT(8) #define HRDE_INT_SOURCE 0x31030c #define HRDE_INT_SOURCE_CLEAR GENMASK(17, 0) #define HRDE_INT_STATUS 0x310318 @@ -57,7 +58,7 @@ #define HRDE_FIFO_STAT_0 0x310200 #define HRDE_DFX_STAT_7 0x310334 #define HRDE_DFX_STAT_8 0x310338 -#define DFX_CTRL0 0x2 +#define DFX_CTRL0 0x3 #define WRITE_CLEAR_VAL GENMASK(31, 0) #define HRDE_AWCACHE 0x310154 #define HRDE_ARCACHE 0x31015c @@ -354,6 +355,95 @@ static inline void hisi_rde_remove_from_list(struct hisi_rde *hisi_rde) mutex_unlock(&hisi_rde_list_lock); }
+static void hisi_rde_engine_init(struct hisi_rde *hisi_rde) +{ + writel(DFX_CTRL0, hisi_rde->qm.io_base + HRDE_DFX_CTRL_0); + + /* usr domain */ + writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_AWUSER_BD_1); + writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_ARUSER_BD_1); + writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_AWUSER_DAT_1); + writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_ARUSER_DAT_1); + writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_ARUSER_SGL_1); + /* rde cache */ + writel(AWCACHE, hisi_rde->qm.io_base + HRDE_AWCACHE); + writel(ARCACHE, hisi_rde->qm.io_base + HRDE_ARCACHE); + + /* rde chn enable + outstangding config */ + writel(CHN_CFG, hisi_rde->qm.io_base + HRDE_CFG); +} + +static void hisi_rde_set_user_domain_and_cache(struct hisi_rde *hisi_rde) +{ + /* qm user domain */ + writel(AXUSER_BASE, hisi_rde->qm.io_base + QM_ARUSER_M_CFG_1); + writel(ARUSER_M_CFG_ENABLE, hisi_rde->qm.io_base + + QM_ARUSER_M_CFG_ENABLE); + writel(AXUSER_BASE, hisi_rde->qm.io_base + QM_AWUSER_M_CFG_1); + writel(AWUSER_M_CFG_ENABLE, hisi_rde->qm.io_base + + QM_AWUSER_M_CFG_ENABLE); + writel(WUSER_M_CFG_ENABLE, hisi_rde->qm.io_base + + QM_WUSER_M_CFG_ENABLE); + + /* qm cache */ + writel(AXI_M_CFG, hisi_rde->qm.io_base + QM_AXI_M_CFG); + writel(AXI_M_CFG_ENABLE, hisi_rde->qm.io_base + QM_AXI_M_CFG_ENABLE); + + /* disable BME/PM/SRIOV FLR*/ + writel(PEH_AXUSER_CFG, hisi_rde->qm.io_base + QM_PEH_AXUSER_CFG); + writel(PEH_AXUSER_CFG_ENABLE, hisi_rde->qm.io_base + + QM_PEH_AXUSER_CFG_ENABLE); + + writel(CACHE_CTL, hisi_rde->qm.io_base + QM_CACHE_CTL); + + hisi_rde_engine_init(hisi_rde); +} + +static void hisi_rde_debug_regs_clear(struct hisi_qm *qm) +{ + /* clear rde debug regs */ + readl(qm->io_base + HRDE_ECC_ERR); + readl(qm->io_base + HRDE_ECC_ERR_CNT); + readl(qm->io_base + HRDE_OP_DONE_CNT); + readl(qm->io_base + HRDE_OP_ERR_CNT); + readl(qm->io_base + HRDE_OP_ABORT_CNT); + writel(WRITE_CLEAR_VAL, qm->io_base + HRDE_FIFO_STAT_0); + writel(WRITE_CLEAR_VAL, qm->io_base + HRDE_DFX_STAT_7); + writel(WRITE_CLEAR_VAL, qm->io_base + HRDE_DFX_STAT_8); + + /* clear current_qm */ + writel(0x0, qm->io_base + QM_DFX_MB_CNT_VF); + writel(0x0, qm->io_base + QM_DFX_DB_CNT_VF); + + hisi_qm_debug_regs_clear(qm); +} + +static void hisi_rde_hw_error_set_state(struct hisi_rde *hisi_rde, bool state) +{ + u32 ras_msk = (HRDE_RAS_CE_MSK | HRDE_RAS_NFE_MSK); + u32 val; + + val = readl(hisi_rde->qm.io_base + HRDE_CFG); + if (state) { + writel(HRDE_INT_SOURCE_CLEAR, + hisi_rde->qm.io_base + HRDE_INT_SOURCE); + writel(HRDE_RAS_ENABLE, + hisi_rde->qm.io_base + HRDE_RAS_INT_MSK); + /* bd prefetch should bd masked to prevent misreport */ + writel((HRDE_INT_ENABLE | HRDE_BD_PREFETCH), + hisi_rde->qm.io_base + HRDE_INT_MSK); + /* make master ooo close, when m-bits error happens*/ + val = val | HRDE_AXI_SHUTDOWN_EN; + } else { + writel(ras_msk, hisi_rde->qm.io_base + HRDE_RAS_INT_MSK); + writel(HRDE_INT_DISABLE, hisi_rde->qm.io_base + HRDE_INT_MSK); + /* make master ooo open, when m-bits error happens*/ + val = val & HRDE_AXI_SHUTDOWN_DIS; + } + + writel(val, hisi_rde->qm.io_base + HRDE_CFG); +} + static inline struct hisi_qm *file_to_qm(struct ctrl_debug_file *file) { struct hisi_rde *hisi_rde = file->ctrl->hisi_rde; @@ -409,8 +499,7 @@ static int current_bd_write(struct ctrl_debug_file *file, u32 val) return -EINVAL; }
- tmp = HRDE_PROBE_DATA_EN | HRDE_PROBE_EN | - (val << HRDE_STRB_CS_SHIFT); + tmp = HRDE_PROBE_DATA_EN | HRDE_PROBE_EN | (val << HRDE_STRB_CS_SHIFT); writel(tmp, qm->io_base + HRDE_PROBE_ADDR);
return 0; @@ -594,84 +683,10 @@ static void hisi_rde_debugfs_exit(struct hisi_rde *hisi_rde) struct hisi_qm *qm = &hisi_rde->qm;
debugfs_remove_recursive(qm->debug.debug_root); -} - -static void hisi_rde_engine_init(struct hisi_rde *hisi_rde) -{ - writel(DFX_CTRL0, hisi_rde->qm.io_base + HRDE_DFX_CTRL_0); - readl(hisi_rde->qm.io_base + HRDE_ECC_ERR); - readl(hisi_rde->qm.io_base + HRDE_ECC_ERR_CNT); - readl(hisi_rde->qm.io_base + HRDE_OP_DONE_CNT); - readl(hisi_rde->qm.io_base + HRDE_OP_ERR_CNT); - readl(hisi_rde->qm.io_base + HRDE_OP_ABORT_CNT); - writel(WRITE_CLEAR_VAL, hisi_rde->qm.io_base + HRDE_FIFO_STAT_0); - writel(WRITE_CLEAR_VAL, hisi_rde->qm.io_base + HRDE_DFX_STAT_7); - writel(WRITE_CLEAR_VAL, hisi_rde->qm.io_base + HRDE_DFX_STAT_8); - - /* usr domain */ - writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_AWUSER_BD_1); - writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_ARUSER_BD_1); - writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_AWUSER_DAT_1); - writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_ARUSER_DAT_1); - writel(HRDE_USER_SMMU, hisi_rde->qm.io_base + HRDE_ARUSER_SGL_1); - /* rde cache */ - writel(AWCACHE, hisi_rde->qm.io_base + HRDE_AWCACHE); - writel(ARCACHE, hisi_rde->qm.io_base + HRDE_ARCACHE); - - /* rde chn enable + outstangding config */ - writel(CHN_CFG, hisi_rde->qm.io_base + HRDE_CFG); -} - -static void hisi_rde_set_user_domain_and_cache(struct hisi_rde *hisi_rde) -{ - /* qm user domain */ - writel(AXUSER_BASE, hisi_rde->qm.io_base + QM_ARUSER_M_CFG_1); - writel(ARUSER_M_CFG_ENABLE, hisi_rde->qm.io_base + - QM_ARUSER_M_CFG_ENABLE); - writel(AXUSER_BASE, hisi_rde->qm.io_base + QM_AWUSER_M_CFG_1); - writel(AWUSER_M_CFG_ENABLE, hisi_rde->qm.io_base + - QM_AWUSER_M_CFG_ENABLE); - writel(WUSER_M_CFG_ENABLE, hisi_rde->qm.io_base + - QM_WUSER_M_CFG_ENABLE); - - /* qm cache */ - writel(AXI_M_CFG, hisi_rde->qm.io_base + QM_AXI_M_CFG); - writel(AXI_M_CFG_ENABLE, hisi_rde->qm.io_base + QM_AXI_M_CFG_ENABLE); - - /* disable BME/PM/SRIOV FLR*/ - writel(PEH_AXUSER_CFG, hisi_rde->qm.io_base + QM_PEH_AXUSER_CFG); - writel(PEH_AXUSER_CFG_ENABLE, hisi_rde->qm.io_base + - QM_PEH_AXUSER_CFG_ENABLE); - - writel(CACHE_CTL, hisi_rde->qm.io_base + QM_CACHE_CTL); - - hisi_rde_engine_init(hisi_rde); -} - -static void hisi_rde_hw_error_set_state(struct hisi_rde *hisi_rde, bool state) -{ - u32 ras_msk = (HRDE_RAS_CE_MSK | HRDE_RAS_NFE_MSK); - u32 val; - - val = readl(hisi_rde->qm.io_base + HRDE_CFG); - if (state) { - writel(HRDE_INT_SOURCE_CLEAR, - hisi_rde->qm.io_base + HRDE_INT_SOURCE); - writel(HRDE_RAS_ENABLE, - hisi_rde->qm.io_base + HRDE_RAS_INT_MSK); - /* bd prefetch should bd masked to prevent misreport */ - writel((HRDE_INT_ENABLE | BIT(8)), - hisi_rde->qm.io_base + HRDE_INT_MSK); - /* make master ooo close, when m-bits error happens*/ - val = val | HRDE_AXI_SHUTDOWN_EN; - } else { - writel(ras_msk, hisi_rde->qm.io_base + HRDE_RAS_INT_MSK); - writel(HRDE_INT_DISABLE, hisi_rde->qm.io_base + HRDE_INT_MSK); - /* make master ooo open, when m-bits error happens*/ - val = val & HRDE_AXI_SHUTDOWN_DIS; + if (qm->fun_type == QM_HW_PF) { + hisi_rde_debug_regs_clear(qm); + qm->debug.curr_qm_qp_num = 0; } - - writel(val, hisi_rde->qm.io_base + HRDE_CFG); }
static void hisi_rde_set_hw_error(struct hisi_rde *hisi_rde, bool state) @@ -770,6 +785,7 @@ static int hisi_rde_pf_probe_init(struct hisi_rde *hisi_rde) hisi_rde_set_user_domain_and_cache(hisi_rde); hisi_rde_set_hw_error(hisi_rde, true); qm->err_ini.open_axi_master_ooo(qm); + hisi_rde_debug_regs_clear(qm);
return 0; } @@ -883,7 +899,6 @@ static void hisi_rde_remove(struct pci_dev *pdev) struct hisi_qm *qm = &hisi_rde->qm;
qm->abnormal_fix = NULL; - qm->debug.curr_qm_qp_num = 0; hisi_rde_hw_error_set_state(hisi_rde, false); cancel_work_sync(&hisi_rde->reset_work); hisi_rde_remove_from_list(hisi_rde);
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch, we try to fixup compilation problem of __hisi_qm_start, when we close CONFIG_CRYPTO_QM_UACCE.If we have not defined this macro, we do not use para qm->reserve and qm->reserve_dma.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/qm.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index ec70383..8d1e767 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -2198,10 +2198,13 @@ static int __hisi_qm_start(struct hisi_qm *qm) QM_INIT_BUF(qm, aeqe, QM_Q_DEPTH); QM_INIT_BUF(qm, sqc, qm->qp_num); QM_INIT_BUF(qm, cqc, qm->qp_num); + +#ifdef CONFIG_CRYPTO_QM_UACCE /* get reserved dma memory */ qm->reserve = qm->qdma.va + off; qm->reserve_dma = qm->qdma.dma + off; off += PAGE_SIZE; +#endif
ret = qm_eq_aeq_ctx_cfg(qm); if (ret)
From: Junxin Chen chenjunxin1@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
----------------------------------
Currently, CONFIG_HNS3_DCB is configed as y default, but in some cases, it may not be set.
This patch fixes an compile error when CONFIG_HNS3_DCB is not set.
Signed-off-by: Junxin Chen chenjunxin1@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/Makefile | 2 +- .../hisilicon/hns3/hns3_cae/hns3_cae_dcb.h | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/Makefile b/drivers/net/ethernet/hisilicon/hns3/Makefile index a17983c..0844a4f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/Makefile +++ b/drivers/net/ethernet/hisilicon/hns3/Makefile @@ -59,7 +59,6 @@ hclgevf-objs := hns3vf/hclgevf_main.o hns3vf/hclgevf_cmd.o hns3vf/hclgevf_mbx.o #add rally code HNS3_CAE_OBJS_PRIM = hns3_cae/hns3_cae_init.o \ hns3_cae/hns3_cae_lib.o \ - hns3_cae/hns3_cae_dcb.o \ hns3_cae/hns3_cae_dcqcn.o \ hns3_cae/hns3_cae_version.o \ hns3_cae/hns3_cae_reset.o \ @@ -86,3 +85,4 @@ HNS3_CAE_OBJS_EXT = hns3_cae/hns3_cae_dfx.o \ hns3_cae/hns3_cae_led.o obj-$(CONFIG_HNS3_CAE) += hns3_cae.o hns3_cae-objs := $(HNS3_CAE_OBJS_PRIM) $(HNS3_CAE_OBJS_EXT) +hns3_cae-$(CONFIG_HNS3_DCB) += hns3_cae/hns3_cae_dcb.o diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h index c9437f5..f6466dba 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dcb.h @@ -57,6 +57,7 @@ struct hns3_cae_dcb_info { struct hns3_cae_ets_cfg_param ets_cfg_info; };
+#ifdef CONFIG_HNS3_DCB int hns3_cae_dcb_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); @@ -66,4 +67,28 @@ int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); +#else +static inline int hns3_cae_dcb_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, void *buf_out, + u32 out_size) +{ + return -EOPNOTSUPP; +} + +static inline int hns3_cae_dcb_ets_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, + void *buf_out, u32 out_size) +{ + return -EOPNOTSUPP; +} + +static inline int hns3_cae_dcb_pfc_cfg(const struct hns3_nic_priv *net_priv, + void *buf_in, u32 in_size, + void *buf_out, u32 out_size) +{ + return -EOPNOTSUPP; +} + +#endif + #endif
From: Junxin Chen chenjunxin1@huawei.com
driver inclusion category: cleanup bugzilla: NA CVE: NA
----------------------------------
This patch clears devil numbers for hns3_cae_dfx, and change version to 1.9.37.0.
Signed-off-by: Junxin Chen chenjunxin1@huawei.com Reviewed-by: Zhong Zhaohui zhongzhaohui@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c | 6 +++--- drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h | 2 +- drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index eea9d59..42d3795 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -30,7 +30,7 @@ #include <linux/pci.h> #include <linux/types.h>
-#define HNAE3_MOD_VERSION "1.9.36.0" +#define HNAE3_MOD_VERSION "1.9.37.0"
#define HNAE3_MIN_VECTOR_NUM 2 /* one for msi-x, another for IO */
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c index 253972b..23c3607 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.c @@ -115,7 +115,7 @@ int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, out_info->func_id = (u8)hdev->pdev->devfn; out_info->is_cs_board = (handle->pdev->revision > 0x20) ? true : false; reg_info.addr = HNS3_CAE_MAC_MODE_ADDR; - reg_info.bit_width = 32; + reg_info.bit_width = HNS3_CAE_BITWIDTH_32BIT; reg_info.is_read = true; ret = hns3_cae_operate_nic_regs(hdev, ®_info); if (ret) { @@ -125,7 +125,7 @@ int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, } out_info->work_mode = reg_info.value; reg_info.addr = HNS3_CAE_MAC_MAP_ADDR; - reg_info.bit_width = 64; + reg_info.bit_width = HNS3_CAE_BITWIDTH_64BIT; reg_info.is_read = true; ret = hns3_cae_operate_nic_regs(hdev, ®_info); if (ret) { @@ -204,7 +204,7 @@ int hns3_cae_event_injection(const struct hns3_nic_priv *net_priv, hdev = vport->back;
reg_info.addr = in_info->addr; - reg_info.bit_width = 32; + reg_info.bit_width = HNS3_CAE_BITWIDTH_32BIT; reg_info.is_read = false; reg_info.value = in_info->value; dev_info(&hdev->pdev->dev, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h index 8d8edb8..d39b5da 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_dfx.h @@ -35,6 +35,9 @@ struct hns3_cae_event_param {
#define HNS3_CAE_MAX_MAC_NUMBER 0x8
+#define HNS3_CAE_BITWIDTH_32BIT 32 +#define HNS3_CAE_BITWIDTH_64BIT 64 + int hns3_cae_get_dfx_info(const struct hns3_nic_priv *net_priv, void *buf_in, u32 in_size, void *buf_out, u32 out_size); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h index a3eb1b1..d85a27d 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_cae/hns3_cae_version.h @@ -4,7 +4,7 @@ #ifndef __HNS3_CAE_VERSION_H__ #define __HNS3_CAE_VERSION_H__
-#define HNS3_CAE_MOD_VERSION "1.9.36.0" +#define HNS3_CAE_MOD_VERSION "1.9.37.0"
#define CMT_ID_LEN 8 #define RESV_LEN 3 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 6e21df8..87ab2fa 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -8,7 +8,7 @@
#include "hnae3.h"
-#define HNS3_MOD_VERSION "1.9.36.0" +#define HNS3_MOD_VERSION "1.9.37.0"
extern char hns3_driver_version[];
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index 44e0713..0daef61 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -12,7 +12,7 @@ #include "hclge_cmd.h" #include "hnae3.h"
-#define HCLGE_MOD_VERSION "1.9.36.0" +#define HCLGE_MOD_VERSION "1.9.37.0" #define HCLGE_DRIVER_NAME "hclge"
#define HCLGE_MAX_PF_NUM 8 diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 3423d40..574b36b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -10,7 +10,7 @@ #include "hclgevf_cmd.h" #include "hnae3.h"
-#define HCLGEVF_MOD_VERSION "1.9.36.0" +#define HCLGEVF_MOD_VERSION "1.9.37.0" #define HCLGEVF_DRIVER_NAME "hclgevf"
#define HCLGEVF_MAX_VLAN_ID 4095
From: Yu'an Wang wangyuan46@huawei.com
driver inclusion category: bugfix bugzilla: NA CVE: NA
In this patch, we try to fix the way judge whether q stop in user space. The driver judge whether device stop by parameter qp_status.used, but this parameter only used in kernel. So we compare sqc and cqc tail to judge finish status of tasks for user space.
Signed-off-by: Yu'an Wang wangyuan46@huawei.com Reviewed-by: Cheng Hu hucheng.hu@huawei.com Signed-off-by: Yang Yingliang yangyingliang@huawei.com --- drivers/crypto/hisilicon/qm.c | 172 ++++++++++++++++++++++++++++-------------- 1 file changed, 115 insertions(+), 57 deletions(-)
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 8d1e767..4bd7739 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -47,6 +47,8 @@
#define QM_SQ_TYPE_MASK 0xf
+#define QM_SQ_TAIL_IDX(sqc) ((le16_to_cpu((sqc)->w11) >> 6) & 0x1) + /* cqc shift */ #define QM_CQ_HOP_NUM_SHIFT 0 #define QM_CQ_PAGE_SIZE_SHIFT 4 @@ -59,6 +61,8 @@
#define QM_QC_CQE_SIZE 4
+#define QM_CQ_TAIL_IDX(cqc) ((le16_to_cpu((cqc)->w11) >> 6) & 0x1) + /* eqc shift */ #define QM_EQE_AEQE_SIZE (2UL << 12) #define QM_EQC_PHASE_SHIFT 16 @@ -164,6 +168,8 @@
#define WAIT_PERIOD 20 #define MAX_WAIT_COUNTS 1000 +#define WAIT_PERIOD_US_MAX 200 +#define WAIT_PERIOD_US_MIN 100 #define MAX_WAIT_TASK_COUNTS 10
#define QM_RAS_NFE_MBIT_DISABLE ~QM_ECC_MBIT @@ -497,6 +503,9 @@ static void qm_poll_qp(struct hisi_qp *qp, struct hisi_qm *qm) { struct qm_cqe *cqe;
+ if (atomic_read(&qp->qp_status.flags) == QP_STOP) + return; + if (qp->event_cb) qp->event_cb(qp); else { @@ -1036,6 +1045,45 @@ static int qm_regs_open(struct inode *inode, struct file *file) .release = single_release, };
+static void *qm_ctx_alloc(struct hisi_qm *qm, size_t ctx_size, + dma_addr_t *dma_addr) +{ + struct device *dev = &qm->pdev->dev; + void *ctx_addr; + + ctx_addr = kzalloc(ctx_size, GFP_KERNEL); + if (!ctx_addr) + return ERR_PTR(-ENOMEM); + + *dma_addr = dma_map_single(dev, ctx_addr, ctx_size, DMA_FROM_DEVICE); + if (dma_mapping_error(dev, *dma_addr)) { + dev_err(dev, "DMA mapping error!\n"); + kfree(ctx_addr); + return ERR_PTR(-ENOMEM); + } + + return ctx_addr; +} + +static void qm_ctx_free(struct hisi_qm *qm, size_t ctx_size, + const void *ctx_addr, dma_addr_t *dma_addr) +{ + struct device *dev = &qm->pdev->dev; + + dma_unmap_single(dev, *dma_addr, ctx_size, DMA_FROM_DEVICE); + kfree(ctx_addr); +} + +static int qm_dump_sqc_raw(struct hisi_qm *qm, dma_addr_t dma_addr, u16 qp_id) +{ + return qm_mb(qm, QM_MB_CMD_SQC, dma_addr, qp_id, 1); +} + +static int qm_dump_cqc_raw(struct hisi_qm *qm, dma_addr_t dma_addr, u16 qp_id) +{ + return qm_mb(qm, QM_MB_CMD_CQC, dma_addr, qp_id, 1); +} + static int qm_create_debugfs_file(struct hisi_qm *qm, enum qm_debug_file index) { struct dentry *qm_d = qm->debug.qm_d, *tmp; @@ -1440,36 +1488,90 @@ int hisi_qm_start_qp(struct hisi_qp *qp, unsigned long arg) /* Callback function should be called whether task completed or not. */ static void qp_stop_fail_cb(struct hisi_qp *qp) { + int qp_used = atomic_read(&qp->qp_status.used); + u16 cur_tail = qp->qp_status.sq_tail; + u16 cur_head = (cur_tail + QM_Q_DEPTH - qp_used) % QM_Q_DEPTH; struct hisi_qm *qm = qp->qm; - int cur_head, cur_tail; - int j, cnt, pos; - - cur_tail = qp->qp_status.sq_tail; - cnt = atomic_read(&qp->qp_status.used); - cur_head = (cur_tail + QM_Q_DEPTH - cnt) % QM_Q_DEPTH; + u16 pos; + int i;
- for (j = 0; j < cnt; j++) { - pos = (j + cur_head) % QM_Q_DEPTH; - qp->req_cb(qp, qp->sqe + qm->sqe_size * pos); + for (i = 0; i < qp_used; i++) { + pos = (i + cur_head) % QM_Q_DEPTH; + qp->req_cb(qp, qp->sqe + (u32)(qm->sqe_size * pos)); atomic_dec(&qp->qp_status.used); } }
+static void qm_qp_has_no_task(struct hisi_qp *qp) +{ + size_t size = sizeof(struct qm_sqc) + sizeof(struct qm_cqc); + struct device *dev = &qp->qm->pdev->dev; + struct qm_sqc *sqc; + struct qm_cqc *cqc; + dma_addr_t dma_addr; + void *addr; + int i = 0; + int ret; + + if (qp->qm->err_ini.is_qm_ecc_mbit || qp->qm->err_ini.is_dev_ecc_mbit) + return; + + addr = qm_ctx_alloc(qp->qm, size, &dma_addr); + if (IS_ERR(addr)) { + dev_err(dev, "alloc ctx for sqc and cqc failed!\n"); + return; + } + + while (++i) { + ret = qm_dump_sqc_raw(qp->qm, dma_addr, qp->qp_id); + if (ret) { + dev_err(dev, "Failed to dump sqc!\n"); + break; + } + sqc = addr; + + ret = qm_dump_cqc_raw(qp->qm, + (dma_addr + sizeof(struct qm_sqc)), qp->qp_id); + if (ret) { + dev_err(dev, "Failed to dump cqc!\n"); + break; + } + cqc = addr + sizeof(struct qm_sqc); + + if ((sqc->tail == cqc->tail) && + (QM_SQ_TAIL_IDX(sqc) == QM_CQ_TAIL_IDX(cqc))) + break; + + if (WARN_ON(i == MAX_WAIT_COUNTS)) + break; + + usleep_range(WAIT_PERIOD_US_MIN, WAIT_PERIOD_US_MAX); + } + + qm_ctx_free(qp->qm, size, addr, &dma_addr); +} + static int hisi_qm_stop_qp_nolock(struct hisi_qp *qp) { struct device *dev = &qp->qm->pdev->dev;
/* it is stopped */ - if (atomic_read(&qp->qp_status.flags) == QP_STOP) + if (atomic_read(&qp->qp_status.flags) == QP_STOP) { + qp->is_resetting = false; return 0; + } if (!qm_qp_avail_state(qp->qm, qp, QP_STOP)) return -EPERM;
atomic_set(&qp->qp_status.flags, QP_STOP);
- /* waiting for increase used count in hisi_qp_send */ - udelay(WAIT_PERIOD); + qm_qp_has_no_task(qp); + + if (qp->qm->wq) + flush_workqueue(qp->qm->wq);
+ /* wait for increase used count in qp send and last poll qp finish */ + udelay(WAIT_PERIOD); if (atomic_read(&qp->qp_status.used)) qp_stop_fail_cb(qp);
@@ -2368,56 +2470,18 @@ static int qm_stop_started_qp(struct hisi_qm *qm) for (i = 0; i < qm->qp_num; i++) { qp = qm->qp_array[i]; if (qp && atomic_read(&qp->qp_status.flags) == QP_START) { + qp->is_resetting = true; ret = hisi_qm_stop_qp_nolock(qp); if (ret < 0) { dev_err(dev, "Failed to stop qp%d!\n", i); return ret; } - - qp->is_resetting = true; } }
return 0; }
-static void qm_set_resetting_flag(struct hisi_qm *qm) -{ - struct hisi_qp *qp; - int i; - - for (i = 0; i < qm->qp_num; i++) { - qp = qm->qp_array[i]; - if (qp && atomic_read(&qp->qp_status.flags) == QP_START) - qp->is_resetting = true; - } -} - -static void qm_wait_task_complete(struct hisi_qm *qm) -{ - struct hisi_qp *qp; - int tmcnt = 0; - int last_num; - int task_num; - int i; - - task_num = 0; - do { - last_num = task_num; - task_num = 0; - msleep(WAIT_PERIOD); - for (i = 0; i < qm->qp_num; i++) { - qp = qm->qp_array[i]; - if (qp) - task_num += atomic_read(&qp->qp_status.used); - } - if (task_num && last_num == task_num) - tmcnt++; - else - tmcnt = 0; - } while (task_num && tmcnt < MAX_WAIT_TASK_COUNTS); -} - /** * hisi_qm_stop() - Stop a qm. * @qm: The qm which will be stopped. @@ -2443,12 +2507,6 @@ int hisi_qm_stop(struct hisi_qm *qm, enum qm_stop_reason r)
if (qm->status.stop_reason == QM_SOFT_RESET || qm->status.stop_reason == QM_FLR) { - qm_set_resetting_flag(qm); - qm_wait_task_complete(qm); - } - - if (qm->status.stop_reason == QM_SOFT_RESET || - qm->status.stop_reason == QM_FLR) { ret = qm_stop_started_qp(qm); if (ret < 0) goto err_unlock;