net/mlx5_core: Set/Query port MTU commands
authorSaeed Mahameed <saeedm@mellanox.com>
Thu, 28 May 2015 19:28:45 +0000 (22:28 +0300)
committerDavid S. Miller <davem@davemloft.net>
Sun, 31 May 2015 01:24:08 +0000 (18:24 -0700)
Introduce set/Query low level functions to access MTU in hardware. To be
used by the netdev.

Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/port.c
include/linux/mlx5/driver.h

index 742a6fb8debe31d79e6a50eed2b68eb75582597b..7d3d0f9f328dd23855ae170f36c778f0c19abf33 100644 (file)
@@ -211,3 +211,56 @@ int mlx5_query_port_status(struct mlx5_core_dev *dev, u8 *status)
        *status = MLX5_GET(paos_reg, out, oper_status);
        return err;
 }
+
+static int mlx5_query_port_mtu(struct mlx5_core_dev *dev,
+                              int *admin_mtu, int *max_mtu, int *oper_mtu)
+{
+       u32 in[MLX5_ST_SZ_DW(pmtu_reg)];
+       u32 out[MLX5_ST_SZ_DW(pmtu_reg)];
+       int err;
+
+       memset(in, 0, sizeof(in));
+
+       MLX5_SET(pmtu_reg, in, local_port, 1);
+
+       err = mlx5_core_access_reg(dev, in, sizeof(in), out,
+                                  sizeof(out), MLX5_REG_PMTU, 0, 0);
+       if (err)
+               return err;
+
+       if (max_mtu)
+               *max_mtu  = MLX5_GET(pmtu_reg, out, max_mtu);
+       if (oper_mtu)
+               *oper_mtu = MLX5_GET(pmtu_reg, out, oper_mtu);
+       if (admin_mtu)
+               *admin_mtu = MLX5_GET(pmtu_reg, out, admin_mtu);
+
+       return 0;
+}
+
+int mlx5_set_port_mtu(struct mlx5_core_dev *dev, int mtu)
+{
+       u32 in[MLX5_ST_SZ_DW(pmtu_reg)];
+       u32 out[MLX5_ST_SZ_DW(pmtu_reg)];
+
+       memset(in, 0, sizeof(in));
+
+       MLX5_SET(pmtu_reg, in, admin_mtu, mtu);
+       MLX5_SET(pmtu_reg, in, local_port, 1);
+
+       return mlx5_core_access_reg(dev, in, sizeof(in), out, sizeof(out),
+                                   MLX5_REG_PMTU, 0, 1);
+}
+EXPORT_SYMBOL_GPL(mlx5_set_port_mtu);
+
+int mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, int *max_mtu)
+{
+       return mlx5_query_port_mtu(dev, NULL, max_mtu, NULL);
+}
+EXPORT_SYMBOL_GPL(mlx5_query_port_max_mtu);
+
+int mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, int *oper_mtu)
+{
+       return mlx5_query_port_mtu(dev, NULL, NULL, oper_mtu);
+}
+EXPORT_SYMBOL_GPL(mlx5_query_port_oper_mtu);
index 6438444ab361e9e468337385934122227e67cdc4..51738472657e3e457f36937c7ce675e137c7729a 100644 (file)
@@ -710,6 +710,10 @@ int mlx5_set_port_status(struct mlx5_core_dev *dev,
                         enum mlx5_port_status status);
 int mlx5_query_port_status(struct mlx5_core_dev *dev, u8 *status);
 
+int mlx5_set_port_mtu(struct mlx5_core_dev *dev, int mtu);
+int mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, int *max_mtu);
+int mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, int *oper_mtu);
+
 int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
 void mlx5_debug_eq_remove(struct mlx5_core_dev *dev, struct mlx5_eq *eq);
 int mlx5_core_eq_query(struct mlx5_core_dev *dev, struct mlx5_eq *eq,