diff mbox

[1/2] libcrc32c: Add crc32c_impl function

Message ID 1515404705-490-2-git-send-email-nborisov@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Nikolay Borisov Jan. 8, 2018, 9:45 a.m. UTC
This function returns a string with the currently in-use implementation
of the crc32c algorithm, i.e crc32c-generic (for unoptimised, generic
implementation) or crc32c-intel for the sse optimised version. This
will be used by btrfs.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 include/linux/crc32c.h | 1 +
 lib/libcrc32c.c        | 6 ++++++
 2 files changed, 7 insertions(+)

Comments

David Sterba Feb. 2, 2018, 5:29 p.m. UTC | #1
Adding linux-crypto@vger.kernel.org to CC

Link to the 2/2 patch https://patchwork.kernel.org/patch/10149203/

On Mon, Jan 08, 2018 at 11:45:04AM +0200, Nikolay Borisov wrote:
> This function returns a string with the currently in-use implementation
> of the crc32c algorithm, i.e crc32c-generic (for unoptimised, generic
> implementation) or crc32c-intel for the sse optimised version. This
> will be used by btrfs.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  include/linux/crc32c.h | 1 +
>  lib/libcrc32c.c        | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/include/linux/crc32c.h b/include/linux/crc32c.h
> index 357ae4611a45..bd21af828ff6 100644
> --- a/include/linux/crc32c.h
> +++ b/include/linux/crc32c.h
> @@ -5,6 +5,7 @@
>  #include <linux/types.h>
>  
>  extern u32 crc32c(u32 crc, const void *address, unsigned int length);
> +extern const char *crc32c_impl(void);
>  
>  /* This macro exists for backwards-compatibility. */
>  #define crc32c_le crc32c
> diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c
> index 9f79547d1b97..eaf71e0e04be 100644
> --- a/lib/libcrc32c.c
> +++ b/lib/libcrc32c.c
> @@ -71,6 +71,12 @@ static void __exit libcrc32c_mod_fini(void)
>  	crypto_free_shash(tfm);
>  }
>  
> +const char *crc32c_impl(void)
> +{
> +	return crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
> +}
> +EXPORT_SYMBOL(crc32c_impl);

Crypto maintainers, would it be still possible to squeeze this patch to
4.16? It's quite trivial, but as it is not in a code I maintain I'm not
comfortable to add it to my tree (unless I get an ACK).

The linked patch depends on that change and would let us get rid of some
custom crypto wrappers around crc32c.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Herbert Xu Feb. 3, 2018, 9:51 a.m. UTC | #2
On Fri, Feb 02, 2018 at 06:29:42PM +0100, David Sterba wrote:
> Adding linux-crypto@vger.kernel.org to CC
> 
> Link to the 2/2 patch https://patchwork.kernel.org/patch/10149203/
> 
> On Mon, Jan 08, 2018 at 11:45:04AM +0200, Nikolay Borisov wrote:
> > This function returns a string with the currently in-use implementation
> > of the crc32c algorithm, i.e crc32c-generic (for unoptimised, generic
> > implementation) or crc32c-intel for the sse optimised version. This
> > will be used by btrfs.
> > 
> > Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> > ---
> >  include/linux/crc32c.h | 1 +
> >  lib/libcrc32c.c        | 6 ++++++
> >  2 files changed, 7 insertions(+)
> > 
> > diff --git a/include/linux/crc32c.h b/include/linux/crc32c.h
> > index 357ae4611a45..bd21af828ff6 100644
> > --- a/include/linux/crc32c.h
> > +++ b/include/linux/crc32c.h
> > @@ -5,6 +5,7 @@
> >  #include <linux/types.h>
> >  
> >  extern u32 crc32c(u32 crc, const void *address, unsigned int length);
> > +extern const char *crc32c_impl(void);
> >  
> >  /* This macro exists for backwards-compatibility. */
> >  #define crc32c_le crc32c
> > diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c
> > index 9f79547d1b97..eaf71e0e04be 100644
> > --- a/lib/libcrc32c.c
> > +++ b/lib/libcrc32c.c
> > @@ -71,6 +71,12 @@ static void __exit libcrc32c_mod_fini(void)
> >  	crypto_free_shash(tfm);
> >  }
> >  
> > +const char *crc32c_impl(void)
> > +{
> > +	return crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
> > +}
> > +EXPORT_SYMBOL(crc32c_impl);

You could just use crypto_shash_driver_name.

> Crypto maintainers, would it be still possible to squeeze this patch to
> 4.16? It's quite trivial, but as it is not in a code I maintain I'm not
> comfortable to add it to my tree (unless I get an ACK).
> 
> The linked patch depends on that change and would let us get rid of some
> custom crypto wrappers around crc32c.

I'm fine with the patch otherwise.

Acked-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,
diff mbox

Patch

diff --git a/include/linux/crc32c.h b/include/linux/crc32c.h
index 357ae4611a45..bd21af828ff6 100644
--- a/include/linux/crc32c.h
+++ b/include/linux/crc32c.h
@@ -5,6 +5,7 @@ 
 #include <linux/types.h>
 
 extern u32 crc32c(u32 crc, const void *address, unsigned int length);
+extern const char *crc32c_impl(void);
 
 /* This macro exists for backwards-compatibility. */
 #define crc32c_le crc32c
diff --git a/lib/libcrc32c.c b/lib/libcrc32c.c
index 9f79547d1b97..eaf71e0e04be 100644
--- a/lib/libcrc32c.c
+++ b/lib/libcrc32c.c
@@ -71,6 +71,12 @@  static void __exit libcrc32c_mod_fini(void)
 	crypto_free_shash(tfm);
 }
 
+const char *crc32c_impl(void)
+{
+	return crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm));
+}
+EXPORT_SYMBOL(crc32c_impl);
+
 module_init(libcrc32c_mod_init);
 module_exit(libcrc32c_mod_fini);