Linux Audio

Check our new training course

Linux kernel drivers training

May 6-19, 2025
Register
Loading...
Note: File does not exist in v5.4.
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/* Copyright (C) 2020 Chelsio Communications.  All rights reserved. */
  3
  4#ifndef __CHCR_KTLS_H__
  5#define __CHCR_KTLS_H__
  6
  7#ifdef CONFIG_CHELSIO_TLS_DEVICE
  8#include <net/tls.h>
  9#include "cxgb4.h"
 10#include "t4_msg.h"
 11#include "t4_tcb.h"
 12#include "l2t.h"
 13#include "chcr_common.h"
 14#include "cxgb4_uld.h"
 15
 16#define CHCR_TCB_STATE_CLOSED	0
 17#define CHCR_KTLS_KEY_CTX_LEN	16
 18#define CHCR_SET_TCB_FIELD_LEN	sizeof(struct cpl_set_tcb_field)
 19#define CHCR_PLAIN_TX_DATA_LEN	(sizeof(struct fw_ulptx_wr) +\
 20				 sizeof(struct ulp_txpkt) +\
 21				 sizeof(struct ulptx_idata) +\
 22				 sizeof(struct cpl_tx_data))
 23
 24#define CHCR_KTLS_WR_SIZE	(CHCR_PLAIN_TX_DATA_LEN +\
 25				 sizeof(struct cpl_tx_sec_pdu))
 26
 27enum chcr_ktls_conn_state {
 28	KTLS_CONN_CLOSED,
 29	KTLS_CONN_ACT_OPEN_REQ,
 30	KTLS_CONN_ACT_OPEN_RPL,
 31	KTLS_CONN_SET_TCB_REQ,
 32	KTLS_CONN_SET_TCB_RPL,
 33	KTLS_CONN_TX_READY,
 34};
 35
 36struct chcr_ktls_info {
 37	struct sock *sk;
 38	spinlock_t lock; /* state machine lock */
 39	struct ktls_key_ctx key_ctx;
 40	struct adapter *adap;
 41	struct l2t_entry *l2te;
 42	struct net_device *netdev;
 43	u64 iv;
 44	u64 record_no;
 45	int tid;
 46	int atid;
 47	int rx_qid;
 48	u32 iv_size;
 49	u32 prev_seq;
 50	u32 prev_ack;
 51	u32 salt_size;
 52	u32 key_ctx_len;
 53	u32 scmd0_seqno_numivs;
 54	u32 scmd0_ivgen_hdrlen;
 55	u32 tcp_start_seq_number;
 56	u32 scmd0_short_seqno_numivs;
 57	u32 scmd0_short_ivgen_hdrlen;
 58	enum chcr_ktls_conn_state connection_state;
 59	u16 prev_win;
 60	u8 tx_chan;
 61	u8 smt_idx;
 62	u8 port_id;
 63	u8 ip_family;
 64	u8 first_qset;
 65};
 66
 67struct chcr_ktls_ofld_ctx_tx {
 68	struct tls_offload_context_tx base;
 69	struct chcr_ktls_info *chcr_info;
 70};
 71
 72static inline struct chcr_ktls_ofld_ctx_tx *
 73chcr_get_ktls_tx_context(struct tls_context *tls_ctx)
 74{
 75	BUILD_BUG_ON(sizeof(struct chcr_ktls_ofld_ctx_tx) >
 76		     TLS_OFFLOAD_CONTEXT_SIZE_TX);
 77	return container_of(tls_offload_ctx_tx(tls_ctx),
 78			    struct chcr_ktls_ofld_ctx_tx,
 79			    base);
 80}
 81
 82static inline int chcr_get_first_rx_qid(struct adapter *adap)
 83{
 84	/* u_ctx is saved in adap, fetch it */
 85	struct uld_ctx *u_ctx = adap->uld[CXGB4_ULD_CRYPTO].handle;
 86
 87	if (!u_ctx)
 88		return -1;
 89	return u_ctx->lldi.rxq_ids[0];
 90}
 91
 92int chcr_ktls_cpl_act_open_rpl(struct adapter *adap, unsigned char *input);
 93int chcr_ktls_cpl_set_tcb_rpl(struct adapter *adap, unsigned char *input);
 94int chcr_ktls_xmit(struct sk_buff *skb, struct net_device *dev);
 95int chcr_ktls_dev_add(struct net_device *netdev, struct sock *sk,
 96		      enum tls_offload_ctx_dir direction,
 97		      struct tls_crypto_info *crypto_info,
 98		      u32 start_offload_tcp_sn);
 99void chcr_ktls_dev_del(struct net_device *netdev,
100		       struct tls_context *tls_ctx,
101		       enum tls_offload_ctx_dir direction);
102#endif /* CONFIG_CHELSIO_TLS_DEVICE */
103#endif /* __CHCR_KTLS_H__ */