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
20 /* These args appear by themselves */
21 #define foreach_eal_double_hyphen_predicate_arg \
27 #define foreach_eal_single_hyphen_arg \
28 _(mem-alloc-request, m) \
31 /* clang-format off */
32 /* These args are preceded by "--" and followed by a single string */
33 #define foreach_eal_double_hyphen_arg \
43 static_always_inline void
44 dpdk_device_flag_set (dpdk_device_t *xd, __typeof__ (xd->flags) flag, int val)
46 xd->flags = val ? xd->flags | flag : xd->flags & ~flag;
50 dpdk_get_xstats (dpdk_device_t * xd)
54 if (!(xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP))
57 len = rte_eth_xstats_get (xd->port_id, NULL, 0);
61 vec_validate (xd->xstats, len - 1);
63 ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
64 if (ret < 0 || ret > len)
66 _vec_len (xd->xstats) = 0;
70 _vec_len (xd->xstats) = len;
73 #define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
76 u64 _v = (xd)->stats.stat; \
77 u64 _lv = (xd)->last_stats.stat; \
78 if (PREDICT_FALSE (_v != _lv)) \
80 if (PREDICT_FALSE (_v < _lv)) \
81 dpdk_log_warn ("%v: %s counter decreased (before %lu after %lu)", \
82 xd->name, #stat, _lv, _v); \
84 vlib_increment_simple_counter ( \
85 vec_elt_at_index ((vnm)->interface_main.sw_if_counters, cnt), \
86 (tidx), (xd)->sw_if_index, _v - _lv); \
92 dpdk_update_counters (dpdk_device_t * xd, f64 now)
94 vnet_main_t *vnm = vnet_get_main ();
95 u32 thread_index = vlib_get_thread_index ();
97 xd->time_last_stats_update = now ? now : xd->time_last_stats_update;
98 clib_memcpy_fast (&xd->last_stats, &xd->stats, sizeof (xd->last_stats));
99 rte_eth_stats_get (xd->port_id, &xd->stats);
101 /* maybe bump interface rx no buffer counter */
102 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, rx_nombuf,
103 VNET_INTERFACE_COUNTER_RX_NO_BUF);
104 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, imissed,
105 VNET_INTERFACE_COUNTER_RX_MISS);
106 DPDK_UPDATE_COUNTER (vnm, thread_index, xd, ierrors,
107 VNET_INTERFACE_COUNTER_RX_ERROR);
109 dpdk_get_xstats (xd);
112 #if RTE_VERSION < RTE_VERSION_NUM(21, 11, 0, 0)
113 #define RTE_MBUF_F_RX_FDIR PKT_RX_FDIR
114 #define RTE_MBUF_F_RX_FDIR_FLX PKT_RX_FDIR_FLX
115 #define RTE_MBUF_F_RX_FDIR_ID PKT_RX_FDIR_ID
116 #define RTE_MBUF_F_RX_IEEE1588_PTP PKT_RX_IEEE1588_PTP
117 #define RTE_MBUF_F_RX_IEEE1588_TMST PKT_RX_IEEE1588_TMST
118 #define RTE_MBUF_F_RX_IP_CKSUM_BAD PKT_RX_IP_CKSUM_BAD
119 #define RTE_MBUF_F_RX_IP_CKSUM_GOOD PKT_RX_IP_CKSUM_GOOD
120 #define RTE_MBUF_F_RX_IP_CKSUM_NONE PKT_RX_IP_CKSUM_GOOD
121 #define RTE_MBUF_F_RX_L4_CKSUM_BAD PKT_RX_L4_CKSUM_BAD
122 #define RTE_MBUF_F_RX_L4_CKSUM_GOOD PKT_RX_L4_CKSUM_GOOD
123 #define RTE_MBUF_F_RX_L4_CKSUM_NONE PKT_RX_L4_CKSUM_GOOD
124 #define RTE_MBUF_F_RX_LRO PKT_RX_LRO
125 #define RTE_MBUF_F_RX_OUTER_IP_CKSUM_BAD PKT_RX_OUTER_IP_CKSUM_BAD
126 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_BAD PKT_RX_OUTER_L4_CKSUM_GOOD
127 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_GOOD PKT_RX_OUTER_L4_CKSUM_GOOD
128 #define RTE_MBUF_F_RX_OUTER_L4_CKSUM_NONE PKT_RX_OUTER_L4_CKSUM_GOOD
129 #define RTE_MBUF_F_RX_QINQ PKT_RX_QINQ
130 #define RTE_MBUF_F_RX_QINQ_STRIPPED PKT_RX_QINQ_STRIPPED
131 #define RTE_MBUF_F_RX_RSS_HASH PKT_RX_RSS_HASH
132 #define RTE_MBUF_F_RX_SEC_OFFLOAD PKT_RX_SEC_OFFLOAD
133 #define RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED PKT_RX_SEC_OFFLOAD_FAILED
134 #define RTE_MBUF_F_RX_VLAN PKT_RX_VLAN
135 #define RTE_MBUF_F_RX_VLAN_STRIPPED PKT_RX_VLAN_STRIPPED
136 #define RTE_MBUF_F_TX_IEEE1588_TMST PKT_TX_IEEE1588_TMST
137 #define RTE_MBUF_F_TX_IPV4 PKT_TX_IPV4
138 #define RTE_MBUF_F_TX_IPV6 PKT_TX_IPV6
139 #define RTE_MBUF_F_TX_IP_CKSUM PKT_TX_IP_CKSUM
140 #define RTE_MBUF_F_TX_MACSEC PKT_TX_MACSEC
141 #define RTE_MBUF_F_TX_OUTER_IPV4 PKT_TX_OUTER_IPV4
142 #define RTE_MBUF_F_TX_OUTER_IPV6 PKT_TX_OUTER_IPV6
143 #define RTE_MBUF_F_TX_OUTER_IP_CKSUM PKT_TX_OUTER_IP_CKSUM
144 #define RTE_MBUF_F_TX_OUTER_UDP_CKSUM PKT_TX_OUTER_UDP_CKSUM
145 #define RTE_MBUF_F_TX_QINQ PKT_TX_QINQ
146 #define RTE_MBUF_F_TX_SCTP_CKSUM PKT_TX_SCTP_CKSUM
147 #define RTE_MBUF_F_TX_SEC_OFFLOAD PKT_TX_SEC_OFFLOAD
148 #define RTE_MBUF_F_TX_TCP_CKSUM PKT_TX_TCP_CKSUM
149 #define RTE_MBUF_F_TX_TCP_SEG PKT_TX_TCP_SEG
150 #define RTE_MBUF_F_TX_TUNNEL_GENEVE PKT_TX_TUNNEL_GENEVE
151 #define RTE_MBUF_F_TX_TUNNEL_GRE PKT_TX_TUNNEL_GRE
152 #define RTE_MBUF_F_TX_TUNNEL_GTP PKT_TX_TUNNEL_GTP
153 #define RTE_MBUF_F_TX_TUNNEL_IP PKT_TX_TUNNEL_IP
154 #define RTE_MBUF_F_TX_TUNNEL_IPIP PKT_TX_TUNNEL_IPIP
155 #define RTE_MBUF_F_TX_TUNNEL_MPLSINUDP PKT_TX_TUNNEL_MPLSINUDP
156 #define RTE_MBUF_F_TX_TUNNEL_UDP PKT_TX_TUNNEL_UDP
157 #define RTE_MBUF_F_TX_TUNNEL_VXLAN PKT_TX_TUNNEL_VXLAN
158 #define RTE_MBUF_F_TX_TUNNEL_VXLAN_GPE PKT_TX_TUNNEL_VXLAN_GPE
159 #define RTE_MBUF_F_TX_UDP_CKSUM PKT_TX_UDP_CKSUM
160 #define RTE_MBUF_F_TX_UDP_SEG PKT_TX_UDP_SEG
161 #define RTE_MBUF_F_TX_VLAN PKT_TX_VLAN
165 * fd.io coding-style-patch-verification: ON
168 * eval: (c-set-style "gnu")