DPDK 22.11.5
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#ifdef __cplusplus
17extern "C" {
18#endif
19
20#include <string.h>
21
22#include <dev_driver.h>
23#include <rte_malloc.h>
24#include <rte_log.h>
25#include <rte_common.h>
26
27#include "rte_rawdev.h"
28
29extern int librawdev_logtype;
30
31/* Logging Macros */
32#define RTE_RDEV_LOG(level, fmt, args...) \
33 rte_log(RTE_LOG_ ## level, librawdev_logtype, "%s(): " fmt "\n", \
34 __func__, ##args)
35
36#define RTE_RDEV_ERR(fmt, args...) \
37 RTE_RDEV_LOG(ERR, fmt, ## args)
38#define RTE_RDEV_DEBUG(fmt, args...) \
39 RTE_RDEV_LOG(DEBUG, fmt, ## args)
40#define RTE_RDEV_INFO(fmt, args...) \
41 RTE_RDEV_LOG(INFO, fmt, ## args)
42
43
44/* Macros to check for valid device */
45#define RTE_RAWDEV_VALID_DEVID_OR_ERR_RET(dev_id, retval) do { \
46 if (!rte_rawdev_pmd_is_valid_dev((dev_id))) { \
47 RTE_RDEV_ERR("Invalid dev_id=%d", dev_id); \
48 return retval; \
49 } \
50} while (0)
51
52#define RTE_RAWDEV_VALID_DEVID_OR_RET(dev_id) do { \
53 if (!rte_rawdev_pmd_is_valid_dev((dev_id))) { \
54 RTE_RDEV_ERR("Invalid dev_id=%d", dev_id); \
55 return; \
56 } \
57} while (0)
58
59#define RTE_RAWDEV_DETACHED (0)
60#define RTE_RAWDEV_ATTACHED (1)
61
62/* Global structure used for maintaining state of allocated raw devices.
63 *
64 * TODO: Can be expanded to <type of raw device>:<count> in future.
65 * Applications should be able to select from a number of type of raw
66 * devices which were detected or attached to this DPDK instance.
67 */
68struct rte_rawdev_global {
70 uint16_t nb_devs;
71};
72
73extern struct rte_rawdev *rte_rawdevs;
85static inline struct rte_rawdev *
87{
88 struct rte_rawdev *dev;
89 unsigned int i;
90
91 if (name == NULL)
92 return NULL;
93
94 for (i = 0; i < RTE_RAWDEV_MAX_DEVS; i++) {
95 dev = &rte_rawdevs[i];
96 if ((dev->attached == RTE_RAWDEV_ATTACHED) &&
97 (strcmp(dev->name, name) == 0))
98 return dev;
99 }
100
101 return NULL;
102}
103
113static inline unsigned
115{
116 struct rte_rawdev *dev;
117
118 if (dev_id >= RTE_RAWDEV_MAX_DEVS)
119 return 0;
120
121 dev = &rte_rawdevs[dev_id];
122 if (dev->attached != RTE_RAWDEV_ATTACHED)
123 return 0;
124 else
125 return 1;
126}
127
147typedef int (*rawdev_info_get_t)(struct rte_rawdev *dev,
148 rte_rawdev_obj_t dev_info,
149 size_t dev_private_size);
150
164typedef int (*rawdev_configure_t)(const struct rte_rawdev *dev,
165 rte_rawdev_obj_t config,
166 size_t config_size);
167
177typedef int (*rawdev_start_t)(struct rte_rawdev *dev);
178
185typedef void (*rawdev_stop_t)(struct rte_rawdev *dev);
186
197typedef int (*rawdev_close_t)(struct rte_rawdev *dev);
198
208typedef int (*rawdev_reset_t)(struct rte_rawdev *dev);
209
225typedef int (*rawdev_queue_conf_get_t)(struct rte_rawdev *dev,
226 uint16_t queue_id,
227 rte_rawdev_obj_t queue_conf,
228 size_t queue_conf_size);
229
245typedef int (*rawdev_queue_setup_t)(struct rte_rawdev *dev,
246 uint16_t queue_id,
247 rte_rawdev_obj_t queue_conf,
248 size_t queue_conf_size);
249
259typedef int (*rawdev_queue_release_t)(struct rte_rawdev *dev,
260 uint16_t queue_id);
261
278typedef uint16_t (*rawdev_queue_count_t)(struct rte_rawdev *dev);
279
302typedef int (*rawdev_enqueue_bufs_t)(struct rte_rawdev *dev,
303 struct rte_rawdev_buf **buffers,
304 unsigned int count,
305 rte_rawdev_obj_t context);
306
327typedef int (*rawdev_dequeue_bufs_t)(struct rte_rawdev *dev,
328 struct rte_rawdev_buf **buffers,
329 unsigned int count,
330 rte_rawdev_obj_t context);
331
344typedef int (*rawdev_dump_t)(struct rte_rawdev *dev, FILE *f);
345
361typedef int (*rawdev_get_attr_t)(struct rte_rawdev *dev,
362 const char *attr_name,
363 uint64_t *attr_value);
364
379typedef int (*rawdev_set_attr_t)(struct rte_rawdev *dev,
380 const char *attr_name,
381 const uint64_t attr_value);
382
399typedef int (*rawdev_xstats_get_t)(const struct rte_rawdev *dev,
400 const unsigned int ids[], uint64_t values[], unsigned int n);
401
405typedef int (*rawdev_xstats_reset_t)(struct rte_rawdev *dev,
406 const uint32_t ids[],
407 uint32_t nb_ids);
408
424typedef int (*rawdev_xstats_get_names_t)(const struct rte_rawdev *dev,
425 struct rte_rawdev_xstats_name *xstats_names,
426 unsigned int size);
427
443typedef uint64_t (*rawdev_xstats_get_by_name_t)(const struct rte_rawdev *dev,
444 const char *name,
445 unsigned int *id);
446
459typedef int (*rawdev_firmware_status_get_t)(struct rte_rawdev *dev,
460 rte_rawdev_obj_t status_info);
461
473typedef int (*rawdev_firmware_version_get_t)(struct rte_rawdev *dev,
474 rte_rawdev_obj_t version_info);
475
490typedef int (*rawdev_firmware_load_t)(struct rte_rawdev *dev,
491 rte_rawdev_obj_t firmware_buf);
492
505typedef int (*rawdev_firmware_unload_t)(struct rte_rawdev *dev);
506
513typedef int (*rawdev_selftest_t)(uint16_t dev_id);
514
529
538
544
545 /* Dump internal information */
547
552
561
570
572 rawdev_selftest_t dev_selftest;
573};
574
590struct rte_rawdev *
591rte_rawdev_pmd_allocate(const char *name, size_t dev_private_size,
592 int socket_id);
593
602int
603rte_rawdev_pmd_release(struct rte_rawdev *rawdev);
604
619struct rte_rawdev *
620rte_rawdev_pmd_init(const char *name, size_t dev_private_size,
621 int socket_id);
622
631int
632rte_rawdev_pmd_uninit(const char *name);
633
634#ifdef __cplusplus
635}
636#endif
637
638#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)
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