xref: /dpdk/drivers/net/thunderx/nicvf_struct.h (revision 6d76fde7dba39769c64bee03b62593cc66a1b0e3)
1e4387966SJerin Jacob /*
2e4387966SJerin Jacob  *   BSD LICENSE
3e4387966SJerin Jacob  *
4e4387966SJerin Jacob  *   Copyright (C) Cavium networks Ltd. 2016.
5e4387966SJerin Jacob  *
6e4387966SJerin Jacob  *   Redistribution and use in source and binary forms, with or without
7e4387966SJerin Jacob  *   modification, are permitted provided that the following conditions
8e4387966SJerin Jacob  *   are met:
9e4387966SJerin Jacob  *
10e4387966SJerin Jacob  *     * Redistributions of source code must retain the above copyright
11e4387966SJerin Jacob  *       notice, this list of conditions and the following disclaimer.
12e4387966SJerin Jacob  *     * Redistributions in binary form must reproduce the above copyright
13e4387966SJerin Jacob  *       notice, this list of conditions and the following disclaimer in
14e4387966SJerin Jacob  *       the documentation and/or other materials provided with the
15e4387966SJerin Jacob  *       distribution.
16e4387966SJerin Jacob  *     * Neither the name of Cavium networks nor the names of its
17e4387966SJerin Jacob  *       contributors may be used to endorse or promote products derived
18e4387966SJerin Jacob  *       from this software without specific prior written permission.
19e4387966SJerin Jacob  *
20e4387966SJerin Jacob  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21e4387966SJerin Jacob  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22e4387966SJerin Jacob  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23e4387966SJerin Jacob  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24e4387966SJerin Jacob  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25e4387966SJerin Jacob  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26e4387966SJerin Jacob  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27e4387966SJerin Jacob  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28e4387966SJerin Jacob  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29e4387966SJerin Jacob  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30e4387966SJerin Jacob  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31e4387966SJerin Jacob  */
32e4387966SJerin Jacob 
33e4387966SJerin Jacob #ifndef _THUNDERX_NICVF_STRUCT_H
34e4387966SJerin Jacob #define _THUNDERX_NICVF_STRUCT_H
35e4387966SJerin Jacob 
36e4387966SJerin Jacob #include <stdint.h>
37e4387966SJerin Jacob 
38e4387966SJerin Jacob #include <rte_spinlock.h>
39e4387966SJerin Jacob #include <rte_mempool.h>
40e4387966SJerin Jacob #include <rte_mbuf.h>
41e4387966SJerin Jacob #include <rte_interrupts.h>
42e4387966SJerin Jacob #include <rte_ethdev.h>
43e4387966SJerin Jacob #include <rte_memory.h>
44e4387966SJerin Jacob 
45e4387966SJerin Jacob struct nicvf_rbdr {
46*6d76fde7SJerin Jacob 	uintptr_t rbdr_status;
47*6d76fde7SJerin Jacob 	uintptr_t rbdr_door;
48e4387966SJerin Jacob 	struct rbdr_entry_t *desc;
49e4387966SJerin Jacob 	nicvf_phys_addr_t phys;
50e4387966SJerin Jacob 	uint32_t buffsz;
51e4387966SJerin Jacob 	uint32_t tail;
52e4387966SJerin Jacob 	uint32_t next_tail;
53e4387966SJerin Jacob 	uint32_t head;
54e4387966SJerin Jacob 	uint32_t qlen_mask;
55e4387966SJerin Jacob } __rte_cache_aligned;
56e4387966SJerin Jacob 
57e4387966SJerin Jacob struct nicvf_txq {
58e4387966SJerin Jacob 	union sq_entry_t *desc;
59e4387966SJerin Jacob 	nicvf_phys_addr_t phys;
60e4387966SJerin Jacob 	struct rte_mbuf **txbuffs;
61*6d76fde7SJerin Jacob 	uintptr_t sq_head;
62*6d76fde7SJerin Jacob 	uintptr_t sq_door;
63e4387966SJerin Jacob 	struct rte_mempool *pool;
64e4387966SJerin Jacob 	struct nicvf *nic;
65e4387966SJerin Jacob 	void (*pool_free)(struct nicvf_txq *sq);
66e4387966SJerin Jacob 	uint32_t head;
67e4387966SJerin Jacob 	uint32_t tail;
68e4387966SJerin Jacob 	int32_t xmit_bufs;
69e4387966SJerin Jacob 	uint32_t qlen_mask;
70e4387966SJerin Jacob 	uint32_t txq_flags;
71e4387966SJerin Jacob 	uint16_t queue_id;
72e4387966SJerin Jacob 	uint16_t tx_free_thresh;
73e4387966SJerin Jacob } __rte_cache_aligned;
74e4387966SJerin Jacob 
75e4387966SJerin Jacob struct nicvf_rxq {
76e4387966SJerin Jacob 	uint64_t mbuf_phys_off;
77*6d76fde7SJerin Jacob 	uintptr_t cq_status;
78*6d76fde7SJerin Jacob 	uintptr_t cq_door;
79e4387966SJerin Jacob 	nicvf_phys_addr_t phys;
80e4387966SJerin Jacob 	union cq_entry_t *desc;
81e4387966SJerin Jacob 	struct nicvf_rbdr *shared_rbdr;
82e4387966SJerin Jacob 	struct nicvf *nic;
83e4387966SJerin Jacob 	struct rte_mempool *pool;
84e4387966SJerin Jacob 	uint32_t head;
85e4387966SJerin Jacob 	uint32_t qlen_mask;
86e4387966SJerin Jacob 	int32_t available_space;
87e4387966SJerin Jacob 	int32_t recv_buffers;
88e4387966SJerin Jacob 	uint16_t rx_free_thresh;
89e4387966SJerin Jacob 	uint16_t queue_id;
90e4387966SJerin Jacob 	uint16_t precharge_cnt;
91e4387966SJerin Jacob 	uint8_t rx_drop_en;
92e4387966SJerin Jacob 	uint8_t  port_id;
93e4387966SJerin Jacob 	uint8_t  rbptr_offset;
94e4387966SJerin Jacob } __rte_cache_aligned;
95e4387966SJerin Jacob 
96e4387966SJerin Jacob struct nicvf {
97e4387966SJerin Jacob 	uint8_t vf_id;
98e4387966SJerin Jacob 	uint8_t node;
99e4387966SJerin Jacob 	uintptr_t reg_base;
100e4387966SJerin Jacob 	bool tns_mode;
101e4387966SJerin Jacob 	bool sqs_mode;
102e4387966SJerin Jacob 	bool loopback_supported;
103e4387966SJerin Jacob 	bool pf_acked:1;
104e4387966SJerin Jacob 	bool pf_nacked:1;
105e4387966SJerin Jacob 	uint64_t hwcap;
106e4387966SJerin Jacob 	uint8_t link_up;
107e4387966SJerin Jacob 	uint8_t	duplex;
108e4387966SJerin Jacob 	uint32_t speed;
109e4387966SJerin Jacob 	uint32_t msg_enable;
110e4387966SJerin Jacob 	uint16_t device_id;
111e4387966SJerin Jacob 	uint16_t vendor_id;
112e4387966SJerin Jacob 	uint16_t subsystem_device_id;
113e4387966SJerin Jacob 	uint16_t subsystem_vendor_id;
114e4387966SJerin Jacob 	struct nicvf_rbdr *rbdr;
115e4387966SJerin Jacob 	struct nicvf_rss_reta_info rss_info;
116e4387966SJerin Jacob 	struct rte_intr_handle intr_handle;
117e4387966SJerin Jacob 	uint8_t cpi_alg;
118e4387966SJerin Jacob 	uint16_t mtu;
119e4387966SJerin Jacob 	bool vlan_filter_en;
120e4387966SJerin Jacob 	uint8_t mac_addr[ETHER_ADDR_LEN];
12110b0e74fSKamil Rytarowski 	/* secondary queue set support */
12210b0e74fSKamil Rytarowski 	uint8_t sqs_id;
12310b0e74fSKamil Rytarowski 	uint8_t sqs_count;
12410b0e74fSKamil Rytarowski #define MAX_SQS_PER_VF 11
12510b0e74fSKamil Rytarowski 	struct nicvf *snicvf[MAX_SQS_PER_VF];
126e4387966SJerin Jacob } __rte_cache_aligned;
127e4387966SJerin Jacob 
128e4387966SJerin Jacob #endif /* _THUNDERX_NICVF_STRUCT_H */
129