Re: [PATCH net-next 2/2] chcr: Add support for Inline IPSec

2017-10-29 Thread kbuild test robot
Hi Atul,

Thank you for the patch! Yet we hit a small issue.
[auto build test WARNING on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Atul-Gupta/cxgb4-Add-support-for-Inline-IPSec-Tx/20171029-060344
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


vim +1678 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

f2b7e78db drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-12-10  1562  
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1563  void t4_wol_magic_enable(struct adapter *adap, unsigned int 
port,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1564   const u8 *addr);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1565  int t4_wol_pat_enable(struct adapter *adap, unsigned int 
port, unsigned int map,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1566u64 mask0, u64 mask1, unsigned int crc, 
bool enable);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1567  
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1568  int t4_fw_hello(struct adapter *adap, unsigned int mbox, 
unsigned int evt_mbox,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1569  enum dev_master master, enum dev_state *state);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1570  int t4_fw_bye(struct adapter *adap, unsigned int mbox);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1571  int t4_early_init(struct adapter *adap, unsigned int mbox);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1572  int t4_fw_reset(struct adapter *adap, unsigned int mbox, int 
reset);
636f9d371 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-09-26  1573  int t4_fixup_host_params(struct adapter *adap, unsigned int 
page_size,
636f9d371 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-09-26  1574unsigned int cache_line_size);
636f9d371 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-09-26  1575  int t4_fw_initialize(struct adapter *adap, unsigned int mbox);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1576  int t4_query_params(struct adapter *adap, unsigned int mbox, 
unsigned int pf,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1577  unsigned int vf, unsigned int nparams, const 
u32 *params,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1578  u32 *val);
8f46d4671 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Arjun Vynipadath 
2017-06-23  1579  int t4_query_params_ns(struct adapter *adap, unsigned int 
mbox, unsigned int pf,
8f46d4671 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Arjun Vynipadath 
2017-06-23  1580 unsigned int vf, unsigned int nparams, 
const u32 *params,
8f46d4671 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Arjun Vynipadath 
2017-06-23  1581 u32 *val);
01b696141 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Hariprasad Shenai
2015-05-22  1582  int t4_query_params_rw(struct adapter *adap, unsigned int 
mbox, unsigned int pf,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1583 unsigned int vf, unsigned int nparams, 
const u32 *params,
8f46d4671 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Arjun Vynipadath 
2017-06-23  1584 u32 *val, int rw, bool sleep_ok);
01b696141 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Hariprasad Shenai
2015-05-22  1585  int t4_set_params_timeout(struct adapter *adap, unsigned int 
mbox,
688848b14 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Anish Bhatt  
2014-06-19  1586unsigned int pf, unsigned int vf,
688848b14 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Anish Bhatt  
2014-06-19  1587unsigned int nparams, const u32 *params,
01b696141 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Hariprasad Shenai
2015-05-22  1588const u32 *val, int timeout);
01b696141 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Hariprasad Shenai
2015-05-22  1589  int t4_set_params(struct adapter *adap, unsigned int mbox, 
unsigned int pf,
01b696141 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Hariprasad Shenai
2015-05-22  1590unsigned int vf, unsigned int nparams, const 
u32 *params,
688848b14 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Anish Bhatt  
2014-06-19  1591

Re: [PATCH net-next 2/2] chcr: Add support for Inline IPSec

2017-10-28 Thread kbuild test robot
Hi Atul,

Thank you for the patch! Yet we hit a small issue.
[auto build test ERROR on net-next/master]

url:
https://github.com/0day-ci/linux/commits/Atul-Gupta/cxgb4-Add-support-for-Inline-IPSec-Tx/20171029-060344
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   In file included from drivers/crypto/chelsio/chcr_core.h:41:0,
from drivers/crypto/chelsio/chcr_ipsec.c:64:
   drivers/crypto/chelsio/chcr_ipsec.c: In function 'chcr_ipsec_xmit':
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1678:13: error: inlining failed 
>> in call to always_inline 'cxgb4_reclaim_completed_tx': function body not 
>> available
inline void cxgb4_reclaim_completed_tx(struct adapter *adap,
^~
   drivers/crypto/chelsio/chcr_ipsec.c:597:2: note: called from here
 cxgb4_reclaim_completed_tx(adap, >q, true);
 ^
   In file included from drivers/crypto/chelsio/chcr_core.h:41:0,
from drivers/crypto/chelsio/chcr_ipsec.c:64:
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1678:13: error: inlining failed 
>> in call to always_inline 'cxgb4_reclaim_completed_tx': function body not 
>> available
inline void cxgb4_reclaim_completed_tx(struct adapter *adap,
^~
   drivers/crypto/chelsio/chcr_ipsec.c:597:2: note: called from here
 cxgb4_reclaim_completed_tx(adap, >q, true);
 ^
   In file included from drivers/crypto/chelsio/chcr_core.h:41:0,
from drivers/crypto/chelsio/chcr_ipsec.c:64:
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1687:13: error: inlining failed 
>> in call to always_inline 'cxgb4_ring_tx_db': function body not available
inline void cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int 
n);
^~~~
   drivers/crypto/chelsio/chcr_ipsec.c:657:2: note: called from here
 cxgb4_ring_tx_db(adap, >q, ndesc);
 ^~~~
   In file included from drivers/crypto/chelsio/chcr_core.h:41:0,
from drivers/crypto/chelsio/chcr_ipsec.c:64:
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4.h:1687:13: error: inlining failed 
>> in call to always_inline 'cxgb4_ring_tx_db': function body not available
inline void cxgb4_ring_tx_db(struct adapter *adap, struct sge_txq *q, int 
n);
^~~~
   drivers/crypto/chelsio/chcr_ipsec.c:657:2: note: called from here
 cxgb4_ring_tx_db(adap, >q, ndesc);
 ^~~~

vim +/cxgb4_reclaim_completed_tx +1678 
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

f2b7e78db drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-12-10  1562  
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1563  void t4_wol_magic_enable(struct adapter *adap, unsigned int 
port,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1564   const u8 *addr);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1565  int t4_wol_pat_enable(struct adapter *adap, unsigned int 
port, unsigned int map,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1566u64 mask0, u64 mask1, unsigned int crc, 
bool enable);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1567  
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1568  int t4_fw_hello(struct adapter *adap, unsigned int mbox, 
unsigned int evt_mbox,
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1569  enum dev_master master, enum dev_state *state);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1570  int t4_fw_bye(struct adapter *adap, unsigned int mbox);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1571  int t4_early_init(struct adapter *adap, unsigned int mbox);
625ba2c2e drivers/net/cxgb4/cxgb4.h  Dimitris Michailidis 
2010-04-01  1572  int t4_fw_reset(struct adapter *adap, unsigned int mbox, int 
reset);
636f9d371 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-09-26  1573  int t4_fixup_host_params(struct adapter *adap, unsigned int 
page_size,
636f9d371 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 
2012-09-26  1574unsigned int cache_line_size);
636f9d371 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h Vipul Pandya 

[PATCH net-next 2/2] chcr: Add support for Inline IPSec

2017-10-27 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 
---
 drivers/crypto/chelsio/Makefile  |   2 +-
 drivers/crypto/chelsio/chcr_algo.c   |  45 ++-
 drivers/crypto/chelsio/chcr_algo.h   |  17 -
 drivers/crypto/chelsio/chcr_core.c   |   8 +
 drivers/crypto/chelsio/chcr_core.h   |  39 +++
 drivers/crypto/chelsio/chcr_crypto.h |  17 +-
 drivers/crypto/chelsio/chcr_ipsec.c  | 659 +++
 7 files changed, 740 insertions(+), 47 deletions(-)
 create mode 100644 drivers/crypto/chelsio/chcr_ipsec.c

diff --git a/drivers/crypto/chelsio/Makefile b/drivers/crypto/chelsio/Makefile
index bebdf06..9056420 100644
--- a/drivers/crypto/chelsio/Makefile
+++ b/drivers/crypto/chelsio/Makefile
@@ -1,4 +1,4 @@
 ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4
 
 obj-$(CONFIG_CRYPTO_DEV_CHELSIO) += chcr.o
-chcr-objs :=  chcr_core.o chcr_algo.o
+chcr-objs :=  chcr_core.o chcr_algo.o chcr_ipsec.o
diff --git a/drivers/crypto/chelsio/chcr_algo.c 
b/drivers/crypto/chelsio/chcr_algo.c
index 0e81607..060f747 100644
--- a/drivers/crypto/chelsio/chcr_algo.c
+++ b/drivers/crypto/chelsio/chcr_algo.c
@@ -70,6 +70,29 @@
 #include "chcr_algo.h"
 #include "chcr_crypto.h"
 
+unsigned int sgl_ent_len[] = {0, 0, 16, 24, 40,
+ 48, 64, 72, 88,
+ 96, 112, 120, 136,
+ 144, 160, 168, 184, 192};
+
+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 is_newsg(struct scatterlist *sgl, unsigned int *newents);
+static struct scatterlist *alloc_new_sg(struct scatterlist *sgl,
+   unsigned int nents);
+static inline void free_new_sg(struct scatterlist *sgl);
+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;
@@ -105,18 +128,6 @@ static inline int is_ofld_imm(const struct sk_buff *skb)
return (skb->len <= CRYPTO_MAX_IMM_TX_PKT_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 void chcr_verify_tag(struct aead_request *req, u8 *input, int *err)
 {
u8 temp[SHA512_DIGEST_SIZE];
@@ -432,7 +443,7 @@ static inline int map_writesg_phys_cpl(struct device *dev,
return 0;
 }
 
-static inline int get_aead_subtype(struct crypto_aead *aead)
+inline int get_aead_subtype(struct crypto_aead *aead)
 {
struct aead_alg *alg = crypto_aead_alg(aead);
struct chcr_alg_template *chcr_crypto_alg =
@@ -3134,10 +3145,10 @@ static int chcr_aead_decrypt(struct aead_request *req)
}
 }
 
-static int chcr_aead_op(struct aead_request *req,
- unsigned short op_type,
- int size,
- create_wr_t create_wr_fn)
+int chcr_aead_op(struct aead_request *req,
+unsigned short op_type,
+int size,
+create_wr_t create_wr_fn)
 {
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
struct chcr_context *ctx = crypto_aead_ctx(tfm);
diff --git a/drivers/crypto/chelsio/chcr_algo.h 
b/drivers/crypto/chelsio/chcr_algo.h
index 583008d..a5f5b19 100644
--- a/drivers/crypto/chelsio/chcr_algo.h
+++ b/drivers/crypto/chelsio/chcr_algo.h
@@ -217,7 +217,6 @@
ULP_TX_SC_MORE_V((immdatalen) ? 0 : 1))
 
 #define MAX_NK 8
-#define CRYPTO_MAX_IMM_TX_PKT_LEN 256
 #define MAX_WR_SIZE512
 #define ROUND_16(bytes)((bytes) & 0xFFF0)
 #define MAX_DSGL_ENT   32
@@ -230,16 +229,6 @@
 #define SPACE_LEFT(len) \
((MAX_WR_SIZE - WR_MIN_LEN - (len)))
 
-unsigned int sgl_ent_len[] = {0, 0, 16, 24, 40,
-   48, 64, 72, 88,
-   96, 112, 120, 136,
-   144, 160, 168, 184,
-