From patchwork Sun Dec 20 21:13:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 85547 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D023AA09FD; Sun, 20 Dec 2020 22:21:51 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18D53CDCE; Sun, 20 Dec 2020 22:15:53 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id BBE4ACD74 for ; Sun, 20 Dec 2020 22:15:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1608498948; 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: in-reply-to:in-reply-to:references:references; bh=wapIGAT/L/lpNUj3xf8stnln27rfX8v3wED6EW6M6kU=; b=eyFDY8G0Q3n40odOqpif5hT4ojNeAuuEv2yH5K+JbrmwkKIbHCC+KBSOMSV45+towzPPSY zDZd/64oqllPmsGyl8J1tw3lO03Dv3sdZRrAZXq4k7lXDtvSRKCXhouzQ669OOd1gshxYn uKqShMNEJgLzJvlHgMBlqr8sRtSLNI0= 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-156-UugmVLx0P3qesWp6DgHZOw-1; Sun, 20 Dec 2020 16:15:46 -0500 X-MC-Unique: UugmVLx0P3qesWp6DgHZOw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6049219251A1; Sun, 20 Dec 2020 21:15:45 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0BFC60C43; Sun, 20 Dec 2020 21:15:43 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, olivier.matz@6wind.com, amorenoz@redhat.com, david.marchand@redhat.com Cc: Maxime Coquelin Date: Sun, 20 Dec 2020 22:13:48 +0100 Message-Id: <20201220211405.313012-24-maxime.coquelin@redhat.com> In-Reply-To: <20201220211405.313012-1-maxime.coquelin@redhat.com> References: <20201220211405.313012-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 23/40] net/virtio: make Vhost-user req sender consistent 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" This patch makes vhost_user_write() consistent with vhost_user_read(), by passing a pointer on the Vhost-user message instead of a buffer pointer and its length, which is now calculated in the function. Signed-off-by: Maxime Coquelin --- drivers/net/virtio/virtio_user/vhost_user.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c index b93e65c60b..e9053eea95 100644 --- a/drivers/net/virtio/virtio_user/vhost_user.c +++ b/drivers/net/virtio/virtio_user/vhost_user.c @@ -51,7 +51,7 @@ struct vhost_user_msg { (sizeof(struct vhost_user_msg) - VHOST_USER_HDR_SIZE) static int -vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num) +vhost_user_write(int fd, struct vhost_user_msg *msg, int *fds, int fd_num) { int r; struct msghdr msgh; @@ -63,8 +63,8 @@ vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num) memset(&msgh, 0, sizeof(msgh)); memset(control, 0, sizeof(control)); - iov.iov_base = (uint8_t *)buf; - iov.iov_len = len; + iov.iov_base = (uint8_t *)msg; + iov.iov_len = VHOST_USER_HDR_SIZE + msg->size; msgh.msg_iov = &iov; msgh.msg_iovlen = 1; @@ -259,7 +259,6 @@ vhost_user_sock(struct virtio_user_dev *dev, int has_reply_ack = 0; int fds[VHOST_MEMORY_MAX_NREGIONS]; int fd_num = 0; - int len; int vhostfd = dev->vhostfd; RTE_SET_USED(m); @@ -359,8 +358,7 @@ vhost_user_sock(struct virtio_user_dev *dev, return -1; } - len = VHOST_USER_HDR_SIZE + msg.size; - if (vhost_user_write(vhostfd, &msg, len, fds, fd_num) < 0) { + if (vhost_user_write(vhostfd, &msg, fds, fd_num) < 0) { PMD_DRV_LOG(ERR, "%s failed: %s", vhost_msg_strings[req], strerror(errno)); return -1;