From patchwork Mon Jun 4 16:50:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 137659 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp1750632lji; Mon, 4 Jun 2018 09:50:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL1s2F8PCvbSrgKvjsLgUjo4OL4o6T6tTOyKAlVRKz5qD3XzSoBk9DhLQACnxzjG1yMXZU5 X-Received: by 2002:a62:aa18:: with SMTP id e24-v6mr8222379pff.72.1528131059487; Mon, 04 Jun 2018 09:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528131059; cv=none; d=google.com; s=arc-20160816; b=GdnSdySEMyVDN/nz959nljNQ/V5qlWp8kIEv0RBzpncD/nCxFguWaBAEh8rwAdNye9 7IKINkhjXT4GneGt2ub5czW1WUJW7r9qfYueXoaWlcCjIabzQ+GEa+1oSqGIEf3W1m1r XBMxr+2XvLnjg7p/WhOWXuu+XKDekBDPui3rJVb/jFdxWW2ucx1XQ4B9QV5LOFjvCaMo AJl1N2wzO7lXYx0FwRI2gc23wwCY/xDLJfPz1Y/N4TH6gfSX4TcOmVsK8iO2r0zOtifs x3prFPzcO9tUz/J9Ay1bZSRk1obolJAyaKqBkrqZyBE0h4+hPd2nwMOzc1ZDbuFy3Xzw N2yA== 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 m8-v6si3524018pgq.637.2018.06.04.09.50.59; Mon, 04 Jun 2018 09:50:59 -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 S1751444AbeFDQu4 (ORCPT + 30 others); Mon, 4 Jun 2018 12:50:56 -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 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(-) -- 2.7.4 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);