xref: /f-stack/dpdk/drivers/net/liquidio/lio_struct.h (revision d30ea906)
1*d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2*d30ea906Sjfb8856606  * Copyright(c) 2017 Cavium, Inc
32bfe3f2eSlogwang  */
42bfe3f2eSlogwang 
52bfe3f2eSlogwang #ifndef _LIO_STRUCT_H_
62bfe3f2eSlogwang #define _LIO_STRUCT_H_
72bfe3f2eSlogwang 
82bfe3f2eSlogwang #include <stdio.h>
92bfe3f2eSlogwang #include <stdint.h>
102bfe3f2eSlogwang #include <sys/queue.h>
112bfe3f2eSlogwang 
122bfe3f2eSlogwang #include <rte_spinlock.h>
132bfe3f2eSlogwang #include <rte_atomic.h>
142bfe3f2eSlogwang 
152bfe3f2eSlogwang #include "lio_hw_defs.h"
162bfe3f2eSlogwang 
172bfe3f2eSlogwang struct lio_stailq_node {
182bfe3f2eSlogwang 	STAILQ_ENTRY(lio_stailq_node) entries;
192bfe3f2eSlogwang };
202bfe3f2eSlogwang 
212bfe3f2eSlogwang STAILQ_HEAD(lio_stailq_head, lio_stailq_node);
222bfe3f2eSlogwang 
232bfe3f2eSlogwang struct lio_version {
242bfe3f2eSlogwang 	uint16_t major;
252bfe3f2eSlogwang 	uint16_t minor;
262bfe3f2eSlogwang 	uint16_t micro;
272bfe3f2eSlogwang 	uint16_t reserved;
282bfe3f2eSlogwang };
292bfe3f2eSlogwang 
302bfe3f2eSlogwang /** Input Queue statistics. Each input queue has four stats fields. */
312bfe3f2eSlogwang struct lio_iq_stats {
322bfe3f2eSlogwang 	uint64_t instr_posted; /**< Instructions posted to this queue. */
332bfe3f2eSlogwang 	uint64_t instr_processed; /**< Instructions processed in this queue. */
342bfe3f2eSlogwang 	uint64_t instr_dropped; /**< Instructions that could not be processed */
352bfe3f2eSlogwang 	uint64_t bytes_sent; /**< Bytes sent through this queue. */
362bfe3f2eSlogwang 	uint64_t tx_done; /**< Num of packets sent to network. */
372bfe3f2eSlogwang 	uint64_t tx_iq_busy; /**< Num of times this iq was found to be full. */
382bfe3f2eSlogwang 	uint64_t tx_dropped; /**< Num of pkts dropped due to xmitpath errors. */
392bfe3f2eSlogwang 	uint64_t tx_tot_bytes; /**< Total count of bytes sent to network. */
402bfe3f2eSlogwang };
412bfe3f2eSlogwang 
422bfe3f2eSlogwang /** Output Queue statistics. Each output queue has four stats fields. */
432bfe3f2eSlogwang struct lio_droq_stats {
442bfe3f2eSlogwang 	/** Number of packets received in this queue. */
452bfe3f2eSlogwang 	uint64_t pkts_received;
462bfe3f2eSlogwang 
472bfe3f2eSlogwang 	/** Bytes received by this queue. */
482bfe3f2eSlogwang 	uint64_t bytes_received;
492bfe3f2eSlogwang 
502bfe3f2eSlogwang 	/** Packets dropped due to no memory available. */
512bfe3f2eSlogwang 	uint64_t dropped_nomem;
522bfe3f2eSlogwang 
532bfe3f2eSlogwang 	/** Packets dropped due to large number of pkts to process. */
542bfe3f2eSlogwang 	uint64_t dropped_toomany;
552bfe3f2eSlogwang 
562bfe3f2eSlogwang 	/** Number of packets  sent to stack from this queue. */
572bfe3f2eSlogwang 	uint64_t rx_pkts_received;
582bfe3f2eSlogwang 
592bfe3f2eSlogwang 	/** Number of Bytes sent to stack from this queue. */
602bfe3f2eSlogwang 	uint64_t rx_bytes_received;
612bfe3f2eSlogwang 
622bfe3f2eSlogwang 	/** Num of Packets dropped due to receive path failures. */
632bfe3f2eSlogwang 	uint64_t rx_dropped;
642bfe3f2eSlogwang 
652bfe3f2eSlogwang 	/** Num of vxlan packets received; */
662bfe3f2eSlogwang 	uint64_t rx_vxlan;
672bfe3f2eSlogwang 
682bfe3f2eSlogwang 	/** Num of failures of rte_pktmbuf_alloc() */
692bfe3f2eSlogwang 	uint64_t rx_alloc_failure;
702bfe3f2eSlogwang 
712bfe3f2eSlogwang };
722bfe3f2eSlogwang 
732bfe3f2eSlogwang /** The Descriptor Ring Output Queue structure.
742bfe3f2eSlogwang  *  This structure has all the information required to implement a
752bfe3f2eSlogwang  *  DROQ.
762bfe3f2eSlogwang  */
772bfe3f2eSlogwang struct lio_droq {
782bfe3f2eSlogwang 	/** A spinlock to protect access to this ring. */
792bfe3f2eSlogwang 	rte_spinlock_t lock;
802bfe3f2eSlogwang 
812bfe3f2eSlogwang 	uint32_t q_no;
822bfe3f2eSlogwang 
832bfe3f2eSlogwang 	uint32_t pkt_count;
842bfe3f2eSlogwang 
852bfe3f2eSlogwang 	struct lio_device *lio_dev;
862bfe3f2eSlogwang 
872bfe3f2eSlogwang 	/** The 8B aligned descriptor ring starts at this address. */
882bfe3f2eSlogwang 	struct lio_droq_desc *desc_ring;
892bfe3f2eSlogwang 
902bfe3f2eSlogwang 	/** Index in the ring where the driver should read the next packet */
912bfe3f2eSlogwang 	uint32_t read_idx;
922bfe3f2eSlogwang 
932bfe3f2eSlogwang 	/** Index in the ring where Octeon will write the next packet */
942bfe3f2eSlogwang 	uint32_t write_idx;
952bfe3f2eSlogwang 
962bfe3f2eSlogwang 	/** Index in the ring where the driver will refill the descriptor's
972bfe3f2eSlogwang 	 * buffer
982bfe3f2eSlogwang 	 */
992bfe3f2eSlogwang 	uint32_t refill_idx;
1002bfe3f2eSlogwang 
1012bfe3f2eSlogwang 	/** Packets pending to be processed */
1022bfe3f2eSlogwang 	rte_atomic64_t pkts_pending;
1032bfe3f2eSlogwang 
1042bfe3f2eSlogwang 	/** Number of  descriptors in this ring. */
105*d30ea906Sjfb8856606 	uint32_t nb_desc;
1062bfe3f2eSlogwang 
1072bfe3f2eSlogwang 	/** The number of descriptors pending refill. */
1082bfe3f2eSlogwang 	uint32_t refill_count;
1092bfe3f2eSlogwang 
1102bfe3f2eSlogwang 	uint32_t refill_threshold;
1112bfe3f2eSlogwang 
1122bfe3f2eSlogwang 	/** The 8B aligned info ptrs begin from this address. */
1132bfe3f2eSlogwang 	struct lio_droq_info *info_list;
1142bfe3f2eSlogwang 
1152bfe3f2eSlogwang 	/** The receive buffer list. This list has the virtual addresses of the
1162bfe3f2eSlogwang 	 *  buffers.
1172bfe3f2eSlogwang 	 */
1182bfe3f2eSlogwang 	struct lio_recv_buffer *recv_buf_list;
1192bfe3f2eSlogwang 
1202bfe3f2eSlogwang 	/** The size of each buffer pointed by the buffer pointer. */
1212bfe3f2eSlogwang 	uint32_t buffer_size;
1222bfe3f2eSlogwang 
1232bfe3f2eSlogwang 	/** Pointer to the mapped packet credit register.
1242bfe3f2eSlogwang 	 *  Host writes number of info/buffer ptrs available to this register
1252bfe3f2eSlogwang 	 */
1262bfe3f2eSlogwang 	void *pkts_credit_reg;
1272bfe3f2eSlogwang 
1282bfe3f2eSlogwang 	/** Pointer to the mapped packet sent register.
1292bfe3f2eSlogwang 	 *  Octeon writes the number of packets DMA'ed to host memory
1302bfe3f2eSlogwang 	 *  in this register.
1312bfe3f2eSlogwang 	 */
1322bfe3f2eSlogwang 	void *pkts_sent_reg;
1332bfe3f2eSlogwang 
1342bfe3f2eSlogwang 	/** Statistics for this DROQ. */
1352bfe3f2eSlogwang 	struct lio_droq_stats stats;
1362bfe3f2eSlogwang 
1372bfe3f2eSlogwang 	/** DMA mapped address of the DROQ descriptor ring. */
1382bfe3f2eSlogwang 	size_t desc_ring_dma;
1392bfe3f2eSlogwang 
1402bfe3f2eSlogwang 	/** Info ptr list are allocated at this virtual address. */
1412bfe3f2eSlogwang 	size_t info_base_addr;
1422bfe3f2eSlogwang 
1432bfe3f2eSlogwang 	/** DMA mapped address of the info list */
1442bfe3f2eSlogwang 	size_t info_list_dma;
1452bfe3f2eSlogwang 
1462bfe3f2eSlogwang 	/** Allocated size of info list. */
1472bfe3f2eSlogwang 	uint32_t info_alloc_size;
1482bfe3f2eSlogwang 
1492bfe3f2eSlogwang 	/** Memory zone **/
1502bfe3f2eSlogwang 	const struct rte_memzone *desc_ring_mz;
1512bfe3f2eSlogwang 	const struct rte_memzone *info_mz;
1522bfe3f2eSlogwang 	struct rte_mempool *mpool;
1532bfe3f2eSlogwang };
1542bfe3f2eSlogwang 
1552bfe3f2eSlogwang /** Receive Header */
1562bfe3f2eSlogwang union octeon_rh {
1572bfe3f2eSlogwang #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
1582bfe3f2eSlogwang 	uint64_t rh64;
1592bfe3f2eSlogwang 	struct	{
1602bfe3f2eSlogwang 		uint64_t opcode : 4;
1612bfe3f2eSlogwang 		uint64_t subcode : 8;
1622bfe3f2eSlogwang 		uint64_t len : 3; /** additional 64-bit words */
1632bfe3f2eSlogwang 		uint64_t reserved : 17;
1642bfe3f2eSlogwang 		uint64_t ossp : 32; /** opcode/subcode specific parameters */
1652bfe3f2eSlogwang 	} r;
1662bfe3f2eSlogwang 	struct	{
1672bfe3f2eSlogwang 		uint64_t opcode : 4;
1682bfe3f2eSlogwang 		uint64_t subcode : 8;
1692bfe3f2eSlogwang 		uint64_t len : 3; /** additional 64-bit words */
1702bfe3f2eSlogwang 		uint64_t extra : 28;
1712bfe3f2eSlogwang 		uint64_t vlan : 12;
1722bfe3f2eSlogwang 		uint64_t priority : 3;
1732bfe3f2eSlogwang 		uint64_t csum_verified : 3; /** checksum verified. */
1742bfe3f2eSlogwang 		uint64_t has_hwtstamp : 1; /** Has hardware timestamp.1 = yes.*/
1752bfe3f2eSlogwang 		uint64_t encap_on : 1;
1762bfe3f2eSlogwang 		uint64_t has_hash : 1; /** Has hash (rth or rss). 1 = yes. */
1772bfe3f2eSlogwang 	} r_dh;
1782bfe3f2eSlogwang 	struct {
1792bfe3f2eSlogwang 		uint64_t opcode : 4;
1802bfe3f2eSlogwang 		uint64_t subcode : 8;
1812bfe3f2eSlogwang 		uint64_t len : 3; /** additional 64-bit words */
1822bfe3f2eSlogwang 		uint64_t reserved : 8;
1832bfe3f2eSlogwang 		uint64_t extra : 25;
1842bfe3f2eSlogwang 		uint64_t gmxport : 16;
1852bfe3f2eSlogwang 	} r_nic_info;
1862bfe3f2eSlogwang #else
1872bfe3f2eSlogwang 	uint64_t rh64;
1882bfe3f2eSlogwang 	struct {
1892bfe3f2eSlogwang 		uint64_t ossp : 32; /** opcode/subcode specific parameters */
1902bfe3f2eSlogwang 		uint64_t reserved : 17;
1912bfe3f2eSlogwang 		uint64_t len : 3; /** additional 64-bit words */
1922bfe3f2eSlogwang 		uint64_t subcode : 8;
1932bfe3f2eSlogwang 		uint64_t opcode : 4;
1942bfe3f2eSlogwang 	} r;
1952bfe3f2eSlogwang 	struct {
1962bfe3f2eSlogwang 		uint64_t has_hash : 1; /** Has hash (rth or rss). 1 = yes. */
1972bfe3f2eSlogwang 		uint64_t encap_on : 1;
1982bfe3f2eSlogwang 		uint64_t has_hwtstamp : 1;  /** 1 = has hwtstamp */
1992bfe3f2eSlogwang 		uint64_t csum_verified : 3; /** checksum verified. */
2002bfe3f2eSlogwang 		uint64_t priority : 3;
2012bfe3f2eSlogwang 		uint64_t vlan : 12;
2022bfe3f2eSlogwang 		uint64_t extra : 28;
2032bfe3f2eSlogwang 		uint64_t len : 3; /** additional 64-bit words */
2042bfe3f2eSlogwang 		uint64_t subcode : 8;
2052bfe3f2eSlogwang 		uint64_t opcode : 4;
2062bfe3f2eSlogwang 	} r_dh;
2072bfe3f2eSlogwang 	struct {
2082bfe3f2eSlogwang 		uint64_t gmxport : 16;
2092bfe3f2eSlogwang 		uint64_t extra : 25;
2102bfe3f2eSlogwang 		uint64_t reserved : 8;
2112bfe3f2eSlogwang 		uint64_t len : 3; /** additional 64-bit words */
2122bfe3f2eSlogwang 		uint64_t subcode : 8;
2132bfe3f2eSlogwang 		uint64_t opcode : 4;
2142bfe3f2eSlogwang 	} r_nic_info;
2152bfe3f2eSlogwang #endif
2162bfe3f2eSlogwang };
2172bfe3f2eSlogwang 
2182bfe3f2eSlogwang #define OCTEON_RH_SIZE (sizeof(union octeon_rh))
2192bfe3f2eSlogwang 
2202bfe3f2eSlogwang /** The txpciq info passed to host from the firmware */
2212bfe3f2eSlogwang union octeon_txpciq {
2222bfe3f2eSlogwang 	uint64_t txpciq64;
2232bfe3f2eSlogwang 
2242bfe3f2eSlogwang 	struct {
2252bfe3f2eSlogwang #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
2262bfe3f2eSlogwang 		uint64_t q_no : 8;
2272bfe3f2eSlogwang 		uint64_t port : 8;
2282bfe3f2eSlogwang 		uint64_t pkind : 6;
2292bfe3f2eSlogwang 		uint64_t use_qpg : 1;
2302bfe3f2eSlogwang 		uint64_t qpg : 11;
2312bfe3f2eSlogwang 		uint64_t aura_num : 10;
2322bfe3f2eSlogwang 		uint64_t reserved : 20;
2332bfe3f2eSlogwang #else
2342bfe3f2eSlogwang 		uint64_t reserved : 20;
2352bfe3f2eSlogwang 		uint64_t aura_num : 10;
2362bfe3f2eSlogwang 		uint64_t qpg : 11;
2372bfe3f2eSlogwang 		uint64_t use_qpg : 1;
2382bfe3f2eSlogwang 		uint64_t pkind : 6;
2392bfe3f2eSlogwang 		uint64_t port : 8;
2402bfe3f2eSlogwang 		uint64_t q_no : 8;
2412bfe3f2eSlogwang #endif
2422bfe3f2eSlogwang 	} s;
2432bfe3f2eSlogwang };
2442bfe3f2eSlogwang 
2452bfe3f2eSlogwang /** The instruction (input) queue.
2462bfe3f2eSlogwang  *  The input queue is used to post raw (instruction) mode data or packet
2472bfe3f2eSlogwang  *  data to Octeon device from the host. Each input queue for
2482bfe3f2eSlogwang  *  a LIO device has one such structure to represent it.
2492bfe3f2eSlogwang  */
2502bfe3f2eSlogwang struct lio_instr_queue {
2512bfe3f2eSlogwang 	/** A spinlock to protect access to the input ring.  */
2522bfe3f2eSlogwang 	rte_spinlock_t lock;
2532bfe3f2eSlogwang 
2542bfe3f2eSlogwang 	rte_spinlock_t post_lock;
2552bfe3f2eSlogwang 
2562bfe3f2eSlogwang 	struct lio_device *lio_dev;
2572bfe3f2eSlogwang 
2582bfe3f2eSlogwang 	uint32_t pkt_in_done;
2592bfe3f2eSlogwang 
2602bfe3f2eSlogwang 	rte_atomic64_t iq_flush_running;
2612bfe3f2eSlogwang 
2622bfe3f2eSlogwang 	/** Flag that indicates if the queue uses 64 byte commands. */
2632bfe3f2eSlogwang 	uint32_t iqcmd_64B:1;
2642bfe3f2eSlogwang 
2652bfe3f2eSlogwang 	/** Queue info. */
2662bfe3f2eSlogwang 	union octeon_txpciq txpciq;
2672bfe3f2eSlogwang 
2682bfe3f2eSlogwang 	uint32_t rsvd:17;
2692bfe3f2eSlogwang 
2702bfe3f2eSlogwang 	uint32_t status:8;
2712bfe3f2eSlogwang 
272*d30ea906Sjfb8856606 	/** Number of  descriptors in this ring. */
273*d30ea906Sjfb8856606 	uint32_t nb_desc;
2742bfe3f2eSlogwang 
2752bfe3f2eSlogwang 	/** Index in input ring where the driver should write the next packet */
2762bfe3f2eSlogwang 	uint32_t host_write_index;
2772bfe3f2eSlogwang 
2782bfe3f2eSlogwang 	/** Index in input ring where Octeon is expected to read the next
2792bfe3f2eSlogwang 	 *  packet.
2802bfe3f2eSlogwang 	 */
2812bfe3f2eSlogwang 	uint32_t lio_read_index;
2822bfe3f2eSlogwang 
2832bfe3f2eSlogwang 	/** This index aids in finding the window in the queue where Octeon
2842bfe3f2eSlogwang 	 *  has read the commands.
2852bfe3f2eSlogwang 	 */
2862bfe3f2eSlogwang 	uint32_t flush_index;
2872bfe3f2eSlogwang 
2882bfe3f2eSlogwang 	/** This field keeps track of the instructions pending in this queue. */
2892bfe3f2eSlogwang 	rte_atomic64_t instr_pending;
2902bfe3f2eSlogwang 
2912bfe3f2eSlogwang 	/** Pointer to the Virtual Base addr of the input ring. */
2922bfe3f2eSlogwang 	uint8_t *base_addr;
2932bfe3f2eSlogwang 
2942bfe3f2eSlogwang 	struct lio_request_list *request_list;
2952bfe3f2eSlogwang 
2962bfe3f2eSlogwang 	/** Octeon doorbell register for the ring. */
2972bfe3f2eSlogwang 	void *doorbell_reg;
2982bfe3f2eSlogwang 
2992bfe3f2eSlogwang 	/** Octeon instruction count register for this ring. */
3002bfe3f2eSlogwang 	void *inst_cnt_reg;
3012bfe3f2eSlogwang 
3022bfe3f2eSlogwang 	/** Number of instructions pending to be posted to Octeon. */
3032bfe3f2eSlogwang 	uint32_t fill_cnt;
3042bfe3f2eSlogwang 
3052bfe3f2eSlogwang 	/** Statistics for this input queue. */
3062bfe3f2eSlogwang 	struct lio_iq_stats stats;
3072bfe3f2eSlogwang 
3082bfe3f2eSlogwang 	/** DMA mapped base address of the input descriptor ring. */
3092bfe3f2eSlogwang 	uint64_t base_addr_dma;
3102bfe3f2eSlogwang 
3112bfe3f2eSlogwang 	/** Application context */
3122bfe3f2eSlogwang 	void *app_ctx;
3132bfe3f2eSlogwang 
3142bfe3f2eSlogwang 	/* network stack queue index */
3152bfe3f2eSlogwang 	int q_index;
3162bfe3f2eSlogwang 
3172bfe3f2eSlogwang 	/* Memory zone */
3182bfe3f2eSlogwang 	const struct rte_memzone *iq_mz;
3192bfe3f2eSlogwang };
3202bfe3f2eSlogwang 
3212bfe3f2eSlogwang /** This structure is used by driver to store information required
3222bfe3f2eSlogwang  *  to free the mbuff when the packet has been fetched by Octeon.
3232bfe3f2eSlogwang  *  Bytes offset below assume worst-case of a 64-bit system.
3242bfe3f2eSlogwang  */
3252bfe3f2eSlogwang struct lio_buf_free_info {
3262bfe3f2eSlogwang 	/** Bytes 1-8. Pointer to network device private structure. */
3272bfe3f2eSlogwang 	struct lio_device *lio_dev;
3282bfe3f2eSlogwang 
3292bfe3f2eSlogwang 	/** Bytes 9-16. Pointer to mbuff. */
3302bfe3f2eSlogwang 	struct rte_mbuf *mbuf;
3312bfe3f2eSlogwang 
3322bfe3f2eSlogwang 	/** Bytes 17-24. Pointer to gather list. */
3332bfe3f2eSlogwang 	struct lio_gather *g;
3342bfe3f2eSlogwang 
3352bfe3f2eSlogwang 	/** Bytes 25-32. Physical address of mbuf->data or gather list. */
3362bfe3f2eSlogwang 	uint64_t dptr;
3372bfe3f2eSlogwang 
3382bfe3f2eSlogwang 	/** Bytes 33-47. Piggybacked soft command, if any */
3392bfe3f2eSlogwang 	struct lio_soft_command *sc;
3402bfe3f2eSlogwang 
3412bfe3f2eSlogwang 	/** Bytes 48-63. iq no */
3422bfe3f2eSlogwang 	uint64_t iq_no;
3432bfe3f2eSlogwang };
3442bfe3f2eSlogwang 
3452bfe3f2eSlogwang /* The Scatter-Gather List Entry. The scatter or gather component used with
3462bfe3f2eSlogwang  * input instruction has this format.
3472bfe3f2eSlogwang  */
3482bfe3f2eSlogwang struct lio_sg_entry {
3492bfe3f2eSlogwang 	/** The first 64 bit gives the size of data in each dptr. */
3502bfe3f2eSlogwang 	union {
3512bfe3f2eSlogwang 		uint16_t size[4];
3522bfe3f2eSlogwang 		uint64_t size64;
3532bfe3f2eSlogwang 	} u;
3542bfe3f2eSlogwang 
3552bfe3f2eSlogwang 	/** The 4 dptr pointers for this entry. */
3562bfe3f2eSlogwang 	uint64_t ptr[4];
3572bfe3f2eSlogwang };
3582bfe3f2eSlogwang 
3592bfe3f2eSlogwang #define LIO_SG_ENTRY_SIZE	(sizeof(struct lio_sg_entry))
3602bfe3f2eSlogwang 
3612bfe3f2eSlogwang /** Structure of a node in list of gather components maintained by
3622bfe3f2eSlogwang  *  driver for each network device.
3632bfe3f2eSlogwang  */
3642bfe3f2eSlogwang struct lio_gather {
3652bfe3f2eSlogwang 	/** List manipulation. Next and prev pointers. */
3662bfe3f2eSlogwang 	struct lio_stailq_node list;
3672bfe3f2eSlogwang 
3682bfe3f2eSlogwang 	/** Size of the gather component at sg in bytes. */
3692bfe3f2eSlogwang 	int sg_size;
3702bfe3f2eSlogwang 
3712bfe3f2eSlogwang 	/** Number of bytes that sg was adjusted to make it 8B-aligned. */
3722bfe3f2eSlogwang 	int adjust;
3732bfe3f2eSlogwang 
3742bfe3f2eSlogwang 	/** Gather component that can accommodate max sized fragment list
3752bfe3f2eSlogwang 	 *  received from the IP layer.
3762bfe3f2eSlogwang 	 */
3772bfe3f2eSlogwang 	struct lio_sg_entry *sg;
3782bfe3f2eSlogwang };
3792bfe3f2eSlogwang 
3802bfe3f2eSlogwang struct lio_rss_ctx {
3812bfe3f2eSlogwang 	uint16_t hash_key_size;
3822bfe3f2eSlogwang 	uint8_t  hash_key[LIO_RSS_MAX_KEY_SZ];
3832bfe3f2eSlogwang 	/* Ideally a factor of number of queues */
3842bfe3f2eSlogwang 	uint8_t  itable[LIO_RSS_MAX_TABLE_SZ];
3852bfe3f2eSlogwang 	uint8_t  itable_size;
3862bfe3f2eSlogwang 	uint8_t  ip;
3872bfe3f2eSlogwang 	uint8_t  tcp_hash;
3882bfe3f2eSlogwang 	uint8_t  ipv6;
3892bfe3f2eSlogwang 	uint8_t  ipv6_tcp_hash;
3902bfe3f2eSlogwang 	uint8_t  ipv6_ex;
3912bfe3f2eSlogwang 	uint8_t  ipv6_tcp_ex_hash;
3922bfe3f2eSlogwang 	uint8_t  hash_disable;
3932bfe3f2eSlogwang };
3942bfe3f2eSlogwang 
3952bfe3f2eSlogwang struct lio_io_enable {
3962bfe3f2eSlogwang 	uint64_t iq;
3972bfe3f2eSlogwang 	uint64_t oq;
3982bfe3f2eSlogwang 	uint64_t iq64B;
3992bfe3f2eSlogwang };
4002bfe3f2eSlogwang 
4012bfe3f2eSlogwang struct lio_fn_list {
4022bfe3f2eSlogwang 	void (*setup_iq_regs)(struct lio_device *, uint32_t);
4032bfe3f2eSlogwang 	void (*setup_oq_regs)(struct lio_device *, uint32_t);
4042bfe3f2eSlogwang 
4052bfe3f2eSlogwang 	int (*setup_mbox)(struct lio_device *);
4062bfe3f2eSlogwang 	void (*free_mbox)(struct lio_device *);
4072bfe3f2eSlogwang 
4082bfe3f2eSlogwang 	int (*setup_device_regs)(struct lio_device *);
4092bfe3f2eSlogwang 	int (*enable_io_queues)(struct lio_device *);
4102bfe3f2eSlogwang 	void (*disable_io_queues)(struct lio_device *);
4112bfe3f2eSlogwang };
4122bfe3f2eSlogwang 
4132bfe3f2eSlogwang struct lio_pf_vf_hs_word {
4142bfe3f2eSlogwang #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
4152bfe3f2eSlogwang 	/** PKIND value assigned for the DPI interface */
4162bfe3f2eSlogwang 	uint64_t pkind : 8;
4172bfe3f2eSlogwang 
4182bfe3f2eSlogwang 	/** OCTEON core clock multiplier */
4192bfe3f2eSlogwang 	uint64_t core_tics_per_us : 16;
4202bfe3f2eSlogwang 
4212bfe3f2eSlogwang 	/** OCTEON coprocessor clock multiplier */
4222bfe3f2eSlogwang 	uint64_t coproc_tics_per_us : 16;
4232bfe3f2eSlogwang 
4242bfe3f2eSlogwang 	/** app that currently running on OCTEON */
4252bfe3f2eSlogwang 	uint64_t app_mode : 8;
4262bfe3f2eSlogwang 
4272bfe3f2eSlogwang 	/** RESERVED */
4282bfe3f2eSlogwang 	uint64_t reserved : 16;
4292bfe3f2eSlogwang 
4302bfe3f2eSlogwang #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
4312bfe3f2eSlogwang 
4322bfe3f2eSlogwang 	/** RESERVED */
4332bfe3f2eSlogwang 	uint64_t reserved : 16;
4342bfe3f2eSlogwang 
4352bfe3f2eSlogwang 	/** app that currently running on OCTEON */
4362bfe3f2eSlogwang 	uint64_t app_mode : 8;
4372bfe3f2eSlogwang 
4382bfe3f2eSlogwang 	/** OCTEON coprocessor clock multiplier */
4392bfe3f2eSlogwang 	uint64_t coproc_tics_per_us : 16;
4402bfe3f2eSlogwang 
4412bfe3f2eSlogwang 	/** OCTEON core clock multiplier */
4422bfe3f2eSlogwang 	uint64_t core_tics_per_us : 16;
4432bfe3f2eSlogwang 
4442bfe3f2eSlogwang 	/** PKIND value assigned for the DPI interface */
4452bfe3f2eSlogwang 	uint64_t pkind : 8;
4462bfe3f2eSlogwang #endif
4472bfe3f2eSlogwang };
4482bfe3f2eSlogwang 
4492bfe3f2eSlogwang struct lio_sriov_info {
4502bfe3f2eSlogwang 	/** Number of rings assigned to VF */
4512bfe3f2eSlogwang 	uint32_t rings_per_vf;
4522bfe3f2eSlogwang 
4532bfe3f2eSlogwang 	/** Number of VF devices enabled */
4542bfe3f2eSlogwang 	uint32_t num_vfs;
4552bfe3f2eSlogwang };
4562bfe3f2eSlogwang 
4572bfe3f2eSlogwang /* Head of a response list */
4582bfe3f2eSlogwang struct lio_response_list {
4592bfe3f2eSlogwang 	/** List structure to add delete pending entries to */
4602bfe3f2eSlogwang 	struct lio_stailq_head head;
4612bfe3f2eSlogwang 
4622bfe3f2eSlogwang 	/** A lock for this response list */
4632bfe3f2eSlogwang 	rte_spinlock_t lock;
4642bfe3f2eSlogwang 
4652bfe3f2eSlogwang 	rte_atomic64_t pending_req_count;
4662bfe3f2eSlogwang };
4672bfe3f2eSlogwang 
4682bfe3f2eSlogwang /* Structure to define the configuration attributes for each Input queue. */
4692bfe3f2eSlogwang struct lio_iq_config {
4702bfe3f2eSlogwang 	/* Max number of IQs available */
4712bfe3f2eSlogwang 	uint8_t max_iqs;
4722bfe3f2eSlogwang 
4732bfe3f2eSlogwang 	/** Pending list size (usually set to the sum of the size of all Input
4742bfe3f2eSlogwang 	 *  queues)
4752bfe3f2eSlogwang 	 */
4762bfe3f2eSlogwang 	uint32_t pending_list_size;
4772bfe3f2eSlogwang 
4782bfe3f2eSlogwang 	/** Command size - 32 or 64 bytes */
4792bfe3f2eSlogwang 	uint32_t instr_type;
4802bfe3f2eSlogwang };
4812bfe3f2eSlogwang 
4822bfe3f2eSlogwang /* Structure to define the configuration attributes for each Output queue. */
4832bfe3f2eSlogwang struct lio_oq_config {
4842bfe3f2eSlogwang 	/* Max number of OQs available */
4852bfe3f2eSlogwang 	uint8_t max_oqs;
4862bfe3f2eSlogwang 
4872bfe3f2eSlogwang 	/** If set, the Output queue uses info-pointer mode. (Default: 1 ) */
4882bfe3f2eSlogwang 	uint32_t info_ptr;
4892bfe3f2eSlogwang 
4902bfe3f2eSlogwang 	/** The number of buffers that were consumed during packet processing by
4912bfe3f2eSlogwang 	 *  the driver on this Output queue before the driver attempts to
4922bfe3f2eSlogwang 	 *  replenish the descriptor ring with new buffers.
4932bfe3f2eSlogwang 	 */
4942bfe3f2eSlogwang 	uint32_t refill_threshold;
4952bfe3f2eSlogwang };
4962bfe3f2eSlogwang 
4972bfe3f2eSlogwang /* Structure to define the configuration. */
4982bfe3f2eSlogwang struct lio_config {
4992bfe3f2eSlogwang 	uint16_t card_type;
5002bfe3f2eSlogwang 	const char *card_name;
5012bfe3f2eSlogwang 
5022bfe3f2eSlogwang 	/** Input Queue attributes. */
5032bfe3f2eSlogwang 	struct lio_iq_config iq;
5042bfe3f2eSlogwang 
5052bfe3f2eSlogwang 	/** Output Queue attributes. */
5062bfe3f2eSlogwang 	struct lio_oq_config oq;
5072bfe3f2eSlogwang 
5082bfe3f2eSlogwang 	int num_nic_ports;
5092bfe3f2eSlogwang 
5102bfe3f2eSlogwang 	int num_def_tx_descs;
5112bfe3f2eSlogwang 
5122bfe3f2eSlogwang 	/* Num of desc for rx rings */
5132bfe3f2eSlogwang 	int num_def_rx_descs;
5142bfe3f2eSlogwang 
5152bfe3f2eSlogwang 	int def_rx_buf_size;
5162bfe3f2eSlogwang };
5172bfe3f2eSlogwang 
5182bfe3f2eSlogwang /** Status of a RGMII Link on Octeon as seen by core driver. */
5192bfe3f2eSlogwang union octeon_link_status {
5202bfe3f2eSlogwang 	uint64_t link_status64;
5212bfe3f2eSlogwang 
5222bfe3f2eSlogwang 	struct {
5232bfe3f2eSlogwang #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
5242bfe3f2eSlogwang 		uint64_t duplex : 8;
5252bfe3f2eSlogwang 		uint64_t mtu : 16;
5262bfe3f2eSlogwang 		uint64_t speed : 16;
5272bfe3f2eSlogwang 		uint64_t link_up : 1;
5282bfe3f2eSlogwang 		uint64_t autoneg : 1;
5292bfe3f2eSlogwang 		uint64_t if_mode : 5;
5302bfe3f2eSlogwang 		uint64_t pause : 1;
5312bfe3f2eSlogwang 		uint64_t flashing : 1;
5322bfe3f2eSlogwang 		uint64_t reserved : 15;
5332bfe3f2eSlogwang #else
5342bfe3f2eSlogwang 		uint64_t reserved : 15;
5352bfe3f2eSlogwang 		uint64_t flashing : 1;
5362bfe3f2eSlogwang 		uint64_t pause : 1;
5372bfe3f2eSlogwang 		uint64_t if_mode : 5;
5382bfe3f2eSlogwang 		uint64_t autoneg : 1;
5392bfe3f2eSlogwang 		uint64_t link_up : 1;
5402bfe3f2eSlogwang 		uint64_t speed : 16;
5412bfe3f2eSlogwang 		uint64_t mtu : 16;
5422bfe3f2eSlogwang 		uint64_t duplex : 8;
5432bfe3f2eSlogwang #endif
5442bfe3f2eSlogwang 	} s;
5452bfe3f2eSlogwang };
5462bfe3f2eSlogwang 
5472bfe3f2eSlogwang /** The rxpciq info passed to host from the firmware */
5482bfe3f2eSlogwang union octeon_rxpciq {
5492bfe3f2eSlogwang 	uint64_t rxpciq64;
5502bfe3f2eSlogwang 
5512bfe3f2eSlogwang 	struct {
5522bfe3f2eSlogwang #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
5532bfe3f2eSlogwang 		uint64_t q_no : 8;
5542bfe3f2eSlogwang 		uint64_t reserved : 56;
5552bfe3f2eSlogwang #else
5562bfe3f2eSlogwang 		uint64_t reserved : 56;
5572bfe3f2eSlogwang 		uint64_t q_no : 8;
5582bfe3f2eSlogwang #endif
5592bfe3f2eSlogwang 	} s;
5602bfe3f2eSlogwang };
5612bfe3f2eSlogwang 
5622bfe3f2eSlogwang /** Information for a OCTEON ethernet interface shared between core & host. */
5632bfe3f2eSlogwang struct octeon_link_info {
5642bfe3f2eSlogwang 	union octeon_link_status link;
5652bfe3f2eSlogwang 	uint64_t hw_addr;
5662bfe3f2eSlogwang 
5672bfe3f2eSlogwang #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
5682bfe3f2eSlogwang 	uint64_t gmxport : 16;
5692bfe3f2eSlogwang 	uint64_t macaddr_is_admin_assigned : 1;
5702bfe3f2eSlogwang 	uint64_t vlan_is_admin_assigned : 1;
5712bfe3f2eSlogwang 	uint64_t rsvd : 30;
5722bfe3f2eSlogwang 	uint64_t num_txpciq : 8;
5732bfe3f2eSlogwang 	uint64_t num_rxpciq : 8;
5742bfe3f2eSlogwang #else
5752bfe3f2eSlogwang 	uint64_t num_rxpciq : 8;
5762bfe3f2eSlogwang 	uint64_t num_txpciq : 8;
5772bfe3f2eSlogwang 	uint64_t rsvd : 30;
5782bfe3f2eSlogwang 	uint64_t vlan_is_admin_assigned : 1;
5792bfe3f2eSlogwang 	uint64_t macaddr_is_admin_assigned : 1;
5802bfe3f2eSlogwang 	uint64_t gmxport : 16;
5812bfe3f2eSlogwang #endif
5822bfe3f2eSlogwang 
5832bfe3f2eSlogwang 	union octeon_txpciq txpciq[LIO_MAX_IOQS_PER_IF];
5842bfe3f2eSlogwang 	union octeon_rxpciq rxpciq[LIO_MAX_IOQS_PER_IF];
5852bfe3f2eSlogwang };
5862bfe3f2eSlogwang 
5872bfe3f2eSlogwang /* -----------------------  THE LIO DEVICE  --------------------------- */
5882bfe3f2eSlogwang /** The lio device.
5892bfe3f2eSlogwang  *  Each lio device has this structure to represent all its
5902bfe3f2eSlogwang  *  components.
5912bfe3f2eSlogwang  */
5922bfe3f2eSlogwang struct lio_device {
5932bfe3f2eSlogwang 	/** PCI device pointer */
5942bfe3f2eSlogwang 	struct rte_pci_device *pci_dev;
5952bfe3f2eSlogwang 
5962bfe3f2eSlogwang 	/** Octeon Chip type */
5972bfe3f2eSlogwang 	uint16_t chip_id;
5982bfe3f2eSlogwang 	uint16_t pf_num;
5992bfe3f2eSlogwang 	uint16_t vf_num;
6002bfe3f2eSlogwang 
6012bfe3f2eSlogwang 	/** This device's PCIe port used for traffic. */
6022bfe3f2eSlogwang 	uint16_t pcie_port;
6032bfe3f2eSlogwang 
6042bfe3f2eSlogwang 	/** The state of this device */
6052bfe3f2eSlogwang 	rte_atomic64_t status;
6062bfe3f2eSlogwang 
6072bfe3f2eSlogwang 	uint8_t intf_open;
6082bfe3f2eSlogwang 
6092bfe3f2eSlogwang 	struct octeon_link_info linfo;
6102bfe3f2eSlogwang 
6112bfe3f2eSlogwang 	uint8_t *hw_addr;
6122bfe3f2eSlogwang 
6132bfe3f2eSlogwang 	struct lio_fn_list fn_list;
6142bfe3f2eSlogwang 
6152bfe3f2eSlogwang 	uint32_t num_iqs;
6162bfe3f2eSlogwang 
6172bfe3f2eSlogwang 	/** Guards each glist */
6182bfe3f2eSlogwang 	rte_spinlock_t *glist_lock;
6192bfe3f2eSlogwang 	/** Array of gather component linked lists */
6202bfe3f2eSlogwang 	struct lio_stailq_head *glist_head;
6212bfe3f2eSlogwang 
6222bfe3f2eSlogwang 	/* The pool containing pre allocated buffers used for soft commands */
6232bfe3f2eSlogwang 	struct rte_mempool *sc_buf_pool;
6242bfe3f2eSlogwang 
6252bfe3f2eSlogwang 	/** The input instruction queues */
6262bfe3f2eSlogwang 	struct lio_instr_queue *instr_queue[LIO_MAX_POSSIBLE_INSTR_QUEUES];
6272bfe3f2eSlogwang 
6282bfe3f2eSlogwang 	/** The singly-linked tail queues of instruction response */
6292bfe3f2eSlogwang 	struct lio_response_list response_list;
6302bfe3f2eSlogwang 
6312bfe3f2eSlogwang 	uint32_t num_oqs;
6322bfe3f2eSlogwang 
6332bfe3f2eSlogwang 	/** The DROQ output queues  */
6342bfe3f2eSlogwang 	struct lio_droq *droq[LIO_MAX_POSSIBLE_OUTPUT_QUEUES];
6352bfe3f2eSlogwang 
6362bfe3f2eSlogwang 	struct lio_io_enable io_qmask;
6372bfe3f2eSlogwang 
6382bfe3f2eSlogwang 	struct lio_sriov_info sriov_info;
6392bfe3f2eSlogwang 
6402bfe3f2eSlogwang 	struct lio_pf_vf_hs_word pfvf_hsword;
6412bfe3f2eSlogwang 
6422bfe3f2eSlogwang 	/** Mail Box details of each lio queue. */
6432bfe3f2eSlogwang 	struct lio_mbox **mbox;
6442bfe3f2eSlogwang 
6452bfe3f2eSlogwang 	char dev_string[LIO_DEVICE_NAME_LEN]; /* Device print string */
6462bfe3f2eSlogwang 
6472bfe3f2eSlogwang 	const struct lio_config *default_config;
6482bfe3f2eSlogwang 
6492bfe3f2eSlogwang 	struct rte_eth_dev      *eth_dev;
6502bfe3f2eSlogwang 
6512bfe3f2eSlogwang 	uint64_t ifflags;
6522bfe3f2eSlogwang 	uint8_t max_rx_queues;
6532bfe3f2eSlogwang 	uint8_t max_tx_queues;
6542bfe3f2eSlogwang 	uint8_t nb_rx_queues;
6552bfe3f2eSlogwang 	uint8_t nb_tx_queues;
6562bfe3f2eSlogwang 	uint8_t port_configured;
6572bfe3f2eSlogwang 	struct lio_rss_ctx rss_state;
6582bfe3f2eSlogwang 	uint16_t port_id;
6592bfe3f2eSlogwang 	char firmware_version[LIO_FW_VERSION_LENGTH];
6602bfe3f2eSlogwang };
6612bfe3f2eSlogwang #endif /* _LIO_STRUCT_H_ */
662