Lines Matching +full:oasis +full:- +full:open

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
32 * # kyua test -k /usr/tests/sys/netmap/Kyuafile
35 * # ./ctrl-api-test
68 return -1; in eventfd()
85 for (i = 0; i < argc - 1; i++) { in exec_command()
88 return -1; in exec_command()
106 fds[i] = open("/dev/null", O_RDONLY); in exec_command()
108 for (i--; i >= 0; i--) { in exec_command()
111 return -1; in exec_command()
120 for (i = 0; i < argc - 1; i++) { in exec_command()
140 return -1; in exec_command()
165 uint32_t sync_kloop_mode; /* sync-kloop */
185 hdr->nr_version = NETMAP_API; in nmreq_hdr_init()
187 strncpy(hdr->nr_name, ifname, sizeof(hdr->nr_name)); in nmreq_hdr_init()
199 printf("Testing NETMAP_REQ_PORT_INFO_GET on '%s'\n", ctx->ifname_ext); in port_info_get()
201 nmreq_hdr_init(&hdr, ctx->ifname_ext); in port_info_get()
205 req.nr_mem_id = ctx->nr_mem_id; in port_info_get()
206 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in port_info_get()
221 return -1; in port_info_get()
225 ctx->nr_tx_slots = req.nr_tx_slots; in port_info_get()
226 ctx->nr_rx_slots = req.nr_rx_slots; in port_info_get()
227 ctx->nr_tx_rings = req.nr_tx_rings; in port_info_get()
228 ctx->nr_rx_rings = req.nr_rx_rings; in port_info_get()
229 ctx->nr_mem_id = req.nr_mem_id; in port_info_get()
245 ctx->nr_mode, ctx->nr_ringid, (unsigned long long)ctx->nr_flags, in port_register()
246 ctx->ifname_ext); in port_register()
248 nmreq_hdr_init(&hdr, ctx->ifname_ext); in port_register()
251 hdr.nr_options = (uintptr_t)ctx->nr_opt; in port_register()
253 req.nr_mem_id = ctx->nr_mem_id; in port_register()
254 req.nr_mode = ctx->nr_mode; in port_register()
255 req.nr_ringid = ctx->nr_ringid; in port_register()
256 req.nr_flags = ctx->nr_flags; in port_register()
257 req.nr_tx_slots = ctx->nr_tx_slots; in port_register()
258 req.nr_rx_slots = ctx->nr_rx_slots; in port_register()
259 req.nr_tx_rings = ctx->nr_tx_rings; in port_register()
260 req.nr_host_tx_rings = ctx->nr_host_tx_rings; in port_register()
261 req.nr_host_rx_rings = ctx->nr_host_rx_rings; in port_register()
262 req.nr_rx_rings = ctx->nr_rx_rings; in port_register()
263 req.nr_extra_bufs = ctx->nr_extra_bufs; in port_register()
264 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in port_register()
280 success = req.nr_memsize && (ctx->nr_mode == req.nr_mode) && in port_register()
281 (ctx->nr_ringid == req.nr_ringid) && in port_register()
282 (ctx->nr_flags == req.nr_flags) && in port_register()
283 ((!ctx->nr_tx_slots && req.nr_tx_slots) || in port_register()
284 (ctx->nr_tx_slots == req.nr_tx_slots)) && in port_register()
285 ((!ctx->nr_rx_slots && req.nr_rx_slots) || in port_register()
286 (ctx->nr_rx_slots == req.nr_rx_slots)) && in port_register()
287 ((!ctx->nr_tx_rings && req.nr_tx_rings) || in port_register()
288 (ctx->nr_tx_rings == req.nr_tx_rings)) && in port_register()
289 ((!ctx->nr_rx_rings && req.nr_rx_rings) || in port_register()
290 (ctx->nr_rx_rings == req.nr_rx_rings)) && in port_register()
291 ((!ctx->nr_host_tx_rings && req.nr_host_tx_rings) || in port_register()
292 (ctx->nr_host_tx_rings == req.nr_host_tx_rings)) && in port_register()
293 ((!ctx->nr_host_rx_rings && req.nr_host_rx_rings) || in port_register()
294 (ctx->nr_host_rx_rings == req.nr_host_rx_rings)) && in port_register()
295 ((!ctx->nr_mem_id && req.nr_mem_id) || in port_register()
296 (ctx->nr_mem_id == req.nr_mem_id)) && in port_register()
297 (ctx->nr_extra_bufs == req.nr_extra_bufs); in port_register()
299 return -1; in port_register()
303 ctx->nr_tx_slots = req.nr_tx_slots; in port_register()
304 ctx->nr_rx_slots = req.nr_rx_slots; in port_register()
305 ctx->nr_tx_rings = req.nr_tx_rings; in port_register()
306 ctx->nr_rx_rings = req.nr_rx_rings; in port_register()
307 ctx->nr_host_tx_rings = req.nr_host_tx_rings; in port_register()
308 ctx->nr_host_rx_rings = req.nr_host_rx_rings; in port_register()
309 ctx->nr_mem_id = req.nr_mem_id; in port_register()
310 ctx->nr_extra_bufs = req.nr_extra_bufs; in port_register()
322 printf("Testing legacy NIOCREGIF on '%s'\n", ctx->ifname_ext); in niocregif()
325 memcpy(req.nr_name, ctx->ifname_ext, sizeof(req.nr_name)); in niocregif()
326 req.nr_name[sizeof(req.nr_name) - 1] = '\0'; in niocregif()
328 req.nr_ringid = ctx->nr_ringid; in niocregif()
329 req.nr_flags = ctx->nr_mode | ctx->nr_flags; in niocregif()
330 req.nr_tx_slots = ctx->nr_tx_slots; in niocregif()
331 req.nr_rx_slots = ctx->nr_rx_slots; in niocregif()
332 req.nr_tx_rings = ctx->nr_tx_rings; in niocregif()
333 req.nr_rx_rings = ctx->nr_rx_rings; in niocregif()
334 req.nr_arg2 = ctx->nr_mem_id; in niocregif()
335 req.nr_arg3 = ctx->nr_extra_bufs; in niocregif()
337 ret = ioctl(ctx->fd, NIOCREGIF, &req); in niocregif()
356 (ctx->nr_ringid == req.nr_ringid) && in niocregif()
357 ((ctx->nr_mode | ctx->nr_flags) == req.nr_flags) && in niocregif()
358 ((!ctx->nr_tx_slots && req.nr_tx_slots) || in niocregif()
359 (ctx->nr_tx_slots == req.nr_tx_slots)) && in niocregif()
360 ((!ctx->nr_rx_slots && req.nr_rx_slots) || in niocregif()
361 (ctx->nr_rx_slots == req.nr_rx_slots)) && in niocregif()
362 ((!ctx->nr_tx_rings && req.nr_tx_rings) || in niocregif()
363 (ctx->nr_tx_rings == req.nr_tx_rings)) && in niocregif()
364 ((!ctx->nr_rx_rings && req.nr_rx_rings) || in niocregif()
365 (ctx->nr_rx_rings == req.nr_rx_rings)) && in niocregif()
366 ((!ctx->nr_mem_id && req.nr_arg2) || in niocregif()
367 (ctx->nr_mem_id == req.nr_arg2)) && in niocregif()
368 (ctx->nr_extra_bufs == req.nr_arg3); in niocregif()
370 return -1; in niocregif()
374 ctx->nr_tx_slots = req.nr_tx_slots; in niocregif()
375 ctx->nr_rx_slots = req.nr_rx_slots; in niocregif()
376 ctx->nr_tx_rings = req.nr_tx_rings; in niocregif()
377 ctx->nr_rx_rings = req.nr_rx_rings; in niocregif()
378 ctx->nr_mem_id = req.nr_arg2; in niocregif()
379 ctx->nr_extra_bufs = req.nr_arg3; in niocregif()
401 ctx->nr_mode = NR_REG_ALL_NIC; in legacy_regif_all_nic()
408 ctx->nr_mode = NR_REG_ALL_NIC; in legacy_regif_12()
415 ctx->nr_mode = NR_REG_SW; in legacy_regif_sw()
422 ctx->nr_mode = NR_REG_NIC_SW; in legacy_regif_future()
432 ctx->nr_mode = NR_REG_ALL_NIC; in legacy_regif_extra_bufs()
433 ctx->nr_extra_bufs = 20; /* arbitrary number of extra bufs */ in legacy_regif_extra_bufs()
440 strncat(ctx->ifname_ext, "{pipeexbuf", sizeof(ctx->ifname_ext)); in legacy_regif_extra_bufs_pipe()
441 ctx->nr_mode = NR_REG_ALL_NIC; in legacy_regif_extra_bufs_pipe()
442 ctx->nr_extra_bufs = 58; /* arbitrary number of extra bufs */ in legacy_regif_extra_bufs_pipe()
450 strncpy(ctx->ifname_ext, "valeX1:Y4", sizeof(ctx->ifname_ext)); in legacy_regif_extra_bufs_pipe_vale()
458 if (ctx->nr_flags & NR_TX_RINGS_ONLY) { in num_registered_rings()
459 return ctx->nr_tx_rings; in num_registered_rings()
461 if (ctx->nr_flags & NR_RX_RINGS_ONLY) { in num_registered_rings()
462 return ctx->nr_rx_rings; in num_registered_rings()
465 return ctx->nr_tx_rings + ctx->nr_rx_rings; in num_registered_rings()
471 ctx->nr_mode = NR_REG_NIC_SW; in port_register_hwall_host()
478 ctx->nr_mode = NR_REG_SW; in port_register_hostall()
485 ctx->nr_mode = NR_REG_ALL_NIC; in port_register_hwall()
492 ctx->nr_mode = NR_REG_ONE_NIC; in port_register_single_hw_pair()
493 ctx->nr_ringid = 0; in port_register_single_hw_pair()
500 ctx->nr_mode = NR_REG_ONE_SW; in port_register_single_host_pair()
501 ctx->nr_host_tx_rings = 2; in port_register_single_host_pair()
502 ctx->nr_host_rx_rings = 2; in port_register_single_host_pair()
503 ctx->nr_ringid = 1; in port_register_single_host_pair()
510 ctx->nr_mode = NR_REG_SW; in port_register_hostall_many()
511 ctx->nr_host_tx_rings = 5; in port_register_hostall_many()
512 ctx->nr_host_rx_rings = 4; in port_register_hostall_many()
519 ctx->nr_mode = NR_REG_ALL_NIC; in port_register_hwall_tx()
520 ctx->nr_flags |= NR_TX_RINGS_ONLY; in port_register_hwall_tx()
527 ctx->nr_mode = NR_REG_ALL_NIC; in port_register_hwall_rx()
528 ctx->nr_flags |= NR_RX_RINGS_ONLY; in port_register_hwall_rx()
536 if (snprintf(vpname, NM_IFNAMSZ, "%s:%s", ctx->bdgname, ctx->ifname_ext) >= NM_IFNAMSZ) { in vale_mkname()
537 fprintf(stderr, "%s:%s too long (max %d chars)\n", ctx->bdgname, ctx->ifname_ext, in vale_mkname()
538 NM_IFNAMSZ - 1); in vale_mkname()
539 return -1; in vale_mkname()
555 return -1; in vale_attach()
562 req.reg.nr_mem_id = ctx->nr_mem_id; in vale_attach()
563 if (ctx->nr_mode == 0) { in vale_attach()
564 ctx->nr_mode = NR_REG_ALL_NIC; /* default */ in vale_attach()
566 req.reg.nr_mode = ctx->nr_mode; in vale_attach()
567 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in vale_attach()
574 return ((!ctx->nr_mem_id && req.reg.nr_mem_id > 1) || in vale_attach()
575 (ctx->nr_mem_id == req.reg.nr_mem_id)) && in vale_attach()
576 (ctx->nr_flags == req.reg.nr_flags) in vale_attach()
578 : -1; in vale_attach()
591 return -1; in vale_detach()
597 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in vale_detach()
622 ctx->nr_mode = NR_REG_NIC_SW; in vale_attach_detach_host_rings()
635 printf("Testing NETMAP_REQ_PORT_HDR_SET on '%s'\n", ctx->ifname_ext); in port_hdr_set_and_get()
637 nmreq_hdr_init(&hdr, ctx->ifname_ext); in port_hdr_set_and_get()
641 req.nr_hdr_len = ctx->nr_hdr_len; in port_hdr_set_and_get()
642 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in port_hdr_set_and_get()
648 if (req.nr_hdr_len != ctx->nr_hdr_len) { in port_hdr_set_and_get()
649 return -1; in port_hdr_set_and_get()
652 printf("Testing NETMAP_REQ_PORT_HDR_GET on '%s'\n", ctx->ifname_ext); in port_hdr_set_and_get()
655 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in port_hdr_set_and_get()
662 return (req.nr_hdr_len == ctx->nr_hdr_len) ? 0 : -1; in port_hdr_set_and_get()
668 * http://docs.oasis-open.org/virtio/virtio/v1.0/cs04/virtio-v1.0-cs04.html
678 strncpy(ctx->ifname_ext, "vale:eph0", sizeof(ctx->ifname_ext)); in vale_ephemeral_port_hdr_manipulation()
679 ctx->nr_mode = NR_REG_ALL_NIC; in vale_ephemeral_port_hdr_manipulation()
684 ctx->nr_hdr_len = VIRTIO_NET_HDR_LEN_WITH_MERGEABLE_RXBUFS; in vale_ephemeral_port_hdr_manipulation()
688 ctx->nr_hdr_len = 0; in vale_ephemeral_port_hdr_manipulation()
692 ctx->nr_hdr_len = VIRTIO_NET_HDR_LEN; in vale_ephemeral_port_hdr_manipulation()
707 strncpy(ctx->ifname_ext, "per4", sizeof(ctx->ifname_ext)); in vale_persistent_port()
709 printf("Testing NETMAP_REQ_VALE_NEWIF on '%s'\n", ctx->ifname_ext); in vale_persistent_port()
711 nmreq_hdr_init(&hdr, ctx->ifname_ext); in vale_persistent_port()
715 req.nr_mem_id = ctx->nr_mem_id; in vale_persistent_port()
716 req.nr_tx_slots = ctx->nr_tx_slots; in vale_persistent_port()
717 req.nr_rx_slots = ctx->nr_rx_slots; in vale_persistent_port()
718 req.nr_tx_rings = ctx->nr_tx_rings; in vale_persistent_port()
719 req.nr_rx_rings = ctx->nr_rx_rings; in vale_persistent_port()
720 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in vale_persistent_port()
729 printf("Testing NETMAP_REQ_VALE_DELIF on '%s'\n", ctx->ifname_ext); in vale_persistent_port()
732 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in vale_persistent_port()
751 printf("Testing NETMAP_REQ_POOLS_INFO_GET on '%s'\n", ctx->ifname_ext); in pools_info_get()
753 nmreq_hdr_init(&hdr, ctx->ifname_ext); in pools_info_get()
757 req.nr_mem_id = ctx->nr_mem_id; in pools_info_get()
758 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in pools_info_get()
785 : -1; in pools_info_get()
800 ctx->nr_mode = NR_REG_ONE_NIC; in pools_info_get_and_register()
805 ctx->nr_mem_id = 1; in pools_info_get_and_register()
814 strncpy(ctx->ifname_ext, "", sizeof(ctx->ifname_ext)); in pools_info_get_empty_ifname()
815 return pools_info_get(ctx) != 0 ? 0 : -1; in pools_info_get_empty_ifname()
821 strncat(ctx->ifname_ext, "{pipeid1", sizeof(ctx->ifname_ext)); in pipe_master()
822 ctx->nr_mode = NR_REG_NIC_SW; in pipe_master()
826 return -1; in pipe_master()
828 ctx->nr_mode = NR_REG_ALL_NIC; in pipe_master()
836 strncat(ctx->ifname_ext, "}pipeid2", sizeof(ctx->ifname_ext)); in pipe_slave()
837 ctx->nr_mode = NR_REG_ALL_NIC; in pipe_slave()
847 strncat(ctx->ifname_ext, "}pipeid3", sizeof(ctx->ifname_ext)); in pipe_port_info_get()
855 strncat(ctx->ifname_ext, "{xid", sizeof(ctx->ifname_ext)); in pipe_pools_info_get()
870 return -1; in vale_polling_enable()
878 req.nr_mode = ctx->nr_mode; in vale_polling_enable()
879 req.nr_first_cpu_id = ctx->nr_first_cpu_id; in vale_polling_enable()
880 req.nr_num_polling_cpus = ctx->nr_num_polling_cpus; in vale_polling_enable()
881 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in vale_polling_enable()
887 return (req.nr_mode == ctx->nr_mode && in vale_polling_enable()
888 req.nr_first_cpu_id == ctx->nr_first_cpu_id && in vale_polling_enable()
889 req.nr_num_polling_cpus == ctx->nr_num_polling_cpus) in vale_polling_enable()
891 : -1; in vale_polling_enable()
904 return -1; in vale_polling_disable()
912 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in vale_polling_disable()
930 ctx->nr_mode = NETMAP_POLLING_MODE_SINGLE_CPU; in vale_polling_enable_disable()
931 ctx->nr_num_polling_cpus = 1; in vale_polling_enable_disable()
932 ctx->nr_first_cpu_id = 0; in vale_polling_enable_disable()
956 opt->nro_next = (uintptr_t)ctx->nr_opt; in push_option()
957 ctx->nr_opt = opt; in push_option()
963 ctx->nr_opt = NULL; in clear_options()
969 if (opt->nro_next != exp->nro_next) { in checkoption()
971 (void *)(uintptr_t)opt->nro_next, in checkoption()
972 (void *)(uintptr_t)exp->nro_next); in checkoption()
973 return -1; in checkoption()
975 if (opt->nro_reqtype != exp->nro_reqtype) { in checkoption()
976 printf("nro_reqtype %u expected %u\n", opt->nro_reqtype, in checkoption()
977 exp->nro_reqtype); in checkoption()
978 return -1; in checkoption()
980 if (opt->nro_status != exp->nro_status) { in checkoption()
981 printf("nro_status %u expected %u\n", opt->nro_status, in checkoption()
982 exp->nro_status); in checkoption()
983 return -1; in checkoption()
993 printf("Testing unsupported option on %s\n", ctx->ifname_ext); in unsupported_option()
1001 return -1; in unsupported_option()
1013 printf("Testing infinite list of options on %s (invalid options)\n", ctx->ifname_ext); in infinite_options()
1020 return -1; in infinite_options()
1022 return (errno == EMSGSIZE ? 0 : -1); in infinite_options()
1030 printf("Testing infinite list of options on %s (valid options)\n", ctx->ifname_ext); in infinite_options2()
1037 return -1; in infinite_options2()
1039 return (errno == EINVAL ? 0 : -1); in infinite_options2()
1051 strncat(param, pname, sizeof(param) - 1); in change_param()
1056 return -1; in change_param()
1061 return -1; in change_param()
1069 return -1; in change_param()
1072 printf("change_param: %s: %ld -> %ld\n", pname, oldv, newv); in change_param()
1083 addr = mmap(NULL, pi->nr_memsize, PROT_READ | PROT_WRITE, in push_extmem_option()
1084 MAP_ANONYMOUS | MAP_SHARED, -1, 0); in push_extmem_option()
1087 return -1; in push_extmem_option()
1091 e->nro_opt.nro_reqtype = NETMAP_REQ_OPT_EXTMEM; in push_extmem_option()
1092 e->nro_info = *pi; in push_extmem_option()
1093 e->nro_usrptr = (uintptr_t)addr; in push_extmem_option()
1095 push_option(&e->nro_opt, ctx); in push_extmem_option()
1106 e = (struct nmreq_opt_extmem *)(uintptr_t)ctx->nr_opt; in pop_extmem_option()
1107 ctx->nr_opt = (struct nmreq_option *)(uintptr_t)ctx->nr_opt->nro_next; in pop_extmem_option()
1109 if ((ret = checkoption(&e->nro_opt, &exp->nro_opt))) { in pop_extmem_option()
1113 if (e->nro_usrptr != exp->nro_usrptr) { in pop_extmem_option()
1115 e->nro_usrptr, exp->nro_usrptr); in pop_extmem_option()
1116 return -1; in pop_extmem_option()
1118 if (e->nro_info.nr_memsize != exp->nro_info.nr_memsize) { in pop_extmem_option()
1120 e->nro_info.nr_memsize, exp->nro_info.nr_memsize); in pop_extmem_option()
1121 return -1; in pop_extmem_option()
1124 if ((ret = munmap((void *)(uintptr_t)e->nro_usrptr, in pop_extmem_option()
1125 e->nro_info.nr_memsize))) in pop_extmem_option()
1143 strncpy(ctx->ifname_ext, "vale0:0", sizeof(ctx->ifname_ext)); in _extmem_option()
1144 ctx->nr_tx_slots = 16; in _extmem_option()
1145 ctx->nr_rx_slots = 16; in _extmem_option()
1160 tot += pi->nr_if_pool_objtotal * pi->nr_if_pool_objsize; in pools_info_min_memsize()
1161 tot += pi->nr_ring_pool_objtotal * pi->nr_ring_pool_objsize; in pools_info_min_memsize()
1162 tot += pi->nr_buf_pool_objtotal * pi->nr_buf_pool_objsize; in pools_info_min_memsize()
1176 pi->nr_if_pool_objtotal = 2; in pools_info_fill()
1177 pi->nr_if_pool_objsize = 1024; in pools_info_fill()
1178 pi->nr_ring_pool_objtotal = 64; in pools_info_fill()
1179 pi->nr_ring_pool_objsize = 512; in pools_info_fill()
1180 pi->nr_buf_pool_objtotal = 4096; in pools_info_fill()
1181 pi->nr_buf_pool_objsize = 2048; in pools_info_fill()
1182 pi->nr_memsize = pools_info_min_memsize(pi); in pools_info_fill()
1208 return _extmem_option(ctx, &pools_info) < 0 ? 0 : -1; in bad_extmem_option()
1233 strncpy(ctx->ifname_ext, "vale0:0", sizeof(ctx->ifname_ext)); in duplicate_extmem_options()
1234 ctx->nr_tx_slots = 16; in duplicate_extmem_options()
1235 ctx->nr_rx_slots = 16; in duplicate_extmem_options()
1240 return -1; in duplicate_extmem_options()
1262 ctx->nr_flags |= NR_EXCLUSIVE; in push_csb_option()
1274 if (ctx->csb) { in push_csb_option()
1275 free(ctx->csb); in push_csb_option()
1277 ret = posix_memalign(&ctx->csb, sizeof(struct nm_csb_atok), csb_size); in push_csb_option()
1284 opt->nro_opt.nro_reqtype = NETMAP_REQ_OPT_CSB; in push_csb_option()
1285 opt->csb_atok = (uintptr_t)ctx->csb; in push_csb_option()
1286 opt->csb_ktoa = (uintptr_t)(((uint8_t *)ctx->csb) + in push_csb_option()
1290 push_option(&opt->nro_opt, ctx); in push_csb_option()
1324 ctx->nr_flags = NR_EXCLUSIVE; in csb_mode_invalid_memory()
1328 return (ret < 0) ? 0 : -1; in csb_mode_invalid_memory()
1337 printf("Testing NETMAP_REQ_SYNC_KLOOP_STOP on '%s'\n", ctx->ifname_ext); in sync_kloop_stop()
1339 nmreq_hdr_init(&hdr, ctx->ifname_ext); in sync_kloop_stop()
1341 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in sync_kloop_stop()
1357 printf("Testing NETMAP_REQ_SYNC_KLOOP_START on '%s'\n", ctx->ifname_ext); in sync_kloop_worker()
1359 nmreq_hdr_init(&hdr, ctx->ifname_ext); in sync_kloop_worker()
1362 hdr.nr_options = (uintptr_t)ctx->nr_opt; in sync_kloop_worker()
1365 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in sync_kloop_worker()
1370 if (ctx->sem) { in sync_kloop_worker()
1371 sem_post(ctx->sem); in sync_kloop_worker()
1387 return -1; in sync_kloop_start_stop()
1400 return thret == THRET_SUCCESS ? 0 : -1; in sync_kloop_start_stop()
1428 modeopt.mode = ctx->sync_kloop_mode; in sync_kloop_eventfds()
1432 opt_size = sizeof(*evopt) + num_entries * sizeof(evopt->eventfds[0]); in sync_kloop_eventfds()
1434 evopt->nro_opt.nro_next = 0; in sync_kloop_eventfds()
1435 evopt->nro_opt.nro_reqtype = NETMAP_REQ_OPT_SYNC_KLOOP_EVENTFDS; in sync_kloop_eventfds()
1436 evopt->nro_opt.nro_status = 0; in sync_kloop_eventfds()
1437 evopt->nro_opt.nro_size = opt_size; in sync_kloop_eventfds()
1441 evopt->eventfds[i].ioeventfd = efd; in sync_kloop_eventfds()
1443 evopt->eventfds[i].irqfd = efd; in sync_kloop_eventfds()
1446 push_option(&evopt->nro_opt, ctx); in sync_kloop_eventfds()
1447 evsave = evopt->nro_opt; in sync_kloop_eventfds()
1461 ret = checkoption(&evopt->nro_opt, &evsave); in sync_kloop_eventfds()
1479 ctx->sync_kloop_mode = sync_kloop_mode; in sync_kloop_eventfds_all_mode()
1543 return sync_kloop_start_stop(ctx) != 0 ? 0 : -1; in sync_kloop_nocsb()
1561 nmreq_hdr_init(&hdr, ctx->ifname_ext); in csb_enable()
1563 hdr.nr_options = (uintptr_t)ctx->nr_opt; in csb_enable()
1566 printf("Testing NETMAP_REQ_CSB_ENABLE on '%s'\n", ctx->ifname_ext); in csb_enable()
1568 ret = ioctl(ctx->fd, NIOCCTRL, &hdr); in csb_enable()
1585 ctx->nr_flags |= NR_EXCLUSIVE; in sync_kloop_csb_enable()
1627 ctx->sem = &sem;
1647 * CPU on a single-CPU system until the semaphore timeout
1675 ctx->sem = NULL;
1684 : -1;
1709 ctx->nr_flags &= ~NR_RX_RINGS_ONLY; in sync_kloop_eventfds_mismatch()
1711 return (sync_kloop_eventfds(ctx) != 0) ? 0 : -1; in sync_kloop_eventfds_mismatch()
1719 ctx->nr_mem_id = 1; in null_port()
1720 ctx->nr_mode = NR_REG_NULL; in null_port()
1721 ctx->nr_tx_rings = 10; in null_port()
1722 ctx->nr_rx_rings = 5; in null_port()
1723 ctx->nr_tx_slots = 256; in null_port()
1724 ctx->nr_rx_slots = 100; in null_port()
1737 ctx->nr_mem_id = 1; in null_port_all_zero()
1738 ctx->nr_mode = NR_REG_NULL; in null_port_all_zero()
1739 ctx->nr_tx_rings = 0; in null_port_all_zero()
1740 ctx->nr_rx_rings = 0; in null_port_all_zero()
1741 ctx->nr_tx_slots = 0; in null_port_all_zero()
1742 ctx->nr_rx_slots = 0; in null_port_all_zero()
1755 ctx->nr_mem_id = 1; in null_port_sync()
1756 ctx->nr_mode = NR_REG_NULL; in null_port_sync()
1757 ctx->nr_tx_rings = 10; in null_port_sync()
1758 ctx->nr_rx_rings = 5; in null_port_sync()
1759 ctx->nr_tx_slots = 256; in null_port_sync()
1760 ctx->nr_rx_slots = 100; in null_port_sync()
1765 ret = ioctl(ctx->fd, NIOCTXSYNC, 0); in null_port_sync()
1784 * - port: what should go into hdr.nr_name
1785 * - suff: the trailing part of the input after parsing (NULL means equal to port spec)
1786 * - err: the expected return value, interpreted as follows
1791 * - mode, ringid flags: what should go into the corresponding nr_* fields in the
1797 { "netmap:eth0-1", "eth0", "", 0, NR_REG_ONE_NIC, 1, 0 },
1798 { "netmap:eth0-", "eth0", "-", -EINVAL,0, 0, 0 },
1803 { "netmap:eth0-2/Tx", "eth0", "", 0, NR_REG_ONE_NIC, 2, NR_TX_RINGS_ONLY|NR_EXCLUSIVE },
1811 { "netmap:eth0@2/R@3", "eth0", "@2/R@3", -EINVAL,0, 0, 0 },
1812 { "netmap:eth0@", "eth0", "@", -EINVAL,0, 0, 0 },
1820 { "valeXXX:YYY-4", "valeXXX:YYY", "", 0, NR_REG_ONE_NIC, 4, 0 },
1825 { "netmap:pipe{in-7", "pipe{in", "", 0, NR_REG_ONE_NIC, 7, 0 },
1830 { "vale0:0-3@opt", "vale0:0", "@opt", 0, NR_REG_ONE_NIC, 3, 0 },
1831 { "vale0:0@", "vale0:0", "@", -EINVAL,0, 0, 0 },
1854 save = ctx->ifparse = t->ifname; in nmreq_hdr_parsing()
1857 printf("nmreq_header: \"%s\"\n", ctx->ifparse); in nmreq_hdr_parsing()
1858 if (nmreq_header_decode(&ctx->ifparse, hdr, ctx->nmctx) < 0) { in nmreq_hdr_parsing()
1859 if (t->exp_error > 0) { in nmreq_hdr_parsing()
1860 if (errno != t->exp_error) { in nmreq_hdr_parsing()
1862 errno, t->exp_error); in nmreq_hdr_parsing()
1863 return -1; in nmreq_hdr_parsing()
1865 if (ctx->ifparse != save) { in nmreq_hdr_parsing()
1867 return -1; in nmreq_hdr_parsing()
1871 return -1; in nmreq_hdr_parsing()
1876 return -1; in nmreq_hdr_parsing()
1878 if (t->exp_error > 0) { in nmreq_hdr_parsing()
1879 printf("!!! nmreq_header_decode returns 0, but error %d was expected\n", t->exp_error); in nmreq_hdr_parsing()
1880 return -1; in nmreq_hdr_parsing()
1882 if (strcmp(t->exp_port, hdr->nr_name) != 0) { in nmreq_hdr_parsing()
1883 printf("!!! got '%s', want '%s'\n", hdr->nr_name, t->exp_port); in nmreq_hdr_parsing()
1884 return -1; in nmreq_hdr_parsing()
1886 if (hdr->nr_reqtype != orig_hdr.nr_reqtype || in nmreq_hdr_parsing()
1887 hdr->nr_options != orig_hdr.nr_options || in nmreq_hdr_parsing()
1888 hdr->nr_body != orig_hdr.nr_body) { in nmreq_hdr_parsing()
1890 return -1; in nmreq_hdr_parsing()
1904 save = ctx->ifparse; in nmreq_reg_parsing()
1907 printf("nmreq_register: \"%s\"\n", ctx->ifparse); in nmreq_reg_parsing()
1908 if (nmreq_register_decode(&ctx->ifparse, reg, ctx->nmctx) < 0) { in nmreq_reg_parsing()
1909 if (t->exp_error < 0) { in nmreq_reg_parsing()
1910 if (errno != -t->exp_error) { in nmreq_reg_parsing()
1912 errno, -t->exp_error); in nmreq_reg_parsing()
1913 return -1; in nmreq_reg_parsing()
1915 if (ctx->ifparse != save) { in nmreq_reg_parsing()
1917 return -1; in nmreq_reg_parsing()
1921 return -1; in nmreq_reg_parsing()
1926 return -1; in nmreq_reg_parsing()
1928 if (t->exp_error < 0) { in nmreq_reg_parsing()
1929 printf("!!! nmreq_register_decode returns 0, but error %d was expected\n", -t->exp_error); in nmreq_reg_parsing()
1930 return -1; in nmreq_reg_parsing()
1932 if (reg->nr_mode != t->exp_mode) { in nmreq_reg_parsing()
1933 printf("!!! got nr_mode '%d', want '%d'\n", reg->nr_mode, t->exp_mode); in nmreq_reg_parsing()
1934 return -1; in nmreq_reg_parsing()
1936 if (reg->nr_ringid != t->exp_ringid) { in nmreq_reg_parsing()
1937 printf("!!! got nr_ringid '%d', want '%d'\n", reg->nr_ringid, t->exp_ringid); in nmreq_reg_parsing()
1938 return -1; in nmreq_reg_parsing()
1940 if (reg->nr_flags != t->exp_flags) { in nmreq_reg_parsing()
1941 printf("!!! got nm_flags '%llx', want '%llx\n", (unsigned long long)reg->nr_flags, in nmreq_reg_parsing()
1942 (unsigned long long)t->exp_flags); in nmreq_reg_parsing()
1943 return -1; in nmreq_reg_parsing()
1945 if (reg->nr_offset != orig_reg.nr_offset || in nmreq_reg_parsing()
1946 reg->nr_memsize != orig_reg.nr_memsize || in nmreq_reg_parsing()
1947 reg->nr_tx_slots != orig_reg.nr_tx_slots || in nmreq_reg_parsing()
1948 reg->nr_rx_slots != orig_reg.nr_rx_slots || in nmreq_reg_parsing()
1949 reg->nr_tx_rings != orig_reg.nr_tx_rings || in nmreq_reg_parsing()
1950 reg->nr_rx_rings != orig_reg.nr_rx_rings || in nmreq_reg_parsing()
1951 reg->nr_extra_bufs != orig_reg.nr_extra_bufs) in nmreq_reg_parsing()
1954 return -1; in nmreq_reg_parsing()
1978 return -1; in nmreq_parsing()
1982 ctx->nmctx = &test_nmctx; in nmreq_parsing()
1983 for (t = nmreq_parse_tests; t->ifname != NULL; t++) { in nmreq_parsing()
1984 const char *exp_suff = t->exp_suff != NULL ? in nmreq_parsing()
1985 t->exp_suff : t->ifname; in nmreq_parsing()
1991 ret = -1; in nmreq_parsing()
1992 } else if (t->exp_error <= 0 && nmreq_reg_parsing(ctx, t, &reg) < 0) { in nmreq_parsing()
1993 ret = -1; in nmreq_parsing()
1995 if (strcmp(ctx->ifparse, exp_suff) != 0) { in nmreq_parsing()
1997 ctx->ifparse, exp_suff); in nmreq_parsing()
1998 ret = -1; in nmreq_parsing()
2001 ctx->nmctx = NULL; in nmreq_parsing()
2012 return -1;\ in binarycomp()
2039 printf("%s -i IFNAME\n" in usage()
2040 "[-j TEST_NUM1[-[TEST_NUM2]] | -[TEST_NUM_2]]\n" in usage()
2041 "[-l (list test cases)]\n", in usage()
2114 if (ctx->csb) { in context_cleanup()
2115 free(ctx->csb); in context_cleanup()
2116 ctx->csb = NULL; in context_cleanup()
2119 close(ctx->fd); in context_cleanup()
2120 ctx->fd = -1; in context_cleanup()
2130 *k = -1; in parse_interval()
2131 if (*scan == '-') { in parse_interval()
2138 *j = *k - 1; in parse_interval()
2140 if (*scan == '-') { in parse_interval()
2141 *k = -1; in parse_interval()
2157 fprintf(stderr, "syntax error in '%s', must be num[-[num]] or -[num]\n", arg); in parse_interval()
2158 return -1; in parse_interval()
2197 int k = -1; in main()
2221 while ((opt = getopt(argc, argv, "hi:j:l")) != -1) { in main()
2228 strncpy(ctx_.ifname, optarg, sizeof(ctx_.ifname) - 1); in main()
2235 return -1; in main()
2247 return -1; in main()
2254 fprintf(stderr, "Test interval %d-%d out of range (%d-%d)\n", in main()
2256 return -1; in main()
2291 return -1; in main()
2313 fd = open("/dev/netmap", O_RDWR); in main()
2315 perror("open(/dev/netmap)"); in main()