Skip to content

Commit e1b9e80

Browse files
vladimirolteandavem330
authored andcommitted
net: mscc: ocelot: fix QoS class for injected packets with "ocelot-8021q"
There are 2 distinct code paths (listed below) in the source code which set up an injection header for Ocelot(-like) switches. Code path (2) lacks the QoS class and source port being set correctly. Especially the improper QoS classification is a problem for the "ocelot-8021q" alternative DSA tagging protocol, because we support tc-taprio and each packet needs to be scheduled precisely through its time slot. This includes PTP, which is normally assigned to a traffic class other than 0, but would be sent through TC 0 nonetheless. The code paths are: (1) ocelot_xmit_common() from net/dsa/tag_ocelot.c - called only by the standard "ocelot" DSA tagging protocol which uses NPI-based injection - sets up bit fields in the tag manually to account for a small difference (destination port offset) between Ocelot and Seville. Namely, ocelot_ifh_set_dest() is omitted out of ocelot_xmit_common(), because there's also seville_ifh_set_dest(). (2) ocelot_ifh_set_basic(), called by: - ocelot_fdma_prepare_skb() for FDMA transmission of the ocelot switchdev driver - ocelot_port_xmit() -> ocelot_port_inject_frame() for register-based transmission of the ocelot switchdev driver - felix_port_deferred_xmit() -> ocelot_port_inject_frame() for the DSA tagger ocelot-8021q when it must transmit PTP frames (also through register-based injection). sets the bit fields according to its own logic. The problem is that (2) doesn't call ocelot_ifh_set_qos_class(). Copying that logic from ocelot_xmit_common() fixes that. Unfortunately, although desirable, it is not easily possible to de-duplicate code paths (1) and (2), and make net/dsa/tag_ocelot.c directly call ocelot_ifh_set_basic()), because of the ocelot/seville difference. This is the "minimal" fix with some logic duplicated (but at least more consolidated). Fixes: 0a6f17c ("net: dsa: tag_ocelot_8021q: add support for PTP timestamping") Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 67c3ca2 commit e1b9e80

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,13 +1208,21 @@ void ocelot_ifh_set_basic(void *ifh, struct ocelot *ocelot, int port,
12081208
u32 rew_op, struct sk_buff *skb)
12091209
{
12101210
struct ocelot_port *ocelot_port = ocelot->ports[port];
1211+
struct net_device *dev = skb->dev;
12111212
u64 vlan_tci, tag_type;
1213+
int qos_class;
12121214

12131215
ocelot_xmit_get_vlan_info(skb, ocelot_port->bridge, &vlan_tci,
12141216
&tag_type);
12151217

1218+
qos_class = netdev_get_num_tc(dev) ?
1219+
netdev_get_prio_tc_map(dev, skb->priority) : skb->priority;
1220+
1221+
memset(ifh, 0, OCELOT_TAG_LEN);
12161222
ocelot_ifh_set_bypass(ifh, 1);
1223+
ocelot_ifh_set_src(ifh, BIT_ULL(ocelot->num_phys_ports));
12171224
ocelot_ifh_set_dest(ifh, BIT_ULL(port));
1225+
ocelot_ifh_set_qos_class(ifh, qos_class);
12181226
ocelot_ifh_set_tag_type(ifh, tag_type);
12191227
ocelot_ifh_set_vlan_tci(ifh, vlan_tci);
12201228
if (rew_op)
@@ -1225,7 +1233,7 @@ EXPORT_SYMBOL(ocelot_ifh_set_basic);
12251233
void ocelot_port_inject_frame(struct ocelot *ocelot, int port, int grp,
12261234
u32 rew_op, struct sk_buff *skb)
12271235
{
1228-
u32 ifh[OCELOT_TAG_LEN / 4] = {0};
1236+
u32 ifh[OCELOT_TAG_LEN / 4];
12291237
unsigned int i, count, last;
12301238

12311239
ocelot_write_rix(ocelot, QS_INJ_CTRL_GAP_SIZE(1) |

drivers/net/ethernet/mscc/ocelot_fdma.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ static int ocelot_fdma_prepare_skb(struct ocelot *ocelot, int port, u32 rew_op,
665665

666666
ifh = skb_push(skb, OCELOT_TAG_LEN);
667667
skb_put(skb, ETH_FCS_LEN);
668-
memset(ifh, 0, OCELOT_TAG_LEN);
669668
ocelot_ifh_set_basic(ifh, ocelot, port, rew_op, skb);
670669

671670
return 0;

0 commit comments

Comments
 (0)