]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/drivers/net/ice/rte_pmd_ice.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / ice / rte_pmd_ice.h
CommitLineData
f67539c2
TL
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
3 */
4
5#ifndef _RTE_PMD_ICE_H_
6#define _RTE_PMD_ICE_H_
7
8/**
9 * @file rte_pmd_ice.h
10 *
11 * ice PMD specific functions.
12 *
13 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
14 *
15 */
16
17#include <stdio.h>
18#include <rte_mbuf.h>
19#include <rte_mbuf_dyn.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * The supported network protocol extraction metadata format.
27 */
28union rte_net_ice_proto_xtr_metadata {
29 uint32_t metadata;
30
31 struct {
32 uint16_t data0;
33 uint16_t data1;
34 } raw;
35
36 struct {
37 uint16_t stag_vid:12,
38 stag_dei:1,
39 stag_pcp:3;
40 uint16_t ctag_vid:12,
41 ctag_dei:1,
42 ctag_pcp:3;
43 } vlan;
44
45 struct {
46 uint16_t protocol:8,
47 ttl:8;
48 uint16_t tos:8,
49 ihl:4,
50 version:4;
51 } ipv4;
52
53 struct {
54 uint16_t hoplimit:8,
55 nexthdr:8;
56 uint16_t flowhi4:4,
57 tc:8,
58 version:4;
59 } ipv6;
60
61 struct {
62 uint16_t flowlo16;
63 uint16_t flowhi4:4,
64 tc:8,
65 version:4;
66 } ipv6_flow;
67
68 struct {
69 uint16_t fin:1,
70 syn:1,
71 rst:1,
72 psh:1,
73 ack:1,
74 urg:1,
75 ece:1,
76 cwr:1,
77 res1:4,
78 doff:4;
79 uint16_t rsvd;
80 } tcp;
81};
82
83/* Offset of mbuf dynamic field for protocol extraction data */
84extern int rte_net_ice_dynfield_proto_xtr_metadata_offs;
85
86/* Mask of mbuf dynamic flags for protocol extraction type */
87extern uint64_t rte_net_ice_dynflag_proto_xtr_vlan_mask;
88extern uint64_t rte_net_ice_dynflag_proto_xtr_ipv4_mask;
89extern uint64_t rte_net_ice_dynflag_proto_xtr_ipv6_mask;
90extern uint64_t rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
91extern uint64_t rte_net_ice_dynflag_proto_xtr_tcp_mask;
92
93/**
94 * The mbuf dynamic field pointer for protocol extraction metadata.
95 */
96#define RTE_NET_ICE_DYNF_PROTO_XTR_METADATA(m) \
97 RTE_MBUF_DYNFIELD((m), \
98 rte_net_ice_dynfield_proto_xtr_metadata_offs, \
99 uint32_t *)
100
101/**
102 * The mbuf dynamic flag for VLAN protocol extraction metadata, it is valid
103 * when dev_args 'proto_xtr' has 'vlan' specified.
104 */
105#define RTE_PKT_RX_DYNF_PROTO_XTR_VLAN \
106 (rte_net_ice_dynflag_proto_xtr_vlan_mask)
107
108/**
109 * The mbuf dynamic flag for IPv4 protocol extraction metadata, it is valid
110 * when dev_args 'proto_xtr' has 'ipv4' specified.
111 */
112#define RTE_PKT_RX_DYNF_PROTO_XTR_IPV4 \
113 (rte_net_ice_dynflag_proto_xtr_ipv4_mask)
114
115/**
116 * The mbuf dynamic flag for IPv6 protocol extraction metadata, it is valid
117 * when dev_args 'proto_xtr' has 'ipv6' specified.
118 */
119#define RTE_PKT_RX_DYNF_PROTO_XTR_IPV6 \
120 (rte_net_ice_dynflag_proto_xtr_ipv6_mask)
121
122/**
123 * The mbuf dynamic flag for IPv6 with flow protocol extraction metadata, it is
124 * valid when dev_args 'proto_xtr' has 'ipv6_flow' specified.
125 */
126#define RTE_PKT_RX_DYNF_PROTO_XTR_IPV6_FLOW \
127 (rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask)
128
129/**
130 * The mbuf dynamic flag for TCP protocol extraction metadata, it is valid
131 * when dev_args 'proto_xtr' has 'tcp' specified.
132 */
133#define RTE_PKT_RX_DYNF_PROTO_XTR_TCP \
134 (rte_net_ice_dynflag_proto_xtr_tcp_mask)
135
136/**
137 * Check if mbuf dynamic field for protocol extraction metadata is registered.
138 *
139 * @return
140 * True if registered, false otherwise.
141 */
142__rte_experimental
143static __rte_always_inline int
144rte_net_ice_dynf_proto_xtr_metadata_avail(void)
145{
146 return rte_net_ice_dynfield_proto_xtr_metadata_offs != -1;
147}
148
149/**
150 * Get the mbuf dynamic field for protocol extraction metadata.
151 *
152 * @param m
153 * The pointer to the mbuf.
154 * @return
155 * The saved protocol extraction metadata.
156 */
157__rte_experimental
158static __rte_always_inline uint32_t
159rte_net_ice_dynf_proto_xtr_metadata_get(struct rte_mbuf *m)
160{
161 return *RTE_NET_ICE_DYNF_PROTO_XTR_METADATA(m);
162}
163
164/**
165 * Dump the mbuf dynamic field for protocol extraction metadata.
166 *
167 * @param m
168 * The pointer to the mbuf.
169 */
170__rte_experimental
171static inline void
172rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
173{
174 union rte_net_ice_proto_xtr_metadata data;
175
176 if (!rte_net_ice_dynf_proto_xtr_metadata_avail())
177 return;
178
179 data.metadata = rte_net_ice_dynf_proto_xtr_metadata_get(m);
180
181 if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_VLAN)
182 printf(" - Protocol Extraction:[0x%04x:0x%04x],vlan,stag=%u:%u:%u,ctag=%u:%u:%u",
183 data.raw.data0, data.raw.data1,
184 data.vlan.stag_pcp,
185 data.vlan.stag_dei,
186 data.vlan.stag_vid,
187 data.vlan.ctag_pcp,
188 data.vlan.ctag_dei,
189 data.vlan.ctag_vid);
190 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IPV4)
191 printf(" - Protocol Extraction:[0x%04x:0x%04x],ipv4,ver=%u,hdrlen=%u,tos=%u,ttl=%u,proto=%u",
192 data.raw.data0, data.raw.data1,
193 data.ipv4.version,
194 data.ipv4.ihl,
195 data.ipv4.tos,
196 data.ipv4.ttl,
197 data.ipv4.protocol);
198 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IPV6)
199 printf(" - Protocol Extraction:[0x%04x:0x%04x],ipv6,ver=%u,tc=%u,flow_hi4=0x%x,nexthdr=%u,hoplimit=%u",
200 data.raw.data0, data.raw.data1,
201 data.ipv6.version,
202 data.ipv6.tc,
203 data.ipv6.flowhi4,
204 data.ipv6.nexthdr,
205 data.ipv6.hoplimit);
206 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IPV6_FLOW)
207 printf(" - Protocol Extraction:[0x%04x:0x%04x],ipv6_flow,ver=%u,tc=%u,flow=0x%x%04x",
208 data.raw.data0, data.raw.data1,
209 data.ipv6_flow.version,
210 data.ipv6_flow.tc,
211 data.ipv6_flow.flowhi4,
212 data.ipv6_flow.flowlo16);
213 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_TCP)
214 printf(" - Protocol Extraction:[0x%04x:0x%04x],tcp,doff=%u,flags=%s%s%s%s%s%s%s%s",
215 data.raw.data0, data.raw.data1,
216 data.tcp.doff,
217 data.tcp.cwr ? "C" : "",
218 data.tcp.ece ? "E" : "",
219 data.tcp.urg ? "U" : "",
220 data.tcp.ack ? "A" : "",
221 data.tcp.psh ? "P" : "",
222 data.tcp.rst ? "R" : "",
223 data.tcp.syn ? "S" : "",
224 data.tcp.fin ? "F" : "");
225}
226
227#ifdef __cplusplus
228}
229#endif
230
231#endif /* _RTE_PMD_ICE_H_ */