Changeset View
Changeset View
Standalone View
Standalone View
sbin/ifconfig/sfp.c
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
sfp_status(int s, struct ifreq *ifr, int verbose) | sfp_status(int s, struct ifreq *ifr, int verbose) | ||||
{ | { | ||||
struct ifconfig_sfp_info info; | struct ifconfig_sfp_info info; | ||||
struct ifconfig_sfp_info_strings strings; | struct ifconfig_sfp_info_strings strings; | ||||
struct ifconfig_sfp_vendor_info vendor_info; | struct ifconfig_sfp_vendor_info vendor_info; | ||||
struct ifconfig_sfp_status status; | struct ifconfig_sfp_status status; | ||||
ifconfig_handle_t *lifh; | |||||
size_t channel_count; | size_t channel_count; | ||||
lifh = ifconfig_open(); | if (ifconfig_sfp_get_sfp_info(lifh, name, &info) == -1) | ||||
if (lifh == NULL) | |||||
return; | return; | ||||
if (ifconfig_sfp_get_sfp_info(lifh, name, &info) == -1) | |||||
goto close; | |||||
ifconfig_sfp_get_sfp_info_strings(&info, &strings); | ifconfig_sfp_get_sfp_info_strings(&info, &strings); | ||||
printf("\tplugged: %s %s (%s)\n", | printf("\tplugged: %s %s (%s)\n", | ||||
ifconfig_sfp_id_display(info.sfp_id), | ifconfig_sfp_id_display(info.sfp_id), | ||||
ifconfig_sfp_physical_spec(&info, &strings), | ifconfig_sfp_physical_spec(&info, &strings), | ||||
strings.sfp_conn); | strings.sfp_conn); | ||||
if (ifconfig_sfp_get_sfp_vendor_info(lifh, name, &vendor_info) == -1) | if (ifconfig_sfp_get_sfp_vendor_info(lifh, name, &vendor_info) == -1) | ||||
goto close; | return; | ||||
printf("\tvendor: %s PN: %s SN: %s DATE: %s\n", | printf("\tvendor: %s PN: %s SN: %s DATE: %s\n", | ||||
vendor_info.name, vendor_info.pn, vendor_info.sn, vendor_info.date); | vendor_info.name, vendor_info.pn, vendor_info.sn, vendor_info.date); | ||||
if (ifconfig_sfp_id_is_qsfp(info.sfp_id)) { | if (ifconfig_sfp_id_is_qsfp(info.sfp_id)) { | ||||
if (verbose > 1) | if (verbose > 1) | ||||
printf("\tcompliance level: %s\n", strings.sfp_rev); | printf("\tcompliance level: %s\n", strings.sfp_rev); | ||||
} else { | } else { | ||||
Show All 22 Lines | if (ifconfig_sfp_get_sfp_status(lifh, name, &status) == 0) { | ||||
} | } | ||||
ifconfig_sfp_free_sfp_status(&status); | ifconfig_sfp_free_sfp_status(&status); | ||||
} | } | ||||
if (verbose > 2) { | if (verbose > 2) { | ||||
struct ifconfig_sfp_dump dump; | struct ifconfig_sfp_dump dump; | ||||
if (ifconfig_sfp_get_sfp_dump(lifh, name, &dump) == -1) | if (ifconfig_sfp_get_sfp_dump(lifh, name, &dump) == -1) | ||||
goto close; | return; | ||||
if (ifconfig_sfp_id_is_qsfp(info.sfp_id)) { | if (ifconfig_sfp_id_is_qsfp(info.sfp_id)) { | ||||
printf("\n\tSFF8436 DUMP (0xA0 128..255 range):\n"); | printf("\n\tSFF8436 DUMP (0xA0 128..255 range):\n"); | ||||
hexdump(dump.data + QSFP_DUMP1_START, QSFP_DUMP1_SIZE, | hexdump(dump.data + QSFP_DUMP1_START, QSFP_DUMP1_SIZE, | ||||
"\t", HD_OMIT_COUNT | HD_OMIT_CHARS); | "\t", HD_OMIT_COUNT | HD_OMIT_CHARS); | ||||
printf("\n\tSFF8436 DUMP (0xA0 0..81 range):\n"); | printf("\n\tSFF8436 DUMP (0xA0 0..81 range):\n"); | ||||
hexdump(dump.data + QSFP_DUMP0_START, QSFP_DUMP0_SIZE, | hexdump(dump.data + QSFP_DUMP0_START, QSFP_DUMP0_SIZE, | ||||
"\t", HD_OMIT_COUNT | HD_OMIT_CHARS); | "\t", HD_OMIT_COUNT | HD_OMIT_CHARS); | ||||
} else { | } else { | ||||
printf("\n\tSFF8472 DUMP (0xA0 0..127 range):\n"); | printf("\n\tSFF8472 DUMP (0xA0 0..127 range):\n"); | ||||
hexdump(dump.data + SFP_DUMP_START, SFP_DUMP_SIZE, | hexdump(dump.data + SFP_DUMP_START, SFP_DUMP_SIZE, | ||||
"\t", HD_OMIT_COUNT | HD_OMIT_CHARS); | "\t", HD_OMIT_COUNT | HD_OMIT_CHARS); | ||||
} | } | ||||
} | } | ||||
close: | |||||
ifconfig_close(lifh); | |||||
} | } |