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 vl_api_qos_record_enable_disable_t_handler (vl_api_qos_record_enable_disable_t
55 vl_api_qos_record_enable_disable_reply_t *rmp;
58 if (mp->input_source > QOS_N_SOURCES)
59 rv = VNET_API_ERROR_INVALID_VALUE;
63 rv = qos_record_enable (ntohl (mp->sw_if_index), mp->input_source);
65 rv = qos_record_disable (ntohl (mp->sw_if_index), mp->input_source);
68 REPLY_MACRO (VL_API_QOS_RECORD_ENABLE_DISABLE_REPLY);
72 vl_api_qos_egress_map_update_t_handler (vl_api_qos_egress_map_update_t * mp)
74 vl_api_qos_egress_map_update_reply_t *rmp;
78 FOR_EACH_QOS_SOURCE (qs)
80 qos_egress_map_update (ntohl (mp->map_id), qs, &mp->rows[qs].outputs[0]);
83 REPLY_MACRO (VL_API_QOS_EGRESS_MAP_UPDATE_REPLY);
87 vl_api_qos_egress_map_delete_t_handler (vl_api_qos_egress_map_delete_t * mp)
89 vl_api_qos_egress_map_delete_reply_t *rmp;
92 qos_egress_map_delete (ntohl (mp->map_id));
94 REPLY_MACRO (VL_API_QOS_EGRESS_MAP_DELETE_REPLY);
98 vl_api_qos_mark_enable_disable_t_handler
99 (vl_api_qos_mark_enable_disable_t * mp)
101 vl_api_qos_mark_enable_disable_reply_t *rmp;
104 if (mp->output_source > QOS_N_SOURCES)
105 rv = VNET_API_ERROR_INVALID_VALUE;
109 rv = qos_mark_enable (ntohl (mp->sw_if_index),
110 mp->output_source, ntohl (mp->map_id));
112 rv = qos_mark_disable (ntohl (mp->sw_if_index), mp->output_source);
115 REPLY_MACRO (VL_API_QOS_MARK_ENABLE_DISABLE_REPLY);
118 #define vl_msg_name_crc_list
119 #include <vnet/qos/qos.api.h>
120 #undef vl_msg_name_crc_list
123 setup_message_id_table (api_main_t * am)
125 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
126 foreach_vl_msg_name_crc_qos;
130 static clib_error_t *
131 qos_api_hookup (vlib_main_t * vm)
133 api_main_t *am = &api_main;
136 vl_msg_api_set_handlers(VL_API_##N, #n, \
137 vl_api_##n##_t_handler, \
139 vl_api_##n##_t_endian, \
140 vl_api_##n##_t_print, \
141 sizeof(vl_api_##n##_t), 1);
146 * Set up the (msg_name, crc, message-id) table
148 setup_message_id_table (am);
153 VLIB_API_INIT_FUNCTION (qos_api_hookup);
156 * fd.io coding-style-patch-verification: ON
159 * eval: (c-set-style "gnu")