4848 * the saquery tool and provides it to other utilities.
4949 */
5050
51+ static struct ibmad_ports_pair * srcports ;
52+
5153struct sa_handle * sa_get_handle (char * ca_name )
5254{
5355 struct sa_handle * handle ;
@@ -57,7 +59,13 @@ struct sa_handle *sa_get_handle(char *ca_name)
5759
5860 char * name = ca_name ? ca_name : ibd_ca ;
5961
60- resolve_sm_portid (name , ibd_ca_port , & handle -> dport );
62+ int mgmt_classes [1 ] = { IB_SA_CLASS };
63+
64+ srcports = mad_rpc_open_port2 (name , ibd_ca_port , mgmt_classes , 1 , 0 );
65+ if (!srcports )
66+ IBEXIT ("Failed to open '%s' port '%d'" , name , ibd_ca_port );
67+
68+ resolve_sm_portid (srcports -> gsi .ca_name , ibd_ca_port , & handle -> dport );
6169 if (!handle -> dport .lid ) {
6270 IBWARN ("No SM/SA found on port %s:%d" ,
6371 name ? "" : name ,
@@ -69,20 +77,8 @@ struct sa_handle *sa_get_handle(char *ca_name)
6977 if (!handle -> dport .qkey )
7078 handle -> dport .qkey = IB_DEFAULT_QP1_QKEY ;
7179
72- handle -> fd = umad_open_port (name , ibd_ca_port );
73- if (handle -> fd < 0 ) {
74- IBWARN ("umad_open_port on port %s:%d failed" ,
75- name ? "" : name ,
76- ibd_ca_port );
77- goto err ;
78- }
79- if ((handle -> agent = umad_register (handle -> fd , IB_SA_CLASS , 2 , 1 , NULL )) < 0 ) {
80- umad_close_port (handle -> fd );
81- IBWARN ("umad_register for SA class failed on port %s:%d" ,
82- name ? "" : name ,
83- ibd_ca_port );
84- goto err ;
85- }
80+ handle -> fd = mad_rpc_portid (srcports -> gsi .port );
81+ handle -> agent = mad_rpc_class_agent (srcports -> gsi .port , IB_SA_CLASS );
8682
8783 return handle ;
8884
@@ -94,7 +90,7 @@ struct sa_handle *sa_get_handle(char *ca_name)
9490void sa_free_handle (struct sa_handle * h )
9591{
9692 umad_unregister (h -> fd , h -> agent );
97- umad_close_port ( h -> fd );
93+ mad_rpc_close_port2 ( srcports );
9894 free (h );
9995}
10096
0 commit comments