ethdev: rework config restore
cover ethdev: rework config restore
Hi all,
We have been working on optimizing the latency of calls to rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start() does a few things on top of calling .dev_start() callback:
- Before calling it:
- eth_dev_mac_restore() - if device supports RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
- eth_dev_mac_restore() - if device does not support RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore() iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1. rte_eth_dev_configure()
2. rte_eth_tx_queue_setup()
3. rte_eth_rx_queue_setup()
4. rte_eth_promiscuous_enable()
- Call dev->dev_ops->promiscuous_enable()
- Stores promiscuous state in dev->data->promiscuous
5. rte_eth_allmulticast_enable()
- Call dev->dev_ops->allmulticast_enable()
- Stores allmulticast state in dev->data->allmulticast
6. rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()
Even though all configuration is available in dev->data after step 5, library forces reapplying this configuration in step 6.
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The same configuration is applied multiple times.
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library
(for example rte_eth_promiscuous_enable() does not call the driver if dev->data->promiscuous is set).
Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to take this configuration into account? In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore.
Drivers could advertise if forceful configuration restore is needed through RTE_ETH_DEV_*_FORCE_RESTORE device flag. If this flag is set, then the driver in question requires ethdev to forcefully restore configuration.
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely on configuration restore.
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not required
lib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)
--
2.39.5
RFC 1/4 ethdev: rework config restore
Extract promiscuous and all multicast configuration restore to separate functions.
This change will allow easier integration of disabling these procedures for supporting PMDs in follow up commits.
--- lib/ethdev/rte_ethdev.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-)
lib/ethdev/rte_ethdev.c +29 -5
@@ -1648,14 +1648,10 @@ eth_dev_mac_restore(struct rte_eth_dev *dev, }static int -eth_dev_config_restore (struct rte_eth_dev *dev, -struct rte_eth_dev_info *dev_info,uint16_t port_id) +eth_dev_promiscuous_restore (struct rte_eth_dev *dev,uint16_t port_id) {int ret; -if (!(*dev_info->dev_flags &RTE_ETH_DEV_NOLIVE_MAC_ADDR )) -eth_dev_mac_restore (dev, dev_info); -/* replay promiscuous configuration */ /* * use callbacks directly since we don't need port_id check and
@@ -1683,6 +1679,14 @@ eth_dev_config_restore(struct rte_eth_dev *dev, } } +return 0 ; +} + +static int +eth_dev_allmulticast_restore (struct rte_eth_dev *dev,uint16_t port_id) +{ +int ret; +/* replay all multicast configuration */ /* * use callbacks directly since we don't need port_id check and
@@ -1713,6 +1717,26 @@ eth_dev_config_restore(struct rte_eth_dev *dev,return 0 ; } +static int +eth_dev_config_restore (struct rte_eth_dev *dev, +struct rte_eth_dev_info *dev_info,uint16_t port_id) +{ +int ret; + +if (!(*dev_info->dev_flags &RTE_ETH_DEV_NOLIVE_MAC_ADDR )) +eth_dev_mac_restore (dev, dev_info); + + ret =eth_dev_promiscuous_restore (dev, port_id); +if (ret !=0 ) +return ret; + + ret =eth_dev_allmulticast_restore (dev, port_id); +if (ret !=0 ) +return ret; + +return 0 ; +} +int rte_eth_dev_start (uint16_t port_id) {
Signature · 1 line
2.39.5
RFC 4/4 ethdev: omit MAC address restore if not required
In reply to Dariusz SosnowskiThis patch adds a new device flag - RTE_ETH_DEV_MAC_ADDR_FORCE_RESTORE. If device driver sets this flag, then it requires that ethdev library forcefully reapplies configured MAC addresses,
after the port is started.
As a result, unnecessary work can be removed from rte_eth_dev_start() for drivers which apply all available configuration in dev_start() (such drivers do not the set the flag).
If RFC is approved, then the next version of this patch should set the new flag for all drivers to maintain the same behavior, until drivers adjust and it can be safely cleared.
--- lib/ethdev/rte_ethdev.c | 3 ++- lib/ethdev/rte_ethdev.h | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
lib/ethdev/rte_ethdev.c +2 -1
@@ -1723,7 +1723,8 @@ eth_dev_config_restore(struct rte_eth_dev *dev, {int ret; -if (!(*dev_info->dev_flags &RTE_ETH_DEV_NOLIVE_MAC_ADDR )) +if ((*dev_info->dev_flags &RTE_ETH_DEV_MAC_ADDR_FORCE_RESTORE ) && + !(*dev_info->dev_flags &RTE_ETH_DEV_NOLIVE_MAC_ADDR ))eth_dev_mac_restore (dev, dev_info);if (*dev_info->dev_flags &RTE_ETH_DEV_PROMISC_FORCE_RESTORE ) {
lib/ethdev/rte_ethdev.h +6 -0
@@ -2132,6 +2132,12 @@ struct rte_eth_dev_owner {* after driver's dev_start() callback is called. */ #define RTE_ETH_DEV_ALLMULTI_FORCE_RESTORE RTE_BIT32(8) +/** +* If this flag is set, then device driver requires that +* ethdev library forcefully reapplies active MAC addresses, +* after driver's dev_start() callback is called. +*/ +#define RTE_ETH_DEV_MAC_ADDR_FORCE_RESTORE RTE_BIT32(9)/**@}*/ /**
Signature · 1 line
2.39.5
RFC 3/4 ethdev: omit all multicast config restore if not required
In reply to Dariusz SosnowskiThis patch adds a new device flag - RTE_ETH_DEV_ALLMULTI_FORCE_RESTORE. If device driver sets this flag, then it requires that ethdev library forcefully reapplies allmulticast configration,
after the port is started.
As a result, unnecessary work can be removed from rte_eth_dev_start() for drivers which apply all available configuration in dev_start() (such drivers do not set the flag).
If RFC is approved, then the next version of this patch should set the new flag for all drivers to maintain the same behavior, until drivers adjust and it can be safely cleared.
--- lib/ethdev/rte_ethdev.c | 8 +++++--- lib/ethdev/rte_ethdev.h | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
lib/ethdev/rte_ethdev.c +5 -3
@@ -1732,9 +1732,11 @@ eth_dev_config_restore(struct rte_eth_dev *dev,return ret; } - ret =eth_dev_allmulticast_restore (dev, port_id); -if (ret !=0 ) -return ret; +if (*dev_info->dev_flags &RTE_ETH_DEV_ALLMULTI_FORCE_RESTORE ) { + ret =eth_dev_allmulticast_restore (dev, port_id); +if (ret !=0 ) +return ret; + }return 0 ; }
lib/ethdev/rte_ethdev.h +6 -0
@@ -2126,6 +2126,12 @@ struct rte_eth_dev_owner {* after driver's dev_start() callback is called. */ #define RTE_ETH_DEV_PROMISC_FORCE_RESTORE RTE_BIT32(7) +/** +* If this flag is set, then device driver requires that +* ethdev library forcefully reapplies allmulticast configuration, +* after driver's dev_start() callback is called. +*/ +#define RTE_ETH_DEV_ALLMULTI_FORCE_RESTORE RTE_BIT32(8)/**@}*/ /**
Signature · 1 line
2.39.5
RFC 2/4 ethdev: omit promiscuous config restore if not required
In reply to Dariusz SosnowskiThis patch adds a new device flag - RTE_ETH_DEV_PROMISC_FORCE_RESTORE. If device driver sets this flag, then it requires that ethdev library forcefully reapplies promiscuous mode configuration,
after the port is started.
As a result, unnecessary work can be removed from rte_eth_dev_start() for drivers which apply all available configuration in dev_start() (such drivers do not set the flag).
If RFC is approved, then the next version of this patch should set the new flag for all drivers to maintain the same behavior, until drivers adjust and it can be safely cleared.
--- lib/ethdev/rte_ethdev.c | 8 +++++--- lib/ethdev/rte_ethdev.h | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
lib/ethdev/rte_ethdev.c +5 -3
@@ -1726,9 +1726,11 @@ eth_dev_config_restore(struct rte_eth_dev *dev,if (!(*dev_info->dev_flags &RTE_ETH_DEV_NOLIVE_MAC_ADDR ))eth_dev_mac_restore (dev, dev_info); - ret =eth_dev_promiscuous_restore (dev, port_id); -if (ret !=0 ) -return ret; +if (*dev_info->dev_flags &RTE_ETH_DEV_PROMISC_FORCE_RESTORE ) { + ret =eth_dev_promiscuous_restore (dev, port_id); +if (ret !=0 ) +return ret; + } ret =eth_dev_allmulticast_restore (dev, port_id);if (ret !=0 )
lib/ethdev/rte_ethdev.h +6 -0
@@ -2120,6 +2120,12 @@ struct rte_eth_dev_owner {* PMDs filling the queue xstats themselves should not set this flag */ #define RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS RTE_BIT32(6) +/** +* If this flag is set, then device driver requires that +* ethdev library forcefully reapplies promiscuous mode configuration, +* after driver's dev_start() callback is called. +*/ +#define RTE_ETH_DEV_PROMISC_FORCE_RESTORE RTE_BIT32(7)/**@}*/ /**
Signature · 1 line
2.39.5
Quoted 62 lines · Dariusz Sosnowski
Hi all,
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous
5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast
6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The same configuration is applied multiple times.
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library
(for examplerte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).
Quoted 7 lines
Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to take this configuration into account? In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.
But I agree this is device specific behavior, and can be managed by what device requires.
Quoted 6 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore.
Drivers could advertise if forceful configuration restore is needed throughRTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restore configuration.
OK to use flag for it, but not sure about using 'dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.
What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
Quoted 16 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely on configuration restore.
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 105 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, September 30, 2024 01:31
To: Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>; Konstantin Ananyev <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 8 lines · Dariusz Sosnowski
Hi all,
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.Quoted 7 lines
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 37 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 6 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 8 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 5 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.But I agree this is device specific behavior, and can be managed by what device requires.
Quoted 5 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
Quoted 6 lines
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Agreed. What do you think about the following?
#define RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE RTE_BIT32(0) #define RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE RTE_BIT32(1) #define RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE RTE_BIT32(2)
struct rte_eth_dev_data {
/* snip */
uint32_t dev_flags;
/**
* Internal device capabilities, used only by ethdev library.
* Certain functionalities provided by the library might enabled/disabled,
* based on driver exposing certain capabilities.
*/
uint32_t internal_flags;
/* snip */
};Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good in my opinion.
At least right now, ethdev does not change any configuration in 'stop' and 'reset' from what I see. But that's on library side only.
Quoted 17 lines
Quoted 2 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 14 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 77 lines
Quoted 77 lines
External email: Use caution opening links or attachments
Quoted 8 lines · Dariusz Sosnowski
Hi all,
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.Quoted 7 lines
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 37 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 6 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 8 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 2 lines
In other words, why library has to reapply the configuration?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.
Yep, as I remember, at least some Intel PMDs calling hw_reset() ad dec_stop() and even dev_start() to make sure that HW is in a clean (known) state.
Quoted 3 lines
Quoted 3 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user
and probably ethdev layer too?
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke during its dev_start() if needed?
Quoted 46 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORERTE_BIT32(2)struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags; /* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good in my opinion.At least right now, ethdev does not change any configuration in 'stop' and 'reset' from what I see. But that's on library side only.
Quoted 17 lines
Quoted 2 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 14 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 107 lines · Konstantin Ananyev
Quoted 77 lines
Quoted 77 lines
External email: Use caution opening links or attachments
Quoted 8 lines · Dariusz Sosnowski
Hi all,
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.Quoted 7 lines
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 37 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 6 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 8 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 2 lines
In other words, why library has to reapply the configuration?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known) state.Quoted 3 lines
Quoted 3 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Suggested 'internal_flag' in "struct rte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.
Instead what do you think to have a separate, dedicated data struct for it?
Quoted 50 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke during its
dev_start()if needed?Quoted 46 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORERTE_BIT32(2)struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags; /* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good in my opinion.At least right now, ethdev does not change any configuration in 'stop' and 'reset' from what I see. But that's on library side only.
Quoted 17 lines
Quoted 2 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 14 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 104 lines
Quoted 104 lines
Quoted 71 lines
Quoted 71 lines
Quoted 8 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.Quoted 7 lines
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 37 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 6 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 8 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 2 lines
In other words, why library has to reapply the configuration?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known) state.Quoted 3 lines
Quoted 3 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()
We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()
And let PMD itself to decide does it needs to call it at dev_start() or not. So it will become:rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
-Call ethdev_replay_user_conf(.)
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
-Call dev->dev_ops->allmulticast_enable()
For PMDs that do need to restore user provided config Andrte_eth_dev_start()
- Call dev->dev_ops->dev_start()
For those who do not.
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.
Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 51 lines
Quoted 51 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke during its
dev_start()if needed?Quoted 46 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORERTE_BIT32(2)struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags; /* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good in my opinion.At least right now, ethdev does not change any configuration in 'stop' and 'reset' from what I see. But that's on library side only.
Quoted 17 lines
Quoted 2 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 14 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 138 lines · Konstantin Ananyev
Quoted 104 lines
Quoted 104 lines
Quoted 71 lines
Quoted 71 lines
Quoted 8 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.Quoted 7 lines
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 37 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 6 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 8 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 2 lines
In other words, why library has to reapply the configuration?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known) state.Quoted 3 lines
Quoted 3 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:
ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()
Quoted 7 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.
Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC) dev->dev_ops->mac_addr_set()
- if (flags & PROMISC) dev->dev_ops->promiscuous_enable()
- ...
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.
Additionally, RTE_ETH_START, RTE_ETH_RESET etc flag can be provided to internal API to get what to restore in different states...
Quoted 62 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 51 lines
Quoted 51 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke during its
dev_start()if needed?Quoted 46 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORERTE_BIT32(2)struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags; /* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good in my opinion.At least right now, ethdev does not change any configuration in 'stop' and 'reset' from what I see. But that's on library side only.
Quoted 17 lines
Quoted 2 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 14 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 143 lines
Quoted 143 lines
Quoted 104 lines
Quoted 104 lines
Quoted 71 lines
Quoted 71 lines
Quoted 8 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.Quoted 7 lines
rte_eth_dev_start()does a few things on top of calling .dev_start() callback:- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 37 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these MAC addresses.Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable() callback.
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable() callback.
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant APIs. Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 6 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 8 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 2 lines
In other words, why library has to reapply the configuration?
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
My assumption is .dev_stop() cause these values reset in some devices, so .dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known) state.Quoted 3 lines
Quoted 3 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:
ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
Quoted 6 lines
Quoted 2 lines
For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.
Yes, every PMD will have to be updated with that way.
Quoted 12 lines
Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...
Quoted 3 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.
Makes sense to me...
Probably less disruptive would be to have a dev_ops function that would tell what settings don't need to be replayed by ehtdev layer.
Quoted 65 lines
Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 62 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 51 lines
Quoted 51 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke during its
dev_start()if needed?Quoted 46 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORERTE_BIT32(2)struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags; /* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar mechanism etc...
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good in my opinion.At least right now, ethdev does not change any configuration in 'stop' and 'reset' from what I see. But that's on library side only.
Quoted 17 lines
Quoted 2 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 14 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 178 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 9 lines · Konstantin Ananyev
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 6 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MACaddresses.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable()
callback.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable()
callback.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant
APIs.
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 22 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 7 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 10 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 5 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known)state.
Quoted 58 lines
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 17 lines
Quoted 16 lines
Quoted 7 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:
ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:
Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...
Could you please explain what is the benefit of exposing flags through dev_ops callback vs a dedicated flags field in rte_eth_dev_data? In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).
I understand that my initial proposal with "internal_flags" was too vague, but renaming and splitting this field into:
- dev_start_restore_flags
- dev_reset_restore_flags
- and so on...
seems sufficient, at least in my opinion.
Quoted 77 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 4 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Quoted 9 lines
Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 191 lines · Dariusz Sosnowski
Quoted 178 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 9 lines · Konstantin Ananyev
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 6 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MACaddresses.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable()
callback.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable()
callback.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant
APIs.
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 22 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 7 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 10 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 5 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known)state.
Quoted 58 lines
Quoted 24 lines
Quoted 24 lines
Quoted 4 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 17 lines
Quoted 16 lines
Quoted 7 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration restore. Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:
ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field inrte_eth_dev_data? In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).
Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to rte_eth_dev_data works, and it is easier since there is direct access from rte_eth_dev to rte_eth_dev_data, so you don't need new dev_ops. So this is a valid option.
But benefit of new dev_ops is to keep "struct rte_eth_dev_data" clean.
"struct rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues, dev_private, dev_conf all important and used a lot.
I want to protect "struct rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.
This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore feature know it.
Quoted 78 lines
Quoted 77 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 4 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Quoted 9 lines
Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORERTE_BIT32(0)#defineRTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORERTE_BIT32(1)#defineRTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library might enabled/disabled, * based on driver exposing certain capabilities. */ uint32_t internal_flags;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
/* snip */ };Quoted 2 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 237 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 113 lines · Dariusz Sosnowski
Quoted 113 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 7 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant
APIs.
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 22 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 7 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 10 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 5 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known)state.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration
restore.
Quoted 64 lines
Quoted 64 lines
Quoted 48 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:
ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 8 lines
Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.
Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore feature know it.
I see. Thank you very much for the explanation.
In this case, it looks like adding this to dev_ops is the way to go.
So, summarizing it all:
1. dev_ops should be extended with a callback with the following signature and enums/flags:
enum rte_eth_dev_operation op {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};
#define RTE_ETH_RESTORE_MAC_ADDR RTE_BIT32(0)
#define RTE_ETH_RESTORE_PROMISC RTE_BIT32(1)
#define RTE_ETH_RESTORE_ALLMULTI RTE_BIT32(2)
void (*get_restore_flags)(
struct rte_eth_dev *dev,
enum rte_eth_dev_operation op,
uint32_t *flags);
2. rte_eth_dev_start() will work as follows:
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callback is not provided, assume flags == 0.
- if (flags & RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...
Also, I would like to add the following:
3. Patchset introducing this change should add get_restore_flags() implementation to all drivers, which informs that all config should be restored. This would preserve the current behavior.
Later, this could be refined driver by driver.
What do you think?
Also, there's an open question about 'stop' and 'reset' operations.
At the moment, ethdev layer does not do any config manipulation during these operations. Maybe we should limit get_restore_flags() to 'start' only?
Quoted 88 lines
Quoted 22 lines
Quoted 22 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities. */
uint32_tinternal_flags;/* snip */ };Quoted 3 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 267 lines · Dariusz Sosnowski
Quoted 237 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 113 lines · Dariusz Sosnowski
Quoted 113 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 7 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant
APIs.
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
Quoted 22 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.Quoted 7 lines
In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev config).
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 10 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 5 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK commit).
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean (known)state.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Probably yes.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration
restore.
Quoted 64 lines
Quoted 64 lines
Quoted 48 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to PMDs) that would do last 3 steps:
ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 8 lines
Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore feature know it.
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature and enums/flags:enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)
#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)
#defineRTE_ETH_RESTORE_ALLMULTIRTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);
Quoted 7 lines
2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callback is not provided, assume flags == 0.
- if (flags &RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...
All above looks good.
Quoted 8 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be restored. This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev layer.
If we introduce back restore via get_restore_flags(), it may stay as it is in drivers, at least for most of them.
What do you think to risk breaking stuff for this case.
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.
Quoted 4 lines
Also, there's an open question about 'stop' and 'reset' operations.
At the moment, ethdev layer does not do any config manipulation during these operations. Maybe we should limitget_restore_flags()to 'start' only?
Ack, I was about to suggest the same, for now only have 'RTE_ETH_START' as a placeholder for later possible usages.
Quoted 89 lines
Quoted 88 lines
Quoted 22 lines
Quoted 22 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities. */
uint32_tinternal_flags;/* snip */ };Quoted 3 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 315 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 14:52
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 88 lines · Dariusz Sosnowski
Quoted 88 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 74 lines · Dariusz Sosnowski
Quoted 74 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 7 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant
APIs.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev
config).
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 7 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 4 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK
commit).
Quoted 129 lines
Quoted 129 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration
restore.
Quoted 72 lines
Quoted 65 lines
Quoted 49 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Quoted 2 lines
Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 6 lines
Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 8 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 11 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...All above looks good.
Quoted 3 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be restored.
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev layer.
Quoted 8 lines
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.What do you think to risk breaking stuff for this case.
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like i40e). So, I don't know what will happen to such drivers. They may be left broken (if they are affected) for 24.11 and future releases. But I agree that if default behavior is preserved, this dependence of drivers on config restore might stay as is.
I'm on the fence about it.
Quoted 5 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.
Seems reasonable to me. In this case, it would be igb (IIUC, now it's named e1000) and ixgbe.
Quoted 9 lines
Quoted 3 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.
Ack
Quoted 90 lines
Quoted 90 lines
Quoted 89 lines
Quoted 23 lines
Quoted 23 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities. */
uint32_tinternal_flags;/* snip */ };Quoted 3 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 320 lines · Dariusz Sosnowski
Quoted 320 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 14:52
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 88 lines · Dariusz Sosnowski
Quoted 88 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 74 lines · Dariusz Sosnowski
Quoted 74 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of the work requires changes in the implementation of .dev_start() PMD callback, but I also wanted to start a discussion regarding configuration restore.
rte_eth_dev_start()does a few things on top of calling .dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
-eth_dev_mac_restore()- if device supportsRTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
-eth_dev_mac_restore()- if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 7 lines
- restore promiscuous config
- restore all multicast config
eth_dev_mac_restore()iterates over all known MAC addresses - stored in rte_eth_dev_data.mac_addrs array - and calls .mac_addr_set() and .mac_addr_add() callbacks to apply these MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is enabled or not, and calls .promiscuous_enable() or .promiscuous_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is enabled or not, and calls .allmulticast_enable() or .allmulticast_disable()
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to bypass the checks for applying the same configuration, which exist in relevant
APIs.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1.
rte_eth_dev_configure()
2.rte_eth_tx_queue_setup()
3.rte_eth_rx_queue_setup()
4.rte_eth_promiscuous_enable()
- Calldev->dev_ops->promiscuous_enable()
- Stores promiscuous state indev->data->promiscuous5.rte_eth_allmulticast_enable()
- Calldev->dev_ops->allmulticast_enable()
- Stores allmulticast state indev->data->allmulticast6.rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Even though all configuration is available in
dev->dataafter step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require communication with the kernel driver, to configure the device (mlx5 PMD must create/destroy new kernel flow rules and/or change netdev
config).
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
mlx5 PMD handles applying all configuration in .dev_start(), so the following forced callbacks force additional communication with the kernel. The
same configuration is applied multiple times.
Quoted 7 lines
As an optimization, mlx5 PMD could check if a given configuration was applied, but this would duplicate the functionality of the library (for example
rte_eth_promiscuous_enable()does not call the driver ifdev->data->promiscuousis set).Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Question: Since all of the configuration is available before .dev_start() callback is called, why ethdev library does not expect .dev_start() to
take this configuration into account?
Quoted 4 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration restore exists as part of the process (it was in the initial DPDK
commit).
Quoted 129 lines
Quoted 129 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
The patches included in this RFC, propose a mechanism which would help with managing which drivers rely on forceful configuration
restore.
Quoted 72 lines
Quoted 65 lines
Quoted 49 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
Drivers could advertise if forceful configuration restore is needed through
RTE_ETH_DEV_*_FORCE_RESTOREdevice flag. If this flag is set, then the driver in question requires ethdev to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Quoted 2 lines
Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 6 lines
Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 8 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 11 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...All above looks good.
Quoted 3 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be restored.
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev layer.
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.What do you think to risk breaking stuff for this case.
Quoted 9 lines
Quoted 3 lines
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like i40e). So, I don't know what will happen to such drivers. They may be left broken (if they are affected) for 24.11 and future releases. But I agree that if default behavior is preserved, this dependence of drivers on config restore might stay as is.
I'm on the fence about it.
Yeah, not sure.
Do you think the dev_ops function can be implemented in the 'ethdev_driver.c' and all drivers use exact same function? So this reduces changes and duplication in drivers while preserving the behavior.
Quoted 111 lines
Quoted 5 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.Seems reasonable to me. In this case, it would be igb (IIUC, now it's named e1000) and ixgbe.
Quoted 9 lines
Quoted 3 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.Ack
Quoted 90 lines
Quoted 90 lines
Quoted 89 lines
Quoted 23 lines
Quoted 23 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities. */
uint32_tinternal_flags;/* snip */ };Quoted 3 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for .dev_start() to handle all starting configuration aspects, we could track which drivers still rely
on configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39 ++++++++++++++++++++++++++++++++++----- lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
config restore
Quoted 323 lines
Quoted 310 lines
Quoted 310 lines
External email: Use caution opening links or attachments
Quoted 88 lines · Dariusz Sosnowski
Quoted 88 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 74 lines · Dariusz Sosnowski
Quoted 74 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of
the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a
discussion regarding configuration restore.rte_eth_dev_start() does a few things on top of calling
.dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
- eth_dev_mac_restore() - if device supports
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
- eth_dev_mac_restore() - if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 7 lines
- restore promiscuous config
- restore all multicast configeth_dev_mac_restore() iterates over all known MAC addresses -
stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these
MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is
enabled or not, and calls .promiscuous_enable() or
.promiscuous_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is
enabled or not, and calls .allmulticast_enable() or
.allmulticast_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to
bypass the checks for applying the same configuration, which
exist in relevantAPIs.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1. rte_eth_dev_configure()
2. rte_eth_tx_queue_setup()
3. rte_eth_rx_queue_setup()
4. rte_eth_promiscuous_enable()
- Call dev->dev_ops->promiscuous_enable()
- Stores promiscuous state in dev->data->promiscuous 5.
rte_eth_allmulticast_enable()
- Call dev->dev_ops->allmulticast_enable()
- Stores allmulticast state in dev->data->allmulticast 6.
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Even though all configuration is available in dev->data after
step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require communication
with the kernel driver, to configure the device (mlx5 PMD
must create/destroy new kernel flow rules and/or change netdevconfig).
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 4 lines
mlx5 PMD handles applying all configuration in .dev_start(),
so the following forced callbacks force additional
communication with the kernel. Thesame configuration is applied multiple times.
Quoted 7 lines
As an optimization, mlx5 PMD could check if a given
configuration was applied, but this would duplicate the
functionality of the library (for example
rte_eth_promiscuous_enable() does not call the driver if
dev->data->promiscuous is set).Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Question: Since all of the configuration is available before
.dev_start() callback is called, why ethdev library does not
expect .dev_start() totake this configuration into account?
Quoted 4 lines
In other words, why library has to reapply the configuration?
I could not find any particular reason why configuration
restore exists as part of the process (it was in the initial DPDKcommit).
Quoted 129 lines
Quoted 129 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
My assumption is .dev_stop() cause these values reset in some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be managed by what device requires.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
The patches included in this RFC, propose a mechanism which
would help with managing which drivers rely on forceful
configurationrestore.
Quoted 72 lines
Quoted 65 lines
Quoted 49 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 4 lines
Drivers could advertise if forceful configuration restore is
needed through `RTE_ETH_DEV_*_FORCE_RESTORE` device flag. If
this flag is set, then the driver in question requires ethdev
to forcefully restoreconfiguration.
Quoted 1 line
OK to use flag for it, but not sure about using '
dev_info->dev_flags' (RTE_ETH_DEV_*) for this, as this flag is shared with user and this is all dpdk internal.What about to have a dedicated flag for it? We can have a dedicated set of flag values for restore.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Quoted 2 lines
Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 6 lines
Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 8 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 11 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...All above looks good.
Quoted 3 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be restored.
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev layer.
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.Quoted 7 lines
Quoted 5 lines
What do you think to risk breaking stuff for this case.
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like
i40e).
Quoted 4 lines
So, I don't know what will happen to such drivers. They may be left broken (if they are affected) for 24.11 and future releases. But I agree that if default behavior is preserved, this dependence of drivers on config restore might stay as is. I'm on the fence about it.
Quoted 6 lines
Yeah, not sure.
Do you think the
dev_opsfunction can be implemented in the 'ethdev_driver.c' and all drivers use exact same function? So this reduces changes and duplication in drivers while preserving the behavior.
Wonder why it can't be done visa-versa?
If this new function is not implemented by PMD, then simply assume that everything needs to be restored (as it happens now)?
Quoted 111 lines
Quoted 111 lines
Quoted 5 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.Seems reasonable to me. In this case, it would be igb (IIUC, now it's named e1000) and ixgbe.
Quoted 9 lines
Quoted 3 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.Ack
Quoted 90 lines
Quoted 90 lines
Quoted 89 lines
Quoted 23 lines
Quoted 23 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities. */
uint32_tinternal_flags;/* snip */ };Quoted 3 lines
Also perhaps we have go into details what needs to be restored after 'stop' and what needs to be restored after 'reset' and use similar
mechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
Quoted 3 lines
This way, if we would conclude that it makes sense for
.dev_start() to handle all starting configuration aspects, we
could track which drivers still relyon configuration restore.
Quoted 15 lines
Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39
++++++++++++++++++++++++++++++++++-----
lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++
2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 328 lines · Konstantin Ananyev
config restore
Quoted 325 lines
Quoted 310 lines
Quoted 310 lines
External email: Use caution opening links or attachments
Quoted 88 lines · Dariusz Sosnowski
Quoted 88 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 74 lines · Dariusz Sosnowski
Quoted 74 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of
the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a
discussion regarding configuration restore.rte_eth_dev_start() does a few things on top of calling
.dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
- eth_dev_mac_restore() - if device supports
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
- eth_dev_mac_restore() - if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- restore promiscuous config
- restore all multicast configeth_dev_mac_restore() iterates over all known MAC addresses -
stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these
MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is
enabled or not, and calls .promiscuous_enable() or
.promiscuous_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is
enabled or not, and calls .allmulticast_enable() or
.allmulticast_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to
bypass the checks for applying the same configuration, which
exist in relevantAPIs.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1. rte_eth_dev_configure()
2. rte_eth_tx_queue_setup()
3. rte_eth_rx_queue_setup()
4. rte_eth_promiscuous_enable()
- Call dev->dev_ops->promiscuous_enable()
- Stores promiscuous state in dev->data->promiscuous 5.
rte_eth_allmulticast_enable()
- Call dev->dev_ops->allmulticast_enable()
- Stores allmulticast state in dev->data->allmulticast 6.
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Even though all configuration is available in dev->data after
step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require communication
with the kernel driver, to configure the device (mlx5 PMD
must create/destroy new kernel flow rules and/or change netdevconfig).
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
mlx5 PMD handles applying all configuration in .dev_start(),
so the following forced callbacks force additional
communication with the kernel. The
same configuration is applied multiple times.As an optimization, mlx5 PMD could check if a given
configuration was applied, but this would duplicate the
functionality of the library (for example
rte_eth_promiscuous_enable() does not call the driver if
dev->data->promiscuous is set).Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Question: Since all of the configuration is available before
.dev_start() callback is called, why ethdev library does not
expect .dev_start() to
take this configuration into account?
In other words, why library has to reapply the configuration?I could not find any particular reason why configuration
restore exists as part of the process (it was in the initial DPDKcommit).
Quoted 129 lines
Quoted 129 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
My assumption is .dev_stop() cause these values reset in some
devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be
managed by what device requires.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
Quoted 4 lines
Quoted 4 lines
The patches included in this RFC, propose a mechanism which
would help with managing which drivers rely on forceful
configurationrestore.
Quoted 72 lines
Quoted 65 lines
Quoted 49 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Drivers could advertise if forceful configuration restore is
needed through `RTE_ETH_DEV_*_FORCE_RESTORE` device flag. If
this flag is set, then the driver in question requires ethdev
to forcefully restore
configuration.OK to use flag for it, but not sure about using 'dev_info->dev_flags'
(RTE_ETH_DEV_*) for this, as this flag is shared with user and
this is all dpdk internal.What about to have a dedicated flag for it? We can have a
dedicated set of flag values for restore.Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Quoted 2 lines
Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 6 lines
Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 8 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 11 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...All above looks good.
Quoted 3 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be restored.
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev layer.
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.Quoted 7 lines
Quoted 5 lines
What do you think to risk breaking stuff for this case.
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like
i40e).
Quoted 4 lines
So, I don't know what will happen to such drivers. They may be left broken (if they are affected) for 24.11 and future releases. But I agree that if default behavior is preserved, this dependence of drivers on config restore might stay as is. I'm on the fence about it.
Yeah, not sure.
Quoted 9 lines
Quoted 4 lines
Do you think the
dev_opsfunction can be implemented in the 'ethdev_driver.c' and all drivers use exact same function? So this reduces changes and duplication in drivers while preserving the behavior.Wonder why it can't be done visa-versa?
If this new function is not implemented by PMD, then simply assume that everything needs to be restored (as it happens now)?
True, this preserve the behavior and prevents updating all drivers.
I think can be done in two ways:
1. dev_ops() tells what NOT to restore, if dev_ops() not implemented or it returns zero, restore everything. Here what not nice is what to restore in this case is not very well defined.
2. dev_ops() tells what to restore, but when not implemented default flag value is all restore. Which is current behavior.
I am for option 2. and I assume that is what Konstantin also suggest, but I want to clarify to be sure.
Quoted 112 lines
Quoted 111 lines
Quoted 111 lines
Quoted 5 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.Seems reasonable to me. In this case, it would be igb (IIUC, now it's named e1000) and ixgbe.
Quoted 9 lines
Quoted 3 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.Ack
Quoted 90 lines
Quoted 90 lines
Quoted 89 lines
Quoted 23 lines
Quoted 23 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define
RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define
RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data { /* snip */ uint32_t dev_flags; /** * Internal device capabilities, used only by ethdev library. * Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities. */
uint32_tinternal_flags;/* snip */ };Quoted 3 lines
Also perhaps we have go into details what needs to be restored
after 'stop' and what needs to be restored after 'reset' and
use similarmechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in 'stop' and
'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
Quoted 19 lines
This way, if we would conclude that it makes sense for
.dev_start() to handle all starting configuration aspects, we
could track which drivers still rely
on configuration restore.Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39
++++++++++++++++++++++++++++++++++-----
lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++
2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 379 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Friday, October 11, 2024 02:03
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 80 lines · Konstantin Ananyev
config restore
Quoted 77 lines
Quoted 77 lines
Quoted 77 lines
External email: Use caution opening links or attachments
Quoted 72 lines · Dariusz Sosnowski
Quoted 72 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 58 lines · Dariusz Sosnowski
Quoted 58 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 11 lines · Konstantin Ananyev
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
We have been working on optimizing the latency of calls
to rte_eth_dev_start(), on ports spawned by mlx5 PMD.
Most of the work requires changes in the implementation
of
.dev_start() PMD callback, but I also wanted to start a
discussion regarding configuration restore.rte_eth_dev_start() does a few things on top of calling
.dev_start()callback:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
- Before calling it:
- eth_dev_mac_restore() - if device supports
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
- eth_dev_mac_restore() - if device does not support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
- restore promiscuous config
- restore all multicast configeth_dev_mac_restore() iterates over all known MAC
addresses - stored in rte_eth_dev_data.mac_addrs array -
and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply
these MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is
enabled or not, and calls .promiscuous_enable() or
.promiscuous_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode
is enabled or not, and calls .allmulticast_enable() or
.allmulticast_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to
bypass the checks for applying the same configuration,
which exist in relevantAPIs.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Checks are bypassed to force drivers to reapply the
configuration.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Let's consider what happens in the following sequence of API
calls.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
1. rte_eth_dev_configure() 2. rte_eth_tx_queue_setup() 3.
rte_eth_rx_queue_setup() 4. rte_eth_promiscuous_enable()
- Call dev->dev_ops->promiscuous_enable()
- Stores promiscuous state in dev->data->promiscuous 5.
rte_eth_allmulticast_enable()
- Call dev->dev_ops->allmulticast_enable()
- Stores allmulticast state in dev->data->allmulticast 6.
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MACaddress
Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()Even though all configuration is available in dev->data
after step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require
communication with the kernel driver, to configure the
device (mlx5 PMD must create/destroy new kernel flow
rules and/or change netdevconfig).
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
mlx5 PMD handles applying all configuration in
.dev_start(), so the following forced callbacks force
additional communication with the kernel. The
same configuration is applied multiple times.As an optimization, mlx5 PMD could check if a given
configuration was applied, but this would duplicate the
functionality of the library (for example
rte_eth_promiscuous_enable() does not call the driver if
dev->data->promiscuous is set).Question: Since all of the configuration is available
before
.dev_start() callback is called, why ethdev library does
not expect .dev_start() toQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
take this configuration into account?
In other words, why library has to reapply the configuration?I could not find any particular reason why configuration
restore exists as part of the process (it was in the
initial DPDKcommit).
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
My assumption is .dev_stop() cause these values reset in
some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be
managed by what device requires.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
Quoted 4 lines
The patches included in this RFC, propose a mechanism
which would help with managing which drivers rely on
forceful configurationrestore.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Drivers could advertise if forceful configuration restore
is needed through `RTE_ETH_DEV_*_FORCE_RESTORE` device
flag. If this flag is set, then the driver in question
requires ethdev to forcefully restoreQuoted 39 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
configuration.
OK to use flag for it, but not sure about using 'dev_info-
dev_flags'Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
(RTE_ETH_DEV_*) for this, as this flag is shared with user
and this is all dpdk internal.What about to have a dedicated flag for it? We can have a
dedicated set of flag values for restore.Agreed. What do you think about the following?
Quoted 7 lines
Quoted 3 lines
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can +make it
transparent to ethdev layer.Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()ornot.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
So it will become:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MACaddress
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 9 lines
- Call
dev->dev_ops->promiscuous_enable()-Calldev->dev_ops->allmulticast_enable()For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work. My below dedicated data struct comment is to have this flag in a new struct, overall like following:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Call dev->dev_ops->get_restore_flags(ethdev,RTE_ETH_START,&flags)
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 36 lines
Quoted 36 lines
Quoted 6 lines
Quoted 3 lines
- if (flags & MAC)
dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct. Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 7 lines
Quoted 7 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 9 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 7 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);Quoted 5 lines
2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
All above looks good.
Quoted 3 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be
restored.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev
layer.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.What do you think to risk breaking stuff for this case.
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like
i40e).
Quoted 1 line
So, I don't know what will happen to such drivers. They may be left broken (if
they are affected) for 24.11 and future releases.
Quoted 1 line
Quoted 1 line
Quoted 1 line
But I agree that if default behavior is preserved, this dependence of drivers
on config restore might stay as is.
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm on the fence about it.
Yeah, not sure.
Quoted 9 lines
Quoted 4 lines
Do you think the
dev_opsfunction can be implemented in the 'ethdev_driver.c' and all drivers use exact same function? So this reduces changes and duplication in drivers while preserving the behavior.Wonder why it can't be done visa-versa?
If this new function is not implemented by PMD, then simply assume that everything needs to be restored (as it happens now)?True, this preserve the behavior and prevents updating all drivers.
I think can be done in two ways:
1.dev_ops()tells what NOT to restore, ifdev_ops()not implemented or it returns zero, restore everything. Here what not nice is what to restore in this case is not very well defined.
Quoted 6 lines
2.
dev_ops()tells what to restore, but when not implemented default flag value is all restore. Which is current behavior.I am for option 2. and I assume that is what Konstantin also suggest, but I want to clarify to be sure.
+1 for option 2
Quoted 118 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.Seems reasonable to me. In this case, it would be igb (IIUC, now it's named
e1000) and ixgbe.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 11 lines
Quoted 5 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.Ack
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() atall.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 7 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct
for it?
Quoted 73 lines
Quoted 72 lines
Quoted 72 lines
Quoted 71 lines
Quoted 71 lines
Quoted 70 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Hmm... not sure I understood you here...
Quoted 4 lines
Quoted 4 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data {
/* snip */uint32_t dev_flags;
/**
* Internal device capabilities, used only by ethdev library.
* Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities.
*/
uint32_t internal_flags;/* snip */
};Also perhaps we have go into details what needs to be
restored after 'stop' and what needs to be restored after
'reset' and use similarmechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev
library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any
configuration in 'stop' and'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
This way, if we would conclude that it makes sense for
.dev_start() to handle all starting configuration
aspects, we could track which drivers still rely
on configuration restore.Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39
++++++++++++++++++++++++++++++++++-----
lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++
2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 342 lines
Quoted 325 lines
Quoted 325 lines
Quoted 310 lines
Quoted 310 lines
External email: Use caution opening links or attachments
Quoted 88 lines · Dariusz Sosnowski
Quoted 88 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 74 lines · Dariusz Sosnowski
Quoted 74 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 10 lines · Konstantin Ananyev
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
We have been working on optimizing the latency of calls to
rte_eth_dev_start(), on ports spawned by mlx5 PMD. Most of
the work requires changes in the implementation of
.dev_start() PMD callback, but I also wanted to start a
discussion regarding configuration restore.rte_eth_dev_start() does a few things on top of calling
.dev_start()callback:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
- Before calling it:
- eth_dev_mac_restore() - if device supports
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
- eth_dev_mac_restore() - if device does not supportQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- restore promiscuous config
- restore all multicast configeth_dev_mac_restore() iterates over all known MAC addresses -
stored in rte_eth_dev_data.mac_addrs array - and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply these
MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode is
enabled or not, and calls .promiscuous_enable() or
.promiscuous_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
All multicast config restore checks if all multicast mode is
enabled or not, and calls .allmulticast_enable() or
.allmulticast_disable()callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to
bypass the checks for applying the same configuration, which
exist in relevantAPIs.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Checks are bypassed to force drivers to reapply the configuration.
Let's consider what happens in the following sequence of API calls.
1. rte_eth_dev_configure()
2. rte_eth_tx_queue_setup()
3. rte_eth_rx_queue_setup()
4. rte_eth_promiscuous_enable()
- Call dev->dev_ops->promiscuous_enable()
- Stores promiscuous state in dev->data->promiscuous 5.
rte_eth_allmulticast_enable()
- Call dev->dev_ops->allmulticast_enable()
- Stores allmulticast state in dev->data->allmulticast 6.
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MAC address
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Even though all configuration is available in dev->data after
step 5, library forces reapplying this configuration in step 6.In mlx5 PMD case all relevant callbacks require communication
with the kernel driver, to configure the device (mlx5 PMD
must create/destroy new kernel flow rules and/or change netdevconfig).
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
mlx5 PMD handles applying all configuration in .dev_start(),
so the following forced callbacks force additional
communication with the kernel. The
same configuration is applied multiple times.As an optimization, mlx5 PMD could check if a given
configuration was applied, but this would duplicate the
functionality of the library (for example
rte_eth_promiscuous_enable() does not call the driver if
dev->data->promiscuous is set).Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Question: Since all of the configuration is available before
.dev_start() callback is called, why ethdev library does not
expect .dev_start() to
take this configuration into account?
In other words, why library has to reapply the configuration?I could not find any particular reason why configuration
restore exists as part of the process (it was in the initial DPDKcommit).
Quoted 129 lines
Quoted 129 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
My assumption is .dev_stop() cause these values reset in some
devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset()addec_stop()and evendev_start()to make sure that HW is in a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
But I agree this is device specific behavior, and can be
managed by what device requires.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
Quoted 4 lines
The patches included in this RFC, propose a mechanism which
would help with managing which drivers rely on forceful
configurationrestore.
Quoted 72 lines
Quoted 65 lines
Quoted 49 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Drivers could advertise if forceful configuration restore is
needed through `RTE_ETH_DEV_*_FORCE_RESTORE` device flag. If
this flag is set, then the driver in question requires ethdev
to forcefully restore
configuration.OK to use flag for it, but not sure about using 'dev_info->dev_flags'
(RTE_ETH_DEV_*) for this, as this flag is shared with user and
this is all dpdk internal.What about to have a dedicated flag for it? We can have a
dedicated set of flag values for restore.Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Agreed. What do you think about the following?
Instead of exposing that, can we probably make it transparent to the user and probably ethdev layer too?
+1 to make it transparent to user, but not sure if we can make it transparent to ethdev layer.
Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()or not. So it will become:rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
-Calldev->dev_ops->allmulticast_enable()Quoted 6 lines
For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work.
My below dedicated data struct comment is to have this flag in a new struct, overall like following:Quoted 6 lines
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(ethdev, RTE_ETH_START, &flags)
- if (flags & MAC)dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Quoted 2 lines
Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct.
Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 6 lines
Quoted 6 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 8 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 11 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...All above looks good.
Quoted 3 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be restored.
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev layer.
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.Quoted 7 lines
Quoted 5 lines
What do you think to risk breaking stuff for this case.
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and fix it.
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like
i40e).
Quoted 4 lines
So, I don't know what will happen to such drivers. They may be left broken (if they are affected) for 24.11 and future releases. But I agree that if default behavior is preserved, this dependence of drivers on config restore might stay as is. I'm on the fence about it.
Yeah, not sure.
Quoted 9 lines
Quoted 4 lines
Do you think the
dev_opsfunction can be implemented in the 'ethdev_driver.c' and all drivers use exact same function? So this reduces changes and duplication in drivers while preserving the behavior.Wonder why it can't be done visa-versa?
If this new function is not implemented by PMD, then simply assume that everything needs to be restored (as it happens now)?True, this preserve the behavior and prevents updating all drivers.
I think can be done in two ways:
1.dev_ops()tells what NOT to restore, ifdev_ops()not implemented or it returns zero, restore everything. Here what not nice is what to restore in this case is not very well defined.
Quoted 6 lines
2.
dev_ops()tells what to restore, but when not implemented default flag value is all restore. Which is current behavior.I am for option 2. and I assume that is what Konstantin also suggest, but I want to clarify to be sure.
Yep, I am also in favor of option 2.
Quoted 113 lines
Quoted 113 lines
Quoted 112 lines
Quoted 112 lines
Quoted 6 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.Seems reasonable to me. In this case, it would be igb (IIUC, now it's named e1000) and ixgbe.
Quoted 9 lines
Quoted 3 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.Ack
Quoted 90 lines
Quoted 90 lines
Quoted 89 lines
Quoted 23 lines
Quoted 23 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() at all.Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 11 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct for it?
Hmm... not sure I understood you here...
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Might be we can move this restoration code into the new ethdev helper function,(ethdevd_user_config_restore() or so) that PMD can invoke
during its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 11 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
struct rte_eth_dev_data {
/* snip */uint32_t dev_flags;
/**
* Internal device capabilities, used only by ethdev library.
* Certain functionalities provided by the library mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities.
*/
uint32_t internal_flags;/* snip */
};Also perhaps we have go into details what needs to be restored
after 'stop' and what needs to be restored after 'reset' and
use similarmechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and ethdev
library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any configuration in
'stop' and'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
But that's on library side only.
This way, if we would conclude that it makes sense for
.dev_start() to handle all starting configuration aspects, we
could track which drivers still rely
on configuration restore.Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39
++++++++++++++++++++++++++++++++++-----
lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++
2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5
Quoted 386 lines
-----Original Message-----
From: Konstantin Ananyev <[email protected]>
Sent: Friday, October 11, 2024 10:29
To: Ferruh Yigit <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: RE: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
Quoted 75 lines
External email: Use caution opening links or attachments
Quoted 70 lines · Dariusz Sosnowski
Quoted 70 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, October 10, 2024 01:17
To: Dariusz Sosnowski <[email protected]>; Konstantin Ananyev <[email protected]>; NBU-Contact-Thomas Monjalon
(EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 55 lines · Dariusz Sosnowski
Quoted 55 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, October 9, 2024 03:08
To: Konstantin Ananyev <[email protected]>; Dariusz Sosnowski <[email protected]>; NBU-Contact-Thomas Monjalon
(EXTERNAL) <[email protected]>; Andrew Rybchenko <[email protected]>
Cc: [email protected]; Bruce Richardson <[email protected]>
Subject: Re: [RFC 0/4] ethdev: rework config restoreExternal email: Use caution opening links or attachments
Quoted 11 lines · Konstantin Ananyev
Quoted 11 lines
Quoted 11 lines
We have been working on optimizing the latency of calls
to rte_eth_dev_start(), on ports spawned by mlx5 PMD.
Most of the work requires changes in the implementation
of
.dev_start() PMD callback, but I also wanted to start a
discussion regarding configuration restore.rte_eth_dev_start() does a few things on top of calling
.dev_start()callback:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
- Before calling it:
- eth_dev_mac_restore() - if device supports
RTE_ETH_DEV_NOLIVE_MAC_ADDR;
- After calling it:
- eth_dev_mac_restore() - if device does not
support
RTE_ETH_DEV_NOLIVE_MAC_ADDR;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
- restore promiscuous config
- restore all multicast configeth_dev_mac_restore() iterates over all known MAC
addresses - stored in rte_eth_dev_data.mac_addrs array
- and calls
.mac_addr_set() and .mac_addr_add() callbacks to apply
these MACaddresses.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Promiscuous config restore checks if promiscuous mode
is enabled or not, and calls .promiscuous_enable() or
.promiscuous_disable()callback.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
All multicast config restore checks if all multicast
mode is enabled or not, and calls
.allmulticast_enable() or
.allmulticast_disable()Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
callback.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Callbacks are called directly in all of these cases, to
bypass the checks for applying the same configuration,
which exist in relevantAPIs.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Checks are bypassed to force drivers to reapply the
configuration.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Let's consider what happens in the following sequence of API
calls.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
1. rte_eth_dev_configure() 2. rte_eth_tx_queue_setup()
3. rte_eth_rx_queue_setup() 4.
rte_eth_promiscuous_enable()
- Call dev->dev_ops->promiscuous_enable()
- Stores promiscuous state in dev->data->promiscuous 5.
rte_eth_allmulticast_enable()
- Call dev->dev_ops->allmulticast_enable()
- Stores allmulticast state in dev->data->allmulticast 6.
rte_eth_dev_start()
- Call dev->dev_ops->dev_start()
- Call dev->dev_ops->mac_addr_set() - apply default MACaddress
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
- Call dev->dev_ops->promiscuous_enable()
- Call dev->dev_ops->allmulticast_enable()Even though all configuration is available in dev->data
after step 5, library forces reapplying this configuration in step6.
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 59 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
In mlx5 PMD case all relevant callbacks require
communication with the kernel driver, to configure the
device (mlx5 PMD must create/destroy new kernel flow
rules and/or change netdevconfig).
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
mlx5 PMD handles applying all configuration in
.dev_start(), so the following forced callbacks force
additional communication with the kernel. The
same configuration is applied multiple times.As an optimization, mlx5 PMD could check if a given
configuration was applied, but this would duplicate the
functionality of the library (for example
rte_eth_promiscuous_enable() does not call the driver
if
dev->data->promiscuous is set).Question: Since all of the configuration is available
before
.dev_start() callback is called, why ethdev library
does not expect .dev_start() toQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
take this configuration into account?
In other words, why library has to reapply the configuration?I could not find any particular reason why
configuration restore exists as part of the process (it
was in the initial DPDKcommit).
Quoted 29 lines
Quoted 29 lines
Quoted 18 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
My assumption is .dev_stop() cause these values reset in
some devices, so
.dev_start() restores them back.
@Bruce or @Konstantin may remember the history.Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Yep, as I remember, at least some Intel PMDs calling
hw_reset() ad
dec_stop() and even dev_start() to make sure that HW is in
a clean
(known)state.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
But I agree this is device specific behavior, and can be
managed by what device requires.Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Probably yes.
The patches included in this RFC, propose a mechanism
which would help with managing which drivers rely on
forceful configurationrestore.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Drivers could advertise if forceful configuration
restore is needed through `RTE_ETH_DEV_*_FORCE_RESTORE`
device flag. If this flag is set, then the driver in
question requires ethdev to forcefully restoreQuoted 39 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
configuration.
OK to use flag for it, but not sure about using 'dev_info-
dev_flags'Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
Quoted 8 lines
Quoted 8 lines
(RTE_ETH_DEV_*) for this, as this flag is shared with
user and this is all dpdk internal.What about to have a dedicated flag for it? We can have
a dedicated set of flag values for restore.Agreed. What do you think about the following?
Quoted 7 lines
Quoted 3 lines
Instead of exposing that, can we probably make it
transparent to the user and probably ethdev layer too?+1 to make it transparent to user, but not sure if we can +make it
transparent to ethdev layer.Just to be clear:
Let say, using example from above:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()We probably can introduce ethdev internal function (still visible to
PMDs) that would do last 3 steps:ethdev_replay_user_conf(...)
- Calldev->dev_ops->mac_addr_set()- apply default MAC address
- Calldev->dev_ops->promiscuous_enable()
- Calldev->dev_ops->allmulticast_enable()And let PMD itself to decide does it needs to call it at
dev_start()ornot.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
So it will become:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
-Callethdev_replay_user_conf(.)
- Calldev->dev_ops->mac_addr_set()- apply default MACaddress
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 9 lines
- Call
dev->dev_ops->promiscuous_enable()-Calldev->dev_ops->allmulticast_enable()For PMDs that do need to restore user provided config And
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()For those who do not.
OK, got it what you mean.
Pushing restore functionality to PMDs works, but this may be doing redundant work on each PMD.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Instead Dariusz suggests PMD to provide a flag to ehtdev to what to restore and common code in ethdev does the work. My below dedicated data struct comment is to have this flag in a new struct, overall like following:
rte_eth_dev_start()
- Calldev->dev_ops->dev_start()
- Call dev->dev_ops->get_restore_flags(ethdev,RTE_ETH_START,&flags)
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 36 lines
Quoted 36 lines
Quoted 6 lines
Quoted 3 lines
- if (flags & MAC)
dev->dev_ops->mac_addr_set()
- if (flags & PROMISC)dev->dev_ops->promiscuous_enable()
- ...Could you please explain what is the benefit of exposing flags through
dev_opscallback vs a dedicated flags field in
rte_eth_dev_data?Quoted 6 lines
In both solutions:
- config restore is transparent to the user,
- drivers can omit config restore (either by not implementing the callback or not providing the flags),
- an ABI change is introduced (not a huge concern, at least for 24.11).Quoted 9 lines
I understand that my initial proposal with "
internal_flags" was too vague, but renaming and splitting this field into:-
dev_start_restore_flags
-dev_reset_restore_flags
- and so on...seems sufficient, at least in my opinion.
Hi Dariusz,
Putting flags to
rte_eth_dev_dataworks, and it is easier since there is direct access fromrte_eth_devtorte_eth_dev_data, so you don't need newdev_ops. So this is a valid option.But benefit of new
dev_opsis to keep "structrte_eth_dev_data" clean."struct
rte_eth_dev_data" is integral data structure for ethdev and it is used in multiple locations, mostly related to the datapath and all drivers needs to deal with fields of this struct. Like [rx]_queues,dev_private,dev_confall important and used a lot.Quoted 7 lines
Quoted 7 lines
I want to protect "struct
rte_eth_dev_data" from noise as much as possible, though what is noise is not always that clear.This restore flag is not critical, and I expect most of the drivers won't care and populate this restore flag at all. That is why to me it is better have dedicated struct for it and only drivers care about restore
feature know it.
Quoted 9 lines
I see. Thank you very much for the explanation.
In this case, it looks like adding this to
dev_opsis the way to go.So, summarizing it all:
1.
dev_opsshould be extended with a callback with the following signature andenums/flags:
Quoted 9 lines
enum
rte_eth_dev_operationop {
RTE_ETH_START,
RTE_ETH_STOP,
RTE_ETH_RESET,
};#define
RTE_ETH_RESTORE_MAC_ADDRRTE_BIT32(0)#defineRTE_ETH_RESTORE_PROMISCRTE_BIT32(1)#define
RTE_ETH_RESTORE_ALLMULTIQuoted 7 lines
RTE_BIT32(2)void (*get_restore_flags)(
structrte_eth_dev*dev,
enumrte_eth_dev_operationop,
uint32_t*flags);Quoted 5 lines
2.
rte_eth_dev_start()will work as follows:- Call
dev->dev_ops->dev_start()
- Calldev->dev_ops->get_restore_flags(dev, RTE_ETH_START, &flags). If callbackis not provided, assume flags == 0.
Quoted 3 lines
- if (flags &
RTE_ETH_RESTORE_MAC_ADDR) - restore MAC addresses
- and so on...Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
All above looks good.
Quoted 4 lines
Also, I would like to add the following:
3. Patchset introducing this change should add
get_restore_flags()implementation to all drivers, which informs that all config should be
restored.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
This would preserve the current behavior.
Later, this could be refined driver by driver.What do you think?
What you are saying is correct, but I suspect most of the drivers don't really need this restore, but they have it since it was in the ethdev
layer.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
If we introduce back restore via
get_restore_flags(), it may stay as it is in drivers, at least for most of them.What do you think to risk breaking stuff for this case.
So don't implement this in the drivers by default, so who needs it will recognize the issue and will implement it. If we merge this patch for -rc1, it gives enough time for drivers to detect the issue and
fix it.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
It seems rather too risky, especially considering that for example, there are a few Intel drivers which do not have maintainers (like
i40e).
Quoted 1 line
So, I don't know what will happen to such drivers. They may be left broken
(if they are affected) for 24.11 and future releases.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
But I agree that if default behavior is preserved, this dependence of drivers
on config restore might stay as is.
Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
I'm on the fence about it.
Yeah, not sure.
Quoted 9 lines
Quoted 4 lines
Do you think the
dev_opsfunction can be implemented in the 'ethdev_driver.c' and all drivers use exact same function? So this reduces changes and duplication in drivers while preserving the behavior.Wonder why it can't be done visa-versa?
If this new function is not implemented by PMD, then simply assume that everything needs to be restored (as it happens now)?True, this preserve the behavior and prevents updating all drivers.
I think can be done in two ways:
1.dev_ops()tells what NOT to restore, ifdev_ops()not implemented or it returns zero, restore everything. Here what not nice is what to restore in this case is not very well defined.
Quoted 8 lines
Quoted 6 lines
2.
dev_ops()tells what to restore, but when not implemented default flag value is all restore. Which is current behavior.I am for option 2. and I assume that is what Konstantin also suggest, but I want to clarify to be sure.
Yep, I am also in favor of option 2.
I sent the patch series implementing the option 2: https://patches.dpdk.org/project/dpdk/list/?series=33433
Quoted 119 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 7 lines
Only we may implement this to the drivers that exist when this restore code was introduced.
I mean whatever driver exist in the initial DPDK commit, implement this logic only to those drivers.Seems reasonable to me. In this case, it would be igb (IIUC, now it's named
e1000) and ixgbe.
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 11 lines
Quoted 5 lines
Also, there's an open question about 'stop' and 'reset' operations. At the moment, ethdev layer does not do any config manipulation during these
operations.
Quoted 2 lines
Maybe we should limit
get_restore_flags()to 'start' only?Ack, I was about to suggest the same, for now only have '
RTE_ETH_START' as a placeholder for later possible usages.Ack
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
So PMDs only will provide what to restore with an internal API and common ethdev layer will restore it.
If no restore required PMD may not implement .get_restore_flags() atall.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Additionally,
RTE_ETH_START,RTE_ETH_RESETetc flag can be provided to internal API to get what to restore in different states...Quoted 7 lines
Quoted 3 lines
Suggested '
internal_flag' in "structrte_eth_dev_data" can be confusing and open to interpretation what to use it for and by time become source of defect.Yes, same thoughts.
Quoted 1 line
Instead what do you think to have a separate, dedicated data struct
for it?
Quoted 74 lines
Quoted 74 lines
Quoted 73 lines
Quoted 73 lines
Quoted 72 lines
Quoted 72 lines
Quoted 71 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Hmm... not sure I understood you here...
Quoted 4 lines
Quoted 4 lines
Might be we can move this restoration code into the new
ethdev helper function,(ethdevd_user_config_restore() or
so) that PMD can invokeduring its
dev_start()if needed?Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
#define RTE_ETH_DEV_INTERNAL_PROMISC_FORCE_RESTORE
RTE_BIT32(0)Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define RTE_ETH_DEV_INTERNAL_ALLMULTI_FORCE_RESTORE
RTE_BIT32(1)Quoted 6 lines
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
#define RTE_ETH_DEV_INTERNAL_MAC_ADDR_FORCE_RESTORE
RTE_BIT32(2)Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
struct rte_eth_dev_data {
/* snip */Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
uint32_t dev_flags;
/**
* Internal device capabilities, used only by ethdev library.
* Certain functionalities provided by the library
mightenabled/disabled,
Quoted 44 lines
Quoted 43 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
* based on driver exposing certain capabilities.
*/
uint32_t internal_flags;/* snip */
};Also perhaps we have go into details what needs to be
restored after 'stop' and what needs to be restored
after 'reset' and use similarmechanism etc...
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
I think we should look into that.
Any 'codification' of semantics between drivers and
ethdev library is good inmy opinion.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
At least right now, ethdev does not change any
configuration in 'stop' and'reset' from what I see.
Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
But that's on library side only.
This way, if we would conclude that it makes sense for
.dev_start() to handle all starting configuration
aspects, we could track which drivers still rely
on configuration restore.Dariusz Sosnowski (4):
ethdev: rework config restore
ethdev: omit promiscuous config restore if not required
ethdev: omit all multicast config restore if not required
ethdev: omit MAC address restore if not requiredlib/ethdev/rte_ethdev.c | 39
++++++++++++++++++++++++++++++++++-----
lib/ethdev/rte_ethdev.h | 18 ++++++++++++++++++
2 files changed, 52 insertions(+), 5 deletions(-)--
2.39.5