FD.io VPP  v20.09-64-g4f7b92f0a
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 _(mem-alloc-request, m) \
41 _(force-ranks, r)
42 
43 /* These args are preceded by "--" and followed by a single string */
44 #define foreach_eal_double_hyphen_arg \
45 _(huge-dir) \
46 _(proc-type) \
47 _(file-prefix) \
48 _(vdev) \
49 _(log-level) \
50 _(iova-mode)
51 
52 static inline void
54 {
55  int len, ret;
56 
57  if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
58  return;
59 
60  len = rte_eth_xstats_get (xd->port_id, NULL, 0);
61  if (len < 0)
62  return;
63 
64  vec_validate (xd->xstats, len - 1);
65 
66  ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
67  if (ret < 0 || ret > len)
68  {
69  _vec_len (xd->xstats) = 0;
70  return;
71  }
72 
73  _vec_len (xd->xstats) = len;
74 }
75 
76 #define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
77  do \
78  { \
79  u64 _v = (xd)->stats.stat; \
80  u64 _lv = (xd)->last_stats.stat; \
81  if (PREDICT_FALSE (_v != _lv)) \
82  { \
83  if (PREDICT_FALSE (_v < _lv)) \
84  dpdk_log_warn ("%v: %s counter decreased (before %lu after %lu)", \
85  xd->name, #stat, _lv, _v); \
86  else \
87  vlib_increment_simple_counter ( \
88  vec_elt_at_index ((vnm)->interface_main.sw_if_counters, cnt), \
89  (tidx), (xd)->sw_if_index, _v - _lv); \
90  } \
91  } \
92  while (0)
93 
94 static inline void
96 {
97  vnet_main_t *vnm = vnet_get_main ();
98  u32 thread_index = vlib_get_thread_index ();
99 
100  /* only update counters for PMD interfaces */
101  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
102  return;
103 
104  xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
105  clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
106  rte_eth_stats_get (xd->port_id, &xd->stats);
107 
108  /* maybe bump interface rx no buffer counter */
109  DPDK_UPDATE_COUNTER (vnm, thread_index, xd, rx_nombuf,
111  DPDK_UPDATE_COUNTER (vnm, thread_index, xd, imissed,
113  DPDK_UPDATE_COUNTER (vnm, thread_index, xd, ierrors,
115 
116  dpdk_get_xstats (xd);
117 }
118 
119 /*
120  * fd.io coding-style-patch-verification: ON
121  *
122  * Local Variables:
123  * eval: (c-set-style "gnu")
124  * End:
125  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
struct rte_eth_stats last_stats
Definition: dpdk.h:222
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
u16 flags
Definition: dpdk.h:186
double f64
Definition: types.h:142
struct rte_eth_stats stats
Definition: dpdk.h:221
dpdk_portid_t port_id
Definition: dpdk.h:189
unsigned int u32
Definition: types.h:88
static void dpdk_get_xstats(dpdk_device_t *xd)
Definition: dpdk_priv.h:53
f64 time_last_stats_update
Definition: dpdk.h:224
u8 len
Definition: ip_types.api:92
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:219
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:95
struct rte_eth_xstat * xstats
Definition: dpdk.h:223
#define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt)
Definition: dpdk_priv.h:76