-int xran_send_message_burst(int dst_id, int pkt_type, void *body, int len)
-{
- struct rte_mbuf *mbufs[BURST_SIZE];
- int i;
- uint8_t *src = body;
- const struct xran_ethdi_ctx *const ctx = xran_ethdi_get_ctx();
-
- /* We're limited by maximum mbuf size on the receive size.
- * We can change this but this would be a bigger rework. */
- RTE_ASSERT(len < MBUF_POOL_ELM_BIG);
-
- /* Allocate the required number of mbufs. */
- const uint8_t count = ceilf((float)len / MAX_DATA_SIZE);
- if (rte_pktmbuf_alloc_bulk(_eth_mbuf_pool, mbufs, count) != 0)
- rte_panic("Failed to allocate %d mbufs\n", count);
-
- nlog("burst transfer with data size %lu", MAX_DATA_SIZE);
- for (i = 0; len > 0; ++i) {
- char *p;
- struct burst_hdr *bhdr;
- struct ethdi_hdr *edi_hdr;
-
- /* Setup the ethdi_hdr. */
- edi_hdr = (void *)rte_pktmbuf_append(mbufs[i], sizeof(*edi_hdr));
- if (edi_hdr == NULL)
- rte_panic("append of ethdi_hdr failed\n");
- edi_hdr->pkt_type = PKT_BURST;
- /* edi_hdr->source_id setup in tx_from_ring */
- edi_hdr->dest_id = dst_id;
-
- /* Setup the burst header */
- bhdr = (void *)rte_pktmbuf_append(mbufs[i], sizeof(*bhdr));
- if (bhdr == NULL) /* append failed. */
- rte_panic("mbuf prepend of burst_hdr failed\n");
- bhdr->original_type = pkt_type;
- bhdr->pkt_idx = i; /* save the index of the burst chunk. */
- bhdr->total_pkts = count;
-
- /* now copy in the actual data */
- const int curr_data_len = RTE_MIN(len, MAX_TX_LEN -
- rte_pktmbuf_pkt_len(mbufs[i]) - sizeof(struct ether_hdr));
- p = (void *)rte_pktmbuf_append(mbufs[i], curr_data_len);
- if (p == NULL)
- rte_panic("mbuf append of %d data bytes failed\n", curr_data_len);
- /* This copy is unavoidable, as we're splitting one big buffer
- * into multiple mbufs. */
- rte_memcpy(p, src, curr_data_len);
-
- dlog("curr_data_len[%d] = %d", i, curr_data_len);
- dlog("packet %d size %d", i, rte_pktmbuf_pkt_len(mbufs[i]));
-
- /* Update our source data pointer and remaining length. */
- len -= curr_data_len;
- src += curr_data_len;
- }