| 524 | } |
| 525 | |
| 526 | static int |
| 527 | pdump_prepare_client_request(const char *device, uint16_t queue, |
| 528 | uint32_t flags, uint32_t snaplen, |
| 529 | uint16_t operation, |
| 530 | struct rte_ring *ring, |
| 531 | struct rte_mempool *mp, |
| 532 | const struct rte_bpf_prm *prm) |
| 533 | { |
| 534 | int ret = -1; |
| 535 | struct rte_mp_msg mp_req, *mp_rep; |
| 536 | struct rte_mp_reply mp_reply; |
| 537 | struct timespec ts = {.tv_sec = 5, .tv_nsec = 0}; |
| 538 | struct pdump_request *req = (struct pdump_request *)mp_req.param; |
| 539 | struct pdump_response *resp; |
| 540 | |
| 541 | if (rte_eal_process_type() == RTE_PROC_PRIMARY) { |
| 542 | PDUMP_LOG(ERR, |
| 543 | "pdump enable/disable not allowed in primary process\n"); |
| 544 | return -EINVAL; |
| 545 | } |
| 546 | |
| 547 | memset(req, 0, sizeof(*req)); |
| 548 | |
| 549 | req->ver = (flags & RTE_PDUMP_FLAG_PCAPNG) ? V2 : V1; |
| 550 | req->flags = flags & RTE_PDUMP_FLAG_RXTX; |
| 551 | req->op = operation; |
| 552 | req->queue = queue; |
| 553 | rte_strscpy(req->device, device, sizeof(req->device)); |
| 554 | |
| 555 | if ((operation & ENABLE) != 0) { |
| 556 | req->ring = ring; |
| 557 | req->mp = mp; |
| 558 | req->prm = prm; |
| 559 | req->snaplen = snaplen; |
| 560 | } |
| 561 | |
| 562 | rte_strscpy(mp_req.name, PDUMP_MP, RTE_MP_MAX_NAME_LEN); |
| 563 | mp_req.len_param = sizeof(*req); |
| 564 | mp_req.num_fds = 0; |
| 565 | if (rte_mp_request_sync(&mp_req, &mp_reply, &ts) == 0) { |
| 566 | mp_rep = &mp_reply.msgs[0]; |
| 567 | resp = (struct pdump_response *)mp_rep->param; |
| 568 | if (resp->err_value == 0) |
| 569 | ret = 0; |
| 570 | else |
| 571 | rte_errno = -resp->err_value; |
| 572 | free(mp_reply.msgs); |
| 573 | } |
| 574 | |
| 575 | if (ret < 0) |
| 576 | PDUMP_LOG(ERR, |
| 577 | "client request for pdump enable/disable failed\n"); |
| 578 | return ret; |
| 579 | } |
| 580 | |
| 581 | /* |
| 582 | * There are two versions of this function, because although original API |
no test coverage detected