summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authormelifaro <melifaro@FreeBSD.org>2014-09-03 11:07:49 +0000
committermelifaro <melifaro@FreeBSD.org>2014-09-03 11:07:49 +0000
commit0db31aaac8ab5f9b7244729e0724f343e89157d7 (patch)
tree8385a7685ffd843e6b1849f47dc82ee12749c244 /sbin/ifconfig
parent36347a8fa2f0a90d4a8402965ac14f80ef80d36d (diff)
downloadFreeBSD-src-0db31aaac8ab5f9b7244729e0724f343e89157d7.zip
FreeBSD-src-0db31aaac8ab5f9b7244729e0724f343e89157d7.tar.gz
* Unconditionally turn on SIOCGI2C probing for all interfaces
on "ifconfig -v". I've seen no measurable timing difference for doing additional SIOCGI2C call for system with 4k vlans. * Determine appropriate handler (SFP/QSFP) by reading identification byte (which is the same for both SFF-8472 and SFF-8436) instead of checking driver name. MFC with: r270064 Sponsored by: Yandex LLC
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/sfp.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c
index d85d4d8..2e8039d 100644
--- a/sbin/ifconfig/sfp.c
+++ b/sbin/ifconfig/sfp.c
@@ -753,25 +753,31 @@ void
sfp_status(int s, struct ifreq *ifr, int verbose)
{
struct i2c_info ii;
+ uint8_t id_byte;
memset(&ii, 0, sizeof(ii));
/* Prepare necessary into to pass to NIC handler */
ii.s = s;
ii.ifr = ifr;
+ ii.f = read_i2c_generic;
/*
- * Check if we have i2c support for particular driver.
- * TODO: Determine driver by original name.
+ * Try to read byte 0 from i2c:
+ * Both SFF-8472 and SFF-8436 use it as
+ * 'identification byte'
*/
- if (strncmp(ifr->ifr_name, "ix", 2) == 0) {
- ii.f = read_i2c_generic;
- print_sfp_status(&ii, verbose);
- } else if (strncmp(ifr->ifr_name, "cxl", 3) == 0) {
- ii.port_id = atoi(&ifr->ifr_name[3]);
- ii.f = read_i2c_generic;
- ii.cfd = -1;
- print_qsfp_status(&ii, verbose);
- } else
+ id_byte = 0;
+ ii.f(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte);
+ if (ii.error != 0)
return;
+
+ switch (id_byte) {
+ case SFF_8024_ID_QSFP:
+ case SFF_8024_ID_QSFPPLUS:
+ print_qsfp_status(&ii, verbose);
+ break;
+ default:
+ print_sfp_status(&ii, verbose);
+ };
}
OpenPOWER on IntegriCloud