vhost: add dynamic logging system
authorAdrian Moreno <amorenoz@redhat.com>
Wed, 4 Dec 2019 15:07:29 +0000 (16:07 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 17 Jan 2020 18:46:01 +0000 (19:46 +0100)
Currently there are a couple of limitations on the logging system: Most
of the logs are compiled out and both datapath and controlpath logs
share the same loglevel.

This patch tries to help fix that situation by:
- Splitting control plane and data plane logs
- Making control plane logs dynamic while keeping data plane logs
  compiled out by default for log levels lower than the INFO.

As a result, two macros are introduced:
- VHOST_LOG_CONFIG(LEVEL, ...): Config path logging. Level can be
  dynamically controlled by "lib.vhost.config"

- VHOST_LOG_DATA(LEVEL, ...): Data path logging. Level can be
  dynamically controlled by "lib.vhost.data". Every log macro with a
  level lower than RTE_LOG_DP_LEVEL (which defaults to RTE_LOG_INFO)
  will be compiled out.

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Acked-by: Tiwei Bie <tiwei.bie@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/iotlb.c
lib/librte_vhost/socket.c
lib/librte_vhost/vhost.c
lib/librte_vhost/vhost.h
lib/librte_vhost/vhost_user.c
lib/librte_vhost/virtio_net.c

index 4a1d8c1..bc17585 100644 (file)
@@ -70,14 +70,14 @@ vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq,
 
        ret = rte_mempool_get(vq->iotlb_pool, (void **)&node);
        if (ret) {
-               RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, clear entries\n");
+               VHOST_LOG_CONFIG(DEBUG, "IOTLB pool empty, clear entries\n");
                if (!TAILQ_EMPTY(&vq->iotlb_pending_list))
                        vhost_user_iotlb_pending_remove_all(vq);
                else
                        vhost_user_iotlb_cache_random_evict(vq);
                ret = rte_mempool_get(vq->iotlb_pool, (void **)&node);
                if (ret) {
-                       RTE_LOG(ERR, VHOST_CONFIG, "IOTLB pool still empty, failure\n");
+                       VHOST_LOG_CONFIG(ERR, "IOTLB pool still empty, failure\n");
                        return;
                }
        }
@@ -163,14 +163,14 @@ vhost_user_iotlb_cache_insert(struct vhost_virtqueue *vq, uint64_t iova,
 
        ret = rte_mempool_get(vq->iotlb_pool, (void **)&new_node);
        if (ret) {
-               RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, clear entries\n");
+               VHOST_LOG_CONFIG(DEBUG, "IOTLB pool empty, clear entries\n");
                if (!TAILQ_EMPTY(&vq->iotlb_list))
                        vhost_user_iotlb_cache_random_evict(vq);
                else
                        vhost_user_iotlb_pending_remove_all(vq);
                ret = rte_mempool_get(vq->iotlb_pool, (void **)&new_node);
                if (ret) {
-                       RTE_LOG(ERR, VHOST_CONFIG, "IOTLB pool still empty, failure\n");
+                       VHOST_LOG_CONFIG(ERR, "IOTLB pool still empty, failure\n");
                        return;
                }
        }
@@ -323,7 +323,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_index)
                        MEMPOOL_F_SP_PUT |
                        MEMPOOL_F_SC_GET);
        if (!vq->iotlb_pool) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "Failed to create IOTLB cache pool (%s)\n",
                                pool_name);
                return -1;
index ebb2ff6..ece9d5d 100644 (file)
@@ -127,12 +127,12 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds,
 
        ret = recvmsg(sockfd, &msgh, 0);
        if (ret <= 0) {
-               RTE_LOG(ERR, VHOST_CONFIG, "recvmsg failed\n");
+               VHOST_LOG_CONFIG(ERR, "recvmsg failed\n");
                return ret;
        }
 
        if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) {
-               RTE_LOG(ERR, VHOST_CONFIG, "truncated msg\n");
+               VHOST_LOG_CONFIG(ERR, "truncated msg\n");
                return -1;
        }
 
@@ -177,7 +177,7 @@ send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num)
                msgh.msg_controllen = sizeof(control);
                cmsg = CMSG_FIRSTHDR(&msgh);
                if (cmsg == NULL) {
-                       RTE_LOG(ERR, VHOST_CONFIG, "cmsg == NULL\n");
+                       VHOST_LOG_CONFIG(ERR, "cmsg == NULL\n");
                        errno = EINVAL;
                        return -1;
                }
@@ -195,7 +195,7 @@ send_fd_message(int sockfd, char *buf, int buflen, int *fds, int fd_num)
        } while (ret < 0 && errno == EINTR);
 
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,  "sendmsg error\n");
+               VHOST_LOG_CONFIG(ERR,  "sendmsg error\n");
                return ret;
        }
 
@@ -240,12 +240,12 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        if (vsocket->linearbuf)
                vhost_enable_linearbuf(vid);
 
-       RTE_LOG(INFO, VHOST_CONFIG, "new device, handle is %d\n", vid);
+       VHOST_LOG_CONFIG(INFO, "new device, handle is %d\n", vid);
 
        if (vsocket->notify_ops->new_connection) {
                ret = vsocket->notify_ops->new_connection(vid);
                if (ret < 0) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to add vhost user connection with fd %d\n",
                                fd);
                        goto err_cleanup;
@@ -258,7 +258,7 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        ret = fdset_add(&vhost_user.fdset, fd, vhost_user_read_cb,
                        NULL, conn);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to add fd %d into vhost server fdset\n",
                        fd);
 
@@ -292,7 +292,7 @@ vhost_user_server_new_connection(int fd, void *dat, int *remove __rte_unused)
        if (fd < 0)
                return;
 
-       RTE_LOG(INFO, VHOST_CONFIG, "new vhost user connection is %d\n", fd);
+       VHOST_LOG_CONFIG(INFO, "new vhost user connection is %d\n", fd);
        vhost_user_add_connection(fd, vsocket);
 }
 
@@ -340,11 +340,11 @@ create_unix_socket(struct vhost_user_socket *vsocket)
        fd = socket(AF_UNIX, SOCK_STREAM, 0);
        if (fd < 0)
                return -1;
-       RTE_LOG(INFO, VHOST_CONFIG, "vhost-user %s: socket created, fd: %d\n",
+       VHOST_LOG_CONFIG(INFO, "vhost-user %s: socket created, fd: %d\n",
                vsocket->is_server ? "server" : "client", fd);
 
        if (!vsocket->is_server && fcntl(fd, F_SETFL, O_NONBLOCK)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "vhost-user: can't set nonblocking mode for socket, fd: "
                        "%d (%s)\n", fd, strerror(errno));
                close(fd);
@@ -379,12 +379,12 @@ vhost_user_start_server(struct vhost_user_socket *vsocket)
         */
        ret = bind(fd, (struct sockaddr *)&vsocket->un, sizeof(vsocket->un));
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to bind to %s: %s; remove it and try again\n",
                        path, strerror(errno));
                goto err;
        }
-       RTE_LOG(INFO, VHOST_CONFIG, "bind to %s\n", path);
+       VHOST_LOG_CONFIG(INFO, "bind to %s\n", path);
 
        ret = listen(fd, MAX_VIRTIO_BACKLOG);
        if (ret < 0)
@@ -393,7 +393,7 @@ vhost_user_start_server(struct vhost_user_socket *vsocket)
        ret = fdset_add(&vhost_user.fdset, fd, vhost_user_server_new_connection,
                  NULL, vsocket);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to add listen fd %d to vhost server fdset\n",
                        fd);
                goto err;
@@ -434,12 +434,12 @@ vhost_user_connect_nonblock(int fd, struct sockaddr *un, size_t sz)
 
        flags = fcntl(fd, F_GETFL, 0);
        if (flags < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "can't get flags for connfd %d\n", fd);
                return -2;
        }
        if ((flags & O_NONBLOCK) && fcntl(fd, F_SETFL, flags & ~O_NONBLOCK)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "can't disable nonblocking on fd %d\n", fd);
                return -2;
        }
@@ -468,7 +468,7 @@ vhost_user_client_reconnect(void *arg __rte_unused)
                                                sizeof(reconn->un));
                        if (ret == -2) {
                                close(reconn->fd);
-                               RTE_LOG(ERR, VHOST_CONFIG,
+                               VHOST_LOG_CONFIG(ERR,
                                        "reconnection for fd %d failed\n",
                                        reconn->fd);
                                goto remove_fd;
@@ -476,7 +476,7 @@ vhost_user_client_reconnect(void *arg __rte_unused)
                        if (ret == -1)
                                continue;
 
-                       RTE_LOG(INFO, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(INFO,
                                "%s: connected\n", reconn->vsocket->path);
                        vhost_user_add_connection(reconn->fd, reconn->vsocket);
 remove_fd:
@@ -498,7 +498,7 @@ vhost_user_reconnect_init(void)
 
        ret = pthread_mutex_init(&reconn_list.mutex, NULL);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG, "failed to initialize mutex");
+               VHOST_LOG_CONFIG(ERR, "failed to initialize mutex");
                return ret;
        }
        TAILQ_INIT(&reconn_list.head);
@@ -506,9 +506,9 @@ vhost_user_reconnect_init(void)
        ret = rte_ctrl_thread_create(&reconn_tid, "vhost_reconn", NULL,
                             vhost_user_client_reconnect, NULL);
        if (ret != 0) {
-               RTE_LOG(ERR, VHOST_CONFIG, "failed to create reconnect thread");
+               VHOST_LOG_CONFIG(ERR, "failed to create reconnect thread");
                if (pthread_mutex_destroy(&reconn_list.mutex)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to destroy reconnect mutex");
                }
        }
@@ -531,7 +531,7 @@ vhost_user_start_client(struct vhost_user_socket *vsocket)
                return 0;
        }
 
-       RTE_LOG(WARNING, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(WARNING,
                "failed to connect to %s: %s\n",
                path, strerror(errno));
 
@@ -540,10 +540,10 @@ vhost_user_start_client(struct vhost_user_socket *vsocket)
                return -1;
        }
 
-       RTE_LOG(INFO, VHOST_CONFIG, "%s: reconnecting...\n", path);
+       VHOST_LOG_CONFIG(INFO, "%s: reconnecting...\n", path);
        reconn = malloc(sizeof(*reconn));
        if (reconn == NULL) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to allocate memory for reconnect\n");
                close(fd);
                return -1;
@@ -698,7 +698,7 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)
        pthread_mutex_lock(&vhost_user.mutex);
        vsocket = find_vhost_user_socket(path);
        if (!vsocket) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "socket file %s is not registered yet.\n", path);
                ret = -1;
                goto unlock_exit;
@@ -712,7 +712,7 @@ rte_vhost_driver_get_features(const char *path, uint64_t *features)
        }
 
        if (vdpa_dev->ops->get_features(did, &vdpa_features) < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "failed to get vdpa features "
                                "for socket file %s.\n", path);
                ret = -1;
@@ -753,7 +753,7 @@ rte_vhost_driver_get_protocol_features(const char *path,
        pthread_mutex_lock(&vhost_user.mutex);
        vsocket = find_vhost_user_socket(path);
        if (!vsocket) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "socket file %s is not registered yet.\n", path);
                ret = -1;
                goto unlock_exit;
@@ -768,7 +768,7 @@ rte_vhost_driver_get_protocol_features(const char *path,
 
        if (vdpa_dev->ops->get_protocol_features(did,
                                &vdpa_protocol_features) < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "failed to get vdpa protocol features "
                                "for socket file %s.\n", path);
                ret = -1;
@@ -795,7 +795,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)
        pthread_mutex_lock(&vhost_user.mutex);
        vsocket = find_vhost_user_socket(path);
        if (!vsocket) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "socket file %s is not registered yet.\n", path);
                ret = -1;
                goto unlock_exit;
@@ -809,7 +809,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32_t *queue_num)
        }
 
        if (vdpa_dev->ops->get_queue_num(did, &vdpa_queue_num) < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "failed to get vdpa queue number "
                                "for socket file %s.\n", path);
                ret = -1;
@@ -854,7 +854,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
        pthread_mutex_lock(&vhost_user.mutex);
 
        if (vhost_user.vsocket_cnt == MAX_VHOST_SOCKET) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "error: the number of vhost sockets reaches maximum\n");
                goto out;
        }
@@ -865,7 +865,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
        memset(vsocket, 0, sizeof(struct vhost_user_socket));
        vsocket->path = strdup(path);
        if (vsocket->path == NULL) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "error: failed to copy socket path string\n");
                vhost_user_socket_mem_free(vsocket);
                goto out;
@@ -873,7 +873,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
        TAILQ_INIT(&vsocket->conn_list);
        ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
        if (ret) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "error: failed to init connection mutex\n");
                goto out_free;
        }
@@ -883,7 +883,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 
        if (vsocket->dequeue_zero_copy &&
            (flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "error: enabling dequeue zero copy and IOMMU features "
                        "simultaneously is not supported\n");
                goto out_mutex;
@@ -913,13 +913,13 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
         */
        if (vsocket->dequeue_zero_copy) {
                if (vsocket->extbuf) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                        "error: zero copy is incompatible with external buffers\n");
                        ret = -1;
                        goto out_mutex;
                }
                if (vsocket->linearbuf) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                        "error: zero copy is incompatible with linear buffers\n");
                        ret = -1;
                        goto out_mutex;
@@ -927,7 +927,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
                vsocket->supported_features &= ~(1ULL << VIRTIO_F_IN_ORDER);
                vsocket->features &= ~(1ULL << VIRTIO_F_IN_ORDER);
 
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "Dequeue zero copy requested, disabling postcopy support\n");
                vsocket->protocol_features &=
                        ~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT);
@@ -944,7 +944,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
                                (1ULL << VIRTIO_NET_F_HOST_TSO6) |
                                (1ULL << VIRTIO_NET_F_HOST_UFO);
 
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "Linear buffers requested without external buffers, "
                        "disabling host segmentation offloading support\n");
                vsocket->supported_features &= ~seg_offload_features;
@@ -961,7 +961,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
                        ~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT);
        } else {
 #ifndef RTE_LIBRTE_VHOST_POSTCOPY
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Postcopy requested but not compiled\n");
                ret = -1;
                goto out_mutex;
@@ -989,7 +989,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
 
 out_mutex:
        if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "error: failed to destroy connection mutex\n");
        }
 out_free:
@@ -1063,7 +1063,7 @@ again:
                                        goto again;
                                }
 
-                               RTE_LOG(INFO, VHOST_CONFIG,
+                               VHOST_LOG_CONFIG(INFO,
                                        "free connfd = %d for device '%s'\n",
                                        conn->connfd, path);
                                close(conn->connfd);
@@ -1147,7 +1147,7 @@ rte_vhost_driver_start(const char *path)
                 * rebuild the wait list of poll.
                 */
                if (fdset_pipe_init(&vhost_user.fdset) < 0) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to create pipe for vhost fdset\n");
                        return -1;
                }
@@ -1156,7 +1156,7 @@ rte_vhost_driver_start(const char *path)
                        "vhost-events", NULL, fdset_event_dispatch,
                        &vhost_user.fdset);
                if (ret != 0) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to create fdset handling thread");
 
                        fdset_pipe_uninit(&vhost_user.fdset);
index 1cbe948..c819a84 100644 (file)
@@ -27,6 +27,9 @@
 
 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE];
 
+int vhost_config_log_level;
+int vhost_data_log_level;
+
 /* Called with iotlb_lock read-locked */
 uint64_t
 __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
@@ -57,7 +60,7 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
                vhost_user_iotlb_pending_insert(vq, iova, perm);
                if (vhost_user_iotlb_miss(dev, iova, perm)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "IOTLB miss req failed for IOVA 0x%" PRIx64 "\n",
                                iova);
                        vhost_user_iotlb_pending_remove(vq, iova, 1, perm);
@@ -124,7 +127,7 @@ __vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
        hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW);
        if (map_len != len) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_DATA(ERR,
                        "Failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found\n",
                        iova);
                return;
@@ -229,7 +232,7 @@ __vhost_log_cache_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
        hva = __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW);
        if (map_len != len) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_DATA(ERR,
                        "Failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found\n",
                        iova);
                return;
@@ -461,7 +464,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
        struct vhost_virtqueue *vq;
 
        if (vring_idx >= VHOST_MAX_VRING) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "Failed not init vring, out of bound (%d)\n",
                                vring_idx);
                return;
@@ -488,7 +491,7 @@ reset_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
        int callfd;
 
        if (vring_idx >= VHOST_MAX_VRING) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "Failed not init vring, out of bound (%d)\n",
                                vring_idx);
                return;
@@ -507,7 +510,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vring_idx)
 
        vq = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0);
        if (vq == NULL) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Failed to allocate memory for vring:%u.\n", vring_idx);
                return -1;
        }
@@ -558,14 +561,14 @@ vhost_new_device(void)
        }
 
        if (i == MAX_VHOST_DEVICE) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Failed to find a free slot for new device.\n");
                return -1;
        }
 
        dev = rte_zmalloc(NULL, sizeof(struct virtio_net), 0);
        if (dev == NULL) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Failed to allocate memory for new dev.\n");
                return -1;
        }
@@ -728,7 +731,7 @@ rte_vhost_get_numa_node(int vid)
        ret = get_mempolicy(&numa_node, NULL, 0, dev,
                            MPOL_F_NODE | MPOL_F_ADDR);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "(%d) failed to query numa node: %s\n",
                        vid, rte_strerror(errno));
                return -1;
@@ -1322,7 +1325,7 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid)
                return 0;
 
        if (unlikely(qid >= dev->nr_vring || (qid & 1) == 0)) {
-               RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n",
+               VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",
                        dev->vid, __func__, qid);
                return 0;
        }
@@ -1457,3 +1460,14 @@ int rte_vhost_extern_callback_register(int vid,
        dev->extern_data = ctx;
        return 0;
 }
+
+RTE_INIT(vhost_log_init)
+{
+       vhost_config_log_level = rte_log_register("lib.vhost.config");
+       if (vhost_config_log_level >= 0)
+               rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO);
+
+       vhost_data_log_level = rte_log_register("lib.vhost.data");
+       if (vhost_data_log_level >= 0)
+               rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING);
+}
index 9f11b28..686ce42 100644 (file)
@@ -498,14 +498,21 @@ vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
                __vhost_log_write(dev, iova, len);
 }
 
-/* Macros for printing using RTE_LOG */
-#define RTE_LOGTYPE_VHOST_CONFIG RTE_LOGTYPE_USER1
-#define RTE_LOGTYPE_VHOST_DATA   RTE_LOGTYPE_USER1
+extern int vhost_config_log_level;
+extern int vhost_data_log_level;
+
+#define VHOST_LOG_CONFIG(level, fmt, args...)                  \
+       rte_log(RTE_LOG_ ## level, vhost_config_log_level,      \
+               "VHOST_CONFIG: " fmt, ##args)
+
+#define VHOST_LOG_DATA(level, fmt, args...) \
+       (void)((RTE_LOG_ ## level <= RTE_LOG_DP_LEVEL) ?        \
+        rte_log(RTE_LOG_ ## level,  vhost_data_log_level,      \
+               "VHOST_DATA : " fmt, ##args) :                  \
+        0)
 
 #ifdef RTE_LIBRTE_VHOST_DEBUG
 #define VHOST_MAX_PRINT_BUFF 6072
-#define VHOST_LOG_DEBUG(log_type, fmt, args...) \
-       RTE_LOG(DEBUG, log_type, fmt, ##args)
 #define PRINT_PACKET(device, addr, size, header) do { \
        char *pkt_addr = (char *)(addr); \
        unsigned int index; \
@@ -521,10 +528,9 @@ vhost_log_write_iova(struct virtio_net *dev, struct vhost_virtqueue *vq,
        } \
        snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRINT_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), "\n"); \
        \
-       VHOST_LOG_DEBUG(VHOST_DATA, "%s", packet); \
+       VHOST_LOG_DATA(DEBUG, "%s", packet); \
 } while (0)
 #else
-#define VHOST_LOG_DEBUG(log_type, fmt, args...) do {} while (0)
 #define PRINT_PACKET(device, addr, size, header) do {} while (0)
 #endif
 
@@ -578,7 +584,7 @@ get_device(int vid)
        struct virtio_net *dev = vhost_devices[vid];
 
        if (unlikely(!dev)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "(%d) device not found.\n", vid);
        }
 
@@ -664,7 +670,7 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
                vq->signalled_used = new;
                vq->signalled_used_valid = true;
 
-               VHOST_LOG_DEBUG(VHOST_DATA, "%s: used_event_idx=%d, old=%d, new=%d\n",
+               VHOST_LOG_DATA(DEBUG, "%s: used_event_idx=%d, old=%d, new=%d\n",
                        __func__,
                        vhost_used_event(vq),
                        old, new);
index 0cfb8b7..47db316 100644 (file)
@@ -111,7 +111,7 @@ validate_msg_fds(struct VhostUserMsg *msg, int expected_fds)
        if (msg->fd_num == expected_fds)
                return 0;
 
-       RTE_LOG(ERR, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(ERR,
                " Expect %d FDs for request %s, received %d\n",
                expected_fds,
                vhost_message_str[msg->request.master],
@@ -322,7 +322,7 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
        rte_vhost_driver_get_features(dev->ifname, &vhost_features);
        if (features & ~vhost_features) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "(%d) received invalid negotiated features.\n",
                        dev->vid);
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -338,7 +338,7 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,
                 * is enabled when the live-migration starts.
                 */
                if ((dev->features ^ features) & ~(1ULL << VHOST_F_LOG_ALL)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "(%d) features changed while device is running.\n",
                                dev->vid);
                        return RTE_VHOST_MSG_RESULT_ERR;
@@ -355,9 +355,9 @@ vhost_user_set_features(struct virtio_net **pdev, struct VhostUserMsg *msg,
        } else {
                dev->vhost_hlen = sizeof(struct virtio_net_hdr);
        }
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "negotiated Virtio features: 0x%" PRIx64 "\n", dev->features);
-       VHOST_LOG_DEBUG(VHOST_CONFIG,
+       VHOST_LOG_CONFIG(DEBUG,
                "(%d) mergeable RX buffers %s, virtio 1 %s\n",
                dev->vid,
                (dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off",
@@ -419,14 +419,14 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
         */
        if (!vq_is_packed(dev)) {
                if (vq->size & (vq->size - 1)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "invalid virtqueue size %u\n", vq->size);
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
        }
 
        if (vq->size > 32768) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "invalid virtqueue size %u\n", vq->size);
                return RTE_VHOST_MSG_RESULT_ERR;
        }
@@ -440,7 +440,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
                vq->zmbufs = rte_zmalloc(NULL, vq->zmbuf_size *
                                         sizeof(struct zcopy_mbuf), 0);
                if (vq->zmbufs == NULL) {
-                       RTE_LOG(WARNING, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(WARNING,
                                "failed to allocate mem for zero copy; "
                                "zero copy is force disabled\n");
                        dev->dequeue_zero_copy = 0;
@@ -456,7 +456,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
                                sizeof(struct vring_used_elem_packed),
                                RTE_CACHE_LINE_SIZE);
                if (!vq->shadow_used_packed) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                        "failed to allocate memory for shadow used ring.\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -468,7 +468,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
                                vq->size * sizeof(struct vring_used_elem),
                                RTE_CACHE_LINE_SIZE);
                if (!vq->shadow_used_split) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                        "failed to allocate memory for shadow used ring.\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -480,7 +480,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev,
                                vq->size * sizeof(struct batch_copy_elem),
                                RTE_CACHE_LINE_SIZE);
        if (!vq->batch_copy_elems) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to allocate memory for batching copy.\n");
                return RTE_VHOST_MSG_RESULT_ERR;
        }
@@ -518,12 +518,12 @@ numa_realloc(struct virtio_net *dev, int index)
        ret |= get_mempolicy(&oldnode, NULL, 0, old_vq,
                             MPOL_F_NODE | MPOL_F_ADDR);
        if (ret) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Unable to get vq numa information.\n");
                return dev;
        }
        if (oldnode != newnode) {
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "reallocate vq from %d to %d node\n", oldnode, newnode);
                vq = rte_malloc_socket(NULL, sizeof(*vq), 0, newnode);
                if (!vq)
@@ -579,12 +579,12 @@ numa_realloc(struct virtio_net *dev, int index)
        ret = get_mempolicy(&oldnode, NULL, 0, old_dev,
                            MPOL_F_NODE | MPOL_F_ADDR);
        if (ret) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Unable to get dev numa information.\n");
                goto out;
        }
        if (oldnode != newnode) {
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "reallocate dev from %d to %d node\n",
                        oldnode, newnode);
                dev = rte_malloc_socket(NULL, sizeof(*dev), 0, newnode);
@@ -692,7 +692,7 @@ translate_log_addr(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
                gpa = hva_to_gpa(dev, hva, exp_size);
                if (!gpa) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "VQ: Failed to find GPA for log_addr: 0x%" PRIx64 " hva: 0x%" PRIx64 "\n",
                                log_addr, hva);
                        return 0;
@@ -714,7 +714,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
                vq->log_guest_addr =
                        translate_log_addr(dev, vq, addr->log_guest_addr);
                if (vq->log_guest_addr == 0) {
-                       RTE_LOG(DEBUG, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(DEBUG,
                                "(%d) failed to map log_guest_addr.\n",
                                dev->vid);
                        return dev;
@@ -728,7 +728,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
                if (vq->desc_packed == NULL ||
                                len != sizeof(struct vring_packed_desc) *
                                vq->size) {
-                       RTE_LOG(DEBUG, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(DEBUG,
                                "(%d) failed to map desc_packed ring.\n",
                                dev->vid);
                        return dev;
@@ -744,7 +744,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
                                        vq, addr->avail_user_addr, &len);
                if (vq->driver_event == NULL ||
                                len != sizeof(struct vring_packed_desc_event)) {
-                       RTE_LOG(DEBUG, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(DEBUG,
                                "(%d) failed to find driver area address.\n",
                                dev->vid);
                        return dev;
@@ -756,7 +756,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
                                        vq, addr->used_user_addr, &len);
                if (vq->device_event == NULL ||
                                len != sizeof(struct vring_packed_desc_event)) {
-                       RTE_LOG(DEBUG, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(DEBUG,
                                "(%d) failed to find device area address.\n",
                                dev->vid);
                        return dev;
@@ -774,7 +774,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
        vq->desc = (struct vring_desc *)(uintptr_t)ring_addr_to_vva(dev,
                        vq, addr->desc_user_addr, &len);
        if (vq->desc == 0 || len != sizeof(struct vring_desc) * vq->size) {
-               RTE_LOG(DEBUG, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(DEBUG,
                        "(%d) failed to map desc ring.\n",
                        dev->vid);
                return dev;
@@ -791,7 +791,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
        vq->avail = (struct vring_avail *)(uintptr_t)ring_addr_to_vva(dev,
                        vq, addr->avail_user_addr, &len);
        if (vq->avail == 0 || len != expected_len) {
-               RTE_LOG(DEBUG, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(DEBUG,
                        "(%d) failed to map avail ring.\n",
                        dev->vid);
                return dev;
@@ -805,14 +805,14 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
        vq->used = (struct vring_used *)(uintptr_t)ring_addr_to_vva(dev,
                        vq, addr->used_user_addr, &len);
        if (vq->used == 0 || len != expected_len) {
-               RTE_LOG(DEBUG, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(DEBUG,
                        "(%d) failed to map used ring.\n",
                        dev->vid);
                return dev;
        }
 
        if (vq->last_used_idx != vq->used->idx) {
-               RTE_LOG(WARNING, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(WARNING,
                        "last_used_idx (%u) and vq->used->idx (%u) mismatches; "
                        "some packets maybe resent for Tx and dropped for Rx\n",
                        vq->last_used_idx, vq->used->idx);
@@ -822,13 +822,13 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
 
        vq->access_ok = 1;
 
-       VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n",
+       VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address desc: %p\n",
                        dev->vid, vq->desc);
-       VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address avail: %p\n",
+       VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address avail: %p\n",
                        dev->vid, vq->avail);
-       VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address used: %p\n",
+       VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address used: %p\n",
                        dev->vid, vq->used);
-       VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) log_guest_addr: %" PRIx64 "\n",
+       VHOST_LOG_CONFIG(DEBUG, "(%d) log_guest_addr: %" PRIx64 "\n",
                        dev->vid, vq->log_guest_addr);
 
        return dev;
@@ -929,7 +929,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t guest_phys_addr,
                dev->guest_pages = realloc(dev->guest_pages,
                                        dev->max_guest_pages * sizeof(*page));
                if (!dev->guest_pages) {
-                       RTE_LOG(ERR, VHOST_CONFIG, "cannot realloc guest_pages\n");
+                       VHOST_LOG_CONFIG(ERR, "cannot realloc guest_pages\n");
                        free(old_pages);
                        return -1;
                }
@@ -1001,7 +1001,7 @@ dump_guest_pages(struct virtio_net *dev)
        for (i = 0; i < dev->nr_guest_pages; i++) {
                page = &dev->guest_pages[i];
 
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "guest physical page region %u\n"
                        "\t guest_phys_addr: %" PRIx64 "\n"
                        "\t host_phys_addr : %" PRIx64 "\n"
@@ -1059,13 +1059,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
                return RTE_VHOST_MSG_RESULT_ERR;
 
        if (memory->nregions > VHOST_MEMORY_MAX_NREGIONS) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "too many memory regions (%u)\n", memory->nregions);
                return RTE_VHOST_MSG_RESULT_ERR;
        }
 
        if (dev->mem && !vhost_memory_changed(memory, dev->mem)) {
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "(%d) memory regions not changed\n", dev->vid);
 
                close_msg_fds(msg);
@@ -1090,7 +1090,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
                dev->guest_pages = malloc(dev->max_guest_pages *
                                                sizeof(struct guest_page));
                if (dev->guest_pages == NULL) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "(%d) failed to allocate memory "
                                "for dev->guest_pages\n",
                                dev->vid);
@@ -1101,7 +1101,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
        dev->mem = rte_zmalloc("vhost-mem-table", sizeof(struct rte_vhost_memory) +
                sizeof(struct rte_vhost_mem_region) * memory->nregions, 0);
        if (dev->mem == NULL) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "(%d) failed to allocate memory for dev->mem\n",
                        dev->vid);
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -1121,7 +1121,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
                /* Check for memory_size + mmap_offset overflow */
                if (mmap_offset >= -reg->size) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "mmap_offset (%#"PRIx64") and memory_size "
                                "(%#"PRIx64") overflow\n",
                                mmap_offset, reg->size);
@@ -1140,7 +1140,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
                 */
                alignment = get_blk_size(fd);
                if (alignment == (uint64_t)-1) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "couldn't get hugepage size through fstat\n");
                        goto err_mmap;
                }
@@ -1151,7 +1151,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
                                 MAP_SHARED | populate, fd, 0);
 
                if (mmap_addr == MAP_FAILED) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "mmap region %u failed.\n", i);
                        goto err_mmap;
                }
@@ -1163,13 +1163,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
                if (dev->dequeue_zero_copy)
                        if (add_guest_pages(dev, reg, alignment) < 0) {
-                               RTE_LOG(ERR, VHOST_CONFIG,
+                               VHOST_LOG_CONFIG(ERR,
                                        "adding guest pages to region %u failed.\n",
                                        i);
                                goto err_mmap;
                        }
 
-               RTE_LOG(INFO, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(INFO,
                        "guest memory region %u, size: 0x%" PRIx64 "\n"
                        "\t guest physical addr: 0x%" PRIx64 "\n"
                        "\t guest virtual  addr: 0x%" PRIx64 "\n"
@@ -1207,7 +1207,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
                 */
                VhostUserMsg ack_msg;
                if (read_vhost_message(main_fd, &ack_msg) <= 0) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "Failed to read qemu ack on postcopy set-mem-table\n");
                        goto err_mmap;
                }
@@ -1216,7 +1216,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
                        goto err_mmap;
 
                if (ack_msg.request.master != VHOST_USER_SET_MEM_TABLE) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "Bad qemu ack on postcopy set-mem-table (%d)\n",
                                ack_msg.request.master);
                        goto err_mmap;
@@ -1239,13 +1239,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
                        if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER,
                                                &reg_struct)) {
-                               RTE_LOG(ERR, VHOST_CONFIG,
+                               VHOST_LOG_CONFIG(ERR,
                                        "Failed to register ufd for region %d: (ufd = %d) %s\n",
                                        i, dev->postcopy_ufd,
                                        strerror(errno));
                                goto err_mmap;
                        }
-                       RTE_LOG(INFO, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(INFO,
                                "\t userfaultfd registered for range : "
                                "%" PRIx64 " - %" PRIx64 "\n",
                                (uint64_t)reg_struct.range.start,
@@ -1323,7 +1323,7 @@ virtio_is_ready(struct virtio_net *dev)
                        return 0;
        }
 
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "virtio is now ready for processing.\n");
        return 1;
 }
@@ -1344,7 +1344,7 @@ inflight_mem_alloc(const char *name, size_t size, int *fd)
        if (mfd == -1) {
                mfd = mkstemp(fname);
                if (mfd == -1) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to get inflight buffer fd\n");
                        return NULL;
                }
@@ -1353,7 +1353,7 @@ inflight_mem_alloc(const char *name, size_t size, int *fd)
        }
 
        if (ftruncate(mfd, size) == -1) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to alloc inflight buffer\n");
                close(mfd);
                return NULL;
@@ -1361,7 +1361,7 @@ inflight_mem_alloc(const char *name, size_t size, int *fd)
 
        ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0);
        if (ptr == MAP_FAILED) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to mmap inflight buffer\n");
                close(mfd);
                return NULL;
@@ -1401,7 +1401,7 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
        void *addr;
 
        if (msg->size != sizeof(msg->payload.inflight)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "invalid get_inflight_fd message size is %d\n",
                        msg->size);
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -1411,7 +1411,7 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
                dev->inflight_info = calloc(1,
                                            sizeof(struct inflight_mem_info));
                if (!dev->inflight_info) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to alloc dev inflight area\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -1420,9 +1420,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
        num_queues = msg->payload.inflight.num_queues;
        queue_size = msg->payload.inflight.queue_size;
 
-       RTE_LOG(INFO, VHOST_CONFIG, "get_inflight_fd num_queues: %u\n",
+       VHOST_LOG_CONFIG(INFO, "get_inflight_fd num_queues: %u\n",
                msg->payload.inflight.num_queues);
-       RTE_LOG(INFO, VHOST_CONFIG, "get_inflight_fd queue_size: %u\n",
+       VHOST_LOG_CONFIG(INFO, "get_inflight_fd queue_size: %u\n",
                msg->payload.inflight.queue_size);
 
        if (vq_is_packed(dev))
@@ -1433,7 +1433,7 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
        mmap_size = num_queues * pervq_inflight_size;
        addr = inflight_mem_alloc("vhost-inflight", mmap_size, &fd);
        if (!addr) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to alloc vhost inflight area\n");
                        msg->payload.inflight.mmap_size = 0;
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -1458,13 +1458,13 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev,
                }
        }
 
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "send inflight mmap_size: %"PRIu64"\n",
                msg->payload.inflight.mmap_size);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "send inflight mmap_offset: %"PRIu64"\n",
                msg->payload.inflight.mmap_offset);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "send inflight fd: %d\n", msg->fds[0]);
 
        return RTE_VHOST_MSG_RESULT_REPLY;
@@ -1484,7 +1484,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
 
        fd = msg->fds[0];
        if (msg->size != sizeof(msg->payload.inflight) || fd < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "invalid set_inflight_fd message size is %d,fd is %d\n",
                        msg->size, fd);
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -1500,17 +1500,17 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
        else
                pervq_inflight_size = get_pervq_shm_size_split(queue_size);
 
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set_inflight_fd mmap_size: %"PRIu64"\n", mmap_size);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set_inflight_fd mmap_offset: %"PRIu64"\n", mmap_offset);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set_inflight_fd num_queues: %u\n", num_queues);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set_inflight_fd queue_size: %u\n", queue_size);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set_inflight_fd fd: %d\n", fd);
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set_inflight_fd pervq_inflight_size: %d\n",
                pervq_inflight_size);
 
@@ -1518,7 +1518,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
                dev->inflight_info = calloc(1,
                                            sizeof(struct inflight_mem_info));
                if (dev->inflight_info == NULL) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to alloc dev inflight area\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -1530,7 +1530,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, VhostUserMsg *msg,
        addr = mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
                    fd, mmap_offset);
        if (addr == MAP_FAILED) {
-               RTE_LOG(ERR, VHOST_CONFIG, "failed to mmap share memory.\n");
+               VHOST_LOG_CONFIG(ERR, "failed to mmap share memory.\n");
                return RTE_VHOST_MSG_RESULT_ERR;
        }
 
@@ -1574,7 +1574,7 @@ vhost_user_set_vring_call(struct virtio_net **pdev, struct VhostUserMsg *msg,
                file.fd = VIRTIO_INVALID_EVENTFD;
        else
                file.fd = msg->fds[0];
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "vring call idx:%d file:%d\n", file.index, file.fd);
 
        vq = dev->virtqueue[file.index];
@@ -1598,7 +1598,7 @@ static int vhost_user_set_vring_err(struct virtio_net **pdev __rte_unused,
 
        if (!(msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK))
                close(msg->fds[0]);
-       RTE_LOG(INFO, VHOST_CONFIG, "not implemented\n");
+       VHOST_LOG_CONFIG(INFO, "not implemented\n");
 
        return RTE_VHOST_MSG_RESULT_OK;
 }
@@ -1660,7 +1660,7 @@ vhost_check_queue_inflights_split(struct virtio_net *dev,
        if (resubmit_num) {
                resubmit  = calloc(1, sizeof(struct rte_vhost_resubmit_info));
                if (!resubmit) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to allocate memory for resubmit info.\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -1668,7 +1668,7 @@ vhost_check_queue_inflights_split(struct virtio_net *dev,
                resubmit->resubmit_list = calloc(resubmit_num,
                        sizeof(struct rte_vhost_resubmit_desc));
                if (!resubmit->resubmit_list) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to allocate memory for inflight desc.\n");
                        free(resubmit);
                        return RTE_VHOST_MSG_RESULT_ERR;
@@ -1751,7 +1751,7 @@ vhost_check_queue_inflights_packed(struct virtio_net *dev,
        if (resubmit_num) {
                resubmit = calloc(1, sizeof(struct rte_vhost_resubmit_info));
                if (resubmit == NULL) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to allocate memory for resubmit info.\n");
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -1759,7 +1759,7 @@ vhost_check_queue_inflights_packed(struct virtio_net *dev,
                resubmit->resubmit_list = calloc(resubmit_num,
                        sizeof(struct rte_vhost_resubmit_desc));
                if (resubmit->resubmit_list == NULL) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to allocate memory for resubmit desc.\n");
                        free(resubmit);
                        return RTE_VHOST_MSG_RESULT_ERR;
@@ -1806,7 +1806,7 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *msg,
                file.fd = VIRTIO_INVALID_EVENTFD;
        else
                file.fd = msg->fds[0];
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "vring kick idx:%d file:%d\n", file.index, file.fd);
 
        /* Interpret ring addresses only when ring is started. */
@@ -1836,13 +1836,13 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
        if (vq_is_packed(dev)) {
                if (vhost_check_queue_inflights_packed(dev, vq)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to inflights for vq: %d\n", file.index);
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
        } else {
                if (vhost_check_queue_inflights_split(dev, vq)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to inflights for vq: %d\n", file.index);
                        return RTE_VHOST_MSG_RESULT_ERR;
                }
@@ -1893,7 +1893,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
                msg->payload.state.num = vq->last_avail_idx;
        }
 
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "vring base idx:%d file:%d\n", msg->payload.state.index,
                msg->payload.state.num);
        /*
@@ -1952,7 +1952,7 @@ vhost_user_set_vring_enable(struct virtio_net **pdev,
        if (validate_msg_fds(msg, 0) != 0)
                return RTE_VHOST_MSG_RESULT_ERR;
 
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "set queue enable: %d to qp idx: %d\n",
                enable, index);
 
@@ -2019,14 +2019,14 @@ vhost_user_set_protocol_features(struct virtio_net **pdev,
        rte_vhost_driver_get_protocol_features(dev->ifname,
                        &slave_protocol_features);
        if (protocol_features & ~slave_protocol_features) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "(%d) received invalid protocol features.\n",
                        dev->vid);
                return RTE_VHOST_MSG_RESULT_ERR;
        }
 
        dev->protocol_features = protocol_features;
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "negotiated Vhost-user protocol features: 0x%" PRIx64 "\n",
                dev->protocol_features);
 
@@ -2046,12 +2046,12 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
                return RTE_VHOST_MSG_RESULT_ERR;
 
        if (fd < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG, "invalid log fd: %d\n", fd);
+               VHOST_LOG_CONFIG(ERR, "invalid log fd: %d\n", fd);
                return RTE_VHOST_MSG_RESULT_ERR;
        }
 
        if (msg->size != sizeof(VhostUserLog)) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "invalid log base msg size: %"PRId32" != %d\n",
                        msg->size, (int)sizeof(VhostUserLog));
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -2062,13 +2062,13 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
        /* Don't allow mmap_offset to point outside the mmap region */
        if (off > size) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "log offset %#"PRIx64" exceeds log size %#"PRIx64"\n",
                        off, size);
                return RTE_VHOST_MSG_RESULT_ERR;
        }
 
-       RTE_LOG(INFO, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(INFO,
                "log mmap size: %"PRId64", offset: %"PRId64"\n",
                size, off);
 
@@ -2079,7 +2079,7 @@ vhost_user_set_log_base(struct virtio_net **pdev, struct VhostUserMsg *msg,
        addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
        close(fd);
        if (addr == MAP_FAILED) {
-               RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");
+               VHOST_LOG_CONFIG(ERR, "mmap log base failed!\n");
                return RTE_VHOST_MSG_RESULT_ERR;
        }
 
@@ -2112,7 +2112,7 @@ static int vhost_user_set_log_fd(struct virtio_net **pdev __rte_unused,
                return RTE_VHOST_MSG_RESULT_ERR;
 
        close(msg->fds[0]);
-       RTE_LOG(INFO, VHOST_CONFIG, "not implemented.\n");
+       VHOST_LOG_CONFIG(INFO, "not implemented.\n");
 
        return RTE_VHOST_MSG_RESULT_OK;
 }
@@ -2137,7 +2137,7 @@ vhost_user_send_rarp(struct virtio_net **pdev, struct VhostUserMsg *msg,
        if (validate_msg_fds(msg, 0) != 0)
                return RTE_VHOST_MSG_RESULT_ERR;
 
-       RTE_LOG(DEBUG, VHOST_CONFIG,
+       VHOST_LOG_CONFIG(DEBUG,
                ":: mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
                mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
        memcpy(dev->mac.addr_bytes, mac, 6);
@@ -2170,7 +2170,7 @@ vhost_user_net_set_mtu(struct virtio_net **pdev, struct VhostUserMsg *msg,
 
        if (msg->payload.u64 < VIRTIO_MIN_MTU ||
                        msg->payload.u64 > VIRTIO_MAX_MTU) {
-               RTE_LOG(ERR, VHOST_CONFIG, "Invalid MTU size (%"PRIu64")\n",
+               VHOST_LOG_CONFIG(ERR, "Invalid MTU size (%"PRIu64")\n",
                                msg->payload.u64);
 
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -2192,7 +2192,7 @@ vhost_user_set_req_fd(struct virtio_net **pdev, struct VhostUserMsg *msg,
                return RTE_VHOST_MSG_RESULT_ERR;
 
        if (fd < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "Invalid file descriptor for slave channel (%d)\n",
                                fd);
                return RTE_VHOST_MSG_RESULT_ERR;
@@ -2308,7 +2308,7 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg,
                }
                break;
        default:
-               RTE_LOG(ERR, VHOST_CONFIG, "Invalid IOTLB message type (%d)\n",
+               VHOST_LOG_CONFIG(ERR, "Invalid IOTLB message type (%d)\n",
                                imsg->type);
                return RTE_VHOST_MSG_RESULT_ERR;
        }
@@ -2331,14 +2331,14 @@ vhost_user_set_postcopy_advise(struct virtio_net **pdev,
        dev->postcopy_ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
 
        if (dev->postcopy_ufd == -1) {
-               RTE_LOG(ERR, VHOST_CONFIG, "Userfaultfd not available: %s\n",
+               VHOST_LOG_CONFIG(ERR, "Userfaultfd not available: %s\n",
                        strerror(errno));
                return RTE_VHOST_MSG_RESULT_ERR;
        }
        api_struct.api = UFFD_API;
        api_struct.features = 0;
        if (ioctl(dev->postcopy_ufd, UFFDIO_API, &api_struct)) {
-               RTE_LOG(ERR, VHOST_CONFIG, "UFFDIO_API ioctl failure: %s\n",
+               VHOST_LOG_CONFIG(ERR, "UFFDIO_API ioctl failure: %s\n",
                        strerror(errno));
                close(dev->postcopy_ufd);
                dev->postcopy_ufd = -1;
@@ -2367,7 +2367,7 @@ vhost_user_set_postcopy_listen(struct virtio_net **pdev,
                return RTE_VHOST_MSG_RESULT_ERR;
 
        if (dev->mem && dev->mem->nregions) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Regions already registered at postcopy-listen\n");
                return RTE_VHOST_MSG_RESULT_ERR;
        }
@@ -2445,7 +2445,7 @@ read_vhost_message(int sockfd, struct VhostUserMsg *msg)
 
        if (msg->size) {
                if (msg->size > sizeof(msg->payload)) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "invalid msg size: %d\n", msg->size);
                        return -1;
                }
@@ -2453,7 +2453,7 @@ read_vhost_message(int sockfd, struct VhostUserMsg *msg)
                if (ret <= 0)
                        return ret;
                if (ret != (int)msg->size) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "read control message failed\n");
                        return -1;
                }
@@ -2529,7 +2529,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_net *dev,
        }
 
        if (vring_idx >= VHOST_MAX_VRING) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "invalid vring index: %u\n", vring_idx);
                return -1;
        }
@@ -2593,7 +2593,7 @@ vhost_user_msg_handler(int vid, int fd)
        if (!dev->notify_ops) {
                dev->notify_ops = vhost_driver_callback_get(dev->ifname);
                if (!dev->notify_ops) {
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "failed to get callback ops for driver %s\n",
                                dev->ifname);
                        return -1;
@@ -2603,10 +2603,10 @@ vhost_user_msg_handler(int vid, int fd)
        ret = read_vhost_message(fd, &msg);
        if (ret <= 0) {
                if (ret < 0)
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "vhost read message failed\n");
                else
-                       RTE_LOG(INFO, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(INFO,
                                "vhost peer closed\n");
 
                return -1;
@@ -2617,18 +2617,18 @@ vhost_user_msg_handler(int vid, int fd)
        if (request > VHOST_USER_NONE && request < VHOST_USER_MAX &&
                        vhost_message_str[request]) {
                if (request != VHOST_USER_IOTLB_MSG)
-                       RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n",
+                       VHOST_LOG_CONFIG(INFO, "read message %s\n",
                                vhost_message_str[request]);
                else
-                       RTE_LOG(DEBUG, VHOST_CONFIG, "read message %s\n",
+                       VHOST_LOG_CONFIG(DEBUG, "read message %s\n",
                                vhost_message_str[request]);
        } else {
-               RTE_LOG(DEBUG, VHOST_CONFIG, "External request %d\n", request);
+               VHOST_LOG_CONFIG(DEBUG, "External request %d\n", request);
        }
 
        ret = vhost_user_check_and_alloc_queue_pair(dev, &msg);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "failed to alloc queue\n");
                return -1;
        }
@@ -2690,19 +2690,19 @@ vhost_user_msg_handler(int vid, int fd)
 
                switch (ret) {
                case RTE_VHOST_MSG_RESULT_ERR:
-                       RTE_LOG(ERR, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(ERR,
                                "Processing %s failed.\n",
                                vhost_message_str[request]);
                        handled = true;
                        break;
                case RTE_VHOST_MSG_RESULT_OK:
-                       RTE_LOG(DEBUG, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(DEBUG,
                                "Processing %s succeeded.\n",
                                vhost_message_str[request]);
                        handled = true;
                        break;
                case RTE_VHOST_MSG_RESULT_REPLY:
-                       RTE_LOG(DEBUG, VHOST_CONFIG,
+                       VHOST_LOG_CONFIG(DEBUG,
                                "Processing %s succeeded and needs reply.\n",
                                vhost_message_str[request]);
                        send_vhost_reply(fd, &msg);
@@ -2736,7 +2736,7 @@ skip_to_post_handle:
 
        /* If message was not handled at this stage, treat it as an error */
        if (!handled) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "vhost message (req: %d) was not handled.\n", request);
                close_msg_fds(&msg);
                ret = RTE_VHOST_MSG_RESULT_ERR;
@@ -2753,7 +2753,7 @@ skip_to_post_handle:
                msg.fd_num = 0;
                send_vhost_reply(fd, &msg);
        } else if (ret == RTE_VHOST_MSG_RESULT_ERR) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "vhost message handling failed.\n");
                return -1;
        }
@@ -2763,7 +2763,7 @@ skip_to_post_handle:
 
                if (!(dev->flags & VIRTIO_DEV_RUNNING)) {
                        if (dev->dequeue_zero_copy) {
-                               RTE_LOG(INFO, VHOST_CONFIG,
+                               VHOST_LOG_CONFIG(INFO,
                                                "dequeue zero copy is enabled\n");
                        }
 
@@ -2800,7 +2800,7 @@ static int process_slave_message_reply(struct virtio_net *dev,
        }
 
        if (msg_reply.request.slave != msg->request.slave) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Received unexpected msg type (%u), expected %u\n",
                        msg_reply.request.slave, msg->request.slave);
                ret = -1;
@@ -2831,7 +2831,7 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_t iova, uint8_t perm)
 
        ret = send_vhost_message(dev->slave_req_fd, &msg);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                                "Failed to send IOTLB miss message (%d)\n",
                                ret);
                return ret;
@@ -2866,7 +2866,7 @@ static int vhost_user_slave_set_vring_host_notifier(struct virtio_net *dev,
 
        ret = send_vhost_slave_message(dev, &msg);
        if (ret < 0) {
-               RTE_LOG(ERR, VHOST_CONFIG,
+               VHOST_LOG_CONFIG(ERR,
                        "Failed to set host notifier (%d)\n", ret);
                return ret;
        }
index 21c3117..73bf98b 100644 (file)
@@ -825,7 +825,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
        else
                hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)hdr_addr;
 
-       VHOST_LOG_DEBUG(VHOST_DATA, "(%d) RX: num merge buffers %d\n",
+       VHOST_LOG_DATA(DEBUG, "(%d) RX: num merge buffers %d\n",
                dev->vid, num_buffers);
 
        if (unlikely(buf_len < dev->vhost_hlen)) {
@@ -1009,14 +1009,14 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
                if (unlikely(reserve_avail_buf_split(dev, vq,
                                                pkt_len, buf_vec, &num_buffers,
                                                avail_head, &nr_vec) < 0)) {
-                       VHOST_LOG_DEBUG(VHOST_DATA,
+                       VHOST_LOG_DATA(DEBUG,
                                "(%d) failed to get enough desc from vring\n",
                                dev->vid);
                        vq->shadow_used_idx -= num_buffers;
                        break;
                }
 
-               VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n",
+               VHOST_LOG_DATA(DEBUG, "(%d) current index %d | end index %d\n",
                        dev->vid, vq->last_avail_idx,
                        vq->last_avail_idx + num_buffers);
 
@@ -1131,13 +1131,13 @@ virtio_dev_rx_single_packed(struct virtio_net *dev,
        rte_smp_rmb();
        if (unlikely(vhost_enqueue_single_packed(dev, vq, pkt, buf_vec,
                                                 &nr_descs) < 0)) {
-               VHOST_LOG_DEBUG(VHOST_DATA,
+               VHOST_LOG_DATA(DEBUG,
                                "(%d) failed to get enough desc from vring\n",
                                dev->vid);
                return -1;
        }
 
-       VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n",
+       VHOST_LOG_DATA(DEBUG, "(%d) current index %d | end index %d\n",
                        dev->vid, vq->last_avail_idx,
                        vq->last_avail_idx + nr_descs);
 
@@ -1192,9 +1192,9 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
        struct vhost_virtqueue *vq;
        uint32_t nb_tx = 0;
 
-       VHOST_LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->vid, __func__);
+       VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
        if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) {
-               RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n",
+               VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n",
                        dev->vid, __func__, queue_id);
                return 0;
        }
@@ -1242,7 +1242,7 @@ rte_vhost_enqueue_burst(int vid, uint16_t queue_id,
                return 0;
 
        if (unlikely(!(dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET))) {
-               RTE_LOG(ERR, VHOST_DATA,
+               VHOST_LOG_DATA(ERR,
                        "(%d) %s: built-in vhost net backend is disabled.\n",
                        dev->vid, __func__);
                return 0;
@@ -1359,7 +1359,7 @@ vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m)
                        m->l4_len = sizeof(struct rte_udp_hdr);
                        break;
                default:
-                       RTE_LOG(WARNING, VHOST_DATA,
+                       VHOST_LOG_DATA(WARNING,
                                "unsupported gso type %u.\n", hdr->gso_type);
                        break;
                }
@@ -1531,7 +1531,7 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
                if (mbuf_avail == 0) {
                        cur = rte_pktmbuf_alloc(mbuf_pool);
                        if (unlikely(cur == NULL)) {
-                               RTE_LOG(ERR, VHOST_DATA, "Failed to "
+                               VHOST_LOG_DATA(ERR, "Failed to "
                                        "allocate memory for mbuf.\n");
                                error = -1;
                                goto out;
@@ -1636,7 +1636,7 @@ virtio_dev_extbuf_alloc(struct rte_mbuf *pkt, uint32_t size)
                                              virtio_dev_extbuf_free, buf);
                if (unlikely(shinfo == NULL)) {
                        rte_free(buf);
-                       RTE_LOG(ERR, VHOST_DATA, "Failed to init shinfo\n");
+                       VHOST_LOG_DATA(ERR, "Failed to init shinfo\n");
                        return -1;
                }
        }
@@ -1658,7 +1658,7 @@ virtio_dev_pktmbuf_alloc(struct virtio_net *dev, struct rte_mempool *mp,
        struct rte_mbuf *pkt = rte_pktmbuf_alloc(mp);
 
        if (unlikely(pkt == NULL)) {
-               RTE_LOG(ERR, VHOST_DATA,
+               VHOST_LOG_DATA(ERR,
                        "Failed to allocate memory for mbuf.\n");
                return NULL;
        }
@@ -1726,11 +1726,11 @@ virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
 
        rte_prefetch0(&vq->avail->ring[vq->last_avail_idx & (vq->size - 1)]);
 
-       VHOST_LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->vid, __func__);
+       VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__);
 
        count = RTE_MIN(count, MAX_PKT_BURST);
        count = RTE_MIN(count, free_entries);
-       VHOST_LOG_DEBUG(VHOST_DATA, "(%d) about to dequeue %u buffers\n",
+       VHOST_LOG_DATA(DEBUG, "(%d) about to dequeue %u buffers\n",
                        dev->vid, count);
 
        for (i = 0; i < count; i++) {
@@ -1938,7 +1938,7 @@ vhost_dequeue_single_packed(struct virtio_net *dev,
 
        *pkts = virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len);
        if (unlikely(*pkts == NULL)) {
-               RTE_LOG(ERR, VHOST_DATA,
+               VHOST_LOG_DATA(ERR,
                        "Failed to allocate memory for mbuf.\n");
                return -1;
        }
@@ -2184,14 +2184,15 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
                return 0;
 
        if (unlikely(!(dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET))) {
-               RTE_LOG(ERR, VHOST_DATA,
+               VHOST_LOG_DATA(ERR,
                        "(%d) %s: built-in vhost net backend is disabled.\n",
                        dev->vid, __func__);
                return 0;
        }
 
        if (unlikely(!is_valid_virt_queue_idx(queue_id, 1, dev->nr_vring))) {
-               RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n",
+               VHOST_LOG_DATA(ERR,
+                       "(%d) %s: invalid virtqueue idx %d.\n",
                        dev->vid, __func__, queue_id);
                return 0;
        }
@@ -2236,8 +2237,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
 
                rarp_mbuf = rte_net_make_rarp_packet(mbuf_pool, &dev->mac);
                if (rarp_mbuf == NULL) {
-                       RTE_LOG(ERR, VHOST_DATA,
-                               "Failed to make RARP packet.\n");
+                       VHOST_LOG_DATA(ERR, "Failed to make RARP packet.\n");
                        count = 0;
                        goto out;
                }