Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9e972be

Browse files
helin-zhangThomas Monjalon
authored andcommitted
app: replace some offload flags with packet type
To unify packet types among all PMDs, bit masks of packet type for 'ol_flags' are replaced by unified packet type. To avoid breaking ABI compatibility, all the changes would be enabled by RTE_NEXT_ABI. Signed-off-by: Helin Zhang <[email protected]> Acked-by: Konstantin Ananyev <[email protected]>
1 parent 429df38 commit 9e972be

4 files changed

Lines changed: 214 additions & 2 deletions

File tree

app/test-pipeline/pipeline_hash.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,20 +459,33 @@ app_main_loop_rx_metadata(void) {
459459
signature = RTE_MBUF_METADATA_UINT32_PTR(m, 0);
460460
key = RTE_MBUF_METADATA_UINT8_PTR(m, 32);
461461

462+
#ifdef RTE_NEXT_ABI
463+
if (RTE_ETH_IS_IPV4_HDR(m->packet_type)) {
464+
#else
462465
if (m->ol_flags & PKT_RX_IPV4_HDR) {
466+
#endif
463467
ip_hdr = (struct ipv4_hdr *)
464468
&m_data[sizeof(struct ether_hdr)];
465469
ip_dst = ip_hdr->dst_addr;
466470

467471
k32 = (uint32_t *) key;
468472
k32[0] = ip_dst & 0xFFFFFF00;
473+
#ifdef RTE_NEXT_ABI
474+
} else if (RTE_ETH_IS_IPV6_HDR(m->packet_type)) {
475+
#else
469476
} else {
477+
#endif
470478
ipv6_hdr = (struct ipv6_hdr *)
471479
&m_data[sizeof(struct ether_hdr)];
472480
ipv6_dst = ipv6_hdr->dst_addr;
473481

474482
memcpy(key, ipv6_dst, 16);
483+
#ifdef RTE_NEXT_ABI
484+
} else
485+
continue;
486+
#else
475487
}
488+
#endif
476489

477490
*signature = test_hash(key, 0, 0);
478491
}

app/test-pmd/csumonly.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,27 @@ parse_ethernet(struct ether_hdr *eth_hdr, struct testpmd_offload_info *info)
202202

203203
/* Parse a vxlan header */
204204
static void
205+
#ifdef RTE_NEXT_ABI
206+
parse_vxlan(struct udp_hdr *udp_hdr,
207+
struct testpmd_offload_info *info,
208+
uint32_t pkt_type)
209+
#else
205210
parse_vxlan(struct udp_hdr *udp_hdr, struct testpmd_offload_info *info,
206211
uint64_t mbuf_olflags)
212+
#endif
207213
{
208214
struct ether_hdr *eth_hdr;
209215

210216
/* check udp destination port, 4789 is the default vxlan port
211217
* (rfc7348) or that the rx offload flag is set (i40e only
212218
* currently) */
213219
if (udp_hdr->dst_port != _htons(4789) &&
220+
#ifdef RTE_NEXT_ABI
221+
RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0)
222+
#else
214223
(mbuf_olflags & (PKT_RX_TUNNEL_IPV4_HDR |
215224
PKT_RX_TUNNEL_IPV6_HDR)) == 0)
225+
#endif
216226
return;
217227

218228
info->is_tunnel = 1;
@@ -549,7 +559,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
549559
struct udp_hdr *udp_hdr;
550560
udp_hdr = (struct udp_hdr *)((char *)l3_hdr +
551561
info.l3_len);
562+
#ifdef RTE_NEXT_ABI
563+
parse_vxlan(udp_hdr, &info, m->packet_type);
564+
#else
552565
parse_vxlan(udp_hdr, &info, m->ol_flags);
566+
#endif
553567
} else if (info.l4_proto == IPPROTO_GRE) {
554568
struct simple_gre_hdr *gre_hdr;
555569
gre_hdr = (struct simple_gre_hdr *)

app/test-pmd/rxonly.c

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ pkt_burst_receive(struct fwd_stream *fs)
9191
uint64_t ol_flags;
9292
uint16_t nb_rx;
9393
uint16_t i, packet_type;
94+
#ifdef RTE_NEXT_ABI
95+
uint16_t is_encapsulation;
96+
#else
9497
uint64_t is_encapsulation;
98+
#endif
9599

96100
#ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
97101
uint64_t start_tsc;
@@ -135,8 +139,12 @@ pkt_burst_receive(struct fwd_stream *fs)
135139
ol_flags = mb->ol_flags;
136140
packet_type = mb->packet_type;
137141

142+
#ifdef RTE_NEXT_ABI
143+
is_encapsulation = RTE_ETH_IS_TUNNEL_PKT(packet_type);
144+
#else
138145
is_encapsulation = ol_flags & (PKT_RX_TUNNEL_IPV4_HDR |
139146
PKT_RX_TUNNEL_IPV6_HDR);
147+
#endif
140148

141149
print_ether_addr(" src=", &eth_hdr->s_addr);
142150
print_ether_addr(" - dst=", &eth_hdr->d_addr);
@@ -163,6 +171,177 @@ pkt_burst_receive(struct fwd_stream *fs)
163171
if (ol_flags & PKT_RX_QINQ_PKT)
164172
printf(" - QinQ VLAN tci=0x%x, VLAN tci outer=0x%x",
165173
mb->vlan_tci, mb->vlan_tci_outer);
174+
#ifdef RTE_NEXT_ABI
175+
if (mb->packet_type) {
176+
uint32_t ptype;
177+
178+
/* (outer) L2 packet type */
179+
ptype = mb->packet_type & RTE_PTYPE_L2_MASK;
180+
switch (ptype) {
181+
case RTE_PTYPE_L2_ETHER:
182+
printf(" - (outer) L2 type: ETHER");
183+
break;
184+
case RTE_PTYPE_L2_ETHER_TIMESYNC:
185+
printf(" - (outer) L2 type: ETHER_Timesync");
186+
break;
187+
case RTE_PTYPE_L2_ETHER_ARP:
188+
printf(" - (outer) L2 type: ETHER_ARP");
189+
break;
190+
case RTE_PTYPE_L2_ETHER_LLDP:
191+
printf(" - (outer) L2 type: ETHER_LLDP");
192+
break;
193+
default:
194+
printf(" - (outer) L2 type: Unknown");
195+
break;
196+
}
197+
198+
/* (outer) L3 packet type */
199+
ptype = mb->packet_type & RTE_PTYPE_L3_MASK;
200+
switch (ptype) {
201+
case RTE_PTYPE_L3_IPV4:
202+
printf(" - (outer) L3 type: IPV4");
203+
break;
204+
case RTE_PTYPE_L3_IPV4_EXT:
205+
printf(" - (outer) L3 type: IPV4_EXT");
206+
break;
207+
case RTE_PTYPE_L3_IPV6:
208+
printf(" - (outer) L3 type: IPV6");
209+
break;
210+
case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN:
211+
printf(" - (outer) L3 type: IPV4_EXT_UNKNOWN");
212+
break;
213+
case RTE_PTYPE_L3_IPV6_EXT:
214+
printf(" - (outer) L3 type: IPV6_EXT");
215+
break;
216+
case RTE_PTYPE_L3_IPV6_EXT_UNKNOWN:
217+
printf(" - (outer) L3 type: IPV6_EXT_UNKNOWN");
218+
break;
219+
default:
220+
printf(" - (outer) L3 type: Unknown");
221+
break;
222+
}
223+
224+
/* (outer) L4 packet type */
225+
ptype = mb->packet_type & RTE_PTYPE_L4_MASK;
226+
switch (ptype) {
227+
case RTE_PTYPE_L4_TCP:
228+
printf(" - (outer) L4 type: TCP");
229+
break;
230+
case RTE_PTYPE_L4_UDP:
231+
printf(" - (outer) L4 type: UDP");
232+
break;
233+
case RTE_PTYPE_L4_FRAG:
234+
printf(" - (outer) L4 type: L4_FRAG");
235+
break;
236+
case RTE_PTYPE_L4_SCTP:
237+
printf(" - (outer) L4 type: SCTP");
238+
break;
239+
case RTE_PTYPE_L4_ICMP:
240+
printf(" - (outer) L4 type: ICMP");
241+
break;
242+
case RTE_PTYPE_L4_NONFRAG:
243+
printf(" - (outer) L4 type: L4_NONFRAG");
244+
break;
245+
default:
246+
printf(" - (outer) L4 type: Unknown");
247+
break;
248+
}
249+
250+
/* packet tunnel type */
251+
ptype = mb->packet_type & RTE_PTYPE_TUNNEL_MASK;
252+
switch (ptype) {
253+
case RTE_PTYPE_TUNNEL_IP:
254+
printf(" - Tunnel type: IP");
255+
break;
256+
case RTE_PTYPE_TUNNEL_GRE:
257+
printf(" - Tunnel type: GRE");
258+
break;
259+
case RTE_PTYPE_TUNNEL_VXLAN:
260+
printf(" - Tunnel type: VXLAN");
261+
break;
262+
case RTE_PTYPE_TUNNEL_NVGRE:
263+
printf(" - Tunnel type: NVGRE");
264+
break;
265+
case RTE_PTYPE_TUNNEL_GENEVE:
266+
printf(" - Tunnel type: GENEVE");
267+
break;
268+
case RTE_PTYPE_TUNNEL_GRENAT:
269+
printf(" - Tunnel type: GRENAT");
270+
break;
271+
default:
272+
printf(" - Tunnel type: Unknown");
273+
break;
274+
}
275+
276+
/* inner L2 packet type */
277+
ptype = mb->packet_type & RTE_PTYPE_INNER_L2_MASK;
278+
switch (ptype) {
279+
case RTE_PTYPE_INNER_L2_ETHER:
280+
printf(" - Inner L2 type: ETHER");
281+
break;
282+
case RTE_PTYPE_INNER_L2_ETHER_VLAN:
283+
printf(" - Inner L2 type: ETHER_VLAN");
284+
break;
285+
default:
286+
printf(" - Inner L2 type: Unknown");
287+
break;
288+
}
289+
290+
/* inner L3 packet type */
291+
ptype = mb->packet_type & RTE_PTYPE_INNER_INNER_L3_MASK;
292+
switch (ptype) {
293+
case RTE_PTYPE_INNER_L3_IPV4:
294+
printf(" - Inner L3 type: IPV4");
295+
break;
296+
case RTE_PTYPE_INNER_L3_IPV4_EXT:
297+
printf(" - Inner L3 type: IPV4_EXT");
298+
break;
299+
case RTE_PTYPE_INNER_L3_IPV6:
300+
printf(" - Inner L3 type: IPV6");
301+
break;
302+
case RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN:
303+
printf(" - Inner L3 type: IPV4_EXT_UNKNOWN");
304+
break;
305+
case RTE_PTYPE_INNER_L3_IPV6_EXT:
306+
printf(" - Inner L3 type: IPV6_EXT");
307+
break;
308+
case RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN:
309+
printf(" - Inner L3 type: IPV6_EXT_UNKNOWN");
310+
break;
311+
default:
312+
printf(" - Inner L3 type: Unknown");
313+
break;
314+
}
315+
316+
/* inner L4 packet type */
317+
ptype = mb->packet_type & RTE_PTYPE_INNER_L4_MASK;
318+
switch (ptype) {
319+
case RTE_PTYPE_INNER_L4_TCP:
320+
printf(" - Inner L4 type: TCP");
321+
break;
322+
case RTE_PTYPE_INNER_L4_UDP:
323+
printf(" - Inner L4 type: UDP");
324+
break;
325+
case RTE_PTYPE_INNER_L4_FRAG:
326+
printf(" - Inner L4 type: L4_FRAG");
327+
break;
328+
case RTE_PTYPE_INNER_L4_SCTP:
329+
printf(" - Inner L4 type: SCTP");
330+
break;
331+
case RTE_PTYPE_INNER_L4_ICMP:
332+
printf(" - Inner L4 type: ICMP");
333+
break;
334+
case RTE_PTYPE_INNER_L4_NONFRAG:
335+
printf(" - Inner L4 type: L4_NONFRAG");
336+
break;
337+
default:
338+
printf(" - Inner L4 type: Unknown");
339+
break;
340+
}
341+
printf("\n");
342+
} else
343+
printf("Unknown packet type\n");
344+
#endif /* RTE_NEXT_ABI */
166345
if (is_encapsulation) {
167346
struct ipv4_hdr *ipv4_hdr;
168347
struct ipv6_hdr *ipv6_hdr;
@@ -176,7 +355,11 @@ pkt_burst_receive(struct fwd_stream *fs)
176355
l2_len = sizeof(struct ether_hdr);
177356

178357
/* Do not support ipv4 option field */
358+
#ifdef RTE_NEXT_ABI
359+
if (RTE_ETH_IS_IPV4_HDR(packet_type)) {
360+
#else
179361
if (ol_flags & PKT_RX_TUNNEL_IPV4_HDR) {
362+
#endif
180363
l3_len = sizeof(struct ipv4_hdr);
181364
ipv4_hdr = rte_pktmbuf_mtod_offset(mb,
182365
struct ipv4_hdr *,

app/test/packet_burst_generator.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,21 @@ generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst,
273273
if (ipv4) {
274274
pkt->vlan_tci = ETHER_TYPE_IPv4;
275275
pkt->l3_len = sizeof(struct ipv4_hdr);
276-
276+
#ifndef RTE_NEXT_ABI
277277
if (vlan_enabled)
278278
pkt->ol_flags = PKT_RX_IPV4_HDR | PKT_RX_VLAN_PKT;
279279
else
280280
pkt->ol_flags = PKT_RX_IPV4_HDR;
281+
#endif
281282
} else {
282283
pkt->vlan_tci = ETHER_TYPE_IPv6;
283284
pkt->l3_len = sizeof(struct ipv6_hdr);
284-
285+
#ifndef RTE_NEXT_ABI
285286
if (vlan_enabled)
286287
pkt->ol_flags = PKT_RX_IPV6_HDR | PKT_RX_VLAN_PKT;
287288
else
288289
pkt->ol_flags = PKT_RX_IPV6_HDR;
290+
#endif
289291
}
290292

291293
pkts_burst[nb_pkt] = pkt;

0 commit comments

Comments
 (0)