From owner-svn-src-head@freebsd.org Fri Nov 30 07:06:59 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3C782115A63A; Fri, 30 Nov 2018 07:06:59 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D46AC70E7F; Fri, 30 Nov 2018 07:06:58 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B5B7A251FB; Fri, 30 Nov 2018 07:06:58 +0000 (UTC) (envelope-from arybchik@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAU76wjq082536; Fri, 30 Nov 2018 07:06:58 GMT (envelope-from arybchik@FreeBSD.org) Received: (from arybchik@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAU76wD2082535; Fri, 30 Nov 2018 07:06:58 GMT (envelope-from arybchik@FreeBSD.org) Message-Id: <201811300706.wAU76wD2082535@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: arybchik set sender to arybchik@FreeBSD.org using -f From: Andrew Rybchenko Date: Fri, 30 Nov 2018 07:06:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341304 - head/sys/dev/sfxge/common X-SVN-Group: head X-SVN-Commit-Author: arybchik X-SVN-Commit-Paths: head/sys/dev/sfxge/common X-SVN-Commit-Revision: 341304 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D46AC70E7F X-Spamd-Result: default: False [0.65 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_LONG(0.34)[0.335,0]; NEURAL_SPAM_MEDIUM(0.31)[0.312,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_SPAM_SHORT(0.01)[0.005,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Nov 2018 07:06:59 -0000 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 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);