Skip to content

Commit

Permalink
SEP/SOCWATCH Update SoCWatch driver after rebasing to linux v5.7
Browse files Browse the repository at this point in the history
- cta driver interface API renamed to pmt for the telemetry aggregator.
- driver level pci enumeration
- locking around pch mailbox accesses

Signed-off-by: Faycal Benmmlih <faycal.benmlih@intel.com>
  • Loading branch information
fbenmlih committed Sep 25, 2020
1 parent 80c46c8 commit cd0ae8e
Show file tree
Hide file tree
Showing 14 changed files with 6,431 additions and 6,167 deletions.
11 changes: 6 additions & 5 deletions drivers/platform/x86/socwatch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

DRIVER_BASE=socwatch
DRIVER_MAJOR=2
DRIVER_MINOR=11
DRIVER_MINOR=12
# basic name of driver
DRIVER_NAME=${DRIVER_BASE}${DRIVER_MAJOR}_${DRIVER_MINOR}

Expand All @@ -17,7 +17,8 @@ obj-$(CONFIG_INTEL_SOCWATCH) += $(DRIVER_NAME).o

$(DRIVER_NAME)-objs := sw_driver.o sw_hardware_io.o \
sw_output_buffer.o sw_tracepoint_handlers.o \
sw_mem.o sw_collector.o sw_telem.o \
sw_file_ops.o sw_internal.o sw_ops_provider.o \
sw_reader.o sw_trace_notifier_provider.o sw_cta.o \
sw_counter_list.o
sw_collector.o sw_mem.o sw_internal.o \
sw_file_ops.o sw_ops_provider.o \
sw_trace_notifier_provider.o sw_reader.o \
sw_telem.o sw_pmt.o sw_counter_list.o sw_pci.o \

8 changes: 6 additions & 2 deletions drivers/platform/x86/socwatch/inc/sw_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,12 @@ int sw_setup_telem(u64 addrs[3]);
*/
void sw_destroy_telem(void);
/*
* Retrieve CTA endpoint descriptors
* Retrieve PMT endpoint descriptors
*/
struct _sw_aggregator_msg const *sw_get_cta_aggregators(void);
struct _sw_aggregator_msg const *sw_get_pmt_aggregators(void);
/*
* Retrieve list of PCI devices on system
*/
struct sw_pci_dev_msg const *sw_get_pci_dev_list(void);

#endif /* __SW_DATA_STRUCTS_H__ */
21 changes: 14 additions & 7 deletions drivers/platform/x86/socwatch/inc/sw_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ enum sw_ioctl_cmd {
sw_ioctl_cmd_config_continuous,
sw_ioctl_cmd_read_continuous,
sw_ioctl_cmd_telem_bar,
sw_ioctl_cmd_avail_cta_aggregators,
sw_ioctl_cmd_avail_pmt_aggregators,
sw_ioctl_cmd_pci_dev_list,
};
/*
* The actual IOCTL commands.
Expand Down Expand Up @@ -230,8 +231,10 @@ enum sw_ioctl_cmd {
_IOW(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_read_continuous, struct sw_driver_ioctl_arg *)
#define PW_IOCTL_SET_TELEM_BAR \
_IOW(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_telem_bar, struct sw_driver_ioctl_arg *)
#define PW_IOCTL_AVAIL_CTA_AGGREGATORS \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_avail_cta_aggregators, struct sw_driver_ioctl_arg *)
#define PW_IOCTL_AVAIL_PMT_AGGREGATORS \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_avail_pmt_aggregators, struct sw_driver_ioctl_arg *)
#define PW_IOCTL_GET_PCI_DEVICE_LIST \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_pci_dev_list, struct sw_driver_ioctl_arg *)

#else /* __APPLE__ */
#define PW_IOCTL_CONFIG \
Expand Down Expand Up @@ -267,8 +270,10 @@ enum sw_ioctl_cmd {
_IOW(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_read_continuous, struct sw_driver_ioctl_arg)
#define PW_IOCTL_SET_TELEM_BAR \
_IOW(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_telem_bar, struct sw_driver_ioctl_arg)
#define PW_IOCTL_AVAIL_CTA_AGGREGATORS \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_avail_cta_aggregators, struct sw_driver_ioctl_arg)
#define PW_IOCTL_AVAIL_PMT_AGGREGATORS \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_avail_pmt_aggregators, struct sw_driver_ioctl_arg)
#define PW_IOCTL_GET_PCI_DEVICE_LIST \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_pci_dev_list, struct sw_driver_ioctl_arg)
#endif /* __APPLE__ */

/*
Expand Down Expand Up @@ -311,7 +316,9 @@ enum sw_ioctl_cmd {
_IOW(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_read_continuous, compat_uptr_t)
#define PW_IOCTL_SET_TELEM_BAR32 \
_IOW(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_telem_bar, compat_uptr_t)
#define PW_IOCTL_AVAIL_CTA_AGGREGATORS32 \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_avail_cta_aggregators, compat_uptr_t)
#define PW_IOCTL_AVAIL_PMT_AGGREGATORS32 \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_avail_pmt_aggregators, compat_uptr_t)
#define PW_IOCTL_GET_PCI_DEVICE_LIST32 \
_IOR(APWR_IOCTL_MAGIC_NUM, sw_ioctl_cmd_pci_dev_list, compat_uptr_t)
#endif /* defined(CONFIG_COMPAT) && defined(CONFIG_X86_64) */
#endif /* __SW_IOCTL_H__ */
61 changes: 61 additions & 0 deletions drivers/platform/x86/socwatch/inc/sw_pci.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* SPDX-License-Identifier: GPL-2.0 AND BSD-3-Clause
*
* This file is provided under a dual BSD/GPLv2 license. When using or
* redistributing this file, you may do so under either license.
*
* GPL LICENSE SUMMARY
*
* Copyright(c) 2020 Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* Contact Information:
* SoC Watch Developer Team <socwatchdevelopers@intel.com>
* Intel Corporation,
* 1300 S Mopac Expwy,
* Austin, TX 78746
*
* BSD LICENSE
*
* Copyright(c) 2020 Intel Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Intel Corporation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SW_PCI_H__
#define __SW_PCI_H__

void sw_pci_enumerate_devices(void);
struct sw_pci_dev_msg const *sw_pci_dev_list(void);

#endif // __SW_PCI_H__
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __SW_CTA_H__
#define __SW_CTA_H__
#ifndef __SW_PMT_H__
#define __SW_PMT_H__


bool sw_cta_register(void);
bool sw_cta_unregister(void);
bool sw_pmt_register(void);
bool sw_pmt_unregister(void);

void sw_read_cta_info(char *dst_vals, int cpu,
void sw_read_pmt_info(char *dst_vals, int cpu,
const struct sw_driver_io_descriptor *descriptor,
u16 counter_size_in_bytes);
bool sw_cta_available(void);
bool sw_pmt_available(void);

struct _sw_aggregator_msg *sw_cta_aggregators(void);
struct _sw_aggregator_msg *sw_pmt_aggregators(void);

#endif // __SW_CTA_H__
#endif // __SW_PMT_H__
46 changes: 36 additions & 10 deletions drivers/platform/x86/socwatch/inc/sw_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ typedef enum sw_when_type {
/*
* AGGREGATOR TELEMETRY
*/
#define MAX_TELEM_AGGR_DEVICES 10
#define MAX_AGGR_TELEM_ENDPOINTS 10

/*
* PCI Devices
*/
#define MAX_PCI_DEVICES 256

enum sw_io_cmd {
SW_IO_CMD_READ = 0,
Expand Down Expand Up @@ -268,16 +272,18 @@ struct sw_driver_telem_io_descriptor {
#pragma pack(push, 1)
/**
* struct - sw_driver_aggr_telem_io_descriptor - Aggregate Telemetry Metric descriptor
* This descriptor is used to interact with TA and CTA driver to get aggregate telemetry data
* This descriptor is used to interact with TA and PMT driver to get aggregate telemetry data
* @num_entries: number of entries we want to read from aggregate telemetry SRAM.
* Note: These entries should be contigous then only TA and CTA driver can read them together
* Note: These entries should be contigous then only TA and PMT driver can read them together
* @offset First offset which we want to read from aggregate telemetry data
* All the offsets are specified in the XML file
*/
struct sw_driver_aggr_telem_io_descriptor {
pw_u64_t offset;
pw_u64_t data_remapped_address;
pw_u32_t num_entries;
pw_u64_t offset;
pw_u64_t data_remapped_address;
pw_u32_t num_entries;
pw_u32_t guid;
pw_u32_t pciDevId;
};
#pragma pack(pop)

Expand Down Expand Up @@ -569,17 +575,37 @@ typedef struct sw_driver_msg_interval {
#pragma pack(push, 1)
typedef struct _sw_aggregator_info {
pw_u64_t startAddress;
pw_u32_t globalUniqueID;
pw_u32_t globallyUniqueId;
pw_u32_t pciDevId;
pw_u32_t size;
pw_u16_t collectionType; // SW_IO_AGGR_TA or SW_IO_AGGR_PMT
} sw_aggregator_info;

typedef struct _sw_aggregator_msg {
pw_u32_t num_entries;
sw_aggregator_info info[MAX_TELEM_AGGR_DEVICES]; /* Array of sw_aggregator_info structs. */
pw_u32_t num_telem_endpoints;
sw_aggregator_info info[MAX_AGGR_TELEM_ENDPOINTS]; /* Array of sw_aggregator_info structs. */
} sw_aggregator_msg;

#define AGGREGATOR_BUFFER_SIZE(entries) (sizeof(sw_aggregator_info) * entries + sizeof(pw_u32_t))
#define AGGREGATOR_BUFFER_SIZE(num_telem_endpoints) (sizeof(sw_aggregator_info) * num_telem_endpoints + sizeof(pw_u32_t))
#pragma pack(pop)

#pragma pack(push, 1)
struct sw_pci_dev_info {
pw_u32_t classID; /* 3 bytes: (base,sub,prog-if) */
pw_u16_t bus;
pw_u16_t device;
pw_u16_t function;
pw_u16_t vendorID;
pw_u16_t deviceID;
pw_u8_t headerType; /* PCI header type (`multi' flag masked out) */
};

struct sw_pci_dev_msg {
pw_u32_t num_entries;
struct sw_pci_dev_info info[MAX_PCI_DEVICES]; /* Array of sw_pci_dev_info structs. */
};

#define PCI_DEV_BUFFER_SIZE(entries) (sizeof(struct sw_pci_dev_info) * (entries) + sizeof(pw_u32_t))
#pragma pack(pop)

#endif /* __SW_STRUCTS_H__ */
2 changes: 1 addition & 1 deletion drivers/platform/x86/socwatch/inc/sw_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
* SOCWatch driver version
*/
#define SW_DRIVER_VERSION_MAJOR 2
#define SW_DRIVER_VERSION_MINOR 11
#define SW_DRIVER_VERSION_MINOR 12
#define SW_DRIVER_VERSION_OTHER 1

#endif /* __SW_VERSION_H__ */
Loading

0 comments on commit cd0ae8e

Please sign in to comment.