2 * Copyright (c) 2005 Cisco Systems. All rights reserved.
3 * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
5 * This software is available to you under a choice of one of two
6 * licenses. You may choose to be licensed under the terms of the GNU
7 * General Public License (GPL) Version 2, available from the file
8 * COPYING in the main directory of this source tree, or the
9 * OpenIB.org BSD license below:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
19 * - Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 #include <infiniband/endian.h>
44 #include <infiniband/verbs.h>
45 #include <infiniband/driver.h>
49 static int null_gid(union ibv_gid *gid)
51 return !(gid->raw[8] | gid->raw[9] | gid->raw[10] | gid->raw[11] |
52 gid->raw[12] | gid->raw[13] | gid->raw[14] | gid->raw[15]);
55 static const char *guid_str(__be64 _node_guid, char *str)
57 uint64_t node_guid = be64toh(_node_guid);
58 sprintf(str, "%04x:%04x:%04x:%04x",
59 (unsigned) (node_guid >> 48) & 0xffff,
60 (unsigned) (node_guid >> 32) & 0xffff,
61 (unsigned) (node_guid >> 16) & 0xffff,
62 (unsigned) (node_guid >> 0) & 0xffff);
66 static const char *transport_str(enum ibv_transport_type transport)
69 case IBV_TRANSPORT_IB: return "InfiniBand";
70 case IBV_TRANSPORT_IWARP: return "iWARP";
71 case IBV_TRANSPORT_USNIC: return "usNIC";
72 case IBV_TRANSPORT_USNIC_UDP: return "usNIC UDP";
73 default: return "invalid transport";
77 static const char *port_state_str(enum ibv_port_state pstate)
80 case IBV_PORT_DOWN: return "PORT_DOWN";
81 case IBV_PORT_INIT: return "PORT_INIT";
82 case IBV_PORT_ARMED: return "PORT_ARMED";
83 case IBV_PORT_ACTIVE: return "PORT_ACTIVE";
84 default: return "invalid state";
88 static const char *port_phy_state_str(uint8_t phys_state)
91 case 1: return "SLEEP";
92 case 2: return "POLLING";
93 case 3: return "DISABLED";
94 case 4: return "PORT_CONFIGURATION TRAINNING";
95 case 5: return "LINK_UP";
96 case 6: return "LINK_ERROR_RECOVERY";
97 case 7: return "PHY TEST";
98 default: return "invalid physical state";
102 static const char *atomic_cap_str(enum ibv_atomic_cap atom_cap)
105 case IBV_ATOMIC_NONE: return "ATOMIC_NONE";
106 case IBV_ATOMIC_HCA: return "ATOMIC_HCA";
107 case IBV_ATOMIC_GLOB: return "ATOMIC_GLOB";
108 default: return "invalid atomic capability";
112 static const char *mtu_str(enum ibv_mtu max_mtu)
115 case IBV_MTU_256: return "256";
116 case IBV_MTU_512: return "512";
117 case IBV_MTU_1024: return "1024";
118 case IBV_MTU_2048: return "2048";
119 case IBV_MTU_4096: return "4096";
120 default: return "invalid MTU";
124 static const char *width_str(uint8_t width)
131 default: return "invalid width";
135 static const char *speed_str(uint8_t speed)
138 case 1: return "2.5 Gbps";
139 case 2: return "5.0 Gbps";
141 case 4: /* fall through */
142 case 8: return "10.0 Gbps";
144 case 16: return "14.0 Gbps";
145 case 32: return "25.0 Gbps";
146 default: return "invalid speed";
150 static const char *vl_str(uint8_t vl_num)
158 default: return "invalid value";
162 static int print_all_port_gids(struct ibv_context *ctx, uint8_t port_num, int tbl_len)
168 for (i = 0; i < tbl_len; i++) {
169 rc = ibv_query_gid(ctx, port_num, i, &gid);
171 fprintf(stderr, "Failed to query gid to port %d, index %d\n",
176 printf("\t\t\tGID[%3d]:\t\t%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
178 gid.raw[ 0], gid.raw[ 1],
179 gid.raw[ 2], gid.raw[ 3],
180 gid.raw[ 4], gid.raw[ 5],
181 gid.raw[ 6], gid.raw[ 7],
182 gid.raw[ 8], gid.raw[ 9],
183 gid.raw[10], gid.raw[11],
184 gid.raw[12], gid.raw[13],
185 gid.raw[14], gid.raw[15]);
190 static const char *link_layer_str(uint8_t link_layer)
192 switch (link_layer) {
193 case IBV_LINK_LAYER_UNSPECIFIED:
194 case IBV_LINK_LAYER_INFINIBAND:
196 case IBV_LINK_LAYER_ETHERNET:
203 static void print_device_cap_flags(uint32_t dev_cap_flags)
205 uint32_t unknown_flags = ~(IBV_DEVICE_RESIZE_MAX_WR |
206 IBV_DEVICE_BAD_PKEY_CNTR |
207 IBV_DEVICE_BAD_QKEY_CNTR |
208 IBV_DEVICE_RAW_MULTI |
209 IBV_DEVICE_AUTO_PATH_MIG |
210 IBV_DEVICE_CHANGE_PHY_PORT |
211 IBV_DEVICE_UD_AV_PORT_ENFORCE |
212 IBV_DEVICE_CURR_QP_STATE_MOD |
213 IBV_DEVICE_SHUTDOWN_PORT |
214 IBV_DEVICE_INIT_TYPE |
215 IBV_DEVICE_PORT_ACTIVE_EVENT |
216 IBV_DEVICE_SYS_IMAGE_GUID |
217 IBV_DEVICE_RC_RNR_NAK_GEN |
218 IBV_DEVICE_SRQ_RESIZE |
219 IBV_DEVICE_N_NOTIFY_CQ |
220 IBV_DEVICE_MEM_WINDOW |
221 IBV_DEVICE_UD_IP_CSUM |
223 IBV_DEVICE_MEM_MGT_EXTENSIONS |
224 IBV_DEVICE_MEM_WINDOW_TYPE_2A |
225 IBV_DEVICE_MEM_WINDOW_TYPE_2B |
226 IBV_DEVICE_RC_IP_CSUM |
227 IBV_DEVICE_RAW_IP_CSUM |
228 IBV_DEVICE_MANAGED_FLOW_STEERING);
230 if (dev_cap_flags & IBV_DEVICE_RESIZE_MAX_WR)
231 printf("\t\t\t\t\tRESIZE_MAX_WR\n");
232 if (dev_cap_flags & IBV_DEVICE_BAD_PKEY_CNTR)
233 printf("\t\t\t\t\tBAD_PKEY_CNTR\n");
234 if (dev_cap_flags & IBV_DEVICE_BAD_QKEY_CNTR)
235 printf("\t\t\t\t\tBAD_QKEY_CNTR\n");
236 if (dev_cap_flags & IBV_DEVICE_RAW_MULTI)
237 printf("\t\t\t\t\tRAW_MULTI\n");
238 if (dev_cap_flags & IBV_DEVICE_AUTO_PATH_MIG)
239 printf("\t\t\t\t\tAUTO_PATH_MIG\n");
240 if (dev_cap_flags & IBV_DEVICE_CHANGE_PHY_PORT)
241 printf("\t\t\t\t\tCHANGE_PHY_PORT\n");
242 if (dev_cap_flags & IBV_DEVICE_UD_AV_PORT_ENFORCE)
243 printf("\t\t\t\t\tUD_AV_PORT_ENFORCE\n");
244 if (dev_cap_flags & IBV_DEVICE_CURR_QP_STATE_MOD)
245 printf("\t\t\t\t\tCURR_QP_STATE_MOD\n");
246 if (dev_cap_flags & IBV_DEVICE_SHUTDOWN_PORT)
247 printf("\t\t\t\t\tSHUTDOWN_PORT\n");
248 if (dev_cap_flags & IBV_DEVICE_INIT_TYPE)
249 printf("\t\t\t\t\tINIT_TYPE\n");
250 if (dev_cap_flags & IBV_DEVICE_PORT_ACTIVE_EVENT)
251 printf("\t\t\t\t\tPORT_ACTIVE_EVENT\n");
252 if (dev_cap_flags & IBV_DEVICE_SYS_IMAGE_GUID)
253 printf("\t\t\t\t\tSYS_IMAGE_GUID\n");
254 if (dev_cap_flags & IBV_DEVICE_RC_RNR_NAK_GEN)
255 printf("\t\t\t\t\tRC_RNR_NAK_GEN\n");
256 if (dev_cap_flags & IBV_DEVICE_SRQ_RESIZE)
257 printf("\t\t\t\t\tSRQ_RESIZE\n");
258 if (dev_cap_flags & IBV_DEVICE_N_NOTIFY_CQ)
259 printf("\t\t\t\t\tN_NOTIFY_CQ\n");
260 if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW)
261 printf("\t\t\t\t\tMEM_WINDOW\n");
262 if (dev_cap_flags & IBV_DEVICE_UD_IP_CSUM)
263 printf("\t\t\t\t\tUD_IP_CSUM\n");
264 if (dev_cap_flags & IBV_DEVICE_XRC)
265 printf("\t\t\t\t\tXRC\n");
266 if (dev_cap_flags & IBV_DEVICE_MEM_MGT_EXTENSIONS)
267 printf("\t\t\t\t\tMEM_MGT_EXTENSIONS\n");
268 if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW_TYPE_2A)
269 printf("\t\t\t\t\tMEM_WINDOW_TYPE_2A\n");
270 if (dev_cap_flags & IBV_DEVICE_MEM_WINDOW_TYPE_2B)
271 printf("\t\t\t\t\tMEM_WINDOW_TYPE_2B\n");
272 if (dev_cap_flags & IBV_DEVICE_RC_IP_CSUM)
273 printf("\t\t\t\t\tRC_IP_CSUM\n");
274 if (dev_cap_flags & IBV_DEVICE_RAW_IP_CSUM)
275 printf("\t\t\t\t\tRAW_IP_CSUM\n");
276 if (dev_cap_flags & IBV_DEVICE_MANAGED_FLOW_STEERING)
277 printf("\t\t\t\t\tMANAGED_FLOW_STEERING\n");
278 if (dev_cap_flags & unknown_flags)
279 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
280 dev_cap_flags & unknown_flags);
283 static void print_odp_trans_caps(uint32_t trans)
285 uint32_t unknown_transport_caps = ~(IBV_ODP_SUPPORT_SEND |
286 IBV_ODP_SUPPORT_RECV |
287 IBV_ODP_SUPPORT_WRITE |
288 IBV_ODP_SUPPORT_READ |
289 IBV_ODP_SUPPORT_ATOMIC);
292 printf("\t\t\t\t\tNO SUPPORT\n");
294 if (trans & IBV_ODP_SUPPORT_SEND)
295 printf("\t\t\t\t\tSUPPORT_SEND\n");
296 if (trans & IBV_ODP_SUPPORT_RECV)
297 printf("\t\t\t\t\tSUPPORT_RECV\n");
298 if (trans & IBV_ODP_SUPPORT_WRITE)
299 printf("\t\t\t\t\tSUPPORT_WRITE\n");
300 if (trans & IBV_ODP_SUPPORT_READ)
301 printf("\t\t\t\t\tSUPPORT_READ\n");
302 if (trans & IBV_ODP_SUPPORT_ATOMIC)
303 printf("\t\t\t\t\tSUPPORT_ATOMIC\n");
304 if (trans & unknown_transport_caps)
305 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
306 trans & unknown_transport_caps);
310 static void print_odp_caps(const struct ibv_odp_caps *caps)
312 uint64_t unknown_general_caps = ~(IBV_ODP_SUPPORT);
314 /* general odp caps */
315 printf("\tgeneral_odp_caps:\n");
316 if (caps->general_caps & IBV_ODP_SUPPORT)
317 printf("\t\t\t\t\tODP_SUPPORT\n");
318 if (caps->general_caps & unknown_general_caps)
319 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n",
320 caps->general_caps & unknown_general_caps);
323 printf("\trc_odp_caps:\n");
324 print_odp_trans_caps(caps->per_transport_caps.rc_odp_caps);
325 printf("\tuc_odp_caps:\n");
326 print_odp_trans_caps(caps->per_transport_caps.uc_odp_caps);
327 printf("\tud_odp_caps:\n");
328 print_odp_trans_caps(caps->per_transport_caps.ud_odp_caps);
331 static void print_device_cap_flags_ex(uint64_t device_cap_flags_ex)
333 uint64_t ex_flags = device_cap_flags_ex & 0xffffffff00000000ULL;
334 uint64_t unknown_flags = ~(IBV_DEVICE_RAW_SCATTER_FCS);
336 if (ex_flags & IBV_DEVICE_RAW_SCATTER_FCS)
337 printf("\t\t\t\t\tRAW_SCATTER_FCS\n");
338 if (ex_flags & unknown_flags)
339 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX64 "\n",
340 ex_flags & unknown_flags);
343 static void print_tso_caps(const struct ibv_tso_caps *caps)
345 uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET |
347 printf("\ttso_caps:\n");
348 printf("\tmax_tso:\t\t\t%d\n", caps->max_tso);
351 printf("\tsupported_qp:\n");
352 if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET))
353 printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n");
354 if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD))
355 printf("\t\t\t\t\tSUPPORT_UD\n");
356 if (caps->supported_qpts & unknown_general_caps)
357 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
358 caps->supported_qpts & unknown_general_caps);
362 static void print_rss_caps(const struct ibv_rss_caps *caps)
364 uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET |
366 printf("\trss_caps:\n");
367 printf("\t\tmax_rwq_indirection_tables:\t\t\t%u\n", caps->max_rwq_indirection_tables);
368 printf("\t\tmax_rwq_indirection_table_size:\t\t\t%u\n", caps->max_rwq_indirection_table_size);
369 printf("\t\trx_hash_function:\t\t\t\t0x%x\n", caps->rx_hash_function);
370 printf("\t\trx_hash_fields_mask:\t\t\t\t0x%" PRIX64 "\n", caps->rx_hash_fields_mask);
372 if (caps->supported_qpts) {
373 printf("\t\tsupported_qp:\n");
374 if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET))
375 printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n");
376 if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD))
377 printf("\t\t\t\t\tSUPPORT_UD\n");
378 if (caps->supported_qpts & unknown_general_caps)
379 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
380 caps->supported_qpts & unknown_general_caps);
384 static void print_packet_pacing_caps(const struct ibv_packet_pacing_caps *caps)
386 uint32_t unknown_general_caps = ~(1 << IBV_QPT_RAW_PACKET |
388 printf("\tpacket_pacing_caps:\n");
389 printf("\t\tqp_rate_limit_min:\t%ukbps\n", caps->qp_rate_limit_min);
390 printf("\t\tqp_rate_limit_max:\t%ukbps\n", caps->qp_rate_limit_max);
392 if (caps->qp_rate_limit_max) {
393 printf("\t\tsupported_qp:\n");
394 if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_RAW_PACKET))
395 printf("\t\t\t\t\tSUPPORT_RAW_PACKET\n");
396 if (ibv_is_qpt_supported(caps->supported_qpts, IBV_QPT_UD))
397 printf("\t\t\t\t\tSUPPORT_UD\n");
398 if (caps->supported_qpts & unknown_general_caps)
399 printf("\t\t\t\t\tUnknown flags: 0x%" PRIX32 "\n",
400 caps->supported_qpts & unknown_general_caps);
404 static void print_raw_packet_caps(uint32_t raw_packet_caps)
406 printf("\traw packet caps:\n");
407 if (raw_packet_caps & IBV_RAW_PACKET_CAP_CVLAN_STRIPPING)
408 printf("\t\t\t\t\tC-VLAN stripping offload\n");
409 if (raw_packet_caps & IBV_RAW_PACKET_CAP_SCATTER_FCS)
410 printf("\t\t\t\t\tScatter FCS offload\n");
411 if (raw_packet_caps & IBV_RAW_PACKET_CAP_IP_CSUM)
412 printf("\t\t\t\t\tIP csum offload\n");
415 static int print_hca_cap(struct ibv_device *ib_dev, uint8_t ib_port)
417 struct ibv_context *ctx;
418 struct ibv_device_attr_ex device_attr;
419 struct ibv_port_attr port_attr;
424 ctx = ibv_open_device(ib_dev);
426 fprintf(stderr, "Failed to open device\n");
430 if (ibv_query_device_ex(ctx, NULL, &device_attr)) {
431 fprintf(stderr, "Failed to query device props\n");
435 if (ib_port && ib_port > device_attr.orig_attr.phys_port_cnt) {
436 fprintf(stderr, "Invalid port requested for device\n");
437 /* rc = 3 is taken by failure to clean up */
442 printf("hca_id:\t%s\n", ibv_get_device_name(ib_dev));
443 printf("\ttransport:\t\t\t%s (%d)\n",
444 transport_str(ib_dev->transport_type), ib_dev->transport_type);
445 if (strlen(device_attr.orig_attr.fw_ver))
446 printf("\tfw_ver:\t\t\t\t%s\n", device_attr.orig_attr.fw_ver);
447 printf("\tnode_guid:\t\t\t%s\n", guid_str(device_attr.orig_attr.node_guid, buf));
448 printf("\tsys_image_guid:\t\t\t%s\n", guid_str(device_attr.orig_attr.sys_image_guid, buf));
449 printf("\tvendor_id:\t\t\t0x%04x\n", device_attr.orig_attr.vendor_id);
450 printf("\tvendor_part_id:\t\t\t%d\n", device_attr.orig_attr.vendor_part_id);
451 printf("\thw_ver:\t\t\t\t0x%X\n", device_attr.orig_attr.hw_ver);
453 if (ibv_read_sysfs_file(ib_dev->ibdev_path, "board_id", buf, sizeof buf) > 0)
454 printf("\tboard_id:\t\t\t%s\n", buf);
456 printf("\tphys_port_cnt:\t\t\t%d\n", device_attr.orig_attr.phys_port_cnt);
459 printf("\tmax_mr_size:\t\t\t0x%llx\n",
460 (unsigned long long) device_attr.orig_attr.max_mr_size);
461 printf("\tpage_size_cap:\t\t\t0x%llx\n",
462 (unsigned long long) device_attr.orig_attr.page_size_cap);
463 printf("\tmax_qp:\t\t\t\t%d\n", device_attr.orig_attr.max_qp);
464 printf("\tmax_qp_wr:\t\t\t%d\n", device_attr.orig_attr.max_qp_wr);
465 printf("\tdevice_cap_flags:\t\t0x%08x\n", device_attr.orig_attr.device_cap_flags);
466 print_device_cap_flags(device_attr.orig_attr.device_cap_flags);
467 printf("\tmax_sge:\t\t\t%d\n", device_attr.orig_attr.max_sge);
468 printf("\tmax_sge_rd:\t\t\t%d\n", device_attr.orig_attr.max_sge_rd);
469 printf("\tmax_cq:\t\t\t\t%d\n", device_attr.orig_attr.max_cq);
470 printf("\tmax_cqe:\t\t\t%d\n", device_attr.orig_attr.max_cqe);
471 printf("\tmax_mr:\t\t\t\t%d\n", device_attr.orig_attr.max_mr);
472 printf("\tmax_pd:\t\t\t\t%d\n", device_attr.orig_attr.max_pd);
473 printf("\tmax_qp_rd_atom:\t\t\t%d\n", device_attr.orig_attr.max_qp_rd_atom);
474 printf("\tmax_ee_rd_atom:\t\t\t%d\n", device_attr.orig_attr.max_ee_rd_atom);
475 printf("\tmax_res_rd_atom:\t\t%d\n", device_attr.orig_attr.max_res_rd_atom);
476 printf("\tmax_qp_init_rd_atom:\t\t%d\n", device_attr.orig_attr.max_qp_init_rd_atom);
477 printf("\tmax_ee_init_rd_atom:\t\t%d\n", device_attr.orig_attr.max_ee_init_rd_atom);
478 printf("\tatomic_cap:\t\t\t%s (%d)\n",
479 atomic_cap_str(device_attr.orig_attr.atomic_cap), device_attr.orig_attr.atomic_cap);
480 printf("\tmax_ee:\t\t\t\t%d\n", device_attr.orig_attr.max_ee);
481 printf("\tmax_rdd:\t\t\t%d\n", device_attr.orig_attr.max_rdd);
482 printf("\tmax_mw:\t\t\t\t%d\n", device_attr.orig_attr.max_mw);
483 printf("\tmax_raw_ipv6_qp:\t\t%d\n", device_attr.orig_attr.max_raw_ipv6_qp);
484 printf("\tmax_raw_ethy_qp:\t\t%d\n", device_attr.orig_attr.max_raw_ethy_qp);
485 printf("\tmax_mcast_grp:\t\t\t%d\n", device_attr.orig_attr.max_mcast_grp);
486 printf("\tmax_mcast_qp_attach:\t\t%d\n", device_attr.orig_attr.max_mcast_qp_attach);
487 printf("\tmax_total_mcast_qp_attach:\t%d\n",
488 device_attr.orig_attr.max_total_mcast_qp_attach);
489 printf("\tmax_ah:\t\t\t\t%d\n", device_attr.orig_attr.max_ah);
490 printf("\tmax_fmr:\t\t\t%d\n", device_attr.orig_attr.max_fmr);
491 if (device_attr.orig_attr.max_fmr)
492 printf("\tmax_map_per_fmr:\t\t%d\n", device_attr.orig_attr.max_map_per_fmr);
493 printf("\tmax_srq:\t\t\t%d\n", device_attr.orig_attr.max_srq);
494 if (device_attr.orig_attr.max_srq) {
495 printf("\tmax_srq_wr:\t\t\t%d\n", device_attr.orig_attr.max_srq_wr);
496 printf("\tmax_srq_sge:\t\t\t%d\n", device_attr.orig_attr.max_srq_sge);
498 printf("\tmax_pkeys:\t\t\t%d\n", device_attr.orig_attr.max_pkeys);
499 printf("\tlocal_ca_ack_delay:\t\t%d\n", device_attr.orig_attr.local_ca_ack_delay);
501 print_odp_caps(&device_attr.odp_caps);
502 if (device_attr.completion_timestamp_mask)
503 printf("\tcompletion timestamp_mask:\t\t\t0x%016" PRIx64 "\n",
504 device_attr.completion_timestamp_mask);
506 printf("\tcompletion_timestamp_mask not supported\n");
508 if (device_attr.hca_core_clock)
509 printf("\thca_core_clock:\t\t\t%" PRIu64 "kHZ\n", device_attr.hca_core_clock);
511 printf("\tcore clock not supported\n");
513 if (device_attr.raw_packet_caps)
514 print_raw_packet_caps(device_attr.raw_packet_caps);
516 printf("\tdevice_cap_flags_ex:\t\t0x%" PRIX64 "\n", device_attr.device_cap_flags_ex);
517 print_device_cap_flags_ex(device_attr.device_cap_flags_ex);
518 print_tso_caps(&device_attr.tso_caps);
519 print_rss_caps(&device_attr.rss_caps);
520 printf("\tmax_wq_type_rq:\t\t\t%u\n", device_attr.max_wq_type_rq);
521 print_packet_pacing_caps(&device_attr.packet_pacing_caps);
524 for (port = 1; port <= device_attr.orig_attr.phys_port_cnt; ++port) {
525 /* if in the command line the user didn't ask for info about this port */
526 if ((ib_port) && (port != ib_port))
529 rc = ibv_query_port(ctx, port, &port_attr);
531 fprintf(stderr, "Failed to query port %u props\n", port);
534 printf("\t\tport:\t%d\n", port);
535 printf("\t\t\tstate:\t\t\t%s (%d)\n",
536 port_state_str(port_attr.state), port_attr.state);
537 printf("\t\t\tmax_mtu:\t\t%s (%d)\n",
538 mtu_str(port_attr.max_mtu), port_attr.max_mtu);
539 printf("\t\t\tactive_mtu:\t\t%s (%d)\n",
540 mtu_str(port_attr.active_mtu), port_attr.active_mtu);
541 printf("\t\t\tsm_lid:\t\t\t%d\n", port_attr.sm_lid);
542 printf("\t\t\tport_lid:\t\t%d\n", port_attr.lid);
543 printf("\t\t\tport_lmc:\t\t0x%02x\n", port_attr.lmc);
544 printf("\t\t\tlink_layer:\t\t%s\n",
545 link_layer_str(port_attr.link_layer));
548 printf("\t\t\tmax_msg_sz:\t\t0x%x\n", port_attr.max_msg_sz);
549 printf("\t\t\tport_cap_flags:\t\t0x%08x\n", port_attr.port_cap_flags);
550 printf("\t\t\tmax_vl_num:\t\t%s (%d)\n",
551 vl_str(port_attr.max_vl_num), port_attr.max_vl_num);
552 printf("\t\t\tbad_pkey_cntr:\t\t0x%x\n", port_attr.bad_pkey_cntr);
553 printf("\t\t\tqkey_viol_cntr:\t\t0x%x\n", port_attr.qkey_viol_cntr);
554 printf("\t\t\tsm_sl:\t\t\t%d\n", port_attr.sm_sl);
555 printf("\t\t\tpkey_tbl_len:\t\t%d\n", port_attr.pkey_tbl_len);
556 printf("\t\t\tgid_tbl_len:\t\t%d\n", port_attr.gid_tbl_len);
557 printf("\t\t\tsubnet_timeout:\t\t%d\n", port_attr.subnet_timeout);
558 printf("\t\t\tinit_type_reply:\t%d\n", port_attr.init_type_reply);
559 printf("\t\t\tactive_width:\t\t%sX (%d)\n",
560 width_str(port_attr.active_width), port_attr.active_width);
561 printf("\t\t\tactive_speed:\t\t%s (%d)\n",
562 speed_str(port_attr.active_speed), port_attr.active_speed);
563 if (ib_dev->transport_type == IBV_TRANSPORT_IB)
564 printf("\t\t\tphys_state:\t\t%s (%d)\n",
565 port_phy_state_str(port_attr.phys_state), port_attr.phys_state);
567 if (print_all_port_gids(ctx, port, port_attr.gid_tbl_len))
574 if (ibv_close_device(ctx)) {
575 fprintf(stderr, "Failed to close device");
581 static void usage(const char *argv0)
583 printf("Usage: %s print the ca attributes\n", argv0);
585 printf("Options:\n");
586 printf(" -d, --ib-dev=<dev> use IB device <dev> (default first device found)\n");
587 printf(" -i, --ib-port=<port> use port <port> of IB device (default all ports)\n");
588 printf(" -l, --list print only the IB devices names\n");
589 printf(" -v, --verbose print all the attributes of the IB device(s)\n");
592 int main(int argc, char *argv[])
594 char *ib_devname = NULL;
596 struct ibv_device **dev_list, **orig_dev_list;
600 /* parse command line options */
603 static struct option long_options[] = {
604 { .name = "ib-dev", .has_arg = 1, .val = 'd' },
605 { .name = "ib-port", .has_arg = 1, .val = 'i' },
606 { .name = "list", .has_arg = 0, .val = 'l' },
607 { .name = "verbose", .has_arg = 0, .val = 'v' },
611 c = getopt_long(argc, argv, "d:i:lv", long_options, NULL);
617 ib_devname = strdup(optarg);
621 ib_port = strtol(optarg, NULL, 0);
633 dev_list = orig_dev_list = ibv_get_device_list(&num_of_hcas);
635 perror("Failed to get IB devices list");
639 printf("%d HCA%s found:\n", num_of_hcas,
640 num_of_hcas != 1 ? "s" : "");
643 printf("\t%s\n", ibv_get_device_name(*dev_list));
649 ibv_free_device_list(orig_dev_list);
659 dev_list = orig_dev_list = ibv_get_device_list(NULL);
661 perror("Failed to get IB devices list");
667 if (!strcmp(ibv_get_device_name(*dev_list), ib_devname))
673 fprintf(stderr, "IB device '%s' wasn't found\n", ib_devname);
677 ret |= print_hca_cap(*dev_list, ib_port);
680 fprintf(stderr, "No IB devices found\n");
685 ret |= print_hca_cap(*dev_list, ib_port);
693 ibv_free_device_list(orig_dev_list);