build: check for broken AVX512 compiler support
[dpdk.git] / drivers / net / virtio / virtio_rxtx.c
index 8df913b..d0365ce 100644 (file)
@@ -328,13 +328,35 @@ virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf **cookie,
        return 0;
 }
 
+static inline void
+virtqueue_refill_single_packed(struct virtqueue *vq,
+                              struct vring_packed_desc *dp,
+                              struct rte_mbuf *cookie)
+{
+       uint16_t flags = vq->vq_packed.cached_flags;
+       struct virtio_hw *hw = vq->hw;
+
+       dp->addr = cookie->buf_iova +
+                       RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size;
+       dp->len = cookie->buf_len -
+               RTE_PKTMBUF_HEADROOM + hw->vtnet_hdr_size;
+
+       virtqueue_store_flags_packed(dp, flags,
+                                    hw->weak_barriers);
+
+       if (++vq->vq_avail_idx >= vq->vq_nentries) {
+               vq->vq_avail_idx -= vq->vq_nentries;
+               vq->vq_packed.cached_flags ^=
+                       VRING_PACKED_DESC_F_AVAIL_USED;
+               flags = vq->vq_packed.cached_flags;
+       }
+}
+
 static inline int
-virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq,
+virtqueue_enqueue_recv_refill_packed_init(struct virtqueue *vq,
                                     struct rte_mbuf **cookie, uint16_t num)
 {
        struct vring_packed_desc *start_dp = vq->vq_packed.ring.desc;
-       uint16_t flags = vq->vq_packed.cached_flags;
-       struct virtio_hw *hw = vq->hw;
        struct vq_desc_extra *dxp;
        uint16_t idx;
        int i;
@@ -350,24 +372,34 @@ virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq,
                dxp->cookie = (void *)cookie[i];
                dxp->ndescs = 1;
 
-               start_dp[idx].addr = cookie[i]->buf_iova +
-                       RTE_PKTMBUF_HEADROOM - hw->vtnet_hdr_size;
-               start_dp[idx].len = cookie[i]->buf_len -
-                       RTE_PKTMBUF_HEADROOM + hw->vtnet_hdr_size;
+               virtqueue_refill_single_packed(vq, &start_dp[idx], cookie[i]);
+       }
+       vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num);
+       return 0;
+}
 
-               vq->vq_desc_head_idx = dxp->next;
-               if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END)
-                       vq->vq_desc_tail_idx = vq->vq_desc_head_idx;
+static inline int
+virtqueue_enqueue_recv_refill_packed(struct virtqueue *vq,
+                                    struct rte_mbuf **cookie, uint16_t num)
+{
+       struct vring_packed_desc *start_dp = vq->vq_packed.ring.desc;
+       struct vq_desc_extra *dxp;
+       uint16_t idx, did;
+       int i;
 
-               virtqueue_store_flags_packed(&start_dp[idx], flags,
-                                            hw->weak_barriers);
+       if (unlikely(vq->vq_free_cnt == 0))
+               return -ENOSPC;
+       if (unlikely(vq->vq_free_cnt < num))
+               return -EMSGSIZE;
 
-               if (++vq->vq_avail_idx >= vq->vq_nentries) {
-                       vq->vq_avail_idx -= vq->vq_nentries;
-                       vq->vq_packed.cached_flags ^=
-                               VRING_PACKED_DESC_F_AVAIL_USED;
-                       flags = vq->vq_packed.cached_flags;
-               }
+       for (i = 0; i < num; i++) {
+               idx = vq->vq_avail_idx;
+               did = start_dp[idx].id;
+               dxp = &vq->vq_descx[did];
+               dxp->cookie = (void *)cookie[i];
+               dxp->ndescs = 1;
+
+               virtqueue_refill_single_packed(vq, &start_dp[idx], cookie[i]);
        }
        vq->vq_free_cnt = (uint16_t)(vq->vq_free_cnt - num);
        return 0;
@@ -448,7 +480,7 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
                if (!vq->hw->has_tx_offload)
                        virtqueue_clear_net_hdr(hdr);
                else
-                       virtqueue_xmit_offload(hdr, cookies[i], true);
+                       virtqueue_xmit_offload(hdr, cookies[i]);
 
                start_dp[idx].addr  = rte_mbuf_data_iova(cookies[i]) - head_size;
                start_dp[idx].len   = cookies[i]->data_len + head_size;
@@ -495,7 +527,7 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,
        if (!vq->hw->has_tx_offload)
                virtqueue_clear_net_hdr(hdr);
        else
-               virtqueue_xmit_offload(hdr, cookie, true);
+               virtqueue_xmit_offload(hdr, cookie);
 
        dp->addr = rte_mbuf_data_iova(cookie) - head_size;
        dp->len  = cookie->data_len + head_size;
@@ -581,7 +613,8 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
                idx = start_dp[idx].next;
        }
 
-       virtqueue_xmit_offload(hdr, cookie, vq->hw->has_tx_offload);
+       if (vq->hw->has_tx_offload)
+               virtqueue_xmit_offload(hdr, cookie);
 
        do {
                start_dp[idx].addr  = rte_mbuf_data_iova(cookie);
@@ -633,6 +666,8 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
        struct virtqueue *vq = hw->vqs[vq_idx];
        struct virtnet_rx *rxvq;
        uint16_t rx_free_thresh;
+       uint16_t buf_size;
+       const char *error;
 
        PMD_INIT_FUNC_TRACE();
 
@@ -641,6 +676,14 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev,
                return -EINVAL;
        }
 
+       buf_size = virtio_rx_mem_pool_buf_size(mp);
+       if (!virtio_rx_check_scatter(hw->max_rx_pkt_len, buf_size,
+                                    hw->rx_ol_scatter, &error)) {
+               PMD_INIT_LOG(ERR, "RxQ %u Rx scatter check failed: %s",
+                            queue_idx, error);
+               return -EINVAL;
+       }
+
        rx_free_thresh = rx_conf->rx_free_thresh;
        if (rx_free_thresh == 0)
                rx_free_thresh =
@@ -739,7 +782,7 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx)
 
                        /* Enqueue allocated buffers */
                        if (virtio_with_packed_queue(vq->hw))
-                               error = virtqueue_enqueue_recv_refill_packed(vq,
+                               error = virtqueue_enqueue_recv_refill_packed_init(vq,
                                                &m, 1);
                        else
                                error = virtqueue_enqueue_recv_refill(vq,