aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-08-01net/mlx5e: Fix uninitialized variableGustavo A. R. Silva1-1/+1
There is a potential execution path in which variable *err* is returned without being properly initialized previously. Fix this by initializing variable *err* to 0. Addresses-Coverity-ID: 1472116 ("Uninitialized scalar variable") Fixes: 0ec13877ce95 ("net/mlx5e: Gather all XDP pre-requisite checks in a single function") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Tariq Toukan <tariqt@mellanox.com> Acked-by: Saeed Mahameed <saeedm@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-31mlx5: handle DMA mapping error case for XDP redirectJesper Dangaard Brouer1-0/+3
Commit 58b99ee3e3eb ("net/mlx5e: Add support for XDP_REDIRECT in device-out side") forgot to return/free the xdp_frame in case the DMA mapping failed, correct this. Also DMA unmap the frame in case mlx5e_xmit_xdp_frame() fails. Fixes: 58b99ee3e3eb ("net/mlx5e: Add support for XDP_REDIRECT in device-out side") Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Reviewed-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-29Merge tag 'mlx5e-updates-2018-07-27' of git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linuxDavid S. Miller8-239/+320
Saeed Mahameed says: ==================== mlx5e-updates-2018-07-27 (Vxlan updates) This series from Gal and Saeed provides updates to mlx5 vxlan implementation. Gal, started with three cleanups to reflect the actual hardware vxlan state - reflect 4789 UDP port default addition to software database - check maximum number of vxlan UDP ports - cleanup an unused member in vxlan work Then Gal provides performance optimization by replacing the vxlan radix tree with a hash table. Measuring mlx5e_vxlan_lookup_port execution time: Radix Tree Hash Table --------------- ------------ ------------ Single Stream 161 ns 79 ns (51% improvement) Multi Stream 259 ns 136 ns (47% improvement) Measuring UDP stream packet rate, single fully utilized TX core: Radix Tree: 498,300 PPS Hash Table: 555,468 PPS (11% improvement) Next, from Saeed, vxlan refactoring to allow sharing the vxlan table between different mlx5 netdevice instances like PF and VF representors, this is done by making mlx5 vxlan interface more generic and decoupling it from PF netdevice structures and logic, then moving it into mlx5 core as a low level interface so it can be used by VF representors, which is illustrated in the last patch of the serious. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-27net/mlx5e: Issue direct lookup on vxlan ports by vport representorsSaeed Mahameed1-10/+2
Remove uplink representor netdevice private structure lookup, and use mlx5 core handle directly from representor private structure to lookup vxlan ports. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, move vxlan logic to core driverSaeed Mahameed7-19/+19
Move vxlan logic and objects to mlx5 core dirver. Since it going to be used from different mlx5 interfaces. e.g. mlx5e PF NIC netdev and mlx5e E-Switch representors. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, add sync lock for add/del vxlan portSaeed Mahameed1-3/+15
Vxlan API can and will be called from different mlx5 modules, we should not count on mlx5e private state lock only, hence we introduce a vxlan private mutex to sync between add/del vxlan port operations. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, return values for add/del portSaeed Mahameed2-11/+21
For a better API mlx5_vxlan_{add/del}_port can fail, make them return error values. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, rename from mlx5e to mlx5Saeed Mahameed5-79/+104
Rename vxlan functions from mlx5e_vxlan_* to mlx5_vxlan_*. Rename mlx5e_vxlan_db to mlx5_vxlan and move it from en.h to vxlan.c since it is not related to mlx5e anymore. Allocate mlx5_vxlan structure dynamically in order to make it easier to move later to core driver and to make it private in vxlan.c. This is in preparation to move vxlan API to mlx5 core. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, rename struct mlx5e_vxlan to mlx5_vxlan_portSaeed Mahameed2-34/+33
The name mlx5e_vxlan will be used in downstream patch to describe mlx5 vxlan structure that will replace mlx5e_vxlan_db. Hence we rename struct mlx5e_vxlan to mlx5_vxlan_port which describes a mlx5 vxlan port. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, move netdev only logic to en_main.cSaeed Mahameed3-61/+61
Create a direct vxlan API to add and delete vxlan ports from HW. +void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port); +void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port); And move vxlan_add/del_work to en_main.c since they are netdev only logic. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, add direct delete functionSaeed Mahameed1-6/+13
Add direct vxlan delete function to be called from vxlan_delete_work. Needed in downstream patch. Signed-off-by: Saeed Mahameed <saeedm@mellanox.com> Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
2018-07-27net/mlx5e: Vxlan, cleanup an unused member in vxlan workGal Pressman3-8/+4
Cleanup the sa_family member of the vxlan work, it is unused/needed anywhere in the code. Signed-off-by: Gal Pressman <galp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-27net/mlx5e: Vxlan, replace ports radix-tree with hash tableGal Pressman3-17/+28
The VXLAN database is accessed in the data path for each VXLAN TX skb in order to check whether the UDP port is being offloaded or not. The number of elements in the database is relatively small, we can simplify the radix-tree to a hash table and speedup the lookup process. Measuring mlx5e_vxlan_lookup_port execution time: Radix Tree Hash Table --------------- ------------ ------------ Single Stream 161 ns 79 ns (51% improvement) Multi Stream 259 ns 136 ns (47% improvement) Measuring UDP stream packet rate, single fully utilized TX core: Radix Tree: 498,300 PPS Hash Table: 555,468 PPS (11% improvement) Signed-off-by: Gal Pressman <galp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-27net/mlx5e: Vxlan, check maximum number of UDP portsGal Pressman2-0/+15
The NIC has a limited number of offloaded VXLAN UDP ports (usually 4). Instead of letting the firmware fail when trying to add more ports than it can handle, let the driver check it on its own. Signed-off-by: Gal Pressman <galp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-27net/mlx5e: Vxlan, reflect 4789 UDP port default addition to software databaseGal Pressman1-13/+27
The hardware offloads 4789 UDP port (default VXLAN port) automatically. Add it to the software database as well in order to reflect the hardware state appropriately. Signed-off-by: Gal Pressman <galp@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-27mlxsw: spectrum: Support ieee_setapp, ieee_delappPetr Machata2-2/+271
The APP TLVs are used for communicating priority-to-protocol ID maps for a given netdevice. Support the following APP TLVs: - DSCP (selector 5) to configure priority-to-DSCP code point maps. Use these maps to configure packet priority on ingress, and DSCP code point rewrite on egress. - Default priority (selector 1, PID 0) to configure priority for the DSCP code points that don't have one assigned by the DSCP selector. In future this could also be used for assigning default port priority when a packet arrives without DSCP tagging. Besides setting up the maps themselves, also configure port trust level and rewrite bits. Port trust level determines whether, for a packet arriving through a certain port, the priority should be determined based on PCP or DSCP header fields. So far, mlxsw kept the device default of trust-PCP. Now, as soon as the first DSCP APP TLV is configured, switch to trust-DSCP. Only when all DSCP APP TLVs are removed, switch back to trust-PCP again. Note that the default priority APP TLV doesn't impact the trust level configuration. Rewrite bits determine whether DSCP and PCP fields of egressing packets should be updated according to switch priority. When port trust is switched to DSCP, enable rewrite of DSCP field. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-27mlxsw: reg: Add QoS Priority to DSCP Mapping RegisterPetr Machata1-0/+89
This register controls mapping from Priority to DSCP for purposes of rewrite. Note that rewrite happens as the packet is transmitted provided that the DSCP rewrite bit is enabled for the packet. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-27mlxsw: reg: Add QoS ReWrite Enable RegisterPetr Machata1-0/+39
This register configures the rewrite enable (whether PCP or DSCP value in packet should be updated according to packet priority) per receive port. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-27mlxsw: reg: Add QoS Priority Trust State RegisterPetr Machata1-0/+39
The QPTS register controls the port policy to calculate the switch priority and packet color based on incoming packet fields. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-27mlxsw: reg: Add QoS Port DSCP to Priority Mapping RegisterPetr Machata1-0/+52
The QPDPM register controls the mapping from DSCP field to Switch Priority for IP packets. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-26net/mlx5e: TX, Use function to access sq_dma object in fifoTariq Toukan1-10/+9
Use designated function mlx5e_dma_get() to get the mlx5e_sq_dma object to be pushed into fifo. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: TX, Move DB fields in TXQ-SQ structTariq Toukan1-6/+4
Pointers in DB are static, move them to read-only area so they do not share a cacheline with fields modified in datapath. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: RX, Prefetch the xdp_frame data areaTariq Toukan1-0/+1
A loaded XDP program might write to the xdp_frame data area, prefetchw() it to avoid a potential cache miss. Performance tests: ConnectX-5, XDP_TX packet rate, single ring. CPU: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz Before: 13,172,976 pps After: 13,456,248 pps 2% gain. Fixes: 22f453988194 ("net/mlx5e: Support XDP over Striding RQ") Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Add support for XDP_REDIRECT in device-out sideTariq Toukan7-21/+154
Add implementation for the ndo_xdp_xmit callback. Dedicate a new set of XDP-SQ instances to satisfy the XDP_REDIRECT requests. These instances are totally separated from the existing XDP-SQ objects that satisfy local XDP_TX actions. Performance tests: xdp_redirect_map from ConnectX-5 to ConnectX-5. CPU: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz Packet-rate of 64B packets. Single queue: 7 Mpps. Multi queue: 55 Mpps. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Re-order fields of struct mlx5e_xdpsqTariq Toukan4-18/+19
In the downstream patch that adds support to XDP_REDIRECT-out, the XDP xmit frame function doesn't share the same run context as the NAPI that polls the XDP-SQ completion queue. Hence, need to re-order the XDP-SQ fields to avoid cacheline false-sharing. Take redirect_flush and doorbell out of DB, into separated cachelines. Add a cacheline breaker within the stats struct. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Refactor XDP countersTariq Toukan5-26/+52
Separate the XDP counters into two sets: (1) One set reside in the RQ stats, and they monitor XDP stats in the RQ side. (2) Another set is per XDP-SQ, and they monitor XDP stats that are related to XDP transmit flow. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Make XDP xmit functions more genericTariq Toukan4-42/+61
Convert the XDP xmit functions to use the generic xdp_frame API in XDP_TX flow. Same functions will be used later in this series to transmit the XDP redirect-out packets as well. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Eugenia Emantayev <eugenia@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Add counter for XDP redirect in RXTariq Toukan3-0/+6
Add per-ring and total stats for received packets that goes into XDP redirection. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Move XDP related code into new XDP filesTariq Toukan7-215/+293
Take XDP code out of the general EN header and RX file into new XDP files. Currently, XDP-SQ resides only within an RQ and used from a single flow (XDP_TX) triggered upon RX completions. In a downstream patch, additional type of XDP-SQ instances will be presented and used for the XDP_REDIRECT flow, totally unrelated to the RX context. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Restrict the combination of large MTU and XDPTariq Toukan2-8/+33
Add checks in control path upon an MTU change or an XDP program set, to prevent reaching cases where large MTU and XDP are set simultaneously. This is to make sure we allow XDP only with the linear RX memory scheme, i.e. a received packet is not scattered to different pages. Change mlx5e_rx_get_linear_frag_sz() accordingly, so that we make sure the XDP configuration can really be set, instead of assuming that it is. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Gather all XDP pre-requisite checks in a single functionTariq Toukan1-11/+22
Dedicate a function to all checks done when setting an XDP program. Take indications from priv instead of netdev features. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Do not recycle RX pages in interface down flowTariq Toukan1-17/+20
Keep all page-pool recycle calls within NAPI context. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-26net/mlx5e: Replace call to MPWQE free with dealloc in interface down flowTariq Toukan3-3/+2
No need to expose the MPWQE free function to control path. The dealloc function already exposed, use it. Signed-off-by: Tariq Toukan <tariqt@mellanox.com> Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-07-25mlxsw: spectrum_acl: Start using A-TCAMIdo Schimmel7-36/+124
Now that all the pieces are in place we can start using the A-TCAM instead of only using the C-TCAM. This allows for much higher scale and better performance (to be improved further by follow-up patch sets). Perform the integration with the A-TCAM and the eRP core by reverting the changes introduced by "mlxsw: spectrum_acl: Enable C-TCAM only mode in eRP core" and add calls from the C-TCAM code into the eRP core. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Add A-TCAM rule insertion and deletionIdo Schimmel4-5/+485
Implement rule insertion and deletion into the A-TCAM before we flip the driver to start using the A-TCAM. Rule insertion into the A-TCAM is very similar to C-TCAM, but there are subtle differences between regions of different sizes (i.e., different number of key blocks). Specifically, as explained in "mlxsw: spectrum_acl: Allow encoding a partial key", in 12 key blocks regions a rule is split into two and the two halves of the rule are linked using a "large entry key ID". Such differences are abstracted away by using different region operations per region type. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Pass C-TCAM region and entry to insert functionIdo Schimmel1-10/+11
When A-TCAM will be used together with C-TCAM, the C-TCAM code will need to call into the eRP core in order to get an eRP for an inserted entry. The eRP core takes an A-TCAM region as one of its arguments, so pass the C-TCAM region to the insertion function which will later allow us to derive the A-TCAM region, given it contains the C-TCAM one. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Add A-TCAM region initializationIdo Schimmel1-22/+33
Before we start using the A-TCAM we need to make sure the region is properly initialized. This includes the setting of its type (which affects the size of its eRP table, for example) and its registration with the eRP core. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Make global TCAM resources available to regionsIdo Schimmel6-3/+9
Each TCAM region currently uses its own resources and there is no sharing between the different regions. This is going to change with A-TCAM as each region will need to allocate an eRP table from the global eRP tables array. Make the global TCAM resources available to each region by passing the TCAM private data to the region initialization routine. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Encapsulate C-TCAM region in A-TCAM regionIdo Schimmel3-11/+16
In Spectrum-2 the C-TCAM is only used for rules that can't fit in the A-TCAM due to a limited number of masks per A-TCAM region. In addition, rules inserted into the C-TCAM may affect rules residing in the A-TCAM, by clearing their C-TCAM prune bit. The two regions are thus closely related and can be thought of as if the C-TCAM region is encapsulated in the A-TCAM one. Change the data structures to reflect that before introducing A-TCAM support and make C-TCAM region initialization part of the A-TCAM region initialization sequence. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Add A-TCAM initializationIdo Schimmel3-0/+23
Initialize the A-TCAM as part of the driver's initialization routine. Specifically, initialize the eRP tables so that A-TCAM regions will be able to perform allocations of eRP tables upon rule insertion in subsequent patches. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Allow encoding a partial keyIdo Schimmel3-6/+11
When working with 12 key blocks in the A-TCAM, rules are split into two records, which constitute two lookups. The two records are linked using a "large entry key ID". The ID is assigned to key blocks 6 to 11 and resolved during the first lookup. The second lookup is performed using the ID and the remaining key blocks. Allow encoding a partial key so that it can be later used to check if an ID can be reused. This is done by adding two arguments to the existing encode function that specify the range of the block indexes we would like to encode. The key and mask arguments become optional, as we will not need to encode both of them all the time. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Extend Spectrum-2 region structIdo Schimmel1-0/+3
In a similar fashion to Spectrum-1's region struct, Spectrum-2's struct needs to store a pointer to the common region struct. The pointer will be used in follow-up patches that implement rules insertion and deletion. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Add support for C-TCAM eRPsIdo Schimmel2-13/+191
The number of eRPs that can be used by a single A-TCAM region is limited to 16. When more eRPs are needed, an ordinary circuit TCAM (C-TCAM) can be used to hold the extra eRPs. Unlike the A-TCAM, only a single (last) lookup is performed in the C-TCAM and not a lookup per-eRP. However, modeling the C-TCAM as extra eRPs will allow us to easily introduce support for pruning in a follow-up patch set and is also logically correct. The following diagram depicts the relation between both TCAMs: C-TCAM +-------------------+ +--------------------+ +-----------+ | | | | | | | eRP #1 (A-TCAM) +----> ... +----+ eRP #16 (A-TCAM) +----+ eRP #17 | | | | | | ... | +-------------------+ +--------------------+ | eRP #N | | | +-----------+ Lookup order is from left to right. Extend the eRP core APIs with a C-TCAM parameter which indicates whether the requested eRP is to be used with the C-TCAM or not. Since the C-TCAM is only meant to absorb rules that can't fit in the A-TCAM due to exceeded number of eRPs or key collision, an error is returned when a C-TCAM eRP needs to be created when the eRP state machine is in its initial state (i.e., 'no masks'). This should only happen in the face of very unlikely errors when trying to push rules into the A-TCAM. In order not to perform unnecessary lookups, the eRP core will only enable a C-TCAM lookup for a given region if it knows there are C-TCAM eRPs present. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Enable C-TCAM only mode in eRP coreIdo Schimmel1-3/+7
Currently, no calls are performed into the eRP core, but in order to make review easier we would like to gradually add these calls. Have the eRP core initialize a region's master mask to all ones and allow it to use an empty eRP table. This directs the lookup to the C-TCAM and allows the C-TCAM only mode to continue working. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: spectrum_acl: Implement common eRP coreIdo Schimmel4-1/+1061
When rules are inserted into the A-TCAM they are associated with a mask, which is part of the lookup key: { masked key, mask ID, region ID }. These masks are called rule patterns (RP) and the aggregation of several masks into one (to be introduced in follow-up patch sets) is called an extended RP (eRP). When a packet undergoes a lookup in an ACL region it is masked by the current set of eRPs used by the region, looking for an exact match. Eventually, the rule with the highest priority is picked. These eRPs are stored in several global banks to allow for lookup to occur using several eRPs simultaneously. At first, an ACL region will only require a single mask - upon the insertion of the first rule. In this case, the region can use the "master RP" which is composed by OR-ing all the masks used by the region. This mask is a property of the region and thus there is no need to use the above mentioned banks. At some point, a second mask will be needed. In this case, the region will need to allocate an eRP table from the above mentioned banks and insert its masks there. >From now on, upon lookup, the eRP table used by the region will be fetched from the eRP banks - using {eRP bank, Index within the bank} - and the eRPs present in the table will be used to mask the packet. Note that masks with consecutive indexes are inserted into consecutive banks. When rules are deleted and a region only needs a single mask once again it can free its eRP table and use the master RP. The above logic is implemented in the eRP core and represented using the following state machine: +------------+ create mask - as master RP +---------------+ | +--------------------------------> | | no masks | | single mask | | <--------------------------------+ | +------------+ delete mask +-----+--^------+ | | | | create mask - | | delete mask - create mask transition to use eRP | | transition to +--------+ table | | use master RP | | | | | | | | +----v--------+----+ create mask +----v--+-----+ | <-------------------------------+ | | multiple masks | | two masks | | +-------------------------------> | +------------------+ delete mask - if two +-------------+ remaining The code that actually configures rules in the A-TCAM will interface with the eRP core by getting or putting an eRP based on the required mask used by the rule. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: resources: Add Spectrum-2 eRP resourcesIdo Schimmel1-0/+12
Add the following resources to be used by A-TCAM code: * Maximum number of eRP banks * Maximum size of eRP bank * Number of eRP entries required for a 2/4/8/12 key blocks mask Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: resources: Add Spectrum-2 maximum large key ID resourceIdo Schimmel1-0/+2
Add a resource to make sure we do not exceed the maximum number of supported large key IDs in a region. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: reg: Add Policy-Engine eRP Table RegisterIdo Schimmel1-0/+113
The register is used to add and delete eRPs from the eRP table. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: reg: Add Policy-Engine TCAM Entry Register Version 3Ido Schimmel1-3/+162
The register is used to configure rules in the A-TCAM. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-25mlxsw: reg: Prepare PERERP register for A-TCAM usageIdo Schimmel2-4/+20
Before introducing A-TCAM support we need to make sure all the necessary fields are configurable and not hard coded to values that worked for the C-TCAM only use case. This includes - for example - the ability to configure the eRP table used by the TCAM region. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>