From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97364C433E0 for ; Mon, 15 Mar 2021 16:52:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6606064F36 for ; Mon, 15 Mar 2021 16:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231426AbhCOQwT (ORCPT ); Mon, 15 Mar 2021 12:52:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57085 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232488AbhCOQvp (ORCPT ); Mon, 15 Mar 2021 12:51:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615827104; 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=MFFcd4wD8/CMTprSPx6NQ5pGVPcuBak1/nAOtKKtWKQ=; b=WuhGiCrPxSAwPNs/wwshEq0B5MzHKYk31vyK1yy8ZPFkKrCOeP6o/uMGDb2g7jJh07yzAB x/xjHZvi90eaWIfEt+rgex+Rqb5QQ6ZhmdojcFNKVCw7dl/0pjzK45S0MINmFVx7VeKJcd GuArS1/2ntul3blQSfWBzcAbrmWDTlc= 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-268-HlO-i1j-P7ub0ae-8cCVmA-1; Mon, 15 Mar 2021 12:51:41 -0400 X-MC-Unique: HlO-i1j-P7ub0ae-8cCVmA-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 98F951B2C981; Mon, 15 Mar 2021 16:51:39 +0000 (UTC) Received: from [10.36.112.75] (ovpn-112-75.ams2.redhat.com [10.36.112.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 359965D745; Mon, 15 Mar 2021 16:51:31 +0000 (UTC) Subject: Re: [PATCH v4 06/14] vringh: add vringh_kiov_length() helper To: Stefano Garzarella , virtualization@lists.linux-foundation.org Cc: netdev@vger.kernel.org, Xie Yongji , Stefan Hajnoczi , linux-kernel@vger.kernel.org, Max Gurtovoy , Jason Wang , Parav Pandit , "Michael S. Tsirkin" , kvm@vger.kernel.org References: <20210315163450.254396-1-sgarzare@redhat.com> <20210315163450.254396-7-sgarzare@redhat.com> From: Laurent Vivier Message-ID: Date: Mon, 15 Mar 2021 17:51:30 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210315163450.254396-7-sgarzare@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 15/03/2021 17:34, Stefano Garzarella wrote: > This new helper returns the total number of bytes covered by > a vringh_kiov. > > Suggested-by: Jason Wang > Acked-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; > +} Do we really need an helper? For instance, we can use: len = iov_length((struct iovec *)kiov->iov, kiov->used); Or do we want to avoid the cast? Thanks, Laurent