Unverified Commit 273a4fbc authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!2864 unic: add ub support to hns3

Merge Pull Request from: @mufengyan 
 
drivers inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8GIXF


CVE: NA

---------------------------------------------------------------

1、Supports the Layer 2 network protocol UBLink.
2、The HNS3 driver supports the UB device. When the driver is loaded
based on the UB device, the driver enters the UB mode and has the
capability of sending and receiving UB packets.
3、These patches fix the bug that configure function guid while
initialization; change the use of sw_ctype in ubl; isolate udma
client functions by udma's macro.

Signed-off-by: default avatarJunxin Chen <chenjunxin1@huawei.com>
Signed-off-by: default avatarFengyan Mu <mufengyan@hisilicon.com>
Signed-off-by: default avatarHaibin Lu <luhaibin10@hisilicon.com>
 
Link:https://gitee.com/openeuler/kernel/pulls/2864

 

Reviewed-by: default avatarLin Yunsheng <linyunsheng@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents f38b9862 7d7d4274
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -864,7 +864,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 {
+13 −7
Original line number Diff line number Diff line
@@ -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,
+2 −2
Original line number Diff line number Diff line
@@ -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
+21 −5
Original line number Diff line number Diff line
@@ -2585,7 +2585,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
@@ -5765,8 +5767,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);
@@ -5787,6 +5795,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:
@@ -6085,14 +6094,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);
Loading