{net, IB}/mlx5: Manage port association for multiport RoCE
[linux-2.6-block.git] / include / linux / mlx5 / driver.h
index 28733529f6ff95a223b2ed3edb1ac75192fe8046..d5c787519e06d0938fc9566d340c0e48c5674222 100644 (file)
@@ -1234,9 +1234,29 @@ static inline bool mlx5_rl_is_supported(struct mlx5_core_dev *dev)
        return !!(dev->priv.rl_table.max_size);
 }
 
+static inline int mlx5_core_is_mp_slave(struct mlx5_core_dev *dev)
+{
+       return MLX5_CAP_GEN(dev, affiliate_nic_vport_criteria) &&
+              MLX5_CAP_GEN(dev, num_vhca_ports) <= 1;
+}
+
+static inline int mlx5_core_is_mp_master(struct mlx5_core_dev *dev)
+{
+       return MLX5_CAP_GEN(dev, num_vhca_ports) > 1;
+}
+
+static inline int mlx5_core_mp_enabled(struct mlx5_core_dev *dev)
+{
+       return mlx5_core_is_mp_slave(dev) ||
+              mlx5_core_is_mp_master(dev);
+}
+
 static inline int mlx5_core_native_port_num(struct mlx5_core_dev *dev)
 {
-       return 1;
+       if (!mlx5_core_mp_enabled(dev))
+               return 1;
+
+       return MLX5_CAP_GEN(dev, native_port_num);
 }
 
 enum {