aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/crypto/chelsio/chcr_ktls.h
diff options
context:
space:
mode:
authorRohit Maheshwari <rohitm@chelsio.com>2020-03-07 20:06:03 +0530
committerDavid S. Miller <davem@davemloft.net>2020-03-08 21:16:23 -0700
commit34aba2c45024a0899776c2146d4ab105912d728d (patch)
treeddc27b9ecf025dae8a96880ce68a61da0d2c0eba /drivers/crypto/chelsio/chcr_ktls.h
parentMerge branch 'net-allow-user-specify-TC-action-HW-stats-type' (diff)
downloadwireguard-linux-34aba2c45024a0899776c2146d4ab105912d728d.tar.xz
wireguard-linux-34aba2c45024a0899776c2146d4ab105912d728d.zip
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 <rohitm@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/crypto/chelsio/chcr_ktls.h')
-rw-r--r--drivers/crypto/chelsio/chcr_ktls.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/crypto/chelsio/chcr_ktls.h b/drivers/crypto/chelsio/chcr_ktls.h
new file mode 100644
index 000000000000..f7b993c73424
--- /dev/null
+++ b/drivers/crypto/chelsio/chcr_ktls.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2020 Chelsio Communications. All rights reserved. */
+
+#ifndef __CHCR_KTLS_H__
+#define __CHCR_KTLS_H__
+
+#ifdef CONFIG_CHELSIO_TLS_DEVICE
+#include <net/tls.h>
+#include "cxgb4.h"
+#include "t4_msg.h"
+#include "t4_tcb.h"
+#include "l2t.h"
+#include "chcr_common.h"
+
+#define CHCR_TCB_STATE_CLOSED 0
+
+enum chcr_ktls_conn_state {
+ KTLS_CONN_CLOSED,
+};
+
+struct chcr_ktls_info {
+ struct sock *sk;
+ spinlock_t lock; /* state machine lock */
+ struct adapter *adap;
+ struct l2t_entry *l2te;
+ struct net_device *netdev;
+ int tid;
+ int atid;
+ int rx_qid;
+ u32 prev_seq;
+ u32 tcp_start_seq_number;
+ enum chcr_ktls_conn_state connection_state;
+ u8 tx_chan;
+ u8 smt_idx;
+ u8 port_id;
+ u8 ip_family;
+};
+
+struct chcr_ktls_ofld_ctx_tx {
+ struct tls_offload_context_tx base;
+ struct chcr_ktls_info *chcr_info;
+};
+
+static inline struct chcr_ktls_ofld_ctx_tx *
+chcr_get_ktls_tx_context(struct tls_context *tls_ctx)
+{
+ BUILD_BUG_ON(sizeof(struct chcr_ktls_ofld_ctx_tx) >
+ TLS_OFFLOAD_CONTEXT_SIZE_TX);
+ return container_of(tls_offload_ctx_tx(tls_ctx),
+ struct chcr_ktls_ofld_ctx_tx,
+ base);
+}
+
+static inline int chcr_get_first_rx_qid(struct adapter *adap)
+{
+ /* u_ctx is saved in adap, fetch it */
+ struct uld_ctx *u_ctx = adap->uld[CXGB4_ULD_CRYPTO].handle;
+
+ if (!u_ctx)
+ return -1;
+ return u_ctx->lldi.rxq_ids[0];
+}
+
+void chcr_enable_ktls(struct adapter *adap);
+void chcr_disable_ktls(struct adapter *adap);
+#endif /* CONFIG_CHELSIO_TLS_DEVICE */
+#endif /* __CHCR_KTLS_H__ */