Commit 4836650b authored by Wei Yongjun's avatar Wei Yongjun Committed by Jeff Kirsher

i40e: using for_each_set_bit to simplify the code

Using for_each_set_bit() to simplify the code.
Signed-off-by: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 55fdbfe7
...@@ -260,23 +260,17 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_idx, ...@@ -260,23 +260,17 @@ static void i40e_config_irq_link_list(struct i40e_vf *vf, u16 vsi_idx,
goto irq_list_done; goto irq_list_done;
} }
tempmap = vecmap->rxq_map; tempmap = vecmap->rxq_map;
vsi_queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(vsi_queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (vsi_queue_id < I40E_MAX_VSI_QP) {
linklistmap |= (1 << linklistmap |= (1 <<
(I40E_VIRTCHNL_SUPPORTED_QTYPES * (I40E_VIRTCHNL_SUPPORTED_QTYPES *
vsi_queue_id)); vsi_queue_id));
vsi_queue_id =
find_next_bit(&tempmap, I40E_MAX_VSI_QP, vsi_queue_id + 1);
} }
tempmap = vecmap->txq_map; tempmap = vecmap->txq_map;
vsi_queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(vsi_queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (vsi_queue_id < I40E_MAX_VSI_QP) {
linklistmap |= (1 << linklistmap |= (1 <<
(I40E_VIRTCHNL_SUPPORTED_QTYPES * vsi_queue_id (I40E_VIRTCHNL_SUPPORTED_QTYPES * vsi_queue_id
+ 1)); + 1));
vsi_queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
vsi_queue_id + 1);
} }
next_q = find_first_bit(&linklistmap, next_q = find_first_bit(&linklistmap,
...@@ -1293,27 +1287,21 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) ...@@ -1293,27 +1287,21 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
/* lookout for the invalid queue index */ /* lookout for the invalid queue index */
tempmap = map->rxq_map; tempmap = map->rxq_map;
vsi_queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(vsi_queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (vsi_queue_id < I40E_MAX_VSI_QP) {
if (!i40e_vc_isvalid_queue_id(vf, vsi_id, if (!i40e_vc_isvalid_queue_id(vf, vsi_id,
vsi_queue_id)) { vsi_queue_id)) {
aq_ret = I40E_ERR_PARAM; aq_ret = I40E_ERR_PARAM;
goto error_param; goto error_param;
} }
vsi_queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
vsi_queue_id + 1);
} }
tempmap = map->txq_map; tempmap = map->txq_map;
vsi_queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(vsi_queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (vsi_queue_id < I40E_MAX_VSI_QP) {
if (!i40e_vc_isvalid_queue_id(vf, vsi_id, if (!i40e_vc_isvalid_queue_id(vf, vsi_id,
vsi_queue_id)) { vsi_queue_id)) {
aq_ret = I40E_ERR_PARAM; aq_ret = I40E_ERR_PARAM;
goto error_param; goto error_param;
} }
vsi_queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
vsi_queue_id + 1);
} }
i40e_config_irq_link_list(vf, vsi_id, map); i40e_config_irq_link_list(vf, vsi_id, map);
...@@ -1358,31 +1346,23 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) ...@@ -1358,31 +1346,23 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
} }
tempmap = vqs->rx_queues; tempmap = vqs->rx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) { if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) {
aq_ret = I40E_ERR_PARAM; aq_ret = I40E_ERR_PARAM;
goto error_param; goto error_param;
} }
i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id, i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_ENABLE); I40E_QUEUE_CTRL_ENABLE);
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
tempmap = vqs->tx_queues; tempmap = vqs->tx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) { if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) {
aq_ret = I40E_ERR_PARAM; aq_ret = I40E_ERR_PARAM;
goto error_param; goto error_param;
} }
i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id, i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_ENABLE); I40E_QUEUE_CTRL_ENABLE);
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
/* Poll the status register to make sure that the /* Poll the status register to make sure that the
...@@ -1391,29 +1371,23 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) ...@@ -1391,29 +1371,23 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
udelay(10); udelay(10);
tempmap = vqs->rx_queues; tempmap = vqs->rx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id, if (i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_ENABLECHECK)) { I40E_QUEUE_CTRL_ENABLECHECK)) {
dev_err(&pf->pdev->dev, dev_err(&pf->pdev->dev,
"Queue control check failed on RX queue %d of VSI %d VF %d\n", "Queue control check failed on RX queue %d of VSI %d VF %d\n",
queue_id, vsi_id, vf->vf_id); queue_id, vsi_id, vf->vf_id);
} }
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
tempmap = vqs->tx_queues; tempmap = vqs->tx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id, if (i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_ENABLECHECK)) { I40E_QUEUE_CTRL_ENABLECHECK)) {
dev_err(&pf->pdev->dev, dev_err(&pf->pdev->dev,
"Queue control check failed on TX queue %d of VSI %d VF %d\n", "Queue control check failed on TX queue %d of VSI %d VF %d\n",
queue_id, vsi_id, vf->vf_id); queue_id, vsi_id, vf->vf_id);
} }
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
error_param: error_param:
...@@ -1457,31 +1431,23 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) ...@@ -1457,31 +1431,23 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
} }
tempmap = vqs->rx_queues; tempmap = vqs->rx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) { if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) {
aq_ret = I40E_ERR_PARAM; aq_ret = I40E_ERR_PARAM;
goto error_param; goto error_param;
} }
i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id, i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_DISABLE); I40E_QUEUE_CTRL_DISABLE);
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
tempmap = vqs->tx_queues; tempmap = vqs->tx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) { if (!i40e_vc_isvalid_queue_id(vf, vsi_id, queue_id)) {
aq_ret = I40E_ERR_PARAM; aq_ret = I40E_ERR_PARAM;
goto error_param; goto error_param;
} }
i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id, i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_DISABLE); I40E_QUEUE_CTRL_DISABLE);
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
/* Poll the status register to make sure that the /* Poll the status register to make sure that the
...@@ -1490,29 +1456,23 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen) ...@@ -1490,29 +1456,23 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
udelay(10); udelay(10);
tempmap = vqs->rx_queues; tempmap = vqs->rx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id, if (i40e_ctrl_vsi_rx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_DISABLECHECK)) { I40E_QUEUE_CTRL_DISABLECHECK)) {
dev_err(&pf->pdev->dev, dev_err(&pf->pdev->dev,
"Queue control check failed on RX queue %d of VSI %d VF %d\n", "Queue control check failed on RX queue %d of VSI %d VF %d\n",
queue_id, vsi_id, vf->vf_id); queue_id, vsi_id, vf->vf_id);
} }
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
tempmap = vqs->tx_queues; tempmap = vqs->tx_queues;
queue_id = find_first_bit(&tempmap, I40E_MAX_VSI_QP); for_each_set_bit(queue_id, &tempmap, I40E_MAX_VSI_QP) {
while (queue_id < I40E_MAX_VSI_QP) {
if (i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id, if (i40e_ctrl_vsi_tx_queue(vf, vsi_id, queue_id,
I40E_QUEUE_CTRL_DISABLECHECK)) { I40E_QUEUE_CTRL_DISABLECHECK)) {
dev_err(&pf->pdev->dev, dev_err(&pf->pdev->dev,
"Queue control check failed on TX queue %d of VSI %d VF %d\n", "Queue control check failed on TX queue %d of VSI %d VF %d\n",
queue_id, vsi_id, vf->vf_id); queue_id, vsi_id, vf->vf_id);
} }
queue_id = find_next_bit(&tempmap, I40E_MAX_VSI_QP,
queue_id + 1);
} }
error_param: error_param:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment