FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
pipe_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 <vnet/vnet.h>
19 #include <vlibmemory/api.h>
20 #include <vnet/devices/pipe/pipe.h>
21 
22 #include <vnet/format_fns.h>
23 #include <vnet/devices/pipe/pipe.api_enum.h>
24 #include <vnet/devices/pipe/pipe.api_types.h>
25 
26 #define REPLY_MSG_ID_BASE msg_id_base
29 
31 
32 static void
34 {
36  u32 parent_sw_if_index;
37  u32 pipe_sw_if_index[2];
38  int rv;
39  u8 is_specified = mp->is_specified;
40  u32 user_instance = ntohl (mp->user_instance);
41 
42  rv = vnet_create_pipe_interface (is_specified, user_instance,
43  &parent_sw_if_index, pipe_sw_if_index);
44 
45  /* *INDENT-OFF* */
46  REPLY_MACRO2(VL_API_PIPE_CREATE_REPLY,
47  ({
48  rmp->sw_if_index = ntohl (parent_sw_if_index);
49  rmp->pipe_sw_if_index[0] = ntohl (pipe_sw_if_index[0]);
50  rmp->pipe_sw_if_index[1] = ntohl (pipe_sw_if_index[1]);
51  }));
52  /* *INDENT-ON* */
53 }
54 
55 static void
57 {
58  vl_api_pipe_delete_reply_t *rmp;
59  int rv;
60 
62 
63  REPLY_MACRO (VL_API_PIPE_DELETE_REPLY);
64 }
65 
66 typedef struct pipe_dump_walk_t_
67 {
71 
72 static walk_rc_t
73 pipe_send_details (u32 parent_sw_if_index,
74  u32 pipe_sw_if_index[2], u32 instance, void *args)
75 {
76  pipe_dump_walk_t *ctx = args;
78 
79  mp = vl_msg_api_alloc (sizeof (*mp));
80  if (!mp)
81  return (WALK_STOP);
82 
83  mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_PIPE_DETAILS);
84  mp->context = ctx->context;
85 
86  mp->instance = ntohl (instance);
87  mp->sw_if_index = ntohl (parent_sw_if_index);
88  mp->pipe_sw_if_index[0] = ntohl (pipe_sw_if_index[0]);
89  mp->pipe_sw_if_index[1] = ntohl (pipe_sw_if_index[1]);
90 
91  vl_api_send_msg (ctx->reg, (u8 *) mp);
92 
93  return (WALK_CONTINUE);
94 }
95 
96 static void
98 {
100 
102  if (!reg)
103  return;
104 
106  .reg = reg,
107  .context = mp->context,
108  };
109 
111 }
112 
113 #include <vnet/devices/pipe/pipe.api.c>
114 static clib_error_t *
116 {
117  /*
118  * Set up the (msg_name, crc, message-id) table
119  */
121 
122  return 0;
123 }
124 
126 
127 /*
128  * fd.io coding-style-patch-verification: ON
129  *
130  * Local Variables:
131  * eval: (c-set-style "gnu")
132  * End:
133  */
vl_api_pipe_delete_t_handler
static void vl_api_pipe_delete_t_handler(vl_api_pipe_delete_t *mp)
Definition: pipe_api.c:56
vl_api_client_index_to_registration
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
api.h
ntohs
#define ntohs(x)
Definition: af_xdp.bpf.c:29
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
REPLY_MACRO2
#define REPLY_MACRO2(t, body)
Definition: api_helper_macros.h:65
pipe_api_hookup
static clib_error_t * pipe_api_hookup(vlib_main_t *vm)
Definition: pipe_api.c:115
vl_api_pipe_create_reply_t
Reply for pipe create reply.
Definition: pipe.api:47
vl_api_send_msg
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
vl_api_pipe_create_reply_t::pipe_sw_if_index
vl_api_interface_index_t pipe_sw_if_index[2]
Definition: pipe.api:52
vl_api_pipe_details_t::pipe_sw_if_index
vl_api_interface_index_t pipe_sw_if_index[2]
Definition: pipe.api:84
vpe_api_main_t
Definition: api_helper_macros.h:414
REPLY_MSG_ID_BASE
#define REPLY_MSG_ID_BASE
Definition: pipe_api.c:26
u16
unsigned short u16
Definition: types.h:57
pipe_walk
void pipe_walk(pipe_cb_fn_t fn, void *ctx)
Walk all the of pipe interfaces.
Definition: pipe.c:649
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vnet_delete_pipe_interface
int vnet_delete_pipe_interface(u32 sw_if_index)
Definition: pipe.c:708
vl_api_pipe_create_reply_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: pipe.api:51
vpe_api_main
vpe_api_main_t vpe_api_main
Definition: interface_api.c:47
vl_api_pipe_details_t::context
u32 context
Definition: pipe.api:82
vl_api_pipe_create_t_handler
static void vl_api_pipe_create_t_handler(vl_api_pipe_create_t *mp)
Definition: pipe_api.c:33
vl_api_pipe_create_t
Initialize a new pipe interface with the given parameters.
Definition: pipe.api:32
pipe.h
vl_api_pipe_dump_t_handler
static void vl_api_pipe_dump_t_handler(vl_api_pipe_dump_t *mp)
Definition: pipe_api.c:97
vl_api_registration_
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
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
vl_api_pipe_create_t::is_specified
bool is_specified
Definition: pipe.api:36
vl_api_pipe_delete_t
Delete pipe interface.
Definition: pipe.api:60
vl_api_pipe_details_t::instance
u32 instance
Definition: pipe.api:85
pipe_send_details
static walk_rc_t pipe_send_details(u32 parent_sw_if_index, u32 pipe_sw_if_index[2], u32 instance, void *args)
Definition: pipe_api.c:73
pipe_dump_walk_t_
Definition: pipe_api.c:66
vnet_create_pipe_interface
int vnet_create_pipe_interface(u8 is_specified, u32 user_instance, u32 *parent_sw_if_index, u32 pipe_sw_if_index[2])
Create a new pipe interface.
Definition: pipe.c:531
format_fns.h
u32
unsigned int u32
Definition: types.h:88
VLIB_API_INIT_FUNCTION
VLIB_API_INIT_FUNCTION(pipe_api_hookup)
vl_api_pipe_dump_t::context
u32 context
Definition: pipe.api:71
vl_api_pipe_details_t
Reply for pipe dump request.
Definition: pipe.api:80
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
api_helper_macros.h
instance
u32 instance
Definition: gre.api:51
vl_api_pipe_dump_t
Dump pipe interfaces request.
Definition: pipe.api:68
vl_api_pipe_create_t::user_instance
u32 user_instance
Definition: pipe.api:37
vl_api_pipe_delete_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: pipe.api:64
pipe_dump_walk_t_::reg
vl_api_registration_t * reg
Definition: pipe_api.c:68
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vl_api_pipe_details_t::sw_if_index
vl_api_interface_index_t sw_if_index
Definition: pipe.api:83
rv
int __clib_unused rv
Definition: application.c:491
msg_id_base
static u16 msg_id_base
Definition: pipe_api.c:30
vnet.h
vl_api_pipe_dump_t::client_index
u32 client_index
Definition: pipe.api:70
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
WALK_STOP
@ WALK_STOP
Definition: interface_funcs.h:173
pipe_dump_walk_t
struct pipe_dump_walk_t_ pipe_dump_walk_t
vl_msg_api_alloc
void * vl_msg_api_alloc(int nbytes)
Definition: memory_shared.c:199
pipe_dump_walk_t_::context
u32 context
Definition: pipe_api.c:69