common/sfc_efx/base: add API to get mport selector by ID
[dpdk.git] / drivers / common / sfc_efx / base / rhead_ev.c
index 5bda315..3eaed9e 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) 2018-2019 Solarflare Communications Inc.
  */
 
@@ -58,6 +58,22 @@ rhead_ev_ew_qpoll(
        __inout         unsigned int *countp,
        __in            const efx_ev_callbacks_t *eecp,
        __in_opt        void *arg);
+
+#if EFSYS_OPT_DESC_PROXY
+static                 boolean_t
+rhead_ev_ew_txq_desc(
+       __in            efx_evq_t *eep,
+       __in            efx_xword_t *eventp,
+       __in            const efx_ev_callbacks_t *eecp,
+       __in_opt        void *arg);
+
+static                 boolean_t
+rhead_ev_ew_virtq_desc(
+       __in            efx_evq_t *eep,
+       __in            efx_xword_t *eventp,
+       __in            const efx_ev_callbacks_t *eecp,
+       __in_opt        void *arg);
+#endif /* EFSYS_OPT_DESC_PROXY */
 #endif /* EFSYS_OPT_EV_EXTENDED_WIDTH */
 
 
@@ -86,11 +102,12 @@ rhead_ev_qcreate(
        __in            uint32_t id,
        __in            uint32_t us,
        __in            uint32_t flags,
+       __in            uint32_t irq,
        __in            efx_evq_t *eep)
 {
        const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
        size_t desc_size;
-       uint32_t irq;
+       uint32_t target_evq = 0;
        efx_rc_t rc;
 
        _NOTE(ARGUNUSED(id))    /* buftbl id managed by MC */
@@ -115,25 +132,31 @@ rhead_ev_qcreate(
        eep->ee_drv_gen = NULL; /* FIXME */
        eep->ee_mcdi    = rhead_ev_mcdi;
 
+#if EFSYS_OPT_DESC_PROXY
+       eep->ee_ew_txq_desc     = rhead_ev_ew_txq_desc;
+       eep->ee_ew_virtq_desc   = rhead_ev_ew_virtq_desc;
+#endif /* EFSYS_OPT_DESC_PROXY */
+
        /* Set up the event queue */
        /* INIT_EVQ expects function-relative vector number */
        if ((flags & EFX_EVQ_FLAGS_NOTIFY_MASK) ==
            EFX_EVQ_FLAGS_NOTIFY_INTERRUPT) {
-               irq = index;
+               /* IRQ number is specified by caller */
        } else if (index == EFX_RHEAD_ALWAYS_INTERRUPTING_EVQ_INDEX) {
-               irq = index;
+               /* Use the first interrupt for always interrupting EvQ */
+               irq = 0;
                flags = (flags & ~EFX_EVQ_FLAGS_NOTIFY_MASK) |
                    EFX_EVQ_FLAGS_NOTIFY_INTERRUPT;
        } else {
-               irq = EFX_RHEAD_ALWAYS_INTERRUPTING_EVQ_INDEX;
+               target_evq = EFX_RHEAD_ALWAYS_INTERRUPTING_EVQ_INDEX;
        }
 
        /*
         * Interrupts may be raised for events immediately after the queue is
         * created. See bug58606.
         */
-       rc = efx_mcdi_init_evq(enp, index, esmp, ndescs, irq, us, flags,
-           B_FALSE);
+       rc = efx_mcdi_init_evq(enp, index, esmp, ndescs, irq, target_evq, us,
+           flags, B_FALSE);
        if (rc != 0)
                goto fail2;
 
@@ -345,6 +368,16 @@ rhead_ev_ew_dispatch(
                    rhead_ev_dispatch(eep, &eventp->ex_qword[0], eecp, arg);
                break;
 
+#if EFSYS_OPT_DESC_PROXY
+       case ESE_GZ_EF100_EVEW_TXQ_DESC:
+               should_abort = eep->ee_ew_txq_desc(eep, eventp, eecp, arg);
+               break;
+
+       case ESE_GZ_EF100_EVEW_VIRTQ_DESC:
+               should_abort = eep->ee_ew_virtq_desc(eep, eventp, eecp, arg);
+               break;
+#endif /* EFSYS_OPT_DESC_PROXY */
+
        default:
                /* Omit currently unused reserved bits from the probe. */
                EFSYS_PROBE7(ew_bad_event, unsigned int, eep->ee_index,
@@ -589,4 +622,68 @@ rhead_ev_mcdi(
        return (ret);
 }
 
+#if EFSYS_OPT_DESC_PROXY
+static                 boolean_t
+rhead_ev_ew_txq_desc(
+       __in            efx_evq_t *eep,
+       __in            efx_xword_t *eventp,
+       __in            const efx_ev_callbacks_t *eecp,
+       __in_opt        void *arg)
+{
+       efx_oword_t txq_desc;
+       uint16_t vi_id;
+       boolean_t should_abort;
+
+       _NOTE(ARGUNUSED(eep))
+
+       vi_id = EFX_XWORD_FIELD(*eventp, ESF_GZ_EV_TXQ_DP_VI_ID);
+
+       /*
+        * NOTE: This is the raw descriptor data, and has not been converted
+        * to host endian. The handler callback must use the EFX_OWORD macros
+        * to extract the descriptor fields as host endian values.
+        */
+       txq_desc = eventp->ex_oword[0];
+
+       EFSYS_ASSERT(eecp->eec_desc_proxy_txq_desc != NULL);
+       should_abort = eecp->eec_desc_proxy_txq_desc(arg, vi_id, txq_desc);
+
+       return (should_abort);
+}
+#endif /* EFSYS_OPT_DESC_PROXY */
+
+
+#if EFSYS_OPT_DESC_PROXY
+static                 boolean_t
+rhead_ev_ew_virtq_desc(
+       __in            efx_evq_t *eep,
+       __in            efx_xword_t *eventp,
+       __in            const efx_ev_callbacks_t *eecp,
+       __in_opt        void *arg)
+{
+       efx_oword_t virtq_desc;
+       uint16_t vi_id;
+       uint16_t avail;
+       boolean_t should_abort;
+
+       _NOTE(ARGUNUSED(eep))
+
+       vi_id = EFX_XWORD_FIELD(*eventp, ESF_GZ_EV_VQ_DP_VI_ID);
+       avail = EFX_XWORD_FIELD(*eventp, ESF_GZ_EV_VQ_DP_AVAIL_ENTRY);
+
+       /*
+        * NOTE: This is the raw descriptor data, and has not been converted
+        * to host endian. The handler callback must use the EFX_OWORD macros
+        * to extract the descriptor fields as host endian values.
+        */
+       virtq_desc = eventp->ex_oword[0];
+
+       EFSYS_ASSERT(eecp->eec_desc_proxy_virtq_desc != NULL);
+       should_abort =
+           eecp->eec_desc_proxy_virtq_desc(arg, vi_id, avail, virtq_desc);
+
+       return (should_abort);
+}
+#endif /* EFSYS_OPT_DESC_PROXY */
+
 #endif /* EFSYS_OPT_RIVERHEAD */