i40e: move to drivers/net/
[dpdk.git] / lib / librte_pmd_ixgbe / ixgbe_rxtx.c
index 9da2c7e..57c9430 100644 (file)
@@ -70,6 +70,7 @@
 #include <rte_sctp.h>
 #include <rte_string_fns.h>
 #include <rte_errno.h>
+#include <rte_ip.h>
 
 #include "ixgbe_logs.h"
 #include "ixgbe/ixgbe_api.h"
@@ -578,7 +579,7 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        uint64_t tx_ol_req;
        uint32_t ctx = 0;
        uint32_t new_ctx;
-       union ixgbe_tx_offload tx_offload = { .data = 0 };
+       union ixgbe_tx_offload tx_offload = {0};
 
        txq = tx_queue;
        sw_ring = txq->sw_ring;
@@ -1021,7 +1022,7 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq)
 }
 
 static inline int
-ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq)
+ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)
 {
        volatile union ixgbe_adv_rx_desc *rxdp;
        struct ixgbe_rx_entry *rxep;
@@ -1031,8 +1032,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq)
        int diag, i;
 
        /* allocate buffers in bulk directly into the S/W ring */
-       alloc_idx = (uint16_t)(rxq->rx_free_trigger -
-                               (rxq->rx_free_thresh - 1));
+       alloc_idx = rxq->rx_free_trigger - (rxq->rx_free_thresh - 1);
        rxep = &rxq->sw_ring[alloc_idx];
        diag = rte_mempool_get_bulk(rxq->mb_pool, (void *)rxep,
                                    rxq->rx_free_thresh);
@@ -1043,11 +1043,14 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq)
        for (i = 0; i < rxq->rx_free_thresh; ++i) {
                /* populate the static rte mbuf fields */
                mb = rxep[i].mbuf;
+               if (reset_mbuf) {
+                       mb->next = NULL;
+                       mb->nb_segs = 1;
+                       mb->port = rxq->port_id;
+               }
+
                rte_mbuf_refcnt_set(mb, 1);
-               mb->next = NULL;
                mb->data_off = RTE_PKTMBUF_HEADROOM;
-               mb->nb_segs = 1;
-               mb->port = rxq->port_id;
 
                /* populate the descriptors */
                dma_addr = rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mb));
@@ -1055,15 +1058,10 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq)
                rxdp[i].read.pkt_addr = dma_addr;
        }
 
-       /* update tail pointer */
-       rte_wmb();
-       IXGBE_PCI_REG_WRITE(rxq->rdt_reg_addr, rxq->rx_free_trigger);
-
        /* update state of internal queue structure */
-       rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_trigger +
-                                               rxq->rx_free_thresh);
+       rxq->rx_free_trigger = rxq->rx_free_trigger + rxq->rx_free_thresh;
        if (rxq->rx_free_trigger >= rxq->nb_rx_desc)
-               rxq->rx_free_trigger = (uint16_t)(rxq->rx_free_thresh - 1);
+               rxq->rx_free_trigger = rxq->rx_free_thresh - 1;
 
        /* no errors */
        return 0;
@@ -1111,7 +1109,9 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
        /* if required, allocate new buffers to replenish descriptors */
        if (rxq->rx_tail > rxq->rx_free_trigger) {
-               if (ixgbe_rx_alloc_bufs(rxq) != 0) {
+               uint16_t cur_free_trigger = rxq->rx_free_trigger;
+
+               if (ixgbe_rx_alloc_bufs(rxq, true) != 0) {
                        int i, j;
                        PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
                                   "queue_id=%u", (unsigned) rxq->port_id,
@@ -1131,6 +1131,10 @@ rx_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
                        return 0;
                }
+
+               /* update tail pointer */
+               rte_wmb();
+               IXGBE_PCI_REG_WRITE(rxq->rdt_reg_addr, cur_free_trigger);
        }
 
        if (rxq->rx_tail >= rxq->nb_rx_desc)
@@ -1181,6 +1185,12 @@ ixgbe_recv_pkts_bulk_alloc(__rte_unused void *rx_queue,
        return 0;
 }
 
+static inline int
+ixgbe_rx_alloc_bufs(__rte_unused struct ixgbe_rx_queue *rxq,
+                   __rte_unused bool reset_mbuf)
+{
+       return -ENOMEM;
+}
 #endif /* RTE_LIBRTE_IXGBE_RX_ALLOW_BULK_ALLOC */
 
 uint16_t
@@ -1365,130 +1375,258 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
        return (nb_rx);
 }
 
-uint16_t
-ixgbe_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
-                         uint16_t nb_pkts)
+/**
+ * Detect an RSC descriptor.
+ */
+static inline uint32_t
+ixgbe_rsc_count(union ixgbe_adv_rx_desc *rx)
+{
+       return (rte_le_to_cpu_32(rx->wb.lower.lo_dword.data) &
+               IXGBE_RXDADV_RSCCNT_MASK) >> IXGBE_RXDADV_RSCCNT_SHIFT;
+}
+
+/**
+ * ixgbe_fill_cluster_head_buf - fill the first mbuf of the returned packet
+ *
+ * Fill the following info in the HEAD buffer of the Rx cluster:
+ *    - RX port identifier
+ *    - hardware offload data, if any:
+ *      - RSS flag & hash
+ *      - IP checksum flag
+ *      - VLAN TCI, if any
+ *      - error flags
+ * @head HEAD of the packet cluster
+ * @desc HW descriptor to get data from
+ * @port_id Port ID of the Rx queue
+ */
+static inline void
+ixgbe_fill_cluster_head_buf(
+       struct rte_mbuf *head,
+       union ixgbe_adv_rx_desc *desc,
+       uint8_t port_id,
+       uint32_t staterr)
 {
-       struct ixgbe_rx_queue *rxq;
-       volatile union ixgbe_adv_rx_desc *rx_ring;
-       volatile union ixgbe_adv_rx_desc *rxdp;
-       struct ixgbe_rx_entry *sw_ring;
-       struct ixgbe_rx_entry *rxe;
-       struct rte_mbuf *first_seg;
-       struct rte_mbuf *last_seg;
-       struct rte_mbuf *rxm;
-       struct rte_mbuf *nmb;
-       union ixgbe_adv_rx_desc rxd;
-       uint64_t dma; /* Physical address of mbuf data buffer */
-       uint32_t staterr;
        uint32_t hlen_type_rss;
-       uint16_t rx_id;
-       uint16_t nb_rx;
-       uint16_t nb_hold;
-       uint16_t data_len;
        uint64_t pkt_flags;
 
-       nb_rx = 0;
-       nb_hold = 0;
-       rxq = rx_queue;
-       rx_id = rxq->rx_tail;
-       rx_ring = rxq->rx_ring;
-       sw_ring = rxq->sw_ring;
+       head->port = port_id;
 
        /*
-        * Retrieve RX context of current packet, if any.
+        * The vlan_tci field is only valid when PKT_RX_VLAN_PKT is
+        * set in the pkt_flags field.
         */
-       first_seg = rxq->pkt_first_seg;
-       last_seg = rxq->pkt_last_seg;
+       head->vlan_tci = rte_le_to_cpu_16(desc->wb.upper.vlan);
+       hlen_type_rss = rte_le_to_cpu_32(desc->wb.lower.lo_dword.data);
+       pkt_flags = rx_desc_hlen_type_rss_to_pkt_flags(hlen_type_rss);
+       pkt_flags |= rx_desc_status_to_pkt_flags(staterr);
+       pkt_flags |= rx_desc_error_to_pkt_flags(staterr);
+       head->ol_flags = pkt_flags;
+
+       if (likely(pkt_flags & PKT_RX_RSS_HASH))
+               head->hash.rss = rte_le_to_cpu_32(desc->wb.lower.hi_dword.rss);
+       else if (pkt_flags & PKT_RX_FDIR) {
+               head->hash.fdir.hash =
+                       rte_le_to_cpu_16(desc->wb.lower.hi_dword.csum_ip.csum)
+                                                         & IXGBE_ATR_HASH_MASK;
+               head->hash.fdir.id =
+                       rte_le_to_cpu_16(desc->wb.lower.hi_dword.csum_ip.ip_id);
+       }
+}
 
-       while (nb_rx < nb_pkts) {
-       next_desc:
-               /*
-                * The order of operations here is important as the DD status
-                * bit must not be read after any other descriptor fields.
-                * rx_ring and rxdp are pointing to volatile data so the order
-                * of accesses cannot be reordered by the compiler. If they were
-                * not volatile, they could be reordered which could lead to
-                * using invalid descriptor fields when read from rxd.
-                */
-               rxdp = &rx_ring[rx_id];
-               staterr = rxdp->wb.upper.status_error;
-               if (! (staterr & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD)))
-                       break;
-               rxd = *rxdp;
+/**
+ * ixgbe_recv_pkts_lro - receive handler for and LRO case.
+ *
+ * @rx_queue Rx queue handle
+ * @rx_pkts table of received packets
+ * @nb_pkts size of rx_pkts table
+ * @bulk_alloc if TRUE bulk allocation is used for a HW ring refilling
+ *
+ * Handles the Rx HW ring completions when RSC feature is configured. Uses an
+ * additional ring of ixgbe_rsc_entry's that will hold the relevant RSC info.
+ *
+ * We use the same logic as in Linux and in FreeBSD ixgbe drivers:
+ * 1) When non-EOP RSC completion arrives:
+ *    a) Update the HEAD of the current RSC aggregation cluster with the new
+ *       segment's data length.
+ *    b) Set the "next" pointer of the current segment to point to the segment
+ *       at the NEXTP index.
+ *    c) Pass the HEAD of RSC aggregation cluster on to the next NEXTP entry
+ *       in the sw_rsc_ring.
+ * 2) When EOP arrives we just update the cluster's total length and offload
+ *    flags and deliver the cluster up to the upper layers. In our case - put it
+ *    in the rx_pkts table.
+ *
+ * Returns the number of received packets/clusters (according to the "bulk
+ * receive" interface).
+ */
+static inline uint16_t
+ixgbe_recv_pkts_lro(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts,
+                   bool bulk_alloc)
+{
+       struct ixgbe_rx_queue *rxq = rx_queue;
+       volatile union ixgbe_adv_rx_desc *rx_ring = rxq->rx_ring;
+       struct ixgbe_rx_entry *sw_ring = rxq->sw_ring;
+       struct ixgbe_scattered_rx_entry *sw_sc_ring = rxq->sw_sc_ring;
+       uint16_t rx_id = rxq->rx_tail;
+       uint16_t nb_rx = 0;
+       uint16_t nb_hold = rxq->nb_rx_hold;
+       uint16_t prev_id = rxq->rx_tail;
 
+       while (nb_rx < nb_pkts) {
+               bool eop;
+               struct ixgbe_rx_entry *rxe;
+               struct ixgbe_scattered_rx_entry *sc_entry;
+               struct ixgbe_scattered_rx_entry *next_sc_entry;
+               struct ixgbe_rx_entry *next_rxe;
+               struct rte_mbuf *first_seg;
+               struct rte_mbuf *rxm;
+               struct rte_mbuf *nmb;
+               union ixgbe_adv_rx_desc rxd;
+               uint16_t data_len;
+               uint16_t next_id;
+               volatile union ixgbe_adv_rx_desc *rxdp;
+               uint32_t staterr;
+
+next_desc:
                /*
-                * Descriptor done.
+                * The code in this whole file uses the volatile pointer to
+                * ensure the read ordering of the status and the rest of the
+                * descriptor fields (on the compiler level only!!!). This is so
+                * UGLY - why not to just use the compiler barrier instead? DPDK
+                * even has the rte_compiler_barrier() for that.
                 *
-                * Allocate a new mbuf to replenish the RX ring descriptor.
-                * If the allocation fails:
-                *    - arrange for that RX descriptor to be the first one
-                *      being parsed the next time the receive function is
-                *      invoked [on the same queue].
+                * But most importantly this is just wrong because this doesn't
+                * ensure memory ordering in a general case at all. For
+                * instance, DPDK is supposed to work on Power CPUs where
+                * compiler barrier may just not be enough!
                 *
-                *    - Stop parsing the RX ring and return immediately.
+                * I tried to write only this function properly to have a
+                * starting point (as a part of an LRO/RSC series) but the
+                * compiler cursed at me when I tried to cast away the
+                * "volatile" from rx_ring (yes, it's volatile too!!!). So, I'm
+                * keeping it the way it is for now.
                 *
-                * This policy does not drop the packet received in the RX
-                * descriptor for which the allocation of a new mbuf failed.
-                * Thus, it allows that packet to be later retrieved if
-                * mbuf have been freed in the mean time.
-                * As a side effect, holding RX descriptors instead of
-                * systematically giving them back to the NIC may lead to
-                * RX ring exhaustion situations.
-                * However, the NIC can gracefully prevent such situations
-                * to happen by sending specific "back-pressure" flow control
-                * frames to its peer(s).
+                * The code in this file is broken in so many other places and
+                * will just not work on a big endian CPU anyway therefore the
+                * lines below will have to be revisited together with the rest
+                * of the ixgbe PMD.
+                *
+                * TODO:
+                *    - Get rid of "volatile" crap and let the compiler do its
+                *      job.
+                *    - Use the proper memory barrier (rte_rmb()) to ensure the
+                *      memory ordering below.
                 */
-               PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_id=%u "
-                          "staterr=0x%x data_len=%u",
-                          (unsigned) rxq->port_id, (unsigned) rxq->queue_id,
-                          (unsigned) rx_id, (unsigned) staterr,
-                          (unsigned) rte_le_to_cpu_16(rxd.wb.upper.length));
+               rxdp = &rx_ring[rx_id];
+               staterr = rte_le_to_cpu_32(rxdp->wb.upper.status_error);
 
-               nmb = rte_rxmbuf_alloc(rxq->mb_pool);
-               if (nmb == NULL) {
-                       PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u "
-                                  "queue_id=%u", (unsigned) rxq->port_id,
-                                  (unsigned) rxq->queue_id);
-                       rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed++;
+               if (!(staterr & IXGBE_RXDADV_STAT_DD))
                        break;
+
+               rxd = *rxdp;
+
+               PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_id=%u "
+                                 "staterr=0x%x data_len=%u",
+                          rxq->port_id, rxq->queue_id, rx_id, staterr,
+                          rte_le_to_cpu_16(rxd.wb.upper.length));
+
+               if (!bulk_alloc) {
+                       nmb = rte_rxmbuf_alloc(rxq->mb_pool);
+                       if (nmb == NULL) {
+                               PMD_RX_LOG(DEBUG, "RX mbuf alloc failed "
+                                                 "port_id=%u queue_id=%u",
+                                          rxq->port_id, rxq->queue_id);
+
+                               rte_eth_devices[rxq->port_id].data->
+                                                       rx_mbuf_alloc_failed++;
+                               break;
+                       }
+               } else if (nb_hold > rxq->rx_free_thresh) {
+                       uint16_t next_rdt = rxq->rx_free_trigger;
+
+                       if (!ixgbe_rx_alloc_bufs(rxq, false)) {
+                               rte_wmb();
+                               IXGBE_PCI_REG_WRITE(rxq->rdt_reg_addr,
+                                                   next_rdt);
+                               nb_hold -= rxq->rx_free_thresh;
+                       } else {
+                               PMD_RX_LOG(DEBUG, "RX bulk alloc failed "
+                                                 "port_id=%u queue_id=%u",
+                                          rxq->port_id, rxq->queue_id);
+
+                               rte_eth_devices[rxq->port_id].data->
+                                                       rx_mbuf_alloc_failed++;
+                               break;
+                       }
                }
 
                nb_hold++;
                rxe = &sw_ring[rx_id];
-               rx_id++;
-               if (rx_id == rxq->nb_rx_desc)
-                       rx_id = 0;
+               eop = staterr & IXGBE_RXDADV_STAT_EOP;
+
+               next_id = rx_id + 1;
+               if (next_id == rxq->nb_rx_desc)
+                       next_id = 0;
 
                /* Prefetch next mbuf while processing current one. */
-               rte_ixgbe_prefetch(sw_ring[rx_id].mbuf);
+               rte_ixgbe_prefetch(sw_ring[next_id].mbuf);
 
                /*
                 * When next RX descriptor is on a cache-line boundary,
-                * prefetch the next 4 RX descriptors and the next 8 pointers
+                * prefetch the next 4 RX descriptors and the next 4 pointers
                 * to mbufs.
                 */
-               if ((rx_id & 0x3) == 0) {
-                       rte_ixgbe_prefetch(&rx_ring[rx_id]);
-                       rte_ixgbe_prefetch(&sw_ring[rx_id]);
+               if ((next_id & 0x3) == 0) {
+                       rte_ixgbe_prefetch(&rx_ring[next_id]);
+                       rte_ixgbe_prefetch(&sw_ring[next_id]);
                }
 
-               /*
-                * Update RX descriptor with the physical address of the new
-                * data buffer of the new allocated mbuf.
-                */
                rxm = rxe->mbuf;
-               rxe->mbuf = nmb;
-               dma = rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(nmb));
-               rxdp->read.hdr_addr = dma;
-               rxdp->read.pkt_addr = dma;
+
+               if (!bulk_alloc) {
+                       __le64 dma =
+                         rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(nmb));
+                       /*
+                        * Update RX descriptor with the physical address of the
+                        * new data buffer of the new allocated mbuf.
+                        */
+                       rxe->mbuf = nmb;
+
+                       rxm->data_off = RTE_PKTMBUF_HEADROOM;
+                       rxdp->read.hdr_addr = dma;
+                       rxdp->read.pkt_addr = dma;
+               } else
+                       rxe->mbuf = NULL;
 
                /*
                 * Set data length & data buffer address of mbuf.
                 */
                data_len = rte_le_to_cpu_16(rxd.wb.upper.length);
                rxm->data_len = data_len;
-               rxm->data_off = RTE_PKTMBUF_HEADROOM;
+
+               if (!eop) {
+                       uint16_t nextp_id;
+                       /*
+                        * Get next descriptor index:
+                        *  - For RSC it's in the NEXTP field.
+                        *  - For a scattered packet - it's just a following
+                        *    descriptor.
+                        */
+                       if (ixgbe_rsc_count(&rxd))
+                               nextp_id =
+                                       (staterr & IXGBE_RXDADV_NEXTP_MASK) >>
+                                                      IXGBE_RXDADV_NEXTP_SHIFT;
+                       else
+                               nextp_id = next_id;
+
+                       next_sc_entry = &sw_sc_ring[nextp_id];
+                       next_rxe = &sw_ring[nextp_id];
+                       rte_ixgbe_prefetch(next_rxe);
+               }
+
+               sc_entry = &sw_sc_ring[rx_id];
+               first_seg = sc_entry->fbuf;
+               sc_entry->fbuf = NULL;
 
                /*
                 * If this is the first buffer of the received packet,
@@ -1503,81 +1641,33 @@ ixgbe_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                        first_seg->pkt_len = data_len;
                        first_seg->nb_segs = 1;
                } else {
-                       first_seg->pkt_len = (uint16_t)(first_seg->pkt_len
-                                       + data_len);
+                       first_seg->pkt_len += data_len;
                        first_seg->nb_segs++;
-                       last_seg->next = rxm;
                }
 
+               prev_id = rx_id;
+               rx_id = next_id;
+
                /*
-                * If this is not the last buffer of the received packet,
-                * update the pointer to the last mbuf of the current scattered
-                * packet and continue to parse the RX ring.
+                * If this is not the last buffer of the received packet, update
+                * the pointer to the first mbuf at the NEXTP entry in the
+                * sw_sc_ring and continue to parse the RX ring.
                 */
-               if (! (staterr & IXGBE_RXDADV_STAT_EOP)) {
-                       last_seg = rxm;
+               if (!eop) {
+                       rxm->next = next_rxe->mbuf;
+                       next_sc_entry->fbuf = first_seg;
                        goto next_desc;
                }
 
                /*
-                * This is the last buffer of the received packet.
-                * If the CRC is not stripped by the hardware:
-                *   - Subtract the CRC length from the total packet length.
-                *   - If the last buffer only contains the whole CRC or a part
-                *     of it, free the mbuf associated to the last buffer.
-                *     If part of the CRC is also contained in the previous
-                *     mbuf, subtract the length of that CRC part from the
-                *     data length of the previous mbuf.
+                * This is the last buffer of the received packet - return
+                * the current cluster to the user.
                 */
                rxm->next = NULL;
-               if (unlikely(rxq->crc_len > 0)) {
-                       first_seg->pkt_len -= ETHER_CRC_LEN;
-                       if (data_len <= ETHER_CRC_LEN) {
-                               rte_pktmbuf_free_seg(rxm);
-                               first_seg->nb_segs--;
-                               last_seg->data_len = (uint16_t)
-                                       (last_seg->data_len -
-                                        (ETHER_CRC_LEN - data_len));
-                               last_seg->next = NULL;
-                       } else
-                               rxm->data_len =
-                                       (uint16_t) (data_len - ETHER_CRC_LEN);
-               }
 
-               /*
-                * Initialize the first mbuf of the returned packet:
-                *    - RX port identifier,
-                *    - hardware offload data, if any:
-                *      - RSS flag & hash,
-                *      - IP checksum flag,
-                *      - VLAN TCI, if any,
-                *      - error flags.
-                */
-               first_seg->port = rxq->port_id;
-
-               /*
-                * The vlan_tci field is only valid when PKT_RX_VLAN_PKT is
-                * set in the pkt_flags field.
-                */
-               first_seg->vlan_tci = rte_le_to_cpu_16(rxd.wb.upper.vlan);
-               hlen_type_rss = rte_le_to_cpu_32(rxd.wb.lower.lo_dword.data);
-               pkt_flags = rx_desc_hlen_type_rss_to_pkt_flags(hlen_type_rss);
-               pkt_flags = (pkt_flags |
-                               rx_desc_status_to_pkt_flags(staterr));
-               pkt_flags = (pkt_flags |
-                               rx_desc_error_to_pkt_flags(staterr));
-               first_seg->ol_flags = pkt_flags;
-
-               if (likely(pkt_flags & PKT_RX_RSS_HASH))
-                       first_seg->hash.rss =
-                                   rte_le_to_cpu_32(rxd.wb.lower.hi_dword.rss);
-               else if (pkt_flags & PKT_RX_FDIR) {
-                       first_seg->hash.fdir.hash =
-                           rte_le_to_cpu_16(rxd.wb.lower.hi_dword.csum_ip.csum)
-                                          & IXGBE_ATR_HASH_MASK;
-                       first_seg->hash.fdir.id =
-                         rte_le_to_cpu_16(rxd.wb.lower.hi_dword.csum_ip.ip_id);
-               }
+               /* Initialize the first mbuf of the returned packet */
+               ixgbe_fill_cluster_head_buf(first_seg, &rxd, rxq->port_id,
+                                           staterr);
 
                /* Prefetch data of first segment, if configured to do so. */
                rte_packet_prefetch((char *)first_seg->buf_addr +
@@ -1588,11 +1678,6 @@ ixgbe_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                 * of returned packets.
                 */
                rx_pkts[nb_rx++] = first_seg;
-
-               /*
-                * Setup receipt context for a new packet.
-                */
-               first_seg = NULL;
        }
 
        /*
@@ -1600,12 +1685,6 @@ ixgbe_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
         */
        rxq->rx_tail = rx_id;
 
-       /*
-        * Save receive context.
-        */
-       rxq->pkt_first_seg = first_seg;
-       rxq->pkt_last_seg = last_seg;
-
        /*
         * If the number of free RX descriptors is greater than the RX free
         * threshold of the queue, advance the Receive Descriptor Tail (RDT)
@@ -1615,20 +1694,32 @@ ixgbe_recv_scattered_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
         * RDH register, which creates a "full" ring situtation from the
         * hardware point of view...
         */
-       nb_hold = (uint16_t) (nb_hold + rxq->nb_rx_hold);
-       if (nb_hold > rxq->rx_free_thresh) {
+       if (!bulk_alloc && nb_hold > rxq->rx_free_thresh) {
                PMD_RX_LOG(DEBUG, "port_id=%u queue_id=%u rx_tail=%u "
                           "nb_hold=%u nb_rx=%u",
-                          (unsigned) rxq->port_id, (unsigned) rxq->queue_id,
-                          (unsigned) rx_id, (unsigned) nb_hold,
-                          (unsigned) nb_rx);
-               rx_id = (uint16_t) ((rx_id == 0) ?
-                                    (rxq->nb_rx_desc - 1) : (rx_id - 1));
-               IXGBE_PCI_REG_WRITE(rxq->rdt_reg_addr, rx_id);
+                          rxq->port_id, rxq->queue_id, rx_id, nb_hold, nb_rx);
+
+               rte_wmb();
+               IXGBE_PCI_REG_WRITE(rxq->rdt_reg_addr, prev_id);
                nb_hold = 0;
        }
+
        rxq->nb_rx_hold = nb_hold;
-       return (nb_rx);
+       return nb_rx;
+}
+
+uint16_t
+ixgbe_recv_pkts_lro_single_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
+                                uint16_t nb_pkts)
+{
+       return ixgbe_recv_pkts_lro(rx_queue, rx_pkts, nb_pkts, false);
+}
+
+uint16_t
+ixgbe_recv_pkts_lro_bulk_alloc(void *rx_queue, struct rte_mbuf **rx_pkts,
+                              uint16_t nb_pkts)
+{
+       return ixgbe_recv_pkts_lro(rx_queue, rx_pkts, nb_pkts, true);
 }
 
 /*********************************************************************
@@ -1728,8 +1819,7 @@ ixgbe_dev_tx_queue_release(void *txq)
 static void
 ixgbe_reset_tx_queue(struct ixgbe_tx_queue *txq)
 {
-       static const union ixgbe_adv_tx_desc zeroed_desc = { .read = {
-                       .buffer_addr = 0}};
+       static const union ixgbe_adv_tx_desc zeroed_desc = {{0}};
        struct ixgbe_tx_entry *txe = txq->sw_ring;
        uint16_t prev, i;
 
@@ -1981,6 +2071,31 @@ ixgbe_dev_tx_queue_setup(struct rte_eth_dev *dev,
        return (0);
 }
 
+/**
+ * ixgbe_free_sc_cluster - free the not-yet-completed scattered cluster
+ *
+ * The "next" pointer of the last segment of (not-yet-completed) RSC clusters
+ * in the sw_rsc_ring is not set to NULL but rather points to the next
+ * mbuf of this RSC aggregation (that has not been completed yet and still
+ * resides on the HW ring). So, instead of calling for rte_pktmbuf_free() we
+ * will just free first "nb_segs" segments of the cluster explicitly by calling
+ * an rte_pktmbuf_free_seg().
+ *
+ * @m scattered cluster head
+ */
+static void
+ixgbe_free_sc_cluster(struct rte_mbuf *m)
+{
+       uint8_t i, nb_segs = m->nb_segs;
+       struct rte_mbuf *next_seg;
+
+       for (i = 0; i < nb_segs; i++) {
+               next_seg = m->next;
+               rte_pktmbuf_free_seg(m);
+               m = next_seg;
+       }
+}
+
 static void
 ixgbe_rx_queue_release_mbufs(struct ixgbe_rx_queue *rxq)
 {
@@ -2004,6 +2119,13 @@ ixgbe_rx_queue_release_mbufs(struct ixgbe_rx_queue *rxq)
                }
 #endif
        }
+
+       if (rxq->sw_sc_ring)
+               for (i = 0; i < rxq->nb_rx_desc; i++)
+                       if (rxq->sw_sc_ring[i].fbuf) {
+                               ixgbe_free_sc_cluster(rxq->sw_sc_ring[i].fbuf);
+                               rxq->sw_sc_ring[i].fbuf = NULL;
+                       }
 }
 
 static void
@@ -2012,6 +2134,7 @@ ixgbe_rx_queue_release(struct ixgbe_rx_queue *rxq)
        if (rxq != NULL) {
                ixgbe_rx_queue_release_mbufs(rxq);
                rte_free(rxq->sw_ring);
+               rte_free(rxq->sw_sc_ring);
                rte_free(rxq);
        }
 }
@@ -2086,10 +2209,9 @@ check_rx_burst_bulk_alloc_preconditions(__rte_unused struct ixgbe_rx_queue *rxq)
 
 /* Reset dynamic ixgbe_rx_queue fields back to defaults */
 static void
-ixgbe_reset_rx_queue(struct ixgbe_hw *hw, struct ixgbe_rx_queue *rxq)
+ixgbe_reset_rx_queue(struct ixgbe_adapter *adapter, struct ixgbe_rx_queue *rxq)
 {
-       static const union ixgbe_adv_rx_desc zeroed_desc = { .read = {
-                       .pkt_addr = 0}};
+       static const union ixgbe_adv_rx_desc zeroed_desc = {{0}};
        unsigned i;
        uint16_t len = rxq->nb_rx_desc;
 
@@ -2103,7 +2225,7 @@ ixgbe_reset_rx_queue(struct ixgbe_hw *hw, struct ixgbe_rx_queue *rxq)
         * constraints here to see if we need to zero out memory after the end
         * of the H/W descriptor ring.
         */
-       if (hw->rx_bulk_alloc_allowed)
+       if (adapter->rx_bulk_alloc_allowed)
                /* zero out extra memory */
                len += RTE_PMD_IXGBE_RX_MAX_BURST;
 
@@ -2148,6 +2270,8 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
        struct ixgbe_rx_queue *rxq;
        struct ixgbe_hw     *hw;
        uint16_t len;
+       struct ixgbe_adapter *adapter =
+               (struct ixgbe_adapter *)dev->data->dev_private;
 
        PMD_INIT_FUNC_TRACE();
        hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -2238,7 +2362,7 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
                                    "preconditions - canceling the feature for "
                                    "the whole port[%d]",
                             rxq->queue_id, rxq->port_id);
-               hw->rx_bulk_alloc_allowed = false;
+               adapter->rx_bulk_alloc_allowed = false;
        }
 
        /*
@@ -2247,31 +2371,51 @@ ixgbe_dev_rx_queue_setup(struct rte_eth_dev *dev,
         * function does not access an invalid memory region.
         */
        len = nb_desc;
-       if (hw->rx_bulk_alloc_allowed)
+       if (adapter->rx_bulk_alloc_allowed)
                len += RTE_PMD_IXGBE_RX_MAX_BURST;
 
        rxq->sw_ring = rte_zmalloc_socket("rxq->sw_ring",
                                          sizeof(struct ixgbe_rx_entry) * len,
                                          RTE_CACHE_LINE_SIZE, socket_id);
-       if (rxq->sw_ring == NULL) {
+       if (!rxq->sw_ring) {
                ixgbe_rx_queue_release(rxq);
                return (-ENOMEM);
        }
-       PMD_INIT_LOG(DEBUG, "sw_ring=%p hw_ring=%p dma_addr=0x%"PRIx64,
-                    rxq->sw_ring, rxq->rx_ring, rxq->rx_ring_phys_addr);
+
+       /*
+        * Always allocate even if it's not going to be needed in order to
+        * simplify the code.
+        *
+        * This ring is used in LRO and Scattered Rx cases and Scattered Rx may
+        * be requested in ixgbe_dev_rx_init(), which is called later from
+        * dev_start() flow.
+        */
+       rxq->sw_sc_ring =
+               rte_zmalloc_socket("rxq->sw_sc_ring",
+                                  sizeof(struct ixgbe_scattered_rx_entry) * len,
+                                  RTE_CACHE_LINE_SIZE, socket_id);
+       if (!rxq->sw_sc_ring) {
+               ixgbe_rx_queue_release(rxq);
+               return (-ENOMEM);
+       }
+
+       PMD_INIT_LOG(DEBUG, "sw_ring=%p sw_sc_ring=%p hw_ring=%p "
+                           "dma_addr=0x%"PRIx64,
+                    rxq->sw_ring, rxq->sw_sc_ring, rxq->rx_ring,
+                    rxq->rx_ring_phys_addr);
 
        if (!rte_is_power_of_2(nb_desc)) {
                PMD_INIT_LOG(DEBUG, "queue[%d] doesn't meet Vector Rx "
                                    "preconditions - canceling the feature for "
                                    "the whole port[%d]",
                             rxq->queue_id, rxq->port_id);
-               hw->rx_vec_allowed = false;
+               adapter->rx_vec_allowed = false;
        } else
                ixgbe_rxq_vec_setup(rxq);
 
        dev->data->rx_queues[queue_idx] = rxq;
 
-       ixgbe_reset_rx_queue(hw, rxq);
+       ixgbe_reset_rx_queue(adapter, rxq);
 
        return 0;
 }
@@ -2325,7 +2469,8 @@ void
 ixgbe_dev_clear_queues(struct rte_eth_dev *dev)
 {
        unsigned i;
-       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct ixgbe_adapter *adapter =
+               (struct ixgbe_adapter *)dev->data->dev_private;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -2341,7 +2486,7 @@ ixgbe_dev_clear_queues(struct rte_eth_dev *dev)
                struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
                if (rxq != NULL) {
                        ixgbe_rx_queue_release_mbufs(rxq);
-                       ixgbe_reset_rx_queue(hw, rxq);
+                       ixgbe_reset_rx_queue(adapter, rxq);
                }
        }
 }
@@ -3503,42 +3648,151 @@ ixgbe_dev_mq_tx_configure(struct rte_eth_dev *dev)
        return 0;
 }
 
-void ixgbe_set_rx_function(struct rte_eth_dev *dev)
+/**
+ * ixgbe_get_rscctl_maxdesc - Calculate the RSCCTL[n].MAXDESC for PF
+ *
+ * Return the RSCCTL[n].MAXDESC for 82599 and x540 PF devices according to the
+ * spec rev. 3.0 chapter 8.2.3.8.13.
+ *
+ * @pool Memory pool of the Rx queue
+ */
+static inline uint32_t
+ixgbe_get_rscctl_maxdesc(struct rte_mempool *pool)
+{
+       struct rte_pktmbuf_pool_private *mp_priv = rte_mempool_get_priv(pool);
+
+       /* MAXDESC * SRRCTL.BSIZEPKT must not exceed 64 KB minus one */
+       uint16_t maxdesc =
+               IPV4_MAX_PKT_LEN /
+                       (mp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM);
+
+       if (maxdesc >= 16)
+               return IXGBE_RSCCTL_MAXDESC_16;
+       else if (maxdesc >= 8)
+               return IXGBE_RSCCTL_MAXDESC_8;
+       else if (maxdesc >= 4)
+               return IXGBE_RSCCTL_MAXDESC_4;
+       else
+               return IXGBE_RSCCTL_MAXDESC_1;
+}
+
+/**
+ * ixgbe_set_ivar - Setup the correct IVAR register for a particular MSIX
+ * interrupt
+ *
+ * (Taken from FreeBSD tree)
+ * (yes this is all very magic and confusing :)
+ *
+ * @dev port handle
+ * @entry the register array entry
+ * @vector the MSIX vector for this queue
+ * @type RX/TX/MISC
+ */
+static void
+ixgbe_set_ivar(struct rte_eth_dev *dev, u8 entry, u8 vector, s8 type)
 {
        struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       u32 ivar, index;
+
+       vector |= IXGBE_IVAR_ALLOC_VAL;
+
+       switch (hw->mac.type) {
+
+       case ixgbe_mac_82598EB:
+               if (type == -1)
+                       entry = IXGBE_IVAR_OTHER_CAUSES_INDEX;
+               else
+                       entry += (type * 64);
+               index = (entry >> 2) & 0x1F;
+               ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(index));
+               ivar &= ~(0xFF << (8 * (entry & 0x3)));
+               ivar |= (vector << (8 * (entry & 0x3)));
+               IXGBE_WRITE_REG(hw, IXGBE_IVAR(index), ivar);
+               break;
+
+       case ixgbe_mac_82599EB:
+       case ixgbe_mac_X540:
+               if (type == -1) { /* MISC IVAR */
+                       index = (entry & 1) * 8;
+                       ivar = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
+                       ivar &= ~(0xFF << index);
+                       ivar |= (vector << index);
+                       IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, ivar);
+               } else {        /* RX/TX IVARS */
+                       index = (16 * (entry & 1)) + (8 * type);
+                       ivar = IXGBE_READ_REG(hw, IXGBE_IVAR(entry >> 1));
+                       ivar &= ~(0xFF << index);
+                       ivar |= (vector << index);
+                       IXGBE_WRITE_REG(hw, IXGBE_IVAR(entry >> 1), ivar);
+               }
+
+               break;
+
+       default:
+               break;
+       }
+}
+
+void ixgbe_set_rx_function(struct rte_eth_dev *dev)
+{
+       struct ixgbe_adapter *adapter =
+               (struct ixgbe_adapter *)dev->data->dev_private;
 
        /*
         * In order to allow Vector Rx there are a few configuration
         * conditions to be met and Rx Bulk Allocation should be allowed.
         */
        if (ixgbe_rx_vec_dev_conf_condition_check(dev) ||
-           !hw->rx_bulk_alloc_allowed) {
+           !adapter->rx_bulk_alloc_allowed) {
                PMD_INIT_LOG(DEBUG, "Port[%d] doesn't meet Vector Rx "
                                    "preconditions or RTE_IXGBE_INC_VECTOR is "
                                    "not enabled",
                             dev->data->port_id);
 
-               hw->rx_vec_allowed = false;
+               adapter->rx_vec_allowed = false;
        }
 
-       if (dev->data->scattered_rx) {
+       /*
+        * Initialize the appropriate LRO callback.
+        *
+        * If all queues satisfy the bulk allocation preconditions
+        * (hw->rx_bulk_alloc_allowed is TRUE) then we may use bulk allocation.
+        * Otherwise use a single allocation version.
+        */
+       if (dev->data->lro) {
+               if (adapter->rx_bulk_alloc_allowed) {
+                       PMD_INIT_LOG(INFO, "LRO is requested. Using a bulk "
+                                          "allocation version");
+                       dev->rx_pkt_burst = ixgbe_recv_pkts_lro_bulk_alloc;
+               } else {
+                       PMD_INIT_LOG(INFO, "LRO is requested. Using a single "
+                                          "allocation version");
+                       dev->rx_pkt_burst = ixgbe_recv_pkts_lro_single_alloc;
+               }
+       } else if (dev->data->scattered_rx) {
                /*
                 * Set the non-LRO scattered callback: there are Vector and
                 * single allocation versions.
                 */
-               if (hw->rx_vec_allowed) {
+               if (adapter->rx_vec_allowed) {
                        PMD_INIT_LOG(DEBUG, "Using Vector Scattered Rx "
                                            "callback (port=%d).",
                                     dev->data->port_id);
 
                        dev->rx_pkt_burst = ixgbe_recv_scattered_pkts_vec;
+               } else if (adapter->rx_bulk_alloc_allowed) {
+                       PMD_INIT_LOG(INFO, "Using a Scattered with bulk "
+                                          "allocation callback (port=%d).",
+                                    dev->data->port_id);
+                       dev->rx_pkt_burst = ixgbe_recv_pkts_lro_bulk_alloc;
                } else {
-                       PMD_INIT_LOG(DEBUG, "Using Regualr (non-vector) "
+                       PMD_INIT_LOG(DEBUG, "Using Regualr (non-vector, "
+                                           "single allocation) "
                                            "Scattered Rx callback "
                                            "(port=%d).",
                                     dev->data->port_id);
 
-                       dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
+                       dev->rx_pkt_burst = ixgbe_recv_pkts_lro_single_alloc;
                }
        /*
         * Below we set "simple" callbacks according to port/queues parameters.
@@ -3548,12 +3802,12 @@ void ixgbe_set_rx_function(struct rte_eth_dev *dev)
         *    - Bulk Allocation
         *    - Single buffer allocation (the simplest one)
         */
-       } else if (hw->rx_vec_allowed) {
+       } else if (adapter->rx_vec_allowed) {
                PMD_INIT_LOG(INFO, "Vector rx enabled, please make sure RX "
                                   "burst size no less than 32.");
 
                dev->rx_pkt_burst = ixgbe_recv_pkts_vec;
-       } else if (hw->rx_bulk_alloc_allowed) {
+       } else if (adapter->rx_bulk_alloc_allowed) {
                PMD_INIT_LOG(DEBUG, "Rx Burst Bulk Alloc Preconditions are "
                                    "satisfied. Rx Burst Bulk Alloc function "
                                    "will be used on port=%d.",
@@ -3571,6 +3825,147 @@ void ixgbe_set_rx_function(struct rte_eth_dev *dev)
        }
 }
 
+/**
+ * ixgbe_set_rsc - configure RSC related port HW registers
+ *
+ * Configures the port's RSC related registers according to the 4.6.7.2 chapter
+ * of 82599 Spec (x540 configuration is virtually the same).
+ *
+ * @dev port handle
+ *
+ * Returns 0 in case of success or a non-zero error code
+ */
+static int
+ixgbe_set_rsc(struct rte_eth_dev *dev)
+{
+       struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
+       struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+       struct rte_eth_dev_info dev_info = { 0 };
+       bool rsc_capable = false;
+       uint16_t i;
+       uint32_t rdrxctl;
+
+       /* Sanity check */
+       dev->dev_ops->dev_infos_get(dev, &dev_info);
+       if (dev_info.rx_offload_capa & DEV_RX_OFFLOAD_TCP_LRO)
+               rsc_capable = true;
+
+       if (!rsc_capable && rx_conf->enable_lro) {
+               PMD_INIT_LOG(CRIT, "LRO is requested on HW that doesn't "
+                                  "support it");
+               return -EINVAL;
+       }
+
+       /* RSC global configuration (chapter 4.6.7.2.1 of 82599 Spec) */
+
+       if (!rx_conf->hw_strip_crc && rx_conf->enable_lro) {
+               /*
+                * According to chapter of 4.6.7.2.1 of the Spec Rev.
+                * 3.0 RSC configuration requires HW CRC stripping being
+                * enabled. If user requested both HW CRC stripping off
+                * and RSC on - return an error.
+                */
+               PMD_INIT_LOG(CRIT, "LRO can't be enabled when HW CRC "
+                                   "is disabled");
+               return -EINVAL;
+       }
+
+       /* RFCTL configuration  */
+       if (rsc_capable) {
+               uint32_t rfctl = IXGBE_READ_REG(hw, IXGBE_RFCTL);
+               if (rx_conf->enable_lro)
+                       /*
+                        * Since NFS packets coalescing is not supported - clear
+                        * RFCTL.NFSW_DIS and RFCTL.NFSR_DIS when RSC is
+                        * enabled.
+                        */
+                       rfctl &= ~(IXGBE_RFCTL_RSC_DIS | IXGBE_RFCTL_NFSW_DIS |
+                                  IXGBE_RFCTL_NFSR_DIS);
+               else
+                       rfctl |= IXGBE_RFCTL_RSC_DIS;
+
+               IXGBE_WRITE_REG(hw, IXGBE_RFCTL, rfctl);
+       }
+
+       /* If LRO hasn't been requested - we are done here. */
+       if (!rx_conf->enable_lro)
+               return 0;
+
+       /* Set RDRXCTL.RSCACKC bit */
+       rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
+       rdrxctl |= IXGBE_RDRXCTL_RSCACKC;
+       IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
+
+       /* Per-queue RSC configuration (chapter 4.6.7.2.2 of 82599 Spec) */
+       for (i = 0; i < dev->data->nb_rx_queues; i++) {
+               struct ixgbe_rx_queue *rxq = dev->data->rx_queues[i];
+               uint32_t srrctl =
+                       IXGBE_READ_REG(hw, IXGBE_SRRCTL(rxq->reg_idx));
+               uint32_t rscctl =
+                       IXGBE_READ_REG(hw, IXGBE_RSCCTL(rxq->reg_idx));
+               uint32_t psrtype =
+                       IXGBE_READ_REG(hw, IXGBE_PSRTYPE(rxq->reg_idx));
+               uint32_t eitr =
+                       IXGBE_READ_REG(hw, IXGBE_EITR(rxq->reg_idx));
+
+               /*
+                * ixgbe PMD doesn't support header-split at the moment.
+                *
+                * Following the 4.6.7.2.1 chapter of the 82599/x540
+                * Spec if RSC is enabled the SRRCTL[n].BSIZEHEADER
+                * should be configured even if header split is not
+                * enabled. We will configure it 128 bytes following the
+                * recommendation in the spec.
+                */
+               srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK;
+               srrctl |= (128 << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
+                                           IXGBE_SRRCTL_BSIZEHDR_MASK;
+
+               /*
+                * TODO: Consider setting the Receive Descriptor Minimum
+                * Threshold Size for an RSC case. This is not an obviously
+                * beneficiary option but the one worth considering...
+                */
+
+               rscctl |= IXGBE_RSCCTL_RSCEN;
+               rscctl |= ixgbe_get_rscctl_maxdesc(rxq->mb_pool);
+               psrtype |= IXGBE_PSRTYPE_TCPHDR;
+
+               /*
+                * RSC: Set ITR interval corresponding to 2K ints/s.
+                *
+                * Full-sized RSC aggregations for a 10Gb/s link will
+                * arrive at about 20K aggregation/s rate.
+                *
+                * 2K inst/s rate will make only 10% of the
+                * aggregations to be closed due to the interrupt timer
+                * expiration for a streaming at wire-speed case.
+                *
+                * For a sparse streaming case this setting will yield
+                * at most 500us latency for a single RSC aggregation.
+                */
+               eitr &= ~IXGBE_EITR_ITR_INT_MASK;
+               eitr |= IXGBE_EITR_INTERVAL_US(500) | IXGBE_EITR_CNT_WDIS;
+
+               IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(rxq->reg_idx), srrctl);
+               IXGBE_WRITE_REG(hw, IXGBE_RSCCTL(rxq->reg_idx), rscctl);
+               IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(rxq->reg_idx), psrtype);
+               IXGBE_WRITE_REG(hw, IXGBE_EITR(rxq->reg_idx), eitr);
+
+               /*
+                * RSC requires the mapping of the queue to the
+                * interrupt vector.
+                */
+               ixgbe_set_ivar(dev, rxq->reg_idx, i, 0);
+       }
+
+       dev->data->lro = 1;
+
+       PMD_INIT_LOG(INFO, "enabling LRO mode");
+
+       return 0;
+}
+
 /*
  * Initializes Receive Unit.
  */
@@ -3579,7 +3974,6 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
 {
        struct ixgbe_hw     *hw;
        struct ixgbe_rx_queue *rxq;
-       struct rte_pktmbuf_pool_private *mbp_priv;
        uint64_t bus_addr;
        uint32_t rxctrl;
        uint32_t fctrl;
@@ -3590,6 +3984,8 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
        uint32_t rxcsum;
        uint16_t buf_size;
        uint16_t i;
+       struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
+       int rc;
 
        PMD_INIT_FUNC_TRACE();
        hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -3612,7 +4008,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
         * Configure CRC stripping, if any.
         */
        hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
-       if (dev->data->dev_conf.rxmode.hw_strip_crc)
+       if (rx_conf->hw_strip_crc)
                hlreg0 |= IXGBE_HLREG0_RXCRCSTRP;
        else
                hlreg0 &= ~IXGBE_HLREG0_RXCRCSTRP;
@@ -3620,11 +4016,11 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
        /*
         * Configure jumbo frame support, if any.
         */
-       if (dev->data->dev_conf.rxmode.jumbo_frame == 1) {
+       if (rx_conf->jumbo_frame == 1) {
                hlreg0 |= IXGBE_HLREG0_JUMBOEN;
                maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
                maxfrs &= 0x0000FFFF;
-               maxfrs |= (dev->data->dev_conf.rxmode.max_rx_pkt_len << 16);
+               maxfrs |= (rx_conf->max_rx_pkt_len << 16);
                IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
        } else
                hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
@@ -3648,9 +4044,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
                 * Reset crc_len in case it was changed after queue setup by a
                 * call to configure.
                 */
-               rxq->crc_len = (uint8_t)
-                               ((dev->data->dev_conf.rxmode.hw_strip_crc) ? 0 :
-                               ETHER_CRC_LEN);
+               rxq->crc_len = rx_conf->hw_strip_crc ? 0 : ETHER_CRC_LEN;
 
                /* Setup the Base and Length of the Rx Descriptor Rings */
                bus_addr = rxq->rx_ring_phys_addr;
@@ -3668,7 +4062,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
                /*
                 * Configure Header Split
                 */
-               if (dev->data->dev_conf.rxmode.header_split) {
+               if (rx_conf->header_split) {
                        if (hw->mac.type == ixgbe_mac_82599EB) {
                                /* Must setup the PSRTYPE register */
                                uint32_t psrtype;
@@ -3678,7 +4072,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
                                        IXGBE_PSRTYPE_IPV6HDR;
                                IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(rxq->reg_idx), psrtype);
                        }
-                       srrctl = ((dev->data->dev_conf.rxmode.split_hdr_size <<
+                       srrctl = ((rx_conf->split_hdr_size <<
                                IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
                                IXGBE_SRRCTL_BSIZEHDR_MASK);
                        srrctl |= IXGBE_SRRCTL_DESCTYPE_HDR_SPLIT_ALWAYS;
@@ -3696,11 +4090,11 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
                 * The value is in 1 KB resolution. Valid values can be from
                 * 1 KB to 16 KB.
                 */
-               mbp_priv = rte_mempool_get_priv(rxq->mb_pool);
-               buf_size = (uint16_t) (mbp_priv->mbuf_data_room_size -
-                                      RTE_PKTMBUF_HEADROOM);
+               buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) -
+                       RTE_PKTMBUF_HEADROOM);
                srrctl |= ((buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) &
                           IXGBE_SRRCTL_BSIZEPKT_MASK);
+
                IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(rxq->reg_idx), srrctl);
 
                buf_size = (uint16_t) ((srrctl & IXGBE_SRRCTL_BSIZEPKT_MASK) <<
@@ -3712,11 +4106,9 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
                        dev->data->scattered_rx = 1;
        }
 
-       if (dev->data->dev_conf.rxmode.enable_scatter)
+       if (rx_conf->enable_scatter)
                dev->data->scattered_rx = 1;
 
-       ixgbe_set_rx_function(dev);
-
        /*
         * Device configured with multiple RX queues.
         */
@@ -3729,7 +4121,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
         */
        rxcsum = IXGBE_READ_REG(hw, IXGBE_RXCSUM);
        rxcsum |= IXGBE_RXCSUM_PCSD;
-       if (dev->data->dev_conf.rxmode.hw_ip_checksum)
+       if (rx_conf->hw_ip_checksum)
                rxcsum |= IXGBE_RXCSUM_IPPCSE;
        else
                rxcsum &= ~IXGBE_RXCSUM_IPPCSE;
@@ -3739,7 +4131,7 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
        if (hw->mac.type == ixgbe_mac_82599EB ||
            hw->mac.type == ixgbe_mac_X540) {
                rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
-               if (dev->data->dev_conf.rxmode.hw_strip_crc)
+               if (rx_conf->hw_strip_crc)
                        rdrxctl |= IXGBE_RDRXCTL_CRCSTRIP;
                else
                        rdrxctl &= ~IXGBE_RDRXCTL_CRCSTRIP;
@@ -3747,6 +4139,12 @@ ixgbe_dev_rx_init(struct rte_eth_dev *dev)
                IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
        }
 
+       rc = ixgbe_set_rsc(dev);
+       if (rc)
+               return rc;
+
+       ixgbe_set_rx_function(dev);
+
        return 0;
 }
 
@@ -3965,6 +4363,8 @@ int
 ixgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 {
        struct ixgbe_hw     *hw;
+       struct ixgbe_adapter *adapter =
+               (struct ixgbe_adapter *)dev->data->dev_private;
        struct ixgbe_rx_queue *rxq;
        uint32_t rxdctl;
        int poll_ms;
@@ -3992,7 +4392,7 @@ ixgbe_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
                rte_delay_us(RTE_IXGBE_WAIT_100_US);
 
                ixgbe_rx_queue_release_mbufs(rxq);
-               ixgbe_reset_rx_queue(hw, rxq);
+               ixgbe_reset_rx_queue(adapter, rxq);
        } else
                return -1;
 
@@ -4109,7 +4509,6 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
 {
        struct ixgbe_hw     *hw;
        struct ixgbe_rx_queue *rxq;
-       struct rte_pktmbuf_pool_private *mbp_priv;
        uint64_t bus_addr;
        uint32_t srrctl, psrtype = 0;
        uint16_t buf_size;
@@ -4196,9 +4595,8 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
                 * The value is in 1 KB resolution. Valid values can be from
                 * 1 KB to 16 KB.
                 */
-               mbp_priv = rte_mempool_get_priv(rxq->mb_pool);
-               buf_size = (uint16_t) (mbp_priv->mbuf_data_room_size -
-                                      RTE_PKTMBUF_HEADROOM);
+               buf_size = (uint16_t)(rte_pktmbuf_data_room_size(rxq->mb_pool) -
+                       RTE_PKTMBUF_HEADROOM);
                srrctl |= ((buf_size >> IXGBE_SRRCTL_BSIZEPKT_SHIFT) &
                           IXGBE_SRRCTL_BSIZEPKT_MASK);
 
@@ -4223,7 +4621,8 @@ ixgbevf_dev_rx_init(struct rte_eth_dev *dev)
                                        ixgbe_recv_scattered_pkts_vec;
                        else
 #endif
-                               dev->rx_pkt_burst = ixgbe_recv_scattered_pkts;
+                               dev->rx_pkt_burst =
+                                       ixgbe_recv_pkts_lro_single_alloc;
                }
        }