aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTariq Toukan <tariqt@mellanox.com>2016-04-20 15:02:09 -0400
committerDavid S. Miller <davem@davemloft.net>2016-04-21 15:09:04 -0400
commit237cd218099ce96edf2890a49aa191b38b84c2fc (patch)
treeee6e61ddb42081b00c7bb574406683d6145a25a9
parentb8fd789afb293002b11086e6ae417b7c523d2bdc (diff)
net/mlx5: Introduce device queue counters
A queue counter can collect several statistics for one or more hardware queues (QPs, RQs, etc ..) that the counter is attached to. For Ethernet it will provide an "out of buffer" counter which collects the number of all packets that are dropped due to lack of software buffers. Here we add device commands to alloc/query/dealloc queue counters. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Rana Shahout <ranas@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/qp.c68
-rw-r--r--include/linux/mlx5/qp.h6
2 files changed, 74 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/qp.c b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
index def289375ecb..b720a274220d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
@@ -538,3 +538,71 @@ void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev,
538 mlx5_core_destroy_sq(dev, sq->qpn); 538 mlx5_core_destroy_sq(dev, sq->qpn);
539} 539}
540EXPORT_SYMBOL(mlx5_core_destroy_sq_tracked); 540EXPORT_SYMBOL(mlx5_core_destroy_sq_tracked);
541
542int mlx5_core_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id)
543{
544 u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)];
545 u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)];
546 int err;
547
548 memset(in, 0, sizeof(in));
549 memset(out, 0, sizeof(out));
550
551 MLX5_SET(alloc_q_counter_in, in, opcode, MLX5_CMD_OP_ALLOC_Q_COUNTER);
552 err = mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, sizeof(out));
553 if (!err)
554 *counter_id = MLX5_GET(alloc_q_counter_out, out,
555 counter_set_id);
556 return err;
557}
558EXPORT_SYMBOL_GPL(mlx5_core_alloc_q_counter);
559
560int mlx5_core_dealloc_q_counter(struct mlx5_core_dev *dev, u16 counter_id)
561{
562 u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)];
563 u32 out[MLX5_ST_SZ_DW(dealloc_q_counter_out)];
564
565 memset(in, 0, sizeof(in));
566 memset(out, 0, sizeof(out));
567
568 MLX5_SET(dealloc_q_counter_in, in, opcode,
569 MLX5_CMD_OP_DEALLOC_Q_COUNTER);
570 MLX5_SET(dealloc_q_counter_in, in, counter_set_id, counter_id);
571 return mlx5_cmd_exec_check_status(dev, in, sizeof(in), out,
572 sizeof(out));
573}
574EXPORT_SYMBOL_GPL(mlx5_core_dealloc_q_counter);
575
576int mlx5_core_query_q_counter(struct mlx5_core_dev *dev, u16 counter_id,
577 int reset, void *out, int out_size)
578{
579 u32 in[MLX5_ST_SZ_DW(query_q_counter_in)];
580
581 memset(in, 0, sizeof(in));
582
583 MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
584 MLX5_SET(query_q_counter_in, in, clear, reset);
585 MLX5_SET(query_q_counter_in, in, counter_set_id, counter_id);
586 return mlx5_cmd_exec_check_status(dev, in, sizeof(in), out, out_size);
587}
588EXPORT_SYMBOL_GPL(mlx5_core_query_q_counter);
589
590int mlx5_core_query_out_of_buffer(struct mlx5_core_dev *dev, u16 counter_id,
591 u32 *out_of_buffer)
592{
593 int outlen = MLX5_ST_SZ_BYTES(query_q_counter_out);
594 void *out;
595 int err;
596
597 out = mlx5_vzalloc(outlen);
598 if (!out)
599 return -ENOMEM;
600
601 err = mlx5_core_query_q_counter(dev, counter_id, 0, out, outlen);
602 if (!err)
603 *out_of_buffer = MLX5_GET(query_q_counter_out, out,
604 out_of_buffer);
605
606 kfree(out);
607 return err;
608}
diff --git a/include/linux/mlx5/qp.h b/include/linux/mlx5/qp.h
index cf031a3f16c5..64221027bf1f 100644
--- a/include/linux/mlx5/qp.h
+++ b/include/linux/mlx5/qp.h
@@ -668,6 +668,12 @@ int mlx5_core_create_sq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen,
668 struct mlx5_core_qp *sq); 668 struct mlx5_core_qp *sq);
669void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev, 669void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev,
670 struct mlx5_core_qp *sq); 670 struct mlx5_core_qp *sq);
671int mlx5_core_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id);
672int mlx5_core_dealloc_q_counter(struct mlx5_core_dev *dev, u16 counter_id);
673int mlx5_core_query_q_counter(struct mlx5_core_dev *dev, u16 counter_id,
674 int reset, void *out, int out_size);
675int mlx5_core_query_out_of_buffer(struct mlx5_core_dev *dev, u16 counter_id,
676 u32 *out_of_buffer);
671 677
672static inline const char *mlx5_qp_type_str(int type) 678static inline const char *mlx5_qp_type_str(int type)
673{ 679{