From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Herve Codina <herve.codina@bootlin.com>
Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, Andrew Lunn <andrew@lunn.ch>,
Mark Brown <broonie@kernel.org>,
Christophe Leroy <christophe.leroy@csgroup.eu>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v4 3/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers
Date: Thu, 22 Feb 2024 17:39:27 +0200 [thread overview]
Message-ID: <Zddqr3aN4rU-upai@smile.fi.intel.com> (raw)
In-Reply-To: <20240222142219.441767-4-herve.codina@bootlin.com>
On Thu, Feb 22, 2024 at 03:22:16PM +0100, Herve Codina wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> These helpers scatters or gathers a bitmap with the help of the mask
> position bits parameter.
>
> bitmap_scatter() does the following:
> src: 0000000001011010
> ||||||
> +------+|||||
> | +----+||||
> | |+----+|||
> | || +-+||
> | || | ||
> mask: ...v..vv...v..vv
> ...0..11...0..10
> dst: 0000001100000010
>
> and bitmap_gather() performs this one:
> mask: ...v..vv...v..vv
> src: 0000001100000010
> ^ ^^ ^ 0
> | || | 10
> | || > 010
> | |+--> 1010
> | +--> 11010
> +----> 011010
> dst: 0000000000011010
>
> bitmap_gather() can the seen as the reverse bitmap_scatter() operation.
> The original work was done by Andy Shevchenko.
Mine SoB is enough for a credit, but thank you :-)
...
> +/**
> + * bitmap_gather - Gather a bitmap according to given mask
> + * @dst: gathered bitmap
> + * @src: scattered bitmap
> + * @mask: mask representing bits to extract from in the scattered bitmap
> + * @nbits: number of bits in each of these bitmaps
> + *
> + * Gathers bitmap with sparse bits according to the given @mask.
> + *
> + * Example:
> + * If @src bitmap = 0x0302, with @mask = 0x1313, @dst will be 0x001a.
> + *
> + * Or in binary form
> + * @src @mask @dst
> + * 0000001100000010 0001001100010011 0000000000011010
> + *
> + * (Bits 0, 1, 4, 8, 9, 12 are copied to the bits 0, 1, 2, 3, 4, 5)
> + *
> + * A more 'visual' description of the operation:
> + * mask: ...v..vv...v..vv
> + * src: 0000001100000010
> + * ^ ^^ ^ 0
> + * | || | 10
> + * | || > 010
> + * | |+--> 1010
> + * | +--> 11010
> + * +----> 011010
> + * dst: 0000000000011010
Cool!
> + * A relationship exists between bitmap_gather() and bitmap_scatter() (See
Either '... (see'
or '(). See'
> + * bitmap_scatter() for the bitmap scatter detailed operations).
> + * Suppose scattered computed using bitmap_scatter(scattered, src, mask, n).
> + * The operation bitmap_gather(result, scattered, mask, n) leads to a result
> + * equal or equivalent to src.
This paragraph...
> + * The result can be 'equivalent' because bitmap_scatter() and bitmap_gather()
> + * are not bijective.
> + * The result and src values are equivalent in that sense that a call to
> + * bitmap_scatter(res, src, mask, n) and a call to bitmap_scatter(res, result,
> + * mask, n) will lead to the same res value.
...seems duplicating this one.
I would drop the latter one.
> + */
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-02-22 15:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 14:22 [PATCH v4 0/5] Add support for QMC HDLC Herve Codina
2024-02-22 14:22 ` [PATCH v4 1/5] net: wan: " Herve Codina
2024-02-22 15:29 ` Andy Shevchenko
2024-02-22 16:45 ` Herve Codina
2024-02-22 16:56 ` Andy Shevchenko
2024-02-22 17:45 ` Herve Codina
2024-02-22 14:22 ` [PATCH v4 2/5] MAINTAINERS: Add the Freescale QMC HDLC driver entry Herve Codina
2024-02-22 14:22 ` [PATCH v4 3/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers Herve Codina
2024-02-22 15:39 ` Andy Shevchenko [this message]
2024-02-22 15:40 ` Andy Shevchenko
2024-02-22 16:49 ` Herve Codina
2024-02-22 21:50 ` Yury Norov
2024-02-23 10:07 ` Herve Codina
2024-02-22 14:22 ` [PATCH v4 4/5] net: wan: fsl_qmc_hdlc: Add runtime timeslots changes support Herve Codina
2024-02-22 15:47 ` Andy Shevchenko
2024-02-23 16:46 ` Herve Codina
2024-02-22 14:22 ` [PATCH v4 5/5] net: wan: fsl_qmc_hdlc: Add framer support Herve Codina
2024-02-22 15:49 ` Andy Shevchenko
2024-02-29 12:56 ` Herve Codina
2024-02-29 13:58 ` Andy Shevchenko
2024-02-29 14:15 ` Herve Codina
2024-02-22 15:50 ` [PATCH v4 0/5] Add support for QMC HDLC Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Zddqr3aN4rU-upai@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andrew@lunn.ch \
--cc=broonie@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=herve.codina@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vadim.fedorenko@linux.dev \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®