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 #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
29 /* These args appear by themselves */
30 #define foreach_eal_double_hyphen_predicate_arg \
36 #define foreach_eal_single_hyphen_arg \
37 _(mem-alloc-request, m) \
40 /* clang-format off */
41 /* These args are preceded by "--" and followed by a single string */
42 #define foreach_eal_double_hyphen_arg \
53 dpdk_get_xstats (dpdk_device_t * xd)
57 if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
60 len = rte_eth_xstats_get (xd->port_id, NULL, 0);
64 vec_validate (xd->xstats, len - 1);
66 ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
67 if (ret < 0 || ret > len)
69 _vec_len (xd->xstats) = 0;
73 _vec_len (xd->xstats) = len;
76 #define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
79 u64 _v = (xd)->stats.stat; \
80 u64 _lv = (xd)->last_stats.stat; \
81 if (PREDICT_FALSE (_v != _lv)) \
83 if (PREDICT_FALSE (_v < _lv)) \
84 dpdk_log_warn ("%v: %s counter decreased (before %lu after %lu)", \
85 xd->name, #stat, _lv, _v); \
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); \
95 dpdk_update_counters (dpdk_device_t * xd, f64 now)
97 vnet_main_t *vnm = vnet_get_main ();
98 u32 thread_index = vlib_get_thread_index ();
100 xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
101 clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
102 rte_eth_stats_get (xd->port_id, &xd->stats);
104 /* maybe bump interface rx no buffer counter */
105 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, rx_nombuf,
106 VNET_INTERFACE_COUNTER_RX_NO_BUF);
107 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, imissed,
108 VNET_INTERFACE_COUNTER_RX_MISS);
109 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, ierrors,
110 VNET_INTERFACE_COUNTER_RX_ERROR);
112 dpdk_get_xstats (xd);
116 * fd.io coding-style-patch-verification: ON
119 * eval: (c-set-style "gnu")