FD.io VPP  v21.10.1-2-g0a485f517
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_MAX_LRO_SIZE_DEFAULT 65536
19 #define DPDK_NB_RX_DESC_VIRTIO 256
20 #define DPDK_NB_TX_DESC_VIRTIO 256
21 
22 #define I40E_DEV_ID_SFP_XL710 0x1572
23 #define I40E_DEV_ID_QSFP_A 0x1583
24 #define I40E_DEV_ID_QSFP_B 0x1584
25 #define I40E_DEV_ID_QSFP_C 0x1585
26 #define I40E_DEV_ID_10G_BASE_T 0x1586
27 #define I40E_DEV_ID_VF 0x154C
28 
29 /* These args appear by themselves */
30 #define foreach_eal_double_hyphen_predicate_arg \
31 _(no-shconf) \
32 _(no-hpet) \
33 _(no-huge) \
34 _(vmware-tsc-map)
35 
36 #define foreach_eal_single_hyphen_mandatory_arg \
37 _(coremask, c) \
38 _(nchannels, n) \
39 
40 #define foreach_eal_single_hyphen_arg \
41 _(mem-alloc-request, m) \
42 _(force-ranks, r)
43 
44 /* clang-format off */
45 /* These args are preceded by "--" and followed by a single string */
46 #define foreach_eal_double_hyphen_arg \
47 _(huge-dir) \
48 _(proc-type) \
49 _(file-prefix) \
50 _(vdev) \
51 _(log-level) \
52 _(iova-mode) \
53 _(base-virtaddr)
54 /* clang-format on */
55 
56 static inline void
58 {
59  int len, ret;
60 
61  if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
62  return;
63 
64  len = rte_eth_xstats_get (xd->port_id, NULL, 0);
65  if (len < 0)
66  return;
67 
68  vec_validate (xd->xstats, len - 1);
69 
70  ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
71  if (ret < 0 || ret > len)
72  {
73  _vec_len (xd->xstats) = 0;
74  return;
75  }
76 
77  _vec_len (xd->xstats) = len;
78 }
79 
80 #define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
81  do \
82  { \
83  u64 _v = (xd)->stats.stat; \
84  u64 _lv = (xd)->last_stats.stat; \
85  if (PREDICT_FALSE (_v != _lv)) \
86  { \
87  if (PREDICT_FALSE (_v < _lv)) \
88  dpdk_log_warn ("%v: %s counter decreased (before %lu after %lu)", \
89  xd->name, #stat, _lv, _v); \
90  else \
91  vlib_increment_simple_counter ( \
92  vec_elt_at_index ((vnm)->interface_main.sw_if_counters, cnt), \
93  (tidx), (xd)->sw_if_index, _v - _lv); \
94  } \
95  } \
96  while (0)
97 
98 static inline void
100 {
101  vnet_main_t *vnm = vnet_get_main ();
103 
104  /* only update counters for PMD interfaces */
105  if ((xd->flags & DPDK_DEVICE_FLAG_PMD) == 0)
106  return;
107 
109  clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
110  rte_eth_stats_get (xd->port_id, &xd->stats);
111 
112  /* maybe bump interface rx no buffer counter */
113  DPDK_UPDATE_COUNTER (vnm, thread_index, xd, rx_nombuf,
115  DPDK_UPDATE_COUNTER (vnm, thread_index, xd, imissed,
117  DPDK_UPDATE_COUNTER (vnm, thread_index, xd, ierrors,
119 
120  dpdk_get_xstats (xd);
121 }
122 
123 /*
124  * fd.io coding-style-patch-verification: ON
125  *
126  * Local Variables:
127  * eval: (c-set-style "gnu")
128  * End:
129  */
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
dpdk_device_t::flags
u16 flags
Definition: dpdk.h:200
dpdk_device_t::stats
struct rte_eth_stats stats
Definition: dpdk.h:235
dpdk_device_t::time_last_stats_update
f64 time_last_stats_update
Definition: dpdk.h:238
dpdk_device_t::port_id
dpdk_portid_t port_id
Definition: dpdk.h:203
dpdk_device_t::last_stats
struct rte_eth_stats last_stats
Definition: dpdk.h:236
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
VNET_INTERFACE_COUNTER_RX_MISS
@ VNET_INTERFACE_COUNTER_RX_MISS
Definition: interface.h:909
len
u8 len
Definition: ip_types.api:103
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:187
DPDK_UPDATE_COUNTER
#define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt)
Definition: dpdk_priv.h:80
dpdk_get_xstats
static void dpdk_get_xstats(dpdk_device_t *xd)
Definition: dpdk_priv.h:57
f64
double f64
Definition: types.h:142
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
vnet_main_t
Definition: vnet.h:76
VNET_INTERFACE_COUNTER_RX_NO_BUF
@ VNET_INTERFACE_COUNTER_RX_NO_BUF
Definition: interface.h:908
u32
unsigned int u32
Definition: types.h:88
dpdk_device_t::xstats
struct rte_eth_xstat * xstats
Definition: dpdk.h:237
VNET_INTERFACE_COUNTER_RX_ERROR
@ VNET_INTERFACE_COUNTER_RX_ERROR
Definition: interface.h:910
now
f64 now
Definition: nat44_ei_out2in.c:710
dpdk_update_counters
static void dpdk_update_counters(dpdk_device_t *xd, f64 now)
Definition: dpdk_priv.h:99
dpdk_device_t
Definition: dpdk.h:182