@@ -777,6 +777,19 @@ static unsigned int get_max(unsigned int num)
777
777
return (1 << r );
778
778
}
779
779
780
+ static uint8_t * get_port_info_for_cap_mask (ibnd_port_t * port )
781
+ {
782
+ uint8_t * info = NULL ;
783
+
784
+ if (port -> node -> type == IB_NODE_SWITCH ) {
785
+ if (port -> node -> ports [0 ])
786
+ info = (uint8_t * )& port -> node -> ports [0 ]-> info ;
787
+ } else
788
+ info = (uint8_t * )& port -> info ;
789
+
790
+ return info ;
791
+ }
792
+
780
793
void get_max_msg (char * width_msg , char * speed_msg , int msg_size , ibnd_port_t * port )
781
794
{
782
795
char buf [64 ];
@@ -797,24 +810,14 @@ void get_max_msg(char *width_msg, char *speed_msg, int msg_size, ibnd_port_t * p
797
810
mad_dump_val (IB_PORT_LINK_WIDTH_ACTIVE_F ,
798
811
buf , 64 , & max_width ));
799
812
800
- if (port -> node -> type == IB_NODE_SWITCH ) {
801
- if (port -> node -> ports [0 ])
802
- info = (uint8_t * )& port -> node -> ports [0 ]-> info ;
803
- }
804
- else
805
- info = (uint8_t * )& port -> info ;
813
+ info = get_port_info_for_cap_mask (port );
806
814
807
815
if (info )
808
816
cap_mask = mad_get_field (info , 0 , IB_PORT_CAPMASK_F );
809
817
else
810
818
cap_mask = 0 ;
811
819
812
- info = NULL ;
813
- if (port -> remoteport -> node -> type == IB_NODE_SWITCH ) {
814
- if (port -> remoteport -> node -> ports [0 ])
815
- info = (uint8_t * )& port -> remoteport -> node -> ports [0 ]-> info ;
816
- } else
817
- info = (uint8_t * )& port -> remoteport -> info ;
820
+ info = get_port_info_for_cap_mask (port -> remoteport );
818
821
819
822
if (info )
820
823
rem_cap_mask = mad_get_field (info , 0 , IB_PORT_CAPMASK_F );
@@ -845,15 +848,15 @@ void get_max_msg(char *width_msg, char *speed_msg, int msg_size, ibnd_port_t * p
845
848
return ;
846
849
847
850
check_ext_speed :
848
- espeed = ibnd_get_agg_linkspeedextsup (port -> info , port -> info );
849
- e2speed = ibnd_get_agg_linkspeedextsup (port -> remoteport -> info ,
851
+ espeed = ibnd_get_agg_linkspeedextsup (get_port_info_for_cap_mask ( port ) , port -> info );
852
+ e2speed = ibnd_get_agg_linkspeedextsup (get_port_info_for_cap_mask ( port -> remoteport ) ,
850
853
port -> remoteport -> info );
851
854
852
855
if (!espeed || !e2speed )
853
856
goto check_fdr10_supp ;
854
857
855
858
max_speed = get_max (espeed & e2speed );
856
- espeed = ibnd_get_agg_linkspeedext (port -> info , port -> info );
859
+ espeed = ibnd_get_agg_linkspeedext (get_port_info_for_cap_mask ( port ) , port -> info );
857
860
858
861
if ((max_speed & espeed ) == 0 )
859
862
// we are not at the max supported extended speed
0 commit comments