net/mlx5: remove redundant flag in device config
[dpdk.git] / drivers / common / sfc_efx / base / efx_ev.c
index 4d11c53..4808f8d 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019-2021 Xilinx, Inc.
  * Copyright(c) 2007-2019 Solarflare Communications Inc.
  */
 
@@ -35,6 +35,7 @@ siena_ev_qcreate(
        __in            uint32_t id,
        __in            uint32_t us,
        __in            uint32_t flags,
+       __in            uint32_t irq,
        __in            efx_evq_t *eep);
 
 static                 void
@@ -109,6 +110,22 @@ static const efx_ev_ops_t  __efx_ev_ef10_ops = {
 };
 #endif /* EFX_OPTS_EF10() */
 
+#if EFSYS_OPT_RIVERHEAD
+static const efx_ev_ops_t      __efx_ev_rhead_ops = {
+       rhead_ev_init,                          /* eevo_init */
+       rhead_ev_fini,                          /* eevo_fini */
+       rhead_ev_qcreate,                       /* eevo_qcreate */
+       rhead_ev_qdestroy,                      /* eevo_qdestroy */
+       rhead_ev_qprime,                        /* eevo_qprime */
+       rhead_ev_qpost,                         /* eevo_qpost */
+       rhead_ev_qpoll,                         /* eevo_qpoll */
+       rhead_ev_qmoderate,                     /* eevo_qmoderate */
+#if EFSYS_OPT_QSTATS
+       rhead_ev_qstats_update,                 /* eevo_qstats_update */
+#endif
+};
+#endif /* EFSYS_OPT_RIVERHEAD */
+
 
        __checkReturn   efx_rc_t
 efx_ev_init(
@@ -150,6 +167,12 @@ efx_ev_init(
                break;
 #endif /* EFSYS_OPT_MEDFORD2 */
 
+#if EFSYS_OPT_RIVERHEAD
+       case EFX_FAMILY_RIVERHEAD:
+               eevop = &__efx_ev_rhead_ops;
+               break;
+#endif /* EFSYS_OPT_RIVERHEAD */
+
        default:
                EFSYS_ASSERT(0);
                rc = ENOTSUP;
@@ -179,19 +202,35 @@ fail1:
        __checkReturn   size_t
 efx_evq_size(
        __in    const efx_nic_t *enp,
-       __in    unsigned int ndescs)
+       __in    unsigned int ndescs,
+       __in    uint32_t flags)
 {
        const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       size_t desc_size;
+
+       desc_size = encp->enc_ev_desc_size;
+
+#if EFSYS_OPT_EV_EXTENDED_WIDTH
+       if (flags & EFX_EVQ_FLAGS_EXTENDED_WIDTH)
+               desc_size = encp->enc_ev_ew_desc_size;
+#else
+       EFSYS_ASSERT((flags & EFX_EVQ_FLAGS_EXTENDED_WIDTH) == 0);
+#endif
 
-       return (ndescs * encp->enc_ev_desc_size);
+       return (ndescs * desc_size);
 }
 
        __checkReturn   unsigned int
 efx_evq_nbufs(
        __in    const efx_nic_t *enp,
-       __in    unsigned int ndescs)
+       __in    unsigned int ndescs,
+       __in    uint32_t flags)
 {
-       return (EFX_DIV_ROUND_UP(efx_evq_size(enp, ndescs), EFX_BUF_SIZE));
+       size_t size;
+
+       size = efx_evq_size(enp, ndescs, flags);
+
+       return (EFX_DIV_ROUND_UP(size, EFX_BUF_SIZE));
 }
 
                void
@@ -215,7 +254,7 @@ efx_ev_fini(
 
 
        __checkReturn   efx_rc_t
-efx_ev_qcreate(
+efx_ev_qcreate_irq(
        __in            efx_nic_t *enp,
        __in            unsigned int index,
        __in            efsys_mem_t *esmp,
@@ -223,6 +262,7 @@ efx_ev_qcreate(
        __in            uint32_t id,
        __in            uint32_t us,
        __in            uint32_t flags,
+       __in            uint32_t irq,
        __deref_out     efx_evq_t **eepp)
 {
        const efx_ev_ops_t *eevop = enp->en_eevop;
@@ -260,6 +300,13 @@ efx_ev_qcreate(
                goto fail4;
        }
 
+       if ((flags & EFX_EVQ_FLAGS_EXTENDED_WIDTH) &&
+           (encp->enc_ev_ew_desc_size == 0)) {
+               /* Extended width event descriptors are not supported. */
+               rc = EINVAL;
+               goto fail5;
+       }
+
        EFSYS_ASSERT(ISP2(encp->enc_evq_max_nevs));
        EFSYS_ASSERT(ISP2(encp->enc_evq_min_nevs));
 
@@ -267,14 +314,20 @@ efx_ev_qcreate(
            ndescs < encp->enc_evq_min_nevs ||
            ndescs > encp->enc_evq_max_nevs) {
                rc = EINVAL;
-               goto fail5;
+               goto fail6;
+       }
+
+       if (EFSYS_MEM_SIZE(esmp) < (ndescs * encp->enc_ev_desc_size)) {
+               /* Buffer too small for event queue descriptors. */
+               rc = EINVAL;
+               goto fail7;
        }
 
        /* Allocate an EVQ object */
        EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (efx_evq_t), eep);
        if (eep == NULL) {
                rc = ENOMEM;
-               goto fail6;
+               goto fail8;
        }
 
        eep->ee_magic = EFX_EVQ_MAGIC;
@@ -296,17 +349,21 @@ efx_ev_qcreate(
        *eepp = eep;
 
        if ((rc = eevop->eevo_qcreate(enp, index, esmp, ndescs, id, us, flags,
-           eep)) != 0)
-               goto fail7;
+           irq, eep)) != 0)
+               goto fail9;
 
        return (0);
 
-fail7:
-       EFSYS_PROBE(fail7);
+fail9:
+       EFSYS_PROBE(fail9);
 
        *eepp = NULL;
        enp->en_ev_qcount--;
        EFSYS_KMEM_FREE(enp->en_esip, sizeof (efx_evq_t), eep);
+fail8:
+       EFSYS_PROBE(fail8);
+fail7:
+       EFSYS_PROBE(fail7);
 fail6:
        EFSYS_PROBE(fail6);
 fail5:
@@ -322,6 +379,23 @@ fail1:
        return (rc);
 }
 
+       __checkReturn   efx_rc_t
+efx_ev_qcreate(
+       __in            efx_nic_t *enp,
+       __in            unsigned int index,
+       __in            efsys_mem_t *esmp,
+       __in            size_t ndescs,
+       __in            uint32_t id,
+       __in            uint32_t us,
+       __in            uint32_t flags,
+       __deref_out     efx_evq_t **eepp)
+{
+       uint32_t irq = index;
+
+       return (efx_ev_qcreate_irq(enp, index, esmp, ndescs, id, us, flags,
+           irq, eepp));
+}
+
                void
 efx_ev_qdestroy(
        __in    efx_evq_t *eep)
@@ -401,6 +475,36 @@ efx_ev_qprefetch(
 
 #endif /* EFSYS_OPT_EV_PREFETCH */
 
+/*
+ * This method is needed to ensure that eec_initialized callback
+ * is invoked after queue creation. The callback will be invoked
+ * on Riverhead boards which have no support for INIT_DONE events
+ * and will do nothing on other boards.
+ *
+ * The client drivers must call this method after calling efx_ev_create().
+ * The call must be done with the same locks being held (if any) which are
+ * normally acquired around efx_ev_qpoll() calls to ensure that
+ * eec_initialized callback is invoked within the same locking context.
+ */
+                       void
+efx_ev_qcreate_check_init_done(
+       __in            efx_evq_t *eep,
+       __in            const efx_ev_callbacks_t *eecp,
+       __in_opt        void *arg)
+{
+       const efx_nic_cfg_t *encp;
+
+       EFSYS_ASSERT(eep != NULL);
+       EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
+       EFSYS_ASSERT(eecp != NULL);
+       EFSYS_ASSERT(eecp->eec_initialized != NULL);
+
+       encp = efx_nic_cfg_get(eep->ee_enp);
+
+       if (encp->enc_evq_init_done_ev_supported == B_FALSE)
+               (void) eecp->eec_initialized(arg);
+}
+
                        void
 efx_ev_qpoll(
        __in            efx_evq_t *eep,
@@ -1193,6 +1297,7 @@ siena_ev_qcreate(
        __in            uint32_t id,
        __in            uint32_t us,
        __in            uint32_t flags,
+       __in            uint32_t irq,
        __in            efx_evq_t *eep)
 {
        efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
@@ -1203,11 +1308,18 @@ siena_ev_qcreate(
 
        _NOTE(ARGUNUSED(esmp))
 
+       EFSYS_ASSERT((flags & EFX_EVQ_FLAGS_EXTENDED_WIDTH) == 0);
+
+       if (irq != index) {
+               rc = EINVAL;
+               goto fail1;
+       }
+
 #if EFSYS_OPT_RX_SCALE
        if (enp->en_intr.ei_type == EFX_INTR_LINE &&
            index >= EFX_MAXRSS_LEGACY) {
                rc = EINVAL;
-               goto fail1;
+               goto fail2;
        }
 #endif
        for (size = 0;
@@ -1217,7 +1329,7 @@ siena_ev_qcreate(
                        break;
        if (id + (1 << size) >= encp->enc_buftbl_limit) {
                rc = EINVAL;
-               goto fail2;
+               goto fail3;
        }
 
        /* Set up the handler table */
@@ -1249,11 +1361,13 @@ siena_ev_qcreate(
 
        return (0);
 
+fail3:
+       EFSYS_PROBE(fail3);
+#if EFSYS_OPT_RX_SCALE
 fail2:
        EFSYS_PROBE(fail2);
-#if EFSYS_OPT_RX_SCALE
-fail1:
 #endif
+fail1:
        EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
        return (rc);