• Home
  • Raw
  • Download

Lines Matching full:ring

36 static int hnae_alloc_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb)  in hnae_alloc_buffer()  argument
38 unsigned int order = hnae_page_order(ring); in hnae_alloc_buffer()
48 cb->length = hnae_page_size(ring); in hnae_alloc_buffer()
54 static void hnae_free_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_free_buffer() argument
61 else if (unlikely(is_rx_ring(ring))) in hnae_free_buffer()
67 static int hnae_map_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_map_buffer() argument
69 cb->dma = dma_map_page(ring_to_dev(ring), cb->priv, 0, in hnae_map_buffer()
70 cb->length, ring_to_dma_dir(ring)); in hnae_map_buffer()
72 if (dma_mapping_error(ring_to_dev(ring), cb->dma)) in hnae_map_buffer()
78 static void hnae_unmap_buffer(struct hnae_ring *ring, struct hnae_desc_cb *cb) in hnae_unmap_buffer() argument
81 dma_unmap_single(ring_to_dev(ring), cb->dma, cb->length, in hnae_unmap_buffer()
82 ring_to_dma_dir(ring)); in hnae_unmap_buffer()
84 dma_unmap_page(ring_to_dev(ring), cb->dma, cb->length, in hnae_unmap_buffer()
85 ring_to_dma_dir(ring)); in hnae_unmap_buffer()
119 static void hnae_free_buffers(struct hnae_ring *ring) in hnae_free_buffers() argument
123 for (i = 0; i < ring->desc_num; i++) in hnae_free_buffers()
124 hnae_free_buffer_detach(ring, i); in hnae_free_buffers()
128 static int hnae_alloc_buffers(struct hnae_ring *ring) in hnae_alloc_buffers() argument
132 for (i = 0; i < ring->desc_num; i++) { in hnae_alloc_buffers()
133 ret = hnae_alloc_buffer_attach(ring, i); in hnae_alloc_buffers()
142 hnae_free_buffer_detach(ring, j); in hnae_alloc_buffers()
147 static void hnae_free_desc(struct hnae_ring *ring) in hnae_free_desc() argument
149 dma_unmap_single(ring_to_dev(ring), ring->desc_dma_addr, in hnae_free_desc()
150 ring->desc_num * sizeof(ring->desc[0]), in hnae_free_desc()
151 ring_to_dma_dir(ring)); in hnae_free_desc()
152 ring->desc_dma_addr = 0; in hnae_free_desc()
153 kfree(ring->desc); in hnae_free_desc()
154 ring->desc = NULL; in hnae_free_desc()
158 static int hnae_alloc_desc(struct hnae_ring *ring) in hnae_alloc_desc() argument
160 int size = ring->desc_num * sizeof(ring->desc[0]); in hnae_alloc_desc()
162 ring->desc = kzalloc(size, GFP_KERNEL); in hnae_alloc_desc()
163 if (!ring->desc) in hnae_alloc_desc()
166 ring->desc_dma_addr = dma_map_single(ring_to_dev(ring), in hnae_alloc_desc()
167 ring->desc, size, ring_to_dma_dir(ring)); in hnae_alloc_desc()
168 if (dma_mapping_error(ring_to_dev(ring), ring->desc_dma_addr)) { in hnae_alloc_desc()
169 ring->desc_dma_addr = 0; in hnae_alloc_desc()
170 kfree(ring->desc); in hnae_alloc_desc()
171 ring->desc = NULL; in hnae_alloc_desc()
178 /* fini ring, also free the buffer for the ring */
179 static void hnae_fini_ring(struct hnae_ring *ring) in hnae_fini_ring() argument
181 if (is_rx_ring(ring)) in hnae_fini_ring()
182 hnae_free_buffers(ring); in hnae_fini_ring()
184 hnae_free_desc(ring); in hnae_fini_ring()
185 kfree(ring->desc_cb); in hnae_fini_ring()
186 ring->desc_cb = NULL; in hnae_fini_ring()
187 ring->next_to_clean = 0; in hnae_fini_ring()
188 ring->next_to_use = 0; in hnae_fini_ring()
191 /* init ring, and with buffer for rx ring */
193 hnae_init_ring(struct hnae_queue *q, struct hnae_ring *ring, int flags) in hnae_init_ring() argument
197 if (ring->desc_num <= 0 || ring->buf_size <= 0) in hnae_init_ring()
200 ring->q = q; in hnae_init_ring()
201 ring->flags = flags; in hnae_init_ring()
202 ring->coal_param = q->handle->coal_param; in hnae_init_ring()
203 assert(!ring->desc && !ring->desc_cb && !ring->desc_dma_addr); in hnae_init_ring()
205 /* not matter for tx or rx ring, the ntc and ntc start from 0 */ in hnae_init_ring()
206 assert(ring->next_to_use == 0); in hnae_init_ring()
207 assert(ring->next_to_clean == 0); in hnae_init_ring()
209 ring->desc_cb = kcalloc(ring->desc_num, sizeof(ring->desc_cb[0]), in hnae_init_ring()
211 if (!ring->desc_cb) { in hnae_init_ring()
216 ret = hnae_alloc_desc(ring); in hnae_init_ring()
220 if (is_rx_ring(ring)) { in hnae_init_ring()
221 ret = hnae_alloc_buffers(ring); in hnae_init_ring()
229 hnae_free_desc(ring); in hnae_init_ring()
231 kfree(ring->desc_cb); in hnae_init_ring()
232 ring->desc_cb = NULL; in hnae_init_ring()
296 for (i = 0; i < handle->q_num; i++) /* free ring*/ in hnae_reinit_handle()
302 for (i = 0; i < handle->q_num; i++) {/* reinit ring*/ in hnae_reinit_handle()