]> git.droids-corp.org - dpdk.git/commitdiff
vhost: declare device id as int
authorYuanhan Liu <yuanhan.liu@linux.intel.com>
Fri, 29 Apr 2016 20:45:51 +0000 (04:45 +0800)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 22 Jun 2016 06:59:54 +0000 (08:59 +0200)
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>
examples/tep_termination/main.c
examples/tep_termination/vxlan_setup.c
examples/vhost/main.c
lib/librte_vhost/rte_virtio_net.h
lib/librte_vhost/vhost-net.h
lib/librte_vhost/vhost_cuse/vhost-net-cdev.c
lib/librte_vhost/vhost_cuse/virtio-net-cdev.c
lib/librte_vhost/vhost_rxtx.c
lib/librte_vhost/vhost_user/vhost-net-user.c
lib/librte_vhost/vhost_user/virtio-net-user.c
lib/librte_vhost/virtio-net.c

index aa67a6b76f9526c6856b32d87d1f7387b4172280..79373b338d57de0a6fb4a80121941371b0c31219 100644 (file)
@@ -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;
index 2a48e1429a89b32f309b3aac1dfcdd6a3b03461f..778c4472e3d2a0e3f4f9cbfd46965857685116a0 100644 (file)
@@ -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;
index 1a0fe49ce0c5be4b23741fefaa797779a67610ed..2266977a5b4a4964716dfff48344434a7f57a832 100644 (file)
@@ -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"
index 4d25f7916b8e885a78bddb59387b483bfb4d38e7..da3af5f05db968f47f90e97c7ade9c58d73c7cd1 100644 (file)
@@ -133,7 +133,7 @@ struct virtio_net {
        struct virtio_memory    *mem;           /**< QEMU memory and memory region information. */
        uint64_t                features;       /**< Negotiated feature set. */
        uint64_t                protocol_features;      /**< Negotiated protocol feature set. */
-       uint64_t                device_fh;      /**< device identifier. */
+       int                     device_fh;      /**< device identifier. */
        uint32_t                flags;          /**< Device flags. Only used to check if device is running on data core. */
 #define IF_NAME_SZ (PATH_MAX > IFNAMSIZ ? PATH_MAX : IFNAMSIZ)
        char                    ifname[IF_NAME_SZ];     /**< Name of the tap device or socket path. */
index f193a1f6525c81f98c71b113723286384f254bcd..4b9d74d6666ab154f655e1804a4019dee2c6b8ac 100644 (file)
@@ -57,9 +57,9 @@
        char packet[VHOST_MAX_PRINT_BUFF]; \
        \
        if ((header)) \
-               snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%" PRIu64 ") Header size %d: ", (device->device_fh), (size)); \
+               snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%d) Header size %d: ", (device->device_fh), (size)); \
        else \
-               snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%" PRIu64 ") Packet size %d: ", (device->device_fh), (size)); \
+               snprintf(packet, VHOST_MAX_PRINT_BUFF, "(%d) Packet size %d: ", (device->device_fh), (size)); \
        for (index = 0; index < (size); index++) { \
                snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), \
                        "%02hhx ", pkt_addr[index]); \
@@ -79,8 +79,8 @@
  * Structure used to identify device context.
  */
 struct vhost_device_ctx {
-       pid_t           pid;    /* PID of process calling the IOCTL. */
-       uint64_t        fh;     /* Populated with fi->fh to track the device index. */
+       pid_t   pid;    /* PID of process calling the IOCTL. */
+       int     fh;     /* Populated with fi->fh to track the device index. */
 };
 
 int vhost_new_device(struct vhost_device_ctx);
index c613e68e8e231be96889542abc8915d2ee2aa565..17124fd0f754fe952bb1ec98520e741f0a86e35e 100644 (file)
@@ -94,7 +94,7 @@ vhost_net_open(fuse_req_t req, struct fuse_file_info *fi)
        fi->fh = err;
 
        RTE_LOG(INFO, VHOST_CONFIG,
-               "(%"PRIu64") Device configuration started\n", fi->fh);
+               "(%d) device configuration started\n", fi->fh);
        fuse_reply_open(req, fi);
 }
 
@@ -108,7 +108,7 @@ vhost_net_release(fuse_req_t req, struct fuse_file_info *fi)
        struct vhost_device_ctx ctx = fuse_req_to_vhost_ctx(req, fi);
 
        vhost_destroy_device(ctx);
-       RTE_LOG(INFO, VHOST_CONFIG, "(%"PRIu64") Device released\n", ctx.fh);
+       RTE_LOG(INFO, VHOST_CONFIG, "(%d) device released\n", ctx.fh);
        fuse_reply_err(req, err);
 }
 
@@ -194,7 +194,7 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
        switch (cmd) {
        case VHOST_NET_SET_BACKEND:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_NET_SET_BACKEND\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_NET_SET_BACKEND\n", ctx.fh);
                if (!in_buf) {
                        VHOST_IOCTL_RETRY(sizeof(file), 0);
                        break;
@@ -206,32 +206,32 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
 
        case VHOST_GET_FEATURES:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_GET_FEATURES\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_GET_FEATURES\n", ctx.fh);
                VHOST_IOCTL_W(uint64_t, features, vhost_get_features);
                break;
 
        case VHOST_SET_FEATURES:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_SET_FEATURES\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_SET_FEATURES\n", ctx.fh);
                VHOST_IOCTL_R(uint64_t, features, vhost_set_features);
                break;
 
        case VHOST_RESET_OWNER:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_RESET_OWNER\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_RESET_OWNER\n", ctx.fh);
                VHOST_IOCTL(vhost_reset_owner);
                break;
 
        case VHOST_SET_OWNER:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_SET_OWNER\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_SET_OWNER\n", ctx.fh);
                VHOST_IOCTL(vhost_set_owner);
                break;
 
        case VHOST_SET_MEM_TABLE:
                /*TODO fix race condition.*/
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_SET_MEM_TABLE\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_SET_MEM_TABLE\n", ctx.fh);
                static struct vhost_memory mem_temp;
 
                switch (in_bufsz) {
@@ -264,28 +264,28 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
 
        case VHOST_SET_VRING_NUM:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_SET_VRING_NUM\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_SET_VRING_NUM\n", ctx.fh);
                VHOST_IOCTL_R(struct vhost_vring_state, state,
                        vhost_set_vring_num);
                break;
 
        case VHOST_SET_VRING_BASE:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_SET_VRING_BASE\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_SET_VRING_BASE\n", ctx.fh);
                VHOST_IOCTL_R(struct vhost_vring_state, state,
                        vhost_set_vring_base);
                break;
 
        case VHOST_GET_VRING_BASE:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_GET_VRING_BASE\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_GET_VRING_BASE\n", ctx.fh);
                VHOST_IOCTL_RW(uint32_t, index,
                        struct vhost_vring_state, state, vhost_get_vring_base);
                break;
 
        case VHOST_SET_VRING_ADDR:
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: VHOST_SET_VRING_ADDR\n", ctx.fh);
+                       "(%d) IOCTL: VHOST_SET_VRING_ADDR\n", ctx.fh);
                VHOST_IOCTL_R(struct vhost_vring_addr, addr,
                        vhost_set_vring_addr);
                break;
@@ -294,11 +294,11 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
        case VHOST_SET_VRING_CALL:
                if (cmd == VHOST_SET_VRING_KICK)
                        LOG_DEBUG(VHOST_CONFIG,
-                               "(%"PRIu64") IOCTL: VHOST_SET_VRING_KICK\n",
+                               "(%d) IOCTL: VHOST_SET_VRING_KICK\n",
                        ctx.fh);
                else
                        LOG_DEBUG(VHOST_CONFIG,
-                               "(%"PRIu64") IOCTL: VHOST_SET_VRING_CALL\n",
+                               "(%d) IOCTL: VHOST_SET_VRING_CALL\n",
                        ctx.fh);
                if (!in_buf)
                        VHOST_IOCTL_RETRY(sizeof(struct vhost_vring_file), 0);
@@ -326,17 +326,17 @@ vhost_net_ioctl(fuse_req_t req, int cmd, void *arg,
 
        default:
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: DOESN NOT EXIST\n", ctx.fh);
+                       "(%d) IOCTL: DOESN NOT EXIST\n", ctx.fh);
                result = -1;
                fuse_reply_ioctl(req, result, NULL, 0);
        }
 
        if (result < 0)
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: FAIL\n", ctx.fh);
+                       "(%d) IOCTL: FAIL\n", ctx.fh);
        else
                LOG_DEBUG(VHOST_CONFIG,
-                       "(%"PRIu64") IOCTL: SUCCESS\n", ctx.fh);
+                       "(%d) IOCTL: SUCCESS\n", ctx.fh);
 }
 
 /*
index a68a8bd4468079ac52f026ab3cb513f66a99def9..69cc29285b35fc213abff2f8a786615c24c94714 100644 (file)
@@ -289,7 +289,7 @@ cuse_set_mem_table(struct vhost_device_ctx ctx,
                sizeof(struct virtio_memory_regions) * nregions);
        if (dev->mem == NULL) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") Failed to allocate memory for dev->mem\n",
+                       "(%d) failed to allocate memory for dev->mem\n",
                        dev->device_fh);
                return -1;
        }
@@ -393,8 +393,7 @@ get_ifname(struct vhost_device_ctx ctx, struct virtio_net *dev, int tap_fd, int
        ret = ioctl(fd_tap, TUNGETIFF, &ifr);
 
        if (close(fd_tap) < 0)
-               RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") fd close failed\n",
+               RTE_LOG(ERR, VHOST_CONFIG, "(%d) fd close failed\n",
                        dev->device_fh);
 
        if (ret >= 0) {
@@ -402,7 +401,7 @@ get_ifname(struct vhost_device_ctx ctx, struct virtio_net *dev, int tap_fd, int
                vhost_set_ifname(ctx, ifr.ifr_name, ifr_size);
        } else
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") TUNGETIFF ioctl failed\n",
+                       "(%d) TUNGETIFF ioctl failed\n",
                        dev->device_fh);
 
        return 0;
index 750821a44654503111956709eeb77b7662ed328b..a66456b600825e1be692b06c9cb4be4ba6ef847a 100644 (file)
@@ -264,11 +264,10 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
        uint16_t desc_indexes[MAX_PKT_BURST];
        uint32_t i;
 
-       LOG_DEBUG(VHOST_DATA, "(%"PRIu64") virtio_dev_rx()\n", dev->device_fh);
+       LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->device_fh, __func__);
        if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->virt_qp_nb))) {
-               RTE_LOG(ERR, VHOST_DATA,
-                       "%s (%"PRIu64"): virtqueue idx:%d invalid.\n",
-                       __func__, dev->device_fh, queue_id);
+               RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n",
+                       dev->device_fh, __func__, queue_id);
                return 0;
        }
 
@@ -280,8 +279,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
        if (count == 0)
                return 0;
 
-       LOG_DEBUG(VHOST_DATA,
-               "(%"PRIu64") res_start_idx %d| res_end_idx Index %d\n",
+       LOG_DEBUG(VHOST_DATA, "(%d) res_start_idx %d | res_end_idx Index %d\n",
                dev->device_fh, res_start_idx, res_end_idx);
 
        /* Retrieve all of the desc indexes first to avoid caching issues. */
@@ -443,8 +441,7 @@ copy_mbuf_to_desc_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
        if (unlikely(m == NULL))
                return 0;
 
-       LOG_DEBUG(VHOST_DATA,
-               "(%"PRIu64") Current Index %d| End Index %d\n",
+       LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n",
                dev->device_fh, cur_idx, res_end_idx);
 
        if (vq->buf_vec[vec_idx].buf_len < vq->vhost_hlen)
@@ -454,7 +451,7 @@ copy_mbuf_to_desc_mergeable(struct virtio_net *dev, struct vhost_virtqueue *vq,
        rte_prefetch0((void *)(uintptr_t)desc_addr);
 
        virtio_hdr.num_buffers = res_end_idx - res_start_idx;
-       LOG_DEBUG(VHOST_DATA, "(%"PRIu64") RX: Num merge buffers %d\n",
+       LOG_DEBUG(VHOST_DATA, "(%d) RX: num merge buffers %d\n",
                dev->device_fh, virtio_hdr.num_buffers);
 
        virtio_enqueue_offload(m, &virtio_hdr.hdr);
@@ -533,12 +530,10 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,
        uint32_t pkt_idx = 0, nr_used = 0;
        uint16_t start, end;
 
-       LOG_DEBUG(VHOST_DATA, "(%"PRIu64") virtio_dev_merge_rx()\n",
-               dev->device_fh);
+       LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->device_fh, __func__);
        if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->virt_qp_nb))) {
-               RTE_LOG(ERR, VHOST_DATA,
-                       "%s (%"PRIu64"): virtqueue idx:%d invalid.\n",
-                       __func__, dev->device_fh, queue_id);
+               RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n",
+                       dev->device_fh, __func__, queue_id);
                return 0;
        }
 
@@ -556,7 +551,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,
                if (unlikely(reserve_avail_buf_mergeable(vq, pkt_len,
                                                         &start, &end) < 0)) {
                        LOG_DEBUG(VHOST_DATA,
-                               "(%" PRIu64 ") Failed to get enough desc from vring\n",
+                               "(%d) failed to get enough desc from vring\n",
                                dev->device_fh);
                        break;
                }
@@ -832,9 +827,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
        uint16_t avail_idx;
 
        if (unlikely(!is_valid_virt_queue_idx(queue_id, 1, dev->virt_qp_nb))) {
-               RTE_LOG(ERR, VHOST_DATA,
-                       "%s (%"PRIu64"): virtqueue idx:%d invalid.\n",
-                       __func__, dev->device_fh, queue_id);
+               RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n",
+                       dev->device_fh, __func__, queue_id);
                return 0;
        }
 
@@ -870,7 +864,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
        if (free_entries == 0)
                goto out;
 
-       LOG_DEBUG(VHOST_DATA, "%s (%"PRIu64")\n", __func__, dev->device_fh);
+       LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->device_fh, __func__);
 
        /* Prefetch available ring to retrieve head indexes. */
        used_idx = vq->last_used_idx & (vq->size - 1);
@@ -878,7 +872,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
 
        count = RTE_MIN(count, MAX_PKT_BURST);
        count = RTE_MIN(count, free_entries);
-       LOG_DEBUG(VHOST_DATA, "(%"PRIu64") about to dequeue %u buffers\n",
+       LOG_DEBUG(VHOST_DATA, "(%d) about to dequeue %u buffers\n",
                        dev->device_fh, count);
 
        /* Retrieve all of the head indexes first to avoid caching issues. */
index df2bd6484f18a34d559ce5d3f678d39d4f4cafae..facbfa1ee023da3fc3dda0ad21ebaaaac6f54e5d 100644 (file)
@@ -58,7 +58,7 @@ static void vserver_message_handler(int fd, void *dat, int *remove);
 
 struct connfd_ctx {
        struct vhost_server *vserver;
-       uint32_t fh;
+       int fh;
 };
 
 #define MAX_VHOST_SERVER 1024
index e775e45210914b3ee0551e06b0793a30734dddc1..10daaa34ff0c5c326fb1750656a237886c7aa939 100644 (file)
@@ -132,7 +132,7 @@ user_set_mem_table(struct vhost_device_ctx ctx, struct VhostUserMsg *pmsg)
                sizeof(struct orig_region_map) * memory.nregions);
        if (dev->mem == NULL) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") Failed to allocate memory for dev->mem\n",
+                       "(%d) failed to allocate memory for dev->mem\n",
                        dev->device_fh);
                return -1;
        }
index c45ed1c5e36d369dc1121df6e7980d99bec62586..202e1969430bba06814b86500c65b840d194c751 100644 (file)
@@ -116,7 +116,7 @@ get_device(struct vhost_device_ctx ctx)
 
        if (unlikely(!dev)) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") device not found.\n", ctx.fh);
+                       "(%d) device not found.\n", ctx.fh);
        }
 
        return dev;
@@ -263,8 +263,7 @@ vhost_new_device(struct vhost_device_ctx ctx)
        dev = rte_zmalloc(NULL, sizeof(struct virtio_net), 0);
        if (dev == NULL) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") Failed to allocate memory for dev.\n",
-                       ctx.fh);
+                       "(%d) failed to allocate memory for dev.\n", ctx.fh);
                return -1;
        }
 
@@ -408,7 +407,7 @@ vhost_set_features(struct vhost_device_ctx ctx, uint64_t *pu)
                vhost_hlen = sizeof(struct virtio_net_hdr);
        }
        LOG_DEBUG(VHOST_CONFIG,
-               "(%"PRIu64") Mergeable RX buffers %s, virtio 1 %s\n",
+               "(%d) mergeable RX buffers %s, virtio 1 %s\n",
                dev->device_fh,
                (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off",
                (dev->features & (1ULL << VIRTIO_F_VERSION_1)) ? "on" : "off");
@@ -549,7 +548,7 @@ vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
                        addr->desc_user_addr);
        if (vq->desc == 0) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") Failed to find desc ring address.\n",
+                       "(%d) failed to find desc ring address.\n",
                        dev->device_fh);
                return -1;
        }
@@ -561,7 +560,7 @@ vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
                        addr->avail_user_addr);
        if (vq->avail == 0) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") Failed to find avail ring address.\n",
+                       "(%d) failed to find avail ring address.\n",
                        dev->device_fh);
                return -1;
        }
@@ -570,20 +569,20 @@ vhost_set_vring_addr(struct vhost_device_ctx ctx, struct vhost_vring_addr *addr)
                        addr->used_user_addr);
        if (vq->used == 0) {
                RTE_LOG(ERR, VHOST_CONFIG,
-                       "(%"PRIu64") Failed to find used ring address.\n",
+                       "(%d) failed to find used ring address.\n",
                        dev->device_fh);
                return -1;
        }
 
        vq->log_guest_addr = addr->log_guest_addr;
 
-       LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address desc: %p\n",
+       LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n",
                        dev->device_fh, vq->desc);
-       LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address avail: %p\n",
+       LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address avail: %p\n",
                        dev->device_fh, vq->avail);
-       LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") mapped address used: %p\n",
+       LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address used: %p\n",
                        dev->device_fh, vq->used);
-       LOG_DEBUG(VHOST_CONFIG, "(%"PRIu64") log_guest_addr: %"PRIx64"\n",
+       LOG_DEBUG(VHOST_CONFIG, "(%d) log_guest_addr: %" PRIx64 "\n",
                        dev->device_fh, vq->log_guest_addr);
 
        return 0;