net/sfc: support scattered Rx DMA
authorAndrew Rybchenko <arybchenko@solarflare.com>
Thu, 15 Dec 2016 12:51:10 +0000 (12:51 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:50 +0000 (19:40 +0100)
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_ethdev.c
drivers/net/sfc/sfc_rx.c

index b5887d5..74cc942 100644 (file)
@@ -9,6 +9,7 @@ Link status          = Y
 Link status event    = Y
 MTU update           = Y
 Jumbo frame          = Y
+Scattered Rx         = Y
 Promiscuous mode     = Y
 Allmulticast mode    = Y
 Multicast MAC filter = Y
index 1333f8b..2e30dfe 100644 (file)
@@ -69,6 +69,8 @@ SFC EFX PMD has support for:
 
 - Received packet type information
 
+- Scattered Rx DMA for packet that are larger that a single Rx descriptor
+
 
 Non-supported Features
 ----------------------
@@ -89,8 +91,6 @@ The features not yet supported include:
 
 - VLAN stripping
 
-- Scattered receive
-
 - LRO
 
 
index 8c845e9..f3ab8bd 100644 (file)
@@ -839,6 +839,7 @@ sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
        qinfo->mp = rxq->refill_mb_pool;
        qinfo->conf.rx_free_thresh = rxq->refill_threshold;
        qinfo->conf.rx_drop_en = 1;
+       qinfo->scattered_rx = (rxq_info->type == EFX_RXQ_TYPE_SCATTER);
        qinfo->nb_desc = rxq_info->entries;
 
        sfc_adapter_unlock(sa);
index 802beb2..2909ec0 100644 (file)
@@ -193,6 +193,7 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
        unsigned int prefix_size = rxq->prefix_size;
        unsigned int done_pkts = 0;
        boolean_t discard_next = B_FALSE;
+       struct rte_mbuf *scatter_pkt = NULL;
 
        if (unlikely((rxq->state & SFC_RXQ_RUNNING) == 0))
                return 0;
@@ -218,9 +219,6 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                if (desc_flags & (EFX_ADDR_MISMATCH | EFX_DISCARD))
                        goto discard;
 
-               if (desc_flags & EFX_PKT_CONT)
-                       goto discard;
-
                if (desc_flags & EFX_PKT_PREFIX_LEN) {
                        uint16_t tmp_size;
                        int rc __rte_unused;
@@ -237,6 +235,29 @@ sfc_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
                rte_pktmbuf_data_len(m) = seg_len;
                rte_pktmbuf_pkt_len(m) = seg_len;
 
+               if (scatter_pkt != NULL) {
+                       if (rte_pktmbuf_chain(scatter_pkt, m) != 0) {
+                               rte_mempool_put(rxq->refill_mb_pool,
+                                               scatter_pkt);
+                               goto discard;
+                       }
+                       /* The packet to deliver */
+                       m = scatter_pkt;
+               }
+
+               if (desc_flags & EFX_PKT_CONT) {
+                       /* The packet is scattered, more fragments to come */
+                       scatter_pkt = m;
+                       /* Futher fragments have no prefix */
+                       prefix_size = 0;
+                       continue;
+               }
+
+               /* Scattered packet is done */
+               scatter_pkt = NULL;
+               /* The first fragment of the packet has prefix */
+               prefix_size = rxq->prefix_size;
+
                m->ol_flags = sfc_rx_desc_flags_to_offload_flags(desc_flags);
                m->packet_type = sfc_rx_desc_flags_to_packet_type(desc_flags);
 
@@ -250,6 +271,9 @@ discard:
                rxd->mbuf = NULL;
        }
 
+       /* pending is only moved when entire packet is received */
+       SFC_ASSERT(scatter_pkt == NULL);
+
        rxq->completed = completed;
 
        sfc_rx_qrefill(rxq);
@@ -618,7 +642,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 
        SFC_ASSERT(nb_rx_desc <= rxq_info->max_entries);
        rxq_info->entries = nb_rx_desc;
-       rxq_info->type = EFX_RXQ_TYPE_DEFAULT;
+       rxq_info->type =
+               sa->eth_dev->data->dev_conf.rxmode.enable_scatter ?
+               EFX_RXQ_TYPE_SCATTER : EFX_RXQ_TYPE_DEFAULT;
 
        evq_index = sfc_evq_index_by_rxq_sw_index(sa, sw_index);
 
@@ -806,11 +832,6 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
                rxmode->hw_strip_crc = 1;
        }
 
-       if (rxmode->enable_scatter) {
-               sfc_err(sa, "Scatter on Rx not supported");
-               rc = EINVAL;
-       }
-
        if (rxmode->enable_lro) {
                sfc_err(sa, "LRO not supported");
                rc = EINVAL;