mbuf: make segment prefree function public
[dpdk.git] / drivers / net / enic / enic_rxtx.c
index 5d59d8f..1ee5cbb 100644 (file)
@@ -260,16 +260,25 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
        }
 
        /* checksum flags */
-       if (!enic_cq_rx_desc_csum_not_calc(cqrd) &&
-               (mbuf->packet_type & RTE_PTYPE_L3_IPV4)) {
-               uint32_t l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
-
-               if (unlikely(!enic_cq_rx_desc_ipv4_csum_ok(cqrd)))
-                       pkt_flags |= PKT_RX_IP_CKSUM_BAD;
-               if (l4_flags == RTE_PTYPE_L4_UDP ||
-                   l4_flags == RTE_PTYPE_L4_TCP) {
-                       if (unlikely(!enic_cq_rx_desc_tcp_udp_csum_ok(cqrd)))
-                               pkt_flags |= PKT_RX_L4_CKSUM_BAD;
+       if (mbuf->packet_type & RTE_PTYPE_L3_IPV4) {
+               if (enic_cq_rx_desc_csum_not_calc(cqrd))
+                       pkt_flags |= (PKT_RX_IP_CKSUM_UNKNOWN &
+                                    PKT_RX_L4_CKSUM_UNKNOWN);
+               else {
+                       uint32_t l4_flags;
+                       l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
+
+                       if (enic_cq_rx_desc_ipv4_csum_ok(cqrd))
+                               pkt_flags |= PKT_RX_IP_CKSUM_GOOD;
+                       else
+                               pkt_flags |= PKT_RX_IP_CKSUM_BAD;
+
+                       if (l4_flags & (RTE_PTYPE_L4_UDP | RTE_PTYPE_L4_TCP)) {
+                               if (enic_cq_rx_desc_tcp_udp_csum_ok(cqrd))
+                                       pkt_flags |= PKT_RX_L4_CKSUM_GOOD;
+                               else
+                                       pkt_flags |= PKT_RX_L4_CKSUM_BAD;
+                       }
                }
        }
 
@@ -437,10 +446,11 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
 
                rte_mb();
                if (data_rq->in_use)
-                       iowrite32(data_rq->posted_index,
-                                 &data_rq->ctrl->posted_index);
+                       iowrite32_relaxed(data_rq->posted_index,
+                                         &data_rq->ctrl->posted_index);
                rte_compiler_barrier();
-               iowrite32(sop_rq->posted_index, &sop_rq->ctrl->posted_index);
+               iowrite32_relaxed(sop_rq->posted_index,
+                                 &sop_rq->ctrl->posted_index);
        }
 
 
@@ -463,7 +473,7 @@ static inline void enic_free_wq_bufs(struct vnic_wq *wq, u16 completed_index)
        pool = ((struct rte_mbuf *)buf->mb)->pool;
        for (i = 0; i < nb_to_free; i++) {
                buf = &wq->bufs[tail_idx];
-               m = __rte_pktmbuf_prefree_seg((struct rte_mbuf *)(buf->mb));
+               m = rte_pktmbuf_prefree_seg((struct rte_mbuf *)(buf->mb));
                buf->mb = NULL;
 
                if (unlikely(m == NULL)) {
@@ -536,16 +546,23 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
 
        for (index = 0; index < nb_pkts; index++) {
                tx_pkt = *tx_pkts++;
+               pkt_len = tx_pkt->pkt_len;
+               data_len = tx_pkt->data_len;
+               ol_flags = tx_pkt->ol_flags;
                nb_segs = tx_pkt->nb_segs;
+
+               if (pkt_len > ENIC_TX_MAX_PKT_SIZE) {
+                       rte_pktmbuf_free(tx_pkt);
+                       rte_atomic64_inc(&enic->soft_stats.tx_oversized);
+                       continue;
+               }
+
                if (nb_segs > wq_desc_avail) {
                        if (index > 0)
                                goto post;
                        goto done;
                }
 
-               pkt_len = tx_pkt->pkt_len;
-               data_len = tx_pkt->data_len;
-               ol_flags = tx_pkt->ol_flags;
                mss = 0;
                vlan_id = 0;
                vlan_tag_insert = 0;
@@ -620,7 +637,7 @@ uint16_t enic_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
        }
  post:
        rte_wmb();
-       iowrite32(head_idx, &wq->ctrl->posted_index);
+       iowrite32_relaxed(head_idx, &wq->ctrl->posted_index);
  done:
        wq->ring.desc_avail = wq_desc_avail;
        wq->head_idx = head_idx;