net: ipa: introduce ipa_syfs.c
Subsystems (3)
cover net: ipa: introduce ipa_syfs.c
This series (its last patch, actually) creates a new source file, "ipa_syfs.c", to contain functions and data that expose to user space information known by the IPA driver via device attributes.
The directory containing these files on supported systems is:
/sys/devices/platform/soc@0/1e40000.ipa
And within that direcftory, the following files and directories are added:
.
|-- feature
| |-- rx_offload Type of checksum offload supported
| `-- tx_offload
| . . .
|-- modem
| |-- rx_endpoint_id IPA endpoint IDs for the embedded modem
| `-- tx_endpoint_id
| . . .
|-- version IPA hardware version (informational)
. . .The first patch just makes endpoint validation unconditional, as suggested by Leon Romanovsky. The second just ensures the version defined in configuration data is valid, so the version attribute doesn't have to handle unrecognized version numbers.
-Alex
Alex Elder (3):
net: ipa: make endpoint data validation unconditional
net: ipa: introduce ipa_version_valid()
net: ipa: introduce sysfs code
.../testing/sysfs-devices-platform-soc-ipa | 78 ++++++++++ drivers/net/ipa/Makefile | 3 +- drivers/net/ipa/ipa_endpoint.c | 12 -- drivers/net/ipa/ipa_main.c | 36 ++++- drivers/net/ipa/ipa_sysfs.c | 136 ++++++++++++++++++ drivers/net/ipa/ipa_sysfs.h | 15 ++ drivers/net/ipa/ipa_version.h | 2 + 7 files changed, 268 insertions(+), 14 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-devices-platform-soc-ipa create mode 100644 drivers/net/ipa/ipa_sysfs.c create mode 100644 drivers/net/ipa/ipa_sysfs.h
Signature · 1 line
2.27.0
PATCH 1/3 net: ipa: make endpoint data validation unconditional
The cost of validating the endpoint configuration data is not all that high, so just do it unconditionally, rather than doing so only when IPA_VALIDATAION is defined.
--- drivers/net/ipa/ipa_endpoint.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/net/ipa/ipa_endpoint.c +0 -12
@@ -75,8 +75,6 @@ struct ipa_status {#define IPA_STATUS_FLAGS1_RT_RULE_ID_FMASK GENMASK(31, 22)#define IPA_STATUS_FLAGS2_TAG_FMASK GENMASK_ULL(63, 16) -#ifdef IPA_VALIDATE -static bool ipa_endpoint_data_valid_one (struct ipa *ipa,u32 count,const struct ipa_gsi_endpoint_data *all_data,const struct ipa_gsi_endpoint_data *data)
@@ -225,16 +223,6 @@ static bool ipa_endpoint_data_valid(struct ipa *ipa, u32 count,return true; } -#else /* !IPA_VALIDATE */ - -static bool ipa_endpoint_data_valid (struct ipa *ipa,u32 count, -const struct ipa_gsi_endpoint_data *data) -{ -return true; -} - -#endif /* !IPA_VALIDATE */ -/* Allocate a transaction to use on a non-command endpoint */ static struct gsi_trans *ipa_endpoint_trans_alloc (struct ipa_endpoint *endpoint,u32 tre_count)
Signature · 1 line
2.27.0
PATCH 2/3 net: ipa: introduce ipa_version_valid()
In reply to Alex ElderDefine and use a new function that just validates the version defined in configuration data.
--- drivers/net/ipa/ipa_main.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/net/ipa/ipa_main.c +26 -1
@@ -639,6 +639,27 @@ static void ipa_validate_build(void)#endif /* IPA_VALIDATE */ } +static bool ipa_version_valid (enum ipa_version version) +{ +switch (version) { +case IPA_VERSION_3_0 : +case IPA_VERSION_3_1 : +case IPA_VERSION_3_5 : +case IPA_VERSION_3_5_1 : +case IPA_VERSION_4_0 : +case IPA_VERSION_4_1 : +case IPA_VERSION_4_2 : +case IPA_VERSION_4_5 : +case IPA_VERSION_4_7 : +case IPA_VERSION_4_9 : +case IPA_VERSION_4_11 : +return true; + +default : +return false; + } +} +/** * ipa_probe() - IPA platform driver probe function * @pdev: Platform device pointer
@@ -676,11 +697,15 @@ static int ipa_probe(struct platform_device *pdev)/* Get configuration data early; needed for clock initialization */ data =of_device_get_match_data (dev);if (!data) { -/* This is really IPA_VALIDATE (should never happen) */ dev_err (dev,"matched hardware not supported\n" );return -ENODEV ; } +if (!ipa_version_valid (data->version)) { +dev_err (dev,"invalid IPA version\n" ); +return -EINVAL ; + } +/* If we need Trust Zone, make sure it's available */ modem_init =of_property_read_bool (dev->of_node,"modem-init" );if (!modem_init)
Signature · 1 line
2.27.0
PATCH 3/3 net: ipa: introduce sysfs code
In reply to Alex ElderAdd IPA device attributes to expose information known by the IPA driver about the hardware and its configuration.
All pointers used to display these attribute values (i.e., IPA pointer and endpoint pointers) will have been initialized by the time IPA probe has completed, so they may be safely dereferenced.
--- .../testing/sysfs-devices-platform-soc-ipa | 78 ++++++++++ drivers/net/ipa/Makefile | 3 +- drivers/net/ipa/ipa_main.c | 9 ++ drivers/net/ipa/ipa_sysfs.c | 136 ++++++++++++++++++ drivers/net/ipa/ipa_sysfs.h | 15 ++ drivers/net/ipa/ipa_version.h | 2 + 6 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 Documentation/ABI/testing/sysfs-devices-platform-soc-ipa create mode 100644 drivers/net/ipa/ipa_sysfs.c create mode 100644 drivers/net/ipa/ipa_sysfs.h
Documentation/ABI/testing/sysfs-devices-platform-soc-ipa new file +78 -0
@@ -0,0 +1,78 @@ +What: /sys/devices/platform/soc@X/XXXXXXX.ipa/ +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The /sys/devices/platform/soc@X/XXXXXXX.ipa/ directory + contains read-only attributes exposing information about + an IPA device. The X values could vary, but are typically + "soc@0/1e40000.ipa". + +What: .../XXXXXXX.ipa/version +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/version file contains the IPA hardware + version, as a period-separated set of two or three integers + (e.g., "3.5.1" or "4.2"). + +What: .../XXXXXXX.ipa/feature/ +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/feature/ directory contains a set of + attributes describing features implemented by the IPA + hardware. + +What: .../XXXXXXX.ipa/feature/rx_offload +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/feature/rx_offload file contains a + string indicating the type of receive checksum offload + that is supported by the hardware. The possible values + are "MAPv4" or "MAPv5". + +What: .../XXXXXXX.ipa/feature/tx_offload +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/feature/tx_offload file contains a + string indicating the type of transmit checksum offload + that is supported by the hardware. The possible values + are "MAPv4" or "MAPv5". + +What: .../XXXXXXX.ipa/modem/ +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/modem/ directory contains a set of + attributes describing properties of the modem execution + environment reachable by the IPA hardware. + +What: .../XXXXXXX.ipa/modem/rx_endpoint_id +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/feature/rx_endpoint_id file contains + the AP endpoint ID that receives packets originating from + the modem execution environment. The "rx" is from the + perspective of the AP; this endpoint is considered an "IPA + producer". An endpoint ID is a small unsigned integer. + +What: .../XXXXXXX.ipa/modem/tx_endpoint_id +Date: June 2021 +KernelVersion: v5.14 +Contact: Alex Elder <[email protected]> +Description: + The .../XXXXXXX.ipa/feature/tx_endpoint_id file contains + the AP endpoint ID used to transmit packets destined for + the modem execution environment. The "tx" is from the + perspective of the AP; this endpoint is considered an "IPA + consumer". An endpoint ID is a small unsigned integer.
drivers/net/ipa/Makefile +2 -1
@@ -7,7 +7,8 @@ ipa-y := ipa_main.o ipa_clock.o ipa_reg.o ipa_mem.o \ ipa_table.o ipa_interrupt.o gsi.o gsi_trans.o \ ipa_gsi.o ipa_smp2p.o ipa_uc.o \ ipa_endpoint.o ipa_cmd.o ipa_modem.o \ - ipa_resource.o ipa_qmi.o ipa_qmi_msg.o + ipa_resource.o ipa_qmi.o ipa_qmi_msg.o \ + ipa_sysfs.o ipa-y += ipa_data-v3.5.1.o ipa_data-v4.2.o \ ipa_data-v4.5.o ipa_data-v4.9.o \
drivers/net/ipa/ipa_main.c +9 -0
@@ -31,6 +31,7 @@#include "ipa_uc.h" #include "ipa_interrupt.h" #include "gsi_trans.h" +#include "ipa_sysfs.h" /** * DOC: The IP Accelerator
@@ -906,6 +907,13 @@ static const struct dev_pm_ops ipa_pm_ops = { .resume = ipa_resume, }; +static const struct attribute_group *ipa_attribute_groups[] = { + &ipa_attribute_group, + &ipa_feature_attribute_group, + &ipa_modem_attribute_group, +NULL , +}; +static struct platform_driver ipa_driver = { .probe = ipa_probe, .remove = ipa_remove,
@@ -914,6 +922,7 @@ static struct platform_driver ipa_driver = { .name = "ipa", .pm = &ipa_pm_ops, .of_match_table = ipa_match, + .dev_groups = ipa_attribute_groups, }, };
drivers/net/ipa/ipa_sysfs.c new file +136 -0
136 lines not on this page · raw message
drivers/net/ipa/ipa_sysfs.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +* Copyright (C) 2019-2021 Linaro Ltd. +*/ +#ifndef _IPA_SYSFS_H_ +#define _IPA_SYSFS_H_ + +struct attribute_group ; + +extern const struct attribute_group ipa_attribute_group; +extern const struct attribute_group ipa_feature_attribute_group; +extern const struct attribute_group ipa_modem_attribute_group; + +#endif /* _IPA_SYSFS_H_ */
drivers/net/ipa/ipa_version.h +2 -0
@@ -21,6 +21,8 @@* @IPA_VERSION_4_11: IPA version 4.11/GSI version 2.11 (2.1.1) * * Defines the version of IPA (and GSI) hardware present on the platform. +* Please update ipa_version_valid() and ipa_version_string() whenever a +* new version is added. */ enum ipa_version {IPA_VERSION_3_0 ,
Signature · 1 line
2.27.0
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Fri, 11 Jun 2021 15:39:37 -0500 you wrote:
This series (its last patch, actually) creates a new source file, "
ipa_syfs.c", to contain functions and data that expose to user space information known by the IPA driver via device attributes.The directory containing these files on supported systems is:
/sys/devices/platform/soc@0/1e40000.ipa[...]
Here is the summary with links:
- [net-next,1/3] net: ipa: make endpoint data validation unconditional
https://git.kernel.org/netdev/net-next/c/9e8fb7bf9c80 - [net-next,2/3] net: ipa: introduce ipa_version_valid() https://git.kernel.org/netdev/net-next/c/e22e8e2fae61 - [net-next,3/3] net: ipa: introduce sysfs code https://git.kernel.org/netdev/net-next/c/2e3cf97f4741
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html