Skip to content

pasw: support the new saline bitstream, ingress ACL offload and fixes - #2

Draft
wkz wants to merge 14 commits into
mainfrom
pasw-acl
Draft

wkz wants to merge 14 commits into
mainfrom
pasw-acl

Conversation

@wkz

@wkz wkz commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Ports the pasw driver to the new saline release and adds offload of tc flower filters to the switch's ingress ACL. Two existing bugs, found while testing on hardware, are fixed first so they can be taken on their own.

Fixes

  • L2 SA hash table out of sync. The core looks up source addresses in a copy of the L2 DA hash table, and the driver only ever wrote the DA table. A learned address that hashed to the slot of a static entry was then taken for a port move, and the learning unit rewrote the static entry's destination. On saline, LLDP from a neighbor redirected the 01:80:C2:00:00:04 and :07 traps this way.
  • VLAN leak. A port that left a bridge stayed in the bridge VLAN's port mask.

New bitstream

  • The PTP tick generator is gone, so the queue shapers run on the core ticks. Their default rates are unchanged.
  • The VLAN table is indexed by all 4096 VIDs. The driver keeps a pool of one internal VLAN per port and clears the table in one write.
  • The switch core grows to 256 KiB of BAR0. The To CPU tag is one byte longer, because its reason code is 16 bits.
  • Rows transfer only the words that hold data, and the generated ABI checks at build time that every table fits in a row.
  • The driver refuses to probe a core whose version differs from the one its ABI was generated for.

Ingress ACL

  • abigen describes the ACL tables. It gains list attributes, like tables, wide fields for the 256-bit keys, and attributes taken from a register's reset value.
  • An ACL core owns the engine. Rules from several owners are kept in order of precedence. Exact matches go to the hash tables and the rest to the TCAM, and each change writes only the rows that differ.
  • IEEE reserved multicast, 01:80:C2:00:00:00-1F, is trapped to the CPU with static L2 entries that bridge fdb cannot change.
  • tc flower filters on user ports are offloaded. They can match on MAC addresses, VID, PCP, VLAN presence and EtherType, and can drop, trap, redirect or set the egress queue.
  • debugfs has an acl file and an fdb file. The fdb file lists the L2 table and marks replica rows that differ from their primary.

Testing

On saline hardware with the new bitstream:

  • The driver probes, and PTP on e0 locks with offsets within ±25 ns.
  • An exact flower drop lands in the large hash table at the slot the datasheet's hash gives, and its drops count up. Wildcard rules go to the TCAM in preference order. A fifth wildcard rule is refused with "The ACL TCAM is full".
  • With the SA fix, neighbor MACs that collide with the trap entries are learned into a free way of the same slot, and the traps stay on the CPU.
  • A port leaving the bridge drops out of the bridge VLAN.
  • The fdb file flags a hand-corrupted SA row and destination copy.

Not tested: shapers and other host-generated traffic, and the redirect and priority actions, since the image lacks act_mirred and act_skbedit.

wkz added 14 commits December 1, 2026 14:28
The core looks up source addresses in a copy of the L2 DA hash table,
and the datasheet requires software to write both. The driver only
wrote the DA table, so the SA table kept whatever the learning unit
had last put there.

A learned address that hashed to the slot of a static entry was then
still found in the SA table, and the learning unit took it for a port
move and rewrote the destination of the static entry. On saline, LLDP
from a neighbor redirected static entries to its ports this way.

Describe the SA table as the replica of the DA table, so that every
write of a row goes to both.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
When a port left a VLAN that other ports still used, such as when it
left a bridge, its bit stayed in the VLAN's port mask. Traffic in the
bridge could then still reach the port after it became standalone.

Clear the port from the mask when the VLAN is still in use, and forget
the old VLAN right away, so that a failure to get the new one does not
release the old one a second time later.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
The new saline bitstream drops the separate PTP tick generator. The
queue shapers now count the core ticks, which also drive L2 aging.

Remove the PTP ticks and have the shapers pick one of the core ticks
instead. The core ticks already default to 1 MHz, each one 10x slower
than the one before it, so the shaper rates come out the same.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Rows were read and written a full address step at a time, but entries
are often narrower than their step. The new saline bitstream spaces
the ACL TCAM entries 32 words apart, while each holds 17 words of
data, and a row would have to be twice the size to hold the padding.

Have abigen record each table's width in words, and transfer only
those. The generated ABI now also checks at build time that every
table fits in a row.

Add pasw_table_clear(), which zeroes a whole table in one write, for
the tables that grow to thousands of entries.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
The driver gave every entry of the VLAN table its own tracking state
and row, and flushed the entries one at a time. On the new saline
bitstream the table is indexed by all 4096 VIDs, which made that
hundreds of kilobytes of state and thousands of writes at every
probe.

A port uses at most one internal VLAN at a time, so keep a pool of
one VLAN per port, using the VIDs at the top of the range, and clear
the whole table in one write at setup. Every port is a member of every
VLAN out of reset, so the table must still be cleared in full.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Import the register and configuration specs of the new saline
release. Besides the changes that earlier commits prepared for, it
brings:

- A larger switch core. Its registers now reach past word 20000, so
  the core's window in BAR0 grows to 256 KiB at the same offset. Size
  the regmap from the window, and have the pasw tool map all of it.
- A 16-bit reason code in the To CPU tag, which makes the tag one byte
  longer and moves the flags and the timestamp. Name the offsets of
  the tag's fields.
- Wider statistics tables. The largest row now takes 14 words.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
pasw_hash() took a u64 key and built a mask for each part with
GENMASK(i + hash_bits, i), which is one bit too wide and runs past
bit 63 for keys that reach it. The ingress ACL on saline hashes keys
of up to 256 bits, so a u64 cannot hold them anyway.

Take the key as a bitmap and XOR it together one hash-wide part at a
time, as the datasheet describes. The L2 table builds its 49-bit
{GID, MAC} key as a bitmap, and its hashes do not change.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Add the configurable ACL tables, the useAcl and aclRule fields of the
source port table, and three attributes from the conf spec: the key
fields the design provides, how many of them a rule may select, and
the width of the key.

abigen learns four things to support this:

- A src path may index into a list, since the conf spec stores per
  engine values as lists.
- An attribute with entries is a list attribute. abigen generates an
  enum from the entries and fills in an array indexed by it from the
  conf list, matching items on a key and copying the named members.
  Entries the design lacks stay zero.
- A table can be declared like another one, and then uses that
  table's struct type. The small and large ACL hash tables share
  struct pasw_t_acl_small.
- A field can be marked wide. It is then described by its start bit
  and width, and written from a bitmap with pasw_row_set_bits(). The
  ACL keys and masks are 256 bits wide.

The TCAM rows hold 17 words, so rows grow to that size.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
The ACL engine is meant to be shared: tc filters should be offloaded
to it, and the driver may need rules of its own. Add a core that owns
all of its state, so that each user only adds and removes rules.

Rules are kept in order of precedence, by owner and then by priority.
Each change plans the whole engine again and then writes only the rows
that differ:

- All ports share one key layout, made up of the fields that any rule
  matches on. Entries built for different layouts could match each
  other's packets, since the valid bits only count the selected
  fields.
- A rule that matches every bit of the key goes to the small or large
  hash table, the others go to the TCAM in order of precedence. A
  TCAM hit always wins over a hash hit, so an exact rule that a
  wildcard rule of lower precedence also matches stays in the TCAM.

Keys are kept as bitmaps, as saline's are 256 bits wide.

The tables are cleared at setup, as the core keeps its state when the
driver is reloaded. A debugfs file, acl, shows the layout and the
part of each entry that the layout uses.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
The To CPU tag carries a reason code. Only reason 0 means that the
switch forwarded the frame to the CPU port as one of its normal
destinations. Any other reason, such as an ACL trap, means the CPU got
the frame instead of the other ports, so the bridge must be free to
forward it in software. Set the offload forward mark only for
reason 0.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Apart from 01:80:C2:00:00:00, which the core always sends to the CPU,
frames to the IEEE reserved groups were flooded to every port of an
offloaded bridge. LACP, LLDP, 802.1X and link-local PTP should
terminate at the bridge, which can still forward the groups in its
group_fwd_mask.

Add static L2 entries at setup that send 01:80:C2:00:00:00-1F to the
CPU port only. All FDB lookups use GID 0, so one entry per group
covers every port. On standalone ports every frame goes to the CPU
anyway.

The switch reports these frames with reason 0, like forwarded ones, so
the tagger also leaves frames to the reserved groups without the
offload forward mark.

The entries belong to the driver. A request to add a reserved group
for the CPU port is already met, one for a user port is refused, and
deleting one does nothing, so bridge fdb and host addresses can not
change them.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Ingress flower filters on a user port become ACL rules for that port.
They can match on the MAC addresses, the outer VID and PCP, the
presence of a VLAN tag and the EtherType. They can drop, trap to the
CPU, redirect to another port on the switch, or pick the egress queue
with skbedit priority. Filters with a lower preference value take
precedence.

The ACL only has four match counters, shared by all rules, so the
statistics of an offloaded filter stay at zero.

All ports share one key, and a field that any filter matches on is
part of it. Every field supported here fits in saline's 256-bit key
at once.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
bridge fdb only shows the entries of user ports, and nothing in it
shows whether the copies of the L2 tables that the core keeps for
source lookups agree with the primaries. The pasw tool reads the
registers directly, but that needs a matching spec on the target.

Add a debugfs file, fdb, that lists every entry in use from the hash
and collision tables. It shows the entry's location, status, GID,
address and destination, and marks each replica row that differs from
its primary.

The file is sized for a full table when opened, since seq_file would
otherwise walk the table again each time it grows its buffer.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
The ABI is generated from the specs of one release of a design. A
different bitstream can move registers and change table layouts, and
the driver would then quietly program the wrong bits, as the move to
the new saline release showed.

Let abigen take an attribute from the reset value of a register field,
with `default: [register, field]`. The Core Version register's reset
value is the version the specs describe, so add it as core_version and
fail the probe when the core reports another one.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
@wkz
wkz marked this pull request as draft December 1, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant