DPDK  23.03.0
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 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <stdint.h>
24 
25 #include <dev_driver.h>
26 #include <rte_common.h>
27 #include <rte_log.h>
28 #include <rte_mldev.h>
29 
30 /* Device state */
31 #define ML_DEV_DETACHED (0)
32 #define ML_DEV_ATTACHED (1)
33 
34 struct rte_ml_dev;
35 
53 typedef uint16_t (*mldev_enqueue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
54  uint16_t nb_ops);
55 
73 typedef uint16_t (*mldev_dequeue_t)(struct rte_ml_dev *dev, uint16_t qp_id, struct rte_ml_op **ops,
74  uint16_t nb_ops);
75 
92 typedef int (*mldev_op_error_get_t)(struct rte_ml_dev *dev, struct rte_ml_op *op,
93  struct rte_ml_op_error *error);
94 
114 typedef int (*mldev_info_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_info *dev_info);
115 
130 typedef int (*mldev_configure_t)(struct rte_ml_dev *dev, const struct rte_ml_dev_config *config);
131 
145 typedef int (*mldev_close_t)(struct rte_ml_dev *dev);
146 
159 typedef int (*mldev_start_t)(struct rte_ml_dev *dev);
160 
173 typedef int (*mldev_stop_t)(struct rte_ml_dev *dev);
174 
193 typedef int (*mldev_queue_pair_setup_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id,
194  const struct rte_ml_dev_qp_conf *queue_pair_conf,
195  int socket_id);
196 
211 typedef int (*mldev_queue_pair_release_t)(struct rte_ml_dev *dev, uint16_t queue_pair_id);
212 
227 typedef int (*mldev_stats_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_stats *stats);
228 
237 typedef void (*mldev_stats_reset_t)(struct rte_ml_dev *dev);
238 
256 typedef int (*mldev_xstats_names_get_t)(struct rte_ml_dev *dev,
257  struct rte_ml_dev_xstats_map *xstats_map, uint32_t size);
258 
277 typedef int (*mldev_xstats_by_name_get_t)(struct rte_ml_dev *dev, const char *name,
278  uint16_t *stat_id, uint64_t *value);
279 
298 typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, const uint16_t *stat_ids,
299  uint64_t *values, uint16_t nb_ids);
300 
317 typedef int (*mldev_xstats_reset_t)(struct rte_ml_dev *dev, const uint16_t *stat_ids,
318  uint16_t nb_ids);
319 
335 typedef int (*mldev_dump_t)(struct rte_ml_dev *dev, FILE *fd);
336 
349 typedef int (*mldev_selftest_t)(struct rte_ml_dev *dev);
350 
367 typedef int (*mldev_model_load_t)(struct rte_ml_dev *dev, struct rte_ml_model_params *params,
368  uint16_t *model_id);
369 
384 typedef int (*mldev_model_unload_t)(struct rte_ml_dev *dev, uint16_t model_id);
385 
400 typedef int (*mldev_model_start_t)(struct rte_ml_dev *dev, uint16_t model_id);
401 
416 typedef int (*mldev_model_stop_t)(struct rte_ml_dev *dev, uint16_t model_id);
417 
434 typedef int (*mldev_model_info_get_t)(struct rte_ml_dev *dev, uint16_t model_id,
435  struct rte_ml_model_info *model_info);
436 
453 typedef int (*mldev_model_params_update_t)(struct rte_ml_dev *dev, uint16_t model_id, void *buffer);
454 
475 typedef int (*mldev_io_input_size_get_t)(struct rte_ml_dev *dev, uint16_t model_id,
476  uint32_t nb_batches, uint64_t *input_qsize,
477  uint64_t *input_dsize);
478 
499 typedef int (*mldev_io_output_size_get_t)(struct rte_ml_dev *dev, uint16_t model_id,
500  uint32_t nb_batches, uint64_t *output_qsize,
501  uint64_t *output_dsize);
502 
523 typedef int (*mldev_io_quantize_t)(struct rte_ml_dev *dev, uint16_t model_id, uint16_t nb_batches,
524  void *dbuffer, void *qbuffer);
525 
546 typedef int (*mldev_io_dequantize_t)(struct rte_ml_dev *dev, uint16_t model_id, uint16_t nb_batches,
547  void *qbuffer, void *dbuffer);
548 
554 struct rte_ml_dev_ops {
556  mldev_info_get_t dev_info_get;
557 
559  mldev_configure_t dev_configure;
560 
562  mldev_close_t dev_close;
563 
565  mldev_start_t dev_start;
566 
568  mldev_stop_t dev_stop;
569 
571  mldev_queue_pair_setup_t dev_queue_pair_setup;
572 
574  mldev_queue_pair_release_t dev_queue_pair_release;
575 
577  mldev_stats_get_t dev_stats_get;
578 
580  mldev_stats_reset_t dev_stats_reset;
581 
583  mldev_xstats_names_get_t dev_xstats_names_get;
584 
586  mldev_xstats_by_name_get_t dev_xstats_by_name_get;
587 
589  mldev_xstats_get_t dev_xstats_get;
590 
592  mldev_xstats_reset_t dev_xstats_reset;
593 
595  mldev_dump_t dev_dump;
596 
598  mldev_selftest_t dev_selftest;
599 
601  mldev_model_load_t model_load;
602 
604  mldev_model_unload_t model_unload;
605 
607  mldev_model_start_t model_start;
608 
610  mldev_model_stop_t model_stop;
611 
613  mldev_model_info_get_t model_info_get;
614 
616  mldev_model_params_update_t model_params_update;
617 
619  mldev_io_input_size_get_t io_input_size_get;
620 
622  mldev_io_output_size_get_t io_output_size_get;
623 
625  mldev_io_quantize_t io_quantize;
626 
628  mldev_io_dequantize_t io_dequantize;
629 };
630 
637 struct rte_ml_dev_data {
639  int16_t dev_id;
640 
642  int16_t socket_id;
643 
645  __extension__ uint8_t dev_started : 1;
646 
648  uint16_t nb_queue_pairs;
649 
651  uint16_t nb_models;
652 
654  void **queue_pairs;
655 
657  void **models;
658 
660  void *dev_private;
661 
663  char name[RTE_ML_STR_MAX];
664 };
665 
671 struct rte_ml_dev {
673  mldev_enqueue_t enqueue_burst;
674 
676  mldev_dequeue_t dequeue_burst;
677 
679  mldev_op_error_get_t op_error_get;
680 
682  struct rte_ml_dev_data *data;
683 
685  struct rte_ml_dev_ops *dev_ops;
686 
688  struct rte_device *device;
689 
691  __extension__ uint8_t attached : 1;
693 
699 struct rte_ml_dev_global {
701  struct rte_ml_dev *devs;
702 
704  struct rte_ml_dev_data **data;
705 
707  uint8_t nb_devs;
708 
710  uint8_t max_devs;
711 };
712 
713 #ifdef __cplusplus
714 }
715 #endif
716 
717 #endif /* RTE_MLDEV_INTERNAL_H */
#define RTE_ML_STR_MAX
Definition: rte_mldev.h:151
int(* mldev_info_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_info *dev_info)
void * dev_private
#define __rte_cache_aligned
Definition: rte_common.h:440