X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vpp%2Fvpp-api%2Fapi.c;h=fb44aaa8371eaacc5b52f36ba07cc1c730ad1cec;hb=c00617b13ccda0cfbd9ea248342643f728b0087f;hp=1de1b55f722db6a5a5179125b03a21dc4b78ad30;hpb=251aec436b9e3be15f92a464fa4559396b115b2a;p=vpp.git diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 1de1b55f722..fb44aaa8371 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -92,9 +92,7 @@ #include #include #endif /* IPSEC */ -#if DPDK > 0 #include -#endif #include #include @@ -347,6 +345,7 @@ _(LISP_EID_TABLE_DUMP, lisp_eid_table_dump) \ _(LISP_GPE_TUNNEL_DUMP, lisp_gpe_tunnel_dump) \ _(LISP_MAP_RESOLVER_DUMP, lisp_map_resolver_dump) \ _(LISP_EID_TABLE_MAP_DUMP, lisp_eid_table_map_dump) \ +_(LISP_EID_TABLE_VNI_DUMP, lisp_eid_table_vni_dump) \ _(SHOW_LISP_STATUS, show_lisp_status) \ _(LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \ lisp_add_del_map_request_itr_rlocs) \ @@ -2887,12 +2886,12 @@ vl_api_vnet_get_summary_stats_t_handler (vl_api_vnet_get_summary_stats_t * mp) } vnet_interface_counter_unlock (im); - /* Note: in HOST byte order! */ - rmp->total_pkts[VLIB_RX] = total_pkts[VLIB_RX]; - rmp->total_bytes[VLIB_RX] = total_bytes[VLIB_RX]; - rmp->total_pkts[VLIB_TX] = total_pkts[VLIB_TX]; - rmp->total_bytes[VLIB_TX] = total_bytes[VLIB_TX]; - rmp->vector_rate = vlib_last_vector_length_per_node (sm->vlib_main); + rmp->total_pkts[VLIB_RX] = clib_host_to_net_u64 (total_pkts[VLIB_RX]); + rmp->total_bytes[VLIB_RX] = clib_host_to_net_u64 (total_bytes[VLIB_RX]); + rmp->total_pkts[VLIB_TX] = clib_host_to_net_u64 (total_pkts[VLIB_TX]); + rmp->total_bytes[VLIB_TX] = clib_host_to_net_u64 (total_bytes[VLIB_TX]); + rmp->vector_rate = + clib_host_to_net_u64 (vlib_last_vector_length_per_node (sm->vlib_main)); vl_msg_api_send_shmem (q, (u8 *) & rmp); } @@ -4027,16 +4026,20 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp) { int rv = 0; vl_api_create_vhost_user_if_reply_t *rmp; -#if DPDK > 0 u32 sw_if_index = (u32) ~ 0; vnet_main_t *vnm = vnet_get_main (); vlib_main_t *vm = vlib_get_main (); - rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename, - mp->is_server, &sw_if_index, (u64) ~ 0, - mp->renumber, ntohl (mp->custom_dev_instance), - (mp->use_custom_mac) ? mp->mac_address : NULL); +#if DPDK > 0 && DPDK_VHOST_USER + rv = dpdk_vhost_user_create_if ( +#else + rv = vhost_user_create_if ( +#endif + vnm, vm, (char *) mp->sock_filename, + mp->is_server, &sw_if_index, (u64) ~ 0, + mp->renumber, ntohl (mp->custom_dev_instance), + (mp->use_custom_mac) ? mp->mac_address : NULL); /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY, @@ -4044,10 +4047,6 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp) rmp->sw_if_index = ntohl (sw_if_index); })); /* *INDENT-ON* */ -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; - REPLY_MACRO (VL_API_CREATE_VHOST_USER_IF_REPLY); -#endif } static void @@ -4055,19 +4054,19 @@ vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t * mp) { int rv = 0; vl_api_modify_vhost_user_if_reply_t *rmp; -#if DPDK > 0 && DPDK_VHOST_USER u32 sw_if_index = ntohl (mp->sw_if_index); vnet_main_t *vnm = vnet_get_main (); vlib_main_t *vm = vlib_get_main (); - rv = dpdk_vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename, - mp->is_server, sw_if_index, (u64) ~ 0, - mp->renumber, - ntohl (mp->custom_dev_instance)); +#if DPDK > 0 && DPDK_VHOST_USER + rv = dpdk_vhost_user_modify_if ( #else - rv = VNET_API_ERROR_UNIMPLEMENTED; + rv = vhost_user_modify_if ( #endif + vnm, vm, (char *) mp->sock_filename, + mp->is_server, sw_if_index, (u64) ~ 0, + mp->renumber, ntohl (mp->custom_dev_instance)); REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY); } @@ -4076,14 +4075,17 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp) { int rv = 0; vl_api_delete_vhost_user_if_reply_t *rmp; -#if DPDK > 0 && DPDK_VHOST_USER vpe_api_main_t *vam = &vpe_api_main; u32 sw_if_index = ntohl (mp->sw_if_index); vnet_main_t *vnm = vnet_get_main (); vlib_main_t *vm = vlib_get_main (); +#if DPDK > 0 && DPDK_VHOST_USER rv = dpdk_vhost_user_delete_if (vnm, vm, sw_if_index); +#else + rv = vhost_user_delete_if (vnm, vm, sw_if_index); +#endif REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY); if (!rv) @@ -4095,10 +4097,6 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp) send_sw_interface_flags_deleted (vam, q, sw_if_index); } -#else - rv = VNET_API_ERROR_UNIMPLEMENTED; - REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY); -#endif } static void @@ -4108,7 +4106,6 @@ static void clib_warning ("BUG"); } -#if DPDK > 0 && DPDK_VHOST_USER static void send_sw_interface_vhost_user_details (vpe_api_main_t * am, unix_shared_memory_queue_t * q, @@ -4135,13 +4132,11 @@ send_sw_interface_vhost_user_details (vpe_api_main_t * am, vl_msg_api_send_shmem (q, (u8 *) & mp); } -#endif static void vl_api_sw_interface_vhost_user_dump_t_handler (vl_api_sw_interface_vhost_user_dump_t * mp) { -#if DPDK > 0 && DPDK_VHOST_USER int rv = 0; vpe_api_main_t *am = &vpe_api_main; vnet_main_t *vnm = vnet_get_main (); @@ -4154,7 +4149,11 @@ static void if (q == 0) return; +#if DPDK > 0 && DPDK_VHOST_USER rv = dpdk_vhost_user_dump_ifs (vnm, vm, &ifaces); +#else + rv = vhost_user_dump_ifs (vnm, vm, &ifaces); +#endif if (rv) return; @@ -4163,7 +4162,6 @@ static void send_sw_interface_vhost_user_details (am, q, vuid, mp->context); } vec_free (ifaces); -#endif } static void @@ -5128,7 +5126,7 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t * vnet_lisp_add_del_locator_set_args_t _a, *a = &_a; locator_t locator; ls_locator_t *ls_loc; - u32 ls_index = ~0; + u32 ls_index = ~0, locator_num; u8 *locator_name = NULL; int i; @@ -5139,9 +5137,10 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t * a->name = locator_name; a->is_add = mp->is_add; a->local = 1; + locator_num = clib_net_to_host_u32 (mp->locator_num); memset (&locator, 0, sizeof (locator)); - for (i = 0; i < mp->locator_num; i++) + for (i = 0; i < locator_num; i++) { ls_loc = &((ls_locator_t *) mp->locators)[i]; VALIDATE_SW_IF_INDEX (ls_loc); @@ -5481,6 +5480,7 @@ static void vl_api_lisp_add_del_remote_mapping_reply_t *rmp; int rv = 0; gid_address_t _eid, *eid = &_eid; + u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num); memset (eid, 0, sizeof (eid[0])); @@ -5489,9 +5489,7 @@ static void if (rv) goto send_reply; - rlocs = unformat_lisp_locs (mp->rlocs, mp->rloc_num); - if (0 == rlocs) - goto send_reply; + rlocs = unformat_lisp_locs (mp->rlocs, rloc_num); if (!mp->is_add) { @@ -5673,6 +5671,8 @@ send_lisp_eid_table_details (mapping_t * mapit, unix_shared_memory_queue_t * q, u32 context, u8 filter) { + lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); + locator_set_t *ls = 0; vl_api_lisp_eid_table_details_t *rmp = NULL; gid_address_t *gid = NULL; u8 *mac = 0; @@ -5703,9 +5703,16 @@ send_lisp_eid_table_details (mapping_t * mapit, rmp = vl_msg_api_alloc (sizeof (*rmp)); memset (rmp, 0, sizeof (*rmp)); rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_DETAILS); - rmp->locator_set_index = mapit->locator_set_index; + + ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index); + if (vec_len (ls->locator_indices) == 0) + rmp->locator_set_index = ~0; + else + rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index); + rmp->is_local = mapit->local; - rmp->ttl = mapit->ttl; + rmp->ttl = clib_host_to_net_u32 (mapit->ttl); + rmp->action = mapit->action; rmp->authoritative = mapit->authoritative; switch (gid_address_type (gid)) @@ -5898,7 +5905,7 @@ send_eid_table_map_pair (hash_pair_t * p, rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS); rmp->vni = clib_host_to_net_u32 (p->key); - rmp->vrf = clib_host_to_net_u32 (p->value[0]); + rmp->dp_table = clib_host_to_net_u32 (p->value[0]); rmp->context = context; vl_msg_api_send_shmem (q, (u8 *) & rmp); } @@ -5910,20 +5917,79 @@ vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t * unix_shared_memory_queue_t *q = NULL; lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); hash_pair_t *p; + uword *vni_table = 0; q = vl_api_client_index_to_input_queue (mp->client_index); if (q == 0) { return; } + + if (mp->is_l2) + { + vni_table = lcm->bd_id_by_vni; + } + else + { + vni_table = lcm->table_id_by_vni; + } + /* *INDENT-OFF* */ - hash_foreach_pair (p, lcm->table_id_by_vni, + hash_foreach_pair (p, vni_table, ({ send_eid_table_map_pair (p, q, mp->context); })); /* *INDENT-ON* */ } +static void +send_eid_table_vni (u32 vni, unix_shared_memory_queue_t * q, u32 context) +{ + vl_api_lisp_eid_table_vni_details_t *rmp = 0; + + rmp = vl_msg_api_alloc (sizeof (*rmp)); + memset (rmp, 0, sizeof (*rmp)); + rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_VNI_DETAILS); + rmp->context = context; + rmp->vni = clib_host_to_net_u32 (vni); + vl_msg_api_send_shmem (q, (u8 *) & rmp); +} + +static void +vl_api_lisp_eid_table_vni_dump_t_handler (vl_api_lisp_eid_table_vni_dump_t * + mp) +{ + hash_pair_t *p; + u32 *vnis = 0; + unix_shared_memory_queue_t *q = 0; + lisp_cp_main_t *lcm = vnet_lisp_cp_get_main (); + + q = vl_api_client_index_to_input_queue (mp->client_index); + if (q == 0) + { + return; + } + + /* *INDENT-OFF* */ + hash_foreach_pair (p, lcm->table_id_by_vni, + ({ + hash_set (vnis, p->key, 0); + })); + + hash_foreach_pair (p, lcm->bd_id_by_vni, + ({ + hash_set (vnis, p->key, 0); + })); + + hash_foreach_pair (p, vnis, + ({ + send_eid_table_vni (p->key, q, mp->context); + })); + /* *INDENT-ON* */ + + hash_free (vnis); +} + static void vl_api_show_lisp_status_t_handler (vl_api_show_lisp_status_t * mp) {