From b97fc7eb4e2a576bdcbfbca2d12a107fd78804d2 Mon Sep 17 00:00:00 2001 From: Haibin Lu Date: Fri, 10 Nov 2023 10:58:14 +0800 Subject: [PATCH 1/5] UBL: verify skb space when sw_ctype adding driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8GIXF CVE: NA ----------------------------------------------------------- When sw_ctype is added, the skb_push function is used, which may cause exceptions because there is insufficient space between skb->head and skb->data. Before calling skb_push, this patch uses skb_cow_head for protection to ensure sufficient space. Signed-off-by: Haibin Lu --- drivers/net/ub/dev/ubl.c | 30 +++++++++++++++++++++++++++++- drivers/net/ub/dev/ubl.h | 25 +++---------------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/drivers/net/ub/dev/ubl.c b/drivers/net/ub/dev/ubl.c index 22132c067c1c..d94fcd1dab16 100644 --- a/drivers/net/ub/dev/ubl.c +++ b/drivers/net/ub/dev/ubl.c @@ -44,6 +44,32 @@ static __be16 ubl_type_to_proto(u8 type) return proto; } +/** + * ubl_add_sw_ctype - add software packet type for skb->data + * @skb: buffer to alter + * @ctype: indicates the packet type + * + * The packet type cannot be known by parsing packe from user, + * which leads to restrictions on the use of socket. + * Add cs_type field to indicate the packet type. And sw_ctype + * exists only during software prcessing. + * +----------+----+-----+-----------+ + * | sw_ctype | CC | NPI | L3 Packet | + * +----------+----+-----+-----------+ + */ +int ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype) +{ + u8 *pkt_cfg; + + if (skb_cow_head(skb, sizeof(u8))) + return -ENOMEM; + + pkt_cfg = (u8 *)skb_push(skb, sizeof(u8)); + *pkt_cfg = ctype; + + return 0; +} + /** * ubl_create_header - create the ubl header * @skb: buffer to alter @@ -72,7 +98,9 @@ int ubl_create_header(struct sk_buff *skb, struct net_device *dev, /* if type is ETH_P_UB, then do nothing. */ ret = 0; } - ubl_add_sw_ctype(skb, ctype); + + if (ubl_add_sw_ctype(skb, ctype)) + ret = -ENOMEM; return ret; } diff --git a/drivers/net/ub/dev/ubl.h b/drivers/net/ub/dev/ubl.h index 02424918b01f..8e646158d07c 100644 --- a/drivers/net/ub/dev/ubl.h +++ b/drivers/net/ub/dev/ubl.h @@ -59,26 +59,6 @@ struct ublhdr { __be32 h_npi; } __packed; -/** - * ubl_add_sw_ctype - add software packet type for skb->data - * @skb: buffer to alter - * @ctype: indicates the packet type - * - * The packet type cannot be known by parsing packe from user, - * which leads to restrictions on the use of socket. - * Add cs_type field to indicate the packet type. And sw_ctype - * exists only during software prcessing. - * +----------+----+-----+-----------+ - * | sw_ctype | CC | NPI | L3 Packet | - * +----------+----+-----+-----------+ - */ -static inline void ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype) -{ - u8 *pkt_cfg = (u8 *)skb_push(skb, sizeof(u8)); - - *pkt_cfg = ctype; -} - /** * ubl_rmv_sw_ctype - delete software packet type for skb->data * @skb: buffer to alter @@ -86,9 +66,9 @@ static inline void ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype) * Before the packet is sent to the hardware, remove sw_ctype field * and restore the original packet. */ -static inline void ubl_rmv_sw_ctype(struct sk_buff *skb) +static inline void *ubl_rmv_sw_ctype(struct sk_buff *skb) { - skb_pull_inline(skb, sizeof(u8)); + return pskb_pull(skb, sizeof(u8)); } int ubl_create_header(struct sk_buff *skb, struct net_device *dev, @@ -98,6 +78,7 @@ void ubl_setup(struct net_device *dev); __be16 ubl_type_trans(struct sk_buff *skb, struct net_device *dev, u8 type); struct net_device *alloc_ubndev_mqs(int sizeof_priv, unsigned int txqs, unsigned int rxqs); +int ubl_add_sw_ctype(struct sk_buff *skb, u8 ctype); #define alloc_ubndev_mq(sizeof_priv, count) \ alloc_ubndev_mqs((sizeof_priv), (count), (count)) -- Gitee From 9ad6364147047c02ed28aab9cfd70d93f82c51c3 Mon Sep 17 00:00:00 2001 From: Haibin Lu Date: Fri, 10 Nov 2023 15:01:33 +0800 Subject: [PATCH 2/5] UNIC: Add the processing of the return value of ubl_rmv_sw_ctype. driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8GIXF CVE: NA ----------------------------------------------------------- After sw_ctype fails to be removed, the xmit process is terminated. Signed-off-by: Haibin Lu --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 88efa8f9546f..7d6cecda2872 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2584,7 +2584,9 @@ netdev_tx_t hns3_nic_net_xmit(struct sk_buff *skb, struct net_device *netdev) } #ifdef CONFIG_HNS3_UBL if (hns3_ubl_supported(hns3_get_handle(netdev))) { - ubl_rmv_sw_ctype(skb); + if (!ubl_rmv_sw_ctype(skb)) + goto out_err_tx_ok; + hns3_unic_set_default_cc(skb); } #endif -- Gitee From b0c148879a02ad602d4526521d88b0a274aabe8d Mon Sep 17 00:00:00 2001 From: Haibin Lu Date: Fri, 10 Nov 2023 17:23:09 +0800 Subject: [PATCH 3/5] UNIC: The driver loading process is terminated when the guid fails to be obtained. driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8GIXF CVE: NA ----------------------------------------------------------- If the guid fails to be obtained during driver loading, the firmware is faulty. In this case, stop the driver loading process. This patch changes the return values of hns3_unic_init() and hns3_unic_init_guid() from void to int. When hns3_unic_init_guid() fails to be executed, The driver terminates its initialization process and releases the previously applied resources. Signed-off-by: Haibin Lu --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 22 +++++++++++++++---- .../net/ethernet/hisilicon/hns3/hns3_unic.c | 21 ++++++++++++------ .../net/ethernet/hisilicon/hns3/hns3_unic.h | 4 ++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 7d6cecda2872..e473d35907d6 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -5745,8 +5745,14 @@ static int hns3_client_init(struct hnae3_handle *handle) netdev->max_mtu = HNS3_MAX_MTU(ae_dev->dev_specs.max_frm_size); #ifdef CONFIG_HNS3_UBL - if (hns3_ubl_supported(handle)) - hns3_unic_init(netdev); + if (hns3_ubl_supported(handle)) { + ret = hns3_unic_init(netdev); + if (ret) { + dev_err(priv->dev, "failed to init unic, ret = %d\n", + ret); + goto out_dbg_init; + } + } #endif hns3_state_init(handle); @@ -5767,6 +5773,7 @@ static int hns3_client_init(struct hnae3_handle *handle) out_reg_netdev_fail: hns3_state_uninit(handle); +out_dbg_init: hns3_dbg_uninit(handle); hns3_client_stop(handle); out_client_start: @@ -6065,14 +6072,21 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle) goto err_client_start_fail; } #ifdef CONFIG_HNS3_UBL - if (hns3_ubl_supported(handle)) - hns3_unic_init_guid(netdev); + if (hns3_ubl_supported(handle)) { + ret = hns3_unic_init_guid(netdev); + if (ret) { + dev_err(priv->dev, "init guid failed! ret=%d\n", ret); + goto err_init_guid_fail; + } + } #endif set_bit(HNS3_NIC_STATE_INITED, &priv->state); return ret; +err_init_guid_fail: + hns3_client_stop(handle); err_client_start_fail: hns3_free_rx_cpu_rmap(netdev); hns3_nic_uninit_irq(priv); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c index 3320d1ad5bd9..0a28e8560b53 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c @@ -36,7 +36,7 @@ void hns3_unic_set_default_cc(struct sk_buff *skb) ubl->h_cc = htons(UNIC_CC_DEFAULT_FECN_MODE); } -void hns3_unic_init(struct net_device *netdev) +int hns3_unic_init(struct net_device *netdev) { struct hnae3_handle *h = hns3_get_handle(netdev); struct pci_dev *pdev = h->pdev; @@ -53,7 +53,7 @@ void hns3_unic_init(struct net_device *netdev) netdev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); netdev->max_mtu = ae_dev->dev_specs.max_frm_size; - hns3_unic_init_guid(netdev); + return hns3_unic_init_guid(netdev); } /** @@ -324,7 +324,7 @@ void hns3_unic_set_rx_mode(struct net_device *netdev) hns3_request_update_promisc_mode(h); } -void hns3_unic_init_guid(struct net_device *netdev) +int hns3_unic_init_guid(struct net_device *netdev) { const u8 bc_guid[HNS3_SIMPLE_GUID_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -336,13 +336,19 @@ void hns3_unic_init_guid(struct net_device *netdev) if (!h->ae_algo->ops->get_func_guid || !h->ae_algo->ops->set_func_guid) { netdev_err(netdev, "the guid handlers may not exist\n"); - return; + return -EOPNOTSUPP; } ret = h->ae_algo->ops->get_func_guid(h, temp_guid_addr); if (ret) { netdev_err(netdev, "get function guid fail, ret = %d!\n", ret); - return; + return ret; + } + + ret = hns3_unic_add_mc_guid(netdev, bc_guid); + if (ret) { + netdev_err(netdev, "add mc guid fail, ret = %d!\n", ret); + return ret; } memcpy(netdev->dev_addr, temp_guid_addr, netdev->addr_len); @@ -351,8 +357,9 @@ void hns3_unic_init_guid(struct net_device *netdev) ret = h->ae_algo->ops->set_func_guid(h, netdev->dev_addr); if (ret) { netdev_err(netdev, "set function guid fail, ret = %d\n", ret); - return; + hns3_unic_del_mc_guid(netdev, bc_guid); + return ret; } - hns3_unic_add_mc_guid(netdev, bc_guid); + return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h index d4071dd72376..028405e39da9 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.h @@ -51,7 +51,7 @@ static inline void hns3_unic_format_sim_guid_addr(char *format_simple_guid_addr, } void hns3_unic_set_default_cc(struct sk_buff *skb); -void hns3_unic_init(struct net_device *netdev); +int hns3_unic_init(struct net_device *netdev); void hns3_unic_set_l3_type(struct sk_buff *skb, u32 *type_cs_vlan_tso); u8 hns3_unic_get_l3_type(struct net_device *netdev, u32 ol_info, u32 l234info); void hns3_unic_lp_setup_skb(struct sk_buff *skb); @@ -60,6 +60,6 @@ void hns3_unic_lb_check_skb_data(struct hns3_enet_ring *ring, void register_ipaddr_notifier(void); void unregister_ipaddr_notifier(void); void hns3_unic_set_rx_mode(struct net_device *netdev); -void hns3_unic_init_guid(struct net_device *netdev); +int hns3_unic_init_guid(struct net_device *netdev); #endif -- Gitee From ea647614603e4681cb2d5f20fd03eed2c8a9963f Mon Sep 17 00:00:00 2001 From: Haibin Lu Date: Sat, 11 Nov 2023 10:34:31 +0800 Subject: [PATCH 4/5] UNIC: config function guid to hw in periodic service task driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8GIXF CVE: NA ----------------------------------------------------------- In the current version, the unic driver configures the function guid to the hardware during initialization. However, no processing is performed after the configuration fails. As a result, the function guid may not be configured to the hardware. This patch adds the process of configuring the function guid to the periodic task to ensure that the function guid can be configured to the hardware. Signed-off-by: Haibin Lu --- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 2 +- .../hns3/hns3_common/hclge_comm_unic_addr.c | 20 ++++++++++++------- .../hns3/hns3_common/hclge_comm_unic_addr.h | 4 ++-- .../net/ethernet/hisilicon/hns3/hns3_unic.c | 7 +------ .../hisilicon/hns3/hns3pf/hclge_main.c | 1 + .../hisilicon/hns3/hns3pf/hclge_main.h | 1 + .../hisilicon/hns3/hns3pf/hclge_unic_guid.c | 6 +++--- .../hisilicon/hns3/hns3pf/hclge_unic_guid.h | 2 +- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 1 + .../hisilicon/hns3/hns3vf/hclgevf_main.h | 1 + .../hisilicon/hns3/hns3vf/hclgevf_unic_guid.c | 4 ++-- .../hisilicon/hns3/hns3vf/hclgevf_unic_guid.h | 2 +- 12 files changed, 28 insertions(+), 23 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index e6f8a254d329..0bd3d361f48a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -858,7 +858,7 @@ struct hnae3_ae_ops { const unsigned char *addr, enum hnae3_unic_addr_type addr_type); int (*get_func_guid)(struct hnae3_handle *handle, u8 *guid); - int (*set_func_guid)(struct hnae3_handle *handle, u8 *guid); + void (*set_func_guid)(struct hnae3_handle *handle, u8 *guid); }; struct hnae3_dcb_ops { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c index 136ec25d2c45..5c11aaa80620 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.c @@ -248,32 +248,38 @@ hclge_comm_unic_func_guid_cmd_prepare(u8 *guid, memcpy(req->guid, guid, UBL_ALEN); } -int hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 *guid) +void hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 **guid) { struct hclge_comm_func_guid_cmd *req; struct hclge_desc desc; int ret; + if (!*guid) + return; + req = (struct hclge_comm_func_guid_cmd *)desc.data; hclge_comm_cmd_setup_basic_desc(&desc, HCLGE_OPC_COMM_CFG_FUNC_GUID, false); - hclge_comm_unic_func_guid_cmd_prepare(guid, req); + hclge_comm_unic_func_guid_cmd_prepare(*guid, req); ret = hclge_comm_cmd_send(hw, &desc, 1); if (ret) - dev_err(&hw->cmq.csq.pdev->dev, - "failed to set guid for cmd_send, ret = %d\n", ret); - - return ret; + dev_warn(&hw->cmq.csq.pdev->dev, + "set guid failed for cmd_send, ret = %d.\n", ret); + else + *guid = NULL; } -void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw) +void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw, u8 **guid) { struct hclge_comm_func_guid_cmd *req; struct hclge_desc desc; int ret; + if (*guid) + return; + req = (struct hclge_comm_func_guid_cmd *)desc.data; hclge_comm_cmd_setup_basic_desc(&desc, HCLGE_OPC_COMM_CFG_FUNC_GUID, diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h index 0db62ac8dbcb..398396099f83 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_common/hclge_comm_unic_addr.h @@ -100,8 +100,8 @@ bool hclge_comm_unic_sync_addr_table(struct hnae3_handle *handle, struct list_head *)); int hclge_comm_unic_convert_ip_addr(const struct sockaddr *addr, struct in6_addr *ip_addr); -int hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 *guid); +void hclge_comm_unic_set_func_guid(struct hclge_comm_hw *hw, u8 **guid); int hclge_comm_unic_get_func_guid(struct hclge_comm_hw *hw, u8 *guid); -void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw); +void hclge_comm_unic_rm_func_guid(struct hclge_comm_hw *hw, u8 **guid); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c index 0a28e8560b53..7e904c23c8b7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_unic.c @@ -354,12 +354,7 @@ int hns3_unic_init_guid(struct net_device *netdev) memcpy(netdev->dev_addr, temp_guid_addr, netdev->addr_len); memcpy(netdev->perm_addr, temp_guid_addr, netdev->addr_len); - ret = h->ae_algo->ops->set_func_guid(h, netdev->dev_addr); - if (ret) { - netdev_err(netdev, "set function guid fail, ret = %d\n", ret); - hns3_unic_del_mc_guid(netdev, bc_guid); - return ret; - } + h->ae_algo->ops->set_func_guid(h, netdev->dev_addr); return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 5ac0d87eb9da..094adac1bdb7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -4775,6 +4775,7 @@ static void hclge_periodic_service_task(struct hclge_dev *hdev) if (hnae3_dev_ubl_supported(hdev->ae_dev)) { hclge_unic_sync_mguid_table(hdev); hclge_unic_sync_ip_table(hdev); + hclge_comm_unic_set_func_guid(&hdev->hw.hw, &hdev->hw.func_guid); } #endif hclge_sync_promisc_mode(hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h index cc373064f198..890fd92beded 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.h @@ -297,6 +297,7 @@ struct hclge_hw { struct hclge_comm_hw hw; struct hclge_mac mac; int num_vec; + u8 *func_guid; }; enum hclge_fc_mode { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c index afbffa0aafc2..376c5dc1de74 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.c @@ -577,12 +577,12 @@ void hclge_unic_reset_mc_guid_space(struct hclge_dev *hdev) bitmap_zero(hdev->mc_guid_tbl_bmap, HCLGE_UNIC_MC_GUID_NUM); } -int hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) +void hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) { struct hclge_vport *vport = hclge_get_vport(handle); struct hclge_dev *hdev = vport->back; - return hclge_comm_unic_set_func_guid(&hdev->hw.hw, guid); + hdev->hw.func_guid = guid; } int hclge_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid) @@ -595,5 +595,5 @@ int hclge_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid) void hclge_unic_rm_func_guid(struct hclge_dev *hdev) { - hclge_comm_unic_rm_func_guid(&hdev->hw.hw); + hclge_comm_unic_rm_func_guid(&hdev->hw.hw, &hdev->hw.func_guid); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h index c9b66400f51d..56f11f43a553 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_unic_guid.h @@ -37,7 +37,7 @@ void hclge_unic_del_vport_all_mc_guid_table(struct hclge_vport *vport, int hclge_unic_update_guid_list(struct hclge_vport *vport, enum HCLGE_COMM_ADDR_NODE_STATE state, const unsigned char *addr); -int hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); +void hclge_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); int hclge_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid); void hclge_unic_rm_func_guid(struct hclge_dev *hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index c702df081275..df1975dc4e81 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -2004,6 +2004,7 @@ static void hclgevf_periodic_service_task(struct hclgevf_dev *hdev) if (hnae3_dev_ubl_supported(hdev->ae_dev)) { hclgevf_unic_sync_mc_guid_list(hdev); hclgevf_unic_sync_ip_list(hdev); + hclge_comm_unic_set_func_guid(&hdev->hw.hw, &hdev->hw.func_guid); } #endif hclgevf_sync_promisc_mode(hdev); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index 699a2afaef0e..77526a0a315b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -156,6 +156,7 @@ struct hclgevf_hw { struct hclge_comm_hw hw; int num_vec; struct hclgevf_mac mac; + u8 *func_guid; }; struct hclgevf_cfg { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c index 53b2b206e745..8762690c5ac7 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.c @@ -103,11 +103,11 @@ void hclgevf_unic_uninit_mc_guid_list(struct hclgevf_dev *hdev) spin_unlock_bh(&hdev->mguid_list_lock); } -int hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) +void hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid) { struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); - return hclge_comm_unic_set_func_guid(&hdev->hw.hw, guid); + hdev->hw.func_guid = guid; } int hclgevf_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h index faf9c90106d9..dd4e308c9e6a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_unic_guid.h @@ -13,7 +13,7 @@ void hclgevf_unic_uninit_mc_guid_list(struct hclgevf_dev *hdev); int hclgevf_unic_update_guid_list(struct hnae3_handle *handle, enum HCLGE_COMM_ADDR_NODE_STATE state, const unsigned char *addr); -int hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); +void hclgevf_unic_set_func_guid(struct hnae3_handle *handle, u8 *guid); int hclgevf_unic_get_func_guid(struct hnae3_handle *handle, u8 *guid); #endif -- Gitee From 7d7d42749689bda81ab215243755cdaf131dde10 Mon Sep 17 00:00:00 2001 From: Fengyan Mu Date: Thu, 9 Nov 2023 21:04:30 +0800 Subject: [PATCH 5/5] Use udma's macro to isolate udma client functions driver inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8GIXF CVE: NA -------------------------------------------------------------------- Use udma's macro CONFIG_HNS3_UDMA to isolate udma client functions in hclge_main_c and hclgevf_main_c. Signed-off-by: Fengyan Mu --- drivers/net/ethernet/hisilicon/hns3/Makefile | 8 ++-- .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 2 + .../hisilicon/hns3/hns3pf/hclge_err.c | 9 +++- .../hisilicon/hns3/hns3pf/hclge_main.c | 48 +++++++++++++++++-- .../hisilicon/hns3/hns3vf/hclgevf_main.c | 24 ++++++++++ 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/Makefile b/drivers/net/ethernet/hisilicon/hns3/Makefile index bd5aea7dd490..28068f9ea35b 100644 --- a/drivers/net/ethernet/hisilicon/hns3/Makefile +++ b/drivers/net/ethernet/hisilicon/hns3/Makefile @@ -21,18 +21,18 @@ hns3-$(CONFIG_HNS3_UBL) += hns3_unic.o hns3_unic_debugfs.o obj-$(CONFIG_HNS3_HCLGEVF) += hclgevf.o hclgevf-objs = hns3vf/hclgevf_main.o hns3vf/hclgevf_mbx.o hns3vf/hclgevf_devlink.o hns3vf/hclgevf_regs.o \ - hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o \ - hns3vf/hclgevf_udma.o + hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o hclgevf-$(CONFIG_HNS3_UBL) += hns3_common/hclge_comm_unic_addr.o hns3vf/hclgevf_unic_ip.o hns3vf/hclgevf_unic_guid.o \ hns3vf/hclgevf_unic_addr.o +hclgevf-$(CONFIG_UB_UDMA_HNS3) += hns3vf/hclgevf_udma.o obj-$(CONFIG_HNS3_HCLGE) += hclge.o hclge-objs = hns3pf/hclge_main.o hns3pf/hclge_mdio.o hns3pf/hclge_tm.o hns3pf/hclge_sysfs.o hns3pf/hclge_regs.o \ hns3pf/hclge_mbx.o hns3pf/hclge_err.o hns3pf/hclge_debugfs.o hns3pf/hclge_ptp.o hns3pf/hclge_devlink.o \ - hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o \ - hns3pf/hclge_udma.o + hns3_common/hclge_comm_cmd.o hns3_common/hclge_comm_rss.o hns3_common/hclge_comm_tqp_stats.o hclge-objs += hns3pf/hclge_ext.o hclge-$(CONFIG_HNS3_UBL) += hns3_common/hclge_comm_unic_addr.o hns3pf/hclge_unic_ip.o hns3pf/hclge_unic_guid.o \ hns3pf/hclge_unic_addr.o +hclge-$(CONFIG_UB_UDMA_HNS3) += hns3pf/hclge_udma.o hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index 54ce0cb8b05e..5d994e8c3f1a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -1821,7 +1821,9 @@ int hclge_dbg_dump_rst_info(struct hclge_dev *hdev, char *buf, int len) hclge_read_dev(&hdev->hw, offset)); } +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) hclge_dbg_dump_udma_rst_info(hdev, buf, len, &pos); +#endif pos += scnprintf(buf + pos, len - pos, "hdev state: 0x%lx\n", hdev->state); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index bd849e06c658..91f0a49a3403 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -2758,7 +2758,10 @@ void hclge_handle_all_hns_hw_errors(struct hnae3_ae_dev *ae_dev) bool hclge_find_error_source(struct hclge_dev *hdev) { - u32 msix_src_flag, hw_err_src_flag, udma_err_src_flag; + u32 msix_src_flag, hw_err_src_flag; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) + u32 udma_err_src_flag; +#endif msix_src_flag = hclge_read_dev(&hdev->hw, HCLGE_MISC_VECTOR_INT_STS) & HCLGE_VECTOR0_REG_MSIX_MASK; @@ -2766,10 +2769,14 @@ bool hclge_find_error_source(struct hclge_dev *hdev) hw_err_src_flag = hclge_read_dev(&hdev->hw, HCLGE_RAS_PF_OTHER_INT_STS_REG) & HCLGE_RAS_REG_ERR_MASK; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) udma_err_src_flag = hclge_get_udma_error_reg(hdev) & HCLGE_RAS_REG_ERR_MASK_UB; return msix_src_flag || hw_err_src_flag || udma_err_src_flag; +#else + return msix_src_flag || hw_err_src_flag; +#endif } void hclge_handle_occurred_error(struct hclge_dev *hdev) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 094adac1bdb7..9b7ddc9abf98 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -796,7 +796,9 @@ static int hclge_query_function_status(struct hclge_dev *hdev) static int hclge_query_pf_resource(struct hclge_dev *hdev) { +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); +#endif struct hclge_pf_res_cmd *req; struct hclge_desc desc; int ret; @@ -849,11 +851,13 @@ static int hclge_query_pf_resource(struct hclge_dev *hdev) */ hdev->num_msi = hdev->num_nic_msi + hdev->num_roce_msi + hdev->num_roh_msi; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) } else if (hnae3_dev_udma_supported(ae_dev)) { hdev->num_udma_msi = le16_to_cpu(req->pf_intr_vector_number_roce); hdev->num_msi = hdev->num_nic_msi + hdev->num_udma_msi; +#endif } else { hdev->num_msi = hdev->num_nic_msi; } @@ -2982,11 +2986,13 @@ static void hclge_push_link_status(struct hclge_dev *hdev) static void hclge_update_link_status(struct hclge_dev *hdev) { struct hnae3_handle *rhandle = &hdev->vport[0].roce; - struct hnae3_handle *uhandle = &hdev->vport[0].udma; struct hnae3_handle *handle = &hdev->vport[0].nic; struct hnae3_client *rclient = hdev->roce_client; - struct hnae3_client *uclient = hdev->udma_client; struct hnae3_client *client = hdev->nic_client; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) + struct hnae3_handle *uhandle = &hdev->vport[0].udma; + struct hnae3_client *uclient = hdev->udma_client; +#endif int state; int ret; @@ -3008,8 +3014,10 @@ static void hclge_update_link_status(struct hclge_dev *hdev) hclge_config_mac_tnl_int(hdev, state); if (rclient && rclient->ops->link_status_change) rclient->ops->link_status_change(rhandle, state); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (uclient && uclient->ops->link_status_change) uclient->ops->link_status_change(uhandle, state); +#endif hclge_push_link_status(hdev); } @@ -3464,14 +3472,16 @@ static int hclge_set_vf_link_state(struct hnae3_handle *handle, int vf, static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) { - u32 cmdq_src_reg, msix_src_reg, hw_err_src_reg, udma_err_src_reg; + u32 cmdq_src_reg, msix_src_reg, hw_err_src_reg; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) + u32 udma_err_src_reg = hclge_get_udma_error_reg(hdev); +#endif /* fetch the events from their corresponding regs */ cmdq_src_reg = hclge_read_dev(&hdev->hw, HCLGE_VECTOR0_CMDQ_SRC_REG); msix_src_reg = hclge_read_dev(&hdev->hw, HCLGE_MISC_VECTOR_INT_STS); hw_err_src_reg = hclge_read_dev(&hdev->hw, HCLGE_RAS_PF_OTHER_INT_STS_REG); - udma_err_src_reg = hclge_get_udma_error_reg(hdev); /* Assumption: If by any chance reset and mailbox events are reported * together then we will only process reset event in this go and will @@ -3500,10 +3510,16 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) } /* check for vector0 msix event and hardware error event source */ +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (msix_src_reg & HCLGE_VECTOR0_REG_MSIX_MASK || hw_err_src_reg & HCLGE_RAS_REG_ERR_MASK || udma_err_src_reg & HCLGE_RAS_REG_ERR_MASK_UB) return HCLGE_VECTOR0_EVENT_ERR; +#else + if (msix_src_reg & HCLGE_VECTOR0_REG_MSIX_MASK || + hw_err_src_reg & HCLGE_RAS_REG_ERR_MASK) + return HCLGE_VECTOR0_EVENT_ERR; +#endif /* check for vector0 ptp event source */ if (BIT(HCLGE_VECTOR0_REG_PTP_INT_B) & msix_src_reg) { @@ -3519,10 +3535,16 @@ static u32 hclge_check_event_cause(struct hclge_dev *hdev, u32 *clearval) } /* print other vector0 event source */ +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) dev_info(&hdev->pdev->dev, "INT status: CMDQ(%#x) HW errors(%#x, %#x) other(%#x)\n", cmdq_src_reg, hw_err_src_reg, udma_err_src_reg, msix_src_reg); +#else + dev_info(&hdev->pdev->dev, + "INT status: CMDQ(%#x) HW errors(%#x) other(%#x)\n", + cmdq_src_reg, hw_err_src_reg, msix_src_reg); +#endif return HCLGE_VECTOR0_EVENT_OTHER; } @@ -4262,9 +4284,11 @@ static int hclge_reset_prepare(struct hclge_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_DOWN_CLIENT); if (ret) return ret; +#endif rtnl_lock(); ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); @@ -4290,9 +4314,11 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_UNINIT_CLIENT); if (ret) return ret; +#endif rtnl_lock(); ret = hclge_reset_stack(hdev); @@ -4318,6 +4344,7 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_INIT_CLIENT); /* ignore udma notify error if it fails HCLGE_RESET_MAX_FAIL_CNT - 1 * times @@ -4325,6 +4352,7 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) if (ret && hdev->rst_stats.reset_fail_cnt < HCLGE_RESET_MAX_FAIL_CNT - 1) return ret; +#endif ret = hclge_reset_prepare_up(hdev); if (ret) @@ -4344,9 +4372,11 @@ static int hclge_reset_rebuild(struct hclge_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_notify_udma_client(hdev, HNAE3_UP_CLIENT); if (ret) return ret; +#endif hdev->last_reset_time = jiffies; hdev->rst_stats.reset_fail_cnt = 0; @@ -4864,8 +4894,10 @@ struct hclge_vport *hclge_get_vport(struct hnae3_handle *handle) return container_of(handle, struct hclge_vport, roce); else if (handle->client->type == HNAE3_CLIENT_ROH) return container_of(handle, struct hclge_vport, roh); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) else if (handle->client->type == HNAE3_CLIENT_UDMA) return container_of(handle, struct hclge_vport, udma); +#endif else return container_of(handle, struct hclge_vport, nic); } @@ -11824,9 +11856,11 @@ static int hclge_init_client_instance(struct hnae3_client *client, if (ret) goto clear_roce; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclge_init_udma_client_instance(ae_dev, vport); if (ret) goto clear_udma; +#endif break; case HNAE3_CLIENT_ROCE: @@ -11851,6 +11885,7 @@ static int hclge_init_client_instance(struct hnae3_client *client, goto clear_roh; break; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) case HNAE3_CLIENT_UDMA: if (hnae3_dev_udma_supported(ae_dev)) { hdev->udma_client = client; @@ -11862,6 +11897,7 @@ static int hclge_init_client_instance(struct hnae3_client *client, goto clear_udma; break; +#endif default: return -EINVAL; } @@ -11880,10 +11916,12 @@ static int hclge_init_client_instance(struct hnae3_client *client, hdev->roh_client = NULL; vport->roh.client = NULL; return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) clear_udma: hdev->udma_client = NULL; vport->udma.client = NULL; return ret; +#endif } static void hclge_uninit_client_instance(struct hnae3_client *client, @@ -11892,6 +11930,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, struct hclge_dev *hdev = ae_dev->priv; struct hclge_vport *vport = &hdev->vport[0]; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (hdev->udma_client && (client->type == HNAE3_CLIENT_UDMA || client->type == HNAE3_CLIENT_KNIC)) { clear_bit(HCLGE_STATE_UDMA_REGISTERED, &hdev->state); @@ -11904,6 +11943,7 @@ static void hclge_uninit_client_instance(struct hnae3_client *client, } if (client->type == HNAE3_CLIENT_UDMA) return; +#endif if (hdev->roh_client && (client->type == HNAE3_CLIENT_ROH || client->type == HNAE3_CLIENT_KNIC)) { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index df1975dc4e81..b9be10cab8e0 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -79,8 +79,10 @@ struct hclgevf_dev *hclgevf_ae_get_hdev(struct hnae3_handle *handle) return container_of(handle, struct hclgevf_dev, nic); else if (handle->client->type == HNAE3_CLIENT_ROCE) return container_of(handle, struct hclgevf_dev, roce); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) else if (handle->client->type == HNAE3_CLIENT_UDMA) return container_of(handle, struct hclgevf_dev, udma); +#endif else return container_of(handle, struct hclgevf_dev, nic); } @@ -452,7 +454,9 @@ static void hclgevf_request_link_info(struct hclgevf_dev *hdev) void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state) { struct hnae3_handle *rhandle = &hdev->roce; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) struct hnae3_handle *uhandle = &hdev->udma; +#endif struct hnae3_handle *handle = &hdev->nic; struct hnae3_client *rclient; struct hnae3_client *uclient; @@ -472,8 +476,10 @@ void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state) client->ops->link_status_change(handle, !!link_state); if (rclient && rclient->ops->link_status_change) rclient->ops->link_status_change(rhandle, !!link_state); +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) if (uclient && uclient->ops->link_status_change) uclient->ops->link_status_change(uhandle, !!link_state); +#endif } clear_bit(HCLGEVF_STATE_LINK_UPDATING, &hdev->state); @@ -1609,9 +1615,11 @@ static int hclgevf_reset_prepare(struct hclgevf_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_notify_udma_client(hdev, HNAE3_DOWN_CLIENT); if (ret) return ret; +#endif rtnl_lock(); /* bring down the nic to stop any ongoing TX/RX */ @@ -1632,9 +1640,11 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_notify_udma_client(hdev, HNAE3_UNINIT_CLIENT); if (ret) return ret; +#endif rtnl_lock(); /* now, re-initialize the nic client and ae device */ @@ -1657,6 +1667,7 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) if (ret) return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_notify_udma_client(hdev, HNAE3_INIT_CLIENT); /* ignore UDMA notify error if it fails HCLGEVF_RESET_MAX_FAIL_CNT - 1 * times @@ -1668,6 +1679,7 @@ static int hclgevf_reset_rebuild(struct hclgevf_dev *hdev) ret = hclgevf_notify_udma_client(hdev, HNAE3_UP_CLIENT); if (ret) return ret; +#endif hdev->last_reset_time = jiffies; hdev->rst_stats.rst_done_cnt++; @@ -2565,10 +2577,12 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, if (ret) goto clear_roce; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) ret = hclgevf_init_udma_client_instance(ae_dev, hdev->udma_client); if (ret) goto clear_udma; +#endif break; case HNAE3_CLIENT_ROCE: @@ -2582,6 +2596,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, goto clear_roce; break; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) case HNAE3_CLIENT_UDMA: if (hnae3_dev_udma_supported(ae_dev)) { hdev->udma_client = client; @@ -2593,6 +2608,7 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, goto clear_udma; break; +#endif default: return -EINVAL; } @@ -2607,10 +2623,12 @@ static int hclgevf_init_client_instance(struct hnae3_client *client, hdev->roce_client = NULL; hdev->roce.client = NULL; return ret; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) clear_udma: hdev->udma_client = NULL; hdev->udma.client = NULL; return ret; +#endif } static void hclgevf_uninit_client_instance(struct hnae3_client *client, @@ -2618,6 +2636,7 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, { struct hclgevf_dev *hdev = ae_dev->priv; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) /* un-init udma, if it exists and called by nic or udma client */ if (hdev->udma_client && (client->type == HNAE3_CLIENT_UDMA || client->type == HNAE3_CLIENT_KNIC)) { @@ -2631,6 +2650,7 @@ static void hclgevf_uninit_client_instance(struct hnae3_client *client, } if (client->type == HNAE3_CLIENT_UDMA) return; +#endif /* un-init roce, if it exists */ if (hdev->roce_client) { @@ -2742,7 +2762,9 @@ static void hclgevf_pci_uninit(struct hclgevf_dev *hdev) static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) { +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) struct hnae3_ae_dev *ae_dev = pci_get_drvdata(hdev->pdev); +#endif struct hclgevf_query_res_cmd *req; struct hclge_desc desc; int ret; @@ -2774,6 +2796,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) */ hdev->num_msi = hdev->num_roce_msix + hdev->roce_base_msix_offset; +#if IS_ENABLED(CONFIG_UB_UDMA_HNS3) } else if (hnae3_dev_udma_supported(ae_dev)) { hdev->roce_base_msix_offset = hnae3_get_field(le16_to_cpu(req->msixcap_localid_ba_rocee), @@ -2791,6 +2814,7 @@ static int hclgevf_query_vf_resource(struct hclgevf_dev *hdev) */ hdev->num_msi = hdev->num_udma_msix + hdev->roce_base_msix_offset; +#endif } else { hdev->num_msi = hnae3_get_field(le16_to_cpu(req->vf_intr_vector_number), -- Gitee