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 #define VMXNET3_SUCCESS 0
46 #define VMXNET3_FAIL -1
52 typedef struct vmxnet3_buf_info {
58 typedef struct vmxnet3_cmd_ring {
59 vmxnet3_buf_info_t *buf_info;
65 Vmxnet3_GenericDesc *base;
70 vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring)
73 if (unlikely(ring->next2fill == ring->size)) {
75 ring->gen = (uint8_t)(ring->gen ^ 1);
80 vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring)
82 VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size);
85 static inline uint32_t
86 vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring)
88 return (ring->next2comp > ring->next2fill ? 0 : ring->size) +
89 ring->next2comp - ring->next2fill - 1;
93 vmxnet3_cmd_ring_desc_empty(struct vmxnet3_cmd_ring *ring)
95 return ring->next2comp == ring->next2fill;
98 typedef struct vmxnet3_comp_ring {
103 Vmxnet3_GenericDesc *base;
105 } vmxnet3_comp_ring_t;
107 struct vmxnet3_data_ring {
108 struct Vmxnet3_TxDataDesc *base;
114 vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring)
117 if (unlikely(ring->next2proc == ring->size)) {
119 ring->gen = (uint8_t)(ring->gen ^ 1);
123 struct vmxnet3_txq_stats {
124 uint64_t drop_total; /* # of pkts dropped by the driver,
125 * the counters below track droppings due to
128 uint64_t drop_too_many_segs;
130 uint64_t tx_ring_full;
133 typedef struct vmxnet3_tx_queue {
134 struct vmxnet3_hw *hw;
135 struct vmxnet3_cmd_ring cmd_ring;
136 struct vmxnet3_comp_ring comp_ring;
137 struct vmxnet3_data_ring data_ring;
139 struct Vmxnet3_TxQueueDesc *shared;
140 struct vmxnet3_txq_stats stats;
142 uint16_t queue_id; /**< Device TX queue index. */
143 uint8_t port_id; /**< Device port identifier. */
144 } vmxnet3_tx_queue_t;
146 struct vmxnet3_rxq_stats {
150 uint64_t rx_buf_alloc_failure;
153 typedef struct vmxnet3_rx_queue {
154 struct rte_mempool *mp;
155 struct vmxnet3_hw *hw;
156 struct vmxnet3_cmd_ring cmd_ring[VMXNET3_RX_CMDRING_SIZE];
157 struct vmxnet3_comp_ring comp_ring;
160 Vmxnet3_RxQueueDesc *shared;
161 struct rte_mbuf *start_seg;
162 struct rte_mbuf *last_seg;
163 struct vmxnet3_rxq_stats stats;
165 uint16_t queue_id; /**< Device RX queue index. */
166 uint8_t port_id; /**< Device port identifier. */
167 } vmxnet3_rx_queue_t;
169 #endif /* _VMXNET3_RING_H_ */