Skip to content

Commit 2301905

Browse files
yotamgidavem330
authored andcommitted
mlxsw: reg: Add the Monitoring Port Analyzer register
The MPAR register is used to bind ports to a SPAN entry (which was created using MPAT register) and thus mirror their traffic (ingress / egress) to a different port. Signed-off-by: Yotam Gigi <yotamg@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>
1 parent 43a4685 commit 2301905

File tree

1 file changed

+67
-0
lines changed
  • drivers/net/ethernet/mellanox/mlxsw

1 file changed

+67
-0
lines changed

drivers/net/ethernet/mellanox/mlxsw/reg.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4675,6 +4675,16 @@ MLXSW_ITEM32(reg, mpat, e, 0x04, 31, 1);
46754675
*/
46764676
MLXSW_ITEM32(reg, mpat, qos, 0x04, 26, 1);
46774677

4678+
/* reg_mpat_be
4679+
* Best effort mode. Indicates mirroring traffic should not cause packet
4680+
* drop or back pressure, but will discard the mirrored packets. Mirrored
4681+
* packets will be forwarded on a best effort manner.
4682+
* 0: Do not discard mirrored packets
4683+
* 1: Discard mirrored packets if causing congestion
4684+
* Access: RW
4685+
*/
4686+
MLXSW_ITEM32(reg, mpat, be, 0x04, 25, 1);
4687+
46784688
static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
46794689
u16 system_port, bool e)
46804690
{
@@ -4683,6 +4693,61 @@ static inline void mlxsw_reg_mpat_pack(char *payload, u8 pa_id,
46834693
mlxsw_reg_mpat_system_port_set(payload, system_port);
46844694
mlxsw_reg_mpat_e_set(payload, e);
46854695
mlxsw_reg_mpat_qos_set(payload, 1);
4696+
mlxsw_reg_mpat_be_set(payload, 1);
4697+
}
4698+
4699+
/* MPAR - Monitoring Port Analyzer Register
4700+
* ----------------------------------------
4701+
* MPAR register is used to query and configure the port analyzer port mirroring
4702+
* properties.
4703+
*/
4704+
#define MLXSW_REG_MPAR_ID 0x901B
4705+
#define MLXSW_REG_MPAR_LEN 0x08
4706+
4707+
static const struct mlxsw_reg_info mlxsw_reg_mpar = {
4708+
.id = MLXSW_REG_MPAR_ID,
4709+
.len = MLXSW_REG_MPAR_LEN,
4710+
};
4711+
4712+
/* reg_mpar_local_port
4713+
* The local port to mirror the packets from.
4714+
* Access: Index
4715+
*/
4716+
MLXSW_ITEM32(reg, mpar, local_port, 0x00, 16, 8);
4717+
4718+
enum mlxsw_reg_mpar_i_e {
4719+
MLXSW_REG_MPAR_TYPE_EGRESS,
4720+
MLXSW_REG_MPAR_TYPE_INGRESS,
4721+
};
4722+
4723+
/* reg_mpar_i_e
4724+
* Ingress/Egress
4725+
* Access: Index
4726+
*/
4727+
MLXSW_ITEM32(reg, mpar, i_e, 0x00, 0, 4);
4728+
4729+
/* reg_mpar_enable
4730+
* Enable mirroring
4731+
* By default, port mirroring is disabled for all ports.
4732+
* Access: RW
4733+
*/
4734+
MLXSW_ITEM32(reg, mpar, enable, 0x04, 31, 1);
4735+
4736+
/* reg_mpar_pa_id
4737+
* Port Analyzer ID.
4738+
* Access: RW
4739+
*/
4740+
MLXSW_ITEM32(reg, mpar, pa_id, 0x04, 0, 4);
4741+
4742+
static inline void mlxsw_reg_mpar_pack(char *payload, u8 local_port,
4743+
enum mlxsw_reg_mpar_i_e i_e,
4744+
bool enable, u8 pa_id)
4745+
{
4746+
MLXSW_REG_ZERO(mpar, payload);
4747+
mlxsw_reg_mpar_local_port_set(payload, local_port);
4748+
mlxsw_reg_mpar_enable_set(payload, enable);
4749+
mlxsw_reg_mpar_i_e_set(payload, i_e);
4750+
mlxsw_reg_mpar_pa_id_set(payload, pa_id);
46864751
}
46874752

46884753
/* MLCR - Management LED Control Register
@@ -5258,6 +5323,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
52585323
return "MTCAP";
52595324
case MLXSW_REG_MPAT_ID:
52605325
return "MPAT";
5326+
case MLXSW_REG_MPAR_ID:
5327+
return "MPAR";
52615328
case MLXSW_REG_MTMP_ID:
52625329
return "MTMP";
52635330
case MLXSW_REG_MLCR_ID:

0 commit comments

Comments
 (0)