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

Function idpf_ctlq_alloc_bufs

dpdk/drivers/common/idpf/base/idpf_controlq_setup.c:34–84  ·  view source on GitHub ↗

* idpf_ctlq_alloc_bufs - Allocate Control Queue (CQ) buffers * @hw: pointer to hw struct * @cq: pointer to the specific Control queue * * Allocate the buffer head for all control queues, and if it's a receive * queue, allocate DMA buffers */

Source from the content-addressed store, hash-verified

32 * queue, allocate DMA buffers
33 */
34static int idpf_ctlq_alloc_bufs(struct idpf_hw *hw,
35 struct idpf_ctlq_info *cq)
36{
37 int i = 0;
38
39 /* Do not allocate DMA buffers for transmit queues */
40 if (cq->cq_type == IDPF_CTLQ_TYPE_MAILBOX_TX)
41 return 0;
42
43 /* We'll be allocating the buffer info memory first, then we can
44 * allocate the mapped buffers for the event processing
45 */
46 cq->bi.rx_buff = (struct idpf_dma_mem **)
47 idpf_calloc(hw, cq->ring_size,
48 sizeof(struct idpf_dma_mem *));
49 if (!cq->bi.rx_buff)
50 return -ENOMEM;
51
52 /* allocate the mapped buffers (except for the last one) */
53 for (i = 0; i < cq->ring_size - 1; i++) {
54 struct idpf_dma_mem *bi;
55 int num = 1; /* number of idpf_dma_mem to be allocated */
56
57 cq->bi.rx_buff[i] = (struct idpf_dma_mem *)idpf_calloc(hw, num,
58 sizeof(struct idpf_dma_mem));
59 if (!cq->bi.rx_buff[i])
60 goto unwind_alloc_cq_bufs;
61
62 bi = cq->bi.rx_buff[i];
63
64 bi->va = idpf_alloc_dma_mem(hw, bi, cq->buf_size);
65 if (!bi->va) {
66 /* unwind will not free the failed entry */
67 idpf_free(hw, cq->bi.rx_buff[i]);
68 goto unwind_alloc_cq_bufs;
69 }
70 }
71
72 return 0;
73
74unwind_alloc_cq_bufs:
75 /* don't try to free the one that failed... */
76 i--;
77 for (; i >= 0; i--) {
78 idpf_free_dma_mem(hw, cq->bi.rx_buff[i]);
79 idpf_free(hw, cq->bi.rx_buff[i]);
80 }
81 idpf_free(hw, cq->bi.rx_buff);
82
83 return -ENOMEM;
84}
85
86/**
87 * idpf_ctlq_free_desc_ring - Free Control Queue (CQ) rings

Callers 1

idpf_ctlq_alloc_ring_resFunction · 0.85

Calls 2

idpf_alloc_dma_memFunction · 0.85
idpf_free_dma_memFunction · 0.85

Tested by

no test coverage detected