Commit Graph

37 Commits

Author SHA1 Message Date
Petr Oros 850da3338c devlink: Fix devlink parallel commands processing
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit d7d75124965aee23e5e4421d78376545cf070b0a
Author: Shay Drory <shayd@nvidia.com>
Date:   Tue Mar 12 12:52:38 2024 +0200

    devlink: Fix devlink parallel commands processing

    Commit 870c7ad4a52b ("devlink: protect devlink->dev by the instance
    lock") added devlink instance locking inside a loop that iterates over
    all the registered devlink instances on the machine in the pre-doit
    phase. This can lead to serialization of devlink commands over
    different devlink instances.

    For example: While the first devlink instance is executing firmware
    flash, all commands to other devlink instances on the machine are
    forced to wait until the first devlink finishes.

    Therefore, in the pre-doit phase, take the devlink instance lock only
    for the devlink instance the command is targeting. Devlink layer is
    taking a reference on the devlink instance, ensuring the devlink->dev
    pointer is valid. This reference taking was introduced by commit
    a380687200e0 ("devlink: take device reference for devlink object").
    Without this commit, it would not be safe to access devlink->dev
    lockless.

    Fixes: 870c7ad4a52b ("devlink: protect devlink->dev by the instance lock")
    Signed-off-by: Shay Drory <shayd@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-30 12:36:41 +02:00
Petr Oros 298f4a3ca9 devlink: extend multicast filtering by port index
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit ded6f77c05b113001d449cf2cc810e090f20ec4a
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Sat Dec 16 13:30:01 2023 +0100

    devlink: extend multicast filtering by port index

    Expose the previously introduced notification multicast messages
    filtering infrastructure and allow the user to select messages using
    port index.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:10 +02:00
Petr Oros d32acff1d1 devlink: add a command to set notification filter and use it for multicasts
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit 13b127d2578432e1e521310b69944c5a1b30679c
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Sat Dec 16 13:30:00 2023 +0100

    devlink: add a command to set notification filter and use it for multicasts

    Currently the user listening on a socket for devlink notifications
    gets always all messages for all existing instances, even if he is
    interested only in one of those. That may cause unnecessary overhead
    on setups with thousands of instances present.

    User is currently able to narrow down the devlink objects replies
    to dump commands by specifying select attributes.

    Allow similar approach for notifications. Introduce a new devlink
    NOTIFY_FILTER_SET which the user passes the select attributes. Store
    these per-socket and use them for filtering messages
    during multicast send.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:10 +02:00
Petr Oros 5a324ef43d devlink: Acquire device lock during reload command
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit bf6b200bc80d18480f8d0fb61e185bb0587e633c
Author: Ido Schimmel <idosch@nvidia.com>
Date:   Wed Nov 15 13:17:14 2023 +0100

    devlink: Acquire device lock during reload command

    Device drivers register with devlink from their probe routines (under
    the device lock) by acquiring the devlink instance lock and calling
    devl_register().

    Drivers that support a devlink reload usually implement the
    reload_{down, up}() operations in a similar fashion to their remove and
    probe routines, respectively.

    However, while the remove and probe routines are invoked with the device
    lock held, the reload operations are only invoked with the devlink
    instance lock held. It is therefore impossible for drivers to acquire
    the device lock from their reload operations, as this would result in
    lock inversion.

    The motivating use case for invoking the reload operations with the
    device lock held is in mlxsw which needs to trigger a PCI reset as part
    of the reload. The driver cannot call pci_reset_function() as this
    function acquires the device lock. Instead, it needs to call
    __pci_reset_function_locked which expects the device lock to be held.

    To that end, adjust devlink to always acquire the device lock before the
    devlink instance lock when performing a reload.

    Do that when reload is explicitly triggered by user space by specifying
    the 'DEVLINK_NL_FLAG_NEED_DEV_LOCK' flag in the pre_doit and post_doit
    operations of the reload command.

    A previous patch already handled the case where reload is invoked as
    part of netns dismantle.

    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:06 +02:00
Petr Oros 33afa4c3ac devlink: Allow taking device lock in pre_doit operations
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit d32c38256db30a2d55b849e2c77342bc70d58c6e
Author: Ido Schimmel <idosch@nvidia.com>
Date:   Wed Nov 15 13:17:13 2023 +0100

    devlink: Allow taking device lock in pre_doit operations

    Introduce a new private flag ('DEVLINK_NL_FLAG_NEED_DEV_LOCK') to allow
    netlink commands to specify that they need to acquire the device lock in
    their pre_doit operation and release it in their post_doit operation.

    The reload command will use this flag in the subsequent patch.

    No functional changes intended.

    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:05 +02:00
Petr Oros 9a27a3c46b devlink: Enable the use of private flags in post_doit operations
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit c8d0a7d6152bec970552786b77626f4b4c562f4d
Author: Ido Schimmel <idosch@nvidia.com>
Date:   Wed Nov 15 13:17:12 2023 +0100

    devlink: Enable the use of private flags in post_doit operations

    Currently, private flags (e.g., 'DEVLINK_NL_FLAG_NEED_PORT') are only
    used in pre_doit operations, but a subsequent patch will need to
    conditionally lock and unlock the device lock in pre and post doit
    operations, respectively.

    As a preparation, enable the use of private flags in post_doit
    operations in a similar fashion to how it is done for pre_doit
    operations.

    No functional changes intended.

    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:05 +02:00
Petr Oros 2d07429340 devlink: Move private netlink flags to C file
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit 526dd6d7877b80b1f56d87156b65b8227c69d59f
Author: Ido Schimmel <idosch@nvidia.com>
Date:   Wed Nov 15 13:17:10 2023 +0100

    devlink: Move private netlink flags to C file

    The flags are not used outside of the C file so move them there.

    Suggested-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Petr Machata <petrm@nvidia.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:05 +02:00
Petr Oros 33978784bf devlink: remove netlink small_ops
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit cebe7306073d4afeb24886f9063417e559fa2e22
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Sat Oct 21 13:27:11 2023 +0200

    devlink: remove netlink small_ops

    All commands are now covered by generated split_ops. Remove the
    small_ops entirely alongside with unified devlink netlink policy array.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://lore.kernel.org/r/20231021112711.660606-11-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:04 +02:00
Petr Oros 73146979d4 devlink: rename netlink callback to be aligned with the generated ones
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit 53590934ba9549c55c57a32e2a6980139af00345
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Sat Oct 21 13:27:08 2023 +0200

    devlink: rename netlink callback to be aligned with the generated ones

    All remaining doit and dumpit netlink callback functions are going to be
    used by generated split ops. They expect certain name format. Rename the
    callback to be aligned with generated names.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Link: https://lore.kernel.org/r/20231021112711.660606-8-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:04 +02:00
Petr Oros 05f6585afe devlink: call peernet2id_alloc() with net pointer under RCU read lock
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit c503bc7df602257e9d03851654a347649a33f3c3
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Oct 13 14:10:24 2023 +0200

    devlink: call peernet2id_alloc() with net pointer under RCU read lock

    peernet2id_alloc() allows to be called lockless with peer net pointer
    obtained in RCU critical section and makes sure to return ns ID if net
    namespaces is not being removed concurrently. Benefit from
    read_pnet_rcu() helper addition, use it to obtain net pointer under RCU
    read lock and pass it to peernet2id_alloc() to get ns ID.

    Fixes: c137743bce02 ("devlink: introduce object and nested devlink relationship infra")
    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:01 +02:00
Petr Oros d85d2b504b devlink: extend devlink_nl_put_nested_handle() with attrtype arg
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit 1c2197c47a93d0ea36e73e437271c7cbcc0e1ceb
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Sep 13 09:12:37 2023 +0200

    devlink: extend devlink_nl_put_nested_handle() with attrtype arg

    As the next patch is going to call this helper with need to fill another
    type of nested attribute, pass it over function arg.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:16:00 +02:00
Petr Oros bd8ba7a254 devlink: move devlink_nl_put_nested_handle() into netlink.c
JIRA: https://issues.redhat.com/browse/RHEL-30145

Upstream commit(s):
commit af1f1400af02e5a069d86ae7001b563c99395ea2
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Sep 13 09:12:36 2023 +0200

    devlink: move devlink_nl_put_nested_handle() into netlink.c

    As the next patch is going to call this helper out of the linecard.c,
    move to netlink.c.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-04-26 17:15:59 +02:00
Ivan Vecera b82a843753 devlink: move small_ops definition into netlink.c
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 29a390d17748d93f9e6bc6fb0e09d89571aa25f6
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Mon Aug 28 08:16:56 2023 +0200

    devlink: move small_ops definition into netlink.c

    Move the generic netlink small_ops definition where they are consumed,
    into netlink.c

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Link: https://lore.kernel.org/r/20230828061657.300667-15-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:34 +02:00
Ivan Vecera cf4877bf90 devlink: move and rename devlink_dpipe_send_and_alloc_skb() helper
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 2475ed158c478c624d8fbc8d639d344a960c1ad8
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Mon Aug 28 08:16:46 2023 +0200

    devlink: move and rename devlink_dpipe_send_and_alloc_skb() helper

    Since both dpipe and resource code is using this helper, in preparation
    for code split to separate files, move
    devlink_dpipe_send_and_alloc_skb() helper into netlink.c. Rename it on
    the way.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Link: https://lore.kernel.org/r/20230828061657.300667-5-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:33 +02:00
Ivan Vecera 821b40dbfa genetlink: use attrs from struct genl_info
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 7288dd2fd4888c85c687f8ded69c280938d1a7b6
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Mon Aug 14 14:47:18 2023 -0700

    genetlink: use attrs from struct genl_info

    Since dumps carry struct genl_info now, use the attrs pointer
    from genl_info and remove the one in struct genl_dumpit_info.

    Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
    Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Link: https://lore.kernel.org/r/20230814214723.2924989-6-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:30 +02:00
Ivan Vecera 1ae2f7e121 devlink: allow user to narrow per-instance dumps by passing handle attrs
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 4a1b5aa8b5c7433ad6e0c8b52469980ae94a4398
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Aug 11 17:57:11 2023 +0200

    devlink: allow user to narrow per-instance dumps by passing handle attrs

    For SFs, one devlink instance per SF is created. There might be
    thousands of these on a single host. When a user needs to know port
    handle for specific SF, he needs to dump all devlink ports on the host
    which does not scale good.

    Allow user to pass devlink handle attributes alongside the dump command
    and dump only objects which are under selected devlink instance.

    Example:
    $ devlink port show
    auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false
    auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false

    $ devlink port show auxiliary/mlx5_core.eth.0
    auxiliary/mlx5_core.eth.0/65535: type eth netdev eth2 flavour physical port 0 splittable false

    $ devlink port show auxiliary/mlx5_core.eth.1
    auxiliary/mlx5_core.eth.1/131071: type eth netdev eth3 flavour physical port 1 splittable false

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230811155714.1736405-11-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:30 +02:00
Ivan Vecera 33e81c6578 devlink: pass flags as an arg of dump_one() callback
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 7d3c6fec6135e10842587f38a15d7d06fd02c21f
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Aug 11 17:57:07 2023 +0200

    devlink: pass flags as an arg of dump_one() callback

    In order to easily set NLM_F_DUMP_FILTERED for partial dumps, pass the
    flags as an arg of dump_one() callback. Currently, it is always
    NLM_F_MULTI.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230811155714.1736405-7-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:30 +02:00
Ivan Vecera 04f6da8c7a devlink: introduce dumpit callbacks for split ops
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 24c8e56d4f983527cc5e1f6d771fef8ec7ce352e
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Aug 11 17:57:06 2023 +0200

    devlink: introduce dumpit callbacks for split ops

    Introduce dumpit callbacks for generated split ops. Have them
    as a thin wrapper around iteration function and allow to pass dump_one()
    function pointer directly without need to store in devlink_cmd structs.

    Note that the function prototypes are temporary until the generated ones
    will replace them in a follow-up patch.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230811155714.1736405-6-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:29 +02:00
Ivan Vecera 86a262a937 devlink: introduce devlink_nl_pre_doit_port*() helper functions
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit ee6d78ac28c708c62fd83595e9366b0eb0deb014
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Aug 11 17:57:04 2023 +0200

    devlink: introduce devlink_nl_pre_doit_port*() helper functions

    Define port handling helpers what don't rely on internal_flags.
    Have __devlink_nl_pre_doit() to accept the flags as a function arg and
    make devlink_nl_pre_doit() a wrapper helper function calling it.
    Introduce new helpers devlink_nl_pre_doit_port() and
    devlink_nl_pre_doit_port_optional() to be used by split ops in follow-up
    patch.

    Note that the function prototypes are temporary until the generated ones
    will replace them in a follow-up patch.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230811155714.1736405-4-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:29 +02:00
Ivan Vecera 43241b40cc devlink: parse rate attrs in doit() callbacks
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 41a1d4d1399af0f4ba9754086b23f7b9576eb25f
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Aug 11 17:57:03 2023 +0200

    devlink: parse rate attrs in doit() callbacks

    No need to give the rate any special treatment in netlink attributes
    parsing, as unlike for ports, there is only a couple of commands
    benefiting from that.

    Remove DEVLINK_NL_FLAG_NEED_RATE*, make pre_doit() callback simpler
    by moving the rate attributes parsing to rate_*_doit() ops.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230811155714.1736405-3-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:29 +02:00
Ivan Vecera c79b906811 devlink: parse linecard attr in doit() callbacks
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 63618463cb94bda3ee68dc2ada998c0ef3c00e67
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Fri Aug 11 17:57:02 2023 +0200

    devlink: parse linecard attr in doit() callbacks

    No need to give the linecards any special treatment in netlink attribute
    parsing, as unlike for ports, there is only a couple of commands
    benefiting from that.

    Remove DEVLINK_NL_FLAG_NEED_LINECARD, make pre_doit() callback simpler
    by moving the linecard attribute parsing to linecard_[gs]et_doit() ops.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230811155714.1736405-2-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:29 +02:00
Ivan Vecera f0a3e0d6a2 devlink: use generated split ops and remove duplicated commands from small ops
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 6e067d0cab68a64ef3488b5639a66b65e91b146d
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Thu Aug 3 13:13:40 2023 +0200

    devlink: use generated split ops and remove duplicated commands from small ops

    Do the switch and use generated split ops for get and info_get commands.
    Remove those from small ops array.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230803111340.1074067-13-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:29 +02:00
Ivan Vecera 214805e93a devlink: un-static devlink_nl_pre/post_doit()
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 8300dce542e45c50ef318c4493bbb2e7966a883c
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Thu Aug 3 13:13:36 2023 +0200

    devlink: un-static devlink_nl_pre/post_doit()

    To be prepared for the follow-up generated split ops addition,
    make the functions devlink_nl_pre_doit() and devlink_nl_post_doit()
    usable outside of netlink.c. Introduce temporary prototypes which are
    going to be removed once the generated header will be included.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230803111340.1074067-9-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:28 +02:00
Ivan Vecera ebba2c624c devlink: introduce couple of dumpit callbacks for split ops
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit 491a24872a64cbb8edf996b6113a97586702e5ca
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Thu Aug 3 13:13:35 2023 +0200

    devlink: introduce couple of dumpit callbacks for split ops

    Introduce couple of dumpit callbacks for generated split ops. Have them
    as a thin wrapper around iteration function and allow to pass dump_one()
    function pointer directly without need to store in devlink_cmd structs.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230803111340.1074067-8-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:28 +02:00
Ivan Vecera 8d6fb0c41a devlink: rename devlink_nl_ops to devlink_nl_small_ops
JIRA: https://issues.redhat.com/browse/RHEL-30656

commit ba0f66c95fa670d99ad40e4a6c1ede425446a291
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Thu Aug 3 13:13:33 2023 +0200

    devlink: rename devlink_nl_ops to devlink_nl_small_ops

    In order to avoid name collision with the generated split ops array
    which is going to be introduced as a follow-up patch, rename
    the existing ops array to devlink_nl_small_ops.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jakub Kicinski <kuba@kernel.org>
    Link: https://lore.kernel.org/r/20230803111340.1074067-6-jiri@resnulli.us
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-04-10 09:19:28 +02:00
Petr Oros 5dbe9b823d devlink: rename and reorder instances of struct devlink_cmd
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 8589ba4e642aa257fa46ee82c975921e19db47d5
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Tue Jan 31 10:06:13 2023 +0100

    devlink: rename and reorder instances of struct devlink_cmd

    In order to maintain naming consistency, rename and reorder all usages
    of struct struct devlink_cmd in the following way:
    1) Remove "gen" and replace it with "cmd" to match the struct name
    2) Order devl_cmds[] and the header file to match the order
       of enum devlink_command
    3) Move devl_cmd_rate_get among the peers
    4) Remove "inst" for DEVLINK_CMD_GET
    5) Add "_get" suffix to all to match DEVLINK_CMD_*_GET (only rate had it
       done correctly)

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-04 11:12:23 +02:00
Petr Oros 889b3ee804 devlink: remove "gen" from struct devlink_gen_cmd name
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit f87445953d4c1cbcaa110f95dfd64193756f7353
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Tue Jan 31 10:06:12 2023 +0100

    devlink: remove "gen" from struct devlink_gen_cmd name

    No need to have "gen" inside name of the structure for devlink commands.
    Remove it.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-04 11:12:23 +02:00
Petr Oros 043f03ef33 devlink: rename devlink_nl_instance_iter_dump() to "dumpit"
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit c3a4fd5718ea6756f2289f4d89468b54ad3d02aa
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Tue Jan 31 10:06:11 2023 +0100

    devlink: rename devlink_nl_instance_iter_dump() to "dumpit"

    To have the name of the function consistent with the struct cb name,
    rename devlink_nl_instance_iter_dump() to
    devlink_nl_instance_iter_dumpit().

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-04 11:12:23 +02:00
Petr Oros 4e5ff960c0 devlink: remove devlink_dump_for_each_instance_get() helper
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 543753d9e22e3943e2c31c4b5241afafb55dd52a
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Jan 18 16:21:14 2023 +0100

    devlink: remove devlink_dump_for_each_instance_get() helper

    devlink_dump_for_each_instance_get() is currently called from
    a single place in netlink.c. As there is no need to use
    this helper anywhere else in the future, remove it and
    call devlinks_xa_find_get() directly from while loop
    in devlink_nl_instance_iter_dump(). Also remove redundant
    idx clear on loop end as it is already done
    in devlink_nl_instance_iter_dump().

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-04 11:12:19 +02:00
Petr Oros c488162f11 devlink: convert reporters dump to devlink_nl_instance_iter_dump()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 19be51a93d9986edcfecae010920ab1d5714479b
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Jan 18 16:21:13 2023 +0100

    devlink: convert reporters dump to devlink_nl_instance_iter_dump()

    Benefit from recently introduced instance iteration and convert
    reporters .dumpit generic netlink callback to use it.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-04 11:12:19 +02:00
Petr Oros b4e89acba9 devlink: convert linecards dump to devlink_nl_instance_iter_dump()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 2557396808d916189ec5812f64e2b08bfb905807
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Jan 18 16:21:12 2023 +0100

    devlink: convert linecards dump to devlink_nl_instance_iter_dump()

    Benefit from recently introduced instance iteration and convert
    linecards .dumpit generic netlink callback to use it.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-04 11:12:18 +02:00
Petr Oros 0356a5743b devlink: remove linecard reference counting
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 3a10173f48aa1bae64baf0fea228c6045996b117
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Jan 18 16:21:05 2023 +0100

    devlink: remove linecard reference counting

    As long as the linecard life time is protected by devlink instance
    lock, the reference counting is no longer needed. Remove it.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 14:06:09 +02:00
Petr Oros b753c1904f devlink: always check if the devlink instance is registered
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit ed539ba614a079ea696b92beef1eafec66f831a4
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Thu Jan 5 22:33:57 2023 -0800

    devlink: always check if the devlink instance is registered

    Always check under the instance lock whether the devlink instance
    is still / already registered.

    This is a no-op for the most part, as the unregistration path currently
    waits for all references. On the init path, however, we may temporarily
    open up a race with netdev code, if netdevs are registered before the
    devlink instance. This is temporary, the next change fixes it, and this
    commit has been split out for the ease of review.

    Note that in case of iterating over sub-objects which have their
    own lock (regions and line cards) we assume an implicit dependency
    between those objects existing and devlink unregistration.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 14:06:07 +02:00
Petr Oros 8f59d7aaa7 devlink: protect devlink->dev by the instance lock
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 870c7ad4a52be2acff92d0355ca118654c7efece
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Thu Jan 5 22:33:56 2023 -0800

    devlink: protect devlink->dev by the instance lock

    devlink->dev is assumed to be always valid as long as any
    outstanding reference to the devlink instance exists.

    In prep for weakening of the references take the instance lock.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 14:06:07 +02:00
Petr Oros be64a81954 devlink: convert remaining dumps to the by-instance scheme
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 5ce76d78b99650c0b22f466060d8b75df9123511
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Jan 4 20:05:31 2023 -0800

    devlink: convert remaining dumps to the by-instance scheme

    Soon we'll have to check if a devlink instance is alive after
    locking it. Convert to the by-instance dumping scheme to make
    refactoring easier.

    Most of the subobject code no longer has to worry about any devlink
    locking / lifetime rules (the only ones that still do are the two subject
    types which stubbornly use their own locking). Both dump and do callbacks
    are given a devlink instance which is already locked and good-to-access
    (do from the .pre_doit handler, dump from the new dump indirection).

    Note that we'll now check presence of an op (e.g. for sb_pool_get)
    under the devlink instance lock, that will soon be necessary anyway,
    because we don't hold refs on the driver modules so the memory
    in which ops live may be gone for a dead instance, after upcoming
    locking changes.

    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 14:06:07 +02:00
Petr Oros de6eebe34b devlink: add by-instance dump infra
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 07f3af66089e20fe439b219d3c9d3e68d964193f
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Jan 4 20:05:30 2023 -0800

    devlink: add by-instance dump infra

    Most dumpit implementations walk the devlink instances.
    This requires careful lock taking and reference dropping.
    Factor the loop out and provide just a callback to handle
    a single instance dump.

    Convert one user as an example, other users converted
    in the next change.

    Slightly inspired by ethtool netlink code.

    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 14:06:07 +02:00
Petr Oros d1f5d4a4de devlink: split out netlink code
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Upstream commit(s):
commit 623cd13b165486afaa2df706d49209392f3764ca
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Wed Jan 4 20:05:20 2023 -0800

    devlink: split out netlink code

    Move out the netlink glue into a separate file.
    Leave the ops in the old file because we'd have to export a ton
    of functions. Going forward we should switch to split ops which
    will let us to put the new ops in the netlink.c file.

    Pure code move, no functional changes.

    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Reviewed-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 14:06:05 +02:00