]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Move ifconfig SFP status functionality into libifconfig
authorfreqlabs <freqlabs@FreeBSD.org>
Sun, 9 Aug 2020 16:27:28 +0000 (16:27 +0000)
committerfreqlabs <freqlabs@FreeBSD.org>
Sun, 9 Aug 2020 16:27:28 +0000 (16:27 +0000)
commit7577abf444f6f1c6c44273bafab457f2457668e5
treecd1eb42508fbc932a852f76cc8c3142ab874b996
parent8b7c28cb971a6cffd9f235958753d7cb5a06c584
Move ifconfig SFP status functionality into libifconfig

libifconfig_sfp.h provides an API in libifconfig for querying SFP module
properties, operational status, and vendor strings, as well as descriptions
of the various fields, string conversions, and other useful helpers for
implementing user interfaces.

SFP module status is obtained by reading registers via an I2C interface.
Descriptions of these registers and the values therein have been collected
in a Lua table which is used to generate all the boilerplace C headers and
source files for accessing these values, their names, and descriptions.
The generated code is fully commented and readable.

This is the first use of libifconfig in ifconfig itself.  For now, the
scope remains very limited.  Over time, more of ifconfig will be replaced
with libifconfig.

Some minor changes to the formatting of ifconfig output have been made:
- Module memory hex dumps are indented one extra space as a result of using
hexdump(3) instead of a bespoke hex dump function.
- Media descriptions have an added two-character short-name in parenthesis.
- QSFP modules were incorrectly displaying TX bias current as power.  Now
  TX channels display bias current, and this change has been made for both
  SFP and QSFP modules for consistency.

A Lua binding for libifconfig including this functionality is implemented
but has not been included in this commit.  The plan is for it to be
committed after dynamic module loading has been enabled in flua.

Reviewed by: kp, melifaro
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D25494
12 files changed:
lib/libifconfig/Makefile
lib/libifconfig/libifconfig.h
lib/libifconfig/libifconfig_sfp.c [new file with mode: 0644]
lib/libifconfig/libifconfig_sfp.h [new file with mode: 0644]
lib/libifconfig/libifconfig_sfp_tables.tpl.c [new file with mode: 0644]
lib/libifconfig/libifconfig_sfp_tables.tpl.h [new file with mode: 0644]
lib/libifconfig/libifconfig_sfp_tables_internal.tpl.h [new file with mode: 0644]
lib/libifconfig/sfp.lua [new file with mode: 0644]
rescue/rescue/Makefile
sbin/ifconfig/Makefile
sbin/ifconfig/sfp.c
tools/lua/template.lua [new file with mode: 0644]