FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
unformat.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2020 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #include <vlib/vlib.h>
19 #include <af_xdp/af_xdp.h>
20 
21 uword
23 {
24  af_xdp_create_if_args_t *args = va_arg (*vargs, af_xdp_create_if_args_t *);
25  unformat_input_t _line_input, *line_input = &_line_input;
26  uword ret = 1;
27 
28  if (!unformat_user (input, unformat_line_input, line_input))
29  return 0;
30 
31  clib_memset (args, 0, sizeof (*args));
32 
33  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
34  {
35  if (unformat (line_input, "host-if %s", &args->linux_ifname))
36  ;
37  else if (unformat (line_input, "name %s", &args->name))
38  ;
39  else if (unformat (line_input, "rx-queue-size %u", &args->rxq_size))
40  ;
41  else if (unformat (line_input, "tx-queue-size %u", &args->txq_size))
42  ;
43  else if (unformat (line_input, "num-rx-queues all"))
45  else if (unformat (line_input, "num-rx-queues %u", &args->rxq_num))
46  ;
47  else if (unformat (line_input, "prog %s", &args->prog))
48  ;
49  else if (unformat (line_input, "no-zero-copy"))
50  args->mode = AF_XDP_MODE_COPY;
51  else if (unformat (line_input, "zero-copy"))
53  else if (unformat (line_input, "no-syscall-lock"))
55  else
56  {
57  /* return failure on unknown input */
58  ret = 0;
59  break;
60  }
61  }
62 
63  unformat_free (line_input);
64  return ret;
65 }
66 
67 /*
68  * fd.io coding-style-patch-verification: ON
69  *
70  * Local Variables:
71  * eval: (c-set-style "gnu")
72  * End:
73  */
vlib.h
af_xdp_create_if_args_t::flags
af_xdp_create_flag_t flags
Definition: af_xdp.h:153
af_xdp_create_if_args_t::prog
char * prog
Definition: af_xdp.h:151
af_xdp.h
af_xdp_create_if_args_t::mode
af_xdp_mode_t mode
Definition: af_xdp.h:152
af_xdp_create_if_args_t::rxq_size
u32 rxq_size
Definition: af_xdp.h:154
unformat_input_t
struct _unformat_input_t unformat_input_t
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
AF_XDP_MODE_COPY
@ AF_XDP_MODE_COPY
Definition: af_xdp.h:138
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
af_xdp_create_if_args_t::linux_ifname
char * linux_ifname
Definition: af_xdp.h:149
uword
u64 uword
Definition: types.h:112
unformat_line_input
__clib_export uword unformat_line_input(unformat_input_t *i, va_list *va)
Definition: unformat.c:415
af_xdp_create_if_args_t::rxq_num
u32 rxq_num
Definition: af_xdp.h:156
af_xdp_create_if_args_t::name
char * name
Definition: af_xdp.h:150
af_xdp_create_if_args_t::txq_size
u32 txq_size
Definition: af_xdp.h:155
af_xdp_create_if_args_t
Definition: af_xdp.h:147
AF_XDP_MODE_ZERO_COPY
@ AF_XDP_MODE_ZERO_COPY
Definition: af_xdp.h:139
unformat_af_xdp_create_if_args
uword unformat_af_xdp_create_if_args(unformat_input_t *input, va_list *vargs)
Definition: unformat.c:22
unformat_user
__clib_export uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
AF_XDP_NUM_RX_QUEUES_ALL
#define AF_XDP_NUM_RX_QUEUES_ALL
Definition: af_xdp.h:25
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
unformat
__clib_export uword unformat(unformat_input_t *input, const char *fmt,...)
Definition: unformat.c:978
AF_XDP_CREATE_FLAGS_NO_SYSCALL_LOCK
@ AF_XDP_CREATE_FLAGS_NO_SYSCALL_LOCK
Definition: af_xdp.h:144
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137