FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
avf_api.c
Go to the documentation of this file.
1 /*
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:
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 <vlib/pci/pci.h>
21 #include <vnet/ethernet/ethernet.h>
22 
23 #include <avf/avf.h>
24 
25 #include <vlibapi/api.h>
26 #include <vlibmemory/api.h>
27 
28 /* define message IDs */
29 #include <avf/avf.api_enum.h>
30 #include <avf/avf.api_types.h>
31 
33 
34 static void
36 {
41  int rv;
42 
43  clib_memset (&args, 0, sizeof (avf_create_if_args_t));
44 
45  args.enable_elog = ntohl (mp->enable_elog);
46  args.addr.as_u32 = ntohl (mp->pci_addr);
47  args.rxq_num = ntohs (mp->rxq_num);
48  args.rxq_size = ntohs (mp->rxq_size);
49  args.txq_size = ntohs (mp->txq_size);
50 
51  avf_create_if (vm, &args);
52  rv = args.rv;
53 
54  /* *INDENT-OFF* */
55  REPLY_MACRO2 (VL_API_AVF_CREATE_REPLY + am->msg_id_base,
56  ({
57  rmp->sw_if_index = ntohl (args.sw_if_index);
58  }));
59  /* *INDENT-ON* */
60 }
61 
62 static void
64 {
66  vnet_main_t *vnm = vnet_get_main ();
68  vl_api_avf_delete_reply_t *rmp;
70  int rv = 0;
71 
72  hw =
74  htonl (mp->sw_if_index));
75  if (hw == NULL || avf_device_class.index != hw->dev_class_index)
76  {
77  rv = VNET_API_ERROR_INVALID_INTERFACE;
78  goto reply;
79  }
80 
83 
84 reply:
85  REPLY_MACRO (VL_API_AVF_DELETE_REPLY + am->msg_id_base);
86 }
87 
88 /* set tup the API message handling tables */
89 #include <avf/avf.api.c>
90 static clib_error_t *
92 {
93  avf_main_t *avm = &avf_main;
95 
96  /* ask for a correctly-sized block of API message decode slots */
98 
99  am->is_mp_safe[avm->msg_id_base + VL_API_AVF_DELETE] = 1;
100 
101  return 0;
102 }
103 
105 
106 /*
107  * fd.io coding-style-patch-verification: ON
108  *
109  * Local Variables:
110  * eval: (c-set-style "gnu")
111  * End:
112  */
vlib.h
api.h
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
avf_main_t::msg_id_base
u16 msg_id_base
Definition: avf.h:323
vl_api_avf_create_t::pci_addr
u32 pci_addr
Definition: avf.api:37
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
vl_api_avf_create_t_handler
static void vl_api_avf_create_t_handler(vl_api_avf_create_t *mp)
Definition: avf_api.c:35
avf_main
avf_main_t avf_main
Definition: device.c:48
avf_main_t
Definition: avf.h:321
avf_plugin_api_hookup
static clib_error_t * avf_plugin_api_hookup(vlib_main_t *vm)
Definition: avf_api.c:91
avf_create_if_args_t::rxq_size
u16 rxq_size
Definition: avf.h:338
am
app_main_t * am
Definition: application.c:489
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
api.h
avf_create_if_args_t::enable_elog
int enable_elog
Definition: avf.h:335
vnet_hw_interface_t::dev_instance
u32 dev_instance
Definition: interface.h:660
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
avf_create_if_args_t
Definition: avf.h:331
avf_device_class
vnet_device_class_t avf_device_class
ethernet.h
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(avf_plugin_api_hookup)
vl_api_avf_create_t::txq_size
u16 txq_size
Definition: avf.api:41
avf_create_if_args_t::addr
vlib_pci_addr_t addr
Definition: avf.h:333
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
setup_message_id_table
static void setup_message_id_table(api_main_t *am)
Definition: sr_mpls_api.c:174
vnet_get_sup_hw_interface_api_visible_or_null
static vnet_hw_interface_t * vnet_get_sup_hw_interface_api_visible_or_null(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:101
vnet_hw_interface_t::dev_class_index
u32 dev_class_index
Definition: interface.h:659
vl_api_avf_delete_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: avf.api:69
vlibapi_get_main
static api_main_t * vlibapi_get_main(void)
Definition: api_common.h:390
avf_create_if_args_t::rxq_num
u16 rxq_num
Definition: avf.h:336
avf_create_if_args_t::rv
int rv
Definition: avf.h:341
avf_create_if
void avf_create_if(vlib_main_t *vm, avf_create_if_args_t *args)
Definition: device.c:1589
avf.h
vl_api_avf_delete_t
Definition: avf.api:64
api_main_t
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:228
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vl_api_avf_create_reply_t
Definition: avf.api:51
vl_api_avf_create_t::rxq_num
u16 rxq_num
Definition: avf.api:39
vl_api_avf_create_t::enable_elog
i32 enable_elog
Definition: avf.api:38
avf_process_node
vlib_node_registration_t avf_process_node
(constructor) VLIB_REGISTER_NODE (avf_process_node)
Definition: device.c:1401
api_helper_macros.h
pci.h
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
clib_error_t
Definition: clib_error.h:21
unix.h
AVF_PROCESS_EVENT_DELETE_IF
@ AVF_PROCESS_EVENT_DELETE_IF
Definition: avf.h:275
vl_api_avf_create_t
Definition: avf.api:32
vl_api_avf_delete_t_handler
static void vl_api_avf_delete_t_handler(vl_api_avf_delete_t *mp)
Definition: avf_api.c:63
rv
int __clib_unused rv
Definition: application.c:491
vl_api_avf_create_t::rxq_size
u16 rxq_size
Definition: avf.api:40
avf_create_if_args_t::txq_size
u16 txq_size
Definition: avf.h:339