diff options
| author | Maor Gottlieb <maorg@mellanox.com> | 2016-07-04 10:23:10 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-07-05 03:06:03 -0400 |
| commit | f913a72aa008777d4a92f82acafb17cce9aed4dc (patch) | |
| tree | 904d0860110f0793788fd00a2be9dc3080590710 | |
| parent | 1174fce8d1410d13b665cb7693250cc789637b9a (diff) | |
net/mlx5e: Add support to get ethtool flow rules
Enhance the existing get_rxnfc callback:
1. Get flow rule of specific ID.
2. Get all flow rules.
3. Get number of rules.
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 9 | ||||
| -rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c | 34 |
3 files changed, 47 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h index 9842594f5980..1365cdc81838 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h | |||
| @@ -717,6 +717,10 @@ int mlx5e_create_flow_steering(struct mlx5e_priv *priv); | |||
| 717 | void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv); | 717 | void mlx5e_destroy_flow_steering(struct mlx5e_priv *priv); |
| 718 | void mlx5e_init_l2_addr(struct mlx5e_priv *priv); | 718 | void mlx5e_init_l2_addr(struct mlx5e_priv *priv); |
| 719 | void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft); | 719 | void mlx5e_destroy_flow_table(struct mlx5e_flow_table *ft); |
| 720 | int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info, | ||
| 721 | int location); | ||
| 722 | int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, | ||
| 723 | struct ethtool_rxnfc *info, u32 *rule_locs); | ||
| 720 | int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv, | 724 | int mlx5e_ethtool_flow_replace(struct mlx5e_priv *priv, |
| 721 | struct ethtool_rx_flow_spec *fs); | 725 | struct ethtool_rx_flow_spec *fs); |
| 722 | int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv, | 726 | int mlx5e_ethtool_flow_remove(struct mlx5e_priv *priv, |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index edbb665f4d22..d652aa917130 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | |||
| @@ -931,6 +931,15 @@ static int mlx5e_get_rxnfc(struct net_device *netdev, | |||
| 931 | case ETHTOOL_GRXRINGS: | 931 | case ETHTOOL_GRXRINGS: |
| 932 | info->data = priv->params.num_channels; | 932 | info->data = priv->params.num_channels; |
| 933 | break; | 933 | break; |
| 934 | case ETHTOOL_GRXCLSRLCNT: | ||
| 935 | info->rule_cnt = priv->fs.ethtool.tot_num_rules; | ||
| 936 | break; | ||
| 937 | case ETHTOOL_GRXCLSRULE: | ||
| 938 | err = mlx5e_ethtool_get_flow(priv, info, info->fs.location); | ||
| 939 | break; | ||
| 940 | case ETHTOOL_GRXCLSRLALL: | ||
| 941 | err = mlx5e_ethtool_get_all_flows(priv, info, rule_locs); | ||
| 942 | break; | ||
| 934 | default: | 943 | default: |
| 935 | err = -EOPNOTSUPP; | 944 | err = -EOPNOTSUPP; |
| 936 | break; | 945 | break; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c index 830106ede872..d17c24227900 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c | |||
| @@ -537,6 +537,40 @@ out: | |||
| 537 | return err; | 537 | return err; |
| 538 | } | 538 | } |
| 539 | 539 | ||
| 540 | int mlx5e_ethtool_get_flow(struct mlx5e_priv *priv, struct ethtool_rxnfc *info, | ||
| 541 | int location) | ||
| 542 | { | ||
| 543 | struct mlx5e_ethtool_rule *eth_rule; | ||
| 544 | |||
| 545 | if (location < 0 || location >= MAX_NUM_OF_ETHTOOL_RULES) | ||
| 546 | return -EINVAL; | ||
| 547 | |||
| 548 | list_for_each_entry(eth_rule, &priv->fs.ethtool.rules, list) { | ||
| 549 | if (eth_rule->flow_spec.location == location) { | ||
| 550 | info->fs = eth_rule->flow_spec; | ||
| 551 | return 0; | ||
| 552 | } | ||
| 553 | } | ||
| 554 | |||
| 555 | return -ENOENT; | ||
| 556 | } | ||
| 557 | |||
| 558 | int mlx5e_ethtool_get_all_flows(struct mlx5e_priv *priv, struct ethtool_rxnfc *info, | ||
| 559 | u32 *rule_locs) | ||
| 560 | { | ||
| 561 | int location = 0; | ||
| 562 | int idx = 0; | ||
| 563 | int err = 0; | ||
| 564 | |||
| 565 | while ((!err || err == -ENOENT) && idx < info->rule_cnt) { | ||
| 566 | err = mlx5e_ethtool_get_flow(priv, info, location); | ||
| 567 | if (!err) | ||
| 568 | rule_locs[idx++] = location; | ||
| 569 | location++; | ||
| 570 | } | ||
| 571 | return err; | ||
| 572 | } | ||
| 573 | |||
| 540 | void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) | 574 | void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) |
| 541 | { | 575 | { |
| 542 | struct mlx5e_ethtool_rule *iter; | 576 | struct mlx5e_ethtool_rule *iter; |
