From patchwork Mon Mar 30 10:25:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 67416 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA5FBA0562; Mon, 30 Mar 2020 12:26:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7CC2D1C07C; Mon, 30 Mar 2020 12:26:22 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id AABD62BEA for ; Mon, 30 Mar 2020 12:26:16 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.61]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 27C8060058 for ; Mon, 30 Mar 2020 10:26:16 +0000 (UTC) Received: from us4-mdac16-3.ut7.mdlocal (unknown [10.7.65.71]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id 259868009E for ; Mon, 30 Mar 2020 10:26:16 +0000 (UTC) X-Virus-Scanned: Proofpoint Essentials engine Received: from mx1-us1.ppe-hosted.com (unknown [10.7.66.37]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 9BF9980058 for ; Mon, 30 Mar 2020 10:26:15 +0000 (UTC) Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 4B066B40061 for ; Mon, 30 Mar 2020 10:26:15 +0000 (UTC) Received: from ukex01.SolarFlarecom.com (10.17.10.4) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 30 Mar 2020 11:26:11 +0100 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 30 Mar 2020 11:26:11 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id 02UAQBIc030738; Mon, 30 Mar 2020 11:26:11 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id DAE1716139D; Mon, 30 Mar 2020 11:26:11 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Mon, 30 Mar 2020 11:25:42 +0100 Message-ID: <1585563945-9537-4-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1585563945-9537-1-git-send-email-arybchenko@solarflare.com> References: <1585563945-9537-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1020-25322.003 X-TM-AS-Result: No-1.989400-8.000000-10 X-TMASE-MatchedRID: 2Blpx5Thclxis7UoQ0MxbqiUivh0j2Pv6VTG9cZxEjKOSVCvVHWJJ0Ac 6DyoS2rI2hTOUzxi3QiJB1aQOIJnkR7jjY8HRMMmbB9GZLXxndjcVi8qZmJWc5GJXR6jRFu47AW YnySaWHtxmqTXW8mz5ULuQ1UfVo/WjIJ0KdSGRo6ZfODRsHrOYD0oG3q2fIVyERgtK1vKtV0t7Y IBToXb92jj7jiWZNolgfPLl/E7ZuVXjgwaaQLSxp4CIKY/Hg3AGdQnQSTrKGPEQdG7H66TyHEqm 8QYBtMOhEeasOyFmL2p6ssCaA/MLtUWK4PUwWi2piSXTx9PFcXJ/h+Kz0SxL0WBtbaNOFxaH6/J WJTiQ2rFfqKrVxdfUqw72msGhQBNk3UkV5Qp4wSI45Rd9ORJwFlJvEhEss3fzQahrdQz77w= X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.989400-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1020-25322.003 X-MDID: 1585563976-BqNUvvmLfxP6 Subject: [dpdk-dev] [PATCH 3/6] net/sfc/base: refactor unicast filters reconfiguration 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Igor Romanov Refactor the unicast filter reconfiguration stage of the reconfigure function to make it clearer and allow for more convenient further changes. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/base/ef10_filter.c | 83 ++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/net/sfc/base/ef10_filter.c index 5033ff75ac..35d675a65d 100644 --- a/drivers/net/sfc/base/ef10_filter.c +++ b/drivers/net/sfc/base/ef10_filter.c @@ -1803,6 +1803,54 @@ ef10_filter_mark_old_filters( } } +static __checkReturn efx_rc_t +ef10_filter_insert_renew_unicst_filters( + __in efx_nic_t *enp, + __in_ecount(6) uint8_t const *mac_addr, + __in boolean_t all_unicst, + __in efx_filter_flags_t filter_flags, + __out boolean_t *all_unicst_inserted) +{ + ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; + efx_rc_t rc; + + /* + * Firmware does not perform chaining on unicast filters. As traffic is + * therefore only delivered to the first matching filter, we should + * always insert the specific filter for our MAC address, to try and + * ensure we get that traffic. + * + * (If the filter for our MAC address has already been inserted by + * another function, we won't receive traffic sent to us, even if we + * insert a unicast mismatch filter. To prevent traffic stealing, this + * therefore relies on the privilege model only allowing functions to + * insert filters for their own MAC address unless explicitly given + * additional privileges by the user. This also means that, even on a + * priviliged function, inserting a unicast mismatch filter may not + * catch all traffic in multi PCI function scenarios.) + */ + table->eft_unicst_filter_count = 0; + rc = ef10_filter_insert_unicast(enp, mac_addr, filter_flags); + *all_unicst_inserted = B_FALSE; + if (all_unicst || (rc != 0)) { + efx_rc_t all_unicst_rc; + + all_unicst_rc = ef10_filter_insert_all_unicast(enp, + filter_flags); + if (all_unicst_rc == 0) { + *all_unicst_inserted = B_TRUE; + } else if (rc != 0) + goto fail1; + } + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + + return (rc); +} + /* * Reconfigure all filters. * If all_unicst and/or all mulcst filters cannot be applied then @@ -1824,7 +1872,7 @@ ef10_filter_reconfigure( ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table; efx_filter_flags_t filter_flags; unsigned int i; - efx_rc_t all_unicst_rc = 0; + boolean_t all_unicst_inserted = B_FALSE; efx_rc_t all_mulcst_rc = 0; efx_rc_t rc; @@ -1847,31 +1895,12 @@ ef10_filter_reconfigure( /* Mark old filters which may need to be removed */ ef10_filter_mark_old_filters(enp); - /* - * Insert or renew unicast filters. - * - * Firmware does not perform chaining on unicast filters. As traffic is - * therefore only delivered to the first matching filter, we should - * always insert the specific filter for our MAC address, to try and - * ensure we get that traffic. - * - * (If the filter for our MAC address has already been inserted by - * another function, we won't receive traffic sent to us, even if we - * insert a unicast mismatch filter. To prevent traffic stealing, this - * therefore relies on the privilege model only allowing functions to - * insert filters for their own MAC address unless explicitly given - * additional privileges by the user. This also means that, even on a - * priviliged function, inserting a unicast mismatch filter may not - * catch all traffic in multi PCI function scenarios.) - */ - table->eft_unicst_filter_count = 0; - rc = ef10_filter_insert_unicast(enp, mac_addr, filter_flags); - if (all_unicst || (rc != 0)) { - all_unicst_rc = ef10_filter_insert_all_unicast(enp, - filter_flags); - if ((rc != 0) && (all_unicst_rc != 0)) - goto fail1; - } + /* Insert or renew unicast filters */ + rc = ef10_filter_insert_renew_unicst_filters(enp, mac_addr, all_unicst, + filter_flags, + &all_unicst_inserted); + if (rc != 0) + goto fail1; /* * WORKAROUND_BUG26807 controls firmware support for chained multicast @@ -1974,7 +2003,7 @@ ef10_filter_reconfigure( ef10_filter_remove_old(enp); /* report if any optional flags were rejected */ - if (((all_unicst != B_FALSE) && (all_unicst_rc != 0)) || + if (((all_unicst != B_FALSE) && (all_unicst_inserted == B_FALSE)) || ((all_mulcst != B_FALSE) && (all_mulcst_rc != 0))) { rc = ENOTSUP; }