4 * Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/queue.h>
40 #include <rte_common.h>
41 #include <rte_interrupts.h>
42 #include <rte_byteorder.h>
44 #include <rte_debug.h>
46 #include <rte_ether.h>
47 #include <rte_ethdev.h>
48 #include <rte_memory.h>
49 #include <rte_memzone.h>
51 #include <rte_atomic.h>
52 #include <rte_malloc.h>
55 #include "e1000_logs.h"
56 #include "base/e1000_api.h"
57 #include "e1000_ethdev.h"
61 * Default values for port configuration
63 #define IGB_DEFAULT_RX_FREE_THRESH 32
64 #define IGB_DEFAULT_RX_PTHRESH 8
65 #define IGB_DEFAULT_RX_HTHRESH 8
66 #define IGB_DEFAULT_RX_WTHRESH 0
68 #define IGB_DEFAULT_TX_PTHRESH 32
69 #define IGB_DEFAULT_TX_HTHRESH 0
70 #define IGB_DEFAULT_TX_WTHRESH 0
72 #define IGB_HKEY_MAX_INDEX 10
74 /* Bit shift and mask */
75 #define IGB_4_BIT_WIDTH (CHAR_BIT / 2)
76 #define IGB_4_BIT_MASK RTE_LEN2MASK(IGB_4_BIT_WIDTH, uint8_t)
77 #define IGB_8_BIT_WIDTH CHAR_BIT
78 #define IGB_8_BIT_MASK UINT8_MAX
80 /* Additional timesync values. */
81 #define E1000_ETQF_FILTER_1588 3
82 #define E1000_TIMINCA_INCVALUE 16000000
83 #define E1000_TIMINCA_INIT ((0x02 << E1000_TIMINCA_16NS_SHIFT) \
84 | E1000_TIMINCA_INCVALUE)
85 #define E1000_TSAUXC_DISABLE_SYSTIME 0x80000000
87 static int eth_igb_configure(struct rte_eth_dev *dev);
88 static int eth_igb_start(struct rte_eth_dev *dev);
89 static void eth_igb_stop(struct rte_eth_dev *dev);
90 static void eth_igb_close(struct rte_eth_dev *dev);
91 static void eth_igb_promiscuous_enable(struct rte_eth_dev *dev);
92 static void eth_igb_promiscuous_disable(struct rte_eth_dev *dev);
93 static void eth_igb_allmulticast_enable(struct rte_eth_dev *dev);
94 static void eth_igb_allmulticast_disable(struct rte_eth_dev *dev);
95 static int eth_igb_link_update(struct rte_eth_dev *dev,
96 int wait_to_complete);
97 static void eth_igb_stats_get(struct rte_eth_dev *dev,
98 struct rte_eth_stats *rte_stats);
99 static int eth_igb_xstats_get(struct rte_eth_dev *dev,
100 struct rte_eth_xstats *xstats, unsigned n);
101 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
102 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
103 static void eth_igb_infos_get(struct rte_eth_dev *dev,
104 struct rte_eth_dev_info *dev_info);
105 static void eth_igbvf_infos_get(struct rte_eth_dev *dev,
106 struct rte_eth_dev_info *dev_info);
107 static int eth_igb_flow_ctrl_get(struct rte_eth_dev *dev,
108 struct rte_eth_fc_conf *fc_conf);
109 static int eth_igb_flow_ctrl_set(struct rte_eth_dev *dev,
110 struct rte_eth_fc_conf *fc_conf);
111 static int eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev);
112 static int eth_igb_rxq_interrupt_setup(struct rte_eth_dev *dev);
113 static int eth_igb_interrupt_get_status(struct rte_eth_dev *dev);
114 static int eth_igb_interrupt_action(struct rte_eth_dev *dev);
115 static void eth_igb_interrupt_handler(struct rte_intr_handle *handle,
117 static int igb_hardware_init(struct e1000_hw *hw);
118 static void igb_hw_control_acquire(struct e1000_hw *hw);
119 static void igb_hw_control_release(struct e1000_hw *hw);
120 static void igb_init_manageability(struct e1000_hw *hw);
121 static void igb_release_manageability(struct e1000_hw *hw);
123 static int eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
125 static int eth_igb_vlan_filter_set(struct rte_eth_dev *dev,
126 uint16_t vlan_id, int on);
127 static void eth_igb_vlan_tpid_set(struct rte_eth_dev *dev, uint16_t tpid_id);
128 static void eth_igb_vlan_offload_set(struct rte_eth_dev *dev, int mask);
130 static void igb_vlan_hw_filter_enable(struct rte_eth_dev *dev);
131 static void igb_vlan_hw_filter_disable(struct rte_eth_dev *dev);
132 static void igb_vlan_hw_strip_enable(struct rte_eth_dev *dev);
133 static void igb_vlan_hw_strip_disable(struct rte_eth_dev *dev);
134 static void igb_vlan_hw_extend_enable(struct rte_eth_dev *dev);
135 static void igb_vlan_hw_extend_disable(struct rte_eth_dev *dev);
137 static int eth_igb_led_on(struct rte_eth_dev *dev);
138 static int eth_igb_led_off(struct rte_eth_dev *dev);
140 static void igb_intr_disable(struct e1000_hw *hw);
141 static int igb_get_rx_buffer_size(struct e1000_hw *hw);
142 static void eth_igb_rar_set(struct rte_eth_dev *dev,
143 struct ether_addr *mac_addr,
144 uint32_t index, uint32_t pool);
145 static void eth_igb_rar_clear(struct rte_eth_dev *dev, uint32_t index);
146 static void eth_igb_default_mac_addr_set(struct rte_eth_dev *dev,
147 struct ether_addr *addr);
149 static void igbvf_intr_disable(struct e1000_hw *hw);
150 static int igbvf_dev_configure(struct rte_eth_dev *dev);
151 static int igbvf_dev_start(struct rte_eth_dev *dev);
152 static void igbvf_dev_stop(struct rte_eth_dev *dev);
153 static void igbvf_dev_close(struct rte_eth_dev *dev);
154 static int eth_igbvf_link_update(struct e1000_hw *hw);
155 static void eth_igbvf_stats_get(struct rte_eth_dev *dev,
156 struct rte_eth_stats *rte_stats);
157 static int eth_igbvf_xstats_get(struct rte_eth_dev *dev,
158 struct rte_eth_xstats *xstats, unsigned n);
159 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
160 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
161 uint16_t vlan_id, int on);
162 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on);
163 static void igbvf_set_vfta_all(struct rte_eth_dev *dev, bool on);
164 static void igbvf_default_mac_addr_set(struct rte_eth_dev *dev,
165 struct ether_addr *addr);
166 static int igbvf_get_reg_length(struct rte_eth_dev *dev);
167 static int igbvf_get_regs(struct rte_eth_dev *dev,
168 struct rte_dev_reg_info *regs);
170 static int eth_igb_rss_reta_update(struct rte_eth_dev *dev,
171 struct rte_eth_rss_reta_entry64 *reta_conf,
173 static int eth_igb_rss_reta_query(struct rte_eth_dev *dev,
174 struct rte_eth_rss_reta_entry64 *reta_conf,
177 static int eth_igb_syn_filter_set(struct rte_eth_dev *dev,
178 struct rte_eth_syn_filter *filter,
180 static int eth_igb_syn_filter_get(struct rte_eth_dev *dev,
181 struct rte_eth_syn_filter *filter);
182 static int eth_igb_syn_filter_handle(struct rte_eth_dev *dev,
183 enum rte_filter_op filter_op,
185 static int igb_add_2tuple_filter(struct rte_eth_dev *dev,
186 struct rte_eth_ntuple_filter *ntuple_filter);
187 static int igb_remove_2tuple_filter(struct rte_eth_dev *dev,
188 struct rte_eth_ntuple_filter *ntuple_filter);
189 static int eth_igb_add_del_flex_filter(struct rte_eth_dev *dev,
190 struct rte_eth_flex_filter *filter,
192 static int eth_igb_get_flex_filter(struct rte_eth_dev *dev,
193 struct rte_eth_flex_filter *filter);
194 static int eth_igb_flex_filter_handle(struct rte_eth_dev *dev,
195 enum rte_filter_op filter_op,
197 static int igb_add_5tuple_filter_82576(struct rte_eth_dev *dev,
198 struct rte_eth_ntuple_filter *ntuple_filter);
199 static int igb_remove_5tuple_filter_82576(struct rte_eth_dev *dev,
200 struct rte_eth_ntuple_filter *ntuple_filter);
201 static int igb_add_del_ntuple_filter(struct rte_eth_dev *dev,
202 struct rte_eth_ntuple_filter *filter,
204 static int igb_get_ntuple_filter(struct rte_eth_dev *dev,
205 struct rte_eth_ntuple_filter *filter);
206 static int igb_ntuple_filter_handle(struct rte_eth_dev *dev,
207 enum rte_filter_op filter_op,
209 static int igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
210 struct rte_eth_ethertype_filter *filter,
212 static int igb_ethertype_filter_handle(struct rte_eth_dev *dev,
213 enum rte_filter_op filter_op,
215 static int igb_get_ethertype_filter(struct rte_eth_dev *dev,
216 struct rte_eth_ethertype_filter *filter);
217 static int eth_igb_filter_ctrl(struct rte_eth_dev *dev,
218 enum rte_filter_type filter_type,
219 enum rte_filter_op filter_op,
221 static int eth_igb_get_reg_length(struct rte_eth_dev *dev);
222 static int eth_igb_get_regs(struct rte_eth_dev *dev,
223 struct rte_dev_reg_info *regs);
224 static int eth_igb_get_eeprom_length(struct rte_eth_dev *dev);
225 static int eth_igb_get_eeprom(struct rte_eth_dev *dev,
226 struct rte_dev_eeprom_info *eeprom);
227 static int eth_igb_set_eeprom(struct rte_eth_dev *dev,
228 struct rte_dev_eeprom_info *eeprom);
229 static int eth_igb_set_mc_addr_list(struct rte_eth_dev *dev,
230 struct ether_addr *mc_addr_set,
231 uint32_t nb_mc_addr);
232 static int igb_timesync_enable(struct rte_eth_dev *dev);
233 static int igb_timesync_disable(struct rte_eth_dev *dev);
234 static int igb_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
235 struct timespec *timestamp,
237 static int igb_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
238 struct timespec *timestamp);
239 static int eth_igb_rx_queue_intr_enable(struct rte_eth_dev *dev,
241 static int eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev,
243 static void eth_igb_assign_msix_vector(struct e1000_hw *hw, int8_t direction,
244 uint8_t queue, uint8_t msix_vector);
245 static void eth_igb_write_ivar(struct e1000_hw *hw, uint8_t msix_vector,
246 uint8_t index, uint8_t offset);
247 static void eth_igb_configure_msix_intr(struct rte_eth_dev *dev);
250 * Define VF Stats MACRO for Non "cleared on read" register
252 #define UPDATE_VF_STAT(reg, last, cur) \
254 u32 latest = E1000_READ_REG(hw, reg); \
255 cur += (latest - last) & UINT_MAX; \
259 #define IGB_FC_PAUSE_TIME 0x0680
260 #define IGB_LINK_UPDATE_CHECK_TIMEOUT 90 /* 9s */
261 #define IGB_LINK_UPDATE_CHECK_INTERVAL 100 /* ms */
263 #define IGBVF_PMD_NAME "rte_igbvf_pmd" /* PMD name */
265 static enum e1000_fc_mode igb_fc_setting = e1000_fc_full;
268 * The set of PCI devices this driver supports
270 static const struct rte_pci_id pci_id_igb_map[] = {
272 #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
273 #include "rte_pci_dev_ids.h"
279 * The set of PCI devices this driver supports (for 82576&I350 VF)
281 static const struct rte_pci_id pci_id_igbvf_map[] = {
283 #define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
284 #include "rte_pci_dev_ids.h"
289 static const struct rte_eth_desc_lim rx_desc_lim = {
290 .nb_max = E1000_MAX_RING_DESC,
291 .nb_min = E1000_MIN_RING_DESC,
292 .nb_align = IGB_RXD_ALIGN,
295 static const struct rte_eth_desc_lim tx_desc_lim = {
296 .nb_max = E1000_MAX_RING_DESC,
297 .nb_min = E1000_MIN_RING_DESC,
298 .nb_align = IGB_RXD_ALIGN,
301 static const struct eth_dev_ops eth_igb_ops = {
302 .dev_configure = eth_igb_configure,
303 .dev_start = eth_igb_start,
304 .dev_stop = eth_igb_stop,
305 .dev_close = eth_igb_close,
306 .promiscuous_enable = eth_igb_promiscuous_enable,
307 .promiscuous_disable = eth_igb_promiscuous_disable,
308 .allmulticast_enable = eth_igb_allmulticast_enable,
309 .allmulticast_disable = eth_igb_allmulticast_disable,
310 .link_update = eth_igb_link_update,
311 .stats_get = eth_igb_stats_get,
312 .xstats_get = eth_igb_xstats_get,
313 .stats_reset = eth_igb_stats_reset,
314 .xstats_reset = eth_igb_xstats_reset,
315 .dev_infos_get = eth_igb_infos_get,
316 .mtu_set = eth_igb_mtu_set,
317 .vlan_filter_set = eth_igb_vlan_filter_set,
318 .vlan_tpid_set = eth_igb_vlan_tpid_set,
319 .vlan_offload_set = eth_igb_vlan_offload_set,
320 .rx_queue_setup = eth_igb_rx_queue_setup,
321 .rx_queue_intr_enable = eth_igb_rx_queue_intr_enable,
322 .rx_queue_intr_disable = eth_igb_rx_queue_intr_disable,
323 .rx_queue_release = eth_igb_rx_queue_release,
324 .rx_queue_count = eth_igb_rx_queue_count,
325 .rx_descriptor_done = eth_igb_rx_descriptor_done,
326 .tx_queue_setup = eth_igb_tx_queue_setup,
327 .tx_queue_release = eth_igb_tx_queue_release,
328 .dev_led_on = eth_igb_led_on,
329 .dev_led_off = eth_igb_led_off,
330 .flow_ctrl_get = eth_igb_flow_ctrl_get,
331 .flow_ctrl_set = eth_igb_flow_ctrl_set,
332 .mac_addr_add = eth_igb_rar_set,
333 .mac_addr_remove = eth_igb_rar_clear,
334 .mac_addr_set = eth_igb_default_mac_addr_set,
335 .reta_update = eth_igb_rss_reta_update,
336 .reta_query = eth_igb_rss_reta_query,
337 .rss_hash_update = eth_igb_rss_hash_update,
338 .rss_hash_conf_get = eth_igb_rss_hash_conf_get,
339 .filter_ctrl = eth_igb_filter_ctrl,
340 .set_mc_addr_list = eth_igb_set_mc_addr_list,
341 .rxq_info_get = igb_rxq_info_get,
342 .txq_info_get = igb_txq_info_get,
343 .timesync_enable = igb_timesync_enable,
344 .timesync_disable = igb_timesync_disable,
345 .timesync_read_rx_timestamp = igb_timesync_read_rx_timestamp,
346 .timesync_read_tx_timestamp = igb_timesync_read_tx_timestamp,
347 .get_reg_length = eth_igb_get_reg_length,
348 .get_reg = eth_igb_get_regs,
349 .get_eeprom_length = eth_igb_get_eeprom_length,
350 .get_eeprom = eth_igb_get_eeprom,
351 .set_eeprom = eth_igb_set_eeprom,
355 * dev_ops for virtual function, bare necessities for basic vf
356 * operation have been implemented
358 static const struct eth_dev_ops igbvf_eth_dev_ops = {
359 .dev_configure = igbvf_dev_configure,
360 .dev_start = igbvf_dev_start,
361 .dev_stop = igbvf_dev_stop,
362 .dev_close = igbvf_dev_close,
363 .link_update = eth_igb_link_update,
364 .stats_get = eth_igbvf_stats_get,
365 .xstats_get = eth_igbvf_xstats_get,
366 .stats_reset = eth_igbvf_stats_reset,
367 .xstats_reset = eth_igbvf_stats_reset,
368 .vlan_filter_set = igbvf_vlan_filter_set,
369 .dev_infos_get = eth_igbvf_infos_get,
370 .rx_queue_setup = eth_igb_rx_queue_setup,
371 .rx_queue_release = eth_igb_rx_queue_release,
372 .tx_queue_setup = eth_igb_tx_queue_setup,
373 .tx_queue_release = eth_igb_tx_queue_release,
374 .set_mc_addr_list = eth_igb_set_mc_addr_list,
375 .rxq_info_get = igb_rxq_info_get,
376 .txq_info_get = igb_txq_info_get,
377 .mac_addr_set = igbvf_default_mac_addr_set,
378 .get_reg_length = igbvf_get_reg_length,
379 .get_reg = igbvf_get_regs,
382 /* store statistics names and its offset in stats structure */
383 struct rte_igb_xstats_name_off {
384 char name[RTE_ETH_XSTATS_NAME_SIZE];
388 static const struct rte_igb_xstats_name_off rte_igb_stats_strings[] = {
389 {"rx_crc_errors", offsetof(struct e1000_hw_stats, crcerrs)},
390 {"rx_align_errors", offsetof(struct e1000_hw_stats, algnerrc)},
391 {"rx_symbol_errors", offsetof(struct e1000_hw_stats, symerrs)},
392 {"rx_missed_packets", offsetof(struct e1000_hw_stats, mpc)},
393 {"tx_single_collision_packets", offsetof(struct e1000_hw_stats, scc)},
394 {"tx_multiple_collision_packets", offsetof(struct e1000_hw_stats, mcc)},
395 {"tx_excessive_collision_packets", offsetof(struct e1000_hw_stats,
397 {"tx_late_collisions", offsetof(struct e1000_hw_stats, latecol)},
398 {"tx_total_collisions", offsetof(struct e1000_hw_stats, colc)},
399 {"tx_deferred_packets", offsetof(struct e1000_hw_stats, dc)},
400 {"tx_no_carrier_sense_packets", offsetof(struct e1000_hw_stats, tncrs)},
401 {"rx_carrier_ext_errors", offsetof(struct e1000_hw_stats, cexterr)},
402 {"rx_length_errors", offsetof(struct e1000_hw_stats, rlec)},
403 {"rx_xon_packets", offsetof(struct e1000_hw_stats, xonrxc)},
404 {"tx_xon_packets", offsetof(struct e1000_hw_stats, xontxc)},
405 {"rx_xoff_packets", offsetof(struct e1000_hw_stats, xoffrxc)},
406 {"tx_xoff_packets", offsetof(struct e1000_hw_stats, xofftxc)},
407 {"rx_flow_control_unsupported_packets", offsetof(struct e1000_hw_stats,
409 {"rx_size_64_packets", offsetof(struct e1000_hw_stats, prc64)},
410 {"rx_size_65_to_127_packets", offsetof(struct e1000_hw_stats, prc127)},
411 {"rx_size_128_to_255_packets", offsetof(struct e1000_hw_stats, prc255)},
412 {"rx_size_256_to_511_packets", offsetof(struct e1000_hw_stats, prc511)},
413 {"rx_size_512_to_1023_packets", offsetof(struct e1000_hw_stats,
415 {"rx_size_1024_to_max_packets", offsetof(struct e1000_hw_stats,
417 {"rx_broadcast_packets", offsetof(struct e1000_hw_stats, bprc)},
418 {"rx_multicast_packets", offsetof(struct e1000_hw_stats, mprc)},
419 {"rx_undersize_errors", offsetof(struct e1000_hw_stats, ruc)},
420 {"rx_fragment_errors", offsetof(struct e1000_hw_stats, rfc)},
421 {"rx_oversize_errors", offsetof(struct e1000_hw_stats, roc)},
422 {"rx_jabber_errors", offsetof(struct e1000_hw_stats, rjc)},
423 {"rx_management_packets", offsetof(struct e1000_hw_stats, mgprc)},
424 {"rx_management_dropped", offsetof(struct e1000_hw_stats, mgpdc)},
425 {"tx_management_packets", offsetof(struct e1000_hw_stats, mgptc)},
426 {"rx_total_packets", offsetof(struct e1000_hw_stats, tpr)},
427 {"tx_total_packets", offsetof(struct e1000_hw_stats, tpt)},
428 {"rx_total_bytes", offsetof(struct e1000_hw_stats, tor)},
429 {"tx_total_bytes", offsetof(struct e1000_hw_stats, tot)},
430 {"tx_size_64_packets", offsetof(struct e1000_hw_stats, ptc64)},
431 {"tx_size_65_to_127_packets", offsetof(struct e1000_hw_stats, ptc127)},
432 {"tx_size_128_to_255_packets", offsetof(struct e1000_hw_stats, ptc255)},
433 {"tx_size_256_to_511_packets", offsetof(struct e1000_hw_stats, ptc511)},
434 {"tx_size_512_to_1023_packets", offsetof(struct e1000_hw_stats,
436 {"tx_size_1023_to_max_packets", offsetof(struct e1000_hw_stats,
438 {"tx_multicast_packets", offsetof(struct e1000_hw_stats, mptc)},
439 {"tx_broadcast_packets", offsetof(struct e1000_hw_stats, bptc)},
440 {"tx_tso_packets", offsetof(struct e1000_hw_stats, tsctc)},
441 {"tx_tso_errors", offsetof(struct e1000_hw_stats, tsctfc)},
442 {"rx_sent_to_host_packets", offsetof(struct e1000_hw_stats, rpthc)},
443 {"tx_sent_by_host_packets", offsetof(struct e1000_hw_stats, hgptc)},
444 {"rx_code_violation_packets", offsetof(struct e1000_hw_stats, scvpc)},
446 {"interrupt_assert_count", offsetof(struct e1000_hw_stats, iac)},
449 #define IGB_NB_XSTATS (sizeof(rte_igb_stats_strings) / \
450 sizeof(rte_igb_stats_strings[0]))
452 static const struct rte_igb_xstats_name_off rte_igbvf_stats_strings[] = {
453 {"rx_multicast_packets", offsetof(struct e1000_vf_stats, mprc)},
454 {"rx_good_loopback_packets", offsetof(struct e1000_vf_stats, gprlbc)},
455 {"tx_good_loopback_packets", offsetof(struct e1000_vf_stats, gptlbc)},
456 {"rx_good_loopback_bytes", offsetof(struct e1000_vf_stats, gorlbc)},
457 {"tx_good_loopback_bytes", offsetof(struct e1000_vf_stats, gotlbc)},
460 #define IGBVF_NB_XSTATS (sizeof(rte_igbvf_stats_strings) / \
461 sizeof(rte_igbvf_stats_strings[0]))
464 * Atomically reads the link status information from global
465 * structure rte_eth_dev.
468 * - Pointer to the structure rte_eth_dev to read from.
469 * - Pointer to the buffer to be saved with the link status.
472 * - On success, zero.
473 * - On failure, negative value.
476 rte_igb_dev_atomic_read_link_status(struct rte_eth_dev *dev,
477 struct rte_eth_link *link)
479 struct rte_eth_link *dst = link;
480 struct rte_eth_link *src = &(dev->data->dev_link);
482 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
483 *(uint64_t *)src) == 0)
490 * Atomically writes the link status information into global
491 * structure rte_eth_dev.
494 * - Pointer to the structure rte_eth_dev to read from.
495 * - Pointer to the buffer to be saved with the link status.
498 * - On success, zero.
499 * - On failure, negative value.
502 rte_igb_dev_atomic_write_link_status(struct rte_eth_dev *dev,
503 struct rte_eth_link *link)
505 struct rte_eth_link *dst = &(dev->data->dev_link);
506 struct rte_eth_link *src = link;
508 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
509 *(uint64_t *)src) == 0)
516 igb_intr_enable(struct rte_eth_dev *dev)
518 struct e1000_interrupt *intr =
519 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
520 struct e1000_hw *hw =
521 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
523 E1000_WRITE_REG(hw, E1000_IMS, intr->mask);
524 E1000_WRITE_FLUSH(hw);
528 igb_intr_disable(struct e1000_hw *hw)
530 E1000_WRITE_REG(hw, E1000_IMC, ~0);
531 E1000_WRITE_FLUSH(hw);
534 static inline int32_t
535 igb_pf_reset_hw(struct e1000_hw *hw)
540 status = e1000_reset_hw(hw);
542 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
543 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
544 ctrl_ext |= E1000_CTRL_EXT_PFRSTD;
545 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
546 E1000_WRITE_FLUSH(hw);
552 igb_identify_hardware(struct rte_eth_dev *dev)
554 struct e1000_hw *hw =
555 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
557 hw->vendor_id = dev->pci_dev->id.vendor_id;
558 hw->device_id = dev->pci_dev->id.device_id;
559 hw->subsystem_vendor_id = dev->pci_dev->id.subsystem_vendor_id;
560 hw->subsystem_device_id = dev->pci_dev->id.subsystem_device_id;
562 e1000_set_mac_type(hw);
564 /* need to check if it is a vf device below */
568 igb_reset_swfw_lock(struct e1000_hw *hw)
573 * Do mac ops initialization manually here, since we will need
574 * some function pointers set by this call.
576 ret_val = e1000_init_mac_params(hw);
581 * SMBI lock should not fail in this early stage. If this is the case,
582 * it is due to an improper exit of the application.
583 * So force the release of the faulty lock.
585 if (e1000_get_hw_semaphore_generic(hw) < 0) {
586 PMD_DRV_LOG(DEBUG, "SMBI lock released");
588 e1000_put_hw_semaphore_generic(hw);
590 if (hw->mac.ops.acquire_swfw_sync != NULL) {
594 * Phy lock should not fail in this early stage. If this is the case,
595 * it is due to an improper exit of the application.
596 * So force the release of the faulty lock.
598 mask = E1000_SWFW_PHY0_SM << hw->bus.func;
599 if (hw->bus.func > E1000_FUNC_1)
601 if (hw->mac.ops.acquire_swfw_sync(hw, mask) < 0) {
602 PMD_DRV_LOG(DEBUG, "SWFW phy%d lock released",
605 hw->mac.ops.release_swfw_sync(hw, mask);
608 * This one is more tricky since it is common to all ports; but
609 * swfw_sync retries last long enough (1s) to be almost sure that if
610 * lock can not be taken it is due to an improper lock of the
613 mask = E1000_SWFW_EEP_SM;
614 if (hw->mac.ops.acquire_swfw_sync(hw, mask) < 0) {
615 PMD_DRV_LOG(DEBUG, "SWFW common locks released");
617 hw->mac.ops.release_swfw_sync(hw, mask);
620 return E1000_SUCCESS;
624 eth_igb_dev_init(struct rte_eth_dev *eth_dev)
627 struct rte_pci_device *pci_dev;
628 struct e1000_hw *hw =
629 E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
630 struct e1000_vfta * shadow_vfta =
631 E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
632 struct e1000_filter_info *filter_info =
633 E1000_DEV_PRIVATE_TO_FILTER_INFO(eth_dev->data->dev_private);
634 struct e1000_adapter *adapter =
635 E1000_DEV_PRIVATE(eth_dev->data->dev_private);
639 pci_dev = eth_dev->pci_dev;
641 rte_eth_copy_pci_info(eth_dev, pci_dev);
643 eth_dev->dev_ops = ð_igb_ops;
644 eth_dev->rx_pkt_burst = ð_igb_recv_pkts;
645 eth_dev->tx_pkt_burst = ð_igb_xmit_pkts;
647 /* for secondary processes, we don't initialise any further as primary
648 * has already done this work. Only check we don't need a different
650 if (rte_eal_process_type() != RTE_PROC_PRIMARY){
651 if (eth_dev->data->scattered_rx)
652 eth_dev->rx_pkt_burst = ð_igb_recv_scattered_pkts;
656 hw->hw_addr= (void *)pci_dev->mem_resource[0].addr;
658 igb_identify_hardware(eth_dev);
659 if (e1000_setup_init_funcs(hw, FALSE) != E1000_SUCCESS) {
664 e1000_get_bus_info(hw);
666 /* Reset any pending lock */
667 if (igb_reset_swfw_lock(hw) != E1000_SUCCESS) {
672 /* Finish initialization */
673 if (e1000_setup_init_funcs(hw, TRUE) != E1000_SUCCESS) {
679 hw->phy.autoneg_wait_to_complete = 0;
680 hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
683 if (hw->phy.media_type == e1000_media_type_copper) {
684 hw->phy.mdix = 0; /* AUTO_ALL_MODES */
685 hw->phy.disable_polarity_correction = 0;
686 hw->phy.ms_type = e1000_ms_hw_default;
690 * Start from a known state, this is important in reading the nvm
695 /* Make sure we have a good EEPROM before we read from it */
696 if (e1000_validate_nvm_checksum(hw) < 0) {
698 * Some PCI-E parts fail the first check due to
699 * the link being in sleep state, call it again,
700 * if it fails a second time its a real issue.
702 if (e1000_validate_nvm_checksum(hw) < 0) {
703 PMD_INIT_LOG(ERR, "EEPROM checksum invalid");
709 /* Read the permanent MAC address out of the EEPROM */
710 if (e1000_read_mac_addr(hw) != 0) {
711 PMD_INIT_LOG(ERR, "EEPROM error while reading MAC address");
716 /* Allocate memory for storing MAC addresses */
717 eth_dev->data->mac_addrs = rte_zmalloc("e1000",
718 ETHER_ADDR_LEN * hw->mac.rar_entry_count, 0);
719 if (eth_dev->data->mac_addrs == NULL) {
720 PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
721 "store MAC addresses",
722 ETHER_ADDR_LEN * hw->mac.rar_entry_count);
727 /* Copy the permanent MAC address */
728 ether_addr_copy((struct ether_addr *)hw->mac.addr, ð_dev->data->mac_addrs[0]);
730 /* initialize the vfta */
731 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
733 /* Now initialize the hardware */
734 if (igb_hardware_init(hw) != 0) {
735 PMD_INIT_LOG(ERR, "Hardware initialization failed");
736 rte_free(eth_dev->data->mac_addrs);
737 eth_dev->data->mac_addrs = NULL;
741 hw->mac.get_link_status = 1;
742 adapter->stopped = 0;
744 /* Indicate SOL/IDER usage */
745 if (e1000_check_reset_block(hw) < 0) {
746 PMD_INIT_LOG(ERR, "PHY reset is blocked due to"
750 /* initialize PF if max_vfs not zero */
751 igb_pf_host_init(eth_dev);
753 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
754 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
755 ctrl_ext |= E1000_CTRL_EXT_PFRSTD;
756 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
757 E1000_WRITE_FLUSH(hw);
759 PMD_INIT_LOG(DEBUG, "port_id %d vendorID=0x%x deviceID=0x%x",
760 eth_dev->data->port_id, pci_dev->id.vendor_id,
761 pci_dev->id.device_id);
763 rte_intr_callback_register(&pci_dev->intr_handle,
764 eth_igb_interrupt_handler,
767 /* enable uio/vfio intr/eventfd mapping */
768 rte_intr_enable(&pci_dev->intr_handle);
770 /* enable support intr */
771 igb_intr_enable(eth_dev);
773 TAILQ_INIT(&filter_info->flex_list);
774 filter_info->flex_mask = 0;
775 TAILQ_INIT(&filter_info->twotuple_list);
776 filter_info->twotuple_mask = 0;
777 TAILQ_INIT(&filter_info->fivetuple_list);
778 filter_info->fivetuple_mask = 0;
783 igb_hw_control_release(hw);
789 eth_igb_dev_uninit(struct rte_eth_dev *eth_dev)
791 struct rte_pci_device *pci_dev;
793 struct e1000_adapter *adapter =
794 E1000_DEV_PRIVATE(eth_dev->data->dev_private);
796 PMD_INIT_FUNC_TRACE();
798 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
801 hw = E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
802 pci_dev = eth_dev->pci_dev;
804 if (adapter->stopped == 0)
805 eth_igb_close(eth_dev);
807 eth_dev->dev_ops = NULL;
808 eth_dev->rx_pkt_burst = NULL;
809 eth_dev->tx_pkt_burst = NULL;
811 /* Reset any pending lock */
812 igb_reset_swfw_lock(hw);
814 rte_free(eth_dev->data->mac_addrs);
815 eth_dev->data->mac_addrs = NULL;
817 /* uninitialize PF if max_vfs not zero */
818 igb_pf_host_uninit(eth_dev);
820 /* disable uio intr before callback unregister */
821 rte_intr_disable(&(pci_dev->intr_handle));
822 rte_intr_callback_unregister(&(pci_dev->intr_handle),
823 eth_igb_interrupt_handler, (void *)eth_dev);
829 * Virtual Function device init
832 eth_igbvf_dev_init(struct rte_eth_dev *eth_dev)
834 struct rte_pci_device *pci_dev;
835 struct e1000_adapter *adapter =
836 E1000_DEV_PRIVATE(eth_dev->data->dev_private);
837 struct e1000_hw *hw =
838 E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
841 PMD_INIT_FUNC_TRACE();
843 eth_dev->dev_ops = &igbvf_eth_dev_ops;
844 eth_dev->rx_pkt_burst = ð_igb_recv_pkts;
845 eth_dev->tx_pkt_burst = ð_igb_xmit_pkts;
847 /* for secondary processes, we don't initialise any further as primary
848 * has already done this work. Only check we don't need a different
850 if (rte_eal_process_type() != RTE_PROC_PRIMARY){
851 if (eth_dev->data->scattered_rx)
852 eth_dev->rx_pkt_burst = ð_igb_recv_scattered_pkts;
856 pci_dev = eth_dev->pci_dev;
858 rte_eth_copy_pci_info(eth_dev, pci_dev);
860 hw->device_id = pci_dev->id.device_id;
861 hw->vendor_id = pci_dev->id.vendor_id;
862 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
863 adapter->stopped = 0;
865 /* Initialize the shared code (base driver) */
866 diag = e1000_setup_init_funcs(hw, TRUE);
868 PMD_INIT_LOG(ERR, "Shared code init failed for igbvf: %d",
873 /* init_mailbox_params */
874 hw->mbx.ops.init_params(hw);
876 /* Disable the interrupts for VF */
877 igbvf_intr_disable(hw);
879 diag = hw->mac.ops.reset_hw(hw);
881 /* Allocate memory for storing MAC addresses */
882 eth_dev->data->mac_addrs = rte_zmalloc("igbvf", ETHER_ADDR_LEN *
883 hw->mac.rar_entry_count, 0);
884 if (eth_dev->data->mac_addrs == NULL) {
886 "Failed to allocate %d bytes needed to store MAC "
888 ETHER_ADDR_LEN * hw->mac.rar_entry_count);
892 /* Copy the permanent MAC address */
893 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
894 ð_dev->data->mac_addrs[0]);
896 PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x "
898 eth_dev->data->port_id, pci_dev->id.vendor_id,
899 pci_dev->id.device_id, "igb_mac_82576_vf");
905 eth_igbvf_dev_uninit(struct rte_eth_dev *eth_dev)
907 struct e1000_adapter *adapter =
908 E1000_DEV_PRIVATE(eth_dev->data->dev_private);
910 PMD_INIT_FUNC_TRACE();
912 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
915 if (adapter->stopped == 0)
916 igbvf_dev_close(eth_dev);
918 eth_dev->dev_ops = NULL;
919 eth_dev->rx_pkt_burst = NULL;
920 eth_dev->tx_pkt_burst = NULL;
922 rte_free(eth_dev->data->mac_addrs);
923 eth_dev->data->mac_addrs = NULL;
928 static struct eth_driver rte_igb_pmd = {
930 .name = "rte_igb_pmd",
931 .id_table = pci_id_igb_map,
932 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_INTR_LSC |
933 RTE_PCI_DRV_DETACHABLE,
935 .eth_dev_init = eth_igb_dev_init,
936 .eth_dev_uninit = eth_igb_dev_uninit,
937 .dev_private_size = sizeof(struct e1000_adapter),
941 * virtual function driver struct
943 static struct eth_driver rte_igbvf_pmd = {
945 .name = "rte_igbvf_pmd",
946 .id_table = pci_id_igbvf_map,
947 .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_DETACHABLE,
949 .eth_dev_init = eth_igbvf_dev_init,
950 .eth_dev_uninit = eth_igbvf_dev_uninit,
951 .dev_private_size = sizeof(struct e1000_adapter),
955 rte_igb_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
957 rte_eth_driver_register(&rte_igb_pmd);
962 igb_vmdq_vlan_hw_filter_enable(struct rte_eth_dev *dev)
964 struct e1000_hw *hw =
965 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
966 /* RCTL: enable VLAN filter since VMDq always use VLAN filter */
967 uint32_t rctl = E1000_READ_REG(hw, E1000_RCTL);
968 rctl |= E1000_RCTL_VFE;
969 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
973 * VF Driver initialization routine.
974 * Invoked one at EAL init time.
975 * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
978 rte_igbvf_pmd_init(const char *name __rte_unused, const char *params __rte_unused)
980 PMD_INIT_FUNC_TRACE();
982 rte_eth_driver_register(&rte_igbvf_pmd);
987 igb_check_mq_mode(struct rte_eth_dev *dev)
989 enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode;
990 enum rte_eth_tx_mq_mode tx_mq_mode = dev->data->dev_conf.txmode.mq_mode;
991 uint16_t nb_rx_q = dev->data->nb_rx_queues;
992 uint16_t nb_tx_q = dev->data->nb_rx_queues;
994 if ((rx_mq_mode & ETH_MQ_RX_DCB_FLAG) ||
995 tx_mq_mode == ETH_MQ_TX_DCB ||
996 tx_mq_mode == ETH_MQ_TX_VMDQ_DCB) {
997 PMD_INIT_LOG(ERR, "DCB mode is not supported.");
1000 if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
1001 /* Check multi-queue mode.
1002 * To no break software we accept ETH_MQ_RX_NONE as this might
1003 * be used to turn off VLAN filter.
1006 if (rx_mq_mode == ETH_MQ_RX_NONE ||
1007 rx_mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
1008 dev->data->dev_conf.rxmode.mq_mode = ETH_MQ_RX_VMDQ_ONLY;
1009 RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
1011 /* Only support one queue on VFs.
1012 * RSS together with SRIOV is not supported.
1014 PMD_INIT_LOG(ERR, "SRIOV is active,"
1015 " wrong mq_mode rx %d.",
1019 /* TX mode is not used here, so mode might be ignored.*/
1020 if (tx_mq_mode != ETH_MQ_TX_VMDQ_ONLY) {
1021 /* SRIOV only works in VMDq enable mode */
1022 PMD_INIT_LOG(WARNING, "SRIOV is active,"
1023 " TX mode %d is not supported. "
1024 " Driver will behave as %d mode.",
1025 tx_mq_mode, ETH_MQ_TX_VMDQ_ONLY);
1028 /* check valid queue number */
1029 if ((nb_rx_q > 1) || (nb_tx_q > 1)) {
1030 PMD_INIT_LOG(ERR, "SRIOV is active,"
1031 " only support one queue on VFs.");
1035 /* To no break software that set invalid mode, only display
1036 * warning if invalid mode is used.
1038 if (rx_mq_mode != ETH_MQ_RX_NONE &&
1039 rx_mq_mode != ETH_MQ_RX_VMDQ_ONLY &&
1040 rx_mq_mode != ETH_MQ_RX_RSS) {
1041 /* RSS together with VMDq not supported*/
1042 PMD_INIT_LOG(ERR, "RX mode %d is not supported.",
1047 if (tx_mq_mode != ETH_MQ_TX_NONE &&
1048 tx_mq_mode != ETH_MQ_TX_VMDQ_ONLY) {
1049 PMD_INIT_LOG(WARNING, "TX mode %d is not supported."
1050 " Due to txmode is meaningless in this"
1051 " driver, just ignore.",
1059 eth_igb_configure(struct rte_eth_dev *dev)
1061 struct e1000_interrupt *intr =
1062 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
1065 PMD_INIT_FUNC_TRACE();
1067 /* multipe queue mode checking */
1068 ret = igb_check_mq_mode(dev);
1070 PMD_DRV_LOG(ERR, "igb_check_mq_mode fails with %d.",
1075 intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
1076 PMD_INIT_FUNC_TRACE();
1082 eth_igb_start(struct rte_eth_dev *dev)
1084 struct e1000_hw *hw =
1085 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1086 struct e1000_adapter *adapter =
1087 E1000_DEV_PRIVATE(dev->data->dev_private);
1088 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
1090 uint32_t intr_vector = 0;
1093 PMD_INIT_FUNC_TRACE();
1095 /* Power up the phy. Needed to make the link go Up */
1096 e1000_power_up_phy(hw);
1099 * Packet Buffer Allocation (PBA)
1100 * Writing PBA sets the receive portion of the buffer
1101 * the remainder is used for the transmit buffer.
1103 if (hw->mac.type == e1000_82575) {
1106 pba = E1000_PBA_32K; /* 32K for Rx, 16K for Tx */
1107 E1000_WRITE_REG(hw, E1000_PBA, pba);
1110 /* Put the address into the Receive Address Array */
1111 e1000_rar_set(hw, hw->mac.addr, 0);
1113 /* Initialize the hardware */
1114 if (igb_hardware_init(hw)) {
1115 PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
1118 adapter->stopped = 0;
1120 E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 | ETHER_TYPE_VLAN);
1122 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
1123 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
1124 ctrl_ext |= E1000_CTRL_EXT_PFRSTD;
1125 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
1126 E1000_WRITE_FLUSH(hw);
1128 /* configure PF module if SRIOV enabled */
1129 igb_pf_host_configure(dev);
1131 /* check and configure queue intr-vector mapping */
1132 if ((rte_intr_cap_multiple(intr_handle) ||
1133 !RTE_ETH_DEV_SRIOV(dev).active) &&
1134 dev->data->dev_conf.intr_conf.rxq != 0) {
1135 intr_vector = dev->data->nb_rx_queues;
1136 if (rte_intr_efd_enable(intr_handle, intr_vector))
1140 if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) {
1141 intr_handle->intr_vec =
1142 rte_zmalloc("intr_vec",
1143 dev->data->nb_rx_queues * sizeof(int), 0);
1144 if (intr_handle->intr_vec == NULL) {
1145 PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
1146 " intr_vec\n", dev->data->nb_rx_queues);
1151 /* confiugre msix for rx interrupt */
1152 eth_igb_configure_msix_intr(dev);
1154 /* Configure for OS presence */
1155 igb_init_manageability(hw);
1157 eth_igb_tx_init(dev);
1159 /* This can fail when allocating mbufs for descriptor rings */
1160 ret = eth_igb_rx_init(dev);
1162 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
1163 igb_dev_clear_queues(dev);
1167 e1000_clear_hw_cntrs_base_generic(hw);
1170 * VLAN Offload Settings
1172 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK | \
1173 ETH_VLAN_EXTEND_MASK;
1174 eth_igb_vlan_offload_set(dev, mask);
1176 if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
1177 /* Enable VLAN filter since VMDq always use VLAN filter */
1178 igb_vmdq_vlan_hw_filter_enable(dev);
1181 if ((hw->mac.type == e1000_82576) || (hw->mac.type == e1000_82580) ||
1182 (hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i210) ||
1183 (hw->mac.type == e1000_i211)) {
1184 /* Configure EITR with the maximum possible value (0xFFFF) */
1185 E1000_WRITE_REG(hw, E1000_EITR(0), 0xFFFF);
1188 /* Setup link speed and duplex */
1189 switch (dev->data->dev_conf.link_speed) {
1190 case ETH_LINK_SPEED_AUTONEG:
1191 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
1192 hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
1193 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
1194 hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
1195 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
1196 hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
1198 goto error_invalid_config;
1200 case ETH_LINK_SPEED_10:
1201 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
1202 hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
1203 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
1204 hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
1205 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
1206 hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
1208 goto error_invalid_config;
1210 case ETH_LINK_SPEED_100:
1211 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
1212 hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
1213 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
1214 hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
1215 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
1216 hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
1218 goto error_invalid_config;
1220 case ETH_LINK_SPEED_1000:
1221 if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) ||
1222 (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX))
1223 hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
1225 goto error_invalid_config;
1227 case ETH_LINK_SPEED_10000:
1229 goto error_invalid_config;
1231 e1000_setup_link(hw);
1233 if (rte_intr_allow_others(intr_handle)) {
1234 /* check if lsc interrupt is enabled */
1235 if (dev->data->dev_conf.intr_conf.lsc != 0)
1236 eth_igb_lsc_interrupt_setup(dev);
1238 rte_intr_callback_unregister(intr_handle,
1239 eth_igb_interrupt_handler,
1241 if (dev->data->dev_conf.intr_conf.lsc != 0)
1242 PMD_INIT_LOG(INFO, "lsc won't enable because of"
1243 " no intr multiplex\n");
1246 /* check if rxq interrupt is enabled */
1247 if (dev->data->dev_conf.intr_conf.rxq != 0 &&
1248 rte_intr_dp_is_en(intr_handle))
1249 eth_igb_rxq_interrupt_setup(dev);
1251 /* enable uio/vfio intr/eventfd mapping */
1252 rte_intr_enable(intr_handle);
1254 /* resume enabled intr since hw reset */
1255 igb_intr_enable(dev);
1257 PMD_INIT_LOG(DEBUG, "<<");
1261 error_invalid_config:
1262 PMD_INIT_LOG(ERR, "Invalid link_speed/link_duplex (%u/%u) for port %u",
1263 dev->data->dev_conf.link_speed,
1264 dev->data->dev_conf.link_duplex, dev->data->port_id);
1265 igb_dev_clear_queues(dev);
1269 /*********************************************************************
1271 * This routine disables all traffic on the adapter by issuing a
1272 * global reset on the MAC.
1274 **********************************************************************/
1276 eth_igb_stop(struct rte_eth_dev *dev)
1278 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1279 struct e1000_filter_info *filter_info =
1280 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
1281 struct rte_eth_link link;
1282 struct e1000_flex_filter *p_flex;
1283 struct e1000_5tuple_filter *p_5tuple, *p_5tuple_next;
1284 struct e1000_2tuple_filter *p_2tuple, *p_2tuple_next;
1285 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
1287 igb_intr_disable(hw);
1289 /* disable intr eventfd mapping */
1290 rte_intr_disable(intr_handle);
1292 igb_pf_reset_hw(hw);
1293 E1000_WRITE_REG(hw, E1000_WUC, 0);
1295 /* Set bit for Go Link disconnect */
1296 if (hw->mac.type >= e1000_82580) {
1299 phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
1300 phpm_reg |= E1000_82580_PM_GO_LINKD;
1301 E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
1304 /* Power down the phy. Needed to make the link go Down */
1305 if (hw->phy.media_type == e1000_media_type_copper)
1306 e1000_power_down_phy(hw);
1308 e1000_shutdown_fiber_serdes_link(hw);
1310 igb_dev_clear_queues(dev);
1312 /* clear the recorded link status */
1313 memset(&link, 0, sizeof(link));
1314 rte_igb_dev_atomic_write_link_status(dev, &link);
1316 /* Remove all flex filters of the device */
1317 while ((p_flex = TAILQ_FIRST(&filter_info->flex_list))) {
1318 TAILQ_REMOVE(&filter_info->flex_list, p_flex, entries);
1321 filter_info->flex_mask = 0;
1323 /* Remove all ntuple filters of the device */
1324 for (p_5tuple = TAILQ_FIRST(&filter_info->fivetuple_list);
1325 p_5tuple != NULL; p_5tuple = p_5tuple_next) {
1326 p_5tuple_next = TAILQ_NEXT(p_5tuple, entries);
1327 TAILQ_REMOVE(&filter_info->fivetuple_list,
1331 filter_info->fivetuple_mask = 0;
1332 for (p_2tuple = TAILQ_FIRST(&filter_info->twotuple_list);
1333 p_2tuple != NULL; p_2tuple = p_2tuple_next) {
1334 p_2tuple_next = TAILQ_NEXT(p_2tuple, entries);
1335 TAILQ_REMOVE(&filter_info->twotuple_list,
1339 filter_info->twotuple_mask = 0;
1341 if (!rte_intr_allow_others(intr_handle))
1342 /* resume to the default handler */
1343 rte_intr_callback_register(intr_handle,
1344 eth_igb_interrupt_handler,
1347 /* Clean datapath event and queue/vec mapping */
1348 rte_intr_efd_disable(intr_handle);
1349 if (intr_handle->intr_vec != NULL) {
1350 rte_free(intr_handle->intr_vec);
1351 intr_handle->intr_vec = NULL;
1356 eth_igb_close(struct rte_eth_dev *dev)
1358 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1359 struct e1000_adapter *adapter =
1360 E1000_DEV_PRIVATE(dev->data->dev_private);
1361 struct rte_eth_link link;
1362 struct rte_pci_device *pci_dev;
1365 adapter->stopped = 1;
1367 e1000_phy_hw_reset(hw);
1368 igb_release_manageability(hw);
1369 igb_hw_control_release(hw);
1371 /* Clear bit for Go Link disconnect */
1372 if (hw->mac.type >= e1000_82580) {
1375 phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
1376 phpm_reg &= ~E1000_82580_PM_GO_LINKD;
1377 E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
1380 igb_dev_free_queues(dev);
1382 pci_dev = dev->pci_dev;
1383 if (pci_dev->intr_handle.intr_vec) {
1384 rte_free(pci_dev->intr_handle.intr_vec);
1385 pci_dev->intr_handle.intr_vec = NULL;
1388 memset(&link, 0, sizeof(link));
1389 rte_igb_dev_atomic_write_link_status(dev, &link);
1393 igb_get_rx_buffer_size(struct e1000_hw *hw)
1395 uint32_t rx_buf_size;
1396 if (hw->mac.type == e1000_82576) {
1397 rx_buf_size = (E1000_READ_REG(hw, E1000_RXPBS) & 0xffff) << 10;
1398 } else if (hw->mac.type == e1000_82580 || hw->mac.type == e1000_i350) {
1399 /* PBS needs to be translated according to a lookup table */
1400 rx_buf_size = (E1000_READ_REG(hw, E1000_RXPBS) & 0xf);
1401 rx_buf_size = (uint32_t) e1000_rxpbs_adjust_82580(rx_buf_size);
1402 rx_buf_size = (rx_buf_size << 10);
1403 } else if (hw->mac.type == e1000_i210 || hw->mac.type == e1000_i211) {
1404 rx_buf_size = (E1000_READ_REG(hw, E1000_RXPBS) & 0x3f) << 10;
1406 rx_buf_size = (E1000_READ_REG(hw, E1000_PBA) & 0xffff) << 10;
1412 /*********************************************************************
1414 * Initialize the hardware
1416 **********************************************************************/
1418 igb_hardware_init(struct e1000_hw *hw)
1420 uint32_t rx_buf_size;
1423 /* Let the firmware know the OS is in control */
1424 igb_hw_control_acquire(hw);
1427 * These parameters control the automatic generation (Tx) and
1428 * response (Rx) to Ethernet PAUSE frames.
1429 * - High water mark should allow for at least two standard size (1518)
1430 * frames to be received after sending an XOFF.
1431 * - Low water mark works best when it is very near the high water mark.
1432 * This allows the receiver to restart by sending XON when it has
1433 * drained a bit. Here we use an arbitrary value of 1500 which will
1434 * restart after one full frame is pulled from the buffer. There
1435 * could be several smaller frames in the buffer and if so they will
1436 * not trigger the XON until their total number reduces the buffer
1438 * - The pause time is fairly large at 1000 x 512ns = 512 usec.
1440 rx_buf_size = igb_get_rx_buffer_size(hw);
1442 hw->fc.high_water = rx_buf_size - (ETHER_MAX_LEN * 2);
1443 hw->fc.low_water = hw->fc.high_water - 1500;
1444 hw->fc.pause_time = IGB_FC_PAUSE_TIME;
1445 hw->fc.send_xon = 1;
1447 /* Set Flow control, use the tunable location if sane */
1448 if ((igb_fc_setting != e1000_fc_none) && (igb_fc_setting < 4))
1449 hw->fc.requested_mode = igb_fc_setting;
1451 hw->fc.requested_mode = e1000_fc_none;
1453 /* Issue a global reset */
1454 igb_pf_reset_hw(hw);
1455 E1000_WRITE_REG(hw, E1000_WUC, 0);
1457 diag = e1000_init_hw(hw);
1461 E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN << 16 | ETHER_TYPE_VLAN);
1462 e1000_get_phy_info(hw);
1463 e1000_check_for_link(hw);
1468 /* This function is based on igb_update_stats_counters() in igb/if_igb.c */
1470 igb_read_stats_registers(struct e1000_hw *hw, struct e1000_hw_stats *stats)
1474 if(hw->phy.media_type == e1000_media_type_copper ||
1475 (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
1477 E1000_READ_REG(hw,E1000_SYMERRS);
1478 stats->sec += E1000_READ_REG(hw, E1000_SEC);
1481 stats->crcerrs += E1000_READ_REG(hw, E1000_CRCERRS);
1482 stats->mpc += E1000_READ_REG(hw, E1000_MPC);
1483 stats->scc += E1000_READ_REG(hw, E1000_SCC);
1484 stats->ecol += E1000_READ_REG(hw, E1000_ECOL);
1486 stats->mcc += E1000_READ_REG(hw, E1000_MCC);
1487 stats->latecol += E1000_READ_REG(hw, E1000_LATECOL);
1488 stats->colc += E1000_READ_REG(hw, E1000_COLC);
1489 stats->dc += E1000_READ_REG(hw, E1000_DC);
1490 stats->rlec += E1000_READ_REG(hw, E1000_RLEC);
1491 stats->xonrxc += E1000_READ_REG(hw, E1000_XONRXC);
1492 stats->xontxc += E1000_READ_REG(hw, E1000_XONTXC);
1494 ** For watchdog management we need to know if we have been
1495 ** paused during the last interval, so capture that here.
1497 pause_frames = E1000_READ_REG(hw, E1000_XOFFRXC);
1498 stats->xoffrxc += pause_frames;
1499 stats->xofftxc += E1000_READ_REG(hw, E1000_XOFFTXC);
1500 stats->fcruc += E1000_READ_REG(hw, E1000_FCRUC);
1501 stats->prc64 += E1000_READ_REG(hw, E1000_PRC64);
1502 stats->prc127 += E1000_READ_REG(hw, E1000_PRC127);
1503 stats->prc255 += E1000_READ_REG(hw, E1000_PRC255);
1504 stats->prc511 += E1000_READ_REG(hw, E1000_PRC511);
1505 stats->prc1023 += E1000_READ_REG(hw, E1000_PRC1023);
1506 stats->prc1522 += E1000_READ_REG(hw, E1000_PRC1522);
1507 stats->gprc += E1000_READ_REG(hw, E1000_GPRC);
1508 stats->bprc += E1000_READ_REG(hw, E1000_BPRC);
1509 stats->mprc += E1000_READ_REG(hw, E1000_MPRC);
1510 stats->gptc += E1000_READ_REG(hw, E1000_GPTC);
1512 /* For the 64-bit byte counters the low dword must be read first. */
1513 /* Both registers clear on the read of the high dword */
1515 stats->gorc += E1000_READ_REG(hw, E1000_GORCL);
1516 stats->gorc += ((uint64_t)E1000_READ_REG(hw, E1000_GORCH) << 32);
1517 stats->gotc += E1000_READ_REG(hw, E1000_GOTCL);
1518 stats->gotc += ((uint64_t)E1000_READ_REG(hw, E1000_GOTCH) << 32);
1520 stats->rnbc += E1000_READ_REG(hw, E1000_RNBC);
1521 stats->ruc += E1000_READ_REG(hw, E1000_RUC);
1522 stats->rfc += E1000_READ_REG(hw, E1000_RFC);
1523 stats->roc += E1000_READ_REG(hw, E1000_ROC);
1524 stats->rjc += E1000_READ_REG(hw, E1000_RJC);
1526 stats->tor += E1000_READ_REG(hw, E1000_TORL);
1527 stats->tor += ((uint64_t)E1000_READ_REG(hw, E1000_TORH) << 32);
1528 stats->tot += E1000_READ_REG(hw, E1000_TOTL);
1529 stats->tot += ((uint64_t)E1000_READ_REG(hw, E1000_TOTH) << 32);
1531 stats->tpr += E1000_READ_REG(hw, E1000_TPR);
1532 stats->tpt += E1000_READ_REG(hw, E1000_TPT);
1533 stats->ptc64 += E1000_READ_REG(hw, E1000_PTC64);
1534 stats->ptc127 += E1000_READ_REG(hw, E1000_PTC127);
1535 stats->ptc255 += E1000_READ_REG(hw, E1000_PTC255);
1536 stats->ptc511 += E1000_READ_REG(hw, E1000_PTC511);
1537 stats->ptc1023 += E1000_READ_REG(hw, E1000_PTC1023);
1538 stats->ptc1522 += E1000_READ_REG(hw, E1000_PTC1522);
1539 stats->mptc += E1000_READ_REG(hw, E1000_MPTC);
1540 stats->bptc += E1000_READ_REG(hw, E1000_BPTC);
1542 /* Interrupt Counts */
1544 stats->iac += E1000_READ_REG(hw, E1000_IAC);
1545 stats->icrxptc += E1000_READ_REG(hw, E1000_ICRXPTC);
1546 stats->icrxatc += E1000_READ_REG(hw, E1000_ICRXATC);
1547 stats->ictxptc += E1000_READ_REG(hw, E1000_ICTXPTC);
1548 stats->ictxatc += E1000_READ_REG(hw, E1000_ICTXATC);
1549 stats->ictxqec += E1000_READ_REG(hw, E1000_ICTXQEC);
1550 stats->ictxqmtc += E1000_READ_REG(hw, E1000_ICTXQMTC);
1551 stats->icrxdmtc += E1000_READ_REG(hw, E1000_ICRXDMTC);
1552 stats->icrxoc += E1000_READ_REG(hw, E1000_ICRXOC);
1554 /* Host to Card Statistics */
1556 stats->cbtmpc += E1000_READ_REG(hw, E1000_CBTMPC);
1557 stats->htdpmc += E1000_READ_REG(hw, E1000_HTDPMC);
1558 stats->cbrdpc += E1000_READ_REG(hw, E1000_CBRDPC);
1559 stats->cbrmpc += E1000_READ_REG(hw, E1000_CBRMPC);
1560 stats->rpthc += E1000_READ_REG(hw, E1000_RPTHC);
1561 stats->hgptc += E1000_READ_REG(hw, E1000_HGPTC);
1562 stats->htcbdpc += E1000_READ_REG(hw, E1000_HTCBDPC);
1563 stats->hgorc += E1000_READ_REG(hw, E1000_HGORCL);
1564 stats->hgorc += ((uint64_t)E1000_READ_REG(hw, E1000_HGORCH) << 32);
1565 stats->hgotc += E1000_READ_REG(hw, E1000_HGOTCL);
1566 stats->hgotc += ((uint64_t)E1000_READ_REG(hw, E1000_HGOTCH) << 32);
1567 stats->lenerrs += E1000_READ_REG(hw, E1000_LENERRS);
1568 stats->scvpc += E1000_READ_REG(hw, E1000_SCVPC);
1569 stats->hrmpc += E1000_READ_REG(hw, E1000_HRMPC);
1571 stats->algnerrc += E1000_READ_REG(hw, E1000_ALGNERRC);
1572 stats->rxerrc += E1000_READ_REG(hw, E1000_RXERRC);
1573 stats->tncrs += E1000_READ_REG(hw, E1000_TNCRS);
1574 stats->cexterr += E1000_READ_REG(hw, E1000_CEXTERR);
1575 stats->tsctc += E1000_READ_REG(hw, E1000_TSCTC);
1576 stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC);
1580 eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
1582 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1583 struct e1000_hw_stats *stats =
1584 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1586 igb_read_stats_registers(hw, stats);
1588 if (rte_stats == NULL)
1592 rte_stats->ibadcrc = stats->crcerrs;
1593 rte_stats->ibadlen = stats->rlec + stats->ruc + stats->roc;
1594 rte_stats->imissed = stats->mpc;
1595 rte_stats->ierrors = rte_stats->ibadcrc +
1596 rte_stats->ibadlen +
1597 rte_stats->imissed +
1598 stats->rxerrc + stats->algnerrc + stats->cexterr;
1601 rte_stats->oerrors = stats->ecol + stats->latecol;
1603 /* XON/XOFF pause frames */
1604 rte_stats->tx_pause_xon = stats->xontxc;
1605 rte_stats->rx_pause_xon = stats->xonrxc;
1606 rte_stats->tx_pause_xoff = stats->xofftxc;
1607 rte_stats->rx_pause_xoff = stats->xoffrxc;
1609 rte_stats->ipackets = stats->gprc;
1610 rte_stats->opackets = stats->gptc;
1611 rte_stats->ibytes = stats->gorc;
1612 rte_stats->obytes = stats->gotc;
1616 eth_igb_stats_reset(struct rte_eth_dev *dev)
1618 struct e1000_hw_stats *hw_stats =
1619 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1621 /* HW registers are cleared on read */
1622 eth_igb_stats_get(dev, NULL);
1624 /* Reset software totals */
1625 memset(hw_stats, 0, sizeof(*hw_stats));
1629 eth_igb_xstats_reset(struct rte_eth_dev *dev)
1631 struct e1000_hw_stats *stats =
1632 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1634 /* HW registers are cleared on read */
1635 eth_igb_xstats_get(dev, NULL, IGB_NB_XSTATS);
1637 /* Reset software totals */
1638 memset(stats, 0, sizeof(*stats));
1642 eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
1645 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1646 struct e1000_hw_stats *hw_stats =
1647 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1650 if (n < IGB_NB_XSTATS)
1651 return IGB_NB_XSTATS;
1653 igb_read_stats_registers(hw, hw_stats);
1655 /* If this is a reset xstats is NULL, and we have cleared the
1656 * registers by reading them.
1661 /* Extended stats */
1662 for (i = 0; i < IGB_NB_XSTATS; i++) {
1663 snprintf(xstats[i].name, sizeof(xstats[i].name),
1664 "%s", rte_igb_stats_strings[i].name);
1665 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
1666 rte_igb_stats_strings[i].offset);
1669 return IGB_NB_XSTATS;
1673 igbvf_read_stats_registers(struct e1000_hw *hw, struct e1000_vf_stats *hw_stats)
1675 /* Good Rx packets, include VF loopback */
1676 UPDATE_VF_STAT(E1000_VFGPRC,
1677 hw_stats->last_gprc, hw_stats->gprc);
1679 /* Good Rx octets, include VF loopback */
1680 UPDATE_VF_STAT(E1000_VFGORC,
1681 hw_stats->last_gorc, hw_stats->gorc);
1683 /* Good Tx packets, include VF loopback */
1684 UPDATE_VF_STAT(E1000_VFGPTC,
1685 hw_stats->last_gptc, hw_stats->gptc);
1687 /* Good Tx octets, include VF loopback */
1688 UPDATE_VF_STAT(E1000_VFGOTC,
1689 hw_stats->last_gotc, hw_stats->gotc);
1691 /* Rx Multicst packets */
1692 UPDATE_VF_STAT(E1000_VFMPRC,
1693 hw_stats->last_mprc, hw_stats->mprc);
1695 /* Good Rx loopback packets */
1696 UPDATE_VF_STAT(E1000_VFGPRLBC,
1697 hw_stats->last_gprlbc, hw_stats->gprlbc);
1699 /* Good Rx loopback octets */
1700 UPDATE_VF_STAT(E1000_VFGORLBC,
1701 hw_stats->last_gorlbc, hw_stats->gorlbc);
1703 /* Good Tx loopback packets */
1704 UPDATE_VF_STAT(E1000_VFGPTLBC,
1705 hw_stats->last_gptlbc, hw_stats->gptlbc);
1707 /* Good Tx loopback octets */
1708 UPDATE_VF_STAT(E1000_VFGOTLBC,
1709 hw_stats->last_gotlbc, hw_stats->gotlbc);
1713 eth_igbvf_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
1716 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1717 struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats *)
1718 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1721 if (n < IGBVF_NB_XSTATS)
1722 return IGBVF_NB_XSTATS;
1724 igbvf_read_stats_registers(hw, hw_stats);
1729 for (i = 0; i < IGBVF_NB_XSTATS; i++) {
1730 snprintf(xstats[i].name, sizeof(xstats[i].name), "%s",
1731 rte_igbvf_stats_strings[i].name);
1732 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
1733 rte_igbvf_stats_strings[i].offset);
1736 return IGBVF_NB_XSTATS;
1740 eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
1742 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1743 struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats *)
1744 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1746 igbvf_read_stats_registers(hw, hw_stats);
1748 if (rte_stats == NULL)
1751 rte_stats->ipackets = hw_stats->gprc;
1752 rte_stats->ibytes = hw_stats->gorc;
1753 rte_stats->opackets = hw_stats->gptc;
1754 rte_stats->obytes = hw_stats->gotc;
1755 rte_stats->imcasts = hw_stats->mprc;
1756 rte_stats->ilbpackets = hw_stats->gprlbc;
1757 rte_stats->ilbbytes = hw_stats->gorlbc;
1758 rte_stats->olbpackets = hw_stats->gptlbc;
1759 rte_stats->olbbytes = hw_stats->gotlbc;
1763 eth_igbvf_stats_reset(struct rte_eth_dev *dev)
1765 struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats*)
1766 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1768 /* Sync HW register to the last stats */
1769 eth_igbvf_stats_get(dev, NULL);
1771 /* reset HW current stats*/
1772 memset(&hw_stats->gprc, 0, sizeof(*hw_stats) -
1773 offsetof(struct e1000_vf_stats, gprc));
1777 eth_igb_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
1779 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1781 dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
1782 dev_info->max_rx_pktlen = 0x3FFF; /* See RLPML register. */
1783 dev_info->max_mac_addrs = hw->mac.rar_entry_count;
1784 dev_info->rx_offload_capa =
1785 DEV_RX_OFFLOAD_VLAN_STRIP |
1786 DEV_RX_OFFLOAD_IPV4_CKSUM |
1787 DEV_RX_OFFLOAD_UDP_CKSUM |
1788 DEV_RX_OFFLOAD_TCP_CKSUM;
1789 dev_info->tx_offload_capa =
1790 DEV_TX_OFFLOAD_VLAN_INSERT |
1791 DEV_TX_OFFLOAD_IPV4_CKSUM |
1792 DEV_TX_OFFLOAD_UDP_CKSUM |
1793 DEV_TX_OFFLOAD_TCP_CKSUM |
1794 DEV_TX_OFFLOAD_SCTP_CKSUM |
1795 DEV_TX_OFFLOAD_TCP_TSO;
1797 switch (hw->mac.type) {
1799 dev_info->max_rx_queues = 4;
1800 dev_info->max_tx_queues = 4;
1801 dev_info->max_vmdq_pools = 0;
1805 dev_info->max_rx_queues = 16;
1806 dev_info->max_tx_queues = 16;
1807 dev_info->max_vmdq_pools = ETH_8_POOLS;
1808 dev_info->vmdq_queue_num = 16;
1812 dev_info->max_rx_queues = 8;
1813 dev_info->max_tx_queues = 8;
1814 dev_info->max_vmdq_pools = ETH_8_POOLS;
1815 dev_info->vmdq_queue_num = 8;
1819 dev_info->max_rx_queues = 8;
1820 dev_info->max_tx_queues = 8;
1821 dev_info->max_vmdq_pools = ETH_8_POOLS;
1822 dev_info->vmdq_queue_num = 8;
1826 dev_info->max_rx_queues = 8;
1827 dev_info->max_tx_queues = 8;
1831 dev_info->max_rx_queues = 4;
1832 dev_info->max_tx_queues = 4;
1833 dev_info->max_vmdq_pools = 0;
1837 dev_info->max_rx_queues = 2;
1838 dev_info->max_tx_queues = 2;
1839 dev_info->max_vmdq_pools = 0;
1843 /* Should not happen */
1846 dev_info->hash_key_size = IGB_HKEY_MAX_INDEX * sizeof(uint32_t);
1847 dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
1848 dev_info->flow_type_rss_offloads = IGB_RSS_OFFLOAD_ALL;
1850 dev_info->default_rxconf = (struct rte_eth_rxconf) {
1852 .pthresh = IGB_DEFAULT_RX_PTHRESH,
1853 .hthresh = IGB_DEFAULT_RX_HTHRESH,
1854 .wthresh = IGB_DEFAULT_RX_WTHRESH,
1856 .rx_free_thresh = IGB_DEFAULT_RX_FREE_THRESH,
1860 dev_info->default_txconf = (struct rte_eth_txconf) {
1862 .pthresh = IGB_DEFAULT_TX_PTHRESH,
1863 .hthresh = IGB_DEFAULT_TX_HTHRESH,
1864 .wthresh = IGB_DEFAULT_TX_WTHRESH,
1869 dev_info->rx_desc_lim = rx_desc_lim;
1870 dev_info->tx_desc_lim = tx_desc_lim;
1874 eth_igbvf_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
1876 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1878 dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
1879 dev_info->max_rx_pktlen = 0x3FFF; /* See RLPML register. */
1880 dev_info->max_mac_addrs = hw->mac.rar_entry_count;
1881 dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP |
1882 DEV_RX_OFFLOAD_IPV4_CKSUM |
1883 DEV_RX_OFFLOAD_UDP_CKSUM |
1884 DEV_RX_OFFLOAD_TCP_CKSUM;
1885 dev_info->tx_offload_capa = DEV_TX_OFFLOAD_VLAN_INSERT |
1886 DEV_TX_OFFLOAD_IPV4_CKSUM |
1887 DEV_TX_OFFLOAD_UDP_CKSUM |
1888 DEV_TX_OFFLOAD_TCP_CKSUM |
1889 DEV_TX_OFFLOAD_SCTP_CKSUM |
1890 DEV_TX_OFFLOAD_TCP_TSO;
1891 switch (hw->mac.type) {
1893 dev_info->max_rx_queues = 2;
1894 dev_info->max_tx_queues = 2;
1896 case e1000_vfadapt_i350:
1897 dev_info->max_rx_queues = 1;
1898 dev_info->max_tx_queues = 1;
1901 /* Should not happen */
1905 dev_info->default_rxconf = (struct rte_eth_rxconf) {
1907 .pthresh = IGB_DEFAULT_RX_PTHRESH,
1908 .hthresh = IGB_DEFAULT_RX_HTHRESH,
1909 .wthresh = IGB_DEFAULT_RX_WTHRESH,
1911 .rx_free_thresh = IGB_DEFAULT_RX_FREE_THRESH,
1915 dev_info->default_txconf = (struct rte_eth_txconf) {
1917 .pthresh = IGB_DEFAULT_TX_PTHRESH,
1918 .hthresh = IGB_DEFAULT_TX_HTHRESH,
1919 .wthresh = IGB_DEFAULT_TX_WTHRESH,
1924 dev_info->rx_desc_lim = rx_desc_lim;
1925 dev_info->tx_desc_lim = tx_desc_lim;
1928 /* return 0 means link status changed, -1 means not changed */
1930 eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete)
1932 struct e1000_hw *hw =
1933 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1934 struct rte_eth_link link, old;
1935 int link_check, count;
1938 hw->mac.get_link_status = 1;
1940 /* possible wait-to-complete in up to 9 seconds */
1941 for (count = 0; count < IGB_LINK_UPDATE_CHECK_TIMEOUT; count ++) {
1942 /* Read the real link status */
1943 switch (hw->phy.media_type) {
1944 case e1000_media_type_copper:
1945 /* Do the work to read phy */
1946 e1000_check_for_link(hw);
1947 link_check = !hw->mac.get_link_status;
1950 case e1000_media_type_fiber:
1951 e1000_check_for_link(hw);
1952 link_check = (E1000_READ_REG(hw, E1000_STATUS) &
1956 case e1000_media_type_internal_serdes:
1957 e1000_check_for_link(hw);
1958 link_check = hw->mac.serdes_has_link;
1961 /* VF device is type_unknown */
1962 case e1000_media_type_unknown:
1963 eth_igbvf_link_update(hw);
1964 link_check = !hw->mac.get_link_status;
1970 if (link_check || wait_to_complete == 0)
1972 rte_delay_ms(IGB_LINK_UPDATE_CHECK_INTERVAL);
1974 memset(&link, 0, sizeof(link));
1975 rte_igb_dev_atomic_read_link_status(dev, &link);
1978 /* Now we check if a transition has happened */
1980 hw->mac.ops.get_link_up_info(hw, &link.link_speed,
1982 link.link_status = 1;
1983 } else if (!link_check) {
1984 link.link_speed = 0;
1985 link.link_duplex = 0;
1986 link.link_status = 0;
1988 rte_igb_dev_atomic_write_link_status(dev, &link);
1991 if (old.link_status == link.link_status)
1999 * igb_hw_control_acquire sets CTRL_EXT:DRV_LOAD bit.
2000 * For ASF and Pass Through versions of f/w this means
2001 * that the driver is loaded.
2004 igb_hw_control_acquire(struct e1000_hw *hw)
2008 /* Let firmware know the driver has taken over */
2009 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2010 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
2014 * igb_hw_control_release resets CTRL_EXT:DRV_LOAD bit.
2015 * For ASF and Pass Through versions of f/w this means that the
2016 * driver is no longer loaded.
2019 igb_hw_control_release(struct e1000_hw *hw)
2023 /* Let firmware taken over control of h/w */
2024 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
2025 E1000_WRITE_REG(hw, E1000_CTRL_EXT,
2026 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
2030 * Bit of a misnomer, what this really means is
2031 * to enable OS management of the system... aka
2032 * to disable special hardware management features.
2035 igb_init_manageability(struct e1000_hw *hw)
2037 if (e1000_enable_mng_pass_thru(hw)) {
2038 uint32_t manc2h = E1000_READ_REG(hw, E1000_MANC2H);
2039 uint32_t manc = E1000_READ_REG(hw, E1000_MANC);
2041 /* disable hardware interception of ARP */
2042 manc &= ~(E1000_MANC_ARP_EN);
2044 /* enable receiving management packets to the host */
2045 manc |= E1000_MANC_EN_MNG2HOST;
2046 manc2h |= 1 << 5; /* Mng Port 623 */
2047 manc2h |= 1 << 6; /* Mng Port 664 */
2048 E1000_WRITE_REG(hw, E1000_MANC2H, manc2h);
2049 E1000_WRITE_REG(hw, E1000_MANC, manc);
2054 igb_release_manageability(struct e1000_hw *hw)
2056 if (e1000_enable_mng_pass_thru(hw)) {
2057 uint32_t manc = E1000_READ_REG(hw, E1000_MANC);
2059 manc |= E1000_MANC_ARP_EN;
2060 manc &= ~E1000_MANC_EN_MNG2HOST;
2062 E1000_WRITE_REG(hw, E1000_MANC, manc);
2067 eth_igb_promiscuous_enable(struct rte_eth_dev *dev)
2069 struct e1000_hw *hw =
2070 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2073 rctl = E1000_READ_REG(hw, E1000_RCTL);
2074 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
2075 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
2079 eth_igb_promiscuous_disable(struct rte_eth_dev *dev)
2081 struct e1000_hw *hw =
2082 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2085 rctl = E1000_READ_REG(hw, E1000_RCTL);
2086 rctl &= (~E1000_RCTL_UPE);
2087 if (dev->data->all_multicast == 1)
2088 rctl |= E1000_RCTL_MPE;
2090 rctl &= (~E1000_RCTL_MPE);
2091 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
2095 eth_igb_allmulticast_enable(struct rte_eth_dev *dev)
2097 struct e1000_hw *hw =
2098 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2101 rctl = E1000_READ_REG(hw, E1000_RCTL);
2102 rctl |= E1000_RCTL_MPE;
2103 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
2107 eth_igb_allmulticast_disable(struct rte_eth_dev *dev)
2109 struct e1000_hw *hw =
2110 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2113 if (dev->data->promiscuous == 1)
2114 return; /* must remain in all_multicast mode */
2115 rctl = E1000_READ_REG(hw, E1000_RCTL);
2116 rctl &= (~E1000_RCTL_MPE);
2117 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
2121 eth_igb_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
2123 struct e1000_hw *hw =
2124 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2125 struct e1000_vfta * shadow_vfta =
2126 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
2131 vid_idx = (uint32_t) ((vlan_id >> E1000_VFTA_ENTRY_SHIFT) &
2132 E1000_VFTA_ENTRY_MASK);
2133 vid_bit = (uint32_t) (1 << (vlan_id & E1000_VFTA_ENTRY_BIT_SHIFT_MASK));
2134 vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, vid_idx);
2139 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, vid_idx, vfta);
2141 /* update local VFTA copy */
2142 shadow_vfta->vfta[vid_idx] = vfta;
2148 eth_igb_vlan_tpid_set(struct rte_eth_dev *dev, uint16_t tpid)
2150 struct e1000_hw *hw =
2151 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2152 uint32_t reg = ETHER_TYPE_VLAN ;
2154 reg |= (tpid << 16);
2155 E1000_WRITE_REG(hw, E1000_VET, reg);
2159 igb_vlan_hw_filter_disable(struct rte_eth_dev *dev)
2161 struct e1000_hw *hw =
2162 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2165 /* Filter Table Disable */
2166 reg = E1000_READ_REG(hw, E1000_RCTL);
2167 reg &= ~E1000_RCTL_CFIEN;
2168 reg &= ~E1000_RCTL_VFE;
2169 E1000_WRITE_REG(hw, E1000_RCTL, reg);
2173 igb_vlan_hw_filter_enable(struct rte_eth_dev *dev)
2175 struct e1000_hw *hw =
2176 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2177 struct e1000_vfta * shadow_vfta =
2178 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
2182 /* Filter Table Enable, CFI not used for packet acceptance */
2183 reg = E1000_READ_REG(hw, E1000_RCTL);
2184 reg &= ~E1000_RCTL_CFIEN;
2185 reg |= E1000_RCTL_VFE;
2186 E1000_WRITE_REG(hw, E1000_RCTL, reg);
2188 /* restore VFTA table */
2189 for (i = 0; i < IGB_VFTA_SIZE; i++)
2190 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, i, shadow_vfta->vfta[i]);
2194 igb_vlan_hw_strip_disable(struct rte_eth_dev *dev)
2196 struct e1000_hw *hw =
2197 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2200 /* VLAN Mode Disable */
2201 reg = E1000_READ_REG(hw, E1000_CTRL);
2202 reg &= ~E1000_CTRL_VME;
2203 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2207 igb_vlan_hw_strip_enable(struct rte_eth_dev *dev)
2209 struct e1000_hw *hw =
2210 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2213 /* VLAN Mode Enable */
2214 reg = E1000_READ_REG(hw, E1000_CTRL);
2215 reg |= E1000_CTRL_VME;
2216 E1000_WRITE_REG(hw, E1000_CTRL, reg);
2220 igb_vlan_hw_extend_disable(struct rte_eth_dev *dev)
2222 struct e1000_hw *hw =
2223 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2226 /* CTRL_EXT: Extended VLAN */
2227 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
2228 reg &= ~E1000_CTRL_EXT_EXTEND_VLAN;
2229 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
2231 /* Update maximum packet length */
2232 if (dev->data->dev_conf.rxmode.jumbo_frame == 1)
2233 E1000_WRITE_REG(hw, E1000_RLPML,
2234 dev->data->dev_conf.rxmode.max_rx_pkt_len +
2239 igb_vlan_hw_extend_enable(struct rte_eth_dev *dev)
2241 struct e1000_hw *hw =
2242 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2245 /* CTRL_EXT: Extended VLAN */
2246 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
2247 reg |= E1000_CTRL_EXT_EXTEND_VLAN;
2248 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
2250 /* Update maximum packet length */
2251 if (dev->data->dev_conf.rxmode.jumbo_frame == 1)
2252 E1000_WRITE_REG(hw, E1000_RLPML,
2253 dev->data->dev_conf.rxmode.max_rx_pkt_len +
2258 eth_igb_vlan_offload_set(struct rte_eth_dev *dev, int mask)
2260 if(mask & ETH_VLAN_STRIP_MASK){
2261 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
2262 igb_vlan_hw_strip_enable(dev);
2264 igb_vlan_hw_strip_disable(dev);
2267 if(mask & ETH_VLAN_FILTER_MASK){
2268 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
2269 igb_vlan_hw_filter_enable(dev);
2271 igb_vlan_hw_filter_disable(dev);
2274 if(mask & ETH_VLAN_EXTEND_MASK){
2275 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
2276 igb_vlan_hw_extend_enable(dev);
2278 igb_vlan_hw_extend_disable(dev);
2284 * It enables the interrupt mask and then enable the interrupt.
2287 * Pointer to struct rte_eth_dev.
2290 * - On success, zero.
2291 * - On failure, a negative value.
2294 eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev)
2296 struct e1000_interrupt *intr =
2297 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2299 intr->mask |= E1000_ICR_LSC;
2304 /* It clears the interrupt causes and enables the interrupt.
2305 * It will be called once only during nic initialized.
2308 * Pointer to struct rte_eth_dev.
2311 * - On success, zero.
2312 * - On failure, a negative value.
2314 static int eth_igb_rxq_interrupt_setup(struct rte_eth_dev *dev)
2316 uint32_t mask, regval;
2317 struct e1000_hw *hw =
2318 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2319 struct rte_eth_dev_info dev_info;
2321 memset(&dev_info, 0, sizeof(dev_info));
2322 eth_igb_infos_get(dev, &dev_info);
2324 mask = 0xFFFFFFFF >> (32 - dev_info.max_rx_queues);
2325 regval = E1000_READ_REG(hw, E1000_EIMS);
2326 E1000_WRITE_REG(hw, E1000_EIMS, regval | mask);
2332 * It reads ICR and gets interrupt causes, check it and set a bit flag
2333 * to update link status.
2336 * Pointer to struct rte_eth_dev.
2339 * - On success, zero.
2340 * - On failure, a negative value.
2343 eth_igb_interrupt_get_status(struct rte_eth_dev *dev)
2346 struct e1000_hw *hw =
2347 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2348 struct e1000_interrupt *intr =
2349 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2351 igb_intr_disable(hw);
2353 /* read-on-clear nic registers here */
2354 icr = E1000_READ_REG(hw, E1000_ICR);
2357 if (icr & E1000_ICR_LSC) {
2358 intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
2361 if (icr & E1000_ICR_VMMB)
2362 intr->flags |= E1000_FLAG_MAILBOX;
2368 * It executes link_update after knowing an interrupt is prsent.
2371 * Pointer to struct rte_eth_dev.
2374 * - On success, zero.
2375 * - On failure, a negative value.
2378 eth_igb_interrupt_action(struct rte_eth_dev *dev)
2380 struct e1000_hw *hw =
2381 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2382 struct e1000_interrupt *intr =
2383 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
2384 uint32_t tctl, rctl;
2385 struct rte_eth_link link;
2388 if (intr->flags & E1000_FLAG_MAILBOX) {
2389 igb_pf_mbx_process(dev);
2390 intr->flags &= ~E1000_FLAG_MAILBOX;
2393 igb_intr_enable(dev);
2394 rte_intr_enable(&(dev->pci_dev->intr_handle));
2396 if (intr->flags & E1000_FLAG_NEED_LINK_UPDATE) {
2397 intr->flags &= ~E1000_FLAG_NEED_LINK_UPDATE;
2399 /* set get_link_status to check register later */
2400 hw->mac.get_link_status = 1;
2401 ret = eth_igb_link_update(dev, 0);
2403 /* check if link has changed */
2407 memset(&link, 0, sizeof(link));
2408 rte_igb_dev_atomic_read_link_status(dev, &link);
2409 if (link.link_status) {
2411 " Port %d: Link Up - speed %u Mbps - %s",
2413 (unsigned)link.link_speed,
2414 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
2415 "full-duplex" : "half-duplex");
2417 PMD_INIT_LOG(INFO, " Port %d: Link Down",
2418 dev->data->port_id);
2421 PMD_INIT_LOG(DEBUG, "PCI Address: %04d:%02d:%02d:%d",
2422 dev->pci_dev->addr.domain,
2423 dev->pci_dev->addr.bus,
2424 dev->pci_dev->addr.devid,
2425 dev->pci_dev->addr.function);
2426 tctl = E1000_READ_REG(hw, E1000_TCTL);
2427 rctl = E1000_READ_REG(hw, E1000_RCTL);
2428 if (link.link_status) {
2430 tctl |= E1000_TCTL_EN;
2431 rctl |= E1000_RCTL_EN;
2434 tctl &= ~E1000_TCTL_EN;
2435 rctl &= ~E1000_RCTL_EN;
2437 E1000_WRITE_REG(hw, E1000_TCTL, tctl);
2438 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
2439 E1000_WRITE_FLUSH(hw);
2440 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
2447 * Interrupt handler which shall be registered at first.
2450 * Pointer to interrupt handle.
2452 * The address of parameter (struct rte_eth_dev *) regsitered before.
2458 eth_igb_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
2461 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
2463 eth_igb_interrupt_get_status(dev);
2464 eth_igb_interrupt_action(dev);
2468 eth_igb_led_on(struct rte_eth_dev *dev)
2470 struct e1000_hw *hw;
2472 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2473 return (e1000_led_on(hw) == E1000_SUCCESS ? 0 : -ENOTSUP);
2477 eth_igb_led_off(struct rte_eth_dev *dev)
2479 struct e1000_hw *hw;
2481 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2482 return (e1000_led_off(hw) == E1000_SUCCESS ? 0 : -ENOTSUP);
2486 eth_igb_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2488 struct e1000_hw *hw;
2493 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2494 fc_conf->pause_time = hw->fc.pause_time;
2495 fc_conf->high_water = hw->fc.high_water;
2496 fc_conf->low_water = hw->fc.low_water;
2497 fc_conf->send_xon = hw->fc.send_xon;
2498 fc_conf->autoneg = hw->mac.autoneg;
2501 * Return rx_pause and tx_pause status according to actual setting of
2502 * the TFCE and RFCE bits in the CTRL register.
2504 ctrl = E1000_READ_REG(hw, E1000_CTRL);
2505 if (ctrl & E1000_CTRL_TFCE)
2510 if (ctrl & E1000_CTRL_RFCE)
2515 if (rx_pause && tx_pause)
2516 fc_conf->mode = RTE_FC_FULL;
2518 fc_conf->mode = RTE_FC_RX_PAUSE;
2520 fc_conf->mode = RTE_FC_TX_PAUSE;
2522 fc_conf->mode = RTE_FC_NONE;
2528 eth_igb_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2530 struct e1000_hw *hw;
2532 enum e1000_fc_mode rte_fcmode_2_e1000_fcmode[] = {
2538 uint32_t rx_buf_size;
2539 uint32_t max_high_water;
2542 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2543 if (fc_conf->autoneg != hw->mac.autoneg)
2545 rx_buf_size = igb_get_rx_buffer_size(hw);
2546 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x", rx_buf_size);
2548 /* At least reserve one Ethernet frame for watermark */
2549 max_high_water = rx_buf_size - ETHER_MAX_LEN;
2550 if ((fc_conf->high_water > max_high_water) ||
2551 (fc_conf->high_water < fc_conf->low_water)) {
2552 PMD_INIT_LOG(ERR, "e1000 incorrect high/low water value");
2553 PMD_INIT_LOG(ERR, "high water must <= 0x%x", max_high_water);
2557 hw->fc.requested_mode = rte_fcmode_2_e1000_fcmode[fc_conf->mode];
2558 hw->fc.pause_time = fc_conf->pause_time;
2559 hw->fc.high_water = fc_conf->high_water;
2560 hw->fc.low_water = fc_conf->low_water;
2561 hw->fc.send_xon = fc_conf->send_xon;
2563 err = e1000_setup_link_generic(hw);
2564 if (err == E1000_SUCCESS) {
2566 /* check if we want to forward MAC frames - driver doesn't have native
2567 * capability to do that, so we'll write the registers ourselves */
2569 rctl = E1000_READ_REG(hw, E1000_RCTL);
2571 /* set or clear MFLCN.PMCF bit depending on configuration */
2572 if (fc_conf->mac_ctrl_frame_fwd != 0)
2573 rctl |= E1000_RCTL_PMCF;
2575 rctl &= ~E1000_RCTL_PMCF;
2577 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
2578 E1000_WRITE_FLUSH(hw);
2583 PMD_INIT_LOG(ERR, "e1000_setup_link_generic = 0x%x", err);
2587 #define E1000_RAH_POOLSEL_SHIFT (18)
2589 eth_igb_rar_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
2590 uint32_t index, __rte_unused uint32_t pool)
2592 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2595 e1000_rar_set(hw, mac_addr->addr_bytes, index);
2596 rah = E1000_READ_REG(hw, E1000_RAH(index));
2597 rah |= (0x1 << (E1000_RAH_POOLSEL_SHIFT + pool));
2598 E1000_WRITE_REG(hw, E1000_RAH(index), rah);
2602 eth_igb_rar_clear(struct rte_eth_dev *dev, uint32_t index)
2604 uint8_t addr[ETHER_ADDR_LEN];
2605 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2607 memset(addr, 0, sizeof(addr));
2609 e1000_rar_set(hw, addr, index);
2613 eth_igb_default_mac_addr_set(struct rte_eth_dev *dev,
2614 struct ether_addr *addr)
2616 eth_igb_rar_clear(dev, 0);
2618 eth_igb_rar_set(dev, (void *)addr, 0, 0);
2621 * Virtual Function operations
2624 igbvf_intr_disable(struct e1000_hw *hw)
2626 PMD_INIT_FUNC_TRACE();
2628 /* Clear interrupt mask to stop from interrupts being generated */
2629 E1000_WRITE_REG(hw, E1000_EIMC, 0xFFFF);
2631 E1000_WRITE_FLUSH(hw);
2635 igbvf_stop_adapter(struct rte_eth_dev *dev)
2639 struct rte_eth_dev_info dev_info;
2640 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2642 memset(&dev_info, 0, sizeof(dev_info));
2643 eth_igbvf_infos_get(dev, &dev_info);
2645 /* Clear interrupt mask to stop from interrupts being generated */
2646 igbvf_intr_disable(hw);
2648 /* Clear any pending interrupts, flush previous writes */
2649 E1000_READ_REG(hw, E1000_EICR);
2651 /* Disable the transmit unit. Each queue must be disabled. */
2652 for (i = 0; i < dev_info.max_tx_queues; i++)
2653 E1000_WRITE_REG(hw, E1000_TXDCTL(i), E1000_TXDCTL_SWFLSH);
2655 /* Disable the receive unit by stopping each queue */
2656 for (i = 0; i < dev_info.max_rx_queues; i++) {
2657 reg_val = E1000_READ_REG(hw, E1000_RXDCTL(i));
2658 reg_val &= ~E1000_RXDCTL_QUEUE_ENABLE;
2659 E1000_WRITE_REG(hw, E1000_RXDCTL(i), reg_val);
2660 while (E1000_READ_REG(hw, E1000_RXDCTL(i)) & E1000_RXDCTL_QUEUE_ENABLE)
2664 /* flush all queues disables */
2665 E1000_WRITE_FLUSH(hw);
2669 static int eth_igbvf_link_update(struct e1000_hw *hw)
2671 struct e1000_mbx_info *mbx = &hw->mbx;
2672 struct e1000_mac_info *mac = &hw->mac;
2673 int ret_val = E1000_SUCCESS;
2675 PMD_INIT_LOG(DEBUG, "e1000_check_for_link_vf");
2678 * We only want to run this if there has been a rst asserted.
2679 * in this case that could mean a link change, device reset,
2680 * or a virtual function reset
2683 /* If we were hit with a reset or timeout drop the link */
2684 if (!e1000_check_for_rst(hw, 0) || !mbx->timeout)
2685 mac->get_link_status = TRUE;
2687 if (!mac->get_link_status)
2690 /* if link status is down no point in checking to see if pf is up */
2691 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
2694 /* if we passed all the tests above then the link is up and we no
2695 * longer need to check for link */
2696 mac->get_link_status = FALSE;
2704 igbvf_dev_configure(struct rte_eth_dev *dev)
2706 struct rte_eth_conf* conf = &dev->data->dev_conf;
2708 PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
2709 dev->data->port_id);
2712 * VF has no ability to enable/disable HW CRC
2713 * Keep the persistent behavior the same as Host PF
2715 #ifndef RTE_LIBRTE_E1000_PF_DISABLE_STRIP_CRC
2716 if (!conf->rxmode.hw_strip_crc) {
2717 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
2718 conf->rxmode.hw_strip_crc = 1;
2721 if (conf->rxmode.hw_strip_crc) {
2722 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
2723 conf->rxmode.hw_strip_crc = 0;
2731 igbvf_dev_start(struct rte_eth_dev *dev)
2733 struct e1000_hw *hw =
2734 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2735 struct e1000_adapter *adapter =
2736 E1000_DEV_PRIVATE(dev->data->dev_private);
2739 PMD_INIT_FUNC_TRACE();
2741 hw->mac.ops.reset_hw(hw);
2742 adapter->stopped = 0;
2745 igbvf_set_vfta_all(dev,1);
2747 eth_igbvf_tx_init(dev);
2749 /* This can fail when allocating mbufs for descriptor rings */
2750 ret = eth_igbvf_rx_init(dev);
2752 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
2753 igb_dev_clear_queues(dev);
2761 igbvf_dev_stop(struct rte_eth_dev *dev)
2763 PMD_INIT_FUNC_TRACE();
2765 igbvf_stop_adapter(dev);
2768 * Clear what we set, but we still keep shadow_vfta to
2769 * restore after device starts
2771 igbvf_set_vfta_all(dev,0);
2773 igb_dev_clear_queues(dev);
2777 igbvf_dev_close(struct rte_eth_dev *dev)
2779 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2780 struct e1000_adapter *adapter =
2781 E1000_DEV_PRIVATE(dev->data->dev_private);
2783 PMD_INIT_FUNC_TRACE();
2787 igbvf_dev_stop(dev);
2788 adapter->stopped = 1;
2789 igb_dev_free_queues(dev);
2792 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on)
2794 struct e1000_mbx_info *mbx = &hw->mbx;
2797 /* After set vlan, vlan strip will also be enabled in igb driver*/
2798 msgbuf[0] = E1000_VF_SET_VLAN;
2800 /* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
2802 msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
2804 return (mbx->ops.write_posted(hw, msgbuf, 2, 0));
2807 static void igbvf_set_vfta_all(struct rte_eth_dev *dev, bool on)
2809 struct e1000_hw *hw =
2810 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2811 struct e1000_vfta * shadow_vfta =
2812 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
2813 int i = 0, j = 0, vfta = 0, mask = 1;
2815 for (i = 0; i < IGB_VFTA_SIZE; i++){
2816 vfta = shadow_vfta->vfta[i];
2819 for (j = 0; j < 32; j++){
2822 (uint16_t)((i<<5)+j), on);
2831 igbvf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
2833 struct e1000_hw *hw =
2834 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2835 struct e1000_vfta * shadow_vfta =
2836 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
2837 uint32_t vid_idx = 0;
2838 uint32_t vid_bit = 0;
2841 PMD_INIT_FUNC_TRACE();
2843 /*vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf*/
2844 ret = igbvf_set_vfta(hw, vlan_id, !!on);
2846 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
2849 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
2850 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
2852 /*Save what we set and retore it after device reset*/
2854 shadow_vfta->vfta[vid_idx] |= vid_bit;
2856 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
2862 igbvf_default_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *addr)
2864 struct e1000_hw *hw =
2865 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2867 /* index is not used by rar_set() */
2868 hw->mac.ops.rar_set(hw, (void *)addr, 0);
2873 eth_igb_rss_reta_update(struct rte_eth_dev *dev,
2874 struct rte_eth_rss_reta_entry64 *reta_conf,
2879 uint16_t idx, shift;
2880 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2882 if (reta_size != ETH_RSS_RETA_SIZE_128) {
2883 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
2884 "(%d) doesn't match the number hardware can supported "
2885 "(%d)\n", reta_size, ETH_RSS_RETA_SIZE_128);
2889 for (i = 0; i < reta_size; i += IGB_4_BIT_WIDTH) {
2890 idx = i / RTE_RETA_GROUP_SIZE;
2891 shift = i % RTE_RETA_GROUP_SIZE;
2892 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
2896 if (mask == IGB_4_BIT_MASK)
2899 r = E1000_READ_REG(hw, E1000_RETA(i >> 2));
2900 for (j = 0, reta = 0; j < IGB_4_BIT_WIDTH; j++) {
2901 if (mask & (0x1 << j))
2902 reta |= reta_conf[idx].reta[shift + j] <<
2905 reta |= r & (IGB_8_BIT_MASK << (CHAR_BIT * j));
2907 E1000_WRITE_REG(hw, E1000_RETA(i >> 2), reta);
2914 eth_igb_rss_reta_query(struct rte_eth_dev *dev,
2915 struct rte_eth_rss_reta_entry64 *reta_conf,
2920 uint16_t idx, shift;
2921 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2923 if (reta_size != ETH_RSS_RETA_SIZE_128) {
2924 PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
2925 "(%d) doesn't match the number hardware can supported "
2926 "(%d)\n", reta_size, ETH_RSS_RETA_SIZE_128);
2930 for (i = 0; i < reta_size; i += IGB_4_BIT_WIDTH) {
2931 idx = i / RTE_RETA_GROUP_SIZE;
2932 shift = i % RTE_RETA_GROUP_SIZE;
2933 mask = (uint8_t)((reta_conf[idx].mask >> shift) &
2937 reta = E1000_READ_REG(hw, E1000_RETA(i >> 2));
2938 for (j = 0; j < IGB_4_BIT_WIDTH; j++) {
2939 if (mask & (0x1 << j))
2940 reta_conf[idx].reta[shift + j] =
2941 ((reta >> (CHAR_BIT * j)) &
2949 #define MAC_TYPE_FILTER_SUP(type) do {\
2950 if ((type) != e1000_82580 && (type) != e1000_i350 &&\
2951 (type) != e1000_82576)\
2956 eth_igb_syn_filter_set(struct rte_eth_dev *dev,
2957 struct rte_eth_syn_filter *filter,
2960 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2961 uint32_t synqf, rfctl;
2963 if (filter->queue >= IGB_MAX_RX_QUEUE_NUM)
2966 synqf = E1000_READ_REG(hw, E1000_SYNQF(0));
2969 if (synqf & E1000_SYN_FILTER_ENABLE)
2972 synqf = (uint32_t)(((filter->queue << E1000_SYN_FILTER_QUEUE_SHIFT) &
2973 E1000_SYN_FILTER_QUEUE) | E1000_SYN_FILTER_ENABLE);
2975 rfctl = E1000_READ_REG(hw, E1000_RFCTL);
2976 if (filter->hig_pri)
2977 rfctl |= E1000_RFCTL_SYNQFP;
2979 rfctl &= ~E1000_RFCTL_SYNQFP;
2981 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl);
2983 if (!(synqf & E1000_SYN_FILTER_ENABLE))
2988 E1000_WRITE_REG(hw, E1000_SYNQF(0), synqf);
2989 E1000_WRITE_FLUSH(hw);
2994 eth_igb_syn_filter_get(struct rte_eth_dev *dev,
2995 struct rte_eth_syn_filter *filter)
2997 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2998 uint32_t synqf, rfctl;
3000 synqf = E1000_READ_REG(hw, E1000_SYNQF(0));
3001 if (synqf & E1000_SYN_FILTER_ENABLE) {
3002 rfctl = E1000_READ_REG(hw, E1000_RFCTL);
3003 filter->hig_pri = (rfctl & E1000_RFCTL_SYNQFP) ? 1 : 0;
3004 filter->queue = (uint8_t)((synqf & E1000_SYN_FILTER_QUEUE) >>
3005 E1000_SYN_FILTER_QUEUE_SHIFT);
3013 eth_igb_syn_filter_handle(struct rte_eth_dev *dev,
3014 enum rte_filter_op filter_op,
3017 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3020 MAC_TYPE_FILTER_SUP(hw->mac.type);
3022 if (filter_op == RTE_ETH_FILTER_NOP)
3026 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
3031 switch (filter_op) {
3032 case RTE_ETH_FILTER_ADD:
3033 ret = eth_igb_syn_filter_set(dev,
3034 (struct rte_eth_syn_filter *)arg,
3037 case RTE_ETH_FILTER_DELETE:
3038 ret = eth_igb_syn_filter_set(dev,
3039 (struct rte_eth_syn_filter *)arg,
3042 case RTE_ETH_FILTER_GET:
3043 ret = eth_igb_syn_filter_get(dev,
3044 (struct rte_eth_syn_filter *)arg);
3047 PMD_DRV_LOG(ERR, "unsupported operation %u\n", filter_op);
3055 #define MAC_TYPE_FILTER_SUP_EXT(type) do {\
3056 if ((type) != e1000_82580 && (type) != e1000_i350)\
3060 /* translate elements in struct rte_eth_ntuple_filter to struct e1000_2tuple_filter_info*/
3062 ntuple_filter_to_2tuple(struct rte_eth_ntuple_filter *filter,
3063 struct e1000_2tuple_filter_info *filter_info)
3065 if (filter->queue >= IGB_MAX_RX_QUEUE_NUM)
3067 if (filter->priority > E1000_2TUPLE_MAX_PRI)
3068 return -EINVAL; /* filter index is out of range. */
3069 if (filter->tcp_flags > TCP_FLAG_ALL)
3070 return -EINVAL; /* flags is invalid. */
3072 switch (filter->dst_port_mask) {
3074 filter_info->dst_port_mask = 0;
3075 filter_info->dst_port = filter->dst_port;
3078 filter_info->dst_port_mask = 1;
3081 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
3085 switch (filter->proto_mask) {
3087 filter_info->proto_mask = 0;
3088 filter_info->proto = filter->proto;
3091 filter_info->proto_mask = 1;
3094 PMD_DRV_LOG(ERR, "invalid protocol mask.");
3098 filter_info->priority = (uint8_t)filter->priority;
3099 if (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG)
3100 filter_info->tcp_flags = filter->tcp_flags;
3102 filter_info->tcp_flags = 0;
3107 static inline struct e1000_2tuple_filter *
3108 igb_2tuple_filter_lookup(struct e1000_2tuple_filter_list *filter_list,
3109 struct e1000_2tuple_filter_info *key)
3111 struct e1000_2tuple_filter *it;
3113 TAILQ_FOREACH(it, filter_list, entries) {
3114 if (memcmp(key, &it->filter_info,
3115 sizeof(struct e1000_2tuple_filter_info)) == 0) {
3123 * igb_add_2tuple_filter - add a 2tuple filter
3126 * dev: Pointer to struct rte_eth_dev.
3127 * ntuple_filter: ponter to the filter that will be added.
3130 * - On success, zero.
3131 * - On failure, a negative value.
3134 igb_add_2tuple_filter(struct rte_eth_dev *dev,
3135 struct rte_eth_ntuple_filter *ntuple_filter)
3137 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3138 struct e1000_filter_info *filter_info =
3139 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3140 struct e1000_2tuple_filter *filter;
3141 uint32_t ttqf = E1000_TTQF_DISABLE_MASK;
3142 uint32_t imir, imir_ext = E1000_IMIREXT_SIZE_BP;
3145 filter = rte_zmalloc("e1000_2tuple_filter",
3146 sizeof(struct e1000_2tuple_filter), 0);
3150 ret = ntuple_filter_to_2tuple(ntuple_filter,
3151 &filter->filter_info);
3156 if (igb_2tuple_filter_lookup(&filter_info->twotuple_list,
3157 &filter->filter_info) != NULL) {
3158 PMD_DRV_LOG(ERR, "filter exists.");
3162 filter->queue = ntuple_filter->queue;
3165 * look for an unused 2tuple filter index,
3166 * and insert the filter to list.
3168 for (i = 0; i < E1000_MAX_TTQF_FILTERS; i++) {
3169 if (!(filter_info->twotuple_mask & (1 << i))) {
3170 filter_info->twotuple_mask |= 1 << i;
3172 TAILQ_INSERT_TAIL(&filter_info->twotuple_list,
3178 if (i >= E1000_MAX_TTQF_FILTERS) {
3179 PMD_DRV_LOG(ERR, "2tuple filters are full.");
3184 imir = (uint32_t)(filter->filter_info.dst_port & E1000_IMIR_DSTPORT);
3185 if (filter->filter_info.dst_port_mask == 1) /* 1b means not compare. */
3186 imir |= E1000_IMIR_PORT_BP;
3188 imir &= ~E1000_IMIR_PORT_BP;
3190 imir |= filter->filter_info.priority << E1000_IMIR_PRIORITY_SHIFT;
3192 ttqf |= E1000_TTQF_QUEUE_ENABLE;
3193 ttqf |= (uint32_t)(filter->queue << E1000_TTQF_QUEUE_SHIFT);
3194 ttqf |= (uint32_t)(filter->filter_info.proto & E1000_TTQF_PROTOCOL_MASK);
3195 if (filter->filter_info.proto_mask == 0)
3196 ttqf &= ~E1000_TTQF_MASK_ENABLE;
3198 /* tcp flags bits setting. */
3199 if (filter->filter_info.tcp_flags & TCP_FLAG_ALL) {
3200 if (filter->filter_info.tcp_flags & TCP_URG_FLAG)
3201 imir_ext |= E1000_IMIREXT_CTRL_URG;
3202 if (filter->filter_info.tcp_flags & TCP_ACK_FLAG)
3203 imir_ext |= E1000_IMIREXT_CTRL_ACK;
3204 if (filter->filter_info.tcp_flags & TCP_PSH_FLAG)
3205 imir_ext |= E1000_IMIREXT_CTRL_PSH;
3206 if (filter->filter_info.tcp_flags & TCP_RST_FLAG)
3207 imir_ext |= E1000_IMIREXT_CTRL_RST;
3208 if (filter->filter_info.tcp_flags & TCP_SYN_FLAG)
3209 imir_ext |= E1000_IMIREXT_CTRL_SYN;
3210 if (filter->filter_info.tcp_flags & TCP_FIN_FLAG)
3211 imir_ext |= E1000_IMIREXT_CTRL_FIN;
3213 imir_ext |= E1000_IMIREXT_CTRL_BP;
3214 E1000_WRITE_REG(hw, E1000_IMIR(i), imir);
3215 E1000_WRITE_REG(hw, E1000_TTQF(i), ttqf);
3216 E1000_WRITE_REG(hw, E1000_IMIREXT(i), imir_ext);
3221 * igb_remove_2tuple_filter - remove a 2tuple filter
3224 * dev: Pointer to struct rte_eth_dev.
3225 * ntuple_filter: ponter to the filter that will be removed.
3228 * - On success, zero.
3229 * - On failure, a negative value.
3232 igb_remove_2tuple_filter(struct rte_eth_dev *dev,
3233 struct rte_eth_ntuple_filter *ntuple_filter)
3235 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3236 struct e1000_filter_info *filter_info =
3237 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3238 struct e1000_2tuple_filter_info filter_2tuple;
3239 struct e1000_2tuple_filter *filter;
3242 memset(&filter_2tuple, 0, sizeof(struct e1000_2tuple_filter_info));
3243 ret = ntuple_filter_to_2tuple(ntuple_filter,
3248 filter = igb_2tuple_filter_lookup(&filter_info->twotuple_list,
3250 if (filter == NULL) {
3251 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3255 filter_info->twotuple_mask &= ~(1 << filter->index);
3256 TAILQ_REMOVE(&filter_info->twotuple_list, filter, entries);
3259 E1000_WRITE_REG(hw, E1000_TTQF(filter->index), E1000_TTQF_DISABLE_MASK);
3260 E1000_WRITE_REG(hw, E1000_IMIR(filter->index), 0);
3261 E1000_WRITE_REG(hw, E1000_IMIREXT(filter->index), 0);
3265 static inline struct e1000_flex_filter *
3266 eth_igb_flex_filter_lookup(struct e1000_flex_filter_list *filter_list,
3267 struct e1000_flex_filter_info *key)
3269 struct e1000_flex_filter *it;
3271 TAILQ_FOREACH(it, filter_list, entries) {
3272 if (memcmp(key, &it->filter_info,
3273 sizeof(struct e1000_flex_filter_info)) == 0)
3281 eth_igb_add_del_flex_filter(struct rte_eth_dev *dev,
3282 struct rte_eth_flex_filter *filter,
3285 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3286 struct e1000_filter_info *filter_info =
3287 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3288 struct e1000_flex_filter *flex_filter, *it;
3289 uint32_t wufc, queueing, mask;
3291 uint8_t shift, i, j = 0;
3293 flex_filter = rte_zmalloc("e1000_flex_filter",
3294 sizeof(struct e1000_flex_filter), 0);
3295 if (flex_filter == NULL)
3298 flex_filter->filter_info.len = filter->len;
3299 flex_filter->filter_info.priority = filter->priority;
3300 memcpy(flex_filter->filter_info.dwords, filter->bytes, filter->len);
3301 for (i = 0; i < RTE_ALIGN(filter->len, CHAR_BIT) / CHAR_BIT; i++) {
3303 /* reverse bits in flex filter's mask*/
3304 for (shift = 0; shift < CHAR_BIT; shift++) {
3305 if (filter->mask[i] & (0x01 << shift))
3306 mask |= (0x80 >> shift);
3308 flex_filter->filter_info.mask[i] = mask;
3311 wufc = E1000_READ_REG(hw, E1000_WUFC);
3312 if (flex_filter->index < E1000_MAX_FHFT)
3313 reg_off = E1000_FHFT(flex_filter->index);
3315 reg_off = E1000_FHFT_EXT(flex_filter->index - E1000_MAX_FHFT);
3318 if (eth_igb_flex_filter_lookup(&filter_info->flex_list,
3319 &flex_filter->filter_info) != NULL) {
3320 PMD_DRV_LOG(ERR, "filter exists.");
3321 rte_free(flex_filter);
3324 flex_filter->queue = filter->queue;
3326 * look for an unused flex filter index
3327 * and insert the filter into the list.
3329 for (i = 0; i < E1000_MAX_FLEX_FILTERS; i++) {
3330 if (!(filter_info->flex_mask & (1 << i))) {
3331 filter_info->flex_mask |= 1 << i;
3332 flex_filter->index = i;
3333 TAILQ_INSERT_TAIL(&filter_info->flex_list,
3339 if (i >= E1000_MAX_FLEX_FILTERS) {
3340 PMD_DRV_LOG(ERR, "flex filters are full.");
3341 rte_free(flex_filter);
3345 E1000_WRITE_REG(hw, E1000_WUFC, wufc | E1000_WUFC_FLEX_HQ |
3346 (E1000_WUFC_FLX0 << flex_filter->index));
3347 queueing = filter->len |
3348 (filter->queue << E1000_FHFT_QUEUEING_QUEUE_SHIFT) |
3349 (filter->priority << E1000_FHFT_QUEUEING_PRIO_SHIFT);
3350 E1000_WRITE_REG(hw, reg_off + E1000_FHFT_QUEUEING_OFFSET,
3352 for (i = 0; i < E1000_FLEX_FILTERS_MASK_SIZE; i++) {
3353 E1000_WRITE_REG(hw, reg_off,
3354 flex_filter->filter_info.dwords[j]);
3355 reg_off += sizeof(uint32_t);
3356 E1000_WRITE_REG(hw, reg_off,
3357 flex_filter->filter_info.dwords[++j]);
3358 reg_off += sizeof(uint32_t);
3359 E1000_WRITE_REG(hw, reg_off,
3360 (uint32_t)flex_filter->filter_info.mask[i]);
3361 reg_off += sizeof(uint32_t) * 2;
3365 it = eth_igb_flex_filter_lookup(&filter_info->flex_list,
3366 &flex_filter->filter_info);
3368 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3369 rte_free(flex_filter);
3373 for (i = 0; i < E1000_FHFT_SIZE_IN_DWD; i++)
3374 E1000_WRITE_REG(hw, reg_off + i * sizeof(uint32_t), 0);
3375 E1000_WRITE_REG(hw, E1000_WUFC, wufc &
3376 (~(E1000_WUFC_FLX0 << it->index)));
3378 filter_info->flex_mask &= ~(1 << it->index);
3379 TAILQ_REMOVE(&filter_info->flex_list, it, entries);
3381 rte_free(flex_filter);
3388 eth_igb_get_flex_filter(struct rte_eth_dev *dev,
3389 struct rte_eth_flex_filter *filter)
3391 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3392 struct e1000_filter_info *filter_info =
3393 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3394 struct e1000_flex_filter flex_filter, *it;
3395 uint32_t wufc, queueing, wufc_en = 0;
3397 memset(&flex_filter, 0, sizeof(struct e1000_flex_filter));
3398 flex_filter.filter_info.len = filter->len;
3399 flex_filter.filter_info.priority = filter->priority;
3400 memcpy(flex_filter.filter_info.dwords, filter->bytes, filter->len);
3401 memcpy(flex_filter.filter_info.mask, filter->mask,
3402 RTE_ALIGN(filter->len, sizeof(char)) / sizeof(char));
3404 it = eth_igb_flex_filter_lookup(&filter_info->flex_list,
3405 &flex_filter.filter_info);
3407 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3411 wufc = E1000_READ_REG(hw, E1000_WUFC);
3412 wufc_en = E1000_WUFC_FLEX_HQ | (E1000_WUFC_FLX0 << it->index);
3414 if ((wufc & wufc_en) == wufc_en) {
3415 uint32_t reg_off = 0;
3416 if (it->index < E1000_MAX_FHFT)
3417 reg_off = E1000_FHFT(it->index);
3419 reg_off = E1000_FHFT_EXT(it->index - E1000_MAX_FHFT);
3421 queueing = E1000_READ_REG(hw,
3422 reg_off + E1000_FHFT_QUEUEING_OFFSET);
3423 filter->len = queueing & E1000_FHFT_QUEUEING_LEN;
3424 filter->priority = (queueing & E1000_FHFT_QUEUEING_PRIO) >>
3425 E1000_FHFT_QUEUEING_PRIO_SHIFT;
3426 filter->queue = (queueing & E1000_FHFT_QUEUEING_QUEUE) >>
3427 E1000_FHFT_QUEUEING_QUEUE_SHIFT;
3434 eth_igb_flex_filter_handle(struct rte_eth_dev *dev,
3435 enum rte_filter_op filter_op,
3438 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3439 struct rte_eth_flex_filter *filter;
3442 MAC_TYPE_FILTER_SUP_EXT(hw->mac.type);
3444 if (filter_op == RTE_ETH_FILTER_NOP)
3448 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u",
3453 filter = (struct rte_eth_flex_filter *)arg;
3454 if (filter->len == 0 || filter->len > E1000_MAX_FLEX_FILTER_LEN
3455 || filter->len % sizeof(uint64_t) != 0) {
3456 PMD_DRV_LOG(ERR, "filter's length is out of range");
3459 if (filter->priority > E1000_MAX_FLEX_FILTER_PRI) {
3460 PMD_DRV_LOG(ERR, "filter's priority is out of range");
3464 switch (filter_op) {
3465 case RTE_ETH_FILTER_ADD:
3466 ret = eth_igb_add_del_flex_filter(dev, filter, TRUE);
3468 case RTE_ETH_FILTER_DELETE:
3469 ret = eth_igb_add_del_flex_filter(dev, filter, FALSE);
3471 case RTE_ETH_FILTER_GET:
3472 ret = eth_igb_get_flex_filter(dev, filter);
3475 PMD_DRV_LOG(ERR, "unsupported operation %u", filter_op);
3483 /* translate elements in struct rte_eth_ntuple_filter to struct e1000_5tuple_filter_info*/
3485 ntuple_filter_to_5tuple_82576(struct rte_eth_ntuple_filter *filter,
3486 struct e1000_5tuple_filter_info *filter_info)
3488 if (filter->queue >= IGB_MAX_RX_QUEUE_NUM_82576)
3490 if (filter->priority > E1000_2TUPLE_MAX_PRI)
3491 return -EINVAL; /* filter index is out of range. */
3492 if (filter->tcp_flags > TCP_FLAG_ALL)
3493 return -EINVAL; /* flags is invalid. */
3495 switch (filter->dst_ip_mask) {
3497 filter_info->dst_ip_mask = 0;
3498 filter_info->dst_ip = filter->dst_ip;
3501 filter_info->dst_ip_mask = 1;
3504 PMD_DRV_LOG(ERR, "invalid dst_ip mask.");
3508 switch (filter->src_ip_mask) {
3510 filter_info->src_ip_mask = 0;
3511 filter_info->src_ip = filter->src_ip;
3514 filter_info->src_ip_mask = 1;
3517 PMD_DRV_LOG(ERR, "invalid src_ip mask.");
3521 switch (filter->dst_port_mask) {
3523 filter_info->dst_port_mask = 0;
3524 filter_info->dst_port = filter->dst_port;
3527 filter_info->dst_port_mask = 1;
3530 PMD_DRV_LOG(ERR, "invalid dst_port mask.");
3534 switch (filter->src_port_mask) {
3536 filter_info->src_port_mask = 0;
3537 filter_info->src_port = filter->src_port;
3540 filter_info->src_port_mask = 1;
3543 PMD_DRV_LOG(ERR, "invalid src_port mask.");
3547 switch (filter->proto_mask) {
3549 filter_info->proto_mask = 0;
3550 filter_info->proto = filter->proto;
3553 filter_info->proto_mask = 1;
3556 PMD_DRV_LOG(ERR, "invalid protocol mask.");
3560 filter_info->priority = (uint8_t)filter->priority;
3561 if (filter->flags & RTE_NTUPLE_FLAGS_TCP_FLAG)
3562 filter_info->tcp_flags = filter->tcp_flags;
3564 filter_info->tcp_flags = 0;
3569 static inline struct e1000_5tuple_filter *
3570 igb_5tuple_filter_lookup_82576(struct e1000_5tuple_filter_list *filter_list,
3571 struct e1000_5tuple_filter_info *key)
3573 struct e1000_5tuple_filter *it;
3575 TAILQ_FOREACH(it, filter_list, entries) {
3576 if (memcmp(key, &it->filter_info,
3577 sizeof(struct e1000_5tuple_filter_info)) == 0) {
3585 * igb_add_5tuple_filter_82576 - add a 5tuple filter
3588 * dev: Pointer to struct rte_eth_dev.
3589 * ntuple_filter: ponter to the filter that will be added.
3592 * - On success, zero.
3593 * - On failure, a negative value.
3596 igb_add_5tuple_filter_82576(struct rte_eth_dev *dev,
3597 struct rte_eth_ntuple_filter *ntuple_filter)
3599 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3600 struct e1000_filter_info *filter_info =
3601 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3602 struct e1000_5tuple_filter *filter;
3603 uint32_t ftqf = E1000_FTQF_VF_BP | E1000_FTQF_MASK;
3604 uint32_t spqf, imir, imir_ext = E1000_IMIREXT_SIZE_BP;
3608 filter = rte_zmalloc("e1000_5tuple_filter",
3609 sizeof(struct e1000_5tuple_filter), 0);
3613 ret = ntuple_filter_to_5tuple_82576(ntuple_filter,
3614 &filter->filter_info);
3620 if (igb_5tuple_filter_lookup_82576(&filter_info->fivetuple_list,
3621 &filter->filter_info) != NULL) {
3622 PMD_DRV_LOG(ERR, "filter exists.");
3626 filter->queue = ntuple_filter->queue;
3629 * look for an unused 5tuple filter index,
3630 * and insert the filter to list.
3632 for (i = 0; i < E1000_MAX_FTQF_FILTERS; i++) {
3633 if (!(filter_info->fivetuple_mask & (1 << i))) {
3634 filter_info->fivetuple_mask |= 1 << i;
3636 TAILQ_INSERT_TAIL(&filter_info->fivetuple_list,
3642 if (i >= E1000_MAX_FTQF_FILTERS) {
3643 PMD_DRV_LOG(ERR, "5tuple filters are full.");
3648 ftqf |= filter->filter_info.proto & E1000_FTQF_PROTOCOL_MASK;
3649 if (filter->filter_info.src_ip_mask == 0) /* 0b means compare. */
3650 ftqf &= ~E1000_FTQF_MASK_SOURCE_ADDR_BP;
3651 if (filter->filter_info.dst_ip_mask == 0)
3652 ftqf &= ~E1000_FTQF_MASK_DEST_ADDR_BP;
3653 if (filter->filter_info.src_port_mask == 0)
3654 ftqf &= ~E1000_FTQF_MASK_SOURCE_PORT_BP;
3655 if (filter->filter_info.proto_mask == 0)
3656 ftqf &= ~E1000_FTQF_MASK_PROTO_BP;
3657 ftqf |= (filter->queue << E1000_FTQF_QUEUE_SHIFT) &
3658 E1000_FTQF_QUEUE_MASK;
3659 ftqf |= E1000_FTQF_QUEUE_ENABLE;
3660 E1000_WRITE_REG(hw, E1000_FTQF(i), ftqf);
3661 E1000_WRITE_REG(hw, E1000_DAQF(i), filter->filter_info.dst_ip);
3662 E1000_WRITE_REG(hw, E1000_SAQF(i), filter->filter_info.src_ip);
3664 spqf = filter->filter_info.src_port & E1000_SPQF_SRCPORT;
3665 E1000_WRITE_REG(hw, E1000_SPQF(i), spqf);
3667 imir = (uint32_t)(filter->filter_info.dst_port & E1000_IMIR_DSTPORT);
3668 if (filter->filter_info.dst_port_mask == 1) /* 1b means not compare. */
3669 imir |= E1000_IMIR_PORT_BP;
3671 imir &= ~E1000_IMIR_PORT_BP;
3672 imir |= filter->filter_info.priority << E1000_IMIR_PRIORITY_SHIFT;
3674 /* tcp flags bits setting. */
3675 if (filter->filter_info.tcp_flags & TCP_FLAG_ALL) {
3676 if (filter->filter_info.tcp_flags & TCP_URG_FLAG)
3677 imir_ext |= E1000_IMIREXT_CTRL_URG;
3678 if (filter->filter_info.tcp_flags & TCP_ACK_FLAG)
3679 imir_ext |= E1000_IMIREXT_CTRL_ACK;
3680 if (filter->filter_info.tcp_flags & TCP_PSH_FLAG)
3681 imir_ext |= E1000_IMIREXT_CTRL_PSH;
3682 if (filter->filter_info.tcp_flags & TCP_RST_FLAG)
3683 imir_ext |= E1000_IMIREXT_CTRL_RST;
3684 if (filter->filter_info.tcp_flags & TCP_SYN_FLAG)
3685 imir_ext |= E1000_IMIREXT_CTRL_SYN;
3686 if (filter->filter_info.tcp_flags & TCP_FIN_FLAG)
3687 imir_ext |= E1000_IMIREXT_CTRL_FIN;
3689 imir_ext |= E1000_IMIREXT_CTRL_BP;
3690 E1000_WRITE_REG(hw, E1000_IMIR(i), imir);
3691 E1000_WRITE_REG(hw, E1000_IMIREXT(i), imir_ext);
3696 * igb_remove_5tuple_filter_82576 - remove a 5tuple filter
3699 * dev: Pointer to struct rte_eth_dev.
3700 * ntuple_filter: ponter to the filter that will be removed.
3703 * - On success, zero.
3704 * - On failure, a negative value.
3707 igb_remove_5tuple_filter_82576(struct rte_eth_dev *dev,
3708 struct rte_eth_ntuple_filter *ntuple_filter)
3710 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3711 struct e1000_filter_info *filter_info =
3712 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3713 struct e1000_5tuple_filter_info filter_5tuple;
3714 struct e1000_5tuple_filter *filter;
3717 memset(&filter_5tuple, 0, sizeof(struct e1000_5tuple_filter_info));
3718 ret = ntuple_filter_to_5tuple_82576(ntuple_filter,
3723 filter = igb_5tuple_filter_lookup_82576(&filter_info->fivetuple_list,
3725 if (filter == NULL) {
3726 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3730 filter_info->fivetuple_mask &= ~(1 << filter->index);
3731 TAILQ_REMOVE(&filter_info->fivetuple_list, filter, entries);
3734 E1000_WRITE_REG(hw, E1000_FTQF(filter->index),
3735 E1000_FTQF_VF_BP | E1000_FTQF_MASK);
3736 E1000_WRITE_REG(hw, E1000_DAQF(filter->index), 0);
3737 E1000_WRITE_REG(hw, E1000_SAQF(filter->index), 0);
3738 E1000_WRITE_REG(hw, E1000_SPQF(filter->index), 0);
3739 E1000_WRITE_REG(hw, E1000_IMIR(filter->index), 0);
3740 E1000_WRITE_REG(hw, E1000_IMIREXT(filter->index), 0);
3745 eth_igb_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
3748 struct e1000_hw *hw;
3749 struct rte_eth_dev_info dev_info;
3750 uint32_t frame_size = mtu + (ETHER_HDR_LEN + ETHER_CRC_LEN +
3753 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3755 #ifdef RTE_LIBRTE_82571_SUPPORT
3756 /* XXX: not bigger than max_rx_pktlen */
3757 if (hw->mac.type == e1000_82571)
3760 eth_igb_infos_get(dev, &dev_info);
3762 /* check that mtu is within the allowed range */
3763 if ((mtu < ETHER_MIN_MTU) ||
3764 (frame_size > dev_info.max_rx_pktlen))
3767 /* refuse mtu that requires the support of scattered packets when this
3768 * feature has not been enabled before. */
3769 if (!dev->data->scattered_rx &&
3770 frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)
3773 rctl = E1000_READ_REG(hw, E1000_RCTL);
3775 /* switch to jumbo mode if needed */
3776 if (frame_size > ETHER_MAX_LEN) {
3777 dev->data->dev_conf.rxmode.jumbo_frame = 1;
3778 rctl |= E1000_RCTL_LPE;
3780 dev->data->dev_conf.rxmode.jumbo_frame = 0;
3781 rctl &= ~E1000_RCTL_LPE;
3783 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
3785 /* update max frame size */
3786 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
3788 E1000_WRITE_REG(hw, E1000_RLPML,
3789 dev->data->dev_conf.rxmode.max_rx_pkt_len);
3795 * igb_add_del_ntuple_filter - add or delete a ntuple filter
3798 * dev: Pointer to struct rte_eth_dev.
3799 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
3800 * add: if true, add filter, if false, remove filter
3803 * - On success, zero.
3804 * - On failure, a negative value.
3807 igb_add_del_ntuple_filter(struct rte_eth_dev *dev,
3808 struct rte_eth_ntuple_filter *ntuple_filter,
3811 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3814 switch (ntuple_filter->flags) {
3815 case RTE_5TUPLE_FLAGS:
3816 case (RTE_5TUPLE_FLAGS | RTE_NTUPLE_FLAGS_TCP_FLAG):
3817 if (hw->mac.type != e1000_82576)
3820 ret = igb_add_5tuple_filter_82576(dev,
3823 ret = igb_remove_5tuple_filter_82576(dev,
3826 case RTE_2TUPLE_FLAGS:
3827 case (RTE_2TUPLE_FLAGS | RTE_NTUPLE_FLAGS_TCP_FLAG):
3828 if (hw->mac.type != e1000_82580 && hw->mac.type != e1000_i350)
3831 ret = igb_add_2tuple_filter(dev, ntuple_filter);
3833 ret = igb_remove_2tuple_filter(dev, ntuple_filter);
3844 * igb_get_ntuple_filter - get a ntuple filter
3847 * dev: Pointer to struct rte_eth_dev.
3848 * ntuple_filter: Pointer to struct rte_eth_ntuple_filter
3851 * - On success, zero.
3852 * - On failure, a negative value.
3855 igb_get_ntuple_filter(struct rte_eth_dev *dev,
3856 struct rte_eth_ntuple_filter *ntuple_filter)
3858 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3859 struct e1000_filter_info *filter_info =
3860 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
3861 struct e1000_5tuple_filter_info filter_5tuple;
3862 struct e1000_2tuple_filter_info filter_2tuple;
3863 struct e1000_5tuple_filter *p_5tuple_filter;
3864 struct e1000_2tuple_filter *p_2tuple_filter;
3867 switch (ntuple_filter->flags) {
3868 case RTE_5TUPLE_FLAGS:
3869 case (RTE_5TUPLE_FLAGS | RTE_NTUPLE_FLAGS_TCP_FLAG):
3870 if (hw->mac.type != e1000_82576)
3872 memset(&filter_5tuple,
3874 sizeof(struct e1000_5tuple_filter_info));
3875 ret = ntuple_filter_to_5tuple_82576(ntuple_filter,
3879 p_5tuple_filter = igb_5tuple_filter_lookup_82576(
3880 &filter_info->fivetuple_list,
3882 if (p_5tuple_filter == NULL) {
3883 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3886 ntuple_filter->queue = p_5tuple_filter->queue;
3888 case RTE_2TUPLE_FLAGS:
3889 case (RTE_2TUPLE_FLAGS | RTE_NTUPLE_FLAGS_TCP_FLAG):
3890 if (hw->mac.type != e1000_82580 && hw->mac.type != e1000_i350)
3892 memset(&filter_2tuple,
3894 sizeof(struct e1000_2tuple_filter_info));
3895 ret = ntuple_filter_to_2tuple(ntuple_filter, &filter_2tuple);
3898 p_2tuple_filter = igb_2tuple_filter_lookup(
3899 &filter_info->twotuple_list,
3901 if (p_2tuple_filter == NULL) {
3902 PMD_DRV_LOG(ERR, "filter doesn't exist.");
3905 ntuple_filter->queue = p_2tuple_filter->queue;
3916 * igb_ntuple_filter_handle - Handle operations for ntuple filter.
3917 * @dev: pointer to rte_eth_dev structure
3918 * @filter_op:operation will be taken.
3919 * @arg: a pointer to specific structure corresponding to the filter_op
3922 igb_ntuple_filter_handle(struct rte_eth_dev *dev,
3923 enum rte_filter_op filter_op,
3926 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
3929 MAC_TYPE_FILTER_SUP(hw->mac.type);
3931 if (filter_op == RTE_ETH_FILTER_NOP)
3935 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
3940 switch (filter_op) {
3941 case RTE_ETH_FILTER_ADD:
3942 ret = igb_add_del_ntuple_filter(dev,
3943 (struct rte_eth_ntuple_filter *)arg,
3946 case RTE_ETH_FILTER_DELETE:
3947 ret = igb_add_del_ntuple_filter(dev,
3948 (struct rte_eth_ntuple_filter *)arg,
3951 case RTE_ETH_FILTER_GET:
3952 ret = igb_get_ntuple_filter(dev,
3953 (struct rte_eth_ntuple_filter *)arg);
3956 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
3964 igb_ethertype_filter_lookup(struct e1000_filter_info *filter_info,
3969 for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
3970 if (filter_info->ethertype_filters[i] == ethertype &&
3971 (filter_info->ethertype_mask & (1 << i)))
3978 igb_ethertype_filter_insert(struct e1000_filter_info *filter_info,
3983 for (i = 0; i < E1000_MAX_ETQF_FILTERS; i++) {
3984 if (!(filter_info->ethertype_mask & (1 << i))) {
3985 filter_info->ethertype_mask |= 1 << i;
3986 filter_info->ethertype_filters[i] = ethertype;
3994 igb_ethertype_filter_remove(struct e1000_filter_info *filter_info,
3997 if (idx >= E1000_MAX_ETQF_FILTERS)
3999 filter_info->ethertype_mask &= ~(1 << idx);
4000 filter_info->ethertype_filters[idx] = 0;
4006 igb_add_del_ethertype_filter(struct rte_eth_dev *dev,
4007 struct rte_eth_ethertype_filter *filter,
4010 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4011 struct e1000_filter_info *filter_info =
4012 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
4016 if (filter->ether_type == ETHER_TYPE_IPv4 ||
4017 filter->ether_type == ETHER_TYPE_IPv6) {
4018 PMD_DRV_LOG(ERR, "unsupported ether_type(0x%04x) in"
4019 " ethertype filter.", filter->ether_type);
4023 if (filter->flags & RTE_ETHTYPE_FLAGS_MAC) {
4024 PMD_DRV_LOG(ERR, "mac compare is unsupported.");
4027 if (filter->flags & RTE_ETHTYPE_FLAGS_DROP) {
4028 PMD_DRV_LOG(ERR, "drop option is unsupported.");
4032 ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
4033 if (ret >= 0 && add) {
4034 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter exists.",
4035 filter->ether_type);
4038 if (ret < 0 && !add) {
4039 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
4040 filter->ether_type);
4045 ret = igb_ethertype_filter_insert(filter_info,
4046 filter->ether_type);
4048 PMD_DRV_LOG(ERR, "ethertype filters are full.");
4052 etqf |= E1000_ETQF_FILTER_ENABLE | E1000_ETQF_QUEUE_ENABLE;
4053 etqf |= (uint32_t)(filter->ether_type & E1000_ETQF_ETHERTYPE);
4054 etqf |= filter->queue << E1000_ETQF_QUEUE_SHIFT;
4056 ret = igb_ethertype_filter_remove(filter_info, (uint8_t)ret);
4060 E1000_WRITE_REG(hw, E1000_ETQF(ret), etqf);
4061 E1000_WRITE_FLUSH(hw);
4067 igb_get_ethertype_filter(struct rte_eth_dev *dev,
4068 struct rte_eth_ethertype_filter *filter)
4070 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4071 struct e1000_filter_info *filter_info =
4072 E1000_DEV_PRIVATE_TO_FILTER_INFO(dev->data->dev_private);
4076 ret = igb_ethertype_filter_lookup(filter_info, filter->ether_type);
4078 PMD_DRV_LOG(ERR, "ethertype (0x%04x) filter doesn't exist.",
4079 filter->ether_type);
4083 etqf = E1000_READ_REG(hw, E1000_ETQF(ret));
4084 if (etqf & E1000_ETQF_FILTER_ENABLE) {
4085 filter->ether_type = etqf & E1000_ETQF_ETHERTYPE;
4087 filter->queue = (etqf & E1000_ETQF_QUEUE) >>
4088 E1000_ETQF_QUEUE_SHIFT;
4096 * igb_ethertype_filter_handle - Handle operations for ethertype filter.
4097 * @dev: pointer to rte_eth_dev structure
4098 * @filter_op:operation will be taken.
4099 * @arg: a pointer to specific structure corresponding to the filter_op
4102 igb_ethertype_filter_handle(struct rte_eth_dev *dev,
4103 enum rte_filter_op filter_op,
4106 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4109 MAC_TYPE_FILTER_SUP(hw->mac.type);
4111 if (filter_op == RTE_ETH_FILTER_NOP)
4115 PMD_DRV_LOG(ERR, "arg shouldn't be NULL for operation %u.",
4120 switch (filter_op) {
4121 case RTE_ETH_FILTER_ADD:
4122 ret = igb_add_del_ethertype_filter(dev,
4123 (struct rte_eth_ethertype_filter *)arg,
4126 case RTE_ETH_FILTER_DELETE:
4127 ret = igb_add_del_ethertype_filter(dev,
4128 (struct rte_eth_ethertype_filter *)arg,
4131 case RTE_ETH_FILTER_GET:
4132 ret = igb_get_ethertype_filter(dev,
4133 (struct rte_eth_ethertype_filter *)arg);
4136 PMD_DRV_LOG(ERR, "unsupported operation %u.", filter_op);
4144 eth_igb_filter_ctrl(struct rte_eth_dev *dev,
4145 enum rte_filter_type filter_type,
4146 enum rte_filter_op filter_op,
4151 switch (filter_type) {
4152 case RTE_ETH_FILTER_NTUPLE:
4153 ret = igb_ntuple_filter_handle(dev, filter_op, arg);
4155 case RTE_ETH_FILTER_ETHERTYPE:
4156 ret = igb_ethertype_filter_handle(dev, filter_op, arg);
4158 case RTE_ETH_FILTER_SYN:
4159 ret = eth_igb_syn_filter_handle(dev, filter_op, arg);
4161 case RTE_ETH_FILTER_FLEXIBLE:
4162 ret = eth_igb_flex_filter_handle(dev, filter_op, arg);
4165 PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
4174 eth_igb_set_mc_addr_list(struct rte_eth_dev *dev,
4175 struct ether_addr *mc_addr_set,
4176 uint32_t nb_mc_addr)
4178 struct e1000_hw *hw;
4180 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4181 e1000_update_mc_addr_list(hw, (u8 *)mc_addr_set, nb_mc_addr);
4186 igb_timesync_enable(struct rte_eth_dev *dev)
4188 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4192 /* Enable system time for it isn't on by default. */
4193 tsauxc = E1000_READ_REG(hw, E1000_TSAUXC);
4194 tsauxc &= ~E1000_TSAUXC_DISABLE_SYSTIME;
4195 E1000_WRITE_REG(hw, E1000_TSAUXC, tsauxc);
4197 /* Start incrementing the register used to timestamp PTP packets. */
4198 E1000_WRITE_REG(hw, E1000_TIMINCA, E1000_TIMINCA_INIT);
4200 /* Enable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
4201 E1000_WRITE_REG(hw, E1000_ETQF(E1000_ETQF_FILTER_1588),
4203 E1000_ETQF_FILTER_ENABLE |
4206 /* Enable timestamping of received PTP packets. */
4207 tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
4208 tsync_ctl |= E1000_TSYNCRXCTL_ENABLED;
4209 E1000_WRITE_REG(hw, E1000_TSYNCRXCTL, tsync_ctl);
4211 /* Enable Timestamping of transmitted PTP packets. */
4212 tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
4213 tsync_ctl |= E1000_TSYNCTXCTL_ENABLED;
4214 E1000_WRITE_REG(hw, E1000_TSYNCTXCTL, tsync_ctl);
4220 igb_timesync_disable(struct rte_eth_dev *dev)
4222 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4225 /* Disable timestamping of transmitted PTP packets. */
4226 tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
4227 tsync_ctl &= ~E1000_TSYNCTXCTL_ENABLED;
4228 E1000_WRITE_REG(hw, E1000_TSYNCTXCTL, tsync_ctl);
4230 /* Disable timestamping of received PTP packets. */
4231 tsync_ctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
4232 tsync_ctl &= ~E1000_TSYNCRXCTL_ENABLED;
4233 E1000_WRITE_REG(hw, E1000_TSYNCRXCTL, tsync_ctl);
4235 /* Disable L2 filtering of IEEE1588/802.1AS Ethernet frame types. */
4236 E1000_WRITE_REG(hw, E1000_ETQF(E1000_ETQF_FILTER_1588), 0);
4238 /* Stop incrementating the System Time registers. */
4239 E1000_WRITE_REG(hw, E1000_TIMINCA, 0);
4245 igb_timesync_read_rx_timestamp(struct rte_eth_dev *dev,
4246 struct timespec *timestamp,
4247 uint32_t flags __rte_unused)
4249 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4250 uint32_t tsync_rxctl;
4254 tsync_rxctl = E1000_READ_REG(hw, E1000_TSYNCRXCTL);
4255 if ((tsync_rxctl & E1000_TSYNCRXCTL_VALID) == 0)
4258 rx_stmpl = E1000_READ_REG(hw, E1000_RXSTMPL);
4259 rx_stmph = E1000_READ_REG(hw, E1000_RXSTMPH);
4261 timestamp->tv_sec = (uint64_t)(((uint64_t)rx_stmph << 32) | rx_stmpl);
4262 timestamp->tv_nsec = 0;
4268 igb_timesync_read_tx_timestamp(struct rte_eth_dev *dev,
4269 struct timespec *timestamp)
4271 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4272 uint32_t tsync_txctl;
4276 tsync_txctl = E1000_READ_REG(hw, E1000_TSYNCTXCTL);
4277 if ((tsync_txctl & E1000_TSYNCTXCTL_VALID) == 0)
4280 tx_stmpl = E1000_READ_REG(hw, E1000_TXSTMPL);
4281 tx_stmph = E1000_READ_REG(hw, E1000_TXSTMPH);
4283 timestamp->tv_sec = (uint64_t)(((uint64_t)tx_stmph << 32) | tx_stmpl);
4284 timestamp->tv_nsec = 0;
4290 eth_igb_get_reg_length(struct rte_eth_dev *dev __rte_unused)
4294 const struct reg_info *reg_group;
4296 while ((reg_group = igb_regs[g_ind++]))
4297 count += igb_reg_group_count(reg_group);
4303 igbvf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
4307 const struct reg_info *reg_group;
4309 while ((reg_group = igbvf_regs[g_ind++]))
4310 count += igb_reg_group_count(reg_group);
4316 eth_igb_get_regs(struct rte_eth_dev *dev,
4317 struct rte_dev_reg_info *regs)
4319 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4320 uint32_t *data = regs->data;
4323 const struct reg_info *reg_group;
4325 /* Support only full register dump */
4326 if ((regs->length == 0) ||
4327 (regs->length == (uint32_t)eth_igb_get_reg_length(dev))) {
4328 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
4330 while ((reg_group = igb_regs[g_ind++]))
4331 count += igb_read_regs_group(dev, &data[count],
4340 igbvf_get_regs(struct rte_eth_dev *dev,
4341 struct rte_dev_reg_info *regs)
4343 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4344 uint32_t *data = regs->data;
4347 const struct reg_info *reg_group;
4349 /* Support only full register dump */
4350 if ((regs->length == 0) ||
4351 (regs->length == (uint32_t)igbvf_get_reg_length(dev))) {
4352 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
4354 while ((reg_group = igbvf_regs[g_ind++]))
4355 count += igb_read_regs_group(dev, &data[count],
4364 eth_igb_get_eeprom_length(struct rte_eth_dev *dev)
4366 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4368 /* Return unit is byte count */
4369 return hw->nvm.word_size * 2;
4373 eth_igb_get_eeprom(struct rte_eth_dev *dev,
4374 struct rte_dev_eeprom_info *in_eeprom)
4376 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4377 struct e1000_nvm_info *nvm = &hw->nvm;
4378 uint16_t *data = in_eeprom->data;
4381 first = in_eeprom->offset >> 1;
4382 length = in_eeprom->length >> 1;
4383 if ((first >= hw->nvm.word_size) ||
4384 ((first + length) >= hw->nvm.word_size))
4387 in_eeprom->magic = hw->vendor_id |
4388 ((uint32_t)hw->device_id << 16);
4390 if ((nvm->ops.read) == NULL)
4393 return nvm->ops.read(hw, first, length, data);
4397 eth_igb_set_eeprom(struct rte_eth_dev *dev,
4398 struct rte_dev_eeprom_info *in_eeprom)
4400 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4401 struct e1000_nvm_info *nvm = &hw->nvm;
4402 uint16_t *data = in_eeprom->data;
4405 first = in_eeprom->offset >> 1;
4406 length = in_eeprom->length >> 1;
4407 if ((first >= hw->nvm.word_size) ||
4408 ((first + length) >= hw->nvm.word_size))
4411 in_eeprom->magic = (uint32_t)hw->vendor_id |
4412 ((uint32_t)hw->device_id << 16);
4414 if ((nvm->ops.write) == NULL)
4416 return nvm->ops.write(hw, first, length, data);
4419 static struct rte_driver pmd_igb_drv = {
4421 .init = rte_igb_pmd_init,
4424 static struct rte_driver pmd_igbvf_drv = {
4426 .init = rte_igbvf_pmd_init,
4430 eth_igb_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
4432 struct e1000_hw *hw =
4433 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4434 uint32_t mask = 1 << queue_id;
4436 E1000_WRITE_REG(hw, E1000_EIMC, mask);
4437 E1000_WRITE_FLUSH(hw);
4443 eth_igb_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
4445 struct e1000_hw *hw =
4446 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4447 uint32_t mask = 1 << queue_id;
4450 regval = E1000_READ_REG(hw, E1000_EIMS);
4451 E1000_WRITE_REG(hw, E1000_EIMS, regval | mask);
4452 E1000_WRITE_FLUSH(hw);
4454 rte_intr_enable(&dev->pci_dev->intr_handle);
4460 eth_igb_write_ivar(struct e1000_hw *hw, uint8_t msix_vector,
4461 uint8_t index, uint8_t offset)
4463 uint32_t val = E1000_READ_REG_ARRAY(hw, E1000_IVAR0, index);
4466 val &= ~((uint32_t)0xFF << offset);
4468 /* write vector and valid bit */
4469 val |= (msix_vector | E1000_IVAR_VALID) << offset;
4471 E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, index, val);
4475 eth_igb_assign_msix_vector(struct e1000_hw *hw, int8_t direction,
4476 uint8_t queue, uint8_t msix_vector)
4480 if (hw->mac.type == e1000_82575) {
4482 tmp = E1000_EICR_RX_QUEUE0 << queue;
4483 else if (direction == 1)
4484 tmp = E1000_EICR_TX_QUEUE0 << queue;
4485 E1000_WRITE_REG(hw, E1000_MSIXBM(msix_vector), tmp);
4486 } else if (hw->mac.type == e1000_82576) {
4487 if ((direction == 0) || (direction == 1))
4488 eth_igb_write_ivar(hw, msix_vector, queue & 0x7,
4489 ((queue & 0x8) << 1) +
4491 } else if ((hw->mac.type == e1000_82580) ||
4492 (hw->mac.type == e1000_i350) ||
4493 (hw->mac.type == e1000_i354) ||
4494 (hw->mac.type == e1000_i210) ||
4495 (hw->mac.type == e1000_i211)) {
4496 if ((direction == 0) || (direction == 1))
4497 eth_igb_write_ivar(hw, msix_vector,
4499 ((queue & 0x1) << 4) +
4504 /* Sets up the hardware to generate MSI-X interrupts properly
4506 * board private structure
4509 eth_igb_configure_msix_intr(struct rte_eth_dev *dev)
4512 uint32_t tmpval, regval, intr_mask;
4513 struct e1000_hw *hw =
4514 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
4515 uint32_t vec = E1000_MISC_VEC_ID;
4516 uint32_t base = E1000_MISC_VEC_ID;
4517 uint32_t misc_shift = 0;
4519 struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
4521 /* won't configure msix register if no mapping is done
4522 * between intr vector and event fd
4524 if (!rte_intr_dp_is_en(intr_handle))
4527 if (rte_intr_allow_others(intr_handle)) {
4528 vec = base = E1000_RX_VEC_START;
4532 /* set interrupt vector for other causes */
4533 if (hw->mac.type == e1000_82575) {
4534 tmpval = E1000_READ_REG(hw, E1000_CTRL_EXT);
4535 /* enable MSI-X PBA support */
4536 tmpval |= E1000_CTRL_EXT_PBA_CLR;
4538 /* Auto-Mask interrupts upon ICR read */
4539 tmpval |= E1000_CTRL_EXT_EIAME;
4540 tmpval |= E1000_CTRL_EXT_IRCA;
4542 E1000_WRITE_REG(hw, E1000_CTRL_EXT, tmpval);
4544 /* enable msix_other interrupt */
4545 E1000_WRITE_REG_ARRAY(hw, E1000_MSIXBM(0), 0, E1000_EIMS_OTHER);
4546 regval = E1000_READ_REG(hw, E1000_EIAC);
4547 E1000_WRITE_REG(hw, E1000_EIAC, regval | E1000_EIMS_OTHER);
4548 regval = E1000_READ_REG(hw, E1000_EIAM);
4549 E1000_WRITE_REG(hw, E1000_EIMS, regval | E1000_EIMS_OTHER);
4550 } else if ((hw->mac.type == e1000_82576) ||
4551 (hw->mac.type == e1000_82580) ||
4552 (hw->mac.type == e1000_i350) ||
4553 (hw->mac.type == e1000_i354) ||
4554 (hw->mac.type == e1000_i210) ||
4555 (hw->mac.type == e1000_i211)) {
4556 /* turn on MSI-X capability first */
4557 E1000_WRITE_REG(hw, E1000_GPIE, E1000_GPIE_MSIX_MODE |
4558 E1000_GPIE_PBA | E1000_GPIE_EIAME |
4560 intr_mask = RTE_LEN2MASK(intr_handle->nb_efd, uint32_t) <<
4562 regval = E1000_READ_REG(hw, E1000_EIAC);
4563 E1000_WRITE_REG(hw, E1000_EIAC, regval | intr_mask);
4565 /* enable msix_other interrupt */
4566 regval = E1000_READ_REG(hw, E1000_EIMS);
4567 E1000_WRITE_REG(hw, E1000_EIMS, regval | intr_mask);
4568 tmpval = (dev->data->nb_rx_queues | E1000_IVAR_VALID) << 8;
4569 E1000_WRITE_REG(hw, E1000_IVAR_MISC, tmpval);
4572 /* use EIAM to auto-mask when MSI-X interrupt
4573 * is asserted, this saves a register write for every interrupt
4575 intr_mask = RTE_LEN2MASK(intr_handle->nb_efd, uint32_t) <<
4577 regval = E1000_READ_REG(hw, E1000_EIAM);
4578 E1000_WRITE_REG(hw, E1000_EIAM, regval | intr_mask);
4580 for (queue_id = 0; queue_id < dev->data->nb_rx_queues; queue_id++) {
4581 eth_igb_assign_msix_vector(hw, 0, queue_id, vec);
4582 intr_handle->intr_vec[queue_id] = vec;
4583 if (vec < base + intr_handle->nb_efd - 1)
4587 E1000_WRITE_FLUSH(hw);
4590 PMD_REGISTER_DRIVER(pmd_igb_drv);
4591 PMD_REGISTER_DRIVER(pmd_igbvf_drv);