aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Machata <petrm@mellanox.com>2018-02-27 08:53:39 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-27 14:46:26 -0500
commit0d6cd3fcbc0222234c7f91c7f3e57d34fc009714 (patch)
tree8f9b43d43f8a6bd0bb478279c7e5f400780e0648
parentb0066da52ea53bae2b4ceed3f47d488df27dab66 (diff)
mlxsw: reg: Add SPAN encapsulation to MPAT register
MPAT Register is used to query and configure the Switch Port Analyzer Table. To configure Port Analyzer to encapsulate mirrored packets, additional fields need to be specified for the MPAT register. 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>
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/reg.h141
1 files changed, 139 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 0e08be41c8e0..2aaccbac3ed1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -1,11 +1,11 @@
1/* 1/*
2 * drivers/net/ethernet/mellanox/mlxsw/reg.h 2 * drivers/net/ethernet/mellanox/mlxsw/reg.h
3 * Copyright (c) 2015-2017 Mellanox Technologies. All rights reserved. 3 * Copyright (c) 2015-2018 Mellanox Technologies. All rights reserved.
4 * Copyright (c) 2015-2016 Ido Schimmel <idosch@mellanox.com> 4 * Copyright (c) 2015-2016 Ido Schimmel <idosch@mellanox.com>
5 * Copyright (c) 2015 Elad Raz <eladr@mellanox.com> 5 * Copyright (c) 2015 Elad Raz <eladr@mellanox.com>
6 * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com> 6 * Copyright (c) 2015-2017 Jiri Pirko <jiri@mellanox.com>
7 * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com> 7 * Copyright (c) 2016 Yotam Gigi <yotamg@mellanox.com>
8 * Copyright (c) 2017 Petr Machata <petrm@mellanox.com> 8 * Copyright (c) 2017-2018 Petr Machata <petrm@mellanox.com>
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met: 11 * modification, are permitted provided that the following conditions are met:
@@ -6772,6 +6772,101 @@ MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
6772 */ 6772 */
6773MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1); 6773MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
6774 6774
6775enum mlxsw_reg_mpat_span_type {
6776 /* Local SPAN Ethernet.
6777 * The original packet is not encapsulated.
6778 */
6779 MLXSW_REG_MPAT_SPAN_TYPE_LOCAL_ETH = 0x0,
6780
6781 /* Encapsulated Remote SPAN Ethernet L3 GRE.
6782 * The packet is encapsulated with GRE header.
6783 */
6784 MLXSW_REG_MPAT_SPAN_TYPE_REMOTE_ETH_L3 = 0x3,
6785};
6786
6787/* reg_mpat_span_type
6788 * SPAN type.
6789 * Access: RW
6790 */
6791MLXSW_ITEM32(reg, mpat, span_type, 0x04, 0, 4);
6792
6793/* Remote SPAN - Ethernet VLAN
6794 * - - - - - - - - - - - - - -
6795 */
6796
6797/* reg_mpat_eth_rspan_vid
6798 * Encapsulation header VLAN ID.
6799 * Access: RW
6800 */
6801MLXSW_ITEM32(reg, mpat, eth_rspan_vid, 0x18, 0, 12);
6802
6803/* Encapsulated Remote SPAN - Ethernet L2
6804 * - - - - - - - - - - - - - - - - - - -
6805 */
6806
6807enum mlxsw_reg_mpat_eth_rspan_version {
6808 MLXSW_REG_MPAT_ETH_RSPAN_VERSION_NO_HEADER = 15,
6809};
6810
6811/* reg_mpat_eth_rspan_version
6812 * RSPAN mirror header version.
6813 * Access: RW
6814 */
6815MLXSW_ITEM32(reg, mpat, eth_rspan_version, 0x10, 18, 4);
6816
6817/* reg_mpat_eth_rspan_mac
6818 * Destination MAC address.
6819 * Access: RW
6820 */
6821MLXSW_ITEM_BUF(reg, mpat, eth_rspan_mac, 0x12, 6);
6822
6823/* reg_mpat_eth_rspan_tp
6824 * Tag Packet. Indicates whether the mirroring header should be VLAN tagged.
6825 * Access: RW
6826 */
6827MLXSW_ITEM32(reg, mpat, eth_rspan_tp, 0x18, 16, 1);
6828
6829/* Encapsulated Remote SPAN - Ethernet L3
6830 * - - - - - - - - - - - - - - - - - - -
6831 */
6832
6833enum mlxsw_reg_mpat_eth_rspan_protocol {
6834 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4,
6835 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6,
6836};
6837
6838/* reg_mpat_eth_rspan_protocol
6839 * SPAN encapsulation protocol.
6840 * Access: RW
6841 */
6842MLXSW_ITEM32(reg, mpat, eth_rspan_protocol, 0x18, 24, 4);
6843
6844/* reg_mpat_eth_rspan_ttl
6845 * Encapsulation header Time-to-Live/HopLimit.
6846 * Access: RW
6847 */
6848MLXSW_ITEM32(reg, mpat, eth_rspan_ttl, 0x1C, 4, 8);
6849
6850/* reg_mpat_eth_rspan_smac
6851 * Source MAC address
6852 * Access: RW
6853 */
6854MLXSW_ITEM_BUF(reg, mpat, eth_rspan_smac, 0x22, 6);
6855
6856/* reg_mpat_eth_rspan_dip*
6857 * Destination IP address. The IP version is configured by protocol.
6858 * Access: RW
6859 */
6860MLXSW_ITEM32(reg, mpat, eth_rspan_dip4, 0x4C, 0, 32);
6861MLXSW_ITEM_BUF(reg, mpat, eth_rspan_dip6, 0x40, 16);
6862
6863/* reg_mpat_eth_rspan_sip*
6864 * Source IP address. The IP version is configured by protocol.
6865 * Access: RW
6866 */
6867MLXSW_ITEM32(reg, mpat, eth_rspan_sip4, 0x5C, 0, 32);
6868MLXSW_ITEM_BUF(reg, mpat, eth_rspan_sip6, 0x50, 16);
6869
6775static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id, 6870static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
6776 u16 system_port, bool e) 6871 u16 system_port, bool e)
6777{ 6872{
@@ -6783,6 +6878,48 @@ static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
6783 mlxsw_reg_mpat_be_set(payload, 1); 6878 mlxsw_reg_mpat_be_set(payload, 1);
6784} 6879}
6785 6880
6881static inline void mlxsw_reg_mpat_eth_rspan_pack(char *payload, u16 vid)
6882{
6883 mlxsw_reg_mpat_eth_rspan_vid_set(payload, vid);
6884}
6885
6886static inline void
6887mlxsw_reg_mpat_eth_rspan_l2_pack(char *payload,
6888 enum mlxsw_reg_mpat_eth_rspan_version version,
6889 const char *mac,
6890 bool tp)
6891{
6892 mlxsw_reg_mpat_eth_rspan_version_set(payload, version);
6893 mlxsw_reg_mpat_eth_rspan_mac_memcpy_to(payload, mac);
6894 mlxsw_reg_mpat_eth_rspan_tp_set(payload, tp);
6895}
6896
6897static inline void
6898mlxsw_reg_mpat_eth_rspan_l3_ipv4_pack(char *payload, u8 ttl,
6899 const char *smac,
6900 u32 sip, u32 dip)
6901{
6902 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
6903 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
6904 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
6905 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV4);
6906 mlxsw_reg_mpat_eth_rspan_sip4_set(payload, sip);
6907 mlxsw_reg_mpat_eth_rspan_dip4_set(payload, dip);
6908}
6909
6910static inline void
6911mlxsw_reg_mpat_eth_rspan_l3_ipv6_pack(char *payload, u8 ttl,
6912 const char *smac,
6913 struct in6_addr sip, struct in6_addr dip)
6914{
6915 mlxsw_reg_mpat_eth_rspan_ttl_set(payload, ttl);
6916 mlxsw_reg_mpat_eth_rspan_smac_memcpy_to(payload, smac);
6917 mlxsw_reg_mpat_eth_rspan_protocol_set(payload,
6918 MLXSW_REG_MPAT_ETH_RSPAN_PROTOCOL_IPV6);
6919 mlxsw_reg_mpat_eth_rspan_sip6_memcpy_to(payload, (void *)&sip);
6920 mlxsw_reg_mpat_eth_rspan_dip6_memcpy_to(payload, (void *)&dip);
6921}
6922
6786/* MPAR - Monitoring Port Analyzer Register 6923/* MPAR - Monitoring Port Analyzer Register
6787 * ---------------------------------------- 6924 * ----------------------------------------
6788 * MPAR register is used to query and configure the port analyzer port mirroring 6925 * MPAR register is used to query and configure the port analyzer port mirroring