FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
pp2_api.c
Go to the documentation of this file.
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 
32 
33 static void
35 {
37  mrvl_pp2_create_if_args_t args = { 0 };
39  int rv;
40 
41  args.name = format (0, "%s", mp->if_name);
42  args.rx_q_sz = ntohs (mp->rx_q_sz);
43  args.tx_q_sz = ntohs (mp->tx_q_sz);
44  mrvl_pp2_create_if (&args);
45  rv = args.rv;
46  vec_free (args.name);
47  if (args.error)
48  {
49  clib_error_free (args.error);
50  }
51  /* *INDENT-OFF* */
52  REPLY_MACRO2 (VL_API_MRVL_PP2_CREATE_REPLY + pp2->msg_id_base,
53  ({
54  rmp->sw_if_index = ntohl (args.sw_if_index);
55  }));
56  /* *INDENT-ON* */
57 }
58 
59 static void
61 {
62  vnet_main_t *vnm = vnet_get_main ();
65  vl_api_mrvl_pp2_delete_reply_t *rmp;
66  mrvl_pp2_if_t *dif;
67  int rv = 0;
68  mp->sw_if_index = ntohl (mp->sw_if_index);
69  hw = vnet_get_sup_hw_interface (vnm, mp->sw_if_index);
70  if (hw == NULL || mrvl_pp2_device_class.index != hw->dev_class_index)
71  {
72  rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
73  goto reply;
74  }
75 
76  dif = pool_elt_at_index (pp2->interfaces, hw->dev_instance);
77 
78  mrvl_pp2_delete_if (dif);
79 
80 reply:
81  REPLY_MACRO (VL_API_MRVL_PP2_DELETE_REPLY + pp2->msg_id_base);
82 }
83 
84 #include <marvell/pp2/pp2.api.c>
85 /* set up the API message handling tables */
88 {
90 
91  /* ask for a correctly-sized block of API message decode slots */
93 
94  return 0;
95 }
96 
97 /*
98  * fd.io coding-style-patch-verification: ON
99  *
100  * Local Variables:
101  * eval: (c-set-style "gnu")
102  * End:
103  */
vlib.h
api.h
vl_api_mrvl_pp2_create_t
Definition: pp2.api:29
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
mrvl_pp2_create_if_args_t::rv
i32 rv
Definition: pp2.h:97
pp2.h
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
mrvl_pp2_main
mrvl_pp2_main_t mrvl_pp2_main
Definition: pp2.c:37
vl_api_mrvl_pp2_create_t::if_name
string if_name[64]
Definition: pp2.api:34
vnet_hw_interface_t::dev_instance
u32 dev_instance
Definition: interface.h:660
mrvl_pp2_create_if_args_t::error
clib_error_t * error
Definition: pp2.h:99
vl_api_mrvl_pp2_create_t::tx_q_sz
u16 tx_q_sz
Definition: pp2.api:36
ethernet.h
mrvl_pp2_create_if_args_t::rx_q_sz
u16 rx_q_sz
Definition: pp2.h:93
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:451
mrvl_pp2_create_if_args_t::name
u8 * name
Definition: pp2.h:92
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
REPLY_MACRO
#define REPLY_MACRO(t)
Definition: api_helper_macros.h:30
vnet_hw_interface_t::dev_class_index
u32 dev_class_index
Definition: interface.h:659
mrvl_pp2_plugin_api_hookup
clib_error_t * mrvl_pp2_plugin_api_hookup(vlib_main_t *vm)
Definition: pp2_api.c:87
mrvl_pp2_main_t::msg_id_base
u16 msg_id_base
Definition: pp2.h:84
mrvl_pp2_device_class
vnet_device_class_t mrvl_pp2_device_class
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
mrvl_pp2_create_if_args_t::tx_q_sz
u16 tx_q_sz
Definition: pp2.h:94
vl_api_mrvl_pp2_delete_t
Definition: pp2.api:60
mrvl_pp2_main_t::interfaces
mrvl_pp2_if_t * interfaces
Definition: pp2.h:80
format
description fragment has unexpected format
Definition: map.api:433
vl_api_mrvl_pp2_create_t_handler
static void vl_api_mrvl_pp2_create_t_handler(vl_api_mrvl_pp2_create_t *mp)
Definition: pp2_api.c:34
vnet_get_sup_hw_interface
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:92
vl_api_mrvl_pp2_delete_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: pp2.api:65
api_helper_macros.h
vl_api_mrvl_pp2_create_t::rx_q_sz
u16 rx_q_sz
Definition: pp2.api:35
vlib_main_t
Definition: main.h:102
mrvl_pp2_create_if_args_t
Definition: pp2.h:90
mrvl_pp2_delete_if
void mrvl_pp2_delete_if(mrvl_pp2_if_t *ppif)
Definition: pp2.c:116
clib_error_t
Definition: clib_error.h:21
unix.h
mrvl_pp2_if_t
Definition: pp2.h:51
vl_api_mrvl_pp2_create_reply_t
Definition: pp2.api:46
vl_api_mrvl_pp2_delete_t_handler
static void vl_api_mrvl_pp2_delete_t_handler(vl_api_mrvl_pp2_delete_t *mp)
Definition: pp2_api.c:60
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
rv
int __clib_unused rv
Definition: application.c:491
mrvl_pp2_create_if
void mrvl_pp2_create_if(mrvl_pp2_create_if_args_t *args)
Definition: pp2.c:176
mrvl_pp2_main_t
Definition: pp2.h:78