2 *------------------------------------------------------------------
3 * Copyright (c) 2019 Arm Limited.
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 <vnet/ethernet/ethernet.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
26 #include <vppinfra/error.h>
27 #include <marvell/pp2/pp2.h>
29 #define __plugin_msg_base pp2_test_main.msg_id_base
30 #include <vlibapi/vat_helper_macros.h>
32 /* declare message IDs */
33 #include <marvell/pp2/pp2.api_enum.h>
34 #include <marvell/pp2/pp2.api_types.h>
38 /* API message ID base */
43 pp2_test_main_t pp2_test_main;
45 /* mrvl_pp2 create API */
47 api_mrvl_pp2_create (vat_main_t * vam)
49 unformat_input_t *i = vam->input;
50 vl_api_mrvl_pp2_create_t *mp;
51 mrvl_pp2_create_if_args_t args;
55 clib_memset (&args, 0, sizeof (mrvl_pp2_create_if_args_t));
56 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
58 if (unformat (i, "name %s", &args.name))
60 else if (unformat (i, "rx-queue-size %u", &size))
62 else if (unformat (i, "tx-queue-size %u", &size))
66 clib_warning ("unknown input '%U'", format_unformat_error, i);
71 M (MRVL_PP2_CREATE, mp);
73 strncpy_s ((char *) mp->if_name, ARRAY_LEN (mp->if_name),
74 (char *) (args.name), strlen ((char *) args.name));
75 mp->rx_q_sz = clib_host_to_net_u16 (args.rx_q_sz);
76 mp->tx_q_sz = clib_host_to_net_u16 (args.tx_q_sz);
86 /* mrvl_pp2 create reply handler */
88 vl_api_mrvl_pp2_create_reply_t_handler (vl_api_mrvl_pp2_create_reply_t * mp)
90 vat_main_t *vam = pp2_test_main.vat_main;
91 i32 retval = ntohl (mp->retval);
95 fformat (vam->ofp, "created mrvl_pp2 with sw_if_index %d\n",
96 ntohl (mp->sw_if_index));
100 vam->result_ready = 1;
101 vam->regenerate_interface_table = 1;
105 /* mrvl_pp2 delete API */
107 api_mrvl_pp2_delete (vat_main_t * vam)
109 unformat_input_t *i = vam->input;
110 //vnet_main_t *vnm = vnet_get_main ();
111 vl_api_mrvl_pp2_delete_t *mp;
115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
117 if (unformat (i, "sw_if_index %d", &sw_if_index))
121 clib_warning ("unknown input '%U'", format_unformat_error, i);
126 M (MRVL_PP2_DELETE, mp);
128 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
136 #include <marvell/pp2/pp2.api_test.c>
139 * fd.io coding-style-patch-verification: ON
142 * eval: (c-set-style "gnu")