Skip to content

Commit ee1eda0

Browse files
mazorasafnmorey
authored andcommitted
libibumad: allow choose port with state DOWN in case of explicit user port
[ Upstream commit 862aede ] Today libibumad rejects ports that are not ACTIVE during selection, which prevents users from targeting a specific port that is administratively DOWN. This change permits selecting a port in DOWN state when the user has explicitly specified the port and the device (e.g., by index/identifier). Automatic port selection behavior is unchanged and will continue to prefer only ACTIVE ports. Validation of the requested port’s existence and basic attributes remains intact. if user explicitly chose device name AND: - port number - port is 0 and device is switch - Only one port for device we skip the verification of port state. This is mainly done to suport opensm standalone feature Fixes: be54b52 ("libibumad: Add new API to support SMI/GSI seperation") Signed-off-by: Asaf Mazor <amazor@nvidia.com> Signed-off-by: Nicolas Morey <nmorey@suse.com>
1 parent 089d755 commit ee1eda0

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

libibumad/umad.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,12 +1568,22 @@ static int umad_find_active(struct umad_ca_pair *ca_pair, const umad_ca_t *ca, b
15681568
return 1;
15691569
}
15701570

1571-
static int find_preferred_ports(struct umad_ca_pair *ca_pair, const umad_ca_t *ca, bool is_gsi, int portnum)
1571+
static int find_preferred_ports(struct umad_ca_pair *ca_pair, const umad_ca_t *ca, bool is_gsi, int portnum, const char *name)
15721572
{
1573-
if (portnum) {
1573+
if (ca && ca->numports == 1) {
1574+
size_t i = 0;
1575+
for (i = 0; i < (size_t)ca->numports + 1; ++i) {
1576+
if (ca->ports[i]) {
1577+
portnum = ca->ports[i]->portnum;
1578+
break;
1579+
}
1580+
}
1581+
}
1582+
if (portnum || (portnum == 0 && ca && ca->node_type == 2)) {
15741583
//in case we have same device, use same port for smi/gsi
15751584
if (!strncmp(ca_pair->gsi_name, ca_pair->smi_name, UMAD_CA_NAME_LEN)) {
1576-
if (!umad_check_active(ca, portnum)) {
1585+
//in case of explicit portnum and device name, no need to check active device
1586+
if ((name) || !umad_check_active(ca, portnum)) {
15771587
ca_pair->gsi_preferred_port = portnum;
15781588
ca_pair->smi_preferred_port = portnum;
15791589
return 0;
@@ -1583,9 +1593,11 @@ static int find_preferred_ports(struct umad_ca_pair *ca_pair, const umad_ca_t *c
15831593
uint32_t *port_to_set = is_gsi ?
15841594
&ca_pair->gsi_preferred_port :
15851595
&ca_pair->smi_preferred_port;
1586-
if (!umad_check_active(ca, portnum)) {
1596+
if ((name) || !umad_check_active(ca, portnum)) {
15871597
*port_to_set = portnum;
1588-
return umad_find_active(ca_pair, ca, !is_gsi);
1598+
//if find active device falis, do not fail if user chose explicit device name and portnum
1599+
int rc = umad_find_active(ca_pair, ca, !is_gsi);
1600+
return name ? 0 : rc;
15891601
}
15901602
return 1;
15911603
}
@@ -1648,7 +1660,7 @@ int umad_get_smi_gsi_pair_by_ca_name(const char *name, uint8_t portnum, struct u
16481660

16491661
// fill candidate
16501662
*ca_pair = cas_pair[i];
1651-
rc = find_preferred_ports(ca_pair, &ca, is_gsi, portnum);
1663+
rc = find_preferred_ports(ca_pair, &ca, is_gsi, portnum, name);
16521664
umad_release_ca(&ca);
16531665

16541666
if (!rc)

0 commit comments

Comments
 (0)