mbuf: add new Rx flags for stripped VLAN
[dpdk.git] / drivers / net / enic / enic_rx.c
index 232987a..6459e97 100644 (file)
 #define rte_packet_prefetch(p) do {} while (0)
 #endif
 
-static inline struct rte_mbuf *
-rte_rxmbuf_alloc(struct rte_mempool *mp)
-{
-       struct rte_mbuf *m;
-
-       m = __rte_mbuf_raw_alloc(mp);
-       __rte_mbuf_sanity_check_raw(m, 0);
-       return m;
-}
-
 static inline uint16_t
 enic_cq_rx_desc_ciflags(struct cq_enet_rq_desc *crd)
 {
@@ -207,7 +197,7 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
 
        /* VLAN stripping */
        if (bwflags & CQ_ENET_RQ_DESC_FLAGS_VLAN_STRIPPED) {
-               pkt_flags |= PKT_RX_VLAN_PKT;
+               pkt_flags |= PKT_RX_VLAN_PKT | PKT_RX_VLAN_STRIPPED;
                mbuf->vlan_tci = enic_cq_rx_desc_vlan(cqrd);
        } else {
                mbuf->vlan_tci = 0;
@@ -238,8 +228,8 @@ static inline uint32_t
 enic_ring_add(uint32_t n_descriptors, uint32_t i0, uint32_t i1)
 {
        uint32_t d = i0 + i1;
-       ASSERT(i0 < n_descriptors);
-       ASSERT(i1 < n_descriptors);
+       RTE_ASSERT(i0 < n_descriptors);
+       RTE_ASSERT(i1 < n_descriptors);
        d -= (d >= n_descriptors) ? n_descriptors : 0;
        return d;
 }
@@ -283,7 +273,7 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                rqd_ptr = (struct rq_enet_desc *)(rq->ring.descs) + rx_id;
 
                /* allocate a new mbuf */
-               nmb = rte_rxmbuf_alloc(rq->mp);
+               nmb = rte_mbuf_raw_alloc(rq->mp);
                if (nmb == NULL) {
                        dev_err(enic, "RX mbuf alloc failed port=%u qid=%u",
                        enic->port_id, (unsigned)rq->index);
@@ -314,9 +304,11 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
                                 + rx_id);
 
                /* Push descriptor for newly allocated mbuf */
-               dma_addr = (dma_addr_t)(nmb->buf_physaddr + nmb->data_off);
+               dma_addr = (dma_addr_t)(nmb->buf_physaddr
+                          + RTE_PKTMBUF_HEADROOM);
                rqd_ptr->address = rte_cpu_to_le_64(dma_addr);
-               rqd_ptr->length_type = cpu_to_le16(nmb->buf_len);
+               rqd_ptr->length_type = cpu_to_le16(nmb->buf_len
+                                      - RTE_PKTMBUF_HEADROOM);
 
                /* Fill in the rest of the mbuf */
                rxmb->data_off = RTE_PKTMBUF_HEADROOM;