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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *------------------------------------------------------------------
18 #include <vnet/vnet.h>
19 #include <vlibmemory/api.h>
20 #include <vnet/api_errno.h>
22 #include <vnet/qos/qos_record.h>
23 #include <vnet/qos/qos_mark.h>
24 #include <vnet/qos/qos_egress_map.h>
26 #include <vnet/vnet_msg_enum.h>
28 #define vl_typedefs /* define message structures */
29 #include <vnet/vnet_all_api_h.h>
32 #define vl_endianfun /* define message structures */
33 #include <vnet/vnet_all_api_h.h>
36 /* instantiate all the print functions we know about */
37 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
39 #include <vnet/vnet_all_api_h.h>
42 #include <vlibapi/api_helper_macros.h>
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)
52 qos_source_decode (vl_api_qos_source_t v, qos_source_t * q)
58 case QOS_API_SOURCE_EXT:
61 case QOS_API_SOURCE_VLAN:
64 case QOS_API_SOURCE_MPLS:
67 case QOS_API_SOURCE_IP:
72 return (VNET_API_ERROR_INVALID_VALUE);
76 vl_api_qos_record_enable_disable_t_handler (vl_api_qos_record_enable_disable_t
79 vl_api_qos_record_enable_disable_reply_t *rmp;
83 rv = qos_source_decode (mp->input_source, &qs);
88 rv = qos_record_enable (ntohl (mp->sw_if_index), qs);
90 rv = qos_record_disable (ntohl (mp->sw_if_index), qs);
93 REPLY_MACRO (VL_API_QOS_RECORD_ENABLE_DISABLE_REPLY);
97 vl_api_qos_egress_map_update_t_handler (vl_api_qos_egress_map_update_t * mp)
99 vl_api_qos_egress_map_update_reply_t *rmp;
103 FOR_EACH_QOS_SOURCE (qs)
105 qos_egress_map_update (ntohl (mp->map_id), qs, &mp->rows[qs].outputs[0]);
108 REPLY_MACRO (VL_API_QOS_EGRESS_MAP_UPDATE_REPLY);
112 vl_api_qos_egress_map_delete_t_handler (vl_api_qos_egress_map_delete_t * mp)
114 vl_api_qos_egress_map_delete_reply_t *rmp;
117 qos_egress_map_delete (ntohl (mp->map_id));
119 REPLY_MACRO (VL_API_QOS_EGRESS_MAP_DELETE_REPLY);
123 vl_api_qos_mark_enable_disable_t_handler
124 (vl_api_qos_mark_enable_disable_t * mp)
126 vl_api_qos_mark_enable_disable_reply_t *rmp;
130 rv = qos_source_decode (mp->output_source, &qs);
136 qos_mark_enable (ntohl (mp->sw_if_index), qs, ntohl (mp->map_id));
138 rv = qos_mark_disable (ntohl (mp->sw_if_index), qs);
141 REPLY_MACRO (VL_API_QOS_MARK_ENABLE_DISABLE_REPLY);
144 #define vl_msg_name_crc_list
145 #include <vnet/qos/qos.api.h>
146 #undef vl_msg_name_crc_list
149 setup_message_id_table (api_main_t * am)
151 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
152 foreach_vl_msg_name_crc_qos;
156 static clib_error_t *
157 qos_api_hookup (vlib_main_t * vm)
159 api_main_t *am = &api_main;
162 vl_msg_api_set_handlers(VL_API_##N, #n, \
163 vl_api_##n##_t_handler, \
165 vl_api_##n##_t_endian, \
166 vl_api_##n##_t_print, \
167 sizeof(vl_api_##n##_t), 1);
172 * Set up the (msg_name, crc, message-id) table
174 setup_message_id_table (am);
179 VLIB_API_INIT_FUNCTION (qos_api_hookup);
182 * fd.io coding-style-patch-verification: ON
185 * eval: (c-set-style "gnu")