2014-02-10 15:27:26 +00:00
|
|
|
/*-
|
|
|
|
* BSD LICENSE
|
2014-06-03 23:42:50 +00:00
|
|
|
*
|
2014-02-10 15:27:26 +00:00
|
|
|
* Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
|
|
|
|
* All rights reserved.
|
2014-06-03 23:42:50 +00:00
|
|
|
*
|
2014-02-10 15:27:26 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2014-06-03 23:42:50 +00:00
|
|
|
*
|
2014-02-10 15:27:26 +00:00
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* * Neither the name of Intel Corporation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
2014-06-03 23:42:50 +00:00
|
|
|
*
|
2014-02-10 15:27:26 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _VMXNET3_RING_H_
|
|
|
|
#define _VMXNET3_RING_H_
|
|
|
|
|
2014-06-03 23:42:50 +00:00
|
|
|
#define VMXNET3_RX_CMDRING_SIZE 2
|
2014-02-10 15:27:26 +00:00
|
|
|
|
2014-06-03 23:42:50 +00:00
|
|
|
#define VMXNET3_DRIVER_VERSION_NUM 0x01012000
|
2014-02-10 15:27:26 +00:00
|
|
|
|
|
|
|
/* Default ring size */
|
2014-06-03 23:42:50 +00:00
|
|
|
#define VMXNET3_DEF_TX_RING_SIZE 512
|
|
|
|
#define VMXNET3_DEF_RX_RING_SIZE 128
|
2014-02-10 15:27:26 +00:00
|
|
|
|
2017-03-06 22:55:04 +00:00
|
|
|
/* Default rx data ring desc size */
|
|
|
|
#define VMXNET3_DEF_RXDATA_DESC_SIZE 128
|
|
|
|
|
2014-06-03 23:42:50 +00:00
|
|
|
#define VMXNET3_SUCCESS 0
|
|
|
|
#define VMXNET3_FAIL -1
|
2014-02-10 15:27:26 +00:00
|
|
|
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct vmxnet3_buf_info {
|
|
|
|
uint16_t len;
|
2014-11-05 01:49:43 +00:00
|
|
|
struct rte_mbuf *m;
|
|
|
|
uint64_t bufPA;
|
|
|
|
} vmxnet3_buf_info_t;
|
2014-02-10 15:27:26 +00:00
|
|
|
|
|
|
|
typedef struct vmxnet3_cmd_ring {
|
|
|
|
vmxnet3_buf_info_t *buf_info;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t next2fill;
|
|
|
|
uint32_t next2comp;
|
|
|
|
uint8_t gen;
|
|
|
|
uint8_t rid;
|
|
|
|
Vmxnet3_GenericDesc *base;
|
|
|
|
uint64_t basePA;
|
|
|
|
} vmxnet3_cmd_ring_t;
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
vmxnet3_cmd_ring_adv_next2fill(struct vmxnet3_cmd_ring *ring)
|
|
|
|
{
|
|
|
|
ring->next2fill++;
|
|
|
|
if (unlikely(ring->next2fill == ring->size)) {
|
|
|
|
ring->next2fill = 0;
|
|
|
|
ring->gen = (uint8_t)(ring->gen ^ 1);
|
2014-06-03 23:42:50 +00:00
|
|
|
}
|
2014-02-10 15:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
vmxnet3_cmd_ring_adv_next2comp(struct vmxnet3_cmd_ring *ring)
|
|
|
|
{
|
2014-06-13 01:37:04 +00:00
|
|
|
VMXNET3_INC_RING_IDX_ONLY(ring->next2comp, ring->size);
|
2014-02-10 15:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
|
|
|
vmxnet3_cmd_ring_desc_avail(struct vmxnet3_cmd_ring *ring)
|
|
|
|
{
|
|
|
|
return (ring->next2comp > ring->next2fill ? 0 : ring->size) +
|
|
|
|
ring->next2comp - ring->next2fill - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
vmxnet3_cmd_ring_desc_empty(struct vmxnet3_cmd_ring *ring)
|
|
|
|
{
|
2016-01-27 13:58:30 +00:00
|
|
|
return ring->next2comp == ring->next2fill;
|
2014-02-10 15:27:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct vmxnet3_comp_ring {
|
2016-08-29 19:18:46 +00:00
|
|
|
uint32_t size;
|
|
|
|
uint32_t next2proc;
|
|
|
|
uint8_t gen;
|
|
|
|
uint8_t intr_idx;
|
2014-02-10 15:27:26 +00:00
|
|
|
Vmxnet3_GenericDesc *base;
|
2016-08-29 19:18:46 +00:00
|
|
|
uint64_t basePA;
|
2014-02-10 15:27:26 +00:00
|
|
|
} vmxnet3_comp_ring_t;
|
|
|
|
|
2014-11-05 01:49:43 +00:00
|
|
|
struct vmxnet3_data_ring {
|
|
|
|
struct Vmxnet3_TxDataDesc *base;
|
|
|
|
uint32_t size;
|
|
|
|
uint64_t basePA;
|
|
|
|
};
|
|
|
|
|
2014-02-10 15:27:26 +00:00
|
|
|
static inline void
|
|
|
|
vmxnet3_comp_ring_adv_next2proc(struct vmxnet3_comp_ring *ring)
|
|
|
|
{
|
|
|
|
ring->next2proc++;
|
|
|
|
if (unlikely(ring->next2proc == ring->size)) {
|
|
|
|
ring->next2proc = 0;
|
|
|
|
ring->gen = (uint8_t)(ring->gen ^ 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct vmxnet3_txq_stats {
|
2016-08-29 19:18:46 +00:00
|
|
|
uint64_t drop_total; /* # of pkts dropped by the driver,
|
2015-07-09 18:24:11 +00:00
|
|
|
* the counters below track droppings due to
|
|
|
|
* different reasons
|
|
|
|
*/
|
2016-08-29 19:18:46 +00:00
|
|
|
uint64_t drop_too_many_segs;
|
|
|
|
uint64_t drop_tso;
|
|
|
|
uint64_t tx_ring_full;
|
2014-02-10 15:27:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct vmxnet3_tx_queue {
|
2014-06-03 23:42:50 +00:00
|
|
|
struct vmxnet3_hw *hw;
|
2014-02-10 15:27:26 +00:00
|
|
|
struct vmxnet3_cmd_ring cmd_ring;
|
|
|
|
struct vmxnet3_comp_ring comp_ring;
|
2014-11-05 01:49:43 +00:00
|
|
|
struct vmxnet3_data_ring data_ring;
|
2014-02-10 15:27:26 +00:00
|
|
|
uint32_t qid;
|
|
|
|
struct Vmxnet3_TxQueueDesc *shared;
|
|
|
|
struct vmxnet3_txq_stats stats;
|
2017-03-15 12:35:10 +00:00
|
|
|
const struct rte_memzone *mz;
|
2014-02-10 15:27:26 +00:00
|
|
|
bool stopped;
|
2014-06-03 23:42:50 +00:00
|
|
|
uint16_t queue_id; /**< Device TX queue index. */
|
|
|
|
uint8_t port_id; /**< Device port identifier. */
|
2017-03-06 22:55:03 +00:00
|
|
|
uint16_t txdata_desc_size;
|
2014-02-10 15:27:26 +00:00
|
|
|
} vmxnet3_tx_queue_t;
|
|
|
|
|
|
|
|
struct vmxnet3_rxq_stats {
|
|
|
|
uint64_t drop_total;
|
|
|
|
uint64_t drop_err;
|
|
|
|
uint64_t drop_fcs;
|
|
|
|
uint64_t rx_buf_alloc_failure;
|
|
|
|
};
|
|
|
|
|
2017-03-06 22:55:04 +00:00
|
|
|
struct vmxnet3_rx_data_ring {
|
|
|
|
uint8_t *base;
|
|
|
|
uint64_t basePA;
|
|
|
|
uint32_t size;
|
|
|
|
};
|
|
|
|
|
2014-02-10 15:27:26 +00:00
|
|
|
typedef struct vmxnet3_rx_queue {
|
2014-06-03 23:42:50 +00:00
|
|
|
struct rte_mempool *mp;
|
|
|
|
struct vmxnet3_hw *hw;
|
2014-02-10 15:27:26 +00:00
|
|
|
struct vmxnet3_cmd_ring cmd_ring[VMXNET3_RX_CMDRING_SIZE];
|
|
|
|
struct vmxnet3_comp_ring comp_ring;
|
2017-03-06 22:55:04 +00:00
|
|
|
struct vmxnet3_rx_data_ring data_ring;
|
|
|
|
uint16_t data_desc_size;
|
2014-02-10 15:27:26 +00:00
|
|
|
uint32_t qid1;
|
|
|
|
uint32_t qid2;
|
2017-03-06 22:55:04 +00:00
|
|
|
/* rqID in RCD for buffer from data ring */
|
|
|
|
uint32_t data_ring_qid;
|
2014-02-10 15:27:26 +00:00
|
|
|
Vmxnet3_RxQueueDesc *shared;
|
2016-08-29 19:18:46 +00:00
|
|
|
struct rte_mbuf *start_seg;
|
|
|
|
struct rte_mbuf *last_seg;
|
2014-02-10 15:27:26 +00:00
|
|
|
struct vmxnet3_rxq_stats stats;
|
2017-03-15 12:35:10 +00:00
|
|
|
const struct rte_memzone *mz;
|
2014-02-10 15:27:26 +00:00
|
|
|
bool stopped;
|
2014-06-03 23:42:50 +00:00
|
|
|
uint16_t queue_id; /**< Device RX queue index. */
|
|
|
|
uint8_t port_id; /**< Device port identifier. */
|
2014-02-10 15:27:26 +00:00
|
|
|
} vmxnet3_rx_queue_t;
|
|
|
|
|
|
|
|
#endif /* _VMXNET3_RING_H_ */
|