Skip to content

Commit e792779

Browse files
niteshbvenkateshanguy11
authored andcommitted
iavf: Prevent changing static ITR values if adaptive moderation is on
Resolve being able to change static values on VF when adaptive interrupt moderation is enabled. This problem is fixed by checking the interrupt settings is not a combination of change of static value while adaptive interrupt moderation is turned on. Without this fix, the user would be able to change static values on VF with adaptive moderation enabled. Fixes: 65e87c0 ("i40evf: support queue-specific settings for interrupt moderation") Signed-off-by: Nitesh B Venkatesh <nitesh.b.venkatesh@intel.com> Tested-by: George Kuruvinakunnel <george.kuruvinakunnel@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 0f296e7 commit e792779

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,12 +723,31 @@ static int iavf_get_per_queue_coalesce(struct net_device *netdev, u32 queue,
723723
*
724724
* Change the ITR settings for a specific queue.
725725
**/
726-
static void iavf_set_itr_per_queue(struct iavf_adapter *adapter,
727-
struct ethtool_coalesce *ec, int queue)
726+
static int iavf_set_itr_per_queue(struct iavf_adapter *adapter,
727+
struct ethtool_coalesce *ec, int queue)
728728
{
729729
struct iavf_ring *rx_ring = &adapter->rx_rings[queue];
730730
struct iavf_ring *tx_ring = &adapter->tx_rings[queue];
731731
struct iavf_q_vector *q_vector;
732+
u16 itr_setting;
733+
734+
itr_setting = rx_ring->itr_setting & ~IAVF_ITR_DYNAMIC;
735+
736+
if (ec->rx_coalesce_usecs != itr_setting &&
737+
ec->use_adaptive_rx_coalesce) {
738+
netif_info(adapter, drv, adapter->netdev,
739+
"Rx interrupt throttling cannot be changed if adaptive-rx is enabled\n");
740+
return -EINVAL;
741+
}
742+
743+
itr_setting = tx_ring->itr_setting & ~IAVF_ITR_DYNAMIC;
744+
745+
if (ec->tx_coalesce_usecs != itr_setting &&
746+
ec->use_adaptive_tx_coalesce) {
747+
netif_info(adapter, drv, adapter->netdev,
748+
"Tx interrupt throttling cannot be changed if adaptive-tx is enabled\n");
749+
return -EINVAL;
750+
}
732751

733752
rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs);
734753
tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs);
@@ -751,6 +770,7 @@ static void iavf_set_itr_per_queue(struct iavf_adapter *adapter,
751770
* the Tx and Rx ITR values based on the values we have entered
752771
* into the q_vector, no need to write the values now.
753772
*/
773+
return 0;
754774
}
755775

756776
/**
@@ -792,9 +812,11 @@ static int __iavf_set_coalesce(struct net_device *netdev,
792812
*/
793813
if (queue < 0) {
794814
for (i = 0; i < adapter->num_active_queues; i++)
795-
iavf_set_itr_per_queue(adapter, ec, i);
815+
if (iavf_set_itr_per_queue(adapter, ec, i))
816+
return -EINVAL;
796817
} else if (queue < adapter->num_active_queues) {
797-
iavf_set_itr_per_queue(adapter, ec, queue);
818+
if (iavf_set_itr_per_queue(adapter, ec, queue))
819+
return -EINVAL;
798820
} else {
799821
netif_info(adapter, drv, netdev, "Invalid queue value, queue range is 0 - %d\n",
800822
adapter->num_active_queues - 1);

0 commit comments

Comments
 (0)