summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorYuanhan Liu <yuanhan.liu@linux.intel.com>2016-04-30 04:45:51 +0800
committerYuanhan Liu <yuanhan.liu@linux.intel.com>2016-06-22 08:59:54 +0200
commitc08a349006f7d26eb32152c34796532f5c7b046f (patch)
treebfb8fe74e29281cc6be15d593b75901ebfa87d58 /examples
parent550c9d27d1438c30a657016a0281fe8e7a133e53 (diff)
downloaddpdk-c08a349006f7d26eb32152c34796532f5c7b046f.zip
dpdk-c08a349006f7d26eb32152c34796532f5c7b046f.tar.gz
dpdk-c08a349006f7d26eb32152c34796532f5c7b046f.tar.xz
vhost: declare device id as int
device_fh repsents the device id for a specific virtio net device. Firstly, "int" would be big enough: we don't need 64 bit. Secondly, this could let us avoid the ugly "%" PRIu64 ".." stuff. And since ctx.fh is derived from device_fh, declare it as int, too. Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com> Tested-by: Rich Lane <rich.lane@bigswitch.com> Acked-by: Rich Lane <rich.lane@bigswitch.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/tep_termination/main.c14
-rw-r--r--examples/tep_termination/vxlan_setup.c4
-rw-r--r--examples/vhost/main.c45
3 files changed, 33 insertions, 30 deletions
diff --git a/examples/tep_termination/main.c b/examples/tep_termination/main.c
index aa67a6b..79373b3 100644
--- a/examples/tep_termination/main.c
+++ b/examples/tep_termination/main.c
@@ -568,7 +568,7 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m)
const uint16_t lcore_id = rte_lcore_id();
struct virtio_net *dev = vdev->dev;
- RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") TX: MAC address is external\n",
+ RTE_LOG(DEBUG, VHOST_DATA, "(%d) TX: MAC address is external\n",
dev->device_fh);
/* Add packet to the port tx queue */
@@ -944,7 +944,7 @@ destroy_device(volatile struct virtio_net *dev)
if (ll_lcore_dev_cur == NULL) {
RTE_LOG(ERR, VHOST_CONFIG,
- "(%"PRIu64") Failed to find the dev to be destroy.\n",
+ "(%d) Failed to find the dev to be destroy.\n",
dev->device_fh);
return;
}
@@ -992,7 +992,7 @@ destroy_device(volatile struct virtio_net *dev)
/* Decrement number of device on the lcore. */
lcore_info[vdev->coreid].lcore_ll->device_num--;
- RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Device has been removed "
+ RTE_LOG(INFO, VHOST_DATA, "(%d) Device has been removed "
"from data core\n", dev->device_fh);
rte_free(vdev);
@@ -1014,7 +1014,7 @@ new_device(struct virtio_net *dev)
vdev = rte_zmalloc("vhost device", sizeof(*vdev), RTE_CACHE_LINE_SIZE);
if (vdev == NULL) {
RTE_LOG(INFO, VHOST_DATA,
- "(%"PRIu64") Couldn't allocate memory for vhost dev\n",
+ "(%d) Couldn't allocate memory for vhost dev\n",
dev->device_fh);
return -1;
}
@@ -1023,7 +1023,7 @@ new_device(struct virtio_net *dev)
/* Add device to main ll */
ll_dev = get_data_ll_free_entry(&ll_root_free);
if (ll_dev == NULL) {
- RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") No free entry found in"
+ RTE_LOG(INFO, VHOST_DATA, "(%d) No free entry found in"
" linked list Device limit of %d devices per core"
" has been reached\n", dev->device_fh, nb_devices);
if (vdev->regions_hpa)
@@ -1050,7 +1050,7 @@ new_device(struct virtio_net *dev)
ll_dev = get_data_ll_free_entry(&lcore_info[core_add].lcore_ll->ll_root_free);
if (ll_dev == NULL) {
RTE_LOG(INFO, VHOST_DATA,
- "(%"PRIu64") Failed to add device to data core\n",
+ "(%d) Failed to add device to data core\n",
dev->device_fh);
vdev->ready = DEVICE_SAFE_REMOVE;
destroy_device(dev);
@@ -1074,7 +1074,7 @@ new_device(struct virtio_net *dev)
lcore_info[vdev->coreid].lcore_ll->device_num++;
dev->flags |= VIRTIO_DEV_RUNNING;
- RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Device has been added to data core %d\n",
+ RTE_LOG(INFO, VHOST_DATA, "(%d) Device has been added to data core %d\n",
dev->device_fh, vdev->coreid);
return 0;
diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index 2a48e14..778c447 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -252,7 +252,7 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
if (unlikely(portid > VXLAN_N_PORTS)) {
RTE_LOG(INFO, VHOST_DATA,
- "(%"PRIu64") WARNING: Not configuring device,"
+ "(%d) WARNING: Not configuring device,"
"as already have %d ports for VXLAN.",
dev->device_fh, VXLAN_N_PORTS);
return -1;
@@ -262,7 +262,7 @@ vxlan_link(struct vhost_dev *vdev, struct rte_mbuf *m)
pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
if (is_same_ether_addr(&(pkt_hdr->s_addr), &vdev->mac_address)) {
RTE_LOG(INFO, VHOST_DATA,
- "(%"PRIu64") WARNING: This device is using an existing"
+ "(%d) WARNING: This device is using an existing"
" MAC address and has not been registered.\n",
dev->device_fh);
return -1;
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index 1a0fe49..2266977 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -716,7 +716,7 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf *m)
if (find_vhost_dev(&pkt_hdr->s_addr)) {
RTE_LOG(ERR, VHOST_DATA,
- "Device (%" PRIu64 ") is using a registered MAC!\n",
+ "(%d) device is using a registered MAC!\n",
dev->device_fh);
return -1;
}
@@ -728,7 +728,8 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf *m)
vdev->vlan_tag = vlan_tags[dev->device_fh];
/* Print out VMDQ registration info. */
- RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") MAC_ADDRESS %02x:%02x:%02x:%02x:%02x:%02x and VLAN_TAG %d registered\n",
+ RTE_LOG(INFO, VHOST_DATA,
+ "(%d) mac %02x:%02x:%02x:%02x:%02x:%02x and vlan %d registered\n",
dev->device_fh,
vdev->mac_address.addr_bytes[0], vdev->mac_address.addr_bytes[1],
vdev->mac_address.addr_bytes[2], vdev->mac_address.addr_bytes[3],
@@ -739,8 +740,9 @@ link_vmdq(struct vhost_dev *vdev, struct rte_mbuf *m)
ret = rte_eth_dev_mac_addr_add(ports[0], &vdev->mac_address,
(uint32_t)dev->device_fh + vmdq_pool_base);
if (ret)
- RTE_LOG(ERR, VHOST_DATA, "(%"PRIu64") Failed to add device MAC address to VMDQ\n",
- dev->device_fh);
+ RTE_LOG(ERR, VHOST_DATA,
+ "(%d) failed to add device MAC address to VMDQ\n",
+ dev->device_fh);
/* Enable stripping of the vlan tag as we handle routing. */
if (vlan_strip)
@@ -812,7 +814,7 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m)
{
struct ether_hdr *pkt_hdr;
struct vhost_dev *dst_vdev;
- uint64_t fh;
+ int fh;
pkt_hdr = rte_pktmbuf_mtod(m, struct ether_hdr *);
@@ -823,17 +825,16 @@ virtio_tx_local(struct vhost_dev *vdev, struct rte_mbuf *m)
fh = dst_vdev->dev->device_fh;
if (fh == vdev->dev->device_fh) {
RTE_LOG(DEBUG, VHOST_DATA,
- "(%" PRIu64 ") TX: src and dst MAC is same. "
- "Dropping packet.\n", fh);
+ "(%d) TX: src and dst MAC is same. Dropping packet.\n",
+ fh);
return 0;
}
- RTE_LOG(DEBUG, VHOST_DATA,
- "(%" PRIu64 ") TX: MAC address is local\n", fh);
+ RTE_LOG(DEBUG, VHOST_DATA, "(%d) TX: MAC address is local\n", fh);
if (unlikely(dst_vdev->remove)) {
- RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") "
- "Device is marked for removal\n", fh);
+ RTE_LOG(DEBUG, VHOST_DATA,
+ "(%d) device is marked for removal\n", fh);
return 0;
}
@@ -858,8 +859,8 @@ find_local_dest(struct virtio_net *dev, struct rte_mbuf *m,
if (dst_vdev->dev->device_fh == dev->device_fh) {
RTE_LOG(DEBUG, VHOST_DATA,
- "(%" PRIu64 ") TX: src and dst MAC is same. "
- " Dropping packet.\n", dst_vdev->dev->device_fh);
+ "(%d) TX: src and dst MAC is same. Dropping packet.\n",
+ dst_vdev->dev->device_fh);
return -1;
}
@@ -872,8 +873,7 @@ find_local_dest(struct virtio_net *dev, struct rte_mbuf *m,
*vlan_tag = vlan_tags[(uint16_t)dst_vdev->dev->device_fh];
RTE_LOG(DEBUG, VHOST_DATA,
- "(%" PRIu64 ") TX: pkt to local VM device id: (%" PRIu64 ") "
- "vlan tag: %u.\n",
+ "(%d) TX: pkt to local VM device id (%d) vlan tag: %u.\n",
dev->device_fh, dst_vdev->dev->device_fh, *vlan_tag);
return 0;
@@ -964,8 +964,8 @@ virtio_tx_route(struct vhost_dev *vdev, struct rte_mbuf *m, uint16_t vlan_tag)
}
}
- RTE_LOG(DEBUG, VHOST_DATA, "(%" PRIu64 ") TX: "
- "MAC address is external\n", dev->device_fh);
+ RTE_LOG(DEBUG, VHOST_DATA,
+ "(%d) TX: MAC is external\n", dev->device_fh);
queue2nic:
@@ -1209,7 +1209,7 @@ destroy_device (volatile struct virtio_net *dev)
lcore_info[vdev->coreid].device_num--;
RTE_LOG(INFO, VHOST_DATA,
- "(%" PRIu64 ") Device has been removed from data core\n",
+ "(%d) device has been removed from data core\n",
dev->device_fh);
rte_free(vdev);
@@ -1228,7 +1228,8 @@ new_device (struct virtio_net *dev)
vdev = rte_zmalloc("vhost device", sizeof(*vdev), RTE_CACHE_LINE_SIZE);
if (vdev == NULL) {
- RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Couldn't allocate memory for vhost dev\n",
+ RTE_LOG(INFO, VHOST_DATA,
+ "(%d) Couldn't allocate memory for vhost dev\n",
dev->device_fh);
return -1;
}
@@ -1260,7 +1261,9 @@ new_device (struct virtio_net *dev)
rte_vhost_enable_guest_notification(dev, VIRTIO_RXQ, 0);
rte_vhost_enable_guest_notification(dev, VIRTIO_TXQ, 0);
- RTE_LOG(INFO, VHOST_DATA, "(%"PRIu64") Device has been added to data core %d\n", dev->device_fh, vdev->coreid);
+ RTE_LOG(INFO, VHOST_DATA,
+ "(%d) device has been added to data core %d\n",
+ dev->device_fh, vdev->coreid);
return 0;
}
@@ -1304,7 +1307,7 @@ print_stats(void)
rx = rte_atomic64_read(&vdev->stats.rx_atomic);
rx_dropped = rx_total - rx;
- printf("Statistics for device %" PRIu64 "\n"
+ printf("Statistics for device %d\n"
"-----------------------\n"
"TX total: %" PRIu64 "\n"
"TX dropped: %" PRIu64 "\n"