Lines Matching +full:tx +full:- +full:sec

1 // SPDX-License-Identifier: GPL-2.0
7 * - UDP 9091 packets are diverted into AF_XDP
8 * - Metadata verified:
9 * - rx_timestamp
10 * - rx_hash
12 * TX:
13 * - TBD
44 struct xsk_ring_prod tx; member
76 xsk->umem_area = mmap(NULL, UMEM_SIZE, PROT_READ | PROT_WRITE, mmap_flags, -1, 0); in open_xsk()
77 if (xsk->umem_area == MAP_FAILED) in open_xsk()
78 return -ENOMEM; in open_xsk()
80 ret = xsk_umem__create(&xsk->umem, in open_xsk()
81 xsk->umem_area, UMEM_SIZE, in open_xsk()
82 &xsk->fill, in open_xsk()
83 &xsk->comp, in open_xsk()
88 ret = xsk_socket__create(&xsk->socket, ifindex, queue_id, in open_xsk()
89 xsk->umem, in open_xsk()
90 &xsk->rx, in open_xsk()
91 &xsk->tx, in open_xsk()
96 /* First half of umem is for TX. This way address matches 1-to-1 in open_xsk()
102 printf("%p: tx_desc[%d] -> %lx\n", xsk, i, addr); in open_xsk()
107 ret = xsk_ring_prod__reserve(&xsk->fill, UMEM_NUM / 2, &idx); in open_xsk()
110 printf("%p: rx_desc[%d] -> %lx\n", xsk, i, addr); in open_xsk()
111 *xsk_ring_prod__fill_addr(&xsk->fill, i) = addr; in open_xsk()
113 xsk_ring_prod__submit(&xsk->fill, ret); in open_xsk()
120 if (xsk->umem) in close_xsk()
121 xsk_umem__delete(xsk->umem); in close_xsk()
122 if (xsk->socket) in close_xsk()
123 xsk_socket__delete(xsk->socket); in close_xsk()
124 munmap(xsk->umem_area, UMEM_SIZE); in close_xsk()
131 if (xsk_ring_prod__reserve(&xsk->fill, 1, &idx) == 1) { in refill_rx()
133 *xsk_ring_prod__fill_addr(&xsk->fill, idx) = addr; in refill_rx()
134 xsk_ring_prod__submit(&xsk->fill, 1); in refill_rx()
157 meta = data - sizeof(*meta); in verify_xdp_metadata()
159 if (meta->rx_hash_err < 0) in verify_xdp_metadata()
160 printf("No rx_hash err=%d\n", meta->rx_hash_err); in verify_xdp_metadata()
163 meta->rx_hash, meta->rx_hash_type); in verify_xdp_metadata()
165 printf("rx_timestamp: %llu (sec:%0.4f)\n", meta->rx_timestamp, in verify_xdp_metadata()
166 (double)meta->rx_timestamp / NANOSEC_PER_SEC); in verify_xdp_metadata()
167 if (meta->rx_timestamp) { in verify_xdp_metadata()
169 __u64 xdp_clock = meta->xdp_timestamp; in verify_xdp_metadata()
170 __s64 delta_X = xdp_clock - meta->rx_timestamp; in verify_xdp_metadata()
171 __s64 delta_X2U = usr_clock - xdp_clock; in verify_xdp_metadata()
173 printf("XDP RX-time: %llu (sec:%0.4f) delta sec:%0.4f (%0.3f usec)\n", in verify_xdp_metadata()
178 printf("AF_XDP time: %llu (sec:%0.4f) delta sec:%0.4f (%0.3f usec)\n", in verify_xdp_metadata()
211 if (cmsg->cmsg_level != SOL_SOCKET) in verify_skb_metadata()
214 switch (cmsg->cmsg_type) { in verify_skb_metadata()
217 if (ts->ts[2].tv_sec || ts->ts[2].tv_nsec) { in verify_skb_metadata()
219 ts->ts[2].tv_sec, ts->ts[2].tv_nsec); in verify_skb_metadata()
255 ret, errno, bpf_obj->bss->pkts_skip, in verify_metadata()
256 bpf_obj->bss->pkts_fail, bpf_obj->bss->pkts_redir); in verify_metadata()
271 ret = xsk_ring_cons__peek(&xsk->rx, 1, &idx); in verify_metadata()
276 rx_desc = xsk_ring_cons__rx_desc(&xsk->rx, idx); in verify_metadata()
277 comp_addr = xsk_umem__extract_addr(rx_desc->addr); in verify_metadata()
278 addr = xsk_umem__add_offset_to_addr(rx_desc->addr); in verify_metadata()
279 printf("%p: rx_desc[%u]->addr=%llx addr=%llx comp_addr=%llx\n", in verify_metadata()
280 xsk, idx, rx_desc->addr, addr, comp_addr); in verify_metadata()
281 verify_xdp_metadata(xsk_umem__get_data(xsk->umem_area, addr), in verify_metadata()
283 xsk_ring_cons__release(&xsk->rx, 1); in verify_metadata()
314 strncpy(ifr.ifr_name, ifname, IF_NAMESIZE - 1); in rxq_num()
335 strncpy(ifr.ifr_name, ifname, IF_NAMESIZE - 1); in hwtstamp_ioctl()
377 opts.old_prog_fd = bpf_program__fd(bpf_obj->progs.rx); in cleanup()
410 int server_fd = -1; in main()
418 return -1; in main()
437 error(1, -ret, "open_xsk"); in main()
439 printf("xsk_socket__fd() -> %d\n", xsk_socket__fd(rx_xsk[i].socket)); in main()
447 prog = bpf_object__find_program_by_name(bpf_obj->obj, "rx"); in main()
454 error(1, -ret, "xdp_hw_metadata__load"); in main()
470 ret = bpf_map_update_elem(bpf_map__fd(bpf_obj->maps.xsk), &queue_id, &sock_fd, 0); in main()
472 error(1, -ret, "bpf_map_update_elem"); in main()
477 bpf_program__fd(bpf_obj->progs.rx), in main()
480 error(1, -ret, "bpf_xdp_attach"); in main()
487 error(1, -ret, "verify_metadata"); in main()