1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019 Intel Corporation
5 #ifndef _RTE_PMD_ICE_H_
6 #define _RTE_PMD_ICE_H_
11 * ice PMD specific functions.
13 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
19 #include <rte_mbuf_dyn.h>
26 * The supported network protocol extraction metadata format.
28 union rte_net_ice_proto_xtr_metadata {
85 /* Offset of mbuf dynamic field for protocol extraction data */
86 extern int rte_net_ice_dynfield_proto_xtr_metadata_offs;
88 /* Mask of mbuf dynamic flags for protocol extraction type */
89 extern uint64_t rte_net_ice_dynflag_proto_xtr_vlan_mask;
90 extern uint64_t rte_net_ice_dynflag_proto_xtr_ipv4_mask;
91 extern uint64_t rte_net_ice_dynflag_proto_xtr_ipv6_mask;
92 extern uint64_t rte_net_ice_dynflag_proto_xtr_ipv6_flow_mask;
93 extern uint64_t rte_net_ice_dynflag_proto_xtr_tcp_mask;
94 extern uint64_t rte_net_ice_dynflag_proto_xtr_ip_offset_mask;
97 * The mbuf dynamic field pointer for protocol extraction metadata.
99 #define RTE_NET_ICE_DYNF_PROTO_XTR_METADATA(m) \
100 RTE_MBUF_DYNFIELD((m), \
101 rte_net_ice_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_PKT_RX_DYNF_PROTO_XTR_VLAN \
109 (rte_net_ice_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_PKT_RX_DYNF_PROTO_XTR_IPV4 \
116 (rte_net_ice_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_PKT_RX_DYNF_PROTO_XTR_IPV6 \
123 (rte_net_ice_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_PKT_RX_DYNF_PROTO_XTR_IPV6_FLOW \
130 (rte_net_ice_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_PKT_RX_DYNF_PROTO_XTR_TCP \
137 (rte_net_ice_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_PKT_RX_DYNF_PROTO_XTR_IP_OFFSET \
144 (rte_net_ice_dynflag_proto_xtr_ip_offset_mask)
147 * Check if mbuf dynamic field for protocol extraction metadata is registered.
150 * True if registered, false otherwise.
153 static __rte_always_inline int
154 rte_net_ice_dynf_proto_xtr_metadata_avail(void)
156 return rte_net_ice_dynfield_proto_xtr_metadata_offs != -1;
160 * Get the mbuf dynamic field for protocol extraction metadata.
163 * The pointer to the mbuf.
165 * The saved protocol extraction metadata.
168 static __rte_always_inline uint32_t
169 rte_net_ice_dynf_proto_xtr_metadata_get(struct rte_mbuf *m)
171 return *RTE_NET_ICE_DYNF_PROTO_XTR_METADATA(m);
175 * Dump the mbuf dynamic field for protocol extraction metadata.
178 * The pointer to the mbuf.
182 rte_net_ice_dump_proto_xtr_metadata(struct rte_mbuf *m)
184 union rte_net_ice_proto_xtr_metadata data;
186 if (!rte_net_ice_dynf_proto_xtr_metadata_avail())
189 data.metadata = rte_net_ice_dynf_proto_xtr_metadata_get(m);
191 if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_VLAN)
192 printf(" - Protocol Extraction:[0x%04x:0x%04x],vlan,stag=%u:%u:%u,ctag=%u:%u:%u",
193 data.raw.data0, data.raw.data1,
200 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IPV4)
201 printf(" - Protocol Extraction:[0x%04x:0x%04x],ipv4,ver=%u,hdrlen=%u,tos=%u,ttl=%u,proto=%u",
202 data.raw.data0, data.raw.data1,
208 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IPV6)
209 printf(" - Protocol Extraction:[0x%04x:0x%04x],ipv6,ver=%u,tc=%u,flow_hi4=0x%x,nexthdr=%u,hoplimit=%u",
210 data.raw.data0, data.raw.data1,
216 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IPV6_FLOW)
217 printf(" - Protocol Extraction:[0x%04x:0x%04x],ipv6_flow,ver=%u,tc=%u,flow=0x%x%04x",
218 data.raw.data0, data.raw.data1,
219 data.ipv6_flow.version,
221 data.ipv6_flow.flowhi4,
222 data.ipv6_flow.flowlo16);
223 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_TCP)
224 printf(" - Protocol Extraction:[0x%04x:0x%04x],tcp,doff=%u,flags=%s%s%s%s%s%s%s%s",
225 data.raw.data0, data.raw.data1,
227 data.tcp.cwr ? "C" : "",
228 data.tcp.ece ? "E" : "",
229 data.tcp.urg ? "U" : "",
230 data.tcp.ack ? "A" : "",
231 data.tcp.psh ? "P" : "",
232 data.tcp.rst ? "R" : "",
233 data.tcp.syn ? "S" : "",
234 data.tcp.fin ? "F" : "");
235 else if (m->ol_flags & RTE_PKT_RX_DYNF_PROTO_XTR_IP_OFFSET)
236 printf(" - Protocol Offset:ip_offset=%u",
244 #endif /* _RTE_PMD_ICE_H_ */