Commit ff8ced4e authored by Jakub Kicinski's avatar Jakub Kicinski

Merge tag 'mlx5-fixes-2023-02-07' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux

Saeed Mahameed says:

====================
mlx5 fixes 2023-02-07

This series provides bug fixes to mlx5 driver.

* tag 'mlx5-fixes-2023-02-07' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux:
  net/mlx5: Serialize module cleanup with reload and remove
  net/mlx5: fw_tracer, Zero consumer index when reloading the tracer
  net/mlx5: fw_tracer, Clear load bit when freeing string DBs buffers
  net/mlx5: Expose SF firmware pages counter
  net/mlx5: Store page counters in a single array
  net/mlx5e: IPoIB, Show unknown speed instead of error
  net/mlx5e: Fix crash unsetting rx-vlan-filter in switchdev mode
  net/mlx5: Bridge, fix ageing of peer FDB entries
  net/mlx5: DR, Fix potential race in dr_rule_create_rule_nic
  net/mlx5e: Update rx ring hw mtu upon each rx-fcs flag change
====================

Link: https://lore.kernel.org/r/20230208030302.95378-1-saeed@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents b963d9d5 8f0d1451
...@@ -245,8 +245,9 @@ void mlx5_pages_debugfs_init(struct mlx5_core_dev *dev) ...@@ -245,8 +245,9 @@ void mlx5_pages_debugfs_init(struct mlx5_core_dev *dev)
pages = dev->priv.dbg.pages_debugfs; pages = dev->priv.dbg.pages_debugfs;
debugfs_create_u32("fw_pages_total", 0400, pages, &dev->priv.fw_pages); debugfs_create_u32("fw_pages_total", 0400, pages, &dev->priv.fw_pages);
debugfs_create_u32("fw_pages_vfs", 0400, pages, &dev->priv.vfs_pages); debugfs_create_u32("fw_pages_vfs", 0400, pages, &dev->priv.page_counters[MLX5_VF]);
debugfs_create_u32("fw_pages_host_pf", 0400, pages, &dev->priv.host_pf_pages); debugfs_create_u32("fw_pages_sfs", 0400, pages, &dev->priv.page_counters[MLX5_SF]);
debugfs_create_u32("fw_pages_host_pf", 0400, pages, &dev->priv.page_counters[MLX5_HOST_PF]);
debugfs_create_u32("fw_pages_alloc_failed", 0400, pages, &dev->priv.fw_pages_alloc_failed); debugfs_create_u32("fw_pages_alloc_failed", 0400, pages, &dev->priv.fw_pages_alloc_failed);
debugfs_create_u32("fw_pages_give_dropped", 0400, pages, &dev->priv.give_pages_dropped); debugfs_create_u32("fw_pages_give_dropped", 0400, pages, &dev->priv.give_pages_dropped);
debugfs_create_u32("fw_pages_reclaim_discard", 0400, pages, debugfs_create_u32("fw_pages_reclaim_discard", 0400, pages,
......
...@@ -64,6 +64,7 @@ static int mlx5_query_mtrc_caps(struct mlx5_fw_tracer *tracer) ...@@ -64,6 +64,7 @@ static int mlx5_query_mtrc_caps(struct mlx5_fw_tracer *tracer)
MLX5_GET(mtrc_cap, out, num_string_trace); MLX5_GET(mtrc_cap, out, num_string_trace);
tracer->str_db.num_string_db = MLX5_GET(mtrc_cap, out, num_string_db); tracer->str_db.num_string_db = MLX5_GET(mtrc_cap, out, num_string_db);
tracer->owner = !!MLX5_GET(mtrc_cap, out, trace_owner); tracer->owner = !!MLX5_GET(mtrc_cap, out, trace_owner);
tracer->str_db.loaded = false;
for (i = 0; i < tracer->str_db.num_string_db; i++) { for (i = 0; i < tracer->str_db.num_string_db; i++) {
mtrc_cap_sp = MLX5_ADDR_OF(mtrc_cap, out, string_db_param[i]); mtrc_cap_sp = MLX5_ADDR_OF(mtrc_cap, out, string_db_param[i]);
...@@ -756,6 +757,7 @@ static int mlx5_fw_tracer_set_mtrc_conf(struct mlx5_fw_tracer *tracer) ...@@ -756,6 +757,7 @@ static int mlx5_fw_tracer_set_mtrc_conf(struct mlx5_fw_tracer *tracer)
if (err) if (err)
mlx5_core_warn(dev, "FWTracer: Failed to set tracer configurations %d\n", err); mlx5_core_warn(dev, "FWTracer: Failed to set tracer configurations %d\n", err);
tracer->buff.consumer_index = 0;
return err; return err;
} }
...@@ -820,7 +822,6 @@ static void mlx5_fw_tracer_ownership_change(struct work_struct *work) ...@@ -820,7 +822,6 @@ static void mlx5_fw_tracer_ownership_change(struct work_struct *work)
mlx5_core_dbg(tracer->dev, "FWTracer: ownership changed, current=(%d)\n", tracer->owner); mlx5_core_dbg(tracer->dev, "FWTracer: ownership changed, current=(%d)\n", tracer->owner);
if (tracer->owner) { if (tracer->owner) {
tracer->owner = false; tracer->owner = false;
tracer->buff.consumer_index = 0;
return; return;
} }
......
...@@ -87,7 +87,7 @@ void mlx5_ec_cleanup(struct mlx5_core_dev *dev) ...@@ -87,7 +87,7 @@ void mlx5_ec_cleanup(struct mlx5_core_dev *dev)
mlx5_host_pf_cleanup(dev); mlx5_host_pf_cleanup(dev);
err = mlx5_wait_for_pages(dev, &dev->priv.host_pf_pages); err = mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_HOST_PF]);
if (err) if (err)
mlx5_core_warn(dev, "Timeout reclaiming external host PF pages err(%d)\n", err); mlx5_core_warn(dev, "Timeout reclaiming external host PF pages err(%d)\n", err);
} }
...@@ -438,10 +438,6 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb, ...@@ -438,10 +438,6 @@ static int mlx5_esw_bridge_switchdev_event(struct notifier_block *nb,
switch (event) { switch (event) {
case SWITCHDEV_FDB_ADD_TO_BRIDGE: case SWITCHDEV_FDB_ADD_TO_BRIDGE:
/* only handle the event on native eswtich of representor */
if (!mlx5_esw_bridge_is_local(dev, rep, esw))
break;
fdb_info = container_of(info, fdb_info = container_of(info,
struct switchdev_notifier_fdb_info, struct switchdev_notifier_fdb_info,
info); info);
......
...@@ -443,7 +443,7 @@ void mlx5e_enable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc) ...@@ -443,7 +443,7 @@ void mlx5e_enable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc)
void mlx5e_disable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc) void mlx5e_disable_cvlan_filter(struct mlx5e_flow_steering *fs, bool promisc)
{ {
if (fs->vlan->cvlan_filter_disabled) if (!fs->vlan || fs->vlan->cvlan_filter_disabled)
return; return;
fs->vlan->cvlan_filter_disabled = true; fs->vlan->cvlan_filter_disabled = true;
......
...@@ -591,7 +591,8 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param ...@@ -591,7 +591,8 @@ static int mlx5e_init_rxq_rq(struct mlx5e_channel *c, struct mlx5e_params *param
rq->ix = c->ix; rq->ix = c->ix;
rq->channel = c; rq->channel = c;
rq->mdev = mdev; rq->mdev = mdev;
rq->hw_mtu = MLX5E_SW2HW_MTU(params, params->sw_mtu); rq->hw_mtu =
MLX5E_SW2HW_MTU(params, params->sw_mtu) - ETH_FCS_LEN * !params->scatter_fcs_en;
rq->xdpsq = &c->rq_xdpsq; rq->xdpsq = &c->rq_xdpsq;
rq->stats = &c->priv->channel_stats[c->ix]->rq; rq->stats = &c->priv->channel_stats[c->ix]->rq;
rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev); rq->ptp_cyc2time = mlx5_rq_ts_translator(mdev);
...@@ -1014,35 +1015,6 @@ int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state) ...@@ -1014,35 +1015,6 @@ int mlx5e_flush_rq(struct mlx5e_rq *rq, int curr_state)
return mlx5e_rq_to_ready(rq, curr_state); return mlx5e_rq_to_ready(rq, curr_state);
} }
static int mlx5e_modify_rq_scatter_fcs(struct mlx5e_rq *rq, bool enable)
{
struct mlx5_core_dev *mdev = rq->mdev;
void *in;
void *rqc;
int inlen;
int err;
inlen = MLX5_ST_SZ_BYTES(modify_rq_in);
in = kvzalloc(inlen, GFP_KERNEL);
if (!in)
return -ENOMEM;
rqc = MLX5_ADDR_OF(modify_rq_in, in, ctx);
MLX5_SET(modify_rq_in, in, rq_state, MLX5_RQC_STATE_RDY);
MLX5_SET64(modify_rq_in, in, modify_bitmask,
MLX5_MODIFY_RQ_IN_MODIFY_BITMASK_SCATTER_FCS);
MLX5_SET(rqc, rqc, scatter_fcs, enable);
MLX5_SET(rqc, rqc, state, MLX5_RQC_STATE_RDY);
err = mlx5_core_modify_rq(mdev, rq->rqn, in);
kvfree(in);
return err;
}
static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd) static int mlx5e_modify_rq_vsd(struct mlx5e_rq *rq, bool vsd)
{ {
struct mlx5_core_dev *mdev = rq->mdev; struct mlx5_core_dev *mdev = rq->mdev;
...@@ -3314,20 +3286,6 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv) ...@@ -3314,20 +3286,6 @@ static void mlx5e_cleanup_nic_tx(struct mlx5e_priv *priv)
mlx5e_destroy_tises(priv); mlx5e_destroy_tises(priv);
} }
static int mlx5e_modify_channels_scatter_fcs(struct mlx5e_channels *chs, bool enable)
{
int err = 0;
int i;
for (i = 0; i < chs->num; i++) {
err = mlx5e_modify_rq_scatter_fcs(&chs->c[i]->rq, enable);
if (err)
return err;
}
return 0;
}
static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd) static int mlx5e_modify_channels_vsd(struct mlx5e_channels *chs, bool vsd)
{ {
int err; int err;
...@@ -3903,41 +3861,27 @@ static int mlx5e_set_rx_port_ts(struct mlx5_core_dev *mdev, bool enable) ...@@ -3903,41 +3861,27 @@ static int mlx5e_set_rx_port_ts(struct mlx5_core_dev *mdev, bool enable)
return mlx5_set_ports_check(mdev, in, sizeof(in)); return mlx5_set_ports_check(mdev, in, sizeof(in));
} }
static int mlx5e_set_rx_port_ts_wrap(struct mlx5e_priv *priv, void *ctx)
{
struct mlx5_core_dev *mdev = priv->mdev;
bool enable = *(bool *)ctx;
return mlx5e_set_rx_port_ts(mdev, enable);
}
static int set_feature_rx_fcs(struct net_device *netdev, bool enable) static int set_feature_rx_fcs(struct net_device *netdev, bool enable)
{ {
struct mlx5e_priv *priv = netdev_priv(netdev); struct mlx5e_priv *priv = netdev_priv(netdev);
struct mlx5e_channels *chs = &priv->channels; struct mlx5e_channels *chs = &priv->channels;
struct mlx5_core_dev *mdev = priv->mdev; struct mlx5e_params new_params;
int err; int err;
mutex_lock(&priv->state_lock); mutex_lock(&priv->state_lock);
if (enable) { new_params = chs->params;
err = mlx5e_set_rx_port_ts(mdev, false); new_params.scatter_fcs_en = enable;
if (err) err = mlx5e_safe_switch_params(priv, &new_params, mlx5e_set_rx_port_ts_wrap,
goto out; &new_params.scatter_fcs_en, true);
chs->params.scatter_fcs_en = true;
err = mlx5e_modify_channels_scatter_fcs(chs, true);
if (err) {
chs->params.scatter_fcs_en = false;
mlx5e_set_rx_port_ts(mdev, true);
}
} else {
chs->params.scatter_fcs_en = false;
err = mlx5e_modify_channels_scatter_fcs(chs, false);
if (err) {
chs->params.scatter_fcs_en = true;
goto out;
}
err = mlx5e_set_rx_port_ts(mdev, true);
if (err) {
mlx5_core_warn(mdev, "Failed to set RX port timestamp %d\n", err);
err = 0;
}
}
out:
mutex_unlock(&priv->state_lock); mutex_unlock(&priv->state_lock);
return err; return err;
} }
...@@ -4074,6 +4018,10 @@ static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev ...@@ -4074,6 +4018,10 @@ static netdev_features_t mlx5e_fix_uplink_rep_features(struct net_device *netdev
if (netdev->features & NETIF_F_GRO_HW) if (netdev->features & NETIF_F_GRO_HW)
netdev_warn(netdev, "Disabling HW_GRO, not supported in switchdev mode\n"); netdev_warn(netdev, "Disabling HW_GRO, not supported in switchdev mode\n");
features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
if (netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
netdev_warn(netdev, "Disabling HW_VLAN CTAG FILTERING, not supported in switchdev mode\n");
return features; return features;
} }
......
...@@ -1715,7 +1715,7 @@ void mlx5_esw_bridge_fdb_update_used(struct net_device *dev, u16 vport_num, u16 ...@@ -1715,7 +1715,7 @@ void mlx5_esw_bridge_fdb_update_used(struct net_device *dev, u16 vport_num, u16
struct mlx5_esw_bridge *bridge; struct mlx5_esw_bridge *bridge;
port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads); port = mlx5_esw_bridge_port_lookup(vport_num, esw_owner_vhca_id, br_offloads);
if (!port || port->flags & MLX5_ESW_BRIDGE_PORT_FLAG_PEER) if (!port)
return; return;
bridge = port->bridge; bridge = port->bridge;
......
...@@ -189,16 +189,16 @@ static inline int mlx5_ptys_rate_enum_to_int(enum mlx5_ptys_rate rate) ...@@ -189,16 +189,16 @@ static inline int mlx5_ptys_rate_enum_to_int(enum mlx5_ptys_rate rate)
} }
} }
static int mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper) static u32 mlx5i_get_speed_settings(u16 ib_link_width_oper, u16 ib_proto_oper)
{ {
int rate, width; int rate, width;
rate = mlx5_ptys_rate_enum_to_int(ib_proto_oper); rate = mlx5_ptys_rate_enum_to_int(ib_proto_oper);
if (rate < 0) if (rate < 0)
return -EINVAL; return SPEED_UNKNOWN;
width = mlx5_ptys_width_enum_to_int(ib_link_width_oper); width = mlx5_ptys_width_enum_to_int(ib_link_width_oper);
if (width < 0) if (width < 0)
return -EINVAL; return SPEED_UNKNOWN;
return rate * width; return rate * width;
} }
...@@ -221,16 +221,13 @@ static int mlx5i_get_link_ksettings(struct net_device *netdev, ...@@ -221,16 +221,13 @@ static int mlx5i_get_link_ksettings(struct net_device *netdev,
ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising); ethtool_link_ksettings_zero_link_mode(link_ksettings, advertising);
speed = mlx5i_get_speed_settings(ib_link_width_oper, ib_proto_oper); speed = mlx5i_get_speed_settings(ib_link_width_oper, ib_proto_oper);
if (speed < 0) link_ksettings->base.speed = speed;
return -EINVAL; link_ksettings->base.duplex = speed == SPEED_UNKNOWN ? DUPLEX_UNKNOWN : DUPLEX_FULL;
link_ksettings->base.duplex = DUPLEX_FULL;
link_ksettings->base.port = PORT_OTHER; link_ksettings->base.port = PORT_OTHER;
link_ksettings->base.autoneg = AUTONEG_DISABLE; link_ksettings->base.autoneg = AUTONEG_DISABLE;
link_ksettings->base.speed = speed;
return 0; return 0;
} }
......
...@@ -2110,7 +2110,7 @@ static int __init mlx5_init(void) ...@@ -2110,7 +2110,7 @@ static int __init mlx5_init(void)
mlx5_core_verify_params(); mlx5_core_verify_params();
mlx5_register_debugfs(); mlx5_register_debugfs();
err = pci_register_driver(&mlx5_core_driver); err = mlx5e_init();
if (err) if (err)
goto err_debug; goto err_debug;
...@@ -2118,16 +2118,16 @@ static int __init mlx5_init(void) ...@@ -2118,16 +2118,16 @@ static int __init mlx5_init(void)
if (err) if (err)
goto err_sf; goto err_sf;
err = mlx5e_init(); err = pci_register_driver(&mlx5_core_driver);
if (err) if (err)
goto err_en; goto err_pci;
return 0; return 0;
err_en: err_pci:
mlx5_sf_driver_unregister(); mlx5_sf_driver_unregister();
err_sf: err_sf:
pci_unregister_driver(&mlx5_core_driver); mlx5e_cleanup();
err_debug: err_debug:
mlx5_unregister_debugfs(); mlx5_unregister_debugfs();
return err; return err;
...@@ -2135,9 +2135,9 @@ static int __init mlx5_init(void) ...@@ -2135,9 +2135,9 @@ static int __init mlx5_init(void)
static void __exit mlx5_cleanup(void) static void __exit mlx5_cleanup(void)
{ {
mlx5e_cleanup();
mlx5_sf_driver_unregister();
pci_unregister_driver(&mlx5_core_driver); pci_unregister_driver(&mlx5_core_driver);
mlx5_sf_driver_unregister();
mlx5e_cleanup();
mlx5_unregister_debugfs(); mlx5_unregister_debugfs();
} }
......
...@@ -74,6 +74,14 @@ static u32 get_function(u16 func_id, bool ec_function) ...@@ -74,6 +74,14 @@ static u32 get_function(u16 func_id, bool ec_function)
return (u32)func_id | (ec_function << 16); return (u32)func_id | (ec_function << 16);
} }
static u16 func_id_to_type(struct mlx5_core_dev *dev, u16 func_id, bool ec_function)
{
if (!func_id)
return mlx5_core_is_ecpf(dev) && !ec_function ? MLX5_HOST_PF : MLX5_PF;
return func_id <= mlx5_core_max_vfs(dev) ? MLX5_VF : MLX5_SF;
}
static struct rb_root *page_root_per_function(struct mlx5_core_dev *dev, u32 function) static struct rb_root *page_root_per_function(struct mlx5_core_dev *dev, u32 function)
{ {
struct rb_root *root; struct rb_root *root;
...@@ -332,6 +340,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, ...@@ -332,6 +340,7 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0}; u32 out[MLX5_ST_SZ_DW(manage_pages_out)] = {0};
int inlen = MLX5_ST_SZ_BYTES(manage_pages_in); int inlen = MLX5_ST_SZ_BYTES(manage_pages_in);
int notify_fail = event; int notify_fail = event;
u16 func_type;
u64 addr; u64 addr;
int err; int err;
u32 *in; u32 *in;
...@@ -383,11 +392,9 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, ...@@ -383,11 +392,9 @@ static int give_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
goto out_dropped; goto out_dropped;
} }
func_type = func_id_to_type(dev, func_id, ec_function);
dev->priv.page_counters[func_type] += npages;
dev->priv.fw_pages += npages; dev->priv.fw_pages += npages;
if (func_id)
dev->priv.vfs_pages += npages;
else if (mlx5_core_is_ecpf(dev) && !ec_function)
dev->priv.host_pf_pages += npages;
mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x, err %d\n", mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x, err %d\n",
npages, ec_function, func_id, err); npages, ec_function, func_id, err);
...@@ -414,6 +421,7 @@ static void release_all_pages(struct mlx5_core_dev *dev, u16 func_id, ...@@ -414,6 +421,7 @@ static void release_all_pages(struct mlx5_core_dev *dev, u16 func_id,
struct rb_root *root; struct rb_root *root;
struct rb_node *p; struct rb_node *p;
int npages = 0; int npages = 0;
u16 func_type;
root = xa_load(&dev->priv.page_root_xa, function); root = xa_load(&dev->priv.page_root_xa, function);
if (WARN_ON_ONCE(!root)) if (WARN_ON_ONCE(!root))
...@@ -428,11 +436,9 @@ static void release_all_pages(struct mlx5_core_dev *dev, u16 func_id, ...@@ -428,11 +436,9 @@ static void release_all_pages(struct mlx5_core_dev *dev, u16 func_id,
free_fwp(dev, fwp, fwp->free_count); free_fwp(dev, fwp, fwp->free_count);
} }
func_type = func_id_to_type(dev, func_id, ec_function);
dev->priv.page_counters[func_type] -= npages;
dev->priv.fw_pages -= npages; dev->priv.fw_pages -= npages;
if (func_id)
dev->priv.vfs_pages -= npages;
else if (mlx5_core_is_ecpf(dev) && !ec_function)
dev->priv.host_pf_pages -= npages;
mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x\n", mlx5_core_dbg(dev, "npages %d, ec_function %d, func_id 0x%x\n",
npages, ec_function, func_id); npages, ec_function, func_id);
...@@ -498,6 +504,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, ...@@ -498,6 +504,7 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
int outlen = MLX5_ST_SZ_BYTES(manage_pages_out); int outlen = MLX5_ST_SZ_BYTES(manage_pages_out);
u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {}; u32 in[MLX5_ST_SZ_DW(manage_pages_in)] = {};
int num_claimed; int num_claimed;
u16 func_type;
u32 *out; u32 *out;
int err; int err;
int i; int i;
...@@ -549,11 +556,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages, ...@@ -549,11 +556,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u16 func_id, int npages,
if (nclaimed) if (nclaimed)
*nclaimed = num_claimed; *nclaimed = num_claimed;
func_type = func_id_to_type(dev, func_id, ec_function);
dev->priv.page_counters[func_type] -= num_claimed;
dev->priv.fw_pages -= num_claimed; dev->priv.fw_pages -= num_claimed;
if (func_id)
dev->priv.vfs_pages -= num_claimed;
else if (mlx5_core_is_ecpf(dev) && !ec_function)
dev->priv.host_pf_pages -= num_claimed;
out_free: out_free:
kvfree(out); kvfree(out);
...@@ -706,12 +711,12 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) ...@@ -706,12 +711,12 @@ int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev)
WARN(dev->priv.fw_pages, WARN(dev->priv.fw_pages,
"FW pages counter is %d after reclaiming all pages\n", "FW pages counter is %d after reclaiming all pages\n",
dev->priv.fw_pages); dev->priv.fw_pages);
WARN(dev->priv.vfs_pages, WARN(dev->priv.page_counters[MLX5_VF],
"VFs FW pages counter is %d after reclaiming all pages\n", "VFs FW pages counter is %d after reclaiming all pages\n",
dev->priv.vfs_pages); dev->priv.page_counters[MLX5_VF]);
WARN(dev->priv.host_pf_pages, WARN(dev->priv.page_counters[MLX5_HOST_PF],
"External host PF FW pages counter is %d after reclaiming all pages\n", "External host PF FW pages counter is %d after reclaiming all pages\n",
dev->priv.host_pf_pages); dev->priv.page_counters[MLX5_HOST_PF]);
return 0; return 0;
} }
......
...@@ -147,7 +147,7 @@ mlx5_device_disable_sriov(struct mlx5_core_dev *dev, int num_vfs, bool clear_vf) ...@@ -147,7 +147,7 @@ mlx5_device_disable_sriov(struct mlx5_core_dev *dev, int num_vfs, bool clear_vf)
mlx5_eswitch_disable_sriov(dev->priv.eswitch, clear_vf); mlx5_eswitch_disable_sriov(dev->priv.eswitch, clear_vf);
if (mlx5_wait_for_pages(dev, &dev->priv.vfs_pages)) if (mlx5_wait_for_pages(dev, &dev->priv.page_counters[MLX5_VF]))
mlx5_core_warn(dev, "timeout reclaiming VFs pages\n"); mlx5_core_warn(dev, "timeout reclaiming VFs pages\n");
} }
......
...@@ -1138,12 +1138,14 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule, ...@@ -1138,12 +1138,14 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
rule->flow_source)) rule->flow_source))
return 0; return 0;
mlx5dr_domain_nic_lock(nic_dmn);
ret = mlx5dr_matcher_select_builders(matcher, ret = mlx5dr_matcher_select_builders(matcher,
nic_matcher, nic_matcher,
dr_rule_get_ipv(&param->outer), dr_rule_get_ipv(&param->outer),
dr_rule_get_ipv(&param->inner)); dr_rule_get_ipv(&param->inner));
if (ret) if (ret)
return ret; goto err_unlock;
hw_ste_arr_is_opt = nic_matcher->num_of_builders <= DR_RULE_MAX_STES_OPTIMIZED; hw_ste_arr_is_opt = nic_matcher->num_of_builders <= DR_RULE_MAX_STES_OPTIMIZED;
if (likely(hw_ste_arr_is_opt)) { if (likely(hw_ste_arr_is_opt)) {
...@@ -1152,12 +1154,12 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule, ...@@ -1152,12 +1154,12 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
hw_ste_arr = kzalloc((nic_matcher->num_of_builders + DR_ACTION_MAX_STES) * hw_ste_arr = kzalloc((nic_matcher->num_of_builders + DR_ACTION_MAX_STES) *
DR_STE_SIZE, GFP_KERNEL); DR_STE_SIZE, GFP_KERNEL);
if (!hw_ste_arr) if (!hw_ste_arr) {
return -ENOMEM; ret = -ENOMEM;
goto err_unlock;
}
} }
mlx5dr_domain_nic_lock(nic_dmn);
ret = mlx5dr_matcher_add_to_tbl_nic(dmn, nic_matcher); ret = mlx5dr_matcher_add_to_tbl_nic(dmn, nic_matcher);
if (ret) if (ret)
goto free_hw_ste; goto free_hw_ste;
...@@ -1223,7 +1225,10 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule, ...@@ -1223,7 +1225,10 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
mlx5dr_domain_nic_unlock(nic_dmn); mlx5dr_domain_nic_unlock(nic_dmn);
goto out; if (unlikely(!hw_ste_arr_is_opt))
kfree(hw_ste_arr);
return 0;
free_rule: free_rule:
dr_rule_clean_rule_members(rule, nic_rule); dr_rule_clean_rule_members(rule, nic_rule);
...@@ -1238,12 +1243,12 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule, ...@@ -1238,12 +1243,12 @@ dr_rule_create_rule_nic(struct mlx5dr_rule *rule,
mlx5dr_matcher_remove_from_tbl_nic(dmn, nic_matcher); mlx5dr_matcher_remove_from_tbl_nic(dmn, nic_matcher);
free_hw_ste: free_hw_ste:
mlx5dr_domain_nic_unlock(nic_dmn); if (!hw_ste_arr_is_opt)
out:
if (unlikely(!hw_ste_arr_is_opt))
kfree(hw_ste_arr); kfree(hw_ste_arr);
err_unlock:
mlx5dr_domain_nic_unlock(nic_dmn);
return ret; return ret;
} }
......
...@@ -573,6 +573,14 @@ struct mlx5_debugfs_entries { ...@@ -573,6 +573,14 @@ struct mlx5_debugfs_entries {
struct dentry *lag_debugfs; struct dentry *lag_debugfs;
}; };
enum mlx5_func_type {
MLX5_PF,
MLX5_VF,
MLX5_SF,
MLX5_HOST_PF,
MLX5_FUNC_TYPE_NUM,
};
struct mlx5_ft_pool; struct mlx5_ft_pool;
struct mlx5_priv { struct mlx5_priv {
/* IRQ table valid only for real pci devices PF or VF */ /* IRQ table valid only for real pci devices PF or VF */
...@@ -583,11 +591,10 @@ struct mlx5_priv { ...@@ -583,11 +591,10 @@ struct mlx5_priv {
struct mlx5_nb pg_nb; struct mlx5_nb pg_nb;
struct workqueue_struct *pg_wq; struct workqueue_struct *pg_wq;
struct xarray page_root_xa; struct xarray page_root_xa;
u32 fw_pages;
atomic_t reg_pages; atomic_t reg_pages;
struct list_head free_list; struct list_head free_list;
u32 vfs_pages; u32 fw_pages;
u32 host_pf_pages; u32 page_counters[MLX5_FUNC_TYPE_NUM];
u32 fw_pages_alloc_failed; u32 fw_pages_alloc_failed;
u32 give_pages_dropped; u32 give_pages_dropped;
u32 reclaim_pages_discard; u32 reclaim_pages_discard;
......
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