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