mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Dynamic link aggregation on top of the static LAGG, for RTL8372/8373: receive, selection and mux state machines (coupled mux, one aggregator per group), with "lacp show" to look inside. Each of the four trunk groups runs its own aggregator on the candidate ports assigned with "lag <n> lacp <ports>"; the engine starts with the first such group and stops with the last. LACPDUs reach the CPU through the reserved-multicast trap, so delivery needs no L2 entry and nothing written per VLAN or per PVID. The trap acts on the address before the VLAN lookup and before the ingress filters, so a LACPDU also arrives on a port that admits tagged frames only and on a port STP holds in blocking, neither of which a forwarded one reaches. A trapped frame carries no VLAN tag, so lacp_in() takes the offset of the PDU body from TRAP_RX_BODY(). The action is set with trap_rma_set(), which leaves the flags sharing that register alone, and "lacp off" puts the slow-protocols drop default back. doc/lacp.md and doc/link_aggregation.md record what was measured, including why the trap looked like a dead end at first. The web UI gets a Static/LACP mode per group on the LAG page with live status, and the startup-config validator knows the per-group syntax. A host-side sandbox for the state machines runs in the test harness together with the LAG hash check. It drives both forms of an incoming LACPDU, so the body offset of a trapped one is covered as well. The L2 table page iterated with the "next unicast" read method, so static multicast entries such as an IGMP group were invisible. It now iterates with "next address", skips L3 entries (their layout carries IP addresses where a MAC is expected), and reports the lowest member of a multicast entry's port mask, so such an entry shows up as a static entry on that port. A port taken out of LACP forgets its partner, so "lacp show" after "lacp off" no longer reports one. Applying the same candidate set to a group again, as the LAG page does on every Apply, leaves the trunk alone instead of tearing it down for a second or two. lacp_in() checks the frame length and ethertype before reading a LACPDU, so a runt or a foreign frame on the slow-protocols address cannot leave stale buffer bytes as a partner. The sandbox covers these three in T20-T22. On the LAG page, LACP mode with no ports checked sends "lag N lacp off", and the startup-config validator wants at least one port after "lacp".
196 lines
5.7 KiB
Makefile
196 lines
5.7 KiB
Makefile
VERSION=0.1.0
|
|
IMAGESIZE = 524288
|
|
DEFAULT_CONFIG_LOCATION = 454656
|
|
CONFIG_LOCATION = 458752
|
|
HTML_LOCATION = 262144
|
|
|
|
ifeq ($(origin CC),default)
|
|
CC = sdcc
|
|
endif
|
|
CC_FLAGS = -mmcs51 -I. -Ihttpd -Iuip
|
|
ASM ?= sdas8051
|
|
AFLAGS= -plosgff
|
|
|
|
SUBDIRS := tools
|
|
SUBDIRSCLEAN=$(addsuffix clean,$(SUBDIRS))
|
|
|
|
ifeq ($(MACHINE),)
|
|
MACHINE:= $(shell grep "^\s*#define MACHINE_" machine.h | sed "s/^\s*#define MACHINE_//")
|
|
else
|
|
CC_FLAGS += -DMACHINE_$(MACHINE)
|
|
endif
|
|
# Health instrumentation and the "health" console command: HEALTH=1 gmake ...
|
|
ifneq ($(HEALTH),)
|
|
CC_FLAGS += -DHEALTH
|
|
endif
|
|
|
|
ifeq ($(CI),1)
|
|
CC_FLAGS += --Werror
|
|
endif
|
|
|
|
BUILDDIR = output/$(MACHINE)
|
|
VERSION_HEADER := version.h
|
|
|
|
GIT_VERSION := $(shell git rev-parse --short HEAD)
|
|
ifeq ($(shell git status --porcelain --untracked-files=no),)
|
|
else
|
|
GIT_VERSION := $(GIT_VERSION)-dirty
|
|
endif
|
|
|
|
VERSION_EXTENSION = v$(VERSION)-$(GIT_VERSION)
|
|
FILENAME_EXTENSION = $(VERSION_EXTENSION)-$(MACHINE)
|
|
|
|
# Deterministic build date: honor SOURCE_DATE_EPOCH, else the HEAD commit date,
|
|
# else wall-clock (no-git fallback). Keeps same-commit builds byte-identical
|
|
# (BUILD_DATE is baked into the image and covered by the trailing CRC).
|
|
SOURCE_DATE_EPOCH ?= $(shell git show -s --format=%ct HEAD 2>/dev/null)
|
|
ifeq ($(SOURCE_DATE_EPOCH),)
|
|
BUILD_DATE := $(shell date +"%Y-%m-%d %H:%M:%S")
|
|
else
|
|
BUILD_DATE := $(shell date -u -d @$(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S" 2>/dev/null \
|
|
|| date -u -r $(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S")
|
|
endif
|
|
|
|
all: create_build_dir $(VERSION_HEADER) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin
|
|
|
|
create_build_dir:
|
|
mkdir -p "$(BUILDDIR)"
|
|
mkdir -p "$(BUILDDIR)/uip"
|
|
mkdir -p "$(BUILDDIR)/httpd"
|
|
|
|
# Keep machine.c in first position to fail immediately on invalid $MACHINE value
|
|
SRCS = \
|
|
machine.c \
|
|
machine_init.c \
|
|
cmd_editor.c \
|
|
cmd_parser.c \
|
|
dhcp.c \
|
|
html_data.c \
|
|
rtlplayground.c \
|
|
boot.c \
|
|
sfp.c \
|
|
dns.c \
|
|
dns_cli.c \
|
|
ntp.c \
|
|
ntp_cli.c \
|
|
syslog.c \
|
|
udp_apps.c
|
|
|
|
# RTL837x
|
|
SRCS += \
|
|
rtl837x_bandwidth.c \
|
|
rtl837x_flash.c \
|
|
rtl837x_igmp.c \
|
|
rtl837x_init.c \
|
|
rtl837x_leds.c \
|
|
rtl837x_leds_dump.c \
|
|
rtl837x_phy.c \
|
|
rtl837x_pins.c\
|
|
rtl837x_port.c \
|
|
rtl837x_stp.c \
|
|
rtl837x_lldp.c \
|
|
rtl837x_storm.c \
|
|
rtl837x_lacp.c \
|
|
rtl837x_trap.c
|
|
SRCS += \
|
|
httpd/httpd.c \
|
|
httpd/page_impl.c
|
|
SRCS += \
|
|
uip/timer.c \
|
|
uip/uip.c \
|
|
uip/uiplib.c \
|
|
uip/uip_arp.c \
|
|
uip/uip-fw.c \
|
|
uip/uip-neighbor.c \
|
|
uip/uip-split.c
|
|
|
|
OBJS = ${SRCS:%.c=$(BUILDDIR)/%.rel}
|
|
DEPS := ${SRCS:%.c=$(BUILDDIR)/%.d}
|
|
HTML := $(shell find html -name '*.js' -or -name '*.html' -or -name '*.svg' -or -name '*.css' -or -name '*.ico')
|
|
|
|
# Minified copy of the web UI sources, used as the fileadder input.
|
|
# The raw html/ sources stay untouched for development; the minified
|
|
# copy is a build artifact under output/.
|
|
HTML_MIN := output/html_min
|
|
.PHONY: html_min
|
|
html_min: $(HTML)
|
|
rm -rf $(HTML_MIN)
|
|
mkdir -p $(HTML_MIN)
|
|
@for f in $(HTML); do python3 tools/minify.py $$f $(HTML_MIN)/$$(basename $$f) || exit 1; done
|
|
|
|
html_data.c html_data.h &: $(HTML) | tools html_min
|
|
tools/output/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -b BANK1 -z -d $(HTML_MIN) -p html_data
|
|
|
|
$(VERSION_HEADER): FORCE
|
|
@printf '%s\n' "#ifndef VERSION_H" "#define VERSION_H" \
|
|
"#define VERSION_SW \"$(VERSION_EXTENSION)\"" \
|
|
"#define BUILD_DATE \"$(BUILD_DATE)\"" \
|
|
"#endif" > $(VERSION_HEADER).tmp
|
|
@cmp -s $(VERSION_HEADER).tmp $(VERSION_HEADER) \
|
|
&& rm -f $(VERSION_HEADER).tmp \
|
|
|| mv $(VERSION_HEADER).tmp $(VERSION_HEADER)
|
|
|
|
httpd: html_data.h
|
|
|
|
$(SUBDIRS):
|
|
$(MAKE) -C $@
|
|
|
|
clean: $(SUBDIRSCLEAN)
|
|
-rm -f html_data.c html_data.h $(VERSION_HEADER)
|
|
-if [ -d $(BUILDDIR) ]; then find $(BUILDDIR) -type f ! -name "*.bin" -delete; fi
|
|
|
|
distclean: $(SUBDIRSCLEAN)
|
|
-rm -f html_data.c html_data.h $(VERSION_HEADER)
|
|
-rm -rf $(BUILDDIR)
|
|
|
|
$(SUBDIRSCLEAN):
|
|
$(MAKE) -C $(@:clean=) clean
|
|
|
|
# Objects depend on the flags they were built with, through a stamp file that
|
|
# is rewritten only when CC_FLAGS actually changes.
|
|
CCFLAGS_STAMP := $(BUILDDIR)/.ccflags
|
|
|
|
.PHONY: FORCE
|
|
FORCE:
|
|
|
|
$(CCFLAGS_STAMP): FORCE | create_build_dir
|
|
@echo '$(CC_FLAGS)' | cmp -s - $@ 2>/dev/null || echo '$(CC_FLAGS)' > $@
|
|
|
|
$(BUILDDIR)/%.rel: %.c $(CCFLAGS_STAMP) | create_build_dir html_data.h
|
|
$(CC) -MMD $(CC_FLAGS) -o $@ -c $<
|
|
|
|
$(BUILDDIR)/%.rel: %.asm $(CCFLAGS_STAMP) | create_build_dir
|
|
${ASM} ${AFLAGS} -o $@ $<
|
|
# mv -f $(addprefix $(basename $^), .lst .rel .sym) .
|
|
|
|
$(BUILDDIR)/rtlplayground.ihx: $(OBJS) $(BUILDDIR)/crtbank.rel $(BUILDDIR)/crc16.rel
|
|
$(CC) $(CC_FLAGS) --xram-size 49151 -Wl-bHOME=0x00000 -Wl-bBANK1=0x14000 -Wl-bBANK2=0x24000 -Wl-bBANK3=0x34000 -Wl-r -o $@ $^
|
|
|
|
$(BUILDDIR)/rtlplayground.img: $(BUILDDIR)/rtlplayground.ihx
|
|
objcopy --input-target=ihex -O binary $< $@
|
|
|
|
$(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.img | tools
|
|
if [ -e $@ ]; then rm $@; fi
|
|
tools/output/imagebuilder -i $^ $@
|
|
tools/output/fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@
|
|
tools/output/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@
|
|
tools/output/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -z -d $(HTML_MIN) -b BANK1 $@
|
|
tools/output/crc_calculator -u $@
|
|
ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin output/rtlplayground.bin
|
|
|
|
.PHONY: clean distclean all $(SUBDIRS) $(SUBDIRSCLEAN) create_build_dir
|
|
|
|
.PHONY:
|
|
machine_check:
|
|
@mkdir -p $(BUILDDIR)/tmp
|
|
@set -eo pipefail; \
|
|
for MACHINE in `grep -E '^[[:space:]]*(//[[:space:]]*)?#define MACHINE_' machine.h | sed -E 's%^[[:space:]]*(//[[:space:]]*)?#define MACHINE_%%' | awk '{print $$1}' | sort -u`; \
|
|
do \
|
|
echo "Checking $${MACHINE}"; \
|
|
$(CC) $(CC_FLAGS) -DMACHINE_$${MACHINE} -MMD -o $(BUILDDIR)/tmp/machine_check -c machine.c; \
|
|
$(CC) $(CC_FLAGS) -DMACHINE_$${MACHINE} -MMD -o $(BUILDDIR)/tmp/machine_check -c machine_init.c; \
|
|
done
|
|
@rm -rf $(BUILDDIR)/tmp
|
|
|
|
-include $(DEPS)
|