netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, yotamg@mellanox.com, idosch@mellanox.com,
	eladr@mellanox.com, nogahf@mellanox.com, ogerlitz@mellanox.com,
	jhs@mojatatu.com, geert+renesas@glider.be,
	stephen@networkplumber.org, xiyou.wangcong@gmail.com,
	linux@roeck-us.net
Subject: [patch net-next RFC 5/6] mlxsw: reg: add the Monitoring Packet Sampling Configuration Register
Date: Wed, 12 Oct 2016 14:41:08 +0200	[thread overview]
Message-ID: <1476276069-5315-6-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1476276069-5315-1-git-send-email-jiri@resnulli.us>

From: Yotam Gigi <yotam.gi@gmail.com>

The MPSC register allows to configure ingress packet sampling on specific
port of the mlxsw device. The sampled packets are then trapped via
PKT_SAMPLE trap.

Signed-off-by: Yotam Gigi <yotamg@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/reg.h | 43 +++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h
index 6460c72..e657865 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h
@@ -4832,6 +4832,47 @@ static inline void mlxsw_reg_mlcr_pack(char *payload, u8 local_port,
 					   MLXSW_REG_MLCR_DURATION_MAX : 0);
 }
 
+/* MPSC - Monitoring Packet Sampling Configuration Register
+ * --------------------------------------------------------
+ * MPSC Register is used to configure the Packet Sampling mechanism.
+ */
+#define MLXSW_REG_MPSC_ID 0x9080
+#define MLXSW_REG_MPSC_LEN 0x14
+
+static const struct mlxsw_reg_info mlxsw_reg_mpsc = {
+	.id = MLXSW_REG_MPSC_ID,
+	.len = MLXSW_REG_MPSC_LEN,
+};
+
+/* reg_mpsc_local_port
+ * Local port number
+ * Not supported for CPU port
+ * Access: Index
+ */
+MLXSW_ITEM32(reg, mpsc, local_port, 0x00, 16, 8);
+
+/* reg_mpsc_e
+ * Enable sampling on port local_port
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mpsc, e, 0x04, 30, 1);
+
+/* reg_mpsc_rate
+ * Sampling rate = 1 out of rate packets (with randomization around
+ * the point). Valid values are: 1 to 3.5*10^9
+ * Access: RW
+ */
+MLXSW_ITEM32(reg, mpsc, rate, 0x08, 0, 32);
+
+static inline void mlxsw_reg_mpsc_pack(char *payload, u8 local_port, bool e,
+				       u32 rate)
+{
+	MLXSW_REG_ZERO(mpsc, payload);
+	mlxsw_reg_mpsc_local_port_set(payload, local_port);
+	mlxsw_reg_mpsc_e_set(payload, e);
+	mlxsw_reg_mpsc_rate_set(payload, rate);
+}
+
 /* SBPR - Shared Buffer Pools Register
  * -----------------------------------
  * The SBPR configures and retrieves the shared buffer pools and configuration.
@@ -5367,6 +5408,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
 		return "MTMP";
 	case MLXSW_REG_MLCR_ID:
 		return "MLCR";
+	case MLXSW_REG_MPSC_ID:
+		return "MPSC";
 	case MLXSW_REG_SBPR_ID:
 		return "SBPR";
 	case MLXSW_REG_SBCM_ID:
-- 
2.5.5

  parent reply	other threads:[~2016-10-12 12:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 12:41 [patch net-next RFC 0/6] Add support for offloading packet-sampling Jiri Pirko
2016-10-12 12:41 ` [patch net-next RFC 1/6] Introduce ife encapsulation module Jiri Pirko
2016-10-12 12:41 ` [patch net-next RFC 2/6] act_ife: Change to use ife module Jiri Pirko
2016-10-12 12:41 ` [patch net-next RFC 3/6] ife: Introduce new metadata tlv types Jiri Pirko
2016-10-12 12:41 ` [patch net-next RFC 4/6] Introduce sample tc action Jiri Pirko
2016-10-15 16:34   ` Roopa Prabhu
2016-10-15 17:31     ` Roopa Prabhu
2016-10-17 10:10     ` Jamal Hadi Salim
2016-10-18  0:17       ` Roopa Prabhu
2016-10-18  5:07         ` Roopa Prabhu
2016-10-18 10:58         ` Yotam Gigi
2016-10-19  7:33           ` Roopa Prabhu
2016-10-19  8:28             ` Yotam Gigi
2016-10-16 10:27   ` Or Gerlitz
2016-10-18  8:33     ` Yotam Gigi
2016-10-12 12:41 ` Jiri Pirko [this message]
2016-10-12 12:41 ` [patch net-next RFC 6/6] mlxsw: packet sample: Add packet sample offloading support Jiri Pirko
2016-10-13  7:29 ` [patch net-next RFC 0/6] Add support for offloading packet-sampling Roopa Prabhu
2016-10-13  8:48   ` Jiri Pirko
2016-10-13 11:49     ` Jamal Hadi Salim
2016-10-13 12:10       ` Jiri Pirko
2016-10-13 12:30         ` Jamal Hadi Salim
2016-10-13 12:45           ` Jiri Pirko
2016-10-14  5:02             ` Roopa Prabhu

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=1476276069-5315-6-git-send-email-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=eladr@mellanox.com \
    --cc=geert+renesas@glider.be \
    --cc=idosch@mellanox.com \
    --cc=jhs@mojatatu.com \
    --cc=linux@roeck-us.net \
    --cc=netdev@vger.kernel.org \
    --cc=nogahf@mellanox.com \
    --cc=ogerlitz@mellanox.com \
    --cc=stephen@networkplumber.org \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yotamg@mellanox.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;
as well as URLs for NNTP newsgroup(s).