xref: /dpdk/drivers/raw/skeleton/skeleton_rawdev.h (revision fd51012de5369679e807be1d6a81d63ef15015ce)
1473c88f9SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
2473c88f9SBruce Richardson  * Copyright 2017 NXP
3473c88f9SBruce Richardson  */
4473c88f9SBruce Richardson 
5473c88f9SBruce Richardson #ifndef __SKELETON_RAWDEV_H__
6473c88f9SBruce Richardson #define __SKELETON_RAWDEV_H__
7473c88f9SBruce Richardson 
8473c88f9SBruce Richardson #include <rte_rawdev.h>
9473c88f9SBruce Richardson 
10473c88f9SBruce Richardson extern int skeleton_pmd_logtype;
112b843cacSDavid Marchand #define RTE_LOGTYPE_SKELETON_PMD skeleton_pmd_logtype
12473c88f9SBruce Richardson 
132b843cacSDavid Marchand #define SKELETON_PMD_LOG(level, ...) \
142b843cacSDavid Marchand 	RTE_LOG_LINE_PREFIX(level, SKELETON_PMD, "%s(): ", __func__, __VA_ARGS__)
15473c88f9SBruce Richardson 
16473c88f9SBruce Richardson #define SKELETON_PMD_FUNC_TRACE() SKELETON_PMD_LOG(DEBUG, ">>")
17473c88f9SBruce Richardson 
18*fd51012dSAndre Muezerie #define SKELETON_PMD_DEBUG(fmt, ...) \
19*fd51012dSAndre Muezerie 	SKELETON_PMD_LOG(DEBUG, fmt, ##__VA_ARGS__)
20*fd51012dSAndre Muezerie #define SKELETON_PMD_INFO(fmt, ...) \
21*fd51012dSAndre Muezerie 	SKELETON_PMD_LOG(INFO, fmt, ##__VA_ARGS__)
22*fd51012dSAndre Muezerie #define SKELETON_PMD_ERR(fmt, ...) \
23*fd51012dSAndre Muezerie 	SKELETON_PMD_LOG(ERR, fmt, ##__VA_ARGS__)
24*fd51012dSAndre Muezerie #define SKELETON_PMD_WARN(fmt, ...) \
25*fd51012dSAndre Muezerie 	SKELETON_PMD_LOG(WARNING, fmt, ##__VA_ARGS__)
26473c88f9SBruce Richardson /* Macros for self test application */
27473c88f9SBruce Richardson #define SKELETON_TEST_INFO	SKELETON_PMD_INFO
28473c88f9SBruce Richardson #define SKELETON_TEST_DEBUG	SKELETON_PMD_DEBUG
29473c88f9SBruce Richardson #define SKELETON_TEST_ERR	SKELETON_PMD_ERR
30473c88f9SBruce Richardson #define SKELETON_TEST_WARN	SKELETON_PMD_WARN
31473c88f9SBruce Richardson 
32473c88f9SBruce Richardson #define SKELETON_SELFTEST_ARG   ("selftest")
33473c88f9SBruce Richardson 
34473c88f9SBruce Richardson #define SKELETON_VENDOR_ID 0x10
35473c88f9SBruce Richardson #define SKELETON_DEVICE_ID 0x01
36473c88f9SBruce Richardson 
37473c88f9SBruce Richardson #define SKELETON_MAJOR_VER 1
38473c88f9SBruce Richardson #define SKELETON_MINOR_VER 0
39473c88f9SBruce Richardson #define SKELETON_SUB_VER   0
40473c88f9SBruce Richardson 
41473c88f9SBruce Richardson #define SKELETON_MAX_QUEUES 1
42473c88f9SBruce Richardson 
43473c88f9SBruce Richardson enum skeleton_firmware_state {
44473c88f9SBruce Richardson 	SKELETON_FW_READY,
45473c88f9SBruce Richardson 	SKELETON_FW_LOADED,
46473c88f9SBruce Richardson 	SKELETON_FW_ERROR
47473c88f9SBruce Richardson };
48473c88f9SBruce Richardson 
49473c88f9SBruce Richardson enum skeleton_device_state {
50473c88f9SBruce Richardson 	SKELETON_DEV_RUNNING,
51473c88f9SBruce Richardson 	SKELETON_DEV_STOPPED
52473c88f9SBruce Richardson };
53473c88f9SBruce Richardson 
54473c88f9SBruce Richardson enum skeleton_queue_state {
55473c88f9SBruce Richardson 	SKELETON_QUEUE_DETACH,
56473c88f9SBruce Richardson 	SKELETON_QUEUE_ATTACH
57473c88f9SBruce Richardson };
58473c88f9SBruce Richardson 
59473c88f9SBruce Richardson #define SKELETON_QUEUE_DEF_DEPTH 10
60473c88f9SBruce Richardson #define SKELETON_QUEUE_MAX_DEPTH 25
61473c88f9SBruce Richardson 
62473c88f9SBruce Richardson struct skeleton_firmware_version_info {
63473c88f9SBruce Richardson 	uint8_t major;
64473c88f9SBruce Richardson 	uint8_t minor;
65473c88f9SBruce Richardson 	uint8_t subrel;
66473c88f9SBruce Richardson };
67473c88f9SBruce Richardson 
68473c88f9SBruce Richardson struct skeleton_firmware {
69473c88f9SBruce Richardson 	/**< Device firmware information */
70473c88f9SBruce Richardson 	struct skeleton_firmware_version_info firmware_version;
71473c88f9SBruce Richardson 	/**< Device state */
72473c88f9SBruce Richardson 	enum skeleton_firmware_state firmware_state;
73473c88f9SBruce Richardson 
74473c88f9SBruce Richardson };
75473c88f9SBruce Richardson 
76473c88f9SBruce Richardson #define SKELETON_MAX_ATTRIBUTES 10
77473c88f9SBruce Richardson #define SKELETON_ATTRIBUTE_NAME_MAX 20
78473c88f9SBruce Richardson 
79473c88f9SBruce Richardson struct skeleton_rawdev_attributes {
80473c88f9SBruce Richardson 	/**< Name of the attribute */
81473c88f9SBruce Richardson 	char *name;
82473c88f9SBruce Richardson 	/**< Value or reference of value of attribute */
83473c88f9SBruce Richardson 	uint64_t value;
84473c88f9SBruce Richardson };
85473c88f9SBruce Richardson 
86473c88f9SBruce Richardson /**< Device supports firmware loading/unloading */
87473c88f9SBruce Richardson #define SKELETON_CAPA_FW_LOAD	0x0001
88473c88f9SBruce Richardson /**< Device supports firmware reset */
89473c88f9SBruce Richardson #define SKELETON_CAPA_FW_RESET  0x0002
90473c88f9SBruce Richardson /**< Device support queue based communication */
91473c88f9SBruce Richardson #define SKELETON_CAPA_QUEUES    0x0004
92473c88f9SBruce Richardson /**< Default Capabilities: FW_LOAD, FW_RESET, QUEUES */
93473c88f9SBruce Richardson #define SKELETON_DEFAULT_CAPA   0x7
94473c88f9SBruce Richardson 
95473c88f9SBruce Richardson struct skeleton_rawdev_queue {
96473c88f9SBruce Richardson 	uint8_t state;
97473c88f9SBruce Richardson 	uint32_t depth;
98473c88f9SBruce Richardson };
99473c88f9SBruce Richardson 
100473c88f9SBruce Richardson struct skeleton_rawdev {
101473c88f9SBruce Richardson 	uint16_t device_id;
102473c88f9SBruce Richardson 	uint16_t vendor_id;
103473c88f9SBruce Richardson 	uint16_t num_queues;
104473c88f9SBruce Richardson 	/**< One of SKELETON_CAPA_* */
105473c88f9SBruce Richardson 	uint16_t capabilities;
106473c88f9SBruce Richardson 	/**< State of device; linked to firmware state */
107473c88f9SBruce Richardson 	enum skeleton_device_state device_state;
108473c88f9SBruce Richardson 	/**< Firmware configuration */
109473c88f9SBruce Richardson 	struct skeleton_firmware fw;
110473c88f9SBruce Richardson 	/**< Collection of all communication channels - which can be referred
111473c88f9SBruce Richardson 	 *  to as queues.
112473c88f9SBruce Richardson 	 */
113473c88f9SBruce Richardson 	struct skeleton_rawdev_queue queues[SKELETON_MAX_QUEUES];
114473c88f9SBruce Richardson 	/**< Global table containing various pre-defined and user-defined
115473c88f9SBruce Richardson 	 * attributes.
116473c88f9SBruce Richardson 	 */
117473c88f9SBruce Richardson 	struct skeleton_rawdev_attributes attr[SKELETON_MAX_ATTRIBUTES];
118473c88f9SBruce Richardson 	struct rte_device *device;
119473c88f9SBruce Richardson };
120473c88f9SBruce Richardson 
121473c88f9SBruce Richardson struct skeleton_rawdev_conf {
122473c88f9SBruce Richardson 	uint16_t num_queues;
123473c88f9SBruce Richardson 	unsigned int capabilities;
124473c88f9SBruce Richardson 	enum skeleton_device_state device_state;
125473c88f9SBruce Richardson 	enum skeleton_firmware_state firmware_state;
126473c88f9SBruce Richardson };
127473c88f9SBruce Richardson 
128473c88f9SBruce Richardson static inline struct skeleton_rawdev *
129473c88f9SBruce Richardson skeleton_rawdev_get_priv(const struct rte_rawdev *rawdev)
130473c88f9SBruce Richardson {
131473c88f9SBruce Richardson 	return rawdev->dev_private;
132473c88f9SBruce Richardson }
133473c88f9SBruce Richardson 
134473c88f9SBruce Richardson int test_rawdev_skeldev(uint16_t dev_id);
135473c88f9SBruce Richardson 
136473c88f9SBruce Richardson #endif /* __SKELETON_RAWDEV_H__ */
137