1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
5 #ifndef _RTE_PMD_IAVF_H_
6 #define _RTE_PMD_IAVF_H_
11 * iavf PMD specific functions.
13 * @b EXPERIMENTAL: this API may change, or be removed, without prior notiavf
19 #include <rte_mbuf_dyn.h>
26 * The supported network flexible descriptor's extraction metadata format.
28 union rte_pmd_ifd_proto_xtr_metadata {
85 /* Offset of mbuf dynamic field for flexible descriptor's extraction data */
86 extern int rte_pmd_ifd_dynfield_proto_xtr_metadata_offs;
88 /* Mask of mbuf dynamic flags for flexible descriptor's extraction type */
89 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_vlan_mask;
90 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask;
91 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask;
92 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask;
93 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_tcp_mask;
94 extern uint64_t rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask;
97 * The mbuf dynamic field pointer for flexible descriptor's extraction metadata.
99 #define RTE_PMD_IFD_DYNF_PROTO_XTR_METADATA(m) \
100 RTE_MBUF_DYNFIELD((m), \
101 rte_pmd_ifd_dynfield_proto_xtr_metadata_offs, \
105 * The mbuf dynamic flag for VLAN protocol extraction metadata, it is valid
106 * when dev_args 'proto_xtr' has 'vlan' specified.
108 #define RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_VLAN \
109 (rte_pmd_ifd_dynflag_proto_xtr_vlan_mask)
112 * The mbuf dynamic flag for IPv4 protocol extraction metadata, it is valid
113 * when dev_args 'proto_xtr' has 'ipv4' specified.
115 #define RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IPV4 \
116 (rte_pmd_ifd_dynflag_proto_xtr_ipv4_mask)
119 * The mbuf dynamic flag for IPv6 protocol extraction metadata, it is valid
120 * when dev_args 'proto_xtr' has 'ipv6' specified.
122 #define RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IPV6 \
123 (rte_pmd_ifd_dynflag_proto_xtr_ipv6_mask)
126 * The mbuf dynamic flag for IPv6 with flow protocol extraction metadata, it is
127 * valid when dev_args 'proto_xtr' has 'ipv6_flow' specified.
129 #define RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IPV6_FLOW \
130 (rte_pmd_ifd_dynflag_proto_xtr_ipv6_flow_mask)
133 * The mbuf dynamic flag for TCP protocol extraction metadata, it is valid
134 * when dev_args 'proto_xtr' has 'tcp' specified.
136 #define RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_TCP \
137 (rte_pmd_ifd_dynflag_proto_xtr_tcp_mask)
140 * The mbuf dynamic flag for IP_OFFSET extraction metadata, it is valid
141 * when dev_args 'proto_xtr' has 'ip_offset' specified.
143 #define RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IP_OFFSET \
144 (rte_pmd_ifd_dynflag_proto_xtr_ip_offset_mask)
147 * Check if mbuf dynamic field for flexible descriptor's extraction metadata
151 * True if registered, false otherwise.
154 static __rte_always_inline int
155 rte_pmd_ifd_dynf_proto_xtr_metadata_avail(void)
157 return rte_pmd_ifd_dynfield_proto_xtr_metadata_offs != -1;
161 * Get the mbuf dynamic field for flexible descriptor's extraction metadata.
164 * The pointer to the mbuf.
166 * The saved protocol extraction metadata.
169 static __rte_always_inline uint32_t
170 rte_pmd_ifd_dynf_proto_xtr_metadata_get(struct rte_mbuf *m)
172 return *RTE_PMD_IFD_DYNF_PROTO_XTR_METADATA(m);
176 * Dump the mbuf dynamic field for flexible descriptor's extraction metadata.
179 * The pointer to the mbuf.
183 rte_pmd_ifd_dump_proto_xtr_metadata(struct rte_mbuf *m)
185 union rte_pmd_ifd_proto_xtr_metadata data;
187 if (!rte_pmd_ifd_dynf_proto_xtr_metadata_avail())
190 data.metadata = rte_pmd_ifd_dynf_proto_xtr_metadata_get(m);
192 if (m->ol_flags & RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_VLAN)
193 printf(" - Flexible descriptor's Metadata: [0x%04x:0x%04x],"
194 "vlan,stag=%u:%u:%u,ctag=%u:%u:%u",
195 data.raw.data0, data.raw.data1,
202 else if (m->ol_flags & RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IPV4)
203 printf(" - Flexible descriptor's Metadata: [0x%04x:0x%04x],"
204 "ipv4,ver=%u,hdrlen=%u,tos=%u,ttl=%u,proto=%u",
205 data.raw.data0, data.raw.data1,
211 else if (m->ol_flags & RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IPV6)
212 printf(" - Flexible descriptor's Metadata: [0x%04x:0x%04x],"
213 "ipv6,ver=%u,tc=%u,flow_hi4=0x%x,nexthdr=%u,hoplimit=%u",
214 data.raw.data0, data.raw.data1,
220 else if (m->ol_flags & RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IPV6_FLOW)
221 printf(" - Flexible descriptor's Metadata: [0x%04x:0x%04x],"
222 "ipv6_flow,ver=%u,tc=%u,flow=0x%x%04x",
223 data.raw.data0, data.raw.data1,
224 data.ipv6_flow.version,
226 data.ipv6_flow.flowhi4,
227 data.ipv6_flow.flowlo16);
228 else if (m->ol_flags & RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_TCP)
229 printf(" - Flexible descriptor's Metadata: [0x%04x:0x%04x],"
230 "tcp,doff=%u,flags=%s%s%s%s%s%s%s%s",
231 data.raw.data0, data.raw.data1,
233 data.tcp.cwr ? "C" : "",
234 data.tcp.ece ? "E" : "",
235 data.tcp.urg ? "U" : "",
236 data.tcp.ack ? "A" : "",
237 data.tcp.psh ? "P" : "",
238 data.tcp.rst ? "R" : "",
239 data.tcp.syn ? "S" : "",
240 data.tcp.fin ? "F" : "");
241 else if (m->ol_flags & RTE_IAVF_PKT_RX_DYNF_PROTO_XTR_IP_OFFSET)
242 printf(" - Flexible descriptor's Extraction: ip_offset=%u",
250 #endif /* _RTE_PMD_IAVF_H_ */