1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved. 3 4 #include <linux/dma-mapping.h> 5 6 #include "hinic3_hwdev.h" 7 #include "hinic3_wq.h" 8 9 void hinic3_wq_get_multi_wqebbs(struct hinic3_wq *wq, 10 u16 num_wqebbs, u16 *prod_idx, 11 struct hinic3_sq_bufdesc **first_part_wqebbs, 12 struct hinic3_sq_bufdesc **second_part_wqebbs, 13 u16 *first_part_wqebbs_num) 14 { 15 u32 idx, remaining; 16 17 idx = wq->prod_idx & wq->idx_mask; 18 wq->prod_idx += num_wqebbs; 19 *prod_idx = idx; 20 *first_part_wqebbs = get_q_element(&wq->qpages, idx, &remaining); 21 if (likely(remaining >= num_wqebbs)) { 22 *first_part_wqebbs_num = num_wqebbs; 23 *second_part_wqebbs = NULL; 24 } else { 25 *first_part_wqebbs_num = remaining; 26 idx += remaining; 27 *second_part_wqebbs = get_q_element(&wq->qpages, idx, NULL); 28 } 29 } 30