[back to the deck]

network: an Intel 82574L network card, written in l8

Hardware: Enclustra Mercury+ KX2 (AMD Kintex-7 XC7K160T FPGA module) on the Enclustra Mercury+ PE1 base board, in a PC's PCIe x4 slot.

Source: what this page distributes is the Verilog exported by the l8 compiler (l8i --emit, comments stripped), with its constraints and Vivado flow -- the design as Vivado builds it. The l8 sources themselves are not published.

Download and flash

Download: l8network-dist.tar.gz (16M) -- the baseline images with checksums, the flash and JTAG scripts, the host tools, each baseline's design as Verilog with its Vivado build scripts, and the card's security core (CSE) as C source for reading. You need Vivado's hardware manager (vivado, for hw_server) and a Xilinx Platform Cable on the PE1's J1700; the switch settings are in "Program a new KX2 + PE1 card" below. Every flash step reads the areas it overwrites back to a backup file first.

tar xzf l8network-dist.tar.gz && cd l8network
make                                               # the targets, options and these examples

# the GIGABIT network card (baseline gd2): the PC sees an Intel 82574L, 1000 Mbit/s
sh scripts/flash_baseline.sh --dry-run gd2        # the plan: checksums, the area, the backup
sh scripts/flash_baseline.sh gd2                  # = make baseline NAME=gd2; then a full power cycle of the PC

# the WIREGUARD appliance (baseline wg100): the card terminates a WireGuard tunnel, 100 Mbit/s
#   wg-peers.conf: if it does not exist, a few questions make it (the card's IP address, each peer's
#   public key -- or 'new' to make a key pair for the peer --, its address, its tunnel address)
sh scripts/flash_baseline.sh --dry-run wg100 --peers wg-peers.conf
sh scripts/flash_baseline.sh wg100 --peers wg-peers.conf   # = make baseline NAME=wg100 PEERS=wg-peers.conf
#   writes the bitstream, the card's firmware and its key store in one go, prints the
#   configuration secret ONCE (also saved to ~/.wgcard/), and AT THE END the card's PUBLIC key,
#   its address and what to do on the peer (the key also filled into the wizard's
#   wg-peer-<name>.conf and saved to ~/.wgcard/card-<date>.pub); then a full power cycle
#   CARD_KEY=1 (--card-key): the card makes its key itself at its first boot -- the public key
#   is then only on its console (the bench section)

# rebuild a baseline's bitstream from its Verilog (verilog/<name>/; Vivado, an hour or less)
make bit NAME=gd2                                  # wd5, gd2 or wg100

wg-peers.conf describes the other end(s) of the tunnel, in WireGuard's own format, and holds nothing secret of the card. If the file does not exist, the flash step asks a few questions and makes it (with suggestions for each answer; answering new for a peer's key makes a key pair for that peer and writes a ready wg-peer-<name>.conf for it). Written by hand it looks like this:

[Peer]
PublicKey  = <the remote peer's public key>     # on a Linux peer: wg show <if> public-key
Endpoint   = 203.0.113.7:51820                  # where the peer listens; optional if only the peer starts
AllowedIPs = 10.8.0.3/32                        # the tunnel addresses behind that peer
# PresharedKey = <from wg genpsk>                optional
# PersistentKeepalive = 25                      optional, behind NAT

Several [Peer] blocks are allowed. The order: set up the remote peer and read its public key; write the file; flash -- the card's public key is printed at the end -- and add the card as a peer on the remote side (copy the wizard's wg-peer-<name>.conf, or wg set <if> peer <the card's key> endpoint <CardAddress>:51820 allowed-ips 10.8.0.2/32). No further access to the card is needed.

sh scripts/flash_baseline.sh NAME HOST:PORT ... uses a remote hw_server (the argument after the baseline's name); without it the local one is used. The details: docs/FLASH.md; the bench path with only the Platform Cable (no PC): "On the bench" below. The output of a real WireGuard flash, question by question: the WireGuard section below, "What to expect".

The KX2 on the PE1 in the test PC's PCIe slot, Eth0 and Eth1 cabled; the USB JTAG cable on top

The KX2 on the PE1 in the test PC's PCIe slot, Eth0 and Eth1 cabled; the USB JTAG cable on top.

The card of the House of cards that is done. An Enclustra Mercury+ KX2 FPGA module (AMD Kintex-7 XC7K160T-2) on its Mercury+ PE1 base board, in a PC's PCIe slot. The PC sees an Intel 82574L Gigabit Network Connection (8086:10d3) and drives it with the driver it already has: e1000e under Linux, the inbox e1i65x64 under Windows 10. The 82574L's registers, its descriptor rings, MSI-X, checksum offload and TCP segmentation are written in l8; the Ethernet leaves through the PE1's left RJ45 (Eth0).

Program a new KX2 + PE1 card

The hardware: an Enclustra Mercury+ KX2 module on a Mercury+ PE1 base board, a PC with a free PCIe x4 (or wider) slot, a Xilinx Platform Cable USB II (or a compatible JTAG cable) and Vivado's hardware server (hw_server, Vivado 2026.1 or later) on the machine the cable is plugged into -- the PC itself or another machine on the network.

1. The switches -- set them with the board UNPOWERED and no USB cable plugged in (the PE1's system controller reads CFG B when power first reaches the board). From the Mercury+ PE1 User Manual V08 (sections 5.2-5.5, 6.3) and the Mercury KX2 User Manual V08 (section 3.3):

switch position why
S1900 power slide PCIe (1-2) 12 V from the PC's slot
CFG A 1 (BOOT_MODE0) ON the FPGA boots from its QSPI flash
CFG A 2 (USB_PWR_EN#) OFF no power over USB -- required when the board is powered over PCIe
CFG A 3 (SDIO_SEL) OFF unused
CFG A 4 (PWR_ON#) ON the module powers up with the PC, no PWR button press
CFG B 1 (USB_ID) OFF
CFG B 2 (USB_SEL) OFF (B1 OFF + B2 ON is forbidden)
CFG B 3 (SCMODE0#) OFF ON turns the system controller into a JTAG programmer on the same lines and blocks the external cable
CFG B 4 (SCMODE1#) OFF
USER 1..4 (S1101) any not read by these designs
J2000 jumpers 9-10 and 3-4

2. Into the PC: the card in a PCIe x4 (or wider) slot; the JTAG cable on the PE1's header J1700 (the module's own USB JTAG did not find the device in our tests), its USB end at the machine running hw_server.

3. Power the PC on. A blank card does not show up on the PCIe bus yet -- that is fine.

4. Write a baseline into the flash (from the unpacked archive, on the machine with Vivado):

sh scripts/flash_baseline.sh gd2                       # gigabit;  wd5 = the 100 Mbit/s baseline
sh scripts/flash_baseline.sh gd2 otherhost:3121        # hw_server on another machine
sh scripts/flash_baseline.sh --dry-run gd2             # only check the files, print the Vivado command

It checks baseline/SHA256SUMS (nothing is written on a mismatch), saves the flash's first 8 MB to flash_backup/, then erases, programs, verifies and boots the FPGA from the flash.

5. Power the PC OFF and on again (a full power cycle): the card now boots from its flash before the BIOS scans the bus. Linux: lspci -nn -k -d 8086:10d3 shows the 82574L with e1000e; Windows 10: "Intel(R) 82574L Gigabit Network Connection" in the Device Manager, no driver to install. An Ethernet cable from the PE1's LEFT RJ45 (Eth0) to your switch.

6. Later: the same script writes another baseline. For tests, sh scripts/jtag_load.sh baseline/<image>.bit loads a bitstream over JTAG without touching the flash: it stays over a warm reboot and is gone after a power cycle (remove the PCI device before, rescan after: docs/FLASH.md). The whole procedure, with the recovery from a bad flash: docs/FLASH.md.

On the bench: flash and provision the WireGuard baseline with only the Platform Cable

Status: TESTED end to end on 2026-11-30 by a user with only this archive: on the bench make baseline NAME=wg100 PEERS=wg-peers.conf asked its questions, wrote key store, firmware and bitstream (all verified) and printed the card's public key; the card then went into a Windows PC, the printed commands set up the peer, the card's LAN settings and the PC's tunnel address -- the PC pinged the peer through the tunnel (the peer's wg show: the card at 192.168.1.251:51820, a fresh handshake). Step 5, reading the key over JTAG, is only needed with --card-key now.

The card is flashed and provisioned on a table, outside any PC, with nothing attached but the 12 V supply and the Xilinx Platform Cable; afterwards it goes into the PC. One machine does everything: the laptop with Vivado (2026.1 or later) and the Platform Cable plugged into it -- scripts/flash_baseline.sh without a HW_SERVER argument uses the laptop's own hardware server. Page and table numbers: Mercury+ PE1 User Manual V08.

1. The board on the table. The PE1 with the KX2 out of the PC; nothing plugged in yet.

2. The peers file, on the laptop: the remote WireGuard peer(s) the card will talk to, in wg's format. The card's own key is never in it (the flash step makes the card's identity key; a PrivateKey line is refused).

[Interface]
ListenPort = 51820

[Peer]
PublicKey = <the remote peer's public key, base64, from `wg show <iface> public-key` there>
Endpoint = 192.0.2.1:51820
AllowedIPs = 10.8.0.3/32
PersistentKeepalive = 25

(PresharedKey and up to 8 IPv4 AllowedIPs per peer are taken too; the addresses here are examples.)

3. Flash and provision -- the dry run first:

sh scripts/flash_baseline.sh --dry-run wg100 --peers wg-peers.conf    # the checks and the plan, nothing written
sh scripts/flash_baseline.sh wg100 --peers wg-peers.conf              # the real run, the laptop's hw_server

The real run checks baseline/SHA256SUMS, makes the keystore record on the laptop, then in one Vivado session: reads back every region it will touch (the bitstream's 8 MB and CSE slot A to flash_backup/, the old key store to ~/.wgcard/), writes and verifies the key store record (0x03F8_0000 / 0x03FC_0000), the CSE firmware (slot A, 0x0200_0000) and the bitstream (at 0), and boots the FPGA. The CONFIG SECRET is printed once and saved to ~/.wgcard/config-secret-<date> (mode 600): keep that file -- changing the card's peers later needs it. The record's own files are deleted after the session. At the very end it prints the card's PUBLIC key (saved to ~/.wgcard/card-<date>.pub), its address and the line to run on the peer. No PC means no PCIe device to remove or rescan.

4. Power-cycle the board: 12 V off, then on. The FPGA loads its image from the flash; the CSE's boot loader checks the firmware's BLAKE2s hash and starts slot A; the CSE takes the card's identity key from the key store and prints only the public key on its console (with --card-key: at this FIRST boot it derives the key, stores it and prints the public key). (The CSE and the debug link run on the board's 100 MHz oscillator through the FPGA's PLL, not on the PCIe clock: I follow a lead that the CSE boots and prints its key without a PCIe host on the bench -- the first bench run confirms it.)

5. (Optional -- only with --card-key, or to check) Read the card's public key over the same Platform Cable (JTAG; no Ethernet needed). Without --card-key step 3 already printed it; the console shows the same key. The JTAG proxy holds a Vivado hardware-manager session on the cable and relays the debug link's datagrams on 127.0.0.1:0x8EF4:

(cd host/l8/net/host && python3 -m l8net.jtag_proxy --lag auto) &           # Vivado found as for flash_baseline.sh
python3 host/l8/cpu/x86/cse/tools/cse_con.py --jtag --bus 2 status         # "boot: slot A ... vfy A booted"
python3 host/l8/cpu/x86/cse/tools/cse_con.py --jtag --bus 2 cat | grep 'ks: public key'
kill %1                                                                    # the proxy owns the cable: stop it

ks: public key <BASE64> is the card's WireGuard public key: enter it at the remote peer (wg set <iface> peer <BASE64> endpoint <the card's outer IPv4>:51820 allowed-ips <the PC's tunnel address>/32). --lag auto measures the cable's TDO lag on an idle pipe; if it refuses ("needs an idle pipe"), start the proxy with --lag 0 (the value the KX2 measured every time in the lab). The JTAG proxy owns the cable: stop it before any flash_baseline.sh or jtag_load.sh, and stop a running Vivado hardware manager before starting the proxy.

6. Into the PC. 12 V off and unplugged; S1900 back to 1-2, "PCIe"; the card into the PC's PCIe slot; the Platform Cable may stay on J1700; Eth0 (the left RJ45) to the LAN. Power the PC on: the PC sees a plain Intel 82574L (lspci -nn -k -d 8086:10d3 with e1000e). Then the card's LAN words -- its outer IPv4 and MAC on Eth0's LAN, the router, the tunnel's virtual gateway -- once after every power-up, until the key store record carries them (record v2, open):

python3 host/l8/bus/pcie/designs/network/host/wgcard.py --jtag --bus 1 --base 0 setup \
    --card-ip 192.0.2.10 --card-mac 02:00:00:00:00:10 --mask 255.255.255.0 --router 192.0.2.254 \
    --gw-ip 10.8.0.1 --gw-mac 02:00:00:00:00:01

over JTAG with the proxy started again as in step 5 (stopped afterwards), or with --udp 192.168.1.250 instead of --jtag over the Eth1 debug link (Eth1 cabled to a trusted bench network: the debug link has no authentication, see "How far the protection goes" in README.md). No --allowed: the CSE writes the peers' AllowedIPs from the key store. wgcard.py needs Python's cryptography package (pip install cryptography); cse_con.py, the proxy and flash_baseline.sh need nothing beyond Python 3 and Vivado. wgcard.py --jtag --bus 1 stats then shows wg_net's configuration and counters.

The images this export carries

The archive ships three baseline images: two plain network cards, proven on Linux and Windows and booted from the flash, and the WireGuard appliance:

Baseline What State
wd5 (baseline/network_kx2_wd5) the 82574L at 100 Mbit/s the first baseline (2026-11-29): Linux TCP 94.1 / 93.9 Mbit/s, Windows 10 soak clean, a power cycle from the flash
gd2 (baseline/network_kx2_gd2) the 82574L at 1000 Mbit/s (RGMII on Eth0, the line-rate DMA) on the board and in the flash since 2026-11-29: Linux TCP 885 / 941 Mbit/s, Windows 10 soak clean
WireGuard the same card as a WireGuard appliance: the PC sees a plain 82574L, the card terminates the tunnel -- ChaCha20-Poly1305 in hardware, the handshake on the card's own x86 control core (CSE-lite, a MINIX-style threader), keys in the card's flash; 100 Mbit/s so that everything fits the KX2 baseline/network_kx2_wg100 (+ cse_fw_a.mcs, the CSE's firmware, and its manifest): proven on the board in a PC on 2026-11-30 under Linux -- the CSE boots from the flash, makes its identity key, does the handshake itself with a laptop's kernel WireGuard, iperf3 90.6 / 90.3 Mbit/s; and under Windows 10 from the flash: ping through the tunnel, 30 MB both ways md5-equal (baseline/BASELINE.md section 3); the debug link stays in (see "How far the protection goes")

Each baseline's design ships as Verilog with its own Vivado build scripts: verilog/wd5/, verilog/gd2/, verilog/wg100/ (the very builds the images came from; make bit NAME=... rebuilds one).

Both come from the same reusable units, chosen by a build profile (link speed, debug on/off, memory style, crypto sharing, control core), so a bigger FPGA later gets a gigabit WireGuard from the same sources.

The WireGuard appliance (the tunnel runs; the control core in development)

A further baseline will turn the same card into a WireGuard tunnel in hardware. The PC still sees a plain Intel 82574L with its inbox driver -- no VPN software, no driver change -- and the card terminates the tunnel itself.

What to expect: flashing the WireGuard baseline (a real run, 2026-11-30)

make baseline NAME=wg100 PEERS=wg-peers.conf started from scratch (no wg-peers.conf yet), the card on the bench (S1900 on external power, the Platform Cable on J1700). The card later goes into a PC in a home LAN 192.168.1.0/24 (router .1): the card gets 192.168.1.251, the peer is a laptop at 192.168.1.183. Anonymized: the configuration secret is not shown, paths are shortened, Vivado's own chatter is left out (about 8 minutes, most of it backups).

Two things this run taught (both fixed since): the laptop that flashed was online over a phone hotspot (172.20.10.x), so the suggestions for the card's address and the peer's endpoint were that network's -- the right answers were typed in; the questions now list the computer's networks and say that the card's network may differ. And the peer's endpoint was typed into the name question, which named the peer file after it -- names are now letters, digits, - and _ only.

$ make baseline NAME=wg100 PEERS=wg-peers.conf
VIVADO=vivado sh scripts/flash_baseline.sh wg100  --peers wg-peers.conf 
flash_baseline: network_kx2_wg100.mcs -- checksums ok
wg-peers.conf does not exist -- a few questions make it.  Press Enter to take the suggestion in [brackets];
Ctrl-C stops at any time and nothing is written.

   WHAT THIS IS: the card will be one end of a WireGuard tunnel (an encrypted link, like a VPN).
   The other end is a PEER: a computer running WireGuard -- for example this laptop, a Linux server or
   a router.  Each peer has a KEY PAIR: a secret half it keeps, and a PUBLIC half it shows to others.
   This file only holds what the card needs to know about its peers -- public things, nothing secret
   of the card.  The card's own key pair is made when it is flashed; its public key is printed then.

1) THE CARD'S ADDRESS
   The card gets its own IPv4 address in your local network (on its Eth0 socket, the left RJ45).
   The peers send their encrypted packets to it.  Choose an address that is free -- not used by any
   other device, and outside the range your router hands out automatically (DHCP).
   Suggestion: an address high up in this computer's network (172.20.10.x).
   the card's IP address [172.20.10.251]: 192.168.1.251

2) HOW MANY PEERS
   Usually one: the computer at the other end of the tunnel.  Up to 16 are possible.
   number of peers [1]: 

3) PEER 1 of 1
   a name for this peer (only a note for you) [laptop]: 192.168.1.183:51820

   Its PUBLIC KEY (44 characters, ending in '=').
   If WireGuard already runs on the peer, show it there with:   sudo wg show <interface> public-key
   If not, answer 'new': a fresh key pair is made here, and a ready configuration file for the peer
   is written next to this file -- copy it to the peer (it contains the peer's SECRET key).
   the peer's public key, or 'new' [new]: 
   made a key pair for 192.168.1.183:51820

   Its ADDRESS and PORT, where the card can reach it (e.g. 172.20.10.5:51820 if this computer is the peer).
   Leave it empty if the peer always starts the connection itself (e.g. a laptop that moves around).
   the peer's endpoint IPv4:port [172.20.10.5:51820]: 192.168.1.183:51820

   Its TUNNEL ADDRESS(ES): the addresses that live inside the tunnel on the peer's side.  The card sends
   packets for them into the tunnel and accepts from this peer only packets from them.
   A single tunnel address per peer is typical, e.g. 10.8.0.3/32.  (The PC with the card gets 10.8.0.2.)
   the peer's tunnel address(es) [10.8.0.3/32]: 

   A PRESHARED KEY is an optional extra secret that both sides must share -- more protection, one more
   thing to copy.  'n' = none (fine for a start), 'y' = make one now.
   preshared key (y/n) [n]: 

   KEEPALIVE: if the card sits behind a NAT router, a small packet every 25 seconds keeps the path
   open.  Empty = off (fine in one local network).
   keepalive seconds: 

---- wg-peers.conf ----

[Interface]
CardAddress = 192.168.1.251

[Peer]
PublicKey = R/xOFvZklNFjTaWIWJk7Fwbf18xxwnoTLuIreeGU2CU=
Endpoint = 192.168.1.183:51820
AllowedIPs = 10.8.0.3/32
----
write it [y]: y
peers-wizard: wg-peers.conf written (mode 600)
peers-wizard: wg-peer-192.168.1.183:51820.conf written (mode 600) -- the peer's own configuration; copy it to 192.168.1.183:51820
wgcard provision-image: the keystore record ([system_net-14d]): 2152 bytes (NP 16, 1 peer, listen port 51820, the identity key made here on this machine, SEED clear: the card takes it as it is)
  peer 0: R/xOFvZklNFjTaWIWJk7Fwbf18xxwnoTLuIreeGU2CU=  endpoint 192.168.1.183:51820  allowed 10.8.0.3/32  keepalive 0
  the unit: 2 x 0x40000 bytes at 0x03F80000 .. 0x04000000 (wgks.mcs), the snapshot at generation 2 and 1
CONFIG SECRET (shown ONCE; saved to ~/.wgcard/config-secret-2026-11-30-195229, mode 600):
  <the secret, 44 characters -- not shown here>
the card's PUBLIC key: b4wJ5v6POXo28gvf/jt3DjN2Yv/bD69gUP/MduqpHXY=
CARD_PUBLIC_KEY b4wJ5v6POXo28gvf/jt3DjN2Yv/bD69gUP/MduqpHXY=
PROVISION_DIR ~/.wgcard/provision-2026-11-30-195048
PROVISION_MCS ~/.wgcard/provision-2026-11-30-195048/wgks.mcs
wgcard provision-image: ~/.wgcard/provision-2026-11-30-195048 holds the identity key and the config secret -- delete it after the flash (flash_baseline.sh does)
flash_baseline: the plan (one Vivado session; every backup before the first erase; written keystore, cse, bit):
  bit  0x00000000 .. 0x00800000 (the bitstream at 0)
     file    baseline/network_kx2_wg100.mcs
     sha256  9d2ffcf6f927fb428019fd2339a21640a06191fae9883d640c08b661ea7266b5
     backup  flash_backup/before-network_kx2_wg100-2026-11-30-195048-bit.bin
  cse_a  0x02000000 .. 0x02800000 (the CSE firmware, slot A)
     file    baseline/cse_fw_a.mcs
     sha256  2a8a203ce0cc8b5f0b8666ffaa3f6f7112a74c05ac05e1e553fed89058a00a18
     backup  flash_backup/before-network_kx2_wg100-2026-11-30-195048-cse_a.bin
  keystore  0x03F80000 .. 0x04000000 (the keystore unit, made in this run)
     file    ~/.wgcard/provision-2026-11-30-195048/wgks.mcs
     sha256  2c921b15c085ead62ca87c600045d775d425bf6d320dee0be1847b2827f19702
     backup  ~/.wgcard/backup-keystore-network_kx2_wg100-2026-11-30-195048.bin
flash_baseline: the PC loses the card while the FPGA reloads -- remove its PCI device first (see --help)

FLASH_PLAN keystore data 0x03F80000 .. 0x04000000 (524288 bytes), sectors 0x03F80000 .. 0x04000000, window 0x03F80000 .. 0x04000000, ~/.wgcard/provision-2026-11-30-195048/wgks.mcs; backup ~/.wgcard/backup-keystore-network_kx2_wg100-2026-11-30-195048.bin
FLASH_PLAN cse_a    data 0x02000000 .. 0x0202306C (143468 bytes), sectors 0x02000000 .. 0x02040000, window 0x02000000 .. 0x02800000, baseline/cse_fw_a.mcs; backup flash_backup/before-network_kx2_wg100-2026-11-30-195048-cse_a.bin
FLASH_PLAN bit      data 0x00000000 .. 0x004A0C6C (4852844 bytes), sectors 0x00000000 .. 0x004C0000, window 0x00000000 .. 0x00800000, baseline/network_kx2_wg100.mcs; backup flash_backup/before-network_kx2_wg100-2026-11-30-195048-bit.bin

FLASH_TARGET localhost:3121/xilinx_tcf/Xilinx/usb3.88 xc7k160t_0

FLASH_BACKUP keystore ~/.wgcard/backup-keystore-network_kx2_wg100-2026-11-30-195048.bin 524288 bytes from 0x03F80000

FLASH_BACKUP cse_a flash_backup/before-network_kx2_wg100-2026-11-30-195048-cse_a.bin 8388608 bytes from 0x02000000

FLASH_BACKUP bit flash_backup/before-network_kx2_wg100-2026-11-30-195048-bit.bin 8388608 bytes from 0x00000000

Program/Verify Operation successful.

FLASH_WRITTEN keystore ~/.wgcard/provision-2026-11-30-195048/wgks.mcs (verified)

Program/Verify Operation successful.

FLASH_WRITTEN cse_a baseline/cse_fw_a.mcs (verified)

Program/Verify Operation successful.

FLASH_WRITTEN bit baseline/network_kx2_wg100.mcs (verified)

DONE_AFTER_BOOT 1

flash_baseline: written; the backups of the flash before: flash_backup/before-network_kx2_wg100-2026-11-30-195048-*.bin, ~/.wgcard/backup-keystore-network_kx2_wg100-2026-11-30-195048.bin (the card's old keys: mode 600, keep it private)
flash_baseline: the record's files (identity key, secret) deleted; the CONFIG SECRET stays in ~/.wgcard/config-secret-*
flash_baseline: now rescan (echo 1 > /sys/bus/pci/rescan, as root) or power-cycle the PC

==== THE CARD's PUBLIC KEY (WireGuard) =========================================================
  b4wJ5v6POXo28gvf/jt3DjN2Yv/bD69gUP/MduqpHXY=
  (public, not secret; saved to ~/.wgcard/card-2026-11-30-195907.pub)
  the card's address: 192.168.1.251, port 51820
ON THE PEER(S):
  - copy wg-peer-192.168.1.183:51820.conf to the peer (the card's key is filled in), e.g. as /etc/wireguard/wg-l8.conf,
    then on the peer:  sudo wg-quick up wg-l8
  - or an existing WireGuard peer: add the card to it:
      sudo wg set <interface> peer b4wJ5v6POXo28gvf/jt3DjN2Yv/bD69gUP/MduqpHXY= endpoint 192.168.1.251:51820 allowed-ips 10.8.0.2/32
================================================================================================

Afterwards: S1900 back to "PCIe", the card into the PC; on the peer, the printed wg-peer-<name>.conf (the card's key filled in) as /etc/wireguard/wg-l8.conf, then sudo wg-quick up wg-l8.

The WireGuard appliance: the data path in hardware, the control path on the card's own x86 core

The data path, in hardware, at line rate. Frames from the PC are classified by the peers' AllowedIPs (a longest-prefix match); tunnel traffic is encrypted with ChaCha20-Poly1305 (RFC 8439) and leaves as WireGuard type-4 messages in UDP; received messages are looked up by their receiver index, checked against the replay window before decryption, decrypted, tag-checked, and handed to the PC with a synthesized Ethernet header. Proxy ARP answers for the tunnel subnet. Built and tested in simulation: 1420-byte packets both ways at once keep up with gigabit at 125 MHz.

The control path, on the card's own x86 core. Like Intel's Management Engine, which runs MINIX on a small 486-class core, the card carries a stripped x86 core (CSE-lite: i486-class, flat protected mode from reset, no BIOS, no x87, only the instructions the firmware uses, running from block RAM) with a MINIX-style microkernel of fixed threads: wg (the Noise IKpsk2 handshake), cfg (configuration), ks (the key store), con (console). The handshake's crypto runs on hardware engines: X25519 (RFC 7748, about 1.2 ms at 50 MHz), BLAKE2s (RFC 7693) with HMAC/HKDF, ChaCha20-Poly1305 -- so a handshake takes a few milliseconds even on a slow core.

Where the keys come from.

  1. The card's identity key (WireGuard's static secret) is made by the flash step on the flashing machine (the operating system's random generator, as wg genkey does) and written into the card's key store in the QSPI flash; the flash prints its PUBLIC key at the end, so the peer can be set up with no further access to the card. The secret half exists on the flashing machine only in the key store record's files, which the flash step deletes. On the card it never leaves through any of its interfaces (but see "How far the protection goes" below: the flash chip itself can be read out with physical access). Option --card-key (make baseline ... CARD_KEY=1): the card makes the key itself at its first boot (from a seed in the record and its own timing samples); its public key is then only on the card's console.
  2. Peers (public keys, pre-shared keys, endpoints, AllowedIPs) come from the PC in WireGuard's own configuration format (wg setconf style), each request signed with a configuration secret (HMAC-BLAKE2s).
  3. The configuration secret is set once, with physical access: it is written when the WireGuard baseline is flashed over JTAG (below), generated on the flashing machine and handed to the user once.
  4. Session keys never come from outside: the card's handshake makes them every two minutes and writes them, write-only, into the data path's key table.

Setting up a WireGuard card, end to end (in development). The whole chain, from flashing a new card to changing a peer later. Choosing the WireGuard baseline is the provisioning: one flash step writes the image, the core's firmware and the key store together.

┌─ 1  FLASH (once, physical access: the JTAG cable on J1700) ──────────────────────────────────────────┐
│ flash_baseline.sh wg100 --peers wg-peers.conf     on the flashing machine                            │
│   bitstream  -> flash 0x0000_0000      the card's FPGA image (82574L + wg_net + CSE-lite)            │
│   firmware   -> flash 0x0200_0000 (A)  the CSE's threader, a BLAKE2s-hashed image                    │
│   keystore   -> flash 0x03F8_0000 +    the record: the card's identity key and the configuration     │
│                0x03FC_0000 (2 copies)  secret (both made here; the secret shown once, kept by the    │
│                                       user) and the peers                                            │
│   at the end: the card's PUBLIC key, its address, what to do on the peer                             │
│   a backup of every area first                                                                       │
└──────────────────────────────────────────────────────────────────────────────────────────────────────┘
        │
        ▼  power the PC off and on
┌─ 2  FIRST BOOT (on the card, no host software) ──────────────────────────────────────────────────────┐
│ the FPGA loads its image from flash; the PC sees a plain Intel 82574L                                │
│ the boot loader copies the firmware into the CSE's RAM, checks its hash, starts it (A, else B)       │
│ the CSE reads the keystore and takes the identity key from it; it never leaves the card.  Only its   │
│ PUBLIC key is shown (console, status page).  (--card-key: no key yet -> the CSE makes one from       │
│ the record's seed and its timing samples and stores it)                                              │
└──────────────────────────────────────────────────────────────────────────────────────────────────────┘
        │
        ▼  the user enters the card's public key (printed at the end of 1) at the remote peer(s)
┌─ 3  RUNNING ─────────────────────────────────────────────────────────────────────────────────────────┐
│ the CSE: WireGuard handshakes with the peers (X25519 / BLAKE2s engines), new session keys            │
│          every 2 minutes, written write-only into the data path's key table                          │
│ the data path: the PC's packets for AllowedIPs are encrypted (ChaCha20-Poly1305) and sent            │
│          from Eth0 to the peer; the peer's packets are checked, decrypted, handed to the PC          │
│ the PC: an ordinary network card; no VPN software, no driver of ours                                 │
└──────────────────────────────────────────────────────────────────────────────────────────────────────┘
        │
        ▼  later, from the PC holding the card
┌─ 4  CHANGES AND STATUS (the management address, PCIe side only) ─────────────────────────────────────┐
│ status page (read-only): the card's public key, peers, last handshake, counters                      │
│ wgcard.py setconf: add / change peers -- each request signed with the configuration secret           │
│ a new card owner / a lost secret: flash again over JTAG (wipes the keystore)                         │
└──────────────────────────────────────────────────────────────────────────────────────────────────────┘

Where each secret lives: the identity key inside the card (made by the flash step, its files on the flashing machine deleted after the flash; never readable from the card); the configuration secret in the card's key store and with the user who flashed it; the session keys only in the card's key table (made by the card's handshake, never readable); the peers' public keys are not secret. Physical access (the JTAG cable) is needed for the first provisioning and for a reset; everything else goes through the PC.

Example: the card facing the internet (documented, not yet run)

The test above stayed inside one home network. Facing the internet, two setups are common; in both the card keeps a fixed address in the home LAN (here 192.168.1.251, router 192.168.1.1) and the internet sees the home router's public address (here 203.0.113.10 -- a documentation address; use yours, or a dynamic-DNS name).

                                        internet                                      LAN
┌──────────────────────────────┐                        ┌───────────────────────────┐         ┌─────────────────────────────┐
│ remote peer (on the road)    │                        │ home router 203.0.113.10  │         │ the card 192.168.1.251      │
│ WireGuard, tunnel 10.8.0.3   │ ─────────────────────▶ │ forwards UDP 51820        │ ──────▶ │ in the PC (tunnel 10.8.0.2) │
│ Endpoint 203.0.113.10:51820  │ ◀───────────────────── │ to 192.168.1.251          │ ◀────── │ Eth0 to the home LAN        │
└──────────────────────────────┘                        └───────────────────────────┘         └─────────────────────────────┘

A -- the remote peer calls home (a laptop on the road). On the home router: forward UDP port 51820 to 192.168.1.251. The questions for wg-peers.conf: the card's IP 192.168.1.251; the peer's public key; its endpoint EMPTY (a travelling peer has no fixed address -- the card answers wherever the peer's packets come from); its tunnel address 10.8.0.3/32; keepalive empty. On the remote peer (the new answer writes this file for it, wg-peer-.conf): Endpoint = 203.0.113.10:51820 (the router's public address, not the card's), the card's public key, AllowedIPs = 10.8.0.2/32, PersistentKeepalive = 25 (keeps its own NAT open).

B -- the card calls out (to a server with a fixed public address, e.g. 198.51.100.7). No port forwarding at home. The questions: the card's IP 192.168.1.251; the server's public key; its endpoint 198.51.100.7:51820; its tunnel address(es); keepalive 25 (the card keeps the home router's NAT mapping open). On the server: the card as a peer with its public key, no Endpoint (it learns the card's address from its packets), AllowedIPs = 10.8.0.2/32.

In both: the card needs its LAN settings (the router as its gateway) -- in this first baseline they come over the debug link after each power-up: wgcard.py ... setup --card-ip 192.168.1.251 --mask 255.255.255.0 --router 192.168.1.1 ... (the key store's next version carries them). And: the card is a WireGuard endpoint, NOT a firewall -- whatever is not tunnel traffic passes between the PC and Eth0 as on any network card, so the PC needs its own firewall as before; keep Eth1 (the debug link) off any network the internet can reach.

How far the protection goes. "Never leaves the card" means: no interface of the card -- the PC, the network, the status page, the configuration channel -- ever hands out the identity key or the configuration secret. It does not protect against someone with the card in their hands. The key store sits in the card's ordinary SPI flash, in plain form in this first version: a clip on the flash chip reads it out, and so does anyone with the JTAG cable (the same path that flashes the card can read the flash back). So keep the card as physically safe as the key would need to be. The identity key is made on the flashing machine (since 2026-11-30, the default; the author's choice -- "otherwise it is overkill"): it exists there during the flash step, in the key store record's files, which the step deletes afterwards -- so use a flashing machine you trust. Making it on the card instead (--card-key) avoids that but gains little today: the key store is plain in the flash anyway, and the card's own TRNG is planned only. Planned: the key store wrapped (AES key wrap) under a device key the FPGA keeps in its own battery- backed or one-time key storage, so a flash read-out alone shows nothing useful.

This baseline's debug link is open -- keep Eth1 on a trusted bench network, or unplugged. The WireGuard baseline in this archive (profile wg100) keeps the card's debug facility: over UDP on Eth1 (and over JTAG) anyone who reaches it reads and writes the card's debug buses without any authentication -- bus 1 is the data path's key table (session keys can be installed there: wgcard.py), bus 2 the CSE's console. The production profile (wg100p) has no debug link; it is not a baseline yet.

The CSE's program can be re-flashed. The CSE's firmware lives in the same SPI flash (slot A at 0x0200_0000, slot B at 0x0280_0000) and is written exactly like the bitstream at 0: with the JTAG cable (flash_baseline.sh) or a clip on the flash chip. That is the update path -- and it means whoever can write the flash can run their own firmware on the card, and whoever controls the firmware controls the card, its identity key included. Each slot's image carries a BLAKE2s hash that the boot loader checks: that catches a corrupted image, NOT a forged one -- there is no signature yet (an authenticated image, HMAC or signature, is specified only).

The attack surface of CSE-lite, as it stands (an assessment, not an audit; nothing here has been fuzzed or attacked on purpose):

surface what an attacker can do protection today planned
JTAG cable (J1700) everything: load any bitstream, read and write the whole flash (bitstream, firmware, key store) physical access only -- (physical security)
SPI flash (a clip on the chip) read the key store (identity key, config secret: plain in v1); write a firmware or a key store record of their own physical access only key store wrapped under a device key held in the FPGA; an authenticated firmware image
firmware slots A / B a forged firmware boots if the attacker can write the flash BLAKE2s hash per image: corruption is detected, forgery is not HMAC / signature over the image
key store records a CORRUPTED record is detected (CRC) and the other copy used (two copies, the newest valid one wins); a CRAFTED record with a recomputed CRC is accepted -- writing one needs physical access CRC, two copies wrapped record (v2); the parser's robustness against crafted records is not fuzz-tested: an open item
Eth0, the network send WireGuard handshake messages (types 1 / 2 / 3), which the CSE parses wg_net passes only messages of the exact size, at most 16 a second (one global rate limit), mac1 checked; the Noise code works in fixed-size buffers cookies (mac2, not built): without them a flood can stop handshakes -- a denial of service, not a key leak; fuzzing the handshake parser
the PC (PCIe) today nothing reaches the CSE from the PC -- the management address: configuration requests signed with the config secret, a read-only status page
Eth1 debug link (this baseline) read / write the key table (install session keys), read the console, read the card's debug words none: no authentication profile wg100p without the debug link
inside the CSE a bug in one thread reaching another's resources threads with their own page tables; only ks maps the key store window, only wg the crypto engines' windows; I/O ports guarded by the I/O bitmap ([cse-01]'s fix, tested on the board); the data path's key table is write-only for session keys (no read-back) --
randomness a weak identity key if the source were weak the key comes from the flashing machine's random generator (os.urandom); with --card-key a seed from there mixed with timing samples on the card the card's own TRNG (plan only)
side channels timing of the X25519 / BLAKE2s engines not assessed an assessment

How the PC talks to the card's core (planned). No driver of our own: the PC reaches the card's x86 core through its ordinary network stack. It sends to the card's management address like to any host behind that adapter -- the frames go down the card's transmit ring as usual, and a filter in the card takes them to the core instead of out of Eth0. The management address exists only on the PCIe side: it never appears on the Eth0 cable, and the same address arriving from Eth0 is dropped. Three addresses in all:

     the PC (Windows / Linux)                 the card                                    the LAN
  ┌──────────────────────────────┐    ┌───────────────────────────────────────────┐
  │ the 82574L's adapter         │    │                                           │
  │  (1) the PC's own address    │PCIe│ 82574L ──── wg_net ───────────────────────┼── Eth0 ──▶ switch / router
  │      (DHCP, as any NIC)      │◀──▶│               │                           │
  │  route 169.254.77.1 -> it    │    │               ├─▶ (2) management address  │   (2) never on this cable
  │                              │    │               │     169.254.77.1 -> CSE   │
  │ browser: the status page     │    │               │     status page, setconf  │
  │ wgcard.py setconf            │    │               │                           │
  │                              │    │               └─▶ (3) tunnel endpoint ────┼── UDP 51820 to the peers
  └──────────────────────────────┘    └───────────────────────────────────────────┘
  1. the PC's own address on the card's adapter (DHCP, as with any network card); its ordinary traffic passes through, tunnel traffic is encrypted on the way;
  2. the management address (a fixed link-local address, so no DHCP is needed; the PC adds one host route to it: netsh interface ipv4 add route 169.254.77.1/32 "<the adapter>" on Windows, ip route add 169.254.77.1/32 dev <if> on Linux) -- a read-only status page (the card's public key, the peers, the last handshake, counters; never anything secret; no TLS needed: nothing on it is secret and nothing on it changes the card) and the signed configuration requests (wgcard.py setconf);
  3. the card's own tunnel endpoint on the LAN, where the peers send their WireGuard packets.

Firmware from flash. The core's firmware lives in the card's QSPI flash, in an A/B pair of slots above the bitstreams. A small boot ROM reads the image header, copies the firmware into the core's memory, checks its BLAKE2s hash with the hash engine and jumps in; a bad image falls back to the other slot. So the firmware is updated without a new bitstream. (On a bigger FPGA the same boot ROM loads into DDR.)

One set of units, chosen by a build profile. Link speed (100 / 1000), the debug facility (on / off), memories in LUT RAM or block RAM, the crypto engines shared or one per direction and their folding, the control core (none, or CSE-lite). The WireGuard baseline uses 100 Mbit/s so that everything fits the KX2; a bigger FPGA gets a gigabit WireGuard from the same sources.

Status: the tunnel runs on the board. With the 100 Mbit WireGuard image, the card terminates a WireGuard tunnel to a Linux peer (the kernel's own WireGuard): pings through the tunnel, and TCP at about 90 Mbit/s in each direction -- the 100 Mbit line rate minus the tunnel's headers -- encrypted and decrypted by the card. For now the handshake runs on a laptop and its keys are written into the card over the debug link (a bring-up mode); the card's x86 core, which will do the handshake itself, runs its firmware in simulation, booting from flash, and comes next. The flash key store and all crypto engines are built and tested in simulation.

Status

Linux (e1000e), 100 Mbit/s works -- baseline wd5, from the flash: TCP 94.1 / 93.9 Mbit/s, UDP 95.0 / 95.0 Mbit/s at 0 % loss
Linux (e1000e), 1000 Mbit/s works -- baseline gd2, from the flash: TCP 885 Mbit/s to the card, 941 Mbit/s from the card
Windows 10 (inbox e1i65x64 12.17.10.8) works at 100 Mbit/s: Status OK, 20 x 30 MB down and 3 x 30 MB up md5-equal, a 29 minute soak of 159 rounds clean, a power cycle from the flash (wd5); at 1 Gbit/s (gd2, from the flash): Status OK, 300 MB up at 752 Mbit/s md5-equal, a 12 minute soak of 342 rounds md5-equal
open Windows counts received frames it discarded (TCP recovers); standby / resume not retested

The board's log, day by day, is docs/BOARD_TEST.md: every image, what it fixed, how Linux and Windows took it.

The baseline images

baseline/network_kx2_wd5 and baseline/network_kx2_gd2: each a .bit (JTAG), a .mcs / .prm (the QSPI flash, S25FL512S SPIx4); SHA256SUMS, baseline/BASELINE.md. Both routed with Vivado 2026.1 (a quick build: default placement and routing), timing met. Both hold the 82574L function and a debug link on Eth1 (UDP at 192.168.1.250 -- an example address of the lab's network; the card answers its own debug datagrams there and Windows / Linux never see them).

wd5 (100 Mbit/s) gd2 (gigabit)
Eth0 MII, 100 Mbit/s RGMII, 1000 Mbit/s, the line-rate DMA
timing WNS +0.018 ns, WHS +0.043 ns WNS +0.107 ns, WHS +0.039 ns
utilisation 26284 LUTs (26 %), 21978 registers (11 %), 40.5 BRAM tiles 28963 LUTs (29 %), 27221 registers (13 %), 41.5 BRAM tiles
Verilog verilog/wd5/ (this image's design) verilog/gd2/ (this image's design)

Both use 4 GTX and the PCIe hard block. scripts/flash_baseline.sh wd5|gd2 writes one into the flash (docs/FLASH.md).

Download: l8network-dist.tar.gz (16M): the three baseline images (bitstreams, flash images, checksums) with the flash and JTAG scripts, the design as Verilog with its constraints and Vivado flow, the host scripts and the board log.

tar xzf l8network-dist.tar.gz && cd l8network
sh scripts/flash_baseline.sh gd2      # checksums, flash backup, gigabit baseline into the KX2's QSPI flash
                                      # then a full power cycle of the PC (wd5: the 100 Mbit/s baseline)

Inside the card

The baseline image, from the PC down to the cable, with the debug facility beside it. The clocks: 250 MHz is the PCIe core's user clock, 125 MHz the card's clock (the card on krst, which follows the link's resets; the facility and Eth0's crossings on crst, the power-up reset), 100 MHz the debug link's, 25 MHz the MII's.

the network card inside: PCIe hard block, clock crossings, shell, the e1000e function, Eth0, and the debug facility on Eth1

Read from the top: the PC's root complex talks PCIe x4 Gen2 to the FPGA's PCIe hard block, which presents the config space of an Intel 82574L and hands every TLP over as 64-bit beats at 250 MHz. The beats cross into the card's 125 MHz clock; the shell routes each request by the BAR it hit (BAR0 the registers, BAR3 the MSI-X table), takes the function's DMA requests to TLPs and sends its interrupts. The function is the 82574L as Linux and Windows drive it: the register file, the NVM and PHY records behind EERD and MDIC, the receive path (address filter, packet RAM, RSS), the transmit path (descriptors, contexts, VLAN, TSO, checksums, padding), and ONE DMA sequencer g that does all of the card's memory work, a piece at a time, the receive side first. Frames leave as bytes through the MAC on the PE1's Eth0. Beside it, the debug facility only LOOKS at the card -- it drives none of its inputs -- and runs on the power-up reset, so a card reset, a reboot or a crash leaves its counters and its trace readable.

The gigabit baseline (gd2, build_gd2, Eth0 at 1000 Mbit/s) splits g into three engines -- gr (RX), gt (TX reads, up to the host's MRRS with several out, descriptors in batches of 4) and gb (TX write-back) -- whose requests are merged onto the one DMA port, the answers routed back in request order; Eth0 runs RGMII at 1000 Mbit/s.

How to

  1. A new card, the switches, the flash: "Program a new KX2 + PE1 card" above, in full docs/FLASH.md.
  2. Linux: lspci -nn -k -d 8086:10d3 shows the 82574L with e1000e; sudo host/host_check.sh <peer-ip> brings the interface up and pings. Windows 10: Device Manager lists "Intel(R) 82574L Gigabit Network Connection", no driver to install.
  3. A JTAG load while the PC runs (sh scripts/jtag_load.sh baseline/network_kx2_gd2.bit, or make prog) replaces the image until the next power cycle: remove the PCI device first and rescan after (echo 1 > /sys/bus/pci/devices/<bdf>/remove, echo 1 > /sys/bus/pci/rescan).
  4. The Makefile does the same for one image: make check (all checksums), make flash / make prog (wd5; IMAGE=baseline/network_kx2_gd2 for gigabit).

make bit [NAME=gd2] rebuilds that baseline's bitstream from verilog/<NAME>/ (wd5, gd2 or wg100; default gd2; Vivado 2026.1 or later on the PATH, the XC7K160T part): verilog/<NAME>/top.bit.

Debugging facility

The card carries its own debugger: a set of counters and state words, and a trace of every TLP the card exchanges with the PC, readable from ANOTHER machine over the PE1's second Ethernet port (Eth1) while Linux or Windows drives the card. Windows owns the card's BARs while it runs; the debug link does not need them. The facility only looks at the card: nothing of it drives an input of the card or the PCIe core, so reading it, or not reading it, never changes what the card does; it runs on the board's power-up reset, so it keeps counting across card resets, reboots and driver crashes.

what where read with
debug words (bus 0): link, resets, TLP and frame counters, the last TLPs UDP port 0x8E92 host/nwdbg.py status, watch
the event trace (pipe 0): every TLP both ways, the card's events UDP port 0x8E8C host/nwdbg.py trace, then regs
discovery: "who is there" UDP port 0x8E92, broadcast host/nwdbg.py find
the same over the FPGA's JTAG J1700 (BSCANE2 USER2) lab only, see below

Cable the PE1's RIGHT RJ45 (Eth1) to a network your debug host is on. The card's debug address is fixed in the image: 192.168.1.250 (MAC 02:00:4c:38:00:11, netmask 255.255.255.0; an example of the lab's network -- the host must have an address in 192.168.1.0/24 on that port, e.g. sudo ip addr add 192.168.1.10/24 dev <if>). The card answers ARP for it and the discovery query (nwdbg.py find lists it as kx2-nw-dbg). Eth1 is the facility's own port: its frames never reach the 82574L, and Linux / Windows never see them.

The debug link sends nothing until a host has spoken to it, and then only to that host. Its output passes a guard (dbg_unicast_guard): a frame to a group address (broadcast, multicast) or to the zero MAC 00:00:00:00:00:00 is dropped, counted, and its destination and UDP source port kept (words 27..29). Why it is there: an earlier image's trace sent frames to the zero MAC before any host had asked for them; the lab's switch flooded them to every port, including the card's own Eth0, and the card spent its receive bandwidth on them -- the PC lost 55 % of its UDP traffic until a host started a trace. With the guard the debug link cannot flood a network; how the trace produced those frames is still open (docs/BOARD_TEST.md, 2026-11-29).

BAR4 and JTAG

BAR4 is a 64 KB "side" BAR after QEMU's four (BAR0..BAR3 are where an 82574L has them); in this image it holds one word that reads 0 -- the trace is read over the debug link, not through a BAR. The FPGA's JTAG port carries the same debug link (the same words and trace, joined with UDP): pcie_dbg.py without --udp, or nwdbg.py --jtag, talks to a JTAG proxy at 127.0.0.1:0x8EF4 that holds the cable through Vivado's hardware server. That proxy is our lab's tool (l8net.jtag_proxy with the repository's tools/jtagio) and is not in this archive: JTAG is lab only; use Eth1.

The debug words: nwdbg.py status

host/nwdbg.py status [IP] reads the words and prints them decoded (it is pcie_dbg.py --udp IP --clock 125 --fn nw). --raw prints them as hex. What they hold:

words what
0, 1 the facility's id 0x4E570002 ("NW", version 2); the card clock's count (125 MHz)
2, 3 the PCIe link: up, the card's bus / device id, bus master, MSI, MPS, MRRS; the clock it first came up
4..7 TLPs from and to the core, interrupts sent, link drops, status updates
8, 9 card resets, the last one's cause (PERST#, the core's user reset = a hot reset, link down), in reset now; the clock it began
10 the core now: LTSSM state, link power state, D-state, user_lnk_up, user_reset, PERST#, the TX handshake, tx_buf_av, Eth0 and Eth1 link
11 the config space's Command and Device Control (MPS, MRRS) as the host wrote them
12, 13 trace events written / lost; since configuration: tx_err_drop, PME_Turn_Off, hot resets, FLRs, user resets, the user clock's heartbeat (moving = alive)
14 the four streams' valid / ready now, the trace ring's size
16..23 the wire capture: the last TLP from the host, the last one with data, the last one with data to the host
24..27 Eth0: frames on the wire, MAC good, MAC dropped (CRC / alignment / overrun), into the card, sent by the card; Eth1: debug frames sent, received, dropped by the guard (16-bit counts, wrapping)
28, 29 the last frame the guard dropped: its destination MAC, the UDP source port it came from (0x8E8C the trace, 0x8E92 the words)

nwdbg.py watch [IP] [SECS] reads them every SECS seconds (default 5) and prints the counters with their change and rate since the last read. The Eth0 counts follow a frame stage by stage: wire -> MAC good -> into the card; a difference says where frames are lost (wire > good: the line or the PHY; good > into the card: the crossing; into the card > the driver's rx_packets: the function).

The event trace: nwdbg.py trace and regs

host/nwdbg.py trace [IP] FILE [SECS] records the trace into FILE with BAR0's registers by name (it runs pcie_dbg.py --udp IP --clock 125 --trace --regs e1000e). The trace is big: a Windows soak of 30 minutes wrote 10.8 GB, so it stops at SECS seconds (default 300) or at --max-bytes (default 2G), whichever comes first. When the host reads too slowly, the card drops whole datagrams rather than wait, and the trace says so: -- N datagrams dropped on the board (its ring was full): TLPs missing here.

What a line holds: the clock (the card's, 125 MHz: 8 ns a tick, from the first line shown), the direction, the TLP decoded (type, length, requester, tag, byte enables, address, data -- each data DW as on the wire and, in brackets after =, as the host CPU reads it), the BAR the host's request hit, and after | the decoding by the 82574L's register names: BAR0 RCTL <- value for a write, BAR0 STATUS read and | = value (STATUS) on its completion, the card's own DMA attributed to the rings (fetch of RXq0 descriptor 5, write-back to TXq1 descriptor 3) once the trace has seen the driver write the ring registers, CTRL.RST when the driver resets the function, WIN: on registers of the 82574L features Windows uses (RSS, the second queue). EVENT lines are the card's own: a card reset (begin, end, cause), a BAR access to an offset where the model has no register, an interrupt (vector, MSI-X / MSI / INTx), a DMA request (read / write, DWs, the BYTE address), the PCIe core's state changing (LTSSM, link power state, D-state, Command, Device Control).

An excerpt (Windows 10 on the card, 2026-11-29; the frame's data cut): one received frame, start to end.

  120083863           EVENT DMA request   read 2 DWs at 0xfedfcfc0
  120083866 card>host MRd32   len 2   req 2d:00.0 tag 0x00 be ff   addr 0xfedfcfc0
  120085436 host>card CplD    len 2   cpl 00:03.1 SC bc 8   req 2d:00.0 tag 0x00 la 0x40   data c0846cde(=de6c84c0) 00000000(=00000000)   (4 clocks)
  120085445           EVENT DMA request   write 15 DWs at 0xde6c84c0
  120085448 card>host MWr32   len 15   req 2d:00.0 tag 0x01 be ff   addr 0xde6c84c0   data ffffffff(=ffffffff) ...
  120085464           EVENT DMA request   write 1 DWs at 0xfedfcfcc
  120085466           EVENT DMA request   write 3 DWs at 0xfedfcfc0
  120085467 card>host MWr32   len 1   req 2d:00.0 tag 0x01 be 0f   addr 0xfedfcfcc   data 3c000000(=0000003c)
  120085471 card>host MWr32   len 3   req 2d:00.0 tag 0x01 be ff   addr 0xfedfcfc0   data 00000000(=00000000) 00000000(=00000000) 03000000(=00000003)   (5 clocks)
  120085476           EVENT interrupt   vector 0   MSI-X
  120085478 card>host MWr32   len 1   req 2d:00.0 tag 0x01 be 0f   addr 0xfee00000   data 00000000(=00000000)
  123498316 host>card MRd32   len 1 attr 1   req 00:00.0 tag 0x21 be 0f   addr 0xfce04000   [BAR0]   | BAR0 CRCERRS read
  123498320 card>host CplD    len 1 attr 1   cpl 2d:00.0 SC bc 4   req 00:00.0 tag 0x21 la 0x00   data 00000000(=00000000)   | = 0x00000000 (CRCERRS)

The card reads the next RX descriptor's buffer address (2 DWs); the host answers 1570 clocks (12.6 us) later with 0xde6c84c0; the card writes the 60-byte frame there (15 DWs, a broadcast: ffffffff...), then the descriptor's write-back -- DW3 the length (0x3c), DW0..2 the status (3: DD | EOP) -- and raises interrupt vector 0, which the shell sends as an MSI-X write to 0xfee00000. Later Windows polls the statistics registers, each read named.

host/nwdbg.py regs FILE summarises a recorded trace: the host's accesses by BAR and by register, CTRL.RST, offsets the model has no register for, the events by type, card resets by cause, interrupts by vector, DMA requests, the core's state changes, and the descriptors: RX buffers by their byte offset in a DW, TX descriptors by kind (context, data, TSO, EOP), TX buffers by offset, crossing a 4 KB page, starting in a page's last DW.

Worked example: the two Windows bugs

Linux ran the card clean; Windows 10 did not. Both faults were found in the trace.

1. RX buffers at a byte offset (Code 43). Windows 10 removed the adapter 11 s after link-up (NDIS event 10317, "the miniport has detected an internal error", Device Manager Code 43). The trace of that boot, regs: RX descriptors' buffers at +2 bytes in a DW (Linux had run on the same image without a fault). The lines of one frame:

241984347469           EVENT DMA request   read 2 DWs at 0xfe52fe000
241984347472 card>host MRd64   len 2   req 2d:00.0 tag 0x00 be ff   addr 0xfe52fe000
241984347585 host>card CplD    len 2   cpl 00:03.1 SC bc 8   req 2d:00.0 tag 0x00 la 0x00   data 0a2040e5(=e540200a) 0f000000(=0000000f)   (4 clocks)
241984347594           EVENT DMA request   write 32 DWs at 0xfe540200a
241984347597 card>host MWr64   len 32   req 2d:00.0 tag 0x01 be ff   addr 0xfe5402008   data 02004c38(=384c0002) 00108cfd(=fd8c1000) ...

The buffer is at 0xf_e540_200a; the DMA request event carries that byte address, but the write went to the DW at 0x...2008 with every byte enabled, the frame's first bytes (its destination MAC, 02:00:4c:38:00:10) first: every frame landed 2 bytes early and overwrote the 2 bytes before Windows' buffer. The fix ([system_pcie-72]): a buffer at any byte address -- the frame's DWs rotated by the address's low bits, the first and last DW's byte enables masking the lanes outside the buffer. The next image (build_wd4) ran Windows with Status OK.

2. A TX buffer in a page's last DW (a Length-0 read). With RX fixed, Windows -> laptop transfers died after 0.2..6 MB ("message authentication code incorrect" in ssh), while the laptop counted no TCP checksum errors: the card sent wrong payload with a valid checksum. The trace's TX descriptors (regs): TSO, header buffers holding the headers and 10 payload bytes, data buffers at byte offsets 1..3, segments spanning buffers -- and 2 of 8130 data descriptors with a buffer starting in the last DW of a 4 KB page, e.g. a 7290-byte buffer at 0x2_79f3_1ffe. The card reads a buffer in pieces that never cross 4 KB; for that buffer the first piece is 2 bytes inside one DW, but the room to the page's end came out as 0 DWs -- and a PCIe read of Length 0 means 1024 DWs: 4 KB asked where 2 bytes were wanted. The fix ([system_pcie-73]): the room counted from the DW that holds the first byte, so such a buffer starts with a one-DW piece; the bench for it (buffers at 0x2FFC..0x2FFF among Windows' shapes) failed on the model before the fix, ~125 payload bytes of a segment replaced. The image after it, build_wd5 (this baseline), moved 20 x 30 MB from Windows md5-equal and ran a 29-minute soak clean. The reads themselves were not in that trace, so the descriptors were the evidence and the bench the proof.

What is in the archive

path what
baseline/ the baseline images: network_kx2_wd5 (100 Mbit/s), network_kx2_gd2 (gigabit) and network_kx2_wg100 (WireGuard, with network_kx2_wg100.manifest and the CSE's firmware cse_fw_a.mcs), each .bit (JTAG), .mcs (the flash), .prm (its map); SHA256SUMS, BASELINE.md (what each holds, how it was proven)
verilog/<name>/ each baseline's design as Verilog (comments stripped), one set a baseline -- wd5/, gd2/, wg100/ -- from the build its image came from: top.v (the board: pins, clocks, the PCIe hard block's wrapper), the card (network_kx2_dbg.v, network_kx2_dbg1g.v, network_kx2_wg.v), top.xdc, top.tcl (the Vivado flow, the PCIe core's configuration), pcie7x.cfg, Makefile; make bit NAME=<name> at the top builds it
cse/ the WireGuard card's security core (CSE) as C source, for reading and auditing, not rebuilt here: src/sw/ (the MINIX-style threader, the threads con / cfg / ks / wg, the Noise handshake on the hardware engines), src/ucode/ (the core's microcode as C), README.md; the firmware the card runs is baseline/cse_fw_a.mcs
scripts/ flash_baseline.sh (a baseline into the flash: checksums, the flash's first 8 MB saved, program, verify, boot; for wg100 the key store record and the CSE firmware in the same session; --dry-run), jtag_load.sh (a bitstream over JTAG, volatile), and the Vivado scripts they run: flash_kx2.tcl, flash_kx2_multi.tcl, flash_mcs_check.tcl, jtag_prog.tcl
host/ host_check.sh (Linux: the interface, a ping, the counters), net_ladder.sh / net_iperf.sh (the lab's test ladder N0..N3 -- they name the lab's machines and a local sudo wrapper kx2-pci: read them as a recipe), nwdbg.py (the debug facility made easy: find, status, watch, trace, regs; see Debugging facility), l8/bus/pcie/host/pcie_dbg.py (the card's debug words and its TLP trace over the Eth1 debug link, what nwdbg.py runs: pcie_dbg.py --udp 192.168.1.250 --clock 125 --trace --regs e1000e) with l8net and the 82574L's register names (e1000e_regs_names.txt, from Linux's e1000e headers); the WireGuard card's tools (the bench section above): l8/bus/pcie/designs/network/host/wgks_provision.py (the key store record with the card's identity key, run by flash_baseline.sh; X25519 from l8/crypto/x25519/gen/x25519_ref.py, plain Python), l8/bus/pcie/designs/network/host/wgcard.py (wg_net's words: setup, stats; --udp or --jtag; needs cryptography), l8/cpu/x86/cse/tools/cse_con.py (the CSE's console and boot status: status, cat, follow; --udp or --jtag), l8/net/host/l8net/jtag_proxy.py (the debug link over the JTAG cable, python3 -m l8net.jtag_proxy from host/l8/net/host) with tools/jtagio / jtagio.tcl (the JTAG pipe through Vivado's hardware manager)
docs/ FLASH.md (a new card, the flash, a JTAG load, recovery), HOWTO.md, BOARD_TEST.md (the board log), plan.md (the design: layers, numbers, decisions), network_card.svg (the card inside, as above)

The design's l8 sources are not in the archive; the Verilog is the design as Vivado builds it. Addresses such as 192.168.1.x in the documents are the lab's, examples only.

[back to the deck]