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

Function prepare_sgl_bufs

dpdk/app/test/test_compressdev.c:684–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682}
683
684static int
685prepare_sgl_bufs(const char *test_buf, struct rte_mbuf *head_buf,
686 uint32_t total_data_size,
687 struct rte_mempool *small_mbuf_pool,
688 struct rte_mempool *large_mbuf_pool,
689 uint8_t limit_segs_in_sgl,
690 uint16_t seg_size)
691{
692 uint32_t remaining_data = total_data_size;
693 uint16_t num_remaining_segs = DIV_CEIL(remaining_data, seg_size);
694 struct rte_mempool *pool;
695 struct rte_mbuf *next_seg;
696 uint32_t data_size;
697 char *buf_ptr;
698 const char *data_ptr = test_buf;
699 uint16_t i;
700 int ret;
701
702 if (limit_segs_in_sgl != 0 && num_remaining_segs > limit_segs_in_sgl)
703 num_remaining_segs = limit_segs_in_sgl - 1;
704
705 /*
706 * Allocate data in the first segment (header) and
707 * copy data if test buffer is provided
708 */
709 if (remaining_data < seg_size)
710 data_size = remaining_data;
711 else
712 data_size = seg_size;
713
714 buf_ptr = rte_pktmbuf_append(head_buf, data_size);
715 if (buf_ptr == NULL) {
716 RTE_LOG(ERR, USER1,
717 "Not enough space in the 1st buffer\n");
718 return -1;
719 }
720
721 if (data_ptr != NULL) {
722 /* Copy characters without NULL terminator */
723 memcpy(buf_ptr, data_ptr, data_size);
724 data_ptr += data_size;
725 }
726 remaining_data -= data_size;
727 num_remaining_segs--;
728
729 /*
730 * Allocate the rest of the segments,
731 * copy the rest of the data and chain the segments.
732 */
733 for (i = 0; i < num_remaining_segs; i++) {
734
735 if (i == (num_remaining_segs - 1)) {
736 /* last segment */
737 if (remaining_data > seg_size)
738 pool = large_mbuf_pool;
739 else
740 pool = small_mbuf_pool;
741 data_size = remaining_data;

Callers 2

test_setup_com_bufsFunction · 0.85
test_setup_output_bufsFunction · 0.85

Calls 5

rte_pktmbuf_appendFunction · 0.85
rte_pktmbuf_allocFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
rte_pktmbuf_chainFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected