提交 9fc63c77 编写于 作者: N Nitesh B Venkatesh 提交者: Zheng Zengkai

iavf: Prevent changing static ITR values if adaptive moderation is on

stable inclusion
from stable-v5.10.83
commit f5af2def7e05cbf739701f2c240b3267a03d76c0
bugzilla: 185879 https://gitee.com/openeuler/kernel/issues/I4QUVG

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=f5af2def7e05cbf739701f2c240b3267a03d76c0

--------------------------------

[ Upstream commit e792779e ]

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: 65e87c03 ("i40evf: support queue-specific settings for interrupt moderation")
Signed-off-by: NNitesh B Venkatesh <nitesh.b.venkatesh@intel.com>
Tested-by: NGeorge Kuruvinakunnel <george.kuruvinakunnel@intel.com>
Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c470fc00
...@@ -731,12 +731,31 @@ static int iavf_get_per_queue_coalesce(struct net_device *netdev, u32 queue, ...@@ -731,12 +731,31 @@ static int iavf_get_per_queue_coalesce(struct net_device *netdev, u32 queue,
* *
* Change the ITR settings for a specific queue. * Change the ITR settings for a specific queue.
**/ **/
static void iavf_set_itr_per_queue(struct iavf_adapter *adapter, static int iavf_set_itr_per_queue(struct iavf_adapter *adapter,
struct ethtool_coalesce *ec, int queue) struct ethtool_coalesce *ec, int queue)
{ {
struct iavf_ring *rx_ring = &adapter->rx_rings[queue]; struct iavf_ring *rx_ring = &adapter->rx_rings[queue];
struct iavf_ring *tx_ring = &adapter->tx_rings[queue]; struct iavf_ring *tx_ring = &adapter->tx_rings[queue];
struct iavf_q_vector *q_vector; struct iavf_q_vector *q_vector;
u16 itr_setting;
itr_setting = rx_ring->itr_setting & ~IAVF_ITR_DYNAMIC;
if (ec->rx_coalesce_usecs != itr_setting &&
ec->use_adaptive_rx_coalesce) {
netif_info(adapter, drv, adapter->netdev,
"Rx interrupt throttling cannot be changed if adaptive-rx is enabled\n");
return -EINVAL;
}
itr_setting = tx_ring->itr_setting & ~IAVF_ITR_DYNAMIC;
if (ec->tx_coalesce_usecs != itr_setting &&
ec->use_adaptive_tx_coalesce) {
netif_info(adapter, drv, adapter->netdev,
"Tx interrupt throttling cannot be changed if adaptive-tx is enabled\n");
return -EINVAL;
}
rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs); rx_ring->itr_setting = ITR_REG_ALIGN(ec->rx_coalesce_usecs);
tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs); tx_ring->itr_setting = ITR_REG_ALIGN(ec->tx_coalesce_usecs);
...@@ -759,6 +778,7 @@ static void iavf_set_itr_per_queue(struct iavf_adapter *adapter, ...@@ -759,6 +778,7 @@ static void iavf_set_itr_per_queue(struct iavf_adapter *adapter,
* the Tx and Rx ITR values based on the values we have entered * the Tx and Rx ITR values based on the values we have entered
* into the q_vector, no need to write the values now. * into the q_vector, no need to write the values now.
*/ */
return 0;
} }
/** /**
...@@ -800,9 +820,11 @@ static int __iavf_set_coalesce(struct net_device *netdev, ...@@ -800,9 +820,11 @@ static int __iavf_set_coalesce(struct net_device *netdev,
*/ */
if (queue < 0) { if (queue < 0) {
for (i = 0; i < adapter->num_active_queues; i++) for (i = 0; i < adapter->num_active_queues; i++)
iavf_set_itr_per_queue(adapter, ec, i); if (iavf_set_itr_per_queue(adapter, ec, i))
return -EINVAL;
} else if (queue < adapter->num_active_queues) { } else if (queue < adapter->num_active_queues) {
iavf_set_itr_per_queue(adapter, ec, queue); if (iavf_set_itr_per_queue(adapter, ec, queue))
return -EINVAL;
} else { } else {
netif_info(adapter, drv, netdev, "Invalid queue value, queue range is 0 - %d\n", netif_info(adapter, drv, netdev, "Invalid queue value, queue range is 0 - %d\n",
adapter->num_active_queues - 1); adapter->num_active_queues - 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册