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

Function ff_bsd_to_rte

lib/ff_memory.c:398–438  ·  view source on GitHub ↗

create rte_mbuf refer to data in bsd mbuf.

Source from the content-addressed store, hash-verified

396
397// create rte_mbuf refer to data in bsd mbuf.
398static inline struct rte_mbuf* ff_bsd_to_rte(void *m, int total)
399{
400 struct rte_mempool *mbuf_pool = ff_ref_pool[lcore_conf.socket_id];
401 struct rte_mbuf *p_head = NULL;
402 struct rte_mbuf *cur = NULL, *prev = NULL, *tmp=NULL;
403 void *data = NULL;
404 void *p_bsdbuf = NULL;
405 unsigned len = 0;
406
407 p_head = rte_pktmbuf_alloc(mbuf_pool);
408 if (p_head == NULL){
409 return NULL;
410 }
411 p_head->pkt_len = total;
412 p_head->nb_segs = 0;
413 cur = p_head;
414 p_bsdbuf = m;
415 while ( p_bsdbuf ){
416 if (cur == NULL) {
417 cur = rte_pktmbuf_alloc(mbuf_pool);
418 if (cur == NULL) {
419 rte_pktmbuf_free(p_head);
420 return NULL;
421 }
422 }
423 ff_next_mbuf(&p_bsdbuf, &data, &len); // p_bsdbuf move to next mbuf.
424 cur->buf_addr = data;
425 cur->buf_iova = ff_mem_virt2phy((const void*)(cur->buf_addr));
426 cur->data_off = 0;
427 cur->data_len = len;
428
429 p_head->nb_segs++;
430 if (prev != NULL) {
431 prev->next = cur;
432 }
433 prev = cur;
434 cur = NULL;
435 }
436
437 return p_head;
438}
439
440int ff_if_send_onepkt(struct ff_dpdk_if_context *ctx, void *m, int total)
441{

Callers 1

ff_if_send_onepktFunction · 0.85

Calls 4

rte_pktmbuf_allocFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
ff_next_mbufFunction · 0.85
ff_mem_virt2phyFunction · 0.85

Tested by

no test coverage detected