Lines Matching refs:ii
79 read_i2c(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len, in read_i2c() argument
85 if (ii->error != 0) in read_i2c()
86 return (ii->error); in read_i2c()
88 ii->ifr.ifr_data = (caddr_t)&req; in read_i2c()
100 if (ifconfig_ioctlwrap(ii->h, AF_LOCAL, SIOCGI2C, in read_i2c()
101 &ii->ifr) != 0) { in read_i2c()
102 ii->error = errno; in read_i2c()
116 i2c_info_init(struct i2c_info *ii, ifconfig_handle_t *h, const char *name) in i2c_info_init() argument
120 memset(ii, 0, sizeof(*ii)); in i2c_info_init()
121 strlcpy(ii->ifr.ifr_name, name, sizeof(ii->ifr.ifr_name)); in i2c_info_init()
122 ii->h = h; in i2c_info_init()
132 read_i2c(ii, SFF_8472_BASE, SFF_8472_ID, 1, &id_byte); in i2c_info_init()
133 if (ii->error != 0) in i2c_info_init()
140 ii->id = id_byte; in i2c_info_init()
145 get_sfp_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp) in get_sfp_info() argument
149 read_i2c(ii, SFF_8472_BASE, SFF_8472_ID, 1, &sfp->sfp_id); in get_sfp_info()
150 read_i2c(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, &sfp->sfp_conn); in get_sfp_info()
153 read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS, 1, &sfp->sfp_eth_ext); in get_sfp_info()
156 read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, &code); in get_sfp_info()
160 read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3, in get_sfp_info()
166 return (ii->error); in get_sfp_info()
170 get_qsfp_info(struct i2c_info *ii, struct ifconfig_sfp_info *sfp) in get_qsfp_info() argument
174 read_i2c(ii, SFF_8436_BASE, SFF_8436_ID, 1, &sfp->sfp_id); in get_qsfp_info()
175 read_i2c(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, &sfp->sfp_conn); in get_qsfp_info()
177 read_i2c(ii, SFF_8436_BASE, SFF_8436_STATUS, 1, &sfp->sfp_rev); in get_qsfp_info()
180 read_i2c(ii, SFF_8436_BASE, SFF_8436_CODE_E1040100G, 1, &code); in get_qsfp_info()
182 read_i2c(ii, SFF_8436_BASE, SFF_8436_OPTIONS_START, 1, in get_qsfp_info()
190 return (ii->error); in get_qsfp_info()
197 struct i2c_info ii; in ifconfig_sfp_get_sfp_info() local
202 if (i2c_info_init(&ii, h, name) != 0) in ifconfig_sfp_get_sfp_info()
206 read_i2c(&ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, buf); in ifconfig_sfp_get_sfp_info()
207 if (ii.error != 0) in ifconfig_sfp_get_sfp_info()
208 return (ii.error); in ifconfig_sfp_get_sfp_info()
222 if (ifconfig_sfp_id_is_qsfp(ii.id)) in ifconfig_sfp_get_sfp_info()
223 return (get_qsfp_info(&ii, sfp)); in ifconfig_sfp_get_sfp_info()
224 return (get_sfp_info(&ii, sfp)); in ifconfig_sfp_get_sfp_info()
254 get_sff_string(struct i2c_info *ii, uint8_t addr, uint8_t off, char *dst) in get_sff_string() argument
256 read_i2c(ii, addr, off, SFF_VENDOR_STRING_SIZE, dst); in get_sff_string()
262 get_sff_date(struct i2c_info *ii, uint8_t addr, uint8_t off, char *dst) in get_sff_date() argument
266 read_i2c(ii, addr, off, SFF_VENDOR_DATE_SIZE, buf); in get_sff_date()
272 get_sfp_vendor_info(struct i2c_info *ii, struct ifconfig_sfp_vendor_info *vi) in get_sfp_vendor_info() argument
274 get_sff_string(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, vi->name); in get_sfp_vendor_info()
275 get_sff_string(ii, SFF_8472_BASE, SFF_8472_PN_START, vi->pn); in get_sfp_vendor_info()
276 get_sff_string(ii, SFF_8472_BASE, SFF_8472_SN_START, vi->sn); in get_sfp_vendor_info()
277 get_sff_date(ii, SFF_8472_BASE, SFF_8472_DATE_START, vi->date); in get_sfp_vendor_info()
278 return (ii->error); in get_sfp_vendor_info()
282 get_qsfp_vendor_info(struct i2c_info *ii, struct ifconfig_sfp_vendor_info *vi) in get_qsfp_vendor_info() argument
284 get_sff_string(ii, SFF_8436_BASE, SFF_8436_VENDOR_START, vi->name); in get_qsfp_vendor_info()
285 get_sff_string(ii, SFF_8436_BASE, SFF_8436_PN_START, vi->pn); in get_qsfp_vendor_info()
286 get_sff_string(ii, SFF_8436_BASE, SFF_8436_SN_START, vi->sn); in get_qsfp_vendor_info()
287 get_sff_date(ii, SFF_8436_BASE, SFF_8436_DATE_START, vi->date); in get_qsfp_vendor_info()
288 return (ii->error); in get_qsfp_vendor_info()
295 struct i2c_info ii; in ifconfig_sfp_get_sfp_vendor_info() local
299 if (i2c_info_init(&ii, h, name) != 0) in ifconfig_sfp_get_sfp_vendor_info()
302 if (ifconfig_sfp_id_is_qsfp(ii.id)) in ifconfig_sfp_get_sfp_vendor_info()
303 return (get_qsfp_vendor_info(&ii, vi)); in ifconfig_sfp_get_sfp_vendor_info()
304 return (get_sfp_vendor_info(&ii, vi)); in ifconfig_sfp_get_sfp_vendor_info()
317 get_sff_temp(struct i2c_info *ii, uint8_t addr, uint8_t off) in get_sff_temp() argument
322 read_i2c(ii, addr, off, 2, buf); in get_sff_temp()
333 get_sff_voltage(struct i2c_info *ii, uint8_t addr, uint8_t off) in get_sff_voltage() argument
338 read_i2c(ii, addr, off, 2, buf); in get_sff_voltage()
369 get_sff_channel(struct i2c_info *ii, uint8_t addr, uint8_t off) in get_sff_channel() argument
373 read_i2c(ii, addr, off, 2, buf); in get_sff_channel()
374 if (ii->error != 0) in get_sff_channel()
381 get_sfp_status(struct i2c_info *ii, struct ifconfig_sfp_status *ss) in get_sfp_status() argument
386 read_i2c(ii, SFF_8472_BASE, SFF_8472_DIAG_TYPE, 1, (caddr_t)&diag_type); in get_sfp_status()
387 if (ii->error != 0) in get_sfp_status()
396 ii->h->error.errtype = OTHER; in get_sfp_status()
397 ii->h->error.errcode = ENXIO; in get_sfp_status()
401 ss->temp = get_sff_temp(ii, SFF_8472_DIAG, SFF_8472_TEMP); in get_sfp_status()
402 ss->voltage = get_sff_voltage(ii, SFF_8472_DIAG, SFF_8472_VCC); in get_sfp_status()
403 ss->channel = calloc(channel_count(ii->id), sizeof(*ss->channel)); in get_sfp_status()
405 ii->h->error.errtype = OTHER; in get_sfp_status()
406 ii->h->error.errcode = ENOMEM; in get_sfp_status()
409 ss->channel[0].rx = get_sff_channel(ii, SFF_8472_DIAG, SFF_8472_RX_POWER); in get_sfp_status()
410 ss->channel[0].tx = get_sff_channel(ii, SFF_8472_DIAG, SFF_8472_TX_BIAS); in get_sfp_status()
411 return (ii->error); in get_sfp_status()
415 get_qsfp_bitrate(struct i2c_info *ii) in get_qsfp_bitrate() argument
421 read_i2c(ii, SFF_8436_BASE, SFF_8436_BITRATE, 1, &code); in get_qsfp_bitrate()
424 read_i2c(ii, SFF_8436_BASE, SFF_8636_BITRATE, 1, &code); in get_qsfp_bitrate()
432 get_qsfp_status(struct i2c_info *ii, struct ifconfig_sfp_status *ss) in get_qsfp_status() argument
436 ss->temp = get_sff_temp(ii, SFF_8436_BASE, SFF_8436_TEMP); in get_qsfp_status()
437 ss->voltage = get_sff_voltage(ii, SFF_8436_BASE, SFF_8436_VCC); in get_qsfp_status()
438 channels = channel_count(ii->id); in get_qsfp_status()
441 ii->h->error.errtype = OTHER; in get_qsfp_status()
442 ii->h->error.errcode = ENOMEM; in get_qsfp_status()
449 get_sff_channel(ii, SFF_8436_BASE, rxoffs); in get_qsfp_status()
451 get_sff_channel(ii, SFF_8436_BASE, txoffs); in get_qsfp_status()
453 ss->bitrate = get_qsfp_bitrate(ii); in get_qsfp_status()
454 return (ii->error); in get_qsfp_status()
461 struct i2c_info ii; in ifconfig_sfp_get_sfp_status() local
465 if (i2c_info_init(&ii, h, name) != 0) in ifconfig_sfp_get_sfp_status()
468 if (ifconfig_sfp_id_is_qsfp(ii.id)) in ifconfig_sfp_get_sfp_status()
469 return (get_qsfp_status(&ii, ss)); in ifconfig_sfp_get_sfp_status()
470 return (get_sfp_status(&ii, ss)); in ifconfig_sfp_get_sfp_status()
554 struct i2c_info ii; in ifconfig_sfp_get_sfp_dump() local
559 if (i2c_info_init(&ii, h, name) != 0) in ifconfig_sfp_get_sfp_dump()
562 if (ifconfig_sfp_id_is_qsfp(ii.id)) { in ifconfig_sfp_get_sfp_dump()
563 read_i2c(&ii, SFF_8436_BASE, QSFP_DUMP0_START, QSFP_DUMP0_SIZE, in ifconfig_sfp_get_sfp_dump()
565 read_i2c(&ii, SFF_8436_BASE, QSFP_DUMP1_START, QSFP_DUMP1_SIZE, in ifconfig_sfp_get_sfp_dump()
568 read_i2c(&ii, SFF_8472_BASE, SFP_DUMP_START, SFP_DUMP_SIZE, in ifconfig_sfp_get_sfp_dump()
572 return (ii.error != 0 ? -1 : 0); in ifconfig_sfp_get_sfp_dump()