A small Bash CLI for interacting with a Microchip KSZ9567 Ethernet switch (via Linux SPI / spidev) to do common operational tasks like port status, counters, and initialization.
Run everything through the entrypoint:
./switch_cli.sh <command> [subcommand] [args...]-
Port status / control (e.g., show link state, enable/disable ports)
-
Counters (read and clear per-port statistics)
-
Initialization (apply a known-good init sequence for your board / wiring)
Linux with SPI enabled and a /dev/spidev* device node
spidev_test available in PATH (or adjust the scripts to point to it)
Typically needs sudo to access /dev/spidev*
Quick start
chmod +x switch_cli.sh
sudo ./switch_cli.sh --helpUsage Port status
./switch_cli.sh port status
./switch_cli.sh port status <port> [<port> ...]Enable / disable ports
sudo ./switch_cli.sh port enable <port> [<port> ...]
sudo ./switch_cli.sh port disable <port> [<port> ...]Read / clear counters
sudo ./switch_cli.sh counters read [<port> ...]
sudo ./switch_cli.sh counters clear [<port> ...]Initialize the switch
sudo ./switch_cli.sh switch initProject layout
switch_cli.sh — CLI entrypoint / dispatcher
ksz9567_spi.sh — low-level SPI + register helpers
commands/ — subcommands (ports, counters, switch operations)
Tip: Run switch_cli.sh from the repo root so relative paths resolve correctly.
Safety notes
This tool performs direct register access. Misconfiguration can disrupt traffic.
Run init on a maintenance window the first time, and validate on your target board.
Contributing
PRs welcome—especially for:
Additional subcommands (VLANs, QoS, mirroring, etc.)
Better board/port mapping configuration
Packaging (install script, completion, manpage)