Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1043807pxb; Thu, 28 Jan 2021 06:51:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9imdjp4mdQFdMP59hMvhNvYDO0lIof5u2JTP64JdpBoqiC+YYL2b/SJUZ9k49fVNJzisl X-Received: by 2002:a17:906:e48:: with SMTP id q8mr11232589eji.478.1611845489126; Thu, 28 Jan 2021 06:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611845489; cv=none; d=google.com; s=arc-20160816; b=GvlO6KJPZ0JrZFPCAcEqPY32D3nOXNi2DjWZBPwhjkfP0W/tw04ZzgX1/XOLt/VCkR soF+QrgWzKeRgccXPgYt3kB9dyTjfkupzdctooem2bWb/UlbB0gWj3jO13yb51MUdJpF 4J3y8siJsMvwWdvMgaestTVUef+G7ES2nKCIioA6WzD/P99zqq2N452ByKSDMHiBBDkX C6YXl3MeWqF95FKo0zQYOOhZPyaK39Ms03FU09789CX/Kt53OI22Kf4cMJMJd3xFfwz2 dzJlHmegADMLINN9fempaeT8mXcEkxcZy/pTlcDM2FnAxlIhLQcSVcupYkfjIAxAcsfa QK2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GX3yzMGQ3b9tW8KNSpNTjKrt3+i1m/42zdPvkaXw/ns=; b=suwYRCWv1aYB+rouLSTyA28avbUvJkcIC9WcqVBwIDhSAZ0zwO626ScEyjNC8G8DVP 2Bp0awr+LOvtAmTDUL/994lDOCeEaufRa3h1qXjuoAJsU6VHtFEUAyQXZrok93aFjvxX XYaCic98jQGjLWfhx8MmSFe9y53hXE5yQVyWlmjxByXhevHvnzsQKn975YGdT0uCkvFc LyTTWO/prUX2gr0/PVB6MeHXINCjVAa2/47+79Jx+4aQczggfe4yx3LEQ4QiDzKalSZU aDDUq8cNL6HAujriL8fpKU34WeRpd5or87cnSobdPGPCXYOnsqU4K8IcSI9WJmIv2EKo l4Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YQQkZWk8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si2636733ejm.210.2021.01.28.06.51.04; Thu, 28 Jan 2021 06:51:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YQQkZWk8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232207AbhA1Orr (ORCPT + 99 others); Thu, 28 Jan 2021 09:47:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:40858 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231863AbhA1On7 (ORCPT ); Thu, 28 Jan 2021 09:43:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611844953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GX3yzMGQ3b9tW8KNSpNTjKrt3+i1m/42zdPvkaXw/ns=; b=YQQkZWk8TggJb7ujbrne/oyZAjG2SQu/tmOXkRsYesSlEjX+wNf2razfKLK8GvUIlpE/Zp JCgdeZsyAf1JweG6Qi/Kr47Q/cDpeVck53yKH5FmHh+X7ZUYMX5ElYvK2gjW8rt8QUgC0H pvg746YfY3qWEEuu3hOwlB9V36loZZs= 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-250-rEt7-J4-OkOT7O3gJRvBUg-1; Thu, 28 Jan 2021 09:42:30 -0500 X-MC-Unique: rEt7-J4-OkOT7O3gJRvBUg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 737C6107ACE8; Thu, 28 Jan 2021 14:42:29 +0000 (UTC) Received: from steredhat.redhat.com (ovpn-113-219.ams2.redhat.com [10.36.113.219]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2869F18642; Thu, 28 Jan 2021 14:42:23 +0000 (UTC) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: Xie Yongji , "Michael S. Tsirkin" , Stefano Garzarella , Laurent Vivier , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Max Gurtovoy , Jason Wang , kvm@vger.kernel.org Subject: [PATCH RFC v2 05/10] vringh: add vringh_kiov_length() helper Date: Thu, 28 Jan 2021 15:41:22 +0100 Message-Id: <20210128144127.113245-6-sgarzare@redhat.com> In-Reply-To: <20210128144127.113245-1-sgarzare@redhat.com> References: <20210128144127.113245-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This new helper returns the total number of bytes covered by a vringh_kiov. Suggested-by: Jason Wang Signed-off-by: Stefano Garzarella --- include/linux/vringh.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/vringh.h b/include/linux/vringh.h index 755211ebd195..84db7b8f912f 100644 --- a/include/linux/vringh.h +++ b/include/linux/vringh.h @@ -199,6 +199,17 @@ static inline void vringh_kiov_cleanup(struct vringh_kiov *kiov) kiov->iov = NULL; } +static inline size_t vringh_kiov_length(struct vringh_kiov *kiov) +{ + size_t len = 0; + int i; + + for (i = kiov->i; i < kiov->used; i++) + len += kiov->iov[i].iov_len; + + return len; +} + void vringh_kiov_advance(struct vringh_kiov *kiov, size_t len); int vringh_getdesc_kern(struct vringh *vrh, -- 2.29.2