DPDK 24.11.1
rte_mldev_core.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2022 Marvell.
3 */
4
5#ifndef RTE_MLDEV_INTERNAL_H
6#define RTE_MLDEV_INTERNAL_H
7
19#include <stdint.h>
20
21#include <dev_driver.h>
22#include <rte_common.h>
23#include <rte_log.h>
24#include <rte_mldev.h>
25
26/* Device state */
27#define ML_DEV_DETACHED (0)
28#define ML_DEV_ATTACHED (1)
29
30struct rte_ml_dev;
31
49typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
50 uint16_t nb_ops);
51
69typedef uint16_t (*mldev_dequeue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
70 uint16_t nb_ops);
71
88typedef int (*mldev_op_error_get_t)(struct rte_ml_dev *dev, struct rte_ml_op *op,
89 struct rte_ml_op_error *error);
90
110typedef int (*mldev_info_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_info *dev_info);
111
126typedef int (*mldev_configure_t)(struct rte_ml_dev *dev, const struct rte_ml_dev_config *config);
127
141typedef int (*mldev_close_t)(struct rte_ml_dev *dev);
142
155typedef int (*mldev_start_t)(struct rte_ml_dev *dev);
156
169typedef int (*mldev_stop_t)(struct rte_ml_dev *dev);
170
189typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id,
190 const struct rte_ml_dev_qp_conf *queue_pair_conf,
191 int socket_id);
192
207typedef int (*mldev_queue_pair_release_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id);
208
223typedef int (*mldev_stats_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_stats *stats);
224
233typedef void (*mldev_stats_reset_t)(struct rte_ml_dev *dev);
234
256typedef int (*mldev_xstats_names_get_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
257 int32_t model_id, struct rte_ml_dev_xstats_map *xstats_map,
258 uint32_t size);
259
278typedef int (*mldev_xstats_by_name_get_t)(struct rte_ml_dev *dev, const char *name,
279 uint16_t *stat_id, uint64_t *value);
280
303typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
304 int32_t model_id, const uint16_t stat_ids[], uint64_t values[],
305 uint16_t nb_ids);
306
327typedef int (*mldev_xstats_reset_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
328 int32_t model_id, const uint16_t stat_ids[], uint16_t nb_ids);
329
345typedef int (*mldev_dump_t)(struct rte_ml_dev *dev, FILE *fd);
346
359typedef int (*mldev_selftest_t)(struct rte_ml_dev *dev);
360
377typedef int (*mldev_model_load_t)(struct rte_ml_dev *dev, struct rte_ml_model_params *params,
378 uint16_t *model_id);
379
394typedef int (*mldev_model_unload_t)(struct rte_ml_dev *dev, uint16_t model_id);
395
410typedef int (*mldev_model_start_t)(struct rte_ml_dev *dev, uint16_t model_id);
411
426typedef int (*mldev_model_stop_t)(struct rte_ml_dev *dev, uint16_t model_id);
427
444typedef int (*mldev_model_info_get_t)(struct rte_ml_dev *dev, uint16_t model_id,
445 struct rte_ml_model_info *model_info);
446
463typedef int (*mldev_model_params_update_t)(struct rte_ml_dev *dev, uint16_t model_id, void *buffer);
464
483typedef int (*mldev_io_quantize_t)(struct rte_ml_dev *dev, uint16_t model_id,
484 struct rte_ml_buff_seg **dbuffer,
485 struct rte_ml_buff_seg **qbuffer);
486
505typedef int (*mldev_io_dequantize_t)(struct rte_ml_dev *dev, uint16_t model_id,
506 struct rte_ml_buff_seg **qbuffer,
507 struct rte_ml_buff_seg **dbuffer);
508
514struct rte_ml_dev_ops {
516 mldev_info_get_t dev_info_get;
517
519 mldev_configure_t dev_configure;
520
522 mldev_close_t dev_close;
523
525 mldev_start_t dev_start;
526
528 mldev_stop_t dev_stop;
529
531 mldev_queue_pair_setup_t dev_queue_pair_setup;
532
534 mldev_queue_pair_release_t dev_queue_pair_release;
535
537 mldev_stats_get_t dev_stats_get;
538
540 mldev_stats_reset_t dev_stats_reset;
541
543 mldev_xstats_names_get_t dev_xstats_names_get;
544
546 mldev_xstats_by_name_get_t dev_xstats_by_name_get;
547
549 mldev_xstats_get_t dev_xstats_get;
550
552 mldev_xstats_reset_t dev_xstats_reset;
553
555 mldev_dump_t dev_dump;
556
558 mldev_selftest_t dev_selftest;
559
561 mldev_model_load_t model_load;
562
564 mldev_model_unload_t model_unload;
565
567 mldev_model_start_t model_start;
568
570 mldev_model_stop_t model_stop;
571
573 mldev_model_info_get_t model_info_get;
574
576 mldev_model_params_update_t model_params_update;
577
579 mldev_io_quantize_t io_quantize;
580
582 mldev_io_dequantize_t io_dequantize;
583};
584
591struct rte_ml_dev_data {
593 int16_t dev_id;
594
596 int16_t socket_id;
597
599 __extension__ uint8_t dev_started : 1;
600
602 uint16_t nb_queue_pairs;
603
605 uint16_t nb_models;
606
608 void **queue_pairs;
609
611 void **models;
612
614 void *dev_private;
615
617 char name[RTE_ML_STR_MAX];
618};
619
625struct __rte_cache_aligned rte_ml_dev {
627 mldev_enqueue_t enqueue_burst;
628
630 mldev_dequeue_t dequeue_burst;
631
633 mldev_op_error_get_t op_error_get;
634
636 struct rte_ml_dev_data *data;
637
639 struct rte_ml_dev_ops *dev_ops;
640
642 struct rte_device *device;
643
645 __extension__ uint8_t attached : 1;
646};
647
653struct rte_ml_dev_global {
655 struct rte_ml_dev *devs;
656
658 struct rte_ml_dev_data **data;
659
661 uint8_t nb_devs;
662
664 uint8_t max_devs;
665};
666
667#endif /* RTE_MLDEV_INTERNAL_H */
#define __rte_cache_aligned
Definition: rte_common.h:627
#define RTE_ML_STR_MAX
Definition: rte_mldev.h:152
rte_ml_dev_xstats_mode
Definition: rte_mldev.h:632
int(* mldev_info_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_info *dev_info)