]> git.karo-electronics.de Git - linux-beck.git/commitdiff
net/mlx5e: Support ethtool get/set_pauseparam
authorAchiad Shochat <achiad@mellanox.com>
Sun, 16 Aug 2015 13:04:51 +0000 (16:04 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Aug 2015 22:51:36 +0000 (15:51 -0700)
Only rx/tx pause settings.
Autoneg setting is currently not supported.

Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
drivers/net/ethernet/mellanox/mlx5/core/port.c
include/linux/mlx5/driver.h

index 77158b31eb0b04ece6c39ef7a1c1782b38366193..bce912688ca821e5b17f6781c16a0cec713913ef 100644 (file)
@@ -820,6 +820,42 @@ static int mlx5e_set_tunable(struct net_device *dev,
        return err;
 }
 
+static void mlx5e_get_pauseparam(struct net_device *netdev,
+                                struct ethtool_pauseparam *pauseparam)
+{
+       struct mlx5e_priv *priv    = netdev_priv(netdev);
+       struct mlx5_core_dev *mdev = priv->mdev;
+       int err;
+
+       err = mlx5_query_port_pause(mdev, &pauseparam->rx_pause,
+                                   &pauseparam->tx_pause);
+       if (err) {
+               netdev_err(netdev, "%s: mlx5_query_port_pause failed:0x%x\n",
+                          __func__, err);
+       }
+}
+
+static int mlx5e_set_pauseparam(struct net_device *netdev,
+                               struct ethtool_pauseparam *pauseparam)
+{
+       struct mlx5e_priv *priv    = netdev_priv(netdev);
+       struct mlx5_core_dev *mdev = priv->mdev;
+       int err;
+
+       if (pauseparam->autoneg)
+               return -EINVAL;
+
+       err = mlx5_set_port_pause(mdev,
+                                 pauseparam->rx_pause ? 1 : 0,
+                                 pauseparam->tx_pause ? 1 : 0);
+       if (err) {
+               netdev_err(netdev, "%s: mlx5_set_port_pause failed:0x%x\n",
+                          __func__, err);
+       }
+
+       return err;
+}
+
 const struct ethtool_ops mlx5e_ethtool_ops = {
        .get_drvinfo       = mlx5e_get_drvinfo,
        .get_link          = ethtool_op_get_link,
@@ -841,4 +877,6 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
        .get_rxnfc         = mlx5e_get_rxnfc,
        .get_tunable       = mlx5e_get_tunable,
        .set_tunable       = mlx5e_set_tunable,
+       .get_pauseparam    = mlx5e_get_pauseparam,
+       .set_pauseparam    = mlx5e_set_pauseparam,
 };
index f8db52bd8f1852430076b20324e4f2fb7098c152..821caaab9bfb04697fb0424cb8498bdc9eacabed 100644 (file)
@@ -334,3 +334,45 @@ int mlx5_query_port_vl_hw_cap(struct mlx5_core_dev *dev,
        return 0;
 }
 EXPORT_SYMBOL_GPL(mlx5_query_port_vl_hw_cap);
+
+int mlx5_set_port_pause(struct mlx5_core_dev *dev, u32 rx_pause, u32 tx_pause)
+{
+       u32 in[MLX5_ST_SZ_DW(pfcc_reg)];
+       u32 out[MLX5_ST_SZ_DW(pfcc_reg)];
+       int err;
+
+       memset(in, 0, sizeof(in));
+       MLX5_SET(pfcc_reg, in, local_port, 1);
+       MLX5_SET(pfcc_reg, in, pptx, tx_pause);
+       MLX5_SET(pfcc_reg, in, pprx, rx_pause);
+
+       err = mlx5_core_access_reg(dev, in, sizeof(in), out,
+                                  sizeof(out), MLX5_REG_PFCC, 0, 1);
+       return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_set_port_pause);
+
+int mlx5_query_port_pause(struct mlx5_core_dev *dev,
+                         u32 *rx_pause, u32 *tx_pause)
+{
+       u32 in[MLX5_ST_SZ_DW(pfcc_reg)];
+       u32 out[MLX5_ST_SZ_DW(pfcc_reg)];
+       int err;
+
+       memset(in, 0, sizeof(in));
+       MLX5_SET(pfcc_reg, in, local_port, 1);
+
+       err = mlx5_core_access_reg(dev, in, sizeof(in), out,
+                                  sizeof(out), MLX5_REG_PFCC, 0, 0);
+       if (err)
+               return err;
+
+       if (rx_pause)
+               *rx_pause = MLX5_GET(pfcc_reg, out, pprx);
+
+       if (tx_pause)
+               *tx_pause = MLX5_GET(pfcc_reg, out, pptx);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(mlx5_query_port_pause);
index 4b5d7fc88d0f76a68bc1755bcbd574aaaf5aa207..8b6d6f2154a4eaab1cce3db487b92d8d1b36d4a9 100644 (file)
@@ -103,6 +103,7 @@ enum {
        MLX5_REG_PMTU            = 0x5003,
        MLX5_REG_PTYS            = 0x5004,
        MLX5_REG_PAOS            = 0x5006,
+       MLX5_REG_PFCC            = 0x5007,
        MLX5_REG_PPCNT           = 0x5008,
        MLX5_REG_PMAOS           = 0x5012,
        MLX5_REG_PUDE            = 0x5009,
@@ -774,6 +775,10 @@ void mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, int *oper_mtu,
 int mlx5_query_port_vl_hw_cap(struct mlx5_core_dev *dev,
                              u8 *vl_hw_cap, u8 local_port);
 
+int mlx5_set_port_pause(struct mlx5_core_dev *dev, u32 rx_pause, u32 tx_pause);
+int mlx5_query_port_pause(struct mlx5_core_dev *dev,
+                         u32 *rx_pause, u32 *tx_pause);
+
 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,