26

Odp: SFP plugin dla LuCI

To coś oczekuje że w /etc/board.json będziesz miał domyślnie sekcję sfp. Więc teraz bierzesz się za przerabianie tego czegoś żeby wykrywało samodzielnie wkładki i wyświetlało to co chcesz.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

27 (edytowany przez Payti 2024-09-17 22:59:40)

Odp: SFP plugin dla LuCI

Mój /etc/board.json wygląda tak:

root@BananaPi_BPi-R3 /root [#]# cat /etc/board.json
{
        "model": {
                "id": "bananapi,bpi-r3",
                "name": "Bananapi BPI-R3"
        },
        "network": {
                "lan": {
                        "ports": [
                                "lan1",
                                "lan2",
                                "lan3",
                                "lan4",
                                "sfp2"
                        ],
                        "protocol": "static"
                },
                "wan": {
                        "ports": [
                                "eth1",
                                "wan"
                        ],
                        "protocol": "dhcp",
                        "macaddr": "a2:1d:43:f7:1f:c7"
                }
        },
        "system": {
                "compat_version": "1.2"
        },
        "wlan": {
                "phy0": {
                        "path": "platform/soc/18000000.wifi",
                        "info": {
                                "antenna_rx": 15,
                                "antenna_tx": 15,
                                "bands": {
                                        "2G": {
                                                "ht": true,
                                                "he": true,
                                                "max_width": 40,
                                                "modes": [
                                                        "NOHT",
                                                        "HT20",
                                                        "HE20",
                                                        "HT40",
                                                        "HE40"
                                                ]
                                        }
                                }
                        }
                },
                "phy1": {
                        "path": "platform/soc/18000000.wifi+1",
                        "info": {
                                "antenna_rx": 15,
                                "antenna_tx": 15,
                                "bands": {
                                        "5G": {
                                                "ht": true,
                                                "vht": true,
                                                "he": true,
                                                "max_width": 160,
                                                "modes": [
                                                        "NOHT",
                                                        "HT20",
                                                        "VHT20",
                                                        "HE20",
                                                        "HT40",
                                                        "VHT40",
                                                        "VHT80",
                                                        "HE80",
                                                        "VHT160",
                                                        "HE160"
                                                ]
                                        }
                                }
                        }
                }
        }
}
root@BananaPi_BPi-R3 /root [#]#

I teraz czy wystarczy tylko przebudowanie w pliku /usr/libexec/rpcd/sfp funkcji list_sfp_interfaces() ?

function list_sfp_interfaces()
    board_file = file.read("/etc/board.json")
    if (board_file == nil) then
        return {}
    end
    parsed_board_file = jsonc.parse(board_file)
    if (parsed_board_file["sfp"] == nil) then
        return {}
    end
    local sfp_data = parsed_board_file["sfp"]
    local return_data = {}
    for k,v in pairs(sfp_data) do
        local this_interface = k
        local this_interface_data = {}
        if (v["debugfs"] ~= nil) then
            local has_debugfs, present = get_sfp_data(this_interface,v["debugfs"])
            if (has_debugfs == true) then
                this_interface_data["present"] = present
            end
        end
        return_data[this_interface] = this_interface_data
    end
    return return_data
end

W BPI-R3 wkładki SFP mogą być w dwóch portach -> dla wan w eth1 i dla lan w sfp2.

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

28 (edytowany przez Payti 2024-09-17 22:56:59)

Odp: SFP plugin dla LuCI

Tu
--> https://forum.traverse.com.au/t/updated … r-luci/186
cos jeszcze piszą o dadaniu info o sfp do board.jason skryptem /etc/board.d/73_sfp
--> https://gitlab.com/traversetech/ls1088f … d.d/73_sfp

zrobiłem plik 73_sfp:

#!/bin/sh

. /lib/functions/uci-defaults.sh

board=$(board_name)
[ "${board}" != "Bananapi BPI-R3" ] && exit 0

board_config_update

json_select_object "sfp"
json_select_object "eth1"
json_add_string debugfs "/sys/kernel/debug/sfp-1/"
json_select ..
json_select_object "sfp2"
json_add_string debugfs "/sys/kernel/debug/sfp-2/"

board_config_flush

W plikach /sys/kernel/debug/sfp-1/state i /sys/kernel/debug/sfp-2/state jest info w BPI-R3 czy SFP włożone czy nie.

root@BananaPi_BPi-R3 /root [#]# cat /sys/kernel/debug/sfp-1/state
Module state: present
Module probe attempts: 0 0
Device state: up
Main state: link_up
Fault recovery remaining retries: 5
PHY probe remaining retries: 12
moddef0: 1
rx_los: 0
tx_fault: 0
tx_disable: 0
root@BananaPi_BPi-R3 /root [#]# cat /sys/kernel/debug/sfp-2/state
Module state: empty
Module probe attempts: 10 12
Device state: up
Main state: down
Fault recovery remaining retries: 0
PHY probe remaining retries: 0
moddef0: 0
rx_los: 0
tx_fault: 0
tx_disable: 1
root@BananaPi_BPi-R3 /root [#]#

Jak myślisz ten j/w 73_sfp nada się do BPi-R3, mogę go bez obaw wgrać do /etc/board.d/ ?
Nie ubije startu routera po reboot ?

Pozdr,

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

29

Odp: SFP plugin dla LuCI

Nic nie wolno ci "wgrywać" do /etc/board.d. Zawarte tam dane opisują statyczną budowę routera i wykorzystywane są raz przy starcie do utworzenia skryptów networka/systemu itd. Wkładki możesz mieć różne,  w różnych urządzeniach mogą one być pod różnymi nazwami, u kogoś może to się inaczej nazywać. Skro wiesz że dane o wkładce są w odpowiednich katalogach w /sys/kernel/debug to skorzystaj  tego, odczytuj je, parsuj i wyświetlaj na ekranie.

Plan gry powinien być taki: przygotuj sobie zestaw poleceń które odzwierciedlają stan wkładki i inne dane które uważasz za potrzebne. Wykorzystaj to co jest napisane (albo jak wspominałeś - 3ginfo), tam też są wykonywane polecenia które zwracają dane. Te dane (linie tekstu lub json) musisz sobie wyświetlić na stronie przy pomocy javaskryptu. I tyle albo aż tyle.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

30 (edytowany przez Payti 2024-09-18 19:21:23)

Odp: SFP plugin dla LuCI

Ok, dzięki za wskazówki.

Więc stworzyłem plik /etc/sfp.json z deklaracją wkładek dla BPI-R3 z zawartością:

{
        "sfp": {
                "eth1": {
                        "debugfs": "/sys/kernel/debug/sfp-1/"
                        },
                "sfp2": {
                        "debugfs": "/sys/kernel/debug/sfp-2/"
                        }
                }
}

Zmieniłem linię 49 w /usr/libexec/rpcd/sfp na

..
function list_sfp_interfaces()
    board_file = file.read("/etc/sfp.json")
..

I jest progres taki, ładnie zaczytał wkładki oraz info z 'state' w debug:
->> https://pasteboard.co/iv0O0eQQ8Gxk.png

Jednakże nie działa mi parsowanie wyniku komendy 'ethtool -m' i nie wiem czemu.
Tak powinno to finalnie wyglądać
-->> https://gitlab.com/-/snippets/2364354

Wersja co mam w routerze (najnowsza po update) ethtool jest niby z obsługą --json

root@BananaPi_BPi-R3 /root [#]# ethtool -h
ethtool version 6.6
Usage:
        ethtool [ FLAGS ]  DEVNAME      Display standard information about device
        ethtool [ FLAGS ] -s|--change DEVNAME   Change generic options
                [ speed %d ]
                [ lanes %d ]
                [ duplex half|full ]
                [ port tp|aui|bnc|mii|fibre|da ]
                [ mdix auto|on|off ]
                [ autoneg on|off ]
                [ advertise %x[/%x] | mode on|off ... [--] ]
                [ phyad %d ]
                [ xcvr internal|external ]
                [ wol %d[/%d] | p|u|m|b|a|g|s|f|d... ]
                [ sopass %x:%x:%x:%x:%x:%x ]
                [ msglvl %d[/%d] | type on|off ... [--] ]
                [ master-slave preferred-master|preferred-slave|forced-master|forced-slave ]
        ethtool [ FLAGS ] -a|--show-pause DEVNAME       Show pause options
                [ --src aggregate | emac | pmac ]
        ethtool [ FLAGS ] -A|--pause DEVNAME    Set pause options
                [ autoneg on|off ]
                [ rx on|off ]
                [ tx on|off ]
        ethtool [ FLAGS ] -c|--show-coalesce DEVNAME    Show coalesce options
        ethtool [ FLAGS ] -C|--coalesce DEVNAME Set coalesce options
                [adaptive-rx on|off]
                [adaptive-tx on|off]
                [rx-usecs N]
                [rx-frames N]
                [rx-usecs-irq N]
                [rx-frames-irq N]
                [tx-usecs N]
                [tx-frames N]
                [tx-usecs-irq N]
                [tx-frames-irq N]
                [stats-block-usecs N]
                [pkt-rate-low N]
                [rx-usecs-low N]
                [rx-frames-low N]
                [tx-usecs-low N]
                [tx-frames-low N]
                [pkt-rate-high N]
                [rx-usecs-high N]
                [rx-frames-high N]
                [tx-usecs-high N]
                [tx-frames-high N]
                [sample-interval N]
                [cqe-mode-rx on|off]
                [cqe-mode-tx on|off]
                [tx-aggr-max-bytes N]
                [tx-aggr-max-frames N]
                [tx-aggr-time-usecs N]
        ethtool [ FLAGS ] -g|--show-ring DEVNAME        Query RX/TX ring parameters
        ethtool [ FLAGS ] -G|--set-ring DEVNAME Set RX/TX ring parameters
                [ rx N ]
                [ rx-mini N ]
                [ rx-jumbo N ]
                [ tx N ]
                [ rx-buf-len N ]
                [ cqe-size N ]
                [ tx-push on|off ]
                [ rx-push on|off ]
                [ tx-push-buf-len N]
        ethtool [ FLAGS ] -k|--show-features|--show-offload DEVNAME     Get state of protocol offload and other features
        ethtool [ FLAGS ] -K|--features|--offload DEVNAME       Set protocol offload and other features
                FEATURE on|off ...
        ethtool [ FLAGS ] -i|--driver DEVNAME   Show driver information
        ethtool [ FLAGS ] -d|--register-dump DEVNAME    Do a register dump
                [ raw on|off ]
                [ file FILENAME ]
        ethtool [ FLAGS ] -e|--eeprom-dump DEVNAME      Do a EEPROM dump
                [ raw on|off ]
                [ offset N ]
                [ length N ]
        ethtool [ FLAGS ] -E|--change-eeprom DEVNAME    Change bytes in device EEPROM
                [ magic N ]
                [ offset N ]
                [ length N ]
                [ value N ]
        ethtool [ FLAGS ] -r|--negotiate DEVNAME        Restart N-WAY negotiation
        ethtool [ FLAGS ] -p|--identify DEVNAME Show visible port identification (e.g. blinking)
                [ TIME-IN-SECONDS ]
        ethtool [ FLAGS ] -t|--test DEVNAME     Execute adapter self test
                [ online | offline | external_lb ]
        ethtool [ FLAGS ] -S|--statistics DEVNAME       Show adapter statistics
                [ --all-groups | --groups [eth-phy] [eth-mac] [eth-ctrl] [rmon] ]
                [ --src aggregate | emac | pmac ]
        ethtool [ FLAGS ] --phy-statistics DEVNAME      Show phy statistics
        ethtool [ FLAGS ] -n|-u|--show-nfc|--show-ntuple DEVNAME        Show Rx network flow classification options or rules
                [ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 [context %d] |
                  rule %d ]
        ethtool [ FLAGS ] -N|-U|--config-nfc|--config-ntuple DEVNAME    Configure Rx network flow classification options or rules
                rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 m|v|t|s|d|f|n|r... [context %d] |
                flow-type ether|ip4|tcp4|udp4|sctp4|ah4|esp4|ip6|tcp6|udp6|ah6|esp6|sctp6
                        [ src %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
                        [ dst %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
                        [ proto %d [m %x] ]
                        [ src-ip IP-ADDRESS [m IP-ADDRESS] ]
                        [ dst-ip IP-ADDRESS [m IP-ADDRESS] ]
                        [ tos %d [m %x] ]
                        [ tclass %d [m %x] ]
                        [ l4proto %d [m %x] ]
                        [ src-port %d [m %x] ]
                        [ dst-port %d [m %x] ]
                        [ spi %d [m %x] ]
                        [ vlan-etype %x [m %x] ]
                        [ vlan %x [m %x] ]
                        [ user-def %x [m %x] ]
                        [ dst-mac %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
                        [ action %d ] | [ vf %d queue %d ]
                        [ context %d ]
                        [ loc %d ] |
                delete %d
        ethtool [ FLAGS ] -T|--show-time-stamping DEVNAME       Show time stamping capabilities
        ethtool [ FLAGS ] -x|--show-rxfh-indir|--show-rxfh DEVNAME      Show Rx flow hash indirection table and/or RSS hash key
                [ context %d ]
        ethtool [ FLAGS ] -X|--set-rxfh-indir|--rxfh DEVNAME    Set Rx flow hash indirection table and/or RSS hash key
                [ context %d|new ]
                [ equal N | weight W0 W1 ... | default ]
                [ hkey %x:%x:%x:%x:%x:.... ]
                [ hfunc FUNC ]
                [ delete ]
        ethtool [ FLAGS ] -f|--flash DEVNAME    Flash firmware image from the specified file to a region on the device
                FILENAME [ REGION-NUMBER-TO-FLASH ]
        ethtool [ FLAGS ] -P|--show-permaddr DEVNAME    Show permanent hardware address
        ethtool [ FLAGS ] -w|--get-dump DEVNAME Get dump flag, data
                [ data FILENAME ]
        ethtool [ FLAGS ] -W|--set-dump DEVNAME Set dump flag of the device
                N
        ethtool [ FLAGS ] -l|--show-channels DEVNAME    Query Channels
        ethtool [ FLAGS ] -L|--set-channels DEVNAME     Set Channels
                [ rx N ]
                [ tx N ]
                [ other N ]
                [ combined N ]
        ethtool [ FLAGS ] --show-priv-flags DEVNAME     Query private flags
        ethtool [ FLAGS ] --set-priv-flags DEVNAME      Set private flags
                FLAG on|off ...
        ethtool [ FLAGS ] -m|--dump-module-eeprom|--module-info DEVNAME Query/Decode Module EEPROM information and optical diagnostics if available
                [ raw on|off ]
                [ hex on|off ]
                [ offset N ]
                [ length N ]
                [ page N ]
                [ bank N ]
                [ i2c N ]
        ethtool [ FLAGS ] --show-eee DEVNAME    Show EEE settings
        ethtool [ FLAGS ] --set-eee DEVNAME     Set EEE settings
                [ eee on|off ]
                [ advertise %x ]
                [ tx-lpi on|off ]
                [ tx-timer %d ]
        ethtool [ FLAGS ] --set-phy-tunable DEVNAME     Set PHY tunable
                [ downshift on|off [count N] ]
                [ fast-link-down on|off [msecs N] ]
                [ energy-detect-power-down on|off [msecs N] ]
        ethtool [ FLAGS ] --get-phy-tunable DEVNAME     Get PHY tunable
                [ downshift ]
                [ fast-link-down ]
                [ energy-detect-power-down ]
        ethtool [ FLAGS ] --get-tunable DEVNAME Get tunable
                [ rx-copybreak ]
                [ tx-copybreak ]
                [ tx-buf-size ]
                [ pfc-prevention-tout ]
        ethtool [ FLAGS ] --set-tunable DEVNAME Set tunable
                [ rx-copybreak N ]
                [ tx-copybreak N ]
                [ tx-buf-size N ]
                [ pfc-prevention-tout N ]
        ethtool [ FLAGS ] --reset DEVNAME       Reset components
                [ flags %x ]
                [ mgmt ]
                [ mgmt-shared ]
                [ irq ]
                [ irq-shared ]
                [ dma ]
                [ dma-shared ]
                [ filter ]
                [ filter-shared ]
                [ offload ]
                [ offload-shared ]
                [ mac ]
                [ mac-shared ]
                [ phy ]
                [ phy-shared ]
                [ ram ]
                [ ram-shared ]
                [ ap ]
                [ ap-shared ]
                [ dedicated ]
                [ all ]
        ethtool [ FLAGS ] --show-fec DEVNAME    Show FEC settings
        ethtool [ FLAGS ] --set-fec DEVNAME     Set FEC settings
                [ encoding auto|off|rs|baser|llrs [...] ]
        ethtool [ FLAGS ] -Q|--per-queue DEVNAME        Apply per-queue command.
The supported sub commands include --show-coalesce, --coalesce          [queue_mask %x] SUB_COMMAND
        ethtool [ FLAGS ] --cable-test DEVNAME  Perform a cable test
        ethtool [ FLAGS ] --cable-test-tdr DEVNAME      Print cable test time domain reflectrometery data
                [ first N ]
                [ last N ]
                [ step N ]
                [ pair N ]
        ethtool [ FLAGS ] --show-tunnels DEVNAME        Show NIC tunnel offload information
        ethtool [ FLAGS ] --show-module DEVNAME Show transceiver module settings
        ethtool [ FLAGS ] --set-module DEVNAME  Set transceiver module settings
                [ power-mode-policy high|auto ]
        ethtool [ FLAGS ] --get-plca-cfg DEVNAME        Get PLCA configuration
        ethtool [ FLAGS ] --set-plca-cfg DEVNAME        Set PLCA configuration
                [ enable on|off ]
                [ node-id N ]
                [ node-cnt N ]
                [ to-tmr N ]
                [ burst-cnt N ]
                [ burst-tmr N ]
        ethtool [ FLAGS ] --get-plca-status DEVNAME     Get PLCA status information
        ethtool [ FLAGS ] --show-mm DEVNAME     Show MAC merge layer state
        ethtool [ FLAGS ] --set-mm DEVNAME      Set MAC merge layer parameters
                [ verify-enabled on|off ]
                [ verify-time N ]
                [ tx-enabled on|off ]
                [ pmac-enabled on|off ]
                [ tx-min-frag-size 60-252 ]
        ethtool [ FLAGS ] --show-pse DEVNAME    Show settings for Power Sourcing Equipment
        ethtool [ FLAGS ] --set-pse DEVNAME     Set Power Sourcing Equipment settings
                [ podl-pse-admin-control enable|disable ]
        ethtool [ FLAGS ] -h|--help             Show this help
        ethtool [ FLAGS ] --version             Show version number
        ethtool --monitor               Show kernel notifications
                ( [ --all ]
                  | -s | --change
                  | -k | --show-features | --show-offload | -K | --features | --offload
                  | --show-priv-flags | --set-priv-flags
                  | -g | --show-ring | -G | --set-ring
                  | -l | --show-channels | -L | --set-channels
                  | -c | --show-coalesce | -C | --coalesce
                  | -a | --show-pause | -A | --pause
                  | --show-eee | --set-eee
                  | --cable-test
                  | --cable-test-tdr
                  | --show-module | --set-module )
                [ DEVNAME | * ]

FLAGS:
        --debug MASK    turn on debugging messages
        --json          enable JSON output format (not supported by all commands)
        -I|--include-statistics         request device statistics related to the command (not supported by all commands)
root@BananaPi_BPi-R3 /root [#]#

No i nie bardzo wiem co sprawdzić teraz ...

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

31

Odp: SFP plugin dla LuCI

Pokaż jak wołasz tego ethtool'a

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

32 (edytowany przez Payti 2024-09-18 19:43:44)

Odp: SFP plugin dla LuCI

Tak stoi wywołanie ethtool -m w /usr/libexec/rpcd/sfp

..
function get_ethtool_output(interface)
    return_wrapper = {}
    local ethtool_success, ethtool_return, ethtool_stdout,
        ethtool_stderr = utils.executeex("ethtool --json -m \"" .. utils.quote_arg(interface) .. "\"")

    if (sfp_status[interface] ~= nil) then
        return_wrapper["status"] = sfp_status[interface]
    end
    if (ethtool_success == true) then
        local parsed_ethtool_output = jsonc.parse(ethtool_stdout)
        if (#parsed_ethtool_output == 1) then
            return_wrapper["ethtool"] = parsed_ethtool_output[1]
        end
    end
    return return_wrapper
end
..

cały rpcd.lua co kopiowany był jako /usr/libexec/rpcd/sfp
-->> https://gitlab.com/traversetech/muvirt- … type=heads

a tu sfp.js w /www/luci-static/resources/view/network/sfp.js
-->> https://gitlab.com/traversetech/muvirt- … type=heads

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

33

Odp: SFP plugin dla LuCI

-m nie ma. i --json też nie działa, wiec po prostu wołasz ethtool z interfejsem i parsujesz tekst który jest zwracany.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

34

Odp: SFP plugin dla LuCI

to jak powinna właściwie wyglądać ta linia?

ethtool_stderr = utils.executeex("ethtool --json -m \"" .. utils.quote_arg(interface) .. "\"")
Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

35

Odp: SFP plugin dla LuCI

ethtool_stderr = utils.executeex("ethtool  \"" .. utils.quote_arg(interface) .. "\"")

I wynik jest teksem a nie jsonem, więc musisz napisać ponownie cały parser wyniku.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

36 (edytowany przez Payti 2024-09-18 19:53:49)

Odp: SFP plugin dla LuCI

Taki jest wynik z konsoli ethtool'a z -m i bez:

root@BananaPi_BPi-R3 /root [#]# ethtool -m eth1
        Identifier                                : 0x03 (SFP)
        Extended identifier                       : 0x04 (GBIC/SFP defined by 2-wire interface ID)
        Connector                                 : 0x01 (SC)
        Transceiver codes                         : 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x20
        Transceiver type                          : Ethernet: 1000BASE-LX
        Transceiver type                          : Extended: 100G SWDM4
        Encoding                                  : 0x03 (NRZ)
        BR, Nominal                               : 3200MBd
        Rate identifier                           : 0x00 (unspecified)
        Length (SMF,km)                           : 40km
        Length (SMF)                              : 25500m
        Length (50um)                             : 0m
        Length (62.5um)                           : 0m
        Length (Copper)                           : 0m
        Length (OM3)                              : 0m
        Laser wavelength                          : 1310nm
        Vendor name                               : ALCATELLUCENT
        Vendor OUI                                : 20:20:20
        Vendor PN                                 : 3FE46541AA
        Vendor rev                                : 0001
        Option values                             : 0x00 0x1a
        Option                                    : RX_LOS implemented
        Option                                    : TX_FAULT implemented
        Option                                    : TX_DISABLE implemented
        BR margin, max                            : 0%
        BR margin, min                            : 0%
        Vendor SN                                 : ALCLFAB03537
        Date code                                 : 170314_U
        Optical diagnostics support               : Yes
        Laser bias current                        : 10.496 mA
        Laser output power                        : 1.6002 mW / 2.04 dBm
        Receiver signal average optical power     : 0.0064 mW / -21.94 dBm
        Module temperature                        : 51.85 degrees C / 125.33 degrees F
        Module voltage                            : 3.2999 V
        Alarm/warning flags implemented           : Yes
        Laser bias current high alarm             : Off
        Laser bias current low alarm              : Off
        Laser bias current high warning           : Off
        Laser bias current low warning            : Off
        Laser output power high alarm             : Off
        Laser output power low alarm              : Off
        Laser output power high warning           : Off
        Laser output power low warning            : Off
        Module temperature high alarm             : Off
        Module temperature low alarm              : Off
        Module temperature high warning           : Off
        Module temperature low warning            : Off
        Module voltage high alarm                 : Off
        Module voltage low alarm                  : Off
        Module voltage high warning               : Off
        Module voltage low warning                : Off
        Laser rx power high alarm                 : Off
        Laser rx power low alarm                  : Off
        Laser rx power high warning               : Off
        Laser rx power low warning                : Off
        Laser bias current high alarm threshold   : 40.000 mA
        Laser bias current low alarm threshold    : 2.800 mA
        Laser bias current high warning threshold : 40.000 mA
        Laser bias current low warning threshold  : 2.800 mA
        Laser output power high alarm threshold   : 3.2000 mW / 5.05 dBm
        Laser output power low alarm threshold    : 1.1220 mW / 0.50 dBm
        Laser output power high warning threshold : 3.2000 mW / 5.05 dBm
        Laser output power low warning threshold  : 1.1220 mW / 0.50 dBm
        Module temperature high alarm threshold   : 85.00 degrees C / 185.00 degrees F
        Module temperature low alarm threshold    : -40.00 degrees C / -40.00 degrees F
        Module temperature high warning threshold : 85.00 degrees C / 185.00 degrees F
        Module temperature low warning threshold  : -40.00 degrees C / -40.00 degrees F
        Module voltage high alarm threshold       : 3.4650 V
        Module voltage low alarm threshold        : 3.0410 V
        Module voltage high warning threshold     : 3.4650 V
        Module voltage low warning threshold      : 3.0410 V
        Laser rx power high alarm threshold       : 0.1600 mW / -7.96 dBm
        Laser rx power low alarm threshold        : 0.0015 mW / -28.24 dBm
        Laser rx power high warning threshold     : 0.1600 mW / -7.96 dBm
        Laser rx power low warning threshold      : 0.0015 mW / -28.24 dBm
root@BananaPi_BPi-R3 /root [#]# ethtool eth1
Settings for eth1:
        Supported ports: [ FIBRE ]
        Supported link modes:   2500baseX/Full
                                1000baseX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  2500baseX/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 2500Mb/s
        Duplex: Full
        Auto-negotiation: on
        Port: FIBRE
        PHYAD: 0
        Transceiver: internal
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: yes
root@BananaPi_BPi-R3 /root [#]#

I nie wiem jak wywołać by był json'em

ethtool --json -m eth1  zwraca:

root@BananaPi_BPi-R3 /root [#]# ethtool --json -m eth1
ethtool: bad command line argument(s)
For more information run ethtool -h
root@BananaPi_BPi-R3 /root [#]#

więc problem tkwi w wywałaniu ethtool'a by zwrócił json'a

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

37

Odp: SFP plugin dla LuCI

Sam sprawdziłeś że nie działa z --json.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

38

Odp: SFP plugin dla LuCI

Cezary napisał wyżej, że parametr --json nie działa.

Zaraz wyjdzie, że szybciej będzie napisać pakiet na nowo niż bawić się w adaptację kodu.

Używasz moich pakietów/obrazów z github?
Chcesz abym dalej je rozwijał i tworzył nowe?
Postaw kawę

39 (edytowany przez Payti 2024-09-18 19:57:22)

Odp: SFP plugin dla LuCI

No tak, ale wg info z helpa ma działać z [FLAGS] --json sad

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

40

Odp: SFP plugin dla LuCI

I co zrobisz? Tupniesz nogą i zacznie działać? Nie działa to nie działa robisz inaczej.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

41

Odp: SFP plugin dla LuCI

Payti napisał/a:

No tak, ale wg info z helpa ma działać z [FLAGS] --json sad

Pytanie w takim razie na jakiej wersji ethtool to testowali, że "działało".

Używasz moich pakietów/obrazów z github?
Chcesz abym dalej je rozwijał i tworzył nowe?
Postaw kawę

42

Odp: SFP plugin dla LuCI

-->> https://patchwork.kernel.org/project/ne … se.com.au/

tu coś pisze o patchu --json do ethtool ...

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

43

Odp: SFP plugin dla LuCI

Nie. Odinstaluj pakiet ethtool i zainstaluj pakiet ethtool-full

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

44 (edytowany przez Payti 2024-09-18 20:15:13)

Odp: SFP plugin dla LuCI

Miałem zainstalowane ethtool-full, przeinstalowałem ale dalej 'pupa' --json nie działa ...

root@BananaPi_BPi-R3 /root [#]# opkg remove ethtool
No packages removed.
root@BananaPi_BPi-R3 /root [#]# opkg remove ethtool-full
Removing package ethtool-full from root...
root@BananaPi_BPi-R3 /root [#]# ethtool eth1
-ash: ethtool: not found
root@BananaPi_BPi-R3 /root [#]# opkg install ethtool-full
Multiple packages (libgcc1 and libgcc1) providing same name marked HOLD or PREFER. Using latest.
Installing ethtool-full (6.6-r1) to root...
Downloading https://downloads.openwrt.org/snapshots/packages/aarch64_cortex-a53/base/ethtool-full_6.6-r1_aarch64_cortex-a53.ipk
Configuring ethtool-full.
root@BananaPi_BPi-R3 /root [#]# ethtool eth1
Settings for eth1:
        Supported ports: [ FIBRE ]
        Supported link modes:   2500baseX/Full
                                1000baseX/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  2500baseX/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 2500Mb/s
        Duplex: Full
        Auto-negotiation: on
        Port: FIBRE
        PHYAD: 0
        Transceiver: internal
        Current message level: 0x000000ff (255)
                               drv probe link timer ifdown ifup rx_err tx_err
        Link detected: yes
root@BananaPi_BPi-R3 /root [#]# ethtool -m eth1
        Identifier                                : 0x03 (SFP)
        Extended identifier                       : 0x04 (GBIC/SFP defined by 2-wire interface ID)
        Connector                                 : 0x01 (SC)
        Transceiver codes                         : 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x20
        Transceiver type                          : Ethernet: 1000BASE-LX
        Transceiver type                          : Extended: 100G SWDM4
        Encoding                                  : 0x03 (NRZ)
        BR, Nominal                               : 3200MBd
        Rate identifier                           : 0x00 (unspecified)
        Length (SMF,km)                           : 40km
        Length (SMF)                              : 25500m
        Length (50um)                             : 0m
        Length (62.5um)                           : 0m
        Length (Copper)                           : 0m
        Length (OM3)                              : 0m
        Laser wavelength                          : 1310nm
        Vendor name                               : ALCATELLUCENT
        Vendor OUI                                : 20:20:20
        Vendor PN                                 : 3FE46541AA
        Vendor rev                                : 0001
        Option values                             : 0x00 0x1a
        Option                                    : RX_LOS implemented
        Option                                    : TX_FAULT implemented
        Option                                    : TX_DISABLE implemented
        BR margin, max                            : 0%
        BR margin, min                            : 0%
        Vendor SN                                 : ALCLFAB03537
        Date code                                 : 170314_U
        Optical diagnostics support               : Yes
        Laser bias current                        : 10.416 mA
        Laser output power                        : 1.6298 mW / 2.12 dBm
        Receiver signal average optical power     : 0.0060 mW / -22.22 dBm
        Module temperature                        : 50.85 degrees C / 123.53 degrees F
        Module voltage                            : 3.2999 V
        Alarm/warning flags implemented           : Yes
        Laser bias current high alarm             : Off
        Laser bias current low alarm              : Off
        Laser bias current high warning           : Off
        Laser bias current low warning            : Off
        Laser output power high alarm             : Off
        Laser output power low alarm              : Off
        Laser output power high warning           : Off
        Laser output power low warning            : Off
        Module temperature high alarm             : Off
        Module temperature low alarm              : Off
        Module temperature high warning           : Off
        Module temperature low warning            : Off
        Module voltage high alarm                 : Off
        Module voltage low alarm                  : Off
        Module voltage high warning               : Off
        Module voltage low warning                : Off
        Laser rx power high alarm                 : Off
        Laser rx power low alarm                  : Off
        Laser rx power high warning               : Off
        Laser rx power low warning                : Off
        Laser bias current high alarm threshold   : 40.000 mA
        Laser bias current low alarm threshold    : 2.800 mA
        Laser bias current high warning threshold : 40.000 mA
        Laser bias current low warning threshold  : 2.800 mA
        Laser output power high alarm threshold   : 3.2000 mW / 5.05 dBm
        Laser output power low alarm threshold    : 1.1220 mW / 0.50 dBm
        Laser output power high warning threshold : 3.2000 mW / 5.05 dBm
        Laser output power low warning threshold  : 1.1220 mW / 0.50 dBm
        Module temperature high alarm threshold   : 85.00 degrees C / 185.00 degrees F
        Module temperature low alarm threshold    : -40.00 degrees C / -40.00 degrees F
        Module temperature high warning threshold : 85.00 degrees C / 185.00 degrees F
        Module temperature low warning threshold  : -40.00 degrees C / -40.00 degrees F
        Module voltage high alarm threshold       : 3.4650 V
        Module voltage low alarm threshold        : 3.0410 V
        Module voltage high warning threshold     : 3.4650 V
        Module voltage low warning threshold      : 3.0410 V
        Laser rx power high alarm threshold       : 0.1600 mW / -7.96 dBm
        Laser rx power low alarm threshold        : 0.0015 mW / -28.24 dBm
        Laser rx power high warning threshold     : 0.1600 mW / -7.96 dBm
        Laser rx power low warning threshold      : 0.0015 mW / -28.24 dBm
root@BananaPi_BPi-R3 /root [#]# ethtool --json -m eth1
ethtool: bad command line argument(s)
For more information run ethtool -h
root@BananaPi_BPi-R3 /root [#]#

Ewidentnie -m ma działać z [FLAGS] wg helpa:

        ethtool [ FLAGS ] -m|--dump-module-eeprom|--module-info DEVNAME Query/Decode Module EEPROM information and optical diagnostics if available
                [ raw on|off ]
                [ hex on|off ]
                [ offset N ]
                [ length N ]
                [ page N ]
                [ bank N ]
                [ i2c N ]
..
FLAGS:
        --debug MASK    turn on debugging messages
        --json          enable JSON output format (not supported by all commands)
        -I|--include-statistics         request device statistics related to the command (not supported by all commands)

No ale jest 'not supported by all commands'

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

45

Odp: SFP plugin dla LuCI

Więc zapomnij o tym i parsuj wynik tekstowy.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

46 (edytowany przez Payti 2024-09-18 20:14:14)

Odp: SFP plugin dla LuCI

Cezary napisał/a:

Więc zapomnij o tym i parsuj wynik tekstowy.

To już więc ponad moje siły by samemu przepisać parser z json na tekstowy ...
Chyba, że podpowiecie coś ...

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

47

Odp: SFP plugin dla LuCI

https://stackoverflow.com/questions/142 … ing-in-lua

Czyli najprostsze

line = ...
t = {}
for k, v in string.gmatch(line, "(%w+):(%w+)") do
   t[k] = v
end

I masz klucz i wartość tablicowane.

Nie wiem w ogóle dlaczego uparłeś się żeby to nadal w lua było, przecież luci odchodzi od lua. I że oryginał był w lua napisany to nie jest argument.

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

48

Odp: SFP plugin dla LuCI

A może trzeba ethtool'a z tymi dwoma patchami:

-->> https://patchwork.kernel.org/project/ne … se.com.au/
-->> https://patchwork.kernel.org/project/ne … se.com.au/

?

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti

49

Odp: SFP plugin dla LuCI

W openwrt wersja ethtoola jest sprzed ponad roku. Od tamtej pory było kilka zmian, także tych związanych z jsonem.
Ale ty chyba chciałeś pisać plugin do luci, a nie robić maintenance pakietu ethtoola?

Masz niepotrzebny router, uszkodzony czy nie - chętnie przygarnę go.

50

Odp: SFP plugin dla LuCI

No w tym przypadku jakby zaktualizować ethtoola to by zadziałało wink bo parser jest gotowy ...
Da radę skompilować nowego ethtoola do OWRT please wink ?

Pozdr,

Banana Pi BPI-R3 + SFP GPON ONT Nokia G-010S-A + LTE FIBOCOM L860-GL-16 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.71)
Zyxel T56 EX5601-T1 (OpenWrt 25.12-SNAPSHOT, kernel 6.12.85)
Xiaomi AX3600 (OpenWrt NSS SNAPSHOT, kernel 6.12.92)
OpenWRT NSS builds for Xiaomi AX3600 by @Payti