summaryrefslogtreecommitdiffstats
path: root/test/vpp_object.py
AgeCommit message (Expand)AuthorFilesLines
2017-03-06make test: reset object registry if vpp diesKlement Sekera1-2/+7
2017-03-02BFD: command line interfaceKlement Sekera1-0/+1
2017-02-14make test: improve stabilityKlement Sekera1-18/+17
2017-01-11BFD: fix bfd_udp_add APIKlement Sekera1-9/+12
2016-12-07BFD: basic asynchronous session up/downKlement Sekera1-0/+79
id='n126' href='#n126'>126 127 128 129 130 131 132 133 134 135 136 137 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
/*
 *------------------------------------------------------------------
 * Copyright (c) 2018 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 <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlib/pci/pci.h>
#include <vnet/ethernet/ethernet.h>

#include <vmxnet3/vmxnet3.h>

u8 *
format_vmxnet3_device_name (u8 * s, va_list * args)
{
  vlib_main_t *vm = vlib_get_main ();
  u32 i = va_arg (*args, u32);
  vmxnet3_main_t *vmxm = &vmxnet3_main;
  vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, i);
  vlib_pci_addr_t *addr = vlib_pci_get_addr (vm, vd->pci_dev_handle);

  s = format (s, "vmxnet3-%x/%x/%x/%x",
	      addr->domain, addr->bus, addr->slot, addr->function);
  return s;
}

u8 *
format_vmxnet3_device_flags (u8 * s, va_list * args)
{
  vmxnet3_device_t *vd = va_arg (*args, vmxnet3_device_t *);
  u8 *t = 0;

#define _(a, b, c) if (vd->flags & (1 << a)) \
    t = format (t, "%s%s", t ? " ":"", c);
  foreach_vmxnet3_device_flags
#undef _
    s = format (s, "%v", t);
  vec_free (t);
  return s;
}

u8 *
format_vmxnet3_device (u8 * s, va_list * args)
{
  u32 i = va_arg (*args, u32);
  vmxnet3_main_t *vmxm = &vmxnet3_main;
  vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, i);
  u32 indent = format_get_indent (s);
  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, 0);
  vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, 0);
  vmxnet3_tx_queue *tx = VMXNET3_TX_START (vd);
  vmxnet3_rx_queue *rx = VMXNET3_RX_START (vd);
  u16 qid;

  s = format (s, "flags: %U", format_vmxnet3_device_flags, vd);
  s = format (s, "\n%Urx queues %u, rx desc %u, tx queues %u, tx desc %u",
	      format_white_space, indent,
	      vd->num_rx_queues, rxq->size, vd->num_tx_queues, txq->size);
  if (vd->error)
    s = format (s, "\n%Uerror %U", format_white_space, indent,
		format_clib_error, vd->error);

  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);

  vec_foreach_index (qid, vd->txqs)
  {
    vmxnet3_tx_stats *txs = vec_elt_at_index (vd->tx_stats, qid);

    s = format (s, "\n%UTX Queue %u:", format_white_space, indent, qid);
    s = format (s, "\n%U  TSO packets                         %llu",
		format_white_space, indent,
		tx->stats.tso_pkts - txs->tso_pkts);
    s = format (s, "\n%U  TSO bytes                           %llu",
		format_white_space, indent,
		tx->stats.tso_bytes - txs->tso_bytes);
    s = format (s, "\n%U  ucast packets                       %llu",
		format_white_space, indent,
		tx->stats.ucast_pkts - txs->ucast_pkts);
    s = format (s, "\n%U  ucast bytes                         %llu",
		format_white_space, indent,
		tx->stats.ucast_bytes - txs->ucast_bytes);
    s = format (s, "\n%U  mcast packets                       %llu",
		format_white_space, indent,
		tx->stats.mcast_pkts - txs->mcast_pkts);
    s = format (s, "\n%U  mcast bytes                         %llu",
		format_white_space, indent,
		tx->stats.mcast_bytes - txs->mcast_bytes);
    s = format (s, "\n%U  bcast packets                       %llu",
		format_white_space, indent,
		tx->stats.bcast_pkts - txs->bcast_pkts);
    s = format (s, "\n%U  bcast bytes                         %llu",
		format_white_space, indent,
		tx->stats.bcast_bytes - txs->bcast_bytes);
    s = format (s, "\n%U  Errors packets                      %llu",
		format_white_space, indent,
		tx->stats.error_pkts - txs->error_pkts);
    s = format (s, "\n%U  Discard packets                     %llu",
		format_white_space, indent,
		tx->stats.discard_pkts - txs->discard_pkts);
    tx++;
  }

  vec_foreach_index (qid, vd->rxqs)
  {
    vmxnet3_rx_stats *rxs = vec_elt_at_index (vd->rx_stats, qid);

    s = format (s, "\n%URX Queue %u:", format_white_space, indent, qid);
    s = format (s, "\n%U  LRO packets                         %llu",
		format_white_space, indent,
		rx->stats.lro_pkts - rxs->lro_pkts);
    s = format (s, "\n%U  LRO bytes                           %llu",
		format_white_space, indent,
		rx->stats.lro_bytes - rxs->lro_bytes);
    s = format (s, "\n%U  ucast packets                       %llu",
		format_white_space, indent,
		rx->stats.ucast_pkts - rxs->ucast_pkts);
    s = format (s, "\n%U  ucast bytes                         %llu",
		format_white_space, indent,
		rx->stats.ucast_bytes - rxs->ucast_bytes);
    s = format (s, "\n%U  mcast packets                       %llu",
		format_white_space, indent,
		rx->stats.mcast_pkts - rxs->mcast_pkts);
    s = format (s, "\n%U  mcast bytes                         %llu",
		format_white_space, indent,
		rx->stats.mcast_bytes - rxs->mcast_bytes);
    s = format (s, "\n%U  bcast packets                       %llu",
		format_white_space, indent,
		rx->stats.bcast_pkts - rxs->bcast_pkts);
    s = format (s, "\n%U  bcast bytes                         %llu",
		format_white_space, indent,
		rx->stats.bcast_bytes - rxs->bcast_bytes);
    s = format (s, "\n%U  No Bufs                             %llu",
		format_white_space, indent,
		rx->stats.nobuf_pkts - rxs->nobuf_pkts);
    s = format (s, "\n%U  Error packets                       %llu",
		format_white_space, indent,
		rx->stats.error_pkts - rxs->error_pkts);
    rx++;
  }
  return s;
}

u8 *
format_vmxnet3_input_trace (u8 * s, va_list * args)
{
  vlib_main_t *vm = va_arg (*args, vlib_main_t *);
  vlib_node_t *node = va_arg (*args, vlib_node_t *);
  vmxnet3_input_trace_t *t = va_arg (*args, vmxnet3_input_trace_t *);
  vnet_main_t *vnm = vnet_get_main ();
  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, t->hw_if_index);

  s = format (s, "vmxnet3: %v (%d) next-node %U",
	      hi->name, t->hw_if_index, format_vlib_next_node_name, vm,
	      node->index, t->next_index);
  s = format (s, "\n  buffer %U", format_vnet_buffer_no_chain, &t->buffer);

  return s;
}

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