net/sfc/base: import RSS support
[dpdk.git] / drivers / net / sfc / base / efx_ev.c
index 74d146e..9f6a309 100644 (file)
@@ -351,6 +351,23 @@ efx_ev_qpending(
        return (EFX_EV_PRESENT(qword));
 }
 
+#if EFSYS_OPT_EV_PREFETCH
+
+                       void
+efx_ev_qprefetch(
+       __in            efx_evq_t *eep,
+       __in            unsigned int count)
+{
+       unsigned int offset;
+
+       EFSYS_ASSERT3U(eep->ee_magic, ==, EFX_EVQ_MAGIC);
+
+       offset = (count & eep->ee_mask) * sizeof (efx_qword_t);
+       EFSYS_MEM_PREFETCH(eep->ee_esmp, offset);
+}
+
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
 #define        EFX_EV_BATCH    8
 
                        void
@@ -403,11 +420,32 @@ efx_ev_qpoll(
                        offset += sizeof (efx_qword_t);
                }
 
+#if EFSYS_OPT_EV_PREFETCH && (EFSYS_OPT_EV_PREFETCH_PERIOD > 1)
+               /*
+                * Prefetch the next batch when we get within PREFETCH_PERIOD
+                * of a completed batch. If the batch is smaller, then prefetch
+                * immediately.
+                */
+               if (total == batch && total < EFSYS_OPT_EV_PREFETCH_PERIOD)
+                       EFSYS_MEM_PREFETCH(eep->ee_esmp, offset);
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
                /* Process the batch of events */
                for (index = 0; index < total; ++index) {
                        boolean_t should_abort;
                        uint32_t code;
 
+#if EFSYS_OPT_EV_PREFETCH
+                       /* Prefetch if we've now reached the batch period */
+                       if (total == batch &&
+                           index + EFSYS_OPT_EV_PREFETCH_PERIOD == total) {
+                               offset = (count + batch) & eep->ee_mask;
+                               offset *= sizeof (efx_qword_t);
+
+                               EFSYS_MEM_PREFETCH(eep->ee_esmp, offset);
+                       }
+#endif /* EFSYS_OPT_EV_PREFETCH */
+
                        EFX_EV_QSTAT_INCR(eep, EV_ALL);
 
                        code = EFX_QWORD_FIELD(ev[index], FSF_AZ_EV_CODE);
@@ -608,6 +646,22 @@ siena_ev_rx_not_ok(
                EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
                (*flagsp) |= EFX_DISCARD;
 
+#if EFSYS_OPT_RX_SCATTER
+               /*
+                * Lookout for payload queue ran dry errors and ignore them.
+                *
+                * Sadly for the header/data split cases, the descriptor
+                * pointer in this event refers to the header queue and
+                * therefore cannot be easily detected as duplicate.
+                * So we drop these and rely on the receive processing seeing
+                * a subsequent packet with FSF_AZ_RX_EV_SOP set to discard
+                * the partially received packet.
+                */
+               if ((EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_SOP) == 0) &&
+                   (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_JUMBO_CONT) == 0) &&
+                   (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_BYTE_CNT) == 0))
+                       ignore = B_TRUE;
+#endif /* EFSYS_OPT_RX_SCATTER */
        }
 
        if (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_ETH_CRC_ERR) != 0) {
@@ -667,6 +721,10 @@ siena_ev_rx(
        uint32_t size;
        uint32_t label;
        boolean_t ok;
+#if EFSYS_OPT_RX_SCATTER
+       boolean_t sop;
+       boolean_t jumbo_cont;
+#endif /* EFSYS_OPT_RX_SCATTER */
        uint32_t hdr_type;
        boolean_t is_v6;
        uint16_t flags;
@@ -681,6 +739,11 @@ siena_ev_rx(
        label = EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_Q_LABEL);
        ok = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_PKT_OK) != 0);
 
+#if EFSYS_OPT_RX_SCATTER
+       sop = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_SOP) != 0);
+       jumbo_cont = (EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_JUMBO_CONT) != 0);
+#endif /* EFSYS_OPT_RX_SCATTER */
+
        hdr_type = EFX_QWORD_FIELD(*eqp, FSF_AZ_RX_EV_HDR_TYPE);
 
        is_v6 = (EFX_QWORD_FIELD(*eqp, FSF_CZ_RX_EV_IPV6_PKT) != 0);
@@ -733,6 +796,14 @@ siena_ev_rx(
                break;
        }
 
+#if EFSYS_OPT_RX_SCATTER
+       /* Report scatter and header/lookahead split buffer flags */
+       if (sop)
+               flags |= EFX_PKT_START;
+       if (jumbo_cont)
+               flags |= EFX_PKT_CONT;
+#endif /* EFSYS_OPT_RX_SCATTER */
+
        /* Detect errors included in the FSF_AZ_RX_EV_PKT_OK indication */
        if (!ok) {
                ignore = siena_ev_rx_not_ok(eep, eqp, label, id, &flags);
@@ -1214,6 +1285,13 @@ siena_ev_qcreate(
                rc = EINVAL;
                goto fail2;
        }
+#if EFSYS_OPT_RX_SCALE
+       if (enp->en_intr.ei_type == EFX_INTR_LINE &&
+           index >= EFX_MAXRSS_LEGACY) {
+               rc = EINVAL;
+               goto fail3;
+       }
+#endif
        for (size = 0; (1 << size) <= (EFX_EVQ_MAXNEVS / EFX_EVQ_MINNEVS);
            size++)
                if ((1 << size) == (int)(n / EFX_EVQ_MINNEVS))
@@ -1254,6 +1332,10 @@ siena_ev_qcreate(
 
 fail4:
        EFSYS_PROBE(fail4);
+#if EFSYS_OPT_RX_SCALE
+fail3:
+       EFSYS_PROBE(fail3);
+#endif
 fail2:
        EFSYS_PROBE(fail2);
 fail1: