Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp818329imm; Fri, 1 Jun 2018 10:03:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIvDHNrOdIyJp4Kvmiiz3h3hjq/ybzUGY+rhdyphBUN8YyrDgR8YRhEbce804KAmgYapupI X-Received: by 2002:a62:aa18:: with SMTP id e24-v6mr11524553pff.107.1527872584696; Fri, 01 Jun 2018 10:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527872584; cv=none; d=google.com; s=arc-20160816; b=P1TTj9AHJRLo4YOvwc8CAItL+nhT4PG+aRySQ+BrnXESGiJ70y0Ay387uLybSB2w1k 8hmiqGXh0L7DVYPr/8VhcIvxT3XtikxEGlmeJMIiHfh/TbSzMtlEcBtiy++x8rjOhXw0 Fl9jsWvRLR8/Q6r8M6aFvOX0zqq5uRJH28EOFdCevS6tfvzfHFT2Va+3Gzuu7ZGyex1s +RM0CB+e221umTEmMEhEy22teDcdeKbhjbcHybYmJGlmu+MDcwbP/nK1BXThMK82lkrg zpyHZO7abPoN/pDlInrrps87cmaZgHKf6l73EYuc+dwBUjBBisbRfU2VxsfgXi5o1Dzf Vt+g== 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 y9-v6si40149263pfk.34.2018.06.01.10.02.49; Fri, 01 Jun 2018 10:03:04 -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 S1752982AbeFARBP (ORCPT + 99 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 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 --- 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..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); -- 2.7.4