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