aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/microchip/vcap
AgeCommit message (Collapse)AuthorFilesLines
2023-05-15net: ethernet: microchip: vcap: Remove extra semicolonAnup Sharma1-4/+4
Remove the extra semicolon at end. Issue identified using semicolon.cocci Coccinelle semantic patch. drivers/net/ethernet/microchip/vcap/vcap_api.c:1124:3-4: Unneeded semicolon drivers/net/ethernet/microchip/vcap/vcap_api.c:1165:3-4: Unneeded semicolon drivers/net/ethernet/microchip/vcap/vcap_api.c:1239:3-4: Unneeded semicolon drivers/net/ethernet/microchip/vcap/vcap_api.c:1287:3-4: Unneeded semicolon Signed-off-by: Anup Sharma <[email protected]> Changes: V1 -> V2: Target tree included in the subject line. Signed-off-by: David S. Miller <[email protected]>
2023-05-10net: lan966x: Add ES0 VCAP modelHoratiu Vultur1-29/+38
Provide ES0 (egress stage 0) VCAP model for lan966x. This provides rewriting functionality in the gress path. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-03-10net: lan966x: Add IS1 VCAP modelHoratiu Vultur2-59/+162
Provide IS1 (ingress stage 1) VCAP model for lan966x. This provides classification actions for lan966x. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
2023-03-08net: microchip: sparx5: Provide rule count, key removal and keyset selectSteen Hegelund2-0/+72
This provides these 3 functions in the VCAP API: - Count the number of rules in a VCAP lookup (chain) - Remove a key from a VCAP rule - Find the keyset that gives the smallest rule list from a list of keysets Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-02-20net: microchip: sparx5: reduce stack usageArnd Bergmann1-14/+12
The vcap_admin structures in vcap_api_next_lookup_advanced_test() take several hundred bytes of stack frame, but when CONFIG_KASAN_STACK is enabled, each one of them also has extra padding before and after it, which ends up blowing the warning limit: In file included from drivers/net/ethernet/microchip/vcap/vcap_api.c:3521: drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c: In function 'vcap_api_next_lookup_advanced_test': drivers/net/ethernet/microchip/vcap/vcap_api_kunit.c:1954:1: error: the frame size of 1448 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] 1954 | } Reduce the total stack usage by replacing the five structures with an array that only needs one pair of padding areas. Fixes: 1f741f001160 ("net: microchip: sparx5: Add KUNIT tests for enabling/disabling chains") Signed-off-by: Arnd Bergmann <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-02-16net: microchip: sparx5: Add TC vlan action support for the ES0 VCAPSteen Hegelund2-0/+4
This provides these 3 actions for rule in the ES0 VCAP: - action vlan pop - action vlan modify id X priority Y - action vlan push id X priority Y protocol Z Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-02-16net: microchip: sparx5: Add ES0 VCAP model and updated KUNIT VCAP modelSteen Hegelund4-119/+339
This provides the VCAP model for the Sparx5 ES0 (Egress Stage 0) VCAP. This VCAP provides rewriting functionality in the egress path. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-02-16net: microchip: sparx5: Use chain ids without offsets when enabling rulesSteen Hegelund1-6/+5
This improves the check performed on linked rules when enabling or disabling them. The chain id used must be the chain id without the offset used for linking the rules. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-02-16net: microchip: sparx5: Clear rule counter even if lookup is disabledSteen Hegelund2-4/+7
The rule counter must be cleared when creating a new rule, even if the VCAP lookup is currently disabled. This ensures that rules located in VCAPs that use external counters (such as Sparx5 IS2 and ES0) will have their counter reset even if the VCAP lookup is not enabled at the moment. Signed-off-by: Steen Hegelund <[email protected]> Fixes: 95fa74148daa ("net: microchip: sparx5: Reset VCAP counter for new rules") Signed-off-by: Paolo Abeni <[email protected]>
2023-02-10net: microchip: vcap: Add tc flower keys for lan966xHoratiu Vultur3-1/+441
Add the following TC flower filter keys to lan966x for IS2: - ipv4_addr (sip and dip) - ipv6_addr (sip and dip) - control (IPv4 fragments) - portnum (tcp and udp port numbers) - basic (L3 and L4 protocol) - vlan (outer vlan tag info) - tcp (tcp flags) - ip (tos field) As the parsing of these keys is similar between lan966x and sparx5, move the code in a separate file to be shared by these 2 chips. And put the specific parsing outside of the common functions. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-02-06sparx5: add support for configuring PSFP via tcDaniel Machon2-1/+5
Add support for tc actions gate and police, in order to implement support for configuring PSFP through tc. Signed-off-by: Daniel Machon <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-30net: microchip: sparx5: Add KUNIT tests for enabling/disabling chainsSteen Hegelund1-0/+66
This enhances the KUNIT test of the VCAP API with tests of the chaining functionality. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-30net: microchip: sparx5: Add ingress information to VCAP instanceSteen Hegelund5-6/+14
This allows the check of the goto action to be specific to the ingress and egress VCAP instances. The debugfs support is also updated to show this information. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-30net: microchip: sparx5: Add ES2 VCAP keyset configuration for Sparx5Steen Hegelund1-1/+4
This adds the ES2 VCAP port keyset configuration for Sparx5 and also updates the debugFS support to show the keyset configuration and the egress port mask. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-30net: microchip: sparx5: Add ES2 VCAP model and updated KUNIT VCAP modelSteen Hegelund2-12/+13
This provides the VCAP model for the Sparx5 ES2 (Egress Stage 2) VCAP. This VCAP provides tagging and remarking functionality This also renames a VCAP keyfield: VCAP_KF_MIRROR_ENA becomes VCAP_KF_MIRROR_PROBE, as the first name was caused by a mistake in the model transformation. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-30net: microchip: sparx5: Add support for getting keysets without a type idSteen Hegelund1-1/+23
When there is only one keyset available for a certain VCAP rule size, the particular keyset does not need a type id when encoded in the VCAP Hardware. This provides support for getting a keyset from a rule, when this is the case: only one keyset fits this rule size. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-26net: microchip: sparx5: Add automatic selection of VCAP rule actionsetSteen Hegelund2-5/+109
With more than one possible actionset in a VCAP instance, the VCAP API will now use the actions in a VCAP rule to select the actionset that fits these actions the best possible way. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-01-26net: microchip: sparx5: Add TC filter chaining support for IS0 and IS2 VCAPsSteen Hegelund2-1/+44
This allows rules to be chained between VCAP instances, e.g. from IS0 Lookup 0 to IS0 Lookup 1, or from one of the IS0 Lookups to one of the IS2 Lookups. Chaining from an IS2 Lookup to another IS2 Lookup is not supported in the hardware. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-01-26net: microchip: sparx5: Add actionset type id information to ruleSteen Hegelund1-0/+34
This adds the actionset type id to the rule information. This is needed as we now have more than one actionset in a VCAP instance (IS0). Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-01-26net: microchip: sparx5: Add IS0 VCAP model and updated KUNIT VCAP modelSteen Hegelund3-1818/+156
This provides the IS0 (Ingress Stage 0) or CLM VCAP model for Sparx5. This VCAP provides classification actions for Sparx5. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2023-01-23net: microchip: sparx5: Fix uninitialized variable in vcap_path_exist()Dan Carpenter1-1/+2
The "eport" variable needs to be initialized to NULL for this code to work. Fixes: 814e7693207f ("net: microchip: vcap api: Add a storage state to a VCAP rule") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Steen Hegelund <[email protected]> Link: https://lore.kernel.org/r/Y8qbYAb+YSXo1DgR@kili Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-20net: microchip: vcap: use kmemdup() to allocate memoryYang Yingliang1-4/+2
Use kmemdup() helper instead of open-coding to simplify the code when allocating newckf and newcaf. Generated by: scripts/coccinelle/api/memdup.cocci Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Jesse Brandeburg <[email protected]> Reviewed-by: Steen Hegelund <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2023-01-18net: microchip: sparx5: Add lock initialization to the KUNIT testsSteen Hegelund2-0/+2
Ensure that the KUNIT tests lock instance is initialized before the test is executed. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-18net: microchip: sparx5: Improve VCAP admin locking in the VCAP APISteen Hegelund1-30/+67
This improves the VCAP cache and the VCAP rule list protection against access from different sources. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-18net: microchip: sparx5: Add VCAP admin locking in debugFSSteen Hegelund3-30/+47
This ensures that the admin lock is taken before the debugFS functions starts iterating the VCAP rules. It also adds a separate function to decode a rule, which expects the lock to have been taken before it is called. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-18net: microchip: sparx5: Add support to check for existing VCAP rule idSteen Hegelund1-2/+16
Add a new function that just checks if the VCAP rule id is already used by an existing rule. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-18net: microchip: sparx5: Add support for rule count by cookieSteen Hegelund2-25/+44
This adds support for TC clients to get the packet count for a TC filter identified by its cookie. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Enable/Disable rules via chains in VCAP HWSteen Hegelund5-10/+222
This supports that individual rules are enabled and disabled via chain information. This is done by keeping disabled rules in the VCAP list (cached) until they are enabled, and only at this time are the rules written to the VCAP HW. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Add a storage state to a VCAP ruleSteen Hegelund4-27/+161
This allows a VCAP rule to be in one of 3 states: - permanently stored in the VCAP HW (for rules that must always be present) - enabled (stored in HW) when the corresponding lookup has been enabled - disabled (stored in SW) when the lookup is disabled This way important VCAP rules can be added even before the user enables the VCAP lookups using a TC matchall filter. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Check chains when adding a tc flower filterSteen Hegelund3-28/+41
This changes the way the chain information verified when adding a new tc flower filter. When adding a flower filter it is now checked that the filter contains a goto action to one of the IS2 VCAP lookups, except for the last lookup which may omit this goto action. It is also checked if you attempt to add multiple matchall filters to enable the same VCAP lookup. This will be rejected. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Use src and dst chain id to chain VCAP lookupsSteen Hegelund2-54/+77
This adds both the source and destination chain id to the information kept for enabled port lookups. This allows enabling and disabling a chain of lookups by walking the chain information for a port. This changes the way that VCAP lookups are enabled from userspace: instead of one matchall rule that enables all the 4 Sparx5 IS2 lookups, you need a matchall rule per lookup. In practice that is done by adding one matchall rule in chain 0 to goto IS2 Lookup 0, and then for each lookup you add a rule per lookup (low priority) that does a goto to the next lookup chain. Examples: If you want IS2 Lookup 0 to be enabled you add the same matchall filter as before: tc filter add dev eth12 ingress chain 0 prio 1000 handle 1000 matchall \ skip_sw action goto chain 8000000 If you also want to enable lookup 1 to 3 in IS2 and chain them you need to add the following matchall filters: tc filter add dev eth12 ingress chain 8000000 prio 1000 handle 1000 \ matchall skip_sw action goto chain 8100000 tc filter add dev eth12 ingress chain 8100000 prio 1000 handle 1000 \ matchall skip_sw action goto chain 8200000 tc filter add dev eth12 ingress chain 8200000 prio 1000 handle 1000 \ matchall skip_sw action goto chain 8300000 Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Convert multi-word keys/actions when encodingSteen Hegelund1-109/+134
The conversion to the platform specific multi-word format is moved from the key/action add functions to the encoding key/action. This allows rules that are disabled (not in VCAP HW) to use the same format for keys/actions as rules that have just been read from VCAP HW. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Always enable VCAP lookupsSteen Hegelund4-26/+3
This changes the VCAP lookups state to always be enabled so that it is possible to add "internal" VCAP rules that must be available even though the user has not yet enabled the VCAP chains via a TC matchall filter. The API callback to enable and disable VCAP lookups is therefore removed. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: sparx5: Reset VCAP counter for new rulesSteen Hegelund2-3/+8
When a rule counter is external to the VCAP such as the Sparx5 IS2 counters are, then this counter must be reset when a new rule is created. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2023-01-16net: microchip: vcap api: Erase VCAP cache before encoding ruleSteen Hegelund1-1/+1
For consistency the VCAP cache area is erased just before the new rule is being encoded. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2022-12-19net: microchip: vcap: Fix initialization of value and maskHoratiu Vultur1-0/+2
Fix the following smatch warning: smatch warnings: drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c:103 vcap_debugfs_show_rule_keyfield() error: uninitialized symbol 'value'. drivers/net/ethernet/microchip/vcap/vcap_api_debugfs.c:106 vcap_debugfs_show_rule_keyfield() error: uninitialized symbol 'mask'. In case the vcap field was VCAP_FIELD_U128 and the key was different than IP6_S/DIP then the value and mask were not initialized, therefore initialize them. Fixes: 610c32b2ce66 ("net: microchip: vcap: Add vcap_get_rule") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: Horatiu Vultur <[email protected]> Reviewed-by: Michal Swiatkowski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2022-12-06net: microchip: vcap: Remove unneeded semicolonszhang songyi1-2/+2
Semicolons after "}" are not needed. Signed-off-by: zhang songyi <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2022-12-06net: microchip: vcap: Add vcap_rule_get_key_u32Horatiu Vultur2-0/+20
Add the function vcap_rule_get_key_u32 which allows to get the value and the mask of a key that exist on the rule. If the key doesn't exist, it would return error. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2022-12-06net: microchip: vcap: Add vcap_mod_ruleHoratiu Vultur2-0/+38
Add the function vcap_mod_rule which allows to update an existing rule in the vcap. It is required for the rule to exist in the vcap to be able to modify it. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2022-12-06net: microchip: vcap: Add vcap_get_ruleHoratiu Vultur4-438/+848
Add function vcap_get_rule which returns a rule based on the internal rule id. The entire functionality of reading and decoding the rule from the VCAP was inside vcap_api_debugfs file. So move the entire implementation in vcap_api as this is used also by vcap_get_rule. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2022-12-01net: microchip: sparx5: Fix error handling in vcap_show_admin()Dan Carpenter1-4/+11
If vcap_dup_rule() fails that leads to an error pointer dereference side the call to vcap_free_rule(). Also it only returns an error if the very last call to vcap_read_rule() fails and it returns success for other errors. I've changed it to just stop printing after the first error and return an error code. Fixes: 3a7921560d2f ("net: microchip: sparx5: Add VCAP rule debugFS support for the VCAP API") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Steen Hegelund <[email protected]> Link: https://lore.kernel.org/r/Y4XUUx9kzurBN+BV@kili Signed-off-by: Paolo Abeni <[email protected]>
2022-11-30net: microchip: vcap: Change how the rule id is generatedHoratiu Vultur2-7/+1
Currently whenever a new rule id is generated, it picks up the next number bigger than previous id. So it would always be 1, 2, 3, etc. When the rule with id 1 will be deleted and a new rule will be added, it will have the id 4 and not id 1. In theory this can be a problem if at some point a rule will be added and removed ~0 times. Then no more rules can be added because there are no more ids. Change this such that when a new rule is added, search for an empty rule id starting with value of 1 as value 0 is reserved. Fixes: c9da1ac1c212 ("net: microchip: sparx5: Adding initial tc flower support for VCAP API") Signed-off-by: Horatiu Vultur <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2022-11-29net: microchip: vcap: Implement w32beHoratiu Vultur1-4/+112
On lan966x the layout of the vcap memory is different than on sparx5. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2022-11-29net: microchip: vcap: Extend vcap with lan966xHoratiu Vultur1-56/+146
Add the keysets, keys, actionsets and actions used by lan966x in IS2. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2022-11-29net: microchip: vcap: Merge the vcap_ag_api_kunit.h into vcap_ag_api.hHoratiu Vultur3-720/+393
Currently there are 2 files that contain the keyfields, keys, actionfields and actions. First file is used by the kunit while the second one is used by VCAP api. The header file that is used by kunit is just a super set of the of the header file used by VCAP api. Therefore not to have duplicate information in different files which is also harder to maintain, create a single file that is used both by API and by kunit. Signed-off-by: Horatiu Vultur <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
2022-11-25net: microchip: sparx5: Add VCAP filter keys KUNIT testSteen Hegelund1-0/+194
This tests the filtering of keys, either dropping unsupported keys or dropping keys specified in a list. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2022-11-25net: microchip: sparx5: Support for displaying a list of keysetsSteen Hegelund2-44/+74
This will display a list of keyset in case the type_id field in the VCAP rule has been wildcarded. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2022-11-25net: microchip: sparx5: Support for copying and modifying rules in the APISteen Hegelund4-11/+206
This adds support for making a copy of a rule and modify keys and actions to differentiate the copy. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2022-11-21net: microchip: sparx5: Add VCAP debugfs KUNIT testSteen Hegelund4-3/+553
This tests the functionality of the debugFS support: - finding valid keyset on an address - raw VCAP output - full rule VCAP output Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2022-11-21net: microchip: sparx5: Add VCAP locking to protect rulesSteen Hegelund3-0/+13
This ensures that the VCAP cache and the lists maintained in the VCAP instance is protected when accessed by different clients. Signed-off-by: Steen Hegelund <[email protected]> Signed-off-by: David S. Miller <[email protected]>