net/mlx5e: Set netdev name space on creation
authorMichael Guralnik <michaelgur@mellanox.com>
Tue, 29 Oct 2019 15:04:30 +0000 (17:04 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Wed, 13 Nov 2019 22:25:04 +0000 (14:25 -0800)
Use devlink instance name space to set the netdev net namespace.

Preparation patch for devlink reload implementation.

Signed-off-by: Michael Guralnik <michaelgur@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
drivers/net/ethernet/mellanox/mlx5/core/lib/mlx5.h

index 772bfdb..06a592f 100644 (file)
@@ -63,6 +63,7 @@
 #include "en/xsk/rx.h"
 #include "en/xsk/tx.h"
 #include "en/hv_vhca_stats.h"
+#include "lib/mlx5.h"
 
 
 bool mlx5e_check_fragmented_striding_rq_cap(struct mlx5_core_dev *mdev)
@@ -5427,6 +5428,7 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
                return NULL;
        }
 
+       dev_net_set(netdev, mlx5_core_net(mdev));
        priv = netdev_priv(netdev);
 
        err = mlx5e_attach(mdev, priv);
index cd9bb7c..c7f98f1 100644 (file)
@@ -47,6 +47,7 @@
 #include "en/tc_tun.h"
 #include "fs_core.h"
 #include "lib/port_tun.h"
+#include "lib/mlx5.h"
 #define CREATE_TRACE_POINTS
 #include "diag/en_rep_tracepoint.h"
 
@@ -1877,6 +1878,7 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
                return -EINVAL;
        }
 
+       dev_net_set(netdev, mlx5_core_net(dev));
        rpriv->netdev = netdev;
        rep->rep_data[REP_ETH].priv = rpriv;
        INIT_LIST_HEAD(&rpriv->vport_sqs_list);
index b99d469..2495392 100644 (file)
@@ -84,4 +84,9 @@ int mlx5_create_encryption_key(struct mlx5_core_dev *mdev,
                               void *key, u32 sz_bytes, u32 *p_key_id);
 void mlx5_destroy_encryption_key(struct mlx5_core_dev *mdev, u32 key_id);
 
+static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
+{
+       return devlink_net(priv_to_devlink(dev));
+}
+
 #endif