net/sfc/base: use simpler code to check hash algorithm type
[dpdk.git] / drivers / net / sfc / base / efx_rx.c
index 4fd73ba..dfd3974 100644 (file)
@@ -298,20 +298,25 @@ fail1:
 efx_rx_scale_hash_flags_get(
        __in                                    efx_nic_t *enp,
        __in                                    efx_rx_hash_alg_t hash_alg,
-       __inout_ecount(EFX_RX_HASH_NFLAGS)      unsigned int *flags,
+       __inout_ecount(EFX_RX_HASH_NFLAGS)      unsigned int *flagsp,
        __out                                   unsigned int *nflagsp)
 {
        efx_nic_cfg_t *encp = &enp->en_nic_cfg;
        boolean_t l4;
        boolean_t additional_modes;
-       unsigned int *entryp = flags;
+       unsigned int *entryp = flagsp;
        efx_rc_t rc;
 
-       if (flags == NULL || nflagsp == NULL) {
+       if (flagsp == NULL || nflagsp == NULL) {
                rc = EINVAL;
                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,42 +345,24 @@ 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 - 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);
 
@@ -831,7 +818,7 @@ efx_rx_qcreate_packed_stream(
 {
        efx_rxq_type_data_t type_data;
 
-       memset(&type_data, 0, sizeof(type_data));
+       memset(&type_data, 0, sizeof (type_data));
 
        type_data.ertd_packed_stream.eps_buf_size = ps_buf_size;
 
@@ -867,7 +854,7 @@ efx_rx_qcreate_es_super_buffer(
                goto fail1;
        }
 
-       memset(&type_data, 0, sizeof(type_data));
+       memset(&type_data, 0, sizeof (type_data));
 
        type_data.ertd_es_super_buffer.eessb_bufs_per_desc = n_bufs_per_desc;
        type_data.ertd_es_super_buffer.eessb_max_dma_len = max_dma_len;