From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B0446A04B5; Wed, 4 Dec 2019 16:07:50 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EB4AC1BF6F; Wed, 4 Dec 2019 16:07:49 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 115941BF6E for ; Wed, 4 Dec 2019 16:07:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575472067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WVONQyMI3tDzZNMT+MXApclgXj8wtuNPqpFSUgVzH2w=; b=P6kSQjohG7mzQYy1d9HqofikYnJTEDqbGBCXu5bD8z4KcUChNKmeU7bNmZ8P0F6TeL0CnS SvrX546umnigxK8gIcfuMqOu4HCpEErnqu5wE0T2n4PKXGngXM8JfqJUl5kIbAISBY68Rm Euy/hr/DFSu/kjKX313uc/1k94a7GvA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-2DtXaBiuNxqvqtyH7vmqbw-1; Wed, 04 Dec 2019 10:07:43 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B17441005510; Wed, 4 Dec 2019 15:07:42 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-117-120.ams2.redhat.com [10.36.117.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF99A691A7; Wed, 4 Dec 2019 15:07:37 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org Cc: tiwei.bie@intel.com, zhihong.wang@intel.com, maxime.coquelin@redhat.com, Adrian Moreno , huawei.xie@intel.com Date: Wed, 4 Dec 2019 16:07:29 +0100 Message-Id: <20191204150729.31816-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 2DtXaBiuNxqvqtyH7vmqbw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH] vhost: Add dynamic logging system X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Fixes: 1c01d52392d5 ("vhost: add debug print") Cc: huawei.xie@intel.com Cc: maxime.coquelin@redhat.com --- lib/librte_vhost/iotlb.c | 10 +- lib/librte_vhost/socket.c | 84 ++++++------- lib/librte_vhost/vhost.c | 34 ++++-- lib/librte_vhost/vhost.h | 24 ++-- lib/librte_vhost/vhost_user.c | 218 +++++++++++++++++----------------- lib/librte_vhost/virtio_net.c | 38 +++--- 6 files changed, 214 insertions(+), 194 deletions(-) diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c index 4a1d8c125..bc1758528 100644 --- a/lib/librte_vhost/iotlb.c +++ b/lib/librte_vhost/iotlb.c @@ -70,14 +70,14 @@ vhost_user_iotlb_pending_insert(struct vhost_virtqueue = *vq, =20 =09ret =3D rte_mempool_get(vq->iotlb_pool, (void **)&node); =09if (ret) { -=09=09RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, clear entries\n"); +=09=09VHOST_LOG_CONFIG(DEBUG, "IOTLB pool empty, clear entries\n"); =09=09if (!TAILQ_EMPTY(&vq->iotlb_pending_list)) =09=09=09vhost_user_iotlb_pending_remove_all(vq); =09=09else =09=09=09vhost_user_iotlb_cache_random_evict(vq); =09=09ret =3D rte_mempool_get(vq->iotlb_pool, (void **)&node); =09=09if (ret) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, "IOTLB pool still empty, failure\n"); +=09=09=09VHOST_LOG_CONFIG(ERR, "IOTLB pool still empty, failure\n"); =09=09=09return; =09=09} =09} @@ -163,14 +163,14 @@ vhost_user_iotlb_cache_insert(struct vhost_virtqueue = *vq, uint64_t iova, =20 =09ret =3D rte_mempool_get(vq->iotlb_pool, (void **)&new_node); =09if (ret) { -=09=09RTE_LOG(DEBUG, VHOST_CONFIG, "IOTLB pool empty, clear entries\n"); +=09=09VHOST_LOG_CONFIG(DEBUG, "IOTLB pool empty, clear entries\n"); =09=09if (!TAILQ_EMPTY(&vq->iotlb_list)) =09=09=09vhost_user_iotlb_cache_random_evict(vq); =09=09else =09=09=09vhost_user_iotlb_pending_remove_all(vq); =09=09ret =3D rte_mempool_get(vq->iotlb_pool, (void **)&new_node); =09=09if (ret) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, "IOTLB pool still empty, failure\n"); +=09=09=09VHOST_LOG_CONFIG(ERR, "IOTLB pool still empty, failure\n"); =09=09=09return; =09=09} =09} @@ -323,7 +323,7 @@ vhost_user_iotlb_init(struct virtio_net *dev, int vq_in= dex) =09=09=09MEMPOOL_F_SP_PUT | =09=09=09MEMPOOL_F_SC_GET); =09if (!vq->iotlb_pool) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Failed to create IOTLB cache pool (%s)\n", =09=09=09=09pool_name); =09=09return -1; diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index ebb2ff6c2..d7ab6155b 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -127,12 +127,12 @@ read_fd_message(int sockfd, char *buf, int buflen, in= t *fds, int max_fds, =20 =09ret =3D recvmsg(sockfd, &msgh, 0); =09if (ret <=3D 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "recvmsg failed\n"); +=09=09VHOST_LOG_CONFIG(ERR, "recvmsg failed\n"); =09=09return ret; =09} =20 =09if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "truncated msg\n"); +=09=09VHOST_LOG_CONFIG(ERR, "truncted msg\n"); =09=09return -1; =09} =20 @@ -177,7 +177,7 @@ send_fd_message(int sockfd, char *buf, int buflen, int = *fds, int fd_num) =09=09msgh.msg_controllen =3D sizeof(control); =09=09cmsg =3D CMSG_FIRSTHDR(&msgh); =09=09if (cmsg =3D=3D NULL) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, "cmsg =3D=3D NULL\n"); +=09=09=09VHOST_LOG_CONFIG(ERR, "cmsg =3D=3D NULL\n"); =09=09=09errno =3D EINVAL; =09=09=09return -1; =09=09} @@ -195,7 +195,7 @@ send_fd_message(int sockfd, char *buf, int buflen, int = *fds, int fd_num) =09} while (ret < 0 && errno =3D=3D EINTR); =20 =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "sendmsg error\n"); +=09=09VHOST_LOG_CONFIG(ERR, "sendmsg error\n"); =09=09return ret; =09} =20 @@ -240,12 +240,12 @@ vhost_user_add_connection(int fd, struct vhost_user_s= ocket *vsocket) =09if (vsocket->linearbuf) =09=09vhost_enable_linearbuf(vid); =20 -=09RTE_LOG(INFO, VHOST_CONFIG, "new device, handle is %d\n", vid); +=09VHOST_LOG_CONFIG(INFO, "new device, handle is %d\n", vid); =20 =09if (vsocket->notify_ops->new_connection) { =09=09ret =3D vsocket->notify_ops->new_connection(vid); =09=09if (ret < 0) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to add vhost user connection with fd %d\n", =09=09=09=09fd); =09=09=09goto err_cleanup; @@ -258,7 +258,7 @@ vhost_user_add_connection(int fd, struct vhost_user_soc= ket *vsocket) =09ret =3D fdset_add(&vhost_user.fdset, fd, vhost_user_read_cb, =09=09=09NULL, conn); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to add fd %d into vhost server fdset\n", =09=09=09fd); =20 @@ -292,7 +292,7 @@ vhost_user_server_new_connection(int fd, void *dat, int= *remove __rte_unused) =09if (fd < 0) =09=09return; =20 -=09RTE_LOG(INFO, VHOST_CONFIG, "new vhost user connection is %d\n", fd); +=09VHOST_LOG_CONFIG(INFO, "new vhost user connection is %d\n", fd); =09vhost_user_add_connection(fd, vsocket); } =20 @@ -340,11 +340,11 @@ create_unix_socket(struct vhost_user_socket *vsocket) =09fd =3D socket(AF_UNIX, SOCK_STREAM, 0); =09if (fd < 0) =09=09return -1; -=09RTE_LOG(INFO, VHOST_CONFIG, "vhost-user %s: socket created, fd: %d\n", +=09VHOST_LOG_CONFIG(INFO, "vhost-user %s: socket created, fd: %d\n", =09=09vsocket->is_server ? "server" : "client", fd); =20 =09if (!vsocket->is_server && fcntl(fd, F_SETFL, O_NONBLOCK)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"vhost-user: can't set nonblocking mode for socket, fd: " =09=09=09"%d (%s)\n", fd, strerror(errno)); =09=09close(fd); @@ -379,12 +379,12 @@ vhost_user_start_server(struct vhost_user_socket *vso= cket) =09 */ =09ret =3D bind(fd, (struct sockaddr *)&vsocket->un, sizeof(vsocket->un)); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to bind to %s: %s; remove it and try again\n", =09=09=09path, strerror(errno)); =09=09goto err; =09} -=09RTE_LOG(INFO, VHOST_CONFIG, "bind to %s\n", path); +=09VHOST_LOG_CONFIG(INFO, "bind to %s\n", path); =20 =09ret =3D listen(fd, MAX_VIRTIO_BACKLOG); =09if (ret < 0) @@ -393,7 +393,7 @@ vhost_user_start_server(struct vhost_user_socket *vsock= et) =09ret =3D fdset_add(&vhost_user.fdset, fd, vhost_user_server_new_connecti= on, =09=09 NULL, vsocket); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to add listen fd %d to vhost server fdset\n", =09=09=09fd); =09=09goto err; @@ -434,12 +434,12 @@ vhost_user_connect_nonblock(int fd, struct sockaddr *= un, size_t sz) =20 =09flags =3D fcntl(fd, F_GETFL, 0); =09if (flags < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"can't get flags for connfd %d\n", fd); =09=09return -2; =09} =09if ((flags & O_NONBLOCK) && fcntl(fd, F_SETFL, flags & ~O_NONBLOCK)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"can't disable nonblocking on fd %d\n", fd); =09=09return -2; =09} @@ -468,7 +468,7 @@ vhost_user_client_reconnect(void *arg __rte_unused) =09=09=09=09=09=09sizeof(reconn->un)); =09=09=09if (ret =3D=3D -2) { =09=09=09=09close(reconn->fd); -=09=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09=09"reconnection for fd %d failed\n", =09=09=09=09=09reconn->fd); =09=09=09=09goto remove_fd; @@ -476,7 +476,7 @@ vhost_user_client_reconnect(void *arg __rte_unused) =09=09=09if (ret =3D=3D -1) =09=09=09=09continue; =20 -=09=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(INFO, =09=09=09=09"%s: connected\n", reconn->vsocket->path); =09=09=09vhost_user_add_connection(reconn->fd, reconn->vsocket); remove_fd: @@ -498,7 +498,7 @@ vhost_user_reconnect_init(void) =20 =09ret =3D pthread_mutex_init(&reconn_list.mutex, NULL); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "failed to initialize mutex"); +=09=09VHOST_LOG_CONFIG(ERR, "failed to initialize mutex"); =09=09return ret; =09} =09TAILQ_INIT(&reconn_list.head); @@ -506,9 +506,9 @@ vhost_user_reconnect_init(void) =09ret =3D rte_ctrl_thread_create(&reconn_tid, "vhost_reconn", NULL, =09=09=09 vhost_user_client_reconnect, NULL); =09if (ret !=3D 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "failed to create reconnect thread"); +=09=09VHOST_LOG_CONFIG(ERR, "failed to create reconnect thread"); =09=09if (pthread_mutex_destroy(&reconn_list.mutex)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to destroy reconnect mutex"); =09=09} =09} @@ -531,7 +531,7 @@ vhost_user_start_client(struct vhost_user_socket *vsock= et) =09=09return 0; =09} =20 -=09RTE_LOG(WARNING, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(WARNING, =09=09"failed to connect to %s: %s\n", =09=09path, strerror(errno)); =20 @@ -540,10 +540,10 @@ vhost_user_start_client(struct vhost_user_socket *vso= cket) =09=09return -1; =09} =20 -=09RTE_LOG(INFO, VHOST_CONFIG, "%s: reconnecting...\n", path); +=09VHOST_LOG_CONFIG(INFO, "%s: reconnecting...\n", path); =09reconn =3D malloc(sizeof(*reconn)); =09if (reconn =3D=3D NULL) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to allocate memory for reconnect\n"); =09=09close(fd); =09=09return -1; @@ -698,7 +698,7 @@ rte_vhost_driver_get_features(const char *path, uint64_= t *features) =09pthread_mutex_lock(&vhost_user.mutex); =09vsocket =3D find_vhost_user_socket(path); =09if (!vsocket) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"socket file %s is not registered yet.\n", path); =09=09ret =3D -1; =09=09goto unlock_exit; @@ -712,7 +712,7 @@ rte_vhost_driver_get_features(const char *path, uint64_= t *features) =09} =20 =09if (vdpa_dev->ops->get_features(did, &vdpa_features) < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to get vdpa features " =09=09=09=09"for socket file %s.\n", path); =09=09ret =3D -1; @@ -753,7 +753,7 @@ rte_vhost_driver_get_protocol_features(const char *path= , =09pthread_mutex_lock(&vhost_user.mutex); =09vsocket =3D find_vhost_user_socket(path); =09if (!vsocket) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"socket file %s is not registered yet.\n", path); =09=09ret =3D -1; =09=09goto unlock_exit; @@ -768,7 +768,7 @@ rte_vhost_driver_get_protocol_features(const char *path= , =20 =09if (vdpa_dev->ops->get_protocol_features(did, =09=09=09=09&vdpa_protocol_features) < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to get vdpa protocol features " =09=09=09=09"for socket file %s.\n", path); =09=09ret =3D -1; @@ -795,7 +795,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32= _t *queue_num) =09pthread_mutex_lock(&vhost_user.mutex); =09vsocket =3D find_vhost_user_socket(path); =09if (!vsocket) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"socket file %s is not registered yet.\n", path); =09=09ret =3D -1; =09=09goto unlock_exit; @@ -809,7 +809,7 @@ rte_vhost_driver_get_queue_num(const char *path, uint32= _t *queue_num) =09} =20 =09if (vdpa_dev->ops->get_queue_num(did, &vdpa_queue_num) < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to get vdpa queue number " =09=09=09=09"for socket file %s.\n", path); =09=09ret =3D -1; @@ -854,7 +854,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =09pthread_mutex_lock(&vhost_user.mutex); =20 =09if (vhost_user.vsocket_cnt =3D=3D MAX_VHOST_SOCKET) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: the number of vhost sockets reaches maximum\n"); =09=09goto out; =09} @@ -865,7 +865,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =09memset(vsocket, 0, sizeof(struct vhost_user_socket)); =09vsocket->path =3D strdup(path); =09if (vsocket->path =3D=3D NULL) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: failed to copy socket path string\n"); =09=09vhost_user_socket_mem_free(vsocket); =09=09goto out; @@ -873,7 +873,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =09TAILQ_INIT(&vsocket->conn_list); =09ret =3D pthread_mutex_init(&vsocket->conn_mutex, NULL); =09if (ret) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: failed to init connection mutex\n"); =09=09goto out_free; =09} @@ -883,7 +883,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =20 =09if (vsocket->dequeue_zero_copy && =09 (flags & RTE_VHOST_USER_IOMMU_SUPPORT)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: enabling dequeue zero copy and IOMMU features " =09=09=09"simultaneously is not supported\n"); =09=09goto out_mutex; @@ -913,13 +913,13 @@ rte_vhost_driver_register(const char *path, uint64_t = flags) =09 */ =09if (vsocket->dequeue_zero_copy) { =09=09if (vsocket->extbuf) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: zero copy is incompatible with external buffers\n"); =09=09=09ret =3D -1; =09=09=09goto out_mutex; =09=09} =09=09if (vsocket->linearbuf) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: zero copy is incompatible with linear buffers\n"); =09=09=09ret =3D -1; =09=09=09goto out_mutex; @@ -927,7 +927,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =09=09vsocket->supported_features &=3D ~(1ULL << VIRTIO_F_IN_ORDER); =09=09vsocket->features &=3D ~(1ULL << VIRTIO_F_IN_ORDER); =20 -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"Dequeue zero copy requested, disabling postcopy support\n"); =09=09vsocket->protocol_features &=3D =09=09=09~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT); @@ -944,7 +944,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =09=09=09=09(1ULL << VIRTIO_NET_F_HOST_TSO6) | =09=09=09=09(1ULL << VIRTIO_NET_F_HOST_UFO); =20 -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"Linear buffers requested without external buffers, " =09=09=09"disabling host segmentation offloading support\n"); =09=09vsocket->supported_features &=3D ~seg_offload_features; @@ -961,7 +961,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =09=09=09~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT); =09} else { #ifndef RTE_LIBRTE_VHOST_POSTCOPY -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Postcopy requested but not compiled\n"); =09=09ret =3D -1; =09=09goto out_mutex; @@ -989,7 +989,7 @@ rte_vhost_driver_register(const char *path, uint64_t fl= ags) =20 out_mutex: =09if (pthread_mutex_destroy(&vsocket->conn_mutex)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"error: failed to destroy connection mutex\n"); =09} out_free: @@ -1063,7 +1063,7 @@ rte_vhost_driver_unregister(const char *path) =09=09=09=09=09goto again; =09=09=09=09} =20 -=09=09=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09=09=09VHOST_LOG_CONFIG(INFO, =09=09=09=09=09"free connfd =3D %d for device '%s'\n", =09=09=09=09=09conn->connfd, path); =09=09=09=09close(conn->connfd); @@ -1147,7 +1147,7 @@ rte_vhost_driver_start(const char *path) =09=09 * rebuild the wait list of poll. =09=09 */ =09=09if (fdset_pipe_init(&vhost_user.fdset) < 0) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to create pipe for vhost fdset\n"); =09=09=09return -1; =09=09} @@ -1156,7 +1156,7 @@ rte_vhost_driver_start(const char *path) =09=09=09"vhost-events", NULL, fdset_event_dispatch, =09=09=09&vhost_user.fdset); =09=09if (ret !=3D 0) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to create fdset handling thread"); =20 =09=09=09fdset_pipe_uninit(&vhost_user.fdset); diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 1cbe948f7..c819a8477 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -27,6 +27,9 @@ =20 struct virtio_net *vhost_devices[MAX_VHOST_DEVICE]; =20 +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, =20 =09=09vhost_user_iotlb_pending_insert(vq, iova, perm); =09=09if (vhost_user_iotlb_miss(dev, iova, perm)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"IOTLB miss req failed for IOVA 0x%" PRIx64 "\n", =09=09=09=09iova); =09=09=09vhost_user_iotlb_pending_remove(vq, iova, 1, perm); @@ -124,7 +127,7 @@ __vhost_log_write_iova(struct virtio_net *dev, struct v= host_virtqueue *vq, =20 =09hva =3D __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW); =09if (map_len !=3D len) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_DATA(ERR, =09=09=09"Failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found= \n", =09=09=09iova); =09=09return; @@ -229,7 +232,7 @@ __vhost_log_cache_write_iova(struct virtio_net *dev, st= ruct vhost_virtqueue *vq, =20 =09hva =3D __vhost_iova_to_vva(dev, vq, iova, &map_len, VHOST_ACCESS_RW); =09if (map_len !=3D len) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_DATA(ERR, =09=09=09"Failed to write log for IOVA 0x%" PRIx64 ". No IOTLB entry found= \n", =09=09=09iova); =09=09return; @@ -461,7 +464,7 @@ init_vring_queue(struct virtio_net *dev, uint32_t vring= _idx) =09struct vhost_virtqueue *vq; =20 =09if (vring_idx >=3D VHOST_MAX_VRING) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Failed not init vring, out of bound (%d)\n", =09=09=09=09vring_idx); =09=09return; @@ -488,7 +491,7 @@ reset_vring_queue(struct virtio_net *dev, uint32_t vrin= g_idx) =09int callfd; =20 =09if (vring_idx >=3D VHOST_MAX_VRING) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Failed not init vring, out of bound (%d)\n", =09=09=09=09vring_idx); =09=09return; @@ -507,7 +510,7 @@ alloc_vring_queue(struct virtio_net *dev, uint32_t vrin= g_idx) =20 =09vq =3D rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0); =09if (vq =3D=3D NULL) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Failed to allocate memory for vring:%u.\n", vring_idx); =09=09return -1; =09} @@ -558,14 +561,14 @@ vhost_new_device(void) =09} =20 =09if (i =3D=3D MAX_VHOST_DEVICE) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Failed to find a free slot for new device.\n"); =09=09return -1; =09} =20 =09dev =3D rte_zmalloc(NULL, sizeof(struct virtio_net), 0); =09if (dev =3D=3D NULL) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Failed to allocate memory for new dev.\n"); =09=09return -1; =09} @@ -728,7 +731,7 @@ rte_vhost_get_numa_node(int vid) =09ret =3D get_mempolicy(&numa_node, NULL, 0, dev, =09=09=09 MPOL_F_NODE | MPOL_F_ADDR); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"(%d) failed to query numa node: %s\n", =09=09=09vid, rte_strerror(errno)); =09=09return -1; @@ -1322,7 +1325,7 @@ rte_vhost_rx_queue_count(int vid, uint16_t qid) =09=09return 0; =20 =09if (unlikely(qid >=3D dev->nr_vring || (qid & 1) =3D=3D 0)) { -=09=09RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n", +=09=09VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n", =09=09=09dev->vid, __func__, qid); =09=09return 0; =09} @@ -1457,3 +1460,14 @@ int rte_vhost_extern_callback_register(int vid, =09dev->extern_data =3D ctx; =09return 0; } + +RTE_INIT(vhost_log_init) +{ +=09vhost_config_log_level =3D rte_log_register("lib.vhost.config"); +=09if (vhost_config_log_level >=3D 0) +=09=09rte_log_set_level(vhost_config_log_level, RTE_LOG_INFO); + +=09vhost_data_log_level =3D rte_log_register("lib.vhost.data"); +=09if (vhost_data_log_level >=3D 0) +=09=09rte_log_set_level(vhost_data_log_level, RTE_LOG_WARNING); +} diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 9f11b28a3..686ce42a2 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -498,14 +498,21 @@ vhost_log_write_iova(struct virtio_net *dev, struct v= host_virtqueue *vq, =09=09__vhost_log_write(dev, iova, len); } =20 -/* 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...)=09=09=09\ +=09rte_log(RTE_LOG_ ## level, vhost_config_log_level,=09\ +=09=09"VHOST_CONFIG: " fmt, ##args) + +#define VHOST_LOG_DATA(level, fmt, args...) \ +=09(void)((RTE_LOG_ ## level <=3D RTE_LOG_DP_LEVEL) ?=09\ +=09 rte_log(RTE_LOG_ ## level, vhost_data_log_level,=09\ +=09=09"VHOST_DATA : " fmt, ##args) :=09=09=09\ +=09 0) =20 #ifdef RTE_LIBRTE_VHOST_DEBUG #define VHOST_MAX_PRINT_BUFF 6072 -#define VHOST_LOG_DEBUG(log_type, fmt, args...) \ -=09RTE_LOG(DEBUG, log_type, fmt, ##args) #define PRINT_PACKET(device, addr, size, header) do { \ =09char *pkt_addr =3D (char *)(addr); \ =09unsigned int index; \ @@ -521,10 +528,9 @@ vhost_log_write_iova(struct virtio_net *dev, struct vh= ost_virtqueue *vq, =09} \ =09snprintf(packet + strnlen(packet, VHOST_MAX_PRINT_BUFF), VHOST_MAX_PRIN= T_BUFF - strnlen(packet, VHOST_MAX_PRINT_BUFF), "\n"); \ =09\ -=09VHOST_LOG_DEBUG(VHOST_DATA, "%s", packet); \ +=09VHOST_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 =20 @@ -578,7 +584,7 @@ get_device(int vid) =09struct virtio_net *dev =3D vhost_devices[vid]; =20 =09if (unlikely(!dev)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"(%d) device not found.\n", vid); =09} =20 @@ -664,7 +670,7 @@ vhost_vring_call_split(struct virtio_net *dev, struct v= host_virtqueue *vq) =09=09vq->signalled_used =3D new; =09=09vq->signalled_used_valid =3D true; =20 -=09=09VHOST_LOG_DEBUG(VHOST_DATA, "%s: used_event_idx=3D%d, old=3D%d, new= =3D%d\n", +=09=09VHOST_LOG_DATA(DEBUG, "%s: used_event_idx=3D%d, old=3D%d, new=3D%d\n= ", =09=09=09__func__, =09=09=09vhost_used_event(vq), =09=09=09old, new); diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 0cfb8b792..47db316a2 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -111,7 +111,7 @@ validate_msg_fds(struct VhostUserMsg *msg, int expected= _fds) =09if (msg->fd_num =3D=3D expected_fds) =09=09return 0; =20 -=09RTE_LOG(ERR, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(ERR, =09=09" Expect %d FDs for request %s, received %d\n", =09=09expected_fds, =09=09vhost_message_str[msg->request.master], @@ -322,7 +322,7 @@ vhost_user_set_features(struct virtio_net **pdev, struc= t VhostUserMsg *msg, =20 =09rte_vhost_driver_get_features(dev->ifname, &vhost_features); =09if (features & ~vhost_features) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"(%d) received invalid negotiated features.\n", =09=09=09dev->vid); =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -338,7 +338,7 @@ vhost_user_set_features(struct virtio_net **pdev, struc= t VhostUserMsg *msg, =09=09 * is enabled when the live-migration starts. =09=09 */ =09=09if ((dev->features ^ features) & ~(1ULL << VHOST_F_LOG_ALL)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"(%d) features changed while device is running.\n", =09=09=09=09dev->vid); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -355,9 +355,9 @@ vhost_user_set_features(struct virtio_net **pdev, struc= t VhostUserMsg *msg, =09} else { =09=09dev->vhost_hlen =3D sizeof(struct virtio_net_hdr); =09} -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"negotiated Virtio features: 0x%" PRIx64 "\n", dev->features); -=09VHOST_LOG_DEBUG(VHOST_CONFIG, +=09VHOST_LOG_CONFIG(DEBUG, =09=09"(%d) mergeable RX buffers %s, virtio 1 %s\n", =09=09dev->vid, =09=09(dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off", @@ -419,14 +419,14 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09 */ =09if (!vq_is_packed(dev)) { =09=09if (vq->size & (vq->size - 1)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"invalid virtqueue size %u\n", vq->size); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} =09} =20 =09if (vq->size > 32768) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"invalid virtqueue size %u\n", vq->size); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} @@ -440,7 +440,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09=09vq->zmbufs =3D rte_zmalloc(NULL, vq->zmbuf_size * =09=09=09=09=09 sizeof(struct zcopy_mbuf), 0); =09=09if (vq->zmbufs =3D=3D NULL) { -=09=09=09RTE_LOG(WARNING, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(WARNING, =09=09=09=09"failed to allocate mem for zero copy; " =09=09=09=09"zero copy is force disabled\n"); =09=09=09dev->dequeue_zero_copy =3D 0; @@ -456,7 +456,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09=09=09=09sizeof(struct vring_used_elem_packed), =09=09=09=09RTE_CACHE_LINE_SIZE); =09=09if (!vq->shadow_used_packed) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09=09"failed to allocate memory for shadow used ring.\n"); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -468,7 +468,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09=09=09=09vq->size * sizeof(struct vring_used_elem), =09=09=09=09RTE_CACHE_LINE_SIZE); =09=09if (!vq->shadow_used_split) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09=09"failed to allocate memory for shadow used ring.\n"); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -480,7 +480,7 @@ vhost_user_set_vring_num(struct virtio_net **pdev, =09=09=09=09vq->size * sizeof(struct batch_copy_elem), =09=09=09=09RTE_CACHE_LINE_SIZE); =09if (!vq->batch_copy_elems) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to allocate memory for batching copy.\n"); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} @@ -518,12 +518,12 @@ numa_realloc(struct virtio_net *dev, int index) =09ret |=3D get_mempolicy(&oldnode, NULL, 0, old_vq, =09=09=09 MPOL_F_NODE | MPOL_F_ADDR); =09if (ret) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Unable to get vq numa information.\n"); =09=09return dev; =09} =09if (oldnode !=3D newnode) { -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"reallocate vq from %d to %d node\n", oldnode, newnode); =09=09vq =3D rte_malloc_socket(NULL, sizeof(*vq), 0, newnode); =09=09if (!vq) @@ -579,12 +579,12 @@ numa_realloc(struct virtio_net *dev, int index) =09ret =3D get_mempolicy(&oldnode, NULL, 0, old_dev, =09=09=09 MPOL_F_NODE | MPOL_F_ADDR); =09if (ret) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Unable to get dev numa information.\n"); =09=09goto out; =09} =09if (oldnode !=3D newnode) { -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"reallocate dev from %d to %d node\n", =09=09=09oldnode, newnode); =09=09dev =3D rte_malloc_socket(NULL, sizeof(*dev), 0, newnode); @@ -692,7 +692,7 @@ translate_log_addr(struct virtio_net *dev, struct vhost= _virtqueue *vq, =20 =09=09gpa =3D hva_to_gpa(dev, hva, exp_size); =09=09if (!gpa) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"VQ: Failed to find GPA for log_addr: 0x%" PRIx64 " hva: 0x%" = PRIx64 "\n", =09=09=09=09log_addr, hva); =09=09=09return 0; @@ -714,7 +714,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09=09vq->log_guest_addr =3D =09=09=09translate_log_addr(dev, vq, addr->log_guest_addr); =09=09if (vq->log_guest_addr =3D=3D 0) { -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09=09"(%d) failed to map log_guest_addr.\n", =09=09=09=09dev->vid); =09=09=09return dev; @@ -728,7 +728,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09=09if (vq->desc_packed =3D=3D NULL || =09=09=09=09len !=3D sizeof(struct vring_packed_desc) * =09=09=09=09vq->size) { -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09=09"(%d) failed to map desc_packed ring.\n", =09=09=09=09dev->vid); =09=09=09return dev; @@ -744,7 +744,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09=09=09=09=09vq, addr->avail_user_addr, &len); =09=09if (vq->driver_event =3D=3D NULL || =09=09=09=09len !=3D sizeof(struct vring_packed_desc_event)) { -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09=09"(%d) failed to find driver area address.\n", =09=09=09=09dev->vid); =09=09=09return dev; @@ -756,7 +756,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09=09=09=09=09vq, addr->used_user_addr, &len); =09=09if (vq->device_event =3D=3D NULL || =09=09=09=09len !=3D sizeof(struct vring_packed_desc_event)) { -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09=09"(%d) failed to find device area address.\n", =09=09=09=09dev->vid); =09=09=09return dev; @@ -774,7 +774,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09vq->desc =3D (struct vring_desc *)(uintptr_t)ring_addr_to_vva(dev, =09=09=09vq, addr->desc_user_addr, &len); =09if (vq->desc =3D=3D 0 || len !=3D sizeof(struct vring_desc) * vq->size)= { -=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09"(%d) failed to map desc ring.\n", =09=09=09dev->vid); =09=09return dev; @@ -791,7 +791,7 @@ translate_ring_addresses(struct virtio_net *dev, int vq= _index) =09vq->avail =3D (struct vring_avail *)(uintptr_t)ring_addr_to_vva(dev, =09=09=09vq, addr->avail_user_addr, &len); =09if (vq->avail =3D=3D 0 || len !=3D expected_len) { -=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09"(%d) failed to map avail ring.\n", =09=09=09dev->vid); =09=09return dev; @@ -805,14 +805,14 @@ translate_ring_addresses(struct virtio_net *dev, int = vq_index) =09vq->used =3D (struct vring_used *)(uintptr_t)ring_addr_to_vva(dev, =09=09=09vq, addr->used_user_addr, &len); =09if (vq->used =3D=3D 0 || len !=3D expected_len) { -=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09"(%d) failed to map used ring.\n", =09=09=09dev->vid); =09=09return dev; =09} =20 =09if (vq->last_used_idx !=3D vq->used->idx) { -=09=09RTE_LOG(WARNING, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(WARNING, =09=09=09"last_used_idx (%u) and vq->used->idx (%u) mismatches; " =09=09=09"some packets maybe resent for Tx and dropped for Rx\n", =09=09=09vq->last_used_idx, vq->used->idx); @@ -822,13 +822,13 @@ translate_ring_addresses(struct virtio_net *dev, int = vq_index) =20 =09vq->access_ok =3D 1; =20 -=09VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n", +=09VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address desc: %p\n", =09=09=09dev->vid, vq->desc); -=09VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address avail: %p\n", +=09VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address avail: %p\n", =09=09=09dev->vid, vq->avail); -=09VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address used: %p\n", +=09VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address used: %p\n", =09=09=09dev->vid, vq->used); -=09VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) log_guest_addr: %" PRIx64 "\n", +=09VHOST_LOG_CONFIG(DEBUG, "(%d) log_guest_addr: %" PRIx64 "\n", =09=09=09dev->vid, vq->log_guest_addr); =20 =09return dev; @@ -929,7 +929,7 @@ add_one_guest_page(struct virtio_net *dev, uint64_t gue= st_phys_addr, =09=09dev->guest_pages =3D realloc(dev->guest_pages, =09=09=09=09=09dev->max_guest_pages * sizeof(*page)); =09=09if (!dev->guest_pages) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, "cannot realloc guest_pages\n"); +=09=09=09VHOST_LOG_CONFIG(ERR, "cannot realloc guest_pages\n"); =09=09=09free(old_pages); =09=09=09return -1; =09=09} @@ -1001,7 +1001,7 @@ dump_guest_pages(struct virtio_net *dev) =09for (i =3D 0; i < dev->nr_guest_pages; i++) { =09=09page =3D &dev->guest_pages[i]; =20 -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"guest physical page region %u\n" =09=09=09"\t guest_phys_addr: %" PRIx64 "\n" =09=09=09"\t host_phys_addr : %" PRIx64 "\n" @@ -1059,13 +1059,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, = struct VhostUserMsg *msg, =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 =09if (memory->nregions > VHOST_MEMORY_MAX_NREGIONS) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"too many memory regions (%u)\n", memory->nregions); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =20 =09if (dev->mem && !vhost_memory_changed(memory, dev->mem)) { -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"(%d) memory regions not changed\n", dev->vid); =20 =09=09close_msg_fds(msg); @@ -1090,7 +1090,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =09=09dev->guest_pages =3D malloc(dev->max_guest_pages * =09=09=09=09=09=09sizeof(struct guest_page)); =09=09if (dev->guest_pages =3D=3D NULL) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"(%d) failed to allocate memory " =09=09=09=09"for dev->guest_pages\n", =09=09=09=09dev->vid); @@ -1101,7 +1101,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =09dev->mem =3D rte_zmalloc("vhost-mem-table", sizeof(struct rte_vhost_mem= ory) + =09=09sizeof(struct rte_vhost_mem_region) * memory->nregions, 0); =09if (dev->mem =3D=3D NULL) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"(%d) failed to allocate memory for dev->mem\n", =09=09=09dev->vid); =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -1121,7 +1121,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =20 =09=09/* Check for memory_size + mmap_offset overflow */ =09=09if (mmap_offset >=3D -reg->size) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"mmap_offset (%#"PRIx64") and memory_size " =09=09=09=09"(%#"PRIx64") overflow\n", =09=09=09=09mmap_offset, reg->size); @@ -1140,7 +1140,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =09=09 */ =09=09alignment =3D get_blk_size(fd); =09=09if (alignment =3D=3D (uint64_t)-1) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"couldn't get hugepage size through fstat\n"); =09=09=09goto err_mmap; =09=09} @@ -1151,7 +1151,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =09=09=09=09 MAP_SHARED | populate, fd, 0); =20 =09=09if (mmap_addr =3D=3D MAP_FAILED) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"mmap region %u failed.\n", i); =09=09=09goto err_mmap; =09=09} @@ -1163,13 +1163,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, = struct VhostUserMsg *msg, =20 =09=09if (dev->dequeue_zero_copy) =09=09=09if (add_guest_pages(dev, reg, alignment) < 0) { -=09=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09=09"adding guest pages to region %u failed.\n", =09=09=09=09=09i); =09=09=09=09goto err_mmap; =09=09=09} =20 -=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(INFO, =09=09=09"guest memory region %u, size: 0x%" PRIx64 "\n" =09=09=09"\t guest physical addr: 0x%" PRIx64 "\n" =09=09=09"\t guest virtual addr: 0x%" PRIx64 "\n" @@ -1207,7 +1207,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =09=09 */ =09=09VhostUserMsg ack_msg; =09=09if (read_vhost_message(main_fd, &ack_msg) <=3D 0) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Failed to read qemu ack on postcopy set-mem-table\n"); =09=09=09goto err_mmap; =09=09} @@ -1216,7 +1216,7 @@ vhost_user_set_mem_table(struct virtio_net **pdev, st= ruct VhostUserMsg *msg, =09=09=09goto err_mmap; =20 =09=09if (ack_msg.request.master !=3D VHOST_USER_SET_MEM_TABLE) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Bad qemu ack on postcopy set-mem-table (%d)\n", =09=09=09=09ack_msg.request.master); =09=09=09goto err_mmap; @@ -1239,13 +1239,13 @@ vhost_user_set_mem_table(struct virtio_net **pdev, = struct VhostUserMsg *msg, =20 =09=09=09if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER, =09=09=09=09=09=09®_struct)) { -=09=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09=09"Failed to register ufd for region %d: (ufd =3D %d) %s\n", =09=09=09=09=09i, dev->postcopy_ufd, =09=09=09=09=09strerror(errno)); =09=09=09=09goto err_mmap; =09=09=09} -=09=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(INFO, =09=09=09=09"\t userfaultfd registered for range : " =09=09=09=09"%" PRIx64 " - %" PRIx64 "\n", =09=09=09=09(uint64_t)reg_struct.range.start, @@ -1323,7 +1323,7 @@ virtio_is_ready(struct virtio_net *dev) =09=09=09return 0; =09} =20 -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"virtio is now ready for processing.\n"); =09return 1; } @@ -1344,7 +1344,7 @@ inflight_mem_alloc(const char *name, size_t size, int= *fd) =09if (mfd =3D=3D -1) { =09=09mfd =3D mkstemp(fname); =09=09if (mfd =3D=3D -1) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to get inflight buffer fd\n"); =09=09=09return NULL; =09=09} @@ -1353,7 +1353,7 @@ inflight_mem_alloc(const char *name, size_t size, int= *fd) =09} =20 =09if (ftruncate(mfd, size) =3D=3D -1) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to alloc inflight buffer\n"); =09=09close(mfd); =09=09return NULL; @@ -1361,7 +1361,7 @@ inflight_mem_alloc(const char *name, size_t size, int= *fd) =20 =09ptr =3D mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0); =09if (ptr =3D=3D MAP_FAILED) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to mmap inflight buffer\n"); =09=09close(mfd); =09=09return NULL; @@ -1401,7 +1401,7 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, =09void *addr; =20 =09if (msg->size !=3D sizeof(msg->payload.inflight)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"invalid get_inflight_fd message size is %d\n", =09=09=09msg->size); =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -1411,7 +1411,7 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, =09=09dev->inflight_info =3D calloc(1, =09=09=09=09=09 sizeof(struct inflight_mem_info)); =09=09if (!dev->inflight_info) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to alloc dev inflight area\n"); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -1420,9 +1420,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, =09num_queues =3D msg->payload.inflight.num_queues; =09queue_size =3D msg->payload.inflight.queue_size; =20 -=09RTE_LOG(INFO, VHOST_CONFIG, "get_inflight_fd num_queues: %u\n", +=09VHOST_LOG_CONFIG(INFO, "get_inflight_fd num_queues: %u\n", =09=09msg->payload.inflight.num_queues); -=09RTE_LOG(INFO, VHOST_CONFIG, "get_inflight_fd queue_size: %u\n", +=09VHOST_LOG_CONFIG(INFO, "get_inflight_fd queue_size: %u\n", =09=09msg->payload.inflight.queue_size); =20 =09if (vq_is_packed(dev)) @@ -1433,7 +1433,7 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, =09mmap_size =3D num_queues * pervq_inflight_size; =09addr =3D inflight_mem_alloc("vhost-inflight", mmap_size, &fd); =09if (!addr) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to alloc vhost inflight area\n"); =09=09=09msg->payload.inflight.mmap_size =3D 0; =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -1458,13 +1458,13 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev= , =09=09} =09} =20 -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"send inflight mmap_size: %"PRIu64"\n", =09=09msg->payload.inflight.mmap_size); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"send inflight mmap_offset: %"PRIu64"\n", =09=09msg->payload.inflight.mmap_offset); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"send inflight fd: %d\n", msg->fds[0]); =20 =09return RTE_VHOST_MSG_RESULT_REPLY; @@ -1484,7 +1484,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, = VhostUserMsg *msg, =20 =09fd =3D msg->fds[0]; =09if (msg->size !=3D sizeof(msg->payload.inflight) || fd < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"invalid set_inflight_fd message size is %d,fd is %d\n", =09=09=09msg->size, fd); =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -1500,17 +1500,17 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev= , VhostUserMsg *msg, =09else =09=09pervq_inflight_size =3D get_pervq_shm_size_split(queue_size); =20 -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set_inflight_fd mmap_size: %"PRIu64"\n", mmap_size); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set_inflight_fd mmap_offset: %"PRIu64"\n", mmap_offset); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set_inflight_fd num_queues: %u\n", num_queues); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set_inflight_fd queue_size: %u\n", queue_size); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set_inflight_fd fd: %d\n", fd); -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set_inflight_fd pervq_inflight_size: %d\n", =09=09pervq_inflight_size); =20 @@ -1518,7 +1518,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, = VhostUserMsg *msg, =09=09dev->inflight_info =3D calloc(1, =09=09=09=09=09 sizeof(struct inflight_mem_info)); =09=09if (dev->inflight_info =3D=3D NULL) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to alloc dev inflight area\n"); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -1530,7 +1530,7 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, = VhostUserMsg *msg, =09addr =3D mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, =09=09 fd, mmap_offset); =09if (addr =3D=3D MAP_FAILED) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "failed to mmap share memory.\n"); +=09=09VHOST_LOG_CONFIG(ERR, "failed to mmap share memory.\n"); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =20 @@ -1574,7 +1574,7 @@ vhost_user_set_vring_call(struct virtio_net **pdev, s= truct VhostUserMsg *msg, =09=09file.fd =3D VIRTIO_INVALID_EVENTFD; =09else =09=09file.fd =3D msg->fds[0]; -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"vring call idx:%d file:%d\n", file.index, file.fd); =20 =09vq =3D dev->virtqueue[file.index]; @@ -1598,7 +1598,7 @@ static int vhost_user_set_vring_err(struct virtio_net= **pdev __rte_unused, =20 =09if (!(msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK)) =09=09close(msg->fds[0]); -=09RTE_LOG(INFO, VHOST_CONFIG, "not implemented\n"); +=09VHOST_LOG_CONFIG(INFO, "not implemented\n"); =20 =09return RTE_VHOST_MSG_RESULT_OK; } @@ -1660,7 +1660,7 @@ vhost_check_queue_inflights_split(struct virtio_net *= dev, =09if (resubmit_num) { =09=09resubmit =3D calloc(1, sizeof(struct rte_vhost_resubmit_info)); =09=09if (!resubmit) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to allocate memory for resubmit info.\n"); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -1668,7 +1668,7 @@ vhost_check_queue_inflights_split(struct virtio_net *= dev, =09=09resubmit->resubmit_list =3D calloc(resubmit_num, =09=09=09sizeof(struct rte_vhost_resubmit_desc)); =09=09if (!resubmit->resubmit_list) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to allocate memory for inflight desc.\n"); =09=09=09free(resubmit); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -1751,7 +1751,7 @@ vhost_check_queue_inflights_packed(struct virtio_net = *dev, =09if (resubmit_num) { =09=09resubmit =3D calloc(1, sizeof(struct rte_vhost_resubmit_info)); =09=09if (resubmit =3D=3D NULL) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to allocate memory for resubmit info.\n"); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -1759,7 +1759,7 @@ vhost_check_queue_inflights_packed(struct virtio_net = *dev, =09=09resubmit->resubmit_list =3D calloc(resubmit_num, =09=09=09sizeof(struct rte_vhost_resubmit_desc)); =09=09if (resubmit->resubmit_list =3D=3D NULL) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to allocate memory for resubmit desc.\n"); =09=09=09free(resubmit); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -1806,7 +1806,7 @@ vhost_user_set_vring_kick(struct virtio_net **pdev, s= truct VhostUserMsg *msg, =09=09file.fd =3D VIRTIO_INVALID_EVENTFD; =09else =09=09file.fd =3D msg->fds[0]; -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"vring kick idx:%d file:%d\n", file.index, file.fd); =20 =09/* Interpret ring addresses only when ring is started. */ @@ -1836,13 +1836,13 @@ vhost_user_set_vring_kick(struct virtio_net **pdev,= struct VhostUserMsg *msg, =20 =09if (vq_is_packed(dev)) { =09=09if (vhost_check_queue_inflights_packed(dev, vq)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to inflights for vq: %d\n", file.index); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} =09} else { =09=09if (vhost_check_queue_inflights_split(dev, vq)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to inflights for vq: %d\n", file.index); =09=09=09return RTE_VHOST_MSG_RESULT_ERR; =09=09} @@ -1893,7 +1893,7 @@ vhost_user_get_vring_base(struct virtio_net **pdev, =09=09msg->payload.state.num =3D vq->last_avail_idx; =09} =20 -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"vring base idx:%d file:%d\n", msg->payload.state.index, =09=09msg->payload.state.num); =09/* @@ -1952,7 +1952,7 @@ vhost_user_set_vring_enable(struct virtio_net **pdev, =09if (validate_msg_fds(msg, 0) !=3D 0) =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"set queue enable: %d to qp idx: %d\n", =09=09enable, index); =20 @@ -2019,14 +2019,14 @@ vhost_user_set_protocol_features(struct virtio_net = **pdev, =09rte_vhost_driver_get_protocol_features(dev->ifname, =09=09=09&slave_protocol_features); =09if (protocol_features & ~slave_protocol_features) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"(%d) received invalid protocol features.\n", =09=09=09dev->vid); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =20 =09dev->protocol_features =3D protocol_features; -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"negotiated Vhost-user protocol features: 0x%" PRIx64 "\n", =09=09dev->protocol_features); =20 @@ -2046,12 +2046,12 @@ vhost_user_set_log_base(struct virtio_net **pdev, s= truct VhostUserMsg *msg, =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 =09if (fd < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "invalid log fd: %d\n", fd); +=09=09VHOST_LOG_CONFIG(ERR, "invalid log fd: %d\n", fd); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =20 =09if (msg->size !=3D sizeof(VhostUserLog)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"invalid log base msg size: %"PRId32" !=3D %d\n", =09=09=09msg->size, (int)sizeof(VhostUserLog)); =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -2062,13 +2062,13 @@ vhost_user_set_log_base(struct virtio_net **pdev, s= truct VhostUserMsg *msg, =20 =09/* Don't allow mmap_offset to point outside the mmap region */ =09if (off > size) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"log offset %#"PRIx64" exceeds log size %#"PRIx64"\n", =09=09=09off, size); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =20 -=09RTE_LOG(INFO, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(INFO, =09=09"log mmap size: %"PRId64", offset: %"PRId64"\n", =09=09size, off); =20 @@ -2079,7 +2079,7 @@ vhost_user_set_log_base(struct virtio_net **pdev, str= uct VhostUserMsg *msg, =09addr =3D mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)= ; =09close(fd); =09if (addr =3D=3D MAP_FAILED) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n"); +=09=09VHOST_LOG_CONFIG(ERR, "mmap log base failed!\n"); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =20 @@ -2112,7 +2112,7 @@ static int vhost_user_set_log_fd(struct virtio_net **= pdev __rte_unused, =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 =09close(msg->fds[0]); -=09RTE_LOG(INFO, VHOST_CONFIG, "not implemented.\n"); +=09VHOST_LOG_CONFIG(INFO, "not implemented.\n"); =20 =09return RTE_VHOST_MSG_RESULT_OK; } @@ -2137,7 +2137,7 @@ vhost_user_send_rarp(struct virtio_net **pdev, struct= VhostUserMsg *msg, =09if (validate_msg_fds(msg, 0) !=3D 0) =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 -=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09VHOST_LOG_CONFIG(DEBUG, =09=09":: mac: %02x:%02x:%02x:%02x:%02x:%02x\n", =09=09mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); =09memcpy(dev->mac.addr_bytes, mac, 6); @@ -2170,7 +2170,7 @@ vhost_user_net_set_mtu(struct virtio_net **pdev, stru= ct VhostUserMsg *msg, =20 =09if (msg->payload.u64 < VIRTIO_MIN_MTU || =09=09=09msg->payload.u64 > VIRTIO_MAX_MTU) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "Invalid MTU size (%"PRIu64")\n", +=09=09VHOST_LOG_CONFIG(ERR, "Invalid MTU size (%"PRIu64")\n", =09=09=09=09msg->payload.u64); =20 =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -2192,7 +2192,7 @@ vhost_user_set_req_fd(struct virtio_net **pdev, struc= t VhostUserMsg *msg, =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 =09if (fd < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Invalid file descriptor for slave channel (%d)\n", =09=09=09=09fd); =09=09return RTE_VHOST_MSG_RESULT_ERR; @@ -2308,7 +2308,7 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct= VhostUserMsg *msg, =09=09} =09=09break; =09default: -=09=09RTE_LOG(ERR, VHOST_CONFIG, "Invalid IOTLB message type (%d)\n", +=09=09VHOST_LOG_CONFIG(ERR, "Invalid IOTLB message type (%d)\n", =09=09=09=09imsg->type); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} @@ -2331,14 +2331,14 @@ vhost_user_set_postcopy_advise(struct virtio_net **= pdev, =09dev->postcopy_ufd =3D syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK)= ; =20 =09if (dev->postcopy_ufd =3D=3D -1) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "Userfaultfd not available: %s\n", +=09=09VHOST_LOG_CONFIG(ERR, "Userfaultfd not available: %s\n", =09=09=09strerror(errno)); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} =09api_struct.api =3D UFFD_API; =09api_struct.features =3D 0; =09if (ioctl(dev->postcopy_ufd, UFFDIO_API, &api_struct)) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, "UFFDIO_API ioctl failure: %s\n", +=09=09VHOST_LOG_CONFIG(ERR, "UFFDIO_API ioctl failure: %s\n", =09=09=09strerror(errno)); =09=09close(dev->postcopy_ufd); =09=09dev->postcopy_ufd =3D -1; @@ -2367,7 +2367,7 @@ vhost_user_set_postcopy_listen(struct virtio_net **pd= ev, =09=09return RTE_VHOST_MSG_RESULT_ERR; =20 =09if (dev->mem && dev->mem->nregions) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Regions already registered at postcopy-listen\n"); =09=09return RTE_VHOST_MSG_RESULT_ERR; =09} @@ -2445,7 +2445,7 @@ read_vhost_message(int sockfd, struct VhostUserMsg *m= sg) =20 =09if (msg->size) { =09=09if (msg->size > sizeof(msg->payload)) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"invalid msg size: %d\n", msg->size); =09=09=09return -1; =09=09} @@ -2453,7 +2453,7 @@ read_vhost_message(int sockfd, struct VhostUserMsg *m= sg) =09=09if (ret <=3D 0) =09=09=09return ret; =09=09if (ret !=3D (int)msg->size) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"read control message failed\n"); =09=09=09return -1; =09=09} @@ -2529,7 +2529,7 @@ vhost_user_check_and_alloc_queue_pair(struct virtio_n= et *dev, =09} =20 =09if (vring_idx >=3D VHOST_MAX_VRING) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"invalid vring index: %u\n", vring_idx); =09=09return -1; =09} @@ -2593,7 +2593,7 @@ vhost_user_msg_handler(int vid, int fd) =09if (!dev->notify_ops) { =09=09dev->notify_ops =3D vhost_driver_callback_get(dev->ifname); =09=09if (!dev->notify_ops) { -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"failed to get callback ops for driver %s\n", =09=09=09=09dev->ifname); =09=09=09return -1; @@ -2603,10 +2603,10 @@ vhost_user_msg_handler(int vid, int fd) =09ret =3D read_vhost_message(fd, &msg); =09if (ret <=3D 0) { =09=09if (ret < 0) -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"vhost read message failed\n"); =09=09else -=09=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(INFO, =09=09=09=09"vhost peer closed\n"); =20 =09=09return -1; @@ -2617,18 +2617,18 @@ vhost_user_msg_handler(int vid, int fd) =09if (request > VHOST_USER_NONE && request < VHOST_USER_MAX && =09=09=09vhost_message_str[request]) { =09=09if (request !=3D VHOST_USER_IOTLB_MSG) -=09=09=09RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n", +=09=09=09VHOST_LOG_CONFIG(INFO, "read message %s\n", =09=09=09=09vhost_message_str[request]); =09=09else -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, "read message %s\n", +=09=09=09VHOST_LOG_CONFIG(DEBUG, "read message %s\n", =09=09=09=09vhost_message_str[request]); =09} else { -=09=09RTE_LOG(DEBUG, VHOST_CONFIG, "External request %d\n", request); +=09=09VHOST_LOG_CONFIG(DEBUG, "External request %d\n", request); =09} =20 =09ret =3D vhost_user_check_and_alloc_queue_pair(dev, &msg); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"failed to alloc queue\n"); =09=09return -1; =09} @@ -2690,19 +2690,19 @@ vhost_user_msg_handler(int vid, int fd) =20 =09=09switch (ret) { =09=09case RTE_VHOST_MSG_RESULT_ERR: -=09=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Processing %s failed.\n", =09=09=09=09vhost_message_str[request]); =09=09=09handled =3D true; =09=09=09break; =09=09case RTE_VHOST_MSG_RESULT_OK: -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09=09"Processing %s succeeded.\n", =09=09=09=09vhost_message_str[request]); =09=09=09handled =3D true; =09=09=09break; =09=09case RTE_VHOST_MSG_RESULT_REPLY: -=09=09=09RTE_LOG(DEBUG, VHOST_CONFIG, +=09=09=09VHOST_LOG_CONFIG(DEBUG, =09=09=09=09"Processing %s succeeded and needs reply.\n", =09=09=09=09vhost_message_str[request]); =09=09=09send_vhost_reply(fd, &msg); @@ -2736,7 +2736,7 @@ vhost_user_msg_handler(int vid, int fd) =20 =09/* If message was not handled at this stage, treat it as an error */ =09if (!handled) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"vhost message (req: %d) was not handled.\n", request); =09=09close_msg_fds(&msg); =09=09ret =3D RTE_VHOST_MSG_RESULT_ERR; @@ -2753,7 +2753,7 @@ vhost_user_msg_handler(int vid, int fd) =09=09msg.fd_num =3D 0; =09=09send_vhost_reply(fd, &msg); =09} else if (ret =3D=3D RTE_VHOST_MSG_RESULT_ERR) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"vhost message handling failed.\n"); =09=09return -1; =09} @@ -2763,7 +2763,7 @@ vhost_user_msg_handler(int vid, int fd) =20 =09=09if (!(dev->flags & VIRTIO_DEV_RUNNING)) { =09=09=09if (dev->dequeue_zero_copy) { -=09=09=09=09RTE_LOG(INFO, VHOST_CONFIG, +=09=09=09=09VHOST_LOG_CONFIG(INFO, =09=09=09=09=09=09"dequeue zero copy is enabled\n"); =09=09=09} =20 @@ -2800,7 +2800,7 @@ static int process_slave_message_reply(struct virtio_= net *dev, =09} =20 =09if (msg_reply.request.slave !=3D msg->request.slave) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Received unexpected msg type (%u), expected %u\n", =09=09=09msg_reply.request.slave, msg->request.slave); =09=09ret =3D -1; @@ -2831,7 +2831,7 @@ vhost_user_iotlb_miss(struct virtio_net *dev, uint64_= t iova, uint8_t perm) =20 =09ret =3D send_vhost_message(dev->slave_req_fd, &msg); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09=09"Failed to send IOTLB miss message (%d)\n", =09=09=09=09ret); =09=09return ret; @@ -2866,7 +2866,7 @@ static int vhost_user_slave_set_vring_host_notifier(s= truct virtio_net *dev, =20 =09ret =3D send_vhost_slave_message(dev, &msg); =09if (ret < 0) { -=09=09RTE_LOG(ERR, VHOST_CONFIG, +=09=09VHOST_LOG_CONFIG(ERR, =09=09=09"Failed to set host notifier (%d)\n", ret); =09=09return ret; =09} diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 21c311732..73bf98bd9 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -825,7 +825,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_= virtqueue *vq, =09else =09=09hdr =3D (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)hdr_addr; =20 -=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) RX: num merge buffers %d\n", +=09VHOST_LOG_DATA(DEBUG, "(%d) RX: num merge buffers %d\n", =09=09dev->vid, num_buffers); =20 =09if (unlikely(buf_len < dev->vhost_hlen)) { @@ -1009,14 +1009,14 @@ virtio_dev_rx_split(struct virtio_net *dev, struct = vhost_virtqueue *vq, =09=09if (unlikely(reserve_avail_buf_split(dev, vq, =09=09=09=09=09=09pkt_len, buf_vec, &num_buffers, =09=09=09=09=09=09avail_head, &nr_vec) < 0)) { -=09=09=09VHOST_LOG_DEBUG(VHOST_DATA, +=09=09=09VHOST_LOG_DATA(DEBUG, =09=09=09=09"(%d) failed to get enough desc from vring\n", =09=09=09=09dev->vid); =09=09=09vq->shadow_used_idx -=3D num_buffers; =09=09=09break; =09=09} =20 -=09=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n"= , +=09=09VHOST_LOG_DATA(DEBUG, "(%d) current index %d | end index %d\n", =09=09=09dev->vid, vq->last_avail_idx, =09=09=09vq->last_avail_idx + num_buffers); =20 @@ -1131,13 +1131,13 @@ virtio_dev_rx_single_packed(struct virtio_net *dev, =09rte_smp_rmb(); =09if (unlikely(vhost_enqueue_single_packed(dev, vq, pkt, buf_vec, =09=09=09=09=09=09 &nr_descs) < 0)) { -=09=09VHOST_LOG_DEBUG(VHOST_DATA, +=09=09VHOST_LOG_DATA(DEBUG, =09=09=09=09"(%d) failed to get enough desc from vring\n", =09=09=09=09dev->vid); =09=09return -1; =09} =20 -=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end index %d\n", +=09VHOST_LOG_DATA(DEBUG, "(%d) current index %d | end index %d\n", =09=09=09dev->vid, vq->last_avail_idx, =09=09=09vq->last_avail_idx + nr_descs); =20 @@ -1192,9 +1192,9 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_= id, =09struct vhost_virtqueue *vq; =09uint32_t nb_tx =3D 0; =20 -=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->vid, __func__); +=09VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__); =09if (unlikely(!is_valid_virt_queue_idx(queue_id, 0, dev->nr_vring))) { -=09=09RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n", +=09=09VHOST_LOG_DATA(ERR, "(%d) %s: invalid virtqueue idx %d.\n", =09=09=09dev->vid, __func__, queue_id); =09=09return 0; =09} @@ -1242,7 +1242,7 @@ rte_vhost_enqueue_burst(int vid, uint16_t queue_id, =09=09return 0; =20 =09if (unlikely(!(dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET))) { -=09=09RTE_LOG(ERR, VHOST_DATA, +=09=09VHOST_LOG_DATA(ERR, =09=09=09"(%d) %s: built-in vhost net backend is disabled.\n", =09=09=09dev->vid, __func__); =09=09return 0; @@ -1359,7 +1359,7 @@ vhost_dequeue_offload(struct virtio_net_hdr *hdr, str= uct rte_mbuf *m) =09=09=09m->l4_len =3D sizeof(struct rte_udp_hdr); =09=09=09break; =09=09default: -=09=09=09RTE_LOG(WARNING, VHOST_DATA, +=09=09=09VHOST_LOG_DATA(WARNING, =09=09=09=09"unsupported gso type %u.\n", hdr->gso_type); =09=09=09break; =09=09} @@ -1531,7 +1531,7 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhos= t_virtqueue *vq, =09=09if (mbuf_avail =3D=3D 0) { =09=09=09cur =3D rte_pktmbuf_alloc(mbuf_pool); =09=09=09if (unlikely(cur =3D=3D NULL)) { -=09=09=09=09RTE_LOG(ERR, VHOST_DATA, "Failed to " +=09=09=09=09VHOST_LOG_DATA(ERR, "Failed to " =09=09=09=09=09"allocate memory for mbuf.\n"); =09=09=09=09error =3D -1; =09=09=09=09goto out; @@ -1636,7 +1636,7 @@ virtio_dev_extbuf_alloc(struct rte_mbuf *pkt, uint32_= t size) =09=09=09=09=09 virtio_dev_extbuf_free, buf); =09=09if (unlikely(shinfo =3D=3D NULL)) { =09=09=09rte_free(buf); -=09=09=09RTE_LOG(ERR, VHOST_DATA, "Failed to init shinfo\n"); +=09=09=09VHOST_LOG_DATA(ERR, "Failed to init shinfo\n"); =09=09=09return -1; =09=09} =09} @@ -1658,7 +1658,7 @@ virtio_dev_pktmbuf_alloc(struct virtio_net *dev, stru= ct rte_mempool *mp, =09struct rte_mbuf *pkt =3D rte_pktmbuf_alloc(mp); =20 =09if (unlikely(pkt =3D=3D NULL)) { -=09=09RTE_LOG(ERR, VHOST_DATA, +=09=09VHOST_LOG_DATA(ERR, =09=09=09"Failed to allocate memory for mbuf.\n"); =09=09return NULL; =09} @@ -1726,11 +1726,11 @@ virtio_dev_tx_split(struct virtio_net *dev, struct = vhost_virtqueue *vq, =20 =09rte_prefetch0(&vq->avail->ring[vq->last_avail_idx & (vq->size - 1)]); =20 -=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) %s\n", dev->vid, __func__); +=09VHOST_LOG_DATA(DEBUG, "(%d) %s\n", dev->vid, __func__); =20 =09count =3D RTE_MIN(count, MAX_PKT_BURST); =09count =3D RTE_MIN(count, free_entries); -=09VHOST_LOG_DEBUG(VHOST_DATA, "(%d) about to dequeue %u buffers\n", +=09VHOST_LOG_DATA(DEBUG, "(%d) about to dequeue %u buffers\n", =09=09=09dev->vid, count); =20 =09for (i =3D 0; i < count; i++) { @@ -1938,7 +1938,7 @@ vhost_dequeue_single_packed(struct virtio_net *dev, =20 =09*pkts =3D virtio_dev_pktmbuf_alloc(dev, mbuf_pool, buf_len); =09if (unlikely(*pkts =3D=3D NULL)) { -=09=09RTE_LOG(ERR, VHOST_DATA, +=09=09VHOST_LOG_DATA(ERR, =09=09=09"Failed to allocate memory for mbuf.\n"); =09=09return -1; =09} @@ -2184,14 +2184,15 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, =09=09return 0; =20 =09if (unlikely(!(dev->flags & VIRTIO_DEV_BUILTIN_VIRTIO_NET))) { -=09=09RTE_LOG(ERR, VHOST_DATA, +=09=09VHOST_LOG_DATA(ERR, =09=09=09"(%d) %s: built-in vhost net backend is disabled.\n", =09=09=09dev->vid, __func__); =09=09return 0; =09} =20 =09if (unlikely(!is_valid_virt_queue_idx(queue_id, 1, dev->nr_vring))) { -=09=09RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n", +=09=09VHOST_LOG_DATA(ERR, +=09=09=09"(%d) %s: invalid virtqueue idx %d.\n", =09=09=09dev->vid, __func__, queue_id); =09=09return 0; =09} @@ -2236,8 +2237,7 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, =20 =09=09rarp_mbuf =3D rte_net_make_rarp_packet(mbuf_pool, &dev->mac); =09=09if (rarp_mbuf =3D=3D NULL) { -=09=09=09RTE_LOG(ERR, VHOST_DATA, -=09=09=09=09"Failed to make RARP packet.\n"); +=09=09=09VHOST_LOG_DATA(ERR, "Failed to make RARP packet.\n"); =09=09=09count =3D 0; =09=09=09goto out; =09=09} --=20 2.21.0