New upstream version 17.11.5
[deb_dpdk.git] / drivers / net / octeontx / base / octeontx_pki_var.h
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright (C) Cavium Inc. 2017. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Cavium networks nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef __OCTEONTX_PKI_VAR_H__
34 #define __OCTEONTX_PKI_VAR_H__
35
36 #include <rte_byteorder.h>
37
38 #define OCTTX_PACKET_WQE_SKIP                   128
39 #define OCTTX_PACKET_FIRST_SKIP_MAXREGVAL       496
40 #define OCTTX_PACKET_FIRST_SKIP_MAXLEN          512
41 #define OCTTX_PACKET_FIRST_SKIP_ADJUST(x)                               \
42                 (RTE_MIN(x, OCTTX_PACKET_FIRST_SKIP_MAXREGVAL))
43 #define OCTTX_PACKET_FIRST_SKIP_SUM(p)                                  \
44                                 (OCTTX_PACKET_WQE_SKIP                  \
45                                 + rte_pktmbuf_priv_size(p)              \
46                                 + RTE_PKTMBUF_HEADROOM)
47 #define OCTTX_PACKET_FIRST_SKIP(p)                                      \
48         OCTTX_PACKET_FIRST_SKIP_ADJUST(OCTTX_PACKET_FIRST_SKIP_SUM(p))
49 #define OCTTX_PACKET_LATER_SKIP         128
50
51 /* WQE descriptor */
52 typedef union octtx_wqe_s {
53         uint64_t        w[6];
54
55         struct {
56 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
57                 struct {
58                         uint64_t        pknd : 6;
59                         uint64_t        rsvd0 : 10;
60                         uint64_t        style : 8;
61                         uint64_t        bufs : 8;
62                         uint64_t        chan : 12;
63                         uint64_t        apad : 3;
64                         uint64_t        rsvd1 : 1;
65                         uint64_t        aura : 12;
66                         uint64_t        rsvd2 : 4;
67                 } w0;
68
69                 struct {
70                         uint64_t        tag :   32;
71                         uint64_t        tt :    2;
72                         uint64_t        grp :   10;
73                         uint64_t        rsvd0 : 2;
74                         uint64_t        rsvd1 : 2;
75                         uint64_t        len :   16;
76                 } w1;
77
78                 struct {
79                         uint64_t        op_code : 8;
80                         uint64_t        err_lev : 3;
81                         uint64_t        raw     : 1;
82                         uint64_t        l2m     : 1;
83                         uint64_t        l2b     : 1;
84                         uint64_t        l3m     : 1;
85                         uint64_t        l3b     : 1;
86                         uint64_t        l3fr    : 1;
87                         uint64_t        pf1     : 1;
88                         uint64_t        pf2     : 1;
89                         uint64_t        pf3     : 1;
90                         uint64_t        pf4     : 1;
91                         uint64_t        sh      : 1;
92                         uint64_t        vs      : 1;
93                         uint64_t        vv      : 1;
94                         uint64_t        rsvd0   : 8;
95                         uint64_t        lae     : 1;
96                         uint64_t        lbty    : 5;
97                         uint64_t        lcty    : 5;
98                         uint64_t        ldty    : 5;
99                         uint64_t        lety    : 5;
100                         uint64_t        lfty    : 5;
101                         uint64_t        lgty    : 5;
102                         uint64_t        sw      : 1;
103                 } w2;
104
105                 struct {
106                         uint64_t        addr;   /* Byte addr of start-of-pkt */
107                 } w3;
108
109                 struct {
110                         uint64_t        laptr : 8;
111                         uint64_t        lbptr : 8;
112                         uint64_t        lcptr : 8;
113                         uint64_t        ldprt : 8;
114                         uint64_t        leptr : 8;
115                         uint64_t        lfptr : 8;
116                         uint64_t        lgptr : 8;
117                         uint64_t        vlptr : 8;
118                 } w4;
119
120                 struct {
121                         uint64_t        rsvd0 : 47;
122                         uint64_t        dwd : 1;
123                         uint64_t        size : 16;
124                 } w5;
125 #else
126                 struct {
127                         uint64_t        rsvd2 : 4;
128                         uint64_t        aura : 12;
129                         uint64_t        rsvd1 : 1;
130                         uint64_t        apad : 3;
131                         uint64_t        chan : 12;
132                         uint64_t        bufs : 8;
133                         uint64_t        style : 8;
134                         uint64_t        rsvd0 : 10;
135                         uint64_t        pknd : 6;
136                 } w0;
137
138                 struct {
139                         uint64_t        len :   16;
140                         uint64_t        rsvd1 : 2;
141                         uint64_t        rsvd0 : 2;
142                         uint64_t        grp :   10;
143                         uint64_t        tt :    2;
144                         uint64_t        tag :   32;
145                 } w1;
146
147                 struct {
148                         uint64_t        sw      : 1;
149                         uint64_t        lgty    : 5;
150                         uint64_t        lfty    : 5;
151                         uint64_t        lety    : 5;
152                         uint64_t        ldty    : 5;
153                         uint64_t        lcty    : 5;
154                         uint64_t        lbty    : 5;
155                         uint64_t        lae     : 1;
156                         uint64_t        rsvd0   : 8;
157                         uint64_t        vv      : 1;
158                         uint64_t        vs      : 1;
159                         uint64_t        sh      : 1;
160                         uint64_t        pf4     : 1;
161                         uint64_t        pf3     : 1;
162                         uint64_t        pf2     : 1;
163                         uint64_t        pf1     : 1;
164                         uint64_t        l3fr    : 1;
165                         uint64_t        l3b     : 1;
166                         uint64_t        l3m     : 1;
167                         uint64_t        l2b     : 1;
168                         uint64_t        l2m     : 1;
169                         uint64_t        raw     : 1;
170         uint64_t        err_lev : 3;
171                         uint64_t        op_code : 8;
172                 } w2;
173
174                 struct {
175                         uint64_t        addr;   /* Byte addr of start-of-pkt */
176                 } w3;
177
178                 struct {
179                         uint64_t        vlptr : 8;
180                         uint64_t        lgptr : 8;
181                         uint64_t        lfptr : 8;
182                         uint64_t        leptr : 8;
183                         uint64_t        ldprt : 8;
184                         uint64_t        lcptr : 8;
185                         uint64_t        lbptr : 8;
186                         uint64_t        laptr : 8;
187                 } w4;
188 #endif
189         } s;
190
191 } __rte_packed octtx_wqe_t;
192
193 enum occtx_pki_ltype_e {
194         OCCTX_PKI_LTYPE_NONE            = 0,
195         OCCTX_PKI_LTYPE_ENET            = 1,
196         OCCTX_PKI_LTYPE_VLAN            = 2,
197         OCCTX_PKI_LTYPE_SNAP_PAYLD      = 5,
198         OCCTX_PKI_LTYPE_ARP             = 6,
199         OCCTX_PKI_LTYPE_RARP            = 7,
200         OCCTX_PKI_LTYPE_IP4             = 8,
201         OCCTX_PKI_LTYPE_IP4_OPT         = 9,
202         OCCTX_PKI_LTYPE_IP6             = 0xa,
203         OCCTX_PKI_LTYPE_IP6_OPT         = 0xb,
204         OCCTX_PKI_LTYPE_IPSEC_ESP       = 0xc,
205         OCCTX_PKI_LTYPE_IPFRAG          = 0xd,
206         OCCTX_PKI_LTYPE_IPCOMP          = 0xe,
207         OCCTX_PKI_LTYPE_TCP             = 0x10,
208         OCCTX_PKI_LTYPE_UDP             = 0x11,
209         OCCTX_PKI_LTYPE_SCTP            = 0x12,
210         OCCTX_PKI_LTYPE_UDP_VXLAN       = 0x13,
211         OCCTX_PKI_LTYPE_GRE             = 0x14,
212         OCCTX_PKI_LTYPE_NVGRE           = 0x15,
213         OCCTX_PKI_LTYPE_GTP             = 0x16,
214         OCCTX_PKI_LTYPE_UDP_GENEVE      = 0x17,
215         OCCTX_PKI_LTYPE_SW28            = 0x1c,
216         OCCTX_PKI_LTYPE_SW29            = 0x1d,
217         OCCTX_PKI_LTYPE_SW30            = 0x1e,
218         OCCTX_PKI_LTYPE_SW31            = 0x1f,
219         OCCTX_PKI_LTYPE_LAST
220 };
221
222 enum lc_type_e {
223         LC_NONE         = OCCTX_PKI_LTYPE_NONE,
224         LC_IPV4         = OCCTX_PKI_LTYPE_IP4,
225         LC_IPV4_OPT     = OCCTX_PKI_LTYPE_IP4_OPT,
226         LC_IPV6         = OCCTX_PKI_LTYPE_IP6,
227         LC_IPV6_OPT     = OCCTX_PKI_LTYPE_IP6_OPT,
228 };
229
230 enum le_type_e {
231         LE_NONE         = OCCTX_PKI_LTYPE_NONE,
232 };
233
234 enum lf_type_e {
235         LF_NONE         = OCCTX_PKI_LTYPE_NONE,
236         LF_IPSEC_ESP    = OCCTX_PKI_LTYPE_IPSEC_ESP,
237         LF_IPFRAG       = OCCTX_PKI_LTYPE_IPFRAG,
238         LF_IPCOMP       = OCCTX_PKI_LTYPE_IPCOMP,
239         LF_TCP          = OCCTX_PKI_LTYPE_TCP,
240         LF_UDP          = OCCTX_PKI_LTYPE_UDP,
241         LF_GRE          = OCCTX_PKI_LTYPE_GRE,
242         LF_UDP_GENEVE   = OCCTX_PKI_LTYPE_UDP_GENEVE,
243         LF_UDP_VXLAN    = OCCTX_PKI_LTYPE_UDP_VXLAN,
244         LF_NVGRE        = OCCTX_PKI_LTYPE_NVGRE,
245 };
246 #endif /* __OCTEONTX_PKI_VAR_H__ */