1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2022 Intel Corporation. All rights reserved.
4  */
5 
6 /*
7  * This file contains structures that are exact copies of an existing ABI used
8  * by IOT middleware. They are Intel specific and will be used by one middleware.
9  *
10  * Some of the structures may contain programming implementations that makes them
11  * unsuitable for generic use and general usage.
12  *
13  * This code is mostly copied "as-is" from existing C++ interface files hence the use of
14  * different style in places. The intention is to keep the interface as close as possible to
15  * original so it's easier to track changes with IPC host code.
16  */
17 
18 /*
19  * \file include/ipc4/probe.h
20  * \brief probe ipc4 definitions.
21  * NOTE: This ABI uses bit fields and is non portable.
22  */
23 
24 #ifndef __SOF_IPC4_PROBE_H__
25 #define __SOF_IPC4_PROBE_H__
26 
27 #include <sof/compiler_attributes.h>
28 #include "base-config.h"
29 #include <rtos/bit.h>
30 #include <stdint.h>
31 
32 /*
33  * Buffer id used in the probe output stream headers for
34  * logging data packet.
35  */
36 #define PROBE_LOGGING_BUFFER_ID		0x01000000
37 
38 #define PROBE_PURPOSE_EXTRACTION	0
39 #define PROBE_PURPOSE_INJECTION		1
40 
41 #define PROBE_TYPE_INPUT		0
42 #define PROBE_TYPE_OUTPUT		1
43 #define PROBE_TYPE_INTERNAL		2
44 
45 #define IPC4_PROBE_MODULE_INJECTION_DMA_ADD	  1
46 #define IPC4_PROBE_MODULE_INJECTION_DMA_DETACH	  2
47 #define IPC4_PROBE_MODULE_PROBE_POINTS_ADD	  3
48 #define IPC4_PROBE_MODULE_DISCONNECT_PROBE_POINTS 4
49 
50 /**
51  * Description of probe dma
52  */
53 struct probe_dma {
54 	uint32_t stream_tag;		/**< Node_id associated with this DMA */
55 	uint32_t dma_buffer_size;	/**< Size of buffer associated with this DMA */
56 } __attribute__((packed, aligned(4)));
57 
58 /**
59  * Description of probe point id
60  */
61 typedef union probe_point_id {
62 	uint32_t full_id;
63 	struct {
64 		uint32_t  module_id   : 16;	/**< Target module ID */
65 		uint32_t  instance_id : 8;	/**< Target module instance ID */
66 		uint32_t  type        : 2;	/**< Probe point type as specified by ProbeType enumeration */
67 		uint32_t  index       : 6;	/**< Queue index inside target module */
68 	} fields;
69 } __attribute__((packed, aligned(4))) probe_point_id_t;
70 
71 /**
72  * Description of probe point
73  */
74 struct probe_point {
75 	probe_point_id_t buffer_id;	/**< ID of buffer to which probe is attached */
76 	uint32_t purpose;	/**< PROBE_PURPOSE_xxx */
77 	uint32_t stream_tag;	/**< Stream tag of DMA via which data will be provided for injection.
78 				 *   For extraction purposes, stream tag is ignored when received,
79 				 *   but returned actual extraction stream tag via INFO function.
80 				 */
81 } __attribute__((packed, aligned(4)));
82 
83 struct sof_ipc_probe_info_params {
84 	uint32_t num_elems;				/**< Count of elements in array */
85 	union {
86 		struct probe_dma probe_dma[0];		/**< DMA info */
87 		struct probe_point probe_point[0];	/**< Probe Point info */
88 	};
89 } __attribute__((packed, aligned(4)));
90 
91 struct ipc4_probe_module_cfg {
92 	struct ipc4_base_module_cfg base_cfg;
93 	struct probe_dma gtw_cfg;
94 } __packed __aligned(8);
95 
96 #endif /* __SOF_IPC4_PROBE_H__ */
97