hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/crypto/chelsio/chcr_core.h
....@@ -37,17 +37,19 @@
3737 #define __CHCR_CORE_H__
3838
3939 #include <crypto/algapi.h>
40
+#include <net/tls.h>
4041 #include "t4_hw.h"
4142 #include "cxgb4.h"
4243 #include "t4_msg.h"
4344 #include "cxgb4_uld.h"
4445
4546 #define DRV_MODULE_NAME "chcr"
46
-#define DRV_VERSION "1.0.0.0"
47
+#define DRV_VERSION "1.0.0.0-ko"
48
+#define DRV_DESC "Chelsio T6 Crypto Co-processor Driver"
4749
4850 #define MAX_PENDING_REQ_TO_HW 20
4951 #define CHCR_TEST_RESPONSE_TIMEOUT 1000
50
-
52
+#define WQ_DETACH_TM (msecs_to_jiffies(50))
5153 #define PAD_ERROR_BIT 1
5254 #define CHK_PAD_ERR_BIT(x) (((x) >> PAD_ERROR_BIT) & 1)
5355
....@@ -61,66 +63,29 @@
6163 #define HASH_WR_MIN_LEN (sizeof(struct chcr_wr) + \
6264 DUMMY_BYTES + \
6365 sizeof(struct ulptx_sgl))
64
-
65
-#define padap(dev) pci_get_drvdata(dev->u_ctx->lldi.pdev)
66
-
6766 struct uld_ctx;
6867
6968 struct _key_ctx {
7069 __be32 ctx_hdr;
7170 u8 salt[MAX_SALT];
7271 __be64 iv_to_auth;
73
- unsigned char key[0];
72
+ unsigned char key[];
7473 };
7574
76
-#define KEYCTX_TX_WR_IV_S 55
77
-#define KEYCTX_TX_WR_IV_M 0x1ffULL
78
-#define KEYCTX_TX_WR_IV_V(x) ((x) << KEYCTX_TX_WR_IV_S)
79
-#define KEYCTX_TX_WR_IV_G(x) \
80
- (((x) >> KEYCTX_TX_WR_IV_S) & KEYCTX_TX_WR_IV_M)
75
+#define WQ_RETRY 5
76
+struct chcr_driver_data {
77
+ struct list_head act_dev;
78
+ struct list_head inact_dev;
79
+ atomic_t dev_count;
80
+ struct mutex drv_mutex;
81
+ struct uld_ctx *last_dev;
82
+};
8183
82
-#define KEYCTX_TX_WR_AAD_S 47
83
-#define KEYCTX_TX_WR_AAD_M 0xffULL
84
-#define KEYCTX_TX_WR_AAD_V(x) ((x) << KEYCTX_TX_WR_AAD_S)
85
-#define KEYCTX_TX_WR_AAD_G(x) (((x) >> KEYCTX_TX_WR_AAD_S) & \
86
- KEYCTX_TX_WR_AAD_M)
87
-
88
-#define KEYCTX_TX_WR_AADST_S 39
89
-#define KEYCTX_TX_WR_AADST_M 0xffULL
90
-#define KEYCTX_TX_WR_AADST_V(x) ((x) << KEYCTX_TX_WR_AADST_S)
91
-#define KEYCTX_TX_WR_AADST_G(x) \
92
- (((x) >> KEYCTX_TX_WR_AADST_S) & KEYCTX_TX_WR_AADST_M)
93
-
94
-#define KEYCTX_TX_WR_CIPHER_S 30
95
-#define KEYCTX_TX_WR_CIPHER_M 0x1ffULL
96
-#define KEYCTX_TX_WR_CIPHER_V(x) ((x) << KEYCTX_TX_WR_CIPHER_S)
97
-#define KEYCTX_TX_WR_CIPHER_G(x) \
98
- (((x) >> KEYCTX_TX_WR_CIPHER_S) & KEYCTX_TX_WR_CIPHER_M)
99
-
100
-#define KEYCTX_TX_WR_CIPHERST_S 23
101
-#define KEYCTX_TX_WR_CIPHERST_M 0x7f
102
-#define KEYCTX_TX_WR_CIPHERST_V(x) ((x) << KEYCTX_TX_WR_CIPHERST_S)
103
-#define KEYCTX_TX_WR_CIPHERST_G(x) \
104
- (((x) >> KEYCTX_TX_WR_CIPHERST_S) & KEYCTX_TX_WR_CIPHERST_M)
105
-
106
-#define KEYCTX_TX_WR_AUTH_S 14
107
-#define KEYCTX_TX_WR_AUTH_M 0x1ff
108
-#define KEYCTX_TX_WR_AUTH_V(x) ((x) << KEYCTX_TX_WR_AUTH_S)
109
-#define KEYCTX_TX_WR_AUTH_G(x) \
110
- (((x) >> KEYCTX_TX_WR_AUTH_S) & KEYCTX_TX_WR_AUTH_M)
111
-
112
-#define KEYCTX_TX_WR_AUTHST_S 7
113
-#define KEYCTX_TX_WR_AUTHST_M 0x7f
114
-#define KEYCTX_TX_WR_AUTHST_V(x) ((x) << KEYCTX_TX_WR_AUTHST_S)
115
-#define KEYCTX_TX_WR_AUTHST_G(x) \
116
- (((x) >> KEYCTX_TX_WR_AUTHST_S) & KEYCTX_TX_WR_AUTHST_M)
117
-
118
-#define KEYCTX_TX_WR_AUTHIN_S 0
119
-#define KEYCTX_TX_WR_AUTHIN_M 0x7f
120
-#define KEYCTX_TX_WR_AUTHIN_V(x) ((x) << KEYCTX_TX_WR_AUTHIN_S)
121
-#define KEYCTX_TX_WR_AUTHIN_G(x) \
122
- (((x) >> KEYCTX_TX_WR_AUTHIN_S) & KEYCTX_TX_WR_AUTHIN_M)
123
-
84
+enum chcr_state {
85
+ CHCR_INIT = 0,
86
+ CHCR_ATTACH,
87
+ CHCR_DETACH,
88
+};
12489 struct chcr_wr {
12590 struct fw_crypto_lookaside_wr wreq;
12691 struct ulp_txpkt ulptx;
....@@ -131,42 +96,17 @@
13196
13297 struct chcr_dev {
13398 spinlock_t lock_chcr_dev;
134
- struct uld_ctx *u_ctx;
135
- unsigned char tx_channel_id;
136
- unsigned char rx_channel_id;
99
+ enum chcr_state state;
100
+ atomic_t inflight;
101
+ int wqretry;
102
+ struct delayed_work detach_work;
103
+ struct completion detach_comp;
137104 };
138105
139106 struct uld_ctx {
140107 struct list_head entry;
141108 struct cxgb4_lld_info lldi;
142
- struct chcr_dev *dev;
143
-};
144
-
145
-struct sge_opaque_hdr {
146
- void *dev;
147
- dma_addr_t addr[MAX_SKB_FRAGS + 1];
148
-};
149
-
150
-struct chcr_ipsec_req {
151
- struct ulp_txpkt ulptx;
152
- struct ulptx_idata sc_imm;
153
- struct cpl_tx_sec_pdu sec_cpl;
154
- struct _key_ctx key_ctx;
155
-};
156
-
157
-struct chcr_ipsec_wr {
158
- struct fw_ulptx_wr wreq;
159
- struct chcr_ipsec_req req;
160
-};
161
-
162
-struct ipsec_sa_entry {
163
- int hmac_ctrl;
164
- unsigned int enckey_len;
165
- unsigned int kctx_len;
166
- unsigned int authsize;
167
- __be32 key_ctx_hdr;
168
- char salt[MAX_SALT];
169
- char key[2 * AES_MAX_KEY_SIZE];
109
+ struct chcr_dev dev;
170110 };
171111
172112 /*
....@@ -181,6 +121,13 @@
181121 return (3 * n) / 2 + (n & 1) + 2;
182122 }
183123
124
+static inline void *padap(struct chcr_dev *dev)
125
+{
126
+ struct uld_ctx *u_ctx = container_of(dev, struct uld_ctx, dev);
127
+
128
+ return pci_get_drvdata(u_ctx->lldi.pdev);
129
+}
130
+
184131 struct uld_ctx *assign_chcr_device(void);
185132 int chcr_send_wr(struct sk_buff *skb);
186133 int start_crypto(void);
....@@ -190,6 +137,4 @@
190137 int chcr_uld_tx_handler(struct sk_buff *skb, struct net_device *dev);
191138 int chcr_handle_resp(struct crypto_async_request *req, unsigned char *input,
192139 int err);
193
-int chcr_ipsec_xmit(struct sk_buff *skb, struct net_device *dev);
194
-void chcr_add_xfrmops(const struct cxgb4_lld_info *lld);
195140 #endif /* __CHCR_CORE_H__ */