Commit ff0f6383 authored by David S. Miller's avatar David S. Miller

Merge branch 'devlink-Add-support-for-control-packet-traps'

Ido Schimmel says:

====================
devlink: Add support for control packet traps

So far device drivers were only able to register drop and exception
packet traps with devlink. These traps are used for packets that were
either dropped by the underlying device or encountered an exception
(e.g., missing neighbour entry) during forwarding.

However, in the steady state, the majority of the packets being trapped
to the CPU are packets that are required for the correct functioning of
the control plane. For example, ARP request and IGMP query packets.

This patch set allows device drivers to register such control traps with
devlink and expose their default control plane policy to user space.
User space can then tune the packet trap policer settings according to
its needs, as with existing packet traps.

In a similar fashion to exception traps, the action associated with such
traps cannot be changed as it can easily break the control plane. Unlike
drop and exception traps, packets trapped via control traps are not
reported to the kernel's drop monitor as they are not indicative of any
problem.

Patch set overview:

Patches #1-#3 break out layer 3 exceptions to a different group to
provide better granularity. A future patch set will make this completely
configurable.

Patch #4 adds a new trap action ('mirror') that is used for packets that
are forwarded by the device and sent to the CPU. Such packets are marked
by device drivers with 'skb->offload_fwd_mark = 1' in order to prevent
the kernel from forwarding them again.

Patch #5 adds the new trap type, 'control'.

Patches #6-#8 gradually add various control traps to devlink with proper
documentation.

Patch #9 adds a few control traps to netdevsim, which are automatically
exercised by existing devlink-trap selftest.

Patches #10 performs small refactoring in mlxsw.

Patches #11-#13 change mlxsw to register its existing control traps with
devlink.

Patch #14 adds a selftest over mlxsw that exercises all the registered
control traps.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents af0a2482 9959b389
...@@ -55,7 +55,7 @@ The following diagram provides a general overview of ``devlink-trap``:: ...@@ -55,7 +55,7 @@ The following diagram provides a general overview of ``devlink-trap``::
| | | |
+-------^--------+ +-------^--------+
| |
| | Non-control traps
| |
+----+----+ +----+----+
| | Kernel's Rx path | | Kernel's Rx path
...@@ -97,6 +97,12 @@ The ``devlink-trap`` mechanism supports the following packet trap types: ...@@ -97,6 +97,12 @@ The ``devlink-trap`` mechanism supports the following packet trap types:
processed by ``devlink`` and injected to the kernel's Rx path. Changing the processed by ``devlink`` and injected to the kernel's Rx path. Changing the
action of such traps is not allowed, as it can easily break the control action of such traps is not allowed, as it can easily break the control
plane. plane.
* ``control``: Trapped packets were trapped by the device because these are
control packets required for the correct functioning of the control plane.
For example, ARP request and IGMP query packets. Packets are injected to
the kernel's Rx path, but not reported to the kernel's drop monitor.
Changing the action of such traps is not allowed, as it can easily break
the control plane.
.. _Trap-Actions: .. _Trap-Actions:
...@@ -108,6 +114,8 @@ The ``devlink-trap`` mechanism supports the following packet trap actions: ...@@ -108,6 +114,8 @@ The ``devlink-trap`` mechanism supports the following packet trap actions:
* ``trap``: The sole copy of the packet is sent to the CPU. * ``trap``: The sole copy of the packet is sent to the CPU.
* ``drop``: The packet is dropped by the underlying device and a copy is not * ``drop``: The packet is dropped by the underlying device and a copy is not
sent to the CPU. sent to the CPU.
* ``mirror``: The packet is forwarded by the underlying device and a copy is
sent to the CPU.
Generic Packet Traps Generic Packet Traps
==================== ====================
...@@ -244,6 +252,159 @@ be added to the following table: ...@@ -244,6 +252,159 @@ be added to the following table:
* - ``egress_flow_action_drop`` * - ``egress_flow_action_drop``
- ``drop`` - ``drop``
- Traps packets dropped during processing of egress flow action drop - Traps packets dropped during processing of egress flow action drop
* - ``stp``
- ``control``
- Traps STP packets
* - ``lacp``
- ``control``
- Traps LACP packets
* - ``lldp``
- ``control``
- Traps LLDP packets
* - ``igmp_query``
- ``control``
- Traps IGMP Membership Query packets
* - ``igmp_v1_report``
- ``control``
- Traps IGMP Version 1 Membership Report packets
* - ``igmp_v2_report``
- ``control``
- Traps IGMP Version 2 Membership Report packets
* - ``igmp_v3_report``
- ``control``
- Traps IGMP Version 3 Membership Report packets
* - ``igmp_v2_leave``
- ``control``
- Traps IGMP Version 2 Leave Group packets
* - ``mld_query``
- ``control``
- Traps MLD Multicast Listener Query packets
* - ``mld_v1_report``
- ``control``
- Traps MLD Version 1 Multicast Listener Report packets
* - ``mld_v2_report``
- ``control``
- Traps MLD Version 2 Multicast Listener Report packets
* - ``mld_v1_done``
- ``control``
- Traps MLD Version 1 Multicast Listener Done packets
* - ``ipv4_dhcp``
- ``control``
- Traps IPv4 DHCP packets
* - ``ipv6_dhcp``
- ``control``
- Traps IPv6 DHCP packets
* - ``arp_request``
- ``control``
- Traps ARP request packets
* - ``arp_response``
- ``control``
- Traps ARP response packets
* - ``arp_overlay``
- ``control``
- Traps NVE-decapsulated ARP packets that reached the overlay network.
This is required, for example, when the address that needs to be
resolved is a local address
* - ``ipv6_neigh_solicit``
- ``control``
- Traps IPv6 Neighbour Solicitation packets
* - ``ipv6_neigh_advert``
- ``control``
- Traps IPv6 Neighbour Advertisement packets
* - ``ipv4_bfd``
- ``control``
- Traps IPv4 BFD packets
* - ``ipv6_bfd``
- ``control``
- Traps IPv6 BFD packets
* - ``ipv4_ospf``
- ``control``
- Traps IPv4 OSPF packets
* - ``ipv6_ospf``
- ``control``
- Traps IPv6 OSPF packets
* - ``ipv4_bgp``
- ``control``
- Traps IPv4 BGP packets
* - ``ipv6_bgp``
- ``control``
- Traps IPv6 BGP packets
* - ``ipv4_vrrp``
- ``control``
- Traps IPv4 VRRP packets
* - ``ipv6_vrrp``
- ``control``
- Traps IPv6 VRRP packets
* - ``ipv4_pim``
- ``control``
- Traps IPv4 PIM packets
* - ``ipv6_pim``
- ``control``
- Traps IPv6 PIM packets
* - ``uc_loopback``
- ``control``
- Traps unicast packets that need to be routed through the same layer 3
interface from which they were received. Such packets are routed by the
kernel, but also cause it to potentially generate ICMP redirect packets
* - ``local_route``
- ``control``
- Traps unicast packets that hit a local route and need to be locally
delivered
* - ``external_route``
- ``control``
- Traps packets that should be routed through an external interface (e.g.,
management interface) that does not belong to the same device (e.g.,
switch ASIC) as the ingress interface
* - ``ipv6_uc_dip_link_local_scope``
- ``control``
- Traps unicast IPv6 packets that need to be routed and have a destination
IP address with a link-local scope (i.e., fe80::/10). The trap allows
device drivers to avoid programming link-local routes, but still receive
packets for local delivery
* - ``ipv6_dip_all_nodes``
- ``control``
- Traps IPv6 packets that their destination IP address is the "All Nodes
Address" (i.e., ff02::1)
* - ``ipv6_dip_all_routers``
- ``control``
- Traps IPv6 packets that their destination IP address is the "All Routers
Address" (i.e., ff02::2)
* - ``ipv6_router_solicit``
- ``control``
- Traps IPv6 Router Solicitation packets
* - ``ipv6_router_advert``
- ``control``
- Traps IPv6 Router Advertisement packets
* - ``ipv6_redirect``
- ``control``
- Traps IPv6 Redirect Message packets
* - ``ipv4_router_alert``
- ``control``
- Traps IPv4 packets that need to be routed and include the Router Alert
option. Such packets need to be locally delivered to raw sockets that
have the IP_ROUTER_ALERT socket option set
* - ``ipv6_router_alert``
- ``control``
- Traps IPv6 packets that need to be routed and include the Router Alert
option in their Hop-by-Hop extension header. Such packets need to be
locally delivered to raw sockets that have the IPV6_ROUTER_ALERT socket
option set
* - ``ptp_event``
- ``control``
- Traps PTP time-critical event messages (Sync, Delay_req, Pdelay_Req and
Pdelay_Resp)
* - ``ptp_general``
- ``control``
- Traps PTP general messages (Announce, Follow_Up, Delay_Resp,
Pdelay_Resp_Follow_Up, management and signaling)
* - ``flow_action_sample``
- ``control``
- Traps packets sampled during processing of flow action sample (e.g., via
tc's sample action)
* - ``flow_action_trap``
- ``control``
- Traps packets logged during processing of flow action trap (e.g., via
tc's trap action)
Driver-specific Packet Traps Driver-specific Packet Traps
============================ ============================
...@@ -277,8 +438,11 @@ narrow. The description of these groups must be added to the following table: ...@@ -277,8 +438,11 @@ narrow. The description of these groups must be added to the following table:
- Contains packet traps for packets that were dropped by the device during - Contains packet traps for packets that were dropped by the device during
layer 2 forwarding (i.e., bridge) layer 2 forwarding (i.e., bridge)
* - ``l3_drops`` * - ``l3_drops``
- Contains packet traps for packets that were dropped by the device or hit - Contains packet traps for packets that were dropped by the device during
an exception (e.g., TTL error) during layer 3 forwarding layer 3 forwarding
* - ``l3_exceptions``
- Contains packet traps for packets that hit an exception (e.g., TTL
error) during layer 3 forwarding
* - ``buffer_drops`` * - ``buffer_drops``
- Contains packet traps for packets that were dropped by the device due to - Contains packet traps for packets that were dropped by the device due to
an enqueue decision an enqueue decision
...@@ -288,6 +452,55 @@ narrow. The description of these groups must be added to the following table: ...@@ -288,6 +452,55 @@ narrow. The description of these groups must be added to the following table:
* - ``acl_drops`` * - ``acl_drops``
- Contains packet traps for packets that were dropped by the device during - Contains packet traps for packets that were dropped by the device during
ACL processing ACL processing
* - ``stp``
- Contains packet traps for STP packets
* - ``lacp``
- Contains packet traps for LACP packets
* - ``lldp``
- Contains packet traps for LLDP packets
* - ``mc_snooping``
- Contains packet traps for IGMP and MLD packets required for multicast
snooping
* - ``dhcp``
- Contains packet traps for DHCP packets
* - ``neigh_discovery``
- Contains packet traps for neighbour discovery packets (e.g., ARP, IPv6
ND)
* - ``bfd``
- Contains packet traps for BFD packets
* - ``ospf``
- Contains packet traps for OSPF packets
* - ``bgp``
- Contains packet traps for BGP packets
* - ``vrrp``
- Contains packet traps for VRRP packets
* - ``pim``
- Contains packet traps for PIM packets
* - ``uc_loopback``
- Contains a packet trap for unicast loopback packets (i.e.,
``uc_loopback``). This trap is singled-out because in cases such as
one-armed router it will be constantly triggered. To limit the impact on
the CPU usage, a packet trap policer with a low rate can be bound to the
group without affecting other traps
* - ``local_delivery``
- Contains packet traps for packets that should be locally delivered after
routing, but do not match more specific packet traps (e.g.,
``ipv4_bgp``)
* - ``ipv6``
- Contains packet traps for various IPv6 control packets (e.g., Router
Advertisements)
* - ``ptp_event``
- Contains packet traps for PTP time-critical event messages (Sync,
Delay_req, Pdelay_Req and Pdelay_Resp)
* - ``ptp_general``
- Contains packet traps for PTP general messages (Announce, Follow_Up,
Delay_Resp, Pdelay_Resp_Follow_Up, management and signaling)
* - ``acl_sample``
- Contains packet traps for packets that were sampled by the device during
ACL processing
* - ``acl_trap``
- Contains packet traps for packets that were trapped (logged) by the
device during ACL processing
Packet Trap Policers Packet Trap Policers
==================== ====================
......
...@@ -5536,7 +5536,6 @@ enum mlxsw_reg_htgt_trap_group { ...@@ -5536,7 +5536,6 @@ enum mlxsw_reg_htgt_trap_group {
MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST, MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST,
MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY, MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP, MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP,
MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE,
MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME, MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP, MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT, MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT,
...@@ -5552,6 +5551,7 @@ enum mlxsw_reg_htgt_trap_group { ...@@ -5552,6 +5551,7 @@ enum mlxsw_reg_htgt_trap_group {
MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY, MLXSW_REG_HTGT_TRAP_GROUP_SP_DUMMY,
MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS, MLXSW_REG_HTGT_TRAP_GROUP_SP_L2_DISCARDS,
MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS, MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS, MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS, MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
......
...@@ -3987,10 +3987,15 @@ static void mlxsw_sp_rx_listener_l3_mark_func(struct sk_buff *skb, ...@@ -3987,10 +3987,15 @@ static void mlxsw_sp_rx_listener_l3_mark_func(struct sk_buff *skb,
return mlxsw_sp_rx_listener_no_mark_func(skb, local_port, priv); return mlxsw_sp_rx_listener_no_mark_func(skb, local_port, priv);
} }
static void mlxsw_sp_rx_listener_sample_func(struct sk_buff *skb, u8 local_port, void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
void *priv) u8 local_port)
{
mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port);
}
void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
u8 local_port)
{ {
struct mlxsw_sp *mlxsw_sp = priv;
struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port];
struct mlxsw_sp_port_sample *sample; struct mlxsw_sp_port_sample *sample;
u32 size; u32 size;
...@@ -4014,14 +4019,6 @@ static void mlxsw_sp_rx_listener_sample_func(struct sk_buff *skb, u8 local_port, ...@@ -4014,14 +4019,6 @@ static void mlxsw_sp_rx_listener_sample_func(struct sk_buff *skb, u8 local_port,
consume_skb(skb); consume_skb(skb);
} }
static void mlxsw_sp_rx_listener_ptp(struct sk_buff *skb, u8 local_port,
void *priv)
{
struct mlxsw_sp *mlxsw_sp = priv;
mlxsw_sp->ptp_ops->receive(mlxsw_sp, skb, local_port);
}
#define MLXSW_SP_RXL_NO_MARK(_trap_id, _action, _trap_group, _is_ctrl) \ #define MLXSW_SP_RXL_NO_MARK(_trap_id, _action, _trap_group, _is_ctrl) \
MLXSW_RXL(mlxsw_sp_rx_listener_no_mark_func, _trap_id, _action, \ MLXSW_RXL(mlxsw_sp_rx_listener_no_mark_func, _trap_id, _action, \
_is_ctrl, SP_##_trap_group, DISCARD) _is_ctrl, SP_##_trap_group, DISCARD)
...@@ -4041,60 +4038,13 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = { ...@@ -4041,60 +4038,13 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
/* Events */ /* Events */
MLXSW_SP_EVENTL(mlxsw_sp_pude_event_func, PUDE), MLXSW_SP_EVENTL(mlxsw_sp_pude_event_func, PUDE),
/* L2 traps */ /* L2 traps */
MLXSW_SP_RXL_NO_MARK(STP, TRAP_TO_CPU, STP, true),
MLXSW_SP_RXL_NO_MARK(LACP, TRAP_TO_CPU, LACP, true),
MLXSW_RXL(mlxsw_sp_rx_listener_ptp, LLDP, TRAP_TO_CPU,
false, SP_LLDP, DISCARD),
MLXSW_SP_RXL_MARK(IGMP_QUERY, MIRROR_TO_CPU, MC_SNOOPING, false),
MLXSW_SP_RXL_NO_MARK(IGMP_V1_REPORT, TRAP_TO_CPU, MC_SNOOPING, false),
MLXSW_SP_RXL_NO_MARK(IGMP_V2_REPORT, TRAP_TO_CPU, MC_SNOOPING, false),
MLXSW_SP_RXL_NO_MARK(IGMP_V2_LEAVE, TRAP_TO_CPU, MC_SNOOPING, false),
MLXSW_SP_RXL_NO_MARK(IGMP_V3_REPORT, TRAP_TO_CPU, MC_SNOOPING, false),
MLXSW_SP_RXL_MARK(ARPBC, MIRROR_TO_CPU, NEIGH_DISCOVERY, false),
MLXSW_SP_RXL_MARK(ARPUC, MIRROR_TO_CPU, NEIGH_DISCOVERY, false),
MLXSW_SP_RXL_NO_MARK(FID_MISS, TRAP_TO_CPU, FID_MISS, false), MLXSW_SP_RXL_NO_MARK(FID_MISS, TRAP_TO_CPU, FID_MISS, false),
MLXSW_SP_RXL_MARK(IPV6_MLDV12_LISTENER_QUERY, MIRROR_TO_CPU,
MC_SNOOPING, false),
MLXSW_SP_RXL_NO_MARK(IPV6_MLDV1_LISTENER_REPORT, TRAP_TO_CPU,
MC_SNOOPING, false),
MLXSW_SP_RXL_NO_MARK(IPV6_MLDV1_LISTENER_DONE, TRAP_TO_CPU, MC_SNOOPING,
false),
MLXSW_SP_RXL_NO_MARK(IPV6_MLDV2_LISTENER_REPORT, TRAP_TO_CPU,
MC_SNOOPING, false),
/* L3 traps */ /* L3 traps */
MLXSW_SP_RXL_L3_MARK(LBERROR, MIRROR_TO_CPU, LBERROR, false),
MLXSW_SP_RXL_MARK(IP2ME, TRAP_TO_CPU, IP2ME, false),
MLXSW_SP_RXL_MARK(IPV6_UNSPECIFIED_ADDRESS, TRAP_TO_CPU, ROUTER_EXP, MLXSW_SP_RXL_MARK(IPV6_UNSPECIFIED_ADDRESS, TRAP_TO_CPU, ROUTER_EXP,
false), false),
MLXSW_SP_RXL_MARK(IPV6_LINK_LOCAL_DEST, TRAP_TO_CPU, IP2ME, false),
MLXSW_SP_RXL_MARK(IPV6_LINK_LOCAL_SRC, TRAP_TO_CPU, ROUTER_EXP, false), MLXSW_SP_RXL_MARK(IPV6_LINK_LOCAL_SRC, TRAP_TO_CPU, ROUTER_EXP, false),
MLXSW_SP_RXL_MARK(IPV6_ALL_NODES_LINK, TRAP_TO_CPU, IPV6, false),
MLXSW_SP_RXL_MARK(IPV6_ALL_ROUTERS_LINK, TRAP_TO_CPU, IPV6,
false),
MLXSW_SP_RXL_MARK(IPV4_OSPF, TRAP_TO_CPU, OSPF, false),
MLXSW_SP_RXL_MARK(IPV6_OSPF, TRAP_TO_CPU, OSPF, false),
MLXSW_SP_RXL_MARK(IPV4_DHCP, TRAP_TO_CPU, DHCP, false),
MLXSW_SP_RXL_MARK(IPV6_DHCP, TRAP_TO_CPU, DHCP, false),
MLXSW_SP_RXL_MARK(RTR_INGRESS0, TRAP_TO_CPU, REMOTE_ROUTE, false),
MLXSW_SP_RXL_MARK(IPV4_BGP, TRAP_TO_CPU, BGP, false),
MLXSW_SP_RXL_MARK(IPV6_BGP, TRAP_TO_CPU, BGP, false),
MLXSW_SP_RXL_MARK(L3_IPV6_ROUTER_SOLICITATION, TRAP_TO_CPU, IPV6,
false),
MLXSW_SP_RXL_MARK(L3_IPV6_ROUTER_ADVERTISEMENT, TRAP_TO_CPU, IPV6,
false),
MLXSW_SP_RXL_MARK(L3_IPV6_NEIGHBOR_SOLICITATION, TRAP_TO_CPU,
NEIGH_DISCOVERY, false),
MLXSW_SP_RXL_MARK(L3_IPV6_NEIGHBOR_ADVERTISEMENT, TRAP_TO_CPU,
NEIGH_DISCOVERY, false),
MLXSW_SP_RXL_MARK(L3_IPV6_REDIRECTION, TRAP_TO_CPU, IPV6, false),
MLXSW_SP_RXL_MARK(IPV6_MC_LINK_LOCAL_DEST, TRAP_TO_CPU, ROUTER_EXP, MLXSW_SP_RXL_MARK(IPV6_MC_LINK_LOCAL_DEST, TRAP_TO_CPU, ROUTER_EXP,
false), false),
MLXSW_SP_RXL_MARK(ROUTER_ALERT_IPV4, TRAP_TO_CPU, IP2ME, false),
MLXSW_SP_RXL_MARK(ROUTER_ALERT_IPV6, TRAP_TO_CPU, IP2ME, false),
MLXSW_SP_RXL_MARK(IPV4_VRRP, TRAP_TO_CPU, VRRP, false),
MLXSW_SP_RXL_MARK(IPV6_VRRP, TRAP_TO_CPU, VRRP, false),
MLXSW_SP_RXL_MARK(IPV4_BFD, TRAP_TO_CPU, BFD, false),
MLXSW_SP_RXL_MARK(IPV6_BFD, TRAP_TO_CPU, BFD, false),
MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_CLASS_E, FORWARD, MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_SIP_CLASS_E, FORWARD,
ROUTER_EXP, false), ROUTER_EXP, false),
MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_MC_DMAC, FORWARD, MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_MC_DMAC, FORWARD,
...@@ -4103,24 +4053,11 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = { ...@@ -4103,24 +4053,11 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
ROUTER_EXP, false), ROUTER_EXP, false),
MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_DIP_LINK_LOCAL, FORWARD, MLXSW_SP_RXL_NO_MARK(DISCARD_ING_ROUTER_DIP_LINK_LOCAL, FORWARD,
ROUTER_EXP, false), ROUTER_EXP, false),
/* PKT Sample trap */
MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU,
false, SP_PKT_SAMPLE, DISCARD),
/* ACL trap */
MLXSW_SP_RXL_NO_MARK(ACL0, TRAP_TO_CPU, FLOW_LOGGING, false),
/* Multicast Router Traps */ /* Multicast Router Traps */
MLXSW_SP_RXL_MARK(IPV4_PIM, TRAP_TO_CPU, PIM, false),
MLXSW_SP_RXL_MARK(IPV6_PIM, TRAP_TO_CPU, PIM, false),
MLXSW_SP_RXL_MARK(ACL1, TRAP_TO_CPU, MULTICAST, false), MLXSW_SP_RXL_MARK(ACL1, TRAP_TO_CPU, MULTICAST, false),
MLXSW_SP_RXL_L3_MARK(ACL2, TRAP_TO_CPU, MULTICAST, false), MLXSW_SP_RXL_L3_MARK(ACL2, TRAP_TO_CPU, MULTICAST, false),
/* NVE traps */ /* NVE traps */
MLXSW_SP_RXL_MARK(NVE_ENCAP_ARP, TRAP_TO_CPU, NEIGH_DISCOVERY, false), MLXSW_SP_RXL_MARK(NVE_ENCAP_ARP, TRAP_TO_CPU, NEIGH_DISCOVERY, false),
MLXSW_SP_RXL_NO_MARK(NVE_DECAP_ARP, TRAP_TO_CPU, NEIGH_DISCOVERY,
false),
/* PTP traps */
MLXSW_RXL(mlxsw_sp_rx_listener_ptp, PTP0, TRAP_TO_CPU,
false, SP_PTP0, DISCARD),
MLXSW_SP_RXL_NO_MARK(PTP1, TRAP_TO_CPU, PTP1, false),
}; };
static const struct mlxsw_listener mlxsw_sp1_listener[] = { static const struct mlxsw_listener mlxsw_sp1_listener[] = {
...@@ -4149,48 +4086,12 @@ static int mlxsw_sp_cpu_policers_set(struct mlxsw_core *mlxsw_core) ...@@ -4149,48 +4086,12 @@ static int mlxsw_sp_cpu_policers_set(struct mlxsw_core *mlxsw_core)
for (i = 0; i < max_cpu_policers; i++) { for (i = 0; i < max_cpu_policers; i++) {
is_bytes = false; is_bytes = false;
switch (i) { switch (i) {
case MLXSW_REG_HTGT_TRAP_GROUP_SP_STP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP:
rate = 128;
burst_size = 7;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING:
rate = 16 * 1024;
burst_size = 10;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP: case MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST: case MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS: case MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS:
rate = 1024; rate = 1024;
burst_size = 7; burst_size = 7;
break; break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0:
rate = 24 * 1024;
burst_size = 12;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1:
rate = 19 * 1024;
burst_size = 12;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP:
rate = 360;
burst_size = 7;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD:
rate = 20 * 1024;
burst_size = 10;
break;
default: default:
continue; continue;
} }
...@@ -4225,46 +4126,12 @@ static int mlxsw_sp_trap_groups_set(struct mlxsw_core *mlxsw_core) ...@@ -4225,46 +4126,12 @@ static int mlxsw_sp_trap_groups_set(struct mlxsw_core *mlxsw_core)
for (i = 0; i < max_trap_groups; i++) { for (i = 0; i < max_trap_groups; i++) {
policer_id = i; policer_id = i;
switch (i) { switch (i) {
case MLXSW_REG_HTGT_TRAP_GROUP_SP_STP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD:
priority = 5;
tc = 5;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP:
priority = 4;
tc = 4;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING:
priority = 3;
tc = 3;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP:
priority = 2;
tc = 2;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP: case MLXSW_REG_HTGT_TRAP_GROUP_SP_ROUTER_EXP:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_REMOTE_ROUTE:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST: case MLXSW_REG_HTGT_TRAP_GROUP_SP_MULTICAST:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS: case MLXSW_REG_HTGT_TRAP_GROUP_SP_FID_MISS:
priority = 1; priority = 1;
tc = 1; tc = 1;
break; break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE:
case MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR:
priority = 0;
tc = 0;
break;
case MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT: case MLXSW_REG_HTGT_TRAP_GROUP_SP_EVENT:
priority = MLXSW_REG_HTGT_DEFAULT_PRIORITY; priority = MLXSW_REG_HTGT_DEFAULT_PRIORITY;
tc = MLXSW_REG_HTGT_DEFAULT_TC; tc = MLXSW_REG_HTGT_DEFAULT_TC;
......
...@@ -451,6 +451,10 @@ extern struct notifier_block mlxsw_sp_switchdev_notifier; ...@@ -451,6 +451,10 @@ extern struct notifier_block mlxsw_sp_switchdev_notifier;
/* spectrum.c */ /* spectrum.c */
void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb, void mlxsw_sp_rx_listener_no_mark_func(struct sk_buff *skb,
u8 local_port, void *priv); u8 local_port, void *priv);
void mlxsw_sp_ptp_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
u8 local_port);
void mlxsw_sp_sample_receive(struct mlxsw_sp *mlxsw_sp, struct sk_buff *skb,
u8 local_port);
int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed); int mlxsw_sp_port_speed_get(struct mlxsw_sp_port *mlxsw_sp_port, u32 *speed);
int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port, int mlxsw_sp_port_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index, enum mlxsw_reg_qeec_hr hr, u8 index, u8 next_index,
......
...@@ -125,8 +125,8 @@ static void mlxsw_sp_rx_acl_drop_listener(struct sk_buff *skb, u8 local_port, ...@@ -125,8 +125,8 @@ static void mlxsw_sp_rx_acl_drop_listener(struct sk_buff *skb, u8 local_port,
consume_skb(skb); consume_skb(skb);
} }
static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, static int __mlxsw_sp_rx_no_mark_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx) void *trap_ctx)
{ {
struct devlink_port *in_devlink_port; struct devlink_port *in_devlink_port;
struct mlxsw_sp_port *mlxsw_sp_port; struct mlxsw_sp_port *mlxsw_sp_port;
...@@ -139,7 +139,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -139,7 +139,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
err = mlxsw_sp_rx_listener(mlxsw_sp, skb, local_port, mlxsw_sp_port); err = mlxsw_sp_rx_listener(mlxsw_sp, skb, local_port, mlxsw_sp_port);
if (err) if (err)
return; return err;
devlink = priv_to_devlink(mlxsw_sp->core); devlink = priv_to_devlink(mlxsw_sp->core);
in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core, in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core,
...@@ -147,10 +147,71 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -147,10 +147,71 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
skb_push(skb, ETH_HLEN); skb_push(skb, ETH_HLEN);
devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port, NULL); devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port, NULL);
skb_pull(skb, ETH_HLEN); skb_pull(skb, ETH_HLEN);
skb->offload_fwd_mark = 1;
return 0;
}
static void mlxsw_sp_rx_no_mark_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
int err;
err = __mlxsw_sp_rx_no_mark_listener(skb, local_port, trap_ctx);
if (err)
return;
netif_receive_skb(skb); netif_receive_skb(skb);
} }
static void mlxsw_sp_rx_mark_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
skb->offload_fwd_mark = 1;
mlxsw_sp_rx_no_mark_listener(skb, local_port, trap_ctx);
}
static void mlxsw_sp_rx_l3_mark_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
skb->offload_l3_fwd_mark = 1;
skb->offload_fwd_mark = 1;
mlxsw_sp_rx_no_mark_listener(skb, local_port, trap_ctx);
}
static void mlxsw_sp_rx_ptp_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
struct mlxsw_sp *mlxsw_sp = devlink_trap_ctx_priv(trap_ctx);
int err;
err = __mlxsw_sp_rx_no_mark_listener(skb, local_port, trap_ctx);
if (err)
return;
/* The PTP handler expects skb->data to point to the start of the
* Ethernet header.
*/
skb_push(skb, ETH_HLEN);
mlxsw_sp_ptp_receive(mlxsw_sp, skb, local_port);
}
static void mlxsw_sp_rx_sample_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
struct mlxsw_sp *mlxsw_sp = devlink_trap_ctx_priv(trap_ctx);
int err;
err = __mlxsw_sp_rx_no_mark_listener(skb, local_port, trap_ctx);
if (err)
return;
/* The sample handler expects skb->data to point to the start of the
* Ethernet header.
*/
skb_push(skb, ETH_HLEN);
mlxsw_sp_sample_receive(mlxsw_sp, skb, local_port);
}
#define MLXSW_SP_TRAP_DROP(_id, _group_id) \ #define MLXSW_SP_TRAP_DROP(_id, _group_id) \
DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \ DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \ DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
...@@ -172,6 +233,11 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -172,6 +233,11 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \ DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
MLXSW_SP_TRAP_METADATA) MLXSW_SP_TRAP_METADATA)
#define MLXSW_SP_TRAP_CONTROL(_id, _group_id, _action) \
DEVLINK_TRAP_GENERIC(CONTROL, _action, _id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
MLXSW_SP_TRAP_METADATA)
#define MLXSW_SP_RXL_DISCARD(_id, _group_id) \ #define MLXSW_SP_RXL_DISCARD(_id, _group_id) \
MLXSW_RXL_DIS(mlxsw_sp_rx_drop_listener, DISCARD_##_id, \ MLXSW_RXL_DIS(mlxsw_sp_rx_drop_listener, DISCARD_##_id, \
TRAP_EXCEPTION_TO_CPU, false, SP_##_group_id, \ TRAP_EXCEPTION_TO_CPU, false, SP_##_group_id, \
...@@ -183,9 +249,21 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -183,9 +249,21 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
SET_FW_DEFAULT, SP_##_dis_group_id) SET_FW_DEFAULT, SP_##_dis_group_id)
#define MLXSW_SP_RXL_EXCEPTION(_id, _group_id, _action) \ #define MLXSW_SP_RXL_EXCEPTION(_id, _group_id, _action) \
MLXSW_RXL(mlxsw_sp_rx_exception_listener, _id, \ MLXSW_RXL(mlxsw_sp_rx_mark_listener, _id, \
_action, false, SP_##_group_id, SET_FW_DEFAULT) _action, false, SP_##_group_id, SET_FW_DEFAULT)
#define MLXSW_SP_RXL_NO_MARK(_id, _group_id, _action, _is_ctrl) \
MLXSW_RXL(mlxsw_sp_rx_no_mark_listener, _id, _action, \
_is_ctrl, SP_##_group_id, DISCARD)
#define MLXSW_SP_RXL_MARK(_id, _group_id, _action, _is_ctrl) \
MLXSW_RXL(mlxsw_sp_rx_mark_listener, _id, _action, _is_ctrl, \
SP_##_group_id, DISCARD)
#define MLXSW_SP_RXL_L3_MARK(_id, _group_id, _action, _is_ctrl) \
MLXSW_RXL(mlxsw_sp_rx_l3_mark_listener, _id, _action, _is_ctrl, \
SP_##_group_id, DISCARD)
#define MLXSW_SP_TRAP_POLICER(_id, _rate, _burst) \ #define MLXSW_SP_TRAP_POLICER(_id, _rate, _burst) \
DEVLINK_TRAP_POLICER(_id, _rate, _burst, \ DEVLINK_TRAP_POLICER(_id, _rate, _burst, \
MLXSW_REG_QPCR_HIGHEST_CIR, \ MLXSW_REG_QPCR_HIGHEST_CIR, \
...@@ -199,6 +277,57 @@ mlxsw_sp_trap_policer_items_arr[] = { ...@@ -199,6 +277,57 @@ mlxsw_sp_trap_policer_items_arr[] = {
{ {
.policer = MLXSW_SP_TRAP_POLICER(1, 10 * 1024, 128), .policer = MLXSW_SP_TRAP_POLICER(1, 10 * 1024, 128),
}, },
{
.policer = MLXSW_SP_TRAP_POLICER(2, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(3, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(4, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(5, 16 * 1024, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(6, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(7, 1024, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(8, 20 * 1024, 1024),
},
{
.policer = MLXSW_SP_TRAP_POLICER(9, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(10, 1024, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(11, 360, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(12, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(13, 128, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(14, 1024, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(15, 1024, 128),
},
{
.policer = MLXSW_SP_TRAP_POLICER(16, 24 * 1024, 4096),
},
{
.policer = MLXSW_SP_TRAP_POLICER(17, 19 * 1024, 4096),
},
{
.policer = MLXSW_SP_TRAP_POLICER(18, 1024, 128),
},
}; };
static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = { static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = {
...@@ -212,6 +341,11 @@ static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = { ...@@ -212,6 +341,11 @@ static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = {
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS, .hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_DISCARDS,
.priority = 0, .priority = 0,
}, },
{
.group = DEVLINK_TRAP_GROUP_GENERIC(L3_EXCEPTIONS, 1),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_L3_EXCEPTIONS,
.priority = 2,
},
{ {
.group = DEVLINK_TRAP_GROUP_GENERIC(TUNNEL_DROPS, 1), .group = DEVLINK_TRAP_GROUP_GENERIC(TUNNEL_DROPS, 1),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS, .hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_TUNNEL_DISCARDS,
...@@ -222,6 +356,96 @@ static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = { ...@@ -222,6 +356,96 @@ static const struct mlxsw_sp_trap_group_item mlxsw_sp_trap_group_items_arr[] = {
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS, .hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_ACL_DISCARDS,
.priority = 0, .priority = 0,
}, },
{
.group = DEVLINK_TRAP_GROUP_GENERIC(STP, 2),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_STP,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(LACP, 3),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_LACP,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(LLDP, 4),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_LLDP,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(MC_SNOOPING, 5),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_MC_SNOOPING,
.priority = 3,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(DHCP, 6),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_DHCP,
.priority = 2,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(NEIGH_DISCOVERY, 7),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_NEIGH_DISCOVERY,
.priority = 2,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(BFD, 8),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_BFD,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(OSPF, 9),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_OSPF,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(BGP, 10),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_BGP,
.priority = 4,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(VRRP, 11),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_VRRP,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(PIM, 12),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_PIM,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(UC_LB, 13),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_LBERROR,
.priority = 0,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(LOCAL_DELIVERY, 14),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_IP2ME,
.priority = 2,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(IPV6, 15),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_IPV6,
.priority = 2,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(PTP_EVENT, 16),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP0,
.priority = 5,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(PTP_GENERAL, 17),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_PTP1,
.priority = 2,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(ACL_SAMPLE, 0),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_PKT_SAMPLE,
.priority = 0,
},
{
.group = DEVLINK_TRAP_GROUP_GENERIC(ACL_TRAP, 18),
.hw_group_id = MLXSW_REG_HTGT_TRAP_GROUP_SP_FLOW_LOGGING,
.priority = 4,
},
}; };
static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = { static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = {
...@@ -332,56 +556,59 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = { ...@@ -332,56 +556,59 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = {
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(MTU_ERROR, L3_DROPS), .trap = MLXSW_SP_TRAP_EXCEPTION(MTU_ERROR, L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(MTUERROR, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(MTUERROR, L3_EXCEPTIONS,
TRAP_TO_CPU), TRAP_TO_CPU),
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(TTL_ERROR, L3_DROPS), .trap = MLXSW_SP_TRAP_EXCEPTION(TTL_ERROR, L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(TTLERROR, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(TTLERROR, L3_EXCEPTIONS,
TRAP_TO_CPU), TRAP_TO_CPU),
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(RPF, L3_DROPS), .trap = MLXSW_SP_TRAP_EXCEPTION(RPF, L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(RPF, L3_DISCARDS, TRAP_TO_CPU), MLXSW_SP_RXL_EXCEPTION(RPF, L3_EXCEPTIONS, TRAP_TO_CPU),
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(REJECT_ROUTE, L3_DROPS), .trap = MLXSW_SP_TRAP_EXCEPTION(REJECT_ROUTE, L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(RTR_INGRESS1, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(RTR_INGRESS1, L3_EXCEPTIONS,
TRAP_TO_CPU), TRAP_TO_CPU),
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(UNRESOLVED_NEIGH, L3_DROPS), .trap = MLXSW_SP_TRAP_EXCEPTION(UNRESOLVED_NEIGH,
L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(HOST_MISS_IPV4, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(HOST_MISS_IPV4, L3_EXCEPTIONS,
TRAP_TO_CPU), TRAP_TO_CPU),
MLXSW_SP_RXL_EXCEPTION(HOST_MISS_IPV6, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(HOST_MISS_IPV6, L3_EXCEPTIONS,
TRAP_TO_CPU), TRAP_TO_CPU),
MLXSW_SP_RXL_EXCEPTION(DISCARD_ROUTER3, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(DISCARD_ROUTER3, L3_EXCEPTIONS,
TRAP_EXCEPTION_TO_CPU), TRAP_EXCEPTION_TO_CPU),
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(IPV4_LPM_UNICAST_MISS, .trap = MLXSW_SP_TRAP_EXCEPTION(IPV4_LPM_UNICAST_MISS,
L3_DROPS), L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(DISCARD_ROUTER_LPM4, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(DISCARD_ROUTER_LPM4,
L3_EXCEPTIONS,
TRAP_EXCEPTION_TO_CPU), TRAP_EXCEPTION_TO_CPU),
}, },
}, },
{ {
.trap = MLXSW_SP_TRAP_EXCEPTION(IPV6_LPM_UNICAST_MISS, .trap = MLXSW_SP_TRAP_EXCEPTION(IPV6_LPM_UNICAST_MISS,
L3_DROPS), L3_EXCEPTIONS),
.listeners_arr = { .listeners_arr = {
MLXSW_SP_RXL_EXCEPTION(DISCARD_ROUTER_LPM6, L3_DISCARDS, MLXSW_SP_RXL_EXCEPTION(DISCARD_ROUTER_LPM6,
L3_EXCEPTIONS,
TRAP_EXCEPTION_TO_CPU), TRAP_EXCEPTION_TO_CPU),
}, },
}, },
...@@ -439,6 +666,320 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = { ...@@ -439,6 +666,320 @@ static const struct mlxsw_sp_trap_item mlxsw_sp_trap_items_arr[] = {
DUMMY), DUMMY),
}, },
}, },
{
.trap = MLXSW_SP_TRAP_CONTROL(STP, STP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(STP, STP, TRAP_TO_CPU, true),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(LACP, LACP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(LACP, LACP, TRAP_TO_CPU, true),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(LLDP, LLDP, TRAP),
.listeners_arr = {
MLXSW_RXL(mlxsw_sp_rx_ptp_listener, LLDP, TRAP_TO_CPU,
false, SP_LLDP, DISCARD),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IGMP_QUERY, MC_SNOOPING, MIRROR),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IGMP_QUERY, MC_SNOOPING,
MIRROR_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IGMP_V1_REPORT, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IGMP_V1_REPORT, MC_SNOOPING,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IGMP_V2_REPORT, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IGMP_V2_REPORT, MC_SNOOPING,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IGMP_V3_REPORT, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IGMP_V3_REPORT, MC_SNOOPING,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IGMP_V2_LEAVE, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IGMP_V2_LEAVE, MC_SNOOPING,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(MLD_QUERY, MC_SNOOPING, MIRROR),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_MLDV12_LISTENER_QUERY,
MC_SNOOPING, MIRROR_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(MLD_V1_REPORT, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IPV6_MLDV1_LISTENER_REPORT,
MC_SNOOPING, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(MLD_V2_REPORT, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IPV6_MLDV2_LISTENER_REPORT,
MC_SNOOPING, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(MLD_V1_DONE, MC_SNOOPING,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(IPV6_MLDV1_LISTENER_DONE,
MC_SNOOPING, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_DHCP, DHCP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV4_DHCP, DHCP, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_DHCP, DHCP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_DHCP, DHCP, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(ARP_REQUEST, NEIGH_DISCOVERY,
MIRROR),
.listeners_arr = {
MLXSW_SP_RXL_MARK(ARPBC, NEIGH_DISCOVERY, MIRROR_TO_CPU,
false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(ARP_RESPONSE, NEIGH_DISCOVERY,
MIRROR),
.listeners_arr = {
MLXSW_SP_RXL_MARK(ARPUC, NEIGH_DISCOVERY, MIRROR_TO_CPU,
false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(ARP_OVERLAY, NEIGH_DISCOVERY,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(NVE_DECAP_ARP, NEIGH_DISCOVERY,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_NEIGH_SOLICIT,
NEIGH_DISCOVERY, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(L3_IPV6_NEIGHBOR_SOLICITATION,
NEIGH_DISCOVERY, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_NEIGH_ADVERT,
NEIGH_DISCOVERY, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(L3_IPV6_NEIGHBOR_ADVERTISEMENT,
NEIGH_DISCOVERY, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_BFD, BFD, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV4_BFD, BFD, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_BFD, BFD, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_BFD, BFD, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_OSPF, OSPF, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV4_OSPF, OSPF, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_OSPF, OSPF, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_OSPF, OSPF, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_BGP, BGP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV4_BGP, BGP, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_BGP, BGP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_BGP, BGP, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_VRRP, VRRP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV4_VRRP, VRRP, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_VRRP, VRRP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_VRRP, VRRP, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_PIM, PIM, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV4_PIM, PIM, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_PIM, PIM, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_PIM, PIM, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(UC_LB, UC_LB, MIRROR),
.listeners_arr = {
MLXSW_SP_RXL_L3_MARK(LBERROR, LBERROR, MIRROR_TO_CPU,
false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(LOCAL_ROUTE, LOCAL_DELIVERY,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IP2ME, IP2ME, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(EXTERNAL_ROUTE, LOCAL_DELIVERY,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(RTR_INGRESS0, IP2ME, TRAP_TO_CPU,
false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_UC_DIP_LINK_LOCAL_SCOPE,
LOCAL_DELIVERY, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_LINK_LOCAL_DEST, IP2ME,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV4_ROUTER_ALERT, LOCAL_DELIVERY,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(ROUTER_ALERT_IPV4, IP2ME, TRAP_TO_CPU,
false),
},
},
{
/* IPV6_ROUTER_ALERT is defined in uAPI as 22, but it is not
* used in this file, so undefine it.
*/
#undef IPV6_ROUTER_ALERT
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_ROUTER_ALERT, LOCAL_DELIVERY,
TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(ROUTER_ALERT_IPV6, IP2ME, TRAP_TO_CPU,
false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_DIP_ALL_NODES, IPV6, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_ALL_NODES_LINK, IPV6,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_DIP_ALL_ROUTERS, IPV6, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(IPV6_ALL_ROUTERS_LINK, IPV6,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_ROUTER_SOLICIT, IPV6, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(L3_IPV6_ROUTER_SOLICITATION, IPV6,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_ROUTER_ADVERT, IPV6, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(L3_IPV6_ROUTER_ADVERTISEMENT, IPV6,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(IPV6_REDIRECT, IPV6, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_MARK(L3_IPV6_REDIRECTION, IPV6,
TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(PTP_EVENT, PTP_EVENT, TRAP),
.listeners_arr = {
MLXSW_RXL(mlxsw_sp_rx_ptp_listener, PTP0, TRAP_TO_CPU,
false, SP_PTP0, DISCARD),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(PTP_GENERAL, PTP_GENERAL, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(PTP1, PTP1, TRAP_TO_CPU, false),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(FLOW_ACTION_SAMPLE, ACL_SAMPLE,
MIRROR),
.listeners_arr = {
MLXSW_RXL(mlxsw_sp_rx_sample_listener, PKT_SAMPLE,
MIRROR_TO_CPU, false, SP_PKT_SAMPLE, DISCARD),
},
},
{
.trap = MLXSW_SP_TRAP_CONTROL(FLOW_ACTION_TRAP, ACL_TRAP, TRAP),
.listeners_arr = {
MLXSW_SP_RXL_NO_MARK(ACL0, FLOW_LOGGING, TRAP_TO_CPU,
false),
},
},
}; };
static struct mlxsw_sp_trap_policer_item * static struct mlxsw_sp_trap_policer_item *
......
...@@ -431,6 +431,10 @@ enum { ...@@ -431,6 +431,10 @@ enum {
DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id, \ DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \ DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
NSIM_TRAP_METADATA) NSIM_TRAP_METADATA)
#define NSIM_TRAP_CONTROL(_id, _group_id, _action) \
DEVLINK_TRAP_GENERIC(CONTROL, _action, _id, \
DEVLINK_TRAP_GROUP_GENERIC_ID_##_group_id, \
NSIM_TRAP_METADATA)
#define NSIM_TRAP_DRIVER_EXCEPTION(_id, _group_id) \ #define NSIM_TRAP_DRIVER_EXCEPTION(_id, _group_id) \
DEVLINK_TRAP_DRIVER(EXCEPTION, TRAP, NSIM_TRAP_ID_##_id, \ DEVLINK_TRAP_DRIVER(EXCEPTION, TRAP, NSIM_TRAP_ID_##_id, \
NSIM_TRAP_NAME_##_id, \ NSIM_TRAP_NAME_##_id, \
...@@ -458,8 +462,10 @@ static const struct devlink_trap_policer nsim_trap_policers_arr[] = { ...@@ -458,8 +462,10 @@ static const struct devlink_trap_policer nsim_trap_policers_arr[] = {
static const struct devlink_trap_group nsim_trap_groups_arr[] = { static const struct devlink_trap_group nsim_trap_groups_arr[] = {
DEVLINK_TRAP_GROUP_GENERIC(L2_DROPS, 0), DEVLINK_TRAP_GROUP_GENERIC(L2_DROPS, 0),
DEVLINK_TRAP_GROUP_GENERIC(L3_DROPS, 1), DEVLINK_TRAP_GROUP_GENERIC(L3_DROPS, 1),
DEVLINK_TRAP_GROUP_GENERIC(L3_EXCEPTIONS, 1),
DEVLINK_TRAP_GROUP_GENERIC(BUFFER_DROPS, 2), DEVLINK_TRAP_GROUP_GENERIC(BUFFER_DROPS, 2),
DEVLINK_TRAP_GROUP_GENERIC(ACL_DROPS, 3), DEVLINK_TRAP_GROUP_GENERIC(ACL_DROPS, 3),
DEVLINK_TRAP_GROUP_GENERIC(MC_SNOOPING, 3),
}; };
static const struct devlink_trap nsim_traps_arr[] = { static const struct devlink_trap nsim_traps_arr[] = {
...@@ -471,12 +477,14 @@ static const struct devlink_trap nsim_traps_arr[] = { ...@@ -471,12 +477,14 @@ static const struct devlink_trap nsim_traps_arr[] = {
NSIM_TRAP_DROP(PORT_LOOPBACK_FILTER, L2_DROPS), NSIM_TRAP_DROP(PORT_LOOPBACK_FILTER, L2_DROPS),
NSIM_TRAP_DRIVER_EXCEPTION(FID_MISS, L2_DROPS), NSIM_TRAP_DRIVER_EXCEPTION(FID_MISS, L2_DROPS),
NSIM_TRAP_DROP(BLACKHOLE_ROUTE, L3_DROPS), NSIM_TRAP_DROP(BLACKHOLE_ROUTE, L3_DROPS),
NSIM_TRAP_EXCEPTION(TTL_ERROR, L3_DROPS), NSIM_TRAP_EXCEPTION(TTL_ERROR, L3_EXCEPTIONS),
NSIM_TRAP_DROP(TAIL_DROP, BUFFER_DROPS), NSIM_TRAP_DROP(TAIL_DROP, BUFFER_DROPS),
NSIM_TRAP_DROP_EXT(INGRESS_FLOW_ACTION_DROP, ACL_DROPS, NSIM_TRAP_DROP_EXT(INGRESS_FLOW_ACTION_DROP, ACL_DROPS,
DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE), DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
NSIM_TRAP_DROP_EXT(EGRESS_FLOW_ACTION_DROP, ACL_DROPS, NSIM_TRAP_DROP_EXT(EGRESS_FLOW_ACTION_DROP, ACL_DROPS,
DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE), DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
NSIM_TRAP_CONTROL(IGMP_QUERY, MC_SNOOPING, MIRROR),
NSIM_TRAP_CONTROL(IGMP_V1_REPORT, MC_SNOOPING, TRAP),
}; };
#define NSIM_TRAP_L4_DATA_LEN 100 #define NSIM_TRAP_L4_DATA_LEN 100
......
...@@ -645,6 +645,50 @@ enum devlink_trap_generic_id { ...@@ -645,6 +645,50 @@ enum devlink_trap_generic_id {
DEVLINK_TRAP_GENERIC_ID_OVERLAY_SMAC_MC, DEVLINK_TRAP_GENERIC_ID_OVERLAY_SMAC_MC,
DEVLINK_TRAP_GENERIC_ID_INGRESS_FLOW_ACTION_DROP, DEVLINK_TRAP_GENERIC_ID_INGRESS_FLOW_ACTION_DROP,
DEVLINK_TRAP_GENERIC_ID_EGRESS_FLOW_ACTION_DROP, DEVLINK_TRAP_GENERIC_ID_EGRESS_FLOW_ACTION_DROP,
DEVLINK_TRAP_GENERIC_ID_STP,
DEVLINK_TRAP_GENERIC_ID_LACP,
DEVLINK_TRAP_GENERIC_ID_LLDP,
DEVLINK_TRAP_GENERIC_ID_IGMP_QUERY,
DEVLINK_TRAP_GENERIC_ID_IGMP_V1_REPORT,
DEVLINK_TRAP_GENERIC_ID_IGMP_V2_REPORT,
DEVLINK_TRAP_GENERIC_ID_IGMP_V3_REPORT,
DEVLINK_TRAP_GENERIC_ID_IGMP_V2_LEAVE,
DEVLINK_TRAP_GENERIC_ID_MLD_QUERY,
DEVLINK_TRAP_GENERIC_ID_MLD_V1_REPORT,
DEVLINK_TRAP_GENERIC_ID_MLD_V2_REPORT,
DEVLINK_TRAP_GENERIC_ID_MLD_V1_DONE,
DEVLINK_TRAP_GENERIC_ID_IPV4_DHCP,
DEVLINK_TRAP_GENERIC_ID_IPV6_DHCP,
DEVLINK_TRAP_GENERIC_ID_ARP_REQUEST,
DEVLINK_TRAP_GENERIC_ID_ARP_RESPONSE,
DEVLINK_TRAP_GENERIC_ID_ARP_OVERLAY,
DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_SOLICIT,
DEVLINK_TRAP_GENERIC_ID_IPV6_NEIGH_ADVERT,
DEVLINK_TRAP_GENERIC_ID_IPV4_BFD,
DEVLINK_TRAP_GENERIC_ID_IPV6_BFD,
DEVLINK_TRAP_GENERIC_ID_IPV4_OSPF,
DEVLINK_TRAP_GENERIC_ID_IPV6_OSPF,
DEVLINK_TRAP_GENERIC_ID_IPV4_BGP,
DEVLINK_TRAP_GENERIC_ID_IPV6_BGP,
DEVLINK_TRAP_GENERIC_ID_IPV4_VRRP,
DEVLINK_TRAP_GENERIC_ID_IPV6_VRRP,
DEVLINK_TRAP_GENERIC_ID_IPV4_PIM,
DEVLINK_TRAP_GENERIC_ID_IPV6_PIM,
DEVLINK_TRAP_GENERIC_ID_UC_LB,
DEVLINK_TRAP_GENERIC_ID_LOCAL_ROUTE,
DEVLINK_TRAP_GENERIC_ID_EXTERNAL_ROUTE,
DEVLINK_TRAP_GENERIC_ID_IPV6_UC_DIP_LINK_LOCAL_SCOPE,
DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_NODES,
DEVLINK_TRAP_GENERIC_ID_IPV6_DIP_ALL_ROUTERS,
DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_SOLICIT,
DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ADVERT,
DEVLINK_TRAP_GENERIC_ID_IPV6_REDIRECT,
DEVLINK_TRAP_GENERIC_ID_IPV4_ROUTER_ALERT,
DEVLINK_TRAP_GENERIC_ID_IPV6_ROUTER_ALERT,
DEVLINK_TRAP_GENERIC_ID_PTP_EVENT,
DEVLINK_TRAP_GENERIC_ID_PTP_GENERAL,
DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_SAMPLE,
DEVLINK_TRAP_GENERIC_ID_FLOW_ACTION_TRAP,
/* Add new generic trap IDs above */ /* Add new generic trap IDs above */
__DEVLINK_TRAP_GENERIC_ID_MAX, __DEVLINK_TRAP_GENERIC_ID_MAX,
...@@ -657,9 +701,28 @@ enum devlink_trap_generic_id { ...@@ -657,9 +701,28 @@ enum devlink_trap_generic_id {
enum devlink_trap_group_generic_id { enum devlink_trap_group_generic_id {
DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS, DEVLINK_TRAP_GROUP_GENERIC_ID_L2_DROPS,
DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS, DEVLINK_TRAP_GROUP_GENERIC_ID_L3_DROPS,
DEVLINK_TRAP_GROUP_GENERIC_ID_L3_EXCEPTIONS,
DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS, DEVLINK_TRAP_GROUP_GENERIC_ID_BUFFER_DROPS,
DEVLINK_TRAP_GROUP_GENERIC_ID_TUNNEL_DROPS, DEVLINK_TRAP_GROUP_GENERIC_ID_TUNNEL_DROPS,
DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_DROPS, DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_DROPS,
DEVLINK_TRAP_GROUP_GENERIC_ID_STP,
DEVLINK_TRAP_GROUP_GENERIC_ID_LACP,
DEVLINK_TRAP_GROUP_GENERIC_ID_LLDP,
DEVLINK_TRAP_GROUP_GENERIC_ID_MC_SNOOPING,
DEVLINK_TRAP_GROUP_GENERIC_ID_DHCP,
DEVLINK_TRAP_GROUP_GENERIC_ID_NEIGH_DISCOVERY,
DEVLINK_TRAP_GROUP_GENERIC_ID_BFD,
DEVLINK_TRAP_GROUP_GENERIC_ID_OSPF,
DEVLINK_TRAP_GROUP_GENERIC_ID_BGP,
DEVLINK_TRAP_GROUP_GENERIC_ID_VRRP,
DEVLINK_TRAP_GROUP_GENERIC_ID_PIM,
DEVLINK_TRAP_GROUP_GENERIC_ID_UC_LB,
DEVLINK_TRAP_GROUP_GENERIC_ID_LOCAL_DELIVERY,
DEVLINK_TRAP_GROUP_GENERIC_ID_IPV6,
DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_EVENT,
DEVLINK_TRAP_GROUP_GENERIC_ID_PTP_GENERAL,
DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_SAMPLE,
DEVLINK_TRAP_GROUP_GENERIC_ID_ACL_TRAP,
/* Add new generic trap group IDs above */ /* Add new generic trap group IDs above */
__DEVLINK_TRAP_GROUP_GENERIC_ID_MAX, __DEVLINK_TRAP_GROUP_GENERIC_ID_MAX,
...@@ -725,17 +788,143 @@ enum devlink_trap_group_generic_id { ...@@ -725,17 +788,143 @@ enum devlink_trap_group_generic_id {
"ingress_flow_action_drop" "ingress_flow_action_drop"
#define DEVLINK_TRAP_GENERIC_NAME_EGRESS_FLOW_ACTION_DROP \ #define DEVLINK_TRAP_GENERIC_NAME_EGRESS_FLOW_ACTION_DROP \
"egress_flow_action_drop" "egress_flow_action_drop"
#define DEVLINK_TRAP_GENERIC_NAME_STP \
"stp"
#define DEVLINK_TRAP_GENERIC_NAME_LACP \
"lacp"
#define DEVLINK_TRAP_GENERIC_NAME_LLDP \
"lldp"
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_QUERY \
"igmp_query"
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V1_REPORT \
"igmp_v1_report"
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_REPORT \
"igmp_v2_report"
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V3_REPORT \
"igmp_v3_report"
#define DEVLINK_TRAP_GENERIC_NAME_IGMP_V2_LEAVE \
"igmp_v2_leave"
#define DEVLINK_TRAP_GENERIC_NAME_MLD_QUERY \
"mld_query"
#define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_REPORT \
"mld_v1_report"
#define DEVLINK_TRAP_GENERIC_NAME_MLD_V2_REPORT \
"mld_v2_report"
#define DEVLINK_TRAP_GENERIC_NAME_MLD_V1_DONE \
"mld_v1_done"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_DHCP \
"ipv4_dhcp"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DHCP \
"ipv6_dhcp"
#define DEVLINK_TRAP_GENERIC_NAME_ARP_REQUEST \
"arp_request"
#define DEVLINK_TRAP_GENERIC_NAME_ARP_RESPONSE \
"arp_response"
#define DEVLINK_TRAP_GENERIC_NAME_ARP_OVERLAY \
"arp_overlay"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_SOLICIT \
"ipv6_neigh_solicit"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_NEIGH_ADVERT \
"ipv6_neigh_advert"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_BFD \
"ipv4_bfd"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_BFD \
"ipv6_bfd"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_OSPF \
"ipv4_ospf"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_OSPF \
"ipv6_ospf"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_BGP \
"ipv4_bgp"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_BGP \
"ipv6_bgp"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_VRRP \
"ipv4_vrrp"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_VRRP \
"ipv6_vrrp"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_PIM \
"ipv4_pim"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_PIM \
"ipv6_pim"
#define DEVLINK_TRAP_GENERIC_NAME_UC_LB \
"uc_loopback"
#define DEVLINK_TRAP_GENERIC_NAME_LOCAL_ROUTE \
"local_route"
#define DEVLINK_TRAP_GENERIC_NAME_EXTERNAL_ROUTE \
"external_route"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_UC_DIP_LINK_LOCAL_SCOPE \
"ipv6_uc_dip_link_local_scope"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_NODES \
"ipv6_dip_all_nodes"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_DIP_ALL_ROUTERS \
"ipv6_dip_all_routers"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_SOLICIT \
"ipv6_router_solicit"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ADVERT \
"ipv6_router_advert"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_REDIRECT \
"ipv6_redirect"
#define DEVLINK_TRAP_GENERIC_NAME_IPV4_ROUTER_ALERT \
"ipv4_router_alert"
#define DEVLINK_TRAP_GENERIC_NAME_IPV6_ROUTER_ALERT \
"ipv6_router_alert"
#define DEVLINK_TRAP_GENERIC_NAME_PTP_EVENT \
"ptp_event"
#define DEVLINK_TRAP_GENERIC_NAME_PTP_GENERAL \
"ptp_general"
#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_SAMPLE \
"flow_action_sample"
#define DEVLINK_TRAP_GENERIC_NAME_FLOW_ACTION_TRAP \
"flow_action_trap"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \ #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L2_DROPS \
"l2_drops" "l2_drops"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS \ #define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_DROPS \
"l3_drops" "l3_drops"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_L3_EXCEPTIONS \
"l3_exceptions"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS \ #define DEVLINK_TRAP_GROUP_GENERIC_NAME_BUFFER_DROPS \
"buffer_drops" "buffer_drops"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_TUNNEL_DROPS \ #define DEVLINK_TRAP_GROUP_GENERIC_NAME_TUNNEL_DROPS \
"tunnel_drops" "tunnel_drops"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_DROPS \ #define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_DROPS \
"acl_drops" "acl_drops"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_STP \
"stp"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LACP \
"lacp"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LLDP \
"lldp"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_MC_SNOOPING \
"mc_snooping"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_DHCP \
"dhcp"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_NEIGH_DISCOVERY \
"neigh_discovery"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BFD \
"bfd"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_OSPF \
"ospf"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_BGP \
"bgp"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_VRRP \
"vrrp"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PIM \
"pim"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_UC_LB \
"uc_loopback"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_LOCAL_DELIVERY \
"local_delivery"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_IPV6 \
"ipv6"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_EVENT \
"ptp_event"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_PTP_GENERAL \
"ptp_general"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_SAMPLE \
"acl_sample"
#define DEVLINK_TRAP_GROUP_GENERIC_NAME_ACL_TRAP \
"acl_trap"
#define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id, \ #define DEVLINK_TRAP_GENERIC(_type, _init_action, _id, _group_id, \
_metadata_cap) \ _metadata_cap) \
......
...@@ -233,10 +233,13 @@ enum { ...@@ -233,10 +233,13 @@ enum {
* @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not * @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not
* sent to the CPU. * sent to the CPU.
* @DEVLINK_TRAP_ACTION_TRAP: The sole copy of the packet is sent to the CPU. * @DEVLINK_TRAP_ACTION_TRAP: The sole copy of the packet is sent to the CPU.
* @DEVLINK_TRAP_ACTION_MIRROR: Packet is forwarded by the device and a copy is
* sent to the CPU.
*/ */
enum devlink_trap_action { enum devlink_trap_action {
DEVLINK_TRAP_ACTION_DROP, DEVLINK_TRAP_ACTION_DROP,
DEVLINK_TRAP_ACTION_TRAP, DEVLINK_TRAP_ACTION_TRAP,
DEVLINK_TRAP_ACTION_MIRROR,
}; };
/** /**
...@@ -250,10 +253,16 @@ enum devlink_trap_action { ...@@ -250,10 +253,16 @@ enum devlink_trap_action {
* control plane for resolution. Trapped packets * control plane for resolution. Trapped packets
* are processed by devlink and injected to * are processed by devlink and injected to
* the kernel's Rx path. * the kernel's Rx path.
* @DEVLINK_TRAP_TYPE_CONTROL: Packet was trapped because it is required for
* the correct functioning of the control plane.
* For example, an ARP request packet. Trapped
* packets are injected to the kernel's Rx path,
* but not reported to drop monitor.
*/ */
enum devlink_trap_type { enum devlink_trap_type {
DEVLINK_TRAP_TYPE_DROP, DEVLINK_TRAP_TYPE_DROP,
DEVLINK_TRAP_TYPE_EXCEPTION, DEVLINK_TRAP_TYPE_EXCEPTION,
DEVLINK_TRAP_TYPE_CONTROL,
}; };
enum { enum {
......
...@@ -5869,7 +5869,8 @@ devlink_trap_action_get_from_info(struct genl_info *info, ...@@ -5869,7 +5869,8 @@ devlink_trap_action_get_from_info(struct genl_info *info,
val = nla_get_u8(info->attrs[DEVLINK_ATTR_TRAP_ACTION]); val = nla_get_u8(info->attrs[DEVLINK_ATTR_TRAP_ACTION]);
switch (val) { switch (val) {
case DEVLINK_TRAP_ACTION_DROP: /* fall-through */ case DEVLINK_TRAP_ACTION_DROP: /* fall-through */
case DEVLINK_TRAP_ACTION_TRAP: case DEVLINK_TRAP_ACTION_TRAP: /* fall-through */
case DEVLINK_TRAP_ACTION_MIRROR:
*p_trap_action = val; *p_trap_action = val;
break; break;
default: default:
...@@ -8494,6 +8495,50 @@ static const struct devlink_trap devlink_trap_generic[] = { ...@@ -8494,6 +8495,50 @@ static const struct devlink_trap devlink_trap_generic[] = {
DEVLINK_TRAP(OVERLAY_SMAC_MC, DROP), DEVLINK_TRAP(OVERLAY_SMAC_MC, DROP),
DEVLINK_TRAP(INGRESS_FLOW_ACTION_DROP, DROP), DEVLINK_TRAP(INGRESS_FLOW_ACTION_DROP, DROP),
DEVLINK_TRAP(EGRESS_FLOW_ACTION_DROP, DROP), DEVLINK_TRAP(EGRESS_FLOW_ACTION_DROP, DROP),
DEVLINK_TRAP(STP, CONTROL),
DEVLINK_TRAP(LACP, CONTROL),
DEVLINK_TRAP(LLDP, CONTROL),
DEVLINK_TRAP(IGMP_QUERY, CONTROL),
DEVLINK_TRAP(IGMP_V1_REPORT, CONTROL),
DEVLINK_TRAP(IGMP_V2_REPORT, CONTROL),
DEVLINK_TRAP(IGMP_V3_REPORT, CONTROL),
DEVLINK_TRAP(IGMP_V2_LEAVE, CONTROL),
DEVLINK_TRAP(MLD_QUERY, CONTROL),
DEVLINK_TRAP(MLD_V1_REPORT, CONTROL),
DEVLINK_TRAP(MLD_V2_REPORT, CONTROL),
DEVLINK_TRAP(MLD_V1_DONE, CONTROL),
DEVLINK_TRAP(IPV4_DHCP, CONTROL),
DEVLINK_TRAP(IPV6_DHCP, CONTROL),
DEVLINK_TRAP(ARP_REQUEST, CONTROL),
DEVLINK_TRAP(ARP_RESPONSE, CONTROL),
DEVLINK_TRAP(ARP_OVERLAY, CONTROL),
DEVLINK_TRAP(IPV6_NEIGH_SOLICIT, CONTROL),
DEVLINK_TRAP(IPV6_NEIGH_ADVERT, CONTROL),
DEVLINK_TRAP(IPV4_BFD, CONTROL),
DEVLINK_TRAP(IPV6_BFD, CONTROL),
DEVLINK_TRAP(IPV4_OSPF, CONTROL),
DEVLINK_TRAP(IPV6_OSPF, CONTROL),
DEVLINK_TRAP(IPV4_BGP, CONTROL),
DEVLINK_TRAP(IPV6_BGP, CONTROL),
DEVLINK_TRAP(IPV4_VRRP, CONTROL),
DEVLINK_TRAP(IPV6_VRRP, CONTROL),
DEVLINK_TRAP(IPV4_PIM, CONTROL),
DEVLINK_TRAP(IPV6_PIM, CONTROL),
DEVLINK_TRAP(UC_LB, CONTROL),
DEVLINK_TRAP(LOCAL_ROUTE, CONTROL),
DEVLINK_TRAP(EXTERNAL_ROUTE, CONTROL),
DEVLINK_TRAP(IPV6_UC_DIP_LINK_LOCAL_SCOPE, CONTROL),
DEVLINK_TRAP(IPV6_DIP_ALL_NODES, CONTROL),
DEVLINK_TRAP(IPV6_DIP_ALL_ROUTERS, CONTROL),
DEVLINK_TRAP(IPV6_ROUTER_SOLICIT, CONTROL),
DEVLINK_TRAP(IPV6_ROUTER_ADVERT, CONTROL),
DEVLINK_TRAP(IPV6_REDIRECT, CONTROL),
DEVLINK_TRAP(IPV4_ROUTER_ALERT, CONTROL),
DEVLINK_TRAP(IPV6_ROUTER_ALERT, CONTROL),
DEVLINK_TRAP(PTP_EVENT, CONTROL),
DEVLINK_TRAP(PTP_GENERAL, CONTROL),
DEVLINK_TRAP(FLOW_ACTION_SAMPLE, CONTROL),
DEVLINK_TRAP(FLOW_ACTION_TRAP, CONTROL),
}; };
#define DEVLINK_TRAP_GROUP(_id) \ #define DEVLINK_TRAP_GROUP(_id) \
...@@ -8505,9 +8550,28 @@ static const struct devlink_trap devlink_trap_generic[] = { ...@@ -8505,9 +8550,28 @@ static const struct devlink_trap devlink_trap_generic[] = {
static const struct devlink_trap_group devlink_trap_group_generic[] = { static const struct devlink_trap_group devlink_trap_group_generic[] = {
DEVLINK_TRAP_GROUP(L2_DROPS), DEVLINK_TRAP_GROUP(L2_DROPS),
DEVLINK_TRAP_GROUP(L3_DROPS), DEVLINK_TRAP_GROUP(L3_DROPS),
DEVLINK_TRAP_GROUP(L3_EXCEPTIONS),
DEVLINK_TRAP_GROUP(BUFFER_DROPS), DEVLINK_TRAP_GROUP(BUFFER_DROPS),
DEVLINK_TRAP_GROUP(TUNNEL_DROPS), DEVLINK_TRAP_GROUP(TUNNEL_DROPS),
DEVLINK_TRAP_GROUP(ACL_DROPS), DEVLINK_TRAP_GROUP(ACL_DROPS),
DEVLINK_TRAP_GROUP(STP),
DEVLINK_TRAP_GROUP(LACP),
DEVLINK_TRAP_GROUP(LLDP),
DEVLINK_TRAP_GROUP(MC_SNOOPING),
DEVLINK_TRAP_GROUP(DHCP),
DEVLINK_TRAP_GROUP(NEIGH_DISCOVERY),
DEVLINK_TRAP_GROUP(BFD),
DEVLINK_TRAP_GROUP(OSPF),
DEVLINK_TRAP_GROUP(BGP),
DEVLINK_TRAP_GROUP(VRRP),
DEVLINK_TRAP_GROUP(PIM),
DEVLINK_TRAP_GROUP(UC_LB),
DEVLINK_TRAP_GROUP(LOCAL_DELIVERY),
DEVLINK_TRAP_GROUP(IPV6),
DEVLINK_TRAP_GROUP(PTP_EVENT),
DEVLINK_TRAP_GROUP(PTP_GENERAL),
DEVLINK_TRAP_GROUP(ACL_SAMPLE),
DEVLINK_TRAP_GROUP(ACL_TRAP),
}; };
static int devlink_trap_generic_verify(const struct devlink_trap *trap) static int devlink_trap_generic_verify(const struct devlink_trap *trap)
...@@ -8845,6 +8909,13 @@ void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, ...@@ -8845,6 +8909,13 @@ void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb,
devlink_trap_stats_update(trap_item->stats, skb->len); devlink_trap_stats_update(trap_item->stats, skb->len);
devlink_trap_stats_update(trap_item->group_item->stats, skb->len); devlink_trap_stats_update(trap_item->group_item->stats, skb->len);
/* Control packets were not dropped by the device or encountered an
* exception during forwarding and therefore should not be reported to
* the kernel's drop monitor.
*/
if (trap_item->trap->type == DEVLINK_TRAP_TYPE_CONTROL)
return;
devlink_trap_report_metadata_fill(&hw_metadata, trap_item, devlink_trap_report_metadata_fill(&hw_metadata, trap_item,
in_devlink_port, fa_cookie); in_devlink_port, fa_cookie);
net_dm_hw_report(skb, &hw_metadata); net_dm_hw_report(skb, &hw_metadata);
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Test devlink-trap control trap functionality over mlxsw. Each registered
# control packet trap is tested to make sure it is triggered under the right
# conditions.
#
# +---------------------------------+
# | H1 (vrf) |
# | + $h1 |
# | | 192.0.2.1/24 |
# | | 2001:db8:1::1/64 |
# | | |
# | | default via 192.0.2.2 |
# | | default via 2001:db8:1::2 |
# +----|----------------------------+
# |
# +----|----------------------------------------------------------------------+
# | SW | |
# | + $rp1 |
# | 192.0.2.2/24 |
# | 2001:db8:1::2/64 |
# | |
# | 2001:db8:2::2/64 |
# | 198.51.100.2/24 |
# | + $rp2 |
# | | |
# +----|----------------------------------------------------------------------+
# |
# +----|----------------------------+
# | | default via 198.51.100.2 |
# | | default via 2001:db8:2::2 |
# | | |
# | | 2001:db8:2::1/64 |
# | | 198.51.100.1/24 |
# | + $h2 |
# | H2 (vrf) |
# +---------------------------------+
lib_dir=$(dirname $0)/../../../net/forwarding
ALL_TESTS="
stp_test
lacp_test
lldp_test
igmp_query_test
igmp_v1_report_test
igmp_v2_report_test
igmp_v3_report_test
igmp_v2_leave_test
mld_query_test
mld_v1_report_test
mld_v2_report_test
mld_v1_done_test
ipv4_dhcp_test
ipv6_dhcp_test
arp_request_test
arp_response_test
ipv6_neigh_solicit_test
ipv6_neigh_advert_test
ipv4_bfd_test
ipv6_bfd_test
ipv4_ospf_test
ipv6_ospf_test
ipv4_bgp_test
ipv6_bgp_test
ipv4_vrrp_test
ipv6_vrrp_test
ipv4_pim_test
ipv6_pim_test
uc_loopback_test
local_route_test
external_route_test
ipv6_uc_dip_link_local_scope_test
ipv4_router_alert_test
ipv6_router_alert_test
ipv6_dip_all_nodes_test
ipv6_dip_all_routers_test
ipv6_router_solicit_test
ipv6_router_advert_test
ipv6_redirect_test
ptp_event_test
ptp_general_test
flow_action_sample_test
flow_action_trap_test
"
NUM_NETIFS=4
source $lib_dir/lib.sh
source $lib_dir/devlink_lib.sh
h1_create()
{
simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
ip -4 route add default vrf v$h1 nexthop via 192.0.2.2
ip -6 route add default vrf v$h1 nexthop via 2001:db8:1::2
}
h1_destroy()
{
ip -6 route del default vrf v$h1 nexthop via 2001:db8:1::2
ip -4 route del default vrf v$h1 nexthop via 192.0.2.2
simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
}
h2_create()
{
simple_if_init $h2 198.51.100.1/24 2001:db8:2::1/64
ip -4 route add default vrf v$h2 nexthop via 198.51.100.2
ip -6 route add default vrf v$h2 nexthop via 2001:db8:2::2
}
h2_destroy()
{
ip -6 route del default vrf v$h2 nexthop via 2001:db8:2::2
ip -4 route del default vrf v$h2 nexthop via 198.51.100.2
simple_if_fini $h2 198.51.100.1/24 2001:db8:2::1/64
}
router_create()
{
ip link set dev $rp1 up
ip link set dev $rp2 up
__addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64
__addr_add_del $rp2 add 198.51.100.2/24 2001:db8:2::2/64
}
router_destroy()
{
__addr_add_del $rp2 del 198.51.100.2/24 2001:db8:2::2/64
__addr_add_del $rp1 del 192.0.2.2/24 2001:db8:1::2/64
ip link set dev $rp2 down
ip link set dev $rp1 down
}
setup_prepare()
{
h1=${NETIFS[p1]}
rp1=${NETIFS[p2]}
rp2=${NETIFS[p3]}
h2=${NETIFS[p4]}
vrf_prepare
forwarding_enable
h1_create
h2_create
router_create
}
cleanup()
{
pre_cleanup
router_destroy
h2_destroy
h1_destroy
forwarding_restore
vrf_cleanup
}
stp_test()
{
devlink_trap_stats_test "STP" "stp" $MZ $h1 -c 1 -t bpdu -q
}
lacp_payload_get()
{
local source_mac=$1; shift
local p
p=$(:
)"01:80:C2:00:00:02:"$( : ETH daddr
)"$source_mac:"$( : ETH saddr
)"88:09:"$( : ETH type
)
echo $p
}
lacp_test()
{
local h1mac=$(mac_get $h1)
devlink_trap_stats_test "LACP" "lacp" $MZ $h1 -c 1 \
$(lacp_payload_get $h1mac) -p 100 -q
}
lldp_payload_get()
{
local source_mac=$1; shift
local p
p=$(:
)"01:80:C2:00:00:0E:"$( : ETH daddr
)"$source_mac:"$( : ETH saddr
)"88:CC:"$( : ETH type
)
echo $p
}
lldp_test()
{
local h1mac=$(mac_get $h1)
devlink_trap_stats_test "LLDP" "lldp" $MZ $h1 -c 1 \
$(lldp_payload_get $h1mac) -p 100 -q
}
igmp_query_test()
{
# IGMP (IP Protocol 2) Membership Query (Type 0x11)
devlink_trap_stats_test "IGMP Membership Query" "igmp_query" \
$MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
-A 192.0.2.1 -B 224.0.0.1 -t ip proto=2,p=11 -p 100 -q
}
igmp_v1_report_test()
{
# IGMP (IP Protocol 2) Version 1 Membership Report (Type 0x12)
devlink_trap_stats_test "IGMP Version 1 Membership Report" \
"igmp_v1_report" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
-A 192.0.2.1 -B 244.0.0.1 -t ip proto=2,p=12 -p 100 -q
}
igmp_v2_report_test()
{
# IGMP (IP Protocol 2) Version 2 Membership Report (Type 0x16)
devlink_trap_stats_test "IGMP Version 2 Membership Report" \
"igmp_v2_report" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
-A 192.0.2.1 -B 244.0.0.1 -t ip proto=2,p=16 -p 100 -q
}
igmp_v3_report_test()
{
# IGMP (IP Protocol 2) Version 3 Membership Report (Type 0x22)
devlink_trap_stats_test "IGMP Version 3 Membership Report" \
"igmp_v3_report" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:01 \
-A 192.0.2.1 -B 244.0.0.1 -t ip proto=2,p=22 -p 100 -q
}
igmp_v2_leave_test()
{
# IGMP (IP Protocol 2) Version 2 Leave Group (Type 0x17)
devlink_trap_stats_test "IGMP Version 2 Leave Group" \
"igmp_v2_leave" $MZ $h1 -c 1 -a own -b 01:00:5E:00:00:02 \
-A 192.0.2.1 -B 224.0.0.2 -t ip proto=2,p=17 -p 100 -q
}
mld_payload_get()
{
local type=$1; shift
local p
type=$(printf "%x" $type)
p=$(:
)"3A:"$( : Next Header - ICMPv6
)"00:"$( : Hdr Ext Len
)"00:00:00:00:00:00:"$( : Options and Padding
)"$type:"$( : ICMPv6.type
)"00:"$( : ICMPv6.code
)"00:"$( : ICMPv6.checksum
)
echo $p
}
mld_query_test()
{
# MLD Multicast Listener Query (Type 130)
devlink_trap_stats_test "MLD Multicast Listener Query" "mld_query" \
$MZ $h1 -6 -c 1 -A fe80::1 -B ff02::1 \
-t ip hop=1,next=0,payload=$(mld_payload_get 130) -p 100 -q
}
mld_v1_report_test()
{
# MLD Version 1 Multicast Listener Report (Type 131)
devlink_trap_stats_test "MLD Version 1 Multicast Listener Report" \
"mld_v1_report" $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::16 \
-t ip hop=1,next=0,payload=$(mld_payload_get 131) -p 100 -q
}
mld_v2_report_test()
{
# MLD Version 2 Multicast Listener Report (Type 143)
devlink_trap_stats_test "MLD Version 2 Multicast Listener Report" \
"mld_v2_report" $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::16 \
-t ip hop=1,next=0,payload=$(mld_payload_get 143) -p 100 -q
}
mld_v1_done_test()
{
# MLD Version 1 Multicast Listener Done (Type 132)
devlink_trap_stats_test "MLD Version 1 Multicast Listener Done" \
"mld_v1_done" $MZ $h1 -6 -c 1 -A fe80::1 -B ff02::16 \
-t ip hop=1,next=0,payload=$(mld_payload_get 132) -p 100 -q
}
ipv4_dhcp_test()
{
devlink_trap_stats_test "IPv4 DHCP Port 67" "ipv4_dhcp" \
$MZ $h1 -c 1 -a own -b bcast -A 0.0.0.0 -B 255.255.255.255 \
-t udp sp=68,dp=67 -p 100 -q
devlink_trap_stats_test "IPv4 DHCP Port 68" "ipv4_dhcp" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) -A 192.0.2.1 \
-B 255.255.255.255 -t udp sp=67,dp=68 -p 100 -q
}
ipv6_dhcp_test()
{
devlink_trap_stats_test "IPv6 DHCP Port 547" "ipv6_dhcp" \
$MZ $h1 -6 -c 1 -A fe80::1 -B ff02::1:2 -t udp sp=546,dp=547 \
-p 100 -q
devlink_trap_stats_test "IPv6 DHCP Port 546" "ipv6_dhcp" \
$MZ $h1 -6 -c 1 -A fe80::1 -B ff02::1:2 -t udp sp=547,dp=546 \
-p 100 -q
}
arp_request_test()
{
devlink_trap_stats_test "ARP Request" "arp_request" \
$MZ $h1 -c 1 -a own -b bcast -t arp request -p 100 -q
}
arp_response_test()
{
devlink_trap_stats_test "ARP Response" "arp_response" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) -t arp reply -p 100 -q
}
icmpv6_header_get()
{
local type=$1; shift
local p
type=$(printf "%x" $type)
p=$(:
)"$type:"$( : ICMPv6.type
)"00:"$( : ICMPv6.code
)"00:"$( : ICMPv6.checksum
)
echo $p
}
ipv6_neigh_solicit_test()
{
devlink_trap_stats_test "IPv6 Neighbour Solicitation" \
"ipv6_neigh_solicit" $MZ $h1 -6 -c 1 \
-A fe80::1 -B ff02::1:ff00:02 \
-t ip hop=1,next=58,payload=$(icmpv6_header_get 135) -p 100 -q
}
ipv6_neigh_advert_test()
{
devlink_trap_stats_test "IPv6 Neighbour Advertisement" \
"ipv6_neigh_advert" $MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A fe80::1 -B 2001:db8:1::2 \
-t ip hop=1,next=58,payload=$(icmpv6_header_get 136) -p 100 -q
}
ipv4_bfd_test()
{
devlink_trap_stats_test "IPv4 BFD Control - Port 3784" "ipv4_bfd" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 192.0.2.2 -t udp sp=49153,dp=3784 -p 100 -q
devlink_trap_stats_test "IPv4 BFD Echo - Port 3785" "ipv4_bfd" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 192.0.2.2 -t udp sp=49153,dp=3785 -p 100 -q
}
ipv6_bfd_test()
{
devlink_trap_stats_test "IPv6 BFD Control - Port 3784" "ipv6_bfd" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:1::2 \
-t udp sp=49153,dp=3784 -p 100 -q
devlink_trap_stats_test "IPv6 BFD Echo - Port 3785" "ipv6_bfd" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:1::2 \
-t udp sp=49153,dp=3785 -p 100 -q
}
ipv4_ospf_test()
{
devlink_trap_stats_test "IPv4 OSPF - Multicast" "ipv4_ospf" \
$MZ $h1 -c 1 -a own -b 01:00:5e:00:00:05 \
-A 192.0.2.1 -B 224.0.0.5 -t ip proto=89 -p 100 -q
devlink_trap_stats_test "IPv4 OSPF - Unicast" "ipv4_ospf" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 192.0.2.2 -t ip proto=89 -p 100 -q
}
ipv6_ospf_test()
{
devlink_trap_stats_test "IPv6 OSPF - Multicast" "ipv6_ospf" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:05 \
-A fe80::1 -B ff02::5 -t ip next=89 -p 100 -q
devlink_trap_stats_test "IPv6 OSPF - Unicast" "ipv6_ospf" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:1::2 -t ip next=89 -p 100 -q
}
ipv4_bgp_test()
{
devlink_trap_stats_test "IPv4 BGP" "ipv4_bgp" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 192.0.2.2 -t tcp sp=54321,dp=179,flags=rst \
-p 100 -q
}
ipv6_bgp_test()
{
devlink_trap_stats_test "IPv6 BGP" "ipv6_bgp" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:1::2 \
-t tcp sp=54321,dp=179,flags=rst -p 100 -q
}
ipv4_vrrp_test()
{
devlink_trap_stats_test "IPv4 VRRP" "ipv4_vrrp" \
$MZ $h1 -c 1 -a own -b 01:00:5e:00:00:12 \
-A 192.0.2.1 -B 224.0.0.18 -t ip proto=112 -p 100 -q
}
ipv6_vrrp_test()
{
devlink_trap_stats_test "IPv6 VRRP" "ipv6_vrrp" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:12 \
-A fe80::1 -B ff02::12 -t ip next=112 -p 100 -q
}
ipv4_pim_test()
{
devlink_trap_stats_test "IPv4 PIM - Multicast" "ipv4_pim" \
$MZ $h1 -c 1 -a own -b 01:00:5e:00:00:0d \
-A 192.0.2.1 -B 224.0.0.13 -t ip proto=103 -p 100 -q
devlink_trap_stats_test "IPv4 PIM - Unicast" "ipv4_pim" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 192.0.2.2 -t ip proto=103 -p 100 -q
}
ipv6_pim_test()
{
devlink_trap_stats_test "IPv6 PIM - Multicast" "ipv6_pim" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:0d \
-A fe80::1 -B ff02::d -t ip next=103 -p 100 -q
devlink_trap_stats_test "IPv6 PIM - Unicast" "ipv6_pim" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A fe80::1 -B 2001:db8:1::2 -t ip next=103 -p 100 -q
}
uc_loopback_test()
{
# Add neighbours to the fake destination IPs, so that the packets are
# routed in the device and not trapped due to an unresolved neighbour
# exception.
ip -4 neigh add 192.0.2.3 lladdr 00:11:22:33:44:55 nud permanent \
dev $rp1
ip -6 neigh add 2001:db8:1::3 lladdr 00:11:22:33:44:55 nud permanent \
dev $rp1
devlink_trap_stats_test "IPv4 Unicast Loopback" "uc_loopback" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 192.0.2.3 -t udp sp=54321,dp=12345 -p 100 -q
devlink_trap_stats_test "IPv6 Unicast Loopback" "uc_loopback" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:1::3 -t udp sp=54321,dp=12345 \
-p 100 -q
ip -6 neigh del 2001:db8:1::3 dev $rp1
ip -4 neigh del 192.0.2.3 dev $rp1
}
local_route_test()
{
# Use a fake source IP to prevent the trap from being triggered twice
# when the router sends back a port unreachable message.
devlink_trap_stats_test "IPv4 Local Route" "local_route" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.3 -B 192.0.2.2 -t udp sp=54321,dp=12345 -p 100 -q
devlink_trap_stats_test "IPv6 Local Route" "local_route" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::3 -B 2001:db8:1::2 -t udp sp=54321,sp=12345 \
-p 100 -q
}
external_route_test()
{
# Add a dummy device through which the incoming packets should be
# routed.
ip link add name dummy10 up type dummy
ip address add 203.0.113.1/24 dev dummy10
ip -6 address add 2001:db8:10::1/64 dev dummy10
devlink_trap_stats_test "IPv4 External Route" "external_route" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 203.0.113.2 -t udp sp=54321,dp=12345 -p 100 -q
devlink_trap_stats_test "IPv6 External Route" "external_route" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:10::2 -t udp sp=54321,sp=12345 \
-p 100 -q
ip -6 address del 2001:db8:10::1/64 dev dummy10
ip address del 203.0.113.1/24 dev dummy10
ip link del dev dummy10
}
ipv6_uc_dip_link_local_scope_test()
{
# Add a dummy link-local prefix route to allow the packet to be routed.
ip -6 route add fe80:1::/64 dev $rp2
devlink_trap_stats_test \
"IPv6 Unicast Destination IP With Link-Local Scope" \
"ipv6_uc_dip_link_local_scope" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A fe80::1 -B fe80:1::2 -t udp sp=54321,sp=12345 \
-p 100 -q
ip -6 route del fe80:1::/64 dev $rp2
}
ipv4_router_alert_get()
{
local p
# https://en.wikipedia.org/wiki/IPv4#Options
p=$(:
)"94:"$( : Option Number
)"04:"$( : Option Length
)"00:00:"$( : Option Data
)
echo $p
}
ipv4_router_alert_test()
{
devlink_trap_stats_test "IPv4 Router Alert" "ipv4_router_alert" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 198.51.100.3 \
-t ip option=$(ipv4_router_alert_get) -p 100 -q
}
ipv6_router_alert_get()
{
local p
# https://en.wikipedia.org/wiki/IPv6_packet#Hop-by-hop_options_and_destination_options
# https://tools.ietf.org/html/rfc2711#section-2.1
p=$(:
)"11:"$( : Next Header - UDP
)"00:"$( : Hdr Ext Len
)"05:02:00:00:00:00:"$( : Option Data
)
echo $p
}
ipv6_router_alert_test()
{
devlink_trap_stats_test "IPv6 Router Alert" "ipv6_router_alert" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A 2001:db8:1::1 -B 2001:db8:1::3 \
-t ip next=0,payload=$(ipv6_router_alert_get) -p 100 -q
}
ipv6_dip_all_nodes_test()
{
devlink_trap_stats_test "IPv6 Destination IP \"All Nodes Address\"" \
"ipv6_dip_all_nodes" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:01 \
-A 2001:db8:1::1 -B ff02::1 -t udp sp=12345,dp=54321 -p 100 -q
}
ipv6_dip_all_routers_test()
{
devlink_trap_stats_test "IPv6 Destination IP \"All Routers Address\"" \
"ipv6_dip_all_routers" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:02 \
-A 2001:db8:1::1 -B ff02::2 -t udp sp=12345,dp=54321 -p 100 -q
}
ipv6_router_solicit_test()
{
devlink_trap_stats_test "IPv6 Router Solicitation" \
"ipv6_router_solicit" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:02 \
-A fe80::1 -B ff02::2 \
-t ip hop=1,next=58,payload=$(icmpv6_header_get 133) -p 100 -q
}
ipv6_router_advert_test()
{
devlink_trap_stats_test "IPv6 Router Advertisement" \
"ipv6_router_advert" \
$MZ $h1 -6 -c 1 -a own -b 33:33:00:00:00:01 \
-A fe80::1 -B ff02::1 \
-t ip hop=1,next=58,payload=$(icmpv6_header_get 134) -p 100 -q
}
ipv6_redirect_test()
{
devlink_trap_stats_test "IPv6 Redirect Message" \
"ipv6_redirect" \
$MZ $h1 -6 -c 1 -a own -b $(mac_get $rp1) \
-A fe80::1 -B 2001:db8:1::2 \
-t ip hop=1,next=58,payload=$(icmpv6_header_get 137) -p 100 -q
}
ptp_event_test()
{
# PTP is only supported on Spectrum-1, for now.
[[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
# PTP Sync (0)
devlink_trap_stats_test "PTP Time-Critical Event Message" "ptp_event" \
$MZ $h1 -c 1 -a own -b 01:00:5e:00:01:81 \
-A 192.0.2.1 -B 224.0.1.129 \
-t udp sp=12345,dp=319,payload=10 -p 100 -q
}
ptp_general_test()
{
# PTP is only supported on Spectrum-1, for now.
[[ "$DEVLINK_VIDDID" != "15b3:cb84" ]] && return
# PTP Announce (b)
devlink_trap_stats_test "PTP General Message" "ptp_general" \
$MZ $h1 -c 1 -a own -b 01:00:5e:00:01:81 \
-A 192.0.2.1 -B 224.0.1.129 \
-t udp sp=12345,dp=320,payload=1b -p 100 -q
}
flow_action_sample_test()
{
# Install a filter that samples every incoming packet.
tc qdisc add dev $rp1 clsact
tc filter add dev $rp1 ingress proto all pref 1 handle 101 matchall \
skip_sw action sample rate 1 group 1
devlink_trap_stats_test "Flow Sampling" "flow_action_sample" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 198.51.100.1 -t udp sp=12345,dp=54321 -p 100 -q
tc filter del dev $rp1 ingress proto all pref 1 handle 101 matchall
tc qdisc del dev $rp1 clsact
}
flow_action_trap_test()
{
# Install a filter that traps a specific flow.
tc qdisc add dev $rp1 clsact
tc filter add dev $rp1 ingress proto ip pref 1 handle 101 flower \
skip_sw ip_proto udp src_port 12345 dst_port 54321 action trap
devlink_trap_stats_test "Flow Trapping (Logging)" "flow_action_trap" \
$MZ $h1 -c 1 -a own -b $(mac_get $rp1) \
-A 192.0.2.1 -B 198.51.100.1 -t udp sp=12345,dp=54321 -p 100 -q
tc filter del dev $rp1 ingress proto ip pref 1 handle 101 flower
tc qdisc del dev $rp1 clsact
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
...@@ -423,6 +423,29 @@ devlink_trap_drop_cleanup() ...@@ -423,6 +423,29 @@ devlink_trap_drop_cleanup()
tc filter del dev $dev egress protocol $proto pref $pref handle $handle flower tc filter del dev $dev egress protocol $proto pref $pref handle $handle flower
} }
devlink_trap_stats_test()
{
local test_name=$1; shift
local trap_name=$1; shift
local send_one="$@"
local t0_packets
local t1_packets
RET=0
t0_packets=$(devlink_trap_rx_packets_get $trap_name)
$send_one && sleep 1
t1_packets=$(devlink_trap_rx_packets_get $trap_name)
if [[ $t1_packets -eq $t0_packets ]]; then
check_err 1 "Trap stats did not increase"
fi
log_test "$test_name"
}
devlink_trap_policers_num_get() devlink_trap_policers_num_get()
{ {
devlink -j -p trap policer show | jq '.[]["'$DEVLINK_DEV'"] | length' devlink -j -p trap policer show | jq '.[]["'$DEVLINK_DEV'"] | length'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment