From patchwork Fri Jun 1 17:00:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 137569 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1185511lji; Fri, 1 Jun 2018 10:01:17 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL1QmyjQa4sAR1EyLpKFf/z4Z1bqs+babXiII7QBTguR61wVH6M7jmnHwVQOXfxR1qa0oZo X-Received: by 2002:a65:4146:: with SMTP id x6-v6mr9397363pgp.221.1527872477448; Fri, 01 Jun 2018 10:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527872477; cv=none; d=google.com; s=arc-20160816; b=wajSC23mEr7h8sLZ/AxouD+NAafIZ03txuF2B6ZFJ+/Eg6dVFnePWPhmcV+6IIF9Kh qd26y8JUYuMM6ZU4/Qpt/+5a8pNPvXpnOpGMrXAqSnaBSy5KSctDXM2s17Xb4S8KhyNB yuF5R4uZIAlkTA+ptsK8VJNP/vd0bCan9KsVjHr9xN6HGjXuf6SLpFJcDSBM8xt6Qqok dpEXknhQH9B8zbFj4/BYbr6dCyKgTJjKKqK6gzHfaZ1q5xOwlUq4QywVYA9818aAXfet WAS6bcCoIawF8+VRpUEO7xWxUnuoxe0rm04IGJ1et9YWAHAj4HRya8gGqdQLQL4ZHSqY I75Q== 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=UUztaoGrUfUZD6wHlRbAIRja40j7IamVcJ/uNd2O6q4=; b=Asj7zW1Q4jo/6G6qTW3Fgl3gThoU4b6ESFaWA5eGm+Evibk14j3wuFLJQTkCaOCeVw f1xKETxBs20+PnVqLIG0o76h+IQwx2rvq8rL3jf5ggpzvrM+XvdwzmESqpxQ5vaS7tkE QuPOCuoFHoROnvrcM1hGReQHmYrpMw5OVQpMeuMtdX8UvcF2BHnm4jxvwC6T+5bfwQjq fDeG/YowUPu3wQlEZC5RBqkoAMbNmBZS3vQN261KbsDRUrre3GG9W5ytiVJo530IH6wA vtKnIz3+DtPjIpabE8i/4FUHMJ6s7QQThb3dgtcJ4CwYgpJMylvFE6jWswN4EYkqf4TW w7RQ== 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 t9-v6si5047730pgc.511.2018.06.01.10.01.17; Fri, 01 Jun 2018 10:01:17 -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 S1753066AbeFARBP (ORCPT + 30 others); Fri, 1 Jun 2018 13:01:15 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:46582 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752107AbeFARBO (ORCPT ); Fri, 1 Jun 2018 13:01:14 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 26EA72DA96E3B; Sat, 2 Jun 2018 01:01:10 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.382.0; Sat, 2 Jun 2018 01:01:01 +0800 From: Salil Mehta To: CC: , , , , , , , Xi Wang Subject: [PATCH net] net: hns: Fix the process of adding broadcast addresses to tcam Date: Fri, 1 Jun 2018 18:00:11 +0100 Message-ID: <20180601170011.22700-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 --- 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..a09a071c 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);