Netdev List
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, richardcochran@gmail.com, jiri@mellanox.com,
	petrm@mellanox.com, mlxsw@mellanox.com,
	Ido Schimmel <idosch@mellanox.com>
Subject: [PATCH net-next v2 06/16] mlxsw: spectrum: Add support for traps specific to Spectrum-1
Date: Sun, 30 Jun 2019 09:04:50 +0300	[thread overview]
Message-ID: <20190630060500.7882-7-idosch@idosch.org> (raw)
In-Reply-To: <20190630060500.7882-1-idosch@idosch.org>

From: Petr Machata <petrm@mellanox.com>

On Spectrum-1, timestamps for PTP packets are delivered through queues
of ingress and egress timestamps. There are two event traps
corresponding to activity on each of those queues. This mechanism is
absent on Spectrum-2, and therefore the traps should only be registered
on Spectrum-1.

Carry a chip-specific listener array in mlxsw_sp->listeners and
listeners_count. Register listeners from that array in
mlxsw_sp_traps_init(). Add a new listener array for Spectrum-1 traps and
configure the newly-added mlxsw_sp->listeners with this array.

The listener array is empty for now, the events will be added in a later
patch.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 .../net/ethernet/mellanox/mlxsw/spectrum.c    | 25 +++++++++++++++++--
 .../net/ethernet/mellanox/mlxsw/spectrum.h    |  2 ++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 0119efe0ea7a..91486193454a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -4114,6 +4114,9 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 	MLXSW_SP_RXL_NO_MARK(NVE_DECAP_ARP, TRAP_TO_CPU, ARP, false),
 };
 
+static const struct mlxsw_listener mlxsw_sp1_listener[] = {
+};
+
 static int mlxsw_sp_cpu_policers_set(struct mlxsw_core *mlxsw_core)
 {
 	char qpcr_pl[MLXSW_REG_QPCR_LEN];
@@ -4302,12 +4305,28 @@ static int mlxsw_sp_traps_init(struct mlxsw_sp *mlxsw_sp)
 	if (err)
 		return err;
 
-	return mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp_listener,
-				       ARRAY_SIZE(mlxsw_sp_listener));
+	err = mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp_listener,
+				      ARRAY_SIZE(mlxsw_sp_listener));
+	if (err)
+		return err;
+
+	err = mlxsw_sp_traps_register(mlxsw_sp, mlxsw_sp->listeners,
+				      mlxsw_sp->listeners_count);
+	if (err)
+		goto err_extra_traps_init;
+
+	return 0;
+
+err_extra_traps_init:
+	mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp_listener,
+				  ARRAY_SIZE(mlxsw_sp_listener));
+	return err;
 }
 
 static void mlxsw_sp_traps_fini(struct mlxsw_sp *mlxsw_sp)
 {
+	mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp->listeners,
+				  mlxsw_sp->listeners_count);
 	mlxsw_sp_traps_unregister(mlxsw_sp, mlxsw_sp_listener,
 				  ARRAY_SIZE(mlxsw_sp_listener));
 }
@@ -4566,6 +4585,8 @@ static int mlxsw_sp1_init(struct mlxsw_core *mlxsw_core,
 	mlxsw_sp->sb_vals = &mlxsw_sp1_sb_vals;
 	mlxsw_sp->port_type_speed_ops = &mlxsw_sp1_port_type_speed_ops;
 	mlxsw_sp->ptp_ops = &mlxsw_sp1_ptp_ops;
+	mlxsw_sp->listeners = mlxsw_sp1_listener;
+	mlxsw_sp->listeners_count = ARRAY_SIZE(mlxsw_sp1_listener);
 
 	return mlxsw_sp_init(mlxsw_core, mlxsw_bus_info);
 }
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 84f4276193b3..9136a86dc55f 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -175,6 +175,8 @@ struct mlxsw_sp {
 	const struct mlxsw_sp_sb_vals *sb_vals;
 	const struct mlxsw_sp_port_type_speed_ops *port_type_speed_ops;
 	const struct mlxsw_sp_ptp_ops *ptp_ops;
+	const struct mlxsw_listener *listeners;
+	size_t listeners_count;
 };
 
 static inline struct mlxsw_sp_upper *
-- 
2.20.1


  parent reply	other threads:[~2019-06-30  6:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-30  6:04 [PATCH net-next v2 00/16] mlxsw: PTP timestamping support Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 01/16] mlxsw: reg: Add Monitoring Time Precision Packet Port Configuration Register Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 02/16] mlxsw: reg: Add Monitoring Precision Time Protocol Trap Register Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 03/16] mlxsw: reg: Add Time Precision Packet Timestamping Reading Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 04/16] mlxsw: reg: Add Monitoring Global Configuration Register Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 05/16] mlxsw: spectrum: Extract a helper for trap registration Ido Schimmel
2019-06-30  6:04 ` Ido Schimmel [this message]
2019-06-30  6:04 ` [PATCH net-next v2 07/16] mlxsw: spectrum: PTP: Hook into packet receive path Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 08/16] mlxsw: core: Add support for using SKB control buffer Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 09/16] mlxsw: pci: PTP: Hook into packet transmit path Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 10/16] mlxsw: spectrum: PTP: Add PTP initialization / finalization Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 11/16] mlxsw: spectrum: PTP: Disable BH when working with PHC Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 12/16] mlxsw: spectrum: PTP: Support timestamping on Spectrum-1 Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 13/16] mlxsw: spectrum: PTP: Garbage-collect unmatched entries Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 14/16] mlxsw: spectrum: PTP: Configure PTP traps and FIFO events Ido Schimmel
2019-06-30  6:04 ` [PATCH net-next v2 15/16] mlxsw: spectrum: PTP: Support SIOCGHWTSTAMP, SIOCSHWTSTAMP ioctls Ido Schimmel
2019-06-30  6:05 ` [PATCH net-next v2 16/16] mlxsw: spectrum: PTP: Support ethtool get_ts_info Ido Schimmel
2019-07-02  1:59 ` [PATCH net-next v2 00/16] mlxsw: PTP timestamping support David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190630060500.7882-7-idosch@idosch.org \
    --to=idosch@idosch.org \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=petrm@mellanox.com \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox