From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0051.outbound.protection.outlook.com [104.47.40.51]) by dpdk.org (Postfix) with ESMTP id 923B62C6D; Sun, 20 May 2018 02:16:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=96n4JurW+6NqxY1ICUuvM8O+t+p0mep1NvC7Vq/gQiE=; b=EKhkRjcMVPwjXrsvQi+qgpxj2bLEXi+Ck3Cmpn/pkGA7kR9LDqkQpWqUaorD5ecwrzhJfix0d+TgpUOVbWmDjnuTNedh4zV5TjhXuw6aAIv7xNGuDL5bModxQXh6GO45jkPjQJDM1kqtGOiLWHExeNFB7UqlfrH3bkFkixtbQiM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Rasesh.Mody@cavium.com; Received: from cavium.com (198.186.0.2) by CY4PR0701MB3668.namprd07.prod.outlook.com (2603:10b6:910:93::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.776.16; Sun, 20 May 2018 00:16:17 +0000 From: Rasesh Mody To: dev@dpdk.org Cc: Harish Patil , ferruh.yigit@intel.com, Dept-EngDPDKDev@cavium.com, stable@dpdk.org, Shahed Shaikh , Rasesh Mody Date: Sat, 19 May 2018 17:15:43 -0700 Message-Id: <1526775346-10643-1-git-send-email-rasesh.mody@cavium.com> X-Mailer: git-send-email 1.7.10.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [198.186.0.2] X-ClientProxiedBy: CO2PR04CA0149.namprd04.prod.outlook.com (2603:10b6:104::27) To CY4PR0701MB3668.namprd07.prod.outlook.com (2603:10b6:910:93::19) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:CY4PR0701MB3668; X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3668; 3:Y+or7s6FsppCVwLPbNgbhjuUf+Q+tiMzxikK+R57l+5gASV2elGqMiEKmk+6wNPVB2liAbnj1HEDGoIT3SY99OoyUrZKU+RW5Sl7OBp4ZhLTY9B45MULxumoI8v0M7thO1WO2bEUbzm2ors/R7RgzGW1k0J/JxGZOpJzaajcOSHREflJDf3GPs38+NA0SE7/BWeoXb2OFC63Y3CxNqKd4PZqHOqzizmn0f+fawvBD3PDcTkNn4I7AU3dAuPbx805; 25:qYA3inyq+6saOkFgmdXCKE6VapKsaO3PtPR57FFq9M9eHZgIEh8fi2mxX/FeN9j18A7UCbRxBG47BbKbaS+tmnaAZQBIM9XvVjpPo26ue3PFum30xsn6FK7TO6DcvYQ9Sq5KdZPEnXXIOXWQ6D3txUzWzAsidMIl5J4Khjs7qAZ8pbrNYn1UrAlyMT0B0I2oTVOLtKdL2xyi0CoGBobdtESF7j6liesCCfs/FFKaIUQoR74X2OKnRzErg/zoTX5U7+EMRPWjwKvzhkUjKqZ/PVmhHiNffFdZcxKpy98QLVrSgcD9BJ9ClggvTYdplfRGuqv8wSWkl9uFyOhRmHUyew==; 31:0cDfuxFhJaFK9nFr8vRwk0vi29dEc1TTbTNTr+qfa/7T6lPxx6CRiIEV3BjgOnLiwuclCIDlFEELS+KF6AtbjAPgjeuKR5/px84p/8uD7Qj5gF4lOCMwvBy3hcNSTkV2t3ZGU6kc8sZv4KtP+GqAepmKu1C5mETcVt3PKTU+I2ftsB6B+vMqUyom7bfuCaYYmWCbvSRBcEV2SVdDNGu+uCTATJcqMwUd+xX0T7Cyou4= X-MS-TrafficTypeDiagnostic: CY4PR0701MB3668: X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3668; 20:oZ3dYDNNlx9gRYEm/ALSlMYjYzB8CA0terUlcF2QXNZnpB+XTd35Yw4pum/0aPxhjdilSCSvvmq+Khz/Wyr5Q02gzLW6YCLOD4DqL7xtc3aEF7DX/cLXq7kNrlwKtR+g5+iiZV8Z3DAuy4FhBMPzU0ugAHO6NHOYe7EwO1C9QnoJXKwdTsffZdxdHnPoR+xz4Nc6ZrODrOnbtxRsMVt1UCJJeLobSb+RKig5cHcrrzfRURMVPyW3zQjQ/wpMb1SAQJIjCgzT3ujOTdc7yPlYr9IDWZM3GEF1Rrs/y/v6GlgQwzcknhKwy8E/ItJ501QCoVI+HYfcbpLHXrDV/4qguRkvg0O8ekJdRUcWPx6lXLZbFCJzTUlS/r6RWRrRHSSNB29GaT1us6SCPRixvgfsx84MAmq612YmDPPJM5mg04gc/lqIs7mIlw3T4Un78lGtdE/BF6sV+FYTR/hPSWusfhpBzg/c3OjGkprSSOpKWX5sMkLLQ7Vvh9R+ULqX4K77; 4:vX4wVfJ93BMoorzgpEUxJtFNpm814svnodrjfnGqMXOxQw7KEvdJaoTQTnk4LeSeJpj5agYfTvZ4sOzbL6fPnTJ7b7ysgXSmbAZoy5IK33VF1Uxxn6FkZGi1oDJgjAUl891VKYEQ1N5rzQOE3HrOVk5jKKovE2m7egIo2+jq1rXz0tXneay5mLeYnTy1EUDjHRHgdsmBpYLdQi+R1L3TY1/ZvOGzwuduhcLiRJ/0S7v09lv63XF9E+ssPSpsFCF68qzw/QndecMUtltfvp39pA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:CY4PR0701MB3668; BCL:0; PCL:0; RULEID:; SRVR:CY4PR0701MB3668; X-Forefront-PRVS: 06780E24F8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(396003)(39850400004)(39380400002)(199004)(189003)(4326008)(16526019)(186003)(575784001)(54906003)(6666003)(386003)(51416003)(7696005)(8936002)(26005)(6116002)(53936002)(316002)(7736002)(69596002)(5660300001)(25786009)(44832011)(16586007)(36756003)(59450400001)(107886003)(81166006)(81156014)(52116002)(68736007)(8676002)(6916009)(4720700003)(2906002)(50226002)(86362001)(2351001)(47776003)(2361001)(105586002)(478600001)(48376002)(66066001)(97736004)(3846002)(486006)(50466002)(476003)(2616005)(305945005)(956004)(21086003)(106356001)(55016002)(72206003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR0701MB3668; H:cavium.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR0701MB3668; 23:i6N9OSzRI8d3CATjUXQ3DqHzPUzBU7tlI4S+4Ws?= =?us-ascii?Q?hBL6ldmMbxEEMknvzjVmz/WTGNwdWq24rNPTisa5HhgPwsFi5CgyLI4fm9F6?= =?us-ascii?Q?x3mAtoB3LOT59rRf58hjT1xW/bX1AMmHJFrzhrbV9vd4guYDFGs+e2Ug43F/?= =?us-ascii?Q?qwC4YEXr8lW6nWZvFGoUAqAYIhXjC2zFowhgBzb+N+TNcJOAhTDBp/fqqN3m?= =?us-ascii?Q?yZ7um3tM5VCzo5oyaVwZWbQM5iCuk/U9LBAtQ8n5RBhrmFJUW8mykWbfS5XJ?= =?us-ascii?Q?LrgH89L5a5i5ylQiMrpHuUgTbNk+T2R2nBt8UFcoRZeFXLK5MqxM3CaBDojD?= =?us-ascii?Q?WqSmPa3FSRHvPMYfL4+FY4O2F40wi7pyWNPjyHdVD9KmDXtgcblbD4F9pytK?= =?us-ascii?Q?JfYH7cQglm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Et9gGYAln1D3iUT/xofSojBQ8xsESUjSLXkRMyIHWk/JyRKM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR0701MB3668; 7:eC1kruNfAxKOaJDTP0WQNSfKTZhIbBJZp+wqlBM4fTq8im9H8Nj42c23og+5IRuRIV4Z1lna4NZLv00FIw8RQekmHam3GPUXdrW1QcZ8FzGQZZ4tV4O5ta16joW8XFhjQfaU9qaoESLMZlX0AoXVRWXZjD2kGvL7mqJUX1MkhUuhOCnXzZNNKG/X4xMVjJF9aLjBTF2yW1AHJDxypNR4uVjsPkj5oWB8rvS6URKmFA+5KP5sfhYTz75TnJrLL+tI X-MS-Office365-Filtering-Correlation-Id: 66c55d66-fc71-4ade-c254-08d5bde6e828 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2018 00:16:17.2593 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66c55d66-fc71-4ade-c254-08d5bde6e828 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR0701MB3668 Subject: [dpdk-dev] [PATCH 1/4] net/qede: fix multicast filtering X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2018 00:16:20 -0000 From: Harish Patil This patch is to fix multicast filtering using set_mc_addr_list(). Fixes: 77fac1b54fc9 ("net/qede: fix filtering code") Cc: stable@dpdk.org Signed-off-by: Harish Patil Signed-off-by: Shahed Shaikh Signed-off-by: Rasesh Mody --- drivers/net/qede/base/ecore_l2.c | 12 +-- drivers/net/qede/base/ecore_l2_api.h | 2 +- drivers/net/qede/base/ecore_sriov.c | 3 +- drivers/net/qede/base/ecore_vf.c | 5 +- drivers/net/qede/base/ecore_vfpf_if.h | 8 +- drivers/net/qede/qede_ethdev.c | 179 ++++++++++++++++++--------------- 6 files changed, 114 insertions(+), 95 deletions(-) diff --git a/drivers/net/qede/base/ecore_l2.c b/drivers/net/qede/base/ecore_l2.c index c897fa5..fdb928a 100644 --- a/drivers/net/qede/base/ecore_l2.c +++ b/drivers/net/qede/base/ecore_l2.c @@ -690,7 +690,7 @@ enum _ecore_status_t p_ramrod->common.update_approx_mcast_flg = 1; for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) { - u32 *p_bins = (u32 *)p_params->bins; + u32 *p_bins = p_params->bins; p_ramrod->approx_mcast.bins[i] = OSAL_CPU_TO_LE32(p_bins[i]); } @@ -1568,8 +1568,8 @@ u8 ecore_mcast_bin_from_mac(u8 *mac) enum spq_mode comp_mode, struct ecore_spq_comp_cb *p_comp_data) { - unsigned long bins[ETH_MULTICAST_MAC_BINS_IN_REGS]; struct vport_update_ramrod_data *p_ramrod = OSAL_NULL; + u32 bins[ETH_MULTICAST_MAC_BINS_IN_REGS]; struct ecore_spq_entry *p_ent = OSAL_NULL; struct ecore_sp_init_data init_data; u8 abs_vport_id = 0; @@ -1608,8 +1608,7 @@ u8 ecore_mcast_bin_from_mac(u8 *mac) /* explicitly clear out the entire vector */ OSAL_MEMSET(&p_ramrod->approx_mcast.bins, 0, sizeof(p_ramrod->approx_mcast.bins)); - OSAL_MEMSET(bins, 0, sizeof(unsigned long) * - ETH_MULTICAST_MAC_BINS_IN_REGS); + OSAL_MEMSET(bins, 0, sizeof(u32) * ETH_MULTICAST_MAC_BINS_IN_REGS); /* filter ADD op is explicit set op and it removes * any existing filters for the vport. */ @@ -1618,16 +1617,15 @@ u8 ecore_mcast_bin_from_mac(u8 *mac) u32 bit; bit = ecore_mcast_bin_from_mac(p_filter_cmd->mac[i]); - OSAL_SET_BIT(bit, bins); + bins[bit / 32] |= 1 << (bit % 32); } /* Convert to correct endianity */ for (i = 0; i < ETH_MULTICAST_MAC_BINS_IN_REGS; i++) { struct vport_update_ramrod_mcast *p_ramrod_bins; - u32 *p_bins = (u32 *)bins; p_ramrod_bins = &p_ramrod->approx_mcast; - p_ramrod_bins->bins[i] = OSAL_CPU_TO_LE32(p_bins[i]); + p_ramrod_bins->bins[i] = OSAL_CPU_TO_LE32(bins[i]); } } diff --git a/drivers/net/qede/base/ecore_l2_api.h b/drivers/net/qede/base/ecore_l2_api.h index ed9837b..8cbe8dd 100644 --- a/drivers/net/qede/base/ecore_l2_api.h +++ b/drivers/net/qede/base/ecore_l2_api.h @@ -332,7 +332,7 @@ struct ecore_sp_vport_update_params { u8 anti_spoofing_en; u8 update_accept_any_vlan_flg; u8 accept_any_vlan; - unsigned long bins[8]; + u32 bins[8]; struct ecore_rss_params *rss_params; struct ecore_filter_accept_flags accept_flags; struct ecore_sge_tpa_params *sge_tpa_params; diff --git a/drivers/net/qede/base/ecore_sriov.c b/drivers/net/qede/base/ecore_sriov.c index 0279709..93674a2 100644 --- a/drivers/net/qede/base/ecore_sriov.c +++ b/drivers/net/qede/base/ecore_sriov.c @@ -2979,8 +2979,7 @@ void *ecore_iov_search_list_tlvs(struct ecore_hwfn *p_hwfn, p_data->update_approx_mcast_flg = 1; OSAL_MEMCPY(p_data->bins, p_mcast_tlv->bins, - sizeof(unsigned long) * - ETH_MULTICAST_MAC_BINS_IN_REGS); + sizeof(u32) * ETH_MULTICAST_MAC_BINS_IN_REGS); *tlvs_mask |= 1 << ECORE_IOV_VP_UPDATE_MCAST; } diff --git a/drivers/net/qede/base/ecore_vf.c b/drivers/net/qede/base/ecore_vf.c index e0f2dd5..8a08911 100644 --- a/drivers/net/qede/base/ecore_vf.c +++ b/drivers/net/qede/base/ecore_vf.c @@ -1275,8 +1275,7 @@ enum _ecore_status_t resp_size += sizeof(struct pfvf_def_resp_tlv); OSAL_MEMCPY(p_mcast_tlv->bins, p_params->bins, - sizeof(unsigned long) * - ETH_MULTICAST_MAC_BINS_IN_REGS); + sizeof(u32) * ETH_MULTICAST_MAC_BINS_IN_REGS); } update_rx = p_params->accept_flags.update_rx_mode_config; @@ -1473,7 +1472,7 @@ void ecore_vf_pf_filter_mcast(struct ecore_hwfn *p_hwfn, u32 bit; bit = ecore_mcast_bin_from_mac(p_filter_cmd->mac[i]); - OSAL_SET_BIT(bit, sp_params.bins); + sp_params.bins[bit / 32] |= 1 << (bit % 32); } } diff --git a/drivers/net/qede/base/ecore_vfpf_if.h b/drivers/net/qede/base/ecore_vfpf_if.h index ecb0064..c6af9ca 100644 --- a/drivers/net/qede/base/ecore_vfpf_if.h +++ b/drivers/net/qede/base/ecore_vfpf_if.h @@ -396,7 +396,13 @@ struct vfpf_vport_update_mcast_bin_tlv { struct channel_tlv tl; u8 padding[4]; - u64 bins[8]; + /* This was a mistake; There are only 256 approx bins, + * and in HSI they're divided into 32-bit values. + * As old VFs used to set-bit to the values on its side, + * the upper half of the array is never expected to contain any data. + */ + u64 bins[4]; + u64 obsolete_bins[4]; }; struct vfpf_vport_update_accept_param_tlv { diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index 50a63be..3e1a62c 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -894,47 +894,69 @@ static void qede_set_ucast_cmn_params(struct ecore_filter_ucast *ucast) } static int -qede_mcast_filter(struct rte_eth_dev *eth_dev, struct ecore_filter_ucast *mcast, - bool add) +qede_add_mcast_filters(struct rte_eth_dev *eth_dev, struct ether_addr *mc_addrs, + uint32_t mc_addrs_num) { struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - struct ether_addr *mac_addr; - struct qede_mcast_entry *tmp = NULL; - struct qede_mcast_entry *m; + struct ecore_filter_mcast mcast; + struct qede_mcast_entry *m = NULL; + uint8_t i; + int rc; - mac_addr = (struct ether_addr *)mcast->mac; - if (add) { - SLIST_FOREACH(tmp, &qdev->mc_list_head, list) { - if (memcmp(mac_addr, &tmp->mac, ETHER_ADDR_LEN) == 0) { - DP_ERR(edev, - "Multicast MAC is already added\n"); - return -EEXIST; - } - } + for (i = 0; i < mc_addrs_num; i++) { m = rte_malloc(NULL, sizeof(struct qede_mcast_entry), - RTE_CACHE_LINE_SIZE); + RTE_CACHE_LINE_SIZE); if (!m) { - DP_ERR(edev, - "Did not allocate memory for mcast\n"); + DP_ERR(edev, "Did not allocate memory for mcast\n"); return -ENOMEM; } - ether_addr_copy(mac_addr, &m->mac); + ether_addr_copy(&mc_addrs[i], &m->mac); SLIST_INSERT_HEAD(&qdev->mc_list_head, m, list); - qdev->num_mc_addr++; - } else { - SLIST_FOREACH(tmp, &qdev->mc_list_head, list) { - if (memcmp(mac_addr, &tmp->mac, ETHER_ADDR_LEN) == 0) - break; - } - if (tmp == NULL) { - DP_INFO(edev, "Multicast mac is not found\n"); - return -EINVAL; - } - SLIST_REMOVE(&qdev->mc_list_head, tmp, - qede_mcast_entry, list); - qdev->num_mc_addr--; } + memset(&mcast, 0, sizeof(mcast)); + mcast.num_mc_addrs = mc_addrs_num; + mcast.opcode = ECORE_FILTER_ADD; + for (i = 0; i < mc_addrs_num; i++) + ether_addr_copy(&mc_addrs[i], (struct ether_addr *) + &mcast.mac[i]); + rc = ecore_filter_mcast_cmd(edev, &mcast, ECORE_SPQ_MODE_CB, NULL); + if (rc != ECORE_SUCCESS) { + DP_ERR(edev, "Failed to add multicast filter (rc = %d\n)", rc); + return -1; + } + + return 0; +} + +static int qede_del_mcast_filters(struct rte_eth_dev *eth_dev) +{ + struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); + struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); + struct qede_mcast_entry *tmp = NULL; + struct ecore_filter_mcast mcast; + int j; + int rc; + + memset(&mcast, 0, sizeof(mcast)); + mcast.num_mc_addrs = qdev->num_mc_addr; + mcast.opcode = ECORE_FILTER_REMOVE; + j = 0; + SLIST_FOREACH(tmp, &qdev->mc_list_head, list) { + ether_addr_copy(&tmp->mac, (struct ether_addr *)&mcast.mac[j]); + j++; + } + rc = ecore_filter_mcast_cmd(edev, &mcast, ECORE_SPQ_MODE_CB, NULL); + if (rc != ECORE_SUCCESS) { + DP_ERR(edev, "Failed to delete multicast filter\n"); + return -1; + } + /* Init the list */ + while (!SLIST_EMPTY(&qdev->mc_list_head)) { + tmp = SLIST_FIRST(&qdev->mc_list_head); + SLIST_REMOVE_HEAD(&qdev->mc_list_head, list); + } + SLIST_INIT(&qdev->mc_list_head); return 0; } @@ -945,59 +967,22 @@ static void qede_set_ucast_cmn_params(struct ecore_filter_ucast *ucast) { struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); - enum _ecore_status_t rc; - struct ecore_filter_mcast mcast; - struct qede_mcast_entry *tmp; - uint16_t j = 0; + enum _ecore_status_t rc = ECORE_INVAL; - /* Multicast */ - if (is_multicast_ether_addr((struct ether_addr *)ucast->mac)) { - if (add) { - if (qdev->num_mc_addr >= ECORE_MAX_MC_ADDRS) { - DP_ERR(edev, - "Mcast filter table limit exceeded, " - "Please enable mcast promisc mode\n"); - return -ECORE_INVAL; - } - } - rc = qede_mcast_filter(eth_dev, ucast, add); - if (rc == 0) { - DP_INFO(edev, "num_mc_addrs = %u\n", qdev->num_mc_addr); - memset(&mcast, 0, sizeof(mcast)); - mcast.num_mc_addrs = qdev->num_mc_addr; - mcast.opcode = ECORE_FILTER_ADD; - SLIST_FOREACH(tmp, &qdev->mc_list_head, list) { - ether_addr_copy(&tmp->mac, - (struct ether_addr *)&mcast.mac[j]); - j++; - } - rc = ecore_filter_mcast_cmd(edev, &mcast, - ECORE_SPQ_MODE_CB, NULL); - } - if (rc != ECORE_SUCCESS) { - DP_ERR(edev, "Failed to add multicast filter" - " rc = %d, op = %d\n", rc, add); - } - } else { /* Unicast */ - if (add) { - if (qdev->num_uc_addr >= - qdev->dev_info.num_mac_filters) { - DP_ERR(edev, - "Ucast filter table limit exceeded," - " Please enable promisc mode\n"); - return -ECORE_INVAL; - } - } - rc = qede_ucast_filter(eth_dev, ucast, add); - if (rc == 0) - rc = ecore_filter_ucast_cmd(edev, ucast, - ECORE_SPQ_MODE_CB, NULL); - if (rc != ECORE_SUCCESS) { - DP_ERR(edev, "MAC filter failed, rc = %d, op = %d\n", - rc, add); - } + if (add && (qdev->num_uc_addr >= qdev->dev_info.num_mac_filters)) { + DP_ERR(edev, "Ucast filter table limit exceeded," + " Please enable promisc mode\n"); + return ECORE_INVAL; } + rc = qede_ucast_filter(eth_dev, ucast, add); + if (rc == 0) + rc = ecore_filter_ucast_cmd(edev, ucast, + ECORE_SPQ_MODE_CB, NULL); + if (rc != ECORE_SUCCESS) + DP_ERR(edev, "MAC filter failed, rc = %d, op = %d\n", + rc, add); + return rc; } @@ -2042,6 +2027,35 @@ static void qede_allmulticast_disable(struct rte_eth_dev *eth_dev) QED_FILTER_RX_MODE_TYPE_REGULAR); } +static int +qede_set_mc_addr_list(struct rte_eth_dev *eth_dev, struct ether_addr *mc_addrs, + uint32_t mc_addrs_num) +{ + struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); + struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); + uint8_t i; + + if (mc_addrs_num > ECORE_MAX_MC_ADDRS) { + DP_ERR(edev, "Reached max multicast filters limit," + "Please enable multicast promisc mode\n"); + return -ENOSPC; + } + + for (i = 0; i < mc_addrs_num; i++) { + if (!is_multicast_ether_addr(&mc_addrs[i])) { + DP_ERR(edev, "Not a valid multicast MAC\n"); + return -EINVAL; + } + } + + /* Flush all existing entries */ + if (qede_del_mcast_filters(eth_dev)) + return -1; + + /* Set new mcast list */ + return qede_add_mcast_filters(eth_dev, mc_addrs, mc_addrs_num); +} + static int qede_flow_ctrl_set(struct rte_eth_dev *eth_dev, struct rte_eth_fc_conf *fc_conf) { @@ -2926,6 +2940,7 @@ int qede_dev_filter_ctrl(struct rte_eth_dev *eth_dev, .promiscuous_disable = qede_promiscuous_disable, .allmulticast_enable = qede_allmulticast_enable, .allmulticast_disable = qede_allmulticast_disable, + .set_mc_addr_list = qede_set_mc_addr_list, .dev_stop = qede_dev_stop, .dev_close = qede_dev_close, .stats_get = qede_get_stats, @@ -2966,6 +2981,7 @@ int qede_dev_filter_ctrl(struct rte_eth_dev *eth_dev, .promiscuous_disable = qede_promiscuous_disable, .allmulticast_enable = qede_allmulticast_enable, .allmulticast_disable = qede_allmulticast_disable, + .set_mc_addr_list = qede_set_mc_addr_list, .dev_stop = qede_dev_stop, .dev_close = qede_dev_close, .stats_get = qede_get_stats, @@ -3174,6 +3190,7 @@ static int qede_common_dev_init(struct rte_eth_dev *eth_dev, bool is_vf) SLIST_INIT(&adapter->fdir_info.fdir_list_head); SLIST_INIT(&adapter->vlan_list_head); SLIST_INIT(&adapter->uc_list_head); + SLIST_INIT(&adapter->mc_list_head); adapter->mtu = ETHER_MTU; adapter->vport_started = false; -- 1.7.10.3