MCPcopy Create free account
hub / github.com/F-Stack/f-stack / init_packet

Function init_packet

dpdk/app/test/test_security_inline_proto.c:455–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453}
454
455static inline struct rte_mbuf *
456init_packet(struct rte_mempool *mp, const uint8_t *data, unsigned int len, bool outer_ipv4)
457{
458 struct rte_mbuf *pkt, *tail;
459 uint16_t space;
460
461 pkt = rte_pktmbuf_alloc(mp);
462 if (pkt == NULL)
463 return NULL;
464
465 if (outer_ipv4) {
466 rte_memcpy(rte_pktmbuf_append(pkt, RTE_ETHER_HDR_LEN),
467 &dummy_ipv4_eth_hdr, RTE_ETHER_HDR_LEN);
468 pkt->l3_len = sizeof(struct rte_ipv4_hdr);
469 } else {
470 rte_memcpy(rte_pktmbuf_append(pkt, RTE_ETHER_HDR_LEN),
471 &dummy_ipv6_eth_hdr, RTE_ETHER_HDR_LEN);
472 pkt->l3_len = sizeof(struct rte_ipv6_hdr);
473 }
474 pkt->l2_len = RTE_ETHER_HDR_LEN;
475
476 space = rte_pktmbuf_tailroom(pkt);
477 tail = pkt;
478 /* Error if SG mode is not enabled */
479 if (!sg_mode && space < len) {
480 rte_pktmbuf_free(pkt);
481 return NULL;
482 }
483 /* Extra room for expansion */
484 while (space < len) {
485 tail->next = rte_pktmbuf_alloc(mp);
486 if (!tail->next)
487 goto error;
488 tail = tail->next;
489 space += rte_pktmbuf_tailroom(tail);
490 pkt->nb_segs++;
491 }
492
493 if (pkt->buf_len > len + RTE_ETHER_HDR_LEN)
494 rte_memcpy(rte_pktmbuf_append(pkt, len), data, len);
495 else
496 copy_buf_to_pkt_segs(data, len, pkt, RTE_ETHER_HDR_LEN);
497 return pkt;
498error:
499 rte_pktmbuf_free(pkt);
500 return NULL;
501}
502
503static int
504init_mempools(unsigned int nb_mbuf)

Calls 6

rte_pktmbuf_allocFunction · 0.85
rte_pktmbuf_appendFunction · 0.85
rte_pktmbuf_tailroomFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
copy_buf_to_pkt_segsFunction · 0.70
rte_memcpyFunction · 0.50

Tested by

no test coverage detected