/* Do not allocate DMA buffers for transmit queues */ if (cq->cq_type == IDPF_CTLQ_TYPE_MAILBOX_TX) return0;
/* We'll be allocating the buffer info memory first, then we can *allocatethemappedbuffersfortheeventprocessing
*/
cq->bi.rx_buff = kcalloc(cq->ring_size, sizeof(struct idpf_dma_mem *),
GFP_KERNEL); if (!cq->bi.rx_buff) return -ENOMEM;
/* allocate the mapped buffers (except for the last one) */ for (i = 0; i < cq->ring_size - 1; i++) { struct idpf_dma_mem *bi; int num = 1; /* number of idpf_dma_mem to be allocated */
cq->bi.rx_buff[i] = kcalloc(num, sizeof(struct idpf_dma_mem),
GFP_KERNEL); if (!cq->bi.rx_buff[i]) goto unwind_alloc_cq_bufs;
bi = cq->bi.rx_buff[i];
bi->va = idpf_alloc_dma_mem(hw, bi, cq->buf_size); if (!bi->va) { /* unwind will not free the failed entry */
kfree(cq->bi.rx_buff[i]); goto unwind_alloc_cq_bufs;
}
}
return0;
unwind_alloc_cq_bufs: /* don't try to free the one that failed... */
i--; for (; i >= 0; i--) {
idpf_free_dma_mem(hw, cq->bi.rx_buff[i]);
kfree(cq->bi.rx_buff[i]);
}
kfree(cq->bi.rx_buff);
if (cq->cq_type == IDPF_CTLQ_TYPE_MAILBOX_RX) { int i;
/* free DMA buffers for rx queues*/ for (i = 0; i < cq->ring_size; i++) { if (cq->bi.rx_buff[i]) {
idpf_free_dma_mem(hw, cq->bi.rx_buff[i]);
kfree(cq->bi.rx_buff[i]);
}
}
bi = (void *)cq->bi.rx_buff;
} else {
bi = (void *)cq->bi.tx_msg;
}
/* free the buffer header */
kfree(bi);
}
/** *idpf_ctlq_dealloc_ring_res-Freememoryallocatedforcontrolqueue *@hw:pointertohwstruct *@cq:pointertothespecificControlqueue * *Freethememoryusedbythering,buffersandotherrelatedstructures
*/ void idpf_ctlq_dealloc_ring_res(struct idpf_hw *hw, struct idpf_ctlq_info *cq)
{ /* free ring buffers and the ring itself */
idpf_ctlq_free_bufs(hw, cq);
idpf_ctlq_free_desc_ring(hw, cq);
}
/** *idpf_ctlq_alloc_ring_res-allocatememoryfordescriptorringandbufs *@hw:pointertohwstruct *@cq:pointertocontrolqueuestruct * *Do*NOT*holdcq_lockwhencallingthisasthememoryallocationroutines *calledarenotgoingtobeatomiccontextsafe
*/ int idpf_ctlq_alloc_ring_res(struct idpf_hw *hw, struct idpf_ctlq_info *cq)
{ int err;
/* allocate the ring memory */
err = idpf_ctlq_alloc_desc_ring(hw, cq); if (err) return err;
/* allocate buffers in the rings */
err = idpf_ctlq_alloc_bufs(hw, cq); if (err) goto idpf_init_cq_free_ring;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.