1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2008-2017 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
13 /* Receive queue control */
15 u64 ring_base; /* 0x00 */
16 u32 ring_size; /* 0x08 */
18 u32 posted_index; /* 0x10 */
20 u32 cq_index; /* 0x18 */
22 u32 enable; /* 0x20 */
24 u32 running; /* 0x28 */
26 u32 fetch_index; /* 0x30 */
28 u32 error_interrupt_enable; /* 0x38 */
30 u32 error_interrupt_offset; /* 0x40 */
32 u32 error_status; /* 0x48 */
34 u32 tcp_sn; /* 0x50 */
36 u32 unused; /* 0x58 */
38 u32 dca_select; /* 0x60 */
40 u32 dca_value; /* 0x68 */
42 u32 data_ring; /* 0x70 */
44 u32 header_split; /* 0x78 */
50 unsigned int posted_index;
51 struct vnic_dev *vdev;
52 struct vnic_rq_ctrl __iomem *ctrl; /* memory-mapped */
53 struct vnic_dev_ring ring;
54 struct rte_mbuf **mbuf_ring; /* array of allocated mbufs */
55 unsigned int mbuf_next_idx; /* next mb to consume */
57 unsigned int pkts_outstanding;
59 uint16_t rx_free_thresh;
60 unsigned int socket_id;
61 struct rte_mempool *mp;
64 uint16_t data_queue_idx;
65 uint8_t data_queue_enable;
68 struct rte_mbuf *pkt_first_seg;
69 struct rte_mbuf *pkt_last_seg;
70 unsigned int max_mbufs_per_pkt;
74 static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
76 /* how many does SW own? */
77 return rq->ring.desc_avail;
80 static inline unsigned int vnic_rq_desc_used(struct vnic_rq *rq)
82 /* how many does HW own? */
83 return rq->ring.desc_count - rq->ring.desc_avail - 1;
88 enum desc_return_options {
90 VNIC_RQ_DEFER_RETURN_DESC,
93 static inline int vnic_rq_fill(struct vnic_rq *rq,
94 int (*buf_fill)(struct vnic_rq *rq))
98 while (vnic_rq_desc_avail(rq) > 0) {
100 err = (*buf_fill)(rq);
108 static inline int vnic_rq_fill_count(struct vnic_rq *rq,
109 int (*buf_fill)(struct vnic_rq *rq), unsigned int count)
113 while ((vnic_rq_desc_avail(rq) > 0) && (count--)) {
115 err = (*buf_fill)(rq);
123 void vnic_rq_free(struct vnic_rq *rq);
124 int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index,
125 unsigned int desc_count, unsigned int desc_size);
126 void vnic_rq_init_start(struct vnic_rq *rq, unsigned int cq_index,
127 unsigned int fetch_index, unsigned int posted_index,
128 unsigned int error_interrupt_enable,
129 unsigned int error_interrupt_offset);
130 void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index,
131 unsigned int error_interrupt_enable,
132 unsigned int error_interrupt_offset);
133 void vnic_rq_error_out(struct vnic_rq *rq, unsigned int error);
134 unsigned int vnic_rq_error_status(struct vnic_rq *rq);
135 void vnic_rq_enable(struct vnic_rq *rq);
136 int vnic_rq_disable(struct vnic_rq *rq);
137 void vnic_rq_clean(struct vnic_rq *rq,
138 void (*buf_clean)(struct rte_mbuf **buf));
139 #endif /* _VNIC_RQ_H_ */