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 B1F92A0565; Tue, 10 Mar 2020 10:49:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 866031C0AD; Tue, 10 Mar 2020 10:48:59 +0100 (CET) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id ECC3E1C02D; Tue, 10 Mar 2020 10:48:49 +0100 (CET) X-Virus-Scanned: Proofpoint Essentials engine 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-us2.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id EF8F528006E; Tue, 10 Mar 2020 09:48:48 +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; Tue, 10 Mar 2020 09:48:45 +0000 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; Tue, 10 Mar 2020 09:48:44 +0000 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 02A9mjgj008744; Tue, 10 Mar 2020 09:48:45 GMT Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 349841611DB; Tue, 10 Mar 2020 09:48:45 +0000 (GMT) From: Andrew Rybchenko To: CC: Igor Romanov , Date: Tue, 10 Mar 2020 09:48:38 +0000 Message-ID: <1583833719-6597-5-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1583833719-6597-1-git-send-email-arybchenko@solarflare.com> References: <1583833719-6597-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-25280.003 X-TM-AS-Result: No-4.032300-8.000000-10 X-TMASE-MatchedRID: Sogx09u5QK0PCyiJ1lKbPBouoVvF2i0Z6VTG9cZxEjKOSVCvVHWJJ3LD irObzoOLSqdra4WWujyPQi9XuOWoOPwfXc9ZWlYMzfqlpbtmcWg9/b618SpbHVubLFXlyveGcOQ FqW7TulVFiOGmSbOoIK1WilC06UhDyDhpVjX3lNR1e7Xbb6Im2qLwP+jjbL9K7L2+zGEubN4w1u ZwCZoKWGxsf0FJsY8t4gYlnr6q/ysfE8yM4pjsDwtuKBGekqUpnH7sbImOEBQw5JhpSjtzEcNW/ UkqJGubJSTGZVEKEZb4ThbLHOzSsSnTQr4DOzhWLlNbIVJ8yWMN73olebhSxCI2aE70AHMMDszJ lpJSnNfkA8OrYHdwDGfYlY/yoV/0Up6EHOb2+c7kHZDO53QSwmA7bUFBqh2V X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.032300-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1020-25280.003 X-MDID: 1583833729-YLUB_ky5xWXQ Subject: [dpdk-dev] [PATCH 4/5] net/sfc/base: refactor filter lookup loop in EF10 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 The code is refactored to make it more clear and allow for more convenient further changes. Fixes: e7cd430c864f ("net/sfc/base: import SFN7xxx family support") Cc: stable@dpdk.org Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/sfc/base/ef10_filter.c | 80 ++++++++++++++---------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/drivers/net/sfc/base/ef10_filter.c b/drivers/net/sfc/base/ef10_filter.c index e4f8de51c..5578765ab 100644 --- a/drivers/net/sfc/base/ef10_filter.c +++ b/drivers/net/sfc/base/ef10_filter.c @@ -628,56 +628,52 @@ ef10_filter_add_internal( * else a free slot to insert at. If any of them are busy, * we have to wait and retry. */ - for (;;) { - ins_index = -1; - depth = 1; - EFSYS_LOCK(enp->en_eslp, state); - locked = B_TRUE; +retry: + EFSYS_LOCK(enp->en_eslp, state); + locked = B_TRUE; - for (;;) { - i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1); - saved_spec = ef10_filter_entry_spec(eftp, i); + ins_index = -1; - if (!saved_spec) { - if (ins_index < 0) { - ins_index = i; - } - } else if (ef10_filter_equal(spec, saved_spec)) { - if (ef10_filter_entry_is_busy(eftp, i)) - break; - if (saved_spec->efs_priority - == EFX_FILTER_PRI_AUTO) { - ins_index = i; - goto found; - } else if (ef10_filter_is_exclusive(spec)) { - if (may_replace) { - ins_index = i; - goto found; - } else { - rc = EEXIST; - goto fail1; - } - } + for (depth = 1; depth <= EF10_FILTER_SEARCH_LIMIT; depth++) { + i = (hash + depth) & (EFX_EF10_FILTER_TBL_ROWS - 1); + saved_spec = ef10_filter_entry_spec(eftp, i); + + if (saved_spec == NULL) { + if (ins_index < 0) + ins_index = i; + } else if (ef10_filter_equal(spec, saved_spec)) { + if (ef10_filter_entry_is_busy(eftp, i)) { + EFSYS_UNLOCK(enp->en_eslp, state); + locked = B_FALSE; + goto retry; + } - /* Leave existing */ + if (saved_spec->efs_priority == EFX_FILTER_PRI_AUTO) { + ins_index = i; + goto found; } - /* - * Once we reach the maximum search depth, use - * the first suitable slot or return EBUSY if - * there was none. - */ - if (depth == EF10_FILTER_SEARCH_LIMIT) { - if (ins_index < 0) { - rc = EBUSY; - goto fail2; + if (ef10_filter_is_exclusive(spec)) { + if (may_replace) { + ins_index = i; + goto found; + } else { + rc = EEXIST; + goto fail1; } - goto found; } - depth++; + + /* Leave existing */ } - EFSYS_UNLOCK(enp->en_eslp, state); - locked = B_FALSE; + } + + /* + * Once we reach the maximum search depth, use the first suitable slot + * or return EBUSY if there was none. + */ + if (ins_index < 0) { + rc = EBUSY; + goto fail2; } found: -- 2.17.1