.. | .. |
---|
36 | 36 | #include <linux/mlx5/cq.h> |
---|
37 | 37 | #include <linux/mlx5/driver.h> |
---|
38 | 38 | #include "mlx5_core.h" |
---|
| 39 | +#include "lib/eq.h" |
---|
39 | 40 | |
---|
40 | 41 | enum { |
---|
41 | 42 | QP_PID, |
---|
.. | .. |
---|
91 | 92 | void mlx5_register_debugfs(void) |
---|
92 | 93 | { |
---|
93 | 94 | mlx5_debugfs_root = debugfs_create_dir("mlx5", NULL); |
---|
94 | | - if (IS_ERR_OR_NULL(mlx5_debugfs_root)) |
---|
95 | | - mlx5_debugfs_root = NULL; |
---|
96 | 95 | } |
---|
97 | 96 | |
---|
98 | 97 | void mlx5_unregister_debugfs(void) |
---|
.. | .. |
---|
100 | 99 | debugfs_remove(mlx5_debugfs_root); |
---|
101 | 100 | } |
---|
102 | 101 | |
---|
103 | | -int mlx5_qp_debugfs_init(struct mlx5_core_dev *dev) |
---|
| 102 | +void mlx5_qp_debugfs_init(struct mlx5_core_dev *dev) |
---|
104 | 103 | { |
---|
105 | | - if (!mlx5_debugfs_root) |
---|
106 | | - return 0; |
---|
107 | | - |
---|
108 | | - atomic_set(&dev->num_qps, 0); |
---|
109 | | - |
---|
110 | 104 | dev->priv.qp_debugfs = debugfs_create_dir("QPs", dev->priv.dbg_root); |
---|
111 | | - if (!dev->priv.qp_debugfs) |
---|
112 | | - return -ENOMEM; |
---|
113 | | - |
---|
114 | | - return 0; |
---|
115 | 105 | } |
---|
| 106 | +EXPORT_SYMBOL(mlx5_qp_debugfs_init); |
---|
116 | 107 | |
---|
117 | 108 | void mlx5_qp_debugfs_cleanup(struct mlx5_core_dev *dev) |
---|
118 | 109 | { |
---|
119 | | - if (!mlx5_debugfs_root) |
---|
120 | | - return; |
---|
121 | | - |
---|
122 | 110 | debugfs_remove_recursive(dev->priv.qp_debugfs); |
---|
123 | 111 | } |
---|
| 112 | +EXPORT_SYMBOL(mlx5_qp_debugfs_cleanup); |
---|
124 | 113 | |
---|
125 | | -int mlx5_eq_debugfs_init(struct mlx5_core_dev *dev) |
---|
| 114 | +void mlx5_eq_debugfs_init(struct mlx5_core_dev *dev) |
---|
126 | 115 | { |
---|
127 | | - if (!mlx5_debugfs_root) |
---|
128 | | - return 0; |
---|
129 | | - |
---|
130 | 116 | dev->priv.eq_debugfs = debugfs_create_dir("EQs", dev->priv.dbg_root); |
---|
131 | | - if (!dev->priv.eq_debugfs) |
---|
132 | | - return -ENOMEM; |
---|
133 | | - |
---|
134 | | - return 0; |
---|
135 | 117 | } |
---|
136 | 118 | |
---|
137 | 119 | void mlx5_eq_debugfs_cleanup(struct mlx5_core_dev *dev) |
---|
138 | 120 | { |
---|
139 | | - if (!mlx5_debugfs_root) |
---|
140 | | - return; |
---|
141 | | - |
---|
142 | 121 | debugfs_remove_recursive(dev->priv.eq_debugfs); |
---|
143 | 122 | } |
---|
144 | 123 | |
---|
.. | .. |
---|
182 | 161 | .write = average_write, |
---|
183 | 162 | }; |
---|
184 | 163 | |
---|
185 | | -int mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev) |
---|
| 164 | +void mlx5_cmdif_debugfs_init(struct mlx5_core_dev *dev) |
---|
186 | 165 | { |
---|
187 | 166 | struct mlx5_cmd_stats *stats; |
---|
188 | 167 | struct dentry **cmd; |
---|
189 | 168 | const char *namep; |
---|
190 | | - int err; |
---|
191 | 169 | int i; |
---|
192 | | - |
---|
193 | | - if (!mlx5_debugfs_root) |
---|
194 | | - return 0; |
---|
195 | 170 | |
---|
196 | 171 | cmd = &dev->priv.cmdif_debugfs; |
---|
197 | 172 | *cmd = debugfs_create_dir("commands", dev->priv.dbg_root); |
---|
198 | | - if (!*cmd) |
---|
199 | | - return -ENOMEM; |
---|
200 | 173 | |
---|
201 | | - for (i = 0; i < ARRAY_SIZE(dev->cmd.stats); i++) { |
---|
| 174 | + for (i = 0; i < MLX5_CMD_OP_MAX; i++) { |
---|
202 | 175 | stats = &dev->cmd.stats[i]; |
---|
203 | 176 | namep = mlx5_command_str(i); |
---|
204 | 177 | if (strcmp(namep, "unknown command opcode")) { |
---|
205 | 178 | stats->root = debugfs_create_dir(namep, *cmd); |
---|
206 | | - if (!stats->root) { |
---|
207 | | - mlx5_core_warn(dev, "failed adding command %d\n", |
---|
208 | | - i); |
---|
209 | | - err = -ENOMEM; |
---|
210 | | - goto out; |
---|
211 | | - } |
---|
212 | 179 | |
---|
213 | | - stats->avg = debugfs_create_file("average", 0400, |
---|
214 | | - stats->root, stats, |
---|
215 | | - &stats_fops); |
---|
216 | | - if (!stats->avg) { |
---|
217 | | - mlx5_core_warn(dev, "failed creating debugfs file\n"); |
---|
218 | | - err = -ENOMEM; |
---|
219 | | - goto out; |
---|
220 | | - } |
---|
221 | | - |
---|
222 | | - stats->count = debugfs_create_u64("n", 0400, |
---|
223 | | - stats->root, |
---|
224 | | - &stats->n); |
---|
225 | | - if (!stats->count) { |
---|
226 | | - mlx5_core_warn(dev, "failed creating debugfs file\n"); |
---|
227 | | - err = -ENOMEM; |
---|
228 | | - goto out; |
---|
229 | | - } |
---|
| 180 | + debugfs_create_file("average", 0400, stats->root, stats, |
---|
| 181 | + &stats_fops); |
---|
| 182 | + debugfs_create_u64("n", 0400, stats->root, &stats->n); |
---|
230 | 183 | } |
---|
231 | 184 | } |
---|
232 | | - |
---|
233 | | - return 0; |
---|
234 | | -out: |
---|
235 | | - debugfs_remove_recursive(dev->priv.cmdif_debugfs); |
---|
236 | | - return err; |
---|
237 | 185 | } |
---|
238 | 186 | |
---|
239 | 187 | void mlx5_cmdif_debugfs_cleanup(struct mlx5_core_dev *dev) |
---|
240 | 188 | { |
---|
241 | | - if (!mlx5_debugfs_root) |
---|
242 | | - return; |
---|
243 | | - |
---|
244 | 189 | debugfs_remove_recursive(dev->priv.cmdif_debugfs); |
---|
245 | 190 | } |
---|
246 | 191 | |
---|
247 | | -int mlx5_cq_debugfs_init(struct mlx5_core_dev *dev) |
---|
| 192 | +void mlx5_cq_debugfs_init(struct mlx5_core_dev *dev) |
---|
248 | 193 | { |
---|
249 | | - if (!mlx5_debugfs_root) |
---|
250 | | - return 0; |
---|
251 | | - |
---|
252 | 194 | dev->priv.cq_debugfs = debugfs_create_dir("CQs", dev->priv.dbg_root); |
---|
253 | | - if (!dev->priv.cq_debugfs) |
---|
254 | | - return -ENOMEM; |
---|
255 | | - |
---|
256 | | - return 0; |
---|
257 | 195 | } |
---|
258 | 196 | |
---|
259 | 197 | void mlx5_cq_debugfs_cleanup(struct mlx5_core_dev *dev) |
---|
260 | 198 | { |
---|
261 | | - if (!mlx5_debugfs_root) |
---|
262 | | - return; |
---|
263 | | - |
---|
264 | 199 | debugfs_remove_recursive(dev->priv.cq_debugfs); |
---|
265 | 200 | } |
---|
266 | 201 | |
---|
.. | .. |
---|
268 | 203 | int index, int *is_str) |
---|
269 | 204 | { |
---|
270 | 205 | int outlen = MLX5_ST_SZ_BYTES(query_qp_out); |
---|
271 | | - struct mlx5_qp_context *ctx; |
---|
| 206 | + u32 in[MLX5_ST_SZ_DW(query_qp_in)] = {}; |
---|
272 | 207 | u64 param = 0; |
---|
273 | 208 | u32 *out; |
---|
| 209 | + int state; |
---|
| 210 | + u32 *qpc; |
---|
274 | 211 | int err; |
---|
275 | | - int no_sq; |
---|
276 | 212 | |
---|
277 | 213 | out = kzalloc(outlen, GFP_KERNEL); |
---|
278 | 214 | if (!out) |
---|
279 | | - return param; |
---|
| 215 | + return 0; |
---|
280 | 216 | |
---|
281 | | - err = mlx5_core_qp_query(dev, qp, out, outlen); |
---|
282 | | - if (err) { |
---|
283 | | - mlx5_core_warn(dev, "failed to query qp err=%d\n", err); |
---|
| 217 | + MLX5_SET(query_qp_in, in, opcode, MLX5_CMD_OP_QUERY_QP); |
---|
| 218 | + MLX5_SET(query_qp_in, in, qpn, qp->qpn); |
---|
| 219 | + err = mlx5_cmd_exec_inout(dev, query_qp, in, out); |
---|
| 220 | + if (err) |
---|
284 | 221 | goto out; |
---|
285 | | - } |
---|
286 | 222 | |
---|
287 | 223 | *is_str = 0; |
---|
288 | 224 | |
---|
289 | | - /* FIXME: use MLX5_GET rather than mlx5_qp_context manual struct */ |
---|
290 | | - ctx = (struct mlx5_qp_context *)MLX5_ADDR_OF(query_qp_out, out, qpc); |
---|
291 | | - |
---|
| 225 | + qpc = MLX5_ADDR_OF(query_qp_out, out, qpc); |
---|
292 | 226 | switch (index) { |
---|
293 | 227 | case QP_PID: |
---|
294 | 228 | param = qp->pid; |
---|
295 | 229 | break; |
---|
296 | 230 | case QP_STATE: |
---|
297 | | - param = (unsigned long)mlx5_qp_state_str(be32_to_cpu(ctx->flags) >> 28); |
---|
| 231 | + state = MLX5_GET(qpc, qpc, state); |
---|
| 232 | + param = (unsigned long)mlx5_qp_state_str(state); |
---|
298 | 233 | *is_str = 1; |
---|
299 | 234 | break; |
---|
300 | 235 | case QP_XPORT: |
---|
301 | | - param = (unsigned long)mlx5_qp_type_str((be32_to_cpu(ctx->flags) >> 16) & 0xff); |
---|
| 236 | + param = (unsigned long)mlx5_qp_type_str(MLX5_GET(qpc, qpc, st)); |
---|
302 | 237 | *is_str = 1; |
---|
303 | 238 | break; |
---|
304 | 239 | case QP_MTU: |
---|
305 | | - switch (ctx->mtu_msgmax >> 5) { |
---|
| 240 | + switch (MLX5_GET(qpc, qpc, mtu)) { |
---|
306 | 241 | case IB_MTU_256: |
---|
307 | 242 | param = 256; |
---|
308 | 243 | break; |
---|
.. | .. |
---|
323 | 258 | } |
---|
324 | 259 | break; |
---|
325 | 260 | case QP_N_RECV: |
---|
326 | | - param = 1 << ((ctx->rq_size_stride >> 3) & 0xf); |
---|
| 261 | + param = 1 << MLX5_GET(qpc, qpc, log_rq_size); |
---|
327 | 262 | break; |
---|
328 | 263 | case QP_RECV_SZ: |
---|
329 | | - param = 1 << ((ctx->rq_size_stride & 7) + 4); |
---|
| 264 | + param = 1 << (MLX5_GET(qpc, qpc, log_rq_stride) + 4); |
---|
330 | 265 | break; |
---|
331 | 266 | case QP_N_SEND: |
---|
332 | | - no_sq = be16_to_cpu(ctx->sq_crq_size) >> 15; |
---|
333 | | - if (!no_sq) |
---|
334 | | - param = 1 << (be16_to_cpu(ctx->sq_crq_size) >> 11); |
---|
335 | | - else |
---|
336 | | - param = 0; |
---|
| 267 | + if (!MLX5_GET(qpc, qpc, no_sq)) |
---|
| 268 | + param = 1 << MLX5_GET(qpc, qpc, log_sq_size); |
---|
337 | 269 | break; |
---|
338 | 270 | case QP_LOG_PG_SZ: |
---|
339 | | - param = (be32_to_cpu(ctx->log_pg_sz_remote_qpn) >> 24) & 0x1f; |
---|
340 | | - param += 12; |
---|
| 271 | + param = MLX5_GET(qpc, qpc, log_page_size) + 12; |
---|
341 | 272 | break; |
---|
342 | 273 | case QP_RQPN: |
---|
343 | | - param = be32_to_cpu(ctx->log_pg_sz_remote_qpn) & 0xffffff; |
---|
| 274 | + param = MLX5_GET(qpc, qpc, remote_qpn); |
---|
344 | 275 | break; |
---|
345 | 276 | } |
---|
346 | | - |
---|
347 | 277 | out: |
---|
348 | 278 | kfree(out); |
---|
349 | 279 | return param; |
---|
.. | .. |
---|
353 | 283 | int index) |
---|
354 | 284 | { |
---|
355 | 285 | int outlen = MLX5_ST_SZ_BYTES(query_eq_out); |
---|
| 286 | + u32 in[MLX5_ST_SZ_DW(query_eq_in)] = {}; |
---|
356 | 287 | u64 param = 0; |
---|
357 | 288 | void *ctx; |
---|
358 | 289 | u32 *out; |
---|
.. | .. |
---|
362 | 293 | if (!out) |
---|
363 | 294 | return param; |
---|
364 | 295 | |
---|
365 | | - err = mlx5_core_eq_query(dev, eq, out, outlen); |
---|
| 296 | + MLX5_SET(query_eq_in, in, opcode, MLX5_CMD_OP_QUERY_EQ); |
---|
| 297 | + MLX5_SET(query_eq_in, in, eq_number, eq->eqn); |
---|
| 298 | + err = mlx5_cmd_exec_inout(dev, query_eq, in, out); |
---|
366 | 299 | if (err) { |
---|
367 | 300 | mlx5_core_warn(dev, "failed to query eq\n"); |
---|
368 | 301 | goto out; |
---|
.. | .. |
---|
399 | 332 | if (!out) |
---|
400 | 333 | return param; |
---|
401 | 334 | |
---|
402 | | - err = mlx5_core_query_cq(dev, cq, out, outlen); |
---|
| 335 | + err = mlx5_core_query_cq(dev, cq, out); |
---|
403 | 336 | if (err) { |
---|
404 | 337 | mlx5_core_warn(dev, "failed to query cq\n"); |
---|
405 | 338 | goto out; |
---|
.. | .. |
---|
473 | 406 | { |
---|
474 | 407 | struct mlx5_rsc_debug *d; |
---|
475 | 408 | char resn[32]; |
---|
476 | | - int err; |
---|
477 | 409 | int i; |
---|
478 | 410 | |
---|
479 | 411 | d = kzalloc(struct_size(d, fields, nfile), GFP_KERNEL); |
---|
.. | .. |
---|
485 | 417 | d->type = type; |
---|
486 | 418 | sprintf(resn, "0x%x", rsn); |
---|
487 | 419 | d->root = debugfs_create_dir(resn, root); |
---|
488 | | - if (!d->root) { |
---|
489 | | - err = -ENOMEM; |
---|
490 | | - goto out_free; |
---|
491 | | - } |
---|
492 | 420 | |
---|
493 | 421 | for (i = 0; i < nfile; i++) { |
---|
494 | 422 | d->fields[i].i = i; |
---|
495 | | - d->fields[i].dent = debugfs_create_file(field[i], 0400, |
---|
496 | | - d->root, &d->fields[i], |
---|
497 | | - &fops); |
---|
498 | | - if (!d->fields[i].dent) { |
---|
499 | | - err = -ENOMEM; |
---|
500 | | - goto out_rem; |
---|
501 | | - } |
---|
| 423 | + debugfs_create_file(field[i], 0400, d->root, &d->fields[i], |
---|
| 424 | + &fops); |
---|
502 | 425 | } |
---|
503 | 426 | *dbg = d; |
---|
504 | 427 | |
---|
505 | 428 | return 0; |
---|
506 | | -out_rem: |
---|
507 | | - debugfs_remove_recursive(d->root); |
---|
508 | | - |
---|
509 | | -out_free: |
---|
510 | | - kfree(d); |
---|
511 | | - return err; |
---|
512 | 429 | } |
---|
513 | 430 | |
---|
514 | 431 | static void rem_res_tree(struct mlx5_rsc_debug *d) |
---|
.. | .. |
---|
532 | 449 | |
---|
533 | 450 | return err; |
---|
534 | 451 | } |
---|
| 452 | +EXPORT_SYMBOL(mlx5_debug_qp_add); |
---|
535 | 453 | |
---|
536 | 454 | void mlx5_debug_qp_remove(struct mlx5_core_dev *dev, struct mlx5_core_qp *qp) |
---|
537 | 455 | { |
---|
.. | .. |
---|
541 | 459 | if (qp->dbg) |
---|
542 | 460 | rem_res_tree(qp->dbg); |
---|
543 | 461 | } |
---|
| 462 | +EXPORT_SYMBOL(mlx5_debug_qp_remove); |
---|
544 | 463 | |
---|
545 | 464 | int mlx5_debug_eq_add(struct mlx5_core_dev *dev, struct mlx5_eq *eq) |
---|
546 | 465 | { |
---|
.. | .. |
---|
588 | 507 | if (!mlx5_debugfs_root) |
---|
589 | 508 | return; |
---|
590 | 509 | |
---|
591 | | - if (cq->dbg) |
---|
| 510 | + if (cq->dbg) { |
---|
592 | 511 | rem_res_tree(cq->dbg); |
---|
| 512 | + cq->dbg = NULL; |
---|
| 513 | + } |
---|
593 | 514 | } |
---|