| 10 | #define CTLQ_RECEIVE_RETRIES 100 |
| 11 | |
| 12 | int |
| 13 | cpfl_send_ctlq_msg(struct idpf_hw *hw, struct idpf_ctlq_info *cq, u16 num_q_msg, |
| 14 | struct idpf_ctlq_msg q_msg[]) |
| 15 | { |
| 16 | struct idpf_ctlq_msg **msg_ptr_list; |
| 17 | u16 clean_count = 0; |
| 18 | int num_cleaned = 0; |
| 19 | int retries = 0; |
| 20 | int ret = 0; |
| 21 | |
| 22 | msg_ptr_list = calloc(num_q_msg, sizeof(struct idpf_ctlq_msg *)); |
| 23 | if (!msg_ptr_list) { |
| 24 | PMD_INIT_LOG(ERR, "no memory for cleaning ctlq"); |
| 25 | ret = -ENOMEM; |
| 26 | goto err; |
| 27 | } |
| 28 | |
| 29 | ret = cpfl_vport_ctlq_send(hw, cq, num_q_msg, q_msg); |
| 30 | if (ret) { |
| 31 | PMD_INIT_LOG(ERR, "cpfl_vport_ctlq_send() failed with error: 0x%4x", ret); |
| 32 | goto send_err; |
| 33 | } |
| 34 | |
| 35 | while (retries <= CTLQ_SEND_RETRIES) { |
| 36 | clean_count = num_q_msg - num_cleaned; |
| 37 | ret = cpfl_vport_ctlq_clean_sq(cq, &clean_count, |
| 38 | &msg_ptr_list[num_cleaned]); |
| 39 | if (ret) { |
| 40 | PMD_INIT_LOG(ERR, "clean ctlq failed: 0x%4x", ret); |
| 41 | goto send_err; |
| 42 | } |
| 43 | |
| 44 | num_cleaned += clean_count; |
| 45 | retries++; |
| 46 | if (num_cleaned >= num_q_msg) |
| 47 | break; |
| 48 | rte_delay_us_sleep(10); |
| 49 | } |
| 50 | |
| 51 | if (retries > CTLQ_SEND_RETRIES) { |
| 52 | PMD_INIT_LOG(ERR, "timed out while polling for completions"); |
| 53 | ret = -1; |
| 54 | goto send_err; |
| 55 | } |
| 56 | |
| 57 | send_err: |
| 58 | free(msg_ptr_list); |
| 59 | err: |
| 60 | return ret; |
| 61 | } |
| 62 | |
| 63 | int |
| 64 | cpfl_receive_ctlq_msg(struct idpf_hw *hw, struct idpf_ctlq_info *cq, u16 num_q_msg, |
no test coverage detected