Re: [PATCH v2 2/2] chcr: Add support for Inline IPSec

2017-11-15 Thread Herbert Xu
On Thu, Nov 16, 2017 at 01:19:52PM +0800, kbuild test robot wrote:
> Hi Atul,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on cryptodev/master]
> [also build test ERROR on next-20171115]
> [cannot apply to v4.14]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Atul-Gupta/cxgb4-Add-support-for-Inline-IPSec-Tx/20171112-012558
> base:   
> https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git 
> master
> config: x86_64-randconfig-g0-11160917 (attached as .config)
> compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All errors (new ones prefixed by >>):
> 
>drivers/crypto/chelsio/chcr_core.o: In function `chcr_uld_tx_handler':
> >> drivers/crypto/chelsio/chcr_core.c:195: undefined reference to 
> >> `chcr_ipsec_xmit'
>drivers/crypto/chelsio/chcr_core.o: In function `chcr_uld_add':
> >> drivers/crypto/chelsio/chcr_core.c:169: undefined reference to 
> >> `chcr_add_xfrmops'

Atul, can you fix this and resubmit your patches please?

Thanks!
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


Re: [PATCH v2 2/2] chcr: Add support for Inline IPSec

2017-11-15 Thread kbuild test robot
Hi Atul,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on cryptodev/master]
[also build test ERROR on next-20171115]
[cannot apply to v4.14]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Atul-Gupta/cxgb4-Add-support-for-Inline-IPSec-Tx/20171112-012558
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: x86_64-randconfig-g0-11160917 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/crypto/chelsio/chcr_core.o: In function `chcr_uld_tx_handler':
>> drivers/crypto/chelsio/chcr_core.c:195: undefined reference to 
>> `chcr_ipsec_xmit'
   drivers/crypto/chelsio/chcr_core.o: In function `chcr_uld_add':
>> drivers/crypto/chelsio/chcr_core.c:169: undefined reference to 
>> `chcr_add_xfrmops'

vim +195 drivers/crypto/chelsio/chcr_core.c

   152  
   153  static void *chcr_uld_add(const struct cxgb4_lld_info *lld)
   154  {
   155  struct uld_ctx *u_ctx;
   156  
   157  /* Create the device and add it in the device list */
   158  if (!(lld->ulp_crypto & ULP_CRYPTO_LOOKASIDE))
   159  return ERR_PTR(-EOPNOTSUPP);
   160  
   161  /* Create the device and add it in the device list */
   162  u_ctx = kzalloc(sizeof(*u_ctx), GFP_KERNEL);
   163  if (!u_ctx) {
   164  u_ctx = ERR_PTR(-ENOMEM);
   165  goto out;
   166  }
   167  u_ctx->lldi = *lld;
   168  if (lld->crypto & ULP_CRYPTO_IPSEC_INLINE)
 > 169  chcr_add_xfrmops(lld);
   170  out:
   171  return u_ctx;
   172  }
   173  
   174  int chcr_uld_rx_handler(void *handle, const __be64 *rsp,
   175  const struct pkt_gl *pgl)
   176  {
   177  struct uld_ctx *u_ctx = (struct uld_ctx *)handle;
   178  struct chcr_dev *dev = u_ctx->dev;
   179  const struct cpl_fw6_pld *rpl = (struct cpl_fw6_pld *)rsp;
   180  
   181  if (rpl->opcode != CPL_FW6_PLD) {
   182  pr_err("Unsupported opcode\n");
   183  return 0;
   184  }
   185  
   186  if (!pgl)
   187  work_handlers[rpl->opcode](dev, (unsigned char 
*)[1]);
   188  else
   189  work_handlers[rpl->opcode](dev, pgl->va);
   190  return 0;
   191  }
   192  
   193  int chcr_uld_tx_handler(struct sk_buff *skb, struct net_device *dev)
   194  {
 > 195  return chcr_ipsec_xmit(skb, dev);
   196  }
   197  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH v2 2/2] chcr: Add support for Inline IPSec

2017-11-13 Thread David Miller
From: Atul Gupta 
Date: Thu,  9 Nov 2017 16:59:01 +0530

> register xfrmdev_ops callbacks, Send IPsec tunneled data
> to HW for inline processing.
> The driver use hardware crypto accelerator to encrypt and
> generate ICV for the transmitted packet in Inline mode.
> 
> Signed-off-by: Atul Gupta 
> Signed-off-by: Harsh Jain 
> Signed-off-by: Ganesh Goudar 
> ---
> V2: Fixed the build warnings and created patch against cryptodev
> to avoid possible merge conflicts

Herbert, feel free to merge these two patches via your crypto
tree.

Thanks!


[PATCH v2 2/2] chcr: Add support for Inline IPSec

2017-11-09 Thread Atul Gupta
register xfrmdev_ops callbacks, Send IPsec tunneled data
to HW for inline processing.
The driver use hardware crypto accelerator to encrypt and
generate ICV for the transmitted packet in Inline mode.

Signed-off-by: Atul Gupta 
Signed-off-by: Harsh Jain 
Signed-off-by: Ganesh Goudar 
---
V2: Fixed the build warnings and created patch against cryptodev
to avoid possible merge conflicts
---
 drivers/crypto/chelsio/Kconfig   |  10 +
 drivers/crypto/chelsio/Makefile  |   1 +
 drivers/crypto/chelsio/chcr_algo.c   | 221 ++--
 drivers/crypto/chelsio/chcr_algo.h   |  15 -
 drivers/crypto/chelsio/chcr_core.c   |   8 +
 drivers/crypto/chelsio/chcr_core.h   |  38 ++
 drivers/crypto/chelsio/chcr_crypto.h |  69 ++--
 drivers/crypto/chelsio/chcr_ipsec.c  | 659 +++
 8 files changed, 853 insertions(+), 168 deletions(-)
 create mode 100644 drivers/crypto/chelsio/chcr_ipsec.c

diff --git a/drivers/crypto/chelsio/Kconfig b/drivers/crypto/chelsio/Kconfig
index 3e104f5..51932c7 100644
--- a/drivers/crypto/chelsio/Kconfig
+++ b/drivers/crypto/chelsio/Kconfig
@@ -18,3 +18,13 @@ config CRYPTO_DEV_CHELSIO
 
  To compile this driver as a module, choose M here: the module
  will be called chcr.
+
+config CHELSIO_IPSEC_INLINE
+bool "Chelsio IPSec XFRM Tx crypto offload"
+depends on CHELSIO_T4
+   depends on CRYPTO_DEV_CHELSIO
+depends on XFRM_OFFLOAD
+depends on INET_ESP_OFFLOAD || INET6_ESP_OFFLOAD
+default n
+---help---
+  Enable support for IPSec Tx Inline.
diff --git a/drivers/crypto/chelsio/Makefile b/drivers/crypto/chelsio/Makefile
index bebdf06..eaecaf1 100644
--- a/drivers/crypto/chelsio/Makefile
+++ b/drivers/crypto/chelsio/Makefile
@@ -2,3 +2,4 @@ ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4
 
 obj-$(CONFIG_CRYPTO_DEV_CHELSIO) += chcr.o
 chcr-objs :=  chcr_core.o chcr_algo.o
+chcr-$(CONFIG_CHELSIO_IPSEC_INLINE) += chcr_ipsec.o
diff --git a/drivers/crypto/chelsio/chcr_algo.c 
b/drivers/crypto/chelsio/chcr_algo.c
index 4eed717..b623368 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -73,6 +73,25 @@
 
 #define IV AES_BLOCK_SIZE
 
+unsigned int sgl_ent_len[] = {0, 0, 16, 24, 40, 48, 64, 72, 88,
+   96, 112, 120, 136, 144, 160, 168, 184,
+   192, 208, 216, 232, 240, 256, 264, 280,
+   288, 304, 312, 328, 336, 352, 360, 376};
+
+unsigned int dsgl_ent_len[] = {0, 32, 32, 48, 48, 64, 64, 80, 80,
+   112, 112, 128, 128, 144, 144, 160, 160,
+   192, 192, 208, 208, 224, 224, 240, 240,
+   272, 272, 288, 288, 304, 304, 320, 320};
+
+static u32 round_constant[11] = {
+   0x0100, 0x0200, 0x0400, 0x0800,
+   0x1000, 0x2000, 0x4000, 0x8000,
+   0x1B00, 0x3600, 0x6C00
+};
+
+static int chcr_handle_cipher_resp(struct ablkcipher_request *req,
+  unsigned char *input, int err);
+
 static inline  struct chcr_aead_ctx *AEAD_CTX(struct chcr_context *ctx)
 {
return ctx->crypto_ctx->aeadctx;
@@ -108,18 +127,6 @@ static inline int is_ofld_imm(const struct sk_buff *skb)
return (skb->len <= SGE_MAX_WR_LEN);
 }
 
-/*
- * sgl_len - calculates the size of an SGL of the given capacity
- * @n: the number of SGL entries
- * Calculates the number of flits needed for a scatter/gather list that
- * can hold the given number of entries.
- */
-static inline unsigned int sgl_len(unsigned int n)
-{
-   n--;
-   return (3 * n) / 2 + (n & 1) + 2;
-}
-
 static int sg_nents_xlen(struct scatterlist *sg, unsigned int reqlen,
 unsigned int entlen,
 unsigned int skip)
@@ -183,30 +190,17 @@ static inline void chcr_handle_ahash_resp(struct 
ahash_request *req,
}
 out:
req->base.complete(>base, err);
+}
 
-   }
-
-static inline void chcr_handle_aead_resp(struct aead_request *req,
-unsigned char *input,
-int err)
+static inline int get_aead_subtype(struct crypto_aead *aead)
 {
-   struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
-   struct crypto_aead *tfm = crypto_aead_reqtfm(req);
-   struct uld_ctx *u_ctx = ULD_CTX(a_ctx(tfm));
-
-
-   chcr_aead_dma_unmap(_ctx->lldi.pdev->dev, req, reqctx->op);
-   if (reqctx->b0_dma)
-   dma_unmap_single(_ctx->lldi.pdev->dev, reqctx->b0_dma,
-reqctx->b0_len, DMA_BIDIRECTIONAL);
-   if (reqctx->verify == VERIFY_SW) {
-   chcr_verify_tag(req, input, );
-   reqctx->verify = VERIFY_HW;
+   struct aead_alg *alg = crypto_aead_alg(aead);
+   struct chcr_alg_template