struct hclge_vport_vtag_tx_cfg_cmd *req;
        struct hclge_dev *hdev = vport->back;
        struct hclge_desc desc;
+       u16 bmap_index;
        int status;
 
        hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_PORT_TX_CFG, false);
        hnae3_set_bit(req->vport_vlan_cfg, HCLGE_CFG_NIC_ROCE_SEL_B, 0);
 
        req->vf_offset = vport->vport_id / HCLGE_VF_NUM_PER_CMD;
-       req->vf_bitmap[req->vf_offset] =
-               1 << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
+       bmap_index = vport->vport_id % HCLGE_VF_NUM_PER_CMD /
+                       HCLGE_VF_NUM_PER_BYTE;
+       req->vf_bitmap[bmap_index] =
+               1U << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
 
        status = hclge_cmd_send(&hdev->hw, &desc, 1);
        if (status)
        struct hclge_vport_vtag_rx_cfg_cmd *req;
        struct hclge_dev *hdev = vport->back;
        struct hclge_desc desc;
+       u16 bmap_index;
        int status;
 
        hclge_cmd_setup_basic_desc(&desc, HCLGE_OPC_VLAN_PORT_RX_CFG, false);
                      vcfg->vlan2_vlan_prionly ? 1 : 0);
 
        req->vf_offset = vport->vport_id / HCLGE_VF_NUM_PER_CMD;
-       req->vf_bitmap[req->vf_offset] =
-               1 << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
+       bmap_index = vport->vport_id % HCLGE_VF_NUM_PER_CMD /
+                       HCLGE_VF_NUM_PER_BYTE;
+       req->vf_bitmap[bmap_index] =
+               1U << (vport->vport_id % HCLGE_VF_NUM_PER_BYTE);
 
        status = hclge_cmd_send(&hdev->hw, &desc, 1);
        if (status)