- uint32_t remaining_data = test_data->input_data_sz;
- uint8_t *input_data_ptr = test_data->input_data;
- size_t data_sz;
- uint8_t *data_addr;
- uint32_t i, j;
-
- for (i = 0; i < test_data->total_bufs; i++) {
- /* Allocate data in input mbuf and copy data from input file */
- test_data->decomp_bufs[i] =
- rte_pktmbuf_alloc(test_data->decomp_buf_pool);
- if (test_data->decomp_bufs[i] == NULL) {
- RTE_LOG(ERR, USER1, "Could not allocate mbuf\n");
- return -1;
- }
-
- cleanup = ST_PREPARE_BUF;
- data_sz = RTE_MIN(remaining_data, test_data->seg_sz);
- data_addr = (uint8_t *) rte_pktmbuf_append(
- test_data->decomp_bufs[i], data_sz);
- if (data_addr == NULL) {
- RTE_LOG(ERR, USER1, "Could not append data\n");
- return -1;
- }
- rte_memcpy(data_addr, input_data_ptr, data_sz);
-
- input_data_ptr += data_sz;
- remaining_data -= data_sz;
-
- /* Already one segment in the mbuf */
- uint16_t segs_per_mbuf = 1;
-
- /* Chain mbufs if needed for input mbufs */
- while (segs_per_mbuf < test_data->max_sgl_segs
- && remaining_data > 0) {
- struct rte_mbuf *next_seg =
- rte_pktmbuf_alloc(test_data->decomp_buf_pool);
-
- if (next_seg == NULL) {
- RTE_LOG(ERR, USER1,
- "Could not allocate mbuf\n");
- return -1;
- }
-
- data_sz = RTE_MIN(remaining_data, test_data->seg_sz);
- data_addr = (uint8_t *)rte_pktmbuf_append(next_seg,
- data_sz);
-
- if (data_addr == NULL) {
- RTE_LOG(ERR, USER1, "Could not append data\n");
- return -1;
- }
-
- rte_memcpy(data_addr, input_data_ptr, data_sz);
- input_data_ptr += data_sz;
- remaining_data -= data_sz;
-
- if (rte_pktmbuf_chain(test_data->decomp_bufs[i],
- next_seg) < 0) {
- RTE_LOG(ERR, USER1, "Could not chain mbufs\n");
- return -1;
- }
- segs_per_mbuf++;
- }
-
- /* Allocate data in output mbuf */
- test_data->comp_bufs[i] =
- rte_pktmbuf_alloc(test_data->comp_buf_pool);
- if (test_data->comp_bufs[i] == NULL) {
- RTE_LOG(ERR, USER1, "Could not allocate mbuf\n");
- return -1;
- }
- data_addr = (uint8_t *) rte_pktmbuf_append(
- test_data->comp_bufs[i],
- test_data->seg_sz);
- if (data_addr == NULL) {
- RTE_LOG(ERR, USER1, "Could not append data\n");
- return -1;
- }
-
- /* Chain mbufs if needed for output mbufs */
- for (j = 1; j < segs_per_mbuf; j++) {
- struct rte_mbuf *next_seg =
- rte_pktmbuf_alloc(test_data->comp_buf_pool);
-
- if (next_seg == NULL) {
- RTE_LOG(ERR, USER1,
- "Could not allocate mbuf\n");
- return -1;
- }
-
- data_addr = (uint8_t *)rte_pktmbuf_append(next_seg,
- test_data->seg_sz);
-
- if (data_addr == NULL) {
- RTE_LOG(ERR, USER1, "Could not append data\n");
- return -1;
- }
-
- if (rte_pktmbuf_chain(test_data->comp_bufs[i],
- next_seg) < 0) {
- RTE_LOG(ERR, USER1, "Could not chain mbufs\n");
- return -1;
- }
- }
- }
-
- return 0;