aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-12-10net: Add netif_is_gretap()/netif_is_ip6gretap()Oz Shlomo1-2/+2
Changed the is_gretap_dev and is_ip6gretap_dev logic from structure comparison to string comparison of the rtnl_link_ops kind field. This approach aligns with the current identification methods and function names of vxlan and geneve network devices. Convert mlxsw to use these helpers and use them in downstream mlx5 patch. Signed-off-by: Oz Shlomo <ozsh@mellanox.com> Reviewed-by: Eli Britstein <elibr@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2018-08-09mlxsw: Replace license text with SPDX identifiers and adjust copyrightsJiri Pirko1-33/+2
Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-11mlxsw: spectrum_span: Change LAG lower selectionPetr Machata1-1/+4
When offloading mirror-to-gretap, mlxsw needs to preroute the path that the encapsulated packet will take. That path may include a LAG device above a front panel port. So far, mlxsw resolved the path to the first up front panel slave of the LAG interface, but that only reflects administrative state of the port. It neglects to consider whether the port actually has a carrier, and what the LACP state is. So instead of checking upness of the device, check carrier state and txability. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-06-04mlxsw: spectrum_span: Suppress VLAN on BRIDGE_VLAN_INFO_UNTAGGEDPetr Machata1-1/+3
When offloading mirroring to gretap or ip6gretap netdevices, an 802.1q bridge is one of the soft devices permissible in the underlay when resolving the packet path. After the packet path is resolved to a particular bridge egress device, flags on packet VLAN determine whether the egressed packet should be tagged. The current logic however only ever sets the VLAN tag, never suppresses it. Thus if there's a VLAN netdevice above the bridge that determines the packet VLAN, that VLAN is never unset, and mirroring is configured with VLAN tagging. Fix by setting the packet VLAN on both branches: set to zero (for unset) when BRIDGE_VLAN_INFO_UNTAGGED, copy the resolved VLAN (e.g. from bridge PVID) otherwise. Fixes: 946a11e7408e ("mlxsw: spectrum_span: Allow bridge for gretap mirror") 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-05-14mlxsw: spectrum_span: Support LAG under mirror-to-gretapPetr Machata1-0/+21
When resolving a path that the packet will take after being encapsulated in mirror-to-gretap scenarios, one of the devices en route could be a LAG. In that case, mirror to first up slave that corresponds to a front panel 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-05-11mlxsw: spectrum_span: Use a more fitting error codePetr Machata1-1/+1
ENOENT is suitable when an item is looked for in a collection and can't be found. The failure here is actually a depletion of a resource, where ENOBUFS is the more fitting error code. 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-05-11mlxsw: spectrum_span: Rename misnamed variable l3edevPetr Machata1-16/+16
Calling the variable l3edev was relevant when neighbor lookup was the last stage in the simulated pipeline. Now that mlxsw handles bridges and vlan devices as well, calling it "L3" is a misnomer. Thus in mlxsw_sp_span_dmac(), rename to "dev", because that function is just a service routine where the distinction between tunnel and egress device isn't necessary. In mlxsw_sp_span_entry_tunnel_parms_common(), rename to "edev" to emphasize that the routine traces packet egress. 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-05-10mlxsw: spectrum_span: Support VLAN under mirror-to-gretapPetr Machata1-8/+19
When mirroring to a gretap or ip6gretap device, allow the underlay packet path to include VLAN devices. The following configurations are supported in underlay: - vlan over phys - vlan-unaware bridge where the egress device is vlan over phys - vlan over vlan-aware bridge where the egress device is phys 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-05-10mlxsw: spectrum_span: Support mirror-to-VLANPetr Machata1-0/+64
Offload "tc action mirred mirror" to a device that is a vlan device on top of a front-panel port device. The hardware encapsulates the mirrored packets in a VLAN tag. That includes the case that the mirrored traffic is already VLAN-tagged--in that case the monitor traffic will be double-tagged, just like in the software path. 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-04-30mlxsw: spectrum_span: Allow bridge for gretap mirrorPetr Machata1-6/+89
When handling mirroring to a gretap or ip6gretap netdevice in mlxsw, the underlay address (i.e. the remote address of the tunnel) may be routed to a bridge. In that case, look up the resolved neighbor Ethernet address in that bridge's FDB. Then configure the offload to direct the mirrored traffic to that port, possibly with tagging. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-23mlxsw: spectrum_span: Prevent duplicate mirrorsIdo Schimmel1-4/+24
In net commit 8175f7c4736f ("mlxsw: spectrum: Prevent duplicate mirrors") we prevented the user from mirroring more than once from a single binding point (port-direction pair). The fix was essentially reverted in a merge conflict resolution when net was merged into net-next. Restore it. Fixes: 03fe2debbb27 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net") 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-03-23mlxsw: spectrum_span: Fix initialization of struct mlxsw_sp_span_parmsPetr Machata1-2/+2
Since the first element of struct mlxsw_sp_span_parms is a pointer, to zero-initialize this structure the correct notation is not = {0}, but rather = {NULL}, as reported by sparse. Signed-off-by: Petr Machata <petrm@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-03-12mlxsw: spectrum: Don't depend on ip_gre and ip6_grePetr Machata1-1/+9
mlxsw_spectrum supports offloading of a tc action mirred egress mirror to a gretap or an ip6gretap netdevice, which necessitates calls to functions defined in ip_gre, ip6_gre and ip6_tunnel modules. Previously this was enabled by introducing a hard dependency of MLXSW_SPECTRUM on NET_IPGRE and IPV6_GRE. However the rest of mlxsw is careful about picking which modules are absolutely required, and therefore the better approach is to make mlxsw_spectrum tolerant of absence of one or both of the GRE flavors. Hence rework the NET_IPGRE and IPV6_GRE dependencies to just guard matching modularity, and hide the corresponding code in spectrum_span.c in an #if IS_ENABLED. Mark mlxsw_sp_span_entry_tunnel_parms_common as maybe unused, to muffle warnings if neither GRE flavor is selected, which seems cleaner than introducing a composite #if. 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-03-12mlxsw: spectrum: Move mlxsw_sp_span_gretap4_route()Petr Machata1-33/+33
Move the function next to the rest of gretap4 functions. Thus the generic functions shared between gretap4 and gretap6 are in one block at the beginning, followed by a gretap4 block, followed by a gretap6 block. 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-02-27mlxsw: spectrum_span: Support mirror to ip6gretapPetr Machata1-0/+101
Similarly to mirror-to-gretap, this enables mirroring to IPv6 gretap netdevice. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: spectrum_span: Support mirror to gretapPetr Machata1-2/+165
When a user requests mirror from a mlxsw physical port (possibly based on an ACL match) to a gretap netdevice, the driver needs to resolve the request to a particular physical port that the mirrored packets will egress through, and a suite of configuration keys (importantly, IP and MAC addresses). That means calling into routing and neighbor kernel code to simulate the decisions made by the system for packets passing through a gretap netdevice. Add a new instance of mlxsw_sp_span_entry_ops to support this. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: Move a mirroring check to mlxsw_sp_span_entry_createPetr Machata1-1/+5
The check for whether a mirror port (which is a mlxsw front panel port) belongs to the same mlxsw instance as the mirrored port, is currently only done in spectrum_acl, even though it's applicable for the matchall case as well. Thus move it to mlxsw_sp_span_entry_create(). Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: Handle config changes pertinent to SPANPetr Machata1-0/+24
For some netdevices, for which mlxsw offloads mirroring, may have a complex relationship between the declared intent and low-level device configuration. Trying to accurately track which changes might influence offloading decisions is finicky and error-prone. Instead, this patch introduces a function mlxsw_sp_span_entry_respin, which re-queries the configuration anew and, if different, removes the existing offloads and installs new ones. Call this function strategically at event handlers that might influence the mirroring configuration. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: spectrum_span: Generalize SPAN supportPetr Machata1-25/+130
To support mirroring to different device types, the functions that partake in configuring the port analyzer need to be extended to admit non-trivial SPAN types. Create a structure where all details of SPAN configuration are kept, struct mlxsw_sp_span_parms. Also create struct mlxsw_sp_span_entry_ops to keep per-SPAN-type operations. Instantiate the latter once for MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH, and once for a suite of NOP callbacks used for invalidated SPAN entry. Put the formet as a sole member of a new array mlxsw_sp_span_entry_types, where all known SPAN types are kept. Introduce a new function, mlxsw_sp_span_entry_ops(), to look up the right ops suite given a netdevice. Change mlxsw_sp_span_mirror_add() to use both parms and ops structures. Change mlxsw_sp_span_entry_get() and mlxsw_sp_span_entry_create() to take these as arguments. Modify mlxsw_sp_span_entry_configure() and mlxsw_sp_span_entry_deconfigure() to dispatch to ops. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: spectrum: Keep mirror netdev in mlxsw_sp_span_entryPetr Machata1-14/+25
Currently the only mirror action supported by mlxsw is mirror to another mlxsw physical port. Correspondingly, span_entry, which tracks each mlxsw mirror in the system, currently holds a u8 number of the destination port. To extend this system to mirror to gretap and ip6gretap netdevices, have struct mlxsw_sp_span_entry actually hold the destination netdevice itself. This change then trickles down in obvious manner to SPAN module API and mirror-related interfaces in struct mlxsw_afa_ops. To prevent use of invalid pointer, NETDEV_UNREGISTER needs to be hooked and the corresponding SPAN entry invalidated. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: spectrum_span: Extract mlxsw_sp_span_entry_{de, }configure()Petr Machata1-14/+29
Configuring the hardware for encapsulated SPAN involves more code than the simple mirroring case. Extract the related code to a separate function to separate it from the rest of SPAN entry creation. Extract deconfigure as well for symmetry, even though disablement is the same regardless of SPAN type. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: spectrum_span: Initialize span_entry.id eagerlyPetr Machata1-9/+9
It is known statically ahead of time which SPAN entry will have which ID. Just initialize it eagerly in mlxsw_sp_span_init(), don't wait until the entry is actually created. This simplifies some code in mlxsw_sp_span_entry_create() Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: span: Remove span_entry by span_idPetr Machata1-7/+22
Instead of removing span_entry by the port number, allow removing by SPAN id. That simplifies some code right here, and for mirroring to soft netdevices, avoids problems with netdevice pointer invalidation and reuse. Rename mlxsw_sp_span_entry_find() to mlxsw_sp_span_entry_find_by_port() and keep it--follow-up patches will make use of it. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-27mlxsw: reg: Extend mlxsw_reg_mpat_pack()Petr Machata1-2/+4
To support encapsulated SPAN, extend mlxsw_reg_mpat_pack() with a field to set the SPAN type. Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2018-02-13mlxsw: spectrum: Move SPAN code to separate modulePetr Machata1-0/+356
For the upcoming work on SPAN, it makes sense to move the current code to a module of its own. It already has a well-defined API boundary to the mirror management (which is used from matchall and ACL code). A couple more functions need to be exported for the functions that spectrum.c needs to use for MTU handling and subsystem init/fini. Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>