Skip to content

Commit 39712e5

Browse files
committed
Merge branch 'mlxsw-fixes'
Jiri Pirko says: ==================== mlxsw fixes Another bulk of fixes from Ido. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 562a9f9 + 28a01d2 commit 39712e5

File tree

4 files changed

+121
-9
lines changed

4 files changed

+121
-9
lines changed

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,62 @@ static inline void mlxsw_reg_spvm_pack(char *payload, u8 local_port,
873873
}
874874
}
875875

876+
/* SPAFT - Switch Port Acceptable Frame Types
877+
* ------------------------------------------
878+
* The Switch Port Acceptable Frame Types register configures the frame
879+
* admittance of the port.
880+
*/
881+
#define MLXSW_REG_SPAFT_ID 0x2010
882+
#define MLXSW_REG_SPAFT_LEN 0x08
883+
884+
static const struct mlxsw_reg_info mlxsw_reg_spaft = {
885+
.id = MLXSW_REG_SPAFT_ID,
886+
.len = MLXSW_REG_SPAFT_LEN,
887+
};
888+
889+
/* reg_spaft_local_port
890+
* Local port number.
891+
* Access: Index
892+
*
893+
* Note: CPU port is not supported (all tag types are allowed).
894+
*/
895+
MLXSW_ITEM32(reg, spaft, local_port, 0x00, 16, 8);
896+
897+
/* reg_spaft_sub_port
898+
* Virtual port within the physical port.
899+
* Should be set to 0 when virtual ports are not enabled on the port.
900+
* Access: RW
901+
*/
902+
MLXSW_ITEM32(reg, spaft, sub_port, 0x00, 8, 8);
903+
904+
/* reg_spaft_allow_untagged
905+
* When set, untagged frames on the ingress are allowed (default).
906+
* Access: RW
907+
*/
908+
MLXSW_ITEM32(reg, spaft, allow_untagged, 0x04, 31, 1);
909+
910+
/* reg_spaft_allow_prio_tagged
911+
* When set, priority tagged frames on the ingress are allowed (default).
912+
* Access: RW
913+
*/
914+
MLXSW_ITEM32(reg, spaft, allow_prio_tagged, 0x04, 30, 1);
915+
916+
/* reg_spaft_allow_tagged
917+
* When set, tagged frames on the ingress are allowed (default).
918+
* Access: RW
919+
*/
920+
MLXSW_ITEM32(reg, spaft, allow_tagged, 0x04, 29, 1);
921+
922+
static inline void mlxsw_reg_spaft_pack(char *payload, u8 local_port,
923+
bool allow_untagged)
924+
{
925+
MLXSW_REG_ZERO(spaft, payload);
926+
mlxsw_reg_spaft_local_port_set(payload, local_port);
927+
mlxsw_reg_spaft_allow_untagged_set(payload, allow_untagged);
928+
mlxsw_reg_spaft_allow_prio_tagged_set(payload, true);
929+
mlxsw_reg_spaft_allow_tagged_set(payload, true);
930+
}
931+
876932
/* SFGC - Switch Flooding Group Configuration
877933
* ------------------------------------------
878934
* The following register controls the association of flooding tables and MIDs
@@ -3203,6 +3259,8 @@ static inline const char *mlxsw_reg_id_str(u16 reg_id)
32033259
return "SPVID";
32043260
case MLXSW_REG_SPVM_ID:
32053261
return "SPVM";
3262+
case MLXSW_REG_SPAFT_ID:
3263+
return "SPAFT";
32063264
case MLXSW_REG_SFGC_ID:
32073265
return "SFGC";
32083266
case MLXSW_REG_SFTR_ID:

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,8 @@ static int mlxsw_sp_port_bridge_leave(struct mlxsw_sp_port *mlxsw_sp_port,
21232123
if (flush_fdb && mlxsw_sp_port_fdb_flush(mlxsw_sp_port))
21242124
netdev_err(mlxsw_sp_port->dev, "Failed to flush FDB\n");
21252125

2126+
mlxsw_sp_port_pvid_set(mlxsw_sp_port, 1);
2127+
21262128
mlxsw_sp_port->learning = 0;
21272129
mlxsw_sp_port->learning_sync = 0;
21282130
mlxsw_sp_port->uc_flood = 0;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,5 +254,6 @@ int mlxsw_sp_port_kill_vid(struct net_device *dev,
254254
int mlxsw_sp_vport_flood_set(struct mlxsw_sp_port *mlxsw_sp_vport, u16 vfid,
255255
bool set, bool only_uc);
256256
void mlxsw_sp_port_active_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port);
257+
int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid);
257258

258259
#endif

drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ static int mlxsw_sp_port_attr_set(struct net_device *dev,
370370
return err;
371371
}
372372

373-
static int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
373+
static int __mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port,
374+
u16 vid)
374375
{
375376
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
376377
char spvid_pl[MLXSW_REG_SPVID_LEN];
@@ -379,6 +380,53 @@ static int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
379380
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spvid), spvid_pl);
380381
}
381382

383+
static int mlxsw_sp_port_allow_untagged_set(struct mlxsw_sp_port *mlxsw_sp_port,
384+
bool allow)
385+
{
386+
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
387+
char spaft_pl[MLXSW_REG_SPAFT_LEN];
388+
389+
mlxsw_reg_spaft_pack(spaft_pl, mlxsw_sp_port->local_port, allow);
390+
return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(spaft), spaft_pl);
391+
}
392+
393+
int mlxsw_sp_port_pvid_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid)
394+
{
395+
struct net_device *dev = mlxsw_sp_port->dev;
396+
int err;
397+
398+
if (!vid) {
399+
err = mlxsw_sp_port_allow_untagged_set(mlxsw_sp_port, false);
400+
if (err) {
401+
netdev_err(dev, "Failed to disallow untagged traffic\n");
402+
return err;
403+
}
404+
} else {
405+
err = __mlxsw_sp_port_pvid_set(mlxsw_sp_port, vid);
406+
if (err) {
407+
netdev_err(dev, "Failed to set PVID\n");
408+
return err;
409+
}
410+
411+
/* Only allow if not already allowed. */
412+
if (!mlxsw_sp_port->pvid) {
413+
err = mlxsw_sp_port_allow_untagged_set(mlxsw_sp_port,
414+
true);
415+
if (err) {
416+
netdev_err(dev, "Failed to allow untagged traffic\n");
417+
goto err_port_allow_untagged_set;
418+
}
419+
}
420+
}
421+
422+
mlxsw_sp_port->pvid = vid;
423+
return 0;
424+
425+
err_port_allow_untagged_set:
426+
__mlxsw_sp_port_pvid_set(mlxsw_sp_port, mlxsw_sp_port->pvid);
427+
return err;
428+
}
429+
382430
static int mlxsw_sp_fid_create(struct mlxsw_sp *mlxsw_sp, u16 fid)
383431
{
384432
char sfmr_pl[MLXSW_REG_SFMR_LEN];
@@ -540,7 +588,12 @@ static int __mlxsw_sp_port_vlans_add(struct mlxsw_sp_port *mlxsw_sp_port,
540588
netdev_err(dev, "Unable to add PVID %d\n", vid_begin);
541589
goto err_port_pvid_set;
542590
}
543-
mlxsw_sp_port->pvid = vid_begin;
591+
} else if (!flag_pvid && old_pvid >= vid_begin && old_pvid <= vid_end) {
592+
err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 0);
593+
if (err) {
594+
netdev_err(dev, "Unable to del PVID\n");
595+
goto err_port_pvid_set;
596+
}
544597
}
545598

546599
/* Changing activity bits only if HW operation succeded */
@@ -892,20 +945,18 @@ static int __mlxsw_sp_port_vlans_del(struct mlxsw_sp_port *mlxsw_sp_port,
892945
return err;
893946
}
894947

948+
if (init)
949+
goto out;
950+
895951
pvid = mlxsw_sp_port->pvid;
896-
if (pvid >= vid_begin && pvid <= vid_end && pvid != 1) {
897-
/* Default VLAN is always 1 */
898-
err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 1);
952+
if (pvid >= vid_begin && pvid <= vid_end) {
953+
err = mlxsw_sp_port_pvid_set(mlxsw_sp_port, 0);
899954
if (err) {
900955
netdev_err(dev, "Unable to del PVID %d\n", pvid);
901956
return err;
902957
}
903-
mlxsw_sp_port->pvid = 1;
904958
}
905959

906-
if (init)
907-
goto out;
908-
909960
err = __mlxsw_sp_port_flood_set(mlxsw_sp_port, vid_begin, vid_end,
910961
false, false);
911962
if (err) {

0 commit comments

Comments
 (0)