summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2019-04-15 03:39:28 +0000
committerdlg <dlg@openbsd.org>2019-04-15 03:39:28 +0000
commite2fee34b7eb588dad48d3e68e4fce97a3c13ee58 (patch)
treee6ca39c7a33cd03b855dd4683a403f63044d9cfc
parentUse literals as format strings. This fixes an error reported by clang. (diff)
downloadwireguard-openbsd-e2fee34b7eb588dad48d3e68e4fce97a3c13ee58.tar.xz
wireguard-openbsd-e2fee34b7eb588dad48d3e68e4fce97a3c13ee58.zip
follow the basic xfp support with basic qsfp+ support
qsfp was originally defined in SFF-8436, but the management interface now seems to be managed in SFF-8636, so this uses sff8636 as a prefix for qsfp things. the same spec applies to qsfp+ and probably qsfp28. XFP and QSFP share a bunch of offsets for where strings are located, so this factors out the printing of those strings from the xfp code and uses it from both the xfp and qsfp handling. i have a qsfp+ to 4x sfp+ cable that looks like this with the new code: transceiver: QSFP+ model: Amphenol 601110005 rev A serial: CN0HVVVFxxxxxxx date: 2013-04-18 if i ever get a pair of optics i can work on the diags
-rw-r--r--sbin/ifconfig/sff.c80
1 files changed, 51 insertions, 29 deletions
diff --git a/sbin/ifconfig/sff.c b/sbin/ifconfig/sff.c
index 62f7aa9648b..5d4cdababc7 100644
--- a/sbin/ifconfig/sff.c
+++ b/sbin/ifconfig/sff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sff.c,v 1.8 2019/04/15 03:12:50 dlg Exp $ */
+/* $OpenBSD: sff.c,v 1.9 2019/04/15 03:39:28 dlg Exp $ */
/*
* Copyright (c) 2019 David Gwynne <dlg@openbsd.org>
@@ -224,25 +224,33 @@ static const char *sff8024_con_names[] = {
#define SFF_POWER_FACTOR 10000.0
/*
+ * QSFP is defined by SFF-8436, but the management interface is
+ * updated and maintained by SFF-8636.
+ */
+
+/*
* XFP stuff is defined by INF-8077.
*
* The "Serial ID Memory Map" on page 1 contains the interesting strings
*/
-#define INF8077_VENDOR_START 148
-#define INF8077_VENDOR_END 163
-#define INF8077_PRODUCT_START 168
-#define INF8077_PRODUCT_END 183
-#define INF8077_REVISION_START 184
-#define INF8077_REVISION_END 185
-#define INF8077_SERIAL_START 196
-#define INF8077_SERIAL_END 211
-#define INF8077_DATECODE 212
-#define INF8077_LOT_START 218
-#define INF8077_LOT_END 219
+/* SFF-8636 and INF-8077 share a layout for various strings */
+
+#define UPPER_VENDOR_START 148
+#define UPPER_VENDOR_END 163
+#define UPPER_PRODUCT_START 168
+#define UPPER_PRODUCT_END 183
+#define UPPER_REVISION_START 184
+#define UPPER_REVISION_END 185
+#define UPPER_SERIAL_START 196
+#define UPPER_SERIAL_END 211
+#define UPPER_DATECODE 212
+#define UPPER_LOT_START 218
+#define UPPER_LOT_END 219
static void hexdump(const void *, size_t);
static int if_sff8472(int, const char *, int, const struct if_sffpage *);
+static int if_sff8636(int, const char *, int, const struct if_sffpage *);
static int if_inf8077(int, const char *, int, const struct if_sffpage *);
static const char *
@@ -347,6 +355,9 @@ if_sff_info(int s, const char *ifname, int dump)
}
error = if_inf8077(s, ifname, dump, &pg0);
break;
+ case SFF8024_ID_QSFP_PLUS:
+ error = if_sff8636(s, ifname, dump, &pg0);
+ break;
}
return (error);
@@ -569,28 +580,39 @@ if_sff8472(int s, const char *ifname, int dump, const struct if_sffpage *pg0)
return (0);
}
+static void
+if_upper_strings(const struct if_sffpage *pg)
+{
+ printf("\n\tmodel: ");
+ if_sff_ascii_print(pg, "",
+ UPPER_VENDOR_START, UPPER_VENDOR_END, " ");
+ if_sff_ascii_print(pg, "",
+ UPPER_PRODUCT_START, UPPER_PRODUCT_END, "");
+ if_sff_ascii_print(pg, " rev ",
+ UPPER_REVISION_START, UPPER_REVISION_END, "");
+
+ if_sff_ascii_print(pg, "\n\tserial: ",
+ UPPER_SERIAL_START, UPPER_SERIAL_END, " ");
+ if_sff_date_print(pg, "date: ", UPPER_DATECODE, " ");
+ if_sff_ascii_print(pg, "lot: ",
+ UPPER_LOT_START, UPPER_LOT_END, "");
+
+ putchar('\n');
+}
+
static int
if_inf8077(int s, const char *ifname, int dump, const struct if_sffpage *pg1)
{
- struct if_sffpage ddm;
- uint8_t con, ddm_types;
- int i;
+ if_upper_strings(pg1);
- printf("\n\tmodel: ");
- if_sff_ascii_print(pg1, "",
- INF8077_VENDOR_START, INF8077_VENDOR_END, " ");
- if_sff_ascii_print(pg1, "",
- INF8077_PRODUCT_START, INF8077_PRODUCT_END, "");
- if_sff_ascii_print(pg1, " rev ",
- INF8077_REVISION_START, INF8077_REVISION_END, "");
-
- if_sff_ascii_print(pg1, "\n\tserial: ",
- INF8077_SERIAL_START, INF8077_SERIAL_END, " ");
- if_sff_date_print(pg1, "date: ", INF8077_DATECODE, " ");
- if_sff_ascii_print(pg1, "lot: ",
- INF8077_LOT_START, INF8077_LOT_END, "");
+ return (0);
+}
+
+static int
+if_sff8636(int s, const char *ifname, int dump, const struct if_sffpage *pg0)
+{
+ if_upper_strings(pg0);
- putchar('\n');
return (0);
}