FD.io VPP  v20.05-21-gb1500e9ff
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 1024
17 #define DPDK_NB_TX_DESC_DEFAULT 1024
18 #define DPDK_NB_RX_DESC_VIRTIO 256
19 #define DPDK_NB_TX_DESC_VIRTIO 256
20 
21 #define I40E_DEV_ID_SFP_XL710 0x1572
22 #define I40E_DEV_ID_QSFP_A 0x1583
23 #define I40E_DEV_ID_QSFP_B 0x1584
24 #define I40E_DEV_ID_QSFP_C 0x1585
25 #define I40E_DEV_ID_10G_BASE_T 0x1586
26 #define I40E_DEV_ID_VF 0x154C
27 
28 /* These args appear by themselves */
29 #define foreach_eal_double_hyphen_predicate_arg \
30 _(no-shconf) \
31 _(no-hpet) \
32 _(no-huge) \
33 _(vmware-tsc-map)
34 
35 #define foreach_eal_single_hyphen_mandatory_arg \
36 _(coremask, c) \
37 _(nchannels, n) \
38 
39 #define foreach_eal_single_hyphen_arg \
40 _(blacklist, b) \
41 _(mem-alloc-request, m) \
42 _(force-ranks, r)
43 
44 /* These args are preceded by "--" and followed by a single string */
45 #define foreach_eal_double_hyphen_arg \
46 _(huge-dir) \
47 _(proc-type) \
48 _(file-prefix) \
49 _(vdev) \
50 _(log-level) \
51 _(iova-mode)
52 
53 static inline void
55 {
56  int len, ret;
57 
58  if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
59  return;
60 
61  len = rte_eth_xstats_get (xd->port_id, NULL, 0);
62  if (len < 0)
63  return;
64 
65  vec_validate (xd->xstats, len - 1);
66 
67  ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
68  if (ret < 0 || ret > len)
69  {
70  _vec_len (xd->xstats) = 0;
71  return;
72  }
73 
74  _vec_len (xd->xstats) = len;
75 }
76 
77 static inline void
79 {
81  vnet_main_t *vnm = vnet_get_main ();
82  u32 thread_index = vlib_get_thread_index ();
83  u64 rxerrors, last_rxerrors;
84 
85  /* only update counters for PMD interfaces */
86  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
87  return;
88 
89  xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
90  clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
91  rte_eth_stats_get (xd->port_id, &xd->stats);
92 
93  /* maybe bump interface rx no buffer counter */
94  if (PREDICT_FALSE (xd->stats.rx_nombuf != xd->last_stats.rx_nombuf))
95  {
98 
99  vlib_increment_simple_counter (cm, thread_index, xd->sw_if_index,
100  xd->stats.rx_nombuf -
101  xd->last_stats.rx_nombuf);
102  }
103 
104  /* missed pkt counter */
105  if (PREDICT_FALSE (xd->stats.imissed != xd->last_stats.imissed))
106  {
109 
110  vlib_increment_simple_counter (cm, thread_index, xd->sw_if_index,
111  xd->stats.imissed -
112  xd->last_stats.imissed);
113  }
114  rxerrors = xd->stats.ierrors;
115  last_rxerrors = xd->last_stats.ierrors;
116 
117  if (PREDICT_FALSE (rxerrors != last_rxerrors))
118  {
121 
122  vlib_increment_simple_counter (cm, thread_index, xd->sw_if_index,
123  rxerrors - last_rxerrors);
124  }
125 
126  dpdk_get_xstats (xd);
127 }
128 
129 /*
130  * fd.io coding-style-patch-verification: ON
131  *
132  * Local Variables:
133  * eval: (c-set-style "gnu")
134  * End:
135  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:507
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
struct rte_eth_stats last_stats
Definition: dpdk.h:211
vnet_interface_main_t interface_main
Definition: vnet.h:56
unsigned long u64
Definition: types.h:89
u32 sw_if_index
Definition: dpdk.h:168
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
u16 flags
Definition: dpdk.h:176
static void vlib_increment_simple_counter(vlib_simple_counter_main_t *cm, u32 thread_index, u32 index, u64 increment)
Increment a simple counter.
Definition: counter.h:78
double f64
Definition: types.h:142
struct rte_eth_stats stats
Definition: dpdk.h:210
dpdk_portid_t port_id
Definition: dpdk.h:165
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
unsigned int u32
Definition: types.h:88
A collection of simple counters.
Definition: counter.h:57
static void dpdk_get_xstats(dpdk_device_t *xd)
Definition: dpdk_priv.h:54
f64 time_last_stats_update
Definition: dpdk.h:213
vnet_crypto_main_t * cm
Definition: quic_crypto.c:53
#define PREDICT_FALSE(x)
Definition: clib.h:118
vlib_simple_counter_main_t * sw_if_counters
Definition: interface.h:866
u8 len
Definition: ip_types.api:92
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:218
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:78
struct rte_eth_xstat * xstats
Definition: dpdk.h:212