FD.io VPP  v20.05-21-gb1500e9ff
Vector Packet Processing
unformat.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2019 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 <rdma/rdma.h>
20 
21 uword
23 {
24  rdma_create_if_args_t *args = va_arg (*vargs, rdma_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->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 %u", &args->rxq_num))
44  ;
45  else if (unformat (line_input, "mode auto"))
46  args->mode = RDMA_MODE_AUTO;
47  else if (unformat (line_input, "mode ibv"))
48  args->mode = RDMA_MODE_IBV;
49  else if (unformat (line_input, "mode dv"))
50  args->mode = RDMA_MODE_DV;
51  else
52  {
53  /* return failure on unknown input */
54  ret = 0;
55  break;
56  }
57  }
58 
59  unformat_free (line_input);
60  return ret;
61 }
62 
63 /*
64  * fd.io coding-style-patch-verification: ON
65  *
66  * Local Variables:
67  * eval: (c-set-style "gnu")
68  * End:
69  */
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
uword unformat_rdma_create_if_args(unformat_input_t *input, va_list *vargs)
Definition: unformat.c:22
struct _unformat_input_t unformat_input_t
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
rdma_mode_t mode
Definition: rdma.h:219
u64 uword
Definition: types.h:112
static void unformat_free(unformat_input_t *i)
Definition: format.h:163
uword unformat_line_input(unformat_input_t *i, va_list *va)
Definition: unformat.c:415
uword unformat(unformat_input_t *input, const char *fmt,...)
Definition: unformat.c:978
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171