Lines Matching refs:ring

12  *      ring buffer queue (rbq):
14 * ring:
16 * ring description (desc):
17 * an element in the ring with packet information
168 /* hardware spec ring buffer format */
224 /* desc type, used by the ring user to mark the type of the priv data */
232 #define RINGF_DIR 0x1 /* TX or RX ring, set if TX */
233 #define is_tx_ring(ring) ((ring)->flags & RINGF_DIR)
234 #define is_rx_ring(ring) (!is_tx_ring(ring))
235 #define ring_to_dma_dir(ring) (is_tx_ring(ring) ? \
267 u8 __iomem *io_base; /* base io address for the ring */
285 /* idx of lastest sent desc, the ring is empty when equal to
290 int flags; /* ring attribute */
300 #define ring_ptr_move_fw(ring, p) \
301 ((ring)->p = ((ring)->p + 1) % (ring)->desc_num)
302 #define ring_ptr_move_bw(ring, p) \
303 ((ring)->p = ((ring)->p - 1 + (ring)->desc_num) % (ring)->desc_num)
310 #define assert_is_ring_idx(ring, idx) \
311 assert((idx) >= 0 && (idx) < (ring)->desc_num)
313 /* the distance between [begin, end) in a ring buffer
316 static inline int ring_dist(struct hnae_ring *ring, int begin, int end)
318 assert_is_ring_idx(ring, begin);
319 assert_is_ring_idx(ring, end);
321 return (end - begin + ring->desc_num) % ring->desc_num;
324 static inline int ring_space(struct hnae_ring *ring)
326 return ring->desc_num -
327 ring_dist(ring, ring->next_to_clean, ring->next_to_use) - 1;
330 static inline int is_ring_empty(struct hnae_ring *ring)
332 assert_is_ring_idx(ring, ring->next_to_use);
333 assert_is_ring_idx(ring, ring->next_to_clean);
335 return ring->next_to_use == ring->next_to_clean;
346 int (*alloc_buffer)(struct hnae_ring *ring, struct hnae_desc_cb *cb);
347 void (*free_buffer)(struct hnae_ring *ring, struct hnae_desc_cb *cb);
348 int (*map_buffer)(struct hnae_ring *ring, struct hnae_desc_cb *cb);
349 void (*unmap_buffer)(struct hnae_ring *ring, struct hnae_desc_cb *cb);
405 * Set the ring irq to be enabled(0) or disable(1)
408 * ring irq state
414 * get ring bd number limit
432 * get RX/TX ring number
434 * get RX/TX ring maximum number
480 void (*toggle_ring_irq)(struct hnae_ring *ring, u32 val);
558 /* the ring index of last ring that set coal param */
570 #define ring_to_dev(ring) ((ring)->q->dev->dev)
592 static inline int hnae_reserve_buffer_map(struct hnae_ring *ring,
595 struct hnae_buf_ops *bops = ring->q->handle->bops;
598 ret = bops->alloc_buffer(ring, cb);
602 ret = bops->map_buffer(ring, cb);
609 bops->free_buffer(ring, cb);
614 static inline int hnae_alloc_buffer_attach(struct hnae_ring *ring, int i)
616 int ret = hnae_reserve_buffer_map(ring, &ring->desc_cb[i]);
621 ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma);
626 static inline void hnae_buffer_detach(struct hnae_ring *ring, int i)
628 ring->q->handle->bops->unmap_buffer(ring, &ring->desc_cb[i]);
629 ring->desc[i].addr = 0;
632 static inline void hnae_free_buffer_detach(struct hnae_ring *ring, int i)
634 struct hnae_buf_ops *bops = ring->q->handle->bops;
635 struct hnae_desc_cb *cb = &ring->desc_cb[i];
637 if (!ring->desc_cb[i].dma)
640 hnae_buffer_detach(ring, i);
641 bops->free_buffer(ring, cb);
645 static inline void hnae_replace_buffer(struct hnae_ring *ring, int i,
648 struct hnae_buf_ops *bops = ring->q->handle->bops;
650 bops->unmap_buffer(ring, &ring->desc_cb[i]);
651 ring->desc_cb[i] = *res_cb;
652 ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma);
653 ring->desc[i].rx.ipoff_bnum_pid_flag = 0;
656 static inline void hnae_reuse_buffer(struct hnae_ring *ring, int i)
658 ring->desc_cb[i].reuse_flag = 0;
659 ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma
660 + ring->desc_cb[i].page_offset);
661 ring->desc[i].rx.ipoff_bnum_pid_flag = 0;
668 struct hnae_ring *ring;
671 ring = &h->qs[i]->rx_ring;
672 for (j = 0; j < ring->desc_num; j++)
673 ring->desc[j].addr = cpu_to_le64(ring->desc_cb[j].dma);
683 struct hnae_ring *ring;
686 ring = &h->qs[i]->rx_ring;
687 for (j = 0; j < ring->desc_num; j++) {
688 ring->desc_cb[j].page_offset = 0;
689 if (ring->desc[j].addr !=
690 cpu_to_le64(ring->desc_cb[j].dma))
691 ring->desc[j].addr =
692 cpu_to_le64(ring->desc_cb[j].dma);