DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Igor Romanov <igor.romanov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH 4/6] net/sfc/base: refactor mcast filters reconfiguration
Date: Mon, 30 Mar 2020 11:25:43 +0100	[thread overview]
Message-ID: <1585563945-9537-5-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1585563945-9537-1-git-send-email-arybchenko@solarflare.com>

From: Igor Romanov <igor.romanov@oktetlabs.ru>

Refactor the multicast filter reconfiguration stage of the reconfigure
function to make it clearer and allow for more convenient further
changes.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/base/ef10_filter.c | 143 +++++++++++++++++++----------
 1 file changed, 92 insertions(+), 51 deletions(-)

diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/net/sfc/base/ef10_filter.c
index 35d675a65d..0a8744c09e 100644
--- a/drivers/net/sfc/base/ef10_filter.c
+++ b/drivers/net/sfc/base/ef10_filter.c
@@ -1851,6 +1851,89 @@ ef10_filter_insert_renew_unicst_filters(
 	return (rc);
 }
 
+static	__checkReturn	efx_rc_t
+ef10_filter_insert_renew_mulcst_filters(
+	__in				efx_nic_t *enp,
+	__in				boolean_t mulcst,
+	__in				boolean_t all_mulcst,
+	__in				boolean_t brdcst,
+	__in_ecount(6*count)		uint8_t const *addrs,
+	__in				uint32_t count,
+	__in				efx_filter_flags_t filter_flags,
+	__in				boolean_t all_unicst_inserted,
+	__out				boolean_t *all_mulcst_inserted)
+{
+	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
+	efx_nic_cfg_t *encp = &enp->en_nic_cfg;
+	efx_rc_t rc;
+
+	*all_mulcst_inserted = B_FALSE;
+
+	if (all_mulcst == B_TRUE) {
+		efx_rc_t all_mulcst_rc;
+
+		/*
+		 * Insert the all multicast filter. If that fails, try to insert
+		 * all of our multicast filters (but without rollback on
+		 * failure).
+		 */
+		all_mulcst_rc = ef10_filter_insert_all_multicast(enp,
+							    filter_flags);
+		if (all_mulcst_rc == 0) {
+			*all_mulcst_inserted = B_TRUE;
+		} else {
+			rc = ef10_filter_insert_multicast_list(enp, B_TRUE,
+			    brdcst, addrs, count, filter_flags, B_FALSE);
+			if (rc != 0)
+				goto fail1;
+		}
+	} else {
+		/*
+		 * Insert filters for multicast addresses.
+		 * If any insertion fails, then rollback and try to insert the
+		 * all multicast filter instead.
+		 * If that also fails, try to insert all of the multicast
+		 * filters (but without rollback on failure).
+		 */
+		rc = ef10_filter_insert_multicast_list(enp, mulcst, brdcst,
+			    addrs, count, filter_flags, B_TRUE);
+		if (rc != 0) {
+			if ((table->eft_using_all_mulcst == B_FALSE) &&
+			    (encp->enc_bug26807_workaround == B_TRUE)) {
+				/*
+				 * Multicast filter chaining is on, so remove
+				 * old filters before inserting the multicast
+				 * all filter to avoid duplicate delivery caused
+				 * by packets matching multiple filters.
+				 */
+				ef10_filter_remove_old(enp);
+			}
+
+			rc = ef10_filter_insert_all_multicast(enp,
+							    filter_flags);
+			if (rc == 0) {
+				*all_mulcst_inserted = B_TRUE;
+			} else {
+				rc = ef10_filter_insert_multicast_list(enp,
+				    mulcst, brdcst,
+				    addrs, count, filter_flags, B_FALSE);
+				if (rc != 0)
+					goto fail2;
+			}
+		}
+	}
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE1(fail2, efx_rc_t, rc);
+
+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
@@ -1873,7 +1956,7 @@ ef10_filter_reconfigure(
 	efx_filter_flags_t filter_flags;
 	unsigned int i;
 	boolean_t all_unicst_inserted = B_FALSE;
-	efx_rc_t all_mulcst_rc = 0;
+	boolean_t all_mulcst_inserted = B_FALSE;
 	efx_rc_t rc;
 
 	if (table->eft_default_rxq == NULL) {
@@ -1944,53 +2027,13 @@ ef10_filter_reconfigure(
 	}
 
 	/* Insert or renew multicast filters */
-	if (all_mulcst == B_TRUE) {
-		/*
-		 * Insert the all multicast filter. If that fails, try to insert
-		 * all of our multicast filters (but without rollback on
-		 * failure).
-		 */
-		all_mulcst_rc = ef10_filter_insert_all_multicast(enp,
-							    filter_flags);
-		if (all_mulcst_rc != 0) {
-			rc = ef10_filter_insert_multicast_list(enp, B_TRUE,
-			    brdcst, addrs, count, filter_flags, B_FALSE);
-			if (rc != 0)
-				goto fail3;
-		}
-	} else {
-		/*
-		 * Insert filters for multicast addresses.
-		 * If any insertion fails, then rollback and try to insert the
-		 * all multicast filter instead.
-		 * If that also fails, try to insert all of the multicast
-		 * filters (but without rollback on failure).
-		 */
-		rc = ef10_filter_insert_multicast_list(enp, mulcst, brdcst,
-			    addrs, count, filter_flags, B_TRUE);
-		if (rc != 0) {
-			if ((table->eft_using_all_mulcst == B_FALSE) &&
-			    (encp->enc_bug26807_workaround == B_TRUE)) {
-				/*
-				 * Multicast filter chaining is on, so remove
-				 * old filters before inserting the multicast
-				 * all filter to avoid duplicate delivery caused
-				 * by packets matching multiple filters.
-				 */
-				ef10_filter_remove_old(enp);
-			}
-
-			rc = ef10_filter_insert_all_multicast(enp,
-							    filter_flags);
-			if (rc != 0) {
-				rc = ef10_filter_insert_multicast_list(enp,
-				    mulcst, brdcst,
-				    addrs, count, filter_flags, B_FALSE);
-				if (rc != 0)
-					goto fail4;
-			}
-		}
-	}
+	rc = ef10_filter_insert_renew_mulcst_filters(enp, mulcst, all_mulcst,
+						     brdcst, addrs, count,
+						     filter_flags,
+						     all_unicst_inserted,
+						     &all_mulcst_inserted);
+	if (rc != 0)
+		goto fail3;
 
 	if (encp->enc_tunnel_encapsulations_supported != 0) {
 		/* Try to insert filters for encapsulated packets. */
@@ -2004,14 +2047,12 @@ ef10_filter_reconfigure(
 
 	/* report if any optional flags were rejected */
 	if (((all_unicst != B_FALSE) && (all_unicst_inserted == B_FALSE)) ||
-	    ((all_mulcst != B_FALSE) && (all_mulcst_rc != 0))) {
+	    ((all_mulcst != B_FALSE) && (all_mulcst_inserted == B_FALSE))) {
 		rc = ENOTSUP;
 	}
 
 	return (rc);
 
-fail4:
-	EFSYS_PROBE(fail4);
 fail3:
 	EFSYS_PROBE(fail3);
 fail2:
-- 
2.17.1


  parent reply	other threads:[~2020-03-30 10:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30 10:25 [dpdk-dev] [PATCH 0/6] net/sfc: improve Rx mode handling on VF Andrew Rybchenko
2020-03-30 10:25 ` [dpdk-dev] [PATCH 1/6] net/sfc/base: refactor filters cleanup in reconfigure Andrew Rybchenko
2020-03-30 10:25 ` [dpdk-dev] [PATCH 2/6] net/sfc/base: refactor filters mark " Andrew Rybchenko
2020-03-30 10:25 ` [dpdk-dev] [PATCH 3/6] net/sfc/base: refactor unicast filters reconfiguration Andrew Rybchenko
2020-03-30 10:25 ` Andrew Rybchenko [this message]
2020-03-30 10:25 ` [dpdk-dev] [PATCH 5/6] net/sfc/base: add API to get currently operating filters Andrew Rybchenko
2020-03-30 10:25 ` [dpdk-dev] [PATCH 6/6] net/sfc: check actual all multicast unknown unicast filters Andrew Rybchenko
2020-04-02  9:37 ` [dpdk-dev] [PATCH 0/6] net/sfc: improve Rx mode handling on VF Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1585563945-9537-5-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=igor.romanov@oktetlabs.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).