14 Commits

Author SHA1 Message Date
adrianc
0eeb54f1c8 chore: use assert in devlink tests
this commit transitions the rest of devlink tests
to use assert package where possible.

Signed-off-by: adrianc <adrianc@nvidia.com>
2025-09-11 09:46:39 -07:00
adrianc
b85149843e feat: add additional devlink port attributes
Add the following devlink port attributes:

PortNumber: the physical port number
PfNumber: the PF number
VfNumber: the VF number (index)
SfNumber: the SF number (index)
ControllerNumber: the controller number
External: if set, indicates external controller

Signed-off-by: adrianc <adrianc@nvidia.com>
2025-09-02 12:31:49 -07:00
Vishvananda Abrams
1e35ba25dc test: Improve test reliability with proper cleanup and isolation
Refactors test setup and teardown logic to use `t.Cleanup` instead
of `defer`. This ensures that cleanup functions are correctly scoped
to each subtest's lifecycle, improving test isolation and reliability.

The `setUpNetlinkTest` helper function is also improved to correctly
save and restore the original network namespace, ensuring that tests
do not leak state.

To support this, a `Close()` method that returns an error is added to
the `Handle` struct, allowing for proper cleanup of underlying netlink
sockets. The test helpers are updated to use this new method,
preventing resource leaks between tests.

Additionally, a bug in the `netns` tests is fixed where a large
namespace ID could overflow a 32-bit integer, causing spurious
failures on some systems.
2025-08-27 09:24:17 -07:00
Yury Kulazhenkov
5daafafd95 Add functions to work with devlink device parameters
Functions added:

DevlinkGetDeviceParams - get all parameters for device
DevlinkGetDeviceParamByName - get specific parameter for device
DevlinkSetDeviceParam - set parameter for device

Signed-off-by: Yury Kulazhenkov <ykulazhenkov@nvidia.com>
2024-02-12 10:28:25 -08:00
adrianc
36b61ad22c Add support to get devlink resources
- Update nl package with new netlink attribute types and consts
- Define structs to model devlink device resources
- Add DevlinkGetDeviceResources method to return device resources
- Add basic test

Signed-off-by: adrianc <adrianc@nvidia.com>
2024-01-22 11:23:43 -08:00
Patryk Strusiewicz-Surmacki
b10eb8fe5c Support for devlink info command 2021-11-01 11:35:09 -05:00
Parav Pandit
77f3f25cb4 Add devlink port function set attribute
Add ability to set port function attributes such as state and hardware
address.

Signed-off-by: Parav Pandit <parav@nvidia.com>
2021-05-08 09:00:34 -07:00
Parav Pandit
22c099edb4 Add devlink port add delete APIs
Add APIs to add and delete a devlink port of specified flavour for a
given devlink device.

Extended test to accept devlink device and sf number parameters from the
test command line.

Signed-off-by: Parav Pandit <parav@nvidia.com>
2021-05-08 09:00:34 -07:00
Parav Pandit
83b6143251 Extend devlink port for function attributes
Extend devlink port for optional port function attributes.

Signed-off-by: Parav Pandit <parav@nvidia.com>
2021-05-08 09:00:34 -07:00
Parav Pandit
e440572571 Add devlink command to get port by index
Add a command to get information about a specific devlink port
referenced by device name and port index(bus, device, port index).

Signed-off-by: Parav Pandit <parav@mellanox.com>
2020-11-21 23:31:39 -08:00
Parav Pandit
ff8f17bc19 Add devlink command to query devlink port list
Add devlink command to get list of devlink ports and their common
attributes.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2020-11-21 23:31:39 -08:00
Parav Pandit
fd97bf4e47 Add command to set devlink device switchdev mode
Devlink device currently has legacy and switchdev mode.
Add an API to set devlink device mode for discovered devlink device.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-05-01 11:37:24 -07:00
Parav Pandit
bcb80b237c Add devlink command by to get specific device name
Add a command to get information about a specific devlink device
referenced by device name (bus, device).

Remove unused setupDevlinkKModule().

Signed-off-by: Parav Pandit <parav@mellanox.com>
2019-05-01 11:37:24 -07:00
Parav Pandit
332a6983d9 Add devlink commands for devlink device information
This patch adds very basic support for getting information about
devlink devices which are typically PCI devices which exposes Networking
switch or legacy devices.

This information includes bus name, device name and eswitch modes.
This is done through devlink family of commands via generic netlink
sockets provided by Linux kernel.

DevlinkDevice represents a devlink device which is identified by bus
name and device name (unlike interface index for netdevices).
It contains the DevlinkDevAttrs device attributes.
Currently only eswitch attributes are queried. In future more attributes
such as port, shared buffer, traffic class will be added.

Signed-off-by: Parav Pandit <parav@mellanox.com>
2018-12-19 14:37:14 -08:00