From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id EE5F75A0274 for ; Fri, 1 Mar 2024 00:11:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1709248281; bh=d40XxkH1OzyImZXWPx0A3fbQ4F8SMGdEOEAIVryOrEM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XUwGqZL11JozFhP5UxxBOv6uCGnq4cASIQ9DbVu8RIog7Dx3Tp1lyV854+iMDp4lr IUobUAWGxe2CG2ydJlBHbyURRZHUhXS3U88/bjb+Q01KQapwyp+ey5xPWgfs+YGzzr 56hrukX7onqioxaWjAKT0wI2LFxV0o+Ac8mPzuUgJcod5TT+l2sXmvnJzNUiSOLATi x9bYAyR8AePRg5TDtrZCHwSPYqANUC6AnhJmumMxZDNtsdv5WWXxny32JAhtWMh9xd OEgSfgzrI//grxaEsTJNQSIOYkYikZIjtbPM9Z07T/h5bVk1ET5utnlFiuvTkpOSFi YlsHDRM9iNq3Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Tm6RF4JLWz4wcb; Fri, 1 Mar 2024 10:11:21 +1100 (AEDT) Date: Fri, 1 Mar 2024 10:05:31 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 2/7] iov: Add helper to find skip over first n bytes of an io vector Message-ID: References: <20240228015206.1214242-1-david@gibson.dropbear.id.au> <20240228015206.1214242-3-david@gibson.dropbear.id.au> <20240229091002.7d7bb1da@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2zYQGJVmU11ggCvz" Content-Disposition: inline In-Reply-To: <20240229091002.7d7bb1da@elisabeth> Message-ID-Hash: XSNWBLYXKI3LQKEG6JZTKO7JP7QCEDM3 X-Message-ID-Hash: XSNWBLYXKI3LQKEG6JZTKO7JP7QCEDM3 X-MailFrom: dgibson@gandalf.ozlabs.org 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: --2zYQGJVmU11ggCvz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 29, 2024 at 09:10:02AM +0100, Stefano Brivio wrote: > On Wed, 28 Feb 2024 12:52:01 +1100 > David Gibson wrote: >=20 > > 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(). > >=20 > > Signed-off-by: David Gibson > > --- > > iov.c | 42 +++++++++++++++++++++++++++++++++--------- > > iov.h | 2 ++ > > tap.c | 12 +++++------- > > 3 files changed, 40 insertions(+), 16 deletions(-) > >=20 > > 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" > > =20 > > + > > +/* iov_skip_bytes() - Skip the first n bytes into an IO vector > > + * @iov: IO vector > > + * @n: Number of entries in @iov >=20 > ...which is a different 'n' compared to two lines above. Ouch, good point. > > + * @vec_offset: Total byte offset into the IO vector >=20 > This doesn't clearly correlate with the description of the function > ("first n bytes"). >=20 > 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. Ok, thanks. I might see if I can improve this one too. >=20 > > + * @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 buffer= s 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 <=3D @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) >=20 --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --2zYQGJVmU11ggCvz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmXhDbYACgkQzQJF27ox 2Gc8wRAAhKfsyrUObw3VwT/XYRd6ppkSIM+/Cz7kG7R9YuVLu3FKz0mvAqJ9WWby leLGTcrFQuXucjDzJ+D2jaTYPOQUR5+SW2+mm8o+iPJ1JMr5vxGXW839YKzBy95q QPmkZfAGVZf2a6Ar5IIE7fTNej1ZhByKx6Va0ZrwM4wFv/daiAYuERDSBvKhm28c 7px7cLZVeE65DL6V1rBswElVyZxxwMnLVNkvdTDm7ilxf1l4HjLJD/K/JFMBM6+G Bn6iRPLPXETE54HI5yVmERg3Q+WgNv8m6VOVZnTXQ7euN6E4SBX7HV9RGaZKN2Oj pb7FrvTTeAtIGhR1L3NcWn8VktvdTbd/68LEntnx1DP0sBMref5aMi4MkeVFAj1n F2eYkzfoH/6W4F2FqdQlB7UB2eiu6aWgJLAtAA7hyj+ThmEpX+b8HZnPvJrs5qVT UHKNVL78nenbczvETRyw+ACr4QC+lmhf6e8+fAi/P40u8wjm+OCpo11fE60fcetF zS4MWx8YuMxb43kI6ix570pKf+hbqTXM/4KRpGQthWCepwHiXWKlIpfld98EuuC3 wDPK6Hr/Hd1Smb44K00SlrEkNDihjNsWyRkZnhXnBILa35LH2azA7HrYzrTac+a3 ffBxN+ZAcAs/jHGruN7clt4vSpQir7Xtf3vJJi7GlDevNDzU+9E= =GcKG -----END PGP SIGNATURE----- --2zYQGJVmU11ggCvz--