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