Lines Matching +full:sync +full:- +full:token

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
73 o->nro_next = h->nr_options; in nmreq_push_option()
74 h->nr_options = (uintptr_t)o; in nmreq_push_option()
86 #define declprefix(prefix, flags) { (prefix), (sizeof(prefix) - 1), (flags) }
98 h->nr_version = NETMAP_API; in nmreq_header_init()
99 h->nr_reqtype = reqtype; in nmreq_header_init()
100 h->nr_body = (uintptr_t)body; in nmreq_header_init()
114 for (p = nmreq_prefixes; p->prefix != NULL; p++) { in nmreq_header_decode()
115 if (!strncmp(scan, p->prefix, p->len)) in nmreq_header_decode()
118 if (p->prefix == NULL) { in nmreq_header_decode()
122 scan += p->len; in nmreq_header_decode()
131 if (!(p->flags & NR_P_ID)) { in nmreq_header_decode()
132 nmctx_ferror(ctx, "%s: no identifier allowed between '%s' and ':'", *pifname, p->prefix); in nmreq_header_decode()
137 nmctx_ferror(ctx, "%s: invalid identifier '%.*s'", *pifname, vpname - scan, scan); in nmreq_header_decode()
141 if ((p->flags & NR_P_ID) && !(p->flags & NR_P_EMPTYID)) { in nmreq_header_decode()
142 nmctx_ferror(ctx, "%s: identifier is missing between '%s' and ':'", *pifname, p->prefix); in nmreq_header_decode()
147 if (p->flags & NR_P_SKIP) in nmreq_header_decode()
152 for (; *scan && !index("-*^/@", *scan); scan++) in nmreq_header_decode()
166 nmctx_ferror(ctx, "%s: invalid pipe name '%.*s'", *pifname, scan - pipesep, pipesep); in nmreq_header_decode()
171 namelen = scan - ifname; in nmreq_header_decode()
172 if (namelen >= sizeof(h->nr_name)) { in nmreq_header_decode()
182 memcpy(h->nr_name, ifname, namelen); in nmreq_header_decode()
183 h->nr_name[namelen] = '\0'; in nmreq_header_decode()
184 ED("name %s", h->nr_name); in nmreq_header_decode()
191 return -1; in nmreq_header_decode()
197 * -1 error
203 int fd = -1; in nmreq_get_mem_id()
238 return -1; in nmreq_get_mem_id()
260 nr_mem_id = r->nr_mem_id; /* if non-zero, further updates are disabled */ in nmreq_register_decode()
275 case '-': /* one NIC ring pair */ in nmreq_register_decode()
353 scan--; /* escape to options */ in nmreq_register_decode()
395 r->nr_mode = nr_mode; in nmreq_register_decode()
396 r->nr_ringid = nr_ringid; in nmreq_register_decode()
397 r->nr_flags = nr_flags; in nmreq_register_decode()
398 r->nr_mem_id = nr_mem_id; in nmreq_register_decode()
405 return -1; in nmreq_register_decode()
426 if (*scan == '-') in nmreq_option_parsekeys()
432 for (k = p->keys; (k - p->keys) < NMREQ_OPT_MAXKEYS && k->key != NULL; in nmreq_option_parsekeys()
434 if (!strcmp(k->key, key)) in nmreq_option_parsekeys()
438 nmctx_ferror(pctx->ctx, "unknown key: '%s'", key); in nmreq_option_parsekeys()
440 return -1; in nmreq_option_parsekeys()
442 if (pctx->keys[k->id] != NULL) { in nmreq_option_parsekeys()
443 nmctx_ferror(pctx->ctx, "option '%s': duplicate key '%s', already set to '%s'", in nmreq_option_parsekeys()
444 prefix, key, pctx->keys[k->id]); in nmreq_option_parsekeys()
446 return -1; in nmreq_option_parsekeys()
453 vlen = scan - value; in nmreq_option_parsekeys()
456 pctx->keys[k->id] = (vlen ? value : NULL); in nmreq_option_parsekeys()
458 if (!(k->flags & NMREQ_OPTK_ALLOWEMPTY)) { in nmreq_option_parsekeys()
459 nmctx_ferror(pctx->ctx, "option '%s': missing '=value' for key '%s'", in nmreq_option_parsekeys()
462 return -1; in nmreq_option_parsekeys()
464 pctx->keys[k->id] = key; in nmreq_option_parsekeys()
467 /* now check that all no-default keys have been assigned */ in nmreq_option_parsekeys()
468 for (k = p->keys; (k - p->keys) < NMREQ_OPT_MAXKEYS && k->key != NULL; k++) { in nmreq_option_parsekeys()
469 if ((k->flags & NMREQ_OPTK_MUSTSET) && pctx->keys[k->id] == NULL) { in nmreq_option_parsekeys()
470 nmctx_ferror(pctx->ctx, "option '%s': mandatory key '%s' not assigned", in nmreq_option_parsekeys()
471 prefix, k->key); in nmreq_option_parsekeys()
473 return -1; in nmreq_option_parsekeys()
482 void *token, struct nmctx *ctx) in nmreq_option_decode1() argument
499 for (p = parsers; p != NULL; p = p->next) { in nmreq_option_decode1()
500 if (!strcmp(prefix, p->prefix)) in nmreq_option_decode1()
506 return -1; in nmreq_option_decode1()
508 if (p->flags & NMREQ_OPTF_DISABLED) { in nmreq_option_decode1()
511 return -1; in nmreq_option_decode1()
515 pctx.token = token; in nmreq_option_decode1()
521 if (!(p->flags & NMREQ_OPTF_ALLOWEMPTY)) { in nmreq_option_decode1()
525 return -1; in nmreq_option_decode1()
529 if (p->default_key < 0 || p->default_key >= NMREQ_OPT_MAXKEYS) { in nmreq_option_decode1()
533 return -1; in nmreq_option_decode1()
538 return -1; in nmreq_option_decode1()
540 pctx.keys[p->default_key] = scan; in nmreq_option_decode1()
544 return -1; in nmreq_option_decode1()
547 return p->parse(&pctx); in nmreq_option_decode1()
552 void *token, struct nmctx *ctx) in nmreq_options_decode() argument
565 return -1; in nmreq_options_decode()
575 len = scan - opt1; in nmreq_options_decode()
579 return -1; in nmreq_options_decode()
585 return -1; in nmreq_options_decode()
589 ret = nmreq_option_decode1(w, parsers, token, ctx); in nmreq_options_decode()
592 return -1; in nmreq_options_decode()
604 if (o->nro_reqtype == t) in nmreq_find_option()
615 for (nmo = (struct nmreq_option **)&h->nr_options; *nmo != NULL; in nmreq_remove_option()
616 nmo = (struct nmreq_option **)&(*nmo)->nro_next) { in nmreq_remove_option()
618 *((uint64_t *)(*nmo)) = o->nro_next; in nmreq_remove_option()
619 o->nro_next = (uint64_t)(uintptr_t)NULL; in nmreq_remove_option()
633 * modification-safe. in nmreq_free_options()
635 for (o = (struct nmreq_option *)(uintptr_t)h->nr_options; o != NULL; in nmreq_free_options()
637 next = (struct nmreq_option *)(uintptr_t)o->nro_next; in nmreq_free_options()
649 return "sync-kloop-eventfds"; in nmreq_option_name()
653 return "sync-kloop-mode"; in nmreq_option_name()
667 printf(" nr_version: %"PRIu16"\n", d->hdr.nr_version);
668 printf(" nr_reqtype: %"PRIu16"\n", d->hdr.nr_reqtype);
669 printf(" nr_reserved: %"PRIu32"\n", d->hdr.nr_reserved);
670 printf(" nr_name: %s\n", d->hdr.nr_name);
671 printf(" nr_options: %lx\n", (unsigned long)d->hdr.nr_options);
672 printf(" nr_body: %lx\n", (unsigned long)d->hdr.nr_body);
674 printf("register (%p):\n", (void *)d->hdr.nr_body);
675 printf(" nr_mem_id: %"PRIu16"\n", d->reg.nr_mem_id);
676 printf(" nr_ringid: %"PRIu16"\n", d->reg.nr_ringid);
677 printf(" nr_mode: %lx\n", (unsigned long)d->reg.nr_mode);
678 printf(" nr_flags: %lx\n", (unsigned long)d->reg.nr_flags);
680 if (d->hdr.nr_options) {
681 struct nmreq_opt_extmem *e = (struct nmreq_opt_extmem *)d->hdr.nr_options;
683 printf(" nro_opt.nro_next: %lx\n", (unsigned long)e->nro_opt.nro_next);
684 printf(" nro_opt.nro_reqtype: %"PRIu32"\n", e->nro_opt.nro_reqtype);
685 printf(" nro_usrptr: %lx\n", (unsigned long)e->nro_usrptr);
686 printf(" nro_info.nr_memsize %"PRIu64"\n", e->nro_info.nr_memsize);
689 printf("mem (%p):\n", d->mem);
690 printf(" refcount: %d\n", d->mem->refcount);
691 printf(" mem: %p\n", d->mem->mem);
692 printf(" size: %zu\n", d->mem->size);
695 printf(" tx: [%d, %d]\n", d->first_tx_ring, d->last_tx_ring);
696 printf(" rx: [%d, %d]\n", d->first_rx_ring, d->last_rx_ring);
704 fprintf(stderr, "usage: %s netmap-expr\n", argv[0]);