service: use id in runstate function
[dpdk.git] / examples / tep_termination / vxlan_setup.c
index 52e404c..050bb32 100644 (file)
@@ -49,7 +49,7 @@
 #include <rte_tcp.h>
 
 #include "main.h"
-#include "rte_virtio_net.h"
+#include "rte_vhost.h"
 #include "vxlan.h"
 #include "vxlan_setup.h"
 
@@ -102,7 +102,7 @@ static const struct rte_eth_conf port_conf = {
                .hw_ip_checksum = 0, /**< IP checksum offload disabled */
                .hw_vlan_filter = 0, /**< VLAN filtering disabled */
                .jumbo_frame    = 0, /**< Jumbo Frame Support disabled */
-               .hw_strip_crc   = 0, /**< CRC stripped by hardware */
+               .hw_strip_crc   = 1, /**< CRC stripped by hardware */
        },
        .txmode = {
                .mq_mode = ETH_MQ_TX_NONE,
@@ -135,8 +135,8 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        uint16_t q;
        struct rte_eth_dev_info dev_info;
        uint16_t rx_rings, tx_rings = (uint16_t)rte_lcore_count();
-       const uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
-       const uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
+       uint16_t rx_ring_size = RTE_TEST_RX_DESC_DEFAULT;
+       uint16_t tx_ring_size = RTE_TEST_TX_DESC_DEFAULT;
        struct rte_eth_udp_tunnel tunnel_udp;
        struct rte_eth_rxconf *rxconf;
        struct rte_eth_txconf *txconf;
@@ -166,6 +166,11 @@ vxlan_port_init(uint8_t port, struct rte_mempool *mbuf_pool)
        if (retval != 0)
                return retval;
 
+       retval = rte_eth_dev_adjust_nb_rx_tx_desc(port, &rx_ring_size,
+                       &tx_ring_size);
+       if (retval != 0)
+               return retval;
+
        /* Setup the queues. */
        for (q = 0; q < rx_rings; q++) {
                retval = rte_eth_rx_queue_setup(port, q, rx_ring_size,
@@ -244,17 +249,16 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
 {
        int i, ret;
        struct ether_hdr *pkt_hdr;
-       struct virtio_net *dev = vdev->dev;
-       uint64_t portid = dev->vid;
+       uint64_t portid = vdev->vid;
        struct ipv4_hdr *ip;
 
        struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
 
-       if (unlikely(portid > VXLAN_N_PORTS)) {
+       if (unlikely(portid >= VXLAN_N_PORTS)) {
                RTE_LOG(INFO, VHOST_DATA,
                        "(%d) WARNING: Not configuring device,"
                        "as already have %d ports for VXLAN.",
-                       dev->vid, VXLAN_N_PORTS);
+                       vdev->vid, VXLAN_N_PORTS);
                return -1;
        }
 
@@ -264,7 +268,7 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
                RTE_LOG(INFO, VHOST_DATA,
                        "(%d) WARNING: This device is using an existing"
                        " MAC address and has not been registered.\n",
-                       dev->vid);
+                       vdev->vid);
                return -1;
        }
 
@@ -425,8 +429,7 @@ vxlan_tx_pkts(uint8_t port_id, uint16_t queue_id,
 
 /* Check for decapsulation and pass packets directly to VIRTIO device */
 int
-vxlan_rx_pkts(struct virtio_net *dev, struct rte_mbuf **pkts_burst,
-               uint32_t rx_count)
+vxlan_rx_pkts(int vid, struct rte_mbuf **pkts_burst, uint32_t rx_count)
 {
        uint32_t i = 0;
        uint32_t count = 0;
@@ -436,11 +439,11 @@ vxlan_rx_pkts(struct virtio_net *dev, struct rte_mbuf **pkts_burst,
        for (i = 0; i < rx_count; i++) {
                if (enable_stats) {
                        rte_atomic64_add(
-                               &dev_statistics[dev->vid].rx_bad_ip_csum,
+                               &dev_statistics[vid].rx_bad_ip_csum,
                                (pkts_burst[i]->ol_flags & PKT_RX_IP_CKSUM_BAD)
                                != 0);
                        rte_atomic64_add(
-                               &dev_statistics[dev->vid].rx_bad_ip_csum,
+                               &dev_statistics[vid].rx_bad_ip_csum,
                                (pkts_burst[i]->ol_flags & PKT_RX_L4_CKSUM_BAD)
                                != 0);
                }
@@ -452,6 +455,6 @@ vxlan_rx_pkts(struct virtio_net *dev, struct rte_mbuf **pkts_burst,
                        count++;
        }
 
-       ret = rte_vhost_enqueue_burst(dev, VIRTIO_RXQ, pkts_valid, count);
+       ret = rte_vhost_enqueue_burst(vid, VIRTIO_RXQ, pkts_valid, count);
        return ret;
 }