FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
dpdk_priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define DPDK_NB_RX_DESC_DEFAULT 512
17 #define DPDK_NB_TX_DESC_DEFAULT 512
18 #define DPDK_NB_RX_DESC_VIRTIO 256
19 #define DPDK_NB_TX_DESC_VIRTIO 256
20 #define DPDK_NB_RX_DESC_10GE 1024
21 #define DPDK_NB_TX_DESC_10GE 1024
22 #define DPDK_NB_RX_DESC_40GE 1024
23 #define DPDK_NB_TX_DESC_40GE 1024
24 #define DPDK_NB_RX_DESC_ENIC 1024
25 
26 #define I40E_DEV_ID_SFP_XL710 0x1572
27 #define I40E_DEV_ID_QSFP_A 0x1583
28 #define I40E_DEV_ID_QSFP_B 0x1584
29 #define I40E_DEV_ID_QSFP_C 0x1585
30 #define I40E_DEV_ID_10G_BASE_T 0x1586
31 #define I40E_DEV_ID_VF 0x154C
32 
33 /* These args appear by themselves */
34 #define foreach_eal_double_hyphen_predicate_arg \
35 _(no-shconf) \
36 _(no-hpet) \
37 _(no-huge) \
38 _(vmware-tsc-map)
39 
40 #define foreach_eal_single_hyphen_mandatory_arg \
41 _(coremask, c) \
42 _(nchannels, n) \
43 
44 #define foreach_eal_single_hyphen_arg \
45 _(blacklist, b) \
46 _(mem-alloc-request, m) \
47 _(force-ranks, r)
48 
49 /* These args are preceeded by "--" and followed by a single string */
50 #define foreach_eal_double_hyphen_arg \
51 _(huge-dir) \
52 _(proc-type) \
53 _(file-prefix) \
54 _(vdev)
55 
56 static inline void
58 {
59  int len;
60  if ((len = rte_eth_xstats_get (xd->device_index, NULL, 0)) > 0)
61  {
62  vec_validate (xd->xstats, len - 1);
63  vec_validate (xd->last_cleared_xstats, len - 1);
64 
65  len =
66  rte_eth_xstats_get (xd->device_index, xd->xstats,
67  vec_len (xd->xstats));
68 
69  ASSERT (vec_len (xd->xstats) == len);
70  ASSERT (vec_len (xd->last_cleared_xstats) == len);
71 
72  _vec_len (xd->xstats) = len;
73  _vec_len (xd->last_cleared_xstats) = len;
74 
75  }
76 }
77 
78 
79 static inline void
81 {
83  vnet_main_t *vnm = vnet_get_main ();
84  u32 my_cpu = os_get_cpu_number ();
85  u64 rxerrors, last_rxerrors;
86 
87  /* only update counters for PMD interfaces */
88  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
89  return;
90 
91  xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
92  clib_memcpy (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
93  rte_eth_stats_get (xd->device_index, &xd->stats);
94 
95  /* maybe bump interface rx no buffer counter */
96  if (PREDICT_FALSE (xd->stats.rx_nombuf != xd->last_stats.rx_nombuf))
97  {
100 
102  xd->stats.rx_nombuf -
103  xd->last_stats.rx_nombuf);
104  }
105 
106  /* missed pkt counter */
107  if (PREDICT_FALSE (xd->stats.imissed != xd->last_stats.imissed))
108  {
111 
113  xd->stats.imissed -
114  xd->last_stats.imissed);
115  }
116  rxerrors = xd->stats.ierrors;
117  last_rxerrors = xd->last_stats.ierrors;
118 
119  if (PREDICT_FALSE (rxerrors != last_rxerrors))
120  {
123 
125  rxerrors - last_rxerrors);
126  }
127 
128  dpdk_get_xstats (xd);
129 }
130 
131 /*
132  * fd.io coding-style-patch-verification: ON
133  *
134  * Local Variables:
135  * eval: (c-set-style "gnu")
136  * End:
137  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:396
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 cpu_index, u32 index, u32 increment)
Increment a simple counter.
Definition: counter.h:78
struct rte_eth_stats last_stats
Definition: dpdk.h:227
vnet_interface_main_t interface_main
Definition: vnet.h:57
#define NULL
Definition: clib.h:55
u16 flags
Definition: dpdk.h:191
struct rte_eth_xstat * last_cleared_xstats
Definition: dpdk.h:230
#define DPDK_DEVICE_FLAG_PMD
Definition: dpdk.h:194
struct rte_eth_stats stats
Definition: dpdk.h:226
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
unsigned long u64
Definition: types.h:89
A collection of simple counters.
Definition: counter.h:59
static void dpdk_get_xstats(dpdk_device_t *xd)
Definition: dpdk_priv.h:57
u32 device_index
Definition: dpdk.h:173
f64 time_last_stats_update
Definition: dpdk.h:231
u32 vlib_sw_if_index
Definition: dpdk.h:176
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
#define PREDICT_FALSE(x)
Definition: clib.h:97
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:614
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:80
#define clib_memcpy(a, b, c)
Definition: string.h:69
struct rte_eth_xstat * xstats
Definition: dpdk.h:229
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
double f64
Definition: types.h:142