In preparation for optimized reception of zerocopy completion, revert the Rx side changes introduced by Commit dfb8434b0a94 ("selftests/net: add zerocopy support for PF_RDS test case")
Unified · Split
| @@ -344,26 +344,6 @@ static int do_setup_tx(int domain, int type, int protocol) · 343 unmodified lines | ||
| 344 | 344 | return fd; |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | −static int do_process_zerocopy_cookies(struct sock_extended_err *serr, | |
| 348 | − uint32_t *ckbuf, size_t nbytes) | |
| 349 | −{ | |
| 350 | − int ncookies, i; | |
| 351 | − | |
| 352 | − if (serr->ee_errno != 0) | |
| 353 | − error(1, 0, "serr: wrong error code: %u", serr->ee_errno); | |
| 354 | − ncookies = serr->ee_data; | |
| 355 | − if (ncookies > SO_EE_ORIGIN_MAX_ZCOOKIES) | |
| 356 | − error(1, 0, "Returned %d cookies, max expected %d\n", | |
| 357 | − ncookies, SO_EE_ORIGIN_MAX_ZCOOKIES); | |
| 358 | − if (nbytes != ncookies * sizeof(uint32_t)) | |
| 359 | − error(1, 0, "Expected %d cookies, got %ld\n", | |
| 360 | − ncookies, nbytes/sizeof(uint32_t)); | |
| 361 | − for (i = 0; i < ncookies; i++) | |
| 362 | − if (cfg_verbose >= 2) | |
| 363 | − fprintf(stderr, "%d\n", ckbuf[i]); | |
| 364 | − return ncookies; | |
| 365 | −} | |
| 366 | − | |
| 367 | 347 | static bool do_recv_completion(int fd) |
| 368 | 348 | { |
| 369 | 349 | struct sock_extended_err *serr; |
| @@ -372,17 +352,10 @@ static bool do_recv_completion(int fd) · 2 unmodified lines | ||
| 372 | 352 | uint32_t hi, lo, range; |
| 373 | 353 | int ret, zerocopy; |
| 374 | 354 | char control[100]; |
| 375 | − uint32_t ckbuf[SO_EE_ORIGIN_MAX_ZCOOKIES]; | |
| 376 | − struct iovec iov; | |
| 377 | 355 | |
| 378 | 356 | msg.msg_control = control; |
| 379 | 357 | msg.msg_controllen = sizeof(control); |
| 380 | 358 | |
| 381 | − iov.iov_base = ckbuf; | |
| 382 | − iov.iov_len = (SO_EE_ORIGIN_MAX_ZCOOKIES * sizeof(ckbuf[0])); | |
| 383 | − msg.msg_iov = &iov; | |
| 384 | − msg.msg_iovlen = 1; | |
| 385 | − | |
| 386 | 359 | ret = recvmsg(fd, &msg, MSG_ERRQUEUE); |
| 387 | 360 | if (ret == -1 && errno == EAGAIN) |
| 388 | 361 | return false; |
| @@ -402,10 +375,6 @@ static bool do_recv_completion(int fd) · 13 unmodified lines | ||
| 402 | 375 | |
| 403 | 376 | serr = (void *) CMSG_DATA(cm); |
| 404 | 377 | |
| 405 | − if (serr->ee_origin == SO_EE_ORIGIN_ZCOOKIE) { | |
| 406 | − completions += do_process_zerocopy_cookies(serr, ckbuf, ret); | |
| 407 | − return true; | |
| 408 | − } | |
| 409 | 378 | if (serr->ee_origin != SO_EE_ORIGIN_ZEROCOPY) |
| 410 | 379 | error(1, 0, "serr: wrong origin: %u", serr->ee_origin); |
| 411 | 380 | if (serr->ee_errno != 0) |
| @@ -631,40 +600,6 @@ static void do_flush_datagram(int fd, int type) · 219 unmodified lines | ||
| 631 | 600 | bytes += cfg_payload_len; |
| 632 | 601 | } |
| 633 | 602 | |
| 634 | − | |
| 635 | −static void do_recvmsg(int fd) | |
| 636 | −{ | |
| 637 | − int ret, off = 0; | |
| 638 | − char *buf; | |
| 639 | − struct iovec iov; | |
| 640 | − struct msghdr msg; | |
| 641 | − struct sockaddr_storage din; | |
| 642 | − | |
| 643 | − buf = calloc(cfg_payload_len, sizeof(char)); | |
| 644 | − iov.iov_base = buf; | |
| 645 | − iov.iov_len = cfg_payload_len; | |
| 646 | − | |
| 647 | − memset(&msg, 0, sizeof(msg)); | |
| 648 | − msg.msg_name = &din; | |
| 649 | − msg.msg_namelen = sizeof(din); | |
| 650 | − msg.msg_iov = &iov; | |
| 651 | − msg.msg_iovlen = 1; | |
| 652 | − | |
| 653 | − ret = recvmsg(fd, &msg, MSG_TRUNC); | |
| 654 | − | |
| 655 | − if (ret == -1) | |
| 656 | − error(1, errno, "recv"); | |
| 657 | − if (ret != cfg_payload_len) | |
| 658 | − error(1, 0, "recv: ret=%u != %u", ret, cfg_payload_len); | |
| 659 | − | |
| 660 | − if (memcmp(buf + off, payload, ret)) | |
| 661 | − error(1, 0, "recv: data mismatch"); | |
| 662 | − | |
| 663 | − free(buf); | |
| 664 | − packets++; | |
| 665 | − bytes += cfg_payload_len; | |
| 666 | −} | |
| 667 | − | |
| 668 | 603 | static void do_rx(int domain, int type, int protocol) |
| 669 | 604 | { |
| 670 | 605 | uint64_t tstop; |
| @@ -676,8 +611,6 @@ static void do_rx(int domain, int type, int protocol) · 5 unmodified lines | ||
| 676 | 611 | do { |
| 677 | 612 | if (type == SOCK_STREAM) |
| 678 | 613 | do_flush_tcp(fd); |
| 679 | − else if (domain == PF_RDS) | |
| 680 | − do_recvmsg(fd); | |
| 681 | 614 | else |
| 682 | 615 | do_flush_datagram(fd, type); |
| 683 | 616 | |