-static struct rte_mbuf *
-cperf_mbuf_create(struct rte_mempool *mempool,
- uint32_t segment_sz,
- uint32_t segments_nb,
- const struct cperf_options *options,
- const struct cperf_test_vector *test_vector)
-{
- struct rte_mbuf *mbuf;
- uint8_t *mbuf_data;
- uint8_t *test_data =
- (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ?
- test_vector->plaintext.data :
- test_vector->ciphertext.data;
- uint32_t remaining_bytes = options->max_buffer_size;
-
- mbuf = rte_pktmbuf_alloc(mempool);
- if (mbuf == NULL)
- goto error;
-
- mbuf_data = (uint8_t *)rte_pktmbuf_append(mbuf, segment_sz);
- if (mbuf_data == NULL)
- goto error;
-
- if (options->max_buffer_size <= segment_sz) {
- memcpy(mbuf_data, test_data, options->max_buffer_size);
- test_data += options->max_buffer_size;
- remaining_bytes = 0;
- } else {
- memcpy(mbuf_data, test_data, segment_sz);
- test_data += segment_sz;
- remaining_bytes -= segment_sz;
- }
- segments_nb--;
-
- while (remaining_bytes) {
- struct rte_mbuf *m;
-
- m = rte_pktmbuf_alloc(mempool);
- if (m == NULL)
- goto error;
-
- rte_pktmbuf_chain(mbuf, m);
-
- mbuf_data = (uint8_t *)rte_pktmbuf_append(mbuf, segment_sz);
- if (mbuf_data == NULL)
- goto error;
-
- if (remaining_bytes <= segment_sz) {
- memcpy(mbuf_data, test_data, remaining_bytes);
- remaining_bytes = 0;
- test_data += remaining_bytes;
- } else {
- memcpy(mbuf_data, test_data, segment_sz);
- remaining_bytes -= segment_sz;
- test_data += segment_sz;
- }
- segments_nb--;
- }
-
- /*
- * If there was not enough room for the digest at the end
- * of the last segment, allocate a new one
- */
- if (segments_nb != 0) {
- struct rte_mbuf *m;
- m = rte_pktmbuf_alloc(mempool);
-
- if (m == NULL)
- goto error;