builtinurl: mark api as deprecated
[vpp.git] / src / plugins / marvell / pp2 / pp2_api.c
1 /*
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:
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 <vlib/unix/unix.h>
20 #include <vnet/ethernet/ethernet.h>
21
22 #include <marvell/pp2/pp2.h>
23
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26
27 /* define message IDs */
28 #include <marvell/pp2/pp2.api_enum.h>
29 #include <marvell/pp2/pp2.api_types.h>
30
31 #define REPLY_MSG_ID_BASE (pp2->msg_id_base)
32 #include <vlibapi/api_helper_macros.h>
33
34 static void
35 vl_api_mrvl_pp2_create_t_handler (vl_api_mrvl_pp2_create_t * mp)
36 {
37   mrvl_pp2_main_t *pp2 = &mrvl_pp2_main;
38   mrvl_pp2_create_if_args_t args = { 0 };
39   vl_api_mrvl_pp2_create_reply_t *rmp;
40   int rv;
41
42   args.name = format (0, "%s", mp->if_name);
43   args.rx_q_sz = ntohs (mp->rx_q_sz);
44   args.tx_q_sz = ntohs (mp->tx_q_sz);
45   mrvl_pp2_create_if (&args);
46   rv = args.rv;
47   vec_free (args.name);
48   if (args.error)
49     {
50       clib_error_free (args.error);
51     }
52   REPLY_MACRO2 (VL_API_MRVL_PP2_CREATE_REPLY,
53                 ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
54 }
55
56 static void
57 vl_api_mrvl_pp2_delete_t_handler (vl_api_mrvl_pp2_delete_t * mp)
58 {
59   vnet_main_t *vnm = vnet_get_main ();
60   vnet_hw_interface_t *hw;
61   mrvl_pp2_main_t *pp2 = &mrvl_pp2_main;
62   vl_api_mrvl_pp2_delete_reply_t *rmp;
63   mrvl_pp2_if_t *dif;
64   int rv = 0;
65   mp->sw_if_index = ntohl (mp->sw_if_index);
66   hw = vnet_get_sup_hw_interface (vnm, mp->sw_if_index);
67   if (hw == NULL || mrvl_pp2_device_class.index != hw->dev_class_index)
68     {
69       rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
70       goto reply;
71     }
72
73   dif = pool_elt_at_index (pp2->interfaces, hw->dev_instance);
74
75   mrvl_pp2_delete_if (dif);
76
77 reply:
78   REPLY_MACRO (VL_API_MRVL_PP2_DELETE_REPLY);
79 }
80
81 #include <marvell/pp2/pp2.api.c>
82 /* set up the API message handling tables */
83 clib_error_t *
84 mrvl_pp2_plugin_api_hookup (vlib_main_t * vm)
85 {
86   mrvl_pp2_main_t *pp2 = &mrvl_pp2_main;
87
88   /* ask for a correctly-sized block of API message decode slots */
89   pp2->msg_id_base = setup_message_id_table ();
90
91   return 0;
92 }
93
94 /*
95  * fd.io coding-style-patch-verification: ON
96  *
97  * Local Variables:
98  * eval: (c-set-style "gnu")
99  * End:
100  */