Skip to contentSkip to conversation

net: mvpp2: Add reserved port private flag configuration

PATCH In review [email protected] 4 participants 10 messages Mar 11, 2021 – Mar 22, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: mvpp2: Add reserved port private flag configuration

From: Stefan Chulski <[email protected]>

According to Armada SoC architecture and design, all the PPv2 ports which are populated on the same communication processor silicon die (CP11x) share the same Classifier and Parser engines.

Armada is an embedded platform and therefore there is a need to reserve some of the PPv2 ports for different use cases.

For example, a port can be reserved for a CM3 CPU running FreeRTOS for management purposes or by user-space data plane application.

During port reservation all common configurations are preserved and only RXQ, TXQ, and interrupt vectors are disabled.
Since TXQ's are disabled, the Kernel won't transmit any packet from this port, and to due the closed RXQ interrupts, the Kernel won't receive any packet.
The port MAC address and administrative UP/DOWN state can still be changed.
The only permitted configuration in this mode is MTU change. The driver's .ndo_change_mtu callback has logic that switches between percpu_pools and shared pools buffer mode, since the buffer management not done by Kernel this should be permitted.

v1 --> v2
- Rename existing mvpp2_ethtool_get_strings and helper _priv function
- Add more info to commit message

---
 drivers/net/ethernet/marvell/mvpp2/mvpp2.h      |   4 +
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 248 ++++++++++++++++++--
 2 files changed, 228 insertions(+), 24 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2.h +4 -0
index 8edba5e..e2f8eec 100644
@@ -865,6 +865,7 @@
 /* Port flags */
 #define MVPP2_F_LOOPBACK		BIT(0)
 #define MVPP2_F_DT_COMPAT		BIT(1)
+#define MVPP22_F_IF_RESERVED		BIT(2)
 
 /* Marvell tag types */
 enum mvpp2_tag_type {
@@ -1251,6 +1252,9 @@ struct mvpp2_port {
 
 	/* Firmware TX flow control */
 	bool tx_fc;
+
+	/* private storage, allocated/used by Reserved/Normal mode toggling */
+	void *res_cfg;
 };
 
 /* The mvpp2_tx_desc and mvpp2_rx_desc structures describe the
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +224 -24

373 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw
Quoted 1 line · On Thu, Mar 11, 2021 at 06:43:27PM +0200, [email protected] wrote:

From: Stefan Chulski <[email protected]>

Hi Stefan

Thanks for the strings change. Looks a lot better.

Now i took a look at the bigger picture.

Quoted 9 lines

According to Armada SoC architecture and design, all the PPv2 ports which are populated on the same communication processor silicon die (CP11x) share the same Classifier and Parser engines.

Armada is an embedded platform and therefore there is a need to reserve some of the PPv2 ports for different use cases.

For example, a port can be reserved for a CM3 CPU running FreeRTOS for management purposes

So the CM3 CPU has its own driver for this hardware? It seems like we should not even instantiate the Linux driver for this port. Does the CM3 have its own DT blob? I think the better solution is that the Armada DT for the board does not list the port, and the DT for the CM3 does. Linux never sees the port, since Linux should not be using it.

Quoted 1 line

or by user-space data plane application.

You mean XDP/AF_XDP? I don't see any other XDP capable drivers having a flag like this. If this was required, i would expect it to be a common properly, not driver private.

Andrew

#2 lore raw
Quoted 15 lines

Hi Stefan

Thanks for the strings change. Looks a lot better.

Now i took a look at the bigger picture.

Quoted 9 lines

According to Armada SoC architecture and design, all the PPv2 ports which are populated on the same communication processor silicon die (CP11x) share the same Classifier and Parser engines.

Armada is an embedded platform and therefore there is a need to reserve some of the PPv2 ports for different use cases.

For example, a port can be reserved for a CM3 CPU running FreeRTOS for management purposes

Hi Andrew and Jakub,

There are multiple reasons why we must let the kernel initialize and manage the reserved port:
1. According to pp2 hardware design, all classifier and parser configuration access are indirect. In order to prevent race conditions, it needs to be configured by single entity.
2. CM3 code has very small footprint requirement, we cannot implement the complete Serdes and PHY infrastructure that kernel provides as part of CM3 application. Therefore I would like to continue relying on kernel configuration for that.
3. In some cases we need to dynamically switch the port "user" between CM3 and kernel. So I would like to preserve this functionality.

Quoted 11 lines

So the CM3 CPU has its own driver for this hardware? It seems like we should not even instantiate the Linux driver for this port. Does the CM3 have its own DT blob? I think the better solution is that the Armada DT for the board does not list the port, and the DT for the CM3 does. Linux never sees the port, since Linux should not be using it.

Quoted 1 line

or by user-space data plane application.

You mean XDP/AF_XDP? I don't see any other XDP capable drivers having a flag like this. If this was required, i would expect it to be a common properly, not driver private.

No XDP doesn't require this. One of the use cases of the port reservation feature is the Marvell User Space SDK (MUSDK) which its latest code is publicly available here:
https://github.com/MarvellEmbeddedProcessors/musdk-marvell
You can find example use case for this application here:
http://wiki.macchiatobin.net/tiki-index.php?page=MUSDK+Introduction

Stefan.

#3 lore raw
Quoted 4 lines · Stefan Chulski

No XDP doesn't require this. One of the use cases of the port reservation feature is the Marvell User Space SDK (MUSDK) which its latest code is publicly available here:
https://github.com/MarvellEmbeddedProcessors/musdk-marvell
You can find example use case for this application here:
http://wiki.macchiatobin.net/tiki-index.php?page=MUSDK+Introduction

I really, really hope that someone has thought this through:

Packet Processor I/O Interface (PPIO)

The MUSDK PPIO driver provides low-level network interface API for User-Space network drivers/applications. The PPIO infrastrcuture maps Marvell's Packet Processor (PPv2) configuration space and I/O descriptors space directly to user-space memory. This allows user-space driver/application to directly process the packet processor I/O rings from user space, without any overhead of a copy operation.

I realy, really hope that you are not exposing the I/O descriptors to userspace, allowing userspace to manipulate the physical addresses in those descriptors, and that userspace is not dealing with physical addresses.

If userspace has access to the I/O descriptors with physical addresses, or userspace is dealing with physical addresses, then you can say good bye to any kind of security on the platform. Essentially, in such a scenario, the entire system memory becomes accessible to userspace, which includes the kernel.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#4 lore raw
Quoted 11 lines

I really, really hope that someone has thought this through:

Packet Processor I/O Interface (PPIO)

The MUSDK PPIO driver provides low-level network interface API for User-Space network drivers/applications. The PPIO infrastrcuture maps Marvell's Packet Processor (PPv2) configuration space and I/O descriptors space directly to user-space memory. This allows user-space driver/application to directly process the packet processor I/O rings from user space, without any overhead of a copy operation.

Quoted 8 lines

I realy, really hope that you are not exposing the I/O descriptors to userspace, allowing userspace to manipulate the physical addresses in those descriptors, and that userspace is not dealing with physical addresses.

If userspace has access to the I/O descriptors with physical addresses, or userspace is dealing with physical addresses, then you can say good bye to any kind of security on the platform. Essentially, in such a scenario, the entire system memory becomes accessible to userspace, which includes the kernel.

Hi Russel,

This patch doesn't relate to MUSDK Packet Processor I/O Interface functionality.
MUSDK is just another possible use case I could think of for the port reservation feature.
I am not responsible for the MUSDK code, but as far as I know it is based on the generic UIO Kernel interface (uio_pdrv_genirq) so the user can decide whether he wants to enable it or not for his platform. For the main CM3 management port use case, security is not an issue since the CM3 processor is secured by hardware in the device and its code is authenticated.

Stefan.

#5 lore raw
In reply to Stefan Chulski
Quoted 4 lines

2. CM3 code has very small footprint requirement, we cannot implement the complete Serdes and PHY infrastructure that kernel provides as part of CM3 application. Therefore I would like to continue relying on kernel configuration for that.

How can that work? How does Linux know when CM3 has up'ed the interface? How does CM3 know the status of the link? How does CM3 set its flow control depending on what auto-neg determines, etc?

Quoted 3 lines

3. In some cases we need to dynamically switch the port "user" between CM3 and kernel. So I would like to preserve this functionality.

And how do you synchronize between Linux and CM3 so you know how is using it and who cannot use it?

Andrew

#6 lore raw
Quoted 8 lines
Quoted 5 lines

2. CM3 code has very small footprint requirement, we cannot implement the complete Serdes and PHY infrastructure that kernel provides as part of CM3 application. Therefore I would like to continue relying on kernel configuration for that.

How can that work? How does Linux know when CM3 has up'ed the interface?

CM3 won't use this interface till ethtool priv flag was set, it can be done by communication over CM3 SRAM memory.

Quoted 1 line

How does CM3 know the status of the link?

CM3 has access to MAC registers and can read port status bit.

Quoted 2 lines

How does CM3 set its
flow control depending on what auto-neg determines, etc?

Same as PPv2 Packet Processor RX and TX flow don't really care about auto-neg, flow control, etc.
CM3 can ignore it, all this stuff handled in MAC layer. CM3 just polling RX descriptor ring and using TX ring for transmit.

Quoted 9 lines
Quoted 4 lines

3. In some cases we need to dynamically switch the port "user" between CM3 and kernel. So I would like to preserve this functionality.

And how do you synchronize between Linux and CM3 so you know how is using it and who cannot use it?

Andrew

I can add CM3 SRAM update into ethtool priv flag callback, so CM3 won't use port till it was reserved to CM3.

Stefan.

#7 lore raw
Quoted 26 lines · Stefan Chulski
Quoted 8 lines
Quoted 5 lines

2. CM3 code has very small footprint requirement, we cannot implement the complete Serdes and PHY infrastructure that kernel provides as part of CM3 application. Therefore I would like to continue relying on kernel configuration for that.

How can that work? How does Linux know when CM3 has up'ed the interface?

CM3 won't use this interface till ethtool priv flag was set, it can be done by communication over CM3 SRAM memory.

Quoted 1 line

How does CM3 know the status of the link?

CM3 has access to MAC registers and can read port status bit.

Quoted 2 lines

How does CM3 set its
flow control depending on what auto-neg determines, etc?

Same as PPv2 Packet Processor RX and TX flow don't really care about auto-neg, flow control, etc.
CM3 can ignore it, all this stuff handled in MAC layer. CM3 just polling RX descriptor ring and using TX ring for transmit.

Quoted 5 lines
Quoted 4 lines

3. In some cases we need to dynamically switch the port "user" between CM3 and kernel. So I would like to preserve this functionality.

Quoted 6 lines
Quoted 4 lines

And how do you synchronize between Linux and CM3 so you know how is using it and who cannot use it?

Andrew

I can add CM3 SRAM update into ethtool priv flag callback, so CM3 won't use port till it was reserved to CM3.

I really think you need to step back here and look at the bigger picture. If linux should not use the interface, it should not exist. If it does not exist, you cannot use ethtool on it.

What you might want to consider is adding remoteproc support between Linux on the main processor and whatever you have on the CM3. You can use RPMsg to send requests back and forth between Linux and the CM3. It can request that the shared parts of the packet processor are set up for it. Linux can tell it when the link comes up? It can request how the PHY auto-neg should be configured.

Andrew

#8 lore raw
Quoted 33 lines
Quoted 1 line

CM3 won't use this interface till ethtool priv flag was set, it can be done by

communication over CM3 SRAM memory.

Quoted 9 lines
Quoted 2 lines

How does CM3 know the status of the link?

CM3 has access to MAC registers and can read port status bit.

Quoted 2 lines

How does CM3 set its
flow control depending on what auto-neg determines, etc?

Same as PPv2 Packet Processor RX and TX flow don't really care about auto-

neg, flow control, etc.

Quoted 1 line

CM3 can ignore it, all this stuff handled in MAC layer. CM3 just polling RX

descriptor ring and using TX ring for transmit.

Quoted 7 lines
Quoted 7 lines
Quoted 5 lines

3. In some cases we need to dynamically switch the port "user" between CM3 and kernel. So I would like to preserve this functionality.

And how do you synchronize between Linux and CM3 so you know how

is

Quoted 5 lines
Quoted 3 lines

using it and who cannot use it?

Andrew

I can add CM3 SRAM update into ethtool priv flag callback, so CM3 won't

use port till it was reserved to CM3.

I really think you need to step back here and look at the bigger picture. If linux should not use the interface, it should not exist. If it does not exist, you cannot use ethtool on it.

Quoted 8 lines

What you might want to consider is adding remoteproc support between Linux on the main processor and whatever you have on the CM3. You can use RPMsg to send requests back and forth between Linux and the CM3. It can request that the shared parts of the packet processor are set up for it. Linux can tell it when the link comes up? It can request how the PHY auto- neg should be configured.

Andrew

I would check this option.

Thanks,
Stefan.

maintainer
#9 lore raw
In reply to [email protected]
Quoted 10 lines · On Thu, 11 Mar 2021 18:43:27 +0200 [email protected] wrote:

According to Armada SoC architecture and design, all the PPv2 ports which are populated on the same communication processor silicon die (CP11x) share the same Classifier and Parser engines.

Armada is an embedded platform and therefore there is a need to reserve some of the PPv2 ports for different use cases.

For example, a port can be reserved for a CM3 CPU running FreeRTOS for management purposes or by user-space data plane application.

Quoted 11 lines

During port reservation all common configurations are preserved and only RXQ, TXQ, and interrupt vectors are disabled.
Since TXQ's are disabled, the Kernel won't transmit any packet from this port, and to due the closed RXQ interrupts, the Kernel won't receive any packet.
The port MAC address and administrative UP/DOWN state can still be changed.
The only permitted configuration in this mode is MTU change. The driver's .ndo_change_mtu callback has logic that switches between percpu_pools and shared pools buffer mode, since the buffer management not done by Kernel this should be permitted.

Andrew asks good questions. This looks like a strange construct.

IMO Linux should either not see the port (like it doesn't see NC-SI), or we need representors for physical and logical ports and explicit forwarding rules.