Skip to contentSkip to conversation

ibccquery.c: Account for enhanced switch port 0 in SwitchPortCongestionSetting handling

PATCH Applied Hal Rosenstock 2 participants 2 messages Jan 9, 2015 – Jan 10, 2015 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ibccquery.c: Account for enhanced switch port 0 in SwitchPortCongestionSetting handling

Enhanced switch port 0 can support CC (indicated in CC ClassPortInfo:CapabilityMask.EnhancedPort0CC).

portnum 0 is a valid port number and offsets should be calculated based on port 0 rather than port 1.

Also, fix some error messages to indicate switch port congestion setting rather then switch congestion setting failure.

---

src/ibccquery.c +7 -7
index ac8bca2..39e45b7 100644
@@ -224,11 +224,11 @@ static char *switch_port_congestion_setting(ib_portid_t * dest, char **argv, int
 
 		memset(data, '\0', sizeof data);
 		if (!cc_query_status_via(data, dest, IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
-					 (portnum - 1) / 32, 0, NULL, srcport, cckey))
-			return "switch congestion setting query failed";
+					 portnum / 32, 0, NULL, srcport, cckey))
+			return "switch port congestion setting query failed";
 
 		mad_dump_cc_switchportcongestionsettingelement(buf, sizeof buf,
-							       data + (((portnum % 32) - 1) * 4),
+							       data + ((portnum % 32) * 4),
 							       4);
 		printf("%s", buf);
 		return NULL;
@@ -236,16 +236,16 @@ static char *switch_port_congestion_setting(ib_portid_t * dest, char **argv, int
 
 	/* else get all port info */
 
-	maxblocks = ((numports - 1) / 32) + 1;
+	maxblocks = numports / 32 + 1;
 
 	for (i = 0; i < maxblocks; i++) {
 		memset(data, '\0', sizeof data);
 		if (!cc_query_status_via(data, dest, IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
 					 i, 0, NULL, srcport, cckey))
-			return "switch congestion setting query failed";
+			return "switch port congestion setting query failed";
 
-		for (j = 0; j < 32 && outputcount < numports; j++) {
-			printf("Port:............................%u\n", i * 32 + j + 1);
+		for (j = 0; j < 32 && outputcount <= numports; j++) {
+			printf("Port:............................%u\n", i * 32 + j);
 			mad_dump_cc_switchportcongestionsettingelement(buf, sizeof buf,
 								       data + j * 4,
 								       4);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 54AFF10A.4050806-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org

Applied
#2 lore raw
Quoted 11 lines

Enhanced switch port 0 can support CC (indicated in CC ClassPortInfo:CapabilityMask.EnhancedPort0CC).

portnum 0 is a valid port number and offsets should be calculated based on port 0 rather than port 1.

Also, fix some error messages to indicate switch port congestion setting rather then switch congestion setting failure.

Thanks applied.
Ira

Quoted 47 lines

---

src/ibccquery.c +2 -2
@@ -224,11 +224,11 @@ static char
 *switch_port_congestion_setting(ib_portid_t * dest, char **argv, int
 
 		memset(data, '\0', sizeof data);
 		if (!cc_query_status_via(data, dest,
 IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
-					 (portnum - 1) / 32, 0, NULL, srcport,
 cckey))
-			return "switch congestion setting query failed";
+					 portnum / 32, 0, NULL, srcport,
 cckey))
+			return "switch port congestion setting query failed";
 
 		mad_dump_cc_switchportcongestionsettingelement(buf, sizeof

buf,

src/ibccquery.c +0 -1
-							       data + (((portnum

% 32) - 1) * 4),

src/ibccquery.c +1 -0
+							       data + ((portnum

% 32) * 4),

src/ibccquery.c +4 -4
 							       4);
 		printf("%s", buf);
 		return NULL;
@@ -236,16 +236,16 @@ static char
 *switch_port_congestion_setting(ib_portid_t * dest, char **argv, int
 
 	/* else get all port info */
 
-	maxblocks = ((numports - 1) / 32) + 1;
+	maxblocks = numports / 32 + 1;
 
 	for (i = 0; i < maxblocks; i++) {
 		memset(data, '\0', sizeof data);
 		if (!cc_query_status_via(data, dest,
 IB_CC_ATTR_SWITCH_PORT_CONGESTION_SETTING,
 					 i, 0, NULL, srcport, cckey))
-			return "switch congestion setting query failed";
+			return "switch port congestion setting query failed";
 
-		for (j = 0; j < 32 && outputcount < numports; j++) {
-			printf("Port:............................%u\n", i * 32 + j + 1);
+		for (j = 0; j < 32 && outputcount <= numports; j++) {
+			printf("Port:............................%u\n", i * 32 + j);
 
Quoted 4 lines

mad_dump_cc_switchportcongestionsettingelement(buf, sizeof buf,
data + j *
4,
4);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html