33
33
*
34
34
*/
35
35
36
+ #include "infiniband/ibnetdisc.h"
36
37
#include <stdio.h>
37
38
#include <stdlib.h>
39
+ #include <stdbool.h>
38
40
#include <unistd.h>
39
41
#include <string.h>
40
42
#include <errno.h>
@@ -436,6 +438,8 @@ int main(int argc, char **argv)
436
438
uint32_t vendorid , rem_vendorid ;
437
439
uint16_t devid , rem_devid ;
438
440
uint64_t val ;
441
+ ext_umad_ca_t ext_ca = {};
442
+ bool is_planarized_fabric = false;
439
443
char * endp ;
440
444
char usage_args [] = "<dest dr_path|lid|guid> <portnum> [<op>]\n"
441
445
"\nSupported ops: enable, disable, on, off, reset, speed, espeed, fdr10,\n"
@@ -455,22 +459,51 @@ int main(int argc, char **argv)
455
459
ibdiag_process_opts (argc , argv , NULL , NULL , NULL , NULL ,
456
460
usage_args , usage_examples );
457
461
462
+ if (ibnd_ext_umad_get_ca_by_name (ibd_ca , ibd_ca_port , & ext_ca ) < 0 )
463
+ IBEXIT ("Couldn't find the umad CA\n" );
464
+ if (!ext_ca .gsi .name [0 ] || !ext_ca .smi .name [0 ])
465
+ IBEXIT ("Invalid CA name found\n" );
466
+
467
+ if (strncmp (ext_ca .gsi .name , ext_ca .smi .name , UMAD_CA_NAME_LEN ))
468
+ is_planarized_fabric = true;
469
+
458
470
argc -= optind ;
459
471
argv += optind ;
460
472
461
473
if (argc < 2 )
462
474
ibdiag_show_usage ();
463
475
464
- srcport = mad_rpc_open_port (ibd_ca , ibd_ca_port , mgmt_classes , 3 );
476
+ // srcport should be the SMI port
477
+ srcport = mad_rpc_open_port (ext_ca .smi .name , ext_ca .smi .ports [0 ], mgmt_classes , 3 );
465
478
if (!srcport )
466
- IBEXIT ("Failed to open '%s' port '%d'" , ibd_ca , ibd_ca_port );
479
+ IBEXIT ("Failed to open '%s' port '%d'" , ext_ca . smi . name , ext_ca . smi . ports [ 0 ] );
467
480
468
481
smp_mkey_set (srcport , ibd_mkey );
469
482
470
- if (resolve_portid_str (ibd_ca , ibd_ca_port , & portid , argv [0 ],
471
- ibd_dest_type , ibd_sm_id , srcport ) < 0 )
483
+ if (resolve_portid_str (ext_ca . smi . name , ext_ca . smi . ports [ 0 ] , & portid , argv [0 ],
484
+ ibd_dest_type , ibd_sm_id , srcport ) < 0 )
472
485
IBEXIT ("can't resolve destination port %s" , argv [0 ]);
473
486
487
+ if (is_planarized_fabric && (ibd_dest_type != IB_DEST_DRPATH )) {
488
+ int rc = 0 ;
489
+ struct ibnd_config config = {};
490
+
491
+ config .mkey = ibd_mkey ;
492
+ config .timeout_ms = ibd_timeout ;
493
+
494
+ ibnd_fabric_t * fabric = ibnd_discover_fabric (ext_ca .smi .name ,
495
+ ext_ca .smi .ports [0 ], NULL , & config );
496
+
497
+ if (!fabric )
498
+ IBEXIT ("Discovery failed" );
499
+
500
+ rc = ibnd_convert_portid_to_dr (fabric , & portid , ibd_dest_type );
501
+ ibnd_destroy_fabric (fabric );
502
+
503
+ if (rc < 0 )
504
+ IBEXIT ("Coultnd't convert destination port %s to direct route" , argv [0 ]);
505
+ }
506
+
474
507
if (argc > 1 )
475
508
portnum = strtol (argv [1 ], NULL , 0 );
476
509
0 commit comments