Skip to contentSkip to conversation

mlxsw: spectrum_ptp: Increase parsing depth when PTP is enabled

PATCH In review Ido Schimmel 3 participants 3 messages Jul 27, 2019 – Jul 29, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxsw: spectrum_ptp: Increase parsing depth when PTP is enabled

From: Petr Machata <[email protected]>

Spectrum systems have a configurable limit on how far into the packet they parse. By default, the limit is 96 bytes.

An IPv6 PTP packet is layered as Ethernet/IPv6/UDP (14+40+8 bytes), and sequence ID of a PTP event is only available 32 bytes into payload, for a total of 94 bytes. When an additional 802.1q header is present as well (such as when ptp4l is running on a VLAN port), the parsing limit is exceeded. Such packets are not recognized as PTP, and are not timestamped.

Therefore generalize the current VXLAN-specific parsing depth setting to allow reference-counted requests from other modules as well. Keep it in the VXLAN module, because the MPRS register also configures UDP destination port number used for VXLAN, and is thus closely tied to the VXLAN code anyway.

Then invoke the new interfaces from both VXLAN (in obvious places), as well as from PTP code, when the (global) timestamping configuration changes from disabled to enabled or vice versa.

Fixes 8748642751ed ("mlxsw: spectrum: PTP: Support SIOCGHWTSTAMP, SIOCSHWTSTAMP ioctls")
---
 .../net/ethernet/mellanox/mlxsw/spectrum.h    |  4 +
 .../ethernet/mellanox/mlxsw/spectrum_nve.c    |  1 +
 .../ethernet/mellanox/mlxsw/spectrum_nve.h    |  1 +
 .../mellanox/mlxsw/spectrum_nve_vxlan.c       | 76 ++++++++++++++-----
 .../ethernet/mellanox/mlxsw/spectrum_ptp.c    | 17 +++++
 5 files changed, 82 insertions(+), 17 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +4 -0
index 131f62ce9297..6664119fb0c8 100644
@@ -951,4 +951,8 @@ void mlxsw_sp_port_nve_fini(struct mlxsw_sp_port *mlxsw_sp_port);
 int mlxsw_sp_nve_init(struct mlxsw_sp *mlxsw_sp);
 void mlxsw_sp_nve_fini(struct mlxsw_sp *mlxsw_sp);
 
+/* spectrum_nve_vxlan.c */
+int mlxsw_sp_nve_inc_parsing_depth_get(struct mlxsw_sp *mlxsw_sp);
+void mlxsw_sp_nve_inc_parsing_depth_put(struct mlxsw_sp *mlxsw_sp);
+
 #endif
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.c +1 -0
index 1df164a4b06d..17f334b46c40 100644
@@ -775,6 +775,7 @@ static void mlxsw_sp_nve_tunnel_fini(struct mlxsw_sp *mlxsw_sp)
 		ops->fini(nve);
 		mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 1,
 				   nve->tunnel_index);
+		memset(&nve->config, 0, sizeof(nve->config));
 	}
 	nve->num_nve_tunnels--;
 }
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve.h +1 -0
index 0035640156a1..12f664f42f21 100644
@@ -29,6 +29,7 @@ struct mlxsw_sp_nve {
 	unsigned int num_max_mc_entries[MLXSW_SP_L3_PROTO_MAX];
 	u32 tunnel_index;
 	u16 ul_rif_index;	/* Reserved for Spectrum */
+	unsigned int inc_parsing_depth_refs;
 };
 
 struct mlxsw_sp_nve_ops {
drivers/net/ethernet/mellanox/mlxsw/spectrum_nve_vxlan.c +59 -17

124 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +17 -0
index bd9c2bc2d5d6..4b352a71f76e 100644
@@ -979,19 +979,36 @@ static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port,
 {
 	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 	struct mlxsw_sp_port *tmp;
+	u16 orig_ing_types = 0;
+	u16 orig_egr_types = 0;
 	int i;
+	int err;
 
 	/* MTPPPC configures timestamping globally, not per port. Find the
 	 * configuration that contains all configured timestamping requests.
 	 */
 	for (i = 1; i < mlxsw_core_max_ports(mlxsw_sp->core); i++) {
 		tmp = mlxsw_sp->ports[i];
+		if (tmp) {
+			orig_ing_types |= tmp->ptp.ing_types;
+			orig_egr_types |= tmp->ptp.egr_types;
+		}
 		if (tmp && tmp != mlxsw_sp_port) {
 			ing_types |= tmp->ptp.ing_types;
 			egr_types |= tmp->ptp.egr_types;
 		}
 	}
 
+	if ((ing_types || egr_types) && !(orig_egr_types || orig_egr_types)) {
+		err = mlxsw_sp_nve_inc_parsing_depth_get(mlxsw_sp);
+		if (err) {
+			netdev_err(mlxsw_sp_port->dev, "Failed to increase parsing depth");
+			return err;
+		}
+	}
+	if (!(ing_types || egr_types) && (orig_egr_types || orig_egr_types))
+		mlxsw_sp_nve_inc_parsing_depth_put(mlxsw_sp);
+
 	return mlxsw_sp1_ptp_mtpppc_set(mlxsw_sp_port->mlxsw_sp,
 				       ing_types, egr_types);
 }
Signature · 1 line
2.21.0
maintainer
#1 lore raw

From: Ido Schimmel <[email protected]>
Date: Sat, 27 Jul 2019 20:35:32 +0300

drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port, · line 985

Quoted 8 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +3 -0
@@ -979,19 +979,36 @@ static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port,
 {
 	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 	struct mlxsw_sp_port *tmp;
+	u16 orig_ing_types = 0;
+	u16 orig_egr_types = 0;
 	int i;
+	int err;

Please preserve the reverse christmas tree here, thank you.

#2 lore raw
Quoted 13 lines · David Miller

From: Ido Schimmel <[email protected]>
Date: Sat, 27 Jul 2019 20:35:32 +0300

drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port, · line 985

Quoted 8 lines
drivers/net/ethernet/mellanox/mlxsw/spectrum_ptp.c +3 -0
@@ -979,19 +979,36 @@ static int mlxsw_sp1_ptp_mtpppc_update(struct mlxsw_sp_port *mlxsw_sp_port,
 {
 	struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
 	struct mlxsw_sp_port *tmp;
+	u16 orig_ing_types = 0;
+	u16 orig_egr_types = 0;
 	int i;
+	int err;

Please preserve the reverse christmas tree here, thank you.

All right, will respin momentarily.