4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef _VMXNET3_RING_H_
35 #define _VMXNET3_RING_H_
37 #define VMXNET3_RX_CMDRING_SIZE 2
39 #define VMXNET3_DRIVER_VERSION_NUM 0x01012000
41 /* Default ring size */
42 #define VMXNET3_DEF_TX_RING_SIZE 512
43 #define VMXNET3_DEF_RX_RING_SIZE 128
45 /* Default rx data ring desc size */
46 #define VMXNET3_DEF_RXDATA_DESC_SIZE 128
48 #define VMXNET3_SUCCESS 0
49 #define VMXNET3_FAIL -1
55 typedef struct vmxnet3_buf_info {
61 typedef struct vmxnet3_cmd_ring {
62 vmxnet3_buf_info_t *buf_info;
68 Vmxnet3_GenericDesc *base;
73 vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring)
76 if (unlikely(ring->next2fill == ring->size)) {
78 ring->gen = (uint8_t)(ring->gen ^ 1);
83 vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring)
85 VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size);
88 static inline uint32_t
89 vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring)
91 return (ring->next2comp > ring->next2fill ? 0 : ring->size) +
92 ring->next2comp - ring->next2fill - 1;
96 vmxnet3_cmd_ring_desc_empty(struct vmxnet3_cmd_ring *ring)
98 return ring->next2comp == ring->next2fill;
101 typedef struct vmxnet3_comp_ring {
106 Vmxnet3_GenericDesc *base;
108 } vmxnet3_comp_ring_t;
110 struct vmxnet3_data_ring {
111 struct Vmxnet3_TxDataDesc *base;
117 vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring)
120 if (unlikely(ring->next2proc == ring->size)) {
122 ring->gen = (uint8_t)(ring->gen ^ 1);
126 struct vmxnet3_txq_stats {
127 uint64_t drop_total; /* # of pkts dropped by the driver,
128 * the counters below track droppings due to
131 uint64_t drop_too_many_segs;
133 uint64_t tx_ring_full;
136 typedef struct vmxnet3_tx_queue {
137 struct vmxnet3_hw *hw;
138 struct vmxnet3_cmd_ring cmd_ring;
139 struct vmxnet3_comp_ring comp_ring;
140 struct vmxnet3_data_ring data_ring;
142 struct Vmxnet3_TxQueueDesc *shared;
143 struct vmxnet3_txq_stats stats;
144 const struct rte_memzone *mz;
146 uint16_t queue_id; /**< Device TX queue index. */
147 uint8_t port_id; /**< Device port identifier. */
148 uint16_t txdata_desc_size;
149 } vmxnet3_tx_queue_t;
151 struct vmxnet3_rxq_stats {
155 uint64_t rx_buf_alloc_failure;
158 struct vmxnet3_rx_data_ring {
164 typedef struct vmxnet3_rx_queue {
165 struct rte_mempool *mp;
166 struct vmxnet3_hw *hw;
167 struct vmxnet3_cmd_ring cmd_ring[VMXNET3_RX_CMDRING_SIZE];
168 struct vmxnet3_comp_ring comp_ring;
169 struct vmxnet3_rx_data_ring data_ring;
170 uint16_t data_desc_size;
173 /* rqID in RCD for buffer from data ring */
174 uint32_t data_ring_qid;
175 Vmxnet3_RxQueueDesc *shared;
176 struct rte_mbuf *start_seg;
177 struct rte_mbuf *last_seg;
178 struct vmxnet3_rxq_stats stats;
179 const struct rte_memzone *mz;
181 uint16_t queue_id; /**< Device RX queue index. */
182 uint8_t port_id; /**< Device port identifier. */
183 } vmxnet3_rx_queue_t;
185 #endif /* _VMXNET3_RING_H_ */