Commit 417e0f6b authored by Jie Wang's avatar Jie Wang Committed by Jiantao Xiao
Browse files

net: hns3: refactor hclge_update_desc_vfid for extension

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


CVE: NA

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

Now, hclge_update_desc_vfid is used to set vf bitmap for batch operations.
But it used fixed description index, so it is hard to extend for more
scenario.

So this patch refactor description index in the function for reuse.

Fixes: a90bb9a5 ("net: hns3: Cleanup for endian issue in hns3 driver")
Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
parent b62afba4
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -8626,16 +8626,16 @@ static int hclge_update_desc_vfid(struct hclge_desc *desc, int vfid, bool clr)
		word_num = vfid / 32;
		bit_num  = vfid % 32;
		if (clr)
			desc[1].data[word_num] &= cpu_to_le32(~(1 << bit_num));
			desc[0].data[word_num] &= cpu_to_le32(~(1 << bit_num));
		else
			desc[1].data[word_num] |= cpu_to_le32(1 << bit_num);
			desc[0].data[word_num] |= cpu_to_le32(1 << bit_num);
	} else {
		word_num = (vfid - HCLGE_VF_NUM_IN_FIRST_DESC) / 32;
		bit_num  = vfid % 32;
		if (clr)
			desc[2].data[word_num] &= cpu_to_le32(~(1 << bit_num));
			desc[1].data[word_num] &= cpu_to_le32(~(1 << bit_num));
		else
			desc[2].data[word_num] |= cpu_to_le32(1 << bit_num);
			desc[1].data[word_num] |= cpu_to_le32(1 << bit_num);
	}

	return 0;
@@ -9148,7 +9148,7 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport,
		memset(desc[1].data, 0, sizeof(desc[0].data));
		memset(desc[2].data, 0, sizeof(desc[0].data));
	}
	status = hclge_update_desc_vfid(desc, vport->vport_id, false);
	status = hclge_update_desc_vfid(&desc[1], vport->vport_id, false);
	if (status)
		return status;
	status = hclge_add_mac_vlan_tbl(vport, &req, desc);
@@ -9201,7 +9201,8 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport,
	status = hclge_lookup_mac_vlan_tbl(vport, &req, desc, true);
	if (!status) {
		/* This mac addr exist, remove this handle's VFID for it */
		status = hclge_update_desc_vfid(desc, vport->vport_id, true);
		status = hclge_update_desc_vfid(&desc[1], vport->vport_id,
						true);
		if (status)
			return status;