Skip to content

Commit 27eab4c

Browse files
HoratiuVulturPaolo Abeni
authored andcommitted
net: lan966x: Make sure to insert the vlan tags also in host mode
When running these commands on DUT (and similar at the other end) ip link set dev eth0 up ip link add link eth0 name eth0.10 type vlan id 10 ip addr add 10.0.0.1/24 dev eth0.10 ip link set dev eth0.10 up ping 10.0.0.2 The ping will fail. The reason why is failing is because, the network interfaces for lan966x have a flag saying that the HW can insert the vlan tags into the frames(NETIF_F_HW_VLAN_CTAG_TX). Meaning that the frames that are transmitted don't have the vlan tag inside the skb data, but they have it inside the skb. We already get that vlan tag and put it in the IFH but the problem is that we don't configure the HW to rewrite the frame when the interface is in host mode. The fix consists in actually configuring the HW to insert the vlan tag if it is different than 0. Reviewed-by: Maxime Chevallier <[email protected]> Fixes: 6d2c186 ("net: lan966x: Add vlan support.") Signed-off-by: Horatiu Vultur <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent f65dca1 commit 27eab4c

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ static int lan966x_probe_port(struct lan966x *lan966x, u32 p,
879879
lan966x_vlan_port_set_vlan_aware(port, 0);
880880
lan966x_vlan_port_set_vid(port, HOST_PVID, false, false);
881881
lan966x_vlan_port_apply(port);
882+
lan966x_vlan_port_rew_host(port);
882883

883884
return 0;
884885
}

drivers/net/ethernet/microchip/lan966x/lan966x_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ void lan966x_vlan_port_apply(struct lan966x_port *port);
497497
bool lan966x_vlan_cpu_member_cpu_vlan_mask(struct lan966x *lan966x, u16 vid);
498498
void lan966x_vlan_port_set_vlan_aware(struct lan966x_port *port,
499499
bool vlan_aware);
500+
void lan966x_vlan_port_rew_host(struct lan966x_port *port);
500501
int lan966x_vlan_port_set_vid(struct lan966x_port *port,
501502
u16 vid,
502503
bool pvid,

drivers/net/ethernet/microchip/lan966x/lan966x_switchdev.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ static void lan966x_port_bridge_leave(struct lan966x_port *port,
297297
lan966x_vlan_port_set_vlan_aware(port, false);
298298
lan966x_vlan_port_set_vid(port, HOST_PVID, false, false);
299299
lan966x_vlan_port_apply(port);
300+
lan966x_vlan_port_rew_host(port);
300301
}
301302

302303
int lan966x_port_changeupper(struct net_device *dev,

drivers/net/ethernet/microchip/lan966x/lan966x_vlan.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@ void lan966x_vlan_port_set_vlan_aware(struct lan966x_port *port,
149149
port->vlan_aware = vlan_aware;
150150
}
151151

152+
/* When the interface is in host mode, the interface should not be vlan aware
153+
* but it should insert all the tags that it gets from the network stack.
154+
* The tags are not in the data of the frame but actually in the skb and the ifh
155+
* is configured already to get this tag. So what we need to do is to update the
156+
* rewriter to insert the vlan tag for all frames which have a vlan tag
157+
* different than 0.
158+
*/
159+
void lan966x_vlan_port_rew_host(struct lan966x_port *port)
160+
{
161+
struct lan966x *lan966x = port->lan966x;
162+
u32 val;
163+
164+
/* Tag all frames except when VID=0*/
165+
val = REW_TAG_CFG_TAG_CFG_SET(2);
166+
167+
/* Update only some bits in the register */
168+
lan_rmw(val,
169+
REW_TAG_CFG_TAG_CFG,
170+
lan966x, REW_TAG_CFG(port->chip_port));
171+
}
172+
152173
void lan966x_vlan_port_apply(struct lan966x_port *port)
153174
{
154175
struct lan966x *lan966x = port->lan966x;

0 commit comments

Comments
 (0)