Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3825854imm; Mon, 4 Jun 2018 09:52:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLOnCDfqyLpaG2kJ4wd1V6Fp7TDDqLbSq+qChttjcTp+zD/F93ogA8KwZSqSZT78QuSkUMY X-Received: by 2002:a62:5d48:: with SMTP id r69-v6mr18336851pfb.84.1528131126582; Mon, 04 Jun 2018 09:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528131126; cv=none; d=google.com; s=arc-20160816; b=Z7LSQzFsHIHUnad9anRpqK6xDei1eXbkl15o/QkdFcWqxWdF/B/deGOfMzumgY4wSh fCEBS8innyXwJZ+87Zbd/18MGq757LiS1zITngrKJHtvm9ybK9kFiQCJQNhkQwt+aJfL mGYyO4XiE+gyqls6jQFlWF7/Qjj1dVd7w9IOtdI7Fqx9EeQg4EJ/YAz13XNN7x4A16s2 NSnCM+ZT1wXpVLFwUS4TIiWN0Dc+VtUOT/nK9WpSfGkhGZmyCDqtTfzj6ikatSxW0kgV 8VOEHqK5sZqCCxtpkIdCI2KBqtbVSQDHguoaL2JADqHdr4629ak+k4A+b/cec2JKxKSJ TvDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=zoT1PLwWSgIcz9xsU9a3DHctmKPUEPu1NgV3EnJlcAA=; b=dU17S/EFy3kIXA36QKsJcgH2rNA/+nwFc9DnxzCOZUOKOAkNOisWNVAfgS7yOT1ul4 EA4ouwa6djjm86jpe+YpU8hcBHBNsWEpdDBPC+FLnEDBEfkvk0Ho4A9R+BNmY2ZA7EOM yeyLWRoqB+UOQxs93fg3+wu7EAWIGE73phvi4juPCVbpwoPe9c+ti22J3q2ME4bqj/ZL s3PjcmgAnIzbtZjkE0AHg8a3p3Uvk/P48JjizgFt9zXx4+9DCgKmf4X8SwEITWUUOhGM Miw4tify7pnw8Cvo1FFZrkSXtc3tGjy1tgUVnGOamYEfAGFfGXQE0KUwv+iGXSZotPsj Yuow== 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 bd1-v6si4369612plb.338.2018.06.04.09.51.52; Mon, 04 Jun 2018 09:52:06 -0700 (PDT) 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 S1751430AbeFDQuz (ORCPT + 99 others); Mon, 4 Jun 2018 12:50:55 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8689 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751203AbeFDQuy (ORCPT ); Mon, 4 Jun 2018 12:50:54 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 52D55D1CD8B74; Tue, 5 Jun 2018 00:50:38 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Tue, 5 Jun 2018 00:50:30 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH V2 net] net: hns: Fix the process of adding broadcast addresses to tcam Date: Mon, 4 Jun 2018 17:50:09 +0100 Message-ID: <20180604165009.24476-1-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xi Wang If the multicast mask value in device tree is configured not all 0xff, the broadcast mac will be lost from tcam table after the execution of command 'ifconfig up'. The address is appended by hns_ae_start, but will be clear later by hns_nic_set_rx_mode called in dev_open process. This patch fixed it by not use the multicast mask when add a broadcast address. Fixes: b5996f11ea54 ("net: add Hisilicon Network Subsystem basic ethernet support") Signed-off-by: Xi Wang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- Patch V2: Fixed comments by David Miller Link: https://lkml.org/lkml/2018/6/4/671 Patch V1: Initial Submit --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index e0bc79e..85e1d14 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c @@ -1648,6 +1648,15 @@ int hns_dsaf_rm_mac_addr( mac_entry->addr); } +static void hns_dsaf_setup_mc_mask(struct dsaf_device *dsaf_dev, + u8 port_num, u8 *mask, u8 *addr) +{ + if (MAC_IS_BROADCAST(addr)) + memset(mask, 0xff, ETH_ALEN); + else + memcpy(mask, dsaf_dev->mac_cb[port_num]->mc_mask, ETH_ALEN); +} + static void hns_dsaf_mc_mask_bit_clear(char *dst, const char *src) { u16 *a = (u16 *)dst; @@ -1676,7 +1685,6 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, struct dsaf_drv_tbl_tcam_key tmp_mac_key; struct dsaf_tbl_tcam_data tcam_data; u8 mc_addr[ETH_ALEN]; - u8 *mc_mask; int mskid; /*chechk mac addr */ @@ -1687,9 +1695,12 @@ int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, } ether_addr_copy(mc_addr, mac_entry->addr); - mc_mask = dsaf_dev->mac_cb[mac_entry->in_port_num]->mc_mask; if (!AE_IS_VER1(dsaf_dev->dsaf_ver)) { + u8 mc_mask[ETH_ALEN]; + /* prepare for key data setting */ + hns_dsaf_setup_mc_mask(dsaf_dev, mac_entry->in_port_num, + mc_mask, mac_entry->addr); hns_dsaf_mc_mask_bit_clear(mc_addr, mc_mask); /* config key mask */ @@ -1844,7 +1855,6 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, struct dsaf_drv_tbl_tcam_key mask_key, tmp_mac_key; struct dsaf_tbl_tcam_data *pmask_key = NULL; u8 mc_addr[ETH_ALEN]; - u8 *mc_mask; if (!(void *)mac_entry) { dev_err(dsaf_dev->dev, @@ -1861,14 +1871,17 @@ int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, /* always mask vlan_id field */ ether_addr_copy(mc_addr, mac_entry->addr); - mc_mask = dsaf_dev->mac_cb[mac_entry->in_port_num]->mc_mask; if (!AE_IS_VER1(dsaf_dev->dsaf_ver)) { + u8 mc_mask[ETH_ALEN]; + /* prepare for key data setting */ + hns_dsaf_setup_mc_mask(dsaf_dev, mac_entry->in_port_num, + mc_mask, mac_entry->addr); hns_dsaf_mc_mask_bit_clear(mc_addr, mc_mask); /* config key mask */ - hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_addr); + hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_mask); mask_key.high.val = le32_to_cpu(mask_key.high.val); mask_key.low.val = le32_to_cpu(mask_key.low.val); -- 2.7.4