xref: /dpdk/lib/mldev/rte_mldev_pmd.h (revision 719834a6849e1daf4a70ff7742bbcc3ae7e25607)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2022 Marvell.
3  */
4 
5 #ifndef RTE_MLDEV_PMD_H
6 #define RTE_MLDEV_PMD_H
7 
8 /**
9  * @file
10  *
11  * ML Device PMD interface
12  *
13  * @note
14  * These APIs are for MLDEV PMDs only and user applications should not call them directly.
15  */
16 
17 #include <stdint.h>
18 
19 #include <rte_common.h>
20 #include <rte_compat.h>
21 #include <rte_mldev.h>
22 #include <rte_mldev_core.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /**
29  * @internal
30  *
31  * Initialisation parameters for ML devices.
32  */
33 struct rte_ml_dev_pmd_init_params {
34 	/** Socket to use for memory allocation. */
35 	uint8_t socket_id;
36 
37 	/** Size of device private data. */
38 	uint64_t private_data_size;
39 };
40 
41 struct rte_ml_dev;
42 
43 /**
44  * @internal
45  *
46  * Get the ML device pointer for the device. Assumes a valid device index.
47  *
48  * @param dev_id
49  *	Device ID value to select the device structure.
50  *
51  * @return
52  *	The rte_ml_dev pointer for the given device ID.
53  */
54 __rte_internal
55 struct rte_ml_dev *
56 rte_ml_dev_pmd_get_dev(int16_t dev_id);
57 
58 /**
59  * @internal
60  *
61  * Get the rte_ml_dev structure device pointer for the named device.
62  *
63  * @param name
64  *	Device name to select the device structure.
65  *
66  * @return
67  *	The rte_ml_dev pointer for the given device ID.
68  */
69 __rte_internal
70 struct rte_ml_dev *
71 rte_ml_dev_pmd_get_named_dev(const char *name);
72 
73 /**
74  * @internal
75  *
76  * Allocates a new mldev slot for an ML device and returns the pointer to that slot for use.
77  * Function for internal use by dummy drivers.
78  *
79  * @param name
80  *	Unique identifier name for each device.
81  * @param socket_id
82  *	Socket to allocate resources.
83  *
84  * @return
85  *	Slot in the rte_ml_dev_devices array for a new device.
86  */
87 __rte_internal
88 struct rte_ml_dev *
89 rte_ml_dev_pmd_allocate(const char *name, uint8_t socket_id);
90 
91 /**
92  * @internal
93  *
94  * Release the specified mldev device.
95  *
96  * @param dev
97  *	ML device.
98  * @return
99  *	- 0 on success.
100  *	- < 0, error code on failure.
101  */
102 __rte_internal
103 int
104 rte_ml_dev_pmd_release(struct rte_ml_dev *dev);
105 
106 /**
107  * @internal
108  *
109  * PMD assist function to provide boiler plate code for ML driver to create and allocate resources
110  * for a new ML PMD device instance.
111  *
112  * @param name
113  *	ML device name.
114  * @param device
115  *	Base device handle.
116  * @param params
117  *	PMD initialisation parameters.
118  *
119  * @return
120  *	- ML device instance on success.
121  *	- NULL on failure.
122  */
123 __rte_internal
124 struct rte_ml_dev *
125 rte_ml_dev_pmd_create(const char *name, struct rte_device *device,
126 		      struct rte_ml_dev_pmd_init_params *params);
127 
128 /**
129  * @internal
130  *
131  * PMD assist function to provide boiler plate code for ML driver to destroy and free resources
132  * associated with a ML PMD device instance.
133  *
134  * @param mldev
135  *	ML device instance.
136  *
137  * @return
138  *	- 0 on success.
139  *	- < 0, error code on failure.
140  */
141 __rte_internal
142 int
143 rte_ml_dev_pmd_destroy(struct rte_ml_dev *mldev);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* RTE_MLDEV_PMD_H */
150