Received: by 10.223.185.111 with SMTP id b44csp1004704wrg; Fri, 9 Mar 2018 18:59:26 -0800 (PST) X-Google-Smtp-Source: AG47ELs6Jv9ETL2Z7jeJhvbVpCQXgQ6dYFmm4blL9phiZSaUdERYzwiRkf5QamQ0ra+aAyAaQM9m X-Received: by 2002:a17:902:7c84:: with SMTP id y4-v6mr671467pll.305.1520650766532; Fri, 09 Mar 2018 18:59:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520650766; cv=none; d=google.com; s=arc-20160816; b=ZZ9zMXg62q2zi2sdbaEoQDWbKTEoFNzx7TSRA375La/SEbXhEtdMCa3CYEjQAqxjiW TW/i3Q8OuaDVQ3myQ+HUwWorlmCewZiEN3Z9bHJ03GV7ZlVMGFmgr6NwR8OieOUKDuaK 2AdrcDzJYgVdDB8nVpLC/tsLU6l2hOMOeonbtsxwPiGID76n3CDnYdU0R+yGRRuDhGyx RepsaKfQPkHClFEtXMA3J/rcqkR32x4X2d2yWDNC1c3vItuJPHC4DSQQVAWgN9LE5h/v CAx1K367Kf2AIKQl8cwQ7XZwOLJmnbZ8HgVJsEi+rkoOjxXHz4IQF3qlsJKEOcc6G86V 73Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=hxP4ss12P1QmHr48DaghHmtBpS90DDx2mJqM4YaytN0=; b=J/eE4KzM7iX/tKtKLJ4cgsMnTikQDi74gkTEeA35/fbRRRXBCpQ5qPh1tleD2JC71N 9Al6QWTYwSXcdCWxe9SohbsGZjYeBNppCsZQM0pIFHo4c3dk2MhikjQfWyZm2ouUqiD6 s4i0g24mN2RihnUIv0f+au+uGHdqQawHsRwrNWJLmBB99rpLGlBPHZD1vpysG2l/FP6N gv26sFni8V+M4/Pet100rwx/oi5H/UltyfQQqlheix9Jx7xunJn7Dbe65y/wzZVoL+4z 0Jjzq+nzFvsQitY6DcFxTXl1ZN4C7Kg3VxZZ8P+t3PckfL2MHKMzA01rxEEGdZA2NzwC ISkg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i4si2014198pfa.152.2018.03.09.18.59.11; Fri, 09 Mar 2018 18:59:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932891AbeCJC5m (ORCPT + 99 others); Fri, 9 Mar 2018 21:57:42 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:6229 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932716AbeCJC5j (ORCPT ); Fri, 9 Mar 2018 21:57:39 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 958876E11A450; Sat, 10 Mar 2018 10:57:26 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Sat, 10 Mar 2018 10:57:18 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 11/12] net: hns3: add existence checking before adding unicast mac address Date: Sat, 10 Mar 2018 11:29:32 +0800 Message-ID: <1520652573-75644-12-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1520652573-75644-1-git-send-email-lipeng321@huawei.com> References: <1520652573-75644-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jian Shen 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 Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 47dcc98..d70619b 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; } -- 2.9.3