Lines Matching refs:adapter
83 static void igbvf_receive_skb(struct igbvf_adapter *adapter, in igbvf_receive_skb() argument
91 if ((adapter->flags & IGBVF_FLAG_RX_LB_VLAN_BSWAP) && in igbvf_receive_skb()
96 if (test_bit(vid, adapter->active_vlans)) in igbvf_receive_skb()
100 napi_gro_receive(&adapter->rx_ring->napi, skb); in igbvf_receive_skb()
103 static inline void igbvf_rx_checksum_adv(struct igbvf_adapter *adapter, in igbvf_rx_checksum_adv() argument
110 (adapter->flags & IGBVF_FLAG_RX_CSUM_DISABLED)) in igbvf_rx_checksum_adv()
117 adapter->hw_csum_err++; in igbvf_rx_checksum_adv()
125 adapter->hw_csum_good++; in igbvf_rx_checksum_adv()
136 struct igbvf_adapter *adapter = rx_ring->adapter; in igbvf_alloc_rx_buffers() local
137 struct net_device *netdev = adapter->netdev; in igbvf_alloc_rx_buffers()
138 struct pci_dev *pdev = adapter->pdev; in igbvf_alloc_rx_buffers()
148 if (adapter->rx_ps_hdr_size) in igbvf_alloc_rx_buffers()
149 bufsz = adapter->rx_ps_hdr_size; in igbvf_alloc_rx_buffers()
151 bufsz = adapter->rx_buffer_len; in igbvf_alloc_rx_buffers()
156 if (adapter->rx_ps_hdr_size && !buffer_info->page_dma) { in igbvf_alloc_rx_buffers()
160 adapter->alloc_rx_buff_failed++; in igbvf_alloc_rx_buffers()
184 adapter->alloc_rx_buff_failed++; in igbvf_alloc_rx_buffers()
202 if (adapter->rx_ps_hdr_size) { in igbvf_alloc_rx_buffers()
231 writel(i, adapter->hw.hw_addr + rx_ring->tail); in igbvf_alloc_rx_buffers()
244 static bool igbvf_clean_rx_irq(struct igbvf_adapter *adapter, in igbvf_clean_rx_irq() argument
247 struct igbvf_ring *rx_ring = adapter->rx_ring; in igbvf_clean_rx_irq()
248 struct net_device *netdev = adapter->netdev; in igbvf_clean_rx_irq()
249 struct pci_dev *pdev = adapter->pdev; in igbvf_clean_rx_irq()
278 if (hlen > adapter->rx_ps_hdr_size) in igbvf_clean_rx_irq()
279 hlen = adapter->rx_ps_hdr_size; in igbvf_clean_rx_irq()
288 if (!adapter->rx_ps_hdr_size) { in igbvf_clean_rx_irq()
290 adapter->rx_buffer_len, in igbvf_clean_rx_irq()
299 adapter->rx_ps_hdr_size, in igbvf_clean_rx_irq()
316 if ((adapter->rx_buffer_len > (PAGE_SIZE / 2)) || in igbvf_clean_rx_irq()
350 igbvf_rx_checksum_adv(adapter, staterr, skb); in igbvf_clean_rx_irq()
354 igbvf_receive_skb(adapter, netdev, skb, staterr, in igbvf_clean_rx_irq()
379 adapter->total_rx_packets += total_packets; in igbvf_clean_rx_irq()
380 adapter->total_rx_bytes += total_bytes; in igbvf_clean_rx_irq()
386 static void igbvf_put_txbuf(struct igbvf_adapter *adapter, in igbvf_put_txbuf() argument
391 dma_unmap_page(&adapter->pdev->dev, in igbvf_put_txbuf()
396 dma_unmap_single(&adapter->pdev->dev, in igbvf_put_txbuf()
416 int igbvf_setup_tx_resources(struct igbvf_adapter *adapter, in igbvf_setup_tx_resources() argument
419 struct pci_dev *pdev = adapter->pdev; in igbvf_setup_tx_resources()
436 tx_ring->adapter = adapter; in igbvf_setup_tx_resources()
443 dev_err(&adapter->pdev->dev, in igbvf_setup_tx_resources()
455 int igbvf_setup_rx_resources(struct igbvf_adapter *adapter, in igbvf_setup_rx_resources() argument
458 struct pci_dev *pdev = adapter->pdev; in igbvf_setup_rx_resources()
480 rx_ring->adapter = adapter; in igbvf_setup_rx_resources()
487 dev_err(&adapter->pdev->dev, in igbvf_setup_rx_resources()
498 struct igbvf_adapter *adapter = tx_ring->adapter; in igbvf_clean_tx_ring() local
509 igbvf_put_txbuf(adapter, buffer_info); in igbvf_clean_tx_ring()
521 writel(0, adapter->hw.hw_addr + tx_ring->head); in igbvf_clean_tx_ring()
522 writel(0, adapter->hw.hw_addr + tx_ring->tail); in igbvf_clean_tx_ring()
533 struct pci_dev *pdev = tx_ring->adapter->pdev; in igbvf_free_tx_resources()
552 struct igbvf_adapter *adapter = rx_ring->adapter; in igbvf_clean_rx_ring() local
554 struct pci_dev *pdev = adapter->pdev; in igbvf_clean_rx_ring()
565 if (adapter->rx_ps_hdr_size) { in igbvf_clean_rx_ring()
567 adapter->rx_ps_hdr_size, in igbvf_clean_rx_ring()
571 adapter->rx_buffer_len, in igbvf_clean_rx_ring()
604 writel(0, adapter->hw.hw_addr + rx_ring->head); in igbvf_clean_rx_ring()
605 writel(0, adapter->hw.hw_addr + rx_ring->tail); in igbvf_clean_rx_ring()
617 struct pci_dev *pdev = rx_ring->adapter->pdev; in igbvf_free_rx_resources()
643 static enum latency_range igbvf_update_itr(struct igbvf_adapter *adapter, in igbvf_update_itr() argument
713 static void igbvf_set_itr(struct igbvf_adapter *adapter) in igbvf_set_itr() argument
717 adapter->tx_ring->itr_range = in igbvf_set_itr()
718 igbvf_update_itr(adapter, in igbvf_set_itr()
719 adapter->tx_ring->itr_val, in igbvf_set_itr()
720 adapter->total_tx_packets, in igbvf_set_itr()
721 adapter->total_tx_bytes); in igbvf_set_itr()
724 if (adapter->requested_itr == 3 && in igbvf_set_itr()
725 adapter->tx_ring->itr_range == lowest_latency) in igbvf_set_itr()
726 adapter->tx_ring->itr_range = low_latency; in igbvf_set_itr()
728 new_itr = igbvf_range_to_itr(adapter->tx_ring->itr_range); in igbvf_set_itr()
730 if (new_itr != adapter->tx_ring->itr_val) { in igbvf_set_itr()
731 u32 current_itr = adapter->tx_ring->itr_val; in igbvf_set_itr()
739 adapter->tx_ring->itr_val = new_itr; in igbvf_set_itr()
741 adapter->tx_ring->set_itr = 1; in igbvf_set_itr()
744 adapter->rx_ring->itr_range = in igbvf_set_itr()
745 igbvf_update_itr(adapter, adapter->rx_ring->itr_val, in igbvf_set_itr()
746 adapter->total_rx_packets, in igbvf_set_itr()
747 adapter->total_rx_bytes); in igbvf_set_itr()
748 if (adapter->requested_itr == 3 && in igbvf_set_itr()
749 adapter->rx_ring->itr_range == lowest_latency) in igbvf_set_itr()
750 adapter->rx_ring->itr_range = low_latency; in igbvf_set_itr()
752 new_itr = igbvf_range_to_itr(adapter->rx_ring->itr_range); in igbvf_set_itr()
754 if (new_itr != adapter->rx_ring->itr_val) { in igbvf_set_itr()
755 u32 current_itr = adapter->rx_ring->itr_val; in igbvf_set_itr()
760 adapter->rx_ring->itr_val = new_itr; in igbvf_set_itr()
762 adapter->rx_ring->set_itr = 1; in igbvf_set_itr()
774 struct igbvf_adapter *adapter = tx_ring->adapter; in igbvf_clean_tx_irq() local
775 struct net_device *netdev = adapter->netdev; in igbvf_clean_tx_irq()
819 igbvf_put_txbuf(adapter, buffer_info); in igbvf_clean_tx_irq()
841 !(test_bit(__IGBVF_DOWN, &adapter->state))) { in igbvf_clean_tx_irq()
843 ++adapter->restart_queue; in igbvf_clean_tx_irq()
855 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_msix_other() local
856 struct e1000_hw *hw = &adapter->hw; in igbvf_msix_other()
858 adapter->int_counter1++; in igbvf_msix_other()
861 if (!test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_msix_other()
862 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igbvf_msix_other()
864 ew32(EIMS, adapter->eims_other); in igbvf_msix_other()
872 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_intr_msix_tx() local
873 struct e1000_hw *hw = &adapter->hw; in igbvf_intr_msix_tx()
874 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_intr_msix_tx()
878 adapter->hw.hw_addr + tx_ring->itr_register); in igbvf_intr_msix_tx()
879 adapter->tx_ring->set_itr = 0; in igbvf_intr_msix_tx()
882 adapter->total_tx_bytes = 0; in igbvf_intr_msix_tx()
883 adapter->total_tx_packets = 0; in igbvf_intr_msix_tx()
900 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_intr_msix_rx() local
902 adapter->int_counter0++; in igbvf_intr_msix_rx()
907 if (adapter->rx_ring->set_itr) { in igbvf_intr_msix_rx()
908 writel(adapter->rx_ring->itr_val, in igbvf_intr_msix_rx()
909 adapter->hw.hw_addr + adapter->rx_ring->itr_register); in igbvf_intr_msix_rx()
910 adapter->rx_ring->set_itr = 0; in igbvf_intr_msix_rx()
913 if (napi_schedule_prep(&adapter->rx_ring->napi)) { in igbvf_intr_msix_rx()
914 adapter->total_rx_bytes = 0; in igbvf_intr_msix_rx()
915 adapter->total_rx_packets = 0; in igbvf_intr_msix_rx()
916 __napi_schedule(&adapter->rx_ring->napi); in igbvf_intr_msix_rx()
924 static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue, in igbvf_assign_vector() argument
927 struct e1000_hw *hw = &adapter->hw; in igbvf_assign_vector()
947 adapter->rx_ring[rx_queue].eims_value = BIT(msix_vector); in igbvf_assign_vector()
962 adapter->tx_ring[tx_queue].eims_value = BIT(msix_vector); in igbvf_assign_vector()
974 static void igbvf_configure_msix(struct igbvf_adapter *adapter) in igbvf_configure_msix() argument
977 struct e1000_hw *hw = &adapter->hw; in igbvf_configure_msix()
978 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_configure_msix()
979 struct igbvf_ring *rx_ring = adapter->rx_ring; in igbvf_configure_msix()
982 adapter->eims_enable_mask = 0; in igbvf_configure_msix()
984 igbvf_assign_vector(adapter, IGBVF_NO_QUEUE, 0, vector++); in igbvf_configure_msix()
985 adapter->eims_enable_mask |= tx_ring->eims_value; in igbvf_configure_msix()
987 igbvf_assign_vector(adapter, 0, IGBVF_NO_QUEUE, vector++); in igbvf_configure_msix()
988 adapter->eims_enable_mask |= rx_ring->eims_value; in igbvf_configure_msix()
997 adapter->eims_enable_mask = GENMASK(vector - 1, 0); in igbvf_configure_msix()
998 adapter->eims_other = BIT(vector - 1); in igbvf_configure_msix()
1002 static void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter) in igbvf_reset_interrupt_capability() argument
1004 if (adapter->msix_entries) { in igbvf_reset_interrupt_capability()
1005 pci_disable_msix(adapter->pdev); in igbvf_reset_interrupt_capability()
1006 kfree(adapter->msix_entries); in igbvf_reset_interrupt_capability()
1007 adapter->msix_entries = NULL; in igbvf_reset_interrupt_capability()
1018 static void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter) in igbvf_set_interrupt_capability() argument
1024 adapter->msix_entries = kcalloc(3, sizeof(struct msix_entry), in igbvf_set_interrupt_capability()
1026 if (adapter->msix_entries) { in igbvf_set_interrupt_capability()
1028 adapter->msix_entries[i].entry = i; in igbvf_set_interrupt_capability()
1030 err = pci_enable_msix_range(adapter->pdev, in igbvf_set_interrupt_capability()
1031 adapter->msix_entries, 3, 3); in igbvf_set_interrupt_capability()
1036 dev_err(&adapter->pdev->dev, in igbvf_set_interrupt_capability()
1038 igbvf_reset_interrupt_capability(adapter); in igbvf_set_interrupt_capability()
1049 static int igbvf_request_msix(struct igbvf_adapter *adapter) in igbvf_request_msix() argument
1051 struct net_device *netdev = adapter->netdev; in igbvf_request_msix()
1055 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name); in igbvf_request_msix()
1056 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name); in igbvf_request_msix()
1058 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ); in igbvf_request_msix()
1059 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ); in igbvf_request_msix()
1062 err = request_irq(adapter->msix_entries[vector].vector, in igbvf_request_msix()
1063 igbvf_intr_msix_tx, 0, adapter->tx_ring->name, in igbvf_request_msix()
1068 adapter->tx_ring->itr_register = E1000_EITR(vector); in igbvf_request_msix()
1069 adapter->tx_ring->itr_val = adapter->current_itr; in igbvf_request_msix()
1072 err = request_irq(adapter->msix_entries[vector].vector, in igbvf_request_msix()
1073 igbvf_intr_msix_rx, 0, adapter->rx_ring->name, in igbvf_request_msix()
1078 adapter->rx_ring->itr_register = E1000_EITR(vector); in igbvf_request_msix()
1079 adapter->rx_ring->itr_val = adapter->current_itr; in igbvf_request_msix()
1082 err = request_irq(adapter->msix_entries[vector].vector, in igbvf_request_msix()
1087 igbvf_configure_msix(adapter); in igbvf_request_msix()
1090 free_irq(adapter->msix_entries[--vector].vector, netdev); in igbvf_request_msix()
1092 free_irq(adapter->msix_entries[--vector].vector, netdev); in igbvf_request_msix()
1101 static int igbvf_alloc_queues(struct igbvf_adapter *adapter) in igbvf_alloc_queues() argument
1103 struct net_device *netdev = adapter->netdev; in igbvf_alloc_queues()
1105 adapter->tx_ring = kzalloc(sizeof(struct igbvf_ring), GFP_KERNEL); in igbvf_alloc_queues()
1106 if (!adapter->tx_ring) in igbvf_alloc_queues()
1109 adapter->rx_ring = kzalloc(sizeof(struct igbvf_ring), GFP_KERNEL); in igbvf_alloc_queues()
1110 if (!adapter->rx_ring) { in igbvf_alloc_queues()
1111 kfree(adapter->tx_ring); in igbvf_alloc_queues()
1115 netif_napi_add(netdev, &adapter->rx_ring->napi, igbvf_poll); in igbvf_alloc_queues()
1127 static int igbvf_request_irq(struct igbvf_adapter *adapter) in igbvf_request_irq() argument
1132 if (adapter->msix_entries) in igbvf_request_irq()
1133 err = igbvf_request_msix(adapter); in igbvf_request_irq()
1138 dev_err(&adapter->pdev->dev, in igbvf_request_irq()
1144 static void igbvf_free_irq(struct igbvf_adapter *adapter) in igbvf_free_irq() argument
1146 struct net_device *netdev = adapter->netdev; in igbvf_free_irq()
1149 if (adapter->msix_entries) { in igbvf_free_irq()
1151 free_irq(adapter->msix_entries[vector].vector, netdev); in igbvf_free_irq()
1159 static void igbvf_irq_disable(struct igbvf_adapter *adapter) in igbvf_irq_disable() argument
1161 struct e1000_hw *hw = &adapter->hw; in igbvf_irq_disable()
1165 if (adapter->msix_entries) in igbvf_irq_disable()
1173 static void igbvf_irq_enable(struct igbvf_adapter *adapter) in igbvf_irq_enable() argument
1175 struct e1000_hw *hw = &adapter->hw; in igbvf_irq_enable()
1177 ew32(EIAC, adapter->eims_enable_mask); in igbvf_irq_enable()
1178 ew32(EIAM, adapter->eims_enable_mask); in igbvf_irq_enable()
1179 ew32(EIMS, adapter->eims_enable_mask); in igbvf_irq_enable()
1190 struct igbvf_adapter *adapter = rx_ring->adapter; in igbvf_poll() local
1191 struct e1000_hw *hw = &adapter->hw; in igbvf_poll()
1194 igbvf_clean_rx_irq(adapter, &work_done, budget); in igbvf_poll()
1203 if (adapter->requested_itr & 3) in igbvf_poll()
1204 igbvf_set_itr(adapter); in igbvf_poll()
1206 if (!test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_poll()
1207 ew32(EIMS, adapter->rx_ring->eims_value); in igbvf_poll()
1219 static void igbvf_set_rlpml(struct igbvf_adapter *adapter) in igbvf_set_rlpml() argument
1222 struct e1000_hw *hw = &adapter->hw; in igbvf_set_rlpml()
1224 max_frame_size = adapter->max_frame_size + VLAN_TAG_SIZE; in igbvf_set_rlpml()
1236 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_vlan_rx_add_vid() local
1237 struct e1000_hw *hw = &adapter->hw; in igbvf_vlan_rx_add_vid()
1242 dev_warn(&adapter->pdev->dev, "Vlan id %d\n is not added", vid); in igbvf_vlan_rx_add_vid()
1249 set_bit(vid, adapter->active_vlans); in igbvf_vlan_rx_add_vid()
1256 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_vlan_rx_kill_vid() local
1257 struct e1000_hw *hw = &adapter->hw; in igbvf_vlan_rx_kill_vid()
1262 dev_err(&adapter->pdev->dev, in igbvf_vlan_rx_kill_vid()
1270 clear_bit(vid, adapter->active_vlans); in igbvf_vlan_rx_kill_vid()
1274 static void igbvf_restore_vlan(struct igbvf_adapter *adapter) in igbvf_restore_vlan() argument
1278 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) in igbvf_restore_vlan()
1279 igbvf_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); in igbvf_restore_vlan()
1288 static void igbvf_configure_tx(struct igbvf_adapter *adapter) in igbvf_configure_tx() argument
1290 struct e1000_hw *hw = &adapter->hw; in igbvf_configure_tx()
1291 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_configure_tx()
1324 adapter->txd_cmd = E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_IFCS; in igbvf_configure_tx()
1327 adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS; in igbvf_configure_tx()
1334 static void igbvf_setup_srrctl(struct igbvf_adapter *adapter) in igbvf_setup_srrctl() argument
1336 struct e1000_hw *hw = &adapter->hw; in igbvf_setup_srrctl()
1347 srrctl |= ALIGN(adapter->rx_buffer_len, 1024) >> in igbvf_setup_srrctl()
1350 if (adapter->rx_buffer_len < 2048) { in igbvf_setup_srrctl()
1351 adapter->rx_ps_hdr_size = 0; in igbvf_setup_srrctl()
1354 adapter->rx_ps_hdr_size = 128; in igbvf_setup_srrctl()
1355 srrctl |= adapter->rx_ps_hdr_size << in igbvf_setup_srrctl()
1369 static void igbvf_configure_rx(struct igbvf_adapter *adapter) in igbvf_configure_rx() argument
1371 struct e1000_hw *hw = &adapter->hw; in igbvf_configure_rx()
1372 struct igbvf_ring *rx_ring = adapter->rx_ring; in igbvf_configure_rx()
1400 igbvf_set_rlpml(adapter); in igbvf_configure_rx()
1417 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_multi() local
1418 struct e1000_hw *hw = &adapter->hw; in igbvf_set_multi()
1452 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_uni() local
1453 struct e1000_hw *hw = &adapter->hw; in igbvf_set_uni()
1495 static void igbvf_configure(struct igbvf_adapter *adapter) in igbvf_configure() argument
1497 igbvf_set_rx_mode(adapter->netdev); in igbvf_configure()
1499 igbvf_restore_vlan(adapter); in igbvf_configure()
1501 igbvf_configure_tx(adapter); in igbvf_configure()
1502 igbvf_setup_srrctl(adapter); in igbvf_configure()
1503 igbvf_configure_rx(adapter); in igbvf_configure()
1504 igbvf_alloc_rx_buffers(adapter->rx_ring, in igbvf_configure()
1505 igbvf_desc_unused(adapter->rx_ring)); in igbvf_configure()
1516 static void igbvf_reset(struct igbvf_adapter *adapter) in igbvf_reset() argument
1518 struct e1000_mac_info *mac = &adapter->hw.mac; in igbvf_reset()
1519 struct net_device *netdev = adapter->netdev; in igbvf_reset()
1520 struct e1000_hw *hw = &adapter->hw; in igbvf_reset()
1526 dev_info(&adapter->pdev->dev, "PF still resetting\n"); in igbvf_reset()
1532 if (is_valid_ether_addr(adapter->hw.mac.addr)) { in igbvf_reset()
1533 eth_hw_addr_set(netdev, adapter->hw.mac.addr); in igbvf_reset()
1534 memcpy(netdev->perm_addr, adapter->hw.mac.addr, in igbvf_reset()
1538 adapter->last_reset = jiffies; in igbvf_reset()
1541 int igbvf_up(struct igbvf_adapter *adapter) in igbvf_up() argument
1543 struct e1000_hw *hw = &adapter->hw; in igbvf_up()
1546 igbvf_configure(adapter); in igbvf_up()
1548 clear_bit(__IGBVF_DOWN, &adapter->state); in igbvf_up()
1550 napi_enable(&adapter->rx_ring->napi); in igbvf_up()
1551 if (adapter->msix_entries) in igbvf_up()
1552 igbvf_configure_msix(adapter); in igbvf_up()
1556 igbvf_irq_enable(adapter); in igbvf_up()
1560 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igbvf_up()
1565 void igbvf_down(struct igbvf_adapter *adapter) in igbvf_down() argument
1567 struct net_device *netdev = adapter->netdev; in igbvf_down()
1568 struct e1000_hw *hw = &adapter->hw; in igbvf_down()
1574 set_bit(__IGBVF_DOWN, &adapter->state); in igbvf_down()
1591 napi_disable(&adapter->rx_ring->napi); in igbvf_down()
1593 igbvf_irq_disable(adapter); in igbvf_down()
1595 del_timer_sync(&adapter->watchdog_timer); in igbvf_down()
1598 igbvf_update_stats(adapter); in igbvf_down()
1600 adapter->link_speed = 0; in igbvf_down()
1601 adapter->link_duplex = 0; in igbvf_down()
1603 igbvf_reset(adapter); in igbvf_down()
1604 igbvf_clean_tx_ring(adapter->tx_ring); in igbvf_down()
1605 igbvf_clean_rx_ring(adapter->rx_ring); in igbvf_down()
1608 void igbvf_reinit_locked(struct igbvf_adapter *adapter) in igbvf_reinit_locked() argument
1611 while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_reinit_locked()
1613 igbvf_down(adapter); in igbvf_reinit_locked()
1614 igbvf_up(adapter); in igbvf_reinit_locked()
1615 clear_bit(__IGBVF_RESETTING, &adapter->state); in igbvf_reinit_locked()
1626 static int igbvf_sw_init(struct igbvf_adapter *adapter) in igbvf_sw_init() argument
1628 struct net_device *netdev = adapter->netdev; in igbvf_sw_init()
1631 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN; in igbvf_sw_init()
1632 adapter->rx_ps_hdr_size = 0; in igbvf_sw_init()
1633 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; in igbvf_sw_init()
1634 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; in igbvf_sw_init()
1636 adapter->tx_int_delay = 8; in igbvf_sw_init()
1637 adapter->tx_abs_int_delay = 32; in igbvf_sw_init()
1638 adapter->rx_int_delay = 0; in igbvf_sw_init()
1639 adapter->rx_abs_int_delay = 8; in igbvf_sw_init()
1640 adapter->requested_itr = 3; in igbvf_sw_init()
1641 adapter->current_itr = IGBVF_START_ITR; in igbvf_sw_init()
1644 adapter->ei->init_ops(&adapter->hw); in igbvf_sw_init()
1646 rc = adapter->hw.mac.ops.init_params(&adapter->hw); in igbvf_sw_init()
1650 rc = adapter->hw.mbx.ops.init_params(&adapter->hw); in igbvf_sw_init()
1654 igbvf_set_interrupt_capability(adapter); in igbvf_sw_init()
1656 if (igbvf_alloc_queues(adapter)) in igbvf_sw_init()
1659 spin_lock_init(&adapter->tx_queue_lock); in igbvf_sw_init()
1662 igbvf_irq_disable(adapter); in igbvf_sw_init()
1664 spin_lock_init(&adapter->stats_lock); in igbvf_sw_init()
1665 spin_lock_init(&adapter->hw.mbx_lock); in igbvf_sw_init()
1667 set_bit(__IGBVF_DOWN, &adapter->state); in igbvf_sw_init()
1671 static void igbvf_initialize_last_counter_stats(struct igbvf_adapter *adapter) in igbvf_initialize_last_counter_stats() argument
1673 struct e1000_hw *hw = &adapter->hw; in igbvf_initialize_last_counter_stats()
1675 adapter->stats.last_gprc = er32(VFGPRC); in igbvf_initialize_last_counter_stats()
1676 adapter->stats.last_gorc = er32(VFGORC); in igbvf_initialize_last_counter_stats()
1677 adapter->stats.last_gptc = er32(VFGPTC); in igbvf_initialize_last_counter_stats()
1678 adapter->stats.last_gotc = er32(VFGOTC); in igbvf_initialize_last_counter_stats()
1679 adapter->stats.last_mprc = er32(VFMPRC); in igbvf_initialize_last_counter_stats()
1680 adapter->stats.last_gotlbc = er32(VFGOTLBC); in igbvf_initialize_last_counter_stats()
1681 adapter->stats.last_gptlbc = er32(VFGPTLBC); in igbvf_initialize_last_counter_stats()
1682 adapter->stats.last_gorlbc = er32(VFGORLBC); in igbvf_initialize_last_counter_stats()
1683 adapter->stats.last_gprlbc = er32(VFGPRLBC); in igbvf_initialize_last_counter_stats()
1685 adapter->stats.base_gprc = er32(VFGPRC); in igbvf_initialize_last_counter_stats()
1686 adapter->stats.base_gorc = er32(VFGORC); in igbvf_initialize_last_counter_stats()
1687 adapter->stats.base_gptc = er32(VFGPTC); in igbvf_initialize_last_counter_stats()
1688 adapter->stats.base_gotc = er32(VFGOTC); in igbvf_initialize_last_counter_stats()
1689 adapter->stats.base_mprc = er32(VFMPRC); in igbvf_initialize_last_counter_stats()
1690 adapter->stats.base_gotlbc = er32(VFGOTLBC); in igbvf_initialize_last_counter_stats()
1691 adapter->stats.base_gptlbc = er32(VFGPTLBC); in igbvf_initialize_last_counter_stats()
1692 adapter->stats.base_gorlbc = er32(VFGORLBC); in igbvf_initialize_last_counter_stats()
1693 adapter->stats.base_gprlbc = er32(VFGPRLBC); in igbvf_initialize_last_counter_stats()
1710 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_open() local
1711 struct e1000_hw *hw = &adapter->hw; in igbvf_open()
1715 if (test_bit(__IGBVF_TESTING, &adapter->state)) in igbvf_open()
1719 err = igbvf_setup_tx_resources(adapter, adapter->tx_ring); in igbvf_open()
1724 err = igbvf_setup_rx_resources(adapter, adapter->rx_ring); in igbvf_open()
1733 igbvf_configure(adapter); in igbvf_open()
1735 err = igbvf_request_irq(adapter); in igbvf_open()
1740 clear_bit(__IGBVF_DOWN, &adapter->state); in igbvf_open()
1742 napi_enable(&adapter->rx_ring->napi); in igbvf_open()
1747 igbvf_irq_enable(adapter); in igbvf_open()
1751 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igbvf_open()
1756 igbvf_free_rx_resources(adapter->rx_ring); in igbvf_open()
1758 igbvf_free_tx_resources(adapter->tx_ring); in igbvf_open()
1760 igbvf_reset(adapter); in igbvf_open()
1778 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_close() local
1780 WARN_ON(test_bit(__IGBVF_RESETTING, &adapter->state)); in igbvf_close()
1781 igbvf_down(adapter); in igbvf_close()
1783 igbvf_free_irq(adapter); in igbvf_close()
1785 igbvf_free_tx_resources(adapter->tx_ring); in igbvf_close()
1786 igbvf_free_rx_resources(adapter->rx_ring); in igbvf_close()
1800 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_mac() local
1801 struct e1000_hw *hw = &adapter->hw; in igbvf_set_mac()
1826 if (current_counter < adapter->stats.last_##name) \
1827 adapter->stats.name += 0x100000000LL; \
1828 adapter->stats.last_##name = current_counter; \
1829 adapter->stats.name &= 0xFFFFFFFF00000000LL; \
1830 adapter->stats.name |= current_counter; \
1837 void igbvf_update_stats(struct igbvf_adapter *adapter) in igbvf_update_stats() argument
1839 struct e1000_hw *hw = &adapter->hw; in igbvf_update_stats()
1840 struct pci_dev *pdev = adapter->pdev; in igbvf_update_stats()
1845 if (adapter->link_speed == 0) in igbvf_update_stats()
1848 if (test_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_update_stats()
1865 adapter->netdev->stats.multicast = adapter->stats.mprc; in igbvf_update_stats()
1868 static void igbvf_print_link_info(struct igbvf_adapter *adapter) in igbvf_print_link_info() argument
1870 dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s Duplex\n", in igbvf_print_link_info()
1871 adapter->link_speed, in igbvf_print_link_info()
1872 adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half"); in igbvf_print_link_info()
1875 static bool igbvf_has_link(struct igbvf_adapter *adapter) in igbvf_has_link() argument
1877 struct e1000_hw *hw = &adapter->hw; in igbvf_has_link()
1882 if (test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_has_link()
1894 if (ret_val && time_after(jiffies, adapter->last_reset + (10 * HZ))) in igbvf_has_link()
1895 schedule_work(&adapter->reset_task); in igbvf_has_link()
1906 struct igbvf_adapter *adapter = from_timer(adapter, t, watchdog_timer); in igbvf_watchdog() local
1909 schedule_work(&adapter->watchdog_task); in igbvf_watchdog()
1914 struct igbvf_adapter *adapter = container_of(work, in igbvf_watchdog_task() local
1917 struct net_device *netdev = adapter->netdev; in igbvf_watchdog_task()
1918 struct e1000_mac_info *mac = &adapter->hw.mac; in igbvf_watchdog_task()
1919 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_watchdog_task()
1920 struct e1000_hw *hw = &adapter->hw; in igbvf_watchdog_task()
1924 link = igbvf_has_link(adapter); in igbvf_watchdog_task()
1928 mac->ops.get_link_up_info(&adapter->hw, in igbvf_watchdog_task()
1929 &adapter->link_speed, in igbvf_watchdog_task()
1930 &adapter->link_duplex); in igbvf_watchdog_task()
1931 igbvf_print_link_info(adapter); in igbvf_watchdog_task()
1938 adapter->link_speed = 0; in igbvf_watchdog_task()
1939 adapter->link_duplex = 0; in igbvf_watchdog_task()
1940 dev_info(&adapter->pdev->dev, "Link is Down\n"); in igbvf_watchdog_task()
1947 igbvf_update_stats(adapter); in igbvf_watchdog_task()
1957 adapter->tx_timeout_count++; in igbvf_watchdog_task()
1958 schedule_work(&adapter->reset_task); in igbvf_watchdog_task()
1963 ew32(EICS, adapter->rx_ring->eims_value); in igbvf_watchdog_task()
1966 if (!test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_watchdog_task()
1967 mod_timer(&adapter->watchdog_timer, in igbvf_watchdog_task()
2120 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_maybe_stop_tx() local
2123 if (igbvf_desc_unused(adapter->tx_ring) >= size) in igbvf_maybe_stop_tx()
2135 if (igbvf_desc_unused(adapter->tx_ring) < size) in igbvf_maybe_stop_tx()
2140 ++adapter->restart_queue; in igbvf_maybe_stop_tx()
2147 static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter, in igbvf_tx_map_adv() argument
2152 struct pci_dev *pdev = adapter->pdev; in igbvf_tx_map_adv()
2213 igbvf_put_txbuf(adapter, buffer_info); in igbvf_tx_map_adv()
2219 static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter, in igbvf_tx_queue_adv() argument
2265 tx_desc->read.cmd_type_len |= cpu_to_le32(adapter->txd_cmd); in igbvf_tx_queue_adv()
2275 writel(i, adapter->hw.hw_addr + tx_ring->tail); in igbvf_tx_queue_adv()
2282 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_xmit_frame_ring_adv() local
2289 if (test_bit(__IGBVF_DOWN, &adapter->state)) { in igbvf_xmit_frame_ring_adv()
2336 count = igbvf_tx_map_adv(adapter, tx_ring, skb); in igbvf_xmit_frame_ring_adv()
2339 igbvf_tx_queue_adv(adapter, tx_ring, tx_flags, count, in igbvf_xmit_frame_ring_adv()
2355 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_xmit_frame() local
2358 if (test_bit(__IGBVF_DOWN, &adapter->state)) { in igbvf_xmit_frame()
2363 tx_ring = &adapter->tx_ring[0]; in igbvf_xmit_frame()
2375 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_tx_timeout() local
2378 adapter->tx_timeout_count++; in igbvf_tx_timeout()
2379 schedule_work(&adapter->reset_task); in igbvf_tx_timeout()
2384 struct igbvf_adapter *adapter; in igbvf_reset_task() local
2386 adapter = container_of(work, struct igbvf_adapter, reset_task); in igbvf_reset_task()
2388 igbvf_reinit_locked(adapter); in igbvf_reset_task()
2400 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_change_mtu() local
2403 while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_change_mtu()
2406 adapter->max_frame_size = max_frame; in igbvf_change_mtu()
2408 igbvf_down(adapter); in igbvf_change_mtu()
2419 adapter->rx_buffer_len = 1024; in igbvf_change_mtu()
2421 adapter->rx_buffer_len = 2048; in igbvf_change_mtu()
2424 adapter->rx_buffer_len = 16384; in igbvf_change_mtu()
2426 adapter->rx_buffer_len = PAGE_SIZE / 2; in igbvf_change_mtu()
2432 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + in igbvf_change_mtu()
2440 igbvf_up(adapter); in igbvf_change_mtu()
2442 igbvf_reset(adapter); in igbvf_change_mtu()
2444 clear_bit(__IGBVF_RESETTING, &adapter->state); in igbvf_change_mtu()
2460 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_suspend() local
2465 WARN_ON(test_bit(__IGBVF_RESETTING, &adapter->state)); in igbvf_suspend()
2466 igbvf_down(adapter); in igbvf_suspend()
2467 igbvf_free_irq(adapter); in igbvf_suspend()
2477 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_resume() local
2483 err = igbvf_request_irq(adapter); in igbvf_resume()
2488 igbvf_reset(adapter); in igbvf_resume()
2491 igbvf_up(adapter); in igbvf_resume()
2510 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_netpoll() local
2512 disable_irq(adapter->pdev->irq); in igbvf_netpoll()
2514 igbvf_clean_tx_irq(adapter->tx_ring); in igbvf_netpoll()
2516 enable_irq(adapter->pdev->irq); in igbvf_netpoll()
2532 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_error_detected() local
2540 igbvf_down(adapter); in igbvf_io_error_detected()
2557 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_slot_reset() local
2566 igbvf_reset(adapter); in igbvf_io_slot_reset()
2582 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_resume() local
2585 if (igbvf_up(adapter)) { in igbvf_io_resume()
2602 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_prepare() local
2604 while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_io_prepare()
2606 igbvf_down(adapter); in igbvf_io_prepare()
2616 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_reset_done() local
2618 igbvf_up(adapter); in igbvf_io_reset_done()
2619 clear_bit(__IGBVF_RESETTING, &adapter->state); in igbvf_io_reset_done()
2622 static void igbvf_print_device_info(struct igbvf_adapter *adapter) in igbvf_print_device_info() argument
2624 struct e1000_hw *hw = &adapter->hw; in igbvf_print_device_info()
2625 struct net_device *netdev = adapter->netdev; in igbvf_print_device_info()
2626 struct pci_dev *pdev = adapter->pdev; in igbvf_print_device_info()
2638 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_features() local
2641 adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED; in igbvf_set_features()
2643 adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED; in igbvf_set_features()
2714 struct igbvf_adapter *adapter; in igbvf_probe() local
2745 adapter = netdev_priv(netdev); in igbvf_probe()
2746 hw = &adapter->hw; in igbvf_probe()
2747 adapter->netdev = netdev; in igbvf_probe()
2748 adapter->pdev = pdev; in igbvf_probe()
2749 adapter->ei = ei; in igbvf_probe()
2750 adapter->pba = ei->pba; in igbvf_probe()
2751 adapter->flags = ei->flags; in igbvf_probe()
2752 adapter->hw.back = adapter; in igbvf_probe()
2753 adapter->hw.mac.type = ei->mac; in igbvf_probe()
2754 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); in igbvf_probe()
2765 adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, 0), in igbvf_probe()
2768 if (!adapter->hw.hw_addr) in igbvf_probe()
2772 err = ei->get_variants(adapter); in igbvf_probe()
2778 err = igbvf_sw_init(adapter); in igbvf_probe()
2789 adapter->bd_number = cards_found++; in igbvf_probe()
2835 else if (is_zero_ether_addr(adapter->hw.mac.addr)) in igbvf_probe()
2838 eth_hw_addr_set(netdev, adapter->hw.mac.addr); in igbvf_probe()
2846 memcpy(adapter->hw.mac.addr, netdev->dev_addr, in igbvf_probe()
2850 timer_setup(&adapter->watchdog_timer, igbvf_watchdog, 0); in igbvf_probe()
2852 INIT_WORK(&adapter->reset_task, igbvf_reset_task); in igbvf_probe()
2853 INIT_WORK(&adapter->watchdog_task, igbvf_watchdog_task); in igbvf_probe()
2856 adapter->rx_ring->count = 1024; in igbvf_probe()
2857 adapter->tx_ring->count = 1024; in igbvf_probe()
2860 igbvf_reset(adapter); in igbvf_probe()
2863 if (adapter->hw.mac.type == e1000_vfadapt_i350) in igbvf_probe()
2864 adapter->flags |= IGBVF_FLAG_RX_LB_VLAN_BSWAP; in igbvf_probe()
2875 igbvf_print_device_info(adapter); in igbvf_probe()
2877 igbvf_initialize_last_counter_stats(adapter); in igbvf_probe()
2882 netif_napi_del(&adapter->rx_ring->napi); in igbvf_probe()
2883 kfree(adapter->tx_ring); in igbvf_probe()
2884 kfree(adapter->rx_ring); in igbvf_probe()
2886 igbvf_reset_interrupt_capability(adapter); in igbvf_probe()
2888 iounmap(adapter->hw.hw_addr); in igbvf_probe()
2911 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_remove() local
2912 struct e1000_hw *hw = &adapter->hw; in igbvf_remove()
2917 set_bit(__IGBVF_DOWN, &adapter->state); in igbvf_remove()
2918 del_timer_sync(&adapter->watchdog_timer); in igbvf_remove()
2920 cancel_work_sync(&adapter->reset_task); in igbvf_remove()
2921 cancel_work_sync(&adapter->watchdog_task); in igbvf_remove()
2925 igbvf_reset_interrupt_capability(adapter); in igbvf_remove()
2930 netif_napi_del(&adapter->rx_ring->napi); in igbvf_remove()
2931 kfree(adapter->tx_ring); in igbvf_remove()
2932 kfree(adapter->rx_ring); in igbvf_remove()