Skip to content

Commit f874524

Browse files
committed
ibportstate: Support XDR speeds decoding
Adding using new aggregation values of LinkSpeedExt & LinkSpeedExt2 mechaism Signed-off-by: Gregory Linschitz <gregoryl@nvidia.com>
1 parent 6cedcca commit f874524

File tree

1 file changed

+55
-25
lines changed

1 file changed

+55
-25
lines changed

infiniband-diags/ibportstate.c

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static int get_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
138138
{
139139
uint8_t smp[IB_SMP_DATA_SIZE];
140140
uint8_t *info;
141-
int cap_mask;
141+
int cap_mask, cap_mask2;
142142

143143
if (is_switch) {
144144
if (!smp_query_via(smp, dest, IB_ATTR_PORT_INFO, 0, 0, srcport))
@@ -149,8 +149,19 @@ static int get_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
149149

150150
if (!smp_query_via(data, dest, IB_ATTR_PORT_INFO, portnum, 0, srcport))
151151
IBEXIT("smp query portinfo failed");
152+
152153
cap_mask = mad_get_field(info, 0, IB_PORT_CAPMASK_F);
153-
return (cap_mask & be32toh(IB_PORT_CAP_HAS_EXT_SPEEDS));
154+
155+
if (cap_mask & be32toh(IB_PORT_CAP_HAS_CAP_MASK2)) {
156+
cap_mask2 =
157+
(mad_get_field(info, 0, IB_PORT_CAPMASK2_F)
158+
& be16toh(IB_PORT_CAP2_IS_EXT_SPEEDS_2_SUPPORTED)) ?
159+
0x02 : 0x00;
160+
} else
161+
cap_mask2 = 0;
162+
163+
return cap_mask2
164+
| ((cap_mask & be32toh(IB_PORT_CAP_HAS_EXT_SPEEDS)) ? 0x01 : 0x00);
154165
}
155166

156167
static void show_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
@@ -196,7 +207,7 @@ static void show_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
196207
mad_dump_field(IB_PORT_LINK_SPEED_ACTIVE_F, buf + strlen(buf),
197208
sizeof buf - strlen(buf), val);
198209
sprintf(buf + strlen(buf), "%s", "\n");
199-
if (espeed_cap) {
210+
if (espeed_cap & 0x01) {
200211
mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_SUPPORTED_F, val);
201212
mad_dump_field(IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
202213
buf + strlen(buf), sizeof buf - strlen(buf),
@@ -213,6 +224,23 @@ static void show_port_info(ib_portid_t * dest, uint8_t * data, int portnum,
213224
val);
214225
sprintf(buf + strlen(buf), "%s", "\n");
215226
}
227+
if (espeed_cap & 0x02) {
228+
mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_SUPPORTED_2_F, val);
229+
mad_dump_field(IB_PORT_LINK_SPEED_EXT_SUPPORTED_2_F,
230+
buf + strlen(buf), sizeof(buf) - strlen(buf),
231+
val);
232+
sprintf(buf + strlen(buf), "%s", "\n");
233+
mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ENABLED_2_F, val);
234+
mad_dump_field(IB_PORT_LINK_SPEED_EXT_ENABLED_2_F,
235+
buf + strlen(buf), sizeof(buf) - strlen(buf),
236+
val);
237+
sprintf(buf + strlen(buf), "%s", "\n");
238+
mad_decode_field(data, IB_PORT_LINK_SPEED_EXT_ACTIVE_2_F, val);
239+
mad_dump_field(IB_PORT_LINK_SPEED_EXT_ACTIVE_2_F,
240+
buf + strlen(buf), sizeof(buf) - strlen(buf),
241+
val);
242+
sprintf(buf + strlen(buf), "%s", "\n");
243+
}
216244
if (!is_switch || portnum == 0) {
217245
if (show_keys) {
218246
mad_decode_field(data, IB_PORT_MKEY_F, val);
@@ -295,6 +323,9 @@ static int get_link_speed(int lse, int lss)
295323

296324
static int get_link_speed_ext(int lsee, int lses)
297325
{
326+
if (lsee & 0x20)
327+
return lsee;
328+
298329
if (lsee == 31)
299330
return lses;
300331
else
@@ -353,8 +384,12 @@ static void validate_speed(int peerspeed, int lsa)
353384

354385
static void validate_extended_speed(int peerespeed, int lsea)
355386
{
356-
357-
if ((espeed & peerespeed & 0x8)) {
387+
if ((espeed & peerespeed & 0x20)) {
388+
if (lsea != 32)
389+
IBWARN
390+
("Peer ports operating at active extended speed %d rather than 32 (212.5 Gbps)",
391+
lsea);
392+
} else if ((espeed & peerespeed & 0x8)) {
358393
if (lsea != 8)
359394
IBWARN
360395
("Peer ports operating at active extended speed %d rather than 8 (106.25 Gbps)",
@@ -387,7 +422,7 @@ int main(int argc, char **argv)
387422
int state, physstate, lwe, lws, lwa, lse, lss, lsa, lsee, lses, lsea,
388423
fdr10s, fdr10e, fdr10a;
389424
int peerlocalportnum, peerlwe, peerlws, peerlwa, peerlse, peerlss,
390-
peerlsa, peerlsee, peerlses, peerlsea, peerfdr10s, peerfdr10e,
425+
peerlsa, peerlsee, peerlses, peerfdr10s, peerfdr10e,
391426
peerfdr10a;
392427
int peerwidth, peerspeed, peerespeed;
393428
uint8_t data[IB_SMP_DATA_SIZE] = { 0 };
@@ -606,7 +641,8 @@ int main(int argc, char **argv)
606641

607642
/* always set enabled speeds/width - defaults to NOP */
608643
mad_set_field(data, 0, IB_PORT_LINK_SPEED_ENABLED_F, speed);
609-
mad_set_field(data, 0, IB_PORT_LINK_SPEED_EXT_ENABLED_F, espeed);
644+
mad_set_field(data, 0, IB_PORT_LINK_SPEED_EXT_ENABLED_F, espeed & 0x1f);
645+
mad_set_field(data, 0, IB_PORT_LINK_SPEED_EXT_ENABLED_2_F, espeed >> 5);
610646
mad_set_field(data, 0, IB_PORT_LINK_WIDTH_ENABLED_F, width);
611647

612648
if (port_args[VLS].set)
@@ -669,15 +705,13 @@ int main(int argc, char **argv)
669705
IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F,
670706
&fdr10a);
671707
if (espeed_cap) {
672-
mad_decode_field(data,
673-
IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
674-
&lses);
675-
mad_decode_field(data,
676-
IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
677-
&lsea);
678-
mad_decode_field(data,
679-
IB_PORT_LINK_SPEED_EXT_ENABLED_F,
680-
&lsee);
708+
lsea = ibnd_get_agg_linkspeedext(data, data);
709+
lsee = ibnd_get_agg_linkspeedexten(data, data);
710+
lses = ibnd_get_agg_linkspeedextsup(data, data);
711+
} else {
712+
lsea = 0;
713+
lsee = 0;
714+
lses = 0;
681715
}
682716

683717
/* Setup portid for peer port */
@@ -743,15 +777,11 @@ int main(int argc, char **argv)
743777
IB_MLNX_EXT_PORT_LINK_SPEED_ACTIVE_F,
744778
&peerfdr10a);
745779
if (peer_espeed_cap) {
746-
mad_decode_field(data,
747-
IB_PORT_LINK_SPEED_EXT_SUPPORTED_F,
748-
&peerlses);
749-
mad_decode_field(data,
750-
IB_PORT_LINK_SPEED_EXT_ACTIVE_F,
751-
&peerlsea);
752-
mad_decode_field(data,
753-
IB_PORT_LINK_SPEED_EXT_ENABLED_F,
754-
&peerlsee);
780+
peerlsee = ibnd_get_agg_linkspeedexten(data, data);
781+
peerlses = ibnd_get_agg_linkspeedextsup(data, data);
782+
} else {
783+
peerlsee = 0;
784+
peerlses = 0;
755785
}
756786

757787
/* Now validate peer port characteristics */

0 commit comments

Comments
 (0)