Skip to content

Commit 41b9eff

Browse files
committed
Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue
Tony Nguyen says: ==================== Intel Wired LAN Driver Updates 2023-07-05 (ice) This series contains updates to ice driver only. Sridhar fixes incorrect comparison of max Tx rate limit to occur against each TC value rather than the aggregate. He also resolves an issue with the wrong VSI being used when setting max Tx rate when TCs are enabled. * '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue: ice: Fix tx queue rate limit when TCs are configured ice: Fix max_rate check while configuring TX rate limits ==================== Link: https://lore.kernel.org/r/20230705201346.49370-1-anthony.l.nguyen@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 4863b57 + 479cdfe commit 41b9eff

3 files changed

Lines changed: 27 additions & 19 deletions

File tree

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5739,6 +5739,13 @@ ice_set_tx_maxrate(struct net_device *netdev, int queue_index, u32 maxrate)
57395739
q_handle = vsi->tx_rings[queue_index]->q_handle;
57405740
tc = ice_dcb_get_tc(vsi, queue_index);
57415741

5742+
vsi = ice_locate_vsi_using_queue(vsi, queue_index);
5743+
if (!vsi) {
5744+
netdev_err(netdev, "Invalid VSI for given queue %d\n",
5745+
queue_index);
5746+
return -EINVAL;
5747+
}
5748+
57425749
/* Set BW back to default, when user set maxrate to 0 */
57435750
if (!maxrate)
57445751
status = ice_cfg_q_bw_dflt_lmt(vsi->port_info, vsi->idx, tc,
@@ -7872,10 +7879,10 @@ static int
78727879
ice_validate_mqprio_qopt(struct ice_vsi *vsi,
78737880
struct tc_mqprio_qopt_offload *mqprio_qopt)
78747881
{
7875-
u64 sum_max_rate = 0, sum_min_rate = 0;
78767882
int non_power_of_2_qcount = 0;
78777883
struct ice_pf *pf = vsi->back;
78787884
int max_rss_q_cnt = 0;
7885+
u64 sum_min_rate = 0;
78797886
struct device *dev;
78807887
int i, speed;
78817888
u8 num_tc;
@@ -7891,6 +7898,7 @@ ice_validate_mqprio_qopt(struct ice_vsi *vsi,
78917898
dev = ice_pf_to_dev(pf);
78927899
vsi->ch_rss_size = 0;
78937900
num_tc = mqprio_qopt->qopt.num_tc;
7901+
speed = ice_get_link_speed_kbps(vsi);
78947902

78957903
for (i = 0; num_tc; i++) {
78967904
int qcount = mqprio_qopt->qopt.count[i];
@@ -7931,7 +7939,6 @@ ice_validate_mqprio_qopt(struct ice_vsi *vsi,
79317939
*/
79327940
max_rate = mqprio_qopt->max_rate[i];
79337941
max_rate = div_u64(max_rate, ICE_BW_KBPS_DIVISOR);
7934-
sum_max_rate += max_rate;
79357942

79367943
/* min_rate is minimum guaranteed rate and it can't be zero */
79377944
min_rate = mqprio_qopt->min_rate[i];
@@ -7944,6 +7951,12 @@ ice_validate_mqprio_qopt(struct ice_vsi *vsi,
79447951
return -EINVAL;
79457952
}
79467953

7954+
if (max_rate && max_rate > speed) {
7955+
dev_err(dev, "TC%d: max_rate(%llu Kbps) > link speed of %u Kbps\n",
7956+
i, max_rate, speed);
7957+
return -EINVAL;
7958+
}
7959+
79477960
iter_div_u64_rem(min_rate, ICE_MIN_BW_LIMIT, &rem);
79487961
if (rem) {
79497962
dev_err(dev, "TC%d: Min Rate not multiple of %u Kbps",
@@ -7981,12 +7994,6 @@ ice_validate_mqprio_qopt(struct ice_vsi *vsi,
79817994
(mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i]))
79827995
return -EINVAL;
79837996

7984-
speed = ice_get_link_speed_kbps(vsi);
7985-
if (sum_max_rate && sum_max_rate > (u64)speed) {
7986-
dev_err(dev, "Invalid max Tx rate(%llu) Kbps > speed(%u) Kbps specified\n",
7987-
sum_max_rate, speed);
7988-
return -EINVAL;
7989-
}
79907997
if (sum_min_rate && sum_min_rate > (u64)speed) {
79917998
dev_err(dev, "Invalid min Tx rate(%llu) Kbps > speed (%u) Kbps specified\n",
79927999
sum_min_rate, speed);

drivers/net/ethernet/intel/ice/ice_tc_lib.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -750,17 +750,16 @@ ice_eswitch_add_tc_fltr(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr)
750750
/**
751751
* ice_locate_vsi_using_queue - locate VSI using queue (forward to queue action)
752752
* @vsi: Pointer to VSI
753-
* @tc_fltr: Pointer to tc_flower_filter
753+
* @queue: Queue index
754754
*
755-
* Locate the VSI using specified queue. When ADQ is not enabled, always
756-
* return input VSI, otherwise locate corresponding VSI based on per channel
757-
* offset and qcount
755+
* Locate the VSI using specified "queue". When ADQ is not enabled,
756+
* always return input VSI, otherwise locate corresponding
757+
* VSI based on per channel "offset" and "qcount"
758758
*/
759-
static struct ice_vsi *
760-
ice_locate_vsi_using_queue(struct ice_vsi *vsi,
761-
struct ice_tc_flower_fltr *tc_fltr)
759+
struct ice_vsi *
760+
ice_locate_vsi_using_queue(struct ice_vsi *vsi, int queue)
762761
{
763-
int num_tc, tc, queue;
762+
int num_tc, tc;
764763

765764
/* if ADQ is not active, passed VSI is the candidate VSI */
766765
if (!ice_is_adq_active(vsi->back))
@@ -770,7 +769,6 @@ ice_locate_vsi_using_queue(struct ice_vsi *vsi,
770769
* upon queue number)
771770
*/
772771
num_tc = vsi->mqprio_qopt.qopt.num_tc;
773-
queue = tc_fltr->action.fwd.q.queue;
774772

775773
for (tc = 0; tc < num_tc; tc++) {
776774
int qcount = vsi->mqprio_qopt.qopt.count[tc];
@@ -812,6 +810,7 @@ ice_tc_forward_action(struct ice_vsi *vsi, struct ice_tc_flower_fltr *tc_fltr)
812810
struct ice_pf *pf = vsi->back;
813811
struct device *dev;
814812
u32 tc_class;
813+
int q;
815814

816815
dev = ice_pf_to_dev(pf);
817816

@@ -840,7 +839,8 @@ ice_tc_forward_action(struct ice_vsi *vsi, struct ice_tc_flower_fltr *tc_fltr)
840839
/* Determine destination VSI even though the action is
841840
* FWD_TO_QUEUE, because QUEUE is associated with VSI
842841
*/
843-
dest_vsi = tc_fltr->dest_vsi;
842+
q = tc_fltr->action.fwd.q.queue;
843+
dest_vsi = ice_locate_vsi_using_queue(vsi, q);
844844
break;
845845
default:
846846
dev_err(dev,
@@ -1716,7 +1716,7 @@ ice_tc_forward_to_queue(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr,
17161716
/* If ADQ is configured, and the queue belongs to ADQ VSI, then prepare
17171717
* ADQ switch filter
17181718
*/
1719-
ch_vsi = ice_locate_vsi_using_queue(vsi, fltr);
1719+
ch_vsi = ice_locate_vsi_using_queue(vsi, fltr->action.fwd.q.queue);
17201720
if (!ch_vsi)
17211721
return -EINVAL;
17221722
fltr->dest_vsi = ch_vsi;

drivers/net/ethernet/intel/ice/ice_tc_lib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static inline int ice_chnl_dmac_fltr_cnt(struct ice_pf *pf)
204204
return pf->num_dmac_chnl_fltrs;
205205
}
206206

207+
struct ice_vsi *ice_locate_vsi_using_queue(struct ice_vsi *vsi, int queue);
207208
int
208209
ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi,
209210
struct flow_cls_offload *cls_flower);

0 commit comments

Comments
 (0)