Skip to content

Commit 79ce39b

Browse files
author
Saeed Mahameed
committed
net/mlx5e: Improve ethtool rxnfc callback structure
Don't choose who implements the rxnfc "get/set" callbacks according to CONFIG_MLX5_EN_RXNFC, instead have the callbacks always available and delegate to a function of a different driver module when needed (en_fs_ethtool.c), have stubs in en/fs.h to fallback to when en_fs_ethtool.c is compiled out, to avoid complications and ifdefs in en_main.c. Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 4240196 commit 79ce39b

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en/fs.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,17 @@ struct mlx5e_ethtool_steering {
132132

133133
void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv);
134134
void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv);
135-
int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd);
136-
int mlx5e_get_rxnfc(struct net_device *dev,
137-
struct ethtool_rxnfc *info, u32 *rule_locs);
135+
int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd);
136+
int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
137+
struct ethtool_rxnfc *info, u32 *rule_locs);
138138
#else
139139
static inline void mlx5e_ethtool_init_steering(struct mlx5e_priv *priv) { }
140140
static inline void mlx5e_ethtool_cleanup_steering(struct mlx5e_priv *priv) { }
141+
static inline int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
142+
{ return -EOPNOTSUPP; }
143+
static inline int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
144+
struct ethtool_rxnfc *info, u32 *rule_locs)
145+
{ return -EOPNOTSUPP; }
141146
#endif /* CONFIG_MLX5_EN_RXNFC */
142147

143148
#ifdef CONFIG_MLX5_EN_ARFS

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1888,21 +1888,27 @@ static u32 mlx5e_get_priv_flags(struct net_device *netdev)
18881888
return priv->channels.params.pflags;
18891889
}
18901890

1891-
#ifndef CONFIG_MLX5_EN_RXNFC
1892-
/* When CONFIG_MLX5_EN_RXNFC=n we only support ETHTOOL_GRXRINGS
1893-
* otherwise this function will be defined from en_fs_ethtool.c
1894-
*/
18951891
static int mlx5e_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info, u32 *rule_locs)
18961892
{
18971893
struct mlx5e_priv *priv = netdev_priv(dev);
18981894

1899-
if (info->cmd != ETHTOOL_GRXRINGS)
1900-
return -EOPNOTSUPP;
1901-
/* ring_count is needed by ethtool -x */
1902-
info->data = priv->channels.params.num_channels;
1903-
return 0;
1895+
/* ETHTOOL_GRXRINGS is needed by ethtool -x which is not part
1896+
* of rxnfc. We keep this logic out of mlx5e_ethtool_get_rxnfc,
1897+
* to avoid breaking "ethtool -x" when mlx5e_ethtool_get_rxnfc
1898+
* is compiled out via CONFIG_MLX5_EN_RXNFC=n.
1899+
*/
1900+
if (info->cmd == ETHTOOL_GRXRINGS) {
1901+
info->data = priv->channels.params.num_channels;
1902+
return 0;
1903+
}
1904+
1905+
return mlx5e_ethtool_get_rxnfc(dev, info, rule_locs);
1906+
}
1907+
1908+
static int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
1909+
{
1910+
return mlx5e_ethtool_set_rxnfc(dev, cmd);
19041911
}
1905-
#endif
19061912

19071913
const struct ethtool_ops mlx5e_ethtool_ops = {
19081914
.get_drvinfo = mlx5e_get_drvinfo,
@@ -1923,9 +1929,7 @@ const struct ethtool_ops mlx5e_ethtool_ops = {
19231929
.get_rxfh = mlx5e_get_rxfh,
19241930
.set_rxfh = mlx5e_set_rxfh,
19251931
.get_rxnfc = mlx5e_get_rxnfc,
1926-
#ifdef CONFIG_MLX5_EN_RXNFC
19271932
.set_rxnfc = mlx5e_set_rxnfc,
1928-
#endif
19291933
.get_tunable = mlx5e_get_tunable,
19301934
.set_tunable = mlx5e_set_tunable,
19311935
.get_pauseparam = mlx5e_get_pauseparam,

drivers/net/ethernet/mellanox/mlx5/core/en_fs_ethtool.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -887,10 +887,10 @@ static int mlx5e_get_rss_hash_opt(struct mlx5e_priv *priv,
887887
return 0;
888888
}
889889

890-
int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
890+
int mlx5e_ethtool_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
891891
{
892-
int err = 0;
893892
struct mlx5e_priv *priv = netdev_priv(dev);
893+
int err = 0;
894894

895895
switch (cmd->cmd) {
896896
case ETHTOOL_SRXCLSRLINS:
@@ -910,16 +910,13 @@ int mlx5e_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
910910
return err;
911911
}
912912

913-
int mlx5e_get_rxnfc(struct net_device *dev,
914-
struct ethtool_rxnfc *info, u32 *rule_locs)
913+
int mlx5e_ethtool_get_rxnfc(struct net_device *dev,
914+
struct ethtool_rxnfc *info, u32 *rule_locs)
915915
{
916916
struct mlx5e_priv *priv = netdev_priv(dev);
917917
int err = 0;
918918

919919
switch (info->cmd) {
920-
case ETHTOOL_GRXRINGS:
921-
info->data = priv->channels.params.num_channels;
922-
break;
923920
case ETHTOOL_GRXCLSRLCNT:
924921
info->rule_cnt = priv->fs.ethtool.tot_num_rules;
925922
break;

0 commit comments

Comments
 (0)