MCPcopy Index your code
hub / github.com/F-Stack/f-stack / sfp_status

Function sfp_status

tools/ifconfig/sfp.c:57–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55#include "ifconfig.h"
56
57void
58sfp_status(int s, struct ifreq *ifr, int verbose)
59{
60 struct ifconfig_sfp_info info;
61 struct ifconfig_sfp_info_strings strings;
62 struct ifconfig_sfp_vendor_info vendor_info;
63 struct ifconfig_sfp_status status;
64 ifconfig_handle_t *lifh;
65 const char *name;
66 size_t channel_count;
67
68 lifh = ifconfig_open();
69 if (lifh == NULL)
70 return;
71
72 name = ifr->ifr_name;
73
74 if (ifconfig_sfp_get_sfp_info(lifh, name, &info) == -1)
75 goto close;
76
77 ifconfig_sfp_get_sfp_info_strings(&info, &strings);
78
79 printf("\tplugged: %s %s (%s)\n",
80 ifconfig_sfp_id_display(info.sfp_id),
81 ifconfig_sfp_physical_spec(&info, &strings),
82 strings.sfp_conn);
83
84 if (ifconfig_sfp_get_sfp_vendor_info(lifh, name, &vendor_info) == -1)
85 goto close;
86
87 printf("\tvendor: %s PN: %s SN: %s DATE: %s\n",
88 vendor_info.name, vendor_info.pn, vendor_info.sn, vendor_info.date);
89
90 if (ifconfig_sfp_id_is_qsfp(info.sfp_id)) {
91 if (verbose > 1)
92 printf("\tcompliance level: %s\n", strings.sfp_rev);
93 } else {
94 if (verbose > 5) {
95 printf("Class: %s\n",
96 ifconfig_sfp_physical_spec(&info, &strings));
97 printf("Length: %s\n", strings.sfp_fc_len);
98 printf("Tech: %s\n", strings.sfp_cab_tech);
99 printf("Media: %s\n", strings.sfp_fc_media);
100 printf("Speed: %s\n", strings.sfp_fc_speed);
101 }
102 }
103
104 if (ifconfig_sfp_get_sfp_status(lifh, name, &status) == 0) {
105 if (ifconfig_sfp_id_is_qsfp(info.sfp_id) && verbose > 1)
106 printf("\tnominal bitrate: %u Mbps\n", status.bitrate);
107 printf("\tmodule temperature: %.2f C voltage: %.2f Volts\n",
108 status.temp, status.voltage);
109 channel_count = ifconfig_sfp_channel_count(&info);
110 for (size_t chan = 0; chan < channel_count; ++chan) {
111 uint16_t rx = status.channel[chan].rx;
112 uint16_t tx = status.channel[chan].tx;
113 printf("\tlane %zu: "
114 "RX power: %.2f mW (%.2f dBm) TX bias: %.2f mA\n",

Callers 1

ifconfig.cFile · 0.85

Calls 2

printfFunction · 0.50
hexdumpFunction · 0.50

Tested by

no test coverage detected