Lines Matching +full:double +full:- +full:channel

1 /*-
87 if (ii->error != 0) in read_i2c()
88 return (ii->error); in read_i2c()
90 ii->ifr.ifr_data = (caddr_t)&req; in read_i2c()
102 if (ifconfig_ioctlwrap(ii->h, AF_LOCAL, SIOCGI2C, in read_i2c()
103 &ii->ifr) != 0) { in read_i2c()
104 ii->error = errno; in read_i2c()
109 len -= l; in read_i2c()
123 strlcpy(ii->ifr.ifr_name, name, sizeof(ii->ifr.ifr_name)); in i2c_info_init()
124 ii->h = h; in i2c_info_init()
128 * Both SFF-8472 and SFF-8436 use it as in i2c_info_init()
130 * Stop reading status on zero as value - in i2c_info_init()
135 if (ii->error != 0) in i2c_info_init()
136 return (-1); in i2c_info_init()
138 h->error.errtype = OTHER; in i2c_info_init()
139 h->error.errcode = ENOENT; in i2c_info_init()
140 return (-1); in i2c_info_init()
142 ii->id = id_byte; in i2c_info_init()
151 read_i2c(ii, SFF_8472_BASE, SFF_8472_ID, 1, &sfp->sfp_id); in get_sfp_info()
152 read_i2c(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, &sfp->sfp_conn); in get_sfp_info()
155 read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS, 1, &sfp->sfp_eth_ext); in get_sfp_info()
156 if (sfp->sfp_eth_ext == 0) { in get_sfp_info()
159 sfp->sfp_eth_10g = find_zero_bit(sfp_eth_10g_table, code, 1); in get_sfp_info()
160 if (sfp->sfp_eth_10g == 0) { in get_sfp_info()
164 sfp->sfp_eth = find_zero_bit(sfp_eth_table, code, 1); in get_sfp_info()
168 return (ii->error); in get_sfp_info()
176 read_i2c(ii, SFF_8436_BASE, SFF_8436_ID, 1, &sfp->sfp_id); in get_qsfp_info()
177 read_i2c(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, &sfp->sfp_conn); in get_qsfp_info()
179 read_i2c(ii, SFF_8436_BASE, SFF_8436_STATUS, 1, &sfp->sfp_rev); in get_qsfp_info()
185 &sfp->sfp_eth_ext); in get_qsfp_info()
186 sfp->sfp_eth_1040g = code; in get_qsfp_info()
189 sfp->sfp_eth_1040g = in get_qsfp_info()
193 return (ii->error); in get_qsfp_info()
206 return (-1); in ifconfig_sfp_get_sfp_info()
208 /* Read bytes 3-10 at once */ in ifconfig_sfp_get_sfp_info()
214 sfp->sfp_eth_10g = find_zero_bit(sfp_eth_10g_table, buf[0], 1); in ifconfig_sfp_get_sfp_info()
215 if (sfp->sfp_eth_10g == 0) { in ifconfig_sfp_get_sfp_info()
217 sfp->sfp_eth = find_zero_bit(sfp_eth_table, buf[3], 1); in ifconfig_sfp_get_sfp_info()
219 sfp->sfp_fc_len = find_zero_bit(sfp_fc_len_table, buf[4], 1); in ifconfig_sfp_get_sfp_info()
220 sfp->sfp_fc_media = find_zero_bit(sfp_fc_media_table, buf[6], 1); in ifconfig_sfp_get_sfp_info()
221 sfp->sfp_fc_speed = find_zero_bit(sfp_fc_speed_table, buf[7], 1); in ifconfig_sfp_get_sfp_info()
222 sfp->sfp_cab_tech = in ifconfig_sfp_get_sfp_info()
249 return (channel_count(sfp->sfp_id)); in ifconfig_sfp_channel_count()
253 * Print SFF-8472/SFF-8436 string to supplied buffer.
254 * All (vendor-specific) strings are padded right with '0x20'.
261 do { *dst-- = '\0'; } while (*dst == 0x20); in get_sff_string()
270 sprintf(dst, "20%c%c-%c%c-%c%c", buf[0], buf[1], buf[2], buf[3], in get_sff_date()
277 get_sff_string(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, vi->name); in get_sfp_vendor_info()
278 get_sff_string(ii, SFF_8472_BASE, SFF_8472_PN_START, vi->pn); in get_sfp_vendor_info()
279 get_sff_string(ii, SFF_8472_BASE, SFF_8472_SN_START, vi->sn); in get_sfp_vendor_info()
280 get_sff_date(ii, SFF_8472_BASE, SFF_8472_DATE_START, vi->date); in get_sfp_vendor_info()
281 return (ii->error); in get_sfp_vendor_info()
287 get_sff_string(ii, SFF_8436_BASE, SFF_8436_VENDOR_START, vi->name); in get_qsfp_vendor_info()
288 get_sff_string(ii, SFF_8436_BASE, SFF_8436_PN_START, vi->pn); in get_qsfp_vendor_info()
289 get_sff_string(ii, SFF_8436_BASE, SFF_8436_SN_START, vi->sn); in get_qsfp_vendor_info()
290 get_sff_date(ii, SFF_8436_BASE, SFF_8436_DATE_START, vi->date); in get_qsfp_vendor_info()
291 return (ii->error); in get_qsfp_vendor_info()
303 return (-1); in ifconfig_sfp_get_sfp_vendor_info()
311 * Converts internal temperature (SFF-8472, SFF-8436)
312 * 16-bit unsigned value to human-readable representation:
315 * as a 16-bit signed twos complement value in increments of
319 static double
322 double d; in get_sff_temp()
326 d = (double)buf[0]; in get_sff_temp()
327 d += (double)buf[1] / 256; in get_sff_temp()
332 * Retrieves supplied voltage (SFF-8472, SFF-8436).
333 * 16-bit usigned value, treated as range 0..+6.55 Volts
335 static double
338 double d; in get_sff_voltage()
342 d = (double)((buf[0] << 8) | buf[1]); in get_sff_voltage()
347 * The following conversions assume internally-calibrated data.
348 * This is always true for SFF-8346, and explicitly checked for SFF-8472.
351 double
358 double
364 double
377 if (ii->error != 0) in get_sff_channel()
390 if (ii->error != 0) in get_sfp_status()
391 return (-1); in get_sfp_status()
399 ii->h->error.errtype = OTHER; in get_sfp_status()
400 ii->h->error.errcode = ENXIO; in get_sfp_status()
401 return (-1); in get_sfp_status()
404 ss->temp = get_sff_temp(ii, SFF_8472_DIAG, SFF_8472_TEMP); in get_sfp_status()
405 ss->voltage = get_sff_voltage(ii, SFF_8472_DIAG, SFF_8472_VCC); in get_sfp_status()
406 ss->channel = calloc(channel_count(ii->id), sizeof(*ss->channel)); in get_sfp_status()
407 if (ss->channel == NULL) { in get_sfp_status()
408 ii->h->error.errtype = OTHER; in get_sfp_status()
409 ii->h->error.errcode = ENOMEM; in get_sfp_status()
410 return (-1); in get_sfp_status()
412 ss->channel[0].rx = get_sff_channel(ii, SFF_8472_DIAG, SFF_8472_RX_POWER); in get_sfp_status()
413 ss->channel[0].tx = get_sff_channel(ii, SFF_8472_DIAG, SFF_8472_TX_BIAS); in get_sfp_status()
414 return (ii->error); in get_sfp_status()
439 ss->temp = get_sff_temp(ii, SFF_8436_BASE, SFF_8436_TEMP); in get_qsfp_status()
440 ss->voltage = get_sff_voltage(ii, SFF_8436_BASE, SFF_8436_VCC); in get_qsfp_status()
441 channels = channel_count(ii->id); in get_qsfp_status()
442 ss->channel = calloc(channels, sizeof(*ss->channel)); in get_qsfp_status()
443 if (ss->channel == NULL) { in get_qsfp_status()
444 ii->h->error.errtype = OTHER; in get_qsfp_status()
445 ii->h->error.errcode = ENOMEM; in get_qsfp_status()
446 return (-1); in get_qsfp_status()
451 ss->channel[chan].rx = in get_qsfp_status()
453 ss->channel[chan].tx = in get_qsfp_status()
456 ss->bitrate = get_qsfp_bitrate(ii); in get_qsfp_status()
457 return (ii->error); in get_qsfp_status()
469 return (-1); in ifconfig_sfp_get_sfp_status()
480 free(ss->channel); in ifconfig_sfp_free_sfp_status()
518 if (strings->sfp_id == NULL) in ifconfig_sfp_get_sfp_info_strings()
519 strings->sfp_id = sfp_id_string_alt(sfp->sfp_id); in ifconfig_sfp_get_sfp_info_strings()
520 if (strings->sfp_conn == NULL) in ifconfig_sfp_get_sfp_info_strings()
521 strings->sfp_conn = sfp_conn_string_alt(sfp->sfp_conn); in ifconfig_sfp_get_sfp_info_strings()
522 if (strings->sfp_rev == NULL) in ifconfig_sfp_get_sfp_info_strings()
523 strings->sfp_rev = "Unallocated"; in ifconfig_sfp_get_sfp_info_strings()
530 switch (sfp->sfp_id) { in ifconfig_sfp_physical_spec()
536 if (sfp->sfp_eth_1040g & SFP_ETH_1040G_EXTENDED) in ifconfig_sfp_physical_spec()
537 return (strings->sfp_eth_ext); in ifconfig_sfp_physical_spec()
538 else if (sfp->sfp_eth_1040g) in ifconfig_sfp_physical_spec()
539 return (strings->sfp_eth_1040g); in ifconfig_sfp_physical_spec()
542 if (sfp->sfp_eth_ext) in ifconfig_sfp_physical_spec()
543 return (strings->sfp_eth_ext); in ifconfig_sfp_physical_spec()
544 else if (sfp->sfp_eth_10g) in ifconfig_sfp_physical_spec()
545 return (strings->sfp_eth_10g); in ifconfig_sfp_physical_spec()
546 else if (sfp->sfp_eth) in ifconfig_sfp_physical_spec()
547 return (strings->sfp_eth); in ifconfig_sfp_physical_spec()
558 uint8_t *buf = dump->data; in ifconfig_sfp_get_sfp_dump()
560 memset(dump->data, 0, sizeof(dump->data)); in ifconfig_sfp_get_sfp_dump()
563 return (-1); in ifconfig_sfp_get_sfp_dump()
575 return (ii.error != 0 ? -1 : 0); in ifconfig_sfp_get_sfp_dump()
581 uint8_t id_byte = dp->data[0]; in ifconfig_sfp_dump_region_count()