Lines Matching +full:eth +full:- +full:ck
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
21 * the other with option '-r' to put it in receiver mode.
23 * If zerocopy mode ('-z') is enabled, the sender will verify that
79 static int cfg_cpu = -1; /* default: pin to last cpu */
96 static int zerocopied = -1;
151 if (ret == -1) in do_poll()
162 if (fd == -1) in do_accept()
174 if (!msg->msg_control) in add_zcopy_cookie()
176 cm = (void *)msg->msg_control; in add_zcopy_cookie()
177 cm->cmsg_len = CMSG_LEN(sizeof(cookie)); in add_zcopy_cookie()
178 cm->cmsg_level = SOL_RDS; in add_zcopy_cookie()
179 cm->cmsg_type = RDS_CMSG_ZCOPY_COOKIE; in add_zcopy_cookie()
190 for (i = 0; i < msg->msg_iovlen; i++) in do_sendmsg()
191 len += msg->msg_iov[i].iov_len; in do_sendmsg()
197 memset(&msg->msg_control, 0, sizeof(msg->msg_control)); in do_sendmsg()
198 msg->msg_controllen = CMSG_SPACE(sizeof(cookie)); in do_sendmsg()
199 msg->msg_control = (struct cmsghdr *)ckbuf; in do_sendmsg()
205 if (ret == -1 && errno == EAGAIN) in do_sendmsg()
207 if (ret == -1) in do_sendmsg()
219 msg->msg_control = NULL; in do_sendmsg()
220 msg->msg_controllen = 0; in do_sendmsg()
231 /* split up the packet. for non-multiple, make first buffer longer */ in do_sendmsg_corked()
233 extra_len = cfg_payload_len - (cfg_cork * payload_len); in do_sendmsg_corked()
239 /* in mixed-frags mode, alternate zerocopy and copy frags in do_sendmsg_corked()
240 * start with non-zerocopy, to ensure attach later works in do_sendmsg_corked()
245 msg->msg_iov[0].iov_len = payload_len + extra_len; in do_sendmsg_corked()
263 iph->version = 4; in setup_iph()
264 iph->tos = 0; in setup_iph()
265 iph->ihl = 5; in setup_iph()
266 iph->ttl = 2; in setup_iph()
267 iph->saddr = saddr->sin_addr.s_addr; in setup_iph()
268 iph->daddr = daddr->sin_addr.s_addr; in setup_iph()
269 iph->protocol = IPPROTO_EGP; in setup_iph()
270 iph->tot_len = htons(sizeof(*iph) + payload_len); in setup_iph()
271 iph->check = get_ip_csum((void *) iph, iph->ihl << 1); in setup_iph()
283 ip6h->version = 6; in setup_ip6h()
284 ip6h->payload_len = htons(payload_len); in setup_ip6h()
285 ip6h->nexthdr = IPPROTO_EGP; in setup_ip6h()
286 ip6h->hop_limit = 2; in setup_ip6h()
287 ip6h->saddr = saddr->sin6_addr; in setup_ip6h()
288 ip6h->daddr = daddr->sin6_addr; in setup_ip6h()
303 addr4->sin_family = AF_INET; in setup_sockaddr()
304 addr4->sin_port = htons(cfg_port); in setup_sockaddr()
306 inet_pton(AF_INET, str_addr, &(addr4->sin_addr)) != 1) in setup_sockaddr()
311 addr6->sin6_family = AF_INET6; in setup_sockaddr()
312 addr6->sin6_port = htons(cfg_port); in setup_sockaddr()
314 inet_pton(AF_INET6, str_addr, &(addr6->sin6_addr)) != 1) in setup_sockaddr()
327 if (fd == -1) in do_setup_tx()
346 static uint32_t do_process_zerocopy_cookies(struct rds_zcopy_cookies *ck) in do_process_zerocopy_cookies() argument
350 if (ck->num > RDS_MAX_ZCOOKIES) in do_process_zerocopy_cookies()
352 ck->num, RDS_MAX_ZCOOKIES); in do_process_zerocopy_cookies()
353 for (i = 0; i < ck->num; i++) in do_process_zerocopy_cookies()
355 fprintf(stderr, "%d\n", ck->cookies[i]); in do_process_zerocopy_cookies()
356 return ck->num; in do_process_zerocopy_cookies()
362 struct rds_zcopy_cookies *ck; in do_recvmsg_completion() local
378 if (cmsg->cmsg_level == SOL_RDS && in do_recvmsg_completion()
379 cmsg->cmsg_type == RDS_CMSG_ZCOPY_COMPLETION) { in do_recvmsg_completion()
381 ck = (struct rds_zcopy_cookies *)CMSG_DATA(cmsg); in do_recvmsg_completion()
382 completions += do_process_zerocopy_cookies(ck); in do_recvmsg_completion()
387 cmsg->cmsg_level, cmsg->cmsg_type); in do_recvmsg_completion()
408 if (ret == -1 && errno == EAGAIN) in do_recv_completion()
410 if (ret == -1) in do_recv_completion()
418 if (!((cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_RECVERR) || in do_recv_completion()
419 (cm->cmsg_level == SOL_IPV6 && cm->cmsg_type == IPV6_RECVERR) || in do_recv_completion()
420 (cm->cmsg_level == SOL_PACKET && cm->cmsg_type == PACKET_TX_TIMESTAMP))) in do_recv_completion()
422 cm->cmsg_level, cm->cmsg_type); in do_recv_completion()
426 if (serr->ee_origin != SO_EE_ORIGIN_ZEROCOPY) in do_recv_completion()
427 error(1, 0, "serr: wrong origin: %u", serr->ee_origin); in do_recv_completion()
428 if (serr->ee_errno != 0) in do_recv_completion()
429 error(1, 0, "serr: wrong error code: %u", serr->ee_errno); in do_recv_completion()
431 hi = serr->ee_data; in do_recv_completion()
432 lo = serr->ee_info; in do_recv_completion()
433 range = hi - lo + 1; in do_recv_completion()
443 zerocopy = !(serr->ee_code & SO_EE_CODE_ZEROCOPY_COPIED); in do_recv_completion()
444 if (zerocopied == -1) in do_recv_completion()
486 struct ethhdr eth; in do_tx() local
501 memset(eth.h_dest, 0x06, ETH_ALEN); in do_tx()
502 memset(eth.h_source, 0x02, ETH_ALEN); in do_tx()
503 eth.h_proto = htons(proto); in do_tx()
504 iov[0].iov_base = ð in do_tx()
505 iov[0].iov_len = sizeof(eth); in do_tx()
543 msg.msg_iov = &iov[3 - msg.msg_iovlen]; in do_tx()
584 if (fd == -1) in do_setup_rx()
610 if (ret == -1 && errno == EAGAIN) in do_flush_tcp()
612 if (ret == -1) in do_flush_tcp()
629 if (ret == -1 && errno == EAGAIN) in do_flush_datagram()
635 ret -= sizeof(struct iphdr); in do_flush_datagram()
638 if (ret == -1) in do_flush_datagram()
642 if (ret > sizeof(buf) - off) in do_flush_datagram()
643 ret = sizeof(buf) - off; in do_flush_datagram()
701 const int max_payload_len = sizeof(payload) - in parse_opts()
702 sizeof(struct ipv6hdr) - in parse_opts()
703 sizeof(struct tcphdr) - in parse_opts()
711 while ((c = getopt(argc, argv, "46c:C:D:i:mp:rs:S:t:vz")) != -1) { in parse_opts()
715 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
721 error(1, 0, "Pass one of -4 or -6"); in parse_opts()
766 cfg_test = argv[argc - 1]; in parse_opts()
769 error(1, 0, "-D <server addr> required for PF_RDS\n"); in parse_opts()
771 error(1, 0, "-S <client addr> required for PF_RDS\n"); in parse_opts()
777 error(1, 0, "-s: payload exceeds max (%d)", max_payload_len); in parse_opts()
779 error(1, 0, "-m: cork_mixed requires corking and zerocopy"); in parse_opts()
781 if (optind != argc - 1) in parse_opts()
791 cfg_test = argv[argc - 1]; in main()