Skip to content

Commit b2383ad

Browse files
chelsiocudbgdavem330
authored andcommitted
cxgb4: reject overlapped queues in TC-MQPRIO offload
A queue can't belong to multiple traffic classes. So, reject any such configuration that results in overlapped queues for a traffic class. Fixes: b1396c2 ("cxgb4: parse and configure TC-MQPRIO offload") Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c856e2b commit b2383ad

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ static int cxgb4_mqprio_validate(struct net_device *dev,
1212
struct port_info *pi = netdev2pinfo(dev);
1313
struct adapter *adap = netdev2adap(dev);
1414
u32 speed, qcount = 0, qoffset = 0;
15+
u32 start_a, start_b, end_a, end_b;
1516
int ret;
16-
u8 i;
17+
u8 i, j;
1718

1819
if (!mqprio->qopt.num_tc)
1920
return 0;
@@ -47,6 +48,31 @@ static int cxgb4_mqprio_validate(struct net_device *dev,
4748
qoffset = max_t(u16, mqprio->qopt.offset[i], qoffset);
4849
qcount += mqprio->qopt.count[i];
4950

51+
start_a = mqprio->qopt.offset[i];
52+
end_a = start_a + mqprio->qopt.count[i] - 1;
53+
for (j = i + 1; j < mqprio->qopt.num_tc; j++) {
54+
start_b = mqprio->qopt.offset[j];
55+
end_b = start_b + mqprio->qopt.count[j] - 1;
56+
57+
/* If queue count is 0, then the traffic
58+
* belonging to this class will not use
59+
* ETHOFLD queues. So, no need to validate
60+
* further.
61+
*/
62+
if (!mqprio->qopt.count[i])
63+
break;
64+
65+
if (!mqprio->qopt.count[j])
66+
continue;
67+
68+
if (max_t(u32, start_a, start_b) <=
69+
min_t(u32, end_a, end_b)) {
70+
netdev_err(dev,
71+
"Queues can't overlap across tc\n");
72+
return -EINVAL;
73+
}
74+
}
75+
5076
/* Convert byte per second to bits per second */
5177
min_rate += (mqprio->min_rate[i] * 8);
5278
max_rate += (mqprio->max_rate[i] * 8);

0 commit comments

Comments
 (0)