35
35
#include <linux/mlx5/fs.h>
36
36
#include <net/vxlan.h>
37
37
#include <linux/bpf.h>
38
+ #include <linux/if_bridge.h>
38
39
#include <net/page_pool.h>
39
40
#include "eswitch.h"
40
41
#include "en.h"
@@ -4305,6 +4306,61 @@ static int mlx5e_xdp(struct net_device *dev, struct netdev_bpf *xdp)
4305
4306
}
4306
4307
}
4307
4308
4309
+ #ifdef CONFIG_MLX5_ESWITCH
4310
+ static int mlx5e_bridge_getlink (struct sk_buff * skb , u32 pid , u32 seq ,
4311
+ struct net_device * dev , u32 filter_mask ,
4312
+ int nlflags )
4313
+ {
4314
+ struct mlx5e_priv * priv = netdev_priv (dev );
4315
+ struct mlx5_core_dev * mdev = priv -> mdev ;
4316
+ u8 mode , setting ;
4317
+ int err ;
4318
+
4319
+ err = mlx5_eswitch_get_vepa (mdev -> priv .eswitch , & setting );
4320
+ if (err )
4321
+ return err ;
4322
+ mode = setting ? BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB ;
4323
+ return ndo_dflt_bridge_getlink (skb , pid , seq , dev ,
4324
+ mode ,
4325
+ 0 , 0 , nlflags , filter_mask , NULL );
4326
+ }
4327
+
4328
+ static int mlx5e_bridge_setlink (struct net_device * dev , struct nlmsghdr * nlh ,
4329
+ u16 flags , struct netlink_ext_ack * extack )
4330
+ {
4331
+ struct mlx5e_priv * priv = netdev_priv (dev );
4332
+ struct mlx5_core_dev * mdev = priv -> mdev ;
4333
+ struct nlattr * attr , * br_spec ;
4334
+ u16 mode = BRIDGE_MODE_UNDEF ;
4335
+ u8 setting ;
4336
+ int rem ;
4337
+
4338
+ br_spec = nlmsg_find_attr (nlh , sizeof (struct ifinfomsg ), IFLA_AF_SPEC );
4339
+ if (!br_spec )
4340
+ return - EINVAL ;
4341
+
4342
+ nla_for_each_nested (attr , br_spec , rem ) {
4343
+ if (nla_type (attr ) != IFLA_BRIDGE_MODE )
4344
+ continue ;
4345
+
4346
+ if (nla_len (attr ) < sizeof (mode ))
4347
+ return - EINVAL ;
4348
+
4349
+ mode = nla_get_u16 (attr );
4350
+ if (mode > BRIDGE_MODE_VEPA )
4351
+ return - EINVAL ;
4352
+
4353
+ break ;
4354
+ }
4355
+
4356
+ if (mode == BRIDGE_MODE_UNDEF )
4357
+ return - EINVAL ;
4358
+
4359
+ setting = (mode == BRIDGE_MODE_VEPA ) ? 1 : 0 ;
4360
+ return mlx5_eswitch_set_vepa (mdev -> priv .eswitch , setting );
4361
+ }
4362
+ #endif
4363
+
4308
4364
const struct net_device_ops mlx5e_netdev_ops = {
4309
4365
.ndo_open = mlx5e_open ,
4310
4366
.ndo_stop = mlx5e_close ,
@@ -4331,6 +4387,9 @@ const struct net_device_ops mlx5e_netdev_ops = {
4331
4387
.ndo_rx_flow_steer = mlx5e_rx_flow_steer ,
4332
4388
#endif
4333
4389
#ifdef CONFIG_MLX5_ESWITCH
4390
+ .ndo_bridge_setlink = mlx5e_bridge_setlink ,
4391
+ .ndo_bridge_getlink = mlx5e_bridge_getlink ,
4392
+
4334
4393
/* SRIOV E-Switch NDOs */
4335
4394
.ndo_set_vf_mac = mlx5e_set_vf_mac ,
4336
4395
.ndo_set_vf_vlan = mlx5e_set_vf_vlan ,
0 commit comments