iavf: new driver using new dev infra
[vpp.git] / src / plugins / dev_iavf / iavf_desc.h
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright (c) 2023 Cisco Systems, Inc.
3  */
4
5 #ifndef _IIAVF_DESC_H_
6 #define _IIAVF_DESC_H_
7
8 #include <vppinfra/clib.h>
9 #include <vppinfra/error_bootstrap.h>
10 #include <vppinfra/format.h>
11 #include <vnet/vnet.h>
12 #include <vnet/dev/dev.h>
13 #include <dev_iavf/virtchnl.h>
14
15 #define IAVF_RX_MAX_DESC_IN_CHAIN 5
16
17 #define IAVF_TXD_CMD(x)                (1 << (x + 4))
18 #define IAVF_TXD_CMD_EXT(x, val)       ((u64) val << (x + 4))
19 #define IAVF_TXD_CMD_EOP               IAVF_TXD_CMD (0)
20 #define IAVF_TXD_CMD_RS                IAVF_TXD_CMD (1)
21 #define IAVF_TXD_CMD_RSV               IAVF_TXD_CMD (2)
22 #define IAVF_TXD_CMD_IIPT_NONE         IAVF_TXD_CMD_EXT (5, 0)
23 #define IAVF_TXD_CMD_IIPT_IPV6         IAVF_TXD_CMD_EXT (5, 1)
24 #define IAVF_TXD_CMD_IIPT_IPV4_NO_CSUM IAVF_TXD_CMD_EXT (5, 2)
25 #define IAVF_TXD_CMD_IIPT_IPV4         IAVF_TXD_CMD_EXT (5, 3)
26 #define IAVF_TXD_CMD_L4T_UNKNOWN       IAVF_TXD_CMD_EXT (8, 0)
27 #define IAVF_TXD_CMD_L4T_TCP           IAVF_TXD_CMD_EXT (8, 1)
28 #define IAVF_TXD_CMD_L4T_SCTP          IAVF_TXD_CMD_EXT (8, 2)
29 #define IAVF_TXD_CMD_L4T_UDP           IAVF_TXD_CMD_EXT (8, 3)
30 #define IAVF_TXD_OFFSET(x, factor, val)                                       \
31   (((u64) val / (u64) factor) << (16 + x))
32 #define IAVF_TXD_OFFSET_MACLEN(val) IAVF_TXD_OFFSET (0, 2, val)
33 #define IAVF_TXD_OFFSET_IPLEN(val)  IAVF_TXD_OFFSET (7, 4, val)
34 #define IAVF_TXD_OFFSET_L4LEN(val)  IAVF_TXD_OFFSET (14, 4, val)
35 #define IAVF_TXD_DTYP_CTX           0x1ULL
36 #define IAVF_TXD_CTX_CMD_TSO        IAVF_TXD_CMD (0)
37 #define IAVF_TXD_CTX_SEG(val, x)    (((u64) val) << (30 + x))
38 #define IAVF_TXD_CTX_SEG_TLEN(val)  IAVF_TXD_CTX_SEG (val, 0)
39 #define IAVF_TXD_CTX_SEG_MSS(val)   IAVF_TXD_CTX_SEG (val, 20)
40
41 typedef union
42 {
43   struct
44   {
45     u32 mirr : 13;
46     u32 _reserved1 : 3;
47     u32 l2tag1 : 16;
48     u32 filter_status;
49   };
50   u64 as_u64;
51 } iavf_rx_desc_qw0_t;
52
53 typedef union
54 {
55   struct
56   {
57     /* status */
58     u64 dd : 1;
59     u64 eop : 1;
60     u64 l2tag1p : 1;
61     u64 l3l4p : 1;
62     u64 crcp : 1;
63     u64 _reserved2 : 4;
64     u64 ubmcast : 2;
65     u64 flm : 1;
66     u64 fltstat : 2;
67     u64 lpbk : 1;
68     u64 ipv6exadd : 1;
69     u64 _reserved3 : 2;
70     u64 int_udp_0 : 1;
71
72     /* error */
73     u64 _reserved_err0 : 3;
74     u64 ipe : 1;
75     u64 l4e : 1;
76     u64 _reserved_err5 : 1;
77     u64 oversize : 1;
78     u64 _reserved_err7 : 1;
79
80     u64 rsv2 : 3;
81     u64 ptype : 8;
82     u64 length : 26;
83   };
84   u64 as_u64;
85 } iavf_rx_desc_qw1_t;
86
87 STATIC_ASSERT_SIZEOF (iavf_rx_desc_qw0_t, 8);
88 STATIC_ASSERT_SIZEOF (iavf_rx_desc_qw1_t, 8);
89
90 typedef struct
91 {
92   union
93   {
94     struct
95     {
96       iavf_rx_desc_qw0_t qw0;
97       iavf_rx_desc_qw0_t qw1;
98       u64 rsv3 : 64;
99       u32 flex_lo;
100       u32 fdid_flex_hi;
101     };
102     u64 qword[4];
103     u64 addr;
104 #ifdef CLIB_HAVE_VEC256
105     u64x4 as_u64x4;
106 #endif
107   };
108 } iavf_rx_desc_t;
109
110 STATIC_ASSERT_SIZEOF (iavf_rx_desc_t, 32);
111
112 typedef struct
113 {
114   union
115   {
116     u64 qword[2];
117 #ifdef CLIB_HAVE_VEC128
118     u64x2 as_u64x2;
119 #endif
120   };
121 } iavf_tx_desc_t;
122
123 STATIC_ASSERT_SIZEOF (iavf_tx_desc_t, 16);
124
125 #endif /* _IIAVF_DESC_H_ */