summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/hisilicon
diff options
context:
space:
mode:
authorJian Shen2018-03-10 04:29:32 +0100
committerDavid S. Miller2018-03-12 03:53:32 +0100
commitd07b6bb4350040e10be8483640ae1b2bf37a3e5e (patch)
tree3e76c94e0ea9a5b0bcf9eb2ccb9a471adad09a33 /drivers/net/ethernet/hisilicon
parentnet: hns3: fix return value error of hclge_get_mac_vlan_cmd_status() (diff)
downloadkernel-qcow2-linux-d07b6bb4350040e10be8483640ae1b2bf37a3e5e.tar.gz
kernel-qcow2-linux-d07b6bb4350040e10be8483640ae1b2bf37a3e5e.tar.xz
kernel-qcow2-linux-d07b6bb4350040e10be8483640ae1b2bf37a3e5e.zip
net: hns3: add existence checking before adding unicast mac address
It's not allowed to add two same unicast mac address entries to the mac_vlan table. When modify the uc mac address of a VF device to the same value with the PF device's, the PF device will lose its entry of the mac_vlan table. Lookup the mac address in the mac_vlan table, and add it if the entry is inexistent. Fixes: 46a3df9f9718 ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support") Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Peng Li <lipeng321@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/hisilicon')
-rw-r--r--drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
index 47dcc9856d4c..d70619b5ff15 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
@@ -4107,6 +4107,7 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport,
{
struct hclge_dev *hdev = vport->back;
struct hclge_mac_vlan_tbl_entry_cmd req;
+ struct hclge_desc desc;
u16 egress_port = 0;
int ret;
@@ -4140,7 +4141,21 @@ int hclge_add_uc_addr_common(struct hclge_vport *vport,
hclge_prepare_mac_addr(&req, addr);
- ret = hclge_add_mac_vlan_tbl(vport, &req, NULL);
+ /* Lookup the mac address in the mac_vlan table, and add
+ * it if the entry is inexistent. Repeated unicast entry
+ * is not allowed in the mac vlan table.
+ */
+ ret = hclge_lookup_mac_vlan_tbl(vport, &req, &desc, false);
+ if (ret == -ENOENT)
+ return hclge_add_mac_vlan_tbl(vport, &req, NULL);
+
+ /* check if we just hit the duplicate */
+ if (!ret)
+ ret = -EINVAL;
+
+ dev_err(&hdev->pdev->dev,
+ "PF failed to add unicast entry(%pM) in the MAC table\n",
+ addr);
return ret;
}