Commit 34aba2c4 authored by Rohit Maheshwari's avatar Rohit Maheshwari Committed by David S. Miller
Browse files

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: default avatarRohit Maheshwari <rohitm@chelsio.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9d2e4e16
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -42,3 +42,14 @@ config CRYPTO_DEV_CHELSIO_TLS

	  To compile this driver as a module, choose M here: the module
	  will be called chtls.

config CHELSIO_TLS_DEVICE
	bool "Chelsio Inline KTLS Offload"
	depends on CHELSIO_T4
	depends on TLS_DEVICE
	select CRYPTO_DEV_CHELSIO
	default y
	help
	  This flag enables support for kernel tls offload over Chelsio T6
	  crypto accelerator. CONFIG_CHELSIO_TLS_DEVICE flag can be enabled
	  only if CONFIG_TLS and CONFIG_TLS_DEVICE flags are enabled.
+3 −0
Original line number Diff line number Diff line
@@ -3,5 +3,8 @@ ccflags-y := -I $(srctree)/drivers/net/ethernet/chelsio/cxgb4

obj-$(CONFIG_CRYPTO_DEV_CHELSIO) += chcr.o
chcr-objs :=  chcr_core.o chcr_algo.o
#ifdef CONFIG_CHELSIO_TLS_DEVICE
chcr-objs += chcr_ktls.o
#endif
chcr-$(CONFIG_CHELSIO_IPSEC_INLINE) += chcr_ipsec.o
obj-$(CONFIG_CRYPTO_DEV_CHELSIO_TLS) += chtls/
+32 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) 2020 Chelsio Communications.  All rights reserved. */

#ifndef __CHCR_COMMON_H__
#define __CHCR_COMMON_H__

#include "cxgb4.h"

enum chcr_state {
	CHCR_INIT = 0,
	CHCR_ATTACH,
	CHCR_DETACH,
};

struct chcr_dev {
	spinlock_t lock_chcr_dev; /* chcr dev structure lock */
	enum chcr_state state;
	atomic_t inflight;
	int wqretry;
	struct delayed_work detach_work;
	struct completion detach_comp;
	unsigned char tx_channel_id;
};

struct uld_ctx {
	struct list_head entry;
	struct cxgb4_lld_info lldi;
	struct chcr_dev dev;
};

struct uld_ctx *assign_chcr_device(void);
#endif /* __CHCR_COMMON_H__ */
+13 −0
Original line number Diff line number Diff line
@@ -205,6 +205,11 @@ static void *chcr_uld_add(const struct cxgb4_lld_info *lld)
	if (lld->crypto & ULP_CRYPTO_IPSEC_INLINE)
		chcr_add_xfrmops(lld);
#endif /* CONFIG_CHELSIO_IPSEC_INLINE */

#ifdef CONFIG_CHELSIO_TLS_DEVICE
	if (lld->ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
		chcr_enable_ktls(padap(&u_ctx->dev));
#endif
out:
	return u_ctx;
}
@@ -304,12 +309,20 @@ static void __exit chcr_crypto_exit(void)
	list_for_each_entry_safe(u_ctx, tmp, &drv_data.act_dev, entry) {
		adap = padap(&u_ctx->dev);
		memset(&adap->chcr_stats, 0, sizeof(adap->chcr_stats));
#ifdef CONFIG_CHELSIO_TLS_DEVICE
		if (u_ctx->lldi.ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
			chcr_disable_ktls(adap);
#endif
		list_del(&u_ctx->entry);
		kfree(u_ctx);
	}
	list_for_each_entry_safe(u_ctx, tmp, &drv_data.inact_dev, entry) {
		adap = padap(&u_ctx->dev);
		memset(&adap->chcr_stats, 0, sizeof(adap->chcr_stats));
#ifdef CONFIG_CHELSIO_TLS_DEVICE
		if (u_ctx->lldi.ulp_crypto & ULP_CRYPTO_KTLS_INLINE)
			chcr_disable_ktls(adap);
#endif
		list_del(&u_ctx->entry);
		kfree(u_ctx);
	}
+4 −0
Original line number Diff line number Diff line
@@ -222,4 +222,8 @@ int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
		     int err);
int chcr_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
void chcr_add_xfrmops(const struct cxgb4_lld_info *lld);
#ifdef CONFIG_CHELSIO_TLS_DEVICE
void chcr_enable_ktls(struct adapter *adap);
void chcr_disable_ktls(struct adapter *adap);
#endif
#endif /* __CHCR_CORE_H__ */
Loading