stm class: Add source type
authorMikhail Lappo <miklelappo@gmail.com>
Mon, 29 Apr 2024 13:01:06 +0000 (16:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 4 May 2024 16:57:21 +0000 (18:57 +0200)
Currently kernel HW tracing infrastrtucture and specifically its SyS-T
part treats all source data in the same way. Treating and encoding
different trace data sources differently might allow decoding software
to make use of e.g. ftrace event ids by converting them to a SyS-T
message catalog.

The solution is to keep source type stored within stm_source_data
structure to allow different handling by stm output/protocol.
Currently we only differentiate between STM_USER and STM_FTRACE sources.

Signed-off-by: Mikhail Lappo <miklelappo@gmail.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240429130119.1518073-3-alexander.shishkin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/stm/console.c
drivers/hwtracing/stm/ftrace.c
drivers/hwtracing/stm/heartbeat.c
include/linux/stm.h

index a00f65e217477e9eaccfbf18acbef1256fd12220..097a00ac43a754db00519076a6fbf3ac4e018591 100644 (file)
@@ -22,6 +22,7 @@ static struct stm_console {
        .data   = {
                .name           = "console",
                .nr_chans       = 1,
+               .type           = STM_USER,
                .link           = stm_console_link,
                .unlink         = stm_console_unlink,
        },
index 3bb606dfa634a3439315fec44b877f394b2a8f61..a7cea7ea01634c5334d87ae24eb80e132ed01bcf 100644 (file)
@@ -23,6 +23,7 @@ static struct stm_ftrace {
        .data   = {
                .name           = "ftrace",
                .nr_chans       = STM_FTRACE_NR_CHANNELS,
+               .type           = STM_FTRACE,
                .link           = stm_ftrace_link,
                .unlink         = stm_ftrace_unlink,
        },
index 81d7b21d31ec27312ab39b853f28593781d005d8..e9496fe97baa10f8c0115ef841b599fc66734a94 100644 (file)
@@ -78,6 +78,7 @@ static int stm_heartbeat_init(void)
                }
 
                stm_heartbeat[i].data.nr_chans  = 1;
+               stm_heartbeat[i].data.type      = STM_USER;
                stm_heartbeat[i].data.link      = stm_heartbeat_link;
                stm_heartbeat[i].data.unlink    = stm_heartbeat_unlink;
                hrtimer_init(&stm_heartbeat[i].hrtimer, CLOCK_MONOTONIC,
index 3b22689512be2afe35aaa5bd36c6b6ccfa7eb621..2fcbef9608f63cb8a1c3c811123c2790165b9486 100644 (file)
@@ -30,6 +30,16 @@ enum stp_packet_flags {
        STP_PACKET_TIMESTAMPED  = 0x2,
 };
 
+/**
+ * enum stm_source_type - STM source driver
+ * @STM_USER: any STM trace source
+ * @STM_FTRACE: ftrace STM source
+ */
+enum stm_source_type {
+       STM_USER,
+       STM_FTRACE,
+};
+
 struct stp_policy;
 
 struct stm_device;
@@ -106,6 +116,7 @@ struct stm_source_device;
  * @name:      device name, will be used for policy lookup
  * @src:       internal structure, only used by stm class code
  * @nr_chans:  number of channels to allocate
+ * @type:      type of STM source driver represented by stm_source_type
  * @link:      called when this source gets linked to an STM device
  * @unlink:    called when this source is about to get unlinked from its STM
  *
@@ -117,6 +128,7 @@ struct stm_source_data {
        struct stm_source_device *src;
        unsigned int            percpu;
        unsigned int            nr_chans;
+       unsigned int            type;
        int                     (*link)(struct stm_source_data *data);
        void                    (*unlink)(struct stm_source_data *data);
 };