* [PATCH net-next v2 0/2] devlink port attr cleanup
@ 2025-08-13 9:44 Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 1/2] devlink/port: Simplify return checks Parav Pandit
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Parav Pandit @ 2025-08-13 9:44 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, netdev, vadim.fedorenko
Cc: jiri, Parav Pandit
Hi,
This two small patches simplifies the devlink port attributes set
functions.
Summary:
patch-1 removes the return 0 check at several places and simplfies
patch-2 constifies the attributes and moves the checks early
caller
Please review.
changelog:
v1->v2:
- Addressed comments from Jakub and Vadim
- changed patch order
- replaced dl_port_attrs to attrs that matches implementation API
declaration
Parav Pandit (2):
devlink/port: Simplify return checks
devlink/port: Check attributes early and constify
include/net/devlink.h | 2 +-
net/devlink/port.c | 33 ++++++++-------------------------
2 files changed, 9 insertions(+), 26 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net-next v2 1/2] devlink/port: Simplify return checks
2025-08-13 9:44 [PATCH net-next v2 0/2] devlink port attr cleanup Parav Pandit
@ 2025-08-13 9:44 ` Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 2/2] devlink/port: Check attributes early and constify Parav Pandit
2025-08-15 0:50 ` [PATCH net-next v2 0/2] devlink port attr cleanup patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Parav Pandit @ 2025-08-13 9:44 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, netdev, vadim.fedorenko
Cc: jiri, Parav Pandit, Jiri Pirko
Drop always returning 0 from the helper routine and simplify
its callers.
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Parav Pandit <parav@nvidia.com>
---
changelog:
v1->v2:
- Addressed comments from Jakub and Vadim
- changed patch order
v1: https://lore.kernel.org/netdev/20250812035106.134529-1-parav@nvidia.com/T/#t
---
net/devlink/port.c | 29 ++++++-----------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/net/devlink/port.c b/net/devlink/port.c
index 939081a0e615..1bb5df75aa20 100644
--- a/net/devlink/port.c
+++ b/net/devlink/port.c
@@ -1333,8 +1333,8 @@ int devlink_port_netdevice_event(struct notifier_block *nb,
return NOTIFY_OK;
}
-static int __devlink_port_attrs_set(struct devlink_port *devlink_port,
- enum devlink_port_flavour flavour)
+static void __devlink_port_attrs_set(struct devlink_port *devlink_port,
+ enum devlink_port_flavour flavour)
{
struct devlink_port_attrs *attrs = &devlink_port->attrs;
@@ -1347,7 +1347,6 @@ static int __devlink_port_attrs_set(struct devlink_port *devlink_port,
} else {
devlink_port->switch_port = false;
}
- return 0;
}
/**
@@ -1359,14 +1358,10 @@ static int __devlink_port_attrs_set(struct devlink_port *devlink_port,
void devlink_port_attrs_set(struct devlink_port *devlink_port,
struct devlink_port_attrs *attrs)
{
- int ret;
-
ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port);
devlink_port->attrs = *attrs;
- ret = __devlink_port_attrs_set(devlink_port, attrs->flavour);
- if (ret)
- return;
+ __devlink_port_attrs_set(devlink_port, attrs->flavour);
WARN_ON(attrs->splittable && attrs->split);
}
EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
@@ -1383,14 +1378,10 @@ void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 contro
u16 pf, bool external)
{
struct devlink_port_attrs *attrs = &devlink_port->attrs;
- int ret;
ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port);
- ret = __devlink_port_attrs_set(devlink_port,
- DEVLINK_PORT_FLAVOUR_PCI_PF);
- if (ret)
- return;
+ __devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PCI_PF);
attrs->pci_pf.controller = controller;
attrs->pci_pf.pf = pf;
attrs->pci_pf.external = external;
@@ -1411,14 +1402,10 @@ void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 contro
u16 pf, u16 vf, bool external)
{
struct devlink_port_attrs *attrs = &devlink_port->attrs;
- int ret;
ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port);
- ret = __devlink_port_attrs_set(devlink_port,
- DEVLINK_PORT_FLAVOUR_PCI_VF);
- if (ret)
- return;
+ __devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PCI_VF);
attrs->pci_vf.controller = controller;
attrs->pci_vf.pf = pf;
attrs->pci_vf.vf = vf;
@@ -1439,14 +1426,10 @@ void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port, u32 contro
u16 pf, u32 sf, bool external)
{
struct devlink_port_attrs *attrs = &devlink_port->attrs;
- int ret;
ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port);
- ret = __devlink_port_attrs_set(devlink_port,
- DEVLINK_PORT_FLAVOUR_PCI_SF);
- if (ret)
- return;
+ __devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PCI_SF);
attrs->pci_sf.controller = controller;
attrs->pci_sf.pf = pf;
attrs->pci_sf.sf = sf;
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH net-next v2 2/2] devlink/port: Check attributes early and constify
2025-08-13 9:44 [PATCH net-next v2 0/2] devlink port attr cleanup Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 1/2] devlink/port: Simplify return checks Parav Pandit
@ 2025-08-13 9:44 ` Parav Pandit
2025-08-15 0:50 ` [PATCH net-next v2 0/2] devlink port attr cleanup patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Parav Pandit @ 2025-08-13 9:44 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni, horms, netdev, vadim.fedorenko
Cc: jiri, Parav Pandit, Jiri Pirko
Constify the devlink port attributes to indicate they are read only
and does not depend on anything else. Therefore, validate it early
before setting in the devlink port.
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Parav Pandit <parav@nvidia.com>
---
changelog:
v1->v2:
- Addressed comments from Jakub and Vadim
- changed patch order
- replaced dl_port_attrs to attrs that matches implementation
v1: https://lore.kernel.org/netdev/20250812035106.134529-1-parav@nvidia.com/T/#t
---
include/net/devlink.h | 2 +-
net/devlink/port.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 93640a29427c..052234f0d8ce 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -1739,7 +1739,7 @@ void devlink_port_type_ib_set(struct devlink_port *devlink_port,
struct ib_device *ibdev);
void devlink_port_type_clear(struct devlink_port *devlink_port);
void devlink_port_attrs_set(struct devlink_port *devlink_port,
- struct devlink_port_attrs *devlink_port_attrs);
+ const struct devlink_port_attrs *attrs);
void devlink_port_attrs_pci_pf_set(struct devlink_port *devlink_port, u32 controller,
u16 pf, bool external);
void devlink_port_attrs_pci_vf_set(struct devlink_port *devlink_port, u32 controller,
diff --git a/net/devlink/port.c b/net/devlink/port.c
index 1bb5df75aa20..93f2969b9cf3 100644
--- a/net/devlink/port.c
+++ b/net/devlink/port.c
@@ -1356,13 +1356,13 @@ static void __devlink_port_attrs_set(struct devlink_port *devlink_port,
* @attrs: devlink port attrs
*/
void devlink_port_attrs_set(struct devlink_port *devlink_port,
- struct devlink_port_attrs *attrs)
+ const struct devlink_port_attrs *attrs)
{
ASSERT_DEVLINK_PORT_NOT_REGISTERED(devlink_port);
+ WARN_ON(attrs->splittable && attrs->split);
devlink_port->attrs = *attrs;
__devlink_port_attrs_set(devlink_port, attrs->flavour);
- WARN_ON(attrs->splittable && attrs->split);
}
EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next v2 0/2] devlink port attr cleanup
2025-08-13 9:44 [PATCH net-next v2 0/2] devlink port attr cleanup Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 1/2] devlink/port: Simplify return checks Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 2/2] devlink/port: Check attributes early and constify Parav Pandit
@ 2025-08-15 0:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-15 0:50 UTC (permalink / raw)
To: Parav Pandit
Cc: davem, edumazet, kuba, pabeni, horms, netdev, vadim.fedorenko,
jiri
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 13 Aug 2025 12:44:15 +0300 you wrote:
> Hi,
>
> This two small patches simplifies the devlink port attributes set
> functions.
>
> Summary:
> patch-1 removes the return 0 check at several places and simplfies
> patch-2 constifies the attributes and moves the checks early
> caller
>
> [...]
Here is the summary with links:
- [net-next,v2,1/2] devlink/port: Simplify return checks
https://git.kernel.org/netdev/net-next/c/0ebc0bcd0aa0
- [net-next,v2,2/2] devlink/port: Check attributes early and constify
https://git.kernel.org/netdev/net-next/c/41a6e8ab1864
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-15 0:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 9:44 [PATCH net-next v2 0/2] devlink port attr cleanup Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 1/2] devlink/port: Simplify return checks Parav Pandit
2025-08-13 9:44 ` [PATCH net-next v2 2/2] devlink/port: Check attributes early and constify Parav Pandit
2025-08-15 0:50 ` [PATCH net-next v2 0/2] devlink port attr cleanup patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).