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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
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
22 /* These args appear by themselves */
23 #define foreach_eal_double_hyphen_predicate_arg \
29 #define foreach_eal_single_hyphen_arg \
30 _(mem-alloc-request, m) \
33 /* clang-format off */
34 /* These args are preceded by "--" and followed by a single string */
35 #define foreach_eal_double_hyphen_arg \
46 dpdk_get_xstats (dpdk_device_t * xd)
50 if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
53 len = rte_eth_xstats_get (xd->port_id, NULL, 0);
57 vec_validate (xd->xstats, len - 1);
59 ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
60 if (ret < 0 || ret > len)
62 _vec_len (xd->xstats) = 0;
66 _vec_len (xd->xstats) = len;
69 #define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
72 u64 _v = (xd)->stats.stat; \
73 u64 _lv = (xd)->last_stats.stat; \
74 if (PREDICT_FALSE (_v != _lv)) \
76 if (PREDICT_FALSE (_v < _lv)) \
77 dpdk_log_warn ("%v: %s counter decreased (before %lu after %lu)", \
78 xd->name, #stat, _lv, _v); \
80 vlib_increment_simple_counter ( \
81 vec_elt_at_index ((vnm)->interface_main.sw_if_counters, cnt), \
82 (tidx), (xd)->sw_if_index, _v - _lv); \
88 dpdk_update_counters (dpdk_device_t * xd, f64 now)
90 vnet_main_t *vnm = vnet_get_main ();
91 u32 thread_index = vlib_get_thread_index ();
93 xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
94 clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
95 rte_eth_stats_get (xd->port_id, &xd->stats);
97 /* maybe bump interface rx no buffer counter */
98 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, rx_nombuf,
99 VNET_INTERFACE_COUNTER_RX_NO_BUF);
100 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, imissed,
101 VNET_INTERFACE_COUNTER_RX_MISS);
102 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, ierrors,
103 VNET_INTERFACE_COUNTER_RX_ERROR);
105 dpdk_get_xstats (xd);
109 * fd.io coding-style-patch-verification: ON
112 * eval: (c-set-style "gnu")