Commit 9b81d5a9 authored by Vu Pham's avatar Vu Pham Committed by Saeed Mahameed

net/mlx5e: Generalize vport type in vport representor

Beside the special vports (PF/uplink/ecpf), the rest of the vports
are similar.
Remove vf_ prefix from function and variable names.

This patch does not change any functionality.
Signed-off-by: default avatarVu Pham <vuhuong@mellanox.com>
Reviewed-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarBodong Wang <bodong@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 7fe4d43e
...@@ -128,7 +128,7 @@ static void mlx5e_rep_get_strings(struct net_device *dev, ...@@ -128,7 +128,7 @@ static void mlx5e_rep_get_strings(struct net_device *dev,
} }
} }
static void mlx5e_vf_rep_update_hw_counters(struct mlx5e_priv *priv) static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv)
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
...@@ -166,17 +166,6 @@ static void mlx5e_uplink_rep_update_hw_counters(struct mlx5e_priv *priv) ...@@ -166,17 +166,6 @@ static void mlx5e_uplink_rep_update_hw_counters(struct mlx5e_priv *priv)
vport_stats->tx_bytes = PPORT_802_3_GET(pstats, a_octets_transmitted_ok); vport_stats->tx_bytes = PPORT_802_3_GET(pstats, a_octets_transmitted_ok);
} }
static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
if (rep->vport == MLX5_VPORT_UPLINK)
mlx5e_uplink_rep_update_hw_counters(priv);
else
mlx5e_vf_rep_update_hw_counters(priv);
}
static void mlx5e_rep_update_sw_counters(struct mlx5e_priv *priv) static void mlx5e_rep_update_sw_counters(struct mlx5e_priv *priv)
{ {
struct mlx5e_sw_stats *s = &priv->stats.sw; struct mlx5e_sw_stats *s = &priv->stats.sw;
...@@ -203,7 +192,7 @@ static void mlx5e_rep_get_ethtool_stats(struct net_device *dev, ...@@ -203,7 +192,7 @@ static void mlx5e_rep_get_ethtool_stats(struct net_device *dev,
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
mlx5e_rep_update_sw_counters(priv); mlx5e_rep_update_sw_counters(priv);
mlx5e_rep_update_hw_counters(priv); priv->profile->update_stats(priv);
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++) for (i = 0; i < NUM_VPORT_REP_SW_COUNTERS; i++)
...@@ -363,7 +352,7 @@ static int mlx5e_uplink_rep_set_link_ksettings(struct net_device *netdev, ...@@ -363,7 +352,7 @@ static int mlx5e_uplink_rep_set_link_ksettings(struct net_device *netdev,
return mlx5e_ethtool_set_link_ksettings(priv, link_ksettings); return mlx5e_ethtool_set_link_ksettings(priv, link_ksettings);
} }
static const struct ethtool_ops mlx5e_vf_rep_ethtool_ops = { static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
.get_drvinfo = mlx5e_rep_get_drvinfo, .get_drvinfo = mlx5e_rep_get_drvinfo,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_strings = mlx5e_rep_get_strings, .get_strings = mlx5e_rep_get_strings,
...@@ -1101,7 +1090,7 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv, ...@@ -1101,7 +1090,7 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
mlx5_tun_entropy_refcount_dec(tun_entropy, e->reformat_type); mlx5_tun_entropy_refcount_dec(tun_entropy, e->reformat_type);
} }
static int mlx5e_vf_rep_open(struct net_device *dev) static int mlx5e_rep_open(struct net_device *dev)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
...@@ -1124,7 +1113,7 @@ static int mlx5e_vf_rep_open(struct net_device *dev) ...@@ -1124,7 +1113,7 @@ static int mlx5e_vf_rep_open(struct net_device *dev)
return err; return err;
} }
static int mlx5e_vf_rep_close(struct net_device *dev) static int mlx5e_rep_close(struct net_device *dev)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
...@@ -1276,7 +1265,7 @@ static int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev ...@@ -1276,7 +1265,7 @@ static int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev
} }
static void static void
mlx5e_vf_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
...@@ -1285,7 +1274,7 @@ mlx5e_vf_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ...@@ -1285,7 +1274,7 @@ mlx5e_vf_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats)
memcpy(stats, &priv->stats.vf_vport, sizeof(*stats)); memcpy(stats, &priv->stats.vf_vport, sizeof(*stats));
} }
static int mlx5e_vf_rep_change_mtu(struct net_device *netdev, int new_mtu) static int mlx5e_rep_change_mtu(struct net_device *netdev, int new_mtu)
{ {
return mlx5e_change_mtu(netdev, new_mtu, NULL); return mlx5e_change_mtu(netdev, new_mtu, NULL);
} }
...@@ -1318,16 +1307,16 @@ static int mlx5e_uplink_rep_set_vf_vlan(struct net_device *dev, int vf, u16 vlan ...@@ -1318,16 +1307,16 @@ static int mlx5e_uplink_rep_set_vf_vlan(struct net_device *dev, int vf, u16 vlan
return 0; return 0;
} }
static const struct net_device_ops mlx5e_netdev_ops_vf_rep = { static const struct net_device_ops mlx5e_netdev_ops_rep = {
.ndo_open = mlx5e_vf_rep_open, .ndo_open = mlx5e_rep_open,
.ndo_stop = mlx5e_vf_rep_close, .ndo_stop = mlx5e_rep_close,
.ndo_start_xmit = mlx5e_xmit, .ndo_start_xmit = mlx5e_xmit,
.ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name, .ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name,
.ndo_setup_tc = mlx5e_rep_setup_tc, .ndo_setup_tc = mlx5e_rep_setup_tc,
.ndo_get_stats64 = mlx5e_vf_rep_get_stats, .ndo_get_stats64 = mlx5e_rep_get_stats,
.ndo_has_offload_stats = mlx5e_rep_has_offload_stats, .ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
.ndo_get_offload_stats = mlx5e_rep_get_offload_stats, .ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
.ndo_change_mtu = mlx5e_vf_rep_change_mtu, .ndo_change_mtu = mlx5e_rep_change_mtu,
.ndo_get_port_parent_id = mlx5e_rep_get_port_parent_id, .ndo_get_port_parent_id = mlx5e_rep_get_port_parent_id,
}; };
...@@ -1355,7 +1344,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = { ...@@ -1355,7 +1344,7 @@ static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
bool mlx5e_eswitch_rep(struct net_device *netdev) bool mlx5e_eswitch_rep(struct net_device *netdev)
{ {
if (netdev->netdev_ops == &mlx5e_netdev_ops_vf_rep || if (netdev->netdev_ops == &mlx5e_netdev_ops_rep ||
netdev->netdev_ops == &mlx5e_netdev_ops_uplink_rep) netdev->netdev_ops == &mlx5e_netdev_ops_uplink_rep)
return true; return true;
...@@ -1418,9 +1407,9 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) ...@@ -1418,9 +1407,9 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev)
netdev->dcbnl_ops = &mlx5e_dcbnl_ops; netdev->dcbnl_ops = &mlx5e_dcbnl_ops;
#endif #endif
} else { } else {
netdev->netdev_ops = &mlx5e_netdev_ops_vf_rep; netdev->netdev_ops = &mlx5e_netdev_ops_rep;
eth_hw_addr_random(netdev); eth_hw_addr_random(netdev);
netdev->ethtool_ops = &mlx5e_vf_rep_ethtool_ops; netdev->ethtool_ops = &mlx5e_rep_ethtool_ops;
} }
netdev->watchdog_timeo = 15 * HZ; netdev->watchdog_timeo = 15 * HZ;
...@@ -1640,7 +1629,7 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv) ...@@ -1640,7 +1629,7 @@ static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
} }
} }
static void mlx5e_vf_rep_enable(struct mlx5e_priv *priv) static void mlx5e_rep_enable(struct mlx5e_priv *priv)
{ {
mlx5e_set_netdev_mtu_boundaries(priv); mlx5e_set_netdev_mtu_boundaries(priv);
} }
...@@ -1712,15 +1701,15 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv) ...@@ -1712,15 +1701,15 @@ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
mlx5_lag_remove(mdev); mlx5_lag_remove(mdev);
} }
static const struct mlx5e_profile mlx5e_vf_rep_profile = { static const struct mlx5e_profile mlx5e_rep_profile = {
.init = mlx5e_init_rep, .init = mlx5e_init_rep,
.cleanup = mlx5e_cleanup_rep, .cleanup = mlx5e_cleanup_rep,
.init_rx = mlx5e_init_rep_rx, .init_rx = mlx5e_init_rep_rx,
.cleanup_rx = mlx5e_cleanup_rep_rx, .cleanup_rx = mlx5e_cleanup_rep_rx,
.init_tx = mlx5e_init_rep_tx, .init_tx = mlx5e_init_rep_tx,
.cleanup_tx = mlx5e_cleanup_rep_tx, .cleanup_tx = mlx5e_cleanup_rep_tx,
.enable = mlx5e_vf_rep_enable, .enable = mlx5e_rep_enable,
.update_stats = mlx5e_vf_rep_update_hw_counters, .update_stats = mlx5e_rep_update_hw_counters,
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep, .rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq, .rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
.max_tc = 1, .max_tc = 1,
...@@ -1759,7 +1748,8 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) ...@@ -1759,7 +1748,8 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
rpriv->rep = rep; rpriv->rep = rep;
nch = mlx5e_get_max_num_channels(dev); nch = mlx5e_get_max_num_channels(dev);
profile = (rep->vport == MLX5_VPORT_UPLINK) ? &mlx5e_uplink_rep_profile : &mlx5e_vf_rep_profile; profile = (rep->vport == MLX5_VPORT_UPLINK) ?
&mlx5e_uplink_rep_profile : &mlx5e_rep_profile;
netdev = mlx5e_create_netdev(dev, profile, nch, rpriv); netdev = mlx5e_create_netdev(dev, profile, nch, rpriv);
if (!netdev) { if (!netdev) {
pr_warn("Failed to create representor netdev for vport %d\n", pr_warn("Failed to create representor netdev for vport %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment