diff options
author | gjb <gjb@FreeBSD.org> | 2016-04-04 23:55:32 +0000 |
---|---|---|
committer | gjb <gjb@FreeBSD.org> | 2016-04-04 23:55:32 +0000 |
commit | 1dc4c40e3b35564cb2e787ad968e6b4a9fb7eb0f (patch) | |
tree | a027fe5a27446f32854d6a07b34b5f2a992bf283 /sbin/ifconfig | |
parent | 3669a0dced7e344be71d234ffc3a71530ef0ae08 (diff) | |
parent | 589cedfe0cde2b49d5f47fc240de37c8bf307abd (diff) | |
download | FreeBSD-src-1dc4c40e3b35564cb2e787ad968e6b4a9fb7eb0f.zip FreeBSD-src-1dc4c40e3b35564cb2e787ad968e6b4a9fb7eb0f.tar.gz |
MFH
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r-- | sbin/ifconfig/ifieee80211.c | 95 | ||||
-rw-r--r-- | sbin/ifconfig/sfp.c | 28 |
2 files changed, 97 insertions, 26 deletions
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c index 5ababf3..84daec9 100644 --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -2534,6 +2534,45 @@ printwmeinfo(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) } static void +printvhtcap(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ + printf("%s", tag); + if (verbose) { + const struct ieee80211_ie_vhtcap *vhtcap = + (const struct ieee80211_ie_vhtcap *) ie; + uint32_t vhtcap_info = LE_READ_4(&vhtcap->vht_cap_info); + + printf("<cap 0x%08x", vhtcap_info); + printf(" rx_mcs_map 0x%x", + LE_READ_2(&vhtcap->supp_mcs.rx_mcs_map)); + printf(" rx_highest %d", + LE_READ_2(&vhtcap->supp_mcs.rx_highest) & 0x1fff); + printf(" tx_mcs_map 0x%x", + LE_READ_2(&vhtcap->supp_mcs.tx_mcs_map)); + printf(" tx_highest %d", + LE_READ_2(&vhtcap->supp_mcs.tx_highest) & 0x1fff); + + printf(">"); + } +} + +static void +printvhtinfo(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ + printf("%s", tag); + if (verbose) { + const struct ieee80211_ie_vht_operation *vhtinfo = + (const struct ieee80211_ie_vht_operation *) ie; + + printf("<chw %d freq1_idx %d freq2_idx %d basic_mcs_set 0x%04x>", + vhtinfo->chan_width, + vhtinfo->center_freq_seg1_idx, + vhtinfo->center_freq_seg2_idx, + LE_READ_2(&vhtinfo->basic_mcs_set)); + } +} + +static void printhtcap(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) { printf("%s", tag); @@ -2674,6 +2713,40 @@ do { \ #undef MATCHOUI } +static void +printbssload(const char *tag, const uint8_t *ie, size_t ielen, int maxlen) +{ + printf("%s", tag); + if (verbose) { + const struct ieee80211_bss_load_ie *bssload = + (const struct ieee80211_bss_load_ie *) ie; + printf("<sta count %d, chan load %d, aac %d>", + LE_READ_2(&bssload->sta_count), + bssload->chan_load, + bssload->aac); + } +} + +static void +printapchanrep(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) +{ + printf("%s", tag); + if (verbose) { + const struct ieee80211_ap_chan_report_ie *ap = + (const struct ieee80211_ap_chan_report_ie *) ie; + const char *sep = ""; + int i; + + printf("<class %u, chan:[", ap->i_class); + + for (i = 3; i < ielen; i++) { + printf("%s%u", sep, ie[i]); + sep = ","; + } + printf("]>"); + } +} + static const char * wpa_cipher(const u_int8_t *sel) { @@ -3018,14 +3091,6 @@ printcountry(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) printf(">"); } -/* unaligned little endian access */ -#define LE_READ_4(p) \ - ((u_int32_t) \ - ((((const u_int8_t *)(p))[0] ) | \ - (((const u_int8_t *)(p))[1] << 8) | \ - (((const u_int8_t *)(p))[2] << 16) | \ - (((const u_int8_t *)(p))[3] << 24))) - static __inline int iswpaoui(const u_int8_t *frm) { @@ -3084,9 +3149,9 @@ iename(int elemid) case IEEE80211_ELEMID_MEASREP: return " MEASREP"; case IEEE80211_ELEMID_QUIET: return " QUIET"; case IEEE80211_ELEMID_IBSSDFS: return " IBSSDFS"; - case IEEE80211_ELEMID_APCHANREP:return " APCHANREP"; case IEEE80211_ELEMID_TPC: return " TPC"; case IEEE80211_ELEMID_CCKM: return " CCKM"; + case IEEE80211_ELEMID_VHT_PWR_ENV: return " VHTPWRENV"; } return " ???"; } @@ -3151,6 +3216,18 @@ printies(const u_int8_t *vp, int ielen, int maxcols) case IEEE80211_ELEMID_MESHCONF: printmeshconf(" MESHCONF", vp, 2+vp[1], maxcols); break; + case IEEE80211_ELEMID_VHT_CAP: + printvhtcap(" VHTCAP", vp, 2+vp[1], maxcols); + break; + case IEEE80211_ELEMID_VHT_OPMODE: + printvhtinfo(" VHTOPMODE", vp, 2+vp[1], maxcols); + break; + case IEEE80211_ELEMID_BSSLOAD: + printbssload(" BSSLOAD", vp, 2+vp[1], maxcols); + break; + case IEEE80211_ELEMID_APCHANREP: + printapchanrep(" APCHANREP", vp, 2+vp[1], maxcols); + break; default: if (verbose) printie(iename(vp[0]), vp, 2+vp[1], maxcols); diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c index 306140a..d92ee2c 100644 --- a/sbin/ifconfig/sfp.c +++ b/sbin/ifconfig/sfp.c @@ -625,14 +625,17 @@ get_sfp_voltage(struct i2c_info *ii, char *buf, size_t size) convert_sff_voltage(buf, size, xbuf); } -static void +static int get_qsfp_temp(struct i2c_info *ii, char *buf, size_t size) { uint8_t xbuf[2]; memset(xbuf, 0, sizeof(xbuf)); read_i2c(ii, SFF_8436_BASE, SFF_8436_TEMP, 2, xbuf); + if ((xbuf[0] == 0xFF && xbuf[1] == 0xFF) || (xbuf[0] == 0 && xbuf[1] == 0)) + return (-1); convert_sff_temp(buf, size, xbuf); + return (0); } static void @@ -779,22 +782,9 @@ static void print_qsfp_status(struct i2c_info *ii, int verbose) { char buf[80], buf2[40], buf3[40]; - uint8_t diag_type; uint32_t bitrate; int i; - /* Read diagnostic monitoring type */ - read_i2c(ii, SFF_8436_BASE, SFF_8436_DIAG_TYPE, 1, (caddr_t)&diag_type); - if (ii->error != 0) - return; - - /* - * Read monitoring data it is supplied. - * XXX: It is not exactly clear from standard - * how one can specify lack of measurements (passive cables case). - */ - if (diag_type != 0) - ii->do_diag = 1; ii->qsfp = 1; /* Transceiver type */ @@ -817,9 +807,13 @@ print_qsfp_status(struct i2c_info *ii, int verbose) printf("\tnominal bitrate: %u Mbps\n", bitrate); } - /* Request current measurements if they are provided: */ - if (ii->do_diag != 0) { - get_qsfp_temp(ii, buf, sizeof(buf)); + /* + * The standards in this area are not clear when the + * additional measurements are present or not. Use a valid + * temperature reading as an indicator for the presence of + * voltage and TX/RX power measurements. + */ + if (get_qsfp_temp(ii, buf, sizeof(buf)) == 0) { get_qsfp_voltage(ii, buf2, sizeof(buf2)); printf("\tmodule temperature: %s voltage: %s\n", buf, buf2); for (i = 1; i <= 4; i++) { |