net/sfc/base: provide a flag for controlling CTPIO mode
[dpdk.git] / drivers / net / sfc / base / efx_rx.c
index f922b59..ae79584 100644 (file)
@@ -1,31 +1,7 @@
-/*
- * Copyright (c) 2007-2016 Solarflare Communications Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
+/* SPDX-License-Identifier: BSD-3-Clause
  *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are
- * those of the authors and should not be interpreted as representing official
- * policies, either expressed or implied, of the FreeBSD Project.
+ * Copyright (c) 2007-2018 Solarflare Communications Inc.
+ * All rights reserved.
  */
 
 #include "efx.h"
@@ -131,9 +107,11 @@ 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,
+       __in            unsigned int flags,
        __in            efx_evq_t *eep,
        __in            efx_rxq_t *erp);
 
@@ -173,7 +151,7 @@ static const efx_rx_ops_t __efx_rx_siena_ops = {
 };
 #endif /* EFSYS_OPT_SIENA */
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
 static const efx_rx_ops_t __efx_rx_ef10_ops = {
        ef10_rx_init,                           /* erxo_init */
        ef10_rx_fini,                           /* erxo_fini */
@@ -200,7 +178,7 @@ static const efx_rx_ops_t __efx_rx_ef10_ops = {
        ef10_rx_qcreate,                        /* erxo_qcreate */
        ef10_rx_qdestroy,                       /* erxo_qdestroy */
 };
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD */
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
 
 
        __checkReturn   efx_rc_t
@@ -242,6 +220,12 @@ efx_rx_init(
                break;
 #endif /* EFSYS_OPT_MEDFORD */
 
+#if EFSYS_OPT_MEDFORD2
+       case EFX_FAMILY_MEDFORD2:
+               erxop = &__efx_rx_ef10_ops;
+               break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
        default:
                EFSYS_ASSERT(0);
                rc = ENOTSUP;
@@ -610,15 +594,17 @@ 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,
+       __in            unsigned int flags,
        __in            efx_evq_t *eep,
        __deref_out     efx_rxq_t **erpp)
 {
@@ -643,8 +629,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,
-           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++;
@@ -662,6 +648,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)
@@ -1303,19 +1326,22 @@ 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,
+       __in            unsigned int flags,
        __in            efx_evq_t *eep,
        __in            efx_rxq_t *erp)
 {
        efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
        efx_oword_t oword;
        uint32_t size;
-       boolean_t jumbo;
+       boolean_t jumbo = B_FALSE;
        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));
@@ -1345,20 +1371,22 @@ siena_rx_qcreate(
 
        switch (type) {
        case EFX_RXQ_TYPE_DEFAULT:
-               jumbo = B_FALSE;
                break;
 
-#if EFSYS_OPT_RX_SCATTER
-       case EFX_RXQ_TYPE_SCATTER:
-               jumbo = B_TRUE;
-               break;
-#endif /* EFSYS_OPT_RX_SCATTER */
-
        default:
                rc = EINVAL;
                goto fail4;
        }
 
+       if (flags & EFX_RXQ_FLAG_SCATTER) {
+#if EFSYS_OPT_RX_SCATTER
+               jumbo = B_TRUE;
+#else
+               rc = EINVAL;
+               goto fail5;
+#endif /* EFSYS_OPT_RX_SCATTER */
+       }
+
        /* Set up the new descriptor queue */
        EFX_POPULATE_OWORD_7(oword,
            FRF_AZ_RX_DESCQ_BUF_BASE_ID, id,
@@ -1374,6 +1402,10 @@ siena_rx_qcreate(
 
        return (0);
 
+#if !EFSYS_OPT_RX_SCATTER
+fail5:
+       EFSYS_PROBE(fail5);
+#endif
 fail4:
        EFSYS_PROBE(fail4);
 fail3: