Unverified Commit 8bce29da authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!10925 [openEuler-22.03-LTS-SP4]UNIC: fixup the problem of print and free...

!10925 [openEuler-22.03-LTS-SP4]UNIC: fixup the problem of print and free mguid'memory after init failed

Merge Pull Request from: @mufengyan 
 
UNIC: fixup the problem of print and free mguid'memory after init failed

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAKMX4


CVE: NA

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

This PR includes seven patches as listed below:
1、0001-UNIC-Solve-the-problem-of-redundant-print-in-ub-mode.patch
2、0002-UNIC-bugfix-for-mguid-s-memory-not-be-free-after-net.patch
3、0003-unic-deleted-redundant-code-and-added-default-proces.patch
4、0004-unic-fix-issue-that-return-value-is-not-processed.patch
5、0005-ubl-correct-comments-and-delete-unused-EXPORT_SYMBOL.patch
6、0006-UNIC-Fix-the-issue-that-RPS-cannot-hash-sw-irq-to-mu.patch
7、0007-UNIC-Fix-the-issue-that-the-debugfs-query-inconsistency.patch

Signed-off-by: default avatarHaibin Lu <luhaibin10@hisilicon.com>
Signed-off-by: default avatarJunxin Chen <chenjunxin1@huawei.com>
Signed-off-by: default avatarGuangwei Zhang <zhangwangwei6@huawei.com>
 
Link:https://gitee.com/openeuler/kernel/pulls/10925

 

Reviewed-by: default avatarLin Yunsheng <linyunsheng@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents 4c126c01 e62daf7f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,6 +33,6 @@ hclge-objs = hns3pf/hclge_main.o hns3pf/hclge_mdio.o hns3pf/hclge_tm.o hns3pf/hc
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
			hns3pf/hclge_unic_addr.o hns3pf/hclge_unic_debugfs.o
hclge-$(CONFIG_UB_UDMA_HNS3) += hns3pf/hclge_udma.o
hclge-$(CONFIG_HNS3_DCB) += hns3pf/hclge_dcb.o
+2 −0
Original line number Diff line number Diff line
@@ -383,11 +383,13 @@ enum hnae3_dbg_cmd {
	HNAE3_DBG_CMD_PAGE_POOL_INFO,
	HNAE3_DBG_CMD_COAL_INFO,
	HNAE3_DBG_CMD_WOL_INFO,
#ifdef CONFIG_HNS3_UBL
	HNAE3_DBG_CMD_IP_SPEC,
	HNAE3_DBG_CMD_GUID_SPEC,
	HNAE3_DBG_CMD_IP_LIST,
	HNAE3_DBG_CMD_GUID_LIST,
	HNAE3_DBG_CMD_FASTPATH_INFO,
#endif
	HNAE3_DBG_CMD_UNKNOWN,
};

+2 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ hclge_comm_unic_update_addr_node(struct hclge_comm_unic_addr_node *addr_node,
		if (addr_node->state == HCLGE_COMM_UNIC_ADDR_TO_ADD)
			addr_node->state = HCLGE_COMM_UNIC_ADDR_ACTIVE;
		break;
	default:
		break;
	}
}

+8 −1
Original line number Diff line number Diff line
@@ -3305,7 +3305,6 @@ const struct net_device_ops hns3_unic_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_rate	= hns3_nic_set_vf_rate,
	.ndo_select_queue	= hns3_nic_select_queue,
};

@@ -4686,6 +4685,10 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)

	ring->tqp_vector->rx_group.total_bytes += len;

#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(hns3_get_handle(netdev)))
		return 0;
#endif
	hns3_set_rx_skb_rss_type(ring, skb, le32_to_cpu(desc->rx.rss_hash),
				 l234info, ol_info);
	return 0;
@@ -5827,6 +5830,10 @@ static int hns3_client_init(struct hnae3_handle *handle)

out_reg_netdev_fail:
	hns3_state_uninit(handle);
#ifdef CONFIG_HNS3_UBL
	if (hns3_ubl_supported(handle))
		hns3_unic_uninit(netdev);
#endif
out_dbg_init:
	hns3_dbg_uninit(handle);
	hns3_client_stop(handle);
+74 −35
Original line number Diff line number Diff line
@@ -27,6 +27,18 @@

#define HNS3_UNIC_LB_TEST_PACKET_SIZE	128

static const u8 mc_guid[][HNS3_SIMPLE_GUID_LEN] = {
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x00}, /* DHCPv4 */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x01}, /* DHCPv6 */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x02}, /* IP notify */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x03}, /* ULDP */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x04}, /* ULAP */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x05}, /* Time sync */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x06}, /* NPIC */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x07}, /* NNP */
	{0xff, 0xff, 0xff, 0xff, 0x01, 0x08}, /* PHCP */
};

void hns3_unic_set_default_cc(struct sk_buff *skb)
{
	struct ublhdr *ubl = (struct ublhdr *)skb->data;
@@ -89,8 +101,8 @@ u8 hns3_unic_get_l3_type(struct net_device *netdev, u32 ol_info, u32 l234info)
	return UB_UNKNOWN_CFG_TYPE;
}

static int addr_event(struct notifier_block *nb, unsigned long event,
		      struct sockaddr *sa, struct net_device *ndev)
static int addr_event(unsigned long event, struct sockaddr *sa,
		      struct net_device *ndev)
{
	struct hnae3_handle *handle;
	int ret;
@@ -141,7 +153,7 @@ static int unic_inetaddr_event(struct notifier_block *this, unsigned long event,
	in.sin_family = AF_INET;
	in.sin_addr.s_addr = ifa4->ifa_address;

	return addr_event(this, event, (struct sockaddr *)&in, ndev);
	return addr_event(event, (struct sockaddr *)&in, ndev);
}

static int unic_inet6addr_event(struct notifier_block *this, unsigned long event,
@@ -154,7 +166,7 @@ static int unic_inet6addr_event(struct notifier_block *this, unsigned long event
	in6.sin6_family = AF_INET6;
	in6.sin6_addr = ifa6->addr;

	return addr_event(this, event, (struct sockaddr *)&in6, ndev);
	return addr_event(event, (struct sockaddr *)&in6, ndev);
}

static struct notifier_block unic_inetaddr_notifier = {
@@ -167,14 +179,14 @@ static struct notifier_block unic_inet6addr_notifier = {

void register_ipaddr_notifier(void)
{
	register_inetaddr_notifier(&unic_inetaddr_notifier);
	register_inet6addr_notifier(&unic_inet6addr_notifier);
	(void)register_inetaddr_notifier(&unic_inetaddr_notifier);
	(void)register_inet6addr_notifier(&unic_inet6addr_notifier);
}

void unregister_ipaddr_notifier(void)
{
	unregister_inetaddr_notifier(&unic_inetaddr_notifier);
	unregister_inet6addr_notifier(&unic_inet6addr_notifier);
	(void)unregister_inetaddr_notifier(&unic_inetaddr_notifier);
	(void)unregister_inet6addr_notifier(&unic_inet6addr_notifier);
}

#define UNIC_DHCPV4_PROTO 0x0100
@@ -239,7 +251,7 @@ void hns3_unic_lb_check_skb_data(struct hns3_enet_ring *ring,
	if (is_success)
		tqp_vector->rx_group.total_packets++;
	else
		print_hex_dump(KERN_ERR, "ubl selftest:", DUMP_PREFIX_OFFSET,
		print_hex_dump(KERN_ERR, "selftest:", DUMP_PREFIX_OFFSET,
			       HNS3_UNIC_DUMP_ROW_SIZE, 1, skb->data, len, true);

	dev_kfree_skb_any(skb);
@@ -262,6 +274,9 @@ static int hns3_unic_add_mc_guid(struct net_device *netdev,
	struct hnae3_handle *h = hns3_get_handle(netdev);
	u8 mguid[UBL_ALEN] = {0};

	if (!h->ae_algo->ops->add_addr)
		return -EOPNOTSUPP;

	if (!hns3_unic_mguid_valid_check(addr)) {
		hns3_unic_format_sim_guid_addr(format_simple_guid_addr, addr);
		netdev_err(netdev, "Add mc guid err! invalid guid: %s\n",
@@ -270,11 +285,9 @@ static int hns3_unic_add_mc_guid(struct net_device *netdev,
	}

	hns3_unic_extern_mc_guid(mguid, addr);
	if (h->ae_algo->ops->add_addr)

	return h->ae_algo->ops->add_addr(h, (const u8 *)mguid,
					 HNAE3_UNIC_MCGUID_ADDR);

	return 0;
}

static int hns3_unic_del_mc_guid(struct net_device *netdev,
@@ -284,6 +297,9 @@ static int hns3_unic_del_mc_guid(struct net_device *netdev,
	struct hnae3_handle *h = hns3_get_handle(netdev);
	u8 mguid[UBL_ALEN] = {0};

	if (!h->ae_algo->ops->rm_addr)
		return -EOPNOTSUPP;

	if (!hns3_unic_mguid_valid_check(addr)) {
		hns3_unic_format_sim_guid_addr(format_simple_guid_addr, addr);
		netdev_err(netdev, "Del mc guid err! invalid guid: %s\n",
@@ -292,11 +308,9 @@ static int hns3_unic_del_mc_guid(struct net_device *netdev,
	}

	hns3_unic_extern_mc_guid(mguid, addr);
	if (h->ae_algo->ops->rm_addr)

	return h->ae_algo->ops->rm_addr(h, (const u8 *)mguid,
					HNAE3_UNIC_MCGUID_ADDR);

	return 0;
}

static u8 hns3_unic_get_netdev_flags(struct net_device *netdev)
@@ -325,23 +339,12 @@ void hns3_unic_set_rx_mode(struct net_device *netdev)
	hns3_request_update_promisc_mode(h);
}

int hns3_unic_init_guid(struct net_device *netdev)
static int hns3_unic_init_func_guid(struct net_device *netdev)
{
	const u8 mc_guid[][HNS3_SIMPLE_GUID_LEN] = {
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x00}, /* DHCPv4 */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x01}, /* DHCPv6 */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x02}, /* IP notify */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x03}, /* ULDP */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x04}, /* ULAP */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x05}, /* Time sync */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x06}, /* NPIC */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x07}, /* NNP */
		{0xff, 0xff, 0xff, 0xff, 0x01, 0x08}, /* PHCP */
	};
	struct hns3_nic_priv *priv = netdev_priv(netdev);
	struct hnae3_handle *h = priv->ae_handle;
	u8 temp_guid_addr[UBL_ALEN];
	int ret, i;
	int ret;

	if (!h->ae_algo->ops->get_func_guid ||
	    !h->ae_algo->ops->set_func_guid) {
@@ -355,6 +358,18 @@ int hns3_unic_init_guid(struct net_device *netdev)
		return ret;
	}

	memcpy(netdev->dev_addr, temp_guid_addr, netdev->addr_len);
	memcpy(netdev->perm_addr, temp_guid_addr, netdev->addr_len);

	h->ae_algo->ops->set_func_guid(h, netdev->dev_addr);

	return 0;
}

static int hns3_unic_init_mc_guid(struct net_device *netdev)
{
	int i, ret;

	for (i = 0; i < ARRAY_SIZE(mc_guid); i++) {
		ret = hns3_unic_add_mc_guid(netdev, mc_guid[i]);
		if (ret) {
@@ -363,11 +378,6 @@ 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);

	h->ae_algo->ops->set_func_guid(h, netdev->dev_addr);

	return 0;

err_add_mc_guid:
@@ -377,6 +387,35 @@ int hns3_unic_init_guid(struct net_device *netdev)
	return ret;
}

int hns3_unic_init_guid(struct net_device *netdev)
{
	int ret;

	ret = hns3_unic_init_func_guid(netdev);
	if (ret)
		return ret;

	return hns3_unic_init_mc_guid(netdev);
}

static void hns3_unic_uninit_mc_guid(struct net_device *netdev)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(mc_guid); i++)
		(void)hns3_unic_del_mc_guid(netdev, mc_guid[i]);
}

static void hns3_unic_uninit_guid(struct net_device *netdev)
{
	hns3_unic_uninit_mc_guid(netdev);
}

void hns3_unic_uninit(struct net_device *netdev)
{
	hns3_unic_uninit_guid(netdev);
}

int hns3_unic_fill_skb_desc(struct hns3_nic_priv *priv,
			    struct hns3_enet_ring *ring,
			    struct sk_buff *skb, struct hns3_desc *desc,
Loading