From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C3999A0562; Mon, 30 Mar 2020 12:26:54 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 401F81C0AF; Mon, 30 Mar 2020 12:26:24 +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 3FD621BFD9 for ; Mon, 30 Mar 2020 12:26:17 +0200 (CEST) Received: from mx1-us1.ppe-hosted.com (unknown [10.7.65.62]) by dispatch1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id AD4F560060 for ; Mon, 30 Mar 2020 10:26:16 +0000 (UTC) Received: from us4-mdac16-22.ut7.mdlocal (unknown [10.7.65.246]) by mx1-us1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTP id ACAC88009B 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 0F383280052 for ; Mon, 30 Mar 2020 10:26:16 +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 B6255B4005E 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 02UAQCr9030750; Mon, 30 Mar 2020 11:26:12 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 0A2AB1627D7; Mon, 30 Mar 2020 11:26:12 +0100 (BST) From: Andrew Rybchenko To: CC: Igor Romanov Date: Mon, 30 Mar 2020 11:25:45 +0100 Message-ID: <1585563945-9537-7-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 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1020-25322.003 X-TM-AS-Result: No-1.640700-8.000000-10 X-TMASE-MatchedRID: kO/+U1LPROF60j/UbRmWKGXaK3KHx/xpy733NwuklsLHoLp1yJ83GItU W2TdSbko8XVI39JCRnT/hOZJ+pyU4JMKhvRh/ZfePwKTD1v8YV5MkOX0UoduuTbpMgyAfh26eCN V1mMi/46cEZnGiJ7tqyHHmeLt1EWwTLYGH8Cfo/bxQg/1zqqUm6CHGfJA0hsdkYldHqNEW7iCe4 dOpanJaSscgJiSQQDe2qrzycqlC69CXIPbCpslENtuAjgC5ilXVoopVBvm9s3M2uabcMu+36PFj JEFr+olwXCBO/GKkVqOhzOa6g8KrQtrCbFBy78J155kI3igSxjqcD0HfMGpsdqCkXIU2eFUZaT5 cTo2Pyy40oom5HQFWjOlB6M/A1moVMc4CiR2e6hCPVOT5NSO24XXmHr+iJs1sqxYnjga4QY83Fq 7f38GK0XAdmaT51YybiPTBhvbLhaUTGVAhB5EbQ== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--1.640700-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1020-25322.003 X-MDID: 1585563976-nvqXsLVQom2z Subject: [dpdk-dev] [PATCH 6/6] net/sfc: check actual all multicast unknown unicast filters 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 Check that unknown unicast and unknown multicast filters are applied and return an error if they are not applied. The error is used in promiscuous and all multicast mode enable and disable callbacks. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/sfc.h | 1 + drivers/net/sfc/sfc_ethdev.c | 16 +++++++--- drivers/net/sfc/sfc_port.c | 62 +++++++++++++++++++++++++++++++++--- drivers/net/sfc/sfc_rx.c | 4 +-- 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 2520cf2b7c..ceb23402a5 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -407,6 +407,7 @@ void sfc_port_link_mode_to_info(efx_link_mode_t link_mode, int sfc_port_update_mac_stats(struct sfc_adapter *sa); int sfc_port_reset_mac_stats(struct sfc_adapter *sa); int sfc_set_rx_mode(struct sfc_adapter *sa); +int sfc_set_rx_mode_unchecked(struct sfc_adapter *sa); #ifdef __cplusplus diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index f8867b0ec0..de490eb90d 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -393,8 +393,16 @@ sfc_dev_filter_set(struct rte_eth_dev *dev, enum sfc_dev_filter_mode mode, } else if ((sa->state == SFC_ADAPTER_STARTED) && ((rc = sfc_set_rx_mode(sa)) != 0)) { *toggle = !(enabled); - sfc_warn(sa, "Failed to %s %s mode", - ((enabled) ? "enable" : "disable"), desc); + sfc_warn(sa, "Failed to %s %s mode, rc = %d", + ((enabled) ? "enable" : "disable"), desc, rc); + + /* + * For promiscuous and all-multicast filters a + * permission failure should be reported as an + * unsupported filter. + */ + if (rc == EPERM) + rc = ENOTSUP; } } @@ -1060,12 +1068,12 @@ sfc_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr) * has no effect on received traffic, therefore * we also need to update unicast filters */ - rc = sfc_set_rx_mode(sa); + rc = sfc_set_rx_mode_unchecked(sa); if (rc != 0) { sfc_err(sa, "cannot set filter (rc = %u)", rc); /* Rollback the old address */ (void)efx_mac_addr_set(sa->nic, old_addr->addr_bytes); - (void)sfc_set_rx_mode(sa); + (void)sfc_set_rx_mode_unchecked(sa); } } else { sfc_warn(sa, "cannot set MAC address with filters installed"); diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 23313e125f..0ddefdefe8 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -239,7 +239,7 @@ sfc_port_start(struct sfc_adapter *sa) B_TRUE : B_FALSE; port->allmulti = (sa->eth_dev->data->all_multicast != 0) ? B_TRUE : B_FALSE; - rc = sfc_set_rx_mode(sa); + rc = sfc_set_rx_mode_unchecked(sa); if (rc != 0) goto fail_mac_filter_set; @@ -485,16 +485,70 @@ sfc_port_detach(struct sfc_adapter *sa) sfc_log_init(sa, "done"); } +static boolean_t +sfc_get_requested_all_ucast(struct sfc_port *port) +{ + return port->promisc; +} + +static boolean_t +sfc_get_requested_all_mcast(struct sfc_port *port) +{ + return port->promisc || port->allmulti; +} + +int +sfc_set_rx_mode_unchecked(struct sfc_adapter *sa) +{ + struct sfc_port *port = &sa->port; + boolean_t requested_all_ucast = sfc_get_requested_all_ucast(port); + boolean_t requested_all_mcast = sfc_get_requested_all_mcast(port); + int rc; + + rc = efx_mac_filter_set(sa->nic, requested_all_ucast, B_TRUE, + requested_all_mcast, B_TRUE); + if (rc != 0) + return rc; + + return 0; +} + int sfc_set_rx_mode(struct sfc_adapter *sa) { struct sfc_port *port = &sa->port; + boolean_t old_all_ucast; + boolean_t old_all_mcast; + boolean_t requested_all_ucast = sfc_get_requested_all_ucast(port); + boolean_t requested_all_mcast = sfc_get_requested_all_mcast(port); + boolean_t actual_all_ucast; + boolean_t actual_all_mcast; int rc; - rc = efx_mac_filter_set(sa->nic, port->promisc, B_TRUE, - port->promisc || port->allmulti, B_TRUE); + efx_mac_filter_get_all_ucast_mcast(sa->nic, &old_all_ucast, + &old_all_mcast); - return rc; + rc = sfc_set_rx_mode_unchecked(sa); + if (rc != 0) + return rc; + + efx_mac_filter_get_all_ucast_mcast(sa->nic, &actual_all_ucast, + &actual_all_mcast); + + if (actual_all_ucast != requested_all_ucast || + actual_all_mcast != requested_all_mcast) { + /* + * MAC filter set succeeded but not all requested modes + * were applied. The rollback is necessary to bring back the + * consistent old state. + */ + (void)efx_mac_filter_set(sa->nic, old_all_ucast, B_TRUE, + old_all_mcast, B_TRUE); + + return EPERM; + } + + return 0; } void diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 891709fd04..183589c639 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -720,7 +720,7 @@ sfc_rx_default_rxq_set_filter(struct sfc_adapter *sa, struct sfc_rxq *rxq) port->promisc = B_FALSE; sa->eth_dev->data->promiscuous = 0; - rc = sfc_set_rx_mode(sa); + rc = sfc_set_rx_mode_unchecked(sa); if (rc != 0) return rc; @@ -734,7 +734,7 @@ sfc_rx_default_rxq_set_filter(struct sfc_adapter *sa, struct sfc_rxq *rxq) port->allmulti = B_FALSE; sa->eth_dev->data->all_multicast = 0; - rc = sfc_set_rx_mode(sa); + rc = sfc_set_rx_mode_unchecked(sa); if (rc != 0) return rc; -- 2.17.1