net/virtio: add device config support to vDPA
[dpdk.git] / drivers / net / virtio / virtio_rxtx.c
index 4028300..34108fb 100644 (file)
@@ -43,7 +43,7 @@ int
 virtio_dev_rx_queue_done(void *rxq, uint16_t offset)
 {
        struct virtnet_rx *rxvq = rxq;
-       struct virtqueue *vq = rxvq->vq;
+       struct virtqueue *vq = virtnet_rxq_to_vq(rxvq);
 
        return virtqueue_nused(vq) >= offset;
 }
@@ -424,7 +424,7 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
                        uint16_t num)
 {
        struct vq_desc_extra *dxp;
-       struct virtqueue *vq = txvq->vq;
+       struct virtqueue *vq = virtnet_txq_to_vq(txvq);
        struct vring_desc *start_dp;
        struct virtio_net_hdr *hdr;
        uint16_t idx;
@@ -448,7 +448,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;
@@ -470,7 +470,7 @@ virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,
                                   struct rte_mbuf *cookie,
                                   int in_order)
 {
-       struct virtqueue *vq = txvq->vq;
+       struct virtqueue *vq = virtnet_txq_to_vq(txvq);
        struct vring_packed_desc *dp;
        struct vq_desc_extra *dxp;
        uint16_t idx, id, flags;
@@ -495,7 +495,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;
@@ -524,7 +524,7 @@ virtqueue_enqueue_xmit(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
 {
        struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
        struct vq_desc_extra *dxp;
-       struct virtqueue *vq = txvq->vq;
+       struct virtqueue *vq = virtnet_txq_to_vq(txvq);
        struct vring_desc *start_dp;
        uint16_t seg_num = cookie->nb_segs;
        uint16_t head_idx, idx;
@@ -581,7 +581,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);
@@ -614,9 +615,9 @@ virtio_dev_cq_start(struct rte_eth_dev *dev)
 {
        struct virtio_hw *hw = dev->data->dev_private;
 
-       if (hw->cvq && hw->cvq->vq) {
+       if (hw->cvq) {
                rte_spinlock_init(&hw->cvq->lock);
-               VIRTQUEUE_DUMP((struct virtqueue *)hw->cvq->vq);
+               VIRTQUEUE_DUMP(virtnet_cq_to_vq(hw->cvq));
        }
 }
 
@@ -703,12 +704,9 @@ virtio_dev_rx_queue_setup_finish(struct rte_eth_dev *dev, uint16_t queue_idx)
                virtio_rxq_vec_setup(rxvq);
        }
 
-       memset(&rxvq->fake_mbuf, 0, sizeof(rxvq->fake_mbuf));
-       for (desc_idx = 0; desc_idx < RTE_PMD_VIRTIO_RX_MAX_BURST;
-            desc_idx++) {
-               vq->sw_ring[vq->vq_nentries + desc_idx] =
-                       &rxvq->fake_mbuf;
-       }
+       memset(rxvq->fake_mbuf, 0, sizeof(*rxvq->fake_mbuf));
+       for (desc_idx = 0; desc_idx < RTE_PMD_VIRTIO_RX_MAX_BURST; desc_idx++)
+               vq->sw_ring[vq->vq_nentries + desc_idx] = rxvq->fake_mbuf;
 
        if (hw->use_vec_rx && !virtio_with_packed_queue(hw)) {
                while (vq->vq_free_cnt >= RTE_VIRTIO_VPMD_RX_REARM_THRESH) {
@@ -948,7 +946,7 @@ uint16_t
 virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 {
        struct virtnet_rx *rxvq = rx_queue;
-       struct virtqueue *vq = rxvq->vq;
+       struct virtqueue *vq = virtnet_rxq_to_vq(rxvq);
        struct virtio_hw *hw = vq->hw;
        struct rte_mbuf *rxm;
        uint16_t nb_used, num, nb_rx;
@@ -1055,7 +1053,7 @@ virtio_recv_pkts_packed(void *rx_queue, struct rte_mbuf **rx_pkts,
                        uint16_t nb_pkts)
 {
        struct virtnet_rx *rxvq = rx_queue;
-       struct virtqueue *vq = rxvq->vq;
+       struct virtqueue *vq = virtnet_rxq_to_vq(rxvq);
        struct virtio_hw *hw = vq->hw;
        struct rte_mbuf *rxm;
        uint16_t num, nb_rx;
@@ -1158,7 +1156,7 @@ virtio_recv_pkts_inorder(void *rx_queue,
                        uint16_t nb_pkts)
 {
        struct virtnet_rx *rxvq = rx_queue;
-       struct virtqueue *vq = rxvq->vq;
+       struct virtqueue *vq = virtnet_rxq_to_vq(rxvq);
        struct virtio_hw *hw = vq->hw;
        struct rte_mbuf *rxm;
        struct rte_mbuf *prev = NULL;
@@ -1342,7 +1340,7 @@ virtio_recv_mergeable_pkts(void *rx_queue,
                        uint16_t nb_pkts)
 {
        struct virtnet_rx *rxvq = rx_queue;
-       struct virtqueue *vq = rxvq->vq;
+       struct virtqueue *vq = virtnet_rxq_to_vq(rxvq);
        struct virtio_hw *hw = vq->hw;
        struct rte_mbuf *rxm;
        struct rte_mbuf *prev = NULL;
@@ -1520,7 +1518,7 @@ virtio_recv_mergeable_pkts_packed(void *rx_queue,
                        uint16_t nb_pkts)
 {
        struct virtnet_rx *rxvq = rx_queue;
-       struct virtqueue *vq = rxvq->vq;
+       struct virtqueue *vq = virtnet_rxq_to_vq(rxvq);
        struct virtio_hw *hw = vq->hw;
        struct rte_mbuf *rxm;
        struct rte_mbuf *prev = NULL;
@@ -1731,7 +1729,7 @@ virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts,
                        uint16_t nb_pkts)
 {
        struct virtnet_tx *txvq = tx_queue;
-       struct virtqueue *vq = txvq->vq;
+       struct virtqueue *vq = virtnet_txq_to_vq(txvq);
        struct virtio_hw *hw = vq->hw;
        uint16_t hdr_size = hw->vtnet_hdr_size;
        uint16_t nb_tx = 0;
@@ -1812,7 +1810,7 @@ uint16_t
 virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 {
        struct virtnet_tx *txvq = tx_queue;
-       struct virtqueue *vq = txvq->vq;
+       struct virtqueue *vq = virtnet_txq_to_vq(txvq);
        struct virtio_hw *hw = vq->hw;
        uint16_t hdr_size = hw->vtnet_hdr_size;
        uint16_t nb_used, nb_tx = 0;
@@ -1912,7 +1910,7 @@ virtio_xmit_pkts_inorder(void *tx_queue,
                        uint16_t nb_pkts)
 {
        struct virtnet_tx *txvq = tx_queue;
-       struct virtqueue *vq = txvq->vq;
+       struct virtqueue *vq = virtnet_txq_to_vq(txvq);
        struct virtio_hw *hw = vq->hw;
        uint16_t hdr_size = hw->vtnet_hdr_size;
        uint16_t nb_used, nb_tx = 0, nb_inorder_pkts = 0;