FD.io VPP  v18.07.1-19-g511ce25
Vector Packet Processing
qos_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/api_errno.h>
21 
22 #include <vnet/qos/qos_record.h>
23 #include <vnet/qos/qos_mark.h>
25 
26 #include <vnet/vnet_msg_enum.h>
27 
28 #define vl_typedefs /* define message structures */
29 #include <vnet/vnet_all_api_h.h>
30 #undef vl_typedefs
31 
32 #define vl_endianfun /* define message structures */
33 #include <vnet/vnet_all_api_h.h>
34 #undef vl_endianfun
35 
36 /* instantiate all the print functions we know about */
37 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
38 #define vl_printfun
39 #include <vnet/vnet_all_api_h.h>
40 #undef vl_printfun
41 
43 
44 
45 #define foreach_qos_api_msg \
46  _(QOS_RECORD_ENABLE_DISABLE, qos_record_enable_disable) \
47  _(QOS_EGRESS_MAP_DELETE, qos_egress_map_delete) \
48  _(QOS_EGRESS_MAP_UPDATE, qos_egress_map_update) \
49  _(QOS_MARK_ENABLE_DISABLE, qos_mark_enable_disable)
50 
51 void
53  * mp)
54 {
55  vl_api_qos_record_enable_disable_reply_t *rmp;
56  int rv = 0;
57 
58  if (mp->input_source >= QOS_N_SOURCES)
59  rv = VNET_API_ERROR_INVALID_VALUE;
60  else
61  {
62  if (mp->enable)
63  rv = qos_record_enable (ntohl (mp->sw_if_index), mp->input_source);
64  else
65  rv = qos_record_disable (ntohl (mp->sw_if_index), mp->input_source);
66  }
67 
68  REPLY_MACRO (VL_API_QOS_RECORD_ENABLE_DISABLE_REPLY);
69 }
70 
71 void
73 {
74  vl_api_qos_egress_map_update_reply_t *rmp;
75  qos_source_t qs;
76  int rv = 0;
77 
79  {
80  qos_egress_map_update (ntohl (mp->map_id), qs, &mp->rows[qs].outputs[0]);
81  }
82 
83  REPLY_MACRO (VL_API_QOS_EGRESS_MAP_UPDATE_REPLY);
84 }
85 
86 void
88 {
89  vl_api_qos_egress_map_delete_reply_t *rmp;
90  int rv = 0;
91 
92  qos_egress_map_delete (ntohl (mp->map_id));
93 
94  REPLY_MACRO (VL_API_QOS_EGRESS_MAP_DELETE_REPLY);
95 }
96 
97 void
100 {
101  vl_api_qos_mark_enable_disable_reply_t *rmp;
102  int rv = 0;
103 
104  if (mp->output_source >= QOS_N_SOURCES)
105  rv = VNET_API_ERROR_INVALID_VALUE;
106  else
107  {
108  if (mp->enable)
109  rv = qos_mark_enable (ntohl (mp->sw_if_index),
110  mp->output_source, ntohl (mp->map_id));
111  else
112  rv = qos_mark_disable (ntohl (mp->sw_if_index), mp->output_source);
113  }
114 
115  REPLY_MACRO (VL_API_QOS_MARK_ENABLE_DISABLE_REPLY);
116 }
117 
118 #define vl_msg_name_crc_list
119 #include <vnet/qos/qos.api.h>
120 #undef vl_msg_name_crc_list
121 
122 static void
124 {
125 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
126  foreach_vl_msg_name_crc_qos;
127 #undef _
128 }
129 
130 static clib_error_t *
132 {
133  api_main_t *am = &api_main;
134 
135 #define _(N,n) \
136  vl_msg_api_set_handlers(VL_API_##N, #n, \
137  vl_api_##n##_t_handler, \
138  vl_noop_handler, \
139  vl_api_##n##_t_endian, \
140  vl_api_##n##_t_print, \
141  sizeof(vl_api_##n##_t), 1);
143 #undef _
144 
145  /*
146  * Set up the (msg_name, crc, message-id) table
147  */
149 
150  return 0;
151 }
152 
154 
155 /*
156  * fd.io coding-style-patch-verification: ON
157  *
158  * Local Variables:
159  * eval: (c-set-style "gnu")
160  * End:
161  */
Delete a Qos Map.
Definition: qos.api:68
vl_api_qos_egress_map_row_t rows[4]
Definition: qos.api:62
static clib_error_t * qos_api_hookup(vlib_main_t *vm)
Definition: qos_api.c:131
void vl_api_qos_egress_map_update_t_handler(vl_api_qos_egress_map_update_t *mp)
Definition: qos_api.c:72
void vl_api_qos_egress_map_delete_t_handler(vl_api_qos_egress_map_delete_t *mp)
Definition: qos_api.c:87
void qos_egress_map_delete(qos_egress_map_id_t mid)
int qos_mark_disable(u32 sw_if_index, qos_source_t output_source)
Definition: qos_mark.c:432
static void setup_message_id_table(api_main_t *am)
Definition: qos_api.c:123
VLIB_API_INIT_FUNCTION(qos_api_hookup)
int qos_mark_enable(u32 sw_if_index, qos_source_t output_source, qos_egress_map_id_t mid)
enable QoS marking by associating a MAP with an interface.
Definition: qos_mark.c:408
#define FOR_EACH_QOS_SOURCE(_src)
Definition: qos_types.h:54
#define foreach_qos_api_msg
Definition: qos_api.c:45
void qos_egress_map_update(qos_egress_map_id_t mid, qos_source_t input_source, qos_bits_t *values)
Add a qos-egress map to an interface.
#define REPLY_MACRO(t)
Enable/Disable QoS recording The QoS bits from the packet at the specified input layer are copied int...
Definition: qos.api:32
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:201
vlib_main_t * vm
Definition: buffer.c:294
enum qos_source_t_ qos_source_t
QoS tyeps.
int qos_record_disable(u32 sw_if_index, qos_source_t input_source)
Definition: qos_record.c:83
Enable/Disable QoS marking The QoS bits from the packet are mapped (using the desired egress map) int...
Definition: qos.api:86
void vl_api_qos_mark_enable_disable_t_handler(vl_api_qos_mark_enable_disable_t *mp)
Definition: qos_api.c:99
Update a QoS Map A QoS map, translates from the QoS value in the packet set by the &#39;record&#39; feature...
Definition: qos.api:57
int qos_record_enable(u32 sw_if_index, qos_source_t input_source)
Definition: qos_record.c:69
api_main_t api_main
Definition: api_shared.c:35
#define QOS_N_SOURCES
The maximum number of sources.
Definition: qos_types.h:45
void vl_api_qos_record_enable_disable_t_handler(vl_api_qos_record_enable_disable_t *mp)
Definition: qos_api.c:52