net/sfc/base: update RSS API to take RSS context parameter
authorMark Spender <mspender@solarflare.com>
Wed, 30 Aug 2017 18:17:37 +0000 (19:17 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 00:49:47 +0000 (02:49 +0200)
Update efx_rx_scale_mode_set(), efx_rx_scale_key_set()
and efx_rx_scale_tbl_set().

Signed-off-by: Mark Spender <mspender@solarflare.com>
Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
drivers/net/sfc/base/ef10_impl.h
drivers/net/sfc/base/ef10_rx.c
drivers/net/sfc/base/efx.h
drivers/net/sfc/base/efx_impl.h
drivers/net/sfc/base/efx_rx.c
drivers/net/sfc/sfc_ethdev.c
drivers/net/sfc/sfc_rx.c

index 71a68d7..8f9eb7a 100644 (file)
@@ -912,6 +912,7 @@ ef10_rx_scale_context_free(
 extern __checkReturn   efx_rc_t
 ef10_rx_scale_mode_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in            efx_rx_hash_alg_t alg,
        __in            efx_rx_hash_type_t type,
        __in            boolean_t insert);
@@ -919,12 +920,14 @@ ef10_rx_scale_mode_set(
 extern __checkReturn   efx_rc_t
 ef10_rx_scale_key_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  uint8_t *key,
        __in            size_t n);
 
 extern __checkReturn   efx_rc_t
 ef10_rx_scale_tbl_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  unsigned int *table,
        __in            size_t n);
 
index 8dd6572..d34ea4d 100644 (file)
@@ -535,6 +535,7 @@ fail1:
        __checkReturn   efx_rc_t
 ef10_rx_scale_mode_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in            efx_rx_hash_alg_t alg,
        __in            efx_rx_hash_type_t type,
        __in            boolean_t insert)
@@ -549,13 +550,16 @@ ef10_rx_scale_mode_set(
                goto fail1;
        }
 
-       if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
-               rc = ENOTSUP;
-               goto fail2;
+       if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
+               if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
+                       rc = ENOTSUP;
+                       goto fail2;
+               }
+               rss_context = enp->en_rss_context;
        }
 
        if ((rc = efx_mcdi_rss_context_set_flags(enp,
-                   enp->en_rss_context, type)) != 0)
+                   rss_context, type)) != 0)
                goto fail3;
 
        return (0);
@@ -575,18 +579,21 @@ fail1:
        __checkReturn   efx_rc_t
 ef10_rx_scale_key_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  uint8_t *key,
        __in            size_t n)
 {
        efx_rc_t rc;
 
-       if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
-               rc = ENOTSUP;
-               goto fail1;
+       if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
+               if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
+                       rc = ENOTSUP;
+                       goto fail1;
+               }
+               rss_context = enp->en_rss_context;
        }
 
-       if ((rc = efx_mcdi_rss_context_set_key(enp,
-           enp->en_rss_context, key, n)) != 0)
+       if ((rc = efx_mcdi_rss_context_set_key(enp, rss_context, key, n)) != 0)
                goto fail2;
 
        return (0);
@@ -604,18 +611,23 @@ fail1:
        __checkReturn   efx_rc_t
 ef10_rx_scale_tbl_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  unsigned int *table,
        __in            size_t n)
 {
        efx_rc_t rc;
 
-       if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
-               rc = ENOTSUP;
-               goto fail1;
+
+       if (rss_context == EFX_RSS_CONTEXT_DEFAULT) {
+               if (enp->en_rss_context_type == EFX_RX_SCALE_UNAVAILABLE) {
+                       rc = ENOTSUP;
+                       goto fail1;
+               }
+               rss_context = enp->en_rss_context;
        }
 
        if ((rc = efx_mcdi_rss_context_set_table(enp,
-           enp->en_rss_context, table, n)) != 0)
+                   rss_context, table, n)) != 0)
                goto fail2;
 
        return (0);
index 0bca7d9..fa0e590 100644 (file)
@@ -1941,6 +1941,7 @@ efx_rx_scale_context_free(
 extern __checkReturn   efx_rc_t
 efx_rx_scale_mode_set(
        __in    efx_nic_t *enp,
+       __in    uint32_t rss_context,
        __in    efx_rx_hash_alg_t alg,
        __in    efx_rx_hash_type_t type,
        __in    boolean_t insert);
@@ -1948,12 +1949,14 @@ efx_rx_scale_mode_set(
 extern __checkReturn   efx_rc_t
 efx_rx_scale_tbl_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  unsigned int *table,
        __in            size_t n);
 
 extern __checkReturn   efx_rc_t
 efx_rx_scale_key_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  uint8_t *key,
        __in            size_t n);
 
index c7ed067..53fa37a 100644 (file)
@@ -156,11 +156,13 @@ typedef struct efx_rx_ops_s {
                                                    efx_rx_scale_context_type_t,
                                                    uint32_t, uint32_t *);
        efx_rc_t        (*erxo_scale_context_free)(efx_nic_t *, uint32_t);
-       efx_rc_t        (*erxo_scale_mode_set)(efx_nic_t *, efx_rx_hash_alg_t,
+       efx_rc_t        (*erxo_scale_mode_set)(efx_nic_t *, uint32_t,
+                                              efx_rx_hash_alg_t,
                                               efx_rx_hash_type_t, boolean_t);
-       efx_rc_t        (*erxo_scale_key_set)(efx_nic_t *, uint8_t *, size_t);
-       efx_rc_t        (*erxo_scale_tbl_set)(efx_nic_t *, unsigned int *,
-                                             size_t);
+       efx_rc_t        (*erxo_scale_key_set)(efx_nic_t *, uint32_t,
+                                             uint8_t *, size_t);
+       efx_rc_t        (*erxo_scale_tbl_set)(efx_nic_t *, uint32_t,
+                                             unsigned int *, size_t);
        uint32_t        (*erxo_prefix_hash)(efx_nic_t *, efx_rx_hash_alg_t,
                                            uint8_t *);
 #endif /* EFSYS_OPT_RX_SCALE */
index d587f08..785365d 100644 (file)
@@ -53,6 +53,7 @@ siena_rx_scatter_enable(
 static __checkReturn   efx_rc_t
 siena_rx_scale_mode_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in            efx_rx_hash_alg_t alg,
        __in            efx_rx_hash_type_t type,
        __in            boolean_t insert);
@@ -60,12 +61,14 @@ siena_rx_scale_mode_set(
 static __checkReturn   efx_rc_t
 siena_rx_scale_key_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  uint8_t *key,
        __in            size_t n);
 
 static __checkReturn   efx_rc_t
 siena_rx_scale_tbl_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  unsigned int *table,
        __in            size_t n);
 
@@ -432,6 +435,7 @@ fail1:
        __checkReturn   efx_rc_t
 efx_rx_scale_mode_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in            efx_rx_hash_alg_t alg,
        __in            efx_rx_hash_type_t type,
        __in            boolean_t insert)
@@ -443,7 +447,7 @@ efx_rx_scale_mode_set(
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX);
 
        if (erxop->erxo_scale_mode_set != NULL) {
-               if ((rc = erxop->erxo_scale_mode_set(enp, alg,
+               if ((rc = erxop->erxo_scale_mode_set(enp, rss_context, alg,
                            type, insert)) != 0)
                        goto fail1;
        }
@@ -460,6 +464,7 @@ fail1:
        __checkReturn   efx_rc_t
 efx_rx_scale_key_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  uint8_t *key,
        __in            size_t n)
 {
@@ -469,7 +474,7 @@ efx_rx_scale_key_set(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX);
 
-       if ((rc = erxop->erxo_scale_key_set(enp, key, n)) != 0)
+       if ((rc = erxop->erxo_scale_key_set(enp, rss_context, key, n)) != 0)
                goto fail1;
 
        return (0);
@@ -485,6 +490,7 @@ fail1:
        __checkReturn   efx_rc_t
 efx_rx_scale_tbl_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  unsigned int *table,
        __in            size_t n)
 {
@@ -494,7 +500,7 @@ efx_rx_scale_tbl_set(
        EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
        EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_RX);
 
-       if ((rc = erxop->erxo_scale_tbl_set(enp, table, n)) != 0)
+       if ((rc = erxop->erxo_scale_tbl_set(enp, rss_context, table, n)) != 0)
                goto fail1;
 
        return (0);
@@ -847,12 +853,18 @@ fail1:
 static __checkReturn   efx_rc_t
 siena_rx_scale_mode_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in            efx_rx_hash_alg_t alg,
        __in            efx_rx_hash_type_t type,
        __in            boolean_t insert)
 {
        efx_rc_t rc;
 
+       if (rss_context != EFX_RSS_CONTEXT_DEFAULT) {
+               rc = EINVAL;
+               goto fail1;
+       }
+
        switch (alg) {
        case EFX_RX_HASHALG_LFSR:
                EFX_RX_LFSR_HASH(enp, insert);
@@ -868,17 +880,19 @@ siena_rx_scale_mode_set(
                    type & EFX_RX_HASH_TCPIPV6,
                    rc);
                if (rc != 0)
-                       goto fail1;
+                       goto fail2;
 
                break;
 
        default:
                rc = EINVAL;
-               goto fail2;
+               goto fail3;
        }
 
        return (0);
 
+fail3:
+       EFSYS_PROBE(fail3);
 fail2:
        EFSYS_PROBE(fail2);
 fail1:
@@ -894,6 +908,7 @@ fail1:
 static __checkReturn   efx_rc_t
 siena_rx_scale_key_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  uint8_t *key,
        __in            size_t n)
 {
@@ -902,6 +917,11 @@ siena_rx_scale_key_set(
        unsigned int offset;
        efx_rc_t rc;
 
+       if (rss_context != EFX_RSS_CONTEXT_DEFAULT) {
+               rc = EINVAL;
+               goto fail1;
+       }
+
        byte = 0;
 
        /* Write Toeplitz IPv4 hash key */
@@ -922,7 +942,7 @@ siena_rx_scale_key_set(
            --offset) {
                if (oword.eo_u8[offset - 1] != key[byte++]) {
                        rc = EFAULT;
-                       goto fail1;
+                       goto fail2;
                }
        }
 
@@ -971,7 +991,7 @@ siena_rx_scale_key_set(
            --offset) {
                if (oword.eo_u8[offset - 1] != key[byte++]) {
                        rc = EFAULT;
-                       goto fail2;
+                       goto fail3;
                }
        }
 
@@ -983,7 +1003,7 @@ siena_rx_scale_key_set(
            --offset) {
                if (oword.eo_u8[offset - 1] != key[byte++]) {
                        rc = EFAULT;
-                       goto fail3;
+                       goto fail4;
                }
        }
 
@@ -995,13 +1015,15 @@ siena_rx_scale_key_set(
            --offset) {
                if (oword.eo_u8[offset - 1] != key[byte++]) {
                        rc = EFAULT;
-                       goto fail4;
+                       goto fail5;
                }
        }
 
 done:
        return (0);
 
+fail5:
+       EFSYS_PROBE(fail5);
 fail4:
        EFSYS_PROBE(fail4);
 fail3:
@@ -1019,6 +1041,7 @@ fail1:
 static __checkReturn   efx_rc_t
 siena_rx_scale_tbl_set(
        __in            efx_nic_t *enp,
+       __in            uint32_t rss_context,
        __in_ecount(n)  unsigned int *table,
        __in            size_t n)
 {
@@ -1029,11 +1052,16 @@ siena_rx_scale_tbl_set(
        EFX_STATIC_ASSERT(EFX_RSS_TBL_SIZE == FR_BZ_RX_INDIRECTION_TBL_ROWS);
        EFX_STATIC_ASSERT(EFX_MAXRSS == (1 << FRF_BZ_IT_QUEUE_WIDTH));
 
-       if (n > FR_BZ_RX_INDIRECTION_TBL_ROWS) {
+       if (rss_context != EFX_RSS_CONTEXT_DEFAULT) {
                rc = EINVAL;
                goto fail1;
        }
 
+       if (n > FR_BZ_RX_INDIRECTION_TBL_ROWS) {
+               rc = EINVAL;
+               goto fail2;
+       }
+
        for (index = 0; index < FR_BZ_RX_INDIRECTION_TBL_ROWS; index++) {
                uint32_t byte;
 
@@ -1062,12 +1090,14 @@ siena_rx_scale_tbl_set(
                /* Verify the entry */
                if (EFX_OWORD_FIELD(oword, FRF_BZ_IT_QUEUE) != byte) {
                        rc = EFAULT;
-                       goto fail2;
+                       goto fail3;
                }
        }
 
        return (0);
 
+fail3:
+       EFSYS_PROBE(fail3);
 fail2:
        EFSYS_PROBE(fail2);
 fail1:
index a206952..d988c81 100644 (file)
@@ -1270,14 +1270,17 @@ sfc_dev_rss_hash_update(struct rte_eth_dev *dev,
 
        efx_hash_types = sfc_rte_to_efx_hash_type(rss_conf->rss_hf);
 
-       rc = efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ,
+       rc = efx_rx_scale_mode_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
+                                  EFX_RX_HASHALG_TOEPLITZ,
                                   efx_hash_types, B_TRUE);
        if (rc != 0)
                goto fail_scale_mode_set;
 
        if (rss_conf->rss_key != NULL) {
                if (sa->state == SFC_ADAPTER_STARTED) {
-                       rc = efx_rx_scale_key_set(sa->nic, rss_conf->rss_key,
+                       rc = efx_rx_scale_key_set(sa->nic,
+                                                 EFX_RSS_CONTEXT_DEFAULT,
+                                                 rss_conf->rss_key,
                                                  sizeof(sa->rss_key));
                        if (rc != 0)
                                goto fail_scale_key_set;
@@ -1293,7 +1296,8 @@ sfc_dev_rss_hash_update(struct rte_eth_dev *dev,
        return 0;
 
 fail_scale_key_set:
-       if (efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ,
+       if (efx_rx_scale_mode_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
+                                 EFX_RX_HASHALG_TOEPLITZ,
                                  sa->rss_hash_types, B_TRUE) != 0)
                sfc_err(sa, "failed to restore RSS mode");
 
@@ -1389,7 +1393,8 @@ sfc_dev_rss_reta_update(struct rte_eth_dev *dev,
                }
        }
 
-       rc = efx_rx_scale_tbl_set(sa->nic, rss_tbl_new, EFX_RSS_TBL_SIZE);
+       rc = efx_rx_scale_tbl_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
+                                 rss_tbl_new, EFX_RSS_TBL_SIZE);
        if (rc == 0)
                rte_memcpy(sa->rss_tbl, rss_tbl_new, sizeof(sa->rss_tbl));
 
index db7d105..79ed046 100644 (file)
@@ -1102,18 +1102,20 @@ sfc_rx_rss_config(struct sfc_adapter *sa)
        int rc = 0;
 
        if (sa->rss_channels > 0) {
-               rc = efx_rx_scale_mode_set(sa->nic, EFX_RX_HASHALG_TOEPLITZ,
+               rc = efx_rx_scale_mode_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
+                                          EFX_RX_HASHALG_TOEPLITZ,
                                           sa->rss_hash_types, B_TRUE);
                if (rc != 0)
                        goto finish;
 
-               rc = efx_rx_scale_key_set(sa->nic, sa->rss_key,
+               rc = efx_rx_scale_key_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
+                                         sa->rss_key,
                                          sizeof(sa->rss_key));
                if (rc != 0)
                        goto finish;
 
-               rc = efx_rx_scale_tbl_set(sa->nic, sa->rss_tbl,
-                                         RTE_DIM(sa->rss_tbl));
+               rc = efx_rx_scale_tbl_set(sa->nic, EFX_RSS_CONTEXT_DEFAULT,
+                                         sa->rss_tbl, RTE_DIM(sa->rss_tbl));
        }
 
 finish: