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);
108 #if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0)
109 #define RTE_MBUF_F_RX_VLAN PKT_RX_VLAN
110 #define RTE_MBUF_F_RX_RSS_HASH PKT_RX_RSS_HASH
111 #define RTE_MBUF_F_RX_FDIR PKT_RX_FDIR
112 #define RTE_MBUF_F_RX_L4_CKSUM_BAD PKT_RX_L4_CKSUM_BAD
113 #define RTE_MBUF_F_RX_IP_CKSUM_BAD PKT_RX_IP_CKSUM_BAD
114 #define RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD PKT_RX_OUTER_IP_CKSUM_BAD
115 #define RTE_MBUF_F_RX_VLAN_STRIPPED PKT_RX_VLAN_STRIPPED
116 #define RTE_MBUF_F_RX_IP_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD
117 #define RTE_MBUF_F_RX_L4_CKSUM_GOOD PKT_RX_L4_CKSUM_GOOD
118 #define RTE_MBUF_F_RX_IEEE1588_PTP PKT_RX_IEEE1588_PTP
119 #define RTE_MBUF_F_RX_IEEE1588_TMST PKT_RX_IEEE1588_TMST
120 #define RTE_MBUF_F_RX_LRO PKT_RX_LRO
121 #define RTE_MBUF_F_RX_QINQ_STRIPPED PKT_RX_QINQ_STRIPPED
122 #define RTE_MBUF_F_RX_FDIR_ID PKT_RX_FDIR_ID
123 #define RTE_MBUF_F_TX_VLAN_PKT PKT_TX_VLAN_PKT
124 #define RTE_MBUF_F_TX_TUNNEL_VXLAN PKT_TX_TUNNEL_VXLAN
125 #define RTE_MBUF_F_TX_IP_CKSUM PKT_TX_IP_CKSUM
126 #define RTE_MBUF_F_TX_TCP_CKSUM PKT_TX_TCP_CKSUM
127 #define RTE_MBUF_F_TX_UDP_CKSUM PKT_TX_UDP_CKSUM
128 #define RTE_MBUF_F_TX_SCTP_CKSUM PKT_TX_SCTP_CKSUM
129 #define RTE_MBUF_F_TX_OUTER_IP_CKSUM PKT_TX_OUTER_IP_CKSUM
130 #define RTE_MBUF_F_TX_TCP_SEG PKT_TX_TCP_SEG
131 #define RTE_MBUF_F_TX_IEEE1588_TMST PKT_TX_IEEE1588_TMST
132 #define RTE_MBUF_F_TX_IPV4 PKT_TX_IPV4
133 #define RTE_MBUF_F_TX_IPV6 PKT_TX_IPV6
134 #define RTE_MBUF_F_TX_OUTER_IPV4 PKT_TX_OUTER_IPV4
135 #define RTE_MBUF_F_TX_OUTER_IPV6 PKT_TX_OUTER_IPV6
136 #define RTE_MBUF_F_TX_UDP_SEG PKT_TX_UDP_SEG
140 * fd.io coding-style-patch-verification: ON
143 * eval: (c-set-style "gnu")