1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Intel(R) Trace Hub data structures for implementing buffer sinks.
5 * Copyright (C) 2019 Intel Corporation.
11 #include <linux/scatterlist.h>
13 /* MSC operating modes (MSC_MODE) */
24 * ->assign() called when buffer 'mode' is set to this driver
26 * @device: struct device * of the msc
27 * @mode: allows the driver to set HW mode (see the enum above)
28 * Returns: a pointer to a private structure associated with this
29 * msc or NULL in case of error. This private structure
30 * will then be passed into all other callbacks.
32 void *(*assign)(struct device *dev, int *mode);
33 /* ->unassign(): some other mode is selected, clean up */
34 void (*unassign)(void *priv);
36 * ->alloc_window(): allocate memory for the window of a given
38 * @sgt: pointer to sg_table, can be overridden by the buffer
39 * driver, or kept intact
40 * Returns: number of sg table entries <= number of pages;
41 * 0 is treated as an allocation failure.
43 int (*alloc_window)(void *priv, struct sg_table **sgt,
45 void (*free_window)(void *priv, struct sg_table *sgt);
46 /* ->activate(): trace has started */
47 void (*activate)(void *priv);
48 /* ->deactivate(): trace is about to stop */
49 void (*deactivate)(void *priv);
51 * ->ready(): window @sgt is filled up to the last block OR
52 * tracing is stopped by the user; this window contains
53 * @bytes data. The window in question transitions into
54 * the "LOCKED" state, indicating that it can't be used
55 * by hardware. To clear this state and make the window
56 * available to the hardware again, call
57 * intel_th_msc_window_unlock().
59 int (*ready)(void *priv, struct sg_table *sgt, size_t bytes);
62 int intel_th_msu_buffer_register(const struct msu_buffer *mbuf,
63 struct module *owner);
64 void intel_th_msu_buffer_unregister(const struct msu_buffer *mbuf);
65 void intel_th_msc_window_unlock(struct device *dev, struct sg_table *sgt);
67 #define module_intel_th_msu_buffer(__buffer) \
68 static int __init __buffer##_init(void) \
70 return intel_th_msu_buffer_register(&(__buffer), THIS_MODULE); \
72 module_init(__buffer##_init); \
73 static void __exit __buffer##_exit(void) \
75 intel_th_msu_buffer_unregister(&(__buffer)); \
77 module_exit(__buffer##_exit);
79 #endif /* _INTEL_TH_H_ */