summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Kotucek <pkotucek@cisco.com>2017-01-09 15:11:03 +0100
committerPavel Kotucek <pkotucek@cisco.com>2017-01-10 10:59:37 +0100
commit738f3f2a170bace45180bc8718d5a7e75939b275 (patch)
tree573abffc564e5f7257f7f98eff29980db2689f72 /src
parent6bbf83a01b813b3d50b27ab9001d25cae5c4592a (diff)
API refactoring : dpdk
Change-Id: If2541be803a0303401b013390e117c26fd1d9739 Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vat/api_format.c119
-rw-r--r--src/vnet.am8
-rw-r--r--src/vnet/devices/dpdk/dpdk.api103
-rw-r--r--src/vnet/devices/dpdk/dpdk_api.c246
-rw-r--r--src/vnet/vnet_all_api_h.h3
-rw-r--r--src/vpp/api/api.c153
-rw-r--r--src/vpp/api/custom_dump.c17
-rw-r--r--src/vpp/api/vpe.api83
8 files changed, 475 insertions, 257 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index e6c0f244d83..c00104defb5 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -3569,9 +3569,6 @@ _(sw_interface_set_mpls_enable_reply) \
_(sw_interface_set_vpath_reply) \
_(sw_interface_set_vxlan_bypass_reply) \
_(sw_interface_set_l2_bridge_reply) \
-_(sw_interface_set_dpdk_hqos_pipe_reply) \
-_(sw_interface_set_dpdk_hqos_subport_reply) \
-_(sw_interface_set_dpdk_hqos_tctbl_reply) \
_(bridge_domain_add_del_reply) \
_(sw_interface_set_l2_xconnect_reply) \
_(l2fib_add_del_reply) \
@@ -3671,6 +3668,13 @@ _(feature_enable_disable_reply) \
_(sw_interface_tag_add_del_reply) \
_(sw_interface_set_mtu_reply)
+#if DPDK > 0
+#define foreach_standard_dpdk_reply_retval_handler \
+_(sw_interface_set_dpdk_hqos_pipe_reply) \
+_(sw_interface_set_dpdk_hqos_subport_reply) \
+_(sw_interface_set_dpdk_hqos_tctbl_reply)
+#endif
+
#define _(n) \
static void vl_api_##n##_t_handler \
(vl_api_##n##_t * mp) \
@@ -3702,6 +3706,39 @@ foreach_standard_reply_retval_handler;
foreach_standard_reply_retval_handler;
#undef _
+#if DPDK > 0
+#define _(n) \
+ static void vl_api_##n##_t_handler \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = &vat_main; \
+ i32 retval = ntohl(mp->retval); \
+ if (vam->async_mode) { \
+ vam->async_errors += (retval < 0); \
+ } else { \
+ vam->retval = retval; \
+ vam->result_ready = 1; \
+ } \
+ }
+foreach_standard_dpdk_reply_retval_handler;
+#undef _
+
+#define _(n) \
+ static void vl_api_##n##_t_handler_json \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = &vat_main; \
+ vat_json_node_t node; \
+ vat_json_init_object(&node); \
+ vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
+ vat_json_print(vam->ofp, &node); \
+ vam->retval = ntohl(mp->retval); \
+ vam->result_ready = 1; \
+ }
+foreach_standard_dpdk_reply_retval_handler;
+#undef _
+#endif
+
/*
* Table of message reply handlers, must include boilerplate handlers
* we just generated
@@ -3725,12 +3762,6 @@ _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
sw_interface_set_l2_xconnect_reply) \
_(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
sw_interface_set_l2_bridge_reply) \
-_(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
- sw_interface_set_dpdk_hqos_pipe_reply) \
-_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
- sw_interface_set_dpdk_hqos_subport_reply) \
-_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
- sw_interface_set_dpdk_hqos_tctbl_reply) \
_(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
_(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
@@ -3924,6 +3955,16 @@ _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
_(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
+#if DPDK > 0
+#define foreach_vpe_dpdk_api_reply_msg \
+_(SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY, \
+ sw_interface_set_dpdk_hqos_pipe_reply) \
+_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY, \
+ sw_interface_set_dpdk_hqos_subport_reply) \
+_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY, \
+ sw_interface_set_dpdk_hqos_tctbl_reply)
+#endif
+
/* M: construct, but don't yet send a message */
#define M(T,t) \
@@ -4724,6 +4765,7 @@ api_sw_interface_clear_stats (vat_main_t * vam)
W;
}
+#if DPDK >0
static int
api_sw_interface_set_dpdk_hqos_pipe (vat_main_t * vam)
{
@@ -4944,6 +4986,7 @@ api_sw_interface_set_dpdk_hqos_tctbl (vat_main_t * vam)
/* NOTREACHED */
return 0;
}
+#endif
static int
api_sw_interface_add_del_address (vat_main_t * vam)
@@ -17434,14 +17477,6 @@ _(sw_interface_set_l2_bridge, \
"<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
"[shg <split-horizon-group>] [bvi]\n" \
"enable | disable") \
-_(sw_interface_set_dpdk_hqos_pipe, \
- "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
- "profile <profile-id>\n") \
-_(sw_interface_set_dpdk_hqos_subport, \
- "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
- "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
-_(sw_interface_set_dpdk_hqos_tctbl, \
- "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n") \
_(bridge_domain_add_del, \
"bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
_(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
@@ -17739,6 +17774,18 @@ _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
_(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
_(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
+#if DPDK > 0
+#define foreach_vpe_dpdk_api_msg \
+_(sw_interface_set_dpdk_hqos_pipe, \
+ "rx <intfc> | sw_if_index <id> subport <subport-id> pipe <pipe-id>\n" \
+ "profile <profile-id>\n") \
+_(sw_interface_set_dpdk_hqos_subport, \
+ "rx <intfc> | sw_if_index <id> subport <subport-id> [rate <n>]\n" \
+ "[bktsize <n>] [tc0 <n>] [tc1 <n>] [tc2 <n>] [tc3 <n>] [period <n>]\n") \
+_(sw_interface_set_dpdk_hqos_tctbl, \
+ "rx <intfc> | sw_if_index <id> entry <n> tc <n> queue <n>\n")
+#endif
+
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \
_(comment, "usage: comment <ignore-rest-of-line>") \
@@ -17776,6 +17823,22 @@ _(unset, "usage: unset <variable-name>")
foreach_vpe_api_reply_msg;
#undef _
+#if DPDK > 0
+#define _(N,n) \
+ static void vl_api_##n##_t_handler_uni \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = &vat_main; \
+ if (vam->json_output) { \
+ vl_api_##n##_t_handler_json(mp); \
+ } else { \
+ vl_api_##n##_t_handler(mp); \
+ } \
+ }
+foreach_vpe_dpdk_api_reply_msg;
+#undef _
+#endif
+
void
vat_api_hookup (vat_main_t * vam)
{
@@ -17789,6 +17852,18 @@ vat_api_hookup (vat_main_t * vam)
foreach_vpe_api_reply_msg;
#undef _
+#if DPDK > 0
+#define _(N,n) \
+ vl_msg_api_set_handlers(VL_API_##N, #n, \
+ vl_api_##n##_t_handler_uni, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_vpe_dpdk_api_reply_msg;
+#undef _
+#endif
+
#if (VPP_API_TEST_BUILTIN==0)
vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
#endif
@@ -17803,11 +17878,21 @@ vat_api_hookup (vat_main_t * vam)
#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
foreach_vpe_api_msg;
#undef _
+#if DPDK >0
+#define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
+ foreach_vpe_dpdk_api_msg;
+#undef _
+#endif
/* Help strings */
#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
foreach_vpe_api_msg;
#undef _
+#if DPDK >0
+#define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
+ foreach_vpe_dpdk_api_msg;
+#undef _
+#endif
/* CLI functions */
#define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
diff --git a/src/vnet.am b/src/vnet.am
index 16ade4d1228..bc0820a3d65 100644
--- a/src/vnet.am
+++ b/src/vnet.am
@@ -759,10 +759,14 @@ libvnet_la_SOURCES += \
vnet/devices/dpdk/init.c \
vnet/devices/dpdk/node.c \
vnet/devices/dpdk/hqos.c \
- vnet/devices/dpdk/cli.c
+ vnet/devices/dpdk/cli.c \
+ vnet/devices/dpdk/dpdk_api.c
nobase_include_HEADERS += \
- vnet/devices/dpdk/dpdk.h
+ vnet/devices/dpdk/dpdk.h \
+ vnet/devices/dpdk/dpdk.api.h
+
+API_FILES += vnet/devices/dpdk/dpdk.api
else
libvnet_la_SOURCES += \
vnet/devices/nic/ixge.c \
diff --git a/src/vnet/devices/dpdk/dpdk.api b/src/vnet/devices/dpdk/dpdk.api
new file mode 100644
index 00000000000..21215d456a3
--- /dev/null
+++ b/src/vnet/devices/dpdk/dpdk.api
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2015-2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** \brief DPDK interface HQoS pipe profile set request
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - the interface
+ @param subport - subport ID
+ @param pipe - pipe ID within its subport
+ @param profile - pipe profile ID
+*/
+define sw_interface_set_dpdk_hqos_pipe {
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u32 subport;
+ u32 pipe;
+ u32 profile;
+};
+
+/** \brief DPDK interface HQoS pipe profile set reply
+ @param context - sender context, to match reply w/ request
+ @param retval - request return code
+*/
+define sw_interface_set_dpdk_hqos_pipe_reply {
+ u32 context;
+ i32 retval;
+};
+
+/** \brief DPDK interface HQoS subport parameters set request
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - the interface
+ @param subport - subport ID
+ @param tb_rate - subport token bucket rate (measured in bytes/second)
+ @param tb_size - subport token bucket size (measured in credits)
+ @param tc_rate - subport traffic class 0 .. 3 rates (measured in bytes/second)
+ @param tc_period - enforcement period for rates (measured in milliseconds)
+*/
+define sw_interface_set_dpdk_hqos_subport {
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u32 subport;
+ u32 tb_rate;
+ u32 tb_size;
+ u32 tc_rate[4];
+ u32 tc_period;
+};
+
+/** \brief DPDK interface HQoS subport parameters set reply
+ @param context - sender context, to match reply w/ request
+ @param retval - request return code
+*/
+define sw_interface_set_dpdk_hqos_subport_reply {
+ u32 context;
+ i32 retval;
+};
+
+/** \brief DPDK interface HQoS tctbl entry set request
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - the interface
+ @param entry - entry index ID
+ @param tc - traffic class (0 .. 3)
+ @param queue - traffic class queue (0 .. 3)
+*/
+define sw_interface_set_dpdk_hqos_tctbl {
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ u32 entry;
+ u32 tc;
+ u32 queue;
+};
+
+/** \brief DPDK interface HQoS tctbl entry set reply
+ @param context - sender context, to match reply w/ request
+ @param retval - request return code
+*/
+define sw_interface_set_dpdk_hqos_tctbl_reply {
+ u32 context;
+ i32 retval;
+};
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
+ \ No newline at end of file
diff --git a/src/vnet/devices/dpdk/dpdk_api.c b/src/vnet/devices/dpdk/dpdk_api.c
new file mode 100644
index 00000000000..8faf5c2cbc4
--- /dev/null
+++ b/src/vnet/devices/dpdk/dpdk_api.c
@@ -0,0 +1,246 @@
+/*
+ *------------------------------------------------------------------
+ * dpdk_api.c - dpdk interface api
+ *
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *------------------------------------------------------------------
+ */
+
+#include <vnet/vnet.h>
+#include <vlibmemory/api.h>
+
+#if DPDK > 0
+#include <vnet/devices/dpdk/dpdk.h>
+#endif
+
+#include <vnet/vnet_msg_enum.h>
+
+#define vl_typedefs /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_typedefs
+
+#define vl_endianfun /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define vl_printfun
+#include <vnet/vnet_all_api_h.h>
+#undef vl_printfun
+
+#include <vlibapi/api_helper_macros.h>
+
+#define foreach_vpe_api_msg \
+_(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
+_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport) \
+_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl)
+
+static void
+ vl_api_sw_interface_set_dpdk_hqos_pipe_t_handler
+ (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp)
+{
+ vl_api_sw_interface_set_dpdk_hqos_pipe_reply_t *rmp;
+ int rv = 0;
+
+#if DPDK > 0
+ dpdk_main_t *dm = &dpdk_main;
+ dpdk_device_t *xd;
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 subport = ntohl (mp->subport);
+ u32 pipe = ntohl (mp->pipe);
+ u32 profile = ntohl (mp->profile);
+ vnet_hw_interface_t *hw;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ /* hw_if & dpdk device */
+ hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
+
+ xd = vec_elt_at_index (dm->devices, hw->dev_instance);
+
+ rv = rte_sched_pipe_config (xd->hqos_ht->hqos, subport, pipe, profile);
+
+ BAD_SW_IF_INDEX_LABEL;
+#else
+ clib_warning ("setting HQoS pipe parameters without DPDK not implemented");
+ rv = VNET_API_ERROR_UNIMPLEMENTED;
+#endif /* DPDK */
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY);
+}
+
+static void
+ vl_api_sw_interface_set_dpdk_hqos_subport_t_handler
+ (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp)
+{
+ vl_api_sw_interface_set_dpdk_hqos_subport_reply_t *rmp;
+ int rv = 0;
+
+#if DPDK > 0
+ dpdk_main_t *dm = &dpdk_main;
+ dpdk_device_t *xd;
+ struct rte_sched_subport_params p;
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 subport = ntohl (mp->subport);
+ p.tb_rate = ntohl (mp->tb_rate);
+ p.tb_size = ntohl (mp->tb_size);
+ p.tc_rate[0] = ntohl (mp->tc_rate[0]);
+ p.tc_rate[1] = ntohl (mp->tc_rate[1]);
+ p.tc_rate[2] = ntohl (mp->tc_rate[2]);
+ p.tc_rate[3] = ntohl (mp->tc_rate[3]);
+ p.tc_period = ntohl (mp->tc_period);
+
+ vnet_hw_interface_t *hw;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ /* hw_if & dpdk device */
+ hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
+
+ xd = vec_elt_at_index (dm->devices, hw->dev_instance);
+
+ rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport, &p);
+
+ BAD_SW_IF_INDEX_LABEL;
+#else
+ clib_warning
+ ("setting HQoS subport parameters without DPDK not implemented");
+ rv = VNET_API_ERROR_UNIMPLEMENTED;
+#endif /* DPDK */
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY);
+}
+
+static void
+ vl_api_sw_interface_set_dpdk_hqos_tctbl_t_handler
+ (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp)
+{
+ vl_api_sw_interface_set_dpdk_hqos_tctbl_reply_t *rmp;
+ int rv = 0;
+
+#if DPDK > 0
+ dpdk_main_t *dm = &dpdk_main;
+ vlib_thread_main_t *tm = vlib_get_thread_main ();
+ dpdk_device_t *xd;
+
+ u32 sw_if_index = ntohl (mp->sw_if_index);
+ u32 entry = ntohl (mp->entry);
+ u32 tc = ntohl (mp->tc);
+ u32 queue = ntohl (mp->queue);
+ u32 val, i;
+
+ vnet_hw_interface_t *hw;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ /* hw_if & dpdk device */
+ hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
+
+ xd = vec_elt_at_index (dm->devices, hw->dev_instance);
+
+ if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
+ {
+ clib_warning ("invalid traffic class !!");
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto done;
+ }
+ if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
+ {
+ clib_warning ("invalid queue !!");
+ rv = VNET_API_ERROR_INVALID_VALUE;
+ goto done;
+ }
+
+ /* Detect the set of worker threads */
+ uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
+
+ if (p == 0)
+ {
+ clib_warning ("worker thread registration AWOL !!");
+ rv = VNET_API_ERROR_INVALID_VALUE_2;
+ goto done;
+ }
+
+ vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
+ int worker_thread_first = tr->first_index;
+ int worker_thread_count = tr->count;
+
+ val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
+ for (i = 0; i < worker_thread_count; i++)
+ xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
+
+ BAD_SW_IF_INDEX_LABEL;
+done:
+#else
+ clib_warning ("setting HQoS DSCP table entry without DPDK not implemented");
+ rv = VNET_API_ERROR_UNIMPLEMENTED;
+#endif /* DPDK */
+
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY);
+}
+
+/*
+ * dpdk_api_hookup
+ * Add vpe's API message handlers to the table.
+ * vlib has alread mapped shared memory and
+ * added the client registration handlers.
+ * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
+ */
+#define vl_msg_name_crc_list
+#include <vnet/vnet_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
+ foreach_vl_msg_name_crc_dpdk;
+#undef _
+}
+
+static clib_error_t *
+dpdk_api_hookup (vlib_main_t * vm)
+{
+ api_main_t *am = &api_main;
+
+#define _(N,n) \
+ vl_msg_api_set_handlers(VL_API_##N, #n, \
+ vl_api_##n##_t_handler, \
+ vl_noop_handler, \
+ vl_api_##n##_t_endian, \
+ vl_api_##n##_t_print, \
+ sizeof(vl_api_##n##_t), 1);
+ foreach_vpe_api_msg;
+#undef _
+
+ /*
+ * Set up the (msg_name, crc, message-id) table
+ */
+ setup_message_id_table (am);
+
+ return 0;
+}
+
+VLIB_API_INIT_FUNCTION (dpdk_api_hookup);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h
index 1b4d6c45ef2..d48e1540592 100644
--- a/src/vnet/vnet_all_api_h.h
+++ b/src/vnet/vnet_all_api_h.h
@@ -30,6 +30,9 @@
#endif /* included_from_layer_3 */
#include <vnet/devices/af_packet/af_packet.api.h>
+#if DPDK > 0
+#include <vnet/devices/dpdk/dpdk.api.h>
+#endif
#include <vnet/devices/netmap/netmap.api.h>
#include <vnet/devices/virtio/vhost_user.api.h>
#include <vnet/gre/gre.api.h>
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index 6289249c4de..46e28e9dc25 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -86,10 +86,6 @@
#undef __included_bihash_template_h__
#include <vnet/l2/l2_fib.h>
-#if DPDK > 0
-#include <vnet/devices/dpdk/dpdk.h>
-#endif
-
#include <vpp/stats/stats.h>
#include <vpp/oam/oam.h>
@@ -131,9 +127,6 @@ _(SW_INTERFACE_SET_VPATH, sw_interface_set_vpath) \
_(SW_INTERFACE_SET_VXLAN_BYPASS, sw_interface_set_vxlan_bypass) \
_(SW_INTERFACE_SET_L2_XCONNECT, sw_interface_set_l2_xconnect) \
_(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
-_(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
-_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport) \
-_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl) \
_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
@@ -698,152 +691,6 @@ static void
}
static void
- vl_api_sw_interface_set_dpdk_hqos_pipe_t_handler
- (vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp)
-{
- vl_api_sw_interface_set_dpdk_hqos_pipe_reply_t *rmp;
- int rv = 0;
-
-#if DPDK > 0
- dpdk_main_t *dm = &dpdk_main;
- dpdk_device_t *xd;
-
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 subport = ntohl (mp->subport);
- u32 pipe = ntohl (mp->pipe);
- u32 profile = ntohl (mp->profile);
- vnet_hw_interface_t *hw;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- /* hw_if & dpdk device */
- hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
-
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- rv = rte_sched_pipe_config (xd->hqos_ht->hqos, subport, pipe, profile);
-
- BAD_SW_IF_INDEX_LABEL;
-#else
- clib_warning ("setting HQoS pipe parameters without DPDK not implemented");
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif /* DPDK */
-
- REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE_REPLY);
-}
-
-static void
- vl_api_sw_interface_set_dpdk_hqos_subport_t_handler
- (vl_api_sw_interface_set_dpdk_hqos_subport_t * mp)
-{
- vl_api_sw_interface_set_dpdk_hqos_subport_reply_t *rmp;
- int rv = 0;
-
-#if DPDK > 0
- dpdk_main_t *dm = &dpdk_main;
- dpdk_device_t *xd;
- struct rte_sched_subport_params p;
-
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 subport = ntohl (mp->subport);
- p.tb_rate = ntohl (mp->tb_rate);
- p.tb_size = ntohl (mp->tb_size);
- p.tc_rate[0] = ntohl (mp->tc_rate[0]);
- p.tc_rate[1] = ntohl (mp->tc_rate[1]);
- p.tc_rate[2] = ntohl (mp->tc_rate[2]);
- p.tc_rate[3] = ntohl (mp->tc_rate[3]);
- p.tc_period = ntohl (mp->tc_period);
-
- vnet_hw_interface_t *hw;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- /* hw_if & dpdk device */
- hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
-
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- rv = rte_sched_subport_config (xd->hqos_ht->hqos, subport, &p);
-
- BAD_SW_IF_INDEX_LABEL;
-#else
- clib_warning
- ("setting HQoS subport parameters without DPDK not implemented");
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif /* DPDK */
-
- REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT_REPLY);
-}
-
-static void
- vl_api_sw_interface_set_dpdk_hqos_tctbl_t_handler
- (vl_api_sw_interface_set_dpdk_hqos_tctbl_t * mp)
-{
- vl_api_sw_interface_set_dpdk_hqos_tctbl_reply_t *rmp;
- int rv = 0;
-
-#if DPDK > 0
- dpdk_main_t *dm = &dpdk_main;
- vlib_thread_main_t *tm = vlib_get_thread_main ();
- dpdk_device_t *xd;
-
- u32 sw_if_index = ntohl (mp->sw_if_index);
- u32 entry = ntohl (mp->entry);
- u32 tc = ntohl (mp->tc);
- u32 queue = ntohl (mp->queue);
- u32 val, i;
-
- vnet_hw_interface_t *hw;
-
- VALIDATE_SW_IF_INDEX (mp);
-
- /* hw_if & dpdk device */
- hw = vnet_get_sup_hw_interface (dm->vnet_main, sw_if_index);
-
- xd = vec_elt_at_index (dm->devices, hw->dev_instance);
-
- if (tc >= RTE_SCHED_TRAFFIC_CLASSES_PER_PIPE)
- {
- clib_warning ("invalid traffic class !!");
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto done;
- }
- if (queue >= RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS)
- {
- clib_warning ("invalid queue !!");
- rv = VNET_API_ERROR_INVALID_VALUE;
- goto done;
- }
-
- /* Detect the set of worker threads */
- uword *p = hash_get_mem (tm->thread_registrations_by_name, "workers");
-
- if (p == 0)
- {
- clib_warning ("worker thread registration AWOL !!");
- rv = VNET_API_ERROR_INVALID_VALUE_2;
- goto done;
- }
-
- vlib_thread_registration_t *tr = (vlib_thread_registration_t *) p[0];
- int worker_thread_first = tr->first_index;
- int worker_thread_count = tr->count;
-
- val = tc * RTE_SCHED_QUEUES_PER_TRAFFIC_CLASS + queue;
- for (i = 0; i < worker_thread_count; i++)
- xd->hqos_wt[worker_thread_first + i].hqos_tc_table[entry] = val;
-
- BAD_SW_IF_INDEX_LABEL;
-done:
-#else
- clib_warning ("setting HQoS DSCP table entry without DPDK not implemented");
- rv = VNET_API_ERROR_UNIMPLEMENTED;
-#endif /* DPDK */
-
- REPLY_MACRO (VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL_REPLY);
-}
-
-static void
vl_api_bridge_domain_add_del_t_handler (vl_api_bridge_domain_add_del_t * mp)
{
vlib_main_t *vm = vlib_get_main ();
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 1964533ee17..c2cd3d15a20 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -238,6 +238,7 @@ static void *vl_api_sw_interface_set_l2_bridge_t_print
FINISH;
}
+#if DPDK > 0
static void *vl_api_sw_interface_set_dpdk_hqos_pipe_t_print
(vl_api_sw_interface_set_dpdk_hqos_pipe_t * mp, void *handle)
{
@@ -287,6 +288,7 @@ static void *vl_api_sw_interface_set_dpdk_hqos_tctbl_t_print
FINISH;
}
+#endif
static void *vl_api_bridge_domain_add_del_t_print
(vl_api_bridge_domain_add_del_t * mp, void *handle)
@@ -3002,9 +3004,6 @@ _(BRIDGE_FLAGS, bridge_flags) \
_(CLASSIFY_ADD_DEL_TABLE, classify_add_del_table) \
_(CLASSIFY_ADD_DEL_SESSION, classify_add_del_session) \
_(SW_INTERFACE_SET_L2_BRIDGE, sw_interface_set_l2_bridge) \
-_(SW_INTERFACE_SET_DPDK_HQOS_PIPE, sw_interface_set_dpdk_hqos_pipe) \
-_(SW_INTERFACE_SET_DPDK_HQOS_SUBPORT, sw_interface_set_dpdk_hqos_subport)\
-_(SW_INTERFACE_SET_DPDK_HQOS_TCTBL, sw_interface_set_dpdk_hqos_tctbl) \
_(BRIDGE_DOMAIN_ADD_DEL, bridge_domain_add_del) \
_(BRIDGE_DOMAIN_DUMP, bridge_domain_dump) \
_(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table) \
@@ -3128,6 +3127,18 @@ vl_msg_api_custom_dump_configure (api_main_t * am)
= (void *) vl_api_##f##_t_print;
foreach_custom_print_function;
#undef _
+
+#if DPDK > 0
+ /*
+ * manually add DPDK hqos print handlers
+ */
+ am->msg_print_handlers[VL_API_SW_INTERFACE_SET_DPDK_HQOS_PIPE] =
+ (void *) vl_api_sw_interface_set_dpdk_hqos_pipe_t_print;
+ am->msg_print_handlers[VL_API_SW_INTERFACE_SET_DPDK_HQOS_SUBPORT] =
+ (void *) vl_api_sw_interface_set_dpdk_hqos_subport_t_print;
+ am->msg_print_handlers[VL_API_SW_INTERFACE_SET_DPDK_HQOS_TCTBL] =
+ (void *) vl_api_sw_interface_set_dpdk_hqos_tctbl_t_print;
+#endif
}
/*
diff --git a/src/vpp/api/vpe.api b/src/vpp/api/vpe.api
index abd0e8f1cba..3e4bcdf9134 100644
--- a/src/vpp/api/vpe.api
+++ b/src/vpp/api/vpe.api
@@ -37,6 +37,7 @@
* IPSEC-GRE APIs: see .../vnet/vnet/ipsec-gre/{ipsec_gre.api, ipsec_gre_api.c}
* LISP APIs: see .../vnet/vnet/lisp/{lisp.api, lisp_api.c}
* LISP-GPE APIs: see .../vnet/vnet/lisp-gpe/{lisp_gpe.api, lisp_gpe_api.c}
+ * DPDK APIs: ... see /src/vnet/devices/dpdk/{dpdk.api, dpdk_api.c}
*/
/** \brief Create a new subinterface with the given vlan id
@@ -2606,88 +2607,6 @@ define delete_subif_reply {
i32 retval;
};
-/** \brief DPDK interface HQoS pipe profile set request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param sw_if_index - the interface
- @param subport - subport ID
- @param pipe - pipe ID within its subport
- @param profile - pipe profile ID
-*/
-define sw_interface_set_dpdk_hqos_pipe {
- u32 client_index;
- u32 context;
- u32 sw_if_index;
- u32 subport;
- u32 pipe;
- u32 profile;
-};
-
-/** \brief DPDK interface HQoS pipe profile set reply
- @param context - sender context, to match reply w/ request
- @param retval - request return code
-*/
-define sw_interface_set_dpdk_hqos_pipe_reply {
- u32 context;
- i32 retval;
-};
-
-/** \brief DPDK interface HQoS subport parameters set request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param sw_if_index - the interface
- @param subport - subport ID
- @param tb_rate - subport token bucket rate (measured in bytes/second)
- @param tb_size - subport token bucket size (measured in credits)
- @param tc_rate - subport traffic class 0 .. 3 rates (measured in bytes/second)
- @param tc_period - enforcement period for rates (measured in milliseconds)
-*/
-define sw_interface_set_dpdk_hqos_subport {
- u32 client_index;
- u32 context;
- u32 sw_if_index;
- u32 subport;
- u32 tb_rate;
- u32 tb_size;
- u32 tc_rate[4];
- u32 tc_period;
-};
-
-/** \brief DPDK interface HQoS subport parameters set reply
- @param context - sender context, to match reply w/ request
- @param retval - request return code
-*/
-define sw_interface_set_dpdk_hqos_subport_reply {
- u32 context;
- i32 retval;
-};
-
-/** \brief DPDK interface HQoS tctbl entry set request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param sw_if_index - the interface
- @param entry - entry index ID
- @param tc - traffic class (0 .. 3)
- @param queue - traffic class queue (0 .. 3)
-*/
-define sw_interface_set_dpdk_hqos_tctbl {
- u32 client_index;
- u32 context;
- u32 sw_if_index;
- u32 entry;
- u32 tc;
- u32 queue;
-};
-
-/** \brief DPDK interface HQoS tctbl entry set reply
- @param context - sender context, to match reply w/ request
- @param retval - request return code
-*/
-define sw_interface_set_dpdk_hqos_tctbl_reply {
- u32 context;
- i32 retval;
-};
-
/** \brief L2 interface pbb tag rewrite configure request
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request