Commit 0ec78cdb authored by Ayush Sawal's avatar Ayush Sawal Committed by Jakub Kicinski

cxgb4/ch_ipsec: Replace the module name to ch_ipsec from chcr

This patch changes the module name to "ch_ipsec" and prepends
"ch_ipsec" string instead of "chcr" in all debug messages and
function names.

V1->V2:
-Removed inline keyword from functions.
-Removed CH_IPSEC prefix from pr_debug.
-Used proper indentation for the continuation line of the function
arguments.

V2->V3:
Fix the checkpatch.pl warnings.

Fixes: 1b77be46 ("crypto/chcr: Moving chelsio's inline ipsec functionality to /drivers/net")
Signed-off-by: default avatarAyush Sawal <ayush.sawal@chelsio.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d25e2e93
...@@ -137,6 +137,4 @@ int chcr_uld_rx_handler(void *handle, const __be64 *rsp, ...@@ -137,6 +137,4 @@ int chcr_uld_rx_handler(void *handle, const __be64 *rsp,
int chcr_uld_tx_handler(struct sk_buff *skb, struct net_device *dev); int chcr_uld_tx_handler(struct sk_buff *skb, struct net_device *dev);
int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input, int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
int err); int err);
int chcr_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
void chcr_add_xfrmops(const struct cxgb4_lld_info *lld);
#endif /* __CHCR_CORE_H__ */ #endif /* __CHCR_CORE_H__ */
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
* Atul Gupta (atul.gupta@chelsio.com) * Atul Gupta (atul.gupta@chelsio.com)
*/ */
#define pr_fmt(fmt) "chcr:" fmt #define pr_fmt(fmt) "ch_ipsec: " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -72,20 +72,21 @@ ...@@ -72,20 +72,21 @@
static LIST_HEAD(uld_ctx_list); static LIST_HEAD(uld_ctx_list);
static DEFINE_MUTEX(dev_mutex); static DEFINE_MUTEX(dev_mutex);
static int chcr_xfrm_add_state(struct xfrm_state *x); static bool ch_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
static void chcr_xfrm_del_state(struct xfrm_state *x);
static void chcr_xfrm_free_state(struct xfrm_state *x);
static bool chcr_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
static void chcr_advance_esn_state(struct xfrm_state *x);
static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state); static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state);
static int ch_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
static void *ch_ipsec_uld_add(const struct cxgb4_lld_info *infop); static void *ch_ipsec_uld_add(const struct cxgb4_lld_info *infop);
static void ch_ipsec_advance_esn_state(struct xfrm_state *x);
static const struct xfrmdev_ops chcr_xfrmdev_ops = { static void ch_ipsec_xfrm_free_state(struct xfrm_state *x);
.xdo_dev_state_add = chcr_xfrm_add_state, static void ch_ipsec_xfrm_del_state(struct xfrm_state *x);
.xdo_dev_state_delete = chcr_xfrm_del_state, static int ch_ipsec_xfrm_add_state(struct xfrm_state *x);
.xdo_dev_state_free = chcr_xfrm_free_state,
.xdo_dev_offload_ok = chcr_ipsec_offload_ok, static const struct xfrmdev_ops ch_ipsec_xfrmdev_ops = {
.xdo_dev_state_advance_esn = chcr_advance_esn_state, .xdo_dev_state_add = ch_ipsec_xfrm_add_state,
.xdo_dev_state_delete = ch_ipsec_xfrm_del_state,
.xdo_dev_state_free = ch_ipsec_xfrm_free_state,
.xdo_dev_offload_ok = ch_ipsec_offload_ok,
.xdo_dev_state_advance_esn = ch_ipsec_advance_esn_state,
}; };
static struct cxgb4_uld_info ch_ipsec_uld_info = { static struct cxgb4_uld_info ch_ipsec_uld_info = {
...@@ -95,8 +96,8 @@ static struct cxgb4_uld_info ch_ipsec_uld_info = { ...@@ -95,8 +96,8 @@ static struct cxgb4_uld_info ch_ipsec_uld_info = {
.rxq_size = 1024, .rxq_size = 1024,
.add = ch_ipsec_uld_add, .add = ch_ipsec_uld_add,
.state_change = ch_ipsec_uld_state_change, .state_change = ch_ipsec_uld_state_change,
.tx_handler = chcr_ipsec_xmit, .tx_handler = ch_ipsec_xmit,
.xfrmdev_ops = &chcr_xfrmdev_ops, .xfrmdev_ops = &ch_ipsec_xfrmdev_ops,
}; };
static void *ch_ipsec_uld_add(const struct cxgb4_lld_info *infop) static void *ch_ipsec_uld_add(const struct cxgb4_lld_info *infop)
...@@ -119,7 +120,7 @@ static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state) ...@@ -119,7 +120,7 @@ static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state)
{ {
struct ipsec_uld_ctx *u_ctx = handle; struct ipsec_uld_ctx *u_ctx = handle;
pr_info("new_state %u\n", new_state); pr_debug("new_state %u\n", new_state);
switch (new_state) { switch (new_state) {
case CXGB4_STATE_UP: case CXGB4_STATE_UP:
pr_info("%s: Up\n", pci_name(u_ctx->lldi.pdev)); pr_info("%s: Up\n", pci_name(u_ctx->lldi.pdev));
...@@ -140,8 +141,8 @@ static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state) ...@@ -140,8 +141,8 @@ static int ch_ipsec_uld_state_change(void *handle, enum cxgb4_state new_state)
return 0; return 0;
} }
static inline int chcr_ipsec_setauthsize(struct xfrm_state *x, static int ch_ipsec_setauthsize(struct xfrm_state *x,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
{ {
int hmac_ctrl; int hmac_ctrl;
int authsize = x->aead->alg_icv_len / 8; int authsize = x->aead->alg_icv_len / 8;
...@@ -164,8 +165,8 @@ static inline int chcr_ipsec_setauthsize(struct xfrm_state *x, ...@@ -164,8 +165,8 @@ static inline int chcr_ipsec_setauthsize(struct xfrm_state *x,
return hmac_ctrl; return hmac_ctrl;
} }
static inline int chcr_ipsec_setkey(struct xfrm_state *x, static int ch_ipsec_setkey(struct xfrm_state *x,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
{ {
int keylen = (x->aead->alg_key_len + 7) / 8; int keylen = (x->aead->alg_key_len + 7) / 8;
unsigned char *key = x->aead->alg_key; unsigned char *key = x->aead->alg_key;
...@@ -223,65 +224,65 @@ static inline int chcr_ipsec_setkey(struct xfrm_state *x, ...@@ -223,65 +224,65 @@ static inline int chcr_ipsec_setkey(struct xfrm_state *x,
} }
/* /*
* chcr_xfrm_add_state * ch_ipsec_xfrm_add_state
* returns 0 on success, negative error if failed to send message to FPGA * returns 0 on success, negative error if failed to send message to FPGA
* positive error if FPGA returned a bad response * positive error if FPGA returned a bad response
*/ */
static int chcr_xfrm_add_state(struct xfrm_state *x) static int ch_ipsec_xfrm_add_state(struct xfrm_state *x)
{ {
struct ipsec_sa_entry *sa_entry; struct ipsec_sa_entry *sa_entry;
int res = 0; int res = 0;
if (x->props.aalgo != SADB_AALG_NONE) { if (x->props.aalgo != SADB_AALG_NONE) {
pr_debug("CHCR: Cannot offload authenticated xfrm states\n"); pr_debug("Cannot offload authenticated xfrm states\n");
return -EINVAL; return -EINVAL;
} }
if (x->props.calgo != SADB_X_CALG_NONE) { if (x->props.calgo != SADB_X_CALG_NONE) {
pr_debug("CHCR: Cannot offload compressed xfrm states\n"); pr_debug("Cannot offload compressed xfrm states\n");
return -EINVAL; return -EINVAL;
} }
if (x->props.family != AF_INET && if (x->props.family != AF_INET &&
x->props.family != AF_INET6) { x->props.family != AF_INET6) {
pr_debug("CHCR: Only IPv4/6 xfrm state offloaded\n"); pr_debug("Only IPv4/6 xfrm state offloaded\n");
return -EINVAL; return -EINVAL;
} }
if (x->props.mode != XFRM_MODE_TRANSPORT && if (x->props.mode != XFRM_MODE_TRANSPORT &&
x->props.mode != XFRM_MODE_TUNNEL) { x->props.mode != XFRM_MODE_TUNNEL) {
pr_debug("CHCR: Only transport and tunnel xfrm offload\n"); pr_debug("Only transport and tunnel xfrm offload\n");
return -EINVAL; return -EINVAL;
} }
if (x->id.proto != IPPROTO_ESP) { if (x->id.proto != IPPROTO_ESP) {
pr_debug("CHCR: Only ESP xfrm state offloaded\n"); pr_debug("Only ESP xfrm state offloaded\n");
return -EINVAL; return -EINVAL;
} }
if (x->encap) { if (x->encap) {
pr_debug("CHCR: Encapsulated xfrm state not offloaded\n"); pr_debug("Encapsulated xfrm state not offloaded\n");
return -EINVAL; return -EINVAL;
} }
if (!x->aead) { if (!x->aead) {
pr_debug("CHCR: Cannot offload xfrm states without aead\n"); pr_debug("Cannot offload xfrm states without aead\n");
return -EINVAL; return -EINVAL;
} }
if (x->aead->alg_icv_len != 128 && if (x->aead->alg_icv_len != 128 &&
x->aead->alg_icv_len != 96) { x->aead->alg_icv_len != 96) {
pr_debug("CHCR: Cannot offload xfrm states with AEAD ICV length other than 96b & 128b\n"); pr_debug("Cannot offload xfrm states with AEAD ICV length other than 96b & 128b\n");
return -EINVAL; return -EINVAL;
} }
if ((x->aead->alg_key_len != 128 + 32) && if ((x->aead->alg_key_len != 128 + 32) &&
(x->aead->alg_key_len != 256 + 32)) { (x->aead->alg_key_len != 256 + 32)) {
pr_debug("CHCR: Cannot offload xfrm states with AEAD key length other than 128/256 bit\n"); pr_debug("cannot offload xfrm states with AEAD key length other than 128/256 bit\n");
return -EINVAL; return -EINVAL;
} }
if (x->tfcpad) { if (x->tfcpad) {
pr_debug("CHCR: Cannot offload xfrm states with tfc padding\n"); pr_debug("Cannot offload xfrm states with tfc padding\n");
return -EINVAL; return -EINVAL;
} }
if (!x->geniv) { if (!x->geniv) {
pr_debug("CHCR: Cannot offload xfrm states without geniv\n"); pr_debug("Cannot offload xfrm states without geniv\n");
return -EINVAL; return -EINVAL;
} }
if (strcmp(x->geniv, "seqiv")) { if (strcmp(x->geniv, "seqiv")) {
pr_debug("CHCR: Cannot offload xfrm states with geniv other than seqiv\n"); pr_debug("Cannot offload xfrm states with geniv other than seqiv\n");
return -EINVAL; return -EINVAL;
} }
...@@ -291,24 +292,24 @@ static int chcr_xfrm_add_state(struct xfrm_state *x) ...@@ -291,24 +292,24 @@ static int chcr_xfrm_add_state(struct xfrm_state *x)
goto out; goto out;
} }
sa_entry->hmac_ctrl = chcr_ipsec_setauthsize(x, sa_entry); sa_entry->hmac_ctrl = ch_ipsec_setauthsize(x, sa_entry);
if (x->props.flags & XFRM_STATE_ESN) if (x->props.flags & XFRM_STATE_ESN)
sa_entry->esn = 1; sa_entry->esn = 1;
chcr_ipsec_setkey(x, sa_entry); ch_ipsec_setkey(x, sa_entry);
x->xso.offload_handle = (unsigned long)sa_entry; x->xso.offload_handle = (unsigned long)sa_entry;
try_module_get(THIS_MODULE); try_module_get(THIS_MODULE);
out: out:
return res; return res;
} }
static void chcr_xfrm_del_state(struct xfrm_state *x) static void ch_ipsec_xfrm_del_state(struct xfrm_state *x)
{ {
/* do nothing */ /* do nothing */
if (!x->xso.offload_handle) if (!x->xso.offload_handle)
return; return;
} }
static void chcr_xfrm_free_state(struct xfrm_state *x) static void ch_ipsec_xfrm_free_state(struct xfrm_state *x)
{ {
struct ipsec_sa_entry *sa_entry; struct ipsec_sa_entry *sa_entry;
...@@ -320,7 +321,7 @@ static void chcr_xfrm_free_state(struct xfrm_state *x) ...@@ -320,7 +321,7 @@ static void chcr_xfrm_free_state(struct xfrm_state *x)
module_put(THIS_MODULE); module_put(THIS_MODULE);
} }
static bool chcr_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x) static bool ch_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
{ {
if (x->props.family == AF_INET) { if (x->props.family == AF_INET) {
/* Offload with IP options is not supported yet */ /* Offload with IP options is not supported yet */
...@@ -334,15 +335,15 @@ static bool chcr_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x) ...@@ -334,15 +335,15 @@ static bool chcr_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
return true; return true;
} }
static void chcr_advance_esn_state(struct xfrm_state *x) static void ch_ipsec_advance_esn_state(struct xfrm_state *x)
{ {
/* do nothing */ /* do nothing */
if (!x->xso.offload_handle) if (!x->xso.offload_handle)
return; return;
} }
static inline int is_eth_imm(const struct sk_buff *skb, static int is_eth_imm(const struct sk_buff *skb,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
{ {
unsigned int kctx_len; unsigned int kctx_len;
int hdrlen; int hdrlen;
...@@ -360,9 +361,9 @@ static inline int is_eth_imm(const struct sk_buff *skb, ...@@ -360,9 +361,9 @@ static inline int is_eth_imm(const struct sk_buff *skb,
return 0; return 0;
} }
static inline unsigned int calc_tx_sec_flits(const struct sk_buff *skb, static unsigned int calc_tx_sec_flits(const struct sk_buff *skb,
struct ipsec_sa_entry *sa_entry, struct ipsec_sa_entry *sa_entry,
bool *immediate) bool *immediate)
{ {
unsigned int kctx_len; unsigned int kctx_len;
unsigned int flits; unsigned int flits;
...@@ -403,7 +404,7 @@ static inline unsigned int calc_tx_sec_flits(const struct sk_buff *skb, ...@@ -403,7 +404,7 @@ static inline unsigned int calc_tx_sec_flits(const struct sk_buff *skb,
return flits; return flits;
} }
inline void *copy_esn_pktxt(struct sk_buff *skb, static void *copy_esn_pktxt(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
void *pos, void *pos,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
...@@ -457,7 +458,7 @@ inline void *copy_esn_pktxt(struct sk_buff *skb, ...@@ -457,7 +458,7 @@ inline void *copy_esn_pktxt(struct sk_buff *skb,
return pos; return pos;
} }
inline void *copy_cpltx_pktxt(struct sk_buff *skb, static void *copy_cpltx_pktxt(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
void *pos, void *pos,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
...@@ -501,10 +502,10 @@ inline void *copy_cpltx_pktxt(struct sk_buff *skb, ...@@ -501,10 +502,10 @@ inline void *copy_cpltx_pktxt(struct sk_buff *skb,
return pos; return pos;
} }
inline void *copy_key_cpltx_pktxt(struct sk_buff *skb, static void *copy_key_cpltx_pktxt(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
void *pos, void *pos,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
{ {
struct _key_ctx *key_ctx; struct _key_ctx *key_ctx;
int left, eoq, key_len; int left, eoq, key_len;
...@@ -549,11 +550,11 @@ inline void *copy_key_cpltx_pktxt(struct sk_buff *skb, ...@@ -549,11 +550,11 @@ inline void *copy_key_cpltx_pktxt(struct sk_buff *skb,
return pos; return pos;
} }
inline void *chcr_crypto_wreq(struct sk_buff *skb, static void *ch_ipsec_crypto_wreq(struct sk_buff *skb,
struct net_device *dev, struct net_device *dev,
void *pos, void *pos,
int credits, int credits,
struct ipsec_sa_entry *sa_entry) struct ipsec_sa_entry *sa_entry)
{ {
struct port_info *pi = netdev_priv(dev); struct port_info *pi = netdev_priv(dev);
struct adapter *adap = pi->adapter; struct adapter *adap = pi->adapter;
...@@ -674,13 +675,13 @@ inline void *chcr_crypto_wreq(struct sk_buff *skb, ...@@ -674,13 +675,13 @@ inline void *chcr_crypto_wreq(struct sk_buff *skb,
* Returns the number of Tx descriptors needed for the supplied number * Returns the number of Tx descriptors needed for the supplied number
* of flits. * of flits.
*/ */
static inline unsigned int flits_to_desc(unsigned int n) static unsigned int flits_to_desc(unsigned int n)
{ {
WARN_ON(n > SGE_MAX_WR_LEN / 8); WARN_ON(n > SGE_MAX_WR_LEN / 8);
return DIV_ROUND_UP(n, 8); return DIV_ROUND_UP(n, 8);
} }
static inline unsigned int txq_avail(const struct sge_txq *q) static unsigned int txq_avail(const struct sge_txq *q)
{ {
return q->size - 1 - q->in_use; return q->size - 1 - q->in_use;
} }
...@@ -691,7 +692,7 @@ static void eth_txq_stop(struct sge_eth_txq *q) ...@@ -691,7 +692,7 @@ static void eth_txq_stop(struct sge_eth_txq *q)
q->q.stops++; q->q.stops++;
} }
static inline void txq_advance(struct sge_txq *q, unsigned int n) static void txq_advance(struct sge_txq *q, unsigned int n)
{ {
q->in_use += n; q->in_use += n;
q->pidx += n; q->pidx += n;
...@@ -700,9 +701,9 @@ static inline void txq_advance(struct sge_txq *q, unsigned int n) ...@@ -700,9 +701,9 @@ static inline void txq_advance(struct sge_txq *q, unsigned int n)
} }
/* /*
* chcr_ipsec_xmit called from ULD Tx handler * ch_ipsec_xmit called from ULD Tx handler
*/ */
int chcr_ipsec_xmit(struct sk_buff *skb, struct net_device *dev) int ch_ipsec_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct xfrm_state *x = xfrm_input_state(skb); struct xfrm_state *x = xfrm_input_state(skb);
unsigned int last_desc, ndesc, flits = 0; unsigned int last_desc, ndesc, flits = 0;
...@@ -763,8 +764,8 @@ out_free: dev_kfree_skb_any(skb); ...@@ -763,8 +764,8 @@ out_free: dev_kfree_skb_any(skb);
before = (u64 *)pos; before = (u64 *)pos;
end = (u64 *)pos + flits; end = (u64 *)pos + flits;
/* Setup IPSec CPL */ /* Setup IPSec CPL */
pos = (void *)chcr_crypto_wreq(skb, dev, (void *)pos, pos = (void *)ch_ipsec_crypto_wreq(skb, dev, (void *)pos,
credits, sa_entry); credits, sa_entry);
if (before > (u64 *)pos) { if (before > (u64 *)pos) {
left = (u8 *)end - (u8 *)q->q.stat; left = (u8 *)end - (u8 *)q->q.stat;
end = (void *)q->q.desc + left; end = (void *)q->q.desc + left;
...@@ -791,14 +792,14 @@ out_free: dev_kfree_skb_any(skb); ...@@ -791,14 +792,14 @@ out_free: dev_kfree_skb_any(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
static int __init chcr_ipsec_init(void) static int __init ch_ipsec_init(void)
{ {
cxgb4_register_uld(CXGB4_ULD_IPSEC, &ch_ipsec_uld_info); cxgb4_register_uld(CXGB4_ULD_IPSEC, &ch_ipsec_uld_info);
return 0; return 0;
} }
static void __exit chcr_ipsec_exit(void) static void __exit ch_ipsec_exit(void)
{ {
struct ipsec_uld_ctx *u_ctx, *tmp; struct ipsec_uld_ctx *u_ctx, *tmp;
struct adapter *adap; struct adapter *adap;
...@@ -814,8 +815,8 @@ static void __exit chcr_ipsec_exit(void) ...@@ -814,8 +815,8 @@ static void __exit chcr_ipsec_exit(void)
cxgb4_unregister_uld(CXGB4_ULD_IPSEC); cxgb4_unregister_uld(CXGB4_ULD_IPSEC);
} }
module_init(chcr_ipsec_init); module_init(ch_ipsec_init);
module_exit(chcr_ipsec_exit); module_exit(ch_ipsec_exit);
MODULE_DESCRIPTION("Crypto IPSEC for Chelsio Terminator cards."); MODULE_DESCRIPTION("Crypto IPSEC for Chelsio Terminator cards.");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment