4 * Copyright(c) 2010-2013 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.
35 #include <sys/queue.h>
41 #include <rte_common.h>
42 #include <rte_interrupts.h>
43 #include <rte_byteorder.h>
45 #include <rte_debug.h>
47 #include <rte_ether.h>
48 #include <rte_ethdev.h>
49 #include <rte_memory.h>
50 #include <rte_memzone.h>
51 #include <rte_tailq.h>
53 #include <rte_atomic.h>
54 #include <rte_malloc.h>
56 #include "e1000_logs.h"
57 #include "e1000/e1000_api.h"
58 #include "e1000_ethdev.h"
60 static int eth_igb_configure(struct rte_eth_dev *dev);
61 static int eth_igb_start(struct rte_eth_dev *dev);
62 static void eth_igb_stop(struct rte_eth_dev *dev);
63 static void eth_igb_close(struct rte_eth_dev *dev);
64 static void eth_igb_promiscuous_enable(struct rte_eth_dev *dev);
65 static void eth_igb_promiscuous_disable(struct rte_eth_dev *dev);
66 static void eth_igb_allmulticast_enable(struct rte_eth_dev *dev);
67 static void eth_igb_allmulticast_disable(struct rte_eth_dev *dev);
68 static int eth_igb_link_update(struct rte_eth_dev *dev,
69 int wait_to_complete);
70 static void eth_igb_stats_get(struct rte_eth_dev *dev,
71 struct rte_eth_stats *rte_stats);
72 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
73 static void eth_igb_infos_get(struct rte_eth_dev *dev,
74 struct rte_eth_dev_info *dev_info);
75 static int eth_igb_flow_ctrl_set(struct rte_eth_dev *dev,
76 struct rte_eth_fc_conf *fc_conf);
77 static int eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev);
78 static int eth_igb_interrupt_get_status(struct rte_eth_dev *dev);
79 static int eth_igb_interrupt_action(struct rte_eth_dev *dev);
80 static void eth_igb_interrupt_handler(struct rte_intr_handle *handle,
82 static int igb_hardware_init(struct e1000_hw *hw);
83 static void igb_hw_control_acquire(struct e1000_hw *hw);
84 static void igb_hw_control_release(struct e1000_hw *hw);
85 static void igb_init_manageability(struct e1000_hw *hw);
86 static void igb_release_manageability(struct e1000_hw *hw);
88 static int eth_igb_vlan_filter_set(struct rte_eth_dev *dev,
89 uint16_t vlan_id, int on);
90 static void eth_igb_vlan_tpid_set(struct rte_eth_dev *dev, uint16_t tpid_id);
91 static void eth_igb_vlan_offload_set(struct rte_eth_dev *dev, int mask);
93 static void igb_vlan_hw_filter_enable(struct rte_eth_dev *dev);
94 static void igb_vlan_hw_filter_disable(struct rte_eth_dev *dev);
95 static void igb_vlan_hw_strip_enable(struct rte_eth_dev *dev);
96 static void igb_vlan_hw_strip_disable(struct rte_eth_dev *dev);
97 static void igb_vlan_hw_extend_enable(struct rte_eth_dev *dev);
98 static void igb_vlan_hw_extend_disable(struct rte_eth_dev *dev);
100 static int eth_igb_led_on(struct rte_eth_dev *dev);
101 static int eth_igb_led_off(struct rte_eth_dev *dev);
103 static void igb_intr_disable(struct e1000_hw *hw);
104 static int igb_get_rx_buffer_size(struct e1000_hw *hw);
105 static void eth_igb_rar_set(struct rte_eth_dev *dev,
106 struct ether_addr *mac_addr,
107 uint32_t index, uint32_t pool);
108 static void eth_igb_rar_clear(struct rte_eth_dev *dev, uint32_t index);
110 static void igbvf_intr_disable(struct e1000_hw *hw);
111 static int igbvf_dev_configure(struct rte_eth_dev *dev);
112 static int igbvf_dev_start(struct rte_eth_dev *dev);
113 static void igbvf_dev_stop(struct rte_eth_dev *dev);
114 static void igbvf_dev_close(struct rte_eth_dev *dev);
115 static int eth_igbvf_link_update(struct e1000_hw *hw);
116 static void eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats);
117 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
118 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
119 uint16_t vlan_id, int on);
120 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on);
121 static void igbvf_set_vfta_all(struct rte_eth_dev *dev, bool on);
122 static int eth_igb_rss_reta_update(struct rte_eth_dev *dev,
123 struct rte_eth_rss_reta *reta_conf);
124 static int eth_igb_rss_reta_query(struct rte_eth_dev *dev,
125 struct rte_eth_rss_reta *reta_conf);
128 * Define VF Stats MACRO for Non "cleared on read" register
130 #define UPDATE_VF_STAT(reg, last, cur) \
132 u32 latest = E1000_READ_REG(hw, reg); \
133 cur += latest - last; \
138 #define IGB_FC_PAUSE_TIME 0x0680
139 #define IGB_LINK_UPDATE_CHECK_TIMEOUT 90 /* 9s */
140 #define IGB_LINK_UPDATE_CHECK_INTERVAL 100 /* ms */
142 #define IGBVF_PMD_NAME "rte_igbvf_pmd" /* PMD name */
144 static enum e1000_fc_mode igb_fc_setting = e1000_fc_full;
147 * The set of PCI devices this driver supports
149 static struct rte_pci_id pci_id_igb_map[] = {
151 #define RTE_PCI_DEV_ID_DECL_IGB(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
152 #include "rte_pci_dev_ids.h"
158 * The set of PCI devices this driver supports (for 82576&I350 VF)
160 static struct rte_pci_id pci_id_igbvf_map[] = {
162 #define RTE_PCI_DEV_ID_DECL_IGBVF(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
163 #include "rte_pci_dev_ids.h"
168 static struct eth_dev_ops eth_igb_ops = {
169 .dev_configure = eth_igb_configure,
170 .dev_start = eth_igb_start,
171 .dev_stop = eth_igb_stop,
172 .dev_close = eth_igb_close,
173 .promiscuous_enable = eth_igb_promiscuous_enable,
174 .promiscuous_disable = eth_igb_promiscuous_disable,
175 .allmulticast_enable = eth_igb_allmulticast_enable,
176 .allmulticast_disable = eth_igb_allmulticast_disable,
177 .link_update = eth_igb_link_update,
178 .stats_get = eth_igb_stats_get,
179 .stats_reset = eth_igb_stats_reset,
180 .dev_infos_get = eth_igb_infos_get,
181 .vlan_filter_set = eth_igb_vlan_filter_set,
182 .vlan_tpid_set = eth_igb_vlan_tpid_set,
183 .vlan_offload_set = eth_igb_vlan_offload_set,
184 .rx_queue_setup = eth_igb_rx_queue_setup,
185 .rx_queue_release = eth_igb_rx_queue_release,
186 .rx_queue_count = eth_igb_rx_queue_count,
187 .rx_descriptor_done = eth_igb_rx_descriptor_done,
188 .tx_queue_setup = eth_igb_tx_queue_setup,
189 .tx_queue_release = eth_igb_tx_queue_release,
190 .dev_led_on = eth_igb_led_on,
191 .dev_led_off = eth_igb_led_off,
192 .flow_ctrl_set = eth_igb_flow_ctrl_set,
193 .mac_addr_add = eth_igb_rar_set,
194 .mac_addr_remove = eth_igb_rar_clear,
195 .reta_update = eth_igb_rss_reta_update,
196 .reta_query = eth_igb_rss_reta_query,
200 * dev_ops for virtual function, bare necessities for basic vf
201 * operation have been implemented
203 static struct eth_dev_ops igbvf_eth_dev_ops = {
204 .dev_configure = igbvf_dev_configure,
205 .dev_start = igbvf_dev_start,
206 .dev_stop = igbvf_dev_stop,
207 .dev_close = igbvf_dev_close,
208 .link_update = eth_igb_link_update,
209 .stats_get = eth_igbvf_stats_get,
210 .stats_reset = eth_igbvf_stats_reset,
211 .vlan_filter_set = igbvf_vlan_filter_set,
212 .dev_infos_get = eth_igb_infos_get,
213 .rx_queue_setup = eth_igb_rx_queue_setup,
214 .rx_queue_release = eth_igb_rx_queue_release,
215 .tx_queue_setup = eth_igb_tx_queue_setup,
216 .tx_queue_release = eth_igb_tx_queue_release,
220 * Atomically reads the link status information from global
221 * structure rte_eth_dev.
224 * - Pointer to the structure rte_eth_dev to read from.
225 * - Pointer to the buffer to be saved with the link status.
228 * - On success, zero.
229 * - On failure, negative value.
232 rte_igb_dev_atomic_read_link_status(struct rte_eth_dev *dev,
233 struct rte_eth_link *link)
235 struct rte_eth_link *dst = link;
236 struct rte_eth_link *src = &(dev->data->dev_link);
238 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
239 *(uint64_t *)src) == 0)
246 * Atomically writes the link status information into global
247 * structure rte_eth_dev.
250 * - Pointer to the structure rte_eth_dev to read from.
251 * - Pointer to the buffer to be saved with the link status.
254 * - On success, zero.
255 * - On failure, negative value.
258 rte_igb_dev_atomic_write_link_status(struct rte_eth_dev *dev,
259 struct rte_eth_link *link)
261 struct rte_eth_link *dst = &(dev->data->dev_link);
262 struct rte_eth_link *src = link;
264 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
265 *(uint64_t *)src) == 0)
272 igb_intr_enable(struct rte_eth_dev *dev)
274 struct e1000_interrupt *intr =
275 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
276 struct e1000_hw *hw =
277 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
279 E1000_WRITE_REG(hw, E1000_IMS, intr->mask);
280 E1000_WRITE_FLUSH(hw);
284 igb_intr_disable(struct e1000_hw *hw)
286 E1000_WRITE_REG(hw, E1000_IMC, ~0);
287 E1000_WRITE_FLUSH(hw);
290 static inline int32_t
291 igb_pf_reset_hw(struct e1000_hw *hw)
296 status = e1000_reset_hw(hw);
298 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
299 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
300 ctrl_ext |= E1000_CTRL_EXT_PFRSTD;
301 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
302 E1000_WRITE_FLUSH(hw);
308 igb_identify_hardware(struct rte_eth_dev *dev)
310 struct e1000_hw *hw =
311 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
313 hw->vendor_id = dev->pci_dev->id.vendor_id;
314 hw->device_id = dev->pci_dev->id.device_id;
315 hw->subsystem_vendor_id = dev->pci_dev->id.subsystem_vendor_id;
316 hw->subsystem_device_id = dev->pci_dev->id.subsystem_device_id;
318 e1000_set_mac_type(hw);
320 /* need to check if it is a vf device below */
324 eth_igb_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
325 struct rte_eth_dev *eth_dev)
328 struct rte_pci_device *pci_dev;
329 struct e1000_hw *hw =
330 E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
331 struct e1000_vfta * shadow_vfta =
332 E1000_DEV_PRIVATE_TO_VFTA(eth_dev->data->dev_private);
335 pci_dev = eth_dev->pci_dev;
336 eth_dev->dev_ops = ð_igb_ops;
337 eth_dev->rx_pkt_burst = ð_igb_recv_pkts;
338 eth_dev->tx_pkt_burst = ð_igb_xmit_pkts;
340 /* for secondary processes, we don't initialise any further as primary
341 * has already done this work. Only check we don't need a different
343 if (rte_eal_process_type() != RTE_PROC_PRIMARY){
344 if (eth_dev->data->scattered_rx)
345 eth_dev->rx_pkt_burst = ð_igb_recv_scattered_pkts;
349 hw->hw_addr= (void *)pci_dev->mem_resource[0].addr;
351 igb_identify_hardware(eth_dev);
352 if (e1000_setup_init_funcs(hw, TRUE) != E1000_SUCCESS) {
357 e1000_get_bus_info(hw);
360 hw->phy.autoneg_wait_to_complete = 0;
361 hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
364 if (hw->phy.media_type == e1000_media_type_copper) {
365 hw->phy.mdix = 0; /* AUTO_ALL_MODES */
366 hw->phy.disable_polarity_correction = 0;
367 hw->phy.ms_type = e1000_ms_hw_default;
371 * Start from a known state, this is important in reading the nvm
376 /* Make sure we have a good EEPROM before we read from it */
377 if (e1000_validate_nvm_checksum(hw) < 0) {
379 * Some PCI-E parts fail the first check due to
380 * the link being in sleep state, call it again,
381 * if it fails a second time its a real issue.
383 if (e1000_validate_nvm_checksum(hw) < 0) {
384 PMD_INIT_LOG(ERR, "EEPROM checksum invalid");
390 /* Read the permanent MAC address out of the EEPROM */
391 if (e1000_read_mac_addr(hw) != 0) {
392 PMD_INIT_LOG(ERR, "EEPROM error while reading MAC address");
397 /* Allocate memory for storing MAC addresses */
398 eth_dev->data->mac_addrs = rte_zmalloc("e1000",
399 ETHER_ADDR_LEN * hw->mac.rar_entry_count, 0);
400 if (eth_dev->data->mac_addrs == NULL) {
401 PMD_INIT_LOG(ERR, "Failed to allocate %d bytes needed to "
402 "store MAC addresses",
403 ETHER_ADDR_LEN * hw->mac.rar_entry_count);
408 /* Copy the permanent MAC address */
409 ether_addr_copy((struct ether_addr *)hw->mac.addr, ð_dev->data->mac_addrs[0]);
411 /* initialize the vfta */
412 memset(shadow_vfta, 0, sizeof(*shadow_vfta));
414 /* Now initialize the hardware */
415 if (igb_hardware_init(hw) != 0) {
416 PMD_INIT_LOG(ERR, "Hardware initialization failed");
417 rte_free(eth_dev->data->mac_addrs);
418 eth_dev->data->mac_addrs = NULL;
422 hw->mac.get_link_status = 1;
424 /* Indicate SOL/IDER usage */
425 if (e1000_check_reset_block(hw) < 0) {
426 PMD_INIT_LOG(ERR, "PHY reset is blocked due to"
430 /* initialize PF if max_vfs not zero */
431 igb_pf_host_init(eth_dev);
433 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
434 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
435 ctrl_ext |= E1000_CTRL_EXT_PFRSTD;
436 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
437 E1000_WRITE_FLUSH(hw);
439 PMD_INIT_LOG(INFO, "port_id %d vendorID=0x%x deviceID=0x%x\n",
440 eth_dev->data->port_id, pci_dev->id.vendor_id,
441 pci_dev->id.device_id);
443 rte_intr_callback_register(&(pci_dev->intr_handle),
444 eth_igb_interrupt_handler, (void *)eth_dev);
446 /* enable uio intr after callback register */
447 rte_intr_enable(&(pci_dev->intr_handle));
449 /* enable support intr */
450 igb_intr_enable(eth_dev);
455 igb_hw_control_release(hw);
461 * Virtual Function device init
464 eth_igbvf_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
465 struct rte_eth_dev *eth_dev)
467 struct rte_pci_device *pci_dev;
468 struct e1000_hw *hw =
469 E1000_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
472 PMD_INIT_LOG(DEBUG, "eth_igbvf_dev_init");
474 eth_dev->dev_ops = &igbvf_eth_dev_ops;
475 pci_dev = eth_dev->pci_dev;
477 hw->device_id = pci_dev->id.device_id;
478 hw->vendor_id = pci_dev->id.vendor_id;
479 hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
481 /* Initialize the shared code */
482 diag = e1000_setup_init_funcs(hw, TRUE);
484 PMD_INIT_LOG(ERR, "Shared code init failed for igbvf: %d",
489 /* init_mailbox_params */
490 hw->mbx.ops.init_params(hw);
492 /* Disable the interrupts for VF */
493 igbvf_intr_disable(hw);
495 diag = hw->mac.ops.reset_hw(hw);
497 /* Allocate memory for storing MAC addresses */
498 eth_dev->data->mac_addrs = rte_zmalloc("igbvf", ETHER_ADDR_LEN *
499 hw->mac.rar_entry_count, 0);
500 if (eth_dev->data->mac_addrs == NULL) {
502 "Failed to allocate %d bytes needed to store MAC "
504 ETHER_ADDR_LEN * hw->mac.rar_entry_count);
508 /* Copy the permanent MAC address */
509 ether_addr_copy((struct ether_addr *) hw->mac.perm_addr,
510 ð_dev->data->mac_addrs[0]);
512 PMD_INIT_LOG(DEBUG, "\nport %d vendorID=0x%x deviceID=0x%x "
514 eth_dev->data->port_id, pci_dev->id.vendor_id,
515 pci_dev->id.device_id,
521 static struct eth_driver rte_igb_pmd = {
523 .name = "rte_igb_pmd",
524 .id_table = pci_id_igb_map,
525 #ifdef RTE_EAL_UNBIND_PORTS
526 .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
529 .eth_dev_init = eth_igb_dev_init,
530 .dev_private_size = sizeof(struct e1000_adapter),
534 * virtual function driver struct
536 static struct eth_driver rte_igbvf_pmd = {
538 .name = "rte_igbvf_pmd",
539 .id_table = pci_id_igbvf_map,
540 #ifdef RTE_EAL_UNBIND_PORTS
541 .drv_flags = RTE_PCI_DRV_NEED_IGB_UIO,
544 .eth_dev_init = eth_igbvf_dev_init,
545 .dev_private_size = sizeof(struct e1000_adapter),
549 rte_igb_pmd_init(void)
551 rte_eth_driver_register(&rte_igb_pmd);
556 * VF Driver initialization routine.
557 * Invoked one at EAL init time.
558 * Register itself as the [Virtual Poll Mode] Driver of PCI IGB devices.
561 rte_igbvf_pmd_init(void)
563 DEBUGFUNC("rte_igbvf_pmd_init");
565 rte_eth_driver_register(&rte_igbvf_pmd);
570 eth_igb_configure(struct rte_eth_dev *dev)
572 struct e1000_interrupt *intr =
573 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
575 PMD_INIT_LOG(DEBUG, ">>");
577 intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
579 PMD_INIT_LOG(DEBUG, "<<");
585 eth_igb_start(struct rte_eth_dev *dev)
587 struct e1000_hw *hw =
588 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
592 PMD_INIT_LOG(DEBUG, ">>");
594 /* Power up the phy. Needed to make the link go Up */
595 e1000_power_up_phy(hw);
598 * Packet Buffer Allocation (PBA)
599 * Writing PBA sets the receive portion of the buffer
600 * the remainder is used for the transmit buffer.
602 if (hw->mac.type == e1000_82575) {
605 pba = E1000_PBA_32K; /* 32K for Rx, 16K for Tx */
606 E1000_WRITE_REG(hw, E1000_PBA, pba);
609 /* Put the address into the Receive Address Array */
610 e1000_rar_set(hw, hw->mac.addr, 0);
612 /* Initialize the hardware */
613 if (igb_hardware_init(hw)) {
614 PMD_INIT_LOG(ERR, "Unable to initialize the hardware");
618 E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN);
620 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
621 /* Set PF Reset Done bit so PF/VF Mail Ops can work */
622 ctrl_ext |= E1000_CTRL_EXT_PFRSTD;
623 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext);
624 E1000_WRITE_FLUSH(hw);
626 /* configure PF module if SRIOV enabled */
627 igb_pf_host_configure(dev);
629 /* Configure for OS presence */
630 igb_init_manageability(hw);
632 eth_igb_tx_init(dev);
634 /* This can fail when allocating mbufs for descriptor rings */
635 ret = eth_igb_rx_init(dev);
637 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
638 igb_dev_clear_queues(dev);
642 e1000_clear_hw_cntrs_base_generic(hw);
645 * VLAN Offload Settings
647 mask = ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK | \
648 ETH_VLAN_EXTEND_MASK;
649 eth_igb_vlan_offload_set(dev, mask);
652 * Configure the Interrupt Moderation register (EITR) with the maximum
653 * possible value (0xFFFF) to minimize "System Partial Write" issued by
654 * spurious [DMA] memory updates of RX and TX ring descriptors.
656 * With a EITR granularity of 2 microseconds in the 82576, only 7/8
657 * spurious memory updates per second should be expected.
658 * ((65535 * 2) / 1000.1000 ~= 0.131 second).
660 * Because interrupts are not used at all, the MSI-X is not activated
661 * and interrupt moderation is controlled by EITR[0].
663 * Note that having [almost] disabled memory updates of RX and TX ring
664 * descriptors through the Interrupt Moderation mechanism, memory
665 * updates of ring descriptors are now moderated by the configurable
666 * value of Write-Back Threshold registers.
668 if ((hw->mac.type == e1000_82576) || (hw->mac.type == e1000_82580) ||
669 (hw->mac.type == e1000_i350) || (hw->mac.type == e1000_i210)) {
672 /* Enable all RX & TX queues in the IVAR registers */
673 ivar = (uint32_t) ((E1000_IVAR_VALID << 16) | E1000_IVAR_VALID);
674 for (i = 0; i < 8; i++)
675 E1000_WRITE_REG_ARRAY(hw, E1000_IVAR0, i, ivar);
677 /* Configure EITR with the maximum possible value (0xFFFF) */
678 E1000_WRITE_REG(hw, E1000_EITR(0), 0xFFFF);
681 /* Setup link speed and duplex */
682 switch (dev->data->dev_conf.link_speed) {
683 case ETH_LINK_SPEED_AUTONEG:
684 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
685 hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
686 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
687 hw->phy.autoneg_advertised = E1000_ALL_HALF_DUPLEX;
688 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
689 hw->phy.autoneg_advertised = E1000_ALL_FULL_DUPLEX;
691 goto error_invalid_config;
693 case ETH_LINK_SPEED_10:
694 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
695 hw->phy.autoneg_advertised = E1000_ALL_10_SPEED;
696 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
697 hw->phy.autoneg_advertised = ADVERTISE_10_HALF;
698 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
699 hw->phy.autoneg_advertised = ADVERTISE_10_FULL;
701 goto error_invalid_config;
703 case ETH_LINK_SPEED_100:
704 if (dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX)
705 hw->phy.autoneg_advertised = E1000_ALL_100_SPEED;
706 else if (dev->data->dev_conf.link_duplex == ETH_LINK_HALF_DUPLEX)
707 hw->phy.autoneg_advertised = ADVERTISE_100_HALF;
708 else if (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX)
709 hw->phy.autoneg_advertised = ADVERTISE_100_FULL;
711 goto error_invalid_config;
713 case ETH_LINK_SPEED_1000:
714 if ((dev->data->dev_conf.link_duplex == ETH_LINK_AUTONEG_DUPLEX) ||
715 (dev->data->dev_conf.link_duplex == ETH_LINK_FULL_DUPLEX))
716 hw->phy.autoneg_advertised = ADVERTISE_1000_FULL;
718 goto error_invalid_config;
720 case ETH_LINK_SPEED_10000:
722 goto error_invalid_config;
724 e1000_setup_link(hw);
726 /* check if lsc interrupt feature is enabled */
727 if (dev->data->dev_conf.intr_conf.lsc != 0)
728 ret = eth_igb_lsc_interrupt_setup(dev);
730 /* resume enabled intr since hw reset */
731 igb_intr_enable(dev);
733 PMD_INIT_LOG(DEBUG, "<<");
737 error_invalid_config:
738 PMD_INIT_LOG(ERR, "Invalid link_speed/link_duplex (%u/%u) for port %u\n",
739 dev->data->dev_conf.link_speed,
740 dev->data->dev_conf.link_duplex, dev->data->port_id);
741 igb_dev_clear_queues(dev);
745 /*********************************************************************
747 * This routine disables all traffic on the adapter by issuing a
748 * global reset on the MAC.
750 **********************************************************************/
752 eth_igb_stop(struct rte_eth_dev *dev)
754 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
755 struct rte_eth_link link;
757 igb_intr_disable(hw);
759 E1000_WRITE_REG(hw, E1000_WUC, 0);
761 /* Set bit for Go Link disconnect */
762 if (hw->mac.type >= e1000_82580) {
765 phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
766 phpm_reg |= E1000_82580_PM_GO_LINKD;
767 E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
770 /* Power down the phy. Needed to make the link go Down */
771 e1000_power_down_phy(hw);
773 igb_dev_clear_queues(dev);
775 /* clear the recorded link status */
776 memset(&link, 0, sizeof(link));
777 rte_igb_dev_atomic_write_link_status(dev, &link);
781 eth_igb_close(struct rte_eth_dev *dev)
783 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
784 struct rte_eth_link link;
787 e1000_phy_hw_reset(hw);
788 igb_release_manageability(hw);
789 igb_hw_control_release(hw);
791 /* Clear bit for Go Link disconnect */
792 if (hw->mac.type >= e1000_82580) {
795 phpm_reg = E1000_READ_REG(hw, E1000_82580_PHY_POWER_MGMT);
796 phpm_reg &= ~E1000_82580_PM_GO_LINKD;
797 E1000_WRITE_REG(hw, E1000_82580_PHY_POWER_MGMT, phpm_reg);
800 igb_dev_clear_queues(dev);
802 memset(&link, 0, sizeof(link));
803 rte_igb_dev_atomic_write_link_status(dev, &link);
807 igb_get_rx_buffer_size(struct e1000_hw *hw)
809 uint32_t rx_buf_size;
810 if (hw->mac.type == e1000_82576) {
811 rx_buf_size = (E1000_READ_REG(hw, E1000_RXPBS) & 0xffff) << 10;
812 } else if (hw->mac.type == e1000_82580 || hw->mac.type == e1000_i350) {
813 /* PBS needs to be translated according to a lookup table */
814 rx_buf_size = (E1000_READ_REG(hw, E1000_RXPBS) & 0xf);
815 rx_buf_size = (uint32_t) e1000_rxpbs_adjust_82580(rx_buf_size);
816 rx_buf_size = (rx_buf_size << 10);
817 } else if (hw->mac.type == e1000_i210) {
818 rx_buf_size = (E1000_READ_REG(hw, E1000_RXPBS) & 0x3f) << 10;
820 rx_buf_size = (E1000_READ_REG(hw, E1000_PBA) & 0xffff) << 10;
826 /*********************************************************************
828 * Initialize the hardware
830 **********************************************************************/
832 igb_hardware_init(struct e1000_hw *hw)
834 uint32_t rx_buf_size;
837 /* Let the firmware know the OS is in control */
838 igb_hw_control_acquire(hw);
841 * These parameters control the automatic generation (Tx) and
842 * response (Rx) to Ethernet PAUSE frames.
843 * - High water mark should allow for at least two standard size (1518)
844 * frames to be received after sending an XOFF.
845 * - Low water mark works best when it is very near the high water mark.
846 * This allows the receiver to restart by sending XON when it has
847 * drained a bit. Here we use an arbitary value of 1500 which will
848 * restart after one full frame is pulled from the buffer. There
849 * could be several smaller frames in the buffer and if so they will
850 * not trigger the XON until their total number reduces the buffer
852 * - The pause time is fairly large at 1000 x 512ns = 512 usec.
854 rx_buf_size = igb_get_rx_buffer_size(hw);
856 hw->fc.high_water = rx_buf_size - (ETHER_MAX_LEN * 2);
857 hw->fc.low_water = hw->fc.high_water - 1500;
858 hw->fc.pause_time = IGB_FC_PAUSE_TIME;
861 /* Set Flow control, use the tunable location if sane */
862 if ((igb_fc_setting != e1000_fc_none) && (igb_fc_setting < 4))
863 hw->fc.requested_mode = igb_fc_setting;
865 hw->fc.requested_mode = e1000_fc_none;
867 /* Issue a global reset */
869 E1000_WRITE_REG(hw, E1000_WUC, 0);
871 diag = e1000_init_hw(hw);
875 E1000_WRITE_REG(hw, E1000_VET, ETHER_TYPE_VLAN);
876 e1000_get_phy_info(hw);
877 e1000_check_for_link(hw);
882 /* This function is based on igb_update_stats_counters() in igb/if_igb.c */
884 eth_igb_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
886 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
887 struct e1000_hw_stats *stats =
888 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
891 if(hw->phy.media_type == e1000_media_type_copper ||
892 (E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU)) {
894 E1000_READ_REG(hw,E1000_SYMERRS);
895 stats->sec += E1000_READ_REG(hw, E1000_SEC);
898 stats->crcerrs += E1000_READ_REG(hw, E1000_CRCERRS);
899 stats->mpc += E1000_READ_REG(hw, E1000_MPC);
900 stats->scc += E1000_READ_REG(hw, E1000_SCC);
901 stats->ecol += E1000_READ_REG(hw, E1000_ECOL);
903 stats->mcc += E1000_READ_REG(hw, E1000_MCC);
904 stats->latecol += E1000_READ_REG(hw, E1000_LATECOL);
905 stats->colc += E1000_READ_REG(hw, E1000_COLC);
906 stats->dc += E1000_READ_REG(hw, E1000_DC);
907 stats->rlec += E1000_READ_REG(hw, E1000_RLEC);
908 stats->xonrxc += E1000_READ_REG(hw, E1000_XONRXC);
909 stats->xontxc += E1000_READ_REG(hw, E1000_XONTXC);
911 ** For watchdog management we need to know if we have been
912 ** paused during the last interval, so capture that here.
914 pause_frames = E1000_READ_REG(hw, E1000_XOFFRXC);
915 stats->xoffrxc += pause_frames;
916 stats->xofftxc += E1000_READ_REG(hw, E1000_XOFFTXC);
917 stats->fcruc += E1000_READ_REG(hw, E1000_FCRUC);
918 stats->prc64 += E1000_READ_REG(hw, E1000_PRC64);
919 stats->prc127 += E1000_READ_REG(hw, E1000_PRC127);
920 stats->prc255 += E1000_READ_REG(hw, E1000_PRC255);
921 stats->prc511 += E1000_READ_REG(hw, E1000_PRC511);
922 stats->prc1023 += E1000_READ_REG(hw, E1000_PRC1023);
923 stats->prc1522 += E1000_READ_REG(hw, E1000_PRC1522);
924 stats->gprc += E1000_READ_REG(hw, E1000_GPRC);
925 stats->bprc += E1000_READ_REG(hw, E1000_BPRC);
926 stats->mprc += E1000_READ_REG(hw, E1000_MPRC);
927 stats->gptc += E1000_READ_REG(hw, E1000_GPTC);
929 /* For the 64-bit byte counters the low dword must be read first. */
930 /* Both registers clear on the read of the high dword */
932 stats->gorc += E1000_READ_REG(hw, E1000_GORCL);
933 stats->gorc += ((uint64_t)E1000_READ_REG(hw, E1000_GORCH) << 32);
934 stats->gotc += E1000_READ_REG(hw, E1000_GOTCL);
935 stats->gotc += ((uint64_t)E1000_READ_REG(hw, E1000_GOTCH) << 32);
937 stats->rnbc += E1000_READ_REG(hw, E1000_RNBC);
938 stats->ruc += E1000_READ_REG(hw, E1000_RUC);
939 stats->rfc += E1000_READ_REG(hw, E1000_RFC);
940 stats->roc += E1000_READ_REG(hw, E1000_ROC);
941 stats->rjc += E1000_READ_REG(hw, E1000_RJC);
943 stats->tor += E1000_READ_REG(hw, E1000_TORH);
944 stats->tot += E1000_READ_REG(hw, E1000_TOTH);
946 stats->tpr += E1000_READ_REG(hw, E1000_TPR);
947 stats->tpt += E1000_READ_REG(hw, E1000_TPT);
948 stats->ptc64 += E1000_READ_REG(hw, E1000_PTC64);
949 stats->ptc127 += E1000_READ_REG(hw, E1000_PTC127);
950 stats->ptc255 += E1000_READ_REG(hw, E1000_PTC255);
951 stats->ptc511 += E1000_READ_REG(hw, E1000_PTC511);
952 stats->ptc1023 += E1000_READ_REG(hw, E1000_PTC1023);
953 stats->ptc1522 += E1000_READ_REG(hw, E1000_PTC1522);
954 stats->mptc += E1000_READ_REG(hw, E1000_MPTC);
955 stats->bptc += E1000_READ_REG(hw, E1000_BPTC);
957 /* Interrupt Counts */
959 stats->iac += E1000_READ_REG(hw, E1000_IAC);
960 stats->icrxptc += E1000_READ_REG(hw, E1000_ICRXPTC);
961 stats->icrxatc += E1000_READ_REG(hw, E1000_ICRXATC);
962 stats->ictxptc += E1000_READ_REG(hw, E1000_ICTXPTC);
963 stats->ictxatc += E1000_READ_REG(hw, E1000_ICTXATC);
964 stats->ictxqec += E1000_READ_REG(hw, E1000_ICTXQEC);
965 stats->ictxqmtc += E1000_READ_REG(hw, E1000_ICTXQMTC);
966 stats->icrxdmtc += E1000_READ_REG(hw, E1000_ICRXDMTC);
967 stats->icrxoc += E1000_READ_REG(hw, E1000_ICRXOC);
969 /* Host to Card Statistics */
971 stats->cbtmpc += E1000_READ_REG(hw, E1000_CBTMPC);
972 stats->htdpmc += E1000_READ_REG(hw, E1000_HTDPMC);
973 stats->cbrdpc += E1000_READ_REG(hw, E1000_CBRDPC);
974 stats->cbrmpc += E1000_READ_REG(hw, E1000_CBRMPC);
975 stats->rpthc += E1000_READ_REG(hw, E1000_RPTHC);
976 stats->hgptc += E1000_READ_REG(hw, E1000_HGPTC);
977 stats->htcbdpc += E1000_READ_REG(hw, E1000_HTCBDPC);
978 stats->hgorc += E1000_READ_REG(hw, E1000_HGORCL);
979 stats->hgorc += ((uint64_t)E1000_READ_REG(hw, E1000_HGORCH) << 32);
980 stats->hgotc += E1000_READ_REG(hw, E1000_HGOTCL);
981 stats->hgotc += ((uint64_t)E1000_READ_REG(hw, E1000_HGOTCH) << 32);
982 stats->lenerrs += E1000_READ_REG(hw, E1000_LENERRS);
983 stats->scvpc += E1000_READ_REG(hw, E1000_SCVPC);
984 stats->hrmpc += E1000_READ_REG(hw, E1000_HRMPC);
986 stats->algnerrc += E1000_READ_REG(hw, E1000_ALGNERRC);
987 stats->rxerrc += E1000_READ_REG(hw, E1000_RXERRC);
988 stats->tncrs += E1000_READ_REG(hw, E1000_TNCRS);
989 stats->cexterr += E1000_READ_REG(hw, E1000_CEXTERR);
990 stats->tsctc += E1000_READ_REG(hw, E1000_TSCTC);
991 stats->tsctfc += E1000_READ_REG(hw, E1000_TSCTFC);
993 if (rte_stats == NULL)
997 rte_stats->ierrors = stats->rxerrc + stats->crcerrs + stats->algnerrc +
998 stats->ruc + stats->roc + stats->mpc + stats->cexterr;
1001 rte_stats->oerrors = stats->ecol + stats->latecol;
1003 rte_stats->ipackets = stats->gprc;
1004 rte_stats->opackets = stats->gptc;
1005 rte_stats->ibytes = stats->gorc;
1006 rte_stats->obytes = stats->gotc;
1010 eth_igb_stats_reset(struct rte_eth_dev *dev)
1012 struct e1000_hw_stats *hw_stats =
1013 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1015 /* HW registers are cleared on read */
1016 eth_igb_stats_get(dev, NULL);
1018 /* Reset software totals */
1019 memset(hw_stats, 0, sizeof(*hw_stats));
1023 eth_igbvf_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *rte_stats)
1025 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1026 struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats*)
1027 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1029 /* Good Rx packets, include VF loopback */
1030 UPDATE_VF_STAT(E1000_VFGPRC,
1031 hw_stats->last_gprc, hw_stats->gprc);
1033 /* Good Rx octets, include VF loopback */
1034 UPDATE_VF_STAT(E1000_VFGORC,
1035 hw_stats->last_gorc, hw_stats->gorc);
1037 /* Good Tx packets, include VF loopback */
1038 UPDATE_VF_STAT(E1000_VFGPTC,
1039 hw_stats->last_gptc, hw_stats->gptc);
1041 /* Good Tx octets, include VF loopback */
1042 UPDATE_VF_STAT(E1000_VFGOTC,
1043 hw_stats->last_gotc, hw_stats->gotc);
1045 /* Rx Multicst packets */
1046 UPDATE_VF_STAT(E1000_VFMPRC,
1047 hw_stats->last_mprc, hw_stats->mprc);
1049 /* Good Rx loopback packets */
1050 UPDATE_VF_STAT(E1000_VFGPRLBC,
1051 hw_stats->last_gprlbc, hw_stats->gprlbc);
1053 /* Good Rx loopback octets */
1054 UPDATE_VF_STAT(E1000_VFGORLBC,
1055 hw_stats->last_gorlbc, hw_stats->gorlbc);
1057 /* Good Tx loopback packets */
1058 UPDATE_VF_STAT(E1000_VFGPTLBC,
1059 hw_stats->last_gptlbc, hw_stats->gptlbc);
1061 /* Good Tx loopback octets */
1062 UPDATE_VF_STAT(E1000_VFGOTLBC,
1063 hw_stats->last_gotlbc, hw_stats->gotlbc);
1065 if (rte_stats == NULL)
1068 memset(rte_stats, 0, sizeof(*rte_stats));
1069 rte_stats->ipackets = hw_stats->gprc;
1070 rte_stats->ibytes = hw_stats->gorc;
1071 rte_stats->opackets = hw_stats->gptc;
1072 rte_stats->obytes = hw_stats->gotc;
1073 rte_stats->imcasts = hw_stats->mprc;
1074 rte_stats->ilbpackets = hw_stats->gprlbc;
1075 rte_stats->ilbbytes = hw_stats->gorlbc;
1076 rte_stats->olbpackets = hw_stats->gptlbc;
1077 rte_stats->olbbytes = hw_stats->gotlbc;
1082 eth_igbvf_stats_reset(struct rte_eth_dev *dev)
1084 struct e1000_vf_stats *hw_stats = (struct e1000_vf_stats*)
1085 E1000_DEV_PRIVATE_TO_STATS(dev->data->dev_private);
1087 /* Sync HW register to the last stats */
1088 eth_igbvf_stats_get(dev, NULL);
1090 /* reset HW current stats*/
1091 memset(&hw_stats->gprc, 0, sizeof(*hw_stats) -
1092 offsetof(struct e1000_vf_stats, gprc));
1097 eth_igb_infos_get(struct rte_eth_dev *dev,
1098 struct rte_eth_dev_info *dev_info)
1100 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1102 dev_info->min_rx_bufsize = 256; /* See BSIZE field of RCTL register. */
1103 dev_info->max_rx_pktlen = 0x3FFF; /* See RLPML register. */
1104 dev_info->max_mac_addrs = hw->mac.rar_entry_count;
1106 switch (hw->mac.type) {
1108 dev_info->max_rx_queues = 4;
1109 dev_info->max_tx_queues = 4;
1113 dev_info->max_rx_queues = 16;
1114 dev_info->max_tx_queues = 16;
1118 dev_info->max_rx_queues = 8;
1119 dev_info->max_tx_queues = 8;
1123 dev_info->max_rx_queues = 8;
1124 dev_info->max_tx_queues = 8;
1128 dev_info->max_rx_queues = 4;
1129 dev_info->max_tx_queues = 4;
1133 dev_info->max_rx_queues = 2;
1134 dev_info->max_tx_queues = 2;
1137 case e1000_vfadapt_i350:
1138 dev_info->max_rx_queues = 1;
1139 dev_info->max_tx_queues = 1;
1143 /* Should not happen */
1144 dev_info->max_rx_queues = 0;
1145 dev_info->max_tx_queues = 0;
1149 /* return 0 means link status changed, -1 means not changed */
1151 eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete)
1153 struct e1000_hw *hw =
1154 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1155 struct rte_eth_link link, old;
1156 int link_check, count;
1159 hw->mac.get_link_status = 1;
1161 /* possible wait-to-complete in up to 9 seconds */
1162 for (count = 0; count < IGB_LINK_UPDATE_CHECK_TIMEOUT; count ++) {
1163 /* Read the real link status */
1164 switch (hw->phy.media_type) {
1165 case e1000_media_type_copper:
1166 /* Do the work to read phy */
1167 e1000_check_for_link(hw);
1168 link_check = !hw->mac.get_link_status;
1171 case e1000_media_type_fiber:
1172 e1000_check_for_link(hw);
1173 link_check = (E1000_READ_REG(hw, E1000_STATUS) &
1177 case e1000_media_type_internal_serdes:
1178 e1000_check_for_link(hw);
1179 link_check = hw->mac.serdes_has_link;
1182 /* VF device is type_unknown */
1183 case e1000_media_type_unknown:
1184 eth_igbvf_link_update(hw);
1185 link_check = !hw->mac.get_link_status;
1191 if (link_check || wait_to_complete == 0)
1193 rte_delay_ms(IGB_LINK_UPDATE_CHECK_INTERVAL);
1195 memset(&link, 0, sizeof(link));
1196 rte_igb_dev_atomic_read_link_status(dev, &link);
1199 /* Now we check if a transition has happened */
1201 hw->mac.ops.get_link_up_info(hw, &link.link_speed,
1203 link.link_status = 1;
1204 } else if (!link_check) {
1205 link.link_speed = 0;
1206 link.link_duplex = 0;
1207 link.link_status = 0;
1209 rte_igb_dev_atomic_write_link_status(dev, &link);
1212 if (old.link_status == link.link_status)
1220 * igb_hw_control_acquire sets CTRL_EXT:DRV_LOAD bit.
1221 * For ASF and Pass Through versions of f/w this means
1222 * that the driver is loaded.
1225 igb_hw_control_acquire(struct e1000_hw *hw)
1229 /* Let firmware know the driver has taken over */
1230 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
1231 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext | E1000_CTRL_EXT_DRV_LOAD);
1235 * igb_hw_control_release resets CTRL_EXT:DRV_LOAD bit.
1236 * For ASF and Pass Through versions of f/w this means that the
1237 * driver is no longer loaded.
1240 igb_hw_control_release(struct e1000_hw *hw)
1244 /* Let firmware taken over control of h/w */
1245 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT);
1246 E1000_WRITE_REG(hw, E1000_CTRL_EXT,
1247 ctrl_ext & ~E1000_CTRL_EXT_DRV_LOAD);
1251 * Bit of a misnomer, what this really means is
1252 * to enable OS management of the system... aka
1253 * to disable special hardware management features.
1256 igb_init_manageability(struct e1000_hw *hw)
1258 if (e1000_enable_mng_pass_thru(hw)) {
1259 uint32_t manc2h = E1000_READ_REG(hw, E1000_MANC2H);
1260 uint32_t manc = E1000_READ_REG(hw, E1000_MANC);
1262 /* disable hardware interception of ARP */
1263 manc &= ~(E1000_MANC_ARP_EN);
1265 /* enable receiving management packets to the host */
1266 manc |= E1000_MANC_EN_MNG2HOST;
1267 manc2h |= 1 << 5; /* Mng Port 623 */
1268 manc2h |= 1 << 6; /* Mng Port 664 */
1269 E1000_WRITE_REG(hw, E1000_MANC2H, manc2h);
1270 E1000_WRITE_REG(hw, E1000_MANC, manc);
1275 igb_release_manageability(struct e1000_hw *hw)
1277 if (e1000_enable_mng_pass_thru(hw)) {
1278 uint32_t manc = E1000_READ_REG(hw, E1000_MANC);
1280 manc |= E1000_MANC_ARP_EN;
1281 manc &= ~E1000_MANC_EN_MNG2HOST;
1283 E1000_WRITE_REG(hw, E1000_MANC, manc);
1288 eth_igb_promiscuous_enable(struct rte_eth_dev *dev)
1290 struct e1000_hw *hw =
1291 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1294 rctl = E1000_READ_REG(hw, E1000_RCTL);
1295 rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
1296 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1300 eth_igb_promiscuous_disable(struct rte_eth_dev *dev)
1302 struct e1000_hw *hw =
1303 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1306 rctl = E1000_READ_REG(hw, E1000_RCTL);
1307 rctl &= (~E1000_RCTL_UPE);
1308 if (dev->data->all_multicast == 1)
1309 rctl |= E1000_RCTL_MPE;
1311 rctl &= (~E1000_RCTL_MPE);
1312 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1316 eth_igb_allmulticast_enable(struct rte_eth_dev *dev)
1318 struct e1000_hw *hw =
1319 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1322 rctl = E1000_READ_REG(hw, E1000_RCTL);
1323 rctl |= E1000_RCTL_MPE;
1324 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1328 eth_igb_allmulticast_disable(struct rte_eth_dev *dev)
1330 struct e1000_hw *hw =
1331 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1334 if (dev->data->promiscuous == 1)
1335 return; /* must remain in all_multicast mode */
1336 rctl = E1000_READ_REG(hw, E1000_RCTL);
1337 rctl &= (~E1000_RCTL_MPE);
1338 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1342 eth_igb_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1344 struct e1000_hw *hw =
1345 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1346 struct e1000_vfta * shadow_vfta =
1347 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1352 vid_idx = (uint32_t) ((vlan_id >> E1000_VFTA_ENTRY_SHIFT) &
1353 E1000_VFTA_ENTRY_MASK);
1354 vid_bit = (uint32_t) (1 << (vlan_id & E1000_VFTA_ENTRY_BIT_SHIFT_MASK));
1355 vfta = E1000_READ_REG_ARRAY(hw, E1000_VFTA, vid_idx);
1360 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, vid_idx, vfta);
1362 /* update local VFTA copy */
1363 shadow_vfta->vfta[vid_idx] = vfta;
1369 eth_igb_vlan_tpid_set(struct rte_eth_dev *dev, uint16_t tpid)
1371 struct e1000_hw *hw =
1372 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1373 uint32_t reg = ETHER_TYPE_VLAN ;
1375 reg |= (tpid << 16);
1376 E1000_WRITE_REG(hw, E1000_VET, reg);
1380 igb_vlan_hw_filter_disable(struct rte_eth_dev *dev)
1382 struct e1000_hw *hw =
1383 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1386 /* Filter Table Disable */
1387 reg = E1000_READ_REG(hw, E1000_RCTL);
1388 reg &= ~E1000_RCTL_CFIEN;
1389 reg &= ~E1000_RCTL_VFE;
1390 E1000_WRITE_REG(hw, E1000_RCTL, reg);
1394 igb_vlan_hw_filter_enable(struct rte_eth_dev *dev)
1396 struct e1000_hw *hw =
1397 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1398 struct e1000_vfta * shadow_vfta =
1399 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1403 /* Filter Table Enable, CFI not used for packet acceptance */
1404 reg = E1000_READ_REG(hw, E1000_RCTL);
1405 reg &= ~E1000_RCTL_CFIEN;
1406 reg |= E1000_RCTL_VFE;
1407 E1000_WRITE_REG(hw, E1000_RCTL, reg);
1409 /* restore VFTA table */
1410 for (i = 0; i < IGB_VFTA_SIZE; i++)
1411 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, i, shadow_vfta->vfta[i]);
1415 igb_vlan_hw_strip_disable(struct rte_eth_dev *dev)
1417 struct e1000_hw *hw =
1418 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1421 /* VLAN Mode Disable */
1422 reg = E1000_READ_REG(hw, E1000_CTRL);
1423 reg &= ~E1000_CTRL_VME;
1424 E1000_WRITE_REG(hw, E1000_CTRL, reg);
1428 igb_vlan_hw_strip_enable(struct rte_eth_dev *dev)
1430 struct e1000_hw *hw =
1431 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1434 /* VLAN Mode Enable */
1435 reg = E1000_READ_REG(hw, E1000_CTRL);
1436 reg |= E1000_CTRL_VME;
1437 E1000_WRITE_REG(hw, E1000_CTRL, reg);
1441 igb_vlan_hw_extend_disable(struct rte_eth_dev *dev)
1443 struct e1000_hw *hw =
1444 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1447 /* CTRL_EXT: Extended VLAN */
1448 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1449 reg &= ~E1000_CTRL_EXT_EXTEND_VLAN;
1450 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1452 /* Update maximum packet length */
1453 if (dev->data->dev_conf.rxmode.jumbo_frame == 1)
1454 E1000_WRITE_REG(hw, E1000_RLPML,
1455 dev->data->dev_conf.rxmode.max_rx_pkt_len +
1460 igb_vlan_hw_extend_enable(struct rte_eth_dev *dev)
1462 struct e1000_hw *hw =
1463 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1466 /* CTRL_EXT: Extended VLAN */
1467 reg = E1000_READ_REG(hw, E1000_CTRL_EXT);
1468 reg |= E1000_CTRL_EXT_EXTEND_VLAN;
1469 E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg);
1471 /* Update maximum packet length */
1472 if (dev->data->dev_conf.rxmode.jumbo_frame == 1)
1473 E1000_WRITE_REG(hw, E1000_RLPML,
1474 dev->data->dev_conf.rxmode.max_rx_pkt_len +
1479 eth_igb_vlan_offload_set(struct rte_eth_dev *dev, int mask)
1481 if(mask & ETH_VLAN_STRIP_MASK){
1482 if (dev->data->dev_conf.rxmode.hw_vlan_strip)
1483 igb_vlan_hw_strip_enable(dev);
1485 igb_vlan_hw_strip_disable(dev);
1488 if(mask & ETH_VLAN_FILTER_MASK){
1489 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
1490 igb_vlan_hw_filter_enable(dev);
1492 igb_vlan_hw_filter_disable(dev);
1495 if(mask & ETH_VLAN_EXTEND_MASK){
1496 if (dev->data->dev_conf.rxmode.hw_vlan_extend)
1497 igb_vlan_hw_extend_enable(dev);
1499 igb_vlan_hw_extend_disable(dev);
1505 * It enables the interrupt mask and then enable the interrupt.
1508 * Pointer to struct rte_eth_dev.
1511 * - On success, zero.
1512 * - On failure, a negative value.
1515 eth_igb_lsc_interrupt_setup(struct rte_eth_dev *dev)
1517 struct e1000_interrupt *intr =
1518 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
1520 intr->mask |= E1000_ICR_LSC;
1526 * It reads ICR and gets interrupt causes, check it and set a bit flag
1527 * to update link status.
1530 * Pointer to struct rte_eth_dev.
1533 * - On success, zero.
1534 * - On failure, a negative value.
1537 eth_igb_interrupt_get_status(struct rte_eth_dev *dev)
1540 struct e1000_hw *hw =
1541 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1542 struct e1000_interrupt *intr =
1543 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
1545 igb_intr_disable(hw);
1547 /* read-on-clear nic registers here */
1548 icr = E1000_READ_REG(hw, E1000_ICR);
1551 if (icr & E1000_ICR_LSC) {
1552 intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
1555 if (icr & E1000_ICR_VMMB)
1556 intr->flags |= E1000_FLAG_MAILBOX;
1562 * It executes link_update after knowing an interrupt is prsent.
1565 * Pointer to struct rte_eth_dev.
1568 * - On success, zero.
1569 * - On failure, a negative value.
1572 eth_igb_interrupt_action(struct rte_eth_dev *dev)
1574 struct e1000_hw *hw =
1575 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1576 struct e1000_interrupt *intr =
1577 E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
1578 uint32_t tctl, rctl;
1579 struct rte_eth_link link;
1582 if (intr->flags & E1000_FLAG_MAILBOX) {
1583 igb_pf_mbx_process(dev);
1584 intr->flags &= ~E1000_FLAG_MAILBOX;
1587 igb_intr_enable(dev);
1588 rte_intr_enable(&(dev->pci_dev->intr_handle));
1590 if (intr->flags & E1000_FLAG_NEED_LINK_UPDATE) {
1591 intr->flags &= ~E1000_FLAG_NEED_LINK_UPDATE;
1593 /* set get_link_status to check register later */
1594 hw->mac.get_link_status = 1;
1595 ret = eth_igb_link_update(dev, 0);
1597 /* check if link has changed */
1601 memset(&link, 0, sizeof(link));
1602 rte_igb_dev_atomic_read_link_status(dev, &link);
1603 if (link.link_status) {
1605 " Port %d: Link Up - speed %u Mbps - %s\n",
1606 dev->data->port_id, (unsigned)link.link_speed,
1607 link.link_duplex == ETH_LINK_FULL_DUPLEX ?
1608 "full-duplex" : "half-duplex");
1610 PMD_INIT_LOG(INFO, " Port %d: Link Down\n",
1611 dev->data->port_id);
1613 PMD_INIT_LOG(INFO, "PCI Address: %04d:%02d:%02d:%d",
1614 dev->pci_dev->addr.domain,
1615 dev->pci_dev->addr.bus,
1616 dev->pci_dev->addr.devid,
1617 dev->pci_dev->addr.function);
1618 tctl = E1000_READ_REG(hw, E1000_TCTL);
1619 rctl = E1000_READ_REG(hw, E1000_RCTL);
1620 if (link.link_status) {
1622 tctl |= E1000_TCTL_EN;
1623 rctl |= E1000_RCTL_EN;
1626 tctl &= ~E1000_TCTL_EN;
1627 rctl &= ~E1000_RCTL_EN;
1629 E1000_WRITE_REG(hw, E1000_TCTL, tctl);
1630 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
1631 E1000_WRITE_FLUSH(hw);
1632 _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC);
1639 * Interrupt handler which shall be registered at first.
1642 * Pointer to interrupt handle.
1644 * The address of parameter (struct rte_eth_dev *) regsitered before.
1650 eth_igb_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
1653 struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
1655 eth_igb_interrupt_get_status(dev);
1656 eth_igb_interrupt_action(dev);
1660 eth_igb_led_on(struct rte_eth_dev *dev)
1662 struct e1000_hw *hw;
1664 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1665 return (e1000_led_on(hw) == E1000_SUCCESS ? 0 : -ENOTSUP);
1669 eth_igb_led_off(struct rte_eth_dev *dev)
1671 struct e1000_hw *hw;
1673 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1674 return (e1000_led_off(hw) == E1000_SUCCESS ? 0 : -ENOTSUP);
1678 eth_igb_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
1680 struct e1000_hw *hw;
1682 enum e1000_fc_mode rte_fcmode_2_e1000_fcmode[] = {
1688 uint32_t rx_buf_size;
1689 uint32_t max_high_water;
1691 hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1692 rx_buf_size = igb_get_rx_buffer_size(hw);
1693 PMD_INIT_LOG(DEBUG, "Rx packet buffer size = 0x%x \n", rx_buf_size);
1695 /* At least reserve one Ethernet frame for watermark */
1696 max_high_water = rx_buf_size - ETHER_MAX_LEN;
1697 if ((fc_conf->high_water > max_high_water) ||
1698 (fc_conf->high_water < fc_conf->low_water)) {
1699 PMD_INIT_LOG(ERR, "e1000 incorrect high/low water value \n");
1700 PMD_INIT_LOG(ERR, "high water must <= 0x%x \n", max_high_water);
1704 hw->fc.requested_mode = rte_fcmode_2_e1000_fcmode[fc_conf->mode];
1705 hw->fc.pause_time = fc_conf->pause_time;
1706 hw->fc.high_water = fc_conf->high_water;
1707 hw->fc.low_water = fc_conf->low_water;
1708 hw->fc.send_xon = fc_conf->send_xon;
1710 err = e1000_setup_link_generic(hw);
1711 if (err == E1000_SUCCESS) {
1715 PMD_INIT_LOG(ERR, "e1000_setup_link_generic = 0x%x \n", err);
1719 #define E1000_RAH_POOLSEL_SHIFT (18)
1721 eth_igb_rar_set(struct rte_eth_dev *dev, struct ether_addr *mac_addr,
1722 uint32_t index, __rte_unused uint32_t pool)
1724 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1727 e1000_rar_set(hw, mac_addr->addr_bytes, index);
1728 rah = E1000_READ_REG(hw, E1000_RAH(index));
1729 rah |= (0x1 << (E1000_RAH_POOLSEL_SHIFT + pool));
1730 E1000_WRITE_REG(hw, E1000_RAH(index), rah);
1734 eth_igb_rar_clear(struct rte_eth_dev *dev, uint32_t index)
1736 uint8_t addr[ETHER_ADDR_LEN];
1737 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1739 memset(addr, 0, sizeof(addr));
1741 e1000_rar_set(hw, addr, index);
1745 * Virtual Function operations
1748 igbvf_intr_disable(struct e1000_hw *hw)
1750 PMD_INIT_LOG(DEBUG, "igbvf_intr_disable");
1752 /* Clear interrupt mask to stop from interrupts being generated */
1753 E1000_WRITE_REG(hw, E1000_EIMC, 0xFFFF);
1755 E1000_WRITE_FLUSH(hw);
1759 igbvf_stop_adapter(struct rte_eth_dev *dev)
1763 struct rte_eth_dev_info dev_info;
1764 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1766 memset(&dev_info, 0, sizeof(dev_info));
1767 eth_igb_infos_get(dev, &dev_info);
1769 /* Clear interrupt mask to stop from interrupts being generated */
1770 igbvf_intr_disable(hw);
1772 /* Clear any pending interrupts, flush previous writes */
1773 E1000_READ_REG(hw, E1000_EICR);
1775 /* Disable the transmit unit. Each queue must be disabled. */
1776 for (i = 0; i < dev_info.max_tx_queues; i++)
1777 E1000_WRITE_REG(hw, E1000_TXDCTL(i), E1000_TXDCTL_SWFLSH);
1779 /* Disable the receive unit by stopping each queue */
1780 for (i = 0; i < dev_info.max_rx_queues; i++) {
1781 reg_val = E1000_READ_REG(hw, E1000_RXDCTL(i));
1782 reg_val &= ~E1000_RXDCTL_QUEUE_ENABLE;
1783 E1000_WRITE_REG(hw, E1000_RXDCTL(i), reg_val);
1784 while (E1000_READ_REG(hw, E1000_RXDCTL(i)) & E1000_RXDCTL_QUEUE_ENABLE)
1788 /* flush all queues disables */
1789 E1000_WRITE_FLUSH(hw);
1793 static int eth_igbvf_link_update(struct e1000_hw *hw)
1795 struct e1000_mbx_info *mbx = &hw->mbx;
1796 struct e1000_mac_info *mac = &hw->mac;
1797 int ret_val = E1000_SUCCESS;
1799 PMD_INIT_LOG(DEBUG, "e1000_check_for_link_vf");
1802 * We only want to run this if there has been a rst asserted.
1803 * in this case that could mean a link change, device reset,
1804 * or a virtual function reset
1807 /* If we were hit with a reset or timeout drop the link */
1808 if (!e1000_check_for_rst(hw, 0) || !mbx->timeout)
1809 mac->get_link_status = TRUE;
1811 if (!mac->get_link_status)
1814 /* if link status is down no point in checking to see if pf is up */
1815 if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
1818 /* if we passed all the tests above then the link is up and we no
1819 * longer need to check for link */
1820 mac->get_link_status = FALSE;
1828 igbvf_dev_configure(struct rte_eth_dev *dev)
1830 struct rte_eth_conf* conf = &dev->data->dev_conf;
1832 PMD_INIT_LOG(DEBUG, "\nConfigured Virtual Function port id: %d\n",
1833 dev->data->port_id);
1836 * VF has no ability to enable/disable HW CRC
1837 * Keep the persistent behavior the same as Host PF
1839 #ifndef RTE_LIBRTE_E1000_PF_DISABLE_STRIP_CRC
1840 if (!conf->rxmode.hw_strip_crc) {
1841 PMD_INIT_LOG(INFO, "VF can't disable HW CRC Strip\n");
1842 conf->rxmode.hw_strip_crc = 1;
1845 if (conf->rxmode.hw_strip_crc) {
1846 PMD_INIT_LOG(INFO, "VF can't enable HW CRC Strip\n");
1847 conf->rxmode.hw_strip_crc = 0;
1855 igbvf_dev_start(struct rte_eth_dev *dev)
1857 struct e1000_hw *hw =
1858 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1861 PMD_INIT_LOG(DEBUG, "igbvf_dev_start");
1863 hw->mac.ops.reset_hw(hw);
1866 igbvf_set_vfta_all(dev,1);
1868 eth_igbvf_tx_init(dev);
1870 /* This can fail when allocating mbufs for descriptor rings */
1871 ret = eth_igbvf_rx_init(dev);
1873 PMD_INIT_LOG(ERR, "Unable to initialize RX hardware");
1874 igb_dev_clear_queues(dev);
1882 igbvf_dev_stop(struct rte_eth_dev *dev)
1884 PMD_INIT_LOG(DEBUG, "igbvf_dev_stop");
1886 igbvf_stop_adapter(dev);
1889 * Clear what we set, but we still keep shadow_vfta to
1890 * restore after device starts
1892 igbvf_set_vfta_all(dev,0);
1894 igb_dev_clear_queues(dev);
1898 igbvf_dev_close(struct rte_eth_dev *dev)
1900 struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1902 PMD_INIT_LOG(DEBUG, "igbvf_dev_close");
1906 igbvf_dev_stop(dev);
1909 static int igbvf_set_vfta(struct e1000_hw *hw, uint16_t vid, bool on)
1911 struct e1000_mbx_info *mbx = &hw->mbx;
1914 /* After set vlan, vlan strip will also be enabled in igb driver*/
1915 msgbuf[0] = E1000_VF_SET_VLAN;
1917 /* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
1919 msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
1921 return (mbx->ops.write_posted(hw, msgbuf, 2, 0));
1924 static void igbvf_set_vfta_all(struct rte_eth_dev *dev, bool on)
1926 struct e1000_hw *hw =
1927 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1928 struct e1000_vfta * shadow_vfta =
1929 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1930 int i = 0, j = 0, vfta = 0, mask = 1;
1932 for (i = 0; i < IGB_VFTA_SIZE; i++){
1933 vfta = shadow_vfta->vfta[i];
1936 for (j = 0; j < 32; j++){
1939 (uint16_t)((i<<5)+j), on);
1948 igbvf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
1950 struct e1000_hw *hw =
1951 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1952 struct e1000_vfta * shadow_vfta =
1953 E1000_DEV_PRIVATE_TO_VFTA(dev->data->dev_private);
1954 uint32_t vid_idx = 0;
1955 uint32_t vid_bit = 0;
1958 PMD_INIT_LOG(DEBUG, "igbvf_vlan_filter_set");
1960 /*vind is not used in VF driver, set to 0, check ixgbe_set_vfta_vf*/
1961 ret = igbvf_set_vfta(hw, vlan_id, !!on);
1963 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
1966 vid_idx = (uint32_t) ((vlan_id >> 5) & 0x7F);
1967 vid_bit = (uint32_t) (1 << (vlan_id & 0x1F));
1969 /*Save what we set and retore it after device reset*/
1971 shadow_vfta->vfta[vid_idx] |= vid_bit;
1973 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
1979 eth_igb_rss_reta_update(struct rte_eth_dev *dev,
1980 struct rte_eth_rss_reta *reta_conf)
1984 struct e1000_hw *hw =
1985 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
1988 * Update Redirection Table RETA[n],n=0...31,The redirection table has
1989 * 128-entries in 32 registers
1991 for(i = 0; i < ETH_RSS_RETA_NUM_ENTRIES; i += 4) {
1992 if (i < ETH_RSS_RETA_NUM_ENTRIES/2)
1993 mask = (uint8_t)((reta_conf->mask_lo >> i) & 0xF);
1995 mask = (uint8_t)((reta_conf->mask_hi >>
1996 (i - ETH_RSS_RETA_NUM_ENTRIES/2)) & 0xF);
1999 /* If all 4 entries were set,don't need read RETA register */
2001 reta = E1000_READ_REG(hw,E1000_RETA(i >> 2));
2003 for (j = 0; j < 4; j++) {
2004 if (mask & (0x1 << j)) {
2006 reta &= ~(0xFF << 8 * j);
2007 reta |= reta_conf->reta[i + j] << 8 * j;
2010 E1000_WRITE_REG(hw, E1000_RETA(i >> 2),reta);
2018 eth_igb_rss_reta_query(struct rte_eth_dev *dev,
2019 struct rte_eth_rss_reta *reta_conf)
2023 struct e1000_hw *hw =
2024 E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
2027 * Read Redirection Table RETA[n],n=0...31,The redirection table has
2028 * 128-entries in 32 registers
2030 for(i = 0; i < ETH_RSS_RETA_NUM_ENTRIES; i += 4) {
2031 if (i < ETH_RSS_RETA_NUM_ENTRIES/2)
2032 mask = (uint8_t)((reta_conf->mask_lo >> i) & 0xF);
2034 mask = (uint8_t)((reta_conf->mask_hi >>
2035 (i - ETH_RSS_RETA_NUM_ENTRIES/2)) & 0xF);
2038 reta = E1000_READ_REG(hw,E1000_RETA(i >> 2));
2039 for (j = 0; j < 4; j++) {
2040 if (mask & (0x1 << j))
2041 reta_conf->reta[i + j] =
2042 (uint8_t)((reta >> 8 * j) & 0xFF);