1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef _VMXNET3_RING_H_
6 #define _VMXNET3_RING_H_
8 #define VMXNET3_RX_CMDRING_SIZE 2
10 #define VMXNET3_DRIVER_VERSION_NUM 0x01012000
12 /* Default ring size */
13 #define VMXNET3_DEF_TX_RING_SIZE 512
14 #define VMXNET3_DEF_RX_RING_SIZE 128
16 /* Default rx data ring desc size */
17 #define VMXNET3_DEF_RXDATA_DESC_SIZE 256
19 #define VMXNET3_SUCCESS 0
20 #define VMXNET3_FAIL -1
26 typedef struct vmxnet3_buf_info {
32 typedef struct vmxnet3_cmd_ring {
33 vmxnet3_buf_info_t *buf_info;
39 Vmxnet3_GenericDesc *base;
44 vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring)
47 if (unlikely(ring->next2fill == ring->size)) {
49 ring->gen = (uint8_t)(ring->gen ^ 1);
54 vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring)
56 VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size);
59 static inline uint32_t
60 vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring)
62 return (ring->next2comp > ring->next2fill ? 0 : ring->size) +
63 ring->next2comp - ring->next2fill - 1;
67 vmxnet3_cmd_ring_desc_empty(struct vmxnet3_cmd_ring *ring)
69 return ring->next2comp == ring->next2fill;
72 typedef struct vmxnet3_comp_ring {
77 Vmxnet3_GenericDesc *base;
79 } vmxnet3_comp_ring_t;
81 struct vmxnet3_data_ring {
82 struct Vmxnet3_TxDataDesc *base;
88 vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring)
91 if (unlikely(ring->next2proc == ring->size)) {
93 ring->gen = (uint8_t)(ring->gen ^ 1);
97 struct vmxnet3_txq_stats {
98 uint64_t drop_total; /* # of pkts dropped by the driver,
99 * the counters below track droppings due to
102 uint64_t drop_too_many_segs;
104 uint64_t tx_ring_full;
107 typedef struct vmxnet3_tx_queue {
108 struct vmxnet3_hw *hw;
109 struct vmxnet3_cmd_ring cmd_ring;
110 struct vmxnet3_comp_ring comp_ring;
111 struct vmxnet3_data_ring data_ring;
113 struct Vmxnet3_TxQueueDesc *shared;
114 struct vmxnet3_txq_stats stats;
115 const struct rte_memzone *mz;
117 uint16_t queue_id; /**< Device TX queue index. */
118 uint16_t port_id; /**< Device port identifier. */
119 uint16_t txdata_desc_size;
120 } vmxnet3_tx_queue_t;
122 struct vmxnet3_rxq_stats {
126 uint64_t rx_buf_alloc_failure;
129 struct vmxnet3_rx_data_ring {
135 typedef struct vmxnet3_rx_queue {
136 struct rte_mempool *mp;
137 struct vmxnet3_hw *hw;
138 struct vmxnet3_cmd_ring cmd_ring[VMXNET3_RX_CMDRING_SIZE];
139 struct vmxnet3_comp_ring comp_ring;
140 struct vmxnet3_rx_data_ring data_ring;
141 uint16_t data_desc_size;
144 /* rqID in RCD for buffer from data ring */
145 uint32_t data_ring_qid;
146 Vmxnet3_RxQueueDesc *shared;
147 struct rte_mbuf *start_seg;
148 struct rte_mbuf *last_seg;
149 struct vmxnet3_rxq_stats stats;
150 const struct rte_memzone *mz;
152 uint16_t queue_id; /**< Device RX queue index. */
153 uint16_t port_id; /**< Device port identifier. */
154 } vmxnet3_rx_queue_t;
156 #endif /* _VMXNET3_RING_H_ */