]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/net/enic/base/vnic_rq.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / net / enic / base / vnic_rq.h
1 /*
2 * Copyright 2008-2010 Cisco Systems, Inc. All rights reserved.
3 * Copyright 2007 Nuova Systems, Inc. All rights reserved.
4 *
5 * Copyright (c) 2014, Cisco Systems, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
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
18 * distribution.
19 *
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.
32 *
33 */
34
35 #ifndef _VNIC_RQ_H_
36 #define _VNIC_RQ_H_
37
38
39 #include "vnic_dev.h"
40 #include "vnic_cq.h"
41
42 /* Receive queue control */
43 struct vnic_rq_ctrl {
44 u64 ring_base; /* 0x00 */
45 u32 ring_size; /* 0x08 */
46 u32 pad0;
47 u32 posted_index; /* 0x10 */
48 u32 pad1;
49 u32 cq_index; /* 0x18 */
50 u32 pad2;
51 u32 enable; /* 0x20 */
52 u32 pad3;
53 u32 running; /* 0x28 */
54 u32 pad4;
55 u32 fetch_index; /* 0x30 */
56 u32 pad5;
57 u32 error_interrupt_enable; /* 0x38 */
58 u32 pad6;
59 u32 error_interrupt_offset; /* 0x40 */
60 u32 pad7;
61 u32 error_status; /* 0x48 */
62 u32 pad8;
63 u32 tcp_sn; /* 0x50 */
64 u32 pad9;
65 u32 unused; /* 0x58 */
66 u32 pad10;
67 u32 dca_select; /* 0x60 */
68 u32 pad11;
69 u32 dca_value; /* 0x68 */
70 u32 pad12;
71 u32 data_ring; /* 0x70 */
72 u32 pad13;
73 u32 header_split; /* 0x78 */
74 u32 pad14;
75 };
76
77 struct vnic_rq {
78 unsigned int index;
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 */
85 void *os_buf_head;
86 unsigned int pkts_outstanding;
87 uint16_t rx_nb_hold;
88 uint16_t rx_free_thresh;
89 unsigned int socket_id;
90 struct rte_mempool *mp;
91 uint16_t rxst_idx;
92 uint32_t tot_pkts;
93 uint16_t data_queue_idx;
94 uint8_t data_queue_enable;
95 uint8_t is_sop;
96 uint8_t in_use;
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;
101 };
102
103 static inline unsigned int vnic_rq_desc_avail(struct vnic_rq *rq)
104 {
105 /* how many does SW own? */
106 return rq->ring.desc_avail;
107 }
108
109 static inline unsigned int vnic_rq_desc_used(struct vnic_rq *rq)
110 {
111 /* how many does HW own? */
112 return rq->ring.desc_count - rq->ring.desc_avail - 1;
113 }
114
115
116
117 enum desc_return_options {
118 VNIC_RQ_RETURN_DESC,
119 VNIC_RQ_DEFER_RETURN_DESC,
120 };
121
122 static inline int vnic_rq_fill(struct vnic_rq *rq,
123 int (*buf_fill)(struct vnic_rq *rq))
124 {
125 int err;
126
127 while (vnic_rq_desc_avail(rq) > 0) {
128
129 err = (*buf_fill)(rq);
130 if (err)
131 return err;
132 }
133
134 return 0;
135 }
136
137 static inline int vnic_rq_fill_count(struct vnic_rq *rq,
138 int (*buf_fill)(struct vnic_rq *rq), unsigned int count)
139 {
140 int err;
141
142 while ((vnic_rq_desc_avail(rq) > 0) && (count--)) {
143
144 err = (*buf_fill)(rq);
145 if (err)
146 return err;
147 }
148
149 return 0;
150 }
151
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_ */