提交 3a586422 编写于 作者: W Weihang Li 提交者: David S. Miller

net: hns3: move some set_bit statement into hclge_prepare_mac_addr

This patch does not change the code logic. There are some same
set_bit statements called by add/rm_uc/mc_addr_common, and move
this statements into hclge_prepare_mac_addr to reduce duplicate
code.
Signed-off-by: NWeihang Li <liweihang@hisilicon.com>
Signed-off-by: NPeng Li <lipeng321@huawei.com>
Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b671b723
...@@ -5586,13 +5586,19 @@ static bool hclge_is_all_function_id_zero(struct hclge_desc *desc) ...@@ -5586,13 +5586,19 @@ static bool hclge_is_all_function_id_zero(struct hclge_desc *desc)
} }
static void hclge_prepare_mac_addr(struct hclge_mac_vlan_tbl_entry_cmd *new_req, static void hclge_prepare_mac_addr(struct hclge_mac_vlan_tbl_entry_cmd *new_req,
const u8 *addr) const u8 *addr, bool is_mc)
{ {
const unsigned char *mac_addr = addr; const unsigned char *mac_addr = addr;
u32 high_val = mac_addr[2] << 16 | (mac_addr[3] << 24) | u32 high_val = mac_addr[2] << 16 | (mac_addr[3] << 24) |
(mac_addr[0]) | (mac_addr[1] << 8); (mac_addr[0]) | (mac_addr[1] << 8);
u32 low_val = mac_addr[4] | (mac_addr[5] << 8); u32 low_val = mac_addr[4] | (mac_addr[5] << 8);
hnae3_set_bit(new_req->flags, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
if (is_mc) {
hnae3_set_bit(new_req->entry_type, HCLGE_MAC_VLAN_BIT1_EN_B, 1);
hnae3_set_bit(new_req->mc_mac_en, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
}
new_req->mac_addr_hi32 = cpu_to_le32(high_val); new_req->mac_addr_hi32 = cpu_to_le32(high_val);
new_req->mac_addr_lo16 = cpu_to_le16(low_val & 0xffff); new_req->mac_addr_lo16 = cpu_to_le16(low_val & 0xffff);
} }
...@@ -5863,14 +5869,13 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport, ...@@ -5863,14 +5869,13 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport,
} }
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
hnae3_set_bit(req.flags, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
hnae3_set_field(egress_port, HCLGE_MAC_EPORT_VFID_M, hnae3_set_field(egress_port, HCLGE_MAC_EPORT_VFID_M,
HCLGE_MAC_EPORT_VFID_S, vport->vport_id); HCLGE_MAC_EPORT_VFID_S, vport->vport_id);
req.egress_port = cpu_to_le16(egress_port); req.egress_port = cpu_to_le16(egress_port);
hclge_prepare_mac_addr(&req, addr); hclge_prepare_mac_addr(&req, addr, false);
/* Lookup the mac address in the mac_vlan table, and add /* Lookup the mac address in the mac_vlan table, and add
* it if the entry is inexistent. Repeated unicast entry * it if the entry is inexistent. Repeated unicast entry
...@@ -5928,9 +5933,8 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport, ...@@ -5928,9 +5933,8 @@ int hclge_rm_uc_addr_common(struct hclge_vport *vport,
} }
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
hnae3_set_bit(req.flags, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0); hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0);
hclge_prepare_mac_addr(&req, addr); hclge_prepare_mac_addr(&req, addr, false);
ret = hclge_remove_mac_vlan_tbl(vport, &req); ret = hclge_remove_mac_vlan_tbl(vport, &req);
if (!ret) if (!ret)
hclge_update_umv_space(vport, true); hclge_update_umv_space(vport, true);
...@@ -5962,11 +5966,8 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport, ...@@ -5962,11 +5966,8 @@ int hclge_add_mc_addr_common(struct hclge_vport *vport,
return -EINVAL; return -EINVAL;
} }
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
hnae3_set_bit(req.flags, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0); hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0);
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT1_EN_B, 1); hclge_prepare_mac_addr(&req, addr, true);
hnae3_set_bit(req.mc_mac_en, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
hclge_prepare_mac_addr(&req, addr);
status = hclge_lookup_mac_vlan_tbl(vport, &req, desc, true); status = hclge_lookup_mac_vlan_tbl(vport, &req, desc, true);
if (!status) { if (!status) {
/* This mac addr exist, update VFID for it */ /* This mac addr exist, update VFID for it */
...@@ -6012,11 +6013,8 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport, ...@@ -6012,11 +6013,8 @@ int hclge_rm_mc_addr_common(struct hclge_vport *vport,
} }
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
hnae3_set_bit(req.flags, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0); hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT0_EN_B, 0);
hnae3_set_bit(req.entry_type, HCLGE_MAC_VLAN_BIT1_EN_B, 1); hclge_prepare_mac_addr(&req, addr, true);
hnae3_set_bit(req.mc_mac_en, HCLGE_MAC_VLAN_BIT0_EN_B, 1);
hclge_prepare_mac_addr(&req, addr);
status = hclge_lookup_mac_vlan_tbl(vport, &req, desc, true); status = hclge_lookup_mac_vlan_tbl(vport, &req, desc, true);
if (!status) { if (!status) {
/* This mac addr exist, remove this handle's VFID for it */ /* This mac addr exist, remove this handle's VFID for it */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册