87342ef7031dd27ea07efc2f2e4ef74630a46d6a
[dpdk.git] / drivers / net / octeontx2 / otx2_ethdev_sec.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2020 Marvell International Ltd.
3  */
4
5 #ifndef __OTX2_ETHDEV_SEC_H__
6 #define __OTX2_ETHDEV_SEC_H__
7
8 #include <rte_ethdev.h>
9
10 #include "otx2_ipsec_fp.h"
11
12 #define OTX2_CPT_RES_ALIGN              16
13
14 #define OTX2_CPT_EGRP_INLINE_IPSEC      1
15
16 #define OTX2_CPT_OP_WRITE_HMAC_IPAD_OPAD        (0x40 | 0x27)
17
18 #define OTX2_SEC_CPT_COMP_GOOD  0x1
19 #define OTX2_SEC_UC_COMP_GOOD   0x0
20 #define OTX2_SEC_COMP_GOOD      (OTX2_SEC_UC_COMP_GOOD << 8 | \
21                                  OTX2_SEC_CPT_COMP_GOOD)
22
23 /* CPT Result */
24 struct otx2_cpt_res {
25         union {
26                 struct {
27                         uint64_t compcode:8;
28                         uint64_t uc_compcode:8;
29                         uint64_t doneint:1;
30                         uint64_t reserved_17_63:47;
31                         uint64_t reserved_64_127;
32                 };
33                 uint16_t u16[8];
34         };
35 };
36
37 struct otx2_cpt_inst_s {
38         union {
39                 struct {
40                         /* W0 */
41                         uint64_t nixtxl : 3;
42                         uint64_t doneint : 1;
43                         uint64_t nixtx_addr : 60;
44                         /* W1 */
45                         uint64_t res_addr : 64;
46                         /* W2 */
47                         uint64_t tag : 32;
48                         uint64_t tt : 2;
49                         uint64_t grp : 10;
50                         uint64_t rsvd_175_172 : 4;
51                         uint64_t rvu_pf_func : 16;
52                         /* W3 */
53                         uint64_t qord : 1;
54                         uint64_t rsvd_194_193 : 2;
55                         uint64_t wqe_ptr : 61;
56                         /* W4 */
57                         uint64_t dlen : 16;
58                         uint64_t param2 : 16;
59                         uint64_t param1 : 16;
60                         uint64_t opcode : 16;
61                         /* W5 */
62                         uint64_t dptr : 64;
63                         /* W6 */
64                         uint64_t rptr : 64;
65                         /* W7 */
66                         uint64_t cptr : 61;
67                         uint64_t egrp : 3;
68                 };
69                 uint64_t u64[8];
70         };
71 };
72
73 /*
74  * Security session for inline IPsec protocol offload. This is private data of
75  * inline capable PMD.
76  */
77 struct otx2_sec_session_ipsec_ip {
78         RTE_STD_C11
79         union {
80                 /*
81                  * Inbound SA would accessed by crypto block. And so the memory
82                  * is allocated differently and shared with the h/w. Only
83                  * holding a pointer to this memory in the session private
84                  * space.
85                  */
86                 void *in_sa;
87                 /* Outbound SA */
88                 struct otx2_ipsec_fp_out_sa out_sa;
89         };
90
91         /* Address of CPT LMTLINE */
92         void *cpt_lmtline;
93         /* CPT LF enqueue register address */
94         rte_iova_t cpt_nq_reg;
95
96         /* CPT QP used by SA */
97         struct otx2_cpt_qp *qp;
98 };
99
100 struct otx2_sec_session_ipsec {
101         struct otx2_sec_session_ipsec_ip ip;
102 };
103
104 struct otx2_sec_session {
105         struct otx2_sec_session_ipsec ipsec;
106         void *userdata;
107         /**< Userdata registered by the application */
108 } __rte_cache_aligned;
109
110 int otx2_eth_sec_ctx_create(struct rte_eth_dev *eth_dev);
111
112 void otx2_eth_sec_ctx_destroy(struct rte_eth_dev *eth_dev);
113
114 int otx2_eth_sec_init(struct rte_eth_dev *eth_dev);
115
116 void otx2_eth_sec_fini(struct rte_eth_dev *eth_dev);
117
118 #endif /* __OTX2_ETHDEV_SEC_H__ */