3 * dpdk_test.c - skeleton vpp-api-test plug-in
5 * Copyright (c) <current-year> <your-organization>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <vlibapi/api.h>
20 #include <vlibmemory/api.h>
21 #include <vppinfra/error.h>
22 #include <vnet/ip/ip.h>
24 uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
26 /* Declare message IDs */
27 #include <dpdk/api/dpdk.api_enum.h>
28 #include <dpdk/api/dpdk.api_types.h>
31 /* API message ID base */
36 dpdk_test_main_t dpdk_test_main;
38 /* M: construct, but don't yet send a message */
41 vam->result_ready = 0; \
42 mp = vl_msg_api_alloc(sizeof(*mp)); \
43 clib_memset (mp, 0, sizeof (*mp)); \
44 mp->_vl_msg_id = ntohs (VL_API_##T + dm->msg_id_base); \
45 mp->client_index = vam->my_client_index; \
50 vam->result_ready = 0; \
51 mp = vl_msg_api_alloc(sizeof(*mp)+(n)); \
52 clib_memset (mp, 0, sizeof (*mp)); \
53 mp->_vl_msg_id = ntohs (VL_API_##T + dm->msg_id_base); \
54 mp->client_index = vam->my_client_index; \
57 /* S: send a message */
58 #define S (vl_msg_api_send_shmem (vam->vl_input_queue, (u8 *)&mp))
60 /* W: wait for results, with timeout */
63 timeout = vat_time_now (vam) + 1.0; \
65 while (vat_time_now (vam) < timeout) { \
66 if (vam->result_ready == 1) { \
67 return (vam->retval); \
74 api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
76 dpdk_test_main_t * dm = &dpdk_test_main;
77 unformat_input_t *i = vam->input;
78 vl_api_sw_interface_set_dpdk_hqos_pipe_t *mp;
81 u8 sw_if_index_set = 0;
89 /* Parse args required to build the message */
90 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
92 if (unformat (i, "rx sw_if_index %u", &sw_if_index))
94 else if (unformat (i, "subport %u", &subport))
96 else if (unformat (i, "pipe %u", &pipe))
98 else if (unformat (i, "profile %u", &profile))
104 if (sw_if_index_set == 0)
106 errmsg ("missing interface name or sw_if_index");
110 if (subport_set == 0)
112 errmsg ("missing subport ");
118 errmsg ("missing pipe");
122 if (profile_set == 0)
124 errmsg ("missing profile");
128 M (SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe);
130 mp->sw_if_index = ntohl (sw_if_index);
131 mp->subport = ntohl (subport);
132 mp->pipe = ntohl (pipe);
133 mp->profile = ntohl (profile);
143 api_sw_interface_set_dpdk_hqos_subport (vat_main_t * vam)
145 dpdk_test_main_t * dm = &dpdk_test_main;
146 unformat_input_t *i = vam->input;
147 vl_api_sw_interface_set_dpdk_hqos_subport_t *mp;
150 u8 sw_if_index_set = 0;
153 u32 tb_rate = 1250000000; /* 10GbE */
154 u32 tb_size = 1000000;
155 u32 tc_rate[] = { 1250000000, 1250000000, 1250000000, 1250000000 };
158 /* Parse args required to build the message */
159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
161 if (unformat (i, "rx sw_if_index %u", &sw_if_index))
163 else if (unformat (i, "subport %u", &subport))
165 else if (unformat (i, "rate %u", &tb_rate))
169 for (tc_id = 0; tc_id < (sizeof (tc_rate) / sizeof (tc_rate[0]));
171 tc_rate[tc_id] = tb_rate;
173 else if (unformat (i, "bktsize %u", &tb_size))
175 else if (unformat (i, "tc0 %u", &tc_rate[0]))
177 else if (unformat (i, "tc1 %u", &tc_rate[1]))
179 else if (unformat (i, "tc2 %u", &tc_rate[2]))
181 else if (unformat (i, "tc3 %u", &tc_rate[3]))
183 else if (unformat (i, "period %u", &tc_period))
189 if (sw_if_index_set == 0)
191 errmsg ("missing interface name or sw_if_index");
195 if (subport_set == 0)
197 errmsg ("missing subport ");
201 M (SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport);
203 mp->sw_if_index = ntohl (sw_if_index);
204 mp->subport = ntohl (subport);
205 mp->tb_rate = ntohl (tb_rate);
206 mp->tb_size = ntohl (tb_size);
207 mp->tc_rate[0] = ntohl (tc_rate[0]);
208 mp->tc_rate[1] = ntohl (tc_rate[1]);
209 mp->tc_rate[2] = ntohl (tc_rate[2]);
210 mp->tc_rate[3] = ntohl (tc_rate[3]);
211 mp->tc_period = ntohl (tc_period);
220 api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
222 dpdk_test_main_t * dm = &dpdk_test_main;
223 unformat_input_t *i = vam->input;
224 vl_api_sw_interface_set_dpdk_hqos_tctbl_t *mp;
227 u8 sw_if_index_set = 0;
231 u32 entry, tc, queue;
233 /* Parse args required to build the message */
234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
236 if (unformat (i, "rx sw_if_index %u", &sw_if_index))
238 else if (unformat (i, "entry %d", &entry))
240 else if (unformat (i, "tc %d", &tc))
242 else if (unformat (i, "queue %d", &queue))
248 if (sw_if_index_set == 0)
250 errmsg ("missing interface name or sw_if_index");
256 errmsg ("missing entry ");
262 errmsg ("missing traffic class ");
268 errmsg ("missing queue ");
272 M (SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl);
274 mp->sw_if_index = ntohl (sw_if_index);
275 mp->entry = ntohl (entry);
277 mp->queue = ntohl (queue);
285 #include <dpdk/api/dpdk.api_test.c>