common/sfc_efx/base: separate target EvQ and IRQ config
[dpdk.git] / drivers / common / sfc_efx / base / ef10_ev.c
index 08729cf..c0cbc42 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) 2012-2019 Solarflare Communications Inc.
  */
 
@@ -47,13 +47,6 @@ ef10_ev_drv_gen(
        __in            const efx_ev_callbacks_t *eecp,
        __in_opt        void *arg);
 
-static __checkReturn   boolean_t
-ef10_ev_mcdi(
-       __in            efx_evq_t *eep,
-       __in            efx_qword_t *eqp,
-       __in            const efx_ev_callbacks_t *eecp,
-       __in_opt        void *arg);
-
 
 static __checkReturn   efx_rc_t
 efx_mcdi_set_evq_tmr(
@@ -128,20 +121,14 @@ ef10_ev_qcreate(
        __in            efx_evq_t *eep)
 {
        efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
-       uint32_t irq;
+       uint32_t irq = 0;
+       uint32_t target_evq = 0;
        efx_rc_t rc;
+       boolean_t low_latency;
 
        _NOTE(ARGUNUSED(id))    /* buftbl id managed by MC */
 
-       if (index >= encp->enc_evq_limit) {
-               rc = EINVAL;
-               goto fail1;
-       }
-
-       if (us > encp->enc_evq_timer_max_us) {
-               rc = EINVAL;
-               goto fail2;
-       }
+       EFSYS_ASSERT((flags & EFX_EVQ_FLAGS_EXTENDED_WIDTH) == 0);
 
        /*
         * NO_CONT_EV mode is only requested from the firmware when creating
@@ -156,7 +143,7 @@ ef10_ev_qcreate(
        if (flags & EFX_EVQ_FLAGS_NO_CONT_EV) {
                if (enp->en_nic_cfg.enc_no_cont_ev_mode_supported == B_FALSE) {
                        rc = EINVAL;
-                       goto fail3;
+                       goto fail1;
                }
        }
 
@@ -173,11 +160,12 @@ ef10_ev_qcreate(
            EFX_EVQ_FLAGS_NOTIFY_INTERRUPT) {
                irq = index;
        } else if (index == EFX_EF10_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_EF10_ALWAYS_INTERRUPTING_EVQ_INDEX;
+               target_evq = EFX_EF10_ALWAYS_INTERRUPTING_EVQ_INDEX;
        }
 
        /*
@@ -185,46 +173,29 @@ ef10_ev_qcreate(
         * created. See bug58606.
         */
 
-       if (encp->enc_init_evq_v2_supported) {
-               /*
-                * On Medford the low latency license is required to enable RX
-                * and event cut through and to disable RX batching.  If event
-                * queue type in flags is auto, we let the firmware decide the
-                * settings to use. If the adapter has a low latency license,
-                * it will choose the best settings for low latency, otherwise
-                * it will choose the best settings for throughput.
-                */
-               rc = efx_mcdi_init_evq_v2(enp, index, esmp, ndescs, irq, us,
-                   flags);
-               if (rc != 0)
-                       goto fail4;
-       } else {
-               /*
-                * On Huntington we need to specify the settings to use.
-                * If event queue type in flags is auto, we favour throughput
-                * if the adapter is running virtualization supporting firmware
-                * (i.e. the full featured firmware variant)
-                * and latency otherwise. The Ethernet Virtual Bridging
-                * capability is used to make this decision. (Note though that
-                * the low latency firmware variant is also best for
-                * throughput and corresponding type should be specified
-                * to choose it.)
-                */
-               boolean_t low_latency = encp->enc_datapath_cap_evb ? 0 : 1;
-               rc = efx_mcdi_init_evq(enp, index, esmp, ndescs, irq, us, flags,
-                   low_latency);
-               if (rc != 0)
-                       goto fail5;
-       }
+       /*
+        * On Huntington we need to specify the settings to use.
+        * If event queue type in flags is auto, we favour throughput
+        * if the adapter is running virtualization supporting firmware
+        * (i.e. the full featured firmware variant)
+        * and latency otherwise. The Ethernet Virtual Bridging
+        * capability is used to make this decision. (Note though that
+        * the low latency firmware variant is also best for
+        * throughput and corresponding type should be specified
+        * to choose it.)
+        *
+        * If FW supports EvQ types (e.g. on Medford and Medford2) the
+        * type which is specified in flags is passed to FW to make the
+        * decision and low_latency hint is ignored.
+        */
+       low_latency = encp->enc_datapath_cap_evb ? 0 : 1;
+       rc = efx_mcdi_init_evq(enp, index, esmp, ndescs, irq, target_evq, us,
+           flags, low_latency);
+       if (rc != 0)
+               goto fail2;
 
        return (0);
 
-fail5:
-       EFSYS_PROBE(fail5);
-fail4:
-       EFSYS_PROBE(fail4);
-fail3:
-       EFSYS_PROBE(fail3);
 fail2:
        EFSYS_PROBE(fail2);
 fail1:
@@ -883,7 +854,11 @@ ef10_ev_drv_gen(
        return (should_abort);
 }
 
-static __checkReturn   boolean_t
+#endif /* EFX_OPTS_EF10() */
+
+#if EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10()
+
+       __checkReturn   boolean_t
 ef10_ev_mcdi(
        __in            efx_evq_t *eep,
        __in            efx_qword_t *eqp,
@@ -1090,6 +1065,10 @@ ef10_ev_mcdi(
        return (should_abort);
 }
 
+#endif /* EFSYS_OPT_RIVERHEAD || EFX_OPTS_EF10() */
+
+#if EFX_OPTS_EF10()
+
                void
 ef10_ev_rxlabel_init(
        __in            efx_evq_t *eep,