Skip to content

Commit d5a1c74

Browse files
jpirkodavem330
authored andcommitted
mlxsw: reg: Add Router Algorithmic LPM Unicast Entry Register definition
Serves for adding, updating and removing fib entries. Signed-off-by: Jiri Pirko <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6b75c48 commit d5a1c74

File tree

1 file changed

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

1 file changed

+264
-0
lines changed

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

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,6 +3622,268 @@ static inline void mlxsw_reg_raltb_pack(char *payload, u16 virtual_router,
36223622
mlxsw_reg_raltb_tree_id_set(payload, tree_id);
36233623
}
36243624

3625+
/* RALUE - Router Algorithmic LPM Unicast Entry Register
3626+
* -----------------------------------------------------
3627+
* RALUE is used to configure and query LPM entries that serve
3628+
* the Unicast protocols.
3629+
*/
3630+
#define MLXSW_REG_RALUE_ID 0x8013
3631+
#define MLXSW_REG_RALUE_LEN 0x38
3632+
3633+
static const struct mlxsw_reg_info mlxsw_reg_ralue = {
3634+
.id = MLXSW_REG_RALUE_ID,
3635+
.len = MLXSW_REG_RALUE_LEN,
3636+
};
3637+
3638+
/* reg_ralue_protocol
3639+
* Protocol.
3640+
* Access: Index
3641+
*/
3642+
MLXSW_ITEM32(reg, ralue, protocol, 0x00, 24, 4);
3643+
3644+
enum mlxsw_reg_ralue_op {
3645+
/* Read operation. If entry doesn't exist, the operation fails. */
3646+
MLXSW_REG_RALUE_OP_QUERY_READ = 0,
3647+
/* Clear on read operation. Used to read entry and
3648+
* clear Activity bit.
3649+
*/
3650+
MLXSW_REG_RALUE_OP_QUERY_CLEAR = 1,
3651+
/* Write operation. Used to write a new entry to the table. All RW
3652+
* fields are written for new entry. Activity bit is set
3653+
* for new entries.
3654+
*/
3655+
MLXSW_REG_RALUE_OP_WRITE_WRITE = 0,
3656+
/* Update operation. Used to update an existing route entry and
3657+
* only update the RW fields that are detailed in the field
3658+
* op_u_mask. If entry doesn't exist, the operation fails.
3659+
*/
3660+
MLXSW_REG_RALUE_OP_WRITE_UPDATE = 1,
3661+
/* Clear activity. The Activity bit (the field a) is cleared
3662+
* for the entry.
3663+
*/
3664+
MLXSW_REG_RALUE_OP_WRITE_CLEAR = 2,
3665+
/* Delete operation. Used to delete an existing entry. If entry
3666+
* doesn't exist, the operation fails.
3667+
*/
3668+
MLXSW_REG_RALUE_OP_WRITE_DELETE = 3,
3669+
};
3670+
3671+
/* reg_ralue_op
3672+
* Operation.
3673+
* Access: OP
3674+
*/
3675+
MLXSW_ITEM32(reg, ralue, op, 0x00, 20, 3);
3676+
3677+
/* reg_ralue_a
3678+
* Activity. Set for new entries. Set if a packet lookup has hit on the
3679+
* specific entry, only if the entry is a route. To clear the a bit, use
3680+
* "clear activity" op.
3681+
* Enabled by activity_dis in RGCR
3682+
* Access: RO
3683+
*/
3684+
MLXSW_ITEM32(reg, ralue, a, 0x00, 16, 1);
3685+
3686+
/* reg_ralue_virtual_router
3687+
* Virtual Router ID
3688+
* Range is 0..cap_max_virtual_routers-1
3689+
* Access: Index
3690+
*/
3691+
MLXSW_ITEM32(reg, ralue, virtual_router, 0x04, 16, 16);
3692+
3693+
#define MLXSW_REG_RALUE_OP_U_MASK_ENTRY_TYPE BIT(0)
3694+
#define MLXSW_REG_RALUE_OP_U_MASK_BMP_LEN BIT(1)
3695+
#define MLXSW_REG_RALUE_OP_U_MASK_ACTION BIT(2)
3696+
3697+
/* reg_ralue_op_u_mask
3698+
* opcode update mask.
3699+
* On read operation, this field is reserved.
3700+
* This field is valid for update opcode, otherwise - reserved.
3701+
* This field is a bitmask of the fields that should be updated.
3702+
* Access: WO
3703+
*/
3704+
MLXSW_ITEM32(reg, ralue, op_u_mask, 0x04, 8, 3);
3705+
3706+
/* reg_ralue_prefix_len
3707+
* Number of bits in the prefix of the LPM route.
3708+
* Note that for IPv6 prefixes, if prefix_len>64 the entry consumes
3709+
* two entries in the physical HW table.
3710+
* Access: Index
3711+
*/
3712+
MLXSW_ITEM32(reg, ralue, prefix_len, 0x08, 0, 8);
3713+
3714+
/* reg_ralue_dip*
3715+
* The prefix of the route or of the marker that the object of the LPM
3716+
* is compared with. The most significant bits of the dip are the prefix.
3717+
* The list significant bits must be '0' if the prefix_len is smaller
3718+
* than 128 for IPv6 or smaller than 32 for IPv4.
3719+
* IPv4 address uses bits dip[31:0] and bits dip[127:32] are reserved.
3720+
* Access: Index
3721+
*/
3722+
MLXSW_ITEM32(reg, ralue, dip4, 0x18, 0, 32);
3723+
3724+
enum mlxsw_reg_ralue_entry_type {
3725+
MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_ENTRY = 1,
3726+
MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY = 2,
3727+
MLXSW_REG_RALUE_ENTRY_TYPE_MARKER_AND_ROUTE_ENTRY = 3,
3728+
};
3729+
3730+
/* reg_ralue_entry_type
3731+
* Entry type.
3732+
* Note - for Marker entries, the action_type and action fields are reserved.
3733+
* Access: RW
3734+
*/
3735+
MLXSW_ITEM32(reg, ralue, entry_type, 0x1C, 30, 2);
3736+
3737+
/* reg_ralue_bmp_len
3738+
* The best match prefix length in the case that there is no match for
3739+
* longer prefixes.
3740+
* If (entry_type != MARKER_ENTRY), bmp_len must be equal to prefix_len
3741+
* Note for any update operation with entry_type modification this
3742+
* field must be set.
3743+
* Access: RW
3744+
*/
3745+
MLXSW_ITEM32(reg, ralue, bmp_len, 0x1C, 16, 8);
3746+
3747+
enum mlxsw_reg_ralue_action_type {
3748+
MLXSW_REG_RALUE_ACTION_TYPE_REMOTE,
3749+
MLXSW_REG_RALUE_ACTION_TYPE_LOCAL,
3750+
MLXSW_REG_RALUE_ACTION_TYPE_IP2ME,
3751+
};
3752+
3753+
/* reg_ralue_action_type
3754+
* Action Type
3755+
* Indicates how the IP address is connected.
3756+
* It can be connected to a local subnet through local_erif or can be
3757+
* on a remote subnet connected through a next-hop router,
3758+
* or transmitted to the CPU.
3759+
* Reserved when entry_type = MARKER_ENTRY
3760+
* Access: RW
3761+
*/
3762+
MLXSW_ITEM32(reg, ralue, action_type, 0x1C, 0, 2);
3763+
3764+
enum mlxsw_reg_ralue_trap_action {
3765+
MLXSW_REG_RALUE_TRAP_ACTION_NOP,
3766+
MLXSW_REG_RALUE_TRAP_ACTION_TRAP,
3767+
MLXSW_REG_RALUE_TRAP_ACTION_MIRROR_TO_CPU,
3768+
MLXSW_REG_RALUE_TRAP_ACTION_MIRROR,
3769+
MLXSW_REG_RALUE_TRAP_ACTION_DISCARD_ERROR,
3770+
};
3771+
3772+
/* reg_ralue_trap_action
3773+
* Trap action.
3774+
* For IP2ME action, only NOP and MIRROR are possible.
3775+
* Access: RW
3776+
*/
3777+
MLXSW_ITEM32(reg, ralue, trap_action, 0x20, 28, 4);
3778+
3779+
/* reg_ralue_trap_id
3780+
* Trap ID to be reported to CPU.
3781+
* Trap ID is RTR_INGRESS0 or RTR_INGRESS1.
3782+
* For trap_action of NOP, MIRROR and DISCARD_ERROR, trap_id is reserved.
3783+
* Access: RW
3784+
*/
3785+
MLXSW_ITEM32(reg, ralue, trap_id, 0x20, 0, 9);
3786+
3787+
/* reg_ralue_adjacency_index
3788+
* Points to the first entry of the group-based ECMP.
3789+
* Only relevant in case of REMOTE action.
3790+
* Access: RW
3791+
*/
3792+
MLXSW_ITEM32(reg, ralue, adjacency_index, 0x24, 0, 24);
3793+
3794+
/* reg_ralue_ecmp_size
3795+
* Amount of sequential entries starting
3796+
* from the adjacency_index (the number of ECMPs).
3797+
* The valid range is 1-64, 512, 1024, 2048 and 4096.
3798+
* Reserved when trap_action is TRAP or DISCARD_ERROR.
3799+
* Only relevant in case of REMOTE action.
3800+
* Access: RW
3801+
*/
3802+
MLXSW_ITEM32(reg, ralue, ecmp_size, 0x28, 0, 13);
3803+
3804+
/* reg_ralue_local_erif
3805+
* Egress Router Interface.
3806+
* Only relevant in case of LOCAL action.
3807+
* Access: RW
3808+
*/
3809+
MLXSW_ITEM32(reg, ralue, local_erif, 0x24, 0, 16);
3810+
3811+
/* reg_ralue_v
3812+
* Valid bit for the tunnel_ptr field.
3813+
* If valid = 0 then trap to CPU as IP2ME trap ID.
3814+
* If valid = 1 and the packet format allows NVE or IPinIP tunnel
3815+
* decapsulation then tunnel decapsulation is done.
3816+
* If valid = 1 and packet format does not allow NVE or IPinIP tunnel
3817+
* decapsulation then trap as IP2ME trap ID.
3818+
* Only relevant in case of IP2ME action.
3819+
* Access: RW
3820+
*/
3821+
MLXSW_ITEM32(reg, ralue, v, 0x24, 31, 1);
3822+
3823+
/* reg_ralue_tunnel_ptr
3824+
* Tunnel Pointer for NVE or IPinIP tunnel decapsulation.
3825+
* For Spectrum, pointer to KVD Linear.
3826+
* Only relevant in case of IP2ME action.
3827+
* Access: RW
3828+
*/
3829+
MLXSW_ITEM32(reg, ralue, tunnel_ptr, 0x24, 0, 24);
3830+
3831+
static inline void mlxsw_reg_ralue_pack(char *payload,
3832+
enum mlxsw_reg_ralxx_protocol protocol,
3833+
enum mlxsw_reg_ralue_op op,
3834+
u16 virtual_router, u8 prefix_len)
3835+
{
3836+
MLXSW_REG_ZERO(ralue, payload);
3837+
mlxsw_reg_ralue_protocol_set(payload, protocol);
3838+
mlxsw_reg_ralue_virtual_router_set(payload, virtual_router);
3839+
mlxsw_reg_ralue_prefix_len_set(payload, prefix_len);
3840+
mlxsw_reg_ralue_entry_type_set(payload,
3841+
MLXSW_REG_RALUE_ENTRY_TYPE_ROUTE_ENTRY);
3842+
mlxsw_reg_ralue_bmp_len_set(payload, prefix_len);
3843+
}
3844+
3845+
static inline void mlxsw_reg_ralue_pack4(char *payload,
3846+
enum mlxsw_reg_ralxx_protocol protocol,
3847+
enum mlxsw_reg_ralue_op op,
3848+
u16 virtual_router, u8 prefix_len,
3849+
u32 dip)
3850+
{
3851+
mlxsw_reg_ralue_pack(payload, protocol, op, virtual_router, prefix_len);
3852+
mlxsw_reg_ralue_dip4_set(payload, dip);
3853+
}
3854+
3855+
static inline void
3856+
mlxsw_reg_ralue_act_remote_pack(char *payload,
3857+
enum mlxsw_reg_ralue_trap_action trap_action,
3858+
u16 trap_id, u32 adjacency_index, u16 ecmp_size)
3859+
{
3860+
mlxsw_reg_ralue_action_type_set(payload,
3861+
MLXSW_REG_RALUE_ACTION_TYPE_REMOTE);
3862+
mlxsw_reg_ralue_trap_action_set(payload, trap_action);
3863+
mlxsw_reg_ralue_trap_id_set(payload, trap_id);
3864+
mlxsw_reg_ralue_adjacency_index_set(payload, adjacency_index);
3865+
mlxsw_reg_ralue_ecmp_size_set(payload, ecmp_size);
3866+
}
3867+
3868+
static inline void
3869+
mlxsw_reg_ralue_act_local_pack(char *payload,
3870+
enum mlxsw_reg_ralue_trap_action trap_action,
3871+
u16 trap_id, u16 local_erif)
3872+
{
3873+
mlxsw_reg_ralue_action_type_set(payload,
3874+
MLXSW_REG_RALUE_ACTION_TYPE_LOCAL);
3875+
mlxsw_reg_ralue_trap_action_set(payload, trap_action);
3876+
mlxsw_reg_ralue_trap_id_set(payload, trap_id);
3877+
mlxsw_reg_ralue_local_erif_set(payload, local_erif);
3878+
}
3879+
3880+
static inline void
3881+
mlxsw_reg_ralue_act_ip2me_pack(char *payload)
3882+
{
3883+
mlxsw_reg_ralue_action_type_set(payload,
3884+
MLXSW_REG_RALUE_ACTION_TYPE_IP2ME);
3885+
}
3886+
36253887
/* MFCR - Management Fan Control Register
36263888
* --------------------------------------
36273889
* This register controls the settings of the Fan Speed PWM mechanism.
@@ -4370,6 +4632,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
43704632
return "RALST";
43714633
case MLXSW_REG_RALTB_ID:
43724634
return "RALTB";
4635+
case MLXSW_REG_RALUE_ID:
4636+
return "RALUE";
43734637
case MLXSW_REG_MFCR_ID:
43744638
return "MFCR";
43754639
case MLXSW_REG_MFSC_ID:

0 commit comments

Comments
 (0)