svn commit: r341304 - head/sys/dev/sfxge/common

Andrew Rybchenko arybchik at FreeBSD.org
Fri Nov 30 07:06:59 UTC 2018


Author: arybchik
Date: Fri Nov 30 07:06:58 2018
New Revision: 341304
URL: https://svnweb.freebsd.org/changeset/base/341304

Log:
  sfxge(4): use simpler code to check hash algorithm type
  
  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.
  
  Submitted by:   Ivan Malov <ivan.malov at oktetlabs.ru>
  Sponsored by:   Solarflare Communications, Inc.
  Differential Revision:  https://reviews.freebsd.org/D18266

Modified:
  head/sys/dev/sfxge/common/efx_rx.c

Modified: head/sys/dev/sfxge/common/efx_rx.c
==============================================================================
--- head/sys/dev/sfxge/common/efx_rx.c	Fri Nov 30 07:06:46 2018	(r341303)
+++ head/sys/dev/sfxge/common/efx_rx.c	Fri Nov 30 07:06:58 2018	(r341304)
@@ -341,6 +341,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;
 
@@ -369,41 +374,23 @@ 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);
 	EFSYS_ASSERT3U(*nflagsp, <=, EFX_RX_HASH_NFLAGS);
 
 	return (0);
-
-fail2:
-	EFSYS_PROBE(fail2);
 
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);


More information about the svn-src-head mailing list