Skip to content

Commit 43d4ec7

Browse files
paravmellanoxjfvogel
authored andcommitted
IB/mlx5: Implement clear counters
This patch implements mlx5 driver to support clearing q counters and congestion counters of a port. Orabug: 26761264 MlnxSF: 00384047 Upstream_status: ignore Signed-off-by: Parav Pandit <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Reviewed-by: Yuval Shaia <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]> Orabug: 31556125 UEK5 => UEK6 (cherry picked from commit fdde66a) cherry-pick-repo=UEK/production/linux-uek.git Conflicts: drivers/infiniband/hw/mlx5/main.c drivers/net/ethernet/mellanox/mlx5/core/lag.c Resolved by adding clear_hw_stats() and initializer, and reverting mlx5_cmd_query_cong_counter() to a non-static routine so it could be called elsewhere. Also, Oracle-specific code was placed within WITHOUT_ORACLE_EXTENSIONS guards. Signed-off-by: William Kucharski <[email protected]> Reviewed-by: Qing Huang <[email protected]> Signed-off-by: Aron Silverton <[email protected]>
1 parent 55a7694 commit 43d4ec7

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5584,6 +5584,39 @@ static struct rdma_hw_stats *mlx5_ib_alloc_hw_stats(struct ib_device *ibdev,
55845584
RDMA_HW_STATS_DEFAULT_LIFESPAN);
55855585
}
55865586

5587+
#ifndef WITHOUT_ORACLE_EXTENSIONS
5588+
static int mlx5_ib_clear_hw_stats(struct ib_device *ibdev, u8 port_num)
5589+
{
5590+
struct mlx5_ib_dev *dev = to_mdev(ibdev);
5591+
struct mlx5_ib_port *port = &dev->port[port_num - 1];
5592+
int outlen = MLX5_ST_SZ_BYTES(query_q_counter_out);
5593+
void *out;
5594+
int ret;
5595+
5596+
out = kvzalloc(outlen, GFP_KERNEL);
5597+
if (!out)
5598+
return -ENOMEM;
5599+
5600+
ret = mlx5_core_query_q_counter(dev->mdev,
5601+
port->cnts.set_id, 1,
5602+
out, outlen);
5603+
kvfree(out);
5604+
5605+
if (ret)
5606+
return ret;
5607+
5608+
outlen = MLX5_ST_SZ_BYTES(query_cong_statistics_out);
5609+
out = kvzalloc(outlen, GFP_KERNEL);
5610+
if (!out)
5611+
return -ENOMEM;
5612+
5613+
ret = mlx5_cmd_query_cong_counter(dev->mdev, true, out, outlen);
5614+
5615+
kvfree(out);
5616+
return ret;
5617+
}
5618+
#endif /* !WITHOUT_ORACLE_EXTENSIONS */
5619+
55875620
static int mlx5_ib_query_q_counters(struct mlx5_core_dev *mdev,
55885621
const struct mlx5_ib_counters *cnts,
55895622
struct rdma_hw_stats *stats,
@@ -6644,6 +6677,9 @@ static void mlx5_ib_stage_odp_cleanup(struct mlx5_ib_dev *dev)
66446677
static const struct ib_device_ops mlx5_ib_dev_hw_stats_ops = {
66456678
.alloc_hw_stats = mlx5_ib_alloc_hw_stats,
66466679
.get_hw_stats = mlx5_ib_get_hw_stats,
6680+
#ifndef WITHOUT_ORACLE_EXTENSIONS
6681+
.clear_hw_stats = mlx5_ib_clear_hw_stats,
6682+
#endif /* !WITHOUT_ORACLE_EXTENSIONS */
66476683
.counter_bind_qp = mlx5_ib_counter_bind_qp,
66486684
.counter_unbind_qp = mlx5_ib_counter_unbind_qp,
66496685
.counter_dealloc = mlx5_ib_counter_dealloc,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ int mlx5_cmd_destroy_vport_lag(struct mlx5_core_dev *dev)
107107
}
108108
EXPORT_SYMBOL(mlx5_cmd_destroy_vport_lag);
109109

110+
#ifndef WITHOUT_ORACLE_EXTENSIONS
111+
int mlx5_cmd_query_cong_counter(struct mlx5_core_dev *dev,
112+
#else /* WITHOUT_ORACLE_EXTENSIONS */
110113
static int mlx5_cmd_query_cong_counter(struct mlx5_core_dev *dev,
114+
#endif /* !WITOUT_ORACLE_EXTENSIONS */
111115
bool reset, void *out, int out_size)
112116
{
113117
u32 in[MLX5_ST_SZ_DW(query_cong_statistics_in)] = { };
@@ -117,6 +121,9 @@ static int mlx5_cmd_query_cong_counter(struct mlx5_core_dev *dev,
117121
MLX5_SET(query_cong_statistics_in, in, clear, reset);
118122
return mlx5_cmd_exec(dev, in, sizeof(in), out, out_size);
119123
}
124+
#ifndef WITHOUT_ORACLE_EXTENSIONS
125+
EXPORT_SYMBOL(mlx5_cmd_query_cong_counter);
126+
#endif /* !WITHOUT_ORACLE_EXTENSIONS */
120127

121128
int mlx5_lag_dev_get_netdev_idx(struct mlx5_lag *ldev,
122129
struct net_device *ndev)

include/linux/mlx5/driver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,10 @@ bool mlx5_lag_is_sriov(struct mlx5_core_dev *dev);
11091109
bool mlx5_lag_is_multipath(struct mlx5_core_dev *dev);
11101110
bool mlx5_lag_is_active(struct mlx5_core_dev *dev);
11111111
struct net_device *mlx5_lag_get_roce_netdev(struct mlx5_core_dev *dev);
1112+
#ifndef WITHOUT_ORACLE_EXTENSIONS
1113+
int mlx5_cmd_query_cong_counter(struct mlx5_core_dev *dev,
1114+
bool reset, void *out, int out_size);
1115+
#endif /* !WITHOUT_ORACLE_EXTENSIONS */
11121116
int mlx5_lag_query_cong_counters(struct mlx5_core_dev *dev,
11131117
u64 *values,
11141118
int num_counters,

0 commit comments

Comments
 (0)