2 *------------------------------------------------------------------
3 * Copyright (c) 2018 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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
18 #include <vlib/vlib.h>
19 #include <vlib/unix/unix.h>
20 #include <vlib/pci/pci.h>
21 #include <vnet/ethernet/ethernet.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
27 #include <vppinfra/error.h>
30 #define __plugin_msg_base avf_test_main.msg_id_base
31 #include <vlibapi/vat_helper_macros.h>
33 /* declare message IDs */
34 #include <avf/avf.api_enum.h>
35 #include <avf/avf.api_types.h>
39 /* API message ID base */
44 avf_test_main_t avf_test_main;
48 api_avf_create (vat_main_t * vam)
50 unformat_input_t *i = vam->input;
51 vl_api_avf_create_t *mp;
52 avf_create_if_args_t args;
57 clib_memset (&args, 0, sizeof (avf_create_if_args_t));
59 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
61 if (unformat (i, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
63 args.addr.domain = x[0];
65 args.addr.slot = x[2];
66 args.addr.function = x[3];
68 else if (unformat (i, "elog"))
70 else if (unformat (i, "rx-queue-size %u", &tmp))
72 else if (unformat (i, "tx-queue-size %u", &tmp))
74 else if (unformat (i, "num-rx-queues %u", &tmp))
78 clib_warning ("unknown input '%U'", format_unformat_error, i);
85 mp->pci_addr = clib_host_to_net_u32 (args.addr.as_u32);
86 mp->enable_elog = clib_host_to_net_u16 (args.enable_elog);
87 mp->rxq_num = clib_host_to_net_u16 (args.rxq_num);
88 mp->rxq_size = clib_host_to_net_u16 (args.rxq_size);
89 mp->txq_size = clib_host_to_net_u16 (args.txq_size);
97 /* avf-create reply handler */
99 vl_api_avf_create_reply_t_handler (vl_api_avf_create_reply_t * mp)
101 vat_main_t *vam = avf_test_main.vat_main;
102 i32 retval = ntohl (mp->retval);
106 fformat (vam->ofp, "created avf with sw_if_index %d\n",
107 ntohl (mp->sw_if_index));
110 vam->retval = retval;
111 vam->result_ready = 1;
112 vam->regenerate_interface_table = 1;
117 api_avf_delete (vat_main_t * vam)
119 unformat_input_t *i = vam->input;
120 vl_api_avf_delete_t *mp;
122 u8 index_defined = 0;
125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
127 if (unformat (i, "sw_if_index %u", &sw_if_index))
131 clib_warning ("unknown input '%U'", format_unformat_error, i);
138 errmsg ("missing sw_if_index\n");
144 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
152 #include <avf/avf.api_test.c>
155 * fd.io coding-style-patch-verification: ON
158 * eval: (c-set-style "gnu")