net/sfc/base: add function to create packed stream RxQ
authorAndrew Rybchenko <arybchenko@solarflare.com>
Sun, 24 Dec 2017 10:46:36 +0000 (10:46 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
Encoding packed stream buffer size in RxQ type is not a future-proof
idea taking into account a new RxQ types with extra parameters.
To be consistent make packet stream buffer size a separate parameter.
In order to avoid blowing of the default RxQ create function prototype
add a dedicated function to create packed stream RxQ without not
applicable paramters.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
Reviewed-by: Mark Spender <mspender@solarflare.com>
drivers/net/sfc/base/ef10_ev.c
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

index ee576a0..80257da 100644 (file)
@@ -1347,8 +1347,7 @@ ef10_ev_rxlabel_init(
 {
        efx_evq_rxq_state_t *eersp;
 #if EFSYS_OPT_RX_PACKED_STREAM
-       boolean_t packed_stream = (type >= EFX_RXQ_TYPE_PACKED_STREAM_1M) &&
-           (type <= EFX_RXQ_TYPE_PACKED_STREAM_64K);
+       boolean_t packed_stream = (type == EFX_RXQ_TYPE_PACKED_STREAM);
 #endif
 
        _NOTE(ARGUNUSED(type))
index 0eeb68f..a17b471 100644 (file)
@@ -977,6 +977,7 @@ ef10_rx_qcreate(
        __in            unsigned int index,
        __in            unsigned int label,
        __in            efx_rxq_type_t type,
+       __in            uint32_t type_data,
        __in            efsys_mem_t *esmp,
        __in            size_t ndescs,
        __in            uint32_t id,
index 9aa8981..17b1652 100644 (file)
@@ -948,6 +948,7 @@ ef10_rx_qcreate(
        __in            unsigned int index,
        __in            unsigned int label,
        __in            efx_rxq_type_t type,
+       __in            uint32_t type_data,
        __in            efsys_mem_t *esmp,
        __in            size_t ndescs,
        __in            uint32_t id,
@@ -984,25 +985,32 @@ ef10_rx_qcreate(
                ps_buf_size = 0;
                break;
 #if EFSYS_OPT_RX_PACKED_STREAM
-       case EFX_RXQ_TYPE_PACKED_STREAM_1M:
-               ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_1M;
-               break;
-       case EFX_RXQ_TYPE_PACKED_STREAM_512K:
-               ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_512K;
-               break;
-       case EFX_RXQ_TYPE_PACKED_STREAM_256K:
-               ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_256K;
-               break;
-       case EFX_RXQ_TYPE_PACKED_STREAM_128K:
-               ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_128K;
-               break;
-       case EFX_RXQ_TYPE_PACKED_STREAM_64K:
-               ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_64K;
+       case EFX_RXQ_TYPE_PACKED_STREAM:
+               switch (type_data) {
+               case EFX_RXQ_PACKED_STREAM_BUF_SIZE_1M:
+                       ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_1M;
+                       break;
+               case EFX_RXQ_PACKED_STREAM_BUF_SIZE_512K:
+                       ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_512K;
+                       break;
+               case EFX_RXQ_PACKED_STREAM_BUF_SIZE_256K:
+                       ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_256K;
+                       break;
+               case EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K:
+                       ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_128K;
+                       break;
+               case EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K:
+                       ps_buf_size = MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_64K;
+                       break;
+               default:
+                       rc = ENOTSUP;
+                       goto fail3;
+               }
                break;
 #endif /* EFSYS_OPT_RX_PACKED_STREAM */
        default:
                rc = ENOTSUP;
-               goto fail3;
+               goto fail4;
        }
 
 #if EFSYS_OPT_RX_PACKED_STREAM
@@ -1010,13 +1018,13 @@ ef10_rx_qcreate(
                /* Check if datapath firmware supports packed stream mode */
                if (encp->enc_rx_packed_stream_supported == B_FALSE) {
                        rc = ENOTSUP;
-                       goto fail4;
+                       goto fail5;
                }
                /* Check if packed stream allows configurable buffer sizes */
-               if ((type != EFX_RXQ_TYPE_PACKED_STREAM_1M) &&
+               if ((ps_buf_size != MC_CMD_INIT_RXQ_EXT_IN_PS_BUFF_1M) &&
                    (encp->enc_rx_var_packed_stream_supported == B_FALSE)) {
                        rc = ENOTSUP;
-                       goto fail5;
+                       goto fail6;
                }
        }
 #else /* EFSYS_OPT_RX_PACKED_STREAM */
@@ -1031,7 +1039,7 @@ ef10_rx_qcreate(
 
        if ((rc = efx_mcdi_init_rxq(enp, ndescs, eep->ee_index, label, index,
                    esmp, disable_scatter, ps_buf_size)) != 0)
-               goto fail6;
+               goto fail7;
 
        erp->er_eep = eep;
        erp->er_label = label;
@@ -1042,16 +1050,20 @@ ef10_rx_qcreate(
 
        return (0);
 
+fail7:
+       EFSYS_PROBE(fail7);
+#if EFSYS_OPT_RX_PACKED_STREAM
 fail6:
        EFSYS_PROBE(fail6);
-#if EFSYS_OPT_RX_PACKED_STREAM
 fail5:
        EFSYS_PROBE(fail5);
+#endif /* EFSYS_OPT_RX_PACKED_STREAM */
 fail4:
        EFSYS_PROBE(fail4);
-#endif /* EFSYS_OPT_RX_PACKED_STREAM */
+#if EFSYS_OPT_RX_PACKED_STREAM
 fail3:
        EFSYS_PROBE(fail3);
+#endif /* EFSYS_OPT_RX_PACKED_STREAM */
 fail2:
        EFSYS_PROBE(fail2);
 fail1:
index e0dc76c..d4e0bc5 100644 (file)
@@ -2002,11 +2002,7 @@ efx_pseudo_hdr_pkt_length_get(
 
 typedef enum efx_rxq_type_e {
        EFX_RXQ_TYPE_DEFAULT,
-       EFX_RXQ_TYPE_PACKED_STREAM_1M,
-       EFX_RXQ_TYPE_PACKED_STREAM_512K,
-       EFX_RXQ_TYPE_PACKED_STREAM_256K,
-       EFX_RXQ_TYPE_PACKED_STREAM_128K,
-       EFX_RXQ_TYPE_PACKED_STREAM_64K,
+       EFX_RXQ_TYPE_PACKED_STREAM,
        EFX_RXQ_NTYPES
 } efx_rxq_type_t;
 
@@ -2030,6 +2026,27 @@ efx_rx_qcreate(
        __in            efx_evq_t *eep,
        __deref_out     efx_rxq_t **erpp);
 
+#if EFSYS_OPT_RX_PACKED_STREAM
+
+#define        EFX_RXQ_PACKED_STREAM_BUF_SIZE_1M       (1U * 1024 * 1024)
+#define        EFX_RXQ_PACKED_STREAM_BUF_SIZE_512K     (512U * 1024)
+#define        EFX_RXQ_PACKED_STREAM_BUF_SIZE_256K     (256U * 1024)
+#define        EFX_RXQ_PACKED_STREAM_BUF_SIZE_128K     (128U * 1024)
+#define        EFX_RXQ_PACKED_STREAM_BUF_SIZE_64K      (64U * 1024)
+
+extern __checkReturn   efx_rc_t
+efx_rx_qcreate_packed_stream(
+       __in            efx_nic_t *enp,
+       __in            unsigned int index,
+       __in            unsigned int label,
+       __in            uint32_t ps_buf_size,
+       __in            efsys_mem_t *esmp,
+       __in            size_t ndescs,
+       __in            efx_evq_t *eep,
+       __deref_out     efx_rxq_t **erpp);
+
+#endif
+
 typedef struct efx_buffer_s {
        efsys_dma_addr_t        eb_addr;
        size_t                  eb_size;
index 8bd667c..16e5c20 100644 (file)
@@ -181,7 +181,7 @@ typedef struct efx_rx_ops_s {
        efx_rc_t        (*erxo_qflush)(efx_rxq_t *);
        void            (*erxo_qenable)(efx_rxq_t *);
        efx_rc_t        (*erxo_qcreate)(efx_nic_t *enp, unsigned int,
-                                       unsigned int, efx_rxq_type_t,
+                                       unsigned int, efx_rxq_type_t, uint32_t,
                                        efsys_mem_t *, size_t, uint32_t,
                                        unsigned int,
                                        efx_evq_t *, efx_rxq_t *);
index 870d42f..d0dd605 100644 (file)
@@ -131,6 +131,7 @@ siena_rx_qcreate(
        __in            unsigned int index,
        __in            unsigned int label,
        __in            efx_rxq_type_t type,
+       __in            uint32_t type_data,
        __in            efsys_mem_t *esmp,
        __in            size_t ndescs,
        __in            uint32_t id,
@@ -611,12 +612,13 @@ efx_rx_qenable(
        erxop->erxo_qenable(erp);
 }
 
-       __checkReturn   efx_rc_t
-efx_rx_qcreate(
+static __checkReturn   efx_rc_t
+efx_rx_qcreate_internal(
        __in            efx_nic_t *enp,
        __in            unsigned int index,
        __in            unsigned int label,
        __in            efx_rxq_type_t type,
+       __in            uint32_t type_data,
        __in            efsys_mem_t *esmp,
        __in            size_t ndescs,
        __in            uint32_t id,
@@ -645,8 +647,8 @@ efx_rx_qcreate(
        erp->er_mask = ndescs - 1;
        erp->er_esmp = esmp;
 
-       if ((rc = erxop->erxo_qcreate(enp, index, label, type, esmp, ndescs, id,
-           flags, eep, erp)) != 0)
+       if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp,
+           ndescs, id, flags, eep, erp)) != 0)
                goto fail2;
 
        enp->en_rx_qcount++;
@@ -664,6 +666,43 @@ fail1:
        return (rc);
 }
 
+       __checkReturn   efx_rc_t
+efx_rx_qcreate(
+       __in            efx_nic_t *enp,
+       __in            unsigned int index,
+       __in            unsigned int label,
+       __in            efx_rxq_type_t type,
+       __in            efsys_mem_t *esmp,
+       __in            size_t ndescs,
+       __in            uint32_t id,
+       __in            unsigned int flags,
+       __in            efx_evq_t *eep,
+       __deref_out     efx_rxq_t **erpp)
+{
+       return efx_rx_qcreate_internal(enp, index, label, type, 0, esmp, ndescs,
+           id, flags, eep, erpp);
+}
+
+#if EFSYS_OPT_RX_PACKED_STREAM
+
+       __checkReturn   efx_rc_t
+efx_rx_qcreate_packed_stream(
+       __in            efx_nic_t *enp,
+       __in            unsigned int index,
+       __in            unsigned int label,
+       __in            uint32_t ps_buf_size,
+       __in            efsys_mem_t *esmp,
+       __in            size_t ndescs,
+       __in            efx_evq_t *eep,
+       __deref_out     efx_rxq_t **erpp)
+{
+       return efx_rx_qcreate_internal(enp, index, label,
+           EFX_RXQ_TYPE_PACKED_STREAM, ps_buf_size, esmp, ndescs,
+           0 /* id unused on EF10 */, EFX_RXQ_FLAG_NONE, eep, erpp);
+}
+
+#endif
+
                        void
 efx_rx_qdestroy(
        __in            efx_rxq_t *erp)
@@ -1305,6 +1344,7 @@ siena_rx_qcreate(
        __in            unsigned int index,
        __in            unsigned int label,
        __in            efx_rxq_type_t type,
+       __in            uint32_t type_data,
        __in            efsys_mem_t *esmp,
        __in            size_t ndescs,
        __in            uint32_t id,
@@ -1319,6 +1359,7 @@ siena_rx_qcreate(
        efx_rc_t rc;
 
        _NOTE(ARGUNUSED(esmp))
+       _NOTE(ARGUNUSED(type_data))
 
        EFX_STATIC_ASSERT(EFX_EV_RX_NLABELS ==
            (1 << FRF_AZ_RX_DESCQ_LABEL_WIDTH));