| 201 | } |
| 202 | |
| 203 | static int |
| 204 | test_single_copy(int16_t dev_id, uint16_t vchan) |
| 205 | { |
| 206 | uint16_t i; |
| 207 | uint16_t id; |
| 208 | enum rte_dma_status_code status; |
| 209 | struct rte_mbuf *src, *dst; |
| 210 | char *src_data, *dst_data; |
| 211 | |
| 212 | src = rte_pktmbuf_alloc(pool); |
| 213 | dst = rte_pktmbuf_alloc(pool); |
| 214 | src_data = rte_pktmbuf_mtod(src, char *); |
| 215 | dst_data = rte_pktmbuf_mtod(dst, char *); |
| 216 | |
| 217 | for (i = 0; i < COPY_LEN; i++) |
| 218 | src_data[i] = rte_rand() & 0xFF; |
| 219 | |
| 220 | id = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), rte_pktmbuf_iova(dst), |
| 221 | COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); |
| 222 | if (id != id_count) |
| 223 | ERR_RETURN("Error with rte_dma_copy, got %u, expected %u\n", |
| 224 | id, id_count); |
| 225 | |
| 226 | /* give time for copy to finish, then check it was done */ |
| 227 | await_hw(dev_id, vchan); |
| 228 | |
| 229 | for (i = 0; i < COPY_LEN; i++) |
| 230 | if (dst_data[i] != src_data[i]) |
| 231 | ERR_RETURN("Data mismatch at char %u [Got %02x not %02x]\n", i, |
| 232 | dst_data[i], src_data[i]); |
| 233 | |
| 234 | /* now check completion works */ |
| 235 | id = ~id; |
| 236 | if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1) |
| 237 | ERR_RETURN("Error with rte_dma_completed\n"); |
| 238 | |
| 239 | if (id != id_count) |
| 240 | ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", |
| 241 | id, id_count); |
| 242 | |
| 243 | /* check for completed and id when no job done */ |
| 244 | id = ~id; |
| 245 | if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) |
| 246 | ERR_RETURN("Error with rte_dma_completed when no job done\n"); |
| 247 | if (id != id_count) |
| 248 | ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", |
| 249 | id, id_count); |
| 250 | |
| 251 | /* check for completed_status and id when no job done */ |
| 252 | id = ~id; |
| 253 | if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) |
| 254 | ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); |
| 255 | if (id != id_count) |
| 256 | ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", |
| 257 | id, id_count); |
| 258 | |
| 259 | rte_pktmbuf_free(src); |
| 260 | rte_pktmbuf_free(dst); |
no test coverage detected