aboutsummaryrefslogtreecommitdiffstats
path: root/docs/cpta/trending/container_memif-3n-skx-xxv710.rst
AgeCommit message (Collapse)AuthorFilesLines
2020-03-30Trending: Update graphs - 3n-skxTibor Frank1-7/+45
Change-Id: I0698e7fa48b7fa199b886407c2e9c1bc5094e746 Signed-off-by: Tibor Frank <tifrank@cisco.com>
2020-02-18Trending: PlotsTibor Frank1-7/+7
- remove not needed params - i40e --> dpdk Change-Id: Ib63a66486b040b01a929f3ee0a4e80468c9d4e28 Signed-off-by: Tibor Frank <tifrank@cisco.com>
2019-12-04Trending: ReorganizationTibor Frank1-0/+54
+ use selection of tests by their full names + finalize trending_test_groups.md + modify static content + modify anchors + specifications: + container memif + ip4 + ip4 tunnels + ip6 + ipsec + l2 + srv6 + vhost + vts + dpdk + add 2n-clx + hyperlinks Change-Id: Ibe073330317539896c6fbfcbd4a7a279b58bdb95 Signed-off-by: Tibor Frank <tifrank@cisco.com>
or: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2019 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 <builtinurl/builtinurl.h>
#include <http_static/http_static.h>
#include <vpp/app/version.h>

int
handle_get_version (http_builtin_method_type_t reqtype,
		    u8 * request, http_session_t * hs)
{
  u8 *s = 0;

  /* Build some json bullshit */
  s = format (s, "{\"vpp_details\": {");
  s = format (s, "   \"version\": \"%s\",", VPP_BUILD_VER);
  s = format (s, "   \"build_date\": \"%s\"}}\r\n", VPP_BUILD_DATE);

  hs->data = s;
  hs->data_offset = 0;
  hs->cache_pool_index = ~0;
  hs->free_data = 1;
  return 0;
}

void
trim_path_from_request (u8 * s, char *path)
{
  u8 *cp;
  int trim_length = strlen (path) + 1 /* remove '?' */ ;

  /* Get rid of the path and question-mark */
  vec_delete (s, trim_length, 0);

  /* Tail trim irrelevant browser info */
  cp = s;
  while ((cp - s) < vec_len (s))
    {
      if (*cp == ' ')
	{
	  /*
	   * Makes request a vector which happens to look
	   * like a c-string.
	   */
	  *cp = 0;
	  _vec_len (s) = cp - s;
	  break;
	}
      cp++;
    }
}

int
handle_get_interface_stats (http_builtin_method_type_t reqtype,
			    u8 * request, http_session_t * hs)
{
  u8 *s = 0, *stats = 0;
  uword *p;
  u32 *sw_if_indices = 0;
  vnet_hw_interface_t *hi;
  vnet_sw_interface_t *si;
  char *q = "\"";
  int i;
  int need_comma = 0;
  u8 *format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
				      vnet_sw_interface_t * si, int json);
  vnet_main_t *vnm = vnet_get_main ();
  vnet_interface_main_t *im = &vnm->interface_main;

  /* Get stats for a single interface via http POST */
  if (reqtype == HTTP_BUILTIN_METHOD_POST)
    {
      trim_path_from_request (request, "interface_stats.json");

      /* Find the sw_if_index */
      p = hash_get (im->hw_interface_by_name, request);
      if (!p)
	{
	  s = format (s, "{\"interface_stats\": {[\n");
	  s = format (s, "   \"name\": \"%s\",", request);
	  s = format (s, "   \"error\": \"%s\"", "UnknownInterface");
	  s = format (s, "]}\n");
	  goto out;
	}

      vec_add1 (sw_if_indices, p[0]);
    }
  else				/* default, HTTP_BUILTIN_METHOD_GET */
    {
      /* *INDENT-OFF* */
      pool_foreach (hi, im->hw_interfaces,
      ({
        vec_add1 (sw_if_indices, hi->sw_if_index);
      }));
      /* *INDENT-ON* */
    }

  s = format (s, "{%sinterface_stats%s: [\n", q, q);

  for (i = 0; i < vec_len (sw_if_indices); i++)
    {
      si = vnet_get_sw_interface (vnm, sw_if_indices[i]);
      if (need_comma)
	s = format (s, ",\n");

      need_comma = 1;

      s = format (s, "{%sname%s: %s%U%s, ", q, q, q,
		  format_vnet_sw_if_index_name, vnm, sw_if_indices[i], q);

      stats = format_vnet_sw_interface_cntrs (stats, &vnm->interface_main, si,
					      1 /* want json */ );
      if (vec_len (stats))
	s = format (s, "%v}", stats);
      else
	s = format (s, "%snone%s: %strue%s}", q, q, q, q);
      vec_reset_length (stats);
    }

  s = format (s, "]}\n");

out:
  hs->data = s;
  hs->data_offset = 0;
  hs->cache_pool_index = ~0;
  hs->free_data = 1;
  vec_free (sw_if_indices);
  vec_free (stats);
  return 0;
}

int
handle_get_interface_list (http_builtin_method_type_t reqtype,
			   u8 * request, http_session_t * hs)
{
  u8 *s = 0;
  int i;
  vnet_main_t *vnm = vnet_get_main ();
  vnet_interface_main_t *im = &vnm->interface_main;
  vnet_hw_interface_t *hi;
  u32 *hw_if_indices = 0;
  int need_comma = 0;

  /* Construct vector of active hw_if_indexes ... */
  /* *INDENT-OFF* */
  pool_foreach (hi, im->hw_interfaces,
  ({
    /* No point in mentioning "local0"... */
    if (hi - im->hw_interfaces)
      vec_add1 (hw_if_indices, hi - im->hw_interfaces);
  }));
  /* *INDENT-ON* */

  /* Build answer */
  s = format (s, "{\"interface_list\": [\n");
  for (i = 0; i < vec_len (hw_if_indices); i++)
    {
      if (need_comma)
	s = format (s, ",\n");
      hi = pool_elt_at_index (im->hw_interfaces, hw_if_indices[i]);
      s = format (s, "\"%v\"", hi->name);
      need_comma = 1;
    }
  s = format (s, "]}\n");
  vec_free (hw_if_indices);

  hs->data = s;
  hs->data_offset = 0;
  hs->cache_pool_index = ~0;
  hs->free_data = 1;
  return 0;
}

void
builtinurl_handler_init (builtinurl_main_t * bm)
{

  bm->register_handler (handle_get_version, "version.json",
			HTTP_BUILTIN_METHOD_GET);
  bm->register_handler (handle_get_interface_list, "interface_list.json",
			HTTP_BUILTIN_METHOD_GET);
  bm->register_handler (handle_get_interface_stats,
			"interface_stats.json", HTTP_BUILTIN_METHOD_GET);
  bm->register_handler (handle_get_interface_stats,
			"interface_stats.json", HTTP_BUILTIN_METHOD_POST);
}

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