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>
@@ -401,6 +403,8 @@ int main(int argc, char **argv)
401
403
uint32_t vendorid , rem_vendorid ;
402
404
uint16_t devid , rem_devid ;
403
405
uint64_t val ;
406
+ ext_umad_ca_t ext_ca = {};
407
+ bool is_planarized_fabric = false;
404
408
char * endp ;
405
409
char usage_args [] = "<dest dr_path|lid|guid> <portnum> [<op>]\n"
406
410
"\nSupported ops: enable, disable, on, off, reset, speed, espeed, fdr10,\n"
@@ -420,22 +424,48 @@ int main(int argc, char **argv)
420
424
ibdiag_process_opts (argc , argv , NULL , NULL , NULL , NULL ,
421
425
usage_args , usage_examples );
422
426
427
+ if (ext_umad_get_ca_by_name (ibd_ca , ibd_ca_port , & ext_ca ) < 0 )
428
+ IBEXIT ("Couldn't find the umad CA\n" );
429
+ if (!ext_ca .gsi .name [0 ] || !ext_ca .smi .name [0 ])
430
+ IBEXIT ("Invalid CA name found\n" );
431
+
432
+ if (strncmp (ext_ca .gsi .name , ext_ca .smi .name , UMAD_CA_NAME_LEN ))
433
+ is_planarized_fabric = true;
434
+
423
435
argc -= optind ;
424
436
argv += optind ;
425
437
426
438
if (argc < 2 )
427
439
ibdiag_show_usage ();
428
440
429
- srcport = mad_rpc_open_port (ibd_ca , ibd_ca_port , mgmt_classes , 3 );
441
+ // srcport should be the SMI port
442
+ srcport = mad_rpc_open_port (ext_ca .smi .name , ext_ca .smi .ports [0 ], mgmt_classes , 3 );
430
443
if (!srcport )
431
- IBEXIT ("Failed to open '%s' port '%d'" , ibd_ca , ibd_ca_port );
444
+ IBEXIT ("Failed to open '%s' port '%d'" , ext_ca . smi . name , ext_ca . smi . ports [ 0 ] );
432
445
433
446
smp_mkey_set (srcport , ibd_mkey );
434
447
435
- if (resolve_portid_str (ibd_ca , ibd_ca_port , & portid , argv [0 ],
436
- ibd_dest_type , ibd_sm_id , srcport ) < 0 )
448
+ if (resolve_portid_str (ext_ca . smi . name , ext_ca . smi . ports [ 0 ] , & portid , argv [0 ],
449
+ ibd_dest_type , ibd_sm_id , srcport ) < 0 )
437
450
IBEXIT ("can't resolve destination port %s" , argv [0 ]);
438
451
452
+ if (is_planarized_fabric && (ibd_dest_type != IB_DEST_DRPATH )) {
453
+ int rc = 0 ;
454
+ struct ibnd_config config = {};
455
+ config .mkey = ibd_mkey ;
456
+ config .timeout_ms = ibd_timeout ;
457
+
458
+ ibnd_fabric_t * fabric = ibnd_discover_fabric (ext_ca .smi .name , ext_ca .smi .ports [0 ], NULL , & config );
459
+ if (!fabric )
460
+ IBEXIT ("Discovery failed" );
461
+
462
+ rc = convert_portid_to_dr (fabric , & portid , ibd_dest_type );
463
+ ibnd_destroy_fabric (fabric );
464
+
465
+ if (rc < 0 )
466
+ IBEXIT ("Coultnd't convert destination port %s to direct route" , argv [0 ]);
467
+ }
468
+
439
469
if (argc > 1 )
440
470
portnum = strtol (argv [1 ], NULL , 0 );
441
471
0 commit comments