[PATCH 1/2] crypto: Add struct crypto_alg-cra_check_optimized
From: Nicholas Bellinger n...@linux-iscsi.org This patch adds an optional struct crypto_alg-cra_check_optimized() caller that can be used by libcrypto algorithms in order to load an architecture dependent optimized / HW offload module. This includes adding the call to alg-cra_check_optimized() inside of crypto_larval_lookup() once the initial generic algorithm has been loaded via request_module(). Signed-off-by: Nicholas A. Bellinger n...@linux-iscsi.org Cc: Herbert Xu herb...@gondor.apana.org.au --- crypto/api.c |6 +- include/linux/crypto.h |1 + 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/crypto/api.c b/crypto/api.c index 033a714..4dcbef6 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -226,8 +226,12 @@ struct crypto_alg *crypto_larval_lookup(const char *name, u32 type, u32 mask) alg = crypto_alg_lookup(name, type, mask); } - if (alg) + if (alg) { + if (alg-cra_check_optimized) + alg-cra_check_optimized(alg); + return crypto_is_larval(alg) ? crypto_larval_wait(alg) : alg; + } return crypto_larval_add(name, type, mask); } diff --git a/include/linux/crypto.h b/include/linux/crypto.h index a6a7a1c..ea7c426 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -295,6 +295,7 @@ struct crypto_alg { int (*cra_init)(struct crypto_tfm *tfm); void (*cra_exit)(struct crypto_tfm *tfm); + void (*cra_check_optimized)(struct crypto_alg *alg); void (*cra_destroy)(struct crypto_alg *alg); struct module *cra_module; -- 1.5.6.5 -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] Add struct crypto_alg-cra_check_optimized for crc32c_intel
On Thu, Mar 10, 2011 at 12:21:10AM -0800, Nicholas A. Bellinger wrote: Nicholas Bellinger (2): crypto: Add struct crypto_alg-cra_check_optimized crypto/crc32c: Add crc32c_cra_check_optimized for crc32c_intel I think you misunderstood my suggestion. The reason I asked for this to be done in the crypto API is because it is not specific to crc32c_intel. So sending me a patch that modifies crc32c clearly misses the point :) This should be done in the core API, i.e., api.c/algapi.c. Thanks, -- Email: Herbert Xu herb...@gondor.apana.org.au Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] Add struct crypto_alg-cra_check_optimized for crc32c_intel
On Thu, 2011-03-10 at 16:43 +0800, Herbert Xu wrote: On Thu, Mar 10, 2011 at 12:21:10AM -0800, Nicholas A. Bellinger wrote: Nicholas Bellinger (2): crypto: Add struct crypto_alg-cra_check_optimized crypto/crc32c: Add crc32c_cra_check_optimized for crc32c_intel I think you misunderstood my suggestion. The reason I asked for this to be done in the crypto API is because it is not specific to crc32c_intel. So sending me a patch that modifies crc32c clearly misses the point :) This should be done in the core API, i.e., api.c/algapi.c. OK, so you mean each struct crypto_alg should define something like a 'cra_optimized_name' for which request_module(alg-cra_optimized_name) is called somewhere in libcrypto code..? Would you mind being a bit more specific where this should be happening in api.c/algapi.c..? Thanks, --nab -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] Add struct crypto_alg-cra_check_optimized for crc32c_intel
On Thu, Mar 10, 2011 at 12:54:24AM -0800, Nicholas A. Bellinger wrote: OK, so you mean each struct crypto_alg should define something like a 'cra_optimized_name' for which request_module(alg-cra_optimized_name) is called somewhere in libcrypto code..? No, what I mean is that whenever we look up an algorithm through crypto_alg_mod_lookup, we should conditionally call modprobe if we havn't done so already. So you just need to record one bit of info in each crypto_alg object to indicate whether we have invoked modprobe. I suggest adding a CRYPTO_ALG_* bit. Cheers, -- Email: Herbert Xu herb...@gondor.apana.org.au Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] Add struct crypto_alg-cra_check_optimized for crc32c_intel
On Thu, 2011-03-10 at 17:09 +0800, Herbert Xu wrote: On Thu, Mar 10, 2011 at 12:54:24AM -0800, Nicholas A. Bellinger wrote: OK, so you mean each struct crypto_alg should define something like a 'cra_optimized_name' for which request_module(alg-cra_optimized_name) is called somewhere in libcrypto code..? No, what I mean is that whenever we look up an algorithm through crypto_alg_mod_lookup, we should conditionally call modprobe if we havn't done so already. So you just need to record one bit of info in each crypto_alg object to indicate whether we have invoked modprobe. I suggest adding a CRYPTO_ALG_* bit. Mmmm, now I am really confused, and please let me apologize in advance for my lack of experience with libcrypto internals.. ;) I thought the problem was that CONFIG_CRYPTO_ALGFOO=y and CONFIG_CRYPTO_ALGFOO_ARCH_HW_OFFLOAD=m would cause the latter to not explictly call request_module() for this HW offload case.. So what I don't understand how adding a request_module() call to a list of known modules works when crc32c_intel.ko has not been loaded yet..? Am I missing something obvious wrt to how crc32c.ko can tell libcrypto about which architecture dependent optimized modules it should load..? Best Regards, --nab -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/2] Add struct crypto_alg-cra_check_optimized for crc32c_intel
On Thu, 2011-03-10 at 01:13 -0800, Nicholas A. Bellinger wrote: On Thu, 2011-03-10 at 17:09 +0800, Herbert Xu wrote: On Thu, Mar 10, 2011 at 12:54:24AM -0800, Nicholas A. Bellinger wrote: OK, so you mean each struct crypto_alg should define something like a 'cra_optimized_name' for which request_module(alg-cra_optimized_name) is called somewhere in libcrypto code..? No, what I mean is that whenever we look up an algorithm through crypto_alg_mod_lookup, we should conditionally call modprobe if we havn't done so already. So you just need to record one bit of info in each crypto_alg object to indicate whether we have invoked modprobe. I suggest adding a CRYPTO_ALG_* bit. Mmmm, now I am really confused, and please let me apologize in advance for my lack of experience with libcrypto internals.. ;) I thought the problem was that CONFIG_CRYPTO_ALGFOO=y and CONFIG_CRYPTO_ALGFOO_ARCH_HW_OFFLOAD=m would cause the latter to not explictly call request_module() for this HW offload case.. So what I don't understand how adding a request_module() call to a list of known modules works when crc32c_intel.ko has not been loaded yet..? Am I missing something obvious wrt to how crc32c.ko can tell libcrypto about which architecture dependent optimized modules it should load..? Just to clarify a bit on my previous comments.. We are still expecting the libcrypto consumer (iscsi_target_mod.ko) to call the arch independent crypto_alloc_hash(crc32c, ...) in order to have libcrypto backend logic perform a request_module() upon architecture dependent offload modules (like crc32c_intel.ko) that libcrypto consumers are not (and should not) be calling directly via crypto_alloc_host(crc32c_intel, ...), correct..? Where I am getting confused is wrt to a new crypto_alg_mod_lookup() - request_module() call for a struct shash_alg that has not yet be loaded via arch/x86/crypto/crc32c-intel.c:crc32c_intel_mod_init() - crypto_register_shash(). Thanks, --nab -- To unsubscribe from this list: send the line unsubscribe linux-crypto in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html