From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 5A8465A0275 for ; Thu, 29 Feb 2024 09:10:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709194244; 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=DW4YNIzR3hFo9yrafZ8wMqc2lOZGJTO0j1GG5We7grQ=; b=D+VAvpEx74UGapK7bIQJC653J0nDOQF5zl3m5rF4/8K80YwFvyyvRsyHSkt9eHthyDp1Kr Rl9sL+TmgiPjpfLXoGB6RiwegHnX5uJrG5u6C15YjvziPPFo/FD3ywribXzxOEge+Z9nFd VNsN3b3phmH/g210BOZB7DsaSxaJjr4= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-275-POQvWAM-Mpqwj1TQ6x7b4g-1; Thu, 29 Feb 2024 03:10:43 -0500 X-MC-Unique: POQvWAM-Mpqwj1TQ6x7b4g-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-55d71ec6ef3so616567a12.0 for ; Thu, 29 Feb 2024 00:10:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709194240; x=1709799040; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DW4YNIzR3hFo9yrafZ8wMqc2lOZGJTO0j1GG5We7grQ=; b=i0vt3SsQ1LKDPCn1CjN9SC6opZS8sUbWHSZ8xHnSiBxrW7YFxXLybXjFlKpp7C3jqW 5km9Bykbj8Bo3LM2EMtWg8+woez4uv3yWlm7lJTCp4MetAxjYmosz86DIy+rTRNKIOVK 5hVfCEZVP1lZ/8k5Pl3uGSjF/hrE6fPM+Y452YcR4hEKgI0AkQkqNZWgma0exzccleif 2s19OVXAX187CyUsEtC96xjUeYLwTw+XSv2nAfvb4OQv35Nstw7FlL8c0l31cXWp0uIf XANfUHRcZj6MlYyjEqjW0WHbia2xD6XdguoTB1XMhYRsXWyOAFuVIGfulTR80oeCKiA1 aIow== X-Forwarded-Encrypted: i=1; AJvYcCUs6yWTXOwczn172XG2qx4/SF3gOn+vAGCftw4aV+zhySMWAsAznlazrRN4K9yVgL2Iy94JSyqNDrGs6oxIiBKaQaah X-Gm-Message-State: AOJu0Yyfr0HjOlEU9qXyWPzZ52IUvMGjYmhUETWH77SvdBV0FrwJwWHj UzagMChJsFR1lnMWnIIAuuMIEseVJXyiuBrJ83xWWC2LMGtU8qQvwqwE0n5GDtcrQp182d2RCMj TDfqo1PThN/Iy+ZGUsRHhxpPo8wXcZ3L6fjnxIJ06ya71fCOvbg== X-Received: by 2002:a50:c90b:0:b0:566:1be1:688c with SMTP id o11-20020a50c90b000000b005661be1688cmr899920edh.11.1709194240323; Thu, 29 Feb 2024 00:10:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6KaomGot3kD/UVMRVhGX5V8D9xRTtksoIeMqIOrTCGiqhWPPT4WH2XmK1Emaz3UepJm/b1g== X-Received: by 2002:a50:c90b:0:b0:566:1be1:688c with SMTP id o11-20020a50c90b000000b005661be1688cmr899911edh.11.1709194240032; Thu, 29 Feb 2024 00:10:40 -0800 (PST) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id s12-20020a056402164c00b005667516866dsm375240edx.33.2024.02.29.00.10.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Feb 2024 00:10:39 -0800 (PST) Date: Thu, 29 Feb 2024 09:10:02 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 2/7] iov: Add helper to find skip over first n bytes of an io vector Message-ID: <20240229091002.7d7bb1da@elisabeth> In-Reply-To: <20240228015206.1214242-3-david@gibson.dropbear.id.au> References: <20240228015206.1214242-1-david@gibson.dropbear.id.au> <20240228015206.1214242-3-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 2FFMUKQSDMW3AILEBLGSGFZXGVXSBAUF X-Message-ID-Hash: 2FFMUKQSDMW3AILEBLGSGFZXGVXSBAUF X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier , passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 28 Feb 2024 12:52:01 +1100 David Gibson wrote: > Several of the IOV functions in iov.c, and also tap_send_frames_passt() > needs to determine which buffer element a byte offset into an IO vector > lies in. Split this out into a helper function iov_skip_bytes(). > > Signed-off-by: David Gibson > --- > iov.c | 42 +++++++++++++++++++++++++++++++++--------- > iov.h | 2 ++ > tap.c | 12 +++++------- > 3 files changed, 40 insertions(+), 16 deletions(-) > > diff --git a/iov.c b/iov.c > index 8a48acb1..e3312628 100644 > --- a/iov.c > +++ b/iov.c > @@ -25,6 +25,36 @@ > #include "util.h" > #include "iov.h" > > + > +/* iov_skip_bytes() - Skip the first n bytes into an IO vector > + * @iov: IO vector > + * @n: Number of entries in @iov ...which is a different 'n' compared to two lines above. > + * @vec_offset: Total byte offset into the IO vector This doesn't clearly correlate with the description of the function ("first n bytes"). Same here, I have no other comments about the series, so I'll apply this and try to improve this a bit as a follow-up. > + * @buf_offset: Offset into a single buffer of the IO vector > + * > + * Return: index I of individual struct iovec which contains the byte at > + * @vec_offset bytes into the vector (as though all its buffers were > + * contiguous). If @buf_offset is non-NULL, update it to the offset of > + * that byte within @iov[I] (guaranteed to be less than @iov[I].iov_len) > + * If the whole vector has <= @vec_offset bytes, return @n. > + */ > +size_t iov_skip_bytes(const struct iovec *iov, size_t n, > + size_t vec_offset, size_t *buf_offset) -- Stefano