From aa3497d4450a603ca18ae4971a96e3890824d887 Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Mon, 30 Aug 2021 16:26:49 +0800 Subject: [PATCH] net/hns3: fix queue flow action validation The used_rx_queues only takes effect after device is started, and its value is incorrect before the device is started. Therefore, it is not suitable for flow action to use it to verify the queue index before the device is started. E.g. Enable dedicated queue in bonding device will configure a queue flow action before start its slave devices. The above problem will make this reasonable flow action configuration fail. This patch use the nb_rx_queues from the configuration phase to achieve verification. Fixes: a951c1ed3ab5 ("net/hns3: support different numbers of Rx and Tx queues") Fixes: f8e7fcbfd0b8 ("net/hns3: support flow action of queue region") Cc: stable@dpdk.org Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_flow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index fc77979c5f..841e0b9da3 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -275,10 +275,10 @@ hns3_handle_action_queue(struct rte_eth_dev *dev, struct hns3_hw *hw = &hns->hw; queue = (const struct rte_flow_action_queue *)action->conf; - if (queue->index >= hw->used_rx_queues) { + if (queue->index >= hw->data->nb_rx_queues) { hns3_err(hw, "queue ID(%u) is greater than number of " "available queue (%u) in driver.", - queue->index, hw->used_rx_queues); + queue->index, hw->data->nb_rx_queues); return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, action, "Invalid queue ID in PF"); @@ -308,8 +308,8 @@ hns3_handle_action_queue_region(struct rte_eth_dev *dev, if ((!rte_is_power_of_2(conf->queue_num)) || conf->queue_num > hw->rss_size_max || - conf->queue[0] >= hw->used_rx_queues || - conf->queue[0] + conf->queue_num > hw->used_rx_queues) { + conf->queue[0] >= hw->data->nb_rx_queues || + conf->queue[0] + conf->queue_num > hw->data->nb_rx_queues) { return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION_CONF, action, "Invalid start queue ID and queue num! the start queue " -- 2.20.1