2 * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 #include <linux/gfp.h>
34 #include <linux/export.h>
35 #include <linux/mlx5/cmd.h>
36 #include <linux/mlx5/qp.h>
37 #include <linux/mlx5/driver.h>
38 #include <linux/mlx5/transobj.h>
40 #include "mlx5_core.h"
42 static struct mlx5_core_rsc_common *mlx5_get_rsc(struct mlx5_core_dev *dev,
45 struct mlx5_qp_table *table = &dev->priv.qp_table;
46 struct mlx5_core_rsc_common *common;
48 spin_lock(&table->lock);
50 common = radix_tree_lookup(&table->tree, rsn);
52 atomic_inc(&common->refcount);
54 spin_unlock(&table->lock);
57 mlx5_core_warn(dev, "Async event for bogus resource 0x%x\n",
64 void mlx5_core_put_rsc(struct mlx5_core_rsc_common *common)
66 if (atomic_dec_and_test(&common->refcount))
67 complete(&common->free);
70 static u64 qp_allowed_event_types(void)
74 mask = BIT(MLX5_EVENT_TYPE_PATH_MIG) |
75 BIT(MLX5_EVENT_TYPE_COMM_EST) |
76 BIT(MLX5_EVENT_TYPE_SQ_DRAINED) |
77 BIT(MLX5_EVENT_TYPE_SRQ_LAST_WQE) |
78 BIT(MLX5_EVENT_TYPE_WQ_CATAS_ERROR) |
79 BIT(MLX5_EVENT_TYPE_PATH_MIG_FAILED) |
80 BIT(MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR) |
81 BIT(MLX5_EVENT_TYPE_WQ_ACCESS_ERROR);
86 static u64 rq_allowed_event_types(void)
90 mask = BIT(MLX5_EVENT_TYPE_SRQ_LAST_WQE) |
91 BIT(MLX5_EVENT_TYPE_WQ_CATAS_ERROR);
96 static u64 sq_allowed_event_types(void)
98 return BIT(MLX5_EVENT_TYPE_WQ_CATAS_ERROR);
101 static u64 dct_allowed_event_types(void)
103 return BIT(MLX5_EVENT_TYPE_DCT_DRAINED);
106 static bool is_event_type_allowed(int rsc_type, int event_type)
109 case MLX5_EVENT_QUEUE_TYPE_QP:
110 return BIT(event_type) & qp_allowed_event_types();
111 case MLX5_EVENT_QUEUE_TYPE_RQ:
112 return BIT(event_type) & rq_allowed_event_types();
113 case MLX5_EVENT_QUEUE_TYPE_SQ:
114 return BIT(event_type) & sq_allowed_event_types();
115 case MLX5_EVENT_QUEUE_TYPE_DCT:
116 return BIT(event_type) & dct_allowed_event_types();
118 WARN(1, "Event arrived for unknown resource type");
123 void mlx5_rsc_event(struct mlx5_core_dev *dev, u32 rsn, int event_type)
125 struct mlx5_core_rsc_common *common = mlx5_get_rsc(dev, rsn);
126 struct mlx5_core_dct *dct;
127 struct mlx5_core_qp *qp;
132 if (!is_event_type_allowed((rsn >> MLX5_USER_INDEX_LEN), event_type)) {
133 mlx5_core_warn(dev, "event 0x%.2x is not allowed on resource 0x%.8x\n",
138 switch (common->res) {
142 qp = (struct mlx5_core_qp *)common;
143 qp->event(qp, event_type);
146 dct = (struct mlx5_core_dct *)common;
147 if (event_type == MLX5_EVENT_TYPE_DCT_DRAINED)
148 complete(&dct->drained);
151 mlx5_core_warn(dev, "invalid resource type for 0x%x\n", rsn);
154 mlx5_core_put_rsc(common);
157 static int create_resource_common(struct mlx5_core_dev *dev,
158 struct mlx5_core_qp *qp,
161 struct mlx5_qp_table *table = &dev->priv.qp_table;
164 qp->common.res = rsc_type;
165 spin_lock_irq(&table->lock);
166 err = radix_tree_insert(&table->tree,
167 qp->qpn | (rsc_type << MLX5_USER_INDEX_LEN),
169 spin_unlock_irq(&table->lock);
173 atomic_set(&qp->common.refcount, 1);
174 init_completion(&qp->common.free);
175 qp->pid = current->pid;
180 static void destroy_resource_common(struct mlx5_core_dev *dev,
181 struct mlx5_core_qp *qp)
183 struct mlx5_qp_table *table = &dev->priv.qp_table;
186 spin_lock_irqsave(&table->lock, flags);
187 radix_tree_delete(&table->tree,
188 qp->qpn | (qp->common.res << MLX5_USER_INDEX_LEN));
189 spin_unlock_irqrestore(&table->lock, flags);
190 mlx5_core_put_rsc((struct mlx5_core_rsc_common *)qp);
191 wait_for_completion(&qp->common.free);
194 int mlx5_core_create_dct(struct mlx5_core_dev *dev,
195 struct mlx5_core_dct *dct,
198 u32 out[MLX5_ST_SZ_DW(create_dct_out)] = {0};
199 u32 din[MLX5_ST_SZ_DW(destroy_dct_in)] = {0};
200 u32 dout[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
201 struct mlx5_core_qp *qp = &dct->mqp;
204 init_completion(&dct->drained);
205 MLX5_SET(create_dct_in, in, opcode, MLX5_CMD_OP_CREATE_DCT);
207 err = mlx5_cmd_exec(dev, in, inlen, &out, sizeof(out));
209 mlx5_core_warn(dev, "create DCT failed, ret %d\n", err);
213 qp->qpn = MLX5_GET(create_dct_out, out, dctn);
214 qp->uid = MLX5_GET(create_dct_in, in, uid);
215 err = create_resource_common(dev, qp, MLX5_RES_DCT);
221 MLX5_SET(destroy_dct_in, din, opcode, MLX5_CMD_OP_DESTROY_DCT);
222 MLX5_SET(destroy_dct_in, din, dctn, qp->qpn);
223 MLX5_SET(destroy_dct_in, din, uid, qp->uid);
224 mlx5_cmd_exec(dev, (void *)&in, sizeof(din),
225 (void *)&out, sizeof(dout));
228 EXPORT_SYMBOL_GPL(mlx5_core_create_dct);
230 int mlx5_core_create_qp(struct mlx5_core_dev *dev,
231 struct mlx5_core_qp *qp,
234 u32 out[MLX5_ST_SZ_DW(create_qp_out)] = {0};
235 u32 dout[MLX5_ST_SZ_DW(destroy_qp_out)];
236 u32 din[MLX5_ST_SZ_DW(destroy_qp_in)];
239 MLX5_SET(create_qp_in, in, opcode, MLX5_CMD_OP_CREATE_QP);
241 err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out));
245 qp->uid = MLX5_GET(create_qp_in, in, uid);
246 qp->qpn = MLX5_GET(create_qp_out, out, qpn);
247 mlx5_core_dbg(dev, "qpn = 0x%x\n", qp->qpn);
249 err = create_resource_common(dev, qp, MLX5_RES_QP);
253 err = mlx5_debug_qp_add(dev, qp);
255 mlx5_core_dbg(dev, "failed adding QP 0x%x to debug file system\n",
258 atomic_inc(&dev->num_qps);
263 memset(din, 0, sizeof(din));
264 memset(dout, 0, sizeof(dout));
265 MLX5_SET(destroy_qp_in, din, opcode, MLX5_CMD_OP_DESTROY_QP);
266 MLX5_SET(destroy_qp_in, din, qpn, qp->qpn);
267 MLX5_SET(destroy_qp_in, din, uid, qp->uid);
268 mlx5_cmd_exec(dev, din, sizeof(din), dout, sizeof(dout));
271 EXPORT_SYMBOL_GPL(mlx5_core_create_qp);
273 static int mlx5_core_drain_dct(struct mlx5_core_dev *dev,
274 struct mlx5_core_dct *dct)
276 u32 out[MLX5_ST_SZ_DW(drain_dct_out)] = {0};
277 u32 in[MLX5_ST_SZ_DW(drain_dct_in)] = {0};
278 struct mlx5_core_qp *qp = &dct->mqp;
280 MLX5_SET(drain_dct_in, in, opcode, MLX5_CMD_OP_DRAIN_DCT);
281 MLX5_SET(drain_dct_in, in, dctn, qp->qpn);
282 MLX5_SET(drain_dct_in, in, uid, qp->uid);
283 return mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
284 (void *)&out, sizeof(out));
287 int mlx5_core_destroy_dct(struct mlx5_core_dev *dev,
288 struct mlx5_core_dct *dct)
290 u32 out[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
291 u32 in[MLX5_ST_SZ_DW(destroy_dct_in)] = {0};
292 struct mlx5_core_qp *qp = &dct->mqp;
295 err = mlx5_core_drain_dct(dev, dct);
297 if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
300 mlx5_core_warn(dev, "failed drain DCT 0x%x with error 0x%x\n", qp->qpn, err);
304 wait_for_completion(&dct->drained);
306 destroy_resource_common(dev, &dct->mqp);
307 MLX5_SET(destroy_dct_in, in, opcode, MLX5_CMD_OP_DESTROY_DCT);
308 MLX5_SET(destroy_dct_in, in, dctn, qp->qpn);
309 MLX5_SET(destroy_dct_in, in, uid, qp->uid);
310 err = mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
311 (void *)&out, sizeof(out));
314 EXPORT_SYMBOL_GPL(mlx5_core_destroy_dct);
316 int mlx5_core_destroy_qp(struct mlx5_core_dev *dev,
317 struct mlx5_core_qp *qp)
319 u32 out[MLX5_ST_SZ_DW(destroy_qp_out)] = {0};
320 u32 in[MLX5_ST_SZ_DW(destroy_qp_in)] = {0};
323 mlx5_debug_qp_remove(dev, qp);
325 destroy_resource_common(dev, qp);
327 MLX5_SET(destroy_qp_in, in, opcode, MLX5_CMD_OP_DESTROY_QP);
328 MLX5_SET(destroy_qp_in, in, qpn, qp->qpn);
329 MLX5_SET(destroy_qp_in, in, uid, qp->uid);
330 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
334 atomic_dec(&dev->num_qps);
337 EXPORT_SYMBOL_GPL(mlx5_core_destroy_qp);
339 int mlx5_core_set_delay_drop(struct mlx5_core_dev *dev,
342 u32 out[MLX5_ST_SZ_DW(set_delay_drop_params_out)] = {0};
343 u32 in[MLX5_ST_SZ_DW(set_delay_drop_params_in)] = {0};
345 MLX5_SET(set_delay_drop_params_in, in, opcode,
346 MLX5_CMD_OP_SET_DELAY_DROP_PARAMS);
347 MLX5_SET(set_delay_drop_params_in, in, delay_drop_timeout,
349 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
351 EXPORT_SYMBOL_GPL(mlx5_core_set_delay_drop);
360 static int mbox_alloc(struct mbox_info *mbox, int inlen, int outlen)
363 mbox->outlen = outlen;
364 mbox->in = kzalloc(mbox->inlen, GFP_KERNEL);
365 mbox->out = kzalloc(mbox->outlen, GFP_KERNEL);
366 if (!mbox->in || !mbox->out) {
375 static void mbox_free(struct mbox_info *mbox)
381 static int modify_qp_mbox_alloc(struct mlx5_core_dev *dev, u16 opcode, int qpn,
382 u32 opt_param_mask, void *qpc,
383 struct mbox_info *mbox, u16 uid)
388 #define MBOX_ALLOC(mbox, typ) \
389 mbox_alloc(mbox, MLX5_ST_SZ_BYTES(typ##_in), MLX5_ST_SZ_BYTES(typ##_out))
391 #define MOD_QP_IN_SET(typ, in, _opcode, _qpn, _uid) \
393 MLX5_SET(typ##_in, in, opcode, _opcode); \
394 MLX5_SET(typ##_in, in, qpn, _qpn); \
395 MLX5_SET(typ##_in, in, uid, _uid); \
398 #define MOD_QP_IN_SET_QPC(typ, in, _opcode, _qpn, _opt_p, _qpc, _uid) \
400 MOD_QP_IN_SET(typ, in, _opcode, _qpn, _uid); \
401 MLX5_SET(typ##_in, in, opt_param_mask, _opt_p); \
402 memcpy(MLX5_ADDR_OF(typ##_in, in, qpc), _qpc, \
403 MLX5_ST_SZ_BYTES(qpc)); \
408 case MLX5_CMD_OP_2RST_QP:
409 if (MBOX_ALLOC(mbox, qp_2rst))
411 MOD_QP_IN_SET(qp_2rst, mbox->in, opcode, qpn, uid);
413 case MLX5_CMD_OP_2ERR_QP:
414 if (MBOX_ALLOC(mbox, qp_2err))
416 MOD_QP_IN_SET(qp_2err, mbox->in, opcode, qpn, uid);
419 /* MODIFY with QPC */
420 case MLX5_CMD_OP_RST2INIT_QP:
421 if (MBOX_ALLOC(mbox, rst2init_qp))
423 MOD_QP_IN_SET_QPC(rst2init_qp, mbox->in, opcode, qpn,
424 opt_param_mask, qpc, uid);
426 case MLX5_CMD_OP_INIT2RTR_QP:
427 if (MBOX_ALLOC(mbox, init2rtr_qp))
429 MOD_QP_IN_SET_QPC(init2rtr_qp, mbox->in, opcode, qpn,
430 opt_param_mask, qpc, uid);
432 case MLX5_CMD_OP_RTR2RTS_QP:
433 if (MBOX_ALLOC(mbox, rtr2rts_qp))
435 MOD_QP_IN_SET_QPC(rtr2rts_qp, mbox->in, opcode, qpn,
436 opt_param_mask, qpc, uid);
438 case MLX5_CMD_OP_RTS2RTS_QP:
439 if (MBOX_ALLOC(mbox, rts2rts_qp))
441 MOD_QP_IN_SET_QPC(rts2rts_qp, mbox->in, opcode, qpn,
442 opt_param_mask, qpc, uid);
444 case MLX5_CMD_OP_SQERR2RTS_QP:
445 if (MBOX_ALLOC(mbox, sqerr2rts_qp))
447 MOD_QP_IN_SET_QPC(sqerr2rts_qp, mbox->in, opcode, qpn,
448 opt_param_mask, qpc, uid);
450 case MLX5_CMD_OP_INIT2INIT_QP:
451 if (MBOX_ALLOC(mbox, init2init_qp))
453 MOD_QP_IN_SET_QPC(init2init_qp, mbox->in, opcode, qpn,
454 opt_param_mask, qpc, uid);
457 mlx5_core_err(dev, "Unknown transition for modify QP: OP(0x%x) QPN(0x%x)\n",
464 int mlx5_core_qp_modify(struct mlx5_core_dev *dev, u16 opcode,
465 u32 opt_param_mask, void *qpc,
466 struct mlx5_core_qp *qp)
468 struct mbox_info mbox;
471 err = modify_qp_mbox_alloc(dev, opcode, qp->qpn,
472 opt_param_mask, qpc, &mbox, qp->uid);
476 err = mlx5_cmd_exec(dev, mbox.in, mbox.inlen, mbox.out, mbox.outlen);
480 EXPORT_SYMBOL_GPL(mlx5_core_qp_modify);
482 void mlx5_init_qp_table(struct mlx5_core_dev *dev)
484 struct mlx5_qp_table *table = &dev->priv.qp_table;
486 memset(table, 0, sizeof(*table));
487 spin_lock_init(&table->lock);
488 INIT_RADIX_TREE(&table->tree, GFP_ATOMIC);
489 mlx5_qp_debugfs_init(dev);
492 void mlx5_cleanup_qp_table(struct mlx5_core_dev *dev)
494 mlx5_qp_debugfs_cleanup(dev);
497 int mlx5_core_qp_query(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp,
498 u32 *out, int outlen)
500 u32 in[MLX5_ST_SZ_DW(query_qp_in)] = {0};
502 MLX5_SET(query_qp_in, in, opcode, MLX5_CMD_OP_QUERY_QP);
503 MLX5_SET(query_qp_in, in, qpn, qp->qpn);
504 return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen);
506 EXPORT_SYMBOL_GPL(mlx5_core_qp_query);
508 int mlx5_core_dct_query(struct mlx5_core_dev *dev, struct mlx5_core_dct *dct,
509 u32 *out, int outlen)
511 u32 in[MLX5_ST_SZ_DW(query_dct_in)] = {0};
512 struct mlx5_core_qp *qp = &dct->mqp;
514 MLX5_SET(query_dct_in, in, opcode, MLX5_CMD_OP_QUERY_DCT);
515 MLX5_SET(query_dct_in, in, dctn, qp->qpn);
517 return mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
518 (void *)out, outlen);
520 EXPORT_SYMBOL_GPL(mlx5_core_dct_query);
522 int mlx5_core_xrcd_alloc(struct mlx5_core_dev *dev, u32 *xrcdn)
524 u32 out[MLX5_ST_SZ_DW(alloc_xrcd_out)] = {0};
525 u32 in[MLX5_ST_SZ_DW(alloc_xrcd_in)] = {0};
528 MLX5_SET(alloc_xrcd_in, in, opcode, MLX5_CMD_OP_ALLOC_XRCD);
529 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
531 *xrcdn = MLX5_GET(alloc_xrcd_out, out, xrcd);
534 EXPORT_SYMBOL_GPL(mlx5_core_xrcd_alloc);
536 int mlx5_core_xrcd_dealloc(struct mlx5_core_dev *dev, u32 xrcdn)
538 u32 out[MLX5_ST_SZ_DW(dealloc_xrcd_out)] = {0};
539 u32 in[MLX5_ST_SZ_DW(dealloc_xrcd_in)] = {0};
541 MLX5_SET(dealloc_xrcd_in, in, opcode, MLX5_CMD_OP_DEALLOC_XRCD);
542 MLX5_SET(dealloc_xrcd_in, in, xrcd, xrcdn);
543 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
545 EXPORT_SYMBOL_GPL(mlx5_core_xrcd_dealloc);
547 static void destroy_rq_tracked(struct mlx5_core_dev *dev, u32 rqn, u16 uid)
549 u32 in[MLX5_ST_SZ_DW(destroy_rq_in)] = {};
550 u32 out[MLX5_ST_SZ_DW(destroy_rq_out)] = {};
552 MLX5_SET(destroy_rq_in, in, opcode, MLX5_CMD_OP_DESTROY_RQ);
553 MLX5_SET(destroy_rq_in, in, rqn, rqn);
554 MLX5_SET(destroy_rq_in, in, uid, uid);
555 mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
558 int mlx5_core_create_rq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen,
559 struct mlx5_core_qp *rq)
564 err = mlx5_core_create_rq(dev, in, inlen, &rqn);
568 rq->uid = MLX5_GET(create_rq_in, in, uid);
570 err = create_resource_common(dev, rq, MLX5_RES_RQ);
577 destroy_rq_tracked(dev, rq->qpn, rq->uid);
581 EXPORT_SYMBOL(mlx5_core_create_rq_tracked);
583 void mlx5_core_destroy_rq_tracked(struct mlx5_core_dev *dev,
584 struct mlx5_core_qp *rq)
586 destroy_resource_common(dev, rq);
587 destroy_rq_tracked(dev, rq->qpn, rq->uid);
589 EXPORT_SYMBOL(mlx5_core_destroy_rq_tracked);
591 static void destroy_sq_tracked(struct mlx5_core_dev *dev, u32 sqn, u16 uid)
593 u32 in[MLX5_ST_SZ_DW(destroy_sq_in)] = {};
594 u32 out[MLX5_ST_SZ_DW(destroy_sq_out)] = {};
596 MLX5_SET(destroy_sq_in, in, opcode, MLX5_CMD_OP_DESTROY_SQ);
597 MLX5_SET(destroy_sq_in, in, sqn, sqn);
598 MLX5_SET(destroy_sq_in, in, uid, uid);
599 mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
602 int mlx5_core_create_sq_tracked(struct mlx5_core_dev *dev, u32 *in, int inlen,
603 struct mlx5_core_qp *sq)
608 err = mlx5_core_create_sq(dev, in, inlen, &sqn);
612 sq->uid = MLX5_GET(create_sq_in, in, uid);
614 err = create_resource_common(dev, sq, MLX5_RES_SQ);
621 destroy_sq_tracked(dev, sq->qpn, sq->uid);
625 EXPORT_SYMBOL(mlx5_core_create_sq_tracked);
627 void mlx5_core_destroy_sq_tracked(struct mlx5_core_dev *dev,
628 struct mlx5_core_qp *sq)
630 destroy_resource_common(dev, sq);
631 destroy_sq_tracked(dev, sq->qpn, sq->uid);
633 EXPORT_SYMBOL(mlx5_core_destroy_sq_tracked);
635 int mlx5_core_alloc_q_counter(struct mlx5_core_dev *dev, u16 *counter_id)
637 u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)] = {0};
638 u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)] = {0};
641 MLX5_SET(alloc_q_counter_in, in, opcode, MLX5_CMD_OP_ALLOC_Q_COUNTER);
642 err = mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
644 *counter_id = MLX5_GET(alloc_q_counter_out, out,
648 EXPORT_SYMBOL_GPL(mlx5_core_alloc_q_counter);
650 int mlx5_core_dealloc_q_counter(struct mlx5_core_dev *dev, u16 counter_id)
652 u32 in[MLX5_ST_SZ_DW(dealloc_q_counter_in)] = {0};
653 u32 out[MLX5_ST_SZ_DW(dealloc_q_counter_out)] = {0};
655 MLX5_SET(dealloc_q_counter_in, in, opcode,
656 MLX5_CMD_OP_DEALLOC_Q_COUNTER);
657 MLX5_SET(dealloc_q_counter_in, in, counter_set_id, counter_id);
658 return mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out));
660 EXPORT_SYMBOL_GPL(mlx5_core_dealloc_q_counter);
662 int mlx5_core_query_q_counter(struct mlx5_core_dev *dev, u16 counter_id,
663 int reset, void *out, int out_size)
665 u32 in[MLX5_ST_SZ_DW(query_q_counter_in)] = {0};
667 MLX5_SET(query_q_counter_in, in, opcode, MLX5_CMD_OP_QUERY_Q_COUNTER);
668 MLX5_SET(query_q_counter_in, in, clear, reset);
669 MLX5_SET(query_q_counter_in, in, counter_set_id, counter_id);
670 return mlx5_cmd_exec(dev, in, sizeof(in), out, out_size);
672 EXPORT_SYMBOL_GPL(mlx5_core_query_q_counter);