2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
5 * Copyright (c) 2014, Cisco Systems, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
42 /* Receive queue control */
44 u64 ring_base; /* 0x00 */
45 u32 ring_size; /* 0x08 */
47 u32 posted_index; /* 0x10 */
49 u32 cq_index; /* 0x18 */
51 u32 enable; /* 0x20 */
53 u32 running; /* 0x28 */
55 u32 fetch_index; /* 0x30 */
57 u32 error_interrupt_enable; /* 0x38 */
59 u32 error_interrupt_offset; /* 0x40 */
61 u32 error_status; /* 0x48 */
63 u32 tcp_sn; /* 0x50 */
65 u32 unused; /* 0x58 */
67 u32 dca_select; /* 0x60 */
69 u32 dca_value; /* 0x68 */
71 u32 data_ring; /* 0x70 */
73 u32 header_split; /* 0x78 */
79 unsigned int posted_index;
80 struct vnic_dev *vdev;
81 struct vnic_rq_ctrl __iomem *ctrl; /* memory-mapped */
82 struct vnic_dev_ring ring;
83 struct rte_mbuf **mbuf_ring; /* array of allocated mbufs */
84 unsigned int mbuf_next_idx; /* next mb to consume */
86 unsigned int pkts_outstanding;
88 uint16_t rx_free_thresh;
89 unsigned int socket_id;
90 struct rte_mempool *mp;
93 uint16_t data_queue_idx;
94 uint8_t data_queue_enable;
97 struct rte_mbuf *pkt_first_seg;
98 struct rte_mbuf *pkt_last_seg;
99 unsigned int max_mbufs_per_pkt;
100 uint16_t tot_nb_desc;
103 static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
105 /* how many does SW own? */
106 return rq->ring.desc_avail;
109 static inline unsigned int vnic_rq_desc_used(struct vnic_rq *rq)
111 /* how many does HW own? */
112 return rq->ring.desc_count - rq->ring.desc_avail - 1;
117 enum desc_return_options {
119 VNIC_RQ_DEFER_RETURN_DESC,
122 static inline int vnic_rq_fill(struct vnic_rq *rq,
123 int (*buf_fill)(struct vnic_rq *rq))
127 while (vnic_rq_desc_avail(rq) > 0) {
129 err = (*buf_fill)(rq);
137 static inline int vnic_rq_fill_count(struct vnic_rq *rq,
138 int (*buf_fill)(struct vnic_rq *rq), unsigned int count)
142 while ((vnic_rq_desc_avail(rq) > 0) && (count--)) {
144 err = (*buf_fill)(rq);
152 void vnic_rq_free(struct vnic_rq *rq);
153 int vnic_rq_alloc(struct vnic_dev *vdev, struct vnic_rq *rq, unsigned int index,
154 unsigned int desc_count, unsigned int desc_size);
155 void vnic_rq_init_start(struct vnic_rq *rq, unsigned int cq_index,
156 unsigned int fetch_index, unsigned int posted_index,
157 unsigned int error_interrupt_enable,
158 unsigned int error_interrupt_offset);
159 void vnic_rq_init(struct vnic_rq *rq, unsigned int cq_index,
160 unsigned int error_interrupt_enable,
161 unsigned int error_interrupt_offset);
162 void vnic_rq_error_out(struct vnic_rq *rq, unsigned int error);
163 unsigned int vnic_rq_error_status(struct vnic_rq *rq);
164 void vnic_rq_enable(struct vnic_rq *rq);
165 int vnic_rq_disable(struct vnic_rq *rq);
166 void vnic_rq_clean(struct vnic_rq *rq,
167 void (*buf_clean)(struct rte_mbuf **buf));
168 #endif /* _VNIC_RQ_H_ */