Lines Matching full:ring
38 static int hnae_alloc_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_alloc_buffer() argument
40 unsigned int order = hnae_page_order(ring); in hnae_alloc_buffer()
50 cb->length = hnae_page_size(ring); in hnae_alloc_buffer()
56 static void hnae_free_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_free_buffer() argument
63 else if (unlikely(is_rx_ring(ring))) in hnae_free_buffer()
69 static int hnae_map_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_map_buffer() argument
71 cb->dma = dma_map_page(ring_to_dev(ring), cb->priv, 0, in hnae_map_buffer()
72 cb->length, ring_to_dma_dir(ring)); in hnae_map_buffer()
74 if (dma_mapping_error(ring_to_dev(ring), cb->dma)) in hnae_map_buffer()
80 static void hnae_unmap_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_unmap_buffer() argument
83 dma_unmap_single(ring_to_dev(ring), cb->dma, cb->length, in hnae_unmap_buffer()
84 ring_to_dma_dir(ring)); in hnae_unmap_buffer()
86 dma_unmap_page(ring_to_dev(ring), cb->dma, cb->length, in hnae_unmap_buffer()
87 ring_to_dma_dir(ring)); in hnae_unmap_buffer()
121 static void hnae_free_buffers(struct hnae_ring *ring) in hnae_free_buffers() argument
125 for (i = 0; i < ring->desc_num; i++) in hnae_free_buffers()
126 hnae_free_buffer_detach(ring, i); in hnae_free_buffers()
130 static int hnae_alloc_buffers(struct hnae_ring *ring) in hnae_alloc_buffers() argument
134 for (i = 0; i < ring->desc_num; i++) { in hnae_alloc_buffers()
135 ret = hnae_alloc_buffer_attach(ring, i); in hnae_alloc_buffers()
144 hnae_free_buffer_detach(ring, j); in hnae_alloc_buffers()
149 static void hnae_free_desc(struct hnae_ring *ring) in hnae_free_desc() argument
151 dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr, in hnae_free_desc()
152 ring->desc_num * sizeof(ring->desc[0]), in hnae_free_desc()
153 ring_to_dma_dir(ring)); in hnae_free_desc()
154 ring->desc_dma_addr = 0; in hnae_free_desc()
155 kfree(ring->desc); in hnae_free_desc()
156 ring->desc = NULL; in hnae_free_desc()
160 static int hnae_alloc_desc(struct hnae_ring *ring) in hnae_alloc_desc() argument
162 int size = ring->desc_num * sizeof(ring->desc[0]); in hnae_alloc_desc()
164 ring->desc = kzalloc(size, GFP_KERNEL); in hnae_alloc_desc()
165 if (!ring->desc) in hnae_alloc_desc()
168 ring->desc_dma_addr = dma_map_single(ring_to_dev(ring), in hnae_alloc_desc()
169 ring->desc, size, ring_to_dma_dir(ring)); in hnae_alloc_desc()
170 if (dma_mapping_error(ring_to_dev(ring), ring->desc_dma_addr)) { in hnae_alloc_desc()
171 ring->desc_dma_addr = 0; in hnae_alloc_desc()
172 kfree(ring->desc); in hnae_alloc_desc()
173 ring->desc = NULL; in hnae_alloc_desc()
180 /* fini ring, also free the buffer for the ring */
181 static void hnae_fini_ring(struct hnae_ring *ring) in hnae_fini_ring() argument
183 if (is_rx_ring(ring)) in hnae_fini_ring()
184 hnae_free_buffers(ring); in hnae_fini_ring()
186 hnae_free_desc(ring); in hnae_fini_ring()
187 kfree(ring->desc_cb); in hnae_fini_ring()
188 ring->desc_cb = NULL; in hnae_fini_ring()
189 ring->next_to_clean = 0; in hnae_fini_ring()
190 ring->next_to_use = 0; in hnae_fini_ring()
193 /* init ring, and with buffer for rx ring */
195 hnae_init_ring(struct hnae_queue *q, struct hnae_ring *ring, int flags) in hnae_init_ring() argument
199 if (ring->desc_num <= 0 || ring->buf_size <= 0) in hnae_init_ring()
202 ring->q = q; in hnae_init_ring()
203 ring->flags = flags; in hnae_init_ring()
204 ring->coal_param = q->handle->coal_param; in hnae_init_ring()
205 assert(!ring->desc && !ring->desc_cb && !ring->desc_dma_addr); in hnae_init_ring()
207 /* not matter for tx or rx ring, the ntc and ntc start from 0 */ in hnae_init_ring()
208 assert(ring->next_to_use == 0); in hnae_init_ring()
209 assert(ring->next_to_clean == 0); in hnae_init_ring()
211 ring->desc_cb = kcalloc(ring->desc_num, sizeof(ring->desc_cb[0]), in hnae_init_ring()
213 if (!ring->desc_cb) { in hnae_init_ring()
218 ret = hnae_alloc_desc(ring); in hnae_init_ring()
222 if (is_rx_ring(ring)) { in hnae_init_ring()
223 ret = hnae_alloc_buffers(ring); in hnae_init_ring()
231 hnae_free_desc(ring); in hnae_init_ring()
233 kfree(ring->desc_cb); in hnae_init_ring()
234 ring->desc_cb = NULL; in hnae_init_ring()
298 for (i = 0; i < handle->q_num; i++) /* free ring*/ in hnae_reinit_handle()
304 for (i = 0; i < handle->q_num; i++) {/* reinit ring*/ in hnae_reinit_handle()