Lines Matching full:adapter
76 * @adapter: board private structure
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()
237 * @adapter: board private structure
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()
411 * @adapter: board private structure
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()
450 * @adapter: board private structure
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()
631 * @adapter: pointer to adapter
632 * @itr_setting: current adapter->itr
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()
859 if (!test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_msix_other()
860 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igbvf_msix_other()
862 ew32(EIMS, adapter->eims_other); in igbvf_msix_other()
870 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_intr_msix_tx() local
871 struct e1000_hw *hw = &adapter->hw; in igbvf_intr_msix_tx()
872 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_intr_msix_tx()
876 adapter->hw.hw_addr + tx_ring->itr_register); in igbvf_intr_msix_tx()
877 adapter->tx_ring->set_itr = 0; in igbvf_intr_msix_tx()
880 adapter->total_tx_bytes = 0; in igbvf_intr_msix_tx()
881 adapter->total_tx_packets = 0; in igbvf_intr_msix_tx()
898 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_intr_msix_rx() local
903 if (adapter->rx_ring->set_itr) { in igbvf_intr_msix_rx()
904 writel(adapter->rx_ring->itr_val, in igbvf_intr_msix_rx()
905 adapter->hw.hw_addr + adapter->rx_ring->itr_register); in igbvf_intr_msix_rx()
906 adapter->rx_ring->set_itr = 0; in igbvf_intr_msix_rx()
909 if (napi_schedule_prep(&adapter->rx_ring->napi)) { in igbvf_intr_msix_rx()
910 adapter->total_rx_bytes = 0; in igbvf_intr_msix_rx()
911 adapter->total_rx_packets = 0; in igbvf_intr_msix_rx()
912 __napi_schedule(&adapter->rx_ring->napi); in igbvf_intr_msix_rx()
920 static void igbvf_assign_vector(struct igbvf_adapter *adapter, int rx_queue, in igbvf_assign_vector() argument
923 struct e1000_hw *hw = &adapter->hw; in igbvf_assign_vector()
943 adapter->rx_ring[rx_queue].eims_value = BIT(msix_vector); in igbvf_assign_vector()
958 adapter->tx_ring[tx_queue].eims_value = BIT(msix_vector); in igbvf_assign_vector()
965 * @adapter: board private structure
970 static void igbvf_configure_msix(struct igbvf_adapter *adapter) in igbvf_configure_msix() argument
973 struct e1000_hw *hw = &adapter->hw; in igbvf_configure_msix()
974 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_configure_msix()
975 struct igbvf_ring *rx_ring = adapter->rx_ring; in igbvf_configure_msix()
978 adapter->eims_enable_mask = 0; in igbvf_configure_msix()
980 igbvf_assign_vector(adapter, IGBVF_NO_QUEUE, 0, vector++); in igbvf_configure_msix()
981 adapter->eims_enable_mask |= tx_ring->eims_value; in igbvf_configure_msix()
983 igbvf_assign_vector(adapter, 0, IGBVF_NO_QUEUE, vector++); in igbvf_configure_msix()
984 adapter->eims_enable_mask |= rx_ring->eims_value; in igbvf_configure_msix()
993 adapter->eims_enable_mask = GENMASK(vector - 1, 0); in igbvf_configure_msix()
994 adapter->eims_other = BIT(vector - 1); in igbvf_configure_msix()
998 static void igbvf_reset_interrupt_capability(struct igbvf_adapter *adapter) in igbvf_reset_interrupt_capability() argument
1000 if (adapter->msix_entries) { in igbvf_reset_interrupt_capability()
1001 pci_disable_msix(adapter->pdev); in igbvf_reset_interrupt_capability()
1002 kfree(adapter->msix_entries); in igbvf_reset_interrupt_capability()
1003 adapter->msix_entries = NULL; in igbvf_reset_interrupt_capability()
1009 * @adapter: board private structure
1014 static void igbvf_set_interrupt_capability(struct igbvf_adapter *adapter) in igbvf_set_interrupt_capability() argument
1020 adapter->msix_entries = kcalloc(3, sizeof(struct msix_entry), in igbvf_set_interrupt_capability()
1022 if (adapter->msix_entries) { in igbvf_set_interrupt_capability()
1024 adapter->msix_entries[i].entry = i; in igbvf_set_interrupt_capability()
1026 err = pci_enable_msix_range(adapter->pdev, in igbvf_set_interrupt_capability()
1027 adapter->msix_entries, 3, 3); in igbvf_set_interrupt_capability()
1032 dev_err(&adapter->pdev->dev, in igbvf_set_interrupt_capability()
1034 igbvf_reset_interrupt_capability(adapter); in igbvf_set_interrupt_capability()
1040 * @adapter: board private structure
1045 static int igbvf_request_msix(struct igbvf_adapter *adapter) in igbvf_request_msix() argument
1047 struct net_device *netdev = adapter->netdev; in igbvf_request_msix()
1051 sprintf(adapter->tx_ring->name, "%s-tx-0", netdev->name); in igbvf_request_msix()
1052 sprintf(adapter->rx_ring->name, "%s-rx-0", netdev->name); in igbvf_request_msix()
1054 memcpy(adapter->tx_ring->name, netdev->name, IFNAMSIZ); in igbvf_request_msix()
1055 memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ); in igbvf_request_msix()
1058 err = request_irq(adapter->msix_entries[vector].vector, in igbvf_request_msix()
1059 igbvf_intr_msix_tx, 0, adapter->tx_ring->name, in igbvf_request_msix()
1064 adapter->tx_ring->itr_register = E1000_EITR(vector); in igbvf_request_msix()
1065 adapter->tx_ring->itr_val = adapter->current_itr; in igbvf_request_msix()
1068 err = request_irq(adapter->msix_entries[vector].vector, in igbvf_request_msix()
1069 igbvf_intr_msix_rx, 0, adapter->rx_ring->name, in igbvf_request_msix()
1074 adapter->rx_ring->itr_register = E1000_EITR(vector); in igbvf_request_msix()
1075 adapter->rx_ring->itr_val = adapter->current_itr; in igbvf_request_msix()
1078 err = request_irq(adapter->msix_entries[vector].vector, in igbvf_request_msix()
1083 igbvf_configure_msix(adapter); in igbvf_request_msix()
1086 free_irq(adapter->msix_entries[--vector].vector, netdev); in igbvf_request_msix()
1088 free_irq(adapter->msix_entries[--vector].vector, netdev); in igbvf_request_msix()
1095 * @adapter: board private structure to initialize
1097 static int igbvf_alloc_queues(struct igbvf_adapter *adapter) in igbvf_alloc_queues() argument
1099 struct net_device *netdev = adapter->netdev; in igbvf_alloc_queues()
1101 adapter->tx_ring = kzalloc(sizeof(struct igbvf_ring), GFP_KERNEL); in igbvf_alloc_queues()
1102 if (!adapter->tx_ring) in igbvf_alloc_queues()
1105 adapter->rx_ring = kzalloc(sizeof(struct igbvf_ring), GFP_KERNEL); in igbvf_alloc_queues()
1106 if (!adapter->rx_ring) { in igbvf_alloc_queues()
1107 kfree(adapter->tx_ring); in igbvf_alloc_queues()
1111 netif_napi_add(netdev, &adapter->rx_ring->napi, igbvf_poll); in igbvf_alloc_queues()
1118 * @adapter: board private structure
1123 static int igbvf_request_irq(struct igbvf_adapter *adapter) in igbvf_request_irq() argument
1128 if (adapter->msix_entries) in igbvf_request_irq()
1129 err = igbvf_request_msix(adapter); in igbvf_request_irq()
1134 dev_err(&adapter->pdev->dev, in igbvf_request_irq()
1140 static void igbvf_free_irq(struct igbvf_adapter *adapter) in igbvf_free_irq() argument
1142 struct net_device *netdev = adapter->netdev; in igbvf_free_irq()
1145 if (adapter->msix_entries) { in igbvf_free_irq()
1147 free_irq(adapter->msix_entries[vector].vector, netdev); in igbvf_free_irq()
1153 * @adapter: board private structure
1155 static void igbvf_irq_disable(struct igbvf_adapter *adapter) in igbvf_irq_disable() argument
1157 struct e1000_hw *hw = &adapter->hw; in igbvf_irq_disable()
1161 if (adapter->msix_entries) in igbvf_irq_disable()
1167 * @adapter: board private structure
1169 static void igbvf_irq_enable(struct igbvf_adapter *adapter) in igbvf_irq_enable() argument
1171 struct e1000_hw *hw = &adapter->hw; in igbvf_irq_enable()
1173 ew32(EIAC, adapter->eims_enable_mask); in igbvf_irq_enable()
1174 ew32(EIAM, adapter->eims_enable_mask); in igbvf_irq_enable()
1175 ew32(EIMS, adapter->eims_enable_mask); in igbvf_irq_enable()
1186 struct igbvf_adapter *adapter = rx_ring->adapter; in igbvf_poll() local
1187 struct e1000_hw *hw = &adapter->hw; in igbvf_poll()
1190 igbvf_clean_rx_irq(adapter, &work_done, budget); in igbvf_poll()
1199 if (adapter->requested_itr & 3) in igbvf_poll()
1200 igbvf_set_itr(adapter); in igbvf_poll()
1202 if (!test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_poll()
1203 ew32(EIMS, adapter->rx_ring->eims_value); in igbvf_poll()
1211 * @adapter: board private structure
1215 static void igbvf_set_rlpml(struct igbvf_adapter *adapter) in igbvf_set_rlpml() argument
1218 struct e1000_hw *hw = &adapter->hw; in igbvf_set_rlpml()
1220 max_frame_size = adapter->max_frame_size + VLAN_TAG_SIZE; in igbvf_set_rlpml()
1232 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_vlan_rx_add_vid() local
1233 struct e1000_hw *hw = &adapter->hw; in igbvf_vlan_rx_add_vid()
1238 dev_warn(&adapter->pdev->dev, "Vlan id %d\n is not added", vid); in igbvf_vlan_rx_add_vid()
1245 set_bit(vid, adapter->active_vlans); in igbvf_vlan_rx_add_vid()
1252 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_vlan_rx_kill_vid() local
1253 struct e1000_hw *hw = &adapter->hw; in igbvf_vlan_rx_kill_vid()
1258 dev_err(&adapter->pdev->dev, in igbvf_vlan_rx_kill_vid()
1266 clear_bit(vid, adapter->active_vlans); in igbvf_vlan_rx_kill_vid()
1270 static void igbvf_restore_vlan(struct igbvf_adapter *adapter) in igbvf_restore_vlan() argument
1274 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) in igbvf_restore_vlan()
1275 igbvf_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); in igbvf_restore_vlan()
1280 * @adapter: board private structure
1284 static void igbvf_configure_tx(struct igbvf_adapter *adapter) in igbvf_configure_tx() argument
1286 struct e1000_hw *hw = &adapter->hw; in igbvf_configure_tx()
1287 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_configure_tx()
1320 adapter->txd_cmd = E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_IFCS; in igbvf_configure_tx()
1323 adapter->txd_cmd |= E1000_ADVTXD_DCMD_RS; in igbvf_configure_tx()
1328 * @adapter: Board private structure
1330 static void igbvf_setup_srrctl(struct igbvf_adapter *adapter) in igbvf_setup_srrctl() argument
1332 struct e1000_hw *hw = &adapter->hw; in igbvf_setup_srrctl()
1343 srrctl |= ALIGN(adapter->rx_buffer_len, 1024) >> in igbvf_setup_srrctl()
1346 if (adapter->rx_buffer_len < 2048) { in igbvf_setup_srrctl()
1347 adapter->rx_ps_hdr_size = 0; in igbvf_setup_srrctl()
1350 adapter->rx_ps_hdr_size = 128; in igbvf_setup_srrctl()
1351 srrctl |= adapter->rx_ps_hdr_size << in igbvf_setup_srrctl()
1361 * @adapter: board private structure
1365 static void igbvf_configure_rx(struct igbvf_adapter *adapter) in igbvf_configure_rx() argument
1367 struct e1000_hw *hw = &adapter->hw; in igbvf_configure_rx()
1368 struct igbvf_ring *rx_ring = adapter->rx_ring; in igbvf_configure_rx()
1396 igbvf_set_rlpml(adapter); in igbvf_configure_rx()
1413 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_multi() local
1414 struct e1000_hw *hw = &adapter->hw; in igbvf_set_multi()
1448 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_uni() local
1449 struct e1000_hw *hw = &adapter->hw; in igbvf_set_uni()
1489 * @adapter: private board structure
1491 static void igbvf_configure(struct igbvf_adapter *adapter) in igbvf_configure() argument
1493 igbvf_set_rx_mode(adapter->netdev); in igbvf_configure()
1495 igbvf_restore_vlan(adapter); in igbvf_configure()
1497 igbvf_configure_tx(adapter); in igbvf_configure()
1498 igbvf_setup_srrctl(adapter); in igbvf_configure()
1499 igbvf_configure_rx(adapter); in igbvf_configure()
1500 igbvf_alloc_rx_buffers(adapter->rx_ring, in igbvf_configure()
1501 igbvf_desc_unused(adapter->rx_ring)); in igbvf_configure()
1505 * @adapter: private board structure
1512 static void igbvf_reset(struct igbvf_adapter *adapter) in igbvf_reset() argument
1514 struct e1000_mac_info *mac = &adapter->hw.mac; in igbvf_reset()
1515 struct net_device *netdev = adapter->netdev; in igbvf_reset()
1516 struct e1000_hw *hw = &adapter->hw; in igbvf_reset()
1522 dev_info(&adapter->pdev->dev, "PF still resetting\n"); in igbvf_reset()
1528 if (is_valid_ether_addr(adapter->hw.mac.addr)) { in igbvf_reset()
1529 eth_hw_addr_set(netdev, adapter->hw.mac.addr); in igbvf_reset()
1530 memcpy(netdev->perm_addr, adapter->hw.mac.addr, in igbvf_reset()
1534 adapter->last_reset = jiffies; in igbvf_reset()
1537 int igbvf_up(struct igbvf_adapter *adapter) in igbvf_up() argument
1539 struct e1000_hw *hw = &adapter->hw; in igbvf_up()
1542 igbvf_configure(adapter); in igbvf_up()
1544 clear_bit(__IGBVF_DOWN, &adapter->state); in igbvf_up()
1546 napi_enable(&adapter->rx_ring->napi); in igbvf_up()
1547 if (adapter->msix_entries) in igbvf_up()
1548 igbvf_configure_msix(adapter); in igbvf_up()
1552 igbvf_irq_enable(adapter); in igbvf_up()
1556 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igbvf_up()
1561 void igbvf_down(struct igbvf_adapter *adapter) in igbvf_down() argument
1563 struct net_device *netdev = adapter->netdev; in igbvf_down()
1564 struct e1000_hw *hw = &adapter->hw; in igbvf_down()
1570 set_bit(__IGBVF_DOWN, &adapter->state); in igbvf_down()
1587 napi_disable(&adapter->rx_ring->napi); in igbvf_down()
1589 igbvf_irq_disable(adapter); in igbvf_down()
1591 timer_delete_sync(&adapter->watchdog_timer); in igbvf_down()
1594 igbvf_update_stats(adapter); in igbvf_down()
1596 adapter->link_speed = 0; in igbvf_down()
1597 adapter->link_duplex = 0; in igbvf_down()
1599 igbvf_reset(adapter); in igbvf_down()
1600 igbvf_clean_tx_ring(adapter->tx_ring); in igbvf_down()
1601 igbvf_clean_rx_ring(adapter->rx_ring); in igbvf_down()
1604 void igbvf_reinit_locked(struct igbvf_adapter *adapter) in igbvf_reinit_locked() argument
1607 while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_reinit_locked()
1609 igbvf_down(adapter); in igbvf_reinit_locked()
1610 igbvf_up(adapter); in igbvf_reinit_locked()
1611 clear_bit(__IGBVF_RESETTING, &adapter->state); in igbvf_reinit_locked()
1616 * @adapter: board private structure to initialize
1618 * igbvf_sw_init initializes the Adapter private data structure.
1622 static int igbvf_sw_init(struct igbvf_adapter *adapter) in igbvf_sw_init() argument
1624 struct net_device *netdev = adapter->netdev; in igbvf_sw_init()
1627 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + ETH_FCS_LEN; in igbvf_sw_init()
1628 adapter->rx_ps_hdr_size = 0; in igbvf_sw_init()
1629 adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; in igbvf_sw_init()
1630 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; in igbvf_sw_init()
1632 adapter->requested_itr = 3; in igbvf_sw_init()
1633 adapter->current_itr = IGBVF_START_ITR; in igbvf_sw_init()
1636 adapter->ei->init_ops(&adapter->hw); in igbvf_sw_init()
1638 rc = adapter->hw.mac.ops.init_params(&adapter->hw); in igbvf_sw_init()
1642 rc = adapter->hw.mbx.ops.init_params(&adapter->hw); in igbvf_sw_init()
1646 igbvf_set_interrupt_capability(adapter); in igbvf_sw_init()
1648 if (igbvf_alloc_queues(adapter)) in igbvf_sw_init()
1652 igbvf_irq_disable(adapter); in igbvf_sw_init()
1654 spin_lock_init(&adapter->hw.mbx_lock); in igbvf_sw_init()
1656 set_bit(__IGBVF_DOWN, &adapter->state); in igbvf_sw_init()
1660 static void igbvf_initialize_last_counter_stats(struct igbvf_adapter *adapter) in igbvf_initialize_last_counter_stats() argument
1662 struct e1000_hw *hw = &adapter->hw; in igbvf_initialize_last_counter_stats()
1664 adapter->stats.last_gprc = er32(VFGPRC); in igbvf_initialize_last_counter_stats()
1665 adapter->stats.last_gorc = er32(VFGORC); in igbvf_initialize_last_counter_stats()
1666 adapter->stats.last_gptc = er32(VFGPTC); in igbvf_initialize_last_counter_stats()
1667 adapter->stats.last_gotc = er32(VFGOTC); in igbvf_initialize_last_counter_stats()
1668 adapter->stats.last_mprc = er32(VFMPRC); in igbvf_initialize_last_counter_stats()
1669 adapter->stats.last_gotlbc = er32(VFGOTLBC); in igbvf_initialize_last_counter_stats()
1670 adapter->stats.last_gptlbc = er32(VFGPTLBC); in igbvf_initialize_last_counter_stats()
1671 adapter->stats.last_gorlbc = er32(VFGORLBC); in igbvf_initialize_last_counter_stats()
1672 adapter->stats.last_gprlbc = er32(VFGPRLBC); in igbvf_initialize_last_counter_stats()
1674 adapter->stats.base_gprc = er32(VFGPRC); in igbvf_initialize_last_counter_stats()
1675 adapter->stats.base_gorc = er32(VFGORC); in igbvf_initialize_last_counter_stats()
1676 adapter->stats.base_gptc = er32(VFGPTC); in igbvf_initialize_last_counter_stats()
1677 adapter->stats.base_gotc = er32(VFGOTC); in igbvf_initialize_last_counter_stats()
1678 adapter->stats.base_mprc = er32(VFMPRC); in igbvf_initialize_last_counter_stats()
1679 adapter->stats.base_gotlbc = er32(VFGOTLBC); in igbvf_initialize_last_counter_stats()
1680 adapter->stats.base_gptlbc = er32(VFGPTLBC); in igbvf_initialize_last_counter_stats()
1681 adapter->stats.base_gorlbc = er32(VFGORLBC); in igbvf_initialize_last_counter_stats()
1682 adapter->stats.base_gprlbc = er32(VFGPRLBC); in igbvf_initialize_last_counter_stats()
1699 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_open() local
1700 struct e1000_hw *hw = &adapter->hw; in igbvf_open()
1704 if (test_bit(__IGBVF_TESTING, &adapter->state)) in igbvf_open()
1708 err = igbvf_setup_tx_resources(adapter, adapter->tx_ring); in igbvf_open()
1713 err = igbvf_setup_rx_resources(adapter, adapter->rx_ring); in igbvf_open()
1722 igbvf_configure(adapter); in igbvf_open()
1724 err = igbvf_request_irq(adapter); in igbvf_open()
1729 clear_bit(__IGBVF_DOWN, &adapter->state); in igbvf_open()
1731 napi_enable(&adapter->rx_ring->napi); in igbvf_open()
1736 igbvf_irq_enable(adapter); in igbvf_open()
1740 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igbvf_open()
1745 igbvf_free_rx_resources(adapter->rx_ring); in igbvf_open()
1747 igbvf_free_tx_resources(adapter->tx_ring); in igbvf_open()
1749 igbvf_reset(adapter); in igbvf_open()
1767 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_close() local
1769 WARN_ON(test_bit(__IGBVF_RESETTING, &adapter->state)); in igbvf_close()
1770 igbvf_down(adapter); in igbvf_close()
1772 igbvf_free_irq(adapter); in igbvf_close()
1774 igbvf_free_tx_resources(adapter->tx_ring); in igbvf_close()
1775 igbvf_free_rx_resources(adapter->rx_ring); in igbvf_close()
1789 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_mac() local
1790 struct e1000_hw *hw = &adapter->hw; in igbvf_set_mac()
1815 if (current_counter < adapter->stats.last_##name) \
1816 adapter->stats.name += 0x100000000LL; \
1817 adapter->stats.last_##name = current_counter; \
1818 adapter->stats.name &= 0xFFFFFFFF00000000LL; \
1819 adapter->stats.name |= current_counter; \
1824 * @adapter: board private structure
1826 void igbvf_update_stats(struct igbvf_adapter *adapter) in igbvf_update_stats() argument
1828 struct e1000_hw *hw = &adapter->hw; in igbvf_update_stats()
1829 struct pci_dev *pdev = adapter->pdev; in igbvf_update_stats()
1831 /* Prevent stats update while adapter is being reset, link is down in igbvf_update_stats()
1834 if (adapter->link_speed == 0) in igbvf_update_stats()
1837 if (test_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_update_stats()
1854 adapter->netdev->stats.multicast = adapter->stats.mprc; in igbvf_update_stats()
1857 static void igbvf_print_link_info(struct igbvf_adapter *adapter) in igbvf_print_link_info() argument
1859 dev_info(&adapter->pdev->dev, "Link is Up %d Mbps %s Duplex\n", in igbvf_print_link_info()
1860 adapter->link_speed, in igbvf_print_link_info()
1861 adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half"); in igbvf_print_link_info()
1864 static bool igbvf_has_link(struct igbvf_adapter *adapter) in igbvf_has_link() argument
1866 struct e1000_hw *hw = &adapter->hw; in igbvf_has_link()
1871 if (test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_has_link()
1883 if (ret_val && time_after(jiffies, adapter->last_reset + (10 * HZ))) in igbvf_has_link()
1884 schedule_work(&adapter->reset_task); in igbvf_has_link()
1895 struct igbvf_adapter *adapter = timer_container_of(adapter, t, in igbvf_watchdog() local
1899 schedule_work(&adapter->watchdog_task); in igbvf_watchdog()
1904 struct igbvf_adapter *adapter = container_of(work, in igbvf_watchdog_task() local
1907 struct net_device *netdev = adapter->netdev; in igbvf_watchdog_task()
1908 struct e1000_mac_info *mac = &adapter->hw.mac; in igbvf_watchdog_task()
1909 struct igbvf_ring *tx_ring = adapter->tx_ring; in igbvf_watchdog_task()
1910 struct e1000_hw *hw = &adapter->hw; in igbvf_watchdog_task()
1914 link = igbvf_has_link(adapter); in igbvf_watchdog_task()
1918 mac->ops.get_link_up_info(&adapter->hw, in igbvf_watchdog_task()
1919 &adapter->link_speed, in igbvf_watchdog_task()
1920 &adapter->link_duplex); in igbvf_watchdog_task()
1921 igbvf_print_link_info(adapter); in igbvf_watchdog_task()
1928 adapter->link_speed = 0; in igbvf_watchdog_task()
1929 adapter->link_duplex = 0; in igbvf_watchdog_task()
1930 dev_info(&adapter->pdev->dev, "Link is Down\n"); in igbvf_watchdog_task()
1937 igbvf_update_stats(adapter); in igbvf_watchdog_task()
1947 adapter->tx_timeout_count++; in igbvf_watchdog_task()
1948 schedule_work(&adapter->reset_task); in igbvf_watchdog_task()
1953 ew32(EICS, adapter->rx_ring->eims_value); in igbvf_watchdog_task()
1956 if (!test_bit(__IGBVF_DOWN, &adapter->state)) in igbvf_watchdog_task()
1957 mod_timer(&adapter->watchdog_timer, in igbvf_watchdog_task()
2110 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_maybe_stop_tx() local
2113 if (igbvf_desc_unused(adapter->tx_ring) >= size) in igbvf_maybe_stop_tx()
2125 if (igbvf_desc_unused(adapter->tx_ring) < size) in igbvf_maybe_stop_tx()
2130 ++adapter->restart_queue; in igbvf_maybe_stop_tx()
2137 static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter, in igbvf_tx_map_adv() argument
2142 struct pci_dev *pdev = adapter->pdev; in igbvf_tx_map_adv()
2203 igbvf_put_txbuf(adapter, buffer_info); in igbvf_tx_map_adv()
2209 static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter, in igbvf_tx_queue_adv() argument
2255 tx_desc->read.cmd_type_len |= cpu_to_le32(adapter->txd_cmd); in igbvf_tx_queue_adv()
2265 writel(i, adapter->hw.hw_addr + tx_ring->tail); in igbvf_tx_queue_adv()
2272 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_xmit_frame_ring_adv() local
2279 if (test_bit(__IGBVF_DOWN, &adapter->state)) { in igbvf_xmit_frame_ring_adv()
2326 count = igbvf_tx_map_adv(adapter, tx_ring, skb); in igbvf_xmit_frame_ring_adv()
2329 igbvf_tx_queue_adv(adapter, tx_ring, tx_flags, count, in igbvf_xmit_frame_ring_adv()
2345 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_xmit_frame() local
2348 if (test_bit(__IGBVF_DOWN, &adapter->state)) { in igbvf_xmit_frame()
2353 tx_ring = &adapter->tx_ring[0]; in igbvf_xmit_frame()
2365 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_tx_timeout() local
2368 adapter->tx_timeout_count++; in igbvf_tx_timeout()
2369 schedule_work(&adapter->reset_task); in igbvf_tx_timeout()
2374 struct igbvf_adapter *adapter; in igbvf_reset_task() local
2376 adapter = container_of(work, struct igbvf_adapter, reset_task); in igbvf_reset_task()
2378 igbvf_reinit_locked(adapter); in igbvf_reset_task()
2390 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_change_mtu() local
2393 while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_change_mtu()
2396 adapter->max_frame_size = max_frame; in igbvf_change_mtu()
2398 igbvf_down(adapter); in igbvf_change_mtu()
2409 adapter->rx_buffer_len = 1024; in igbvf_change_mtu()
2411 adapter->rx_buffer_len = 2048; in igbvf_change_mtu()
2414 adapter->rx_buffer_len = 16384; in igbvf_change_mtu()
2416 adapter->rx_buffer_len = PAGE_SIZE / 2; in igbvf_change_mtu()
2422 adapter->rx_buffer_len = ETH_FRAME_LEN + VLAN_HLEN + in igbvf_change_mtu()
2430 igbvf_up(adapter); in igbvf_change_mtu()
2432 igbvf_reset(adapter); in igbvf_change_mtu()
2434 clear_bit(__IGBVF_RESETTING, &adapter->state); in igbvf_change_mtu()
2450 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_suspend() local
2455 WARN_ON(test_bit(__IGBVF_RESETTING, &adapter->state)); in igbvf_suspend()
2456 igbvf_down(adapter); in igbvf_suspend()
2457 igbvf_free_irq(adapter); in igbvf_suspend()
2467 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_resume() local
2473 err = igbvf_request_irq(adapter); in igbvf_resume()
2478 igbvf_reset(adapter); in igbvf_resume()
2481 igbvf_up(adapter); in igbvf_resume()
2500 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_netpoll() local
2502 disable_irq(adapter->pdev->irq); in igbvf_netpoll()
2504 igbvf_clean_tx_irq(adapter->tx_ring); in igbvf_netpoll()
2506 enable_irq(adapter->pdev->irq); in igbvf_netpoll()
2522 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_error_detected() local
2530 igbvf_down(adapter); in igbvf_io_error_detected()
2547 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_slot_reset() local
2556 igbvf_reset(adapter); in igbvf_io_slot_reset()
2572 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_resume() local
2575 if (igbvf_up(adapter)) { in igbvf_io_resume()
2592 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_prepare() local
2594 while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state)) in igbvf_io_prepare()
2596 igbvf_down(adapter); in igbvf_io_prepare()
2606 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_io_reset_done() local
2608 igbvf_up(adapter); in igbvf_io_reset_done()
2609 clear_bit(__IGBVF_RESETTING, &adapter->state); in igbvf_io_reset_done()
2612 static void igbvf_print_device_info(struct igbvf_adapter *adapter) in igbvf_print_device_info() argument
2614 struct e1000_hw *hw = &adapter->hw; in igbvf_print_device_info()
2615 struct net_device *netdev = adapter->netdev; in igbvf_print_device_info()
2616 struct pci_dev *pdev = adapter->pdev; in igbvf_print_device_info()
2628 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_set_features() local
2631 adapter->flags &= ~IGBVF_FLAG_RX_CSUM_DISABLED; in igbvf_set_features()
2633 adapter->flags |= IGBVF_FLAG_RX_CSUM_DISABLED; in igbvf_set_features()
2697 * igbvf_probe initializes an adapter identified by a pci_dev structure.
2698 * The OS initialization, configuring of the adapter private structure,
2704 struct igbvf_adapter *adapter; in igbvf_probe() local
2734 adapter = netdev_priv(netdev); in igbvf_probe()
2735 hw = &adapter->hw; in igbvf_probe()
2736 adapter->netdev = netdev; in igbvf_probe()
2737 adapter->pdev = pdev; in igbvf_probe()
2738 adapter->ei = ei; in igbvf_probe()
2739 adapter->pba = ei->pba; in igbvf_probe()
2740 adapter->flags = ei->flags; in igbvf_probe()
2741 adapter->hw.back = adapter; in igbvf_probe()
2742 adapter->hw.mac.type = ei->mac; in igbvf_probe()
2743 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); in igbvf_probe()
2754 adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, 0), in igbvf_probe()
2757 if (!adapter->hw.hw_addr) in igbvf_probe()
2761 err = ei->get_variants(adapter); in igbvf_probe()
2766 /* setup adapter struct */ in igbvf_probe()
2767 err = igbvf_sw_init(adapter); in igbvf_probe()
2822 else if (is_zero_ether_addr(adapter->hw.mac.addr)) in igbvf_probe()
2825 eth_hw_addr_set(netdev, adapter->hw.mac.addr); in igbvf_probe()
2833 memcpy(adapter->hw.mac.addr, netdev->dev_addr, in igbvf_probe()
2837 timer_setup(&adapter->watchdog_timer, igbvf_watchdog, 0); in igbvf_probe()
2839 INIT_WORK(&adapter->reset_task, igbvf_reset_task); in igbvf_probe()
2840 INIT_WORK(&adapter->watchdog_task, igbvf_watchdog_task); in igbvf_probe()
2843 adapter->rx_ring->count = 1024; in igbvf_probe()
2844 adapter->tx_ring->count = 1024; in igbvf_probe()
2847 igbvf_reset(adapter); in igbvf_probe()
2850 if (adapter->hw.mac.type == e1000_vfadapt_i350) in igbvf_probe()
2851 adapter->flags |= IGBVF_FLAG_RX_LB_VLAN_BSWAP; in igbvf_probe()
2862 igbvf_print_device_info(adapter); in igbvf_probe()
2864 igbvf_initialize_last_counter_stats(adapter); in igbvf_probe()
2869 netif_napi_del(&adapter->rx_ring->napi); in igbvf_probe()
2870 kfree(adapter->tx_ring); in igbvf_probe()
2871 kfree(adapter->rx_ring); in igbvf_probe()
2873 igbvf_reset_interrupt_capability(adapter); in igbvf_probe()
2875 iounmap(adapter->hw.hw_addr); in igbvf_probe()
2898 struct igbvf_adapter *adapter = netdev_priv(netdev); in igbvf_remove() local
2899 struct e1000_hw *hw = &adapter->hw; in igbvf_remove()
2904 set_bit(__IGBVF_DOWN, &adapter->state); in igbvf_remove()
2905 timer_delete_sync(&adapter->watchdog_timer); in igbvf_remove()
2907 cancel_work_sync(&adapter->reset_task); in igbvf_remove()
2908 cancel_work_sync(&adapter->watchdog_task); in igbvf_remove()
2912 igbvf_reset_interrupt_capability(adapter); in igbvf_remove()
2917 netif_napi_del(&adapter->rx_ring->napi); in igbvf_remove()
2918 kfree(adapter->tx_ring); in igbvf_remove()
2919 kfree(adapter->rx_ring); in igbvf_remove()