5
5
6
6
#include "mqnic.h"
7
7
8
+ #include <linux/version.h>
9
+
8
10
struct mqnic_port * mqnic_create_port (struct mqnic_if * interface , int index ,
9
11
int phys_index , struct mqnic_reg_block * port_rb )
10
12
{
11
13
struct device * dev = interface -> dev ;
12
14
struct devlink * devlink = priv_to_devlink (interface -> mdev );
15
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION (5 , 9 , 0 )
13
16
struct devlink_port_attrs attrs = {};
17
+ #endif
14
18
struct mqnic_port * port ;
15
19
struct mqnic_reg_block * rb ;
16
20
u32 offset ;
@@ -21,9 +25,19 @@ struct mqnic_port *mqnic_create_port(struct mqnic_if *interface, int index,
21
25
if (!port )
22
26
return ERR_PTR (- ENOMEM );
23
27
28
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION (5 , 9 , 0 )
24
29
attrs .flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL ;
25
30
attrs .phys .port_number = phys_index ;
26
31
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
27
41
28
42
ret = devlink_port_register (devlink , & port -> dl_port , phys_index );
29
43
if (ret ) {
0 commit comments