summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib/fib_api.h
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2017-03-02 09:51:27 +0100
committerNeale Ranns <nranns@cisco.com>2017-03-02 13:40:37 +0000
commit8ab4ccc900d786f65e517d95c1317292e6c66f6c (patch)
tree654a6ebca330d7f74d536e6905b5b00fa7433bc2 /src/vnet/fib/fib_api.h
parent443312bb41bde74e5907db35322877a9f103f2c4 (diff)
Update CSIT tests 170220 -> 170302
- update of CSIT operational branch to be used for VPP-patch test Change-Id: Ia8078ae23e0e6fb701e141fd0701fb82987743d7 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'src/vnet/fib/fib_api.h')
0 files changed, 0 insertions, 0 deletions
8' href='#n138'>138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
/*
 * tracedump.c - tracedump vpp-api-test plug-in
 *
 * Copyright (c) <current-year> <your-organization>
 * 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 <vat/vat.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vppinfra/error.h>
#include <vnet/api_errno.h>
#include <stdbool.h>

#define __plugin_msg_base tracedump_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>

/* Declare message IDs */
#include <tracedump/tracedump.api_enum.h>
#include <tracedump/tracedump.api_types.h>

typedef struct
{
  /* API message ID base */
  u16 msg_id_base;
  vat_main_t *vat_main;
} tracedump_test_main_t;

tracedump_test_main_t tracedump_test_main;


int
api_trace_set_filters (vat_main_t * vam)
{
  unformat_input_t *i = vam->input;
  vl_api_trace_set_filters_t *mp;
  u32 flag;
  u32 count;
  u32 node_index;
  u32 classifier;

  flag = TRACE_FF_NONE;
  count = 50;
  node_index = ~0;
  classifier = ~0;

  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
    {
      if (unformat (i, "none"))
	flag = TRACE_FF_NONE;
      else if (unformat (i, "include_node %u", &node_index))
	flag = TRACE_FF_INCLUDE_NODE;
      else if (unformat (i, "exclude_node %u", &node_index))
	flag = TRACE_FF_EXCLUDE_NODE;
      else if (unformat (i, "include_classifier %u", &classifier))
	flag = TRACE_FF_INCLUDE_CLASSIFIER;
      else if (unformat (i, "exclude_classifier %u", &classifier))
	flag = TRACE_FF_EXCLUDE_CLASSIFIER;
      else if (unformat (i, "count %u", &count))
	;
      else
	{
	  clib_warning ("Unknown input: %U\n", format_unformat_error, i);
	  return -99;
	}
    }

  M (TRACE_SET_FILTERS, mp);
  mp->flag = htonl (flag);
  mp->node_index = htonl (node_index);
  mp->count = htonl (count);
  mp->classifier_table_index = htonl (classifier);

  int ret = 0;
  S (mp);
  W (ret);

  return ret;
}


int
api_trace_capture_packets (vat_main_t * vam)
{
  unformat_input_t *i = vam->input;
  vl_api_trace_capture_packets_t *mp;
  u32 node_index;
  u32 max;
  bool pre_capture_clear;
  bool use_filter;
  bool verbose;

  node_index = ~0;
  max = 50;
  pre_capture_clear = use_filter = verbose = false;

  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
    {
      if (unformat (i, "node_index %u", &node_index))
	;
      else if (unformat (i, "max %u", &max))
	;
      else if (unformat (i, "pre_capture_clear"))
	pre_capture_clear = false;
      else if (unformat (i, "use_filter"))
	use_filter = false;
      else if (unformat (i, "verbose"))
	verbose = false;
      else
	{
	  clib_warning ("Unknown input: %U\n", format_unformat_error, i);
	  return -99;
	}
    }

  M (TRACE_CAPTURE_PACKETS, mp);
  mp->node_index = htonl (node_index);
  mp->max_packets = htonl (max);
  mp->use_filter = use_filter;
  mp->verbose = verbose;
  mp->pre_capture_clear = pre_capture_clear;

  int ret = 0;
  S (mp);
  W (ret);

  return ret;
}


static void
vl_api_trace_details_t_handler (vl_api_trace_details_t * dmp)
{
  u32 packet_number;
  u32 thread_id, position;

  thread_id = clib_net_to_host_u32 (dmp->thread_id);
  position = clib_net_to_host_u32 (dmp->position);
  packet_number = clib_net_to_host_u32 (dmp->packet_number);
  fformat
    (stdout,
     "thread %d position %d more_this_thread %d more_threads %d done %d\n",
     thread_id, position, (u32) dmp->more_this_thread,
     (u32) dmp->more_threads, (u32) dmp->done);
  fformat (stdout, "Packet %d\n%U\n\n",
	   packet_number, vl_api_format_string, (&dmp->trace_data));
}


static void
vl_api_trace_dump_reply_t_handler (vl_api_trace_dump_reply_t * rmp)
{
  tracedump_test_main_t *ttm = &tracedump_test_main;
  vat_main_t *vam = ttm->vat_main;
  vl_api_trace_dump_t *mp;
  i32 retval = (i32) clib_net_to_host_u32 (rmp->retval);
  u32 thread_id, position;

  if (retval != 0 || rmp->done)
    {
      vam->result_ready = 1;
      vam->retval = retval;

      /* Clear the cache */
      if (retval == 0 && rmp->flush_only == 0)
	{
	  M (TRACE_DUMP, mp);
	  mp->clear_cache = 1;
	  mp->thread_id = 0xFFFFFFFF;
	  mp->position = 0xFFFFFFFF;
	  S (mp);
	}
      return;
    }

  /* Figure out where the next batch starts */
  thread_id = clib_host_to_net_u32 (rmp->last_thread_id);
  position = clib_host_to_net_u32 (rmp->last_position);

  if (rmp->more_threads)
    {
      position = 0;
      thread_id++;
    }
  else
    position++;

  M (TRACE_DUMP, mp);
  mp->clear_cache = 0;
  mp->thread_id = clib_host_to_net_u32 (thread_id);
  mp->position = clib_host_to_net_u32 (position);
  mp->max_records = clib_host_to_net_u32 (10);
  S (mp);
}

static int
api_trace_dump (vat_main_t * vam)
{
  vl_api_trace_dump_t *mp;
  int ret;

  M (TRACE_DUMP, mp);
  mp->clear_cache = 1;
  mp->thread_id = 0;
  mp->position = 0;
  mp->max_records = clib_host_to_net_u32 (10);

  S (mp);

  W (ret);
  return ret;
}

int
api_trace_clear_capture (vat_main_t * vam)
{
  vl_api_trace_clear_capture_t *mp;
  int ret;

  M (TRACE_CLEAR_CAPTURE, mp);
  S (mp);
  W (ret);
  return ret;
}




#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
#define vl_endianfun
#include <tracedump/tracedump.api.h>
#undef vl_endianfun
#define vl_printfun
#include <tracedump/tracedump.api.h>
#undef vl_printfun

void
manual_setup_message_id_table (vat_main_t * vam)
{
  vl_msg_api_set_handlers (VL_API_TRACE_DETAILS
			   + tracedump_test_main.msg_id_base, "trace_details",
			   vl_api_trace_details_t_handler, vl_noop_handler,
			   vl_api_trace_details_t_endian,
			   vl_api_trace_details_t_print,
			   sizeof (vl_api_trace_details_t), 1);
}

#define VL_API_LOCAL_SETUP_MESSAGE_ID_TABLE manual_setup_message_id_table
#define VL_API_TRACE_DUMP_REPLY_T_HANDLER

#include <tracedump/tracedump.api_test.c>

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */