History

net/mlx5: Remove Q counter low level helper APIs

mlx5 core users are encouraged to use low level API (mlx5_cmd_exec) without the need of helper functions, do this for q counters, remove helper functions and call mlx5_cmd_exec directly from users. This will help reduce the total amount of code and reduction of the mlx5_core symbol table.

Leon Romanovsky committed 6 years ago

Commit 66247fb1 parent 57a6c5e5 files · +80 −92Browse files

Unified · Split

5 files
  1. drivers/infiniband/hw/mlx5/main.c +32 −23
  2. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +25 −14
  3. drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +23 −12
  4. drivers/net/ethernet/mellanox/mlx5/core/qp.c +0 −39
  5. include/linux/mlx5/qp.h +0 −4
drivers/infiniband/hw/mlx5/main.c+32−23
@@ -5439,15 +5439,21 @@ static bool is_mdev_switchdev_mode(const struct mlx5_core_dev *mdev) · 5438 unmodified lines
54395439
54405440 static void mlx5_ib_dealloc_counters(struct mlx5_ib_dev *dev)
54415441 {
5442+ u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)] = {};
54425443 int num_cnt_ports;
54435444 int i;
54445445
54455446 num_cnt_ports = is_mdev_switchdev_mode(dev->mdev) ? 1 : dev->num_ports;
54465447
5448+ MLX5_SET(dealloc_q_counter_in, in, opcode,
5449+ MLX5_CMD_OP_DEALLOC_Q_COUNTER);
5450+
54475451 for (i = 0; i < num_cnt_ports; i++) {
5448− if (dev->port[i].cnts.set_id_valid)
5449− mlx5_core_dealloc_q_counter(dev->mdev,
5450− dev->port[i].cnts.set_id);
5452+ if (dev->port[i].cnts.set_id_valid) {
5453+ MLX5_SET(dealloc_q_counter_in, in, counter_set_id,
5454+ dev->port[i].cnts.set_id);
5455+ mlx5_cmd_exec_in(dev->mdev, dealloc_q_counter, in);
5456+ }
54515457 kfree(dev->port[i].cnts.names);
54525458 kfree(dev->port[i].cnts.offsets);
54535459 }
@@ -5638,27 +5644,23 @@ static int mlx5_ib_query_q_counters(struct mlx5_core_dev *mdev, · 184 unmodified lines
56385644 struct rdma_hw_stats *stats,
56395645 u16 set_id)
56405646 {
5641− int outlen = MLX5_ST_SZ_BYTES(query_q_counter_out);
5642− void *out;
5647+ u32 out[MLX5_ST_SZ_DW(query_q_counter_out)] = {};
5648+ u32 in[MLX5_ST_SZ_DW(query_q_counter_in)] = {};
56435649 __be32 val;
56445650 int ret, i;
56455651
5646− out = kvzalloc(outlen, GFP_KERNEL);
5647− if (!out)
5648− return -ENOMEM;
5649−
5650− ret = mlx5_core_query_q_counter(mdev, set_id, 0, out, outlen);
5652+ MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
5653+ MLX5_SET(query_q_counter_in, in, counter_set_id, set_id);
5654+ ret = mlx5_cmd_exec_inout(mdev, query_q_counter, in, out);
56515655 if (ret)
5652− goto free;
5656+ return ret;
56535657
56545658 for (i = 0; i < cnts->num_q_counters; i++) {
5655− val = *(__be32 *)(out + cnts->offsets[i]);
5659+ val = *(__be32 *)((void *)out + cnts->offsets[i]);
56565660 stats->value[i] = (u64)be32_to_cpu(val);
56575661 }
56585662
5659−free:
5660− kvfree(out);
5661− return ret;
5663+ return 0;
56625664 }
56635665
56645666 static int mlx5_ib_query_ext_ppcnt_counters(struct mlx5_ib_dev *dev,
@@ -5765,6 +5767,20 @@ static int mlx5_ib_counter_update_stats(struct rdma_counter *counter) · 100 unmodified lines
57655767 counter->stats, counter->id);
57665768 }
57675769
5770+static int mlx5_ib_counter_dealloc(struct rdma_counter *counter)
5771+{
5772+ struct mlx5_ib_dev *dev = to_mdev(counter->device);
5773+ u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)] = {};
5774+
5775+ if (!counter->id)
5776+ return 0;
5777+
5778+ MLX5_SET(dealloc_q_counter_in, in, opcode,
5779+ MLX5_CMD_OP_DEALLOC_Q_COUNTER);
5780+ MLX5_SET(dealloc_q_counter_in, in, counter_set_id, counter->id);
5781+ return mlx5_cmd_exec_in(dev->mdev, dealloc_q_counter, in);
5782+}
5783+
57685784 static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter,
57695785 struct ib_qp *qp)
57705786 {
@@ -5788,7 +5804,7 @@ static int mlx5_ib_counter_bind_qp(struct rdma_counter *counter, · 17 unmodified lines
57885804 return 0;
57895805
57905806 fail_set_counter:
5791− mlx5_core_dealloc_q_counter(dev->mdev, cnt_set_id);
5807+ mlx5_ib_counter_dealloc(counter);
57925808 counter->id = 0;
57935809
57945810 return err;
@@ -5799,13 +5815,6 @@ static int mlx5_ib_counter_unbind_qp(struct ib_qp *qp) · 4 unmodified lines
57995815 return mlx5_ib_qp_set_counter(qp, NULL);
58005816 }
58015817
5802−static int mlx5_ib_counter_dealloc(struct rdma_counter *counter)
5803−{
5804− struct mlx5_ib_dev *dev = to_mdev(counter->device);
5805−
5806− return mlx5_core_dealloc_q_counter(dev->mdev, counter->id);
5807−}
5808−
58095818 static int mlx5_ib_rn_get_params(struct ib_device *device, u8 port_num,
58105819 enum rdma_netdev_t type,
58115820 struct rdma_netdev_alloc_params *params)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+25−14
@@ -4997,29 +4997,40 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) · 4996 unmodified lines
49974997
49984998 void mlx5e_create_q_counters(struct mlx5e_priv *priv)
49994999 {
5000+ u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)] = {};
5001+ u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)] = {};
50005002 struct mlx5_core_dev *mdev = priv->mdev;
50015003 int err;
50025004
5003− err = mlx5_core_alloc_q_counter(mdev, &priv->q_counter);
5004− if (err) {
5005− mlx5_core_warn(mdev, "alloc queue counter failed, %d\n", err);
5006− priv->q_counter = 0;
5007− }
5005+ MLX5_SET(alloc_q_counter_in, in, opcode, MLX5_CMD_OP_ALLOC_Q_COUNTER);
5006+ err = mlx5_cmd_exec_inout(mdev, alloc_q_counter, in, out);
5007+ if (!err)
5008+ priv->q_counter =
5009+ MLX5_GET(alloc_q_counter_out, out, counter_set_id);
50085010
5009− err = mlx5_core_alloc_q_counter(mdev, &priv->drop_rq_q_counter);
5010− if (err) {
5011− mlx5_core_warn(mdev, "alloc drop RQ counter failed, %d\n", err);
5012− priv->drop_rq_q_counter = 0;
5013− }
5011+ err = mlx5_cmd_exec_inout(mdev, alloc_q_counter, in, out);
5012+ if (!err)
5013+ priv->drop_rq_q_counter =
5014+ MLX5_GET(alloc_q_counter_out, out, counter_set_id);
50145015 }
50155016
50165017 void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
50175018 {
5018− if (priv->q_counter)
5019− mlx5_core_dealloc_q_counter(priv->mdev, priv->q_counter);
5019+ u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)] = {};
5020+
5021+ MLX5_SET(dealloc_q_counter_in, in, opcode,
5022+ MLX5_CMD_OP_DEALLOC_Q_COUNTER);
5023+ if (priv->q_counter) {
5024+ MLX5_SET(dealloc_q_counter_in, in, counter_set_id,
5025+ priv->q_counter);
5026+ mlx5_cmd_exec_in(priv->mdev, dealloc_q_counter, in);
5027+ }
50205028
5021− if (priv->drop_rq_q_counter)
5022− mlx5_core_dealloc_q_counter(priv->mdev, priv->drop_rq_q_counter);
5029+ if (priv->drop_rq_q_counter) {
5030+ MLX5_SET(dealloc_q_counter_in, in, counter_set_id,
5031+ priv->drop_rq_q_counter);
5032+ mlx5_cmd_exec_in(priv->mdev, dealloc_q_counter, in);
5033+ }
50235034 }
50245035
50255036 static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c+23−12
@@ -411,18 +411,29 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS(qcnt) · 410 unmodified lines
411411 static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(qcnt)
412412 {
413413 struct mlx5e_qcounter_stats *qcnt = &priv->stats.qcnt;
414− u32 out[MLX5_ST_SZ_DW(query_q_counter_out)];
415−
416− if (priv->q_counter &&
417− !mlx5_core_query_q_counter(priv->mdev, priv->q_counter, 0, out,
418− sizeof(out)))
419− qcnt->rx_out_of_buffer = MLX5_GET(query_q_counter_out,
420− out, out_of_buffer);
421− if (priv->drop_rq_q_counter &&
422− !mlx5_core_query_q_counter(priv->mdev, priv->drop_rq_q_counter, 0,
423− out, sizeof(out)))
424− qcnt->rx_if_down_packets = MLX5_GET(query_q_counter_out, out,
425− out_of_buffer);
414+ u32 out[MLX5_ST_SZ_DW(query_q_counter_out)] = {};
415+ u32 in[MLX5_ST_SZ_DW(query_q_counter_in)] = {};
416+ int ret;
417+
418+ MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
419+
420+ if (priv->q_counter) {
421+ MLX5_SET(query_q_counter_in, in, counter_set_id,
422+ priv->q_counter);
423+ ret = mlx5_cmd_exec_inout(priv->mdev, query_q_counter, in, out);
424+ if (!ret)
425+ qcnt->rx_out_of_buffer = MLX5_GET(query_q_counter_out,
426+ out, out_of_buffer);
427+ }
428+
429+ if (priv->drop_rq_q_counter) {
430+ MLX5_SET(query_q_counter_in, in, counter_set_id,
431+ priv->drop_rq_q_counter);
432+ ret = mlx5_cmd_exec_inout(priv->mdev, query_q_counter, in, out);
433+ if (!ret)
434+ qcnt->rx_if_down_packets = MLX5_GET(query_q_counter_out,
435+ out, out_of_buffer);
436+ }
426437 }
427438
428439 #define VNIC_ENV_OFF(c) MLX5_BYTE_OFF(query_vnic_env_out, c)
drivers/net/ethernet/mellanox/mlx5/core/qp.c+0−39
@@ -680,45 +680,6 @@ void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev, · 679 unmodified lines
680680 }
681681 EXPORT_SYMBOL(mlx5_core_destroy_sq_tracked);
682682
683−int mlx5_core_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id)
684−{
685− u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)] = {0};
686− u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)] = {0};
687− int err;
688−
689− MLX5_SET(alloc_q_counter_in, in, opcode, MLX5_CMD_OP_ALLOC_Q_COUNTER);
690− err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
691− if (!err)
692− *counter_id = MLX5_GET(alloc_q_counter_out, out,
693− counter_set_id);
694− return err;
695−}
696−EXPORT_SYMBOL_GPL(mlx5_core_alloc_q_counter);
697−
698−int mlx5_core_dealloc_q_counter(struct mlx5_core_dev *dev, u16 counter_id)
699−{
700− u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)] = {0};
701− u32 out[MLX5_ST_SZ_DW(dealloc_q_counter_out)] = {0};
702−
703− MLX5_SET(dealloc_q_counter_in, in, opcode,
704− MLX5_CMD_OP_DEALLOC_Q_COUNTER);
705− MLX5_SET(dealloc_q_counter_in, in, counter_set_id, counter_id);
706− return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
707−}
708−EXPORT_SYMBOL_GPL(mlx5_core_dealloc_q_counter);
709−
710−int mlx5_core_query_q_counter(struct mlx5_core_dev *dev, u16 counter_id,
711− int reset, void *out, int out_size)
712−{
713− u32 in[MLX5_ST_SZ_DW(query_q_counter_in)] = {0};
714−
715− MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
716− MLX5_SET(query_q_counter_in, in, clear, reset);
717− MLX5_SET(query_q_counter_in, in, counter_set_id, counter_id);
718− return mlx5_cmd_exec(dev, in, sizeof(in), out, out_size);
719−}
720−EXPORT_SYMBOL_GPL(mlx5_core_query_q_counter);
721−
722683 struct mlx5_core_rsc_common *mlx5_core_res_hold(struct mlx5_core_dev *dev,
723684 int res_num,
724685 enum mlx5_res_type res_type)
include/linux/mlx5/qp.h+0−4
@@ -595,10 +595,6 @@ int mlx5_core_create_sq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen, · 594 unmodified lines
595595 struct mlx5_core_qp *sq);
596596 void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev,
597597 struct mlx5_core_qp *sq);
598−int mlx5_core_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id);
599−int mlx5_core_dealloc_q_counter(struct mlx5_core_dev *dev, u16 counter_id);
600−int mlx5_core_query_q_counter(struct mlx5_core_dev *dev, u16 counter_id,
601− int reset, void *out, int out_size);
602598
603599 struct mlx5_core_rsc_common *mlx5_core_res_hold(struct mlx5_core_dev *dev,
604600 int res_num,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t