Skip to content

Commit 34aba2c

Browse files
rmchelsiodavem330
authored andcommitted
cxgb4/chcr : Register to tls add and del callback
A new macro is defined to enable ktls tx offload support on Chelsio T6 adapter. And if this macro is enabled, cxgb4 will send mailbox to enable or disable ktls settings on HW. In chcr, enabled tx offload flag in netdev and registered tls_dev_add and tls_dev_del. v1->v2: - mark tcb state to close in tls_dev_del. - u_ctx is now picked from adapter structure. - clear atid in case of failure. - corrected ULP_CRYPTO_KTLS_INLINE value. v2->v3: - add empty line after variable declaration. - local variable declaration in reverse christmas tree ordering. Signed-off-by: Rohit Maheshwari <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9d2e4e1 commit 34aba2c

File tree

11 files changed

+499
-0
lines changed

11 files changed

+499
-0
lines changed

drivers/crypto/chelsio/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,14 @@ config CRYPTO_DEV_CHELSIO_TLS
4242

4343
To compile this driver as a module, choose M here: the module
4444
will be called chtls.
45+
46+
config CHELSIO_TLS_DEVICE
47+
bool "Chelsio Inline KTLS Offload"
48+
depends on CHELSIO_T4
49+
depends on TLS_DEVICE
50+
select CRYPTO_DEV_CHELSIO
51+
default y
52+
help
53+
This flag enables support for kernel tls offload over Chelsio T6
54+
crypto accelerator. CONFIG_CHELSIO_TLS_DEVICE flag can be enabled
55+
only if CONFIG_TLS and CONFIG_TLS_DEVICE flags are enabled.

drivers/crypto/chelsio/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ ccflags-y := -I $(srctree)/drivers/net/ethernet/chelsio/cxgb4
33

44
obj-$(CONFIG_CRYPTO_DEV_CHELSIO) += chcr.o
55
chcr-objs := chcr_core.o chcr_algo.o
6+
#ifdef CONFIG_CHELSIO_TLS_DEVICE
7+
chcr-objs += chcr_ktls.o
8+
#endif
69
chcr-$(CONFIG_CHELSIO_IPSEC_INLINE) += chcr_ipsec.o
710
obj-$(CONFIG_CRYPTO_DEV_CHELSIO_TLS) += chtls/

drivers/crypto/chelsio/chcr_common.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/* Copyright (C) 2020 Chelsio Communications. All rights reserved. */
3+
4+
#ifndef __CHCR_COMMON_H__
5+
#define __CHCR_COMMON_H__
6+
7+
#include "cxgb4.h"
8+
9+
enum chcr_state {
10+
CHCR_INIT = 0,
11+
CHCR_ATTACH,
12+
CHCR_DETACH,
13+
};
14+
15+
struct chcr_dev {
16+
spinlock_t lock_chcr_dev; /* chcr dev structure lock */
17+
enum chcr_state state;
18+
atomic_t inflight;
19+
int wqretry;
20+
struct delayed_work detach_work;
21+
struct completion detach_comp;
22+
unsigned char tx_channel_id;
23+
};
24+
25+
struct uld_ctx {
26+
struct list_head entry;
27+
struct cxgb4_lld_info lldi;
28+
struct chcr_dev dev;
29+
};
30+
31+
struct uld_ctx *assign_chcr_device(void);
32+
#endif /* __CHCR_COMMON_H__ */

drivers/crypto/chelsio/chcr_core.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ static void *chcr_uld_add(const struct cxgb4_lld_info *lld)
205205
if (lld->crypto & ULP_CRYPTO_IPSEC_INLINE)
206206
chcr_add_xfrmops(lld);
207207
#endif /* CONFIG_CHELSIO_IPSEC_INLINE */
208+
209+
#ifdef CONFIG_CHELSIO_TLS_DEVICE
210+
if (lld->ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
211+
chcr_enable_ktls(padap(&u_ctx->dev));
212+
#endif
208213
out:
209214
return u_ctx;
210215
}
@@ -304,12 +309,20 @@ static void __exit chcr_crypto_exit(void)
304309
list_for_each_entry_safe(u_ctx, tmp, &drv_data.act_dev, entry) {
305310
adap = padap(&u_ctx->dev);
306311
memset(&adap->chcr_stats, 0, sizeof(adap->chcr_stats));
312+
#ifdef CONFIG_CHELSIO_TLS_DEVICE
313+
if (u_ctx->lldi.ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
314+
chcr_disable_ktls(adap);
315+
#endif
307316
list_del(&u_ctx->entry);
308317
kfree(u_ctx);
309318
}
310319
list_for_each_entry_safe(u_ctx, tmp, &drv_data.inact_dev, entry) {
311320
adap = padap(&u_ctx->dev);
312321
memset(&adap->chcr_stats, 0, sizeof(adap->chcr_stats));
322+
#ifdef CONFIG_CHELSIO_TLS_DEVICE
323+
if (u_ctx->lldi.ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
324+
chcr_disable_ktls(adap);
325+
#endif
313326
list_del(&u_ctx->entry);
314327
kfree(u_ctx);
315328
}

drivers/crypto/chelsio/chcr_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,4 +222,8 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
222222
int err);
223223
int chcr_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
224224
void chcr_add_xfrmops(const struct cxgb4_lld_info *lld);
225+
#ifdef CONFIG_CHELSIO_TLS_DEVICE
226+
void chcr_enable_ktls(struct adapter *adap);
227+
void chcr_disable_ktls(struct adapter *adap);
228+
#endif
225229
#endif /* __CHCR_CORE_H__ */

0 commit comments

Comments
 (0)