Skip to content

Commit c1aa0a9

Browse files
committed
Merge branch 'sparx5-IS2-VCAP'
Steen Hegelund says: ==================== Add support for Sparx5 IS2 VCAP This provides initial support for the Sparx5 VCAP functionality via the 'tc' traffic control userspace tool and its flower filter. Overview: ========= The supported flower filter keys and actions are: - source and destination MAC address keys - trap action - pass action The supported Sparx5 VCAPs are: IS2 (see below for more info) The VCAP (Versatile Content-Aware Processor) feature is essentially a TCAM with rules consisting of: - Programmable key fields - Programmable action fields - A counter (which may be only one bit wide) Besides this each VCAP has: - A number of independent lookups - A keyset configuration typically per port per lookup VCAPs are used in many of the TSN features such as PSFP, PTP, FRER as well as the general shaping, policing and access control, so it is an important building block for these advanced features. Functionality: ============== When a frame is passed to a VCAP the VCAP will generate a set of keys (keyset) based on the traffic type. If there is a rule created with this keyset in the VCAP and the values of the keys matches the values in the keyset of the frame, the rule is said to match and the actions in the rule will be executed and the rule counter will be incremented. No more rules will be examined in this VCAP lookup. If there is no match in the current lookup the frame will be matched against the next lookup (some VCAPs do the processing of the lookups in parallel). The Sparx5 SoC has 6 different VCAP types: - IS0: Ingress Stage 0 (AKA CLM) mostly handles classification - IS2: Ingress Stage 2 mostly handles access control - IP6PFX: IPv6 prefix: Provides tables for IPV6 address management - LPM: Longest Path Match for IP guarding and routing - ES0: Egress Stage 0 is mostly used for CPU copying and multicast handling - ES2: Egress Stage 2 is known as the rewriter and mostly updates tags Design: ======= The VCAP implementation provides switchcore independent handling of rules and supports: - Creating and deleting rules - Updating and getting rules The platform specific API implementation as well as the platform specific model of the VCAP instances are attached to the VCAP API and a client can then access rules via the API in a platform independent way, with the limitations that each VCAP has in terms of is supported keys and actions. The VCAP model is generated from information delivered by the designers of the VCAP hardware. Here is an illustration of this: +------------------+ +------------------+ | TC flower filter | | PTP client | | for Sparx5 | | for Sparx5 | +-------------\----+ +---------/--------+ \ / \ / \ / \ / \ / +----v--------v----+ | VCAP API | +---------|--------+ | | | | +---------v--------+ | VCAP control | | instance | +----/--------|----+ / | / | / | / | +--------------v---+ +----v-------------+ | Sparx5 VCAP | | Sparx5 VCAP API | | model | | Implementation | +------------------+ +---------|--------+ | | | | +---------v--------+ | Sparx5 VCAP HW | +------------------+ Delivery: ========= For now only the IS2 is supported but later the IS0, ES0 and ES2 will be added. There are currently no plans to support the IP6PFX and the LPM VCAPs. The IS2 VCAP has 4 lookups and they are accessible with a TC chain id: - chain 8000000: IS2 Lookup 0 - chain 8100000: IS2 Lookup 1 - chain 8200000: IS2 Lookup 2 - chain 8300000: IS2 Lookup 3 These lookups are executed in parallel by the IS2 VCAP but the actions are executed in series (the datasheet explains what happens if actions overlap). The functionality of TC flower as well as TC matchall filters will be expanded in later submissions as well as the number of VCAPs supported. This is current plan: - add support for more TC flower filter keys and extend the Sparx5 port keyset configuration - support for TC protocol all - debugfs support for inspecting rules - TC flower filter statistics - Sparx5 IS0 VCAP support and more TC keys and actions to support this - add TC policer and drop action support (depends on the Sparx5 QoS support upstreamed separately) - Sparx5 ES0 VCAP support and more TC actions to support this - TC flower template support - TC matchall filter support for mirroring and policing ports - TC flower filter mirror action support - Sparx5 ES2 VCAP support The LAN966x switchcore will also be updated to use the VCAP API as well as future Microchip switches. The LAN966x has 3 VCAPS (IS1, IS2 and ES0) and a slightly different keyset and actionset portfolio than Sparx5. Version History: ================ v3 Moved the sparx5_tc_flower_set_exterr function to the VCAP API and renamed it. Moved the sparx5_netbytes_copy function to the VCAP_API and renamed it (thanks Horatiu Vultur). Fixed indentation in the vcap_write_rule function. Added a comment mentioning the typegroup table terminator in the vcap_iter_skip_tg function. v2 Made the KUNIT test model a superset of the real model to fix a kernel robot build error. v1 Initial version ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents abc2109 + 67d6375 commit c1aa0a9

25 files changed

+11877
-4
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,7 @@ L: [email protected] (moderated for non-subscribers)
24392439
S: Supported
24402440
T: git git://github.com/microchip-ung/linux-upstream.git
24412441
F: arch/arm64/boot/dts/microchip/
2442+
F: drivers/net/ethernet/microchip/vcap/
24422443
F: drivers/pinctrl/pinctrl-microchip-sgpio.c
24432444
N: sparx5
24442445

drivers/net/ethernet/microchip/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ config LAN743X
5757

5858
source "drivers/net/ethernet/microchip/lan966x/Kconfig"
5959
source "drivers/net/ethernet/microchip/sparx5/Kconfig"
60+
source "drivers/net/ethernet/microchip/vcap/Kconfig"
6061

6162
endif # NET_VENDOR_MICROCHIP

drivers/net/ethernet/microchip/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ lan743x-objs := lan743x_main.o lan743x_ethtool.o lan743x_ptp.o
1111

1212
obj-$(CONFIG_LAN966X_SWITCH) += lan966x/
1313
obj-$(CONFIG_SPARX5_SWITCH) += sparx5/
14+
obj-$(CONFIG_VCAP) += vcap/

drivers/net/ethernet/microchip/sparx5/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ config SPARX5_SWITCH
99
select PHYLINK
1010
select PHY_SPARX5_SERDES
1111
select RESET_CONTROLLER
12+
select VCAP
1213
help
1314
This driver supports the Sparx5 network switch device.

drivers/net/ethernet/microchip/sparx5/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o
77

8-
sparx5-switch-objs := sparx5_main.o sparx5_packet.o \
8+
sparx5-switch-y := sparx5_main.o sparx5_packet.o \
99
sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o \
1010
sparx5_switchdev.o sparx5_calendar.o sparx5_ethtool.o sparx5_fdma.o \
11-
sparx5_ptp.o sparx5_pgid.o sparx5_tc.o sparx5_qos.o
11+
sparx5_ptp.o sparx5_pgid.o sparx5_tc.o sparx5_qos.o \
12+
sparx5_vcap_impl.o sparx5_vcap_ag_api.o sparx5_tc_flower.o
13+
14+
# Provide include files
15+
ccflags-y += -I$(srctree)/drivers/net/ethernet/microchip/vcap

drivers/net/ethernet/microchip/sparx5/sparx5_main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,14 @@ static int sparx5_start(struct sparx5 *sparx5)
672672

673673
sparx5_board_init(sparx5);
674674
err = sparx5_register_notifier_blocks(sparx5);
675+
if (err)
676+
return err;
677+
678+
err = sparx5_vcap_init(sparx5);
679+
if (err) {
680+
sparx5_unregister_notifier_blocks(sparx5);
681+
return err;
682+
}
675683

676684
/* Start Frame DMA with fallback to register based INJ/XTR */
677685
err = -ENXIO;
@@ -906,6 +914,7 @@ static int mchp_sparx5_remove(struct platform_device *pdev)
906914
sparx5_ptp_deinit(sparx5);
907915
sparx5_fdma_stop(sparx5);
908916
sparx5_cleanup_ports(sparx5);
917+
sparx5_vcap_destroy(sparx5);
909918
/* Unregister netdevs */
910919
sparx5_unregister_notifier_blocks(sparx5);
911920

drivers/net/ethernet/microchip/sparx5/sparx5_main.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ struct sparx5 {
288288
struct mutex ptp_lock; /* lock for ptp interface state */
289289
u16 ptp_skbs;
290290
int ptp_irq;
291+
/* VCAP */
292+
struct vcap_control *vcap_ctrl;
291293
/* PGID allocation map */
292294
u8 pgid_map[PGID_TABLE_SIZE];
293295
};
@@ -382,6 +384,10 @@ void sparx5_ptp_txtstamp_release(struct sparx5_port *port,
382384
struct sk_buff *skb);
383385
irqreturn_t sparx5_ptp_irq_handler(int irq, void *args);
384386

387+
/* sparx5_vcap_impl.c */
388+
int sparx5_vcap_init(struct sparx5 *sparx5);
389+
void sparx5_vcap_destroy(struct sparx5 *sparx5);
390+
385391
/* sparx5_pgid.c */
386392
enum sparx5_pgid_type {
387393
SPX5_PGID_FREE,

0 commit comments

Comments
 (0)