net/mlx5e: Ethtool steering, move ethtool callbacks
[sfrench/cifs-2.6.git] / drivers / net / ethernet / mellanox / mlx5 / core / en_fs_ethtool.c
index 9e216f2dc16acda57795b9760c9a698075d7f735..75bb981e00b7205ad10b467dc64a821a4f8867a9 100644 (file)
@@ -675,8 +675,9 @@ static int validate_flow(struct mlx5e_priv *priv,
        return num_tuples;
 }
 
-int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
-                              struct ethtool_rx_flow_spec *fs)
+static int
+mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv,
+                          struct ethtool_rx_flow_spec *fs)
 {
        struct mlx5e_ethtool_table *eth_ft;
        struct mlx5e_ethtool_rule *eth_rule;
@@ -723,8 +724,8 @@ del_ethtool_rule:
        return err;
 }
 
-int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv,
-                             int location)
+static int
+mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv, int location)
 {
        struct mlx5e_ethtool_rule *eth_rule;
        int err = 0;
@@ -743,8 +744,9 @@ out:
        return err;
 }
 
-int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
-                          int location)
+static int
+mlx5e_ethtool_get_flow(struct mlx5e_priv *priv,
+                      struct ethtool_rxnfc *info, int location)
 {
        struct mlx5e_ethtool_rule *eth_rule;
 
@@ -761,8 +763,9 @@ int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
        return -ENOENT;
 }
 
-int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, struct ethtool_rxnfc *info,
-                               u32 *rule_locs)
+static int
+mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv,
+                           struct ethtool_rxnfc *info, u32 *rule_locs)
 {
        int location = 0;
        int idx = 0;
@@ -791,3 +794,51 @@ void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv)
 {
        INIT_LIST_HEAD(&priv->fs.ethtool.rules);
 }
+
+int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
+{
+       int err = 0;
+       struct mlx5e_priv *priv = netdev_priv(dev);
+
+       switch (cmd->cmd) {
+       case ETHTOOL_SRXCLSRLINS:
+               err = mlx5e_ethtool_flow_replace(priv, &cmd->fs);
+               break;
+       case ETHTOOL_SRXCLSRLDEL:
+               err = mlx5e_ethtool_flow_remove(priv, cmd->fs.location);
+               break;
+       default:
+               err = -EOPNOTSUPP;
+               break;
+       }
+
+       return err;
+}
+
+int mlx5e_get_rxnfc(struct net_device *dev,
+                   struct ethtool_rxnfc *info, u32 *rule_locs)
+{
+       struct mlx5e_priv *priv = netdev_priv(dev);
+       int err = 0;
+
+       switch (info->cmd) {
+       case ETHTOOL_GRXRINGS:
+               info->data = priv->channels.params.num_channels;
+               break;
+       case ETHTOOL_GRXCLSRLCNT:
+               info->rule_cnt = priv->fs.ethtool.tot_num_rules;
+               break;
+       case ETHTOOL_GRXCLSRULE:
+               err = mlx5e_ethtool_get_flow(priv, info, info->fs.location);
+               break;
+       case ETHTOOL_GRXCLSRLALL:
+               err = mlx5e_ethtool_get_all_flows(priv, info, rule_locs);
+               break;
+       default:
+               err = -EOPNOTSUPP;
+               break;
+       }
+
+       return err;
+}
+