Page MenuHomeFreeBSD

D58263.diff
No OneTemporary

D58263.diff

diff --git a/lib/libifconfig/libifconfig_sfp.h b/lib/libifconfig/libifconfig_sfp.h
--- a/lib/libifconfig/libifconfig_sfp.h
+++ b/lib/libifconfig/libifconfig_sfp.h
@@ -85,10 +85,11 @@
#define CMIS_DUMP_SIZE 512 /**< CMIS dump buffer size */
#define CMIS_DUMP_P11 256 /**< offset of Page 11h in dump buffer */
+#define CMIS_DUMP_P10 384 /**< offset of Page 10h in dump buffer */
/** SFP module I2C memory dump
* SFP modules have one region, QSFP modules have two.
- * CMIS modules have three: lower memory, Page 00h, and Page 11h.
+ * CMIS modules have four: lower memory, Page 00h, Page 11h, and Page 10h.
*/
struct ifconfig_sfp_dump {
uint8_t data[CMIS_DUMP_SIZE]; /**< memory dump data */
diff --git a/lib/libifconfig/libifconfig_sfp.c b/lib/libifconfig/libifconfig_sfp.c
--- a/lib/libifconfig/libifconfig_sfp.c
+++ b/lib/libifconfig/libifconfig_sfp.c
@@ -238,6 +238,27 @@
return (ii->error);
}
+/* Count active host lanes (nonzero AppSelCode) in the Active Control Set. */
+static uint8_t
+get_cmis_active_lanes(struct i2c_info *ii)
+{
+ uint8_t dpconfig[CMIS_MAX_LANES];
+ uint8_t lanes;
+ int i;
+
+ lanes = 0;
+ read_i2c_page(ii, CMIS_BASE, 0x11, 0, CMIS_P11_ACS_DPCONFIG1,
+ sizeof(dpconfig), dpconfig);
+ if (ii->error != 0)
+ return (0);
+
+ for (i = 0; i < CMIS_MAX_LANES; i++) {
+ if ((dpconfig[i] & CMIS_ACS_APPSEL_MASK) != 0)
+ lanes++;
+ }
+ return (lanes);
+}
+
static int
get_cmis_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp)
{
@@ -287,8 +308,10 @@
break;
}
- /* Extract media lane count from app descriptor byte 2, bits 3:0 */
- sfp->sfp_cmis_lanes = app_desc[CMIS_APP_LANE_COUNT] & 0x0F;
+ /* Count active lanes; fall back to the descriptor's media lane count. */
+ sfp->sfp_cmis_lanes = get_cmis_active_lanes(ii);
+ if (sfp->sfp_cmis_lanes == 0)
+ sfp->sfp_cmis_lanes = app_desc[CMIS_APP_LANE_COUNT] & 0x0F;
return (ii->error);
}
@@ -657,15 +680,18 @@
if (ifconfig_sfp_id_is_cmis(ii.id)) {
/*
- * For CMIS, we need the lane count from the module info.
- * Read the first Application Descriptor to get it.
+ * Match the active-lane count reported by get_cmis_info();
+ * fall back to the first descriptor's media lane count.
*/
uint8_t app_desc[CMIS_APP_DESC_SIZE];
size_t channels;
- read_i2c(&ii, CMIS_BASE, CMIS_APP_DESC_START,
- CMIS_APP_DESC_SIZE, app_desc);
- channels = app_desc[CMIS_APP_LANE_COUNT] & 0x0F;
+ channels = get_cmis_active_lanes(&ii);
+ if (channels == 0) {
+ read_i2c(&ii, CMIS_BASE, CMIS_APP_DESC_START,
+ CMIS_APP_DESC_SIZE, app_desc);
+ channels = app_desc[CMIS_APP_LANE_COUNT] & 0x0F;
+ }
return (get_cmis_status(&ii, ss, channels));
}
@@ -779,12 +805,14 @@
return (-1);
if (ifconfig_sfp_id_is_cmis(ii.id)) {
- /* Lower memory (0-127), Page 00h (128-255), Page 11h */
+ /* Lower memory (0-127), Page 00h, Page 11h, Page 10h */
read_i2c(&ii, CMIS_BASE, 0, 128, buf);
read_i2c_page(&ii, CMIS_BASE, 0x00, 0, 128, 128,
buf + 128);
read_i2c_page(&ii, CMIS_BASE, 0x11, 0, 128, 128,
buf + CMIS_DUMP_P11);
+ read_i2c_page(&ii, CMIS_BASE, 0x10, 0, 128, 128,
+ buf + CMIS_DUMP_P10);
} else if (ifconfig_sfp_id_is_qsfp(ii.id)) {
read_i2c(&ii, SFF_8436_BASE, QSFP_DUMP0_START, QSFP_DUMP0_SIZE,
buf + QSFP_DUMP0_START);
@@ -804,7 +832,7 @@
uint8_t id_byte = dp->data[0];
if (ifconfig_sfp_id_is_cmis((enum sfp_id)id_byte))
- return (3);
+ return (4);
switch ((enum sfp_id)id_byte) {
case SFP_ID_UNKNOWN:
diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c
--- a/sbin/ifconfig/sfp.c
+++ b/sbin/ifconfig/sfp.c
@@ -122,6 +122,11 @@
printf("\n\tCMIS DUMP (Page 00h 128..255):\n");
hexdump(dump.data + 128, 128,
"\t", HD_OMIT_COUNT | HD_OMIT_CHARS);
+ if (verbose > 3) {
+ printf("\n\tCMIS DUMP (Page 10h 128..255):\n");
+ hexdump(dump.data + CMIS_DUMP_P10, 128,
+ "\t", HD_OMIT_COUNT | HD_OMIT_CHARS);
+ }
printf("\n\tCMIS DUMP (Page 11h 128..255):\n");
hexdump(dump.data + CMIS_DUMP_P11, 128,
"\t", HD_OMIT_COUNT | HD_OMIT_CHARS);

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 23, 8:14 PM (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35366772
Default Alt Text
D58263.diff (3 KB)

Event Timeline