Skip to content

Commit

Permalink
Add ifdefs for changes to devlink_port_attrs_set
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Forencich <[email protected]>
  • Loading branch information
alexforencich committed Apr 16, 2024
1 parent 22f4ed6 commit b6daefd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/mqnic/mqnic_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

#include "mqnic.h"

#include <linux/version.h>

struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
int phys_index, struct mqnic_reg_block *port_rb)
{
struct device *dev = interface->dev;
struct devlink *devlink = priv_to_devlink(interface->mdev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
struct devlink_port_attrs attrs = {};
#endif
struct mqnic_port *port;
struct mqnic_reg_block *rb;
u32 offset;
Expand All @@ -21,9 +25,19 @@ struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
if (!port)
return ERR_PTR(-ENOMEM);

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
attrs.phys.port_number = phys_index;
devlink_port_attrs_set(&port->dl_port, &attrs);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
devlink_port_attrs_set(&port->dl_port,
DEVLINK_PORT_FLAVOUR_PHYSICAL,
phys_index, 0, 0, NULL, 0);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
devlink_port_attrs_set(&port->dl_port,
DEVLINK_PORT_FLAVOUR_PHYSICAL,
phys_index, 0, 0);
#endif

ret = devlink_port_register(devlink, &port->dl_port, phys_index);
if (ret) {
Expand Down

0 comments on commit b6daefd

Please sign in to comment.