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
428 * get RX/TX ring number
430 * get RX/TX ring maximum number
476 void (*toggle_ring_irq)(struct hnae_ring *ring, u32 val);
552 /* the ring index of last ring that set coal param */
564 #define ring_to_dev(ring) ((ring)->q->dev->dev)
586 static inline int hnae_reserve_buffer_map(struct hnae_ring *ring,
589 struct hnae_buf_ops *bops = ring->q->handle->bops;
592 ret = bops->alloc_buffer(ring, cb);
596 ret = bops->map_buffer(ring, cb);
603 bops->free_buffer(ring, cb);
608 static inline int hnae_alloc_buffer_attach(struct hnae_ring *ring, int i)
610 int ret = hnae_reserve_buffer_map(ring, &ring->desc_cb[i]);
615 ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma);
620 static inline void hnae_buffer_detach(struct hnae_ring *ring, int i)
622 ring->q->handle->bops->unmap_buffer(ring, &ring->desc_cb[i]);
623 ring->desc[i].addr = 0;
626 static inline void hnae_free_buffer_detach(struct hnae_ring *ring, int i)
628 struct hnae_buf_ops *bops = ring->q->handle->bops;
629 struct hnae_desc_cb *cb = &ring->desc_cb[i];
631 if (!ring->desc_cb[i].dma)
634 hnae_buffer_detach(ring, i);
635 bops->free_buffer(ring, cb);
639 static inline void hnae_replace_buffer(struct hnae_ring *ring, int i,
642 struct hnae_buf_ops *bops = ring->q->handle->bops;
644 bops->unmap_buffer(ring, &ring->desc_cb[i]);
645 ring->desc_cb[i] = *res_cb;
646 ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma);
647 ring->desc[i].rx.ipoff_bnum_pid_flag = 0;
650 static inline void hnae_reuse_buffer(struct hnae_ring *ring, int i)
652 ring->desc_cb[i].reuse_flag = 0;
653 ring->desc[i].addr = cpu_to_le64(ring->desc_cb[i].dma
654 + ring->desc_cb[i].page_offset);
655 ring->desc[i].rx.ipoff_bnum_pid_flag = 0;
662 struct hnae_ring *ring;
665 ring = &h->qs[i]->rx_ring;
666 for (j = 0; j < ring->desc_num; j++)
667 ring->desc[j].addr = cpu_to_le64(ring->desc_cb[j].dma);
677 struct hnae_ring *ring;
680 ring = &h->qs[i]->rx_ring;
681 for (j = 0; j < ring->desc_num; j++) {
682 ring->desc_cb[j].page_offset = 0;
683 if (ring->desc[j].addr !=
684 cpu_to_le64(ring->desc_cb[j].dma))
685 ring->desc[j].addr =
686 cpu_to_le64(ring->desc_cb[j].dma);