[31/37] net/sfc/base: use simpler code to check hash algorithm type

Message ID 1536572016-18134-32-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: update base driver |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Andrew Rybchenko Sept. 10, 2018, 9:33 a.m. UTC
  From: Ivan Malov <Ivan.Malov@oktetlabs.ru>

The API which is used to list supported hash flags verifies
hash algorithm choice before writing the output. This check
is based on a switch() statement which has only two options
and no distinctive actions to be conducted for each of them.
Use simpler code instead of switch() to improve readability.

Signed-off-by: Ivan Malov <Ivan.Malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/base/efx_rx.c | 39 ++++++++++++-----------------------
 1 file changed, 13 insertions(+), 26 deletions(-)
  

Patch

diff --git a/drivers/net/sfc/base/efx_rx.c b/drivers/net/sfc/base/efx_rx.c
index 7b9f28664..dfd3974da 100644
--- a/drivers/net/sfc/base/efx_rx.c
+++ b/drivers/net/sfc/base/efx_rx.c
@@ -312,6 +312,11 @@  efx_rx_scale_hash_flags_get(
 		goto fail1;
 	}
 
+	if ((encp->enc_rx_scale_hash_alg_mask & (1U << hash_alg)) == 0) {
+		*nflagsp = 0;
+		return 0;
+	}
+
 	l4 = encp->enc_rx_scale_l4_hash_supported;
 	additional_modes = encp->enc_rx_scale_additional_modes_supported;
 
@@ -340,32 +345,17 @@  efx_rx_scale_hash_flags_get(
 		_NOTE(CONSTANTCONDITION)				\
 	} while (B_FALSE)
 
-	switch (hash_alg) {
-	case EFX_RX_HASHALG_PACKED_STREAM:
-		if ((encp->enc_rx_scale_hash_alg_mask & (1U << hash_alg)) == 0)
-			break;
-		/* FALLTHRU */
-	case EFX_RX_HASHALG_TOEPLITZ:
-		if ((encp->enc_rx_scale_hash_alg_mask & (1U << hash_alg)) == 0)
-			break;
+	LIST_FLAGS(entryp, IPV4_TCP, l4, additional_modes);
+	LIST_FLAGS(entryp, IPV6_TCP, l4, additional_modes);
 
-		LIST_FLAGS(entryp, IPV4_TCP, l4, additional_modes);
-		LIST_FLAGS(entryp, IPV6_TCP, l4, additional_modes);
-
-		if (additional_modes) {
-			LIST_FLAGS(entryp, IPV4_UDP, l4, additional_modes);
-			LIST_FLAGS(entryp, IPV6_UDP, l4, additional_modes);
-		}
-
-		LIST_FLAGS(entryp, IPV4, B_FALSE, additional_modes);
-		LIST_FLAGS(entryp, IPV6, B_FALSE, additional_modes);
-		break;
-
-	default:
-		rc = EINVAL;
-		goto fail2;
+	if (additional_modes) {
+		LIST_FLAGS(entryp, IPV4_UDP, l4, additional_modes);
+		LIST_FLAGS(entryp, IPV6_UDP, l4, additional_modes);
 	}
 
+	LIST_FLAGS(entryp, IPV4, B_FALSE, additional_modes);
+	LIST_FLAGS(entryp, IPV6, B_FALSE, additional_modes);
+
 #undef LIST_FLAGS
 
 	*nflagsp = (unsigned int)(entryp - flagsp);
@@ -373,9 +363,6 @@  efx_rx_scale_hash_flags_get(
 
 	return (0);
 
-fail2:
-	EFSYS_PROBE(fail2);
-
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);