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