Commit 6c86bc23 authored by David S. Miller's avatar David S. Miller

Merge tag 'mlx5-uplink-rep-2018-12-15' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed:

====================
mlx5-uplink-rep-2018-12-15

Or Gerlitz says:

This series is essentially a cleanup to align with the rest of the NIC
switchdev drivers and make us
more robust and clear/n: currently the PF netdev serves as the mlx5
e-switch uplink netdev
representor when going into switchdev mode and back as plain NIC
netdev when going out.
This causes some irregularities and misc troubles.

Move to use dedicated uplink rep, as we have for the VF vports.

The uplink rep netdev does has sysfs link and supports the sriov vf
mac ndo, these two are in
use by libvirt and other orchestrators, It also has richer ethtool
support to allow controlling the
port link & mtu along with supporting dcb and plugging into the mlx5
lag logic.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a26d94bf ff9b85de
...@@ -775,6 +775,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe, ...@@ -775,6 +775,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
struct mlx5e_wqe_frag_info *wi, u32 cqe_bcnt); struct mlx5e_wqe_frag_info *wi, u32 cqe_bcnt);
void mlx5e_update_stats(struct mlx5e_priv *priv); void mlx5e_update_stats(struct mlx5e_priv *priv);
void mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats);
void mlx5e_init_l2_addr(struct mlx5e_priv *priv); void mlx5e_init_l2_addr(struct mlx5e_priv *priv);
int mlx5e_self_test_num(struct mlx5e_priv *priv); int mlx5e_self_test_num(struct mlx5e_priv *priv);
...@@ -939,7 +940,7 @@ int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc, ...@@ -939,7 +940,7 @@ int mlx5e_create_tis(struct mlx5_core_dev *mdev, int tc,
void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn); void mlx5e_destroy_tis(struct mlx5_core_dev *mdev, u32 tisn);
int mlx5e_create_tises(struct mlx5e_priv *priv); int mlx5e_create_tises(struct mlx5e_priv *priv);
void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv); void mlx5e_update_carrier(struct mlx5e_priv *priv);
int mlx5e_close(struct net_device *netdev); int mlx5e_close(struct net_device *netdev);
int mlx5e_open(struct net_device *netdev); int mlx5e_open(struct net_device *netdev);
void mlx5e_update_ndo_stats(struct mlx5e_priv *priv); void mlx5e_update_ndo_stats(struct mlx5e_priv *priv);
...@@ -948,6 +949,7 @@ void mlx5e_queue_update_stats(struct mlx5e_priv *priv); ...@@ -948,6 +949,7 @@ void mlx5e_queue_update_stats(struct mlx5e_priv *priv);
int mlx5e_bits_invert(unsigned long a, int size); int mlx5e_bits_invert(unsigned long a, int size);
typedef int (*change_hw_mtu_cb)(struct mlx5e_priv *priv); typedef int (*change_hw_mtu_cb)(struct mlx5e_priv *priv);
int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv);
int mlx5e_change_mtu(struct net_device *netdev, int new_mtu, int mlx5e_change_mtu(struct net_device *netdev, int new_mtu,
change_hw_mtu_cb set_mtu_cb); change_hw_mtu_cb set_mtu_cb);
...@@ -971,12 +973,20 @@ int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv, ...@@ -971,12 +973,20 @@ int mlx5e_ethtool_get_coalesce(struct mlx5e_priv *priv,
struct ethtool_coalesce *coal); struct ethtool_coalesce *coal);
int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv, int mlx5e_ethtool_set_coalesce(struct mlx5e_priv *priv,
struct ethtool_coalesce *coal); struct ethtool_coalesce *coal);
int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,
struct ethtool_link_ksettings *link_ksettings);
int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
const struct ethtool_link_ksettings *link_ksettings);
u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv); u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv);
u32 mlx5e_ethtool_get_rxfh_indir_size(struct mlx5e_priv *priv); u32 mlx5e_ethtool_get_rxfh_indir_size(struct mlx5e_priv *priv);
int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv, int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
struct ethtool_ts_info *info); struct ethtool_ts_info *info);
int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv, int mlx5e_ethtool_flash_device(struct mlx5e_priv *priv,
struct ethtool_flash *flash); struct ethtool_flash *flash);
void mlx5e_ethtool_get_pauseparam(struct mlx5e_priv *priv,
struct ethtool_pauseparam *pauseparam);
int mlx5e_ethtool_set_pauseparam(struct mlx5e_priv *priv,
struct ethtool_pauseparam *pauseparam);
/* mlx5e generic netdev management API */ /* mlx5e generic netdev management API */
int mlx5e_netdev_init(struct net_device *netdev, int mlx5e_netdev_init(struct net_device *netdev,
...@@ -1002,4 +1012,16 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params, ...@@ -1002,4 +1012,16 @@ void mlx5e_build_rss_params(struct mlx5e_rss_params *rss_params,
u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev); u8 mlx5e_params_calculate_tx_min_inline(struct mlx5_core_dev *mdev);
void mlx5e_rx_dim_work(struct work_struct *work); void mlx5e_rx_dim_work(struct work_struct *work);
void mlx5e_tx_dim_work(struct work_struct *work); void mlx5e_tx_dim_work(struct work_struct *work);
void mlx5e_add_vxlan_port(struct net_device *netdev, struct udp_tunnel_info *ti);
void mlx5e_del_vxlan_port(struct net_device *netdev, struct udp_tunnel_info *ti);
netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct net_device *netdev,
netdev_features_t features);
#ifdef CONFIG_MLX5_ESWITCH
int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac);
int mlx5e_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate, int max_tx_rate);
int mlx5e_get_vf_config(struct net_device *dev, int vf, struct ifla_vf_info *ivi);
int mlx5e_get_vf_stats(struct net_device *dev, int vf, struct ifla_vf_stats *vf_stats);
#endif
#endif /* __MLX5_EN_H__ */ #endif /* __MLX5_EN_H__ */
...@@ -787,10 +787,9 @@ static void get_lp_advertising(u32 eth_proto_lp, ...@@ -787,10 +787,9 @@ static void get_lp_advertising(u32 eth_proto_lp,
ptys2ethtool_adver_link(lp_advertising, eth_proto_lp); ptys2ethtool_adver_link(lp_advertising, eth_proto_lp);
} }
static int mlx5e_get_link_ksettings(struct net_device *netdev, int mlx5e_ethtool_get_link_ksettings(struct mlx5e_priv *priv,
struct ethtool_link_ksettings *link_ksettings) struct ethtool_link_ksettings *link_ksettings)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0}; u32 out[MLX5_ST_SZ_DW(ptys_reg)] = {0};
u32 rx_pause = 0; u32 rx_pause = 0;
...@@ -806,7 +805,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, ...@@ -806,7 +805,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
err = mlx5_query_port_ptys(mdev, out, sizeof(out), MLX5_PTYS_EN, 1); err = mlx5_query_port_ptys(mdev, out, sizeof(out), MLX5_PTYS_EN, 1);
if (err) { if (err) {
netdev_err(netdev, "%s: query port ptys failed: %d\n", netdev_err(priv->netdev, "%s: query port ptys failed: %d\n",
__func__, err); __func__, err);
goto err_query_regs; goto err_query_regs;
} }
...@@ -826,7 +825,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, ...@@ -826,7 +825,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
get_supported(eth_proto_cap, link_ksettings); get_supported(eth_proto_cap, link_ksettings);
get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings); get_advertising(eth_proto_admin, tx_pause, rx_pause, link_ksettings);
get_speed_duplex(netdev, eth_proto_oper, link_ksettings); get_speed_duplex(priv->netdev, eth_proto_oper, link_ksettings);
eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap; eth_proto_oper = eth_proto_oper ? eth_proto_oper : eth_proto_cap;
...@@ -846,7 +845,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, ...@@ -846,7 +845,7 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
Autoneg); Autoneg);
if (get_fec_supported_advertised(mdev, link_ksettings)) if (get_fec_supported_advertised(mdev, link_ksettings))
netdev_dbg(netdev, "%s: FEC caps query failed: %d\n", netdev_dbg(priv->netdev, "%s: FEC caps query failed: %d\n",
__func__, err); __func__, err);
if (!an_disable_admin) if (!an_disable_admin)
...@@ -857,6 +856,14 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev, ...@@ -857,6 +856,14 @@ static int mlx5e_get_link_ksettings(struct net_device *netdev,
return err; return err;
} }
static int mlx5e_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *link_ksettings)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_get_link_ksettings(priv, link_ksettings);
}
static u32 mlx5e_ethtool2ptys_adver_link(const unsigned long *link_modes) static u32 mlx5e_ethtool2ptys_adver_link(const unsigned long *link_modes)
{ {
u32 i, ptys_modes = 0; u32 i, ptys_modes = 0;
...@@ -871,10 +878,9 @@ static u32 mlx5e_ethtool2ptys_adver_link(const unsigned long *link_modes) ...@@ -871,10 +878,9 @@ static u32 mlx5e_ethtool2ptys_adver_link(const unsigned long *link_modes)
return ptys_modes; return ptys_modes;
} }
static int mlx5e_set_link_ksettings(struct net_device *netdev, int mlx5e_ethtool_set_link_ksettings(struct mlx5e_priv *priv,
const struct ethtool_link_ksettings *link_ksettings) const struct ethtool_link_ksettings *link_ksettings)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u32 eth_proto_cap, eth_proto_admin; u32 eth_proto_cap, eth_proto_admin;
bool an_changes = false; bool an_changes = false;
...@@ -894,14 +900,14 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev, ...@@ -894,14 +900,14 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev,
err = mlx5_query_port_proto_cap(mdev, &eth_proto_cap, MLX5_PTYS_EN); err = mlx5_query_port_proto_cap(mdev, &eth_proto_cap, MLX5_PTYS_EN);
if (err) { if (err) {
netdev_err(netdev, "%s: query port eth proto cap failed: %d\n", netdev_err(priv->netdev, "%s: query port eth proto cap failed: %d\n",
__func__, err); __func__, err);
goto out; goto out;
} }
link_modes = link_modes & eth_proto_cap; link_modes = link_modes & eth_proto_cap;
if (!link_modes) { if (!link_modes) {
netdev_err(netdev, "%s: Not supported link mode(s) requested", netdev_err(priv->netdev, "%s: Not supported link mode(s) requested",
__func__); __func__);
err = -EINVAL; err = -EINVAL;
goto out; goto out;
...@@ -909,7 +915,7 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev, ...@@ -909,7 +915,7 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev,
err = mlx5_query_port_proto_admin(mdev, &eth_proto_admin, MLX5_PTYS_EN); err = mlx5_query_port_proto_admin(mdev, &eth_proto_admin, MLX5_PTYS_EN);
if (err) { if (err) {
netdev_err(netdev, "%s: query port eth proto admin failed: %d\n", netdev_err(priv->netdev, "%s: query port eth proto admin failed: %d\n",
__func__, err); __func__, err);
goto out; goto out;
} }
...@@ -931,6 +937,14 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev, ...@@ -931,6 +937,14 @@ static int mlx5e_set_link_ksettings(struct net_device *netdev,
return err; return err;
} }
static int mlx5e_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *link_ksettings)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_set_link_ksettings(priv, link_ksettings);
}
u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv) u32 mlx5e_ethtool_get_rxfh_key_size(struct mlx5e_priv *priv)
{ {
return sizeof(priv->rss_params.toeplitz_hash_key); return sizeof(priv->rss_params.toeplitz_hash_key);
...@@ -1127,25 +1141,31 @@ static int mlx5e_set_tunable(struct net_device *dev, ...@@ -1127,25 +1141,31 @@ static int mlx5e_set_tunable(struct net_device *dev,
return err; return err;
} }
static void mlx5e_get_pauseparam(struct net_device *netdev, void mlx5e_ethtool_get_pauseparam(struct mlx5e_priv *priv,
struct ethtool_pauseparam *pauseparam) struct ethtool_pauseparam *pauseparam)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
int err; int err;
err = mlx5_query_port_pause(mdev, &pauseparam->rx_pause, err = mlx5_query_port_pause(mdev, &pauseparam->rx_pause,
&pauseparam->tx_pause); &pauseparam->tx_pause);
if (err) { if (err) {
netdev_err(netdev, "%s: mlx5_query_port_pause failed:0x%x\n", netdev_err(priv->netdev, "%s: mlx5_query_port_pause failed:0x%x\n",
__func__, err); __func__, err);
} }
} }
static int mlx5e_set_pauseparam(struct net_device *netdev, static void mlx5e_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pauseparam) struct ethtool_pauseparam *pauseparam)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
mlx5e_ethtool_get_pauseparam(priv, pauseparam);
}
int mlx5e_ethtool_set_pauseparam(struct mlx5e_priv *priv,
struct ethtool_pauseparam *pauseparam)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
int err; int err;
...@@ -1156,13 +1176,21 @@ static int mlx5e_set_pauseparam(struct net_device *netdev, ...@@ -1156,13 +1176,21 @@ static int mlx5e_set_pauseparam(struct net_device *netdev,
pauseparam->rx_pause ? 1 : 0, pauseparam->rx_pause ? 1 : 0,
pauseparam->tx_pause ? 1 : 0); pauseparam->tx_pause ? 1 : 0);
if (err) { if (err) {
netdev_err(netdev, "%s: mlx5_set_port_pause failed:0x%x\n", netdev_err(priv->netdev, "%s: mlx5_set_port_pause failed:0x%x\n",
__func__, err); __func__, err);
} }
return err; return err;
} }
static int mlx5e_set_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pauseparam)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_set_pauseparam(priv, pauseparam);
}
int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv, int mlx5e_ethtool_get_ts_info(struct mlx5e_priv *priv,
struct ethtool_ts_info *info) struct ethtool_ts_info *info)
{ {
......
...@@ -225,7 +225,7 @@ void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params) ...@@ -225,7 +225,7 @@ void mlx5e_set_rq_type(struct mlx5_core_dev *mdev, struct mlx5e_params *params)
MLX5_WQ_TYPE_CYCLIC; MLX5_WQ_TYPE_CYCLIC;
} }
static void mlx5e_update_carrier(struct mlx5e_priv *priv) void mlx5e_update_carrier(struct mlx5e_priv *priv)
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u8 port_state; u8 port_state;
...@@ -2821,7 +2821,7 @@ static void mlx5e_query_mtu(struct mlx5_core_dev *mdev, ...@@ -2821,7 +2821,7 @@ static void mlx5e_query_mtu(struct mlx5_core_dev *mdev,
*mtu = MLX5E_HW2SW_MTU(params, hw_mtu); *mtu = MLX5E_HW2SW_MTU(params, hw_mtu);
} }
static int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv) int mlx5e_set_dev_port_mtu(struct mlx5e_priv *priv)
{ {
struct mlx5e_params *params = &priv->channels.params; struct mlx5e_params *params = &priv->channels.params;
struct net_device *netdev = priv->netdev; struct net_device *netdev = priv->netdev;
...@@ -2901,7 +2901,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv) ...@@ -2901,7 +2901,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)
mlx5e_activate_channels(&priv->channels); mlx5e_activate_channels(&priv->channels);
netif_tx_start_all_queues(priv->netdev); netif_tx_start_all_queues(priv->netdev);
if (MLX5_ESWITCH_MANAGER(priv->mdev)) if (mlx5e_is_vport_rep(priv))
mlx5e_add_sqs_fwd_rules(priv); mlx5e_add_sqs_fwd_rules(priv);
mlx5e_wait_channels_min_rx_wqes(&priv->channels); mlx5e_wait_channels_min_rx_wqes(&priv->channels);
...@@ -2912,7 +2912,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv) ...@@ -2912,7 +2912,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)
{ {
mlx5e_redirect_rqts_to_drop(priv); mlx5e_redirect_rqts_to_drop(priv);
if (MLX5_ESWITCH_MANAGER(priv->mdev)) if (mlx5e_is_vport_rep(priv))
mlx5e_remove_sqs_fwd_rules(priv); mlx5e_remove_sqs_fwd_rules(priv);
/* FIXME: This is a W/A only for tx timeout watch dog false alarm when /* FIXME: This is a W/A only for tx timeout watch dog false alarm when
...@@ -3164,7 +3164,7 @@ int mlx5e_create_tises(struct mlx5e_priv *priv) ...@@ -3164,7 +3164,7 @@ int mlx5e_create_tises(struct mlx5e_priv *priv)
return err; return err;
} }
void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv) static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
{ {
int tc; int tc;
...@@ -3409,7 +3409,8 @@ static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data, ...@@ -3409,7 +3409,8 @@ static int mlx5e_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
return mlx5e_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS); return mlx5e_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS |
MLX5E_TC_NIC_OFFLOAD);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -3452,7 +3453,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -3452,7 +3453,7 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
} }
} }
static void void
mlx5e_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) mlx5e_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);
...@@ -3596,7 +3597,7 @@ static int set_feature_tc_num_filters(struct net_device *netdev, bool enable) ...@@ -3596,7 +3597,7 @@ static int set_feature_tc_num_filters(struct net_device *netdev, bool enable)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
if (!enable && mlx5e_tc_num_filters(priv)) { if (!enable && mlx5e_tc_num_filters(priv, MLX5E_TC_NIC_OFFLOAD)) {
netdev_err(netdev, netdev_err(netdev,
"Active offloaded tc filters, can't turn hw_tc_offload off\n"); "Active offloaded tc filters, can't turn hw_tc_offload off\n");
return -EINVAL; return -EINVAL;
...@@ -3898,7 +3899,7 @@ static int mlx5e_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -3898,7 +3899,7 @@ static int mlx5e_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
} }
#ifdef CONFIG_MLX5_ESWITCH #ifdef CONFIG_MLX5_ESWITCH
static int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac) int mlx5e_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
...@@ -3935,8 +3936,8 @@ static int mlx5e_set_vf_trust(struct net_device *dev, int vf, bool setting) ...@@ -3935,8 +3936,8 @@ static int mlx5e_set_vf_trust(struct net_device *dev, int vf, bool setting)
return mlx5_eswitch_set_vport_trust(mdev->priv.eswitch, vf + 1, setting); return mlx5_eswitch_set_vport_trust(mdev->priv.eswitch, vf + 1, setting);
} }
static int mlx5e_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate, int mlx5e_set_vf_rate(struct net_device *dev, int vf, int min_tx_rate,
int max_tx_rate) int max_tx_rate)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
...@@ -3977,8 +3978,8 @@ static int mlx5e_set_vf_link_state(struct net_device *dev, int vf, ...@@ -3977,8 +3978,8 @@ static int mlx5e_set_vf_link_state(struct net_device *dev, int vf,
mlx5_ifla_link2vport(link_state)); mlx5_ifla_link2vport(link_state));
} }
static int mlx5e_get_vf_config(struct net_device *dev, int mlx5e_get_vf_config(struct net_device *dev,
int vf, struct ifla_vf_info *ivi) int vf, struct ifla_vf_info *ivi)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
...@@ -3991,8 +3992,8 @@ static int mlx5e_get_vf_config(struct net_device *dev, ...@@ -3991,8 +3992,8 @@ static int mlx5e_get_vf_config(struct net_device *dev,
return 0; return 0;
} }
static int mlx5e_get_vf_stats(struct net_device *dev, int mlx5e_get_vf_stats(struct net_device *dev,
int vf, struct ifla_vf_stats *vf_stats) int vf, struct ifla_vf_stats *vf_stats)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
...@@ -4053,8 +4054,7 @@ static void mlx5e_vxlan_queue_work(struct mlx5e_priv *priv, u16 port, int add) ...@@ -4053,8 +4054,7 @@ static void mlx5e_vxlan_queue_work(struct mlx5e_priv *priv, u16 port, int add)
queue_work(priv->wq, &vxlan_work->work); queue_work(priv->wq, &vxlan_work->work);
} }
static void mlx5e_add_vxlan_port(struct net_device *netdev, void mlx5e_add_vxlan_port(struct net_device *netdev, struct udp_tunnel_info *ti)
struct udp_tunnel_info *ti)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -4067,8 +4067,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev, ...@@ -4067,8 +4067,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev,
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1); mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1);
} }
static void mlx5e_del_vxlan_port(struct net_device *netdev, void mlx5e_del_vxlan_port(struct net_device *netdev, struct udp_tunnel_info *ti)
struct udp_tunnel_info *ti)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -4118,9 +4117,9 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv, ...@@ -4118,9 +4117,9 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK);
} }
static netdev_features_t mlx5e_features_check(struct sk_buff *skb, netdev_features_t mlx5e_features_check(struct sk_buff *skb,
struct net_device *netdev, struct net_device *netdev,
netdev_features_t features) netdev_features_t features)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -4380,8 +4379,6 @@ const struct net_device_ops mlx5e_netdev_ops = { ...@@ -4380,8 +4379,6 @@ const struct net_device_ops mlx5e_netdev_ops = {
.ndo_get_vf_config = mlx5e_get_vf_config, .ndo_get_vf_config = mlx5e_get_vf_config,
.ndo_set_vf_link_state = mlx5e_set_vf_link_state, .ndo_set_vf_link_state = mlx5e_set_vf_link_state,
.ndo_get_vf_stats = mlx5e_get_vf_stats, .ndo_get_vf_stats = mlx5e_get_vf_stats,
.ndo_has_offload_stats = mlx5e_has_offload_stats,
.ndo_get_offload_stats = mlx5e_get_offload_stats,
#endif #endif
}; };
...@@ -4607,12 +4604,6 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev) ...@@ -4607,12 +4604,6 @@ static void mlx5e_set_netdev_dev_addr(struct net_device *netdev)
} }
} }
#if IS_ENABLED(CONFIG_MLX5_ESWITCH)
static const struct switchdev_ops mlx5e_switchdev_ops = {
.switchdev_port_attr_get = mlx5e_attr_get,
};
#endif
static void mlx5e_build_nic_netdev(struct net_device *netdev) static void mlx5e_build_nic_netdev(struct net_device *netdev)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -4722,12 +4713,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) ...@@ -4722,12 +4713,6 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->priv_flags |= IFF_UNICAST_FLT; netdev->priv_flags |= IFF_UNICAST_FLT;
mlx5e_set_netdev_dev_addr(netdev); mlx5e_set_netdev_dev_addr(netdev);
#if IS_ENABLED(CONFIG_MLX5_ESWITCH)
if (MLX5_ESWITCH_MANAGER(mdev))
netdev->switchdev_ops = &mlx5e_switchdev_ops;
#endif
mlx5e_ipsec_build_netdev(priv); mlx5e_ipsec_build_netdev(priv);
mlx5e_tls_build_netdev(priv); mlx5e_tls_build_netdev(priv);
} }
...@@ -4907,9 +4892,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv) ...@@ -4907,9 +4892,6 @@ static void mlx5e_nic_enable(struct mlx5e_priv *priv)
if (mlx5e_monitor_counter_supported(priv)) if (mlx5e_monitor_counter_supported(priv))
mlx5e_monitor_counter_init(priv); mlx5e_monitor_counter_init(priv);
if (MLX5_ESWITCH_MANAGER(priv->mdev))
mlx5e_register_vport_reps(priv);
if (netdev->reg_state != NETREG_REGISTERED) if (netdev->reg_state != NETREG_REGISTERED)
return; return;
#ifdef CONFIG_MLX5_CORE_EN_DCB #ifdef CONFIG_MLX5_CORE_EN_DCB
...@@ -4942,9 +4924,6 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv) ...@@ -4942,9 +4924,6 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
queue_work(priv->wq, &priv->set_rx_mode_work); queue_work(priv->wq, &priv->set_rx_mode_work);
if (MLX5_ESWITCH_MANAGER(priv->mdev))
mlx5e_unregister_vport_reps(priv);
if (mlx5e_monitor_counter_supported(priv)) if (mlx5e_monitor_counter_supported(priv))
mlx5e_monitor_counter_cleanup(priv); mlx5e_monitor_counter_cleanup(priv);
...@@ -5143,7 +5122,6 @@ static void mlx5e_detach(struct mlx5_core_dev *mdev, void *vpriv) ...@@ -5143,7 +5122,6 @@ static void mlx5e_detach(struct mlx5_core_dev *mdev, void *vpriv)
static void *mlx5e_add(struct mlx5_core_dev *mdev) static void *mlx5e_add(struct mlx5_core_dev *mdev)
{ {
struct net_device *netdev; struct net_device *netdev;
void *rpriv = NULL;
void *priv; void *priv;
int err; int err;
int nch; int nch;
...@@ -5153,20 +5131,18 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) ...@@ -5153,20 +5131,18 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
return NULL; return NULL;
#ifdef CONFIG_MLX5_ESWITCH #ifdef CONFIG_MLX5_ESWITCH
if (MLX5_ESWITCH_MANAGER(mdev)) { if (MLX5_ESWITCH_MANAGER(mdev) &&
rpriv = mlx5e_alloc_nic_rep_priv(mdev); mlx5_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {
if (!rpriv) { mlx5e_rep_register_vport_reps(mdev);
mlx5_core_warn(mdev, "Failed to alloc NIC rep priv data\n"); return mdev;
return NULL;
}
} }
#endif #endif
nch = mlx5e_get_max_num_channels(mdev); nch = mlx5e_get_max_num_channels(mdev);
netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, nch, rpriv); netdev = mlx5e_create_netdev(mdev, &mlx5e_nic_profile, nch, NULL);
if (!netdev) { if (!netdev) {
mlx5_core_err(mdev, "mlx5e_create_netdev failed\n"); mlx5_core_err(mdev, "mlx5e_create_netdev failed\n");
goto err_free_rpriv; return NULL;
} }
priv = netdev_priv(netdev); priv = netdev_priv(netdev);
...@@ -5192,23 +5168,26 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev) ...@@ -5192,23 +5168,26 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)
mlx5e_detach(mdev, priv); mlx5e_detach(mdev, priv);
err_destroy_netdev: err_destroy_netdev:
mlx5e_destroy_netdev(priv); mlx5e_destroy_netdev(priv);
err_free_rpriv:
kfree(rpriv);
return NULL; return NULL;
} }
static void mlx5e_remove(struct mlx5_core_dev *mdev, void *vpriv) static void mlx5e_remove(struct mlx5_core_dev *mdev, void *vpriv)
{ {
struct mlx5e_priv *priv = vpriv; struct mlx5e_priv *priv;
void *ppriv = priv->ppriv;
#ifdef CONFIG_MLX5_ESWITCH
if (MLX5_ESWITCH_MANAGER(mdev) && vpriv == mdev) {
mlx5e_rep_unregister_vport_reps(mdev);
return;
}
#endif
priv = vpriv;
#ifdef CONFIG_MLX5_CORE_EN_DCB #ifdef CONFIG_MLX5_CORE_EN_DCB
mlx5e_dcbnl_delete_app(priv); mlx5e_dcbnl_delete_app(priv);
#endif #endif
unregister_netdev(priv->netdev); unregister_netdev(priv->netdev);
mlx5e_detach(mdev, vpriv); mlx5e_detach(mdev, vpriv);
mlx5e_destroy_netdev(priv); mlx5e_destroy_netdev(priv);
kfree(ppriv);
} }
static struct mlx5_interface mlx5e_interface = { static struct mlx5_interface mlx5e_interface = {
......
...@@ -108,7 +108,7 @@ static void mlx5e_rep_get_strings(struct net_device *dev, ...@@ -108,7 +108,7 @@ static void mlx5e_rep_get_strings(struct net_device *dev,
} }
} }
static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv) static void mlx5e_vf_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;
...@@ -131,6 +131,32 @@ static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv) ...@@ -131,6 +131,32 @@ static void mlx5e_rep_update_hw_counters(struct mlx5e_priv *priv)
vport_stats->tx_bytes = vf_stats.rx_bytes; vport_stats->tx_bytes = vf_stats.rx_bytes;
} }
static void mlx5e_uplink_rep_update_hw_counters(struct mlx5e_priv *priv)
{
struct mlx5e_pport_stats *pstats = &priv->stats.pport;
struct rtnl_link_stats64 *vport_stats;
mlx5e_grp_802_3_update_stats(priv);
vport_stats = &priv->stats.vf_vport;
vport_stats->rx_packets = PPORT_802_3_GET(pstats, a_frames_received_ok);
vport_stats->rx_bytes = PPORT_802_3_GET(pstats, a_octets_received_ok);
vport_stats->tx_packets = PPORT_802_3_GET(pstats, a_frames_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 == FDB_UPLINK_VPORT)
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;
...@@ -266,6 +292,22 @@ static int mlx5e_rep_set_channels(struct net_device *dev, ...@@ -266,6 +292,22 @@ static int mlx5e_rep_set_channels(struct net_device *dev,
return 0; return 0;
} }
static int mlx5e_rep_get_coalesce(struct net_device *netdev,
struct ethtool_coalesce *coal)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_get_coalesce(priv, coal);
}
static int mlx5e_rep_set_coalesce(struct net_device *netdev,
struct ethtool_coalesce *coal)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_set_coalesce(priv, coal);
}
static u32 mlx5e_rep_get_rxfh_key_size(struct net_device *netdev) static u32 mlx5e_rep_get_rxfh_key_size(struct net_device *netdev)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
...@@ -280,7 +322,39 @@ static u32 mlx5e_rep_get_rxfh_indir_size(struct net_device *netdev) ...@@ -280,7 +322,39 @@ static u32 mlx5e_rep_get_rxfh_indir_size(struct net_device *netdev)
return mlx5e_ethtool_get_rxfh_indir_size(priv); return mlx5e_ethtool_get_rxfh_indir_size(priv);
} }
static const struct ethtool_ops mlx5e_rep_ethtool_ops = { static void mlx5e_uplink_rep_get_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pauseparam)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
mlx5e_ethtool_get_pauseparam(priv, pauseparam);
}
static int mlx5e_uplink_rep_set_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pauseparam)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_set_pauseparam(priv, pauseparam);
}
static int mlx5e_uplink_rep_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *link_ksettings)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_get_link_ksettings(priv, link_ksettings);
}
static int mlx5e_uplink_rep_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *link_ksettings)
{
struct mlx5e_priv *priv = netdev_priv(netdev);
return mlx5e_ethtool_set_link_ksettings(priv, link_ksettings);
}
static const struct ethtool_ops mlx5e_vf_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,
...@@ -290,11 +364,33 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = { ...@@ -290,11 +364,33 @@ static const struct ethtool_ops mlx5e_rep_ethtool_ops = {
.set_ringparam = mlx5e_rep_set_ringparam, .set_ringparam = mlx5e_rep_set_ringparam,
.get_channels = mlx5e_rep_get_channels, .get_channels = mlx5e_rep_get_channels,
.set_channels = mlx5e_rep_set_channels, .set_channels = mlx5e_rep_set_channels,
.get_coalesce = mlx5e_rep_get_coalesce,
.set_coalesce = mlx5e_rep_set_coalesce,
.get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size, .get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size,
.get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size, .get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size,
}; };
int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr) static const struct ethtool_ops mlx5e_uplink_rep_ethtool_ops = {
.get_drvinfo = mlx5e_rep_get_drvinfo,
.get_link = ethtool_op_get_link,
.get_strings = mlx5e_rep_get_strings,
.get_sset_count = mlx5e_rep_get_sset_count,
.get_ethtool_stats = mlx5e_rep_get_ethtool_stats,
.get_ringparam = mlx5e_rep_get_ringparam,
.set_ringparam = mlx5e_rep_set_ringparam,
.get_channels = mlx5e_rep_get_channels,
.set_channels = mlx5e_rep_set_channels,
.get_coalesce = mlx5e_rep_get_coalesce,
.set_coalesce = mlx5e_rep_set_coalesce,
.get_link_ksettings = mlx5e_uplink_rep_get_link_ksettings,
.set_link_ksettings = mlx5e_uplink_rep_set_link_ksettings,
.get_rxfh_key_size = mlx5e_rep_get_rxfh_key_size,
.get_rxfh_indir_size = mlx5e_rep_get_rxfh_indir_size,
.get_pauseparam = mlx5e_uplink_rep_get_pauseparam,
.set_pauseparam = mlx5e_uplink_rep_set_pauseparam,
};
static int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
{ {
struct mlx5e_priv *priv = netdev_priv(dev); struct mlx5e_priv *priv = netdev_priv(dev);
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
...@@ -576,21 +672,19 @@ mlx5e_rep_indr_offload(struct net_device *netdev, ...@@ -576,21 +672,19 @@ mlx5e_rep_indr_offload(struct net_device *netdev,
struct tc_cls_flower_offload *flower, struct tc_cls_flower_offload *flower,
struct mlx5e_rep_indr_block_priv *indr_priv) struct mlx5e_rep_indr_block_priv *indr_priv)
{ {
int err = 0;
struct mlx5e_priv *priv = netdev_priv(indr_priv->rpriv->netdev); struct mlx5e_priv *priv = netdev_priv(indr_priv->rpriv->netdev);
int flags = MLX5E_TC_EGRESS | MLX5E_TC_ESW_OFFLOAD;
int err = 0;
switch (flower->command) { switch (flower->command) {
case TC_CLSFLOWER_REPLACE: case TC_CLSFLOWER_REPLACE:
err = mlx5e_configure_flower(netdev, priv, err = mlx5e_configure_flower(netdev, priv, flower, flags);
flower, MLX5E_TC_EGRESS);
break; break;
case TC_CLSFLOWER_DESTROY: case TC_CLSFLOWER_DESTROY:
err = mlx5e_delete_flower(netdev, priv, err = mlx5e_delete_flower(netdev, priv, flower, flags);
flower, MLX5E_TC_EGRESS);
break; break;
case TC_CLSFLOWER_STATS: case TC_CLSFLOWER_STATS:
err = mlx5e_stats_flower(netdev, priv, err = mlx5e_stats_flower(netdev, priv, flower, flags);
flower, MLX5E_TC_EGRESS);
break; break;
default: default:
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
...@@ -983,7 +1077,7 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv, ...@@ -983,7 +1077,7 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
mlx5e_rep_neigh_entry_destroy(priv, nhe); mlx5e_rep_neigh_entry_destroy(priv, nhe);
} }
static int mlx5e_rep_open(struct net_device *dev) static int mlx5e_vf_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;
...@@ -1005,7 +1099,7 @@ static int mlx5e_rep_open(struct net_device *dev) ...@@ -1005,7 +1099,7 @@ static int mlx5e_rep_open(struct net_device *dev)
return err; return err;
} }
static int mlx5e_rep_close(struct net_device *dev) static int mlx5e_vf_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;
...@@ -1062,7 +1156,8 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data, ...@@ -1062,7 +1156,8 @@ static int mlx5e_rep_setup_tc_cb(enum tc_setup_type type, void *type_data,
switch (type) { switch (type) {
case TC_SETUP_CLSFLOWER: case TC_SETUP_CLSFLOWER:
return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS); return mlx5e_rep_setup_tc_cls_flower(priv, type_data, MLX5E_TC_INGRESS |
MLX5E_TC_ESW_OFFLOAD);
default: default:
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1101,43 +1196,23 @@ static int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -1101,43 +1196,23 @@ static int mlx5e_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv)
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
struct mlx5e_rep_priv *rpriv = priv->ppriv; struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep; struct mlx5_eswitch_rep *rep;
if (!MLX5_ESWITCH_MANAGER(priv->mdev)) if (!MLX5_ESWITCH_MANAGER(priv->mdev))
return false; return false;
rep = rpriv->rep; if (!rpriv) /* non vport rep mlx5e instances don't use this field */
if (esw->mode == SRIOV_OFFLOADS &&
rep && rep->vport == FDB_UPLINK_VPORT)
return true;
return false;
}
static bool mlx5e_is_vf_vport_rep(struct mlx5e_priv *priv)
{
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep;
if (!MLX5_ESWITCH_MANAGER(priv->mdev))
return false; return false;
rep = rpriv->rep; rep = rpriv->rep;
if (rep && rep->vport != FDB_UPLINK_VPORT) return (rep->vport == FDB_UPLINK_VPORT);
return true;
return false;
} }
bool mlx5e_has_offload_stats(const struct net_device *dev, int attr_id) static bool mlx5e_rep_has_offload_stats(const struct net_device *dev, int attr_id)
{ {
struct mlx5e_priv *priv = netdev_priv(dev);
switch (attr_id) { switch (attr_id) {
case IFLA_OFFLOAD_XSTATS_CPU_HIT: case IFLA_OFFLOAD_XSTATS_CPU_HIT:
if (mlx5e_is_vf_vport_rep(priv) || mlx5e_is_uplink_rep(priv))
return true; return true;
} }
...@@ -1163,8 +1238,8 @@ mlx5e_get_sw_stats64(const struct net_device *dev, ...@@ -1163,8 +1238,8 @@ mlx5e_get_sw_stats64(const struct net_device *dev,
return 0; return 0;
} }
int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev, static int mlx5e_rep_get_offload_stats(int attr_id, const struct net_device *dev,
void *sp) void *sp)
{ {
switch (attr_id) { switch (attr_id) {
case IFLA_OFFLOAD_XSTATS_CPU_HIT: case IFLA_OFFLOAD_XSTATS_CPU_HIT:
...@@ -1175,7 +1250,7 @@ int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev, ...@@ -1175,7 +1250,7 @@ int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev,
} }
static void static void
mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) mlx5e_vf_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);
...@@ -1184,39 +1259,84 @@ mlx5e_rep_get_stats(struct net_device *dev, struct rtnl_link_stats64 *stats) ...@@ -1184,39 +1259,84 @@ mlx5e_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)
{
return mlx5e_change_mtu(netdev, new_mtu, NULL);
}
static int mlx5e_uplink_rep_change_mtu(struct net_device *netdev, int new_mtu)
{
return mlx5e_change_mtu(netdev, new_mtu, mlx5e_set_dev_port_mtu);
}
static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr)
{
struct sockaddr *saddr = addr;
if (!is_valid_ether_addr(saddr->sa_data))
return -EADDRNOTAVAIL;
ether_addr_copy(netdev->dev_addr, saddr->sa_data);
return 0;
}
static const struct switchdev_ops mlx5e_rep_switchdev_ops = { static const struct switchdev_ops mlx5e_rep_switchdev_ops = {
.switchdev_port_attr_get = mlx5e_attr_get, .switchdev_port_attr_get = mlx5e_attr_get,
}; };
static int mlx5e_change_rep_mtu(struct net_device *netdev, int new_mtu) static const struct net_device_ops mlx5e_netdev_ops_vf_rep = {
{ .ndo_open = mlx5e_vf_rep_open,
return mlx5e_change_mtu(netdev, new_mtu, NULL); .ndo_stop = mlx5e_vf_rep_close,
} .ndo_start_xmit = mlx5e_xmit,
.ndo_get_phys_port_name = mlx5e_rep_get_phys_port_name,
.ndo_setup_tc = mlx5e_rep_setup_tc,
.ndo_get_stats64 = mlx5e_vf_rep_get_stats,
.ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
.ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
.ndo_change_mtu = mlx5e_vf_rep_change_mtu,
};
static const struct net_device_ops mlx5e_netdev_ops_rep = { static const struct net_device_ops mlx5e_netdev_ops_uplink_rep = {
.ndo_open = mlx5e_rep_open, .ndo_open = mlx5e_open,
.ndo_stop = mlx5e_rep_close, .ndo_stop = mlx5e_close,
.ndo_start_xmit = mlx5e_xmit, .ndo_start_xmit = mlx5e_xmit,
.ndo_set_mac_address = mlx5e_uplink_rep_set_mac,
.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_rep_get_stats, .ndo_get_stats64 = mlx5e_get_stats,
.ndo_has_offload_stats = mlx5e_has_offload_stats, .ndo_has_offload_stats = mlx5e_rep_has_offload_stats,
.ndo_get_offload_stats = mlx5e_get_offload_stats, .ndo_get_offload_stats = mlx5e_rep_get_offload_stats,
.ndo_change_mtu = mlx5e_change_rep_mtu, .ndo_change_mtu = mlx5e_uplink_rep_change_mtu,
.ndo_udp_tunnel_add = mlx5e_add_vxlan_port,
.ndo_udp_tunnel_del = mlx5e_del_vxlan_port,
.ndo_features_check = mlx5e_features_check,
.ndo_set_vf_mac = mlx5e_set_vf_mac,
.ndo_set_vf_rate = mlx5e_set_vf_rate,
.ndo_get_vf_config = mlx5e_get_vf_config,
.ndo_get_vf_stats = mlx5e_get_vf_stats,
}; };
static void mlx5e_build_rep_params(struct mlx5_core_dev *mdev, static void mlx5e_build_rep_params(struct net_device *netdev)
struct mlx5e_params *params,
struct mlx5e_rss_params *rss_params,
u16 mtu)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5e_params *params;
u8 cq_period_mode = MLX5_CAP_GEN(mdev, cq_period_start_from_cqe) ? u8 cq_period_mode = MLX5_CAP_GEN(mdev, cq_period_start_from_cqe) ?
MLX5_CQ_PERIOD_MODE_START_FROM_CQE : MLX5_CQ_PERIOD_MODE_START_FROM_CQE :
MLX5_CQ_PERIOD_MODE_START_FROM_EQE; MLX5_CQ_PERIOD_MODE_START_FROM_EQE;
params = &priv->channels.params;
params->hard_mtu = MLX5E_ETH_HARD_MTU; params->hard_mtu = MLX5E_ETH_HARD_MTU;
params->sw_mtu = mtu; params->sw_mtu = netdev->mtu;
params->log_sq_size = MLX5E_REP_PARAMS_LOG_SQ_SIZE;
/* SQ */
if (rep->vport == FDB_UPLINK_VPORT)
params->log_sq_size = MLX5E_PARAMS_DEFAULT_LOG_SQ_SIZE;
else
params->log_sq_size = MLX5E_REP_PARAMS_LOG_SQ_SIZE;
/* RQ */ /* RQ */
mlx5e_build_rq_params(mdev, params); mlx5e_build_rq_params(mdev, params);
...@@ -1230,20 +1350,34 @@ static void mlx5e_build_rep_params(struct mlx5_core_dev *mdev, ...@@ -1230,20 +1350,34 @@ static void mlx5e_build_rep_params(struct mlx5_core_dev *mdev,
mlx5_query_min_inline(mdev, &params->tx_min_inline_mode); mlx5_query_min_inline(mdev, &params->tx_min_inline_mode);
/* RSS */ /* RSS */
mlx5e_build_rss_params(rss_params, params->num_channels); mlx5e_build_rss_params(&priv->rss_params, params->num_channels);
} }
static void mlx5e_build_rep_netdev(struct net_device *netdev) static void mlx5e_build_rep_netdev(struct net_device *netdev)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_eswitch_rep *rep = rpriv->rep;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
u16 max_mtu;
netdev->netdev_ops = &mlx5e_netdev_ops_rep; if (rep->vport == FDB_UPLINK_VPORT) {
SET_NETDEV_DEV(netdev, &priv->mdev->pdev->dev);
netdev->netdev_ops = &mlx5e_netdev_ops_uplink_rep;
/* we want a persistent mac for the uplink rep */
mlx5_query_nic_vport_mac_address(mdev, 0, netdev->dev_addr);
netdev->ethtool_ops = &mlx5e_uplink_rep_ethtool_ops;
#ifdef CONFIG_MLX5_CORE_EN_DCB
if (MLX5_CAP_GEN(mdev, qos))
netdev->dcbnl_ops = &mlx5e_dcbnl_ops;
#endif
} else {
netdev->netdev_ops = &mlx5e_netdev_ops_vf_rep;
eth_hw_addr_random(netdev);
netdev->ethtool_ops = &mlx5e_vf_rep_ethtool_ops;
}
netdev->watchdog_timeo = 15 * HZ; netdev->watchdog_timeo = 15 * HZ;
netdev->ethtool_ops = &mlx5e_rep_ethtool_ops;
netdev->switchdev_ops = &mlx5e_rep_switchdev_ops; netdev->switchdev_ops = &mlx5e_rep_switchdev_ops;
...@@ -1259,12 +1393,15 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) ...@@ -1259,12 +1393,15 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev)
netdev->hw_features |= NETIF_F_RXCSUM; netdev->hw_features |= NETIF_F_RXCSUM;
netdev->features |= netdev->hw_features; netdev->features |= netdev->hw_features;
}
eth_hw_addr_random(netdev); static int mlx5e_rep_get_default_num_channels(struct mlx5_eswitch_rep *rep,
struct net_device *netdev)
netdev->min_mtu = ETH_MIN_MTU; {
mlx5_query_port_max_mtu(mdev, &max_mtu, 1); if (rep->vport == FDB_UPLINK_VPORT)
netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu); return mlx5e_get_netdev_max_channels(netdev);
else
return 1;
} }
static int mlx5e_init_rep(struct mlx5_core_dev *mdev, static int mlx5e_init_rep(struct mlx5_core_dev *mdev,
...@@ -1273,18 +1410,17 @@ static int mlx5e_init_rep(struct mlx5_core_dev *mdev, ...@@ -1273,18 +1410,17 @@ static int mlx5e_init_rep(struct mlx5_core_dev *mdev,
void *ppriv) void *ppriv)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5e_rep_priv *rpriv = ppriv;
int err; int err;
err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv); err = mlx5e_netdev_init(netdev, priv, mdev, profile, ppriv);
if (err) if (err)
return err; return err;
priv->channels.params.num_channels = priv->channels.params.num_channels =
mlx5e_get_netdev_max_channels(netdev); mlx5e_rep_get_default_num_channels(rpriv->rep, netdev);
mlx5e_build_rep_params(mdev, &priv->channels.params, mlx5e_build_rep_params(netdev);
&priv->rss_params, netdev->mtu);
mlx5e_build_rep_netdev(netdev); mlx5e_build_rep_netdev(netdev);
mlx5e_timestamp_init(priv); mlx5e_timestamp_init(priv);
...@@ -1407,97 +1543,159 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv) ...@@ -1407,97 +1543,159 @@ static void mlx5e_cleanup_rep_rx(struct mlx5e_priv *priv)
static int mlx5e_init_rep_tx(struct mlx5e_priv *priv) static int mlx5e_init_rep_tx(struct mlx5e_priv *priv)
{ {
int err; struct mlx5e_rep_priv *rpriv = priv->ppriv;
struct mlx5_rep_uplink_priv *uplink_priv;
int tc, err;
err = mlx5e_create_tises(priv); err = mlx5e_create_tises(priv);
if (err) { if (err) {
mlx5_core_warn(priv->mdev, "create tises failed, %d\n", err); mlx5_core_warn(priv->mdev, "create tises failed, %d\n", err);
return err; return err;
} }
if (rpriv->rep->vport == FDB_UPLINK_VPORT) {
uplink_priv = &rpriv->uplink_priv;
/* init shared tc flow table */
err = mlx5e_tc_esw_init(&uplink_priv->tc_ht);
if (err)
goto destroy_tises;
/* init indirect block notifications */
INIT_LIST_HEAD(&uplink_priv->tc_indr_block_priv_list);
uplink_priv->netdevice_nb.notifier_call = mlx5e_nic_rep_netdevice_event;
err = register_netdevice_notifier(&uplink_priv->netdevice_nb);
if (err) {
mlx5_core_err(priv->mdev, "Failed to register netdev notifier\n");
goto tc_esw_cleanup;
}
}
return 0; return 0;
tc_esw_cleanup:
mlx5e_tc_esw_cleanup(&uplink_priv->tc_ht);
destroy_tises:
for (tc = 0; tc < priv->profile->max_tc; tc++)
mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);
return err;
} }
static const struct mlx5e_profile mlx5e_rep_profile = { static void mlx5e_cleanup_rep_tx(struct mlx5e_priv *priv)
.init = mlx5e_init_rep, {
.cleanup = mlx5e_cleanup_rep, struct mlx5e_rep_priv *rpriv = priv->ppriv;
.init_rx = mlx5e_init_rep_rx, int tc;
.cleanup_rx = mlx5e_cleanup_rep_rx,
.init_tx = mlx5e_init_rep_tx,
.cleanup_tx = mlx5e_cleanup_nic_tx,
.update_stats = mlx5e_rep_update_hw_counters,
.update_carrier = NULL,
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
.max_tc = 1,
};
/* e-Switch vport representors */ for (tc = 0; tc < priv->profile->max_tc; tc++)
mlx5e_destroy_tis(priv->mdev, priv->tisn[tc]);
static int if (rpriv->rep->vport == FDB_UPLINK_VPORT) {
mlx5e_nic_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) /* clean indirect TC block notifications */
{ unregister_netdevice_notifier(&rpriv->uplink_priv.netdevice_nb);
struct mlx5e_rep_priv *rpriv = mlx5e_rep_to_rep_priv(rep); mlx5e_rep_indr_clean_block_privs(rpriv);
struct mlx5e_priv *priv = netdev_priv(rpriv->netdev);
struct mlx5_rep_uplink_priv *uplink_priv = &rpriv->uplink_priv;
int err;
if (test_bit(MLX5E_STATE_OPENED, &priv->state)) { /* delete shared tc flow table */
err = mlx5e_add_sqs_fwd_rules(priv); mlx5e_tc_esw_cleanup(&rpriv->uplink_priv.tc_ht);
if (err)
return err;
} }
}
err = mlx5e_rep_neigh_init(rpriv); static void mlx5e_vf_rep_enable(struct mlx5e_priv *priv)
if (err) {
goto err_remove_sqs; struct net_device *netdev = priv->netdev;
struct mlx5_core_dev *mdev = priv->mdev;
u16 max_mtu;
/* init shared tc flow table */ netdev->min_mtu = ETH_MIN_MTU;
err = mlx5e_tc_esw_init(&uplink_priv->tc_ht); mlx5_query_port_max_mtu(mdev, &max_mtu, 1);
if (err) netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
goto err_neigh_cleanup; }
/* init indirect block notifications */ static int uplink_rep_async_event(struct notifier_block *nb, unsigned long event, void *data)
INIT_LIST_HEAD(&uplink_priv->tc_indr_block_priv_list); {
uplink_priv->netdevice_nb.notifier_call = mlx5e_nic_rep_netdevice_event; struct mlx5e_priv *priv = container_of(nb, struct mlx5e_priv, events_nb);
err = register_netdevice_notifier(&uplink_priv->netdevice_nb); struct mlx5_eqe *eqe = data;
if (err) {
mlx5_core_err(priv->mdev, "Failed to register netdev notifier\n");
goto err_indirect_block_cleanup;
}
return 0; if (event != MLX5_EVENT_TYPE_PORT_CHANGE)
return NOTIFY_DONE;
err_indirect_block_cleanup: switch (eqe->sub_type) {
mlx5e_tc_esw_cleanup(&uplink_priv->tc_ht); case MLX5_PORT_CHANGE_SUBTYPE_DOWN:
err_neigh_cleanup: case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE:
mlx5e_rep_neigh_cleanup(rpriv); queue_work(priv->wq, &priv->update_carrier_work);
err_remove_sqs: break;
mlx5e_remove_sqs_fwd_rules(priv); default:
return err; return NOTIFY_DONE;
}
return NOTIFY_OK;
} }
static void static void mlx5e_uplink_rep_enable(struct mlx5e_priv *priv)
mlx5e_nic_rep_unload(struct mlx5_eswitch_rep *rep)
{ {
struct mlx5e_rep_priv *rpriv = mlx5e_rep_to_rep_priv(rep); struct net_device *netdev = priv->netdev;
struct mlx5e_priv *priv = netdev_priv(rpriv->netdev); struct mlx5_core_dev *mdev = priv->mdev;
u16 max_mtu;
if (test_bit(MLX5E_STATE_OPENED, &priv->state))
mlx5e_remove_sqs_fwd_rules(priv);
/* clean indirect TC block notifications */ netdev->min_mtu = ETH_MIN_MTU;
unregister_netdevice_notifier(&rpriv->uplink_priv.netdevice_nb); mlx5_query_port_max_mtu(priv->mdev, &max_mtu, 1);
mlx5e_rep_indr_clean_block_privs(rpriv); netdev->max_mtu = MLX5E_HW2SW_MTU(&priv->channels.params, max_mtu);
mlx5e_set_dev_port_mtu(priv);
mlx5_lag_add(mdev, netdev);
priv->events_nb.notifier_call = uplink_rep_async_event;
mlx5_notifier_register(mdev, &priv->events_nb);
#ifdef CONFIG_MLX5_CORE_EN_DCB
mlx5e_dcbnl_initialize(priv);
mlx5e_dcbnl_init_app(priv);
#endif
}
/* clean uplink offloaded TC rules, delete shared tc flow table */ static void mlx5e_uplink_rep_disable(struct mlx5e_priv *priv)
mlx5e_tc_esw_cleanup(&rpriv->uplink_priv.tc_ht); {
struct mlx5_core_dev *mdev = priv->mdev;
mlx5e_rep_neigh_cleanup(rpriv); #ifdef CONFIG_MLX5_CORE_EN_DCB
mlx5e_dcbnl_delete_app(priv);
#endif
mlx5_notifier_unregister(mdev, &priv->events_nb);
mlx5_lag_remove(mdev);
} }
static const struct mlx5e_profile mlx5e_vf_rep_profile = {
.init = mlx5e_init_rep,
.cleanup = mlx5e_cleanup_rep,
.init_rx = mlx5e_init_rep_rx,
.cleanup_rx = mlx5e_cleanup_rep_rx,
.init_tx = mlx5e_init_rep_tx,
.cleanup_tx = mlx5e_cleanup_rep_tx,
.enable = mlx5e_vf_rep_enable,
.update_stats = mlx5e_vf_rep_update_hw_counters,
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
.max_tc = 1,
};
static const struct mlx5e_profile mlx5e_uplink_rep_profile = {
.init = mlx5e_init_rep,
.cleanup = mlx5e_cleanup_rep,
.init_rx = mlx5e_init_rep_rx,
.cleanup_rx = mlx5e_cleanup_rep_rx,
.init_tx = mlx5e_init_rep_tx,
.cleanup_tx = mlx5e_cleanup_rep_tx,
.enable = mlx5e_uplink_rep_enable,
.disable = mlx5e_uplink_rep_disable,
.update_stats = mlx5e_uplink_rep_update_hw_counters,
.update_carrier = mlx5e_update_carrier,
.rx_handlers.handle_rx_cqe = mlx5e_handle_rx_cqe_rep,
.rx_handlers.handle_rx_cqe_mpwqe = mlx5e_handle_rx_cqe_mpwrq,
.max_tc = MLX5E_MAX_NUM_TC,
};
/* e-Switch vport representors */
static int static int
mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
{ {
const struct mlx5e_profile *profile;
struct mlx5e_rep_priv *rpriv; struct mlx5e_rep_priv *rpriv;
struct net_device *netdev; struct net_device *netdev;
int nch, err; int nch, err;
...@@ -1506,8 +1704,12 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) ...@@ -1506,8 +1704,12 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
if (!rpriv) if (!rpriv)
return -ENOMEM; return -ENOMEM;
/* rpriv->rep to be looked up when profile->init() is called */
rpriv->rep = rep;
nch = mlx5e_get_max_num_channels(dev); nch = mlx5e_get_max_num_channels(dev);
netdev = mlx5e_create_netdev(dev, &mlx5e_rep_profile, nch, rpriv); profile = (rep->vport == FDB_UPLINK_VPORT) ? &mlx5e_uplink_rep_profile : &mlx5e_vf_rep_profile;
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",
rep->vport); rep->vport);
...@@ -1516,15 +1718,20 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) ...@@ -1516,15 +1718,20 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
} }
rpriv->netdev = netdev; rpriv->netdev = netdev;
rpriv->rep = rep;
rep->rep_if[REP_ETH].priv = rpriv; rep->rep_if[REP_ETH].priv = rpriv;
INIT_LIST_HEAD(&rpriv->vport_sqs_list); INIT_LIST_HEAD(&rpriv->vport_sqs_list);
if (rep->vport == FDB_UPLINK_VPORT) {
err = mlx5e_create_mdev_resources(dev);
if (err)
goto err_destroy_netdev;
}
err = mlx5e_attach_netdev(netdev_priv(netdev)); err = mlx5e_attach_netdev(netdev_priv(netdev));
if (err) { if (err) {
pr_warn("Failed to attach representor netdev for vport %d\n", pr_warn("Failed to attach representor netdev for vport %d\n",
rep->vport); rep->vport);
goto err_destroy_netdev; goto err_destroy_mdev_resources;
} }
err = mlx5e_rep_neigh_init(rpriv); err = mlx5e_rep_neigh_init(rpriv);
...@@ -1549,6 +1756,10 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep) ...@@ -1549,6 +1756,10 @@ mlx5e_vport_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
err_detach_netdev: err_detach_netdev:
mlx5e_detach_netdev(netdev_priv(netdev)); mlx5e_detach_netdev(netdev_priv(netdev));
err_destroy_mdev_resources:
if (rep->vport == FDB_UPLINK_VPORT)
mlx5e_destroy_mdev_resources(dev);
err_destroy_netdev: err_destroy_netdev:
mlx5e_destroy_netdev(netdev_priv(netdev)); mlx5e_destroy_netdev(netdev_priv(netdev));
kfree(rpriv); kfree(rpriv);
...@@ -1566,6 +1777,8 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep) ...@@ -1566,6 +1777,8 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
unregister_netdev(netdev); unregister_netdev(netdev);
mlx5e_rep_neigh_cleanup(rpriv); mlx5e_rep_neigh_cleanup(rpriv);
mlx5e_detach_netdev(priv); mlx5e_detach_netdev(priv);
if (rep->vport == FDB_UPLINK_VPORT)
mlx5e_destroy_mdev_resources(priv->mdev);
mlx5e_destroy_netdev(priv); mlx5e_destroy_netdev(priv);
kfree(ppriv); /* mlx5e_rep_priv */ kfree(ppriv); /* mlx5e_rep_priv */
} }
...@@ -1579,14 +1792,13 @@ static void *mlx5e_vport_rep_get_proto_dev(struct mlx5_eswitch_rep *rep) ...@@ -1579,14 +1792,13 @@ static void *mlx5e_vport_rep_get_proto_dev(struct mlx5_eswitch_rep *rep)
return rpriv->netdev; return rpriv->netdev;
} }
static void mlx5e_rep_register_vf_vports(struct mlx5e_priv *priv) void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev)
{ {
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_eswitch *esw = mdev->priv.eswitch;
struct mlx5_eswitch *esw = mdev->priv.eswitch;
int total_vfs = MLX5_TOTAL_VPORTS(mdev); int total_vfs = MLX5_TOTAL_VPORTS(mdev);
int vport; int vport;
for (vport = 1; vport < total_vfs; vport++) { for (vport = 0; vport < total_vfs; vport++) {
struct mlx5_eswitch_rep_if rep_if = {}; struct mlx5_eswitch_rep_if rep_if = {};
rep_if.load = mlx5e_vport_rep_load; rep_if.load = mlx5e_vport_rep_load;
...@@ -1596,55 +1808,12 @@ static void mlx5e_rep_register_vf_vports(struct mlx5e_priv *priv) ...@@ -1596,55 +1808,12 @@ static void mlx5e_rep_register_vf_vports(struct mlx5e_priv *priv)
} }
} }
static void mlx5e_rep_unregister_vf_vports(struct mlx5e_priv *priv) void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev)
{ {
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5_eswitch *esw = mdev->priv.eswitch; struct mlx5_eswitch *esw = mdev->priv.eswitch;
int total_vfs = MLX5_TOTAL_VPORTS(mdev); int total_vfs = MLX5_TOTAL_VPORTS(mdev);
int vport; int vport;
for (vport = 1; vport < total_vfs; vport++) for (vport = total_vfs - 1; vport >= 0; vport--)
mlx5_eswitch_unregister_vport_rep(esw, vport, REP_ETH); mlx5_eswitch_unregister_vport_rep(esw, vport, REP_ETH);
} }
void mlx5e_register_vport_reps(struct mlx5e_priv *priv)
{
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5_eswitch *esw = mdev->priv.eswitch;
struct mlx5_eswitch_rep_if rep_if;
struct mlx5e_rep_priv *rpriv;
rpriv = priv->ppriv;
rpriv->netdev = priv->netdev;
rep_if.load = mlx5e_nic_rep_load;
rep_if.unload = mlx5e_nic_rep_unload;
rep_if.get_proto_dev = mlx5e_vport_rep_get_proto_dev;
rep_if.priv = rpriv;
INIT_LIST_HEAD(&rpriv->vport_sqs_list);
mlx5_eswitch_register_vport_rep(esw, 0, &rep_if, REP_ETH); /* UPLINK PF vport*/
mlx5e_rep_register_vf_vports(priv); /* VFs vports */
}
void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv)
{
struct mlx5_core_dev *mdev = priv->mdev;
struct mlx5_eswitch *esw = mdev->priv.eswitch;
mlx5e_rep_unregister_vf_vports(priv); /* VFs vports */
mlx5_eswitch_unregister_vport_rep(esw, 0, REP_ETH); /* UPLINK PF*/
}
void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev)
{
struct mlx5_eswitch *esw = mdev->priv.eswitch;
struct mlx5e_rep_priv *rpriv;
rpriv = kzalloc(sizeof(*rpriv), GFP_KERNEL);
if (!rpriv)
return NULL;
rpriv->rep = &esw->offloads.vport_reps[0];
return rpriv;
}
...@@ -162,16 +162,12 @@ struct mlx5e_rep_sq { ...@@ -162,16 +162,12 @@ struct mlx5e_rep_sq {
}; };
void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev); void *mlx5e_alloc_nic_rep_priv(struct mlx5_core_dev *mdev);
void mlx5e_register_vport_reps(struct mlx5e_priv *priv); void mlx5e_rep_register_vport_reps(struct mlx5_core_dev *mdev);
void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv); void mlx5e_rep_unregister_vport_reps(struct mlx5_core_dev *mdev);
bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv); bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv);
int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv); int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv);
void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv); void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv);
int mlx5e_get_offload_stats(int attr_id, const struct net_device *dev, void *sp);
bool mlx5e_has_offload_stats(const struct net_device *dev, int attr_id);
int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr);
void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe); void mlx5e_handle_rx_cqe_rep(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe);
int mlx5e_rep_encap_entry_attach(struct mlx5e_priv *priv, int mlx5e_rep_encap_entry_attach(struct mlx5e_priv *priv,
...@@ -181,11 +177,13 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv, ...@@ -181,11 +177,13 @@ void mlx5e_rep_encap_entry_detach(struct mlx5e_priv *priv,
void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv); void mlx5e_rep_queue_neigh_stats_work(struct mlx5e_priv *priv);
#else /* CONFIG_MLX5_ESWITCH */ #else /* CONFIG_MLX5_ESWITCH */
static inline void mlx5e_register_vport_reps(struct mlx5e_priv *priv) {}
static inline void mlx5e_unregister_vport_reps(struct mlx5e_priv *priv) {}
static inline bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) { return false; } static inline bool mlx5e_is_uplink_rep(struct mlx5e_priv *priv) { return false; }
static inline int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv) { return 0; } static inline int mlx5e_add_sqs_fwd_rules(struct mlx5e_priv *priv) { return 0; }
static inline void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) {} static inline void mlx5e_remove_sqs_fwd_rules(struct mlx5e_priv *priv) {}
#endif #endif
static inline bool mlx5e_is_vport_rep(struct mlx5e_priv *priv)
{
return (MLX5_ESWITCH_MANAGER(priv->mdev) && priv->ppriv);
}
#endif /* __MLX5E_REP_H__ */ #endif /* __MLX5E_REP_H__ */
...@@ -486,7 +486,7 @@ static int mlx5e_grp_802_3_fill_stats(struct mlx5e_priv *priv, u64 *data, ...@@ -486,7 +486,7 @@ static int mlx5e_grp_802_3_fill_stats(struct mlx5e_priv *priv, u64 *data,
#define MLX5_BASIC_PPCNT_SUPPORTED(mdev) \ #define MLX5_BASIC_PPCNT_SUPPORTED(mdev) \
(MLX5_CAP_GEN(mdev, pcam_reg) ? MLX5_CAP_PCAM_REG(mdev, ppcnt) : 1) (MLX5_CAP_GEN(mdev, pcam_reg) ? MLX5_CAP_PCAM_REG(mdev, ppcnt) : 1)
static void mlx5e_grp_802_3_update_stats(struct mlx5e_priv *priv) void mlx5e_grp_802_3_update_stats(struct mlx5e_priv *priv)
{ {
struct mlx5e_pport_stats *pstats = &priv->stats.pport; struct mlx5e_pport_stats *pstats = &priv->stats.pport;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5_core_dev *mdev = priv->mdev;
......
...@@ -280,5 +280,6 @@ extern const struct mlx5e_stats_grp mlx5e_stats_grps[]; ...@@ -280,5 +280,6 @@ extern const struct mlx5e_stats_grp mlx5e_stats_grps[];
extern const int mlx5e_num_stats_grps; extern const int mlx5e_num_stats_grps;
void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv); void mlx5e_grp_sw_update_stats(struct mlx5e_priv *priv);
void mlx5e_grp_802_3_update_stats(struct mlx5e_priv *priv);
#endif /* __MLX5_EN_STATS_H__ */ #endif /* __MLX5_EN_STATS_H__ */
...@@ -69,13 +69,13 @@ struct mlx5_nic_flow_attr { ...@@ -69,13 +69,13 @@ struct mlx5_nic_flow_attr {
enum { enum {
MLX5E_TC_FLOW_INGRESS = MLX5E_TC_INGRESS, MLX5E_TC_FLOW_INGRESS = MLX5E_TC_INGRESS,
MLX5E_TC_FLOW_EGRESS = MLX5E_TC_EGRESS, MLX5E_TC_FLOW_EGRESS = MLX5E_TC_EGRESS,
MLX5E_TC_FLOW_ESWITCH = BIT(MLX5E_TC_FLOW_BASE), MLX5E_TC_FLOW_ESWITCH = MLX5E_TC_ESW_OFFLOAD,
MLX5E_TC_FLOW_NIC = BIT(MLX5E_TC_FLOW_BASE + 1), MLX5E_TC_FLOW_NIC = MLX5E_TC_NIC_OFFLOAD,
MLX5E_TC_FLOW_OFFLOADED = BIT(MLX5E_TC_FLOW_BASE + 2), MLX5E_TC_FLOW_OFFLOADED = BIT(MLX5E_TC_FLOW_BASE),
MLX5E_TC_FLOW_HAIRPIN = BIT(MLX5E_TC_FLOW_BASE + 3), MLX5E_TC_FLOW_HAIRPIN = BIT(MLX5E_TC_FLOW_BASE + 1),
MLX5E_TC_FLOW_HAIRPIN_RSS = BIT(MLX5E_TC_FLOW_BASE + 4), MLX5E_TC_FLOW_HAIRPIN_RSS = BIT(MLX5E_TC_FLOW_BASE + 2),
MLX5E_TC_FLOW_SLOW = BIT(MLX5E_TC_FLOW_BASE + 5), MLX5E_TC_FLOW_SLOW = BIT(MLX5E_TC_FLOW_BASE + 3),
MLX5E_TC_FLOW_DUP = BIT(MLX5E_TC_FLOW_BASE + 6), MLX5E_TC_FLOW_DUP = BIT(MLX5E_TC_FLOW_BASE + 4),
}; };
#define MLX5E_TC_MAX_SPLITS 1 #define MLX5E_TC_MAX_SPLITS 1
...@@ -834,7 +834,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv, ...@@ -834,7 +834,7 @@ static void mlx5e_tc_del_nic_flow(struct mlx5e_priv *priv,
mlx5_del_flow_rules(flow->rule[0]); mlx5_del_flow_rules(flow->rule[0]);
mlx5_fc_destroy(priv->mdev, counter); mlx5_fc_destroy(priv->mdev, counter);
if (!mlx5e_tc_num_filters(priv) && priv->fs.tc.t) { if (!mlx5e_tc_num_filters(priv, MLX5E_TC_NIC_OFFLOAD) && priv->fs.tc.t) {
mlx5_destroy_flow_table(priv->fs.tc.t); mlx5_destroy_flow_table(priv->fs.tc.t);
priv->fs.tc.t = NULL; priv->fs.tc.t = NULL;
} }
...@@ -2686,6 +2686,11 @@ static void get_flags(int flags, u16 *flow_flags) ...@@ -2686,6 +2686,11 @@ static void get_flags(int flags, u16 *flow_flags)
if (flags & MLX5E_TC_EGRESS) if (flags & MLX5E_TC_EGRESS)
__flow_flags |= MLX5E_TC_FLOW_EGRESS; __flow_flags |= MLX5E_TC_FLOW_EGRESS;
if (flags & MLX5E_TC_ESW_OFFLOAD)
__flow_flags |= MLX5E_TC_FLOW_ESWITCH;
if (flags & MLX5E_TC_NIC_OFFLOAD)
__flow_flags |= MLX5E_TC_FLOW_NIC;
*flow_flags = __flow_flags; *flow_flags = __flow_flags;
} }
...@@ -2696,15 +2701,15 @@ static const struct rhashtable_params tc_ht_params = { ...@@ -2696,15 +2701,15 @@ static const struct rhashtable_params tc_ht_params = {
.automatic_shrinking = true, .automatic_shrinking = true,
}; };
static struct rhashtable *get_tc_ht(struct mlx5e_priv *priv) static struct rhashtable *get_tc_ht(struct mlx5e_priv *priv, int flags)
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
struct mlx5e_rep_priv *uplink_rpriv; struct mlx5e_rep_priv *uplink_rpriv;
if (MLX5_VPORT_MANAGER(priv->mdev) && esw->mode == SRIOV_OFFLOADS) { if (flags & MLX5E_TC_ESW_OFFLOAD) {
uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH); uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
return &uplink_rpriv->uplink_priv.tc_ht; return &uplink_rpriv->uplink_priv.tc_ht;
} else } else /* NIC offload */
return &priv->fs.tc.ht; return &priv->fs.tc.ht;
} }
...@@ -2973,7 +2978,7 @@ int mlx5e_configure_flower(struct net_device *dev, struct mlx5e_priv *priv, ...@@ -2973,7 +2978,7 @@ int mlx5e_configure_flower(struct net_device *dev, struct mlx5e_priv *priv,
struct tc_cls_flower_offload *f, int flags) struct tc_cls_flower_offload *f, int flags)
{ {
struct netlink_ext_ack *extack = f->common.extack; struct netlink_ext_ack *extack = f->common.extack;
struct rhashtable *tc_ht = get_tc_ht(priv); struct rhashtable *tc_ht = get_tc_ht(priv, flags);
struct mlx5e_tc_flow *flow; struct mlx5e_tc_flow *flow;
int err = 0; int err = 0;
...@@ -3018,7 +3023,7 @@ static bool same_flow_direction(struct mlx5e_tc_flow *flow, int flags) ...@@ -3018,7 +3023,7 @@ static bool same_flow_direction(struct mlx5e_tc_flow *flow, int flags)
int mlx5e_delete_flower(struct net_device *dev, struct mlx5e_priv *priv, int mlx5e_delete_flower(struct net_device *dev, struct mlx5e_priv *priv,
struct tc_cls_flower_offload *f, int flags) struct tc_cls_flower_offload *f, int flags)
{ {
struct rhashtable *tc_ht = get_tc_ht(priv); struct rhashtable *tc_ht = get_tc_ht(priv, flags);
struct mlx5e_tc_flow *flow; struct mlx5e_tc_flow *flow;
flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params); flow = rhashtable_lookup_fast(tc_ht, &f->cookie, tc_ht_params);
...@@ -3038,7 +3043,7 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv, ...@@ -3038,7 +3043,7 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
struct tc_cls_flower_offload *f, int flags) struct tc_cls_flower_offload *f, int flags)
{ {
struct mlx5_devcom *devcom = priv->mdev->priv.devcom; struct mlx5_devcom *devcom = priv->mdev->priv.devcom;
struct rhashtable *tc_ht = get_tc_ht(priv); struct rhashtable *tc_ht = get_tc_ht(priv, flags);
struct mlx5_eswitch *peer_esw; struct mlx5_eswitch *peer_esw;
struct mlx5e_tc_flow *flow; struct mlx5e_tc_flow *flow;
struct mlx5_fc *counter; struct mlx5_fc *counter;
...@@ -3168,7 +3173,7 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) ...@@ -3168,7 +3173,7 @@ void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv)
if (tc->netdevice_nb.notifier_call) if (tc->netdevice_nb.notifier_call)
unregister_netdevice_notifier(&tc->netdevice_nb); unregister_netdevice_notifier(&tc->netdevice_nb);
rhashtable_free_and_destroy(&tc->ht, _mlx5e_tc_del_flow, NULL); rhashtable_destroy(&tc->ht);
if (!IS_ERR_OR_NULL(tc->t)) { if (!IS_ERR_OR_NULL(tc->t)) {
mlx5_destroy_flow_table(tc->t); mlx5_destroy_flow_table(tc->t);
...@@ -3186,9 +3191,9 @@ void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht) ...@@ -3186,9 +3191,9 @@ void mlx5e_tc_esw_cleanup(struct rhashtable *tc_ht)
rhashtable_free_and_destroy(tc_ht, _mlx5e_tc_del_flow, NULL); rhashtable_free_and_destroy(tc_ht, _mlx5e_tc_del_flow, NULL);
} }
int mlx5e_tc_num_filters(struct mlx5e_priv *priv) int mlx5e_tc_num_filters(struct mlx5e_priv *priv, int flags)
{ {
struct rhashtable *tc_ht = get_tc_ht(priv); struct rhashtable *tc_ht = get_tc_ht(priv, flags);
return atomic_read(&tc_ht->nelems); return atomic_read(&tc_ht->nelems);
} }
......
...@@ -42,7 +42,9 @@ ...@@ -42,7 +42,9 @@
enum { enum {
MLX5E_TC_INGRESS = BIT(0), MLX5E_TC_INGRESS = BIT(0),
MLX5E_TC_EGRESS = BIT(1), MLX5E_TC_EGRESS = BIT(1),
MLX5E_TC_LAST_EXPORTED_BIT = 1, MLX5E_TC_NIC_OFFLOAD = BIT(2),
MLX5E_TC_ESW_OFFLOAD = BIT(3),
MLX5E_TC_LAST_EXPORTED_BIT = 3,
}; };
int mlx5e_tc_nic_init(struct mlx5e_priv *priv); int mlx5e_tc_nic_init(struct mlx5e_priv *priv);
...@@ -68,13 +70,13 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv, ...@@ -68,13 +70,13 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv,
struct mlx5e_neigh_hash_entry; struct mlx5e_neigh_hash_entry;
void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe); void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe);
int mlx5e_tc_num_filters(struct mlx5e_priv *priv); int mlx5e_tc_num_filters(struct mlx5e_priv *priv, int flags);
#else /* CONFIG_MLX5_ESWITCH */ #else /* CONFIG_MLX5_ESWITCH */
static inline int mlx5e_tc_nic_init(struct mlx5e_priv *priv) { return 0; } static inline int mlx5e_tc_nic_init(struct mlx5e_priv *priv) { return 0; }
static inline void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) {} static inline void mlx5e_tc_nic_cleanup(struct mlx5e_priv *priv) {}
static inline int mlx5e_tc_num_filters(struct mlx5e_priv *priv) { return 0; } static inline int mlx5e_tc_num_filters(struct mlx5e_priv *priv, int flags) { return 0; }
#endif #endif
#endif /* __MLX5_EN_TC_H__ */ #endif /* __MLX5_EN_TC_H__ */
...@@ -1630,6 +1630,7 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) ...@@ -1630,6 +1630,7 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
esw_warn(esw->dev, "E-Switch engress ACL is not supported by FW\n"); esw_warn(esw->dev, "E-Switch engress ACL is not supported by FW\n");
esw_info(esw->dev, "E-Switch enable SRIOV: nvfs(%d) mode (%d)\n", nvfs, mode); esw_info(esw->dev, "E-Switch enable SRIOV: nvfs(%d) mode (%d)\n", nvfs, mode);
esw->mode = mode; esw->mode = mode;
mlx5_lag_update(esw->dev); mlx5_lag_update(esw->dev);
...@@ -1637,8 +1638,8 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) ...@@ -1637,8 +1638,8 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
if (mode == SRIOV_LEGACY) { if (mode == SRIOV_LEGACY) {
err = esw_create_legacy_fdb_table(esw); err = esw_create_legacy_fdb_table(esw);
} else { } else {
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB); mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
err = esw_offloads_init(esw, nvfs + 1); err = esw_offloads_init(esw, nvfs + 1);
} }
...@@ -1669,8 +1670,10 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode) ...@@ -1669,8 +1670,10 @@ int mlx5_eswitch_enable_sriov(struct mlx5_eswitch *esw, int nvfs, int mode)
abort: abort:
esw->mode = SRIOV_NONE; esw->mode = SRIOV_NONE;
if (mode == SRIOV_OFFLOADS) if (mode == SRIOV_OFFLOADS) {
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB); mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
}
return err; return err;
} }
...@@ -1712,8 +1715,10 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw) ...@@ -1712,8 +1715,10 @@ void mlx5_eswitch_disable_sriov(struct mlx5_eswitch *esw)
mlx5_lag_update(esw->dev); mlx5_lag_update(esw->dev);
if (old_mode == SRIOV_OFFLOADS) if (old_mode == SRIOV_OFFLOADS) {
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB); mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_ETH);
}
} }
int mlx5_eswitch_init(struct mlx5_core_dev *dev) int mlx5_eswitch_init(struct mlx5_core_dev *dev)
......
...@@ -1450,9 +1450,6 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw, ...@@ -1450,9 +1450,6 @@ static int esw_offloads_stop(struct mlx5_eswitch *esw,
} }
} }
/* enable back PF RoCE */
mlx5_reload_interface(esw->dev, MLX5_INTERFACE_PROTOCOL_IB);
return err; return err;
} }
......
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