Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iavf: Fix TC config comparison with existing adapter TC config

Same number of TCs doesn't imply that underlying TC configs are
same. The config could be different due to difference in number
of queues in each TC. Add utility function to determine if TC
configs are same.

Fixes: d5b33d024496 ("i40evf: add ndo_setup_tc callback to i40evf")
Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
Tested-by: Mineri Bhange <minerix.bhange@intel.com> (A Contingent Worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Link: https://lore.kernel.org/r/20240423182723.740401-4-anthony.l.nguyen@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Sudheer Mogilappagari and committed by
Jakub Kicinski
54976cf5 ef3c3131

+29 -1
+29 -1
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 3503 3503 } 3504 3504 3505 3505 /** 3506 + * iavf_is_tc_config_same - Compare the mqprio TC config with the 3507 + * TC config already configured on this adapter. 3508 + * @adapter: board private structure 3509 + * @mqprio_qopt: TC config received from kernel. 3510 + * 3511 + * This function compares the TC config received from the kernel 3512 + * with the config already configured on the adapter. 3513 + * 3514 + * Return: True if configuration is same, false otherwise. 3515 + **/ 3516 + static bool iavf_is_tc_config_same(struct iavf_adapter *adapter, 3517 + struct tc_mqprio_qopt *mqprio_qopt) 3518 + { 3519 + struct virtchnl_channel_info *ch = &adapter->ch_config.ch_info[0]; 3520 + int i; 3521 + 3522 + if (adapter->num_tc != mqprio_qopt->num_tc) 3523 + return false; 3524 + 3525 + for (i = 0; i < adapter->num_tc; i++) { 3526 + if (ch[i].count != mqprio_qopt->count[i] || 3527 + ch[i].offset != mqprio_qopt->offset[i]) 3528 + return false; 3529 + } 3530 + return true; 3531 + } 3532 + 3533 + /** 3506 3534 * __iavf_setup_tc - configure multiple traffic classes 3507 3535 * @netdev: network interface device structure 3508 3536 * @type_data: tc offload data ··· 3587 3559 if (ret) 3588 3560 return ret; 3589 3561 /* Return if same TC config is requested */ 3590 - if (adapter->num_tc == num_tc) 3562 + if (iavf_is_tc_config_same(adapter, &mqprio_qopt->qopt)) 3591 3563 return 0; 3592 3564 adapter->num_tc = num_tc; 3593 3565