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: b1396c2bd675 ("cxgb4: parse and configure TC-MQPRIO offload")
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Rahul Lakkireddy and committed by David S. Miller b2383ad9 c856e2b6

Changed files
+27 -1
drivers
net
ethernet
chelsio
+27 -1
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c
··· 12 12 struct port_info *pi = netdev2pinfo(dev); 13 13 struct adapter *adap = netdev2adap(dev); 14 14 u32 speed, qcount = 0, qoffset = 0; 15 + u32 start_a, start_b, end_a, end_b; 15 16 int ret; 16 - u8 i; 17 + u8 i, j; 17 18 18 19 if (!mqprio->qopt.num_tc) 19 20 return 0; ··· 47 46 for (i = 0; i < mqprio->qopt.num_tc; i++) { 48 47 qoffset = max_t(u16, mqprio->qopt.offset[i], qoffset); 49 48 qcount += mqprio->qopt.count[i]; 49 + 50 + start_a = mqprio->qopt.offset[i]; 51 + end_a = start_a + mqprio->qopt.count[i] - 1; 52 + for (j = i + 1; j < mqprio->qopt.num_tc; j++) { 53 + start_b = mqprio->qopt.offset[j]; 54 + end_b = start_b + mqprio->qopt.count[j] - 1; 55 + 56 + /* If queue count is 0, then the traffic 57 + * belonging to this class will not use 58 + * ETHOFLD queues. So, no need to validate 59 + * further. 60 + */ 61 + if (!mqprio->qopt.count[i]) 62 + break; 63 + 64 + if (!mqprio->qopt.count[j]) 65 + continue; 66 + 67 + if (max_t(u32, start_a, start_b) <= 68 + min_t(u32, end_a, end_b)) { 69 + netdev_err(dev, 70 + "Queues can't overlap across tc\n"); 71 + return -EINVAL; 72 + } 73 + } 50 74 51 75 /* Convert byte per second to bits per second */ 52 76 min_rate += (mqprio->min_rate[i] * 8);