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

Function mbuf_copy_split

dpdk/app/test-pmd/csumonly.c:643–703  ·  view source on GitHub ↗

* Helper function. * Performs actual copying. * Returns number of segments in the destination mbuf on success, * or negative error code on failure. */

Source from the content-addressed store, hash-verified

641 * or negative error code on failure.
642 */
643static int
644mbuf_copy_split(const struct rte_mbuf *ms, struct rte_mbuf *md[],
645 uint16_t seglen[], uint8_t nb_seg)
646{
647 uint32_t dlen, slen, tlen;
648 uint32_t i, len;
649 const struct rte_mbuf *m;
650 const uint8_t *src;
651 uint8_t *dst;
652
653 dlen = 0;
654 slen = 0;
655 tlen = 0;
656
657 dst = NULL;
658 src = NULL;
659
660 m = ms;
661 i = 0;
662 while (ms != NULL && i != nb_seg) {
663
664 if (slen == 0) {
665 slen = rte_pktmbuf_data_len(ms);
666 src = rte_pktmbuf_mtod(ms, const uint8_t *);
667 }
668
669 if (dlen == 0) {
670 dlen = RTE_MIN(seglen[i], slen);
671 md[i]->data_len = dlen;
672 md[i]->next = (i + 1 == nb_seg) ? NULL : md[i + 1];
673 dst = rte_pktmbuf_mtod(md[i], uint8_t *);
674 }
675
676 len = RTE_MIN(slen, dlen);
677 memcpy(dst, src, len);
678 tlen += len;
679 slen -= len;
680 dlen -= len;
681 src += len;
682 dst += len;
683
684 if (slen == 0)
685 ms = ms->next;
686 if (dlen == 0)
687 i++;
688 }
689
690 if (ms != NULL)
691 return -ENOBUFS;
692 else if (tlen != m->pkt_len)
693 return -EINVAL;
694
695 md[0]->nb_segs = nb_seg;
696 md[0]->pkt_len = tlen;
697 md[0]->vlan_tci = m->vlan_tci;
698 md[0]->vlan_tci_outer = m->vlan_tci_outer;
699 md[0]->ol_flags = m->ol_flags;
700 md[0]->tx_offload = m->tx_offload;

Callers 1

pkt_copy_splitFunction · 0.85

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected