net/sfc: support user mark and flag Rx for EF100
authorAndrew Rybchenko <arybchenko@solarflare.com>
Tue, 13 Oct 2020 13:45:50 +0000 (14:45 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 16 Oct 2020 17:48:18 +0000 (19:48 +0200)
Flow rules may be used mark packets. Support delivery of mark/flag
values to user in mbuf fields.

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/sfc_ef100_rx.c

index 6fb78b6..0623f6e 100644 (file)
@@ -57,6 +57,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_NOT_RUNNING      0x2
 #define SFC_EF100_RXQ_EXCEPTION                0x4
 #define SFC_EF100_RXQ_RSS_HASH         0x10
+#define SFC_EF100_RXQ_USER_MARK                0x20
        unsigned int                    ptr_mask;
        unsigned int                    evq_phase_bit_shift;
        unsigned int                    ready_pkts;
@@ -351,8 +352,10 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 
                SFC_EF100_RX_PREFIX_FIELD(LENGTH, B_FALSE),
                SFC_EF100_RX_PREFIX_FIELD(RSS_HASH_VALID, B_FALSE),
+               SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
                SFC_EF100_RX_PREFIX_FIELD(CLASS, B_FALSE),
                SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
+               SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
 
 #undef SFC_EF100_RX_PREFIX_FIELD
        }
@@ -388,6 +391,14 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
                                              ESF_GZ_RX_PREFIX_RSS_HASH);
        }
 
+       if ((rxq->flags & SFC_EF100_RXQ_USER_MARK) &&
+           EFX_TEST_OWORD_BIT(rx_prefix[0], ESF_GZ_RX_PREFIX_USER_FLAG_LBN)) {
+               ol_flags |= PKT_RX_FDIR_ID;
+               /* EFX_OWORD_FIELD converts little-endian to CPU */
+               m->hash.fdir.hi = EFX_OWORD_FIELD(rx_prefix[0],
+                                                 ESF_GZ_RX_PREFIX_USER_MARK);
+       }
+
        m->ol_flags = ol_flags;
        return true;
 }
@@ -760,6 +771,13 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
        else
                rxq->flags &= ~SFC_EF100_RXQ_RSS_HASH;
 
+       if ((unsup_rx_prefix_fields &
+            ((1U << EFX_RX_PREFIX_FIELD_USER_FLAG) |
+             (1U << EFX_RX_PREFIX_FIELD_USER_MARK))) == 0)
+               rxq->flags |= SFC_EF100_RXQ_USER_MARK;
+       else
+               rxq->flags &= ~SFC_EF100_RXQ_USER_MARK;
+
        rxq->prefix_size = pinfo->erpl_length;
        rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
                                                       rxq->prefix_size);