net/sfc: support RSS hash offload
authorIvan Malov <ivan.malov@oktetlabs.ru>
Thu, 15 Dec 2016 12:51:18 +0000 (12:51 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:50 +0000 (19:40 +0100)
Extract RSS hash provided by the HW in the prefix and put it to mbuf.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
Reviewed-by: Robert Stonehouse <rstonehouse@solarflare.com>
doc/guides/nics/features/sfc_efx.ini
doc/guides/nics/sfc_efx.rst
drivers/net/sfc/sfc_rx.c

index e7a1143..debea27 100644 (file)
@@ -14,6 +14,7 @@ Scattered Rx         = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 Multicast MAC filter = Y
+RSS hash             = Y
 Flow control         = Y
 VLAN offload         = P
 L3 checksum offload  = Y
index 17e81dd..bc45b17 100644 (file)
@@ -71,6 +71,8 @@ SFC EFX PMD has support for:
 
 - Receive side scaling (RSS)
 
+- RSS hash
+
 - Scattered Rx DMA for packet that are larger that a single Rx descriptor
 
 - Deferred receive and transmit queue start
index 36a7d71..9b507c3 100644 (file)
@@ -185,6 +185,28 @@ sfc_rx_desc_flags_to_packet_type(const unsigned int desc_flags)
                ((desc_flags & EFX_PKT_UDP) ? RTE_PTYPE_L4_UDP : 0);
 }
 
+static void
+sfc_rx_set_rss_hash(struct sfc_rxq *rxq, unsigned int flags, struct rte_mbuf *m)
+{
+#if EFSYS_OPT_RX_SCALE
+       uint8_t *mbuf_data;
+
+
+       if ((rxq->flags & SFC_RXQ_RSS_HASH) == 0)
+               return;
+
+       mbuf_data = rte_pktmbuf_mtod(m, uint8_t *);
+
+       if (flags & (EFX_PKT_IPV4 | EFX_PKT_IPV6)) {
+               m->hash.rss = efx_pseudo_hdr_hash_get(rxq->common,
+                                                     EFX_RX_HASHALG_TOEPLITZ,
+                                                     mbuf_data);
+
+               m->ol_flags |= PKT_RX_RSS_HASH;
+       }
+#endif
+}
+
 uint16_t
 sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 {
@@ -231,7 +253,6 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                        seg_len = rxd->size - prefix_size;
                }
 
-               m->data_off += prefix_size;
                rte_pktmbuf_data_len(m) = seg_len;
                rte_pktmbuf_pkt_len(m) = seg_len;
 
@@ -261,6 +282,14 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                m->ol_flags = sfc_rx_desc_flags_to_offload_flags(desc_flags);
                m->packet_type = sfc_rx_desc_flags_to_packet_type(desc_flags);
 
+               /*
+                * Extract RSS hash from the packet prefix and
+                * set the corresponding field (if needed and possible)
+                */
+               sfc_rx_set_rss_hash(rxq, desc_flags, m);
+
+               m->data_off += prefix_size;
+
                *rx_pkts++ = m;
                done_pkts++;
                continue;