Skip to content

Commit b6daefd

Browse files
committed
Add ifdefs for changes to devlink_port_attrs_set
Signed-off-by: Alex Forencich <alex@alexforencich.com>
1 parent 22f4ed6 commit b6daefd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

modules/mqnic/mqnic_port.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55

66
#include "mqnic.h"
77

8+
#include <linux/version.h>
9+
810
struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
911
int phys_index, struct mqnic_reg_block *port_rb)
1012
{
1113
struct device *dev = interface->dev;
1214
struct devlink *devlink = priv_to_devlink(interface->mdev);
15+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
1316
struct devlink_port_attrs attrs = {};
17+
#endif
1418
struct mqnic_port *port;
1519
struct mqnic_reg_block *rb;
1620
u32 offset;
@@ -21,9 +25,19 @@ struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
2125
if (!port)
2226
return ERR_PTR(-ENOMEM);
2327

28+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
2429
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
2530
attrs.phys.port_number = phys_index;
2631
devlink_port_attrs_set(&port->dl_port, &attrs);
32+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
33+
devlink_port_attrs_set(&port->dl_port,
34+
DEVLINK_PORT_FLAVOUR_PHYSICAL,
35+
phys_index, 0, 0, NULL, 0);
36+
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
37+
devlink_port_attrs_set(&port->dl_port,
38+
DEVLINK_PORT_FLAVOUR_PHYSICAL,
39+
phys_index, 0, 0);
40+
#endif
2741

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

0 commit comments

Comments
 (0)