Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2017 Intel Corporation
3 : : */
4 : :
5 : : #include <sys/queue.h>
6 : : #include <stdio.h>
7 : : #include <errno.h>
8 : : #include <stdint.h>
9 : : #include <string.h>
10 : : #include <unistd.h>
11 : : #include <stdarg.h>
12 : : #include <inttypes.h>
13 : : #include <rte_string_fns.h>
14 : : #include <rte_byteorder.h>
15 : : #include <rte_common.h>
16 : : #include <rte_cycles.h>
17 : :
18 : : #include <rte_interrupts.h>
19 : : #include <rte_log.h>
20 : : #include <rte_debug.h>
21 : : #include <rte_pci.h>
22 : : #include <bus_pci_driver.h>
23 : : #include <rte_branch_prediction.h>
24 : : #include <rte_memory.h>
25 : : #include <rte_kvargs.h>
26 : : #include <rte_eal.h>
27 : : #include <rte_alarm.h>
28 : : #include <rte_ether.h>
29 : : #include <ethdev_driver.h>
30 : : #include <ethdev_pci.h>
31 : : #include <rte_malloc.h>
32 : : #include <rte_random.h>
33 : : #include <dev_driver.h>
34 : : #include <rte_hash_crc.h>
35 : : #ifdef RTE_LIB_SECURITY
36 : : #include <rte_security_driver.h>
37 : : #endif
38 : :
39 : : #include "ixgbe_logs.h"
40 : : #include "base/ixgbe_api.h"
41 : : #include "base/ixgbe_vf.h"
42 : : #include "base/ixgbe_common.h"
43 : : #include "ixgbe_ethdev.h"
44 : : #include "ixgbe_bypass.h"
45 : : #include "ixgbe_rxtx.h"
46 : : #include "base/ixgbe_type.h"
47 : : #include "base/ixgbe_phy.h"
48 : : #include "base/ixgbe_osdep.h"
49 : : #include "ixgbe_regs.h"
50 : :
51 : : /*
52 : : * High threshold controlling when to start sending XOFF frames. Must be at
53 : : * least 8 bytes less than receive packet buffer size. This value is in units
54 : : * of 1024 bytes.
55 : : */
56 : : #define IXGBE_FC_HI 0x80
57 : :
58 : : /*
59 : : * Low threshold controlling when to start sending XON frames. This value is
60 : : * in units of 1024 bytes.
61 : : */
62 : : #define IXGBE_FC_LO 0x40
63 : :
64 : : /* Timer value included in XOFF frames. */
65 : : #define IXGBE_FC_PAUSE 0x680
66 : :
67 : : /*Default value of Max Rx Queue*/
68 : : #define IXGBE_MAX_RX_QUEUE_NUM 128
69 : :
70 : : #define IXGBE_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
71 : : #define IXGBE_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
72 : : #define IXGBE_VMDQ_NUM_UC_MAC 4096 /* Maximum nb. of UC MAC addr. */
73 : :
74 : : #define IXGBE_MMW_SIZE_DEFAULT 0x4
75 : : #define IXGBE_MMW_SIZE_JUMBO_FRAME 0x14
76 : : #define IXGBE_MAX_RING_DESC 4096 /* replicate define from rxtx */
77 : :
78 : : /*
79 : : * Default values for RX/TX configuration
80 : : */
81 : : #define IXGBE_DEFAULT_RX_FREE_THRESH 32
82 : : #define IXGBE_DEFAULT_RX_PTHRESH 8
83 : : #define IXGBE_DEFAULT_RX_HTHRESH 8
84 : : #define IXGBE_DEFAULT_RX_WTHRESH 0
85 : :
86 : : #define IXGBE_DEFAULT_TX_FREE_THRESH 32
87 : : #define IXGBE_DEFAULT_TX_PTHRESH 32
88 : : #define IXGBE_DEFAULT_TX_HTHRESH 0
89 : : #define IXGBE_DEFAULT_TX_WTHRESH 0
90 : : #define IXGBE_DEFAULT_TX_RSBIT_THRESH 32
91 : :
92 : : /* Bit shift and mask */
93 : : #define IXGBE_4_BIT_WIDTH (CHAR_BIT / 2)
94 : : #define IXGBE_4_BIT_MASK RTE_LEN2MASK(IXGBE_4_BIT_WIDTH, uint8_t)
95 : : #define IXGBE_8_BIT_WIDTH CHAR_BIT
96 : : #define IXGBE_8_BIT_MASK UINT8_MAX
97 : :
98 : : #define IXGBEVF_PMD_NAME "rte_ixgbevf_pmd" /* PMD name */
99 : :
100 : : #define IXGBE_QUEUE_STAT_COUNTERS (sizeof(hw_stats->qprc) / sizeof(hw_stats->qprc[0]))
101 : :
102 : : /* Additional timesync values. */
103 : : #define NSEC_PER_SEC 1000000000L
104 : : #define IXGBE_INCVAL_10GB 0x66666666
105 : : #define IXGBE_INCVAL_1GB 0x40000000
106 : : #define IXGBE_INCVAL_100 0x50000000
107 : : #define IXGBE_INCVAL_SHIFT_10GB 28
108 : : #define IXGBE_INCVAL_SHIFT_1GB 24
109 : : #define IXGBE_INCVAL_SHIFT_100 21
110 : : #define IXGBE_INCVAL_SHIFT_82599 7
111 : : #define IXGBE_INCPER_SHIFT_82599 24
112 : :
113 : : #define IXGBE_CYCLECOUNTER_MASK 0xffffffffffffffffULL
114 : :
115 : : #define IXGBE_VT_CTL_POOLING_MODE_MASK 0x00030000
116 : : #define IXGBE_VT_CTL_POOLING_MODE_ETAG 0x00010000
117 : : #define IXGBE_ETAG_ETYPE 0x00005084
118 : : #define IXGBE_ETAG_ETYPE_MASK 0x0000ffff
119 : : #define IXGBE_ETAG_ETYPE_VALID 0x80000000
120 : : #define IXGBE_RAH_ADTYPE 0x40000000
121 : : #define IXGBE_RAL_ETAG_FILTER_MASK 0x00003fff
122 : : #define IXGBE_VMVIR_TAGA_MASK 0x18000000
123 : : #define IXGBE_VMVIR_TAGA_ETAG_INSERT 0x08000000
124 : : #define IXGBE_VMTIR(_i) (0x00017000 + ((_i) * 4)) /* 64 of these (0-63) */
125 : : #define IXGBE_QDE_STRIP_TAG 0x00000004
126 : : #define IXGBE_VTEICR_MASK 0x07
127 : :
128 : : #define IXGBE_EXVET_VET_EXT_SHIFT 16
129 : : #define IXGBE_DMATXCTL_VT_MASK 0xFFFF0000
130 : :
131 : : #define IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE "fiber_sdp3_no_tx_disable"
132 : :
133 : : static const char * const ixgbe_valid_arguments[] = {
134 : : IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE,
135 : : NULL
136 : : };
137 : :
138 : : #define IXGBEVF_DEVARG_PFLINK_FULLCHK "pflink_fullchk"
139 : :
140 : : static const char * const ixgbevf_valid_arguments[] = {
141 : : IXGBEVF_DEVARG_PFLINK_FULLCHK,
142 : : NULL
143 : : };
144 : :
145 : : static int eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params);
146 : : static int eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev);
147 : : static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev);
148 : : static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev);
149 : : static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev);
150 : : static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev);
151 : : static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev);
152 : : static int ixgbe_dev_configure(struct rte_eth_dev *dev);
153 : : static int ixgbe_dev_start(struct rte_eth_dev *dev);
154 : : static int ixgbe_dev_stop(struct rte_eth_dev *dev);
155 : : static int ixgbe_dev_set_link_up(struct rte_eth_dev *dev);
156 : : static int ixgbe_dev_set_link_down(struct rte_eth_dev *dev);
157 : : static int ixgbe_dev_close(struct rte_eth_dev *dev);
158 : : static int ixgbe_dev_reset(struct rte_eth_dev *dev);
159 : : static int ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev);
160 : : static int ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev);
161 : : static int ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev);
162 : : static int ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev);
163 : : static int ixgbe_dev_link_update(struct rte_eth_dev *dev,
164 : : int wait_to_complete);
165 : : static int ixgbe_dev_stats_get(struct rte_eth_dev *dev,
166 : : struct rte_eth_stats *stats);
167 : : static int ixgbe_dev_xstats_get(struct rte_eth_dev *dev,
168 : : struct rte_eth_xstat *xstats, unsigned n);
169 : : static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
170 : : struct rte_eth_xstat *xstats, unsigned n);
171 : : static int
172 : : ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
173 : : uint64_t *values, unsigned int n);
174 : : static int ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
175 : : static int ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
176 : : static int ixgbe_dev_xstats_get_names(struct rte_eth_dev *dev,
177 : : struct rte_eth_xstat_name *xstats_names,
178 : : unsigned int size);
179 : : static int ixgbevf_dev_xstats_get_names(struct rte_eth_dev *dev,
180 : : struct rte_eth_xstat_name *xstats_names, unsigned limit);
181 : : static int ixgbe_dev_xstats_get_names_by_id(
182 : : struct rte_eth_dev *dev,
183 : : const uint64_t *ids,
184 : : struct rte_eth_xstat_name *xstats_names,
185 : : unsigned int limit);
186 : : static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
187 : : uint16_t queue_id,
188 : : uint8_t stat_idx,
189 : : uint8_t is_rx);
190 : : static int ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version,
191 : : size_t fw_size);
192 : : static int ixgbe_dev_info_get(struct rte_eth_dev *dev,
193 : : struct rte_eth_dev_info *dev_info);
194 : : static const uint32_t *ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev,
195 : : size_t *no_of_elements);
196 : : static int ixgbevf_dev_info_get(struct rte_eth_dev *dev,
197 : : struct rte_eth_dev_info *dev_info);
198 : : static int ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
199 : :
200 : : static int ixgbe_vlan_filter_set(struct rte_eth_dev *dev,
201 : : uint16_t vlan_id, int on);
202 : : static int ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
203 : : enum rte_vlan_type vlan_type,
204 : : uint16_t tpid_id);
205 : : static void ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev,
206 : : uint16_t queue, bool on);
207 : : static void ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue,
208 : : int on);
209 : : static void ixgbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev,
210 : : int mask);
211 : : static int ixgbe_vlan_offload_config(struct rte_eth_dev *dev, int mask);
212 : : static int ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask);
213 : : static void ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue);
214 : : static void ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue);
215 : : static void ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev);
216 : : static void ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev);
217 : :
218 : : static int ixgbe_dev_led_on(struct rte_eth_dev *dev);
219 : : static int ixgbe_dev_led_off(struct rte_eth_dev *dev);
220 : : static int ixgbe_flow_ctrl_get(struct rte_eth_dev *dev,
221 : : struct rte_eth_fc_conf *fc_conf);
222 : : static int ixgbe_flow_ctrl_set(struct rte_eth_dev *dev,
223 : : struct rte_eth_fc_conf *fc_conf);
224 : : static int ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev,
225 : : struct rte_eth_pfc_conf *pfc_conf);
226 : : static int ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
227 : : struct rte_eth_rss_reta_entry64 *reta_conf,
228 : : uint16_t reta_size);
229 : : static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
230 : : struct rte_eth_rss_reta_entry64 *reta_conf,
231 : : uint16_t reta_size);
232 : : static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
233 : : static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on);
234 : : static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
235 : : static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
236 : : static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
237 : : static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
238 : : static void ixgbe_dev_interrupt_handler(void *param);
239 : : static void ixgbe_dev_interrupt_delayed_handler(void *param);
240 : : static uint32_t ixgbe_dev_setup_link_thread_handler(void *param);
241 : : static int ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev,
242 : : uint32_t timeout_ms);
243 : :
244 : : static int ixgbe_add_rar(struct rte_eth_dev *dev,
245 : : struct rte_ether_addr *mac_addr,
246 : : uint32_t index, uint32_t pool);
247 : : static void ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index);
248 : : static int ixgbe_set_default_mac_addr(struct rte_eth_dev *dev,
249 : : struct rte_ether_addr *mac_addr);
250 : : static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config);
251 : : static bool is_device_supported(struct rte_eth_dev *dev,
252 : : struct rte_pci_driver *drv);
253 : :
254 : : /* For Virtual Function support */
255 : : static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
256 : : static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev);
257 : : static int ixgbevf_dev_configure(struct rte_eth_dev *dev);
258 : : static int ixgbevf_dev_start(struct rte_eth_dev *dev);
259 : : static int ixgbevf_dev_link_update(struct rte_eth_dev *dev,
260 : : int wait_to_complete);
261 : : static int ixgbevf_dev_stop(struct rte_eth_dev *dev);
262 : : static int ixgbevf_dev_close(struct rte_eth_dev *dev);
263 : : static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
264 : : static void ixgbevf_intr_disable(struct rte_eth_dev *dev);
265 : : static void ixgbevf_intr_enable(struct rte_eth_dev *dev);
266 : : static int ixgbevf_dev_stats_get(struct rte_eth_dev *dev,
267 : : struct rte_eth_stats *stats);
268 : : static int ixgbevf_dev_stats_reset(struct rte_eth_dev *dev);
269 : : static int ixgbevf_vlan_filter_set(struct rte_eth_dev *dev,
270 : : uint16_t vlan_id, int on);
271 : : static void ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev,
272 : : uint16_t queue, int on);
273 : : static int ixgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
274 : : static int ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask);
275 : : static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
276 : : static int ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
277 : : uint16_t queue_id);
278 : : static int ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
279 : : uint16_t queue_id);
280 : : static void ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
281 : : uint8_t queue, uint8_t msix_vector);
282 : : static void ixgbevf_configure_msix(struct rte_eth_dev *dev);
283 : : static int ixgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev);
284 : : static int ixgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev);
285 : : static int ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev);
286 : : static int ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev);
287 : :
288 : : /* For Eth VMDQ APIs support */
289 : : static int ixgbe_uc_hash_table_set(struct rte_eth_dev *dev, struct
290 : : rte_ether_addr * mac_addr, uint8_t on);
291 : : static int ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on);
292 : : static int ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
293 : : uint16_t queue_id);
294 : : static int ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
295 : : uint16_t queue_id);
296 : : static void ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
297 : : uint8_t queue, uint8_t msix_vector);
298 : : static void ixgbe_configure_msix(struct rte_eth_dev *dev);
299 : :
300 : : static int ixgbevf_add_mac_addr(struct rte_eth_dev *dev,
301 : : struct rte_ether_addr *mac_addr,
302 : : uint32_t index, uint32_t pool);
303 : : static void ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
304 : : static int ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
305 : : struct rte_ether_addr *mac_addr);
306 : : static int ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
307 : : struct ixgbe_5tuple_filter *filter);
308 : : static void ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
309 : : struct ixgbe_5tuple_filter *filter);
310 : : static int ixgbe_dev_flow_ops_get(struct rte_eth_dev *dev,
311 : : const struct rte_flow_ops **ops);
312 : : static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu);
313 : :
314 : : static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
315 : : struct rte_ether_addr *mc_addr_set,
316 : : uint32_t nb_mc_addr);
317 : : static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
318 : : struct rte_eth_dcb_info *dcb_info);
319 : :
320 : : static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
321 : : static int ixgbe_get_regs(struct rte_eth_dev *dev,
322 : : struct rte_dev_reg_info *regs);
323 : : static int ixgbe_get_eeprom_length(struct rte_eth_dev *dev);
324 : : static int ixgbe_get_eeprom(struct rte_eth_dev *dev,
325 : : struct rte_dev_eeprom_info *eeprom);
326 : : static int ixgbe_set_eeprom(struct rte_eth_dev *dev,
327 : : struct rte_dev_eeprom_info *eeprom);
328 : :
329 : : static int ixgbe_get_module_info(struct rte_eth_dev *dev,
330 : : struct rte_eth_dev_module_info *modinfo);
331 : : static int ixgbe_get_module_eeprom(struct rte_eth_dev *dev,
332 : : struct rte_dev_eeprom_info *info);
333 : :
334 : : static int ixgbevf_get_reg_length(struct rte_eth_dev *dev);
335 : : static int ixgbevf_get_regs(struct rte_eth_dev *dev,
336 : : struct rte_dev_reg_info *regs);
337 : :
338 : : static int ixgbe_timesync_enable(struct rte_eth_dev *dev);
339 : : static int ixgbe_timesync_disable(struct rte_eth_dev *dev);
340 : : static int ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
341 : : struct timespec *timestamp,
342 : : uint32_t flags);
343 : : static int ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
344 : : struct timespec *timestamp);
345 : : static int ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta);
346 : : static int ixgbe_timesync_read_time(struct rte_eth_dev *dev,
347 : : struct timespec *timestamp);
348 : : static int ixgbe_timesync_write_time(struct rte_eth_dev *dev,
349 : : const struct timespec *timestamp);
350 : : static void ixgbevf_dev_interrupt_handler(void *param);
351 : :
352 : : static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
353 : : struct rte_eth_udp_tunnel *udp_tunnel);
354 : : static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
355 : : struct rte_eth_udp_tunnel *udp_tunnel);
356 : : static int ixgbe_filter_restore(struct rte_eth_dev *dev);
357 : : static void ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev);
358 : : static int ixgbe_wait_for_link_up(struct ixgbe_hw *hw);
359 : : static int devarg_handle_int(__rte_unused const char *key, const char *value,
360 : : void *extra_args);
361 : :
362 : : /*
363 : : * Define VF Stats MACRO for Non "cleared on read" register
364 : : */
365 : : #define UPDATE_VF_STAT(reg, last, cur) \
366 : : { \
367 : : uint32_t latest = IXGBE_READ_REG(hw, reg); \
368 : : cur += (latest - last) & UINT_MAX; \
369 : : last = latest; \
370 : : }
371 : :
372 : : #define UPDATE_VF_STAT_36BIT(lsb, msb, last, cur) \
373 : : { \
374 : : u64 new_lsb = IXGBE_READ_REG(hw, lsb); \
375 : : u64 new_msb = IXGBE_READ_REG(hw, msb); \
376 : : u64 latest = ((new_msb << 32) | new_lsb); \
377 : : cur += (0x1000000000LL + latest - last) & 0xFFFFFFFFFLL; \
378 : : last = latest; \
379 : : }
380 : :
381 : : #define IXGBE_SET_HWSTRIP(h, q) do {\
382 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
383 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
384 : : (h)->bitmap[idx] |= 1 << bit;\
385 : : } while (0)
386 : :
387 : : #define IXGBE_CLEAR_HWSTRIP(h, q) do {\
388 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
389 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
390 : : (h)->bitmap[idx] &= ~(1 << bit);\
391 : : } while (0)
392 : :
393 : : #define IXGBE_GET_HWSTRIP(h, q, r) do {\
394 : : uint32_t idx = (q) / (sizeof((h)->bitmap[0]) * NBBY); \
395 : : uint32_t bit = (q) % (sizeof((h)->bitmap[0]) * NBBY); \
396 : : (r) = (h)->bitmap[idx] >> bit & 1;\
397 : : } while (0)
398 : :
399 : : /*
400 : : * The set of PCI devices this driver supports
401 : : */
402 : : static const struct rte_pci_id pci_id_ixgbe_map[] = {
403 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598) },
404 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_BX) },
405 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_DUAL_PORT) },
406 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AF_SINGLE_PORT) },
407 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT) },
408 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598AT2) },
409 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_SFP_LOM) },
410 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_CX4) },
411 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_CX4_DUAL_PORT) },
412 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_DA_DUAL_PORT) },
413 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM) },
414 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82598EB_XF_LR) },
415 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4) },
416 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KX4_MEZZ) },
417 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_KR) },
418 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_COMBO_BACKPLANE) },
419 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_CX4) },
420 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP) },
421 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BACKPLANE_FCOE) },
422 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_FCOE) },
423 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_EM) },
424 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF2) },
425 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_SFP_SF_QP) },
426 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_QSFP_SF_QP) },
427 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599EN_SFP) },
428 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_XAUI_LOM) },
429 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_T3_LOM) },
430 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_LS) },
431 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T) },
432 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540T1) },
433 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_SFP) },
434 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_10G_T) },
435 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_1G_T) },
436 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T) },
437 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550T1) },
438 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR) },
439 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_KR_L) },
440 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP_N) },
441 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII) },
442 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SGMII_L) },
443 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_10G_T) },
444 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP) },
445 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_QSFP_N) },
446 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_SFP) },
447 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T) },
448 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_1G_T_L) },
449 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KX4) },
450 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_KR) },
451 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_XFI) },
452 : : #ifdef RTE_LIBRTE_IXGBE_BYPASS
453 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_BYPASS) },
454 : : #endif
455 : : { .vendor_id = 0, /* sentinel */ },
456 : : };
457 : :
458 : : /*
459 : : * The set of PCI devices this driver supports (for 82599 VF)
460 : : */
461 : : static const struct rte_pci_id pci_id_ixgbevf_map[] = {
462 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF) },
463 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF_HV) },
464 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF) },
465 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF_HV) },
466 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF_HV) },
467 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF) },
468 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF) },
469 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF_HV) },
470 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF) },
471 : : { RTE_PCI_DEVICE(IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF_HV) },
472 : : { .vendor_id = 0, /* sentinel */ },
473 : : };
474 : :
475 : : static const struct rte_eth_desc_lim rx_desc_lim = {
476 : : .nb_max = IXGBE_MAX_RING_DESC,
477 : : .nb_min = IXGBE_MIN_RING_DESC,
478 : : .nb_align = IXGBE_RXD_ALIGN,
479 : : };
480 : :
481 : : static const struct rte_eth_desc_lim tx_desc_lim = {
482 : : .nb_max = IXGBE_MAX_RING_DESC,
483 : : .nb_min = IXGBE_MIN_RING_DESC,
484 : : .nb_align = IXGBE_TXD_ALIGN,
485 : : .nb_seg_max = IXGBE_TX_MAX_SEG,
486 : : .nb_mtu_seg_max = IXGBE_TX_MAX_SEG,
487 : : };
488 : :
489 : : static const struct eth_dev_ops ixgbe_eth_dev_ops = {
490 : : .dev_configure = ixgbe_dev_configure,
491 : : .dev_start = ixgbe_dev_start,
492 : : .dev_stop = ixgbe_dev_stop,
493 : : .dev_set_link_up = ixgbe_dev_set_link_up,
494 : : .dev_set_link_down = ixgbe_dev_set_link_down,
495 : : .dev_close = ixgbe_dev_close,
496 : : .dev_reset = ixgbe_dev_reset,
497 : : .promiscuous_enable = ixgbe_dev_promiscuous_enable,
498 : : .promiscuous_disable = ixgbe_dev_promiscuous_disable,
499 : : .allmulticast_enable = ixgbe_dev_allmulticast_enable,
500 : : .allmulticast_disable = ixgbe_dev_allmulticast_disable,
501 : : .link_update = ixgbe_dev_link_update,
502 : : .stats_get = ixgbe_dev_stats_get,
503 : : .xstats_get = ixgbe_dev_xstats_get,
504 : : .xstats_get_by_id = ixgbe_dev_xstats_get_by_id,
505 : : .stats_reset = ixgbe_dev_stats_reset,
506 : : .xstats_reset = ixgbe_dev_xstats_reset,
507 : : .xstats_get_names = ixgbe_dev_xstats_get_names,
508 : : .xstats_get_names_by_id = ixgbe_dev_xstats_get_names_by_id,
509 : : .queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
510 : : .fw_version_get = ixgbe_fw_version_get,
511 : : .dev_infos_get = ixgbe_dev_info_get,
512 : : .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
513 : : .mtu_set = ixgbe_dev_mtu_set,
514 : : .vlan_filter_set = ixgbe_vlan_filter_set,
515 : : .vlan_tpid_set = ixgbe_vlan_tpid_set,
516 : : .vlan_offload_set = ixgbe_vlan_offload_set,
517 : : .vlan_strip_queue_set = ixgbe_vlan_strip_queue_set,
518 : : .rx_queue_start = ixgbe_dev_rx_queue_start,
519 : : .rx_queue_stop = ixgbe_dev_rx_queue_stop,
520 : : .tx_queue_start = ixgbe_dev_tx_queue_start,
521 : : .tx_queue_stop = ixgbe_dev_tx_queue_stop,
522 : : .rx_queue_setup = ixgbe_dev_rx_queue_setup,
523 : : .rx_queue_intr_enable = ixgbe_dev_rx_queue_intr_enable,
524 : : .rx_queue_intr_disable = ixgbe_dev_rx_queue_intr_disable,
525 : : .rx_queue_release = ixgbe_dev_rx_queue_release,
526 : : .tx_queue_setup = ixgbe_dev_tx_queue_setup,
527 : : .tx_queue_release = ixgbe_dev_tx_queue_release,
528 : : .dev_led_on = ixgbe_dev_led_on,
529 : : .dev_led_off = ixgbe_dev_led_off,
530 : : .flow_ctrl_get = ixgbe_flow_ctrl_get,
531 : : .flow_ctrl_set = ixgbe_flow_ctrl_set,
532 : : .priority_flow_ctrl_set = ixgbe_priority_flow_ctrl_set,
533 : : .mac_addr_add = ixgbe_add_rar,
534 : : .mac_addr_remove = ixgbe_remove_rar,
535 : : .mac_addr_set = ixgbe_set_default_mac_addr,
536 : : .uc_hash_table_set = ixgbe_uc_hash_table_set,
537 : : .uc_all_hash_table_set = ixgbe_uc_all_hash_table_set,
538 : : .set_queue_rate_limit = ixgbe_set_queue_rate_limit,
539 : : .reta_update = ixgbe_dev_rss_reta_update,
540 : : .reta_query = ixgbe_dev_rss_reta_query,
541 : : .rss_hash_update = ixgbe_dev_rss_hash_update,
542 : : .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
543 : : .flow_ops_get = ixgbe_dev_flow_ops_get,
544 : : .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
545 : : .rxq_info_get = ixgbe_rxq_info_get,
546 : : .txq_info_get = ixgbe_txq_info_get,
547 : : .recycle_rxq_info_get = ixgbe_recycle_rxq_info_get,
548 : : .timesync_enable = ixgbe_timesync_enable,
549 : : .timesync_disable = ixgbe_timesync_disable,
550 : : .timesync_read_rx_timestamp = ixgbe_timesync_read_rx_timestamp,
551 : : .timesync_read_tx_timestamp = ixgbe_timesync_read_tx_timestamp,
552 : : .get_reg = ixgbe_get_regs,
553 : : .get_eeprom_length = ixgbe_get_eeprom_length,
554 : : .get_eeprom = ixgbe_get_eeprom,
555 : : .set_eeprom = ixgbe_set_eeprom,
556 : : .get_module_info = ixgbe_get_module_info,
557 : : .get_module_eeprom = ixgbe_get_module_eeprom,
558 : : .get_dcb_info = ixgbe_dev_get_dcb_info,
559 : : .timesync_adjust_time = ixgbe_timesync_adjust_time,
560 : : .timesync_read_time = ixgbe_timesync_read_time,
561 : : .timesync_write_time = ixgbe_timesync_write_time,
562 : : .udp_tunnel_port_add = ixgbe_dev_udp_tunnel_port_add,
563 : : .udp_tunnel_port_del = ixgbe_dev_udp_tunnel_port_del,
564 : : .tm_ops_get = ixgbe_tm_ops_get,
565 : : .tx_done_cleanup = ixgbe_dev_tx_done_cleanup,
566 : : .get_monitor_addr = ixgbe_get_monitor_addr,
567 : : };
568 : :
569 : : /*
570 : : * dev_ops for virtual function, bare necessities for basic vf
571 : : * operation have been implemented
572 : : */
573 : : static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
574 : : .dev_configure = ixgbevf_dev_configure,
575 : : .dev_start = ixgbevf_dev_start,
576 : : .dev_stop = ixgbevf_dev_stop,
577 : : .link_update = ixgbevf_dev_link_update,
578 : : .stats_get = ixgbevf_dev_stats_get,
579 : : .xstats_get = ixgbevf_dev_xstats_get,
580 : : .stats_reset = ixgbevf_dev_stats_reset,
581 : : .xstats_reset = ixgbevf_dev_stats_reset,
582 : : .xstats_get_names = ixgbevf_dev_xstats_get_names,
583 : : .dev_close = ixgbevf_dev_close,
584 : : .dev_reset = ixgbevf_dev_reset,
585 : : .promiscuous_enable = ixgbevf_dev_promiscuous_enable,
586 : : .promiscuous_disable = ixgbevf_dev_promiscuous_disable,
587 : : .allmulticast_enable = ixgbevf_dev_allmulticast_enable,
588 : : .allmulticast_disable = ixgbevf_dev_allmulticast_disable,
589 : : .dev_infos_get = ixgbevf_dev_info_get,
590 : : .dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
591 : : .mtu_set = ixgbevf_dev_set_mtu,
592 : : .vlan_filter_set = ixgbevf_vlan_filter_set,
593 : : .vlan_strip_queue_set = ixgbevf_vlan_strip_queue_set,
594 : : .vlan_offload_set = ixgbevf_vlan_offload_set,
595 : : .rx_queue_setup = ixgbe_dev_rx_queue_setup,
596 : : .rx_queue_release = ixgbe_dev_rx_queue_release,
597 : : .tx_queue_setup = ixgbe_dev_tx_queue_setup,
598 : : .tx_queue_release = ixgbe_dev_tx_queue_release,
599 : : .rx_queue_intr_enable = ixgbevf_dev_rx_queue_intr_enable,
600 : : .rx_queue_intr_disable = ixgbevf_dev_rx_queue_intr_disable,
601 : : .mac_addr_add = ixgbevf_add_mac_addr,
602 : : .mac_addr_remove = ixgbevf_remove_mac_addr,
603 : : .set_mc_addr_list = ixgbe_dev_set_mc_addr_list,
604 : : .rxq_info_get = ixgbe_rxq_info_get,
605 : : .txq_info_get = ixgbe_txq_info_get,
606 : : .mac_addr_set = ixgbevf_set_default_mac_addr,
607 : : .get_reg = ixgbevf_get_regs,
608 : : .reta_update = ixgbe_dev_rss_reta_update,
609 : : .reta_query = ixgbe_dev_rss_reta_query,
610 : : .rss_hash_update = ixgbe_dev_rss_hash_update,
611 : : .rss_hash_conf_get = ixgbe_dev_rss_hash_conf_get,
612 : : .tx_done_cleanup = ixgbe_dev_tx_done_cleanup,
613 : : .get_monitor_addr = ixgbe_get_monitor_addr,
614 : : };
615 : :
616 : : /* store statistics names and its offset in stats structure */
617 : : struct rte_ixgbe_xstats_name_off {
618 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
619 : : unsigned offset;
620 : : };
621 : :
622 : : static const struct rte_ixgbe_xstats_name_off rte_ixgbe_stats_strings[] = {
623 : : {"rx_crc_errors", offsetof(struct ixgbe_hw_stats, crcerrs)},
624 : : {"rx_illegal_byte_errors", offsetof(struct ixgbe_hw_stats, illerrc)},
625 : : {"rx_error_bytes", offsetof(struct ixgbe_hw_stats, errbc)},
626 : : {"mac_local_errors", offsetof(struct ixgbe_hw_stats, mlfc)},
627 : : {"mac_remote_errors", offsetof(struct ixgbe_hw_stats, mrfc)},
628 : : {"rx_length_errors", offsetof(struct ixgbe_hw_stats, rlec)},
629 : : {"tx_xon_packets", offsetof(struct ixgbe_hw_stats, lxontxc)},
630 : : {"rx_xon_packets", offsetof(struct ixgbe_hw_stats, lxonrxc)},
631 : : {"tx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxofftxc)},
632 : : {"rx_xoff_packets", offsetof(struct ixgbe_hw_stats, lxoffrxc)},
633 : : {"rx_size_64_packets", offsetof(struct ixgbe_hw_stats, prc64)},
634 : : {"rx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, prc127)},
635 : : {"rx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, prc255)},
636 : : {"rx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, prc511)},
637 : : {"rx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
638 : : prc1023)},
639 : : {"rx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
640 : : prc1522)},
641 : : {"rx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bprc)},
642 : : {"rx_multicast_packets", offsetof(struct ixgbe_hw_stats, mprc)},
643 : : {"rx_fragment_errors", offsetof(struct ixgbe_hw_stats, rfc)},
644 : : {"rx_undersize_errors", offsetof(struct ixgbe_hw_stats, ruc)},
645 : : {"rx_oversize_errors", offsetof(struct ixgbe_hw_stats, roc)},
646 : : {"rx_jabber_errors", offsetof(struct ixgbe_hw_stats, rjc)},
647 : : {"rx_management_packets", offsetof(struct ixgbe_hw_stats, mngprc)},
648 : : {"rx_management_dropped", offsetof(struct ixgbe_hw_stats, mngpdc)},
649 : : {"tx_management_packets", offsetof(struct ixgbe_hw_stats, mngptc)},
650 : : {"rx_total_packets", offsetof(struct ixgbe_hw_stats, tpr)},
651 : : {"rx_total_bytes", offsetof(struct ixgbe_hw_stats, tor)},
652 : : {"tx_total_packets", offsetof(struct ixgbe_hw_stats, tpt)},
653 : : {"tx_size_64_packets", offsetof(struct ixgbe_hw_stats, ptc64)},
654 : : {"tx_size_65_to_127_packets", offsetof(struct ixgbe_hw_stats, ptc127)},
655 : : {"tx_size_128_to_255_packets", offsetof(struct ixgbe_hw_stats, ptc255)},
656 : : {"tx_size_256_to_511_packets", offsetof(struct ixgbe_hw_stats, ptc511)},
657 : : {"tx_size_512_to_1023_packets", offsetof(struct ixgbe_hw_stats,
658 : : ptc1023)},
659 : : {"tx_size_1024_to_max_packets", offsetof(struct ixgbe_hw_stats,
660 : : ptc1522)},
661 : : {"tx_multicast_packets", offsetof(struct ixgbe_hw_stats, mptc)},
662 : : {"tx_broadcast_packets", offsetof(struct ixgbe_hw_stats, bptc)},
663 : : {"rx_mac_short_packet_dropped", offsetof(struct ixgbe_hw_stats, mspdc)},
664 : : {"rx_l3_l4_xsum_error", offsetof(struct ixgbe_hw_stats, xec)},
665 : :
666 : : {"flow_director_added_filters", offsetof(struct ixgbe_hw_stats,
667 : : fdirustat_add)},
668 : : {"flow_director_removed_filters", offsetof(struct ixgbe_hw_stats,
669 : : fdirustat_remove)},
670 : : {"flow_director_filter_add_errors", offsetof(struct ixgbe_hw_stats,
671 : : fdirfstat_fadd)},
672 : : {"flow_director_filter_remove_errors", offsetof(struct ixgbe_hw_stats,
673 : : fdirfstat_fremove)},
674 : : {"flow_director_matched_filters", offsetof(struct ixgbe_hw_stats,
675 : : fdirmatch)},
676 : : {"flow_director_missed_filters", offsetof(struct ixgbe_hw_stats,
677 : : fdirmiss)},
678 : :
679 : : {"rx_fcoe_crc_errors", offsetof(struct ixgbe_hw_stats, fccrc)},
680 : : {"rx_fcoe_dropped", offsetof(struct ixgbe_hw_stats, fcoerpdc)},
681 : : {"rx_fcoe_mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats,
682 : : fclast)},
683 : : {"rx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeprc)},
684 : : {"tx_fcoe_packets", offsetof(struct ixgbe_hw_stats, fcoeptc)},
685 : : {"rx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwrc)},
686 : : {"tx_fcoe_bytes", offsetof(struct ixgbe_hw_stats, fcoedwtc)},
687 : : {"rx_fcoe_no_direct_data_placement", offsetof(struct ixgbe_hw_stats,
688 : : fcoe_noddp)},
689 : : {"rx_fcoe_no_direct_data_placement_ext_buff",
690 : : offsetof(struct ixgbe_hw_stats, fcoe_noddp_ext_buff)},
691 : :
692 : : {"tx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
693 : : lxontxc)},
694 : : {"rx_flow_control_xon_packets", offsetof(struct ixgbe_hw_stats,
695 : : lxonrxc)},
696 : : {"tx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
697 : : lxofftxc)},
698 : : {"rx_flow_control_xoff_packets", offsetof(struct ixgbe_hw_stats,
699 : : lxoffrxc)},
700 : : {"rx_total_missed_packets", offsetof(struct ixgbe_hw_stats, mpctotal)},
701 : : };
702 : :
703 : : #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
704 : : sizeof(rte_ixgbe_stats_strings[0]))
705 : :
706 : : /* MACsec statistics */
707 : : static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
708 : : {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
709 : : out_pkts_untagged)},
710 : : {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
711 : : out_pkts_encrypted)},
712 : : {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
713 : : out_pkts_protected)},
714 : : {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
715 : : out_octets_encrypted)},
716 : : {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
717 : : out_octets_protected)},
718 : : {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
719 : : in_pkts_untagged)},
720 : : {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
721 : : in_pkts_badtag)},
722 : : {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
723 : : in_pkts_nosci)},
724 : : {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
725 : : in_pkts_unknownsci)},
726 : : {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
727 : : in_octets_decrypted)},
728 : : {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
729 : : in_octets_validated)},
730 : : {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
731 : : in_pkts_unchecked)},
732 : : {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
733 : : in_pkts_delayed)},
734 : : {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
735 : : in_pkts_late)},
736 : : {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
737 : : in_pkts_ok)},
738 : : {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
739 : : in_pkts_invalid)},
740 : : {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
741 : : in_pkts_notvalid)},
742 : : {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
743 : : in_pkts_unusedsa)},
744 : : {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
745 : : in_pkts_notusingsa)},
746 : : };
747 : :
748 : : #define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
749 : : sizeof(rte_ixgbe_macsec_strings[0]))
750 : :
751 : : /* Per-queue statistics */
752 : : static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
753 : : {"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
754 : : {"dropped", offsetof(struct ixgbe_hw_stats, mpc)},
755 : : {"xon_packets", offsetof(struct ixgbe_hw_stats, pxonrxc)},
756 : : {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxoffrxc)},
757 : : };
758 : :
759 : : #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
760 : : sizeof(rte_ixgbe_rxq_strings[0]))
761 : : #define IXGBE_NB_RXQ_PRIO_VALUES 8
762 : :
763 : : static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
764 : : {"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
765 : : {"xoff_packets", offsetof(struct ixgbe_hw_stats, pxofftxc)},
766 : : {"xon_to_xoff_packets", offsetof(struct ixgbe_hw_stats,
767 : : pxon2offc)},
768 : : };
769 : :
770 : : #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
771 : : sizeof(rte_ixgbe_txq_strings[0]))
772 : : #define IXGBE_NB_TXQ_PRIO_VALUES 8
773 : :
774 : : static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
775 : : {"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
776 : : };
777 : :
778 : : #define IXGBEVF_NB_XSTATS (sizeof(rte_ixgbevf_stats_strings) / \
779 : : sizeof(rte_ixgbevf_stats_strings[0]))
780 : :
781 : : /*
782 : : * This function is the same as ixgbe_is_sfp() in base/ixgbe.h.
783 : : */
784 : : static inline int
785 : 0 : ixgbe_is_sfp(struct ixgbe_hw *hw)
786 : : {
787 [ # # ]: 0 : switch (hw->phy.type) {
788 : : case ixgbe_phy_sfp_avago:
789 : : case ixgbe_phy_sfp_ftl:
790 : : case ixgbe_phy_sfp_intel:
791 : : case ixgbe_phy_sfp_unknown:
792 : : case ixgbe_phy_sfp_passive_tyco:
793 : : case ixgbe_phy_sfp_passive_unknown:
794 : : return 1;
795 : 0 : default:
796 : : /* x550em devices may be SFP, check media type */
797 [ # # ]: 0 : switch (hw->mac.type) {
798 : 0 : case ixgbe_mac_X550EM_x:
799 : : case ixgbe_mac_X550EM_a:
800 : 0 : switch (ixgbe_get_media_type(hw)) {
801 : : case ixgbe_media_type_fiber:
802 : : case ixgbe_media_type_fiber_qsfp:
803 : : return 1;
804 : : default:
805 : : break;
806 : : }
807 : : default:
808 : : break;
809 : : }
810 : : return 0;
811 : : }
812 : : }
813 : :
814 : : static inline int32_t
815 : 0 : ixgbe_pf_reset_hw(struct ixgbe_hw *hw)
816 : : {
817 : : uint32_t ctrl_ext;
818 : : int32_t status;
819 : :
820 : 0 : status = ixgbe_reset_hw(hw);
821 : :
822 : 0 : ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
823 : : /* Set PF Reset Done bit so PF/VF Mail Ops can work */
824 : 0 : ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
825 : 0 : IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
826 : 0 : IXGBE_WRITE_FLUSH(hw);
827 : :
828 [ # # ]: 0 : if (status == IXGBE_ERR_SFP_NOT_PRESENT)
829 : : status = IXGBE_SUCCESS;
830 : 0 : return status;
831 : : }
832 : :
833 : : static inline void
834 : : ixgbe_enable_intr(struct rte_eth_dev *dev)
835 : : {
836 : : struct ixgbe_interrupt *intr =
837 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
838 : : struct ixgbe_hw *hw =
839 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
840 : :
841 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMS, intr->mask);
842 : 0 : IXGBE_WRITE_FLUSH(hw);
843 : 0 : }
844 : :
845 : : /*
846 : : * This function is based on ixgbe_disable_intr() in base/ixgbe.h.
847 : : */
848 : : static void
849 : 0 : ixgbe_disable_intr(struct ixgbe_hw *hw)
850 : : {
851 : 0 : PMD_INIT_FUNC_TRACE();
852 : :
853 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
854 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMC, ~0);
855 : : } else {
856 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMC, 0xFFFF0000);
857 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(0), ~0);
858 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMC_EX(1), ~0);
859 : : }
860 : 0 : IXGBE_WRITE_FLUSH(hw);
861 : 0 : }
862 : :
863 : : /*
864 : : * This function resets queue statistics mapping registers.
865 : : * From Niantic datasheet, Initialization of Statistics section:
866 : : * "...if software requires the queue counters, the RQSMR and TQSM registers
867 : : * must be re-programmed following a device reset.
868 : : */
869 : : static void
870 : : ixgbe_reset_qstat_mappings(struct ixgbe_hw *hw)
871 : : {
872 : : uint32_t i;
873 : :
874 [ # # ]: 0 : for (i = 0; i != IXGBE_NB_STAT_MAPPING_REGS; i++) {
875 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), 0);
876 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), 0);
877 : : }
878 : : }
879 : :
880 : :
881 : : static int
882 : 0 : ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
883 : : uint16_t queue_id,
884 : : uint8_t stat_idx,
885 : : uint8_t is_rx)
886 : : {
887 : : #define QSM_REG_NB_BITS_PER_QMAP_FIELD 8
888 : : #define NB_QMAP_FIELDS_PER_QSM_REG 4
889 : : #define QMAP_FIELD_RESERVED_BITS_MASK 0x0f
890 : :
891 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
892 : : struct ixgbe_stat_mapping_registers *stat_mappings =
893 : : IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(eth_dev->data->dev_private);
894 : : uint32_t qsmr_mask = 0;
895 : : uint32_t clearing_mask = QMAP_FIELD_RESERVED_BITS_MASK;
896 : : uint32_t q_map;
897 : : uint8_t n, offset;
898 : :
899 [ # # ]: 0 : if ((hw->mac.type != ixgbe_mac_82599EB) &&
900 [ # # ]: 0 : (hw->mac.type != ixgbe_mac_X540) &&
901 [ # # ]: 0 : (hw->mac.type != ixgbe_mac_X550) &&
902 [ # # ]: 0 : (hw->mac.type != ixgbe_mac_X550EM_x) &&
903 : : (hw->mac.type != ixgbe_mac_X550EM_a))
904 : : return -ENOSYS;
905 : :
906 [ # # ]: 0 : PMD_INIT_LOG(DEBUG, "Setting port %d, %s queue_id %d to stat index %d",
907 : : (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
908 : : queue_id, stat_idx);
909 : :
910 : 0 : n = (uint8_t)(queue_id / NB_QMAP_FIELDS_PER_QSM_REG);
911 [ # # ]: 0 : if (n >= IXGBE_NB_STAT_MAPPING_REGS) {
912 : 0 : PMD_INIT_LOG(ERR, "Nb of stat mapping registers exceeded");
913 : 0 : return -EIO;
914 : : }
915 : 0 : offset = (uint8_t)(queue_id % NB_QMAP_FIELDS_PER_QSM_REG);
916 : :
917 : : /* Now clear any previous stat_idx set */
918 : 0 : clearing_mask <<= (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
919 [ # # ]: 0 : if (!is_rx)
920 : 0 : stat_mappings->tqsm[n] &= ~clearing_mask;
921 : : else
922 : 0 : stat_mappings->rqsmr[n] &= ~clearing_mask;
923 : :
924 : : q_map = (uint32_t)stat_idx;
925 : 0 : q_map &= QMAP_FIELD_RESERVED_BITS_MASK;
926 : 0 : qsmr_mask = q_map << (QSM_REG_NB_BITS_PER_QMAP_FIELD * offset);
927 [ # # ]: 0 : if (!is_rx)
928 : 0 : stat_mappings->tqsm[n] |= qsmr_mask;
929 : : else
930 : 0 : stat_mappings->rqsmr[n] |= qsmr_mask;
931 : :
932 : 0 : PMD_INIT_LOG(DEBUG, "Set port %d, %s queue_id %d to stat index %d",
933 : : (int)(eth_dev->data->port_id), is_rx ? "RX" : "TX",
934 : : queue_id, stat_idx);
935 [ # # # # ]: 0 : PMD_INIT_LOG(DEBUG, "%s[%d] = 0x%08x", is_rx ? "RQSMR" : "TQSM", n,
936 : : is_rx ? stat_mappings->rqsmr[n] : stat_mappings->tqsm[n]);
937 : :
938 : : /* Now write the mapping in the appropriate register */
939 [ # # ]: 0 : if (is_rx) {
940 : 0 : PMD_INIT_LOG(DEBUG, "Write 0x%x to RX IXGBE stat mapping reg:%d",
941 : : stat_mappings->rqsmr[n], n);
942 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RQSMR(n), stat_mappings->rqsmr[n]);
943 : : } else {
944 : 0 : PMD_INIT_LOG(DEBUG, "Write 0x%x to TX IXGBE stat mapping reg:%d",
945 : : stat_mappings->tqsm[n], n);
946 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TQSM(n), stat_mappings->tqsm[n]);
947 : : }
948 : : return 0;
949 : : }
950 : :
951 : : static void
952 : 0 : ixgbe_restore_statistics_mapping(struct rte_eth_dev *dev)
953 : : {
954 : : struct ixgbe_stat_mapping_registers *stat_mappings =
955 : 0 : IXGBE_DEV_PRIVATE_TO_STAT_MAPPINGS(dev->data->dev_private);
956 : : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
957 : : int i;
958 : :
959 : : /* write whatever was in stat mapping table to the NIC */
960 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_STAT_MAPPING_REGS; i++) {
961 : : /* rx */
962 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RQSMR(i), stat_mappings->rqsmr[i]);
963 : :
964 : : /* tx */
965 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TQSM(i), stat_mappings->tqsm[i]);
966 : : }
967 : 0 : }
968 : :
969 : : static void
970 : 0 : ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config *dcb_config)
971 : : {
972 : : uint8_t i;
973 : : struct ixgbe_dcb_tc_config *tc;
974 : : uint8_t dcb_max_tc = IXGBE_DCB_MAX_TRAFFIC_CLASS;
975 : :
976 : 0 : dcb_config->num_tcs.pg_tcs = dcb_max_tc;
977 : 0 : dcb_config->num_tcs.pfc_tcs = dcb_max_tc;
978 [ # # ]: 0 : for (i = 0; i < dcb_max_tc; i++) {
979 : 0 : tc = &dcb_config->tc_config[i];
980 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].bwg_id = i;
981 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent =
982 : 0 : (uint8_t)(100/dcb_max_tc + (i & 1));
983 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].bwg_id = i;
984 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].bwg_percent =
985 : : (uint8_t)(100/dcb_max_tc + (i & 1));
986 : 0 : tc->pfc = ixgbe_dcb_pfc_disabled;
987 : : }
988 : :
989 : : /* Initialize default user to priority mapping, UPx->TC0 */
990 : : tc = &dcb_config->tc_config[0];
991 : 0 : tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF;
992 : 0 : tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF;
993 [ # # ]: 0 : for (i = 0; i < IXGBE_DCB_MAX_BW_GROUP; i++) {
994 : 0 : dcb_config->bw_percentage[IXGBE_DCB_TX_CONFIG][i] = 100;
995 : 0 : dcb_config->bw_percentage[IXGBE_DCB_RX_CONFIG][i] = 100;
996 : : }
997 : 0 : dcb_config->rx_pba_cfg = ixgbe_dcb_pba_equal;
998 : 0 : dcb_config->pfc_mode_enable = false;
999 : 0 : dcb_config->vt_mode = true;
1000 : 0 : dcb_config->round_robin_enable = false;
1001 : : /* support all DCB capabilities in 82599 */
1002 : 0 : dcb_config->support.capabilities = 0xFF;
1003 : :
1004 : : /*we only support 4 Tcs for X540, X550 */
1005 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X540 ||
1006 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550 ||
1007 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
1008 : : hw->mac.type == ixgbe_mac_X550EM_a) {
1009 : 0 : dcb_config->num_tcs.pg_tcs = 4;
1010 : 0 : dcb_config->num_tcs.pfc_tcs = 4;
1011 : : }
1012 : 0 : }
1013 : :
1014 : : /*
1015 : : * Ensure that all locks are released before first NVM or PHY access
1016 : : */
1017 : : static void
1018 : 0 : ixgbe_swfw_lock_reset(struct ixgbe_hw *hw)
1019 : : {
1020 : : uint16_t mask;
1021 : :
1022 : : /*
1023 : : * Phy lock should not fail in this early stage. If this is the case,
1024 : : * it is due to an improper exit of the application.
1025 : : * So force the release of the faulty lock. Release of common lock
1026 : : * is done automatically by swfw_sync function.
1027 : : */
1028 : 0 : mask = IXGBE_GSSR_PHY0_SM << hw->bus.func;
1029 [ # # ]: 0 : if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1030 : 0 : PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released", hw->bus.func);
1031 : : }
1032 : 0 : ixgbe_release_swfw_semaphore(hw, mask);
1033 : :
1034 : : /*
1035 : : * These ones are more tricky since they are common to all ports; but
1036 : : * swfw_sync retries last long enough (1s) to be almost sure that if
1037 : : * lock can not be taken it is due to an improper lock of the
1038 : : * semaphore.
1039 : : */
1040 : : mask = IXGBE_GSSR_EEP_SM | IXGBE_GSSR_MAC_CSR_SM | IXGBE_GSSR_SW_MNG_SM;
1041 [ # # ]: 0 : if (ixgbe_acquire_swfw_semaphore(hw, mask) < 0) {
1042 : 0 : PMD_DRV_LOG(DEBUG, "SWFW common locks released");
1043 : : }
1044 : 0 : ixgbe_release_swfw_semaphore(hw, mask);
1045 : 0 : }
1046 : :
1047 : : static void
1048 : 0 : ixgbe_parse_devargs(struct ixgbe_adapter *adapter,
1049 : : struct rte_devargs *devargs)
1050 : : {
1051 : : struct rte_kvargs *kvlist;
1052 : : uint16_t sdp3_no_tx_disable;
1053 : :
1054 [ # # ]: 0 : if (devargs == NULL)
1055 : 0 : return;
1056 : :
1057 : 0 : kvlist = rte_kvargs_parse(devargs->args, ixgbe_valid_arguments);
1058 [ # # ]: 0 : if (kvlist == NULL)
1059 : : return;
1060 : :
1061 [ # # # # ]: 0 : if (rte_kvargs_count(kvlist, IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE) == 1 &&
1062 : 0 : rte_kvargs_process(kvlist, IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE,
1063 : 0 : devarg_handle_int, &sdp3_no_tx_disable) == 0 &&
1064 [ # # ]: 0 : sdp3_no_tx_disable == 1)
1065 : 0 : adapter->sdp3_no_tx_disable = 1;
1066 : :
1067 : 0 : rte_kvargs_free(kvlist);
1068 : : }
1069 : :
1070 : : /*
1071 : : * This function is based on code in ixgbe_attach() in base/ixgbe.c.
1072 : : * It returns 0 on success.
1073 : : */
1074 : : static int
1075 : 0 : eth_ixgbe_dev_init(struct rte_eth_dev *eth_dev, void *init_params __rte_unused)
1076 : : {
1077 : 0 : struct ixgbe_adapter *ad = eth_dev->data->dev_private;
1078 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1079 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1080 : 0 : struct ixgbe_hw *hw =
1081 : : IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1082 : 0 : struct ixgbe_vfta *shadow_vfta =
1083 : : IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1084 : 0 : struct ixgbe_hwstrip *hwstrip =
1085 : : IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1086 : 0 : struct ixgbe_dcb_config *dcb_config =
1087 : : IXGBE_DEV_PRIVATE_TO_DCB_CFG(eth_dev->data->dev_private);
1088 : 0 : struct ixgbe_filter_info *filter_info =
1089 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1090 : 0 : struct ixgbe_bw_conf *bw_conf =
1091 : : IXGBE_DEV_PRIVATE_TO_BW_CONF(eth_dev->data->dev_private);
1092 : : uint32_t ctrl_ext;
1093 : : uint16_t csum;
1094 : : int diag, i, ret;
1095 : :
1096 : 0 : PMD_INIT_FUNC_TRACE();
1097 : :
1098 : 0 : ixgbe_dev_macsec_setting_reset(eth_dev);
1099 : :
1100 : 0 : eth_dev->dev_ops = &ixgbe_eth_dev_ops;
1101 : 0 : eth_dev->rx_queue_count = ixgbe_dev_rx_queue_count;
1102 : 0 : eth_dev->rx_descriptor_status = ixgbe_dev_rx_descriptor_status;
1103 : 0 : eth_dev->tx_descriptor_status = ixgbe_dev_tx_descriptor_status;
1104 : 0 : eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1105 : 0 : eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1106 : 0 : eth_dev->tx_pkt_prepare = &ixgbe_prep_pkts;
1107 : :
1108 : : /*
1109 : : * For secondary processes, we don't initialise any further as primary
1110 : : * has already done this work. Only check we don't need a different
1111 : : * RX and TX function.
1112 : : */
1113 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1114 : : struct ixgbe_tx_queue *txq;
1115 : : /* TX queue function in primary, set by last queue initialized
1116 : : * Tx queue may not initialized by primary process
1117 : : */
1118 [ # # ]: 0 : if (eth_dev->data->tx_queues) {
1119 : 0 : txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues-1];
1120 : 0 : ixgbe_set_tx_function(eth_dev, txq);
1121 : : } else {
1122 : : /* Use default TX function if we get here */
1123 : 0 : PMD_INIT_LOG(NOTICE, "No TX queues configured yet. "
1124 : : "Using default TX function.");
1125 : : }
1126 : :
1127 : 0 : ixgbe_set_rx_function(eth_dev);
1128 : :
1129 : 0 : return 0;
1130 : : }
1131 : :
1132 : : /* NOTE: review for potential ordering optimization */
1133 : 0 : __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST);
1134 : 0 : ixgbe_parse_devargs(eth_dev->data->dev_private,
1135 : : pci_dev->device.devargs);
1136 : 0 : rte_eth_copy_pci_info(eth_dev, pci_dev);
1137 : 0 : eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
1138 : :
1139 : : /* Vendor and Device ID need to be set before init of shared code */
1140 : 0 : hw->device_id = pci_dev->id.device_id;
1141 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
1142 : 0 : hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1143 : 0 : hw->allow_unsupported_sfp = 1;
1144 : :
1145 : : /* Initialize the shared code (base driver) */
1146 : : #ifdef RTE_LIBRTE_IXGBE_BYPASS
1147 : 0 : diag = ixgbe_bypass_init_shared_code(hw);
1148 : : #else
1149 : : diag = ixgbe_init_shared_code(hw);
1150 : : #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1151 : :
1152 [ # # ]: 0 : if (diag != IXGBE_SUCCESS) {
1153 : 0 : PMD_INIT_LOG(ERR, "Shared code init failed: %d", diag);
1154 : 0 : return -EIO;
1155 : : }
1156 : :
1157 [ # # # # ]: 0 : if (hw->mac.ops.fw_recovery_mode && hw->mac.ops.fw_recovery_mode(hw)) {
1158 : 0 : PMD_INIT_LOG(ERR, "\nERROR: "
1159 : : "Firmware recovery mode detected. Limiting functionality.\n"
1160 : : "Refer to the Intel(R) Ethernet Adapters and Devices "
1161 : : "User Guide for details on firmware recovery mode.");
1162 : 0 : return -EIO;
1163 : : }
1164 : :
1165 : : /* pick up the PCI bus settings for reporting later */
1166 : 0 : ixgbe_get_bus_info(hw);
1167 : :
1168 : : /* Unlock any pending hardware semaphore */
1169 : 0 : ixgbe_swfw_lock_reset(hw);
1170 : :
1171 : : #ifdef RTE_LIB_SECURITY
1172 : : /* Initialize security_ctx only for primary process*/
1173 [ # # ]: 0 : if (ixgbe_ipsec_ctx_create(eth_dev))
1174 : : return -ENOMEM;
1175 : : #endif
1176 : :
1177 : : /* Initialize DCB configuration*/
1178 : : memset(dcb_config, 0, sizeof(struct ixgbe_dcb_config));
1179 : 0 : ixgbe_dcb_init(hw, dcb_config);
1180 : : /* Get Hardware Flow Control setting */
1181 : 0 : hw->fc.requested_mode = ixgbe_fc_none;
1182 : 0 : hw->fc.current_mode = ixgbe_fc_none;
1183 : 0 : hw->fc.pause_time = IXGBE_FC_PAUSE;
1184 [ # # ]: 0 : for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
1185 : 0 : hw->fc.low_water[i] = IXGBE_FC_LO;
1186 : 0 : hw->fc.high_water[i] = IXGBE_FC_HI;
1187 : : }
1188 : 0 : hw->fc.send_xon = 1;
1189 : :
1190 : : /* Make sure we have a good EEPROM before we read from it */
1191 : 0 : diag = ixgbe_validate_eeprom_checksum(hw, &csum);
1192 [ # # ]: 0 : if (diag != IXGBE_SUCCESS) {
1193 : 0 : PMD_INIT_LOG(ERR, "The EEPROM checksum is not valid: %d", diag);
1194 : : ret = -EIO;
1195 : 0 : goto err_exit;
1196 : : }
1197 : :
1198 : : #ifdef RTE_LIBRTE_IXGBE_BYPASS
1199 : 0 : diag = ixgbe_bypass_init_hw(hw);
1200 : : #else
1201 : : diag = ixgbe_init_hw(hw);
1202 : : #endif /* RTE_LIBRTE_IXGBE_BYPASS */
1203 : :
1204 : : /*
1205 : : * Devices with copper phys will fail to initialise if ixgbe_init_hw()
1206 : : * is called too soon after the kernel driver unbinding/binding occurs.
1207 : : * The failure occurs in ixgbe_identify_phy_generic() for all devices,
1208 : : * but for non-copper devies, ixgbe_identify_sfp_module_generic() is
1209 : : * also called. See ixgbe_identify_phy_82599(). The reason for the
1210 : : * failure is not known, and only occuts when virtualisation features
1211 : : * are disabled in the bios. A delay of 100ms was found to be enough by
1212 : : * trial-and-error, and is doubled to be safe.
1213 : : */
1214 [ # # # # ]: 0 : if (diag && (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper)) {
1215 : : rte_delay_ms(200);
1216 : 0 : diag = ixgbe_init_hw(hw);
1217 : : }
1218 : :
1219 [ # # ]: 0 : if (diag == IXGBE_ERR_SFP_NOT_PRESENT)
1220 : : diag = IXGBE_SUCCESS;
1221 : :
1222 [ # # ]: 0 : if (diag == IXGBE_ERR_EEPROM_VERSION) {
1223 : 0 : PMD_INIT_LOG(ERR, "This device is a pre-production adapter/"
1224 : : "LOM. Please be aware there may be issues associated "
1225 : : "with your hardware.");
1226 : 0 : PMD_INIT_LOG(ERR, "If you are experiencing problems "
1227 : : "please contact your Intel or hardware representative "
1228 : : "who provided you with this hardware.");
1229 [ # # ]: 0 : } else if (diag == IXGBE_ERR_SFP_NOT_SUPPORTED)
1230 : 0 : PMD_INIT_LOG(ERR, "Unsupported SFP+ Module");
1231 [ # # ]: 0 : if (diag) {
1232 : 0 : PMD_INIT_LOG(ERR, "Hardware Initialization Failure: %d", diag);
1233 : : ret = -EIO;
1234 : 0 : goto err_exit;
1235 : : }
1236 : :
1237 : : /* Reset the hw statistics */
1238 : 0 : ixgbe_dev_stats_reset(eth_dev);
1239 : :
1240 : : /* disable interrupt */
1241 : 0 : ixgbe_disable_intr(hw);
1242 : :
1243 : : /* reset mappings for queue statistics hw counters*/
1244 : : ixgbe_reset_qstat_mappings(hw);
1245 : :
1246 : : /* Allocate memory for storing MAC addresses */
1247 : 0 : eth_dev->data->mac_addrs = rte_zmalloc("ixgbe", RTE_ETHER_ADDR_LEN *
1248 : 0 : hw->mac.num_rar_entries, 0);
1249 [ # # ]: 0 : if (eth_dev->data->mac_addrs == NULL) {
1250 : 0 : PMD_INIT_LOG(ERR,
1251 : : "Failed to allocate %u bytes needed to store "
1252 : : "MAC addresses",
1253 : : RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1254 : : ret = -ENOMEM;
1255 : 0 : goto err_exit;
1256 : : }
1257 : : /* Copy the permanent MAC address */
1258 : : rte_ether_addr_copy((struct rte_ether_addr *)hw->mac.perm_addr,
1259 : : ð_dev->data->mac_addrs[0]);
1260 : :
1261 : : /* Allocate memory for storing hash filter MAC addresses */
1262 : 0 : eth_dev->data->hash_mac_addrs = rte_zmalloc(
1263 : : "ixgbe", RTE_ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC, 0);
1264 [ # # ]: 0 : if (eth_dev->data->hash_mac_addrs == NULL) {
1265 : 0 : PMD_INIT_LOG(ERR,
1266 : : "Failed to allocate %d bytes needed to store MAC addresses",
1267 : : RTE_ETHER_ADDR_LEN * IXGBE_VMDQ_NUM_UC_MAC);
1268 : 0 : rte_free(eth_dev->data->mac_addrs);
1269 : 0 : eth_dev->data->mac_addrs = NULL;
1270 : : ret = -ENOMEM;
1271 : 0 : goto err_exit;
1272 : : }
1273 : :
1274 : : /* initialize the vfta */
1275 : : memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1276 : :
1277 : : /* initialize the hw strip bitmap*/
1278 : : memset(hwstrip, 0, sizeof(*hwstrip));
1279 : :
1280 : : /* initialize PF if max_vfs not zero */
1281 : 0 : ret = ixgbe_pf_host_init(eth_dev);
1282 [ # # ]: 0 : if (ret)
1283 : 0 : goto err_pf_host_init;
1284 : :
1285 : 0 : ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
1286 : : /* let hardware know driver is loaded */
1287 : : ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
1288 : : /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1289 : 0 : ctrl_ext |= IXGBE_CTRL_EXT_PFRSTD;
1290 : 0 : IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
1291 : 0 : IXGBE_WRITE_FLUSH(hw);
1292 : :
1293 [ # # # # ]: 0 : if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present)
1294 : 0 : PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d, SFP+: %d",
1295 : : (int) hw->mac.type, (int) hw->phy.type,
1296 : : (int) hw->phy.sfp_type);
1297 : : else
1298 : 0 : PMD_INIT_LOG(DEBUG, "MAC: %d, PHY: %d",
1299 : : (int) hw->mac.type, (int) hw->phy.type);
1300 : :
1301 : 0 : PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x",
1302 : : eth_dev->data->port_id, pci_dev->id.vendor_id,
1303 : : pci_dev->id.device_id);
1304 : :
1305 : 0 : rte_intr_callback_register(intr_handle,
1306 : : ixgbe_dev_interrupt_handler, eth_dev);
1307 : :
1308 : : /* enable uio/vfio intr/eventfd mapping */
1309 : 0 : rte_intr_enable(intr_handle);
1310 : :
1311 : : /* enable support intr */
1312 : : ixgbe_enable_intr(eth_dev);
1313 : :
1314 : : /* initialize filter info */
1315 : : memset(filter_info, 0,
1316 : : sizeof(struct ixgbe_filter_info));
1317 : :
1318 : : /* initialize 5tuple filter list */
1319 : 0 : TAILQ_INIT(&filter_info->fivetuple_list);
1320 : :
1321 : : /* initialize flow director filter list & hash */
1322 : 0 : ret = ixgbe_fdir_filter_init(eth_dev);
1323 [ # # ]: 0 : if (ret)
1324 : 0 : goto err_fdir_filter_init;
1325 : :
1326 : : /* initialize l2 tunnel filter list & hash */
1327 : 0 : ret = ixgbe_l2_tn_filter_init(eth_dev);
1328 [ # # ]: 0 : if (ret)
1329 : 0 : goto err_l2_tn_filter_init;
1330 : :
1331 : : /* initialize flow filter lists */
1332 : 0 : ixgbe_filterlist_init();
1333 : :
1334 : : /* initialize bandwidth configuration info */
1335 : : memset(bw_conf, 0, sizeof(struct ixgbe_bw_conf));
1336 : :
1337 : : /* initialize Traffic Manager configuration */
1338 : 0 : ixgbe_tm_conf_init(eth_dev);
1339 : :
1340 : 0 : return 0;
1341 : :
1342 : : err_l2_tn_filter_init:
1343 : 0 : ixgbe_fdir_filter_uninit(eth_dev);
1344 : 0 : err_fdir_filter_init:
1345 : 0 : ixgbe_disable_intr(hw);
1346 : 0 : rte_intr_disable(intr_handle);
1347 : 0 : rte_intr_callback_unregister(intr_handle,
1348 : : ixgbe_dev_interrupt_handler, eth_dev);
1349 : 0 : ixgbe_pf_host_uninit(eth_dev);
1350 : 0 : err_pf_host_init:
1351 : 0 : rte_free(eth_dev->data->mac_addrs);
1352 : 0 : eth_dev->data->mac_addrs = NULL;
1353 : 0 : rte_free(eth_dev->data->hash_mac_addrs);
1354 : 0 : eth_dev->data->hash_mac_addrs = NULL;
1355 : 0 : err_exit:
1356 : : #ifdef RTE_LIB_SECURITY
1357 : 0 : rte_free(eth_dev->security_ctx);
1358 : 0 : eth_dev->security_ctx = NULL;
1359 : : #endif
1360 : 0 : return ret;
1361 : : }
1362 : :
1363 : : static int
1364 : 0 : eth_ixgbe_dev_uninit(struct rte_eth_dev *eth_dev)
1365 : : {
1366 : 0 : PMD_INIT_FUNC_TRACE();
1367 : :
1368 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1369 : : return 0;
1370 : :
1371 : 0 : ixgbe_dev_close(eth_dev);
1372 : :
1373 : 0 : return 0;
1374 : : }
1375 : :
1376 : 0 : static int ixgbe_ntuple_filter_uninit(struct rte_eth_dev *eth_dev)
1377 : : {
1378 : : struct ixgbe_filter_info *filter_info =
1379 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
1380 : : struct ixgbe_5tuple_filter *p_5tuple;
1381 : :
1382 [ # # ]: 0 : while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list))) {
1383 [ # # ]: 0 : TAILQ_REMOVE(&filter_info->fivetuple_list,
1384 : : p_5tuple,
1385 : : entries);
1386 : 0 : rte_free(p_5tuple);
1387 : : }
1388 : 0 : memset(filter_info->fivetuple_mask, 0,
1389 : : sizeof(uint32_t) * IXGBE_5TUPLE_ARRAY_SIZE);
1390 : :
1391 : 0 : return 0;
1392 : : }
1393 : :
1394 : 0 : static int ixgbe_fdir_filter_uninit(struct rte_eth_dev *eth_dev)
1395 : : {
1396 : : struct ixgbe_hw_fdir_info *fdir_info =
1397 : 0 : IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1398 : : struct ixgbe_fdir_filter *fdir_filter;
1399 : :
1400 : 0 : rte_free(fdir_info->hash_map);
1401 : 0 : rte_hash_free(fdir_info->hash_handle);
1402 : :
1403 [ # # ]: 0 : while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
1404 [ # # ]: 0 : TAILQ_REMOVE(&fdir_info->fdir_list,
1405 : : fdir_filter,
1406 : : entries);
1407 : 0 : rte_free(fdir_filter);
1408 : : }
1409 : :
1410 : 0 : return 0;
1411 : : }
1412 : :
1413 : 0 : static int ixgbe_l2_tn_filter_uninit(struct rte_eth_dev *eth_dev)
1414 : : {
1415 : : struct ixgbe_l2_tn_info *l2_tn_info =
1416 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1417 : : struct ixgbe_l2_tn_filter *l2_tn_filter;
1418 : :
1419 : 0 : rte_free(l2_tn_info->hash_map);
1420 : 0 : rte_hash_free(l2_tn_info->hash_handle);
1421 : :
1422 [ # # ]: 0 : while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
1423 [ # # ]: 0 : TAILQ_REMOVE(&l2_tn_info->l2_tn_list,
1424 : : l2_tn_filter,
1425 : : entries);
1426 : 0 : rte_free(l2_tn_filter);
1427 : : }
1428 : :
1429 : 0 : return 0;
1430 : : }
1431 : :
1432 : 0 : static int ixgbe_fdir_filter_init(struct rte_eth_dev *eth_dev)
1433 : : {
1434 : : struct ixgbe_hw_fdir_info *fdir_info =
1435 : 0 : IXGBE_DEV_PRIVATE_TO_FDIR_INFO(eth_dev->data->dev_private);
1436 : : char fdir_hash_name[RTE_HASH_NAMESIZE];
1437 : 0 : struct rte_hash_parameters fdir_hash_params = {
1438 : : .name = fdir_hash_name,
1439 : : .entries = IXGBE_MAX_FDIR_FILTER_NUM,
1440 : : .key_len = sizeof(union ixgbe_atr_input),
1441 : : .hash_func = rte_hash_crc,
1442 : : .hash_func_init_val = 0,
1443 : 0 : .socket_id = rte_socket_id(),
1444 : : };
1445 : :
1446 : 0 : TAILQ_INIT(&fdir_info->fdir_list);
1447 : 0 : snprintf(fdir_hash_name, RTE_HASH_NAMESIZE,
1448 : 0 : "fdir_%s", eth_dev->device->name);
1449 : 0 : fdir_info->hash_handle = rte_hash_create(&fdir_hash_params);
1450 [ # # ]: 0 : if (!fdir_info->hash_handle) {
1451 : 0 : PMD_INIT_LOG(ERR, "Failed to create fdir hash table!");
1452 : 0 : return -EINVAL;
1453 : : }
1454 : 0 : fdir_info->hash_map = rte_zmalloc("ixgbe",
1455 : : sizeof(struct ixgbe_fdir_filter *) *
1456 : : IXGBE_MAX_FDIR_FILTER_NUM,
1457 : : 0);
1458 [ # # ]: 0 : if (!fdir_info->hash_map) {
1459 : 0 : PMD_INIT_LOG(ERR,
1460 : : "Failed to allocate memory for fdir hash map!");
1461 : 0 : rte_hash_free(fdir_info->hash_handle);
1462 : 0 : return -ENOMEM;
1463 : : }
1464 : 0 : fdir_info->mask_added = FALSE;
1465 : :
1466 : 0 : return 0;
1467 : : }
1468 : :
1469 : 0 : static int ixgbe_l2_tn_filter_init(struct rte_eth_dev *eth_dev)
1470 : : {
1471 : : struct ixgbe_l2_tn_info *l2_tn_info =
1472 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(eth_dev->data->dev_private);
1473 : : char l2_tn_hash_name[RTE_HASH_NAMESIZE];
1474 : 0 : struct rte_hash_parameters l2_tn_hash_params = {
1475 : : .name = l2_tn_hash_name,
1476 : : .entries = IXGBE_MAX_L2_TN_FILTER_NUM,
1477 : : .key_len = sizeof(struct ixgbe_l2_tn_key),
1478 : : .hash_func = rte_hash_crc,
1479 : : .hash_func_init_val = 0,
1480 : 0 : .socket_id = rte_socket_id(),
1481 : : };
1482 : :
1483 : 0 : TAILQ_INIT(&l2_tn_info->l2_tn_list);
1484 : 0 : snprintf(l2_tn_hash_name, RTE_HASH_NAMESIZE,
1485 : 0 : "l2_tn_%s", eth_dev->device->name);
1486 : 0 : l2_tn_info->hash_handle = rte_hash_create(&l2_tn_hash_params);
1487 [ # # ]: 0 : if (!l2_tn_info->hash_handle) {
1488 : 0 : PMD_INIT_LOG(ERR, "Failed to create L2 TN hash table!");
1489 : 0 : return -EINVAL;
1490 : : }
1491 : 0 : l2_tn_info->hash_map = rte_zmalloc("ixgbe",
1492 : : sizeof(struct ixgbe_l2_tn_filter *) *
1493 : : IXGBE_MAX_L2_TN_FILTER_NUM,
1494 : : 0);
1495 [ # # ]: 0 : if (!l2_tn_info->hash_map) {
1496 : 0 : PMD_INIT_LOG(ERR,
1497 : : "Failed to allocate memory for L2 TN hash map!");
1498 : 0 : rte_hash_free(l2_tn_info->hash_handle);
1499 : 0 : return -ENOMEM;
1500 : : }
1501 : 0 : l2_tn_info->e_tag_en = FALSE;
1502 : 0 : l2_tn_info->e_tag_fwd_en = FALSE;
1503 : 0 : l2_tn_info->e_tag_ether_type = RTE_ETHER_TYPE_ETAG;
1504 : :
1505 : 0 : return 0;
1506 : : }
1507 : : /*
1508 : : * Negotiate mailbox API version with the PF.
1509 : : * After reset API version is always set to the basic one (ixgbe_mbox_api_10).
1510 : : * Then we try to negotiate starting with the most recent one.
1511 : : * If all negotiation attempts fail, then we will proceed with
1512 : : * the default one (ixgbe_mbox_api_10).
1513 : : */
1514 : : static void
1515 : 0 : ixgbevf_negotiate_api(struct ixgbe_hw *hw)
1516 : : {
1517 : : int32_t i;
1518 : :
1519 : : /* start with highest supported, proceed down */
1520 : : static const enum ixgbe_pfvf_api_rev sup_ver[] = {
1521 : : ixgbe_mbox_api_13,
1522 : : ixgbe_mbox_api_12,
1523 : : ixgbe_mbox_api_11,
1524 : : ixgbe_mbox_api_10,
1525 : : };
1526 : :
1527 : 0 : for (i = 0;
1528 [ # # # # ]: 0 : i != RTE_DIM(sup_ver) &&
1529 : 0 : ixgbevf_negotiate_api_version(hw, sup_ver[i]) != 0;
1530 : 0 : i++)
1531 : : ;
1532 : 0 : }
1533 : :
1534 : : static void
1535 : 0 : generate_random_mac_addr(struct rte_ether_addr *mac_addr)
1536 : : {
1537 : : uint64_t random;
1538 : :
1539 : : /* Set Organizationally Unique Identifier (OUI) prefix. */
1540 : : mac_addr->addr_bytes[0] = 0x00;
1541 : 0 : mac_addr->addr_bytes[1] = 0x09;
1542 : 0 : mac_addr->addr_bytes[2] = 0xC0;
1543 : : /* Force indication of locally assigned MAC address. */
1544 : 0 : mac_addr->addr_bytes[0] |= RTE_ETHER_LOCAL_ADMIN_ADDR;
1545 : : /* Generate the last 3 bytes of the MAC address with a random number. */
1546 : 0 : random = rte_rand();
1547 : 0 : memcpy(&mac_addr->addr_bytes[3], &random, 3);
1548 : 0 : }
1549 : :
1550 : : static int
1551 : 0 : devarg_handle_int(__rte_unused const char *key, const char *value,
1552 : : void *extra_args)
1553 : : {
1554 : : uint16_t *n = extra_args;
1555 : :
1556 [ # # ]: 0 : if (value == NULL || extra_args == NULL)
1557 : : return -EINVAL;
1558 : :
1559 : 0 : *n = (uint16_t)strtoul(value, NULL, 0);
1560 [ # # # # ]: 0 : if (*n == USHRT_MAX && errno == ERANGE)
1561 : 0 : return -1;
1562 : :
1563 : : return 0;
1564 : : }
1565 : :
1566 : : static void
1567 : 0 : ixgbevf_parse_devargs(struct ixgbe_adapter *adapter,
1568 : : struct rte_devargs *devargs)
1569 : : {
1570 : : struct rte_kvargs *kvlist;
1571 : : uint16_t pflink_fullchk;
1572 : :
1573 [ # # ]: 0 : if (devargs == NULL)
1574 : 0 : return;
1575 : :
1576 : 0 : kvlist = rte_kvargs_parse(devargs->args, ixgbevf_valid_arguments);
1577 [ # # ]: 0 : if (kvlist == NULL)
1578 : : return;
1579 : :
1580 [ # # # # ]: 0 : if (rte_kvargs_count(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK) == 1 &&
1581 : 0 : rte_kvargs_process(kvlist, IXGBEVF_DEVARG_PFLINK_FULLCHK,
1582 : 0 : devarg_handle_int, &pflink_fullchk) == 0 &&
1583 [ # # ]: 0 : pflink_fullchk == 1)
1584 : 0 : adapter->pflink_fullchk = 1;
1585 : :
1586 : 0 : rte_kvargs_free(kvlist);
1587 : : }
1588 : :
1589 : : /*
1590 : : * Virtual Function device init
1591 : : */
1592 : : static int
1593 : 0 : eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev)
1594 : : {
1595 : : int diag;
1596 : : uint32_t tc, tcs;
1597 : 0 : struct ixgbe_adapter *ad = eth_dev->data->dev_private;
1598 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
1599 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1600 : 0 : struct ixgbe_hw *hw =
1601 : : IXGBE_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
1602 : 0 : struct ixgbe_vfta *shadow_vfta =
1603 : : IXGBE_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
1604 : 0 : struct ixgbe_hwstrip *hwstrip =
1605 : : IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(eth_dev->data->dev_private);
1606 : 0 : struct rte_ether_addr *perm_addr =
1607 : : (struct rte_ether_addr *)hw->mac.perm_addr;
1608 : :
1609 : 0 : PMD_INIT_FUNC_TRACE();
1610 : :
1611 : 0 : eth_dev->dev_ops = &ixgbevf_eth_dev_ops;
1612 : 0 : eth_dev->rx_descriptor_status = ixgbe_dev_rx_descriptor_status;
1613 : 0 : eth_dev->tx_descriptor_status = ixgbe_dev_tx_descriptor_status;
1614 : 0 : eth_dev->rx_pkt_burst = &ixgbe_recv_pkts;
1615 : 0 : eth_dev->tx_pkt_burst = &ixgbe_xmit_pkts;
1616 : :
1617 : : /* for secondary processes, we don't initialise any further as primary
1618 : : * has already done this work. Only check we don't need a different
1619 : : * RX function
1620 : : */
1621 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
1622 : : struct ixgbe_tx_queue *txq;
1623 : : /* TX queue function in primary, set by last queue initialized
1624 : : * Tx queue may not initialized by primary process
1625 : : */
1626 [ # # ]: 0 : if (eth_dev->data->tx_queues) {
1627 : 0 : txq = eth_dev->data->tx_queues[eth_dev->data->nb_tx_queues - 1];
1628 : 0 : ixgbe_set_tx_function(eth_dev, txq);
1629 : : } else {
1630 : : /* Use default TX function if we get here */
1631 : 0 : PMD_INIT_LOG(NOTICE,
1632 : : "No TX queues configured yet. Using default TX function.");
1633 : : }
1634 : :
1635 : 0 : ixgbe_set_rx_function(eth_dev);
1636 : :
1637 : 0 : return 0;
1638 : : }
1639 : :
1640 : : /* NOTE: review for potential ordering optimization */
1641 : 0 : __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST);
1642 : 0 : ixgbevf_parse_devargs(eth_dev->data->dev_private,
1643 : : pci_dev->device.devargs);
1644 : :
1645 : 0 : rte_eth_copy_pci_info(eth_dev, pci_dev);
1646 : 0 : eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
1647 : :
1648 : 0 : hw->device_id = pci_dev->id.device_id;
1649 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
1650 : 0 : hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
1651 : :
1652 : : /* initialize the vfta */
1653 : : memset(shadow_vfta, 0, sizeof(*shadow_vfta));
1654 : :
1655 : : /* initialize the hw strip bitmap*/
1656 : : memset(hwstrip, 0, sizeof(*hwstrip));
1657 : :
1658 : : /* Initialize the shared code (base driver) */
1659 : 0 : diag = ixgbe_init_shared_code(hw);
1660 [ # # ]: 0 : if (diag != IXGBE_SUCCESS) {
1661 : 0 : PMD_INIT_LOG(ERR, "Shared code init failed for ixgbevf: %d", diag);
1662 : 0 : return -EIO;
1663 : : }
1664 : :
1665 : : /* init_mailbox_params */
1666 : 0 : hw->mbx.ops.init_params(hw);
1667 : :
1668 : : /* Reset the hw statistics */
1669 : : ixgbevf_dev_stats_reset(eth_dev);
1670 : :
1671 : : /* Disable the interrupts for VF */
1672 : 0 : ixgbevf_intr_disable(eth_dev);
1673 : :
1674 : 0 : hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
1675 : 0 : diag = hw->mac.ops.reset_hw(hw);
1676 : :
1677 : : /*
1678 : : * The VF reset operation returns the IXGBE_ERR_INVALID_MAC_ADDR when
1679 : : * the underlying PF driver has not assigned a MAC address to the VF.
1680 : : * In this case, assign a random MAC address.
1681 : : */
1682 [ # # ]: 0 : if ((diag != IXGBE_SUCCESS) && (diag != IXGBE_ERR_INVALID_MAC_ADDR)) {
1683 : 0 : PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1684 : : /*
1685 : : * This error code will be propagated to the app by
1686 : : * rte_eth_dev_reset, so use a public error code rather than
1687 : : * the internal-only IXGBE_ERR_RESET_FAILED
1688 : : */
1689 : 0 : return -EAGAIN;
1690 : : }
1691 : :
1692 : : /* negotiate mailbox API version to use with the PF. */
1693 : 0 : ixgbevf_negotiate_api(hw);
1694 : :
1695 : : /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
1696 : 0 : ixgbevf_get_queues(hw, &tcs, &tc);
1697 : :
1698 : : /* Allocate memory for storing MAC addresses */
1699 : 0 : eth_dev->data->mac_addrs = rte_zmalloc("ixgbevf", RTE_ETHER_ADDR_LEN *
1700 : 0 : hw->mac.num_rar_entries, 0);
1701 [ # # ]: 0 : if (eth_dev->data->mac_addrs == NULL) {
1702 : 0 : PMD_INIT_LOG(ERR,
1703 : : "Failed to allocate %u bytes needed to store "
1704 : : "MAC addresses",
1705 : : RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
1706 : 0 : return -ENOMEM;
1707 : : }
1708 : :
1709 : : /* Generate a random MAC address, if none was assigned by PF. */
1710 [ # # ]: 0 : if (rte_is_zero_ether_addr(perm_addr)) {
1711 : 0 : generate_random_mac_addr(perm_addr);
1712 : 0 : diag = ixgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
1713 [ # # ]: 0 : if (diag) {
1714 : 0 : rte_free(eth_dev->data->mac_addrs);
1715 : 0 : eth_dev->data->mac_addrs = NULL;
1716 : 0 : return diag;
1717 : : }
1718 : 0 : PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
1719 : 0 : PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
1720 : : RTE_ETHER_ADDR_PRT_FMT,
1721 : : RTE_ETHER_ADDR_BYTES(perm_addr));
1722 : : }
1723 : :
1724 : : /* Copy the permanent MAC address */
1725 : 0 : rte_ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
1726 : :
1727 : : /* reset the hardware with the new settings */
1728 : 0 : diag = hw->mac.ops.start_hw(hw);
1729 [ # # ]: 0 : switch (diag) {
1730 : : case 0:
1731 : : break;
1732 : :
1733 : 0 : default:
1734 : 0 : PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", diag);
1735 : 0 : rte_free(eth_dev->data->mac_addrs);
1736 : 0 : eth_dev->data->mac_addrs = NULL;
1737 : 0 : return -EIO;
1738 : : }
1739 : :
1740 : 0 : rte_intr_callback_register(intr_handle,
1741 : : ixgbevf_dev_interrupt_handler, eth_dev);
1742 : 0 : rte_intr_enable(intr_handle);
1743 : 0 : ixgbevf_intr_enable(eth_dev);
1744 : :
1745 : 0 : PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
1746 : : eth_dev->data->port_id, pci_dev->id.vendor_id,
1747 : : pci_dev->id.device_id, "ixgbe_mac_82599_vf");
1748 : :
1749 : 0 : return 0;
1750 : : }
1751 : :
1752 : : /* Virtual Function device uninit */
1753 : :
1754 : : static int
1755 : 0 : eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
1756 : : {
1757 : 0 : PMD_INIT_FUNC_TRACE();
1758 : :
1759 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1760 : : return 0;
1761 : :
1762 : 0 : ixgbevf_dev_close(eth_dev);
1763 : :
1764 : 0 : return 0;
1765 : : }
1766 : :
1767 : : static int
1768 : 0 : eth_ixgbe_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1769 : : struct rte_pci_device *pci_dev)
1770 : : {
1771 : : char name[RTE_ETH_NAME_MAX_LEN];
1772 : : struct rte_eth_dev *pf_ethdev;
1773 : : struct rte_eth_devargs eth_da;
1774 : : int i, retval;
1775 : :
1776 [ # # ]: 0 : if (pci_dev->device.devargs) {
1777 : 0 : retval = rte_eth_devargs_parse(pci_dev->device.devargs->args,
1778 : : ð_da, 1);
1779 [ # # ]: 0 : if (retval < 0)
1780 : : return retval;
1781 : : } else
1782 : : memset(ð_da, 0, sizeof(eth_da));
1783 : :
1784 [ # # ]: 0 : if (eth_da.nb_representor_ports > 0 &&
1785 [ # # ]: 0 : eth_da.type != RTE_ETH_REPRESENTOR_VF) {
1786 : 0 : PMD_DRV_LOG(ERR, "unsupported representor type: %s\n",
1787 : : pci_dev->device.devargs->args);
1788 : 0 : return -ENOTSUP;
1789 : : }
1790 : :
1791 : 0 : retval = rte_eth_dev_create(&pci_dev->device, pci_dev->device.name,
1792 : : sizeof(struct ixgbe_adapter),
1793 : : eth_dev_pci_specific_init, pci_dev,
1794 : : eth_ixgbe_dev_init, NULL);
1795 : :
1796 [ # # # # ]: 0 : if (retval || eth_da.nb_representor_ports < 1)
1797 : : return retval;
1798 : :
1799 : 0 : pf_ethdev = rte_eth_dev_allocated(pci_dev->device.name);
1800 [ # # ]: 0 : if (pf_ethdev == NULL)
1801 : : return -ENODEV;
1802 : :
1803 : : /* probe VF representor ports */
1804 [ # # ]: 0 : for (i = 0; i < eth_da.nb_representor_ports; i++) {
1805 : : struct ixgbe_vf_info *vfinfo;
1806 : : struct ixgbe_vf_representor representor;
1807 : :
1808 : 0 : vfinfo = *IXGBE_DEV_PRIVATE_TO_P_VFDATA(
1809 : : pf_ethdev->data->dev_private);
1810 [ # # ]: 0 : if (vfinfo == NULL) {
1811 : 0 : PMD_DRV_LOG(ERR,
1812 : : "no virtual functions supported by PF");
1813 : 0 : break;
1814 : : }
1815 : :
1816 : 0 : representor.vf_id = eth_da.representor_ports[i];
1817 : 0 : representor.switch_domain_id = vfinfo->switch_domain_id;
1818 : 0 : representor.pf_ethdev = pf_ethdev;
1819 : :
1820 : : /* representor port net_bdf_port */
1821 : 0 : snprintf(name, sizeof(name), "net_%s_representor_%d",
1822 : : pci_dev->device.name,
1823 : : eth_da.representor_ports[i]);
1824 : :
1825 : 0 : retval = rte_eth_dev_create(&pci_dev->device, name,
1826 : : sizeof(struct ixgbe_vf_representor), NULL, NULL,
1827 : : ixgbe_vf_representor_init, &representor);
1828 : :
1829 [ # # ]: 0 : if (retval)
1830 : 0 : PMD_DRV_LOG(ERR, "failed to create ixgbe vf "
1831 : : "representor %s.", name);
1832 : : }
1833 : :
1834 : : return 0;
1835 : : }
1836 : :
1837 : 0 : static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
1838 : : {
1839 : : struct rte_eth_dev *ethdev;
1840 : :
1841 : 0 : ethdev = rte_eth_dev_allocated(pci_dev->device.name);
1842 [ # # ]: 0 : if (!ethdev)
1843 : : return 0;
1844 : :
1845 [ # # ]: 0 : if (rte_eth_dev_is_repr(ethdev))
1846 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev,
1847 : : ixgbe_vf_representor_uninit);
1848 : : else
1849 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev,
1850 : : eth_ixgbe_dev_uninit);
1851 : : }
1852 : :
1853 : : static struct rte_pci_driver rte_ixgbe_pmd = {
1854 : : .id_table = pci_id_ixgbe_map,
1855 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC,
1856 : : .probe = eth_ixgbe_pci_probe,
1857 : : .remove = eth_ixgbe_pci_remove,
1858 : : };
1859 : :
1860 : 0 : static int eth_ixgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
1861 : : struct rte_pci_device *pci_dev)
1862 : : {
1863 : 0 : return rte_eth_dev_pci_generic_probe(pci_dev,
1864 : : sizeof(struct ixgbe_adapter), eth_ixgbevf_dev_init);
1865 : : }
1866 : :
1867 : 0 : static int eth_ixgbevf_pci_remove(struct rte_pci_device *pci_dev)
1868 : : {
1869 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev, eth_ixgbevf_dev_uninit);
1870 : : }
1871 : :
1872 : : /*
1873 : : * virtual function driver struct
1874 : : */
1875 : : static struct rte_pci_driver rte_ixgbevf_pmd = {
1876 : : .id_table = pci_id_ixgbevf_map,
1877 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
1878 : : .probe = eth_ixgbevf_pci_probe,
1879 : : .remove = eth_ixgbevf_pci_remove,
1880 : : };
1881 : :
1882 : : static int
1883 : 0 : ixgbe_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1884 : : {
1885 : : struct ixgbe_hw *hw =
1886 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1887 : : struct ixgbe_vfta *shadow_vfta =
1888 : : IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1889 : : uint32_t vfta;
1890 : : uint32_t vid_idx;
1891 : : uint32_t vid_bit;
1892 : :
1893 : 0 : vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1894 : 0 : vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1895 : 0 : vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(vid_idx));
1896 [ # # ]: 0 : if (on)
1897 : 0 : vfta |= vid_bit;
1898 : : else
1899 : 0 : vfta &= ~vid_bit;
1900 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTA(vid_idx), vfta);
1901 : :
1902 : : /* update local VFTA copy */
1903 : 0 : shadow_vfta->vfta[vid_idx] = vfta;
1904 : :
1905 : 0 : return 0;
1906 : : }
1907 : :
1908 : : static void
1909 : 0 : ixgbe_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
1910 : : {
1911 [ # # ]: 0 : if (on)
1912 : 0 : ixgbe_vlan_hw_strip_enable(dev, queue);
1913 : : else
1914 : 0 : ixgbe_vlan_hw_strip_disable(dev, queue);
1915 : 0 : }
1916 : :
1917 : : static int
1918 : 0 : ixgbe_vlan_tpid_set(struct rte_eth_dev *dev,
1919 : : enum rte_vlan_type vlan_type,
1920 : : uint16_t tpid)
1921 : : {
1922 : : struct ixgbe_hw *hw =
1923 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1924 : : int ret = 0;
1925 : : uint32_t reg;
1926 : : uint32_t qinq;
1927 : :
1928 : 0 : qinq = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1929 : 0 : qinq &= IXGBE_DMATXCTL_GDV;
1930 : :
1931 [ # # # ]: 0 : switch (vlan_type) {
1932 : 0 : case RTE_ETH_VLAN_TYPE_INNER:
1933 [ # # ]: 0 : if (qinq) {
1934 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1935 : 0 : reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1936 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1937 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1938 : 0 : reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1939 : 0 : | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1940 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1941 : : } else {
1942 : : ret = -ENOTSUP;
1943 : 0 : PMD_DRV_LOG(ERR, "Inner type is not supported"
1944 : : " by single VLAN");
1945 : : }
1946 : : break;
1947 : 0 : case RTE_ETH_VLAN_TYPE_OUTER:
1948 [ # # ]: 0 : if (qinq) {
1949 : : /* Only the high 16-bits is valid */
1950 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EXVET, (uint32_t)tpid <<
1951 : : IXGBE_EXVET_VET_EXT_SHIFT);
1952 : : } else {
1953 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1954 : 0 : reg = (reg & (~IXGBE_VLNCTRL_VET)) | (uint32_t)tpid;
1955 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, reg);
1956 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1957 : 0 : reg = (reg & (~IXGBE_DMATXCTL_VT_MASK))
1958 : 0 : | ((uint32_t)tpid << IXGBE_DMATXCTL_VT_SHIFT);
1959 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1960 : : }
1961 : :
1962 : : break;
1963 : 0 : default:
1964 : : ret = -EINVAL;
1965 : 0 : PMD_DRV_LOG(ERR, "Unsupported VLAN type %d", vlan_type);
1966 : 0 : break;
1967 : : }
1968 : :
1969 : 0 : return ret;
1970 : : }
1971 : :
1972 : : void
1973 : 0 : ixgbe_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1974 : : {
1975 : : struct ixgbe_hw *hw =
1976 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1977 : : uint32_t vlnctrl;
1978 : :
1979 : 0 : PMD_INIT_FUNC_TRACE();
1980 : :
1981 : : /* Filter Table Disable */
1982 : 0 : vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
1983 : 0 : vlnctrl &= ~IXGBE_VLNCTRL_VFE;
1984 : :
1985 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
1986 : 0 : }
1987 : :
1988 : : void
1989 : 0 : ixgbe_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1990 : : {
1991 : : struct ixgbe_hw *hw =
1992 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1993 : : struct ixgbe_vfta *shadow_vfta =
1994 : : IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1995 : : uint32_t vlnctrl;
1996 : : uint16_t i;
1997 : :
1998 : 0 : PMD_INIT_FUNC_TRACE();
1999 : :
2000 : : /* Filter Table Enable */
2001 : 0 : vlnctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2002 : 0 : vlnctrl &= ~IXGBE_VLNCTRL_CFIEN;
2003 : 0 : vlnctrl |= IXGBE_VLNCTRL_VFE;
2004 : :
2005 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
2006 : :
2007 : : /* write whatever is in local vfta copy */
2008 [ # # ]: 0 : for (i = 0; i < IXGBE_VFTA_SIZE; i++)
2009 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFTA(i), shadow_vfta->vfta[i]);
2010 : 0 : }
2011 : :
2012 : : static void
2013 : 0 : ixgbe_vlan_hw_strip_bitmap_set(struct rte_eth_dev *dev, uint16_t queue, bool on)
2014 : : {
2015 : : struct ixgbe_hwstrip *hwstrip =
2016 : 0 : IXGBE_DEV_PRIVATE_TO_HWSTRIP_BITMAP(dev->data->dev_private);
2017 : : struct ixgbe_rx_queue *rxq;
2018 : :
2019 [ # # ]: 0 : if (queue >= IXGBE_MAX_RX_QUEUE_NUM)
2020 : : return;
2021 : :
2022 [ # # ]: 0 : if (on)
2023 : 0 : IXGBE_SET_HWSTRIP(hwstrip, queue);
2024 : : else
2025 : 0 : IXGBE_CLEAR_HWSTRIP(hwstrip, queue);
2026 : :
2027 [ # # ]: 0 : if (queue >= dev->data->nb_rx_queues)
2028 : : return;
2029 : :
2030 : 0 : rxq = dev->data->rx_queues[queue];
2031 : :
2032 [ # # ]: 0 : if (on) {
2033 : 0 : rxq->vlan_flags = RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
2034 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
2035 : : } else {
2036 : 0 : rxq->vlan_flags = RTE_MBUF_F_RX_VLAN;
2037 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
2038 : : }
2039 : : }
2040 : :
2041 : : static void
2042 : 0 : ixgbe_vlan_hw_strip_disable(struct rte_eth_dev *dev, uint16_t queue)
2043 : : {
2044 : : struct ixgbe_hw *hw =
2045 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2046 : : uint32_t ctrl;
2047 : :
2048 : 0 : PMD_INIT_FUNC_TRACE();
2049 : :
2050 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
2051 : : /* No queue level support */
2052 : 0 : PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2053 : 0 : return;
2054 : : }
2055 : :
2056 : : /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2057 [ # # ]: 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2058 : 0 : ctrl &= ~IXGBE_RXDCTL_VME;
2059 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2060 : :
2061 : : /* record those setting for HW strip per queue */
2062 : 0 : ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 0);
2063 : : }
2064 : :
2065 : : static void
2066 : 0 : ixgbe_vlan_hw_strip_enable(struct rte_eth_dev *dev, uint16_t queue)
2067 : : {
2068 : : struct ixgbe_hw *hw =
2069 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2070 : : uint32_t ctrl;
2071 : :
2072 : 0 : PMD_INIT_FUNC_TRACE();
2073 : :
2074 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
2075 : : /* No queue level supported */
2076 : 0 : PMD_INIT_LOG(NOTICE, "82598EB not support queue level hw strip");
2077 : 0 : return;
2078 : : }
2079 : :
2080 : : /* Other 10G NIC, the VLAN strip can be setup per queue in RXDCTL */
2081 [ # # ]: 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
2082 : 0 : ctrl |= IXGBE_RXDCTL_VME;
2083 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
2084 : :
2085 : : /* record those setting for HW strip per queue */
2086 : 0 : ixgbe_vlan_hw_strip_bitmap_set(dev, queue, 1);
2087 : : }
2088 : :
2089 : : static void
2090 : 0 : ixgbe_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2091 : : {
2092 : : struct ixgbe_hw *hw =
2093 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2094 : : uint32_t ctrl;
2095 : :
2096 : 0 : PMD_INIT_FUNC_TRACE();
2097 : :
2098 : : /* DMATXCTRL: Geric Double VLAN Disable */
2099 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2100 : 0 : ctrl &= ~IXGBE_DMATXCTL_GDV;
2101 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2102 : :
2103 : : /* CTRL_EXT: Global Double VLAN Disable */
2104 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2105 : 0 : ctrl &= ~IXGBE_EXTENDED_VLAN;
2106 : 0 : IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2107 : :
2108 : 0 : }
2109 : :
2110 : : static void
2111 : 0 : ixgbe_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2112 : : {
2113 : : struct ixgbe_hw *hw =
2114 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2115 : : uint32_t ctrl;
2116 : :
2117 : 0 : PMD_INIT_FUNC_TRACE();
2118 : :
2119 : : /* DMATXCTRL: Geric Double VLAN Enable */
2120 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
2121 : 0 : ctrl |= IXGBE_DMATXCTL_GDV;
2122 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, ctrl);
2123 : :
2124 : : /* CTRL_EXT: Global Double VLAN Enable */
2125 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
2126 : 0 : ctrl |= IXGBE_EXTENDED_VLAN;
2127 : 0 : IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl);
2128 : :
2129 : : /* Clear pooling mode of PFVTCTL. It's required by X550. */
2130 : 0 : if (hw->mac.type == ixgbe_mac_X550 ||
2131 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550EM_x ||
2132 : : hw->mac.type == ixgbe_mac_X550EM_a) {
2133 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
2134 : 0 : ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
2135 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
2136 : : }
2137 : :
2138 : : /*
2139 : : * VET EXT field in the EXVET register = 0x8100 by default
2140 : : * So no need to change. Same to VT field of DMATXCTL register
2141 : : */
2142 : 0 : }
2143 : :
2144 : : void
2145 : 0 : ixgbe_vlan_hw_strip_config(struct rte_eth_dev *dev)
2146 : : {
2147 : : struct ixgbe_hw *hw =
2148 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2149 : : struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
2150 : : uint32_t ctrl;
2151 : : uint16_t i;
2152 : : struct ixgbe_rx_queue *rxq;
2153 : : bool on;
2154 : :
2155 : 0 : PMD_INIT_FUNC_TRACE();
2156 : :
2157 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
2158 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
2159 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2160 : 0 : ctrl |= IXGBE_VLNCTRL_VME;
2161 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2162 : : } else {
2163 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2164 : 0 : ctrl &= ~IXGBE_VLNCTRL_VME;
2165 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, ctrl);
2166 : : }
2167 : : } else {
2168 : : /*
2169 : : * Other 10G NIC, the VLAN strip can be setup
2170 : : * per queue in RXDCTL
2171 : : */
2172 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2173 : 0 : rxq = dev->data->rx_queues[i];
2174 [ # # ]: 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(rxq->reg_idx));
2175 [ # # ]: 0 : if (rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
2176 : 0 : ctrl |= IXGBE_RXDCTL_VME;
2177 : : on = TRUE;
2178 : : } else {
2179 : 0 : ctrl &= ~IXGBE_RXDCTL_VME;
2180 : : on = FALSE;
2181 : : }
2182 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(rxq->reg_idx), ctrl);
2183 : :
2184 : : /* record those setting for HW strip per queue */
2185 : 0 : ixgbe_vlan_hw_strip_bitmap_set(dev, i, on);
2186 : : }
2187 : : }
2188 : 0 : }
2189 : :
2190 : : static void
2191 : 0 : ixgbe_config_vlan_strip_on_all_queues(struct rte_eth_dev *dev, int mask)
2192 : : {
2193 : : uint16_t i;
2194 : : struct rte_eth_rxmode *rxmode;
2195 : : struct ixgbe_rx_queue *rxq;
2196 : :
2197 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
2198 : 0 : rxmode = &dev->data->dev_conf.rxmode;
2199 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
2200 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2201 : 0 : rxq = dev->data->rx_queues[i];
2202 : 0 : rxq->offloads |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
2203 : : }
2204 : : else
2205 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
2206 : 0 : rxq = dev->data->rx_queues[i];
2207 : 0 : rxq->offloads &= ~RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
2208 : : }
2209 : : }
2210 : 0 : }
2211 : :
2212 : : static int
2213 : 0 : ixgbe_vlan_offload_config(struct rte_eth_dev *dev, int mask)
2214 : : {
2215 : : struct rte_eth_rxmode *rxmode;
2216 : 0 : rxmode = &dev->data->dev_conf.rxmode;
2217 : :
2218 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK)
2219 : 0 : ixgbe_vlan_hw_strip_config(dev);
2220 : :
2221 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_FILTER_MASK) {
2222 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
2223 : 0 : ixgbe_vlan_hw_filter_enable(dev);
2224 : : else
2225 : 0 : ixgbe_vlan_hw_filter_disable(dev);
2226 : : }
2227 : :
2228 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
2229 [ # # ]: 0 : if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_EXTEND)
2230 : 0 : ixgbe_vlan_hw_extend_enable(dev);
2231 : : else
2232 : 0 : ixgbe_vlan_hw_extend_disable(dev);
2233 : : }
2234 : :
2235 : 0 : return 0;
2236 : : }
2237 : :
2238 : : static int
2239 : 0 : ixgbe_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2240 : : {
2241 : 0 : ixgbe_config_vlan_strip_on_all_queues(dev, mask);
2242 : :
2243 : 0 : ixgbe_vlan_offload_config(dev, mask);
2244 : :
2245 : 0 : return 0;
2246 : : }
2247 : :
2248 : : static void
2249 : : ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2250 : : {
2251 : : struct ixgbe_hw *hw =
2252 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2253 : : /* VLNCTRL: enable vlan filtering and allow all vlan tags through */
2254 : 0 : uint32_t vlanctrl = IXGBE_READ_REG(hw, IXGBE_VLNCTRL);
2255 : :
2256 : 0 : vlanctrl |= IXGBE_VLNCTRL_VFE; /* enable vlan filters */
2257 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlanctrl);
2258 : 0 : }
2259 : :
2260 : : static int
2261 : : ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev *dev, uint16_t nb_rx_q)
2262 : : {
2263 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2264 : :
2265 [ # # # ]: 0 : switch (nb_rx_q) {
2266 : 0 : case 1:
2267 : : case 2:
2268 : 0 : RTE_ETH_DEV_SRIOV(dev).active = RTE_ETH_64_POOLS;
2269 : 0 : break;
2270 : 0 : case 4:
2271 : 0 : RTE_ETH_DEV_SRIOV(dev).active = RTE_ETH_32_POOLS;
2272 : 0 : break;
2273 : : default:
2274 : : return -EINVAL;
2275 : : }
2276 : :
2277 : 0 : RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool =
2278 : 0 : IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2279 : 0 : RTE_ETH_DEV_SRIOV(dev).def_pool_q_idx =
2280 : 0 : pci_dev->max_vfs * RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2281 : : return 0;
2282 : : }
2283 : :
2284 : : static int
2285 : 0 : ixgbe_check_mq_mode(struct rte_eth_dev *dev)
2286 : : {
2287 : 0 : struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
2288 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2289 : 0 : uint16_t nb_rx_q = dev->data->nb_rx_queues;
2290 : 0 : uint16_t nb_tx_q = dev->data->nb_tx_queues;
2291 : :
2292 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
2293 : : /* check multi-queue mode */
2294 [ # # # # : 0 : switch (dev_conf->rxmode.mq_mode) {
# ]
2295 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB:
2296 : 0 : PMD_INIT_LOG(INFO, "RTE_ETH_MQ_RX_VMDQ_DCB mode supported in SRIOV");
2297 : 0 : break;
2298 : 0 : case RTE_ETH_MQ_RX_VMDQ_DCB_RSS:
2299 : : /* DCB/RSS VMDQ in SRIOV mode, not implement yet */
2300 : 0 : PMD_INIT_LOG(ERR, "SRIOV active,"
2301 : : " unsupported mq_mode rx %d.",
2302 : : dev_conf->rxmode.mq_mode);
2303 : 0 : return -EINVAL;
2304 : 0 : case RTE_ETH_MQ_RX_RSS:
2305 : : case RTE_ETH_MQ_RX_VMDQ_RSS:
2306 : 0 : dev->data->dev_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_VMDQ_RSS;
2307 [ # # ]: 0 : if (nb_rx_q <= RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)
2308 : : if (ixgbe_check_vf_rss_rxq_num(dev, nb_rx_q)) {
2309 : 0 : PMD_INIT_LOG(ERR, "SRIOV is active,"
2310 : : " invalid queue number"
2311 : : " for VMDQ RSS, allowed"
2312 : : " value are 1, 2 or 4.");
2313 : 0 : return -EINVAL;
2314 : : }
2315 : : break;
2316 : 0 : case RTE_ETH_MQ_RX_VMDQ_ONLY:
2317 : : case RTE_ETH_MQ_RX_NONE:
2318 : : /* if nothing mq mode configure, use default scheme */
2319 : 0 : dev->data->dev_conf.rxmode.mq_mode = RTE_ETH_MQ_RX_VMDQ_ONLY;
2320 : 0 : break;
2321 : 0 : default: /* RTE_ETH_MQ_RX_DCB, RTE_ETH_MQ_RX_DCB_RSS or RTE_ETH_MQ_TX_DCB*/
2322 : : /* SRIOV only works in VMDq enable mode */
2323 : 0 : PMD_INIT_LOG(ERR, "SRIOV is active,"
2324 : : " wrong mq_mode rx %d.",
2325 : : dev_conf->rxmode.mq_mode);
2326 : 0 : return -EINVAL;
2327 : : }
2328 : :
2329 [ # # ]: 0 : switch (dev_conf->txmode.mq_mode) {
2330 : 0 : case RTE_ETH_MQ_TX_VMDQ_DCB:
2331 : 0 : PMD_INIT_LOG(INFO, "RTE_ETH_MQ_TX_VMDQ_DCB mode supported in SRIOV");
2332 : 0 : dev->data->dev_conf.txmode.mq_mode = RTE_ETH_MQ_TX_VMDQ_DCB;
2333 : 0 : break;
2334 : 0 : default: /* RTE_ETH_MQ_TX_VMDQ_ONLY or RTE_ETH_MQ_TX_NONE */
2335 : 0 : dev->data->dev_conf.txmode.mq_mode = RTE_ETH_MQ_TX_VMDQ_ONLY;
2336 : 0 : break;
2337 : : }
2338 : :
2339 : : /* check valid queue number */
2340 [ # # # # ]: 0 : if ((nb_rx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool) ||
2341 : : (nb_tx_q > RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool)) {
2342 : 0 : PMD_INIT_LOG(ERR, "SRIOV is active,"
2343 : : " nb_rx_q=%d nb_tx_q=%d queue number"
2344 : : " must be less than or equal to %d.",
2345 : : nb_rx_q, nb_tx_q,
2346 : : RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool);
2347 : 0 : return -EINVAL;
2348 : : }
2349 : : } else {
2350 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB_RSS) {
2351 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB+RSS mq_mode is"
2352 : : " not supported.");
2353 : 0 : return -EINVAL;
2354 : : }
2355 : : /* check configuration for vmdb+dcb mode */
2356 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_DCB) {
2357 : : const struct rte_eth_vmdq_dcb_conf *conf;
2358 : :
2359 [ # # ]: 0 : if (nb_rx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2360 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_rx_q != %d.",
2361 : : IXGBE_VMDQ_DCB_NB_QUEUES);
2362 : 0 : return -EINVAL;
2363 : : }
2364 : : conf = &dev_conf->rx_adv_conf.vmdq_dcb_conf;
2365 [ # # ]: 0 : if (!(conf->nb_queue_pools == RTE_ETH_16_POOLS ||
2366 : : conf->nb_queue_pools == RTE_ETH_32_POOLS)) {
2367 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2368 : : " nb_queue_pools must be %d or %d.",
2369 : : RTE_ETH_16_POOLS, RTE_ETH_32_POOLS);
2370 : 0 : return -EINVAL;
2371 : : }
2372 : : }
2373 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_VMDQ_DCB) {
2374 : : const struct rte_eth_vmdq_dcb_tx_conf *conf;
2375 : :
2376 [ # # ]: 0 : if (nb_tx_q != IXGBE_VMDQ_DCB_NB_QUEUES) {
2377 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB, nb_tx_q != %d",
2378 : : IXGBE_VMDQ_DCB_NB_QUEUES);
2379 : 0 : return -EINVAL;
2380 : : }
2381 : : conf = &dev_conf->tx_adv_conf.vmdq_dcb_tx_conf;
2382 [ # # ]: 0 : if (!(conf->nb_queue_pools == RTE_ETH_16_POOLS ||
2383 : : conf->nb_queue_pools == RTE_ETH_32_POOLS)) {
2384 : 0 : PMD_INIT_LOG(ERR, "VMDQ+DCB selected,"
2385 : : " nb_queue_pools != %d and"
2386 : : " nb_queue_pools != %d.",
2387 : : RTE_ETH_16_POOLS, RTE_ETH_32_POOLS);
2388 : 0 : return -EINVAL;
2389 : : }
2390 : : }
2391 : :
2392 : : /* For DCB mode check our configuration before we go further */
2393 [ # # ]: 0 : if (dev_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_DCB) {
2394 : : const struct rte_eth_dcb_rx_conf *conf;
2395 : :
2396 : : conf = &dev_conf->rx_adv_conf.dcb_rx_conf;
2397 [ # # ]: 0 : if (!(conf->nb_tcs == RTE_ETH_4_TCS ||
2398 : : conf->nb_tcs == RTE_ETH_8_TCS)) {
2399 : 0 : PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2400 : : " and nb_tcs != %d.",
2401 : : RTE_ETH_4_TCS, RTE_ETH_8_TCS);
2402 : 0 : return -EINVAL;
2403 : : }
2404 : : }
2405 : :
2406 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_DCB) {
2407 : : const struct rte_eth_dcb_tx_conf *conf;
2408 : :
2409 : : conf = &dev_conf->tx_adv_conf.dcb_tx_conf;
2410 [ # # ]: 0 : if (!(conf->nb_tcs == RTE_ETH_4_TCS ||
2411 : : conf->nb_tcs == RTE_ETH_8_TCS)) {
2412 : 0 : PMD_INIT_LOG(ERR, "DCB selected, nb_tcs != %d"
2413 : : " and nb_tcs != %d.",
2414 : : RTE_ETH_4_TCS, RTE_ETH_8_TCS);
2415 : 0 : return -EINVAL;
2416 : : }
2417 : : }
2418 : :
2419 : : /*
2420 : : * When DCB/VT is off, maximum number of queues changes,
2421 : : * except for 82598EB, which remains constant.
2422 : : */
2423 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_NONE &&
2424 [ # # ]: 0 : hw->mac.type != ixgbe_mac_82598EB) {
2425 [ # # ]: 0 : if (nb_tx_q > IXGBE_NONE_MODE_TX_NB_QUEUES) {
2426 : 0 : PMD_INIT_LOG(ERR,
2427 : : "Neither VT nor DCB are enabled, "
2428 : : "nb_tx_q > %d.",
2429 : : IXGBE_NONE_MODE_TX_NB_QUEUES);
2430 : 0 : return -EINVAL;
2431 : : }
2432 : : }
2433 : : }
2434 : : return 0;
2435 : : }
2436 : :
2437 : : static int
2438 : 0 : ixgbe_dev_configure(struct rte_eth_dev *dev)
2439 : : {
2440 : : struct ixgbe_interrupt *intr =
2441 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2442 : : struct ixgbe_adapter *adapter = dev->data->dev_private;
2443 : : int ret;
2444 : :
2445 : 0 : PMD_INIT_FUNC_TRACE();
2446 : :
2447 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
2448 : 0 : dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
2449 : :
2450 : : /* multiple queue mode checking */
2451 : 0 : ret = ixgbe_check_mq_mode(dev);
2452 [ # # ]: 0 : if (ret != 0) {
2453 : 0 : PMD_DRV_LOG(ERR, "ixgbe_check_mq_mode fails with %d.",
2454 : : ret);
2455 : 0 : return ret;
2456 : : }
2457 : :
2458 : : /* set flag to update link status after init */
2459 : 0 : intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
2460 : :
2461 : : /*
2462 : : * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
2463 : : * allocation or vector Rx preconditions we will reset it.
2464 : : */
2465 : 0 : adapter->rx_bulk_alloc_allowed = true;
2466 : 0 : adapter->rx_vec_allowed = true;
2467 : :
2468 : 0 : return 0;
2469 : : }
2470 : :
2471 : : static void
2472 : 0 : ixgbe_dev_phy_intr_setup(struct rte_eth_dev *dev)
2473 : : {
2474 : : struct ixgbe_hw *hw =
2475 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2476 : : struct ixgbe_interrupt *intr =
2477 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2478 : : uint32_t gpie;
2479 : :
2480 : : /* only set up it on X550EM_X */
2481 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X550EM_x) {
2482 : 0 : gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
2483 : 0 : gpie |= IXGBE_SDP0_GPIEN_X550EM_x;
2484 : 0 : IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
2485 [ # # ]: 0 : if (hw->phy.type == ixgbe_phy_x550em_ext_t)
2486 : 0 : intr->mask |= IXGBE_EICR_GPI_SDP0_X550EM_x;
2487 : : }
2488 : 0 : }
2489 : :
2490 : : int
2491 : 0 : ixgbe_set_vf_rate_limit(struct rte_eth_dev *dev, uint16_t vf,
2492 : : uint32_t tx_rate, uint64_t q_msk)
2493 : : {
2494 : : struct ixgbe_hw *hw;
2495 : : struct ixgbe_vf_info *vfinfo;
2496 : : struct rte_eth_link link;
2497 : : uint8_t nb_q_per_pool;
2498 : : uint32_t queue_stride;
2499 : : uint32_t queue_idx, idx = 0, vf_idx;
2500 : : uint32_t queue_end;
2501 : : uint16_t total_rate = 0;
2502 : : struct rte_pci_device *pci_dev;
2503 : : int ret;
2504 : :
2505 : 0 : pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2506 : 0 : ret = rte_eth_link_get_nowait(dev->data->port_id, &link);
2507 [ # # ]: 0 : if (ret < 0)
2508 : : return ret;
2509 : :
2510 [ # # ]: 0 : if (vf >= pci_dev->max_vfs)
2511 : : return -EINVAL;
2512 : :
2513 [ # # ]: 0 : if (tx_rate > link.link_speed)
2514 : : return -EINVAL;
2515 : :
2516 [ # # ]: 0 : if (q_msk == 0)
2517 : : return 0;
2518 : :
2519 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2520 : 0 : vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
2521 : 0 : nb_q_per_pool = RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool;
2522 : 0 : queue_stride = IXGBE_MAX_RX_QUEUE_NUM / RTE_ETH_DEV_SRIOV(dev).active;
2523 : 0 : queue_idx = vf * queue_stride;
2524 : 0 : queue_end = queue_idx + nb_q_per_pool - 1;
2525 [ # # ]: 0 : if (queue_end >= hw->mac.max_tx_queues)
2526 : : return -EINVAL;
2527 : :
2528 [ # # ]: 0 : if (vfinfo) {
2529 [ # # ]: 0 : for (vf_idx = 0; vf_idx < pci_dev->max_vfs; vf_idx++) {
2530 [ # # ]: 0 : if (vf_idx == vf)
2531 : 0 : continue;
2532 [ # # ]: 0 : for (idx = 0; idx < RTE_DIM(vfinfo[vf_idx].tx_rate);
2533 : 0 : idx++)
2534 : 0 : total_rate += vfinfo[vf_idx].tx_rate[idx];
2535 : : }
2536 : : } else {
2537 : : return -EINVAL;
2538 : : }
2539 : :
2540 : : /* Store tx_rate for this vf. */
2541 [ # # ]: 0 : for (idx = 0; idx < nb_q_per_pool; idx++) {
2542 [ # # ]: 0 : if (((uint64_t)0x1 << idx) & q_msk) {
2543 [ # # ]: 0 : if (vfinfo[vf].tx_rate[idx] != tx_rate)
2544 : 0 : vfinfo[vf].tx_rate[idx] = tx_rate;
2545 : 0 : total_rate += tx_rate;
2546 : : }
2547 : : }
2548 : :
2549 [ # # ]: 0 : if (total_rate > dev->data->dev_link.link_speed) {
2550 : : /* Reset stored TX rate of the VF if it causes exceed
2551 : : * link speed.
2552 : : */
2553 : 0 : memset(vfinfo[vf].tx_rate, 0, sizeof(vfinfo[vf].tx_rate));
2554 : 0 : return -EINVAL;
2555 : : }
2556 : :
2557 : : /* Set RTTBCNRC of each queue/pool for vf X */
2558 [ # # ]: 0 : for (; queue_idx <= queue_end; queue_idx++) {
2559 [ # # ]: 0 : if (0x1 & q_msk)
2560 : 0 : ixgbe_set_queue_rate_limit(dev, queue_idx, tx_rate);
2561 : 0 : q_msk = q_msk >> 1;
2562 : : }
2563 : :
2564 : : return 0;
2565 : : }
2566 : :
2567 : : static int
2568 : 0 : ixgbe_flow_ctrl_enable(struct rte_eth_dev *dev, struct ixgbe_hw *hw)
2569 : : {
2570 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
2571 : : int err;
2572 : : uint32_t mflcn;
2573 : :
2574 : 0 : ixgbe_setup_fc(hw);
2575 : :
2576 : 0 : err = ixgbe_fc_enable(hw);
2577 : :
2578 : : /* Not negotiated is not an error case */
2579 [ # # ]: 0 : if (err == IXGBE_SUCCESS || err == IXGBE_ERR_FC_NOT_NEGOTIATED) {
2580 : : /*
2581 : : *check if we want to forward MAC frames - driver doesn't
2582 : : *have native capability to do that,
2583 : : *so we'll write the registers ourselves
2584 : : */
2585 : :
2586 : 0 : mflcn = IXGBE_READ_REG(hw, IXGBE_MFLCN);
2587 : :
2588 : : /* set or clear MFLCN.PMCF bit depending on configuration */
2589 [ # # ]: 0 : if (adapter->mac_ctrl_frame_fwd != 0)
2590 : 0 : mflcn |= IXGBE_MFLCN_PMCF;
2591 : : else
2592 : 0 : mflcn &= ~IXGBE_MFLCN_PMCF;
2593 : :
2594 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn);
2595 : 0 : IXGBE_WRITE_FLUSH(hw);
2596 : :
2597 : 0 : return 0;
2598 : : }
2599 : : return err;
2600 : : }
2601 : :
2602 : : /*
2603 : : * Configure device link speed and setup link.
2604 : : * It returns 0 on success.
2605 : : */
2606 : : static int
2607 : 0 : ixgbe_dev_start(struct rte_eth_dev *dev)
2608 : : {
2609 : 0 : struct ixgbe_hw *hw =
2610 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2611 : 0 : struct ixgbe_vf_info *vfinfo =
2612 : : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2613 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2614 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2615 : : uint32_t intr_vector = 0;
2616 : : int err;
2617 : 0 : bool link_up = false, negotiate = 0;
2618 : 0 : uint32_t speed = 0;
2619 : : uint32_t allowed_speeds = 0;
2620 : : int mask = 0;
2621 : : int status;
2622 : : uint16_t vf, idx;
2623 : : uint32_t *link_speeds;
2624 : : struct ixgbe_tm_conf *tm_conf =
2625 : : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2626 : 0 : struct ixgbe_macsec_setting *macsec_setting =
2627 : : IXGBE_DEV_PRIVATE_TO_MACSEC_SETTING(dev->data->dev_private);
2628 : :
2629 : 0 : PMD_INIT_FUNC_TRACE();
2630 : :
2631 : : /* Stop the link setup handler before resetting the HW. */
2632 : 0 : ixgbe_dev_wait_setup_link_complete(dev, 0);
2633 : :
2634 : : /* disable uio/vfio intr/eventfd mapping */
2635 : 0 : rte_intr_disable(intr_handle);
2636 : :
2637 : : /* stop adapter */
2638 : 0 : hw->adapter_stopped = 0;
2639 : 0 : ixgbe_stop_adapter(hw);
2640 : :
2641 : : /* reinitialize adapter
2642 : : * this calls reset and start
2643 : : */
2644 : 0 : status = ixgbe_pf_reset_hw(hw);
2645 [ # # ]: 0 : if (status != 0)
2646 : : return -1;
2647 : 0 : hw->mac.ops.start_hw(hw);
2648 : 0 : hw->mac.get_link_status = true;
2649 : :
2650 : : /* configure PF module if SRIOV enabled */
2651 : 0 : ixgbe_pf_host_configure(dev);
2652 : :
2653 : 0 : ixgbe_dev_phy_intr_setup(dev);
2654 : :
2655 : : /* check and configure queue intr-vector mapping */
2656 [ # # ]: 0 : if ((rte_intr_cap_multiple(intr_handle) ||
2657 [ # # ]: 0 : !RTE_ETH_DEV_SRIOV(dev).active) &&
2658 [ # # ]: 0 : dev->data->dev_conf.intr_conf.rxq != 0) {
2659 : 0 : intr_vector = dev->data->nb_rx_queues;
2660 [ # # ]: 0 : if (intr_vector > IXGBE_MAX_INTR_QUEUE_NUM) {
2661 : 0 : PMD_INIT_LOG(ERR, "At most %d intr queues supported",
2662 : : IXGBE_MAX_INTR_QUEUE_NUM);
2663 : 0 : return -ENOTSUP;
2664 : : }
2665 [ # # ]: 0 : if (rte_intr_efd_enable(intr_handle, intr_vector))
2666 : : return -1;
2667 : : }
2668 : :
2669 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
2670 [ # # ]: 0 : if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
2671 : 0 : dev->data->nb_rx_queues)) {
2672 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
2673 : : " intr_vec", dev->data->nb_rx_queues);
2674 : 0 : return -ENOMEM;
2675 : : }
2676 : : }
2677 : :
2678 : : /* configure MSI-X for sleep until Rx interrupt */
2679 : 0 : ixgbe_configure_msix(dev);
2680 : :
2681 : : /* initialize transmission unit */
2682 : 0 : ixgbe_dev_tx_init(dev);
2683 : :
2684 : : /* This can fail when allocating mbufs for descriptor rings */
2685 : 0 : err = ixgbe_dev_rx_init(dev);
2686 [ # # ]: 0 : if (err) {
2687 : 0 : PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2688 : 0 : goto error;
2689 : : }
2690 : :
2691 : : mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
2692 : : RTE_ETH_VLAN_EXTEND_MASK;
2693 : 0 : err = ixgbe_vlan_offload_config(dev, mask);
2694 [ # # ]: 0 : if (err) {
2695 : 0 : PMD_INIT_LOG(ERR, "Unable to set VLAN offload");
2696 : 0 : goto error;
2697 : : }
2698 : :
2699 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode == RTE_ETH_MQ_RX_VMDQ_ONLY) {
2700 : : /* Enable vlan filtering for VMDq */
2701 : : ixgbe_vmdq_vlan_hw_filter_enable(dev);
2702 : : }
2703 : :
2704 : : /* Configure DCB hw */
2705 : 0 : ixgbe_configure_dcb(dev);
2706 : :
2707 [ # # ]: 0 : if (IXGBE_DEV_FDIR_CONF(dev)->mode != RTE_FDIR_MODE_NONE) {
2708 : 0 : err = ixgbe_fdir_configure(dev);
2709 [ # # ]: 0 : if (err)
2710 : 0 : goto error;
2711 : : }
2712 : :
2713 : : /* Restore vf rate limit */
2714 [ # # ]: 0 : if (vfinfo != NULL) {
2715 [ # # ]: 0 : for (vf = 0; vf < pci_dev->max_vfs; vf++)
2716 [ # # ]: 0 : for (idx = 0; idx < IXGBE_MAX_QUEUE_NUM_PER_VF; idx++)
2717 [ # # ]: 0 : if (vfinfo[vf].tx_rate[idx] != 0)
2718 : 0 : ixgbe_set_vf_rate_limit(
2719 : : dev, vf,
2720 : : vfinfo[vf].tx_rate[idx],
2721 : 0 : 1 << idx);
2722 : : }
2723 : :
2724 : 0 : ixgbe_restore_statistics_mapping(dev);
2725 : :
2726 : 0 : err = ixgbe_flow_ctrl_enable(dev, hw);
2727 [ # # ]: 0 : if (err < 0) {
2728 : 0 : PMD_INIT_LOG(ERR, "enable flow ctrl err");
2729 : 0 : goto error;
2730 : : }
2731 : :
2732 : 0 : err = ixgbe_dev_rxtx_start(dev);
2733 [ # # ]: 0 : if (err < 0) {
2734 : 0 : PMD_INIT_LOG(ERR, "Unable to start rxtx queues");
2735 : 0 : goto error;
2736 : : }
2737 : :
2738 : : /* Skip link setup if loopback mode is enabled. */
2739 [ # # ]: 0 : if (dev->data->dev_conf.lpbk_mode != 0) {
2740 : 0 : err = ixgbe_check_supported_loopback_mode(dev);
2741 [ # # ]: 0 : if (err < 0) {
2742 : 0 : PMD_INIT_LOG(ERR, "Unsupported loopback mode");
2743 : 0 : goto error;
2744 : : } else {
2745 : 0 : goto skip_link_setup;
2746 : : }
2747 : : }
2748 : :
2749 [ # # # # ]: 0 : if (ixgbe_is_sfp(hw) && hw->phy.multispeed_fiber) {
2750 : 0 : err = hw->mac.ops.setup_sfp(hw);
2751 [ # # ]: 0 : if (err)
2752 : 0 : goto error;
2753 : : }
2754 : :
2755 [ # # ]: 0 : if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2756 : : /* Turn on the copper */
2757 : 0 : ixgbe_set_phy_power(hw, true);
2758 : : } else {
2759 : : /* Turn on the laser */
2760 : 0 : ixgbe_enable_tx_laser(hw);
2761 : : }
2762 : :
2763 : 0 : err = ixgbe_check_link(hw, &speed, &link_up, 0);
2764 [ # # ]: 0 : if (err)
2765 : 0 : goto error;
2766 : 0 : dev->data->dev_link.link_status = link_up;
2767 : :
2768 : 0 : err = ixgbe_get_link_capabilities(hw, &speed, &negotiate);
2769 [ # # ]: 0 : if (err)
2770 : 0 : goto error;
2771 : :
2772 [ # # ]: 0 : switch (hw->mac.type) {
2773 : 0 : case ixgbe_mac_X550:
2774 : : case ixgbe_mac_X550EM_x:
2775 : : case ixgbe_mac_X550EM_a:
2776 : : allowed_speeds = RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_1G |
2777 : : RTE_ETH_LINK_SPEED_2_5G | RTE_ETH_LINK_SPEED_5G |
2778 : : RTE_ETH_LINK_SPEED_10G;
2779 [ # # ]: 0 : if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
2780 : : hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L)
2781 : : allowed_speeds = RTE_ETH_LINK_SPEED_10M |
2782 : : RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_1G;
2783 : : break;
2784 : : default:
2785 : : allowed_speeds = RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_1G |
2786 : : RTE_ETH_LINK_SPEED_10G;
2787 : : }
2788 : :
2789 : 0 : link_speeds = &dev->data->dev_conf.link_speeds;
2790 : :
2791 : : /* Ignore autoneg flag bit and check the validity ofÂ
2792 : : * link_speedÂ
2793 : : */
2794 [ # # ]: 0 : if (((*link_speeds) >> 1) & ~(allowed_speeds >> 1)) {
2795 : 0 : PMD_INIT_LOG(ERR, "Invalid link setting");
2796 : 0 : goto error;
2797 : : }
2798 : :
2799 : 0 : speed = 0x0;
2800 [ # # ]: 0 : if (*link_speeds == RTE_ETH_LINK_SPEED_AUTONEG) {
2801 [ # # # # ]: 0 : switch (hw->mac.type) {
2802 : 0 : case ixgbe_mac_82598EB:
2803 : 0 : speed = IXGBE_LINK_SPEED_82598_AUTONEG;
2804 : 0 : break;
2805 : 0 : case ixgbe_mac_82599EB:
2806 : : case ixgbe_mac_X540:
2807 : 0 : speed = IXGBE_LINK_SPEED_82599_AUTONEG;
2808 : 0 : break;
2809 : 0 : case ixgbe_mac_X550:
2810 : : case ixgbe_mac_X550EM_x:
2811 : : case ixgbe_mac_X550EM_a:
2812 : 0 : speed = IXGBE_LINK_SPEED_X550_AUTONEG;
2813 : 0 : break;
2814 : 0 : default:
2815 : 0 : speed = IXGBE_LINK_SPEED_82599_AUTONEG;
2816 : : }
2817 : : } else {
2818 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_10G)
2819 : 0 : speed |= IXGBE_LINK_SPEED_10GB_FULL;
2820 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_5G)
2821 : 0 : speed |= IXGBE_LINK_SPEED_5GB_FULL;
2822 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_2_5G)
2823 : 0 : speed |= IXGBE_LINK_SPEED_2_5GB_FULL;
2824 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_1G)
2825 : 0 : speed |= IXGBE_LINK_SPEED_1GB_FULL;
2826 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_100M)
2827 : 0 : speed |= IXGBE_LINK_SPEED_100_FULL;
2828 [ # # ]: 0 : if (*link_speeds & RTE_ETH_LINK_SPEED_10M)
2829 : 0 : speed |= IXGBE_LINK_SPEED_10_FULL;
2830 : : }
2831 : :
2832 : 0 : err = ixgbe_setup_link(hw, speed, link_up);
2833 [ # # ]: 0 : if (err)
2834 : 0 : goto error;
2835 : :
2836 : 0 : skip_link_setup:
2837 : :
2838 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
2839 : : /* check if lsc interrupt is enabled */
2840 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
2841 : 0 : ixgbe_dev_lsc_interrupt_setup(dev, TRUE);
2842 : : else
2843 : 0 : ixgbe_dev_lsc_interrupt_setup(dev, FALSE);
2844 : : ixgbe_dev_macsec_interrupt_setup(dev);
2845 : : } else {
2846 : 0 : rte_intr_callback_unregister(intr_handle,
2847 : : ixgbe_dev_interrupt_handler, dev);
2848 [ # # ]: 0 : if (dev->data->dev_conf.intr_conf.lsc != 0)
2849 : 0 : PMD_INIT_LOG(INFO, "lsc won't enable because of"
2850 : : " no intr multiplex");
2851 : : }
2852 : :
2853 : : /* check if rxq interrupt is enabled */
2854 [ # # # # ]: 0 : if (dev->data->dev_conf.intr_conf.rxq != 0 &&
2855 : 0 : rte_intr_dp_is_en(intr_handle))
2856 : : ixgbe_dev_rxq_interrupt_setup(dev);
2857 : :
2858 : : /* enable uio/vfio intr/eventfd mapping */
2859 : 0 : rte_intr_enable(intr_handle);
2860 : :
2861 : : /* resume enabled intr since hw reset */
2862 : : ixgbe_enable_intr(dev);
2863 : 0 : ixgbe_l2_tunnel_conf(dev);
2864 : 0 : ixgbe_filter_restore(dev);
2865 : :
2866 [ # # # # ]: 0 : if (tm_conf->root && !tm_conf->committed)
2867 : 0 : PMD_DRV_LOG(WARNING,
2868 : : "please call hierarchy_commit() "
2869 : : "before starting the port");
2870 : :
2871 : : /* wait for the controller to acquire link */
2872 : : err = ixgbe_wait_for_link_up(hw);
2873 : : if (err)
2874 : : goto error;
2875 : :
2876 : : /*
2877 : : * Update link status right before return, because it may
2878 : : * start link configuration process in a separate thread.
2879 : : */
2880 : : ixgbe_dev_link_update(dev, 0);
2881 : :
2882 : : /* setup the macsec setting register */
2883 [ # # ]: 0 : if (macsec_setting->offload_en)
2884 : 0 : ixgbe_dev_macsec_register_enable(dev, macsec_setting);
2885 : :
2886 : : return 0;
2887 : :
2888 : 0 : error:
2889 : 0 : PMD_INIT_LOG(ERR, "failure in ixgbe_dev_start(): %d", err);
2890 : 0 : ixgbe_dev_clear_queues(dev);
2891 : 0 : return -EIO;
2892 : : }
2893 : :
2894 : : /*
2895 : : * Stop device: disable rx and tx functions to allow for reconfiguring.
2896 : : */
2897 : : static int
2898 : 0 : ixgbe_dev_stop(struct rte_eth_dev *dev)
2899 : : {
2900 : : struct rte_eth_link link;
2901 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
2902 : 0 : struct ixgbe_hw *hw =
2903 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2904 : 0 : struct ixgbe_vf_info *vfinfo =
2905 : : *IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private);
2906 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2907 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
2908 : : int vf;
2909 : : struct ixgbe_tm_conf *tm_conf =
2910 : : IXGBE_DEV_PRIVATE_TO_TM_CONF(dev->data->dev_private);
2911 : :
2912 [ # # ]: 0 : if (hw->adapter_stopped)
2913 : : return 0;
2914 : :
2915 : 0 : PMD_INIT_FUNC_TRACE();
2916 : :
2917 : 0 : ixgbe_dev_wait_setup_link_complete(dev, 0);
2918 : :
2919 : : /* disable interrupts */
2920 : 0 : ixgbe_disable_intr(hw);
2921 : :
2922 : : /* reset the NIC */
2923 : 0 : ixgbe_pf_reset_hw(hw);
2924 : 0 : hw->adapter_stopped = 0;
2925 : :
2926 : : /* stop adapter */
2927 : 0 : ixgbe_stop_adapter(hw);
2928 : :
2929 [ # # # # ]: 0 : for (vf = 0; vfinfo != NULL && vf < pci_dev->max_vfs; vf++)
2930 : 0 : vfinfo[vf].clear_to_send = false;
2931 : :
2932 [ # # ]: 0 : if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2933 : : /* Turn off the copper */
2934 : 0 : ixgbe_set_phy_power(hw, false);
2935 : : } else {
2936 : : /* Turn off the laser */
2937 : 0 : ixgbe_disable_tx_laser(hw);
2938 : : }
2939 : :
2940 : 0 : ixgbe_dev_clear_queues(dev);
2941 : :
2942 : : /* Clear stored conf */
2943 : 0 : dev->data->scattered_rx = 0;
2944 : 0 : dev->data->lro = 0;
2945 : :
2946 : : /* Clear recorded link status */
2947 : : memset(&link, 0, sizeof(link));
2948 : 0 : rte_eth_linkstatus_set(dev, &link);
2949 : :
2950 [ # # ]: 0 : if (!rte_intr_allow_others(intr_handle))
2951 : : /* resume to the default handler */
2952 : 0 : rte_intr_callback_register(intr_handle,
2953 : : ixgbe_dev_interrupt_handler,
2954 : : (void *)dev);
2955 : :
2956 : : /* Clean datapath event and queue/vec mapping */
2957 : 0 : rte_intr_efd_disable(intr_handle);
2958 : 0 : rte_intr_vec_list_free(intr_handle);
2959 : :
2960 : : /* reset hierarchy commit */
2961 : 0 : tm_conf->committed = false;
2962 : :
2963 : 0 : adapter->rss_reta_updated = 0;
2964 : :
2965 : 0 : hw->adapter_stopped = true;
2966 : 0 : dev->data->dev_started = 0;
2967 : :
2968 : 0 : return 0;
2969 : : }
2970 : :
2971 : : /*
2972 : : * Set device link up: enable tx.
2973 : : */
2974 : : static int
2975 : 0 : ixgbe_dev_set_link_up(struct rte_eth_dev *dev)
2976 : : {
2977 : 0 : struct ixgbe_hw *hw =
2978 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2979 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB) {
2980 : : #ifdef RTE_LIBRTE_IXGBE_BYPASS
2981 [ # # ]: 0 : if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
2982 : : /* Not supported in bypass mode */
2983 : 0 : PMD_INIT_LOG(ERR, "Set link up is not supported "
2984 : : "by device id 0x%x", hw->device_id);
2985 : 0 : return -ENOTSUP;
2986 : : }
2987 : : #endif
2988 : : }
2989 : :
2990 [ # # ]: 0 : if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
2991 : : /* Turn on the copper */
2992 : 0 : ixgbe_set_phy_power(hw, true);
2993 : : } else {
2994 : : /* Turn on the laser */
2995 : 0 : ixgbe_enable_tx_laser(hw);
2996 : : ixgbe_dev_link_update(dev, 0);
2997 : : }
2998 : :
2999 : : return 0;
3000 : : }
3001 : :
3002 : : /*
3003 : : * Set device link down: disable tx.
3004 : : */
3005 : : static int
3006 : 0 : ixgbe_dev_set_link_down(struct rte_eth_dev *dev)
3007 : : {
3008 : 0 : struct ixgbe_hw *hw =
3009 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3010 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82599EB) {
3011 : : #ifdef RTE_LIBRTE_IXGBE_BYPASS
3012 [ # # ]: 0 : if (hw->device_id == IXGBE_DEV_ID_82599_BYPASS) {
3013 : : /* Not supported in bypass mode */
3014 : 0 : PMD_INIT_LOG(ERR, "Set link down is not supported "
3015 : : "by device id 0x%x", hw->device_id);
3016 : 0 : return -ENOTSUP;
3017 : : }
3018 : : #endif
3019 : : }
3020 : :
3021 [ # # ]: 0 : if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_copper) {
3022 : : /* Turn off the copper */
3023 : 0 : ixgbe_set_phy_power(hw, false);
3024 : : } else {
3025 : : /* Turn off the laser */
3026 : 0 : ixgbe_disable_tx_laser(hw);
3027 : : ixgbe_dev_link_update(dev, 0);
3028 : : }
3029 : :
3030 : : return 0;
3031 : : }
3032 : :
3033 : : /*
3034 : : * Reset and stop device.
3035 : : */
3036 : : static int
3037 : 0 : ixgbe_dev_close(struct rte_eth_dev *dev)
3038 : : {
3039 : 0 : struct ixgbe_hw *hw =
3040 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3041 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3042 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
3043 : : int retries = 0;
3044 : : int ret;
3045 : :
3046 : 0 : PMD_INIT_FUNC_TRACE();
3047 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
3048 : : return 0;
3049 : :
3050 : 0 : ixgbe_pf_reset_hw(hw);
3051 : :
3052 : 0 : ret = ixgbe_dev_stop(dev);
3053 : :
3054 : 0 : ixgbe_dev_free_queues(dev);
3055 : :
3056 : 0 : ixgbe_disable_pcie_master(hw);
3057 : :
3058 : : /* reprogram the RAR[0] in case user changed it. */
3059 : 0 : ixgbe_set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
3060 : :
3061 : : /* Unlock any pending hardware semaphore */
3062 : 0 : ixgbe_swfw_lock_reset(hw);
3063 : :
3064 : : /* disable uio intr before callback unregister */
3065 : 0 : rte_intr_disable(intr_handle);
3066 : :
3067 : : do {
3068 : 0 : ret = rte_intr_callback_unregister(intr_handle,
3069 : : ixgbe_dev_interrupt_handler, dev);
3070 [ # # ]: 0 : if (ret >= 0 || ret == -ENOENT) {
3071 : : break;
3072 [ # # ]: 0 : } else if (ret != -EAGAIN) {
3073 : 0 : PMD_INIT_LOG(ERR,
3074 : : "intr callback unregister failed: %d",
3075 : : ret);
3076 : : }
3077 : : rte_delay_ms(100);
3078 [ # # ]: 0 : } while (retries++ < (10 + IXGBE_LINK_UP_TIME));
3079 : :
3080 : : /* cancel the delay handler before remove dev */
3081 : 0 : rte_eal_alarm_cancel(ixgbe_dev_interrupt_delayed_handler, dev);
3082 : :
3083 : : /* uninitialize PF if max_vfs not zero */
3084 : 0 : ixgbe_pf_host_uninit(dev);
3085 : :
3086 : : /* remove all the fdir filters & hash */
3087 : 0 : ixgbe_fdir_filter_uninit(dev);
3088 : :
3089 : : /* remove all the L2 tunnel filters & hash */
3090 : 0 : ixgbe_l2_tn_filter_uninit(dev);
3091 : :
3092 : : /* Remove all ntuple filters of the device */
3093 : 0 : ixgbe_ntuple_filter_uninit(dev);
3094 : :
3095 : : /* clear all the filters list */
3096 : 0 : ixgbe_filterlist_flush();
3097 : :
3098 : : /* Remove all Traffic Manager configuration */
3099 : 0 : ixgbe_tm_conf_uninit(dev);
3100 : :
3101 : : #ifdef RTE_LIB_SECURITY
3102 : 0 : rte_free(dev->security_ctx);
3103 : 0 : dev->security_ctx = NULL;
3104 : : #endif
3105 : :
3106 : 0 : return ret;
3107 : : }
3108 : :
3109 : : /*
3110 : : * Reset PF device.
3111 : : */
3112 : : static int
3113 : 0 : ixgbe_dev_reset(struct rte_eth_dev *dev)
3114 : : {
3115 : : int ret;
3116 : :
3117 : : /* When a DPDK PMD PF begin to reset PF port, it should notify all
3118 : : * its VF to make them align with it. The detailed notification
3119 : : * mechanism is PMD specific. As to ixgbe PF, it is rather complex.
3120 : : * To avoid unexpected behavior in VF, currently reset of PF with
3121 : : * SR-IOV activation is not supported. It might be supported later.
3122 : : */
3123 [ # # ]: 0 : if (dev->data->sriov.active)
3124 : : return -ENOTSUP;
3125 : :
3126 : 0 : ret = eth_ixgbe_dev_uninit(dev);
3127 [ # # ]: 0 : if (ret)
3128 : : return ret;
3129 : :
3130 : 0 : ret = eth_ixgbe_dev_init(dev, NULL);
3131 : :
3132 : 0 : return ret;
3133 : : }
3134 : :
3135 : : static void
3136 : 0 : ixgbe_read_stats_registers(struct ixgbe_hw *hw,
3137 : : struct ixgbe_hw_stats *hw_stats,
3138 : : struct ixgbe_macsec_stats *macsec_stats,
3139 : : uint64_t *total_missed_rx, uint64_t *total_qbrc,
3140 : : uint64_t *total_qprc, uint64_t *total_qprdc)
3141 : : {
3142 : : uint32_t bprc, lxon, lxoff, total;
3143 : : uint32_t delta_gprc = 0;
3144 : : unsigned i;
3145 : : /* Workaround for RX byte count not including CRC bytes when CRC
3146 : : * strip is enabled. CRC bytes are removed from counters when crc_strip
3147 : : * is disabled.
3148 : : */
3149 : 0 : int crc_strip = (IXGBE_READ_REG(hw, IXGBE_HLREG0) &
3150 : : IXGBE_HLREG0_RXCRCSTRP);
3151 : :
3152 : 0 : hw_stats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS);
3153 : 0 : hw_stats->illerrc += IXGBE_READ_REG(hw, IXGBE_ILLERRC);
3154 : 0 : hw_stats->errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
3155 : 0 : hw_stats->mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
3156 : :
3157 [ # # ]: 0 : for (i = 0; i < 8; i++) {
3158 : 0 : uint32_t mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
3159 : :
3160 : : /* global total per queue */
3161 : 0 : hw_stats->mpc[i] += mp;
3162 : : /* Running comprehensive total for stats display */
3163 : 0 : *total_missed_rx += hw_stats->mpc[i];
3164 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
3165 : 0 : hw_stats->rnbc[i] +=
3166 : 0 : IXGBE_READ_REG(hw, IXGBE_RNBC(i));
3167 : 0 : hw_stats->pxonrxc[i] +=
3168 : 0 : IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
3169 : 0 : hw_stats->pxoffrxc[i] +=
3170 : 0 : IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
3171 : : } else {
3172 : 0 : hw_stats->pxonrxc[i] +=
3173 : 0 : IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
3174 : 0 : hw_stats->pxoffrxc[i] +=
3175 : 0 : IXGBE_READ_REG(hw, IXGBE_PXOFFRXCNT(i));
3176 : 0 : hw_stats->pxon2offc[i] +=
3177 : 0 : IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
3178 : : }
3179 : 0 : hw_stats->pxontxc[i] +=
3180 : 0 : IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
3181 : 0 : hw_stats->pxofftxc[i] +=
3182 : 0 : IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
3183 : : }
3184 [ # # ]: 0 : for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3185 : 0 : uint32_t delta_qprc = IXGBE_READ_REG(hw, IXGBE_QPRC(i));
3186 : 0 : uint32_t delta_qptc = IXGBE_READ_REG(hw, IXGBE_QPTC(i));
3187 : 0 : uint32_t delta_qprdc = IXGBE_READ_REG(hw, IXGBE_QPRDC(i));
3188 : :
3189 : 0 : delta_gprc += delta_qprc;
3190 : :
3191 : 0 : hw_stats->qprc[i] += delta_qprc;
3192 : 0 : hw_stats->qptc[i] += delta_qptc;
3193 : :
3194 : 0 : hw_stats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i));
3195 : 0 : hw_stats->qbrc[i] +=
3196 : 0 : ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBRC_H(i)) << 32);
3197 [ # # ]: 0 : if (crc_strip == 0)
3198 : 0 : hw_stats->qbrc[i] -= delta_qprc * RTE_ETHER_CRC_LEN;
3199 : :
3200 : 0 : hw_stats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i));
3201 : 0 : hw_stats->qbtc[i] +=
3202 : 0 : ((uint64_t)IXGBE_READ_REG(hw, IXGBE_QBTC_H(i)) << 32);
3203 : :
3204 : 0 : hw_stats->qprdc[i] += delta_qprdc;
3205 : 0 : *total_qprdc += hw_stats->qprdc[i];
3206 : :
3207 : 0 : *total_qprc += hw_stats->qprc[i];
3208 : 0 : *total_qbrc += hw_stats->qbrc[i];
3209 : : }
3210 : 0 : hw_stats->mlfc += IXGBE_READ_REG(hw, IXGBE_MLFC);
3211 : 0 : hw_stats->mrfc += IXGBE_READ_REG(hw, IXGBE_MRFC);
3212 : 0 : hw_stats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC);
3213 : :
3214 : : /*
3215 : : * An errata states that gprc actually counts good + missed packets:
3216 : : * Workaround to set gprc to summated queue packet receives
3217 : : */
3218 : 0 : hw_stats->gprc = *total_qprc;
3219 : :
3220 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
3221 : 0 : hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL);
3222 : 0 : hw_stats->gorc += ((u64)IXGBE_READ_REG(hw, IXGBE_GORCH) << 32);
3223 : 0 : hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL);
3224 : 0 : hw_stats->gotc += ((u64)IXGBE_READ_REG(hw, IXGBE_GOTCH) << 32);
3225 : 0 : hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORL);
3226 : 0 : hw_stats->tor += ((u64)IXGBE_READ_REG(hw, IXGBE_TORH) << 32);
3227 : 0 : hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT);
3228 : 0 : hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXCNT);
3229 : : } else {
3230 : 0 : hw_stats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC);
3231 : 0 : hw_stats->lxoffrxc += IXGBE_READ_REG(hw, IXGBE_LXOFFRXC);
3232 : : /* 82598 only has a counter in the high register */
3233 : 0 : hw_stats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH);
3234 : 0 : hw_stats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH);
3235 : 0 : hw_stats->tor += IXGBE_READ_REG(hw, IXGBE_TORH);
3236 : : }
3237 : 0 : uint64_t old_tpr = hw_stats->tpr;
3238 : :
3239 : 0 : hw_stats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR);
3240 : 0 : hw_stats->tpt += IXGBE_READ_REG(hw, IXGBE_TPT);
3241 : :
3242 [ # # ]: 0 : if (crc_strip == 0)
3243 : 0 : hw_stats->gorc -= delta_gprc * RTE_ETHER_CRC_LEN;
3244 : :
3245 : 0 : uint64_t delta_gptc = IXGBE_READ_REG(hw, IXGBE_GPTC);
3246 : 0 : hw_stats->gptc += delta_gptc;
3247 : 0 : hw_stats->gotc -= delta_gptc * RTE_ETHER_CRC_LEN;
3248 : 0 : hw_stats->tor -= (hw_stats->tpr - old_tpr) * RTE_ETHER_CRC_LEN;
3249 : :
3250 : : /*
3251 : : * Workaround: mprc hardware is incorrectly counting
3252 : : * broadcasts, so for now we subtract those.
3253 : : */
3254 : 0 : bprc = IXGBE_READ_REG(hw, IXGBE_BPRC);
3255 : 0 : hw_stats->bprc += bprc;
3256 : 0 : hw_stats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC);
3257 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
3258 : 0 : hw_stats->mprc -= bprc;
3259 : :
3260 : 0 : hw_stats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64);
3261 : 0 : hw_stats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127);
3262 : 0 : hw_stats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255);
3263 : 0 : hw_stats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511);
3264 : 0 : hw_stats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023);
3265 : 0 : hw_stats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522);
3266 : :
3267 : 0 : lxon = IXGBE_READ_REG(hw, IXGBE_LXONTXC);
3268 : 0 : hw_stats->lxontxc += lxon;
3269 : 0 : lxoff = IXGBE_READ_REG(hw, IXGBE_LXOFFTXC);
3270 : 0 : hw_stats->lxofftxc += lxoff;
3271 : 0 : total = lxon + lxoff;
3272 : :
3273 : 0 : hw_stats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC);
3274 : 0 : hw_stats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64);
3275 : 0 : hw_stats->gptc -= total;
3276 : 0 : hw_stats->mptc -= total;
3277 : 0 : hw_stats->ptc64 -= total;
3278 : 0 : hw_stats->gotc -= total * RTE_ETHER_MIN_LEN;
3279 : :
3280 : 0 : hw_stats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC);
3281 : 0 : hw_stats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC);
3282 : 0 : hw_stats->roc += IXGBE_READ_REG(hw, IXGBE_ROC);
3283 : 0 : hw_stats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC);
3284 : 0 : hw_stats->mngprc += IXGBE_READ_REG(hw, IXGBE_MNGPRC);
3285 : 0 : hw_stats->mngpdc += IXGBE_READ_REG(hw, IXGBE_MNGPDC);
3286 : 0 : hw_stats->mngptc += IXGBE_READ_REG(hw, IXGBE_MNGPTC);
3287 : 0 : hw_stats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127);
3288 : 0 : hw_stats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255);
3289 : 0 : hw_stats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511);
3290 : 0 : hw_stats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023);
3291 : 0 : hw_stats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522);
3292 : 0 : hw_stats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC);
3293 : 0 : hw_stats->xec += IXGBE_READ_REG(hw, IXGBE_XEC);
3294 : 0 : hw_stats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC);
3295 : 0 : hw_stats->fclast += IXGBE_READ_REG(hw, IXGBE_FCLAST);
3296 : : /* Only read FCOE on 82599 */
3297 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
3298 : 0 : hw_stats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC);
3299 : 0 : hw_stats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC);
3300 : 0 : hw_stats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC);
3301 : 0 : hw_stats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC);
3302 : 0 : hw_stats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC);
3303 : : }
3304 : :
3305 : : /* Flow Director Stats registers */
3306 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
3307 : 0 : hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
3308 : 0 : hw_stats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS);
3309 : 0 : hw_stats->fdirustat_add += IXGBE_READ_REG(hw,
3310 : 0 : IXGBE_FDIRUSTAT) & 0xFFFF;
3311 : 0 : hw_stats->fdirustat_remove += (IXGBE_READ_REG(hw,
3312 : 0 : IXGBE_FDIRUSTAT) >> 16) & 0xFFFF;
3313 : 0 : hw_stats->fdirfstat_fadd += IXGBE_READ_REG(hw,
3314 : 0 : IXGBE_FDIRFSTAT) & 0xFFFF;
3315 : 0 : hw_stats->fdirfstat_fremove += (IXGBE_READ_REG(hw,
3316 : 0 : IXGBE_FDIRFSTAT) >> 16) & 0xFFFF;
3317 : : }
3318 : : /* MACsec Stats registers */
3319 : 0 : macsec_stats->out_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECTXUT);
3320 : 0 : macsec_stats->out_pkts_encrypted +=
3321 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECTXPKTE);
3322 : 0 : macsec_stats->out_pkts_protected +=
3323 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECTXPKTP);
3324 : 0 : macsec_stats->out_octets_encrypted +=
3325 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECTXOCTE);
3326 : 0 : macsec_stats->out_octets_protected +=
3327 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECTXOCTP);
3328 : 0 : macsec_stats->in_pkts_untagged += IXGBE_READ_REG(hw, IXGBE_LSECRXUT);
3329 : 0 : macsec_stats->in_pkts_badtag += IXGBE_READ_REG(hw, IXGBE_LSECRXBAD);
3330 : 0 : macsec_stats->in_pkts_nosci += IXGBE_READ_REG(hw, IXGBE_LSECRXNOSCI);
3331 : 0 : macsec_stats->in_pkts_unknownsci +=
3332 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXUNSCI);
3333 : 0 : macsec_stats->in_octets_decrypted +=
3334 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXOCTD);
3335 : 0 : macsec_stats->in_octets_validated +=
3336 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXOCTV);
3337 : 0 : macsec_stats->in_pkts_unchecked += IXGBE_READ_REG(hw, IXGBE_LSECRXUNCH);
3338 : 0 : macsec_stats->in_pkts_delayed += IXGBE_READ_REG(hw, IXGBE_LSECRXDELAY);
3339 : 0 : macsec_stats->in_pkts_late += IXGBE_READ_REG(hw, IXGBE_LSECRXLATE);
3340 [ # # ]: 0 : for (i = 0; i < 2; i++) {
3341 : 0 : macsec_stats->in_pkts_ok +=
3342 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXOK(i));
3343 : 0 : macsec_stats->in_pkts_invalid +=
3344 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXINV(i));
3345 : 0 : macsec_stats->in_pkts_notvalid +=
3346 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXNV(i));
3347 : : }
3348 : 0 : macsec_stats->in_pkts_unusedsa += IXGBE_READ_REG(hw, IXGBE_LSECRXUNSA);
3349 : 0 : macsec_stats->in_pkts_notusingsa +=
3350 : 0 : IXGBE_READ_REG(hw, IXGBE_LSECRXNUSA);
3351 : 0 : }
3352 : :
3353 : : /*
3354 : : * This function is based on ixgbe_update_stats_counters() in ixgbe/ixgbe.c
3355 : : */
3356 : : static int
3357 : 0 : ixgbe_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3358 : : {
3359 : 0 : struct ixgbe_hw *hw =
3360 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3361 : 0 : struct ixgbe_hw_stats *hw_stats =
3362 : : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3363 : 0 : struct ixgbe_macsec_stats *macsec_stats =
3364 : : IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3365 : : dev->data->dev_private);
3366 : : uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3367 : : unsigned i;
3368 : :
3369 : 0 : total_missed_rx = 0;
3370 : 0 : total_qbrc = 0;
3371 : 0 : total_qprc = 0;
3372 : 0 : total_qprdc = 0;
3373 : :
3374 : 0 : ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3375 : : &total_qbrc, &total_qprc, &total_qprdc);
3376 : :
3377 [ # # ]: 0 : if (stats == NULL)
3378 : : return -EINVAL;
3379 : :
3380 : : /* Fill out the rte_eth_stats statistics structure */
3381 : 0 : stats->ipackets = total_qprc;
3382 : 0 : stats->ibytes = total_qbrc;
3383 : 0 : stats->opackets = hw_stats->gptc;
3384 : 0 : stats->obytes = hw_stats->gotc;
3385 : :
3386 [ # # ]: 0 : for (i = 0; i < IXGBE_QUEUE_STAT_COUNTERS; i++) {
3387 : 0 : stats->q_ipackets[i] = hw_stats->qprc[i];
3388 : 0 : stats->q_opackets[i] = hw_stats->qptc[i];
3389 : 0 : stats->q_ibytes[i] = hw_stats->qbrc[i];
3390 : 0 : stats->q_obytes[i] = hw_stats->qbtc[i];
3391 : 0 : stats->q_errors[i] = hw_stats->qprdc[i];
3392 : : }
3393 : :
3394 : : /* Rx Errors */
3395 : 0 : stats->imissed = total_missed_rx;
3396 : 0 : stats->ierrors = hw_stats->crcerrs +
3397 : 0 : hw_stats->mspdc +
3398 : 0 : hw_stats->rlec +
3399 : 0 : hw_stats->ruc +
3400 : 0 : hw_stats->roc +
3401 : 0 : hw_stats->illerrc +
3402 : 0 : hw_stats->errbc +
3403 : 0 : hw_stats->rfc +
3404 : 0 : hw_stats->fccrc +
3405 : 0 : hw_stats->fclast;
3406 : :
3407 : : /*
3408 : : * 82599 errata, UDP frames with a 0 checksum can be marked as checksum
3409 : : * errors.
3410 : : */
3411 [ # # ]: 0 : if (hw->mac.type != ixgbe_mac_82599EB)
3412 : 0 : stats->ierrors += hw_stats->xec;
3413 : :
3414 : : /* Tx Errors */
3415 : 0 : stats->oerrors = 0;
3416 : 0 : return 0;
3417 : : }
3418 : :
3419 : : static int
3420 : 0 : ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
3421 : : {
3422 : 0 : struct ixgbe_hw_stats *stats =
3423 : 0 : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3424 : :
3425 : : /* HW registers are cleared on read */
3426 : 0 : ixgbe_dev_stats_get(dev, NULL);
3427 : :
3428 : : /* Reset software totals */
3429 : : memset(stats, 0, sizeof(*stats));
3430 : :
3431 : 0 : return 0;
3432 : : }
3433 : :
3434 : : /* This function calculates the number of xstats based on the current config */
3435 : : static unsigned
3436 : : ixgbe_xstats_calc_num(void) {
3437 : : return IXGBE_NB_HW_STATS + IXGBE_NB_MACSEC_STATS +
3438 : : (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
3439 : : (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
3440 : : }
3441 : :
3442 : 0 : static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3443 : : struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned int size)
3444 : : {
3445 : : const unsigned cnt_stats = ixgbe_xstats_calc_num();
3446 : : unsigned stat, i, count;
3447 : :
3448 [ # # ]: 0 : if (xstats_names != NULL) {
3449 : : count = 0;
3450 : :
3451 : : /* Note: limit >= cnt_stats checked upstream
3452 : : * in rte_eth_xstats_names()
3453 : : */
3454 : :
3455 : : /* Extended stats from ixgbe_hw_stats */
3456 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3457 : 0 : strlcpy(xstats_names[count].name,
3458 : : rte_ixgbe_stats_strings[i].name,
3459 : : sizeof(xstats_names[count].name));
3460 : 0 : count++;
3461 : : }
3462 : :
3463 : : /* MACsec Stats */
3464 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3465 : 0 : strlcpy(xstats_names[count].name,
3466 : : rte_ixgbe_macsec_strings[i].name,
3467 : : sizeof(xstats_names[count].name));
3468 : 0 : count++;
3469 : : }
3470 : :
3471 : : /* RX Priority Stats */
3472 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3473 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3474 : 0 : snprintf(xstats_names[count].name,
3475 : : sizeof(xstats_names[count].name),
3476 : : "rx_priority%u_%s", i,
3477 : 0 : rte_ixgbe_rxq_strings[stat].name);
3478 : 0 : count++;
3479 : : }
3480 : : }
3481 : :
3482 : : /* TX Priority Stats */
3483 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3484 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3485 : 0 : snprintf(xstats_names[count].name,
3486 : : sizeof(xstats_names[count].name),
3487 : : "tx_priority%u_%s", i,
3488 : 0 : rte_ixgbe_txq_strings[stat].name);
3489 : 0 : count++;
3490 : : }
3491 : : }
3492 : : }
3493 : 0 : return cnt_stats;
3494 : : }
3495 : :
3496 : 0 : static int ixgbe_dev_xstats_get_names_by_id(
3497 : : struct rte_eth_dev *dev,
3498 : : const uint64_t *ids,
3499 : : struct rte_eth_xstat_name *xstats_names,
3500 : : unsigned int limit)
3501 : 0 : {
3502 [ # # ]: 0 : if (!ids) {
3503 : : const unsigned int cnt_stats = ixgbe_xstats_calc_num();
3504 : : unsigned int stat, i, count;
3505 : :
3506 [ # # ]: 0 : if (xstats_names != NULL) {
3507 : : count = 0;
3508 : :
3509 : : /* Note: limit >= cnt_stats checked upstream
3510 : : * in rte_eth_xstats_names()
3511 : : */
3512 : :
3513 : : /* Extended stats from ixgbe_hw_stats */
3514 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3515 : 0 : strlcpy(xstats_names[count].name,
3516 : : rte_ixgbe_stats_strings[i].name,
3517 : : sizeof(xstats_names[count].name));
3518 : 0 : count++;
3519 : : }
3520 : :
3521 : : /* MACsec Stats */
3522 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3523 : 0 : strlcpy(xstats_names[count].name,
3524 : : rte_ixgbe_macsec_strings[i].name,
3525 : : sizeof(xstats_names[count].name));
3526 : 0 : count++;
3527 : : }
3528 : :
3529 : : /* RX Priority Stats */
3530 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3531 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3532 : 0 : snprintf(xstats_names[count].name,
3533 : : sizeof(xstats_names[count].name),
3534 : : "rx_priority%u_%s", i,
3535 : 0 : rte_ixgbe_rxq_strings[stat].name);
3536 : 0 : count++;
3537 : : }
3538 : : }
3539 : :
3540 : : /* TX Priority Stats */
3541 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3542 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3543 : 0 : snprintf(xstats_names[count].name,
3544 : : sizeof(xstats_names[count].name),
3545 : : "tx_priority%u_%s", i,
3546 : 0 : rte_ixgbe_txq_strings[stat].name);
3547 : 0 : count++;
3548 : : }
3549 : : }
3550 : : }
3551 : 0 : return cnt_stats;
3552 : : }
3553 : :
3554 : : uint16_t i;
3555 : : uint16_t size = ixgbe_xstats_calc_num();
3556 : 0 : struct rte_eth_xstat_name xstats_names_copy[size];
3557 : :
3558 : 0 : ixgbe_dev_xstats_get_names_by_id(dev, NULL, xstats_names_copy,
3559 : : size);
3560 : :
3561 [ # # ]: 0 : for (i = 0; i < limit; i++) {
3562 [ # # ]: 0 : if (ids[i] >= size) {
3563 : 0 : PMD_INIT_LOG(ERR, "id value isn't valid");
3564 : 0 : return -1;
3565 : : }
3566 : 0 : strcpy(xstats_names[i].name,
3567 : 0 : xstats_names_copy[ids[i]].name);
3568 : : }
3569 : 0 : return limit;
3570 : : }
3571 : :
3572 : 0 : static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
3573 : : struct rte_eth_xstat_name *xstats_names, unsigned limit)
3574 : : {
3575 : : unsigned i;
3576 : :
3577 [ # # ]: 0 : if (limit < IXGBEVF_NB_XSTATS && xstats_names != NULL)
3578 : : return -ENOMEM;
3579 : :
3580 [ # # ]: 0 : if (xstats_names != NULL)
3581 [ # # ]: 0 : for (i = 0; i < IXGBEVF_NB_XSTATS; i++)
3582 : 0 : strlcpy(xstats_names[i].name,
3583 : : rte_ixgbevf_stats_strings[i].name,
3584 : : sizeof(xstats_names[i].name));
3585 : : return IXGBEVF_NB_XSTATS;
3586 : : }
3587 : :
3588 : : static int
3589 : 0 : ixgbe_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3590 : : unsigned n)
3591 : : {
3592 : 0 : struct ixgbe_hw *hw =
3593 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3594 : 0 : struct ixgbe_hw_stats *hw_stats =
3595 : : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3596 : 0 : struct ixgbe_macsec_stats *macsec_stats =
3597 : : IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3598 : : dev->data->dev_private);
3599 : : uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3600 : : unsigned i, stat, count = 0;
3601 : :
3602 : : count = ixgbe_xstats_calc_num();
3603 : :
3604 [ # # ]: 0 : if (n < count)
3605 : : return count;
3606 : :
3607 : 0 : total_missed_rx = 0;
3608 : 0 : total_qbrc = 0;
3609 : 0 : total_qprc = 0;
3610 : 0 : total_qprdc = 0;
3611 : :
3612 : 0 : ixgbe_read_stats_registers(hw, hw_stats, macsec_stats, &total_missed_rx,
3613 : : &total_qbrc, &total_qprc, &total_qprdc);
3614 : :
3615 : : /* If this is a reset xstats is NULL, and we have cleared the
3616 : : * registers by reading them.
3617 : : */
3618 [ # # ]: 0 : if (!xstats)
3619 : : return 0;
3620 : :
3621 : : /* Extended stats from ixgbe_hw_stats */
3622 : : count = 0;
3623 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3624 : 0 : xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3625 : 0 : rte_ixgbe_stats_strings[i].offset);
3626 : 0 : xstats[count].id = count;
3627 : 0 : count++;
3628 : : }
3629 : :
3630 : : /* MACsec Stats */
3631 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3632 : 0 : xstats[count].value = *(uint64_t *)(((char *)macsec_stats) +
3633 : 0 : rte_ixgbe_macsec_strings[i].offset);
3634 : 0 : xstats[count].id = count;
3635 : 0 : count++;
3636 : : }
3637 : :
3638 : : /* RX Priority Stats */
3639 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3640 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3641 : 0 : xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3642 : 0 : rte_ixgbe_rxq_strings[stat].offset +
3643 : 0 : (sizeof(uint64_t) * i));
3644 : 0 : xstats[count].id = count;
3645 : 0 : count++;
3646 : : }
3647 : : }
3648 : :
3649 : : /* TX Priority Stats */
3650 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3651 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3652 : 0 : xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
3653 : 0 : rte_ixgbe_txq_strings[stat].offset +
3654 : 0 : (sizeof(uint64_t) * i));
3655 : 0 : xstats[count].id = count;
3656 : 0 : count++;
3657 : : }
3658 : : }
3659 : 0 : return count;
3660 : : }
3661 : :
3662 : : static int
3663 : 0 : ixgbe_dev_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
3664 : : uint64_t *values, unsigned int n)
3665 : 0 : {
3666 [ # # ]: 0 : if (!ids) {
3667 : 0 : struct ixgbe_hw *hw =
3668 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3669 : 0 : struct ixgbe_hw_stats *hw_stats =
3670 : : IXGBE_DEV_PRIVATE_TO_STATS(
3671 : : dev->data->dev_private);
3672 : 0 : struct ixgbe_macsec_stats *macsec_stats =
3673 : : IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3674 : : dev->data->dev_private);
3675 : : uint64_t total_missed_rx, total_qbrc, total_qprc, total_qprdc;
3676 : : unsigned int i, stat, count = 0;
3677 : :
3678 : : count = ixgbe_xstats_calc_num();
3679 : :
3680 [ # # ]: 0 : if (!ids && n < count)
3681 : : return count;
3682 : :
3683 : 0 : total_missed_rx = 0;
3684 : 0 : total_qbrc = 0;
3685 : 0 : total_qprc = 0;
3686 : 0 : total_qprdc = 0;
3687 : :
3688 : 0 : ixgbe_read_stats_registers(hw, hw_stats, macsec_stats,
3689 : : &total_missed_rx, &total_qbrc, &total_qprc,
3690 : : &total_qprdc);
3691 : :
3692 : : /* If this is a reset xstats is NULL, and we have cleared the
3693 : : * registers by reading them.
3694 : : */
3695 [ # # ]: 0 : if (!ids && !values)
3696 : : return 0;
3697 : :
3698 : : /* Extended stats from ixgbe_hw_stats */
3699 : : count = 0;
3700 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
3701 : 0 : values[count] = *(uint64_t *)(((char *)hw_stats) +
3702 : 0 : rte_ixgbe_stats_strings[i].offset);
3703 : 0 : count++;
3704 : : }
3705 : :
3706 : : /* MACsec Stats */
3707 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_MACSEC_STATS; i++) {
3708 : 0 : values[count] = *(uint64_t *)(((char *)macsec_stats) +
3709 : 0 : rte_ixgbe_macsec_strings[i].offset);
3710 : 0 : count++;
3711 : : }
3712 : :
3713 : : /* RX Priority Stats */
3714 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
3715 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
3716 : 0 : values[count] =
3717 : 0 : *(uint64_t *)(((char *)hw_stats) +
3718 : 0 : rte_ixgbe_rxq_strings[stat].offset +
3719 : 0 : (sizeof(uint64_t) * i));
3720 : 0 : count++;
3721 : : }
3722 : : }
3723 : :
3724 : : /* TX Priority Stats */
3725 [ # # ]: 0 : for (stat = 0; stat < IXGBE_NB_TXQ_PRIO_STATS; stat++) {
3726 [ # # ]: 0 : for (i = 0; i < IXGBE_NB_TXQ_PRIO_VALUES; i++) {
3727 : 0 : values[count] =
3728 : 0 : *(uint64_t *)(((char *)hw_stats) +
3729 : 0 : rte_ixgbe_txq_strings[stat].offset +
3730 : 0 : (sizeof(uint64_t) * i));
3731 : 0 : count++;
3732 : : }
3733 : : }
3734 : 0 : return count;
3735 : : }
3736 : :
3737 : : uint16_t i;
3738 : : uint16_t size = ixgbe_xstats_calc_num();
3739 : 0 : uint64_t values_copy[size];
3740 : :
3741 : 0 : ixgbe_dev_xstats_get_by_id(dev, NULL, values_copy, size);
3742 : :
3743 [ # # ]: 0 : for (i = 0; i < n; i++) {
3744 [ # # ]: 0 : if (ids[i] >= size) {
3745 : 0 : PMD_INIT_LOG(ERR, "id value isn't valid");
3746 : 0 : return -1;
3747 : : }
3748 : 0 : values[i] = values_copy[ids[i]];
3749 : : }
3750 : 0 : return n;
3751 : : }
3752 : :
3753 : : static int
3754 : 0 : ixgbe_dev_xstats_reset(struct rte_eth_dev *dev)
3755 : : {
3756 : 0 : struct ixgbe_hw_stats *stats =
3757 : 0 : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3758 : 0 : struct ixgbe_macsec_stats *macsec_stats =
3759 : : IXGBE_DEV_PRIVATE_TO_MACSEC_STATS(
3760 : : dev->data->dev_private);
3761 : :
3762 : : unsigned count = ixgbe_xstats_calc_num();
3763 : :
3764 : : /* HW registers are cleared on read */
3765 : 0 : ixgbe_dev_xstats_get(dev, NULL, count);
3766 : :
3767 : : /* Reset software totals */
3768 : : memset(stats, 0, sizeof(*stats));
3769 : : memset(macsec_stats, 0, sizeof(*macsec_stats));
3770 : :
3771 : 0 : return 0;
3772 : : }
3773 : :
3774 : : static void
3775 : 0 : ixgbevf_update_stats(struct rte_eth_dev *dev)
3776 : : {
3777 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3778 : : struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3779 : : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3780 : :
3781 : : /* Good Rx packet, include VF loopback */
3782 : 0 : UPDATE_VF_STAT(IXGBE_VFGPRC,
3783 : : hw_stats->last_vfgprc, hw_stats->vfgprc);
3784 : :
3785 : : /* Good Rx octets, include VF loopback */
3786 : 0 : UPDATE_VF_STAT_36BIT(IXGBE_VFGORC_LSB, IXGBE_VFGORC_MSB,
3787 : : hw_stats->last_vfgorc, hw_stats->vfgorc);
3788 : :
3789 : : /* Good Tx packet, include VF loopback */
3790 : 0 : UPDATE_VF_STAT(IXGBE_VFGPTC,
3791 : : hw_stats->last_vfgptc, hw_stats->vfgptc);
3792 : :
3793 : : /* Good Tx octets, include VF loopback */
3794 : 0 : UPDATE_VF_STAT_36BIT(IXGBE_VFGOTC_LSB, IXGBE_VFGOTC_MSB,
3795 : : hw_stats->last_vfgotc, hw_stats->vfgotc);
3796 : :
3797 : : /* Rx Multicst Packet */
3798 : 0 : UPDATE_VF_STAT(IXGBE_VFMPRC,
3799 : : hw_stats->last_vfmprc, hw_stats->vfmprc);
3800 : 0 : }
3801 : :
3802 : : static int
3803 : 0 : ixgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
3804 : : unsigned n)
3805 : : {
3806 : : struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3807 : 0 : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3808 : : unsigned i;
3809 : :
3810 [ # # ]: 0 : if (n < IXGBEVF_NB_XSTATS)
3811 : : return IXGBEVF_NB_XSTATS;
3812 : :
3813 : 0 : ixgbevf_update_stats(dev);
3814 : :
3815 [ # # ]: 0 : if (!xstats)
3816 : : return 0;
3817 : :
3818 : : /* Extended stats */
3819 [ # # ]: 0 : for (i = 0; i < IXGBEVF_NB_XSTATS; i++) {
3820 : 0 : xstats[i].id = i;
3821 : 0 : xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
3822 : : rte_ixgbevf_stats_strings[i].offset);
3823 : : }
3824 : :
3825 : : return IXGBEVF_NB_XSTATS;
3826 : : }
3827 : :
3828 : : static int
3829 : 0 : ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
3830 : : {
3831 : : struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3832 : 0 : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3833 : :
3834 : 0 : ixgbevf_update_stats(dev);
3835 : :
3836 [ # # ]: 0 : if (stats == NULL)
3837 : : return -EINVAL;
3838 : :
3839 : 0 : stats->ipackets = hw_stats->vfgprc;
3840 : 0 : stats->ibytes = hw_stats->vfgorc;
3841 : 0 : stats->opackets = hw_stats->vfgptc;
3842 : 0 : stats->obytes = hw_stats->vfgotc;
3843 : 0 : return 0;
3844 : : }
3845 : :
3846 : : static int
3847 : 0 : ixgbevf_dev_stats_reset(struct rte_eth_dev *dev)
3848 : : {
3849 : : struct ixgbevf_hw_stats *hw_stats = (struct ixgbevf_hw_stats *)
3850 : 0 : IXGBE_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
3851 : :
3852 : : /* Sync HW register to the last stats */
3853 : : ixgbevf_dev_stats_get(dev, NULL);
3854 : :
3855 : : /* reset HW current stats*/
3856 : 0 : hw_stats->vfgprc = 0;
3857 : 0 : hw_stats->vfgorc = 0;
3858 : 0 : hw_stats->vfgptc = 0;
3859 : 0 : hw_stats->vfgotc = 0;
3860 : 0 : hw_stats->vfmprc = 0;
3861 : :
3862 : 0 : return 0;
3863 : : }
3864 : :
3865 : : static int
3866 : 0 : ixgbe_fw_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size)
3867 : : {
3868 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3869 : : struct ixgbe_nvm_version nvm_ver;
3870 : : int ret;
3871 : :
3872 : 0 : ixgbe_get_oem_prod_version(hw, &nvm_ver);
3873 [ # # ]: 0 : if (nvm_ver.oem_valid) {
3874 : 0 : snprintf(fw_version, fw_size, "%x.%x.%x",
3875 : 0 : nvm_ver.oem_major, nvm_ver.oem_minor,
3876 : 0 : nvm_ver.oem_release);
3877 : 0 : return 0;
3878 : : }
3879 : :
3880 : 0 : ixgbe_get_etk_id(hw, &nvm_ver);
3881 : 0 : ixgbe_get_orom_version(hw, &nvm_ver);
3882 : :
3883 [ # # ]: 0 : if (nvm_ver.or_valid) {
3884 : 0 : snprintf(fw_version, fw_size, "0x%08x, %d.%d.%d",
3885 : 0 : nvm_ver.etk_id, nvm_ver.or_major,
3886 : 0 : nvm_ver.or_build, nvm_ver.or_patch);
3887 : 0 : return 0;
3888 : : }
3889 : :
3890 [ # # ]: 0 : ret = snprintf(fw_version, fw_size, "0x%08x", nvm_ver.etk_id);
3891 [ # # ]: 0 : if (ret < 0)
3892 : : return -EINVAL;
3893 : :
3894 [ # # ]: 0 : return (fw_size < (size_t)ret++) ? ret : 0;
3895 : : }
3896 : :
3897 : : static int
3898 : 0 : ixgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
3899 : : {
3900 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
3901 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3902 : : struct rte_eth_conf *dev_conf = &dev->data->dev_conf;
3903 : :
3904 : 0 : dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
3905 : 0 : dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
3906 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active == 0) {
3907 : : /*
3908 : : * When DCB/VT is off, maximum number of queues changes,
3909 : : * except for 82598EB, which remains constant.
3910 : : */
3911 [ # # ]: 0 : if (dev_conf->txmode.mq_mode == RTE_ETH_MQ_TX_NONE &&
3912 [ # # ]: 0 : hw->mac.type != ixgbe_mac_82598EB)
3913 : 0 : dev_info->max_tx_queues = IXGBE_NONE_MODE_TX_NB_QUEUES;
3914 : : }
3915 : 0 : dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL register */
3916 : 0 : dev_info->max_rx_pktlen = 15872; /* includes CRC, cf MAXFRS register */
3917 : 0 : dev_info->max_mac_addrs = hw->mac.num_rar_entries;
3918 : 0 : dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
3919 : 0 : dev_info->max_vfs = pci_dev->max_vfs;
3920 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
3921 : 0 : dev_info->max_vmdq_pools = RTE_ETH_16_POOLS;
3922 : : else
3923 : 0 : dev_info->max_vmdq_pools = RTE_ETH_64_POOLS;
3924 : 0 : dev_info->max_mtu = dev_info->max_rx_pktlen - IXGBE_ETH_OVERHEAD;
3925 : 0 : dev_info->min_mtu = RTE_ETHER_MIN_MTU;
3926 : 0 : dev_info->vmdq_queue_num = dev_info->max_rx_queues;
3927 : 0 : dev_info->rx_queue_offload_capa = ixgbe_get_rx_queue_offloads(dev);
3928 : 0 : dev_info->rx_offload_capa = (ixgbe_get_rx_port_offloads(dev) |
3929 : 0 : dev_info->rx_queue_offload_capa);
3930 : 0 : dev_info->tx_queue_offload_capa = ixgbe_get_tx_queue_offloads(dev);
3931 : 0 : dev_info->tx_offload_capa = ixgbe_get_tx_port_offloads(dev);
3932 : :
3933 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
3934 : : .rx_thresh = {
3935 : : .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
3936 : : .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
3937 : : .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
3938 : : },
3939 : : .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
3940 : : .rx_drop_en = 0,
3941 : : .offloads = 0,
3942 : : };
3943 : :
3944 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
3945 : : .tx_thresh = {
3946 : : .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
3947 : : .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
3948 : : .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
3949 : : },
3950 : : .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
3951 : : .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
3952 : : .offloads = 0,
3953 : : };
3954 : :
3955 : 0 : dev_info->rx_desc_lim = rx_desc_lim;
3956 : 0 : dev_info->tx_desc_lim = tx_desc_lim;
3957 : :
3958 : 0 : dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
3959 : 0 : dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
3960 : 0 : dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
3961 : :
3962 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_1G | RTE_ETH_LINK_SPEED_10G;
3963 [ # # ]: 0 : if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
3964 : : hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L)
3965 : 0 : dev_info->speed_capa = RTE_ETH_LINK_SPEED_10M |
3966 : : RTE_ETH_LINK_SPEED_100M | RTE_ETH_LINK_SPEED_1G;
3967 : :
3968 : 0 : if (hw->mac.type == ixgbe_mac_X540 ||
3969 : : hw->mac.type == ixgbe_mac_X540_vf ||
3970 [ # # ]: 0 : hw->mac.type == ixgbe_mac_X550 ||
3971 : : hw->mac.type == ixgbe_mac_X550_vf) {
3972 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_100M;
3973 : : }
3974 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X550) {
3975 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_2_5G;
3976 : 0 : dev_info->speed_capa |= RTE_ETH_LINK_SPEED_5G;
3977 : : }
3978 : :
3979 : : /* Driver-preferred Rx/Tx parameters */
3980 : 0 : dev_info->default_rxportconf.burst_size = 32;
3981 : 0 : dev_info->default_txportconf.burst_size = 32;
3982 : 0 : dev_info->default_rxportconf.nb_queues = 1;
3983 : 0 : dev_info->default_txportconf.nb_queues = 1;
3984 : 0 : dev_info->default_rxportconf.ring_size = 256;
3985 : 0 : dev_info->default_txportconf.ring_size = 256;
3986 : :
3987 : 0 : return 0;
3988 : : }
3989 : :
3990 : : static const uint32_t *
3991 : 0 : ixgbe_dev_supported_ptypes_get(struct rte_eth_dev *dev, size_t *no_of_elements)
3992 : : {
3993 : : static const uint32_t ptypes[] = {
3994 : : /* For non-vec functions,
3995 : : * refers to ixgbe_rxd_pkt_info_to_pkt_type();
3996 : : * for vec functions,
3997 : : * refers to _recv_raw_pkts_vec().
3998 : : */
3999 : : RTE_PTYPE_L2_ETHER,
4000 : : RTE_PTYPE_L3_IPV4,
4001 : : RTE_PTYPE_L3_IPV4_EXT,
4002 : : RTE_PTYPE_L3_IPV6,
4003 : : RTE_PTYPE_L3_IPV6_EXT,
4004 : : RTE_PTYPE_L4_SCTP,
4005 : : RTE_PTYPE_L4_TCP,
4006 : : RTE_PTYPE_L4_UDP,
4007 : : RTE_PTYPE_TUNNEL_IP,
4008 : : RTE_PTYPE_INNER_L3_IPV6,
4009 : : RTE_PTYPE_INNER_L3_IPV6_EXT,
4010 : : RTE_PTYPE_INNER_L4_TCP,
4011 : : RTE_PTYPE_INNER_L4_UDP,
4012 : : };
4013 : :
4014 [ # # # # ]: 0 : if (dev->rx_pkt_burst == ixgbe_recv_pkts ||
4015 [ # # ]: 0 : dev->rx_pkt_burst == ixgbe_recv_pkts_lro_single_alloc ||
4016 [ # # ]: 0 : dev->rx_pkt_burst == ixgbe_recv_pkts_lro_bulk_alloc ||
4017 : : dev->rx_pkt_burst == ixgbe_recv_pkts_bulk_alloc) {
4018 : 0 : *no_of_elements = RTE_DIM(ptypes);
4019 : 0 : return ptypes;
4020 : : }
4021 : :
4022 : : #if defined(RTE_ARCH_X86) || defined(__ARM_NEON)
4023 [ # # # # ]: 0 : if (dev->rx_pkt_burst == ixgbe_recv_pkts_vec ||
4024 : : dev->rx_pkt_burst == ixgbe_recv_scattered_pkts_vec) {
4025 : 0 : *no_of_elements = RTE_DIM(ptypes);
4026 : 0 : return ptypes;
4027 : : }
4028 : : #endif
4029 : : return NULL;
4030 : : }
4031 : :
4032 : : static int
4033 : 0 : ixgbevf_dev_info_get(struct rte_eth_dev *dev,
4034 : : struct rte_eth_dev_info *dev_info)
4035 : : {
4036 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4037 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4038 : :
4039 : 0 : dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
4040 : 0 : dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
4041 : 0 : dev_info->min_rx_bufsize = 1024; /* cf BSIZEPACKET in SRRCTL reg */
4042 : 0 : dev_info->max_rx_pktlen = 9728; /* includes CRC, cf MAXFRS reg */
4043 : 0 : dev_info->max_mtu = dev_info->max_rx_pktlen - IXGBE_ETH_OVERHEAD;
4044 : 0 : dev_info->max_mac_addrs = hw->mac.num_rar_entries;
4045 : 0 : dev_info->max_hash_mac_addrs = IXGBE_VMDQ_NUM_UC_MAC;
4046 : 0 : dev_info->max_vfs = pci_dev->max_vfs;
4047 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB)
4048 : 0 : dev_info->max_vmdq_pools = RTE_ETH_16_POOLS;
4049 : : else
4050 : 0 : dev_info->max_vmdq_pools = RTE_ETH_64_POOLS;
4051 : 0 : dev_info->rx_queue_offload_capa = ixgbe_get_rx_queue_offloads(dev);
4052 : 0 : dev_info->rx_offload_capa = (ixgbe_get_rx_port_offloads(dev) |
4053 : 0 : dev_info->rx_queue_offload_capa);
4054 : 0 : dev_info->tx_queue_offload_capa = ixgbe_get_tx_queue_offloads(dev);
4055 : 0 : dev_info->tx_offload_capa = ixgbe_get_tx_port_offloads(dev);
4056 : 0 : dev_info->hash_key_size = IXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
4057 : 0 : dev_info->reta_size = ixgbe_reta_size_get(hw->mac.type);
4058 : 0 : dev_info->flow_type_rss_offloads = IXGBE_RSS_OFFLOAD_ALL;
4059 : :
4060 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
4061 : : .rx_thresh = {
4062 : : .pthresh = IXGBE_DEFAULT_RX_PTHRESH,
4063 : : .hthresh = IXGBE_DEFAULT_RX_HTHRESH,
4064 : : .wthresh = IXGBE_DEFAULT_RX_WTHRESH,
4065 : : },
4066 : : .rx_free_thresh = IXGBE_DEFAULT_RX_FREE_THRESH,
4067 : : .rx_drop_en = 0,
4068 : : .offloads = 0,
4069 : : };
4070 : :
4071 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
4072 : : .tx_thresh = {
4073 : : .pthresh = IXGBE_DEFAULT_TX_PTHRESH,
4074 : : .hthresh = IXGBE_DEFAULT_TX_HTHRESH,
4075 : : .wthresh = IXGBE_DEFAULT_TX_WTHRESH,
4076 : : },
4077 : : .tx_free_thresh = IXGBE_DEFAULT_TX_FREE_THRESH,
4078 : : .tx_rs_thresh = IXGBE_DEFAULT_TX_RSBIT_THRESH,
4079 : : .offloads = 0,
4080 : : };
4081 : :
4082 : 0 : dev_info->rx_desc_lim = rx_desc_lim;
4083 : 0 : dev_info->tx_desc_lim = tx_desc_lim;
4084 : :
4085 : 0 : dev_info->err_handle_mode = RTE_ETH_ERROR_HANDLE_MODE_PASSIVE;
4086 : :
4087 : 0 : return 0;
4088 : : }
4089 : :
4090 : : static int
4091 : 0 : ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
4092 : : bool *link_up, int wait_to_complete)
4093 : : {
4094 : : struct ixgbe_adapter *adapter = container_of(hw,
4095 : : struct ixgbe_adapter, hw);
4096 : : struct ixgbe_mbx_info *mbx = &hw->mbx;
4097 : : struct ixgbe_mac_info *mac = &hw->mac;
4098 : : uint32_t links_reg, in_msg;
4099 : : int ret_val = 0;
4100 : :
4101 : : /* If we were hit with a reset drop the link */
4102 [ # # # # ]: 0 : if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
4103 : 0 : mac->get_link_status = true;
4104 : :
4105 [ # # ]: 0 : if (!mac->get_link_status)
4106 : 0 : goto out;
4107 : :
4108 : : /* if link status is down no point in checking to see if pf is up */
4109 : 0 : links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
4110 [ # # ]: 0 : if (!(links_reg & IXGBE_LINKS_UP))
4111 : 0 : goto out;
4112 : :
4113 : : /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
4114 : : * before the link status is correct
4115 : : */
4116 [ # # # # ]: 0 : if (mac->type == ixgbe_mac_82599_vf && wait_to_complete) {
4117 : : int i;
4118 : :
4119 [ # # ]: 0 : for (i = 0; i < 5; i++) {
4120 : 0 : rte_delay_us(100);
4121 : 0 : links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
4122 : :
4123 [ # # ]: 0 : if (!(links_reg & IXGBE_LINKS_UP))
4124 : 0 : goto out;
4125 : : }
4126 : : }
4127 : :
4128 [ # # # # : 0 : switch (links_reg & IXGBE_LINKS_SPEED_82599) {
# ]
4129 : 0 : case IXGBE_LINKS_SPEED_10G_82599:
4130 : 0 : *speed = IXGBE_LINK_SPEED_10GB_FULL;
4131 [ # # ]: 0 : if (hw->mac.type >= ixgbe_mac_X550) {
4132 [ # # ]: 0 : if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
4133 : 0 : *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
4134 : : }
4135 : : break;
4136 : 0 : case IXGBE_LINKS_SPEED_1G_82599:
4137 : 0 : *speed = IXGBE_LINK_SPEED_1GB_FULL;
4138 : 0 : break;
4139 : 0 : case IXGBE_LINKS_SPEED_100_82599:
4140 : 0 : *speed = IXGBE_LINK_SPEED_100_FULL;
4141 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X550) {
4142 [ # # ]: 0 : if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
4143 : 0 : *speed = IXGBE_LINK_SPEED_5GB_FULL;
4144 : : }
4145 : : break;
4146 : 0 : case IXGBE_LINKS_SPEED_10_X550EM_A:
4147 : 0 : *speed = IXGBE_LINK_SPEED_UNKNOWN;
4148 : : /* Since Reserved in older MAC's */
4149 [ # # ]: 0 : if (hw->mac.type >= ixgbe_mac_X550)
4150 : 0 : *speed = IXGBE_LINK_SPEED_10_FULL;
4151 : : break;
4152 : 0 : default:
4153 : 0 : *speed = IXGBE_LINK_SPEED_UNKNOWN;
4154 : : }
4155 : :
4156 [ # # # # ]: 0 : if (wait_to_complete == 0 && adapter->pflink_fullchk == 0) {
4157 [ # # ]: 0 : if (*speed == IXGBE_LINK_SPEED_UNKNOWN)
4158 : 0 : mac->get_link_status = true;
4159 : : else
4160 : 0 : mac->get_link_status = false;
4161 : :
4162 : 0 : goto out;
4163 : : }
4164 : :
4165 : : /* if the read failed it could just be a mailbox collision, best wait
4166 : : * until we are called again and don't report an error
4167 : : */
4168 [ # # ]: 0 : if (mbx->ops.read(hw, &in_msg, 1, 0))
4169 : 0 : goto out;
4170 : :
4171 [ # # ]: 0 : if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) {
4172 : : /* msg is not CTS and is NACK we must have lost CTS status */
4173 [ # # ]: 0 : if (in_msg & IXGBE_VT_MSGTYPE_NACK)
4174 : 0 : mac->get_link_status = false;
4175 : 0 : goto out;
4176 : : }
4177 : :
4178 : : /* the pf is talking, if we timed out in the past we reinit */
4179 [ # # ]: 0 : if (!mbx->timeout) {
4180 : : ret_val = -1;
4181 : 0 : goto out;
4182 : : }
4183 : :
4184 : : /* if we passed all the tests above then the link is up and we no
4185 : : * longer need to check for link
4186 : : */
4187 : 0 : mac->get_link_status = false;
4188 : :
4189 : 0 : out:
4190 : 0 : *link_up = !mac->get_link_status;
4191 : 0 : return ret_val;
4192 : : }
4193 : :
4194 : : /*
4195 : : * If @timeout_ms was 0, it means that it will not return until link complete.
4196 : : * It returns 1 on complete, return 0 on timeout.
4197 : : */
4198 : : static int
4199 : 0 : ixgbe_dev_wait_setup_link_complete(struct rte_eth_dev *dev, uint32_t timeout_ms)
4200 : : {
4201 : : #define WARNING_TIMEOUT 9000 /* 9s in total */
4202 : 0 : struct ixgbe_adapter *ad = dev->data->dev_private;
4203 [ # # ]: 0 : uint32_t timeout = timeout_ms ? timeout_ms : WARNING_TIMEOUT;
4204 : :
4205 : : /* NOTE: review for potential ordering optimization */
4206 [ # # ]: 0 : while (__atomic_load_n(&ad->link_thread_running, __ATOMIC_SEQ_CST)) {
4207 : 0 : msec_delay(1);
4208 : 0 : timeout--;
4209 : :
4210 [ # # ]: 0 : if (timeout_ms) {
4211 [ # # ]: 0 : if (!timeout)
4212 : : return 0;
4213 [ # # ]: 0 : } else if (!timeout) {
4214 : : /* It will not return until link complete */
4215 : : timeout = WARNING_TIMEOUT;
4216 : 0 : PMD_DRV_LOG(ERR, "IXGBE link thread not complete too long time!");
4217 : : }
4218 : : }
4219 : :
4220 : : return 1;
4221 : : }
4222 : :
4223 : : static uint32_t
4224 : 0 : ixgbe_dev_setup_link_thread_handler(void *param)
4225 : : {
4226 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4227 : 0 : struct ixgbe_adapter *ad = dev->data->dev_private;
4228 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4229 : : struct ixgbe_interrupt *intr =
4230 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4231 : : u32 speed;
4232 : 0 : bool autoneg = false;
4233 : :
4234 : 0 : rte_thread_detach(rte_thread_self());
4235 : 0 : speed = hw->phy.autoneg_advertised;
4236 [ # # ]: 0 : if (!speed)
4237 : 0 : ixgbe_get_link_capabilities(hw, &speed, &autoneg);
4238 : :
4239 : 0 : ixgbe_setup_link(hw, speed, true);
4240 : :
4241 : 0 : intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG;
4242 : : /* NOTE: review for potential ordering optimization */
4243 : 0 : __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST);
4244 : 0 : return 0;
4245 : : }
4246 : :
4247 : : /*
4248 : : * In freebsd environment, nic_uio drivers do not support interrupts,
4249 : : * rte_intr_callback_register() will fail to register interrupts.
4250 : : * We can not make link status to change from down to up by interrupt
4251 : : * callback. So we need to wait for the controller to acquire link
4252 : : * when ports start.
4253 : : * It returns 0 on link up.
4254 : : */
4255 : : static int
4256 : : ixgbe_wait_for_link_up(struct ixgbe_hw *hw)
4257 : : {
4258 : : #ifdef RTE_EXEC_ENV_FREEBSD
4259 : : int err, i;
4260 : : bool link_up = false;
4261 : : uint32_t speed = 0;
4262 : : const int nb_iter = 25;
4263 : :
4264 : : for (i = 0; i < nb_iter; i++) {
4265 : : err = ixgbe_check_link(hw, &speed, &link_up, 0);
4266 : : if (err)
4267 : : return err;
4268 : : if (link_up)
4269 : : return 0;
4270 : : msec_delay(200);
4271 : : }
4272 : :
4273 : : return 0;
4274 : : #else
4275 : : RTE_SET_USED(hw);
4276 : : return 0;
4277 : : #endif
4278 : : }
4279 : :
4280 : : /* return 0 means link status changed, -1 means not changed */
4281 : : int
4282 : 0 : ixgbe_dev_link_update_share(struct rte_eth_dev *dev,
4283 : : int wait_to_complete, int vf)
4284 : : {
4285 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4286 : : struct ixgbe_adapter *ad = dev->data->dev_private;
4287 : : struct rte_eth_link link;
4288 [ # # ]: 0 : ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN;
4289 : : struct ixgbe_interrupt *intr =
4290 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4291 : : bool link_up;
4292 : : int diag;
4293 : : int wait = 1;
4294 : : u32 esdp_reg;
4295 : :
4296 : : memset(&link, 0, sizeof(link));
4297 : : link.link_status = RTE_ETH_LINK_DOWN;
4298 : : link.link_speed = RTE_ETH_SPEED_NUM_NONE;
4299 : : link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
4300 : 0 : link.link_autoneg = !(dev->data->dev_conf.link_speeds &
4301 : : RTE_ETH_LINK_SPEED_FIXED);
4302 : :
4303 : 0 : hw->mac.get_link_status = true;
4304 : :
4305 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG)
4306 : 0 : return rte_eth_linkstatus_set(dev, &link);
4307 : :
4308 : : /* check if it needs to wait to complete, if lsc interrupt is enabled */
4309 [ # # # # ]: 0 : if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0)
4310 : : wait = 0;
4311 : :
4312 : : /* BSD has no interrupt mechanism, so force NIC status synchronization. */
4313 : : #ifdef RTE_EXEC_ENV_FREEBSD
4314 : : wait = 1;
4315 : : #endif
4316 : :
4317 [ # # ]: 0 : if (vf)
4318 : 0 : diag = ixgbevf_check_link(hw, &link_speed, &link_up, wait);
4319 : : else
4320 : 0 : diag = ixgbe_check_link(hw, &link_speed, &link_up, wait);
4321 : :
4322 [ # # ]: 0 : if (diag != 0) {
4323 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
4324 [ # # ]: 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
4325 : 0 : return rte_eth_linkstatus_set(dev, &link);
4326 : : }
4327 : :
4328 [ # # ]: 0 : if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber &&
4329 [ # # ]: 0 : !ad->sdp3_no_tx_disable) {
4330 : 0 : esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
4331 [ # # ]: 0 : if ((esdp_reg & IXGBE_ESDP_SDP3))
4332 : 0 : link_up = 0;
4333 : : }
4334 : :
4335 [ # # ]: 0 : if (link_up == 0) {
4336 [ # # ]: 0 : if (ixgbe_get_media_type(hw) == ixgbe_media_type_fiber) {
4337 : 0 : ixgbe_dev_wait_setup_link_complete(dev, 0);
4338 : : /* NOTE: review for potential ordering optimization */
4339 [ # # ]: 0 : if (!__atomic_test_and_set(&ad->link_thread_running, __ATOMIC_SEQ_CST)) {
4340 : : /* To avoid race condition between threads, set
4341 : : * the IXGBE_FLAG_NEED_LINK_CONFIG flag only
4342 : : * when there is no link thread running.
4343 : : */
4344 : 0 : intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG;
4345 [ # # ]: 0 : if (rte_thread_create_internal_control(&ad->link_thread_tid,
4346 : : "ixgbe-link",
4347 : : ixgbe_dev_setup_link_thread_handler, dev) < 0) {
4348 : 0 : PMD_DRV_LOG(ERR,
4349 : : "Create link thread failed!");
4350 : : /* NOTE: review for potential ordering optimization */
4351 : 0 : __atomic_clear(&ad->link_thread_running, __ATOMIC_SEQ_CST);
4352 : : }
4353 : : } else {
4354 : 0 : PMD_DRV_LOG(ERR,
4355 : : "Other link thread is running now!");
4356 : : }
4357 : : }
4358 : 0 : return rte_eth_linkstatus_set(dev, &link);
4359 : : }
4360 : :
4361 : 0 : link.link_status = RTE_ETH_LINK_UP;
4362 : 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
4363 : :
4364 [ # # # # : 0 : switch (link_speed) {
# # # ]
4365 : 0 : default:
4366 : : case IXGBE_LINK_SPEED_UNKNOWN:
4367 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_UNKNOWN;
4368 : 0 : break;
4369 : :
4370 : 0 : case IXGBE_LINK_SPEED_10_FULL:
4371 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_10M;
4372 : 0 : break;
4373 : :
4374 : 0 : case IXGBE_LINK_SPEED_100_FULL:
4375 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_100M;
4376 : 0 : break;
4377 : :
4378 : 0 : case IXGBE_LINK_SPEED_1GB_FULL:
4379 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_1G;
4380 : 0 : break;
4381 : :
4382 : 0 : case IXGBE_LINK_SPEED_2_5GB_FULL:
4383 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_2_5G;
4384 : 0 : break;
4385 : :
4386 : 0 : case IXGBE_LINK_SPEED_5GB_FULL:
4387 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_5G;
4388 : 0 : break;
4389 : :
4390 : 0 : case IXGBE_LINK_SPEED_10GB_FULL:
4391 : 0 : link.link_speed = RTE_ETH_SPEED_NUM_10G;
4392 : 0 : break;
4393 : : }
4394 : :
4395 : : return rte_eth_linkstatus_set(dev, &link);
4396 : : }
4397 : :
4398 : : static int
4399 : 0 : ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
4400 : : {
4401 : 0 : return ixgbe_dev_link_update_share(dev, wait_to_complete, 0);
4402 : : }
4403 : :
4404 : : static int
4405 : 0 : ixgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
4406 : : {
4407 : 0 : return ixgbe_dev_link_update_share(dev, wait_to_complete, 1);
4408 : : }
4409 : :
4410 : : static int
4411 : 0 : ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev)
4412 : : {
4413 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4414 : : uint32_t fctrl;
4415 : :
4416 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4417 : 0 : fctrl |= (IXGBE_FCTRL_UPE | IXGBE_FCTRL_MPE);
4418 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4419 : :
4420 : 0 : return 0;
4421 : : }
4422 : :
4423 : : static int
4424 : 0 : ixgbe_dev_promiscuous_disable(struct rte_eth_dev *dev)
4425 : : {
4426 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4427 : : uint32_t fctrl;
4428 : :
4429 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4430 : 0 : fctrl &= (~IXGBE_FCTRL_UPE);
4431 [ # # ]: 0 : if (dev->data->all_multicast == 1)
4432 : 0 : fctrl |= IXGBE_FCTRL_MPE;
4433 : : else
4434 : 0 : fctrl &= (~IXGBE_FCTRL_MPE);
4435 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4436 : :
4437 : 0 : return 0;
4438 : : }
4439 : :
4440 : : static int
4441 : 0 : ixgbe_dev_allmulticast_enable(struct rte_eth_dev *dev)
4442 : : {
4443 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4444 : : uint32_t fctrl;
4445 : :
4446 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4447 : 0 : fctrl |= IXGBE_FCTRL_MPE;
4448 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4449 : :
4450 : 0 : return 0;
4451 : : }
4452 : :
4453 : : static int
4454 : 0 : ixgbe_dev_allmulticast_disable(struct rte_eth_dev *dev)
4455 : : {
4456 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4457 : : uint32_t fctrl;
4458 : :
4459 [ # # ]: 0 : if (dev->data->promiscuous == 1)
4460 : : return 0; /* must remain in all_multicast mode */
4461 : :
4462 : 0 : fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
4463 : 0 : fctrl &= (~IXGBE_FCTRL_MPE);
4464 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
4465 : :
4466 : 0 : return 0;
4467 : : }
4468 : :
4469 : : /**
4470 : : * It clears the interrupt causes and enables the interrupt.
4471 : : * It will be called once only during nic initialized.
4472 : : *
4473 : : * @param dev
4474 : : * Pointer to struct rte_eth_dev.
4475 : : * @param on
4476 : : * Enable or Disable.
4477 : : *
4478 : : * @return
4479 : : * - On success, zero.
4480 : : * - On failure, a negative value.
4481 : : */
4482 : : static int
4483 : 0 : ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev, uint8_t on)
4484 : : {
4485 : : struct ixgbe_interrupt *intr =
4486 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4487 : :
4488 : 0 : ixgbe_dev_link_status_print(dev);
4489 [ # # ]: 0 : if (on)
4490 : 0 : intr->mask |= IXGBE_EICR_LSC;
4491 : : else
4492 : 0 : intr->mask &= ~IXGBE_EICR_LSC;
4493 : :
4494 : 0 : return 0;
4495 : : }
4496 : :
4497 : : /**
4498 : : * It clears the interrupt causes and enables the interrupt.
4499 : : * It will be called once only during nic initialized.
4500 : : *
4501 : : * @param dev
4502 : : * Pointer to struct rte_eth_dev.
4503 : : *
4504 : : * @return
4505 : : * - On success, zero.
4506 : : * - On failure, a negative value.
4507 : : */
4508 : : static int
4509 : : ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev)
4510 : : {
4511 : : struct ixgbe_interrupt *intr =
4512 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4513 : :
4514 : 0 : intr->mask |= IXGBE_EICR_RTX_QUEUE;
4515 : :
4516 : 0 : return 0;
4517 : : }
4518 : :
4519 : : /**
4520 : : * It clears the interrupt causes and enables the interrupt.
4521 : : * It will be called once only during nic initialized.
4522 : : *
4523 : : * @param dev
4524 : : * Pointer to struct rte_eth_dev.
4525 : : *
4526 : : * @return
4527 : : * - On success, zero.
4528 : : * - On failure, a negative value.
4529 : : */
4530 : : static int
4531 : : ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev)
4532 : : {
4533 : : struct ixgbe_interrupt *intr =
4534 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4535 : :
4536 : 0 : intr->mask |= IXGBE_EICR_LINKSEC;
4537 : :
4538 : 0 : return 0;
4539 : : }
4540 : :
4541 : : /*
4542 : : * It reads ICR and sets flag (IXGBE_EICR_LSC) for the link_update.
4543 : : *
4544 : : * @param dev
4545 : : * Pointer to struct rte_eth_dev.
4546 : : *
4547 : : * @return
4548 : : * - On success, zero.
4549 : : * - On failure, a negative value.
4550 : : */
4551 : : static int
4552 : 0 : ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev)
4553 : : {
4554 : : uint32_t eicr;
4555 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4556 : : struct ixgbe_interrupt *intr =
4557 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4558 : :
4559 : : /* clear all cause mask */
4560 : 0 : ixgbe_disable_intr(hw);
4561 : :
4562 : : /* read-on-clear nic registers here */
4563 : 0 : eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4564 : 0 : PMD_DRV_LOG(DEBUG, "eicr %x", eicr);
4565 : :
4566 : 0 : intr->flags = 0;
4567 : :
4568 : : /* set flag for async link update */
4569 [ # # ]: 0 : if (eicr & IXGBE_EICR_LSC)
4570 : 0 : intr->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;
4571 : :
4572 [ # # ]: 0 : if (eicr & IXGBE_EICR_MAILBOX)
4573 : 0 : intr->flags |= IXGBE_FLAG_MAILBOX;
4574 : :
4575 [ # # ]: 0 : if (eicr & IXGBE_EICR_LINKSEC)
4576 : 0 : intr->flags |= IXGBE_FLAG_MACSEC;
4577 : :
4578 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X550EM_x &&
4579 [ # # ]: 0 : hw->phy.type == ixgbe_phy_x550em_ext_t &&
4580 [ # # ]: 0 : (eicr & IXGBE_EICR_GPI_SDP0_X550EM_x))
4581 : 0 : intr->flags |= IXGBE_FLAG_PHY_INTERRUPT;
4582 : :
4583 : 0 : return 0;
4584 : : }
4585 : :
4586 : : /**
4587 : : * It gets and then prints the link status.
4588 : : *
4589 : : * @param dev
4590 : : * Pointer to struct rte_eth_dev.
4591 : : *
4592 : : * @return
4593 : : * - On success, zero.
4594 : : * - On failure, a negative value.
4595 : : */
4596 : : static void
4597 : 0 : ixgbe_dev_link_status_print(struct rte_eth_dev *dev)
4598 : : {
4599 [ # # ]: 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4600 : : struct rte_eth_link link;
4601 : :
4602 : : rte_eth_linkstatus_get(dev, &link);
4603 : :
4604 [ # # ]: 0 : if (link.link_status) {
4605 [ # # ]: 0 : PMD_INIT_LOG(INFO, "Port %d: Link Up - speed %u Mbps - %s",
4606 : : (int)(dev->data->port_id),
4607 : : (unsigned)link.link_speed,
4608 : : link.link_duplex == RTE_ETH_LINK_FULL_DUPLEX ?
4609 : : "full-duplex" : "half-duplex");
4610 : : } else {
4611 : 0 : PMD_INIT_LOG(INFO, " Port %d: Link Down",
4612 : : (int)(dev->data->port_id));
4613 : : }
4614 : 0 : PMD_INIT_LOG(DEBUG, "PCI Address: " PCI_PRI_FMT,
4615 : : pci_dev->addr.domain,
4616 : : pci_dev->addr.bus,
4617 : : pci_dev->addr.devid,
4618 : : pci_dev->addr.function);
4619 : 0 : }
4620 : :
4621 : : /*
4622 : : * It executes link_update after knowing an interrupt occurred.
4623 : : *
4624 : : * @param dev
4625 : : * Pointer to struct rte_eth_dev.
4626 : : *
4627 : : * @return
4628 : : * - On success, zero.
4629 : : * - On failure, a negative value.
4630 : : */
4631 : : static int
4632 : 0 : ixgbe_dev_interrupt_action(struct rte_eth_dev *dev)
4633 : : {
4634 : : struct ixgbe_interrupt *intr =
4635 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4636 : : int64_t timeout;
4637 : 0 : struct ixgbe_hw *hw =
4638 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4639 : :
4640 : 0 : PMD_DRV_LOG(DEBUG, "intr action type %d", intr->flags);
4641 : :
4642 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_MAILBOX) {
4643 : 0 : ixgbe_pf_mbx_process(dev);
4644 : 0 : intr->flags &= ~IXGBE_FLAG_MAILBOX;
4645 : : }
4646 : :
4647 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4648 : 0 : ixgbe_handle_lasi(hw);
4649 : 0 : intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4650 : : }
4651 : :
4652 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4653 : : struct rte_eth_link link;
4654 : :
4655 : : /* get the link status before link update, for predicting later */
4656 : : rte_eth_linkstatus_get(dev, &link);
4657 : :
4658 : : ixgbe_dev_link_update(dev, 0);
4659 : :
4660 : : /* likely to up */
4661 [ # # ]: 0 : if (!link.link_status)
4662 : : /* handle it 1 sec later, wait it being stable */
4663 : : timeout = IXGBE_LINK_UP_CHECK_TIMEOUT;
4664 : : /* likely to down */
4665 : : else
4666 : : /* handle it 4 sec later, wait it being stable */
4667 : : timeout = IXGBE_LINK_DOWN_CHECK_TIMEOUT;
4668 : :
4669 : 0 : ixgbe_dev_link_status_print(dev);
4670 [ # # ]: 0 : if (rte_eal_alarm_set(timeout * 1000,
4671 : : ixgbe_dev_interrupt_delayed_handler, (void *)dev) < 0)
4672 : 0 : PMD_DRV_LOG(ERR, "Error setting alarm");
4673 : : else {
4674 : : /* remember original mask */
4675 : 0 : intr->mask_original = intr->mask;
4676 : : /* only disable lsc interrupt */
4677 : 0 : intr->mask &= ~IXGBE_EIMS_LSC;
4678 : : }
4679 : : }
4680 : :
4681 : 0 : PMD_DRV_LOG(DEBUG, "enable intr immediately");
4682 : : ixgbe_enable_intr(dev);
4683 : :
4684 : 0 : return 0;
4685 : : }
4686 : :
4687 : : /**
4688 : : * Interrupt handler which shall be registered for alarm callback for delayed
4689 : : * handling specific interrupt to wait for the stable nic state. As the
4690 : : * NIC interrupt state is not stable for ixgbe after link is just down,
4691 : : * it needs to wait 4 seconds to get the stable status.
4692 : : *
4693 : : * @param handle
4694 : : * Pointer to interrupt handle.
4695 : : * @param param
4696 : : * The address of parameter (struct rte_eth_dev *) registered before.
4697 : : *
4698 : : * @return
4699 : : * void
4700 : : */
4701 : : static void
4702 : 0 : ixgbe_dev_interrupt_delayed_handler(void *param)
4703 : : {
4704 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4705 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
4706 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
4707 : : struct ixgbe_interrupt *intr =
4708 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
4709 : 0 : struct ixgbe_hw *hw =
4710 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4711 : : uint32_t eicr;
4712 : :
4713 : 0 : ixgbe_disable_intr(hw);
4714 : :
4715 : 0 : eicr = IXGBE_READ_REG(hw, IXGBE_EICR);
4716 [ # # ]: 0 : if (eicr & IXGBE_EICR_MAILBOX)
4717 : 0 : ixgbe_pf_mbx_process(dev);
4718 : :
4719 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_PHY_INTERRUPT) {
4720 : 0 : ixgbe_handle_lasi(hw);
4721 : 0 : intr->flags &= ~IXGBE_FLAG_PHY_INTERRUPT;
4722 : : }
4723 : :
4724 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_NEED_LINK_UPDATE) {
4725 : : ixgbe_dev_link_update(dev, 0);
4726 : 0 : intr->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE;
4727 : 0 : ixgbe_dev_link_status_print(dev);
4728 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
4729 : : }
4730 : :
4731 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_MACSEC) {
4732 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_MACSEC, NULL);
4733 : 0 : intr->flags &= ~IXGBE_FLAG_MACSEC;
4734 : : }
4735 : :
4736 : : /* restore original mask */
4737 : 0 : intr->mask = intr->mask_original;
4738 : 0 : intr->mask_original = 0;
4739 : :
4740 : 0 : PMD_DRV_LOG(DEBUG, "enable intr in delayed handler S[%08x]", eicr);
4741 : : ixgbe_enable_intr(dev);
4742 : 0 : rte_intr_ack(intr_handle);
4743 : 0 : }
4744 : :
4745 : : /**
4746 : : * Interrupt handler triggered by NIC for handling
4747 : : * specific interrupt.
4748 : : *
4749 : : * @param handle
4750 : : * Pointer to interrupt handle.
4751 : : * @param param
4752 : : * The address of parameter (struct rte_eth_dev *) registered before.
4753 : : *
4754 : : * @return
4755 : : * void
4756 : : */
4757 : : static void
4758 : 0 : ixgbe_dev_interrupt_handler(void *param)
4759 : : {
4760 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
4761 : :
4762 : 0 : ixgbe_dev_interrupt_get_status(dev);
4763 : 0 : ixgbe_dev_interrupt_action(dev);
4764 : 0 : }
4765 : :
4766 : : static int
4767 : 0 : ixgbe_dev_led_on(struct rte_eth_dev *dev)
4768 : : {
4769 : : struct ixgbe_hw *hw;
4770 : :
4771 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4772 [ # # ]: 0 : return ixgbe_led_on(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4773 : : }
4774 : :
4775 : : static int
4776 : 0 : ixgbe_dev_led_off(struct rte_eth_dev *dev)
4777 : : {
4778 : : struct ixgbe_hw *hw;
4779 : :
4780 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4781 [ # # ]: 0 : return ixgbe_led_off(hw, 0) == IXGBE_SUCCESS ? 0 : -ENOTSUP;
4782 : : }
4783 : :
4784 : : static int
4785 : 0 : ixgbe_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4786 : : {
4787 : : struct ixgbe_hw *hw;
4788 : : uint32_t mflcn_reg;
4789 : : uint32_t fccfg_reg;
4790 : : int rx_pause;
4791 : : int tx_pause;
4792 : :
4793 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4794 : :
4795 : 0 : fc_conf->pause_time = hw->fc.pause_time;
4796 : 0 : fc_conf->high_water = hw->fc.high_water[0];
4797 : 0 : fc_conf->low_water = hw->fc.low_water[0];
4798 : 0 : fc_conf->send_xon = hw->fc.send_xon;
4799 : 0 : fc_conf->autoneg = !hw->fc.disable_fc_autoneg;
4800 : :
4801 : : /*
4802 : : * Return rx_pause status according to actual setting of
4803 : : * MFLCN register.
4804 : : */
4805 : 0 : mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4806 [ # # ]: 0 : if (mflcn_reg & IXGBE_MFLCN_PMCF)
4807 : 0 : fc_conf->mac_ctrl_frame_fwd = 1;
4808 : : else
4809 : 0 : fc_conf->mac_ctrl_frame_fwd = 0;
4810 : :
4811 [ # # ]: 0 : if (mflcn_reg & (IXGBE_MFLCN_RPFCE | IXGBE_MFLCN_RFCE))
4812 : : rx_pause = 1;
4813 : : else
4814 : : rx_pause = 0;
4815 : :
4816 : : /*
4817 : : * Return tx_pause status according to actual setting of
4818 : : * FCCFG register.
4819 : : */
4820 : 0 : fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4821 [ # # ]: 0 : if (fccfg_reg & (IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY))
4822 : : tx_pause = 1;
4823 : : else
4824 : : tx_pause = 0;
4825 : :
4826 [ # # ]: 0 : if (rx_pause && tx_pause)
4827 : 0 : fc_conf->mode = RTE_ETH_FC_FULL;
4828 [ # # ]: 0 : else if (rx_pause)
4829 : 0 : fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
4830 [ # # ]: 0 : else if (tx_pause)
4831 : 0 : fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
4832 : : else
4833 : 0 : fc_conf->mode = RTE_ETH_FC_NONE;
4834 : :
4835 : 0 : return 0;
4836 : : }
4837 : :
4838 : : static int
4839 : 0 : ixgbe_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
4840 : : {
4841 : : struct ixgbe_hw *hw;
4842 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
4843 : : int err;
4844 : : uint32_t rx_buf_size;
4845 : : uint32_t max_high_water;
4846 : 0 : enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
4847 : : ixgbe_fc_none,
4848 : : ixgbe_fc_rx_pause,
4849 : : ixgbe_fc_tx_pause,
4850 : : ixgbe_fc_full
4851 : : };
4852 : :
4853 : 0 : PMD_INIT_FUNC_TRACE();
4854 : :
4855 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4856 : 0 : rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0));
4857 : 0 : PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
4858 : :
4859 : : /*
4860 : : * At least reserve one Ethernet frame for watermark
4861 : : * high_water/low_water in kilo bytes for ixgbe
4862 : : */
4863 : 0 : max_high_water = (rx_buf_size -
4864 : : RTE_ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
4865 [ # # ]: 0 : if ((fc_conf->high_water > max_high_water) ||
4866 [ # # ]: 0 : (fc_conf->high_water < fc_conf->low_water)) {
4867 : 0 : PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
4868 : 0 : PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
4869 : 0 : return -EINVAL;
4870 : : }
4871 : :
4872 : 0 : hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[fc_conf->mode];
4873 : 0 : hw->fc.pause_time = fc_conf->pause_time;
4874 : 0 : hw->fc.high_water[0] = fc_conf->high_water;
4875 : 0 : hw->fc.low_water[0] = fc_conf->low_water;
4876 : 0 : hw->fc.send_xon = fc_conf->send_xon;
4877 : 0 : hw->fc.disable_fc_autoneg = !fc_conf->autoneg;
4878 : 0 : adapter->mac_ctrl_frame_fwd = fc_conf->mac_ctrl_frame_fwd;
4879 : :
4880 : 0 : err = ixgbe_flow_ctrl_enable(dev, hw);
4881 [ # # ]: 0 : if (err < 0) {
4882 : 0 : PMD_INIT_LOG(ERR, "ixgbe_flow_ctrl_enable = 0x%x", err);
4883 : 0 : return -EIO;
4884 : : }
4885 : : return err;
4886 : : }
4887 : :
4888 : : /**
4889 : : * ixgbe_pfc_enable_generic - Enable flow control
4890 : : * @hw: pointer to hardware structure
4891 : : * @tc_num: traffic class number
4892 : : * Enable flow control according to the current settings.
4893 : : */
4894 : : static int
4895 : 0 : ixgbe_dcb_pfc_enable_generic(struct ixgbe_hw *hw, uint8_t tc_num)
4896 : : {
4897 : : int ret_val = 0;
4898 : : uint32_t mflcn_reg, fccfg_reg;
4899 : : uint32_t reg;
4900 : : uint32_t fcrtl, fcrth;
4901 : : uint8_t i;
4902 : : uint8_t nb_rx_en;
4903 : :
4904 : : /* Validate the water mark configuration */
4905 [ # # ]: 0 : if (!hw->fc.pause_time) {
4906 : : ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4907 : 0 : goto out;
4908 : : }
4909 : :
4910 : : /* Low water mark of zero causes XOFF floods */
4911 [ # # ]: 0 : if (hw->fc.current_mode & ixgbe_fc_tx_pause) {
4912 : : /* High/Low water can not be 0 */
4913 [ # # # # ]: 0 : if ((!hw->fc.high_water[tc_num]) || (!hw->fc.low_water[tc_num])) {
4914 : 0 : PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4915 : : ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4916 : 0 : goto out;
4917 : : }
4918 : :
4919 [ # # ]: 0 : if (hw->fc.low_water[tc_num] >= hw->fc.high_water[tc_num]) {
4920 : 0 : PMD_INIT_LOG(ERR, "Invalid water mark configuration");
4921 : : ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
4922 : 0 : goto out;
4923 : : }
4924 : : }
4925 : : /* Negotiate the fc mode to use */
4926 : 0 : ixgbe_fc_autoneg(hw);
4927 : :
4928 : : /* Disable any previous flow control settings */
4929 : 0 : mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
4930 : 0 : mflcn_reg &= ~(IXGBE_MFLCN_RPFCE_SHIFT | IXGBE_MFLCN_RFCE|IXGBE_MFLCN_RPFCE);
4931 : :
4932 : 0 : fccfg_reg = IXGBE_READ_REG(hw, IXGBE_FCCFG);
4933 : 0 : fccfg_reg &= ~(IXGBE_FCCFG_TFCE_802_3X | IXGBE_FCCFG_TFCE_PRIORITY);
4934 : :
4935 [ # # # # : 0 : switch (hw->fc.current_mode) {
# ]
4936 : : case ixgbe_fc_none:
4937 : : /*
4938 : : * If the count of enabled RX Priority Flow control >1,
4939 : : * and the TX pause can not be disabled
4940 : : */
4941 : : nb_rx_en = 0;
4942 [ # # ]: 0 : for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4943 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4944 [ # # ]: 0 : if (reg & IXGBE_FCRTH_FCEN)
4945 : 0 : nb_rx_en++;
4946 : : }
4947 [ # # ]: 0 : if (nb_rx_en > 1)
4948 : 0 : fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4949 : : break;
4950 : 0 : case ixgbe_fc_rx_pause:
4951 : : /*
4952 : : * Rx Flow control is enabled and Tx Flow control is
4953 : : * disabled by software override. Since there really
4954 : : * isn't a way to advertise that we are capable of RX
4955 : : * Pause ONLY, we will advertise that we support both
4956 : : * symmetric and asymmetric Rx PAUSE. Later, we will
4957 : : * disable the adapter's ability to send PAUSE frames.
4958 : : */
4959 : 0 : mflcn_reg |= IXGBE_MFLCN_RPFCE;
4960 : : /*
4961 : : * If the count of enabled RX Priority Flow control >1,
4962 : : * and the TX pause can not be disabled
4963 : : */
4964 : : nb_rx_en = 0;
4965 [ # # ]: 0 : for (i = 0; i < IXGBE_DCB_MAX_TRAFFIC_CLASS; i++) {
4966 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_FCRTH_82599(i));
4967 [ # # ]: 0 : if (reg & IXGBE_FCRTH_FCEN)
4968 : 0 : nb_rx_en++;
4969 : : }
4970 [ # # ]: 0 : if (nb_rx_en > 1)
4971 : 0 : fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4972 : : break;
4973 : 0 : case ixgbe_fc_tx_pause:
4974 : : /*
4975 : : * Tx Flow control is enabled, and Rx Flow control is
4976 : : * disabled by software override.
4977 : : */
4978 : 0 : fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4979 : 0 : break;
4980 : 0 : case ixgbe_fc_full:
4981 : : /* Flow control (both Rx and Tx) is enabled by SW override. */
4982 : 0 : mflcn_reg |= IXGBE_MFLCN_RPFCE;
4983 : 0 : fccfg_reg |= IXGBE_FCCFG_TFCE_PRIORITY;
4984 : 0 : break;
4985 : 0 : default:
4986 : 0 : PMD_DRV_LOG(DEBUG, "Flow control param set incorrectly");
4987 : : ret_val = IXGBE_ERR_CONFIG;
4988 : 0 : goto out;
4989 : : }
4990 : :
4991 : : /* Set 802.3x based flow control settings. */
4992 : 0 : mflcn_reg |= IXGBE_MFLCN_DPF;
4993 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MFLCN, mflcn_reg);
4994 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCCFG, fccfg_reg);
4995 : :
4996 : : /* Set up and enable Rx high/low water mark thresholds, enable XON. */
4997 [ # # ]: 0 : if ((hw->fc.current_mode & ixgbe_fc_tx_pause) &&
4998 [ # # ]: 0 : hw->fc.high_water[tc_num]) {
4999 : 0 : fcrtl = (hw->fc.low_water[tc_num] << 10) | IXGBE_FCRTL_XONE;
5000 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), fcrtl);
5001 : 0 : fcrth = (hw->fc.high_water[tc_num] << 10) | IXGBE_FCRTH_FCEN;
5002 : : } else {
5003 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCRTL_82599(tc_num), 0);
5004 : : /*
5005 : : * In order to prevent Tx hangs when the internal Tx
5006 : : * switch is enabled we must set the high water mark
5007 : : * to the maximum FCRTH value. This allows the Tx
5008 : : * switch to function even under heavy Rx workloads.
5009 : : */
5010 : 0 : fcrth = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num)) - 32;
5011 : : }
5012 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCRTH_82599(tc_num), fcrth);
5013 : :
5014 : : /* Configure pause time (2 TCs per register) */
5015 : 0 : reg = hw->fc.pause_time * 0x00010001;
5016 [ # # ]: 0 : for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
5017 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
5018 : :
5019 : : /* Configure flow control refresh threshold value */
5020 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
5021 : :
5022 : 0 : out:
5023 : 0 : return ret_val;
5024 : : }
5025 : :
5026 : : static int
5027 : : ixgbe_dcb_pfc_enable(struct rte_eth_dev *dev, uint8_t tc_num)
5028 : : {
5029 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5030 : : int32_t ret_val = IXGBE_NOT_IMPLEMENTED;
5031 : :
5032 : 0 : if (hw->mac.type != ixgbe_mac_82598EB) {
5033 : 0 : ret_val = ixgbe_dcb_pfc_enable_generic(hw, tc_num);
5034 : : }
5035 : : return ret_val;
5036 : : }
5037 : :
5038 : : static int
5039 : 0 : ixgbe_priority_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf)
5040 : : {
5041 : : int err;
5042 : : uint32_t rx_buf_size;
5043 : : uint32_t max_high_water;
5044 : : uint8_t tc_num;
5045 : 0 : uint8_t map[IXGBE_DCB_MAX_USER_PRIORITY] = { 0 };
5046 : : struct ixgbe_hw *hw =
5047 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5048 : 0 : struct ixgbe_dcb_config *dcb_config =
5049 : : IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
5050 : :
5051 : 0 : enum ixgbe_fc_mode rte_fcmode_2_ixgbe_fcmode[] = {
5052 : : ixgbe_fc_none,
5053 : : ixgbe_fc_rx_pause,
5054 : : ixgbe_fc_tx_pause,
5055 : : ixgbe_fc_full
5056 : : };
5057 : :
5058 : 0 : PMD_INIT_FUNC_TRACE();
5059 : :
5060 : 0 : ixgbe_dcb_unpack_map_cee(dcb_config, IXGBE_DCB_RX_CONFIG, map);
5061 : 0 : tc_num = map[pfc_conf->priority];
5062 : 0 : rx_buf_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc_num));
5063 : 0 : PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
5064 : : /*
5065 : : * At least reserve one Ethernet frame for watermark
5066 : : * high_water/low_water in kilo bytes for ixgbe
5067 : : */
5068 : 0 : max_high_water = (rx_buf_size -
5069 : : RTE_ETHER_MAX_LEN) >> IXGBE_RXPBSIZE_SHIFT;
5070 [ # # ]: 0 : if ((pfc_conf->fc.high_water > max_high_water) ||
5071 [ # # ]: 0 : (pfc_conf->fc.high_water <= pfc_conf->fc.low_water)) {
5072 : 0 : PMD_INIT_LOG(ERR, "Invalid high/low water setup value in KB");
5073 : 0 : PMD_INIT_LOG(ERR, "High_water must <= 0x%x", max_high_water);
5074 : 0 : return -EINVAL;
5075 : : }
5076 : :
5077 : 0 : hw->fc.requested_mode = rte_fcmode_2_ixgbe_fcmode[pfc_conf->fc.mode];
5078 : 0 : hw->fc.pause_time = pfc_conf->fc.pause_time;
5079 : 0 : hw->fc.send_xon = pfc_conf->fc.send_xon;
5080 : 0 : hw->fc.low_water[tc_num] = pfc_conf->fc.low_water;
5081 [ # # ]: 0 : hw->fc.high_water[tc_num] = pfc_conf->fc.high_water;
5082 : :
5083 : : err = ixgbe_dcb_pfc_enable(dev, tc_num);
5084 : :
5085 : : /* Not negotiated is not an error case */
5086 [ # # ]: 0 : if ((err == IXGBE_SUCCESS) || (err == IXGBE_ERR_FC_NOT_NEGOTIATED))
5087 : : return 0;
5088 : :
5089 : 0 : PMD_INIT_LOG(ERR, "ixgbe_dcb_pfc_enable = 0x%x", err);
5090 : 0 : return -EIO;
5091 : : }
5092 : :
5093 : : static int
5094 : 0 : ixgbe_dev_rss_reta_update(struct rte_eth_dev *dev,
5095 : : struct rte_eth_rss_reta_entry64 *reta_conf,
5096 : : uint16_t reta_size)
5097 : : {
5098 : : uint16_t i, sp_reta_size;
5099 : : uint8_t j, mask;
5100 : : uint32_t reta, r;
5101 : : uint16_t idx, shift;
5102 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
5103 : : struct rte_eth_dev_data *dev_data = dev->data;
5104 : : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5105 : : uint32_t reta_reg;
5106 : :
5107 : 0 : PMD_INIT_FUNC_TRACE();
5108 : :
5109 [ # # ]: 0 : if (!dev_data->dev_started) {
5110 : 0 : PMD_DRV_LOG(ERR,
5111 : : "port %d must be started before rss reta update",
5112 : : dev_data->port_id);
5113 : 0 : return -EIO;
5114 : : }
5115 : :
5116 [ # # ]: 0 : if (!ixgbe_rss_update_sp(hw->mac.type)) {
5117 : 0 : PMD_DRV_LOG(ERR, "RSS reta update is not supported on this "
5118 : : "NIC.");
5119 : 0 : return -ENOTSUP;
5120 : : }
5121 : :
5122 : 0 : sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
5123 [ # # ]: 0 : if (reta_size != sp_reta_size) {
5124 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
5125 : : "(%d) doesn't match the number hardware can supported "
5126 : : "(%d)", reta_size, sp_reta_size);
5127 : 0 : return -EINVAL;
5128 : : }
5129 : :
5130 [ # # ]: 0 : for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
5131 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
5132 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
5133 : 0 : mask = (uint8_t)((reta_conf[idx].mask >> shift) &
5134 : : IXGBE_4_BIT_MASK);
5135 [ # # ]: 0 : if (!mask)
5136 : 0 : continue;
5137 : 0 : reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
5138 [ # # ]: 0 : if (mask == IXGBE_4_BIT_MASK)
5139 : : r = 0;
5140 : : else
5141 : 0 : r = IXGBE_READ_REG(hw, reta_reg);
5142 [ # # ]: 0 : for (j = 0, reta = 0; j < IXGBE_4_BIT_WIDTH; j++) {
5143 [ # # ]: 0 : if (mask & (0x1 << j))
5144 : 0 : reta |= reta_conf[idx].reta[shift + j] <<
5145 : 0 : (CHAR_BIT * j);
5146 : : else
5147 : 0 : reta |= r & (IXGBE_8_BIT_MASK <<
5148 : 0 : (CHAR_BIT * j));
5149 : : }
5150 : 0 : IXGBE_WRITE_REG(hw, reta_reg, reta);
5151 : : }
5152 : 0 : adapter->rss_reta_updated = 1;
5153 : :
5154 : 0 : return 0;
5155 : : }
5156 : :
5157 : : static int
5158 : 0 : ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
5159 : : struct rte_eth_rss_reta_entry64 *reta_conf,
5160 : : uint16_t reta_size)
5161 : : {
5162 : : uint16_t i, sp_reta_size;
5163 : : uint8_t j, mask;
5164 : : uint32_t reta;
5165 : : uint16_t idx, shift;
5166 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5167 : : uint32_t reta_reg;
5168 : :
5169 : 0 : PMD_INIT_FUNC_TRACE();
5170 : 0 : sp_reta_size = ixgbe_reta_size_get(hw->mac.type);
5171 [ # # ]: 0 : if (reta_size != sp_reta_size) {
5172 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
5173 : : "(%d) doesn't match the number hardware can supported "
5174 : : "(%d)", reta_size, sp_reta_size);
5175 : 0 : return -EINVAL;
5176 : : }
5177 : :
5178 [ # # ]: 0 : for (i = 0; i < reta_size; i += IXGBE_4_BIT_WIDTH) {
5179 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
5180 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
5181 : 0 : mask = (uint8_t)((reta_conf[idx].mask >> shift) &
5182 : : IXGBE_4_BIT_MASK);
5183 [ # # ]: 0 : if (!mask)
5184 : 0 : continue;
5185 : :
5186 : 0 : reta_reg = ixgbe_reta_reg_get(hw->mac.type, i);
5187 : 0 : reta = IXGBE_READ_REG(hw, reta_reg);
5188 [ # # ]: 0 : for (j = 0; j < IXGBE_4_BIT_WIDTH; j++) {
5189 [ # # ]: 0 : if (mask & (0x1 << j))
5190 : 0 : reta_conf[idx].reta[shift + j] =
5191 : 0 : ((reta >> (CHAR_BIT * j)) &
5192 : : IXGBE_8_BIT_MASK);
5193 : : }
5194 : : }
5195 : :
5196 : : return 0;
5197 : : }
5198 : :
5199 : : static int
5200 : 0 : ixgbe_add_rar(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
5201 : : uint32_t index, uint32_t pool)
5202 : : {
5203 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5204 : : uint32_t enable_addr = 1;
5205 : :
5206 : 0 : return ixgbe_set_rar(hw, index, mac_addr->addr_bytes,
5207 : : pool, enable_addr);
5208 : : }
5209 : :
5210 : : static void
5211 : 0 : ixgbe_remove_rar(struct rte_eth_dev *dev, uint32_t index)
5212 : : {
5213 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5214 : :
5215 : 0 : ixgbe_clear_rar(hw, index);
5216 : 0 : }
5217 : :
5218 : : static int
5219 : 0 : ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *addr)
5220 : : {
5221 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5222 : :
5223 : : ixgbe_remove_rar(dev, 0);
5224 : 0 : ixgbe_add_rar(dev, addr, 0, pci_dev->max_vfs);
5225 : :
5226 : 0 : return 0;
5227 : : }
5228 : :
5229 : : static bool
5230 : : is_device_supported(struct rte_eth_dev *dev, struct rte_pci_driver *drv)
5231 : : {
5232 : 0 : if (strcmp(dev->device->driver->name, drv->driver.name))
5233 : 0 : return false;
5234 : :
5235 : : return true;
5236 : : }
5237 : :
5238 : : bool
5239 [ # # ]: 0 : is_ixgbe_supported(struct rte_eth_dev *dev)
5240 : : {
5241 : 0 : return is_device_supported(dev, &rte_ixgbe_pmd);
5242 : : }
5243 : :
5244 : : static int
5245 : 0 : ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
5246 : : {
5247 : : uint32_t hlreg0;
5248 : : uint32_t maxfrs;
5249 : : struct ixgbe_hw *hw;
5250 : : struct rte_eth_dev_info dev_info;
5251 : 0 : uint32_t frame_size = mtu + IXGBE_ETH_OVERHEAD;
5252 : : int ret;
5253 : :
5254 : 0 : ret = ixgbe_dev_info_get(dev, &dev_info);
5255 [ # # ]: 0 : if (ret != 0)
5256 : : return ret;
5257 : :
5258 : : /* check that mtu is within the allowed range */
5259 [ # # # # ]: 0 : if (mtu < RTE_ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen)
5260 : : return -EINVAL;
5261 : :
5262 : : /* If device is started, refuse mtu that requires the support of
5263 : : * scattered packets when this feature has not been enabled before.
5264 : : */
5265 [ # # ]: 0 : if (dev->data->dev_started && !dev->data->scattered_rx &&
5266 : 0 : frame_size + 2 * RTE_VLAN_HLEN >
5267 [ # # ]: 0 : dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM) {
5268 : 0 : PMD_INIT_LOG(ERR, "Stop port first.");
5269 : 0 : return -EINVAL;
5270 : : }
5271 : :
5272 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5273 : 0 : hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
5274 : :
5275 : : /* switch to jumbo mode if needed */
5276 [ # # ]: 0 : if (mtu > RTE_ETHER_MTU)
5277 : 0 : hlreg0 |= IXGBE_HLREG0_JUMBOEN;
5278 : : else
5279 : 0 : hlreg0 &= ~IXGBE_HLREG0_JUMBOEN;
5280 : 0 : IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
5281 : :
5282 : 0 : maxfrs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
5283 : 0 : maxfrs &= 0x0000FFFF;
5284 : 0 : maxfrs |= (frame_size << 16);
5285 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, maxfrs);
5286 : :
5287 : 0 : return 0;
5288 : : }
5289 : :
5290 : : /*
5291 : : * Virtual Function operations
5292 : : */
5293 : : static void
5294 : 0 : ixgbevf_intr_disable(struct rte_eth_dev *dev)
5295 : : {
5296 : : struct ixgbe_interrupt *intr =
5297 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5298 : : struct ixgbe_hw *hw =
5299 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5300 : :
5301 : 0 : PMD_INIT_FUNC_TRACE();
5302 : :
5303 : : /* Clear interrupt mask to stop from interrupts being generated */
5304 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEIMC, IXGBE_VF_IRQ_CLEAR_MASK);
5305 : :
5306 : 0 : IXGBE_WRITE_FLUSH(hw);
5307 : :
5308 : : /* Clear mask value. */
5309 : 0 : intr->mask = 0;
5310 : 0 : }
5311 : :
5312 : : static void
5313 : 0 : ixgbevf_intr_enable(struct rte_eth_dev *dev)
5314 : : {
5315 : : struct ixgbe_interrupt *intr =
5316 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5317 : : struct ixgbe_hw *hw =
5318 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5319 : :
5320 : 0 : PMD_INIT_FUNC_TRACE();
5321 : :
5322 : : /* VF enable interrupt autoclean */
5323 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEIAM, IXGBE_VF_IRQ_ENABLE_MASK);
5324 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEIAC, IXGBE_VF_IRQ_ENABLE_MASK);
5325 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, IXGBE_VF_IRQ_ENABLE_MASK);
5326 : :
5327 : 0 : IXGBE_WRITE_FLUSH(hw);
5328 : :
5329 : : /* Save IXGBE_VTEIMS value to mask. */
5330 : 0 : intr->mask = IXGBE_VF_IRQ_ENABLE_MASK;
5331 : 0 : }
5332 : :
5333 : : static int
5334 : 0 : ixgbevf_dev_configure(struct rte_eth_dev *dev)
5335 : : {
5336 : 0 : struct rte_eth_conf *conf = &dev->data->dev_conf;
5337 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
5338 : :
5339 : 0 : PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
5340 : : dev->data->port_id);
5341 : :
5342 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
5343 : 0 : dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
5344 : :
5345 : : /*
5346 : : * VF has no ability to enable/disable HW CRC
5347 : : * Keep the persistent behavior the same as Host PF
5348 : : */
5349 : : #ifndef RTE_LIBRTE_IXGBE_PF_DISABLE_STRIP_CRC
5350 [ # # ]: 0 : if (conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC) {
5351 : 0 : PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
5352 : 0 : conf->rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_KEEP_CRC;
5353 : : }
5354 : : #else
5355 : : if (!(conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)) {
5356 : : PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
5357 : : conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
5358 : : }
5359 : : #endif
5360 : :
5361 : : /*
5362 : : * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
5363 : : * allocation or vector Rx preconditions we will reset it.
5364 : : */
5365 : 0 : adapter->rx_bulk_alloc_allowed = true;
5366 : 0 : adapter->rx_vec_allowed = true;
5367 : :
5368 : 0 : return 0;
5369 : : }
5370 : :
5371 : : static int
5372 : 0 : ixgbevf_dev_start(struct rte_eth_dev *dev)
5373 : : {
5374 : 0 : struct ixgbe_hw *hw =
5375 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5376 : : uint32_t intr_vector = 0;
5377 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5378 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5379 : :
5380 : : int err, mask = 0;
5381 : :
5382 : 0 : PMD_INIT_FUNC_TRACE();
5383 : :
5384 : : /* Stop the link setup handler before resetting the HW. */
5385 : 0 : ixgbe_dev_wait_setup_link_complete(dev, 0);
5386 : :
5387 : 0 : err = hw->mac.ops.reset_hw(hw);
5388 : :
5389 : : /**
5390 : : * In this case, reuses the MAC address assigned by VF
5391 : : * initialization.
5392 : : */
5393 [ # # ]: 0 : if (err != IXGBE_SUCCESS && err != IXGBE_ERR_INVALID_MAC_ADDR) {
5394 : 0 : PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
5395 : 0 : return err;
5396 : : }
5397 : :
5398 : 0 : hw->mac.get_link_status = true;
5399 : :
5400 : : /* negotiate mailbox API version to use with the PF. */
5401 : 0 : ixgbevf_negotiate_api(hw);
5402 : :
5403 : 0 : ixgbevf_dev_tx_init(dev);
5404 : :
5405 : : /* This can fail when allocating mbufs for descriptor rings */
5406 : 0 : err = ixgbevf_dev_rx_init(dev);
5407 [ # # ]: 0 : if (err) {
5408 : 0 : PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
5409 : 0 : ixgbe_dev_clear_queues(dev);
5410 : 0 : return err;
5411 : : }
5412 : :
5413 : : /* Set vfta */
5414 : 0 : ixgbevf_set_vfta_all(dev, 1);
5415 : :
5416 : : /* Set HW strip */
5417 : : mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
5418 : : RTE_ETH_VLAN_EXTEND_MASK;
5419 : 0 : err = ixgbevf_vlan_offload_config(dev, mask);
5420 [ # # ]: 0 : if (err) {
5421 : 0 : PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
5422 : 0 : ixgbe_dev_clear_queues(dev);
5423 : 0 : return err;
5424 : : }
5425 : :
5426 : 0 : ixgbevf_dev_rxtx_start(dev);
5427 : :
5428 : : /* check and configure queue intr-vector mapping */
5429 [ # # ]: 0 : if (rte_intr_cap_multiple(intr_handle) &&
5430 [ # # ]: 0 : dev->data->dev_conf.intr_conf.rxq) {
5431 : : /* According to datasheet, only vector 0/1/2 can be used,
5432 : : * now only one vector is used for Rx queue
5433 : : */
5434 : : intr_vector = 1;
5435 [ # # ]: 0 : if (rte_intr_efd_enable(intr_handle, intr_vector)) {
5436 : 0 : ixgbe_dev_clear_queues(dev);
5437 : 0 : return -1;
5438 : : }
5439 : : }
5440 : :
5441 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
5442 [ # # ]: 0 : if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
5443 : 0 : dev->data->nb_rx_queues)) {
5444 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
5445 : : " intr_vec", dev->data->nb_rx_queues);
5446 : 0 : ixgbe_dev_clear_queues(dev);
5447 : 0 : return -ENOMEM;
5448 : : }
5449 : : }
5450 : 0 : ixgbevf_configure_msix(dev);
5451 : :
5452 : : /* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
5453 : : * is mapped to VFIO vector 0 in eth_ixgbevf_dev_init( ).
5454 : : * If previous VFIO interrupt mapping setting in eth_ixgbevf_dev_init( )
5455 : : * is not cleared, it will fail when following rte_intr_enable( ) tries
5456 : : * to map Rx queue interrupt to other VFIO vectors.
5457 : : * So clear uio/vfio intr/evevnfd first to avoid failure.
5458 : : */
5459 : 0 : rte_intr_disable(intr_handle);
5460 : :
5461 : 0 : rte_intr_enable(intr_handle);
5462 : :
5463 : : /* Re-enable interrupt for VF */
5464 : 0 : ixgbevf_intr_enable(dev);
5465 : :
5466 : : /*
5467 : : * Update link status right before return, because it may
5468 : : * start link configuration process in a separate thread.
5469 : : */
5470 : : ixgbevf_dev_link_update(dev, 0);
5471 : :
5472 : 0 : hw->adapter_stopped = false;
5473 : :
5474 : 0 : return 0;
5475 : : }
5476 : :
5477 : : static int
5478 : 0 : ixgbevf_dev_stop(struct rte_eth_dev *dev)
5479 : : {
5480 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5481 : : struct ixgbe_adapter *adapter = dev->data->dev_private;
5482 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5483 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5484 : :
5485 [ # # ]: 0 : if (hw->adapter_stopped)
5486 : : return 0;
5487 : :
5488 : 0 : PMD_INIT_FUNC_TRACE();
5489 : :
5490 : 0 : ixgbe_dev_wait_setup_link_complete(dev, 0);
5491 : :
5492 : 0 : ixgbevf_intr_disable(dev);
5493 : :
5494 : 0 : dev->data->dev_started = 0;
5495 : 0 : hw->adapter_stopped = 1;
5496 : 0 : ixgbe_stop_adapter(hw);
5497 : :
5498 : : /*
5499 : : * Clear what we set, but we still keep shadow_vfta to
5500 : : * restore after device starts
5501 : : */
5502 : 0 : ixgbevf_set_vfta_all(dev, 0);
5503 : :
5504 : : /* Clear stored conf */
5505 : 0 : dev->data->scattered_rx = 0;
5506 : :
5507 : 0 : ixgbe_dev_clear_queues(dev);
5508 : :
5509 : : /* Clean datapath event and queue/vec mapping */
5510 : 0 : rte_intr_efd_disable(intr_handle);
5511 : 0 : rte_intr_vec_list_free(intr_handle);
5512 : :
5513 : 0 : adapter->rss_reta_updated = 0;
5514 : :
5515 : 0 : return 0;
5516 : : }
5517 : :
5518 : : static int
5519 : 0 : ixgbevf_dev_close(struct rte_eth_dev *dev)
5520 : : {
5521 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5522 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5523 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5524 : : int ret;
5525 : :
5526 : 0 : PMD_INIT_FUNC_TRACE();
5527 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
5528 : : return 0;
5529 : :
5530 : 0 : ixgbe_reset_hw(hw);
5531 : :
5532 : 0 : ret = ixgbevf_dev_stop(dev);
5533 : :
5534 : 0 : ixgbe_dev_free_queues(dev);
5535 : :
5536 : : /**
5537 : : * Remove the VF MAC address ro ensure
5538 : : * that the VF traffic goes to the PF
5539 : : * after stop, close and detach of the VF
5540 : : **/
5541 : 0 : ixgbevf_remove_mac_addr(dev, 0);
5542 : :
5543 : 0 : rte_intr_disable(intr_handle);
5544 : 0 : rte_intr_callback_unregister(intr_handle,
5545 : : ixgbevf_dev_interrupt_handler, dev);
5546 : :
5547 : 0 : return ret;
5548 : : }
5549 : :
5550 : : /*
5551 : : * Reset VF device
5552 : : */
5553 : : static int
5554 : 0 : ixgbevf_dev_reset(struct rte_eth_dev *dev)
5555 : : {
5556 : : int ret;
5557 : :
5558 : 0 : ret = eth_ixgbevf_dev_uninit(dev);
5559 [ # # ]: 0 : if (ret)
5560 : : return ret;
5561 : :
5562 : 0 : ret = eth_ixgbevf_dev_init(dev);
5563 : :
5564 : 0 : return ret;
5565 : : }
5566 : :
5567 : 0 : static void ixgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
5568 : : {
5569 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5570 : : struct ixgbe_vfta *shadow_vfta =
5571 : : IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5572 : : int i = 0, j = 0, vfta = 0, mask = 1;
5573 : :
5574 [ # # ]: 0 : for (i = 0; i < IXGBE_VFTA_SIZE; i++) {
5575 : 0 : vfta = shadow_vfta->vfta[i];
5576 [ # # ]: 0 : if (vfta) {
5577 : : mask = 1;
5578 [ # # ]: 0 : for (j = 0; j < 32; j++) {
5579 [ # # ]: 0 : if (vfta & mask)
5580 : 0 : ixgbe_set_vfta(hw, (i<<5)+j, 0,
5581 : : on, false);
5582 : 0 : mask <<= 1;
5583 : : }
5584 : : }
5585 : : }
5586 : :
5587 : 0 : }
5588 : :
5589 : : static int
5590 : 0 : ixgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
5591 : : {
5592 : 0 : struct ixgbe_hw *hw =
5593 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5594 : : struct ixgbe_vfta *shadow_vfta =
5595 : : IXGBE_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
5596 : : uint32_t vid_idx = 0;
5597 : : uint32_t vid_bit = 0;
5598 : : int ret = 0;
5599 : :
5600 : 0 : PMD_INIT_FUNC_TRACE();
5601 : :
5602 : : /* vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf */
5603 : 0 : ret = ixgbe_set_vfta(hw, vlan_id, 0, !!on, false);
5604 [ # # ]: 0 : if (ret) {
5605 : 0 : PMD_INIT_LOG(ERR, "Unable to set VF vlan");
5606 : 0 : return ret;
5607 : : }
5608 : 0 : vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
5609 : 0 : vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
5610 : :
5611 : : /* Save what we set and retore it after device reset */
5612 [ # # ]: 0 : if (on)
5613 : 0 : shadow_vfta->vfta[vid_idx] |= vid_bit;
5614 : : else
5615 : 0 : shadow_vfta->vfta[vid_idx] &= ~vid_bit;
5616 : :
5617 : : return 0;
5618 : : }
5619 : :
5620 : : static void
5621 : 0 : ixgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
5622 : : {
5623 : : struct ixgbe_hw *hw =
5624 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5625 : : uint32_t ctrl;
5626 : :
5627 : 0 : PMD_INIT_FUNC_TRACE();
5628 : :
5629 [ # # ]: 0 : if (queue >= hw->mac.max_rx_queues)
5630 : : return;
5631 : :
5632 [ # # ]: 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_RXDCTL(queue));
5633 [ # # ]: 0 : if (on)
5634 : 0 : ctrl |= IXGBE_RXDCTL_VME;
5635 : : else
5636 : 0 : ctrl &= ~IXGBE_RXDCTL_VME;
5637 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RXDCTL(queue), ctrl);
5638 : :
5639 : 0 : ixgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
5640 : : }
5641 : :
5642 : : static int
5643 : 0 : ixgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask)
5644 : : {
5645 : : struct ixgbe_rx_queue *rxq;
5646 : : uint16_t i;
5647 : : int on = 0;
5648 : :
5649 : : /* VF function only support hw strip feature, others are not support */
5650 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
5651 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
5652 : 0 : rxq = dev->data->rx_queues[i];
5653 : 0 : on = !!(rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP);
5654 : 0 : ixgbevf_vlan_strip_queue_set(dev, i, on);
5655 : : }
5656 : : }
5657 : :
5658 : 0 : return 0;
5659 : : }
5660 : :
5661 : : static int
5662 : 0 : ixgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
5663 : : {
5664 : 0 : ixgbe_config_vlan_strip_on_all_queues(dev, mask);
5665 : :
5666 : 0 : ixgbevf_vlan_offload_config(dev, mask);
5667 : :
5668 : 0 : return 0;
5669 : : }
5670 : :
5671 : : int
5672 : 0 : ixgbe_vt_check(struct ixgbe_hw *hw)
5673 : : {
5674 : : uint32_t reg_val;
5675 : :
5676 : : /* if Virtualization Technology is enabled */
5677 : 0 : reg_val = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
5678 [ # # ]: 0 : if (!(reg_val & IXGBE_VT_CTL_VT_ENABLE)) {
5679 : 0 : PMD_INIT_LOG(ERR, "VT must be enabled for this setting");
5680 : 0 : return -1;
5681 : : }
5682 : :
5683 : : return 0;
5684 : : }
5685 : :
5686 : : static uint32_t
5687 : 0 : ixgbe_uta_vector(struct ixgbe_hw *hw, struct rte_ether_addr *uc_addr)
5688 : : {
5689 : : uint32_t vector = 0;
5690 : :
5691 [ # # # # : 0 : switch (hw->mac.mc_filter_type) {
# ]
5692 : 0 : case 0: /* use bits [47:36] of the address */
5693 : 0 : vector = ((uc_addr->addr_bytes[4] >> 4) |
5694 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 4));
5695 : 0 : break;
5696 : 0 : case 1: /* use bits [46:35] of the address */
5697 : 0 : vector = ((uc_addr->addr_bytes[4] >> 3) |
5698 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 5));
5699 : 0 : break;
5700 : 0 : case 2: /* use bits [45:34] of the address */
5701 : 0 : vector = ((uc_addr->addr_bytes[4] >> 2) |
5702 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 6));
5703 : 0 : break;
5704 : 0 : case 3: /* use bits [43:32] of the address */
5705 : 0 : vector = ((uc_addr->addr_bytes[4]) |
5706 : 0 : (((uint16_t)uc_addr->addr_bytes[5]) << 8));
5707 : 0 : break;
5708 : : default: /* Invalid mc_filter_type */
5709 : : break;
5710 : : }
5711 : :
5712 : : /* vector can only be 12-bits or boundary will be exceeded */
5713 : 0 : vector &= 0xFFF;
5714 : 0 : return vector;
5715 : : }
5716 : :
5717 : : static int
5718 : 0 : ixgbe_uc_hash_table_set(struct rte_eth_dev *dev,
5719 : : struct rte_ether_addr *mac_addr, uint8_t on)
5720 : : {
5721 : : uint32_t vector;
5722 : : uint32_t uta_idx;
5723 : : uint32_t reg_val;
5724 : : uint32_t uta_shift;
5725 : : uint32_t rc;
5726 : : const uint32_t ixgbe_uta_idx_mask = 0x7F;
5727 : : const uint32_t ixgbe_uta_bit_shift = 5;
5728 : : const uint32_t ixgbe_uta_bit_mask = (0x1 << ixgbe_uta_bit_shift) - 1;
5729 : : const uint32_t bit1 = 0x1;
5730 : :
5731 : 0 : struct ixgbe_hw *hw =
5732 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5733 : : struct ixgbe_uta_info *uta_info =
5734 : : IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5735 : :
5736 : : /* The UTA table only exists on 82599 hardware and newer */
5737 [ # # ]: 0 : if (hw->mac.type < ixgbe_mac_82599EB)
5738 : : return -ENOTSUP;
5739 : :
5740 : 0 : vector = ixgbe_uta_vector(hw, mac_addr);
5741 : 0 : uta_idx = (vector >> ixgbe_uta_bit_shift) & ixgbe_uta_idx_mask;
5742 : 0 : uta_shift = vector & ixgbe_uta_bit_mask;
5743 : :
5744 : 0 : rc = ((uta_info->uta_shadow[uta_idx] >> uta_shift & bit1) != 0);
5745 [ # # ]: 0 : if (rc == on)
5746 : : return 0;
5747 : :
5748 : 0 : reg_val = IXGBE_READ_REG(hw, IXGBE_UTA(uta_idx));
5749 [ # # ]: 0 : if (on) {
5750 : 0 : uta_info->uta_in_use++;
5751 : 0 : reg_val |= (bit1 << uta_shift);
5752 : 0 : uta_info->uta_shadow[uta_idx] |= (bit1 << uta_shift);
5753 : : } else {
5754 : 0 : uta_info->uta_in_use--;
5755 : 0 : reg_val &= ~(bit1 << uta_shift);
5756 : 0 : uta_info->uta_shadow[uta_idx] &= ~(bit1 << uta_shift);
5757 : : }
5758 : :
5759 : 0 : IXGBE_WRITE_REG(hw, IXGBE_UTA(uta_idx), reg_val);
5760 : :
5761 [ # # ]: 0 : if (uta_info->uta_in_use > 0)
5762 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL,
5763 : : IXGBE_MCSTCTRL_MFE | hw->mac.mc_filter_type);
5764 : : else
5765 : 0 : IXGBE_WRITE_REG(hw, IXGBE_MCSTCTRL, hw->mac.mc_filter_type);
5766 : :
5767 : : return 0;
5768 : : }
5769 : :
5770 : : static int
5771 : 0 : ixgbe_uc_all_hash_table_set(struct rte_eth_dev *dev, uint8_t on)
5772 : : {
5773 : : int i;
5774 : : struct ixgbe_hw *hw =
5775 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5776 : : struct ixgbe_uta_info *uta_info =
5777 : : IXGBE_DEV_PRIVATE_TO_UTA(dev->data->dev_private);
5778 : :
5779 : : /* The UTA table only exists on 82599 hardware and newer */
5780 [ # # ]: 0 : if (hw->mac.type < ixgbe_mac_82599EB)
5781 : : return -ENOTSUP;
5782 : :
5783 [ # # ]: 0 : if (on) {
5784 [ # # ]: 0 : for (i = 0; i < RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5785 : 0 : uta_info->uta_shadow[i] = ~0;
5786 : 0 : IXGBE_WRITE_REG(hw, IXGBE_UTA(i), ~0);
5787 : : }
5788 : : } else {
5789 [ # # ]: 0 : for (i = 0; i < RTE_ETH_VMDQ_NUM_UC_HASH_ARRAY; i++) {
5790 : 0 : uta_info->uta_shadow[i] = 0;
5791 : 0 : IXGBE_WRITE_REG(hw, IXGBE_UTA(i), 0);
5792 : : }
5793 : : }
5794 : : return 0;
5795 : :
5796 : : }
5797 : :
5798 : : uint32_t
5799 : 0 : ixgbe_convert_vm_rx_mask_to_val(uint16_t rx_mask, uint32_t orig_val)
5800 : : {
5801 : : uint32_t new_val = orig_val;
5802 : :
5803 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_UNTAG)
5804 : 0 : new_val |= IXGBE_VMOLR_AUPE;
5805 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_HASH_MC)
5806 : 0 : new_val |= IXGBE_VMOLR_ROMPE;
5807 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_HASH_UC)
5808 : 0 : new_val |= IXGBE_VMOLR_ROPE;
5809 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_BROADCAST)
5810 : 0 : new_val |= IXGBE_VMOLR_BAM;
5811 [ # # ]: 0 : if (rx_mask & RTE_ETH_VMDQ_ACCEPT_MULTICAST)
5812 : 0 : new_val |= IXGBE_VMOLR_MPE;
5813 : :
5814 : 0 : return new_val;
5815 : : }
5816 : :
5817 : : static int
5818 : 0 : ixgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5819 : : {
5820 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5821 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5822 : : struct ixgbe_interrupt *intr =
5823 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5824 : : struct ixgbe_hw *hw =
5825 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5826 : : uint32_t vec = IXGBE_MISC_VEC_ID;
5827 : :
5828 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
5829 : : vec = IXGBE_RX_VEC_START;
5830 : 0 : intr->mask |= (1 << vec);
5831 : : RTE_SET_USED(queue_id);
5832 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, intr->mask);
5833 : :
5834 : 0 : rte_intr_ack(intr_handle);
5835 : :
5836 : 0 : return 0;
5837 : : }
5838 : :
5839 : : static int
5840 : 0 : ixgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5841 : : {
5842 : : struct ixgbe_interrupt *intr =
5843 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5844 : : struct ixgbe_hw *hw =
5845 : : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5846 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5847 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5848 : : uint32_t vec = IXGBE_MISC_VEC_ID;
5849 : :
5850 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
5851 : : vec = IXGBE_RX_VEC_START;
5852 : 0 : intr->mask &= ~(1 << vec);
5853 : : RTE_SET_USED(queue_id);
5854 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, intr->mask);
5855 : :
5856 : 0 : return 0;
5857 : : }
5858 : :
5859 : : static int
5860 : 0 : ixgbe_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
5861 : : {
5862 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5863 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5864 : : uint32_t mask;
5865 : 0 : struct ixgbe_hw *hw =
5866 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5867 : : struct ixgbe_interrupt *intr =
5868 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5869 : :
5870 [ # # ]: 0 : if (queue_id < 16) {
5871 : 0 : ixgbe_disable_intr(hw);
5872 : 0 : intr->mask |= (1 << queue_id);
5873 : : ixgbe_enable_intr(dev);
5874 [ # # ]: 0 : } else if (queue_id < 32) {
5875 : 0 : mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5876 : 0 : mask &= (1 << queue_id);
5877 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5878 [ # # ]: 0 : } else if (queue_id < 64) {
5879 : 0 : mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5880 : 0 : mask &= (1 << (queue_id - 32));
5881 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5882 : : }
5883 : 0 : rte_intr_ack(intr_handle);
5884 : :
5885 : 0 : return 0;
5886 : : }
5887 : :
5888 : : static int
5889 : 0 : ixgbe_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
5890 : : {
5891 : : uint32_t mask;
5892 : 0 : struct ixgbe_hw *hw =
5893 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5894 : : struct ixgbe_interrupt *intr =
5895 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
5896 : :
5897 [ # # ]: 0 : if (queue_id < 16) {
5898 : 0 : ixgbe_disable_intr(hw);
5899 : 0 : intr->mask &= ~(1 << queue_id);
5900 : : ixgbe_enable_intr(dev);
5901 [ # # ]: 0 : } else if (queue_id < 32) {
5902 : 0 : mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(0));
5903 : 0 : mask &= ~(1 << queue_id);
5904 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(0), mask);
5905 [ # # ]: 0 : } else if (queue_id < 64) {
5906 : 0 : mask = IXGBE_READ_REG(hw, IXGBE_EIMS_EX(1));
5907 : 0 : mask &= ~(1 << (queue_id - 32));
5908 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIMS_EX(1), mask);
5909 : : }
5910 : :
5911 : 0 : return 0;
5912 : : }
5913 : :
5914 : : static void
5915 : 0 : ixgbevf_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5916 : : uint8_t queue, uint8_t msix_vector)
5917 : : {
5918 : : uint32_t tmp, idx;
5919 : :
5920 [ # # ]: 0 : if (direction == -1) {
5921 : : /* other causes */
5922 : 0 : msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5923 : 0 : tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR_MISC);
5924 : 0 : tmp &= ~0xFF;
5925 : 0 : tmp |= msix_vector;
5926 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTIVAR_MISC, tmp);
5927 : : } else {
5928 : : /* rx or tx cause */
5929 : 0 : msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5930 : 0 : idx = ((16 * (queue & 1)) + (8 * direction));
5931 : 0 : tmp = IXGBE_READ_REG(hw, IXGBE_VTIVAR(queue >> 1));
5932 : 0 : tmp &= ~(0xFF << idx);
5933 : 0 : tmp |= (msix_vector << idx);
5934 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTIVAR(queue >> 1), tmp);
5935 : : }
5936 : 0 : }
5937 : :
5938 : : /**
5939 : : * set the IVAR registers, mapping interrupt causes to vectors
5940 : : * @param hw
5941 : : * pointer to ixgbe_hw struct
5942 : : * @direction
5943 : : * 0 for Rx, 1 for Tx, -1 for other causes
5944 : : * @queue
5945 : : * queue to map the corresponding interrupt to
5946 : : * @msix_vector
5947 : : * the vector to map to the corresponding queue
5948 : : */
5949 : : static void
5950 : 0 : ixgbe_set_ivar_map(struct ixgbe_hw *hw, int8_t direction,
5951 : : uint8_t queue, uint8_t msix_vector)
5952 : : {
5953 : : uint32_t tmp, idx;
5954 : :
5955 : 0 : msix_vector |= IXGBE_IVAR_ALLOC_VAL;
5956 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
5957 [ # # ]: 0 : if (direction == -1)
5958 : : direction = 0;
5959 : 0 : idx = (((direction * 64) + queue) >> 2) & 0x1F;
5960 : 0 : tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(idx));
5961 : 0 : tmp &= ~(0xFF << (8 * (queue & 0x3)));
5962 : 0 : tmp |= (msix_vector << (8 * (queue & 0x3)));
5963 : 0 : IXGBE_WRITE_REG(hw, IXGBE_IVAR(idx), tmp);
5964 [ # # ]: 0 : } else if ((hw->mac.type == ixgbe_mac_82599EB) ||
5965 : : (hw->mac.type == ixgbe_mac_X540) ||
5966 : : (hw->mac.type == ixgbe_mac_X550) ||
5967 : : (hw->mac.type == ixgbe_mac_X550EM_a) ||
5968 : : (hw->mac.type == ixgbe_mac_X550EM_x)) {
5969 [ # # ]: 0 : if (direction == -1) {
5970 : : /* other causes */
5971 : 0 : idx = ((queue & 1) * 8);
5972 : 0 : tmp = IXGBE_READ_REG(hw, IXGBE_IVAR_MISC);
5973 : 0 : tmp &= ~(0xFF << idx);
5974 : 0 : tmp |= (msix_vector << idx);
5975 : 0 : IXGBE_WRITE_REG(hw, IXGBE_IVAR_MISC, tmp);
5976 : : } else {
5977 : : /* rx or tx causes */
5978 : 0 : idx = ((16 * (queue & 1)) + (8 * direction));
5979 : 0 : tmp = IXGBE_READ_REG(hw, IXGBE_IVAR(queue >> 1));
5980 : 0 : tmp &= ~(0xFF << idx);
5981 : 0 : tmp |= (msix_vector << idx);
5982 : 0 : IXGBE_WRITE_REG(hw, IXGBE_IVAR(queue >> 1), tmp);
5983 : : }
5984 : : }
5985 : 0 : }
5986 : :
5987 : : static void
5988 : 0 : ixgbevf_configure_msix(struct rte_eth_dev *dev)
5989 : : {
5990 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
5991 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
5992 : 0 : struct ixgbe_hw *hw =
5993 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
5994 : : uint32_t q_idx;
5995 : : uint32_t vector_idx = IXGBE_MISC_VEC_ID;
5996 : : uint32_t base = IXGBE_MISC_VEC_ID;
5997 : :
5998 : : /* Configure VF other cause ivar */
5999 : : ixgbevf_set_ivar_map(hw, -1, 1, vector_idx);
6000 : :
6001 : : /* won't configure msix register if no mapping is done
6002 : : * between intr vector and event fd.
6003 : : */
6004 [ # # ]: 0 : if (!rte_intr_dp_is_en(intr_handle))
6005 : : return;
6006 : :
6007 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
6008 : : base = IXGBE_RX_VEC_START;
6009 : : vector_idx = IXGBE_RX_VEC_START;
6010 : : }
6011 : :
6012 : : /* Configure all RX queues of VF */
6013 [ # # ]: 0 : for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
6014 : : /* Force all queue use vector 0,
6015 : : * as IXGBE_VF_MAXMSIVECTOR = 1
6016 : : */
6017 : 0 : ixgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
6018 : 0 : rte_intr_vec_list_index_set(intr_handle, q_idx,
6019 : : vector_idx);
6020 : 0 : if (vector_idx < base + rte_intr_nb_efd_get(intr_handle)
6021 [ # # ]: 0 : - 1)
6022 : 0 : vector_idx++;
6023 : : }
6024 : :
6025 : : /* As RX queue setting above show, all queues use the vector 0.
6026 : : * Set only the ITR value of IXGBE_MISC_VEC_ID.
6027 : : */
6028 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VTEITR(IXGBE_MISC_VEC_ID),
6029 : : IXGBE_EITR_INTERVAL_US(IXGBE_QUEUE_ITR_INTERVAL_DEFAULT)
6030 : : | IXGBE_EITR_CNT_WDIS);
6031 : : }
6032 : :
6033 : : /**
6034 : : * Sets up the hardware to properly generate MSI-X interrupts
6035 : : * @hw
6036 : : * board private structure
6037 : : */
6038 : : static void
6039 : 0 : ixgbe_configure_msix(struct rte_eth_dev *dev)
6040 : : {
6041 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
6042 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
6043 : 0 : struct ixgbe_hw *hw =
6044 : 0 : IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6045 : : uint32_t queue_id, base = IXGBE_MISC_VEC_ID;
6046 : : uint32_t vec = IXGBE_MISC_VEC_ID;
6047 : : uint32_t mask;
6048 : : uint32_t gpie;
6049 : :
6050 : : /* won't configure msix register if no mapping is done
6051 : : * between intr vector and event fd
6052 : : * but if misx has been enabled already, need to configure
6053 : : * auto clean, auto mask and throttling.
6054 : : */
6055 : 0 : gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
6056 [ # # ]: 0 : if (!rte_intr_dp_is_en(intr_handle) &&
6057 [ # # ]: 0 : !(gpie & (IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT)))
6058 : : return;
6059 : :
6060 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
6061 : : vec = base = IXGBE_RX_VEC_START;
6062 : :
6063 : : /* setup GPIE for MSI-x mode */
6064 : 0 : gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
6065 : 0 : gpie |= IXGBE_GPIE_MSIX_MODE | IXGBE_GPIE_PBA_SUPPORT |
6066 : : IXGBE_GPIE_OCD | IXGBE_GPIE_EIAME;
6067 : : /* auto clearing and auto setting corresponding bits in EIMS
6068 : : * when MSI-X interrupt is triggered
6069 : : */
6070 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_82598EB) {
6071 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIAM, IXGBE_EICS_RTX_QUEUE);
6072 : : } else {
6073 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(0), 0xFFFFFFFF);
6074 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIAM_EX(1), 0xFFFFFFFF);
6075 : : }
6076 : 0 : IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
6077 : :
6078 : : /* Populate the IVAR table and set the ITR values to the
6079 : : * corresponding register.
6080 : : */
6081 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
6082 [ # # ]: 0 : for (queue_id = 0; queue_id < dev->data->nb_rx_queues;
6083 : 0 : queue_id++) {
6084 : : /* by default, 1:1 mapping */
6085 : 0 : ixgbe_set_ivar_map(hw, 0, queue_id, vec);
6086 : 0 : rte_intr_vec_list_index_set(intr_handle,
6087 : : queue_id, vec);
6088 : 0 : if (vec < base + rte_intr_nb_efd_get(intr_handle)
6089 [ # # ]: 0 : - 1)
6090 : 0 : vec++;
6091 : : }
6092 : :
6093 [ # # # ]: 0 : switch (hw->mac.type) {
6094 : 0 : case ixgbe_mac_82598EB:
6095 : 0 : ixgbe_set_ivar_map(hw, -1,
6096 : : IXGBE_IVAR_OTHER_CAUSES_INDEX,
6097 : : IXGBE_MISC_VEC_ID);
6098 : 0 : break;
6099 : 0 : case ixgbe_mac_82599EB:
6100 : : case ixgbe_mac_X540:
6101 : : case ixgbe_mac_X550:
6102 : : case ixgbe_mac_X550EM_x:
6103 : 0 : ixgbe_set_ivar_map(hw, -1, 1, IXGBE_MISC_VEC_ID);
6104 : 0 : break;
6105 : : default:
6106 : : break;
6107 : : }
6108 : : }
6109 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EITR(IXGBE_MISC_VEC_ID),
6110 : : IXGBE_EITR_INTERVAL_US(IXGBE_QUEUE_ITR_INTERVAL_DEFAULT)
6111 : : | IXGBE_EITR_CNT_WDIS);
6112 : :
6113 : : /* set up to autoclear timer, and the vectors */
6114 : : mask = IXGBE_EIMS_ENABLE_MASK;
6115 : : mask &= ~(IXGBE_EIMS_OTHER |
6116 : : IXGBE_EIMS_MAILBOX |
6117 : : IXGBE_EIMS_LSC);
6118 : :
6119 : 0 : IXGBE_WRITE_REG(hw, IXGBE_EIAC, mask);
6120 : : }
6121 : :
6122 : : int
6123 : 0 : ixgbe_set_queue_rate_limit(struct rte_eth_dev *dev,
6124 : : uint16_t queue_idx, uint32_t tx_rate)
6125 : : {
6126 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6127 : : uint32_t rf_dec, rf_int;
6128 : : uint32_t bcnrc_val;
6129 : 0 : uint16_t link_speed = dev->data->dev_link.link_speed;
6130 : :
6131 [ # # ]: 0 : if (queue_idx >= hw->mac.max_tx_queues)
6132 : : return -EINVAL;
6133 : :
6134 [ # # ]: 0 : if (tx_rate != 0) {
6135 : : /* Calculate the rate factor values to set */
6136 : 0 : rf_int = (uint32_t)link_speed / (uint32_t)tx_rate;
6137 : 0 : rf_dec = (uint32_t)link_speed % (uint32_t)tx_rate;
6138 : 0 : rf_dec = (rf_dec << IXGBE_RTTBCNRC_RF_INT_SHIFT) / tx_rate;
6139 : :
6140 : : bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
6141 : 0 : bcnrc_val |= ((rf_int << IXGBE_RTTBCNRC_RF_INT_SHIFT) &
6142 : : IXGBE_RTTBCNRC_RF_INT_MASK_M);
6143 : 0 : bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
6144 : : } else {
6145 : : bcnrc_val = 0;
6146 : : }
6147 : :
6148 : : /*
6149 : : * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
6150 : : * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported, otherwise
6151 : : * set as 0x4.
6152 : : */
6153 [ # # ]: 0 : if (dev->data->mtu + IXGBE_ETH_OVERHEAD >= IXGBE_MAX_JUMBO_FRAME_SIZE)
6154 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM, IXGBE_MMW_SIZE_JUMBO_FRAME);
6155 : : else
6156 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM, IXGBE_MMW_SIZE_DEFAULT);
6157 : :
6158 : : /* Set RTTBCNRC of queue X */
6159 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, queue_idx);
6160 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
6161 : 0 : IXGBE_WRITE_FLUSH(hw);
6162 : :
6163 : 0 : return 0;
6164 : : }
6165 : :
6166 : : static int
6167 : 0 : ixgbevf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
6168 : : __rte_unused uint32_t index,
6169 : : __rte_unused uint32_t pool)
6170 : : {
6171 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6172 : : int diag;
6173 : :
6174 : : /*
6175 : : * On a 82599 VF, adding again the same MAC addr is not an idempotent
6176 : : * operation. Trap this case to avoid exhausting the [very limited]
6177 : : * set of PF resources used to store VF MAC addresses.
6178 : : */
6179 [ # # ]: 0 : if (memcmp(hw->mac.perm_addr, mac_addr,
6180 : : sizeof(struct rte_ether_addr)) == 0)
6181 : : return -1;
6182 : 0 : diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
6183 [ # # ]: 0 : if (diag != 0)
6184 : 0 : PMD_DRV_LOG(ERR, "Unable to add MAC address "
6185 : : RTE_ETHER_ADDR_PRT_FMT " - diag=%d",
6186 : : RTE_ETHER_ADDR_BYTES(mac_addr), diag);
6187 : : return diag;
6188 : : }
6189 : :
6190 : : static void
6191 : 0 : ixgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
6192 : : {
6193 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6194 : 0 : struct rte_ether_addr *perm_addr =
6195 : : (struct rte_ether_addr *)hw->mac.perm_addr;
6196 : : struct rte_ether_addr *mac_addr;
6197 : : uint32_t i;
6198 : : int diag;
6199 : :
6200 : : /*
6201 : : * The IXGBE_VF_SET_MACVLAN command of the ixgbe-pf driver does
6202 : : * not support the deletion of a given MAC address.
6203 : : * Instead, it imposes to delete all MAC addresses, then to add again
6204 : : * all MAC addresses with the exception of the one to be deleted.
6205 : : */
6206 : 0 : (void) ixgbevf_set_uc_addr_vf(hw, 0, NULL);
6207 : :
6208 : : /*
6209 : : * Add again all MAC addresses, with the exception of the deleted one
6210 : : * and of the permanent MAC address.
6211 : : */
6212 : 0 : for (i = 0, mac_addr = dev->data->mac_addrs;
6213 [ # # ]: 0 : i < hw->mac.num_rar_entries; i++, mac_addr++) {
6214 : : /* Skip the deleted MAC address */
6215 [ # # ]: 0 : if (i == index)
6216 : 0 : continue;
6217 : : /* Skip NULL MAC addresses */
6218 [ # # ]: 0 : if (rte_is_zero_ether_addr(mac_addr))
6219 : 0 : continue;
6220 : : /* Skip the permanent MAC address */
6221 [ # # ]: 0 : if (memcmp(perm_addr, mac_addr,
6222 : : sizeof(struct rte_ether_addr)) == 0)
6223 : 0 : continue;
6224 : 0 : diag = ixgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
6225 [ # # ]: 0 : if (diag != 0)
6226 : 0 : PMD_DRV_LOG(ERR,
6227 : : "Adding again MAC address "
6228 : : RTE_ETHER_ADDR_PRT_FMT " failed "
6229 : : "diag=%d", RTE_ETHER_ADDR_BYTES(mac_addr),
6230 : : diag);
6231 : : }
6232 : 0 : }
6233 : :
6234 : : static int
6235 : 0 : ixgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
6236 : : struct rte_ether_addr *addr)
6237 : : {
6238 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6239 : :
6240 : 0 : hw->mac.ops.set_rar(hw, 0, (void *)addr, 0, 0);
6241 : :
6242 : 0 : return 0;
6243 : : }
6244 : :
6245 : : int
6246 : 0 : ixgbe_syn_filter_set(struct rte_eth_dev *dev,
6247 : : struct rte_eth_syn_filter *filter,
6248 : : bool add)
6249 : : {
6250 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6251 : : struct ixgbe_filter_info *filter_info =
6252 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6253 : : uint32_t syn_info;
6254 : : uint32_t synqf;
6255 : :
6256 [ # # ]: 0 : if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6257 : : return -EINVAL;
6258 : :
6259 : 0 : syn_info = filter_info->syn_info;
6260 : :
6261 [ # # ]: 0 : if (add) {
6262 [ # # ]: 0 : if (syn_info & IXGBE_SYN_FILTER_ENABLE)
6263 : : return -EINVAL;
6264 : 0 : synqf = (uint32_t)(((filter->queue << IXGBE_SYN_FILTER_QUEUE_SHIFT) &
6265 : 0 : IXGBE_SYN_FILTER_QUEUE) | IXGBE_SYN_FILTER_ENABLE);
6266 : :
6267 [ # # ]: 0 : if (filter->hig_pri)
6268 : 0 : synqf |= IXGBE_SYN_FILTER_SYNQFP;
6269 : : else
6270 : : synqf &= ~IXGBE_SYN_FILTER_SYNQFP;
6271 : : } else {
6272 : 0 : synqf = IXGBE_READ_REG(hw, IXGBE_SYNQF);
6273 [ # # ]: 0 : if (!(syn_info & IXGBE_SYN_FILTER_ENABLE))
6274 : : return -ENOENT;
6275 : 0 : synqf &= ~(IXGBE_SYN_FILTER_QUEUE | IXGBE_SYN_FILTER_ENABLE);
6276 : : }
6277 : :
6278 : 0 : filter_info->syn_info = synqf;
6279 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
6280 : 0 : IXGBE_WRITE_FLUSH(hw);
6281 : 0 : return 0;
6282 : : }
6283 : :
6284 : :
6285 : : static inline enum ixgbe_5tuple_protocol
6286 : : convert_protocol_type(uint8_t protocol_value)
6287 : : {
6288 : 0 : if (protocol_value == IPPROTO_TCP)
6289 : : return IXGBE_FILTER_PROTOCOL_TCP;
6290 [ # # ]: 0 : else if (protocol_value == IPPROTO_UDP)
6291 : : return IXGBE_FILTER_PROTOCOL_UDP;
6292 [ # # ]: 0 : else if (protocol_value == IPPROTO_SCTP)
6293 : : return IXGBE_FILTER_PROTOCOL_SCTP;
6294 : : else
6295 : 0 : return IXGBE_FILTER_PROTOCOL_NONE;
6296 : : }
6297 : :
6298 : : /* inject a 5-tuple filter to HW */
6299 : : static inline void
6300 : 0 : ixgbe_inject_5tuple_filter(struct rte_eth_dev *dev,
6301 : : struct ixgbe_5tuple_filter *filter)
6302 : : {
6303 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6304 : : int i;
6305 : : uint32_t ftqf, sdpqf;
6306 : : uint32_t l34timir = 0;
6307 : : uint8_t mask = 0xff;
6308 : :
6309 : 0 : i = filter->index;
6310 : :
6311 : 0 : sdpqf = (uint32_t)(filter->filter_info.dst_port <<
6312 : : IXGBE_SDPQF_DSTPORT_SHIFT);
6313 : 0 : sdpqf = sdpqf | (filter->filter_info.src_port & IXGBE_SDPQF_SRCPORT);
6314 : :
6315 : 0 : ftqf = (uint32_t)(filter->filter_info.proto &
6316 : : IXGBE_FTQF_PROTOCOL_MASK);
6317 : 0 : ftqf |= (uint32_t)((filter->filter_info.priority &
6318 : 0 : IXGBE_FTQF_PRIORITY_MASK) << IXGBE_FTQF_PRIORITY_SHIFT);
6319 [ # # ]: 0 : if (filter->filter_info.src_ip_mask == 0) /* 0 means compare. */
6320 : : mask &= IXGBE_FTQF_SOURCE_ADDR_MASK;
6321 [ # # ]: 0 : if (filter->filter_info.dst_ip_mask == 0)
6322 : 0 : mask &= IXGBE_FTQF_DEST_ADDR_MASK;
6323 [ # # ]: 0 : if (filter->filter_info.src_port_mask == 0)
6324 : 0 : mask &= IXGBE_FTQF_SOURCE_PORT_MASK;
6325 [ # # ]: 0 : if (filter->filter_info.dst_port_mask == 0)
6326 : 0 : mask &= IXGBE_FTQF_DEST_PORT_MASK;
6327 [ # # ]: 0 : if (filter->filter_info.proto_mask == 0)
6328 : 0 : mask &= IXGBE_FTQF_PROTOCOL_COMP_MASK;
6329 : 0 : ftqf |= mask << IXGBE_FTQF_5TUPLE_MASK_SHIFT;
6330 : : ftqf |= IXGBE_FTQF_POOL_MASK_EN;
6331 : 0 : ftqf |= IXGBE_FTQF_QUEUE_ENABLE;
6332 : :
6333 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DAQF(i), filter->filter_info.dst_ip);
6334 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SAQF(i), filter->filter_info.src_ip);
6335 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SDPQF(i), sdpqf);
6336 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FTQF(i), ftqf);
6337 : :
6338 : : l34timir |= IXGBE_L34T_IMIR_RESERVE;
6339 : 0 : l34timir |= (uint32_t)(filter->queue <<
6340 : : IXGBE_L34T_IMIR_QUEUE_SHIFT);
6341 : 0 : IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(i), l34timir);
6342 : 0 : }
6343 : :
6344 : : /*
6345 : : * add a 5tuple filter
6346 : : *
6347 : : * @param
6348 : : * dev: Pointer to struct rte_eth_dev.
6349 : : * index: the index the filter allocates.
6350 : : * filter: pointer to the filter that will be added.
6351 : : * rx_queue: the queue id the filter assigned to.
6352 : : *
6353 : : * @return
6354 : : * - On success, zero.
6355 : : * - On failure, a negative value.
6356 : : */
6357 : : static int
6358 : 0 : ixgbe_add_5tuple_filter(struct rte_eth_dev *dev,
6359 : : struct ixgbe_5tuple_filter *filter)
6360 : : {
6361 : : struct ixgbe_filter_info *filter_info =
6362 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6363 : : int i, idx, shift;
6364 : :
6365 : : /*
6366 : : * look for an unused 5tuple filter index,
6367 : : * and insert the filter to list.
6368 : : */
6369 [ # # ]: 0 : for (i = 0; i < IXGBE_MAX_FTQF_FILTERS; i++) {
6370 : 0 : idx = i / (sizeof(uint32_t) * NBBY);
6371 : 0 : shift = i % (sizeof(uint32_t) * NBBY);
6372 [ # # ]: 0 : if (!(filter_info->fivetuple_mask[idx] & (1 << shift))) {
6373 : 0 : filter_info->fivetuple_mask[idx] |= 1 << shift;
6374 : 0 : filter->index = i;
6375 : 0 : TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
6376 : : filter,
6377 : : entries);
6378 : 0 : break;
6379 : : }
6380 : : }
6381 [ # # ]: 0 : if (i >= IXGBE_MAX_FTQF_FILTERS) {
6382 : 0 : PMD_DRV_LOG(ERR, "5tuple filters are full.");
6383 : 0 : return -ENOSYS;
6384 : : }
6385 : :
6386 : 0 : ixgbe_inject_5tuple_filter(dev, filter);
6387 : :
6388 : 0 : return 0;
6389 : : }
6390 : :
6391 : : /*
6392 : : * remove a 5tuple filter
6393 : : *
6394 : : * @param
6395 : : * dev: Pointer to struct rte_eth_dev.
6396 : : * filter: the pointer of the filter will be removed.
6397 : : */
6398 : : static void
6399 : 0 : ixgbe_remove_5tuple_filter(struct rte_eth_dev *dev,
6400 : : struct ixgbe_5tuple_filter *filter)
6401 : : {
6402 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6403 : : struct ixgbe_filter_info *filter_info =
6404 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6405 : 0 : uint16_t index = filter->index;
6406 : :
6407 : 0 : filter_info->fivetuple_mask[index / (sizeof(uint32_t) * NBBY)] &=
6408 : 0 : ~(1 << (index % (sizeof(uint32_t) * NBBY)));
6409 [ # # ]: 0 : TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
6410 : 0 : rte_free(filter);
6411 : :
6412 : 0 : IXGBE_WRITE_REG(hw, IXGBE_DAQF(index), 0);
6413 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SAQF(index), 0);
6414 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SDPQF(index), 0);
6415 : 0 : IXGBE_WRITE_REG(hw, IXGBE_FTQF(index), 0);
6416 : 0 : IXGBE_WRITE_REG(hw, IXGBE_L34T_IMIR(index), 0);
6417 : 0 : }
6418 : :
6419 : : static int
6420 : 0 : ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
6421 : : {
6422 : : struct ixgbe_hw *hw;
6423 : 0 : uint32_t max_frame = mtu + IXGBE_ETH_OVERHEAD;
6424 : 0 : struct rte_eth_dev_data *dev_data = dev->data;
6425 : :
6426 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6427 : :
6428 [ # # ]: 0 : if (mtu < RTE_ETHER_MIN_MTU || max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
6429 : : return -EINVAL;
6430 : :
6431 : : /* If device is started, refuse mtu that requires the support of
6432 : : * scattered packets when this feature has not been enabled before.
6433 : : */
6434 [ # # ]: 0 : if (dev_data->dev_started && !dev_data->scattered_rx &&
6435 : 0 : (max_frame + 2 * RTE_VLAN_HLEN >
6436 [ # # ]: 0 : dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
6437 : 0 : PMD_INIT_LOG(ERR, "Stop port first.");
6438 : 0 : return -EINVAL;
6439 : : }
6440 : :
6441 : : /*
6442 : : * When supported by the underlying PF driver, use the IXGBE_VF_SET_MTU
6443 : : * request of the version 2.0 of the mailbox API.
6444 : : * For now, use the IXGBE_VF_SET_LPE request of the version 1.0
6445 : : * of the mailbox API.
6446 : : * This call to IXGBE_SET_LPE action won't work with ixgbe pf drivers
6447 : : * prior to 3.11.33 which contains the following change:
6448 : : * "ixgbe: Enable jumbo frames support w/ SR-IOV"
6449 : : */
6450 [ # # ]: 0 : if (ixgbevf_rlpml_set_vf(hw, max_frame))
6451 : 0 : return -EINVAL;
6452 : :
6453 : : return 0;
6454 : : }
6455 : :
6456 : : static inline struct ixgbe_5tuple_filter *
6457 : : ixgbe_5tuple_filter_lookup(struct ixgbe_5tuple_filter_list *filter_list,
6458 : : struct ixgbe_5tuple_filter_info *key)
6459 : : {
6460 : : struct ixgbe_5tuple_filter *it;
6461 : :
6462 [ # # ]: 0 : TAILQ_FOREACH(it, filter_list, entries) {
6463 [ # # ]: 0 : if (memcmp(key, &it->filter_info,
6464 : : sizeof(struct ixgbe_5tuple_filter_info)) == 0) {
6465 : : return it;
6466 : : }
6467 : : }
6468 : : return NULL;
6469 : : }
6470 : :
6471 : : /* translate elements in struct rte_eth_ntuple_filter to struct ixgbe_5tuple_filter_info*/
6472 : : static inline int
6473 : 0 : ntuple_filter_to_5tuple(struct rte_eth_ntuple_filter *filter,
6474 : : struct ixgbe_5tuple_filter_info *filter_info)
6475 : : {
6476 [ # # ]: 0 : if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
6477 [ # # # # ]: 0 : filter->priority > IXGBE_5TUPLE_MAX_PRI ||
6478 : : filter->priority < IXGBE_5TUPLE_MIN_PRI)
6479 : : return -EINVAL;
6480 : :
6481 [ # # # ]: 0 : switch (filter->dst_ip_mask) {
6482 : 0 : case UINT32_MAX:
6483 : 0 : filter_info->dst_ip_mask = 0;
6484 : 0 : filter_info->dst_ip = filter->dst_ip;
6485 : 0 : break;
6486 : 0 : case 0:
6487 : 0 : filter_info->dst_ip_mask = 1;
6488 : 0 : break;
6489 : 0 : default:
6490 : 0 : PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
6491 : 0 : return -EINVAL;
6492 : : }
6493 : :
6494 [ # # # ]: 0 : switch (filter->src_ip_mask) {
6495 : 0 : case UINT32_MAX:
6496 : 0 : filter_info->src_ip_mask = 0;
6497 : 0 : filter_info->src_ip = filter->src_ip;
6498 : 0 : break;
6499 : 0 : case 0:
6500 : 0 : filter_info->src_ip_mask = 1;
6501 : 0 : break;
6502 : 0 : default:
6503 : 0 : PMD_DRV_LOG(ERR, "invalid src_ip mask.");
6504 : 0 : return -EINVAL;
6505 : : }
6506 : :
6507 [ # # # ]: 0 : switch (filter->dst_port_mask) {
6508 : 0 : case UINT16_MAX:
6509 : 0 : filter_info->dst_port_mask = 0;
6510 : 0 : filter_info->dst_port = filter->dst_port;
6511 : 0 : break;
6512 : 0 : case 0:
6513 : 0 : filter_info->dst_port_mask = 1;
6514 : 0 : break;
6515 : 0 : default:
6516 : 0 : PMD_DRV_LOG(ERR, "invalid dst_port mask.");
6517 : 0 : return -EINVAL;
6518 : : }
6519 : :
6520 [ # # # ]: 0 : switch (filter->src_port_mask) {
6521 : 0 : case UINT16_MAX:
6522 : 0 : filter_info->src_port_mask = 0;
6523 : 0 : filter_info->src_port = filter->src_port;
6524 : 0 : break;
6525 : 0 : case 0:
6526 : 0 : filter_info->src_port_mask = 1;
6527 : 0 : break;
6528 : 0 : default:
6529 : 0 : PMD_DRV_LOG(ERR, "invalid src_port mask.");
6530 : 0 : return -EINVAL;
6531 : : }
6532 : :
6533 [ # # # ]: 0 : switch (filter->proto_mask) {
6534 : 0 : case UINT8_MAX:
6535 : 0 : filter_info->proto_mask = 0;
6536 : 0 : filter_info->proto =
6537 [ # # ]: 0 : convert_protocol_type(filter->proto);
6538 : 0 : break;
6539 : 0 : case 0:
6540 : 0 : filter_info->proto_mask = 1;
6541 : 0 : break;
6542 : 0 : default:
6543 : 0 : PMD_DRV_LOG(ERR, "invalid protocol mask.");
6544 : 0 : return -EINVAL;
6545 : : }
6546 : :
6547 : 0 : filter_info->priority = (uint8_t)filter->priority;
6548 : 0 : return 0;
6549 : : }
6550 : :
6551 : : /*
6552 : : * add or delete a ntuple filter
6553 : : *
6554 : : * @param
6555 : : * dev: Pointer to struct rte_eth_dev.
6556 : : * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
6557 : : * add: if true, add filter, if false, remove filter
6558 : : *
6559 : : * @return
6560 : : * - On success, zero.
6561 : : * - On failure, a negative value.
6562 : : */
6563 : : int
6564 : 0 : ixgbe_add_del_ntuple_filter(struct rte_eth_dev *dev,
6565 : : struct rte_eth_ntuple_filter *ntuple_filter,
6566 : : bool add)
6567 : : {
6568 : : struct ixgbe_filter_info *filter_info =
6569 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6570 : : struct ixgbe_5tuple_filter_info filter_5tuple;
6571 : : struct ixgbe_5tuple_filter *filter;
6572 : : int ret;
6573 : :
6574 [ # # ]: 0 : if (ntuple_filter->flags != RTE_5TUPLE_FLAGS) {
6575 : 0 : PMD_DRV_LOG(ERR, "only 5tuple is supported.");
6576 : 0 : return -EINVAL;
6577 : : }
6578 : :
6579 : : memset(&filter_5tuple, 0, sizeof(struct ixgbe_5tuple_filter_info));
6580 : 0 : ret = ntuple_filter_to_5tuple(ntuple_filter, &filter_5tuple);
6581 [ # # ]: 0 : if (ret < 0)
6582 : : return ret;
6583 : :
6584 : : filter = ixgbe_5tuple_filter_lookup(&filter_info->fivetuple_list,
6585 : : &filter_5tuple);
6586 [ # # ]: 0 : if (filter != NULL && add) {
6587 : 0 : PMD_DRV_LOG(ERR, "filter exists.");
6588 : 0 : return -EEXIST;
6589 : : }
6590 [ # # ]: 0 : if (filter == NULL && !add) {
6591 : 0 : PMD_DRV_LOG(ERR, "filter doesn't exist.");
6592 : 0 : return -ENOENT;
6593 : : }
6594 : :
6595 [ # # ]: 0 : if (add) {
6596 : 0 : filter = rte_zmalloc("ixgbe_5tuple_filter",
6597 : : sizeof(struct ixgbe_5tuple_filter), 0);
6598 [ # # ]: 0 : if (filter == NULL)
6599 : : return -ENOMEM;
6600 [ # # ]: 0 : rte_memcpy(&filter->filter_info,
6601 : : &filter_5tuple,
6602 : : sizeof(struct ixgbe_5tuple_filter_info));
6603 : 0 : filter->queue = ntuple_filter->queue;
6604 : 0 : ret = ixgbe_add_5tuple_filter(dev, filter);
6605 [ # # ]: 0 : if (ret < 0) {
6606 : 0 : rte_free(filter);
6607 : 0 : return ret;
6608 : : }
6609 : : } else
6610 : 0 : ixgbe_remove_5tuple_filter(dev, filter);
6611 : :
6612 : : return 0;
6613 : : }
6614 : :
6615 : : int
6616 : 0 : ixgbe_add_del_ethertype_filter(struct rte_eth_dev *dev,
6617 : : struct rte_eth_ethertype_filter *filter,
6618 : : bool add)
6619 : : {
6620 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6621 : : struct ixgbe_filter_info *filter_info =
6622 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
6623 : : uint32_t etqf = 0;
6624 : : uint32_t etqs = 0;
6625 : : int ret;
6626 : : struct ixgbe_ethertype_filter ethertype_filter;
6627 : :
6628 [ # # ]: 0 : if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM)
6629 : : return -EINVAL;
6630 : :
6631 [ # # ]: 0 : if (filter->ether_type == RTE_ETHER_TYPE_IPV4 ||
6632 : : filter->ether_type == RTE_ETHER_TYPE_IPV6) {
6633 : 0 : PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
6634 : : " ethertype filter.", filter->ether_type);
6635 : 0 : return -EINVAL;
6636 : : }
6637 : :
6638 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
6639 : 0 : PMD_DRV_LOG(ERR, "mac compare is unsupported.");
6640 : 0 : return -EINVAL;
6641 : : }
6642 [ # # ]: 0 : if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
6643 : 0 : PMD_DRV_LOG(ERR, "drop option is unsupported.");
6644 : 0 : return -EINVAL;
6645 : : }
6646 : :
6647 : 0 : ret = ixgbe_ethertype_filter_lookup(filter_info, filter->ether_type);
6648 [ # # ]: 0 : if (ret >= 0 && add) {
6649 : 0 : PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
6650 : : filter->ether_type);
6651 : 0 : return -EEXIST;
6652 : : }
6653 [ # # ]: 0 : if (ret < 0 && !add) {
6654 : 0 : PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
6655 : : filter->ether_type);
6656 : 0 : return -ENOENT;
6657 : : }
6658 : :
6659 [ # # ]: 0 : if (add) {
6660 : : etqf = IXGBE_ETQF_FILTER_EN;
6661 : 0 : etqf |= (uint32_t)filter->ether_type;
6662 : 0 : etqs |= (uint32_t)((filter->queue <<
6663 : : IXGBE_ETQS_RX_QUEUE_SHIFT) &
6664 : : IXGBE_ETQS_RX_QUEUE);
6665 : 0 : etqs |= IXGBE_ETQS_QUEUE_EN;
6666 : :
6667 : : ethertype_filter.ethertype = filter->ether_type;
6668 : : ethertype_filter.etqf = etqf;
6669 : : ethertype_filter.etqs = etqs;
6670 : : ethertype_filter.conf = FALSE;
6671 : : ret = ixgbe_ethertype_filter_insert(filter_info,
6672 : : ðertype_filter);
6673 [ # # ]: 0 : if (ret < 0) {
6674 : 0 : PMD_DRV_LOG(ERR, "ethertype filters are full.");
6675 : 0 : return -ENOSPC;
6676 : : }
6677 : : } else {
6678 [ # # ]: 0 : ret = ixgbe_ethertype_filter_remove(filter_info, (uint8_t)ret);
6679 : : if (ret < 0)
6680 : : return -ENOSYS;
6681 : : }
6682 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQF(ret), etqf);
6683 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQS(ret), etqs);
6684 : 0 : IXGBE_WRITE_FLUSH(hw);
6685 : :
6686 : 0 : return 0;
6687 : : }
6688 : :
6689 : : static int
6690 : 0 : ixgbe_dev_flow_ops_get(__rte_unused struct rte_eth_dev *dev,
6691 : : const struct rte_flow_ops **ops)
6692 : : {
6693 : 0 : *ops = &ixgbe_flow_ops;
6694 : 0 : return 0;
6695 : : }
6696 : :
6697 : : static u8 *
6698 : 0 : ixgbe_dev_addr_list_itr(__rte_unused struct ixgbe_hw *hw,
6699 : : u8 **mc_addr_ptr, u32 *vmdq)
6700 : : {
6701 : : u8 *mc_addr;
6702 : :
6703 : 0 : *vmdq = 0;
6704 : 0 : mc_addr = *mc_addr_ptr;
6705 : 0 : *mc_addr_ptr = (mc_addr + sizeof(struct rte_ether_addr));
6706 : 0 : return mc_addr;
6707 : : }
6708 : :
6709 : : static int
6710 : 0 : ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
6711 : : struct rte_ether_addr *mc_addr_set,
6712 : : uint32_t nb_mc_addr)
6713 : : {
6714 : : struct ixgbe_hw *hw;
6715 : : u8 *mc_addr_list;
6716 : :
6717 : 0 : hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6718 : : mc_addr_list = (u8 *)mc_addr_set;
6719 : 0 : return ixgbe_update_mc_addr_list(hw, mc_addr_list, nb_mc_addr,
6720 : : ixgbe_dev_addr_list_itr, TRUE);
6721 : : }
6722 : :
6723 : : static uint64_t
6724 : 0 : ixgbe_read_systime_cyclecounter(struct rte_eth_dev *dev)
6725 : : {
6726 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6727 : : uint64_t systime_cycles;
6728 : :
6729 [ # # ]: 0 : switch (hw->mac.type) {
6730 : 0 : case ixgbe_mac_X550:
6731 : : case ixgbe_mac_X550EM_x:
6732 : : case ixgbe_mac_X550EM_a:
6733 : : /* SYSTIMEL stores ns and SYSTIMEH stores seconds. */
6734 : 0 : systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6735 : 0 : systime_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6736 : 0 : * NSEC_PER_SEC;
6737 : 0 : break;
6738 : 0 : default:
6739 : 0 : systime_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIML);
6740 : 0 : systime_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_SYSTIMH)
6741 : 0 : << 32;
6742 : : }
6743 : :
6744 : 0 : return systime_cycles;
6745 : : }
6746 : :
6747 : : static uint64_t
6748 : 0 : ixgbe_read_rx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6749 : : {
6750 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6751 : : uint64_t rx_tstamp_cycles;
6752 : :
6753 [ # # ]: 0 : switch (hw->mac.type) {
6754 : 0 : case ixgbe_mac_X550:
6755 : : case ixgbe_mac_X550EM_x:
6756 : : case ixgbe_mac_X550EM_a:
6757 : : /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6758 : 0 : rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6759 : 0 : rx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6760 : 0 : * NSEC_PER_SEC;
6761 : 0 : break;
6762 : 0 : default:
6763 : : /* RXSTMPL stores ns and RXSTMPH stores seconds. */
6764 : 0 : rx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);
6765 : 0 : rx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_RXSTMPH)
6766 : 0 : << 32;
6767 : : }
6768 : :
6769 : 0 : return rx_tstamp_cycles;
6770 : : }
6771 : :
6772 : : static uint64_t
6773 : 0 : ixgbe_read_tx_tstamp_cyclecounter(struct rte_eth_dev *dev)
6774 : : {
6775 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6776 : : uint64_t tx_tstamp_cycles;
6777 : :
6778 [ # # ]: 0 : switch (hw->mac.type) {
6779 : 0 : case ixgbe_mac_X550:
6780 : : case ixgbe_mac_X550EM_x:
6781 : : case ixgbe_mac_X550EM_a:
6782 : : /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6783 : 0 : tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6784 : 0 : tx_tstamp_cycles += (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6785 : 0 : * NSEC_PER_SEC;
6786 : 0 : break;
6787 : 0 : default:
6788 : : /* TXSTMPL stores ns and TXSTMPH stores seconds. */
6789 : 0 : tx_tstamp_cycles = (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);
6790 : 0 : tx_tstamp_cycles |= (uint64_t)IXGBE_READ_REG(hw, IXGBE_TXSTMPH)
6791 : 0 : << 32;
6792 : : }
6793 : :
6794 : 0 : return tx_tstamp_cycles;
6795 : : }
6796 : :
6797 : : static void
6798 : 0 : ixgbe_start_timecounters(struct rte_eth_dev *dev)
6799 : : {
6800 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6801 : : struct ixgbe_adapter *adapter = dev->data->dev_private;
6802 : : struct rte_eth_link link;
6803 : : uint32_t incval = 0;
6804 : : uint32_t shift = 0;
6805 : :
6806 : : /* Get current link speed. */
6807 : : ixgbe_dev_link_update(dev, 1);
6808 : : rte_eth_linkstatus_get(dev, &link);
6809 : :
6810 [ # # # ]: 0 : switch (link.link_speed) {
6811 : : case RTE_ETH_SPEED_NUM_100M:
6812 : : incval = IXGBE_INCVAL_100;
6813 : : shift = IXGBE_INCVAL_SHIFT_100;
6814 : : break;
6815 : 0 : case RTE_ETH_SPEED_NUM_1G:
6816 : : incval = IXGBE_INCVAL_1GB;
6817 : : shift = IXGBE_INCVAL_SHIFT_1GB;
6818 : 0 : break;
6819 : 0 : case RTE_ETH_SPEED_NUM_10G:
6820 : : default:
6821 : : incval = IXGBE_INCVAL_10GB;
6822 : : shift = IXGBE_INCVAL_SHIFT_10GB;
6823 : 0 : break;
6824 : : }
6825 : :
6826 [ # # # # ]: 0 : switch (hw->mac.type) {
6827 : 0 : case ixgbe_mac_X550:
6828 : : case ixgbe_mac_X550EM_x:
6829 : : case ixgbe_mac_X550EM_a:
6830 : : /* Independent of link speed. */
6831 : : incval = 1;
6832 : : /* Cycles read will be interpreted as ns. */
6833 : : shift = 0;
6834 : : /* Fall-through */
6835 : 0 : case ixgbe_mac_X540:
6836 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, incval);
6837 : : break;
6838 : 0 : case ixgbe_mac_82599EB:
6839 : 0 : incval >>= IXGBE_INCVAL_SHIFT_82599;
6840 : 0 : shift -= IXGBE_INCVAL_SHIFT_82599;
6841 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TIMINCA,
6842 : : (1 << IXGBE_INCPER_SHIFT_82599) | incval);
6843 : : break;
6844 : : default:
6845 : : /* Not supported. */
6846 : : return;
6847 : : }
6848 : :
6849 : 0 : memset(&adapter->systime_tc, 0, sizeof(struct rte_timecounter));
6850 : 0 : memset(&adapter->rx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6851 : 0 : memset(&adapter->tx_tstamp_tc, 0, sizeof(struct rte_timecounter));
6852 : :
6853 : 0 : adapter->systime_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6854 : 0 : adapter->systime_tc.cc_shift = shift;
6855 : 0 : adapter->systime_tc.nsec_mask = (1ULL << shift) - 1;
6856 : :
6857 : 0 : adapter->rx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6858 : 0 : adapter->rx_tstamp_tc.cc_shift = shift;
6859 : 0 : adapter->rx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6860 : :
6861 : 0 : adapter->tx_tstamp_tc.cc_mask = IXGBE_CYCLECOUNTER_MASK;
6862 : 0 : adapter->tx_tstamp_tc.cc_shift = shift;
6863 : 0 : adapter->tx_tstamp_tc.nsec_mask = (1ULL << shift) - 1;
6864 : : }
6865 : :
6866 : : static int
6867 : 0 : ixgbe_timesync_adjust_time(struct rte_eth_dev *dev, int64_t delta)
6868 : : {
6869 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
6870 : :
6871 : 0 : adapter->systime_tc.nsec += delta;
6872 : 0 : adapter->rx_tstamp_tc.nsec += delta;
6873 : 0 : adapter->tx_tstamp_tc.nsec += delta;
6874 : :
6875 : 0 : return 0;
6876 : : }
6877 : :
6878 : : static int
6879 : 0 : ixgbe_timesync_write_time(struct rte_eth_dev *dev, const struct timespec *ts)
6880 : : {
6881 : : uint64_t ns;
6882 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
6883 : :
6884 : : ns = rte_timespec_to_ns(ts);
6885 : : /* Set the timecounters to a new value. */
6886 : 0 : adapter->systime_tc.nsec = ns;
6887 : 0 : adapter->rx_tstamp_tc.nsec = ns;
6888 : 0 : adapter->tx_tstamp_tc.nsec = ns;
6889 : :
6890 : 0 : return 0;
6891 : : }
6892 : :
6893 : : static int
6894 : 0 : ixgbe_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
6895 : : {
6896 : : uint64_t ns, systime_cycles;
6897 : 0 : struct ixgbe_adapter *adapter = dev->data->dev_private;
6898 : :
6899 : 0 : systime_cycles = ixgbe_read_systime_cyclecounter(dev);
6900 : : ns = rte_timecounter_update(&adapter->systime_tc, systime_cycles);
6901 : 0 : *ts = rte_ns_to_timespec(ns);
6902 : :
6903 : 0 : return 0;
6904 : : }
6905 : :
6906 : : static int
6907 : 0 : ixgbe_timesync_enable(struct rte_eth_dev *dev)
6908 : : {
6909 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6910 : : uint32_t tsync_ctl;
6911 : : uint32_t tsauxc;
6912 : :
6913 : : /* Stop the timesync system time. */
6914 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0x0);
6915 : : /* Reset the timesync system time value. */
6916 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SYSTIML, 0x0);
6917 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SYSTIMH, 0x0);
6918 : :
6919 : : /* Enable system time for platforms where it isn't on by default. */
6920 : 0 : tsauxc = IXGBE_READ_REG(hw, IXGBE_TSAUXC);
6921 : 0 : tsauxc &= ~IXGBE_TSAUXC_DISABLE_SYSTIME;
6922 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TSAUXC, tsauxc);
6923 : :
6924 : 0 : ixgbe_start_timecounters(dev);
6925 : :
6926 : : /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6927 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588),
6928 : : (RTE_ETHER_TYPE_1588 |
6929 : : IXGBE_ETQF_FILTER_EN |
6930 : : IXGBE_ETQF_1588));
6931 : :
6932 : : /* Enable timestamping of received PTP packets. */
6933 : 0 : tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6934 : 0 : tsync_ctl |= IXGBE_TSYNCRXCTL_ENABLED;
6935 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6936 : :
6937 : : /* Enable timestamping of transmitted PTP packets. */
6938 : 0 : tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6939 : 0 : tsync_ctl |= IXGBE_TSYNCTXCTL_ENABLED;
6940 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6941 : :
6942 : 0 : IXGBE_WRITE_FLUSH(hw);
6943 : :
6944 : 0 : return 0;
6945 : : }
6946 : :
6947 : : static int
6948 : 0 : ixgbe_timesync_disable(struct rte_eth_dev *dev)
6949 : : {
6950 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6951 : : uint32_t tsync_ctl;
6952 : :
6953 : : /* Disable timestamping of transmitted PTP packets. */
6954 : 0 : tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
6955 : 0 : tsync_ctl &= ~IXGBE_TSYNCTXCTL_ENABLED;
6956 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TSYNCTXCTL, tsync_ctl);
6957 : :
6958 : : /* Disable timestamping of received PTP packets. */
6959 : 0 : tsync_ctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6960 : 0 : tsync_ctl &= ~IXGBE_TSYNCRXCTL_ENABLED;
6961 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TSYNCRXCTL, tsync_ctl);
6962 : :
6963 : : /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
6964 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), 0);
6965 : :
6966 : : /* Stop incrementing the System Time registers. */
6967 : 0 : IXGBE_WRITE_REG(hw, IXGBE_TIMINCA, 0);
6968 : :
6969 : 0 : return 0;
6970 : : }
6971 : :
6972 : : static int
6973 : 0 : ixgbe_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
6974 : : struct timespec *timestamp,
6975 : : uint32_t flags __rte_unused)
6976 : : {
6977 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6978 : : struct ixgbe_adapter *adapter = dev->data->dev_private;
6979 : : uint32_t tsync_rxctl;
6980 : : uint64_t rx_tstamp_cycles;
6981 : : uint64_t ns;
6982 : :
6983 : 0 : tsync_rxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL);
6984 [ # # ]: 0 : if ((tsync_rxctl & IXGBE_TSYNCRXCTL_VALID) == 0)
6985 : : return -EINVAL;
6986 : :
6987 : 0 : rx_tstamp_cycles = ixgbe_read_rx_tstamp_cyclecounter(dev);
6988 : : ns = rte_timecounter_update(&adapter->rx_tstamp_tc, rx_tstamp_cycles);
6989 : 0 : *timestamp = rte_ns_to_timespec(ns);
6990 : :
6991 : 0 : return 0;
6992 : : }
6993 : :
6994 : : static int
6995 : 0 : ixgbe_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
6996 : : struct timespec *timestamp)
6997 : : {
6998 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
6999 : : struct ixgbe_adapter *adapter = dev->data->dev_private;
7000 : : uint32_t tsync_txctl;
7001 : : uint64_t tx_tstamp_cycles;
7002 : : uint64_t ns;
7003 : :
7004 : 0 : tsync_txctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);
7005 [ # # ]: 0 : if ((tsync_txctl & IXGBE_TSYNCTXCTL_VALID) == 0)
7006 : : return -EINVAL;
7007 : :
7008 : 0 : tx_tstamp_cycles = ixgbe_read_tx_tstamp_cyclecounter(dev);
7009 : : ns = rte_timecounter_update(&adapter->tx_tstamp_tc, tx_tstamp_cycles);
7010 : 0 : *timestamp = rte_ns_to_timespec(ns);
7011 : :
7012 : 0 : return 0;
7013 : : }
7014 : :
7015 : : static int
7016 : 0 : ixgbe_get_reg_length(struct rte_eth_dev *dev)
7017 : : {
7018 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7019 : : int count = 0;
7020 : : int g_ind = 0;
7021 : : const struct reg_info *reg_group;
7022 : 0 : const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
7023 [ # # ]: 0 : ixgbe_regs_mac_82598EB : ixgbe_regs_others;
7024 : :
7025 [ # # ]: 0 : while ((reg_group = reg_set[g_ind++]))
7026 : 0 : count += ixgbe_regs_group_count(reg_group);
7027 : :
7028 : 0 : return count;
7029 : : }
7030 : :
7031 : : static int
7032 : : ixgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
7033 : : {
7034 : : int count = 0;
7035 : : int g_ind = 0;
7036 : : const struct reg_info *reg_group;
7037 : :
7038 [ # # # # ]: 0 : while ((reg_group = ixgbevf_regs[g_ind++]))
7039 : 0 : count += ixgbe_regs_group_count(reg_group);
7040 : :
7041 : : return count;
7042 : : }
7043 : :
7044 : : static int
7045 : 0 : ixgbe_get_regs(struct rte_eth_dev *dev,
7046 : : struct rte_dev_reg_info *regs)
7047 : : {
7048 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7049 : 0 : uint32_t *data = regs->data;
7050 : : int g_ind = 0;
7051 : : int count = 0;
7052 : : const struct reg_info *reg_group;
7053 : 0 : const struct reg_info **reg_set = (hw->mac.type == ixgbe_mac_82598EB) ?
7054 [ # # ]: 0 : ixgbe_regs_mac_82598EB : ixgbe_regs_others;
7055 : :
7056 [ # # ]: 0 : if (data == NULL) {
7057 : 0 : regs->length = ixgbe_get_reg_length(dev);
7058 : 0 : regs->width = sizeof(uint32_t);
7059 : 0 : return 0;
7060 : : }
7061 : :
7062 : : /* Support only full register dump */
7063 [ # # ]: 0 : if ((regs->length == 0) ||
7064 [ # # ]: 0 : (regs->length == (uint32_t)ixgbe_get_reg_length(dev))) {
7065 : 0 : regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7066 : 0 : hw->device_id;
7067 [ # # ]: 0 : while ((reg_group = reg_set[g_ind++]))
7068 : 0 : count += ixgbe_read_regs_group(dev, &data[count],
7069 : : reg_group);
7070 : : return 0;
7071 : : }
7072 : :
7073 : : return -ENOTSUP;
7074 : : }
7075 : :
7076 : : static int
7077 : 0 : ixgbevf_get_regs(struct rte_eth_dev *dev,
7078 : : struct rte_dev_reg_info *regs)
7079 : : {
7080 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7081 : 0 : uint32_t *data = regs->data;
7082 : : int g_ind = 0;
7083 : : int count = 0;
7084 : : const struct reg_info *reg_group;
7085 : :
7086 [ # # ]: 0 : if (data == NULL) {
7087 : 0 : regs->length = ixgbevf_get_reg_length(dev);
7088 : 0 : regs->width = sizeof(uint32_t);
7089 : 0 : return 0;
7090 : : }
7091 : :
7092 : : /* Support only full register dump */
7093 [ # # ]: 0 : if ((regs->length == 0) ||
7094 [ # # ]: 0 : (regs->length == (uint32_t)ixgbevf_get_reg_length(dev))) {
7095 : 0 : regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
7096 : 0 : hw->device_id;
7097 [ # # ]: 0 : while ((reg_group = ixgbevf_regs[g_ind++]))
7098 : 0 : count += ixgbe_read_regs_group(dev, &data[count],
7099 : : reg_group);
7100 : : return 0;
7101 : : }
7102 : :
7103 : : return -ENOTSUP;
7104 : : }
7105 : :
7106 : : static int
7107 : 0 : ixgbe_get_eeprom_length(struct rte_eth_dev *dev)
7108 : : {
7109 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7110 : :
7111 : : /* Return unit is byte count */
7112 : 0 : return hw->eeprom.word_size * 2;
7113 : : }
7114 : :
7115 : : static int
7116 : 0 : ixgbe_get_eeprom(struct rte_eth_dev *dev,
7117 : : struct rte_dev_eeprom_info *in_eeprom)
7118 : : {
7119 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7120 : : struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7121 : 0 : uint16_t *data = in_eeprom->data;
7122 : : int first, length;
7123 : :
7124 : 0 : first = in_eeprom->offset >> 1;
7125 : 0 : length = in_eeprom->length >> 1;
7126 [ # # ]: 0 : if ((first > hw->eeprom.word_size) ||
7127 [ # # ]: 0 : ((first + length) > hw->eeprom.word_size))
7128 : : return -EINVAL;
7129 : :
7130 : 0 : in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7131 : :
7132 : 0 : return eeprom->ops.read_buffer(hw, first, length, data);
7133 : : }
7134 : :
7135 : : static int
7136 : 0 : ixgbe_set_eeprom(struct rte_eth_dev *dev,
7137 : : struct rte_dev_eeprom_info *in_eeprom)
7138 : : {
7139 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7140 : : struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
7141 : 0 : uint16_t *data = in_eeprom->data;
7142 : : int first, length;
7143 : :
7144 : 0 : first = in_eeprom->offset >> 1;
7145 : 0 : length = in_eeprom->length >> 1;
7146 [ # # ]: 0 : if ((first > hw->eeprom.word_size) ||
7147 [ # # ]: 0 : ((first + length) > hw->eeprom.word_size))
7148 : : return -EINVAL;
7149 : :
7150 : 0 : in_eeprom->magic = hw->vendor_id | (hw->device_id << 16);
7151 : :
7152 : 0 : return eeprom->ops.write_buffer(hw, first, length, data);
7153 : : }
7154 : :
7155 : : static int
7156 : 0 : ixgbe_get_module_info(struct rte_eth_dev *dev,
7157 : : struct rte_eth_dev_module_info *modinfo)
7158 : : {
7159 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7160 : : uint32_t status;
7161 : : uint8_t sff8472_rev, addr_mode;
7162 : : bool page_swap = false;
7163 : :
7164 : : /* Check whether we support SFF-8472 or not */
7165 : 0 : status = hw->phy.ops.read_i2c_eeprom(hw,
7166 : : IXGBE_SFF_SFF_8472_COMP,
7167 : : &sff8472_rev);
7168 [ # # ]: 0 : if (status != 0)
7169 : : return -EIO;
7170 : :
7171 : : /* addressing mode is not supported */
7172 : 0 : status = hw->phy.ops.read_i2c_eeprom(hw,
7173 : : IXGBE_SFF_SFF_8472_SWAP,
7174 : : &addr_mode);
7175 [ # # ]: 0 : if (status != 0)
7176 : : return -EIO;
7177 : :
7178 [ # # ]: 0 : if (addr_mode & IXGBE_SFF_ADDRESSING_MODE) {
7179 : 0 : PMD_DRV_LOG(ERR,
7180 : : "Address change required to access page 0xA2, "
7181 : : "but not supported. Please report the module "
7182 : : "type to the driver maintainers.");
7183 : : page_swap = true;
7184 : : }
7185 : :
7186 [ # # # # ]: 0 : if (sff8472_rev == IXGBE_SFF_SFF_8472_UNSUP || page_swap) {
7187 : : /* We have a SFP, but it does not support SFF-8472 */
7188 : 0 : modinfo->type = RTE_ETH_MODULE_SFF_8079;
7189 : 0 : modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8079_LEN;
7190 : : } else {
7191 : : /* We have a SFP which supports a revision of SFF-8472. */
7192 : 0 : modinfo->type = RTE_ETH_MODULE_SFF_8472;
7193 : 0 : modinfo->eeprom_len = RTE_ETH_MODULE_SFF_8472_LEN;
7194 : : }
7195 : :
7196 : : return 0;
7197 : : }
7198 : :
7199 : : static int
7200 : 0 : ixgbe_get_module_eeprom(struct rte_eth_dev *dev,
7201 : : struct rte_dev_eeprom_info *info)
7202 : : {
7203 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7204 : : uint32_t status = IXGBE_ERR_PHY_ADDR_INVALID;
7205 : 0 : uint8_t databyte = 0xFF;
7206 : 0 : uint8_t *data = info->data;
7207 : : uint32_t i = 0;
7208 : :
7209 [ # # ]: 0 : for (i = info->offset; i < info->offset + info->length; i++) {
7210 [ # # ]: 0 : if (i < RTE_ETH_MODULE_SFF_8079_LEN)
7211 : 0 : status = hw->phy.ops.read_i2c_eeprom(hw, i, &databyte);
7212 : : else
7213 : 0 : status = hw->phy.ops.read_i2c_sff8472(hw, i, &databyte);
7214 : :
7215 [ # # ]: 0 : if (status != 0)
7216 : : return -EIO;
7217 : :
7218 : 0 : data[i - info->offset] = databyte;
7219 : : }
7220 : :
7221 : : return 0;
7222 : : }
7223 : :
7224 : : uint16_t
7225 : 0 : ixgbe_reta_size_get(enum ixgbe_mac_type mac_type) {
7226 [ # # # # ]: 0 : switch (mac_type) {
7227 : : case ixgbe_mac_X550:
7228 : : case ixgbe_mac_X550EM_x:
7229 : : case ixgbe_mac_X550EM_a:
7230 : : return RTE_ETH_RSS_RETA_SIZE_512;
7231 : 0 : case ixgbe_mac_X550_vf:
7232 : : case ixgbe_mac_X550EM_x_vf:
7233 : : case ixgbe_mac_X550EM_a_vf:
7234 : 0 : return RTE_ETH_RSS_RETA_SIZE_64;
7235 : 0 : case ixgbe_mac_X540_vf:
7236 : : case ixgbe_mac_82599_vf:
7237 : 0 : return 0;
7238 : 0 : default:
7239 : 0 : return RTE_ETH_RSS_RETA_SIZE_128;
7240 : : }
7241 : : }
7242 : :
7243 : : uint32_t
7244 : 0 : ixgbe_reta_reg_get(enum ixgbe_mac_type mac_type, uint16_t reta_idx) {
7245 [ # # # ]: 0 : switch (mac_type) {
7246 : 0 : case ixgbe_mac_X550:
7247 : : case ixgbe_mac_X550EM_x:
7248 : : case ixgbe_mac_X550EM_a:
7249 [ # # ]: 0 : if (reta_idx < RTE_ETH_RSS_RETA_SIZE_128)
7250 : 0 : return IXGBE_RETA(reta_idx >> 2);
7251 : : else
7252 : 0 : return IXGBE_ERETA((reta_idx - RTE_ETH_RSS_RETA_SIZE_128) >> 2);
7253 : 0 : case ixgbe_mac_X550_vf:
7254 : : case ixgbe_mac_X550EM_x_vf:
7255 : : case ixgbe_mac_X550EM_a_vf:
7256 : 0 : return IXGBE_VFRETA(reta_idx >> 2);
7257 : 0 : default:
7258 : 0 : return IXGBE_RETA(reta_idx >> 2);
7259 : : }
7260 : : }
7261 : :
7262 : : uint32_t
7263 : 0 : ixgbe_mrqc_reg_get(enum ixgbe_mac_type mac_type) {
7264 [ # # ]: 0 : switch (mac_type) {
7265 : : case ixgbe_mac_X550_vf:
7266 : : case ixgbe_mac_X550EM_x_vf:
7267 : : case ixgbe_mac_X550EM_a_vf:
7268 : : return IXGBE_VFMRQC;
7269 : 0 : default:
7270 : 0 : return IXGBE_MRQC;
7271 : : }
7272 : : }
7273 : :
7274 : : uint32_t
7275 : 0 : ixgbe_rssrk_reg_get(enum ixgbe_mac_type mac_type, uint8_t i) {
7276 [ # # ]: 0 : switch (mac_type) {
7277 : 0 : case ixgbe_mac_X550_vf:
7278 : : case ixgbe_mac_X550EM_x_vf:
7279 : : case ixgbe_mac_X550EM_a_vf:
7280 : 0 : return IXGBE_VFRSSRK(i);
7281 : 0 : default:
7282 : 0 : return IXGBE_RSSRK(i);
7283 : : }
7284 : : }
7285 : :
7286 : : bool
7287 : 0 : ixgbe_rss_update_sp(enum ixgbe_mac_type mac_type) {
7288 [ # # ]: 0 : switch (mac_type) {
7289 : : case ixgbe_mac_82599_vf:
7290 : : case ixgbe_mac_X540_vf:
7291 : : return 0;
7292 : 0 : default:
7293 : 0 : return 1;
7294 : : }
7295 : : }
7296 : :
7297 : : static int
7298 : 0 : ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
7299 : : struct rte_eth_dcb_info *dcb_info)
7300 : : {
7301 : : struct ixgbe_dcb_config *dcb_config =
7302 : 0 : IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
7303 : : struct ixgbe_dcb_tc_config *tc;
7304 : : struct rte_eth_dcb_tc_queue_mapping *tc_queue;
7305 : : uint8_t nb_tcs;
7306 : : uint8_t i, j;
7307 : :
7308 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_DCB_FLAG)
7309 : 0 : dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
7310 : : else
7311 : 0 : dcb_info->nb_tcs = 1;
7312 : :
7313 : : tc_queue = &dcb_info->tc_queue;
7314 : 0 : nb_tcs = dcb_info->nb_tcs;
7315 : :
7316 [ # # ]: 0 : if (dcb_config->vt_mode) { /* vt is enabled*/
7317 : : struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
7318 : : &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
7319 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
7320 : 0 : dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
7321 [ # # ]: 0 : if (RTE_ETH_DEV_SRIOV(dev).active > 0) {
7322 [ # # ]: 0 : for (j = 0; j < nb_tcs; j++) {
7323 : 0 : tc_queue->tc_rxq[0][j].base = j;
7324 : 0 : tc_queue->tc_rxq[0][j].nb_queue = 1;
7325 : 0 : tc_queue->tc_txq[0][j].base = j;
7326 : 0 : tc_queue->tc_txq[0][j].nb_queue = 1;
7327 : : }
7328 : : } else {
7329 [ # # ]: 0 : for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
7330 [ # # ]: 0 : for (j = 0; j < nb_tcs; j++) {
7331 : 0 : tc_queue->tc_rxq[i][j].base =
7332 : 0 : i * nb_tcs + j;
7333 : 0 : tc_queue->tc_rxq[i][j].nb_queue = 1;
7334 : 0 : tc_queue->tc_txq[i][j].base =
7335 : : i * nb_tcs + j;
7336 : 0 : tc_queue->tc_txq[i][j].nb_queue = 1;
7337 : : }
7338 : : }
7339 : : }
7340 : : } else { /* vt is disabled*/
7341 : : struct rte_eth_dcb_rx_conf *rx_conf =
7342 : : &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
7343 [ # # ]: 0 : for (i = 0; i < RTE_ETH_DCB_NUM_USER_PRIORITIES; i++)
7344 : 0 : dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
7345 [ # # ]: 0 : if (dcb_info->nb_tcs == RTE_ETH_4_TCS) {
7346 [ # # ]: 0 : for (i = 0; i < dcb_info->nb_tcs; i++) {
7347 : 0 : dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
7348 : 0 : dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7349 : : }
7350 : 0 : dcb_info->tc_queue.tc_txq[0][0].base = 0;
7351 : 0 : dcb_info->tc_queue.tc_txq[0][1].base = 64;
7352 : 0 : dcb_info->tc_queue.tc_txq[0][2].base = 96;
7353 : 0 : dcb_info->tc_queue.tc_txq[0][3].base = 112;
7354 : 0 : dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
7355 : 0 : dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7356 : 0 : dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7357 : 0 : dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7358 [ # # ]: 0 : } else if (dcb_info->nb_tcs == RTE_ETH_8_TCS) {
7359 [ # # ]: 0 : for (i = 0; i < dcb_info->nb_tcs; i++) {
7360 : 0 : dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
7361 : 0 : dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
7362 : : }
7363 : 0 : dcb_info->tc_queue.tc_txq[0][0].base = 0;
7364 : 0 : dcb_info->tc_queue.tc_txq[0][1].base = 32;
7365 : 0 : dcb_info->tc_queue.tc_txq[0][2].base = 64;
7366 : 0 : dcb_info->tc_queue.tc_txq[0][3].base = 80;
7367 : 0 : dcb_info->tc_queue.tc_txq[0][4].base = 96;
7368 : 0 : dcb_info->tc_queue.tc_txq[0][5].base = 104;
7369 : 0 : dcb_info->tc_queue.tc_txq[0][6].base = 112;
7370 : 0 : dcb_info->tc_queue.tc_txq[0][7].base = 120;
7371 : 0 : dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
7372 : 0 : dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
7373 : 0 : dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
7374 : 0 : dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
7375 : 0 : dcb_info->tc_queue.tc_txq[0][4].nb_queue = 8;
7376 : 0 : dcb_info->tc_queue.tc_txq[0][5].nb_queue = 8;
7377 : 0 : dcb_info->tc_queue.tc_txq[0][6].nb_queue = 8;
7378 : 0 : dcb_info->tc_queue.tc_txq[0][7].nb_queue = 8;
7379 : : }
7380 : : }
7381 [ # # ]: 0 : for (i = 0; i < dcb_info->nb_tcs; i++) {
7382 : 0 : tc = &dcb_config->tc_config[i];
7383 : 0 : dcb_info->tc_bws[i] = tc->path[IXGBE_DCB_TX_CONFIG].bwg_percent;
7384 : : }
7385 : 0 : return 0;
7386 : : }
7387 : :
7388 : : /* Update e-tag ether type */
7389 : : static int
7390 : : ixgbe_update_e_tag_eth_type(struct ixgbe_hw *hw,
7391 : : uint16_t ether_type)
7392 : : {
7393 : : uint32_t etag_etype;
7394 : :
7395 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7396 : 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7397 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7398 : : return -ENOTSUP;
7399 : : }
7400 : :
7401 : 0 : etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7402 : 0 : etag_etype &= ~IXGBE_ETAG_ETYPE_MASK;
7403 : 0 : etag_etype |= ether_type;
7404 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7405 : 0 : IXGBE_WRITE_FLUSH(hw);
7406 : :
7407 : 0 : return 0;
7408 : : }
7409 : :
7410 : : /* Enable e-tag tunnel */
7411 : : static int
7412 : : ixgbe_e_tag_enable(struct ixgbe_hw *hw)
7413 : : {
7414 : : uint32_t etag_etype;
7415 : :
7416 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7417 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7418 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7419 : : return -ENOTSUP;
7420 : : }
7421 : :
7422 : 0 : etag_etype = IXGBE_READ_REG(hw, IXGBE_ETAG_ETYPE);
7423 : 0 : etag_etype |= IXGBE_ETAG_ETYPE_VALID;
7424 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETAG_ETYPE, etag_etype);
7425 : 0 : IXGBE_WRITE_FLUSH(hw);
7426 : :
7427 : 0 : return 0;
7428 : : }
7429 : :
7430 : : static int
7431 : 0 : ixgbe_e_tag_filter_del(struct rte_eth_dev *dev,
7432 : : struct ixgbe_l2_tunnel_conf *l2_tunnel)
7433 : : {
7434 : : int ret = 0;
7435 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7436 : : uint32_t i, rar_entries;
7437 : : uint32_t rar_low, rar_high;
7438 : :
7439 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7440 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7441 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7442 : : return -ENOTSUP;
7443 : : }
7444 : :
7445 : 0 : rar_entries = ixgbe_get_num_rx_addrs(hw);
7446 : :
7447 [ # # ]: 0 : for (i = 1; i < rar_entries; i++) {
7448 [ # # ]: 0 : rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7449 [ # # ]: 0 : rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(i));
7450 [ # # ]: 0 : if ((rar_high & IXGBE_RAH_AV) &&
7451 [ # # ]: 0 : (rar_high & IXGBE_RAH_ADTYPE) &&
7452 : 0 : ((rar_low & IXGBE_RAL_ETAG_FILTER_MASK) ==
7453 [ # # ]: 0 : l2_tunnel->tunnel_id)) {
7454 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RAL(i), 0);
7455 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RAH(i), 0);
7456 : :
7457 : 0 : ixgbe_clear_vmdq(hw, i, IXGBE_CLEAR_VMDQ_ALL);
7458 : :
7459 : 0 : return ret;
7460 : : }
7461 : : }
7462 : :
7463 : : return ret;
7464 : : }
7465 : :
7466 : : static int
7467 : 0 : ixgbe_e_tag_filter_add(struct rte_eth_dev *dev,
7468 : : struct ixgbe_l2_tunnel_conf *l2_tunnel)
7469 : : {
7470 : : int ret = 0;
7471 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7472 : : uint32_t i, rar_entries;
7473 : : uint32_t rar_low, rar_high;
7474 : :
7475 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7476 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7477 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7478 : : return -ENOTSUP;
7479 : : }
7480 : :
7481 : : /* One entry for one tunnel. Try to remove potential existing entry. */
7482 : 0 : ixgbe_e_tag_filter_del(dev, l2_tunnel);
7483 : :
7484 : 0 : rar_entries = ixgbe_get_num_rx_addrs(hw);
7485 : :
7486 [ # # ]: 0 : for (i = 1; i < rar_entries; i++) {
7487 [ # # ]: 0 : rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(i));
7488 [ # # ]: 0 : if (rar_high & IXGBE_RAH_AV) {
7489 : : continue;
7490 : : } else {
7491 : 0 : ixgbe_set_vmdq(hw, i, l2_tunnel->pool);
7492 : : rar_high = IXGBE_RAH_AV | IXGBE_RAH_ADTYPE;
7493 : 0 : rar_low = l2_tunnel->tunnel_id;
7494 : :
7495 [ # # ]: 0 : IXGBE_WRITE_REG(hw, IXGBE_RAL(i), rar_low);
7496 : 0 : IXGBE_WRITE_REG(hw, IXGBE_RAH(i), rar_high);
7497 : :
7498 : 0 : return ret;
7499 : : }
7500 : : }
7501 : :
7502 : 0 : PMD_INIT_LOG(NOTICE, "The table of E-tag forwarding rule is full."
7503 : : " Please remove a rule before adding a new one.");
7504 : 0 : return -EINVAL;
7505 : : }
7506 : :
7507 : : static inline struct ixgbe_l2_tn_filter *
7508 : : ixgbe_l2_tn_filter_lookup(struct ixgbe_l2_tn_info *l2_tn_info,
7509 : : struct ixgbe_l2_tn_key *key)
7510 : : {
7511 : : int ret;
7512 : :
7513 : 0 : ret = rte_hash_lookup(l2_tn_info->hash_handle, (const void *)key);
7514 [ # # ]: 0 : if (ret < 0)
7515 : : return NULL;
7516 : :
7517 : 0 : return l2_tn_info->hash_map[ret];
7518 : : }
7519 : :
7520 : : static inline int
7521 : 0 : ixgbe_insert_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7522 : : struct ixgbe_l2_tn_filter *l2_tn_filter)
7523 : : {
7524 : : int ret;
7525 : :
7526 : 0 : ret = rte_hash_add_key(l2_tn_info->hash_handle,
7527 : 0 : &l2_tn_filter->key);
7528 : :
7529 [ # # ]: 0 : if (ret < 0) {
7530 : 0 : PMD_DRV_LOG(ERR,
7531 : : "Failed to insert L2 tunnel filter"
7532 : : " to hash table %d!",
7533 : : ret);
7534 : 0 : return ret;
7535 : : }
7536 : :
7537 : 0 : l2_tn_info->hash_map[ret] = l2_tn_filter;
7538 : :
7539 : 0 : TAILQ_INSERT_TAIL(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7540 : :
7541 : 0 : return 0;
7542 : : }
7543 : :
7544 : : static inline int
7545 : 0 : ixgbe_remove_l2_tn_filter(struct ixgbe_l2_tn_info *l2_tn_info,
7546 : : struct ixgbe_l2_tn_key *key)
7547 : : {
7548 : : int ret;
7549 : : struct ixgbe_l2_tn_filter *l2_tn_filter;
7550 : :
7551 : 0 : ret = rte_hash_del_key(l2_tn_info->hash_handle, key);
7552 : :
7553 [ # # ]: 0 : if (ret < 0) {
7554 : 0 : PMD_DRV_LOG(ERR,
7555 : : "No such L2 tunnel filter to delete %d!",
7556 : : ret);
7557 : 0 : return ret;
7558 : : }
7559 : :
7560 : 0 : l2_tn_filter = l2_tn_info->hash_map[ret];
7561 : 0 : l2_tn_info->hash_map[ret] = NULL;
7562 : :
7563 [ # # ]: 0 : TAILQ_REMOVE(&l2_tn_info->l2_tn_list, l2_tn_filter, entries);
7564 : 0 : rte_free(l2_tn_filter);
7565 : :
7566 : 0 : return 0;
7567 : : }
7568 : :
7569 : : /* Add l2 tunnel filter */
7570 : : int
7571 : 0 : ixgbe_dev_l2_tunnel_filter_add(struct rte_eth_dev *dev,
7572 : : struct ixgbe_l2_tunnel_conf *l2_tunnel,
7573 : : bool restore)
7574 : : {
7575 : : int ret;
7576 : 0 : struct ixgbe_l2_tn_info *l2_tn_info =
7577 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7578 : : struct ixgbe_l2_tn_key key;
7579 : : struct ixgbe_l2_tn_filter *node;
7580 : :
7581 [ # # ]: 0 : if (!restore) {
7582 : 0 : key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7583 : 0 : key.tn_id = l2_tunnel->tunnel_id;
7584 : :
7585 : : node = ixgbe_l2_tn_filter_lookup(l2_tn_info, &key);
7586 : :
7587 [ # # ]: 0 : if (node) {
7588 : 0 : PMD_DRV_LOG(ERR,
7589 : : "The L2 tunnel filter already exists!");
7590 : 0 : return -EINVAL;
7591 : : }
7592 : :
7593 : 0 : node = rte_zmalloc("ixgbe_l2_tn",
7594 : : sizeof(struct ixgbe_l2_tn_filter),
7595 : : 0);
7596 [ # # ]: 0 : if (!node)
7597 : : return -ENOMEM;
7598 : :
7599 [ # # ]: 0 : rte_memcpy(&node->key,
7600 : : &key,
7601 : : sizeof(struct ixgbe_l2_tn_key));
7602 : 0 : node->pool = l2_tunnel->pool;
7603 : 0 : ret = ixgbe_insert_l2_tn_filter(l2_tn_info, node);
7604 [ # # ]: 0 : if (ret < 0) {
7605 : 0 : rte_free(node);
7606 : 0 : return ret;
7607 : : }
7608 : : }
7609 : :
7610 [ # # ]: 0 : switch (l2_tunnel->l2_tunnel_type) {
7611 : 0 : case RTE_ETH_L2_TUNNEL_TYPE_E_TAG:
7612 : 0 : ret = ixgbe_e_tag_filter_add(dev, l2_tunnel);
7613 : 0 : break;
7614 : 0 : default:
7615 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
7616 : : ret = -EINVAL;
7617 : 0 : break;
7618 : : }
7619 : :
7620 [ # # ]: 0 : if ((!restore) && (ret < 0))
7621 : 0 : (void)ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7622 : :
7623 : : return ret;
7624 : : }
7625 : :
7626 : : /* Delete l2 tunnel filter */
7627 : : int
7628 : 0 : ixgbe_dev_l2_tunnel_filter_del(struct rte_eth_dev *dev,
7629 : : struct ixgbe_l2_tunnel_conf *l2_tunnel)
7630 : : {
7631 : : int ret;
7632 : 0 : struct ixgbe_l2_tn_info *l2_tn_info =
7633 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
7634 : : struct ixgbe_l2_tn_key key;
7635 : :
7636 : 0 : key.l2_tn_type = l2_tunnel->l2_tunnel_type;
7637 : 0 : key.tn_id = l2_tunnel->tunnel_id;
7638 : 0 : ret = ixgbe_remove_l2_tn_filter(l2_tn_info, &key);
7639 [ # # ]: 0 : if (ret < 0)
7640 : : return ret;
7641 : :
7642 [ # # ]: 0 : switch (l2_tunnel->l2_tunnel_type) {
7643 : 0 : case RTE_ETH_L2_TUNNEL_TYPE_E_TAG:
7644 : 0 : ret = ixgbe_e_tag_filter_del(dev, l2_tunnel);
7645 : 0 : break;
7646 : 0 : default:
7647 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
7648 : : ret = -EINVAL;
7649 : 0 : break;
7650 : : }
7651 : :
7652 : : return ret;
7653 : : }
7654 : :
7655 : : static int
7656 : : ixgbe_e_tag_forwarding_en_dis(struct rte_eth_dev *dev, bool en)
7657 : : {
7658 : : int ret = 0;
7659 : : uint32_t ctrl;
7660 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7661 : :
7662 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7663 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7664 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7665 : : return -ENOTSUP;
7666 : : }
7667 : :
7668 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
7669 : 0 : ctrl &= ~IXGBE_VT_CTL_POOLING_MODE_MASK;
7670 : : if (en)
7671 : 0 : ctrl |= IXGBE_VT_CTL_POOLING_MODE_ETAG;
7672 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, ctrl);
7673 : :
7674 : 0 : return ret;
7675 : : }
7676 : :
7677 : : static int
7678 : : ixgbe_update_vxlan_port(struct ixgbe_hw *hw,
7679 : : uint16_t port)
7680 : : {
7681 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, port);
7682 : 0 : IXGBE_WRITE_FLUSH(hw);
7683 : :
7684 : : return 0;
7685 : : }
7686 : :
7687 : : /* There's only one register for VxLAN UDP port.
7688 : : * So, we cannot add several ports. Will update it.
7689 : : */
7690 : : static int
7691 : 0 : ixgbe_add_vxlan_port(struct ixgbe_hw *hw,
7692 : : uint16_t port)
7693 : : {
7694 [ # # ]: 0 : if (port == 0) {
7695 : 0 : PMD_DRV_LOG(ERR, "Add VxLAN port 0 is not allowed.");
7696 : 0 : return -EINVAL;
7697 : : }
7698 : :
7699 : 0 : return ixgbe_update_vxlan_port(hw, port);
7700 : : }
7701 : :
7702 : : /* We cannot delete the VxLAN port. For there's a register for VxLAN
7703 : : * UDP port, it must have a value.
7704 : : * So, will reset it to the original value 0.
7705 : : */
7706 : : static int
7707 : 0 : ixgbe_del_vxlan_port(struct ixgbe_hw *hw,
7708 : : uint16_t port)
7709 : : {
7710 : : uint16_t cur_port;
7711 : :
7712 : 0 : cur_port = (uint16_t)IXGBE_READ_REG(hw, IXGBE_VXLANCTRL);
7713 : :
7714 [ # # ]: 0 : if (cur_port != port) {
7715 : 0 : PMD_DRV_LOG(ERR, "Port %u does not exist.", port);
7716 : 0 : return -EINVAL;
7717 : : }
7718 : :
7719 : 0 : return ixgbe_update_vxlan_port(hw, 0);
7720 : : }
7721 : :
7722 : : /* Add UDP tunneling port */
7723 : : static int
7724 : 0 : ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev *dev,
7725 : : struct rte_eth_udp_tunnel *udp_tunnel)
7726 : : {
7727 : : int ret = 0;
7728 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7729 : :
7730 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7731 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7732 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7733 : : return -ENOTSUP;
7734 : : }
7735 : :
7736 [ # # ]: 0 : if (udp_tunnel == NULL)
7737 : : return -EINVAL;
7738 : :
7739 [ # # # ]: 0 : switch (udp_tunnel->prot_type) {
7740 : 0 : case RTE_ETH_TUNNEL_TYPE_VXLAN:
7741 : 0 : ret = ixgbe_add_vxlan_port(hw, udp_tunnel->udp_port);
7742 : 0 : break;
7743 : :
7744 : 0 : case RTE_ETH_TUNNEL_TYPE_GENEVE:
7745 : : case RTE_ETH_TUNNEL_TYPE_TEREDO:
7746 : 0 : PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7747 : : ret = -EINVAL;
7748 : 0 : break;
7749 : :
7750 : 0 : default:
7751 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
7752 : : ret = -EINVAL;
7753 : 0 : break;
7754 : : }
7755 : :
7756 : : return ret;
7757 : : }
7758 : :
7759 : : /* Remove UDP tunneling port */
7760 : : static int
7761 : 0 : ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
7762 : : struct rte_eth_udp_tunnel *udp_tunnel)
7763 : : {
7764 : : int ret = 0;
7765 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7766 : :
7767 : 0 : if (hw->mac.type != ixgbe_mac_X550 &&
7768 [ # # ]: 0 : hw->mac.type != ixgbe_mac_X550EM_x &&
7769 : : hw->mac.type != ixgbe_mac_X550EM_a) {
7770 : : return -ENOTSUP;
7771 : : }
7772 : :
7773 [ # # ]: 0 : if (udp_tunnel == NULL)
7774 : : return -EINVAL;
7775 : :
7776 [ # # # ]: 0 : switch (udp_tunnel->prot_type) {
7777 : 0 : case RTE_ETH_TUNNEL_TYPE_VXLAN:
7778 : 0 : ret = ixgbe_del_vxlan_port(hw, udp_tunnel->udp_port);
7779 : 0 : break;
7780 : 0 : case RTE_ETH_TUNNEL_TYPE_GENEVE:
7781 : : case RTE_ETH_TUNNEL_TYPE_TEREDO:
7782 : 0 : PMD_DRV_LOG(ERR, "Tunnel type is not supported now.");
7783 : : ret = -EINVAL;
7784 : 0 : break;
7785 : 0 : default:
7786 : 0 : PMD_DRV_LOG(ERR, "Invalid tunnel type");
7787 : : ret = -EINVAL;
7788 : 0 : break;
7789 : : }
7790 : :
7791 : : return ret;
7792 : : }
7793 : :
7794 : : static int
7795 : 0 : ixgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
7796 : : {
7797 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7798 : : int ret;
7799 : :
7800 [ # # # ]: 0 : switch (hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_PROMISC)) {
7801 : : case IXGBE_SUCCESS:
7802 : : ret = 0;
7803 : : break;
7804 : 0 : case IXGBE_ERR_FEATURE_NOT_SUPPORTED:
7805 : : ret = -ENOTSUP;
7806 : 0 : break;
7807 : 0 : default:
7808 : : ret = -EAGAIN;
7809 : 0 : break;
7810 : : }
7811 : :
7812 : 0 : return ret;
7813 : : }
7814 : :
7815 : : static int
7816 : 0 : ixgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev)
7817 : : {
7818 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7819 : : int mode = IXGBEVF_XCAST_MODE_NONE;
7820 : : int ret;
7821 : :
7822 [ # # ]: 0 : if (dev->data->all_multicast)
7823 : : mode = IXGBEVF_XCAST_MODE_ALLMULTI;
7824 : :
7825 [ # # # ]: 0 : switch (hw->mac.ops.update_xcast_mode(hw, mode)) {
7826 : : case IXGBE_SUCCESS:
7827 : : ret = 0;
7828 : : break;
7829 : 0 : case IXGBE_ERR_FEATURE_NOT_SUPPORTED:
7830 : : ret = -ENOTSUP;
7831 : 0 : break;
7832 : 0 : default:
7833 : : ret = -EAGAIN;
7834 : 0 : break;
7835 : : }
7836 : :
7837 : 0 : return ret;
7838 : : }
7839 : :
7840 : : static int
7841 : 0 : ixgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
7842 : : {
7843 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7844 : : int ret;
7845 : : int mode = IXGBEVF_XCAST_MODE_ALLMULTI;
7846 : :
7847 [ # # ]: 0 : if (dev->data->promiscuous)
7848 : : return 0;
7849 : :
7850 [ # # # ]: 0 : switch (hw->mac.ops.update_xcast_mode(hw, mode)) {
7851 : : case IXGBE_SUCCESS:
7852 : : ret = 0;
7853 : : break;
7854 : 0 : case IXGBE_ERR_FEATURE_NOT_SUPPORTED:
7855 : : ret = -ENOTSUP;
7856 : 0 : break;
7857 : 0 : default:
7858 : : ret = -EAGAIN;
7859 : 0 : break;
7860 : : }
7861 : :
7862 : : return ret;
7863 : : }
7864 : :
7865 : : static int
7866 : 0 : ixgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
7867 : : {
7868 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7869 : : int ret;
7870 : :
7871 [ # # ]: 0 : if (dev->data->promiscuous)
7872 : : return 0;
7873 : :
7874 [ # # # ]: 0 : switch (hw->mac.ops.update_xcast_mode(hw, IXGBEVF_XCAST_MODE_MULTI)) {
7875 : : case IXGBE_SUCCESS:
7876 : : ret = 0;
7877 : : break;
7878 : 0 : case IXGBE_ERR_FEATURE_NOT_SUPPORTED:
7879 : : ret = -ENOTSUP;
7880 : 0 : break;
7881 : 0 : default:
7882 : : ret = -EAGAIN;
7883 : 0 : break;
7884 : : }
7885 : :
7886 : : return ret;
7887 : : }
7888 : :
7889 : 0 : static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
7890 : : {
7891 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7892 : 0 : u32 in_msg = 0;
7893 : :
7894 : : /* peek the message first */
7895 : 0 : in_msg = IXGBE_READ_REG(hw, IXGBE_VFMBMEM);
7896 : :
7897 : : /* PF reset VF event */
7898 [ # # ]: 0 : if (in_msg == IXGBE_PF_CONTROL_MSG) {
7899 : : /* dummy mbx read to ack pf */
7900 [ # # ]: 0 : if (ixgbe_read_mbx(hw, &in_msg, 1, 0))
7901 : 0 : return;
7902 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
7903 : : NULL);
7904 : : }
7905 : : }
7906 : :
7907 : : static int
7908 : 0 : ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
7909 : : {
7910 : : uint32_t eicr;
7911 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
7912 : : struct ixgbe_interrupt *intr =
7913 : : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7914 : 0 : ixgbevf_intr_disable(dev);
7915 : :
7916 : : /* read-on-clear nic registers here */
7917 : 0 : eicr = IXGBE_READ_REG(hw, IXGBE_VTEICR);
7918 : 0 : intr->flags = 0;
7919 : :
7920 : : /* only one misc vector supported - mailbox */
7921 : 0 : eicr &= IXGBE_VTEICR_MASK;
7922 [ # # ]: 0 : if (eicr == IXGBE_MISC_VEC_ID)
7923 : 0 : intr->flags |= IXGBE_FLAG_MAILBOX;
7924 : :
7925 : 0 : return 0;
7926 : : }
7927 : :
7928 : : static int
7929 : 0 : ixgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
7930 : : {
7931 : : struct ixgbe_interrupt *intr =
7932 : 0 : IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
7933 : :
7934 [ # # ]: 0 : if (intr->flags & IXGBE_FLAG_MAILBOX) {
7935 : 0 : ixgbevf_mbx_process(dev);
7936 : 0 : intr->flags &= ~IXGBE_FLAG_MAILBOX;
7937 : : }
7938 : :
7939 : 0 : ixgbevf_intr_enable(dev);
7940 : :
7941 : 0 : return 0;
7942 : : }
7943 : :
7944 : : static void
7945 : 0 : ixgbevf_dev_interrupt_handler(void *param)
7946 : : {
7947 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
7948 : :
7949 : 0 : ixgbevf_dev_interrupt_get_status(dev);
7950 : 0 : ixgbevf_dev_interrupt_action(dev);
7951 : 0 : }
7952 : :
7953 : : /**
7954 : : * ixgbe_disable_sec_tx_path_generic - Stops the transmit data path
7955 : : * @hw: pointer to hardware structure
7956 : : *
7957 : : * Stops the transmit data path and waits for the HW to internally empty
7958 : : * the Tx security block
7959 : : **/
7960 : 0 : int ixgbe_disable_sec_tx_path_generic(struct ixgbe_hw *hw)
7961 : : {
7962 : : #define IXGBE_MAX_SECTX_POLL 40
7963 : :
7964 : : int i;
7965 : : int sectxreg;
7966 : :
7967 : 0 : sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7968 : 0 : sectxreg |= IXGBE_SECTXCTRL_TX_DIS;
7969 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7970 [ # # ]: 0 : for (i = 0; i < IXGBE_MAX_SECTX_POLL; i++) {
7971 : 0 : sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT);
7972 [ # # ]: 0 : if (sectxreg & IXGBE_SECTXSTAT_SECTX_RDY)
7973 : : break;
7974 : : /* Use interrupt-safe sleep just in case */
7975 : 0 : usec_delay(1000);
7976 : : }
7977 : :
7978 : : /* For informational purposes only */
7979 [ # # ]: 0 : if (i >= IXGBE_MAX_SECTX_POLL)
7980 : 0 : PMD_DRV_LOG(DEBUG, "Tx unit being enabled before security "
7981 : : "path fully disabled. Continuing with init.");
7982 : :
7983 : 0 : return IXGBE_SUCCESS;
7984 : : }
7985 : :
7986 : : /**
7987 : : * ixgbe_enable_sec_tx_path_generic - Enables the transmit data path
7988 : : * @hw: pointer to hardware structure
7989 : : *
7990 : : * Enables the transmit data path.
7991 : : **/
7992 : 0 : int ixgbe_enable_sec_tx_path_generic(struct ixgbe_hw *hw)
7993 : : {
7994 : : uint32_t sectxreg;
7995 : :
7996 : 0 : sectxreg = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
7997 : 0 : sectxreg &= ~IXGBE_SECTXCTRL_TX_DIS;
7998 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, sectxreg);
7999 : 0 : IXGBE_WRITE_FLUSH(hw);
8000 : :
8001 : 0 : return IXGBE_SUCCESS;
8002 : : }
8003 : :
8004 : : /* restore n-tuple filter */
8005 : : static inline void
8006 : : ixgbe_ntuple_filter_restore(struct rte_eth_dev *dev)
8007 : : {
8008 : : struct ixgbe_filter_info *filter_info =
8009 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8010 : : struct ixgbe_5tuple_filter *node;
8011 : :
8012 [ # # ]: 0 : TAILQ_FOREACH(node, &filter_info->fivetuple_list, entries) {
8013 : 0 : ixgbe_inject_5tuple_filter(dev, node);
8014 : : }
8015 : : }
8016 : :
8017 : : /* restore ethernet type filter */
8018 : : static inline void
8019 : 0 : ixgbe_ethertype_filter_restore(struct rte_eth_dev *dev)
8020 : : {
8021 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8022 : : struct ixgbe_filter_info *filter_info =
8023 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8024 : : int i;
8025 : :
8026 [ # # ]: 0 : for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8027 [ # # ]: 0 : if (filter_info->ethertype_mask & (1 << i)) {
8028 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQF(i),
8029 : : filter_info->ethertype_filters[i].etqf);
8030 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQS(i),
8031 : : filter_info->ethertype_filters[i].etqs);
8032 : 0 : IXGBE_WRITE_FLUSH(hw);
8033 : : }
8034 : : }
8035 : 0 : }
8036 : :
8037 : : /* restore SYN filter */
8038 : : static inline void
8039 : : ixgbe_syn_filter_restore(struct rte_eth_dev *dev)
8040 : : {
8041 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8042 : : struct ixgbe_filter_info *filter_info =
8043 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8044 : : uint32_t synqf;
8045 : :
8046 : 0 : synqf = filter_info->syn_info;
8047 : :
8048 [ # # ]: 0 : if (synqf & IXGBE_SYN_FILTER_ENABLE) {
8049 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SYNQF, synqf);
8050 : 0 : IXGBE_WRITE_FLUSH(hw);
8051 : : }
8052 : : }
8053 : :
8054 : : /* restore L2 tunnel filter */
8055 : : static inline void
8056 : 0 : ixgbe_l2_tn_filter_restore(struct rte_eth_dev *dev)
8057 : : {
8058 : : struct ixgbe_l2_tn_info *l2_tn_info =
8059 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8060 : : struct ixgbe_l2_tn_filter *node;
8061 : : struct ixgbe_l2_tunnel_conf l2_tn_conf;
8062 : :
8063 [ # # ]: 0 : TAILQ_FOREACH(node, &l2_tn_info->l2_tn_list, entries) {
8064 : 0 : l2_tn_conf.l2_tunnel_type = node->key.l2_tn_type;
8065 : 0 : l2_tn_conf.tunnel_id = node->key.tn_id;
8066 : 0 : l2_tn_conf.pool = node->pool;
8067 : 0 : (void)ixgbe_dev_l2_tunnel_filter_add(dev, &l2_tn_conf, TRUE);
8068 : : }
8069 : 0 : }
8070 : :
8071 : : /* restore rss filter */
8072 : : static inline void
8073 : : ixgbe_rss_filter_restore(struct rte_eth_dev *dev)
8074 : : {
8075 : : struct ixgbe_filter_info *filter_info =
8076 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8077 : :
8078 [ # # ]: 0 : if (filter_info->rss_info.conf.queue_num)
8079 : 0 : ixgbe_config_rss_filter(dev,
8080 : : &filter_info->rss_info, TRUE);
8081 : : }
8082 : :
8083 : : static int
8084 : 0 : ixgbe_filter_restore(struct rte_eth_dev *dev)
8085 : : {
8086 : : ixgbe_ntuple_filter_restore(dev);
8087 : 0 : ixgbe_ethertype_filter_restore(dev);
8088 : : ixgbe_syn_filter_restore(dev);
8089 : 0 : ixgbe_fdir_filter_restore(dev);
8090 : 0 : ixgbe_l2_tn_filter_restore(dev);
8091 : : ixgbe_rss_filter_restore(dev);
8092 : :
8093 : 0 : return 0;
8094 : : }
8095 : :
8096 : : static void
8097 : 0 : ixgbe_l2_tunnel_conf(struct rte_eth_dev *dev)
8098 : : {
8099 : : struct ixgbe_l2_tn_info *l2_tn_info =
8100 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8101 : : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8102 : :
8103 [ # # ]: 0 : if (l2_tn_info->e_tag_en)
8104 : : (void)ixgbe_e_tag_enable(hw);
8105 : :
8106 [ # # ]: 0 : if (l2_tn_info->e_tag_fwd_en)
8107 : : (void)ixgbe_e_tag_forwarding_en_dis(dev, 1);
8108 : :
8109 [ # # ]: 0 : (void)ixgbe_update_e_tag_eth_type(hw, l2_tn_info->e_tag_ether_type);
8110 : 0 : }
8111 : :
8112 : : /* remove all the n-tuple filters */
8113 : : void
8114 : 0 : ixgbe_clear_all_ntuple_filter(struct rte_eth_dev *dev)
8115 : : {
8116 : : struct ixgbe_filter_info *filter_info =
8117 : 0 : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8118 : : struct ixgbe_5tuple_filter *p_5tuple;
8119 : :
8120 [ # # ]: 0 : while ((p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list)))
8121 : 0 : ixgbe_remove_5tuple_filter(dev, p_5tuple);
8122 : 0 : }
8123 : :
8124 : : /* remove all the ether type filters */
8125 : : void
8126 : 0 : ixgbe_clear_all_ethertype_filter(struct rte_eth_dev *dev)
8127 : : {
8128 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8129 : : struct ixgbe_filter_info *filter_info =
8130 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8131 : : int i;
8132 : :
8133 [ # # ]: 0 : for (i = 0; i < IXGBE_MAX_ETQF_FILTERS; i++) {
8134 [ # # ]: 0 : if (filter_info->ethertype_mask & (1 << i) &&
8135 [ # # ]: 0 : !filter_info->ethertype_filters[i].conf) {
8136 : : (void)ixgbe_ethertype_filter_remove(filter_info,
8137 : : (uint8_t)i);
8138 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQF(i), 0);
8139 : 0 : IXGBE_WRITE_REG(hw, IXGBE_ETQS(i), 0);
8140 : 0 : IXGBE_WRITE_FLUSH(hw);
8141 : : }
8142 : : }
8143 : 0 : }
8144 : :
8145 : : /* remove the SYN filter */
8146 : : void
8147 : 0 : ixgbe_clear_syn_filter(struct rte_eth_dev *dev)
8148 : : {
8149 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8150 : : struct ixgbe_filter_info *filter_info =
8151 : : IXGBE_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
8152 : :
8153 [ # # ]: 0 : if (filter_info->syn_info & IXGBE_SYN_FILTER_ENABLE) {
8154 : 0 : filter_info->syn_info = 0;
8155 : :
8156 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SYNQF, 0);
8157 : 0 : IXGBE_WRITE_FLUSH(hw);
8158 : : }
8159 : 0 : }
8160 : :
8161 : : /* remove all the L2 tunnel filters */
8162 : : int
8163 : 0 : ixgbe_clear_all_l2_tn_filter(struct rte_eth_dev *dev)
8164 : : {
8165 : : struct ixgbe_l2_tn_info *l2_tn_info =
8166 : 0 : IXGBE_DEV_PRIVATE_TO_L2_TN_INFO(dev->data->dev_private);
8167 : : struct ixgbe_l2_tn_filter *l2_tn_filter;
8168 : : struct ixgbe_l2_tunnel_conf l2_tn_conf;
8169 : : int ret = 0;
8170 : :
8171 [ # # ]: 0 : while ((l2_tn_filter = TAILQ_FIRST(&l2_tn_info->l2_tn_list))) {
8172 : 0 : l2_tn_conf.l2_tunnel_type = l2_tn_filter->key.l2_tn_type;
8173 : 0 : l2_tn_conf.tunnel_id = l2_tn_filter->key.tn_id;
8174 : 0 : l2_tn_conf.pool = l2_tn_filter->pool;
8175 : 0 : ret = ixgbe_dev_l2_tunnel_filter_del(dev, &l2_tn_conf);
8176 [ # # ]: 0 : if (ret < 0)
8177 : 0 : return ret;
8178 : : }
8179 : :
8180 : : return 0;
8181 : : }
8182 : :
8183 : : void
8184 : 0 : ixgbe_dev_macsec_setting_save(struct rte_eth_dev *dev,
8185 : : struct ixgbe_macsec_setting *macsec_setting)
8186 : : {
8187 : : struct ixgbe_macsec_setting *macsec =
8188 : 0 : IXGBE_DEV_PRIVATE_TO_MACSEC_SETTING(dev->data->dev_private);
8189 : :
8190 : 0 : macsec->offload_en = macsec_setting->offload_en;
8191 : 0 : macsec->encrypt_en = macsec_setting->encrypt_en;
8192 : 0 : macsec->replayprotect_en = macsec_setting->replayprotect_en;
8193 : 0 : }
8194 : :
8195 : : void
8196 : 0 : ixgbe_dev_macsec_setting_reset(struct rte_eth_dev *dev)
8197 : : {
8198 : : struct ixgbe_macsec_setting *macsec =
8199 : 0 : IXGBE_DEV_PRIVATE_TO_MACSEC_SETTING(dev->data->dev_private);
8200 : :
8201 : 0 : macsec->offload_en = 0;
8202 : 0 : macsec->encrypt_en = 0;
8203 : 0 : macsec->replayprotect_en = 0;
8204 : 0 : }
8205 : :
8206 : : void
8207 : 0 : ixgbe_dev_macsec_register_enable(struct rte_eth_dev *dev,
8208 : : struct ixgbe_macsec_setting *macsec_setting)
8209 : : {
8210 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8211 : : uint32_t ctrl;
8212 : 0 : uint8_t en = macsec_setting->encrypt_en;
8213 : 0 : uint8_t rp = macsec_setting->replayprotect_en;
8214 : :
8215 : : /**
8216 : : * Workaround:
8217 : : * As no ixgbe_disable_sec_rx_path equivalent is
8218 : : * implemented for tx in the base code, and we are
8219 : : * not allowed to modify the base code in DPDK, so
8220 : : * just call the hand-written one directly for now.
8221 : : * The hardware support has been checked by
8222 : : * ixgbe_disable_sec_rx_path().
8223 : : */
8224 : 0 : ixgbe_disable_sec_tx_path_generic(hw);
8225 : :
8226 : : /* Enable Ethernet CRC (required by MACsec offload) */
8227 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_HLREG0);
8228 : 0 : ctrl |= IXGBE_HLREG0_TXCRCEN | IXGBE_HLREG0_RXCRCSTRP;
8229 : 0 : IXGBE_WRITE_REG(hw, IXGBE_HLREG0, ctrl);
8230 : :
8231 : : /* Enable the TX and RX crypto engines */
8232 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8233 : 0 : ctrl &= ~IXGBE_SECTXCTRL_SECTX_DIS;
8234 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, ctrl);
8235 : :
8236 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
8237 : 0 : ctrl &= ~IXGBE_SECRXCTRL_SECRX_DIS;
8238 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, ctrl);
8239 : :
8240 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXMINIFG);
8241 : 0 : ctrl &= ~IXGBE_SECTX_MINSECIFG_MASK;
8242 : 0 : ctrl |= 0x3;
8243 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECTXMINIFG, ctrl);
8244 : :
8245 : : /* Enable SA lookup */
8246 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_LSECTXCTRL);
8247 : 0 : ctrl &= ~IXGBE_LSECTXCTRL_EN_MASK;
8248 [ # # ]: 0 : ctrl |= en ? IXGBE_LSECTXCTRL_AUTH_ENCRYPT :
8249 : : IXGBE_LSECTXCTRL_AUTH;
8250 : : ctrl |= IXGBE_LSECTXCTRL_AISCI;
8251 : : ctrl &= ~IXGBE_LSECTXCTRL_PNTHRSH_MASK;
8252 : 0 : ctrl |= IXGBE_MACSEC_PNTHRSH & IXGBE_LSECTXCTRL_PNTHRSH_MASK;
8253 : 0 : IXGBE_WRITE_REG(hw, IXGBE_LSECTXCTRL, ctrl);
8254 : :
8255 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_LSECRXCTRL);
8256 : : ctrl &= ~IXGBE_LSECRXCTRL_EN_MASK;
8257 : : ctrl |= IXGBE_LSECRXCTRL_STRICT << IXGBE_LSECRXCTRL_EN_SHIFT;
8258 : : ctrl &= ~IXGBE_LSECRXCTRL_PLSH;
8259 [ # # ]: 0 : if (rp)
8260 : 0 : ctrl |= IXGBE_LSECRXCTRL_RP;
8261 : : else
8262 : 0 : ctrl &= ~IXGBE_LSECRXCTRL_RP;
8263 : 0 : IXGBE_WRITE_REG(hw, IXGBE_LSECRXCTRL, ctrl);
8264 : :
8265 : : /* Start the data paths */
8266 : 0 : ixgbe_enable_sec_rx_path(hw);
8267 : : /**
8268 : : * Workaround:
8269 : : * As no ixgbe_enable_sec_rx_path equivalent is
8270 : : * implemented for tx in the base code, and we are
8271 : : * not allowed to modify the base code in DPDK, so
8272 : : * just call the hand-written one directly for now.
8273 : : */
8274 : 0 : ixgbe_enable_sec_tx_path_generic(hw);
8275 : 0 : }
8276 : :
8277 : : void
8278 : 0 : ixgbe_dev_macsec_register_disable(struct rte_eth_dev *dev)
8279 : : {
8280 : 0 : struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
8281 : : uint32_t ctrl;
8282 : :
8283 : : /**
8284 : : * Workaround:
8285 : : * As no ixgbe_disable_sec_rx_path equivalent is
8286 : : * implemented for tx in the base code, and we are
8287 : : * not allowed to modify the base code in DPDK, so
8288 : : * just call the hand-written one directly for now.
8289 : : * The hardware support has been checked by
8290 : : * ixgbe_disable_sec_rx_path().
8291 : : */
8292 : 0 : ixgbe_disable_sec_tx_path_generic(hw);
8293 : :
8294 : : /* Disable the TX and RX crypto engines */
8295 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_SECTXCTRL);
8296 : 0 : ctrl |= IXGBE_SECTXCTRL_SECTX_DIS;
8297 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECTXCTRL, ctrl);
8298 : :
8299 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_SECRXCTRL);
8300 : 0 : ctrl |= IXGBE_SECRXCTRL_SECRX_DIS;
8301 : 0 : IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, ctrl);
8302 : :
8303 : : /* Disable SA lookup */
8304 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_LSECTXCTRL);
8305 : 0 : ctrl &= ~IXGBE_LSECTXCTRL_EN_MASK;
8306 : : ctrl |= IXGBE_LSECTXCTRL_DISABLE;
8307 : 0 : IXGBE_WRITE_REG(hw, IXGBE_LSECTXCTRL, ctrl);
8308 : :
8309 : 0 : ctrl = IXGBE_READ_REG(hw, IXGBE_LSECRXCTRL);
8310 : 0 : ctrl &= ~IXGBE_LSECRXCTRL_EN_MASK;
8311 : : ctrl |= IXGBE_LSECRXCTRL_DISABLE << IXGBE_LSECRXCTRL_EN_SHIFT;
8312 : 0 : IXGBE_WRITE_REG(hw, IXGBE_LSECRXCTRL, ctrl);
8313 : :
8314 : : /* Start the data paths */
8315 : 0 : ixgbe_enable_sec_rx_path(hw);
8316 : : /**
8317 : : * Workaround:
8318 : : * As no ixgbe_enable_sec_rx_path equivalent is
8319 : : * implemented for tx in the base code, and we are
8320 : : * not allowed to modify the base code in DPDK, so
8321 : : * just call the hand-written one directly for now.
8322 : : */
8323 : 0 : ixgbe_enable_sec_tx_path_generic(hw);
8324 : 0 : }
8325 : :
8326 : 238 : RTE_PMD_REGISTER_PCI(net_ixgbe, rte_ixgbe_pmd);
8327 : : RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe, pci_id_ixgbe_map);
8328 : : RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe, "* igb_uio | uio_pci_generic | vfio-pci");
8329 : : RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe,
8330 : : IXGBE_DEVARG_FIBER_SDP3_NOT_TX_DISABLE "=<0|1>");
8331 : 238 : RTE_PMD_REGISTER_PCI(net_ixgbe_vf, rte_ixgbevf_pmd);
8332 : : RTE_PMD_REGISTER_PCI_TABLE(net_ixgbe_vf, pci_id_ixgbevf_map);
8333 : : RTE_PMD_REGISTER_KMOD_DEP(net_ixgbe_vf, "* igb_uio | vfio-pci");
8334 : : RTE_PMD_REGISTER_PARAM_STRING(net_ixgbe_vf,
8335 : : IXGBEVF_DEVARG_PFLINK_FULLCHK "=<0|1>");
8336 : :
8337 [ - + ]: 238 : RTE_LOG_REGISTER_SUFFIX(ixgbe_logtype_init, init, NOTICE);
8338 [ - + ]: 238 : RTE_LOG_REGISTER_SUFFIX(ixgbe_logtype_driver, driver, NOTICE);
8339 : :
8340 : : #ifdef RTE_ETHDEV_DEBUG_RX
8341 : : RTE_LOG_REGISTER_SUFFIX(ixgbe_logtype_rx, rx, DEBUG);
8342 : : #endif
8343 : : #ifdef RTE_ETHDEV_DEBUG_TX
8344 : : RTE_LOG_REGISTER_SUFFIX(ixgbe_logtype_tx, tx, DEBUG);
8345 : : #endif
|