Skip to content

Commit b2e345f

Browse files
Elad Razdavem330
authored andcommitted
mlxsw: reg: Add Switch Port VID and Switch Port VLAN Membership registers definitions
Add SPVID and SPVM registers responsible for default port VID configuration and VLAN membership of a port. Signed-off-by: Elad Raz <eladr@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f5d88f5 commit b2e345f

File tree

1 file changed

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

1 file changed

+146
-0
lines changed

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

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,148 @@ static inline void mlxsw_reg_spms_vid_pack(char *payload, u16 vid,
517517
mlxsw_reg_spms_state_set(payload, vid, state);
518518
}
519519

520+
/* SPVID - Switch Port VID
521+
* -----------------------
522+
* The switch port VID configures the default VID for a port.
523+
*/
524+
#define MLXSW_REG_SPVID_ID 0x200E
525+
#define MLXSW_REG_SPVID_LEN 0x08
526+
527+
static const struct mlxsw_reg_info mlxsw_reg_spvid = {
528+
.id = MLXSW_REG_SPVID_ID,
529+
.len = MLXSW_REG_SPVID_LEN,
530+
};
531+
532+
/* reg_spvid_local_port
533+
* Local port number.
534+
* Access: Index
535+
*/
536+
MLXSW_ITEM32(reg, spvid, local_port, 0x00, 16, 8);
537+
538+
/* reg_spvid_sub_port
539+
* Virtual port within the physical port.
540+
* Should be set to 0 when virtual ports are not enabled on the port.
541+
* Access: Index
542+
*/
543+
MLXSW_ITEM32(reg, spvid, sub_port, 0x00, 8, 8);
544+
545+
/* reg_spvid_pvid
546+
* Port default VID
547+
* Access: RW
548+
*/
549+
MLXSW_ITEM32(reg, spvid, pvid, 0x04, 0, 12);
550+
551+
static inline void mlxsw_reg_spvid_pack(char *payload, u8 local_port, u16 pvid)
552+
{
553+
MLXSW_REG_ZERO(spvid, payload);
554+
mlxsw_reg_spvid_local_port_set(payload, local_port);
555+
mlxsw_reg_spvid_pvid_set(payload, pvid);
556+
}
557+
558+
/* SPVM - Switch Port VLAN Membership
559+
* ----------------------------------
560+
* The Switch Port VLAN Membership register configures the VLAN membership
561+
* of a port in a VLAN denoted by VID. VLAN membership is managed per
562+
* virtual port. The register can be used to add and remove VID(s) from a port.
563+
*/
564+
#define MLXSW_REG_SPVM_ID 0x200F
565+
#define MLXSW_REG_SPVM_BASE_LEN 0x04 /* base length, without records */
566+
#define MLXSW_REG_SPVM_REC_LEN 0x04 /* record length */
567+
#define MLXSW_REG_SPVM_REC_MAX_COUNT 256
568+
#define MLXSW_REG_SPVM_LEN (MLXSW_REG_SPVM_BASE_LEN + \
569+
MLXSW_REG_SPVM_REC_LEN * MLXSW_REG_SPVM_REC_MAX_COUNT)
570+
571+
static const struct mlxsw_reg_info mlxsw_reg_spvm = {
572+
.id = MLXSW_REG_SPVM_ID,
573+
.len = MLXSW_REG_SPVM_LEN,
574+
};
575+
576+
/* reg_spvm_pt
577+
* Priority tagged. If this bit is set, packets forwarded to the port with
578+
* untagged VLAN membership (u bit is set) will be tagged with priority tag
579+
* (VID=0)
580+
* Access: RW
581+
*/
582+
MLXSW_ITEM32(reg, spvm, pt, 0x00, 31, 1);
583+
584+
/* reg_spvm_pte
585+
* Priority Tagged Update Enable. On Write operations, if this bit is cleared,
586+
* the pt bit will NOT be updated. To update the pt bit, pte must be set.
587+
* Access: WO
588+
*/
589+
MLXSW_ITEM32(reg, spvm, pte, 0x00, 30, 1);
590+
591+
/* reg_spvm_local_port
592+
* Local port number.
593+
* Access: Index
594+
*/
595+
MLXSW_ITEM32(reg, spvm, local_port, 0x00, 16, 8);
596+
597+
/* reg_spvm_sub_port
598+
* Virtual port within the physical port.
599+
* Should be set to 0 when virtual ports are not enabled on the port.
600+
* Access: Index
601+
*/
602+
MLXSW_ITEM32(reg, spvm, sub_port, 0x00, 8, 8);
603+
604+
/* reg_spvm_num_rec
605+
* Number of records to update. Each record contains: i, e, u, vid.
606+
* Access: OP
607+
*/
608+
MLXSW_ITEM32(reg, spvm, num_rec, 0x00, 0, 8);
609+
610+
/* reg_spvm_rec_i
611+
* Ingress membership in VLAN ID.
612+
* Access: Index
613+
*/
614+
MLXSW_ITEM32_INDEXED(reg, spvm, rec_i,
615+
MLXSW_REG_SPVM_BASE_LEN, 14, 1,
616+
MLXSW_REG_SPVM_REC_LEN, 0, false);
617+
618+
/* reg_spvm_rec_e
619+
* Egress membership in VLAN ID.
620+
* Access: Index
621+
*/
622+
MLXSW_ITEM32_INDEXED(reg, spvm, rec_e,
623+
MLXSW_REG_SPVM_BASE_LEN, 13, 1,
624+
MLXSW_REG_SPVM_REC_LEN, 0, false);
625+
626+
/* reg_spvm_rec_u
627+
* Untagged - port is an untagged member - egress transmission uses untagged
628+
* frames on VID<n>
629+
* Access: Index
630+
*/
631+
MLXSW_ITEM32_INDEXED(reg, spvm, rec_u,
632+
MLXSW_REG_SPVM_BASE_LEN, 12, 1,
633+
MLXSW_REG_SPVM_REC_LEN, 0, false);
634+
635+
/* reg_spvm_rec_vid
636+
* Egress membership in VLAN ID.
637+
* Access: Index
638+
*/
639+
MLXSW_ITEM32_INDEXED(reg, spvm, rec_vid,
640+
MLXSW_REG_SPVM_BASE_LEN, 0, 12,
641+
MLXSW_REG_SPVM_REC_LEN, 0, false);
642+
643+
static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
644+
u16 vid_begin, u16 vid_end,
645+
bool is_member, bool untagged)
646+
{
647+
int size = vid_end - vid_begin + 1;
648+
int i;
649+
650+
MLXSW_REG_ZERO(spvm, payload);
651+
mlxsw_reg_spvm_local_port_set(payload, local_port);
652+
mlxsw_reg_spvm_num_rec_set(payload, size);
653+
654+
for (i = 0; i < size; i++) {
655+
mlxsw_reg_spvm_rec_i_set(payload, i, is_member);
656+
mlxsw_reg_spvm_rec_e_set(payload, i, is_member);
657+
mlxsw_reg_spvm_rec_u_set(payload, i, untagged);
658+
mlxsw_reg_spvm_rec_vid_set(payload, i, vid_begin + i);
659+
}
660+
}
661+
520662
/* SFGC - Switch Flooding Group Configuration
521663
* ------------------------------------------
522664
* The following register controls the association of flooding tables and MIDs
@@ -1570,6 +1712,10 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
15701712
return "SFN";
15711713
case MLXSW_REG_SPMS_ID:
15721714
return "SPMS";
1715+
case MLXSW_REG_SPVID_ID:
1716+
return "SPVID";
1717+
case MLXSW_REG_SPVM_ID:
1718+
return "SPVM";
15731719
case MLXSW_REG_SFGC_ID:
15741720
return "SFGC";
15751721
case MLXSW_REG_SFTR_ID:

0 commit comments

Comments
 (0)