net/bnxt: add core changes for EM and EEM lookups
[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 #define OTX2_NIX_SEND_DESC_ALIGN        16
14 #define OTX2_CPT_INST_SIZE              64
15
16 #define OTX2_CPT_EGRP_INLINE_IPSEC      1
17
18 #define OTX2_CPT_OP_INLINE_IPSEC_OUTB           (0x40 | 0x25)
19 #define OTX2_CPT_OP_INLINE_IPSEC_INB            (0x40 | 0x26)
20 #define OTX2_CPT_OP_WRITE_HMAC_IPAD_OPAD        (0x40 | 0x27)
21
22 #define OTX2_SEC_CPT_COMP_GOOD  0x1
23 #define OTX2_SEC_UC_COMP_GOOD   0x0
24 #define OTX2_SEC_COMP_GOOD      (OTX2_SEC_UC_COMP_GOOD << 8 | \
25                                  OTX2_SEC_CPT_COMP_GOOD)
26
27 /* CPT Result */
28 struct otx2_cpt_res {
29         union {
30                 struct {
31                         uint64_t compcode:8;
32                         uint64_t uc_compcode:8;
33                         uint64_t doneint:1;
34                         uint64_t reserved_17_63:47;
35                         uint64_t reserved_64_127;
36                 };
37                 uint16_t u16[8];
38         };
39 };
40
41 struct otx2_cpt_inst_s {
42         union {
43                 struct {
44                         /* W0 */
45                         uint64_t nixtxl : 3;
46                         uint64_t doneint : 1;
47                         uint64_t nixtx_addr : 60;
48                         /* W1 */
49                         uint64_t res_addr : 64;
50                         /* W2 */
51                         uint64_t tag : 32;
52                         uint64_t tt : 2;
53                         uint64_t grp : 10;
54                         uint64_t rsvd_175_172 : 4;
55                         uint64_t rvu_pf_func : 16;
56                         /* W3 */
57                         uint64_t qord : 1;
58                         uint64_t rsvd_194_193 : 2;
59                         uint64_t wqe_ptr : 61;
60                         /* W4 */
61                         uint64_t dlen : 16;
62                         uint64_t param2 : 16;
63                         uint64_t param1 : 16;
64                         uint64_t opcode : 16;
65                         /* W5 */
66                         uint64_t dptr : 64;
67                         /* W6 */
68                         uint64_t rptr : 64;
69                         /* W7 */
70                         uint64_t cptr : 61;
71                         uint64_t egrp : 3;
72                 };
73                 uint64_t u64[8];
74         };
75 };
76
77 /*
78  * Security session for inline IPsec protocol offload. This is private data of
79  * inline capable PMD.
80  */
81 struct otx2_sec_session_ipsec_ip {
82         RTE_STD_C11
83         union {
84                 /*
85                  * Inbound SA would accessed by crypto block. And so the memory
86                  * is allocated differently and shared with the h/w. Only
87                  * holding a pointer to this memory in the session private
88                  * space.
89                  */
90                 void *in_sa;
91                 /* Outbound SA */
92                 struct otx2_ipsec_fp_out_sa out_sa;
93         };
94
95         /* Address of CPT LMTLINE */
96         void *cpt_lmtline;
97         /* CPT LF enqueue register address */
98         rte_iova_t cpt_nq_reg;
99
100         /* Pre calculated lengths and data for a session */
101         uint8_t partial_len;
102         uint8_t roundup_len;
103         uint8_t roundup_byte;
104         uint16_t ip_id;
105         union {
106                 uint64_t esn;
107                 struct {
108                         uint32_t seq;
109                         uint32_t esn_hi;
110                 };
111         };
112
113         uint64_t inst_w7;
114
115         /* CPT QP used by SA */
116         struct otx2_cpt_qp *qp;
117 };
118
119 struct otx2_sec_session_ipsec {
120         struct otx2_sec_session_ipsec_ip ip;
121 };
122
123 struct otx2_sec_session {
124         struct otx2_sec_session_ipsec ipsec;
125         void *userdata;
126         /**< Userdata registered by the application */
127 } __rte_cache_aligned;
128
129 int otx2_eth_sec_ctx_create(struct rte_eth_dev *eth_dev);
130
131 void otx2_eth_sec_ctx_destroy(struct rte_eth_dev *eth_dev);
132
133 int otx2_eth_sec_update_tag_type(struct rte_eth_dev *eth_dev);
134
135 int otx2_eth_sec_init(struct rte_eth_dev *eth_dev);
136
137 void otx2_eth_sec_fini(struct rte_eth_dev *eth_dev);
138
139 #endif /* __OTX2_ETHDEV_SEC_H__ */