Lines Matching +full:cm +full:- +full:poll +full:- +full:mode
7 * - SOCK_STREAM
8 * - SOCK_DGRAM
9 * - SOCK_DGRAM with UDP_CORK
10 * - SOCK_RAW
11 * - SOCK_RAW with IP_HDRINCL
14 * - SOCK_DGRAM
15 * - SOCK_RAW
18 * - SOCK_SEQPACKET
20 * Start this program on two connected hosts, one in send mode and
21 * the other with option '-r' to put it in receiver mode.
23 * If zerocopy mode ('-z') is enabled, the sender will verify that
45 #include <poll.h>
79 static int cfg_cpu = -1; /* default: pin to last cpu */
97 static int zerocopied = -1;
152 ret = poll(&pfd, 1, cfg_waittime_ms); in do_poll()
153 if (ret == -1) in do_poll()
154 error(1, errno, "poll"); in do_poll()
164 if (fd == -1) in do_accept()
174 struct cmsghdr *cm; in add_zcopy_cookie() local
176 if (!msg->msg_control) in add_zcopy_cookie()
178 cm = (void *)msg->msg_control; in add_zcopy_cookie()
179 cm->cmsg_len = CMSG_LEN(sizeof(cookie)); in add_zcopy_cookie()
180 cm->cmsg_level = SOL_RDS; in add_zcopy_cookie()
181 cm->cmsg_type = RDS_CMSG_ZCOPY_COOKIE; in add_zcopy_cookie()
182 memcpy(CMSG_DATA(cm), &cookie, sizeof(cookie)); in add_zcopy_cookie()
192 for (i = 0; i < msg->msg_iovlen; i++) in do_sendmsg()
193 len += msg->msg_iov[i].iov_len; in do_sendmsg()
199 memset(&msg->msg_control, 0, sizeof(msg->msg_control)); in do_sendmsg()
200 msg->msg_controllen = CMSG_SPACE(sizeof(cookie)); in do_sendmsg()
201 msg->msg_control = (struct cmsghdr *)ckbuf; in do_sendmsg()
207 if (ret == -1 && errno == EAGAIN) in do_sendmsg()
209 if (ret == -1) in do_sendmsg()
222 msg->msg_control = NULL; in do_sendmsg()
223 msg->msg_controllen = 0; in do_sendmsg()
234 /* split up the packet. for non-multiple, make first buffer longer */ in do_sendmsg_corked()
236 extra_len = cfg_payload_len - (cfg_cork * payload_len); in do_sendmsg_corked()
242 /* in mixed-frags mode, alternate zerocopy and copy frags in do_sendmsg_corked()
243 * start with non-zerocopy, to ensure attach later works in do_sendmsg_corked()
248 msg->msg_iov[0].iov_len = payload_len + extra_len; in do_sendmsg_corked()
266 iph->version = 4; in setup_iph()
267 iph->tos = 0; in setup_iph()
268 iph->ihl = 5; in setup_iph()
269 iph->ttl = 2; in setup_iph()
270 iph->saddr = saddr->sin_addr.s_addr; in setup_iph()
271 iph->daddr = daddr->sin_addr.s_addr; in setup_iph()
272 iph->protocol = IPPROTO_EGP; in setup_iph()
273 iph->tot_len = htons(sizeof(*iph) + payload_len); in setup_iph()
274 iph->check = get_ip_csum((void *) iph, iph->ihl << 1); in setup_iph()
286 ip6h->version = 6; in setup_ip6h()
287 ip6h->payload_len = htons(payload_len); in setup_ip6h()
288 ip6h->nexthdr = IPPROTO_EGP; in setup_ip6h()
289 ip6h->hop_limit = 2; in setup_ip6h()
290 ip6h->saddr = saddr->sin6_addr; in setup_ip6h()
291 ip6h->daddr = daddr->sin6_addr; in setup_ip6h()
306 addr4->sin_family = AF_INET; in setup_sockaddr()
307 addr4->sin_port = htons(cfg_port); in setup_sockaddr()
309 inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1) in setup_sockaddr()
314 addr6->sin6_family = AF_INET6; in setup_sockaddr()
315 addr6->sin6_port = htons(cfg_port); in setup_sockaddr()
317 inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1) in setup_sockaddr()
330 if (fd == -1) in do_setup_tx()
353 if (ck->num > RDS_MAX_ZCOOKIES) in do_process_zerocopy_cookies()
355 ck->num, RDS_MAX_ZCOOKIES); in do_process_zerocopy_cookies()
356 for (i = 0; i < ck->num; i++) in do_process_zerocopy_cookies()
358 fprintf(stderr, "%d\n", ck->cookies[i]); in do_process_zerocopy_cookies()
359 return ck->num; in do_process_zerocopy_cookies()
381 if (cmsg->cmsg_level == SOL_RDS && in do_recvmsg_completion()
382 cmsg->cmsg_type == RDS_CMSG_ZCOPY_COMPLETION) { in do_recvmsg_completion()
390 cmsg->cmsg_level, cmsg->cmsg_type); in do_recvmsg_completion()
399 struct cmsghdr *cm; in do_recv_completion() local
411 if (ret == -1 && errno == EAGAIN) in do_recv_completion()
413 if (ret == -1) in do_recv_completion()
418 cm = CMSG_FIRSTHDR(&msg); in do_recv_completion()
419 if (!cm) in do_recv_completion()
421 if (!((cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_RECVERR) || in do_recv_completion()
422 (cm->cmsg_level == SOL_IPV6 && cm->cmsg_type == IPV6_RECVERR) || in do_recv_completion()
423 (cm->cmsg_level == SOL_PACKET && cm->cmsg_type == PACKET_TX_TIMESTAMP))) in do_recv_completion()
425 cm->cmsg_level, cm->cmsg_type); in do_recv_completion()
427 serr = (void *) CMSG_DATA(cm); in do_recv_completion()
429 if (serr->ee_origin != SO_EE_ORIGIN_ZEROCOPY) in do_recv_completion()
430 error(1, 0, "serr: wrong origin: %u", serr->ee_origin); in do_recv_completion()
431 if (serr->ee_errno != 0) in do_recv_completion()
432 error(1, 0, "serr: wrong error code: %u", serr->ee_errno); in do_recv_completion()
434 hi = serr->ee_data; in do_recv_completion()
435 lo = serr->ee_info; in do_recv_completion()
436 range = hi - lo + 1; in do_recv_completion()
446 zerocopy = !(serr->ee_code & SO_EE_CODE_ZEROCOPY_COPIED); in do_recv_completion()
447 if (zerocopied == -1) in do_recv_completion()
547 msg.msg_iov = &iov[3 - msg.msg_iovlen]; in do_tx()
591 if (fd == -1) in do_setup_rx()
617 if (ret == -1 && errno == EAGAIN) in do_flush_tcp()
619 if (ret == -1) in do_flush_tcp()
636 if (ret == -1 && errno == EAGAIN) in do_flush_datagram()
642 ret -= sizeof(struct iphdr); in do_flush_datagram()
645 if (ret == -1) in do_flush_datagram()
649 if (ret > sizeof(buf) - off) in do_flush_datagram()
650 ret = sizeof(buf) - off; in do_flush_datagram()
708 const int max_payload_len = sizeof(payload) - in parse_opts()
709 sizeof(struct ipv6hdr) - in parse_opts()
710 sizeof(struct tcphdr) - in parse_opts()
718 while ((c = getopt(argc, argv, "46c:C:D:i:l:mp:rs:S:t:vz")) != -1) { in parse_opts()
722 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
728 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
776 cfg_test = argv[argc - 1]; in parse_opts()
779 error(1, 0, "-D <server addr> required for PF_RDS\n"); in parse_opts()
781 error(1, 0, "-S <client addr> required for PF_RDS\n"); in parse_opts()
787 error(1, 0, "-s: payload exceeds max (%d)", max_payload_len); in parse_opts()
789 error(1, 0, "-m: cork_mixed requires corking and zerocopy"); in parse_opts()
791 if (optind != argc - 1) in parse_opts()
801 cfg_test = argv[argc - 1]; in main()