DPDK  24.07.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 
260 typedef int (*mldev_xstats_names_get_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
261  int32_t model_id, struct rte_ml_dev_xstats_map *xstats_map,
262  uint32_t size);
263 
282 typedef int (*mldev_xstats_by_name_get_t)(struct rte_ml_dev *dev, const char *name,
283  uint16_t *stat_id, uint64_t *value);
284 
307 typedef int (*mldev_xstats_get_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
308  int32_t model_id, const uint16_t stat_ids[], uint64_t values[],
309  uint16_t nb_ids);
310 
331 typedef int (*mldev_xstats_reset_t)(struct rte_ml_dev *dev, enum rte_ml_dev_xstats_mode mode,
332  int32_t model_id, const uint16_t stat_ids[], uint16_t nb_ids);
333 
349 typedef int (*mldev_dump_t)(struct rte_ml_dev *dev, FILE *fd);
350 
363 typedef int (*mldev_selftest_t)(struct rte_ml_dev *dev);
364 
381 typedef int (*mldev_model_load_t)(struct rte_ml_dev *dev, struct rte_ml_model_params *params,
382  uint16_t *model_id);
383 
398 typedef int (*mldev_model_unload_t)(struct rte_ml_dev *dev, uint16_t model_id);
399 
414 typedef int (*mldev_model_start_t)(struct rte_ml_dev *dev, uint16_t model_id);
415 
430 typedef int (*mldev_model_stop_t)(struct rte_ml_dev *dev, uint16_t model_id);
431 
448 typedef int (*mldev_model_info_get_t)(struct rte_ml_dev *dev, uint16_t model_id,
449  struct rte_ml_model_info *model_info);
450 
467 typedef int (*mldev_model_params_update_t)(struct rte_ml_dev *dev, uint16_t model_id, void *buffer);
468 
487 typedef int (*mldev_io_quantize_t)(struct rte_ml_dev *dev, uint16_t model_id,
488  struct rte_ml_buff_seg **dbuffer,
489  struct rte_ml_buff_seg **qbuffer);
490 
509 typedef int (*mldev_io_dequantize_t)(struct rte_ml_dev *dev, uint16_t model_id,
510  struct rte_ml_buff_seg **qbuffer,
511  struct rte_ml_buff_seg **dbuffer);
512 
518 struct rte_ml_dev_ops {
520  mldev_info_get_t dev_info_get;
521 
523  mldev_configure_t dev_configure;
524 
526  mldev_close_t dev_close;
527 
529  mldev_start_t dev_start;
530 
532  mldev_stop_t dev_stop;
533 
535  mldev_queue_pair_setup_t dev_queue_pair_setup;
536 
538  mldev_queue_pair_release_t dev_queue_pair_release;
539 
541  mldev_stats_get_t dev_stats_get;
542 
544  mldev_stats_reset_t dev_stats_reset;
545 
547  mldev_xstats_names_get_t dev_xstats_names_get;
548 
550  mldev_xstats_by_name_get_t dev_xstats_by_name_get;
551 
553  mldev_xstats_get_t dev_xstats_get;
554 
556  mldev_xstats_reset_t dev_xstats_reset;
557 
559  mldev_dump_t dev_dump;
560 
562  mldev_selftest_t dev_selftest;
563 
565  mldev_model_load_t model_load;
566 
568  mldev_model_unload_t model_unload;
569 
571  mldev_model_start_t model_start;
572 
574  mldev_model_stop_t model_stop;
575 
577  mldev_model_info_get_t model_info_get;
578 
580  mldev_model_params_update_t model_params_update;
581 
583  mldev_io_quantize_t io_quantize;
584 
586  mldev_io_dequantize_t io_dequantize;
587 };
588 
595 struct rte_ml_dev_data {
597  int16_t dev_id;
598 
600  int16_t socket_id;
601 
603  __extension__ uint8_t dev_started : 1;
604 
606  uint16_t nb_queue_pairs;
607 
609  uint16_t nb_models;
610 
612  void **queue_pairs;
613 
615  void **models;
616 
618  void *dev_private;
619 
621  char name[RTE_ML_STR_MAX];
622 };
623 
629 struct __rte_cache_aligned rte_ml_dev {
631  mldev_enqueue_t enqueue_burst;
632 
634  mldev_dequeue_t dequeue_burst;
635 
637  mldev_op_error_get_t op_error_get;
638 
640  struct rte_ml_dev_data *data;
641 
643  struct rte_ml_dev_ops *dev_ops;
644 
646  struct rte_device *device;
647 
649  __extension__ uint8_t attached : 1;
650 };
651 
657 struct rte_ml_dev_global {
659  struct rte_ml_dev *devs;
660 
662  struct rte_ml_dev_data **data;
663 
665  uint8_t nb_devs;
666 
668  uint8_t max_devs;
669 };
670 
671 #ifdef __cplusplus
672 }
673 #endif
674 
675 #endif /* RTE_MLDEV_INTERNAL_H */
#define RTE_ML_STR_MAX
Definition: rte_mldev.h:152
int(* mldev_info_get_t)(struct rte_ml_dev *dev, struct rte_ml_dev_info *dev_info)
#define __rte_cache_aligned
Definition: rte_common.h:568
rte_ml_dev_xstats_mode
Definition: rte_mldev.h:619