DPDK 25.03.0-rc0
rte_rawdev_pmd.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2017 NXP
3 */
4
5#ifndef _RTE_RAWDEV_PMD_H_
6#define _RTE_RAWDEV_PMD_H_
7
16#include <string.h>
17
18#include <dev_driver.h>
19#include <rte_malloc.h>
20#include <rte_log.h>
21#include <rte_common.h>
22
23#include "rte_rawdev.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29extern int librawdev_logtype;
30#define RTE_LOGTYPE_RAWDEV librawdev_logtype
31
32/* Logging Macros */
33#define RTE_RDEV_LOG(level, ...) \
34 RTE_LOG_LINE_PREFIX(level, RAWDEV, "%s(): ", __func__, __VA_ARGS__)
35
36#define RTE_RDEV_ERR(...) \
37 RTE_RDEV_LOG(ERR, __VA_ARGS__)
38
39#define RTE_RDEV_DEBUG(...) \
40 RTE_RDEV_LOG(DEBUG, __VA_ARGS__)
41
42#define RTE_RDEV_INFO(...) \
43 RTE_RDEV_LOG(INFO, __VA_ARGS__)
44
45/* Macros to check for valid device */
46#define RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
47 if (!rte_rawdev_pmd_is_valid_dev((dev_id))) { \
48 RTE_RDEV_ERR("Invalid dev_id=%d", dev_id); \
49 return retval; \
50 } \
51} while (0)
52
53#define RTE_RAWDEV_VALID_DEVID_OR_RET(dev_id) do { \
54 if (!rte_rawdev_pmd_is_valid_dev((dev_id))) { \
55 RTE_RDEV_ERR("Invalid dev_id=%d", dev_id); \
56 return; \
57 } \
58} while (0)
59
60#define RTE_RAWDEV_DETACHED (0)
61#define RTE_RAWDEV_ATTACHED (1)
62
63/* Global structure used for maintaining state of allocated raw devices.
64 *
65 * TODO: Can be expanded to <type of raw device>:<count> in future.
66 * Applications should be able to select from a number of type of raw
67 * devices which were detected or attached to this DPDK instance.
68 */
69struct rte_rawdev_global {
71 uint16_t nb_devs;
72};
73
74extern struct rte_rawdev *rte_rawdevs;
86static inline struct rte_rawdev *
88{
89 struct rte_rawdev *dev;
90 unsigned int i;
91
92 if (name == NULL)
93 return NULL;
94
95 for (i = 0; i < RTE_RAWDEV_MAX_DEVS; i++) {
96 dev = &rte_rawdevs[i];
97 if ((dev->attached == RTE_RAWDEV_ATTACHED) &&
98 (strcmp(dev->name, name) == 0))
99 return dev;
100 }
101
102 return NULL;
103}
104
114static inline struct rte_rawdev *
116{
117 struct rte_rawdev *dev;
118
119 if (dev_id >= RTE_RAWDEV_MAX_DEVS)
120 return NULL;
121
122 dev = &rte_rawdevs[dev_id];
123 if (dev->attached == RTE_RAWDEV_ATTACHED)
124 return dev;
125
126 return NULL;
127}
128
138static inline unsigned
140{
141 struct rte_rawdev *dev;
142
143 if (dev_id >= RTE_RAWDEV_MAX_DEVS)
144 return 0;
145
146 dev = &rte_rawdevs[dev_id];
147 if (dev->attached != RTE_RAWDEV_ATTACHED)
148 return 0;
149 else
150 return 1;
151}
152
172typedef int (*rawdev_info_get_t)(struct rte_rawdev *dev,
173 rte_rawdev_obj_t dev_info,
174 size_t dev_private_size);
175
189typedef int (*rawdev_configure_t)(const struct rte_rawdev *dev,
190 rte_rawdev_obj_t config,
191 size_t config_size);
192
202typedef int (*rawdev_start_t)(struct rte_rawdev *dev);
203
210typedef void (*rawdev_stop_t)(struct rte_rawdev *dev);
211
222typedef int (*rawdev_close_t)(struct rte_rawdev *dev);
223
233typedef int (*rawdev_reset_t)(struct rte_rawdev *dev);
234
250typedef int (*rawdev_queue_conf_get_t)(struct rte_rawdev *dev,
251 uint16_t queue_id,
252 rte_rawdev_obj_t queue_conf,
253 size_t queue_conf_size);
254
270typedef int (*rawdev_queue_setup_t)(struct rte_rawdev *dev,
271 uint16_t queue_id,
272 rte_rawdev_obj_t queue_conf,
273 size_t queue_conf_size);
274
283typedef int (*rawdev_queue_release_t)(struct rte_rawdev *dev,
284 uint16_t queue_id);
285
301typedef uint16_t (*rawdev_queue_count_t)(struct rte_rawdev *dev);
302
325typedef int (*rawdev_enqueue_bufs_t)(struct rte_rawdev *dev,
326 struct rte_rawdev_buf **buffers,
327 unsigned int count,
328 rte_rawdev_obj_t context);
329
350typedef int (*rawdev_dequeue_bufs_t)(struct rte_rawdev *dev,
351 struct rte_rawdev_buf **buffers,
352 unsigned int count,
353 rte_rawdev_obj_t context);
354
366typedef int (*rawdev_dump_t)(struct rte_rawdev *dev, FILE *f);
367
383typedef int (*rawdev_get_attr_t)(struct rte_rawdev *dev,
384 const char *attr_name,
385 uint64_t *attr_value);
386
401typedef int (*rawdev_set_attr_t)(struct rte_rawdev *dev,
402 const char *attr_name,
403 const uint64_t attr_value);
404
421typedef int (*rawdev_xstats_get_t)(const struct rte_rawdev *dev,
422 const unsigned int ids[], uint64_t values[], unsigned int n);
423
427typedef int (*rawdev_xstats_reset_t)(struct rte_rawdev *dev,
428 const uint32_t ids[],
429 uint32_t nb_ids);
430
446typedef int (*rawdev_xstats_get_names_t)(const struct rte_rawdev *dev,
447 struct rte_rawdev_xstats_name *xstats_names,
448 unsigned int size);
449
465typedef uint64_t (*rawdev_xstats_get_by_name_t)(const struct rte_rawdev *dev,
466 const char *name,
467 unsigned int *id);
468
481typedef int (*rawdev_firmware_status_get_t)(struct rte_rawdev *dev,
482 rte_rawdev_obj_t status_info);
483
495typedef int (*rawdev_firmware_version_get_t)(struct rte_rawdev *dev,
496 rte_rawdev_obj_t version_info);
497
512typedef int (*rawdev_firmware_load_t)(struct rte_rawdev *dev,
513 rte_rawdev_obj_t firmware_buf);
514
527typedef int (*rawdev_firmware_unload_t)(struct rte_rawdev *dev);
528
535typedef int (*rawdev_selftest_t)(uint16_t dev_id);
536
551
560
566
567 /* Dump internal information */
569
574
583
592
594 rawdev_selftest_t dev_selftest;
595};
596
612struct rte_rawdev *
613rte_rawdev_pmd_allocate(const char *name, size_t dev_private_size,
614 int socket_id);
615
624int
625rte_rawdev_pmd_release(struct rte_rawdev *rawdev);
626
641struct rte_rawdev *
642rte_rawdev_pmd_init(const char *name, size_t dev_private_size,
643 int socket_id);
644
653int
654rte_rawdev_pmd_uninit(const char *name);
655
656#ifdef __cplusplus
657}
658#endif
659
660#endif /* _RTE_RAWDEV_PMD_H_ */
int(* rawdev_dump_t)(struct rte_rawdev *dev, FILE *f)
int(* rawdev_xstats_reset_t)(struct rte_rawdev *dev, const uint32_t ids[], uint32_t nb_ids)
int(* rawdev_reset_t)(struct rte_rawdev *dev)
int(* rawdev_firmware_version_get_t)(struct rte_rawdev *dev, rte_rawdev_obj_t version_info)
void(* rawdev_stop_t)(struct rte_rawdev *dev)
int(* rawdev_xstats_get_t)(const struct rte_rawdev *dev, const unsigned int ids[], uint64_t values[], unsigned int n)
int(* rawdev_queue_setup_t)(struct rte_rawdev *dev, uint16_t queue_id, rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
uint16_t(* rawdev_queue_count_t)(struct rte_rawdev *dev)
int(* rawdev_get_attr_t)(struct rte_rawdev *dev, const char *attr_name, uint64_t *attr_value)
int rte_rawdev_pmd_release(struct rte_rawdev *rawdev)
int(* rawdev_selftest_t)(uint16_t dev_id)
struct rte_rawdev * rte_rawdev_pmd_allocate(const char *name, size_t dev_private_size, int socket_id)
static unsigned rte_rawdev_pmd_is_valid_dev(uint8_t dev_id)
int(* rawdev_queue_conf_get_t)(struct rte_rawdev *dev, uint16_t queue_id, rte_rawdev_obj_t queue_conf, size_t queue_conf_size)
static struct rte_rawdev * rte_rawdev_pmd_get_dev(uint8_t dev_id)
int(* rawdev_firmware_load_t)(struct rte_rawdev *dev, rte_rawdev_obj_t firmware_buf)
int(* rawdev_enqueue_bufs_t)(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)
int(* rawdev_xstats_get_names_t)(const struct rte_rawdev *dev, struct rte_rawdev_xstats_name *xstats_names, unsigned int size)
int(* rawdev_firmware_status_get_t)(struct rte_rawdev *dev, rte_rawdev_obj_t status_info)
int(* rawdev_dequeue_bufs_t)(struct rte_rawdev *dev, struct rte_rawdev_buf **buffers, unsigned int count, rte_rawdev_obj_t context)
int(* rawdev_close_t)(struct rte_rawdev *dev)
int(* rawdev_start_t)(struct rte_rawdev *dev)
static struct rte_rawdev * rte_rawdev_pmd_get_named_dev(const char *name)
int(* rawdev_info_get_t)(struct rte_rawdev *dev, rte_rawdev_obj_t dev_info, size_t dev_private_size)
int rte_rawdev_pmd_uninit(const char *name)
int(* rawdev_firmware_unload_t)(struct rte_rawdev *dev)
uint64_t(* rawdev_xstats_get_by_name_t)(const struct rte_rawdev *dev, const char *name, unsigned int *id)
struct rte_rawdev * rte_rawdev_pmd_init(const char *name, size_t dev_private_size, int socket_id)
int(* rawdev_queue_release_t)(struct rte_rawdev *dev, uint16_t queue_id)
int(* rawdev_configure_t)(const struct rte_rawdev *dev, rte_rawdev_obj_t config, size_t config_size)
int(* rawdev_set_attr_t)(struct rte_rawdev *dev, const char *attr_name, const uint64_t attr_value)
rawdev_configure_t dev_configure
rawdev_firmware_load_t firmware_load
rawdev_queue_conf_get_t queue_def_conf
rawdev_set_attr_t attr_set
rawdev_xstats_get_t xstats_get
rawdev_xstats_reset_t xstats_reset
rawdev_stop_t dev_stop
rawdev_dump_t dump
rawdev_enqueue_bufs_t enqueue_bufs
rawdev_firmware_unload_t firmware_unload
rawdev_queue_setup_t queue_setup
rawdev_get_attr_t attr_get
rawdev_dequeue_bufs_t dequeue_bufs
rawdev_start_t dev_start
rawdev_info_get_t dev_info_get
rawdev_close_t dev_close
rawdev_queue_release_t queue_release
rawdev_queue_count_t queue_count
rawdev_xstats_get_names_t xstats_get_names
rawdev_firmware_version_get_t firmware_version_get
rawdev_firmware_status_get_t firmware_status_get
rawdev_xstats_get_by_name_t xstats_get_by_name
rawdev_reset_t dev_reset