Lines Matching full:adapter

50 vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, const u8 *mac);
56 vmxnet3_enable_intr(struct vmxnet3_adapter *adapter, unsigned intr_idx) in vmxnet3_enable_intr() argument
58 VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_IMR + intr_idx * 8, 0); in vmxnet3_enable_intr()
63 vmxnet3_disable_intr(struct vmxnet3_adapter *adapter, unsigned intr_idx) in vmxnet3_disable_intr() argument
65 VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_IMR + intr_idx * 8, 1); in vmxnet3_disable_intr()
73 vmxnet3_enable_all_intrs(struct vmxnet3_adapter *adapter) in vmxnet3_enable_all_intrs() argument
77 for (i = 0; i < adapter->intr.num_intrs; i++) in vmxnet3_enable_all_intrs()
78 vmxnet3_enable_intr(adapter, i); in vmxnet3_enable_all_intrs()
79 if (!VMXNET3_VERSION_GE_6(adapter) || in vmxnet3_enable_all_intrs()
80 !adapter->queuesExtEnabled) { in vmxnet3_enable_all_intrs()
81 adapter->shared->devRead.intrConf.intrCtrl &= in vmxnet3_enable_all_intrs()
84 adapter->shared->devReadExt.intrConfExt.intrCtrl &= in vmxnet3_enable_all_intrs()
91 vmxnet3_disable_all_intrs(struct vmxnet3_adapter *adapter) in vmxnet3_disable_all_intrs() argument
95 if (!VMXNET3_VERSION_GE_6(adapter) || in vmxnet3_disable_all_intrs()
96 !adapter->queuesExtEnabled) { in vmxnet3_disable_all_intrs()
97 adapter->shared->devRead.intrConf.intrCtrl |= in vmxnet3_disable_all_intrs()
100 adapter->shared->devReadExt.intrConfExt.intrCtrl |= in vmxnet3_disable_all_intrs()
103 for (i = 0; i < adapter->intr.num_intrs; i++) in vmxnet3_disable_all_intrs()
104 vmxnet3_disable_intr(adapter, i); in vmxnet3_disable_all_intrs()
109 vmxnet3_ack_events(struct vmxnet3_adapter *adapter, u32 events) in vmxnet3_ack_events() argument
111 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_ECR, events); in vmxnet3_ack_events()
116 vmxnet3_tq_stopped(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) in vmxnet3_tq_stopped() argument
123 vmxnet3_tq_start(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) in vmxnet3_tq_start() argument
126 netif_start_subqueue(adapter->netdev, tq - adapter->tx_queue); in vmxnet3_tq_start()
131 vmxnet3_tq_wake(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) in vmxnet3_tq_wake() argument
134 netif_wake_subqueue(adapter->netdev, (tq - adapter->tx_queue)); in vmxnet3_tq_wake()
139 vmxnet3_tq_stop(struct vmxnet3_tx_queue *tq, struct vmxnet3_adapter *adapter) in vmxnet3_tq_stop() argument
143 netif_stop_subqueue(adapter->netdev, (tq - adapter->tx_queue)); in vmxnet3_tq_stop()
165 vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue) in vmxnet3_check_link() argument
171 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_check_link()
172 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK); in vmxnet3_check_link()
173 ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_check_link()
174 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_check_link()
176 adapter->link_speed = ret >> 16; in vmxnet3_check_link()
178 netdev_info(adapter->netdev, "NIC Link is Up %d Mbps\n", in vmxnet3_check_link()
179 adapter->link_speed); in vmxnet3_check_link()
180 netif_carrier_on(adapter->netdev); in vmxnet3_check_link()
183 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_check_link()
184 vmxnet3_tq_start(&adapter->tx_queue[i], in vmxnet3_check_link()
185 adapter); in vmxnet3_check_link()
188 netdev_info(adapter->netdev, "NIC Link is Down\n"); in vmxnet3_check_link()
189 netif_carrier_off(adapter->netdev); in vmxnet3_check_link()
192 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_check_link()
193 vmxnet3_tq_stop(&adapter->tx_queue[i], adapter); in vmxnet3_check_link()
199 vmxnet3_process_events(struct vmxnet3_adapter *adapter) in vmxnet3_process_events() argument
203 u32 events = le32_to_cpu(adapter->shared->ecr); in vmxnet3_process_events()
207 vmxnet3_ack_events(adapter, events); in vmxnet3_process_events()
211 vmxnet3_check_link(adapter, true); in vmxnet3_process_events()
215 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_process_events()
216 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_process_events()
218 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_process_events()
220 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_process_events()
221 if (adapter->tqd_start[i].status.stopped) in vmxnet3_process_events()
222 dev_err(&adapter->netdev->dev, in vmxnet3_process_events()
224 adapter->netdev->name, i, le32_to_cpu( in vmxnet3_process_events()
225 adapter->tqd_start[i].status.error)); in vmxnet3_process_events()
226 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_process_events()
227 if (adapter->rqd_start[i].status.stopped) in vmxnet3_process_events()
228 dev_err(&adapter->netdev->dev, in vmxnet3_process_events()
230 adapter->netdev->name, i, in vmxnet3_process_events()
231 adapter->rqd_start[i].status.error); in vmxnet3_process_events()
233 schedule_work(&adapter->work); in vmxnet3_process_events()
359 struct pci_dev *pdev, struct vmxnet3_adapter *adapter, in vmxnet3_unmap_pkt() argument
402 struct vmxnet3_adapter *adapter) in vmxnet3_tq_tx_complete() argument
419 &gdesc->tcd), tq, adapter->pdev, in vmxnet3_tq_tx_complete()
420 adapter, &bq); in vmxnet3_tq_tx_complete()
430 if (unlikely(vmxnet3_tq_stopped(tq, adapter) && in vmxnet3_tq_tx_complete()
433 netif_carrier_ok(adapter->netdev))) { in vmxnet3_tq_tx_complete()
434 vmxnet3_tq_wake(tq, adapter); in vmxnet3_tq_tx_complete()
444 struct vmxnet3_adapter *adapter) in vmxnet3_tq_cleanup() argument
459 vmxnet3_unmap_tx_buf(tbi, adapter->pdev); in vmxnet3_tq_cleanup()
487 struct vmxnet3_adapter *adapter) in vmxnet3_tq_destroy() argument
490 dma_free_coherent(&adapter->pdev->dev, tq->tx_ring.size * in vmxnet3_tq_destroy()
496 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_tq_destroy()
502 dma_free_coherent(&adapter->pdev->dev, tq->comp_ring.size * in vmxnet3_tq_destroy()
514 vmxnet3_tq_destroy_all(struct vmxnet3_adapter *adapter) in vmxnet3_tq_destroy_all() argument
518 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_tq_destroy_all()
519 vmxnet3_tq_destroy(&adapter->tx_queue[i], adapter); in vmxnet3_tq_destroy_all()
525 struct vmxnet3_adapter *adapter) in vmxnet3_tq_init() argument
555 struct vmxnet3_adapter *adapter) in vmxnet3_tq_create() argument
560 tq->tx_ring.base = dma_alloc_coherent(&adapter->pdev->dev, in vmxnet3_tq_create()
564 netdev_err(adapter->netdev, "failed to allocate tx ring\n"); in vmxnet3_tq_create()
568 tq->data_ring.base = dma_alloc_coherent(&adapter->pdev->dev, in vmxnet3_tq_create()
572 netdev_err(adapter->netdev, "failed to allocate tx data ring\n"); in vmxnet3_tq_create()
576 tq->comp_ring.base = dma_alloc_coherent(&adapter->pdev->dev, in vmxnet3_tq_create()
580 netdev_err(adapter->netdev, "failed to allocate tx comp ring\n"); in vmxnet3_tq_create()
586 dev_to_node(&adapter->pdev->dev)); in vmxnet3_tq_create()
593 vmxnet3_tq_destroy(tq, adapter); in vmxnet3_tq_create()
598 vmxnet3_tq_cleanup_all(struct vmxnet3_adapter *adapter) in vmxnet3_tq_cleanup_all() argument
602 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_tq_cleanup_all()
603 vmxnet3_tq_cleanup(&adapter->tx_queue[i], adapter); in vmxnet3_tq_cleanup_all()
614 int num_to_alloc, struct vmxnet3_adapter *adapter) in vmxnet3_rq_alloc_rx_buf() argument
641 rbi->skb = __netdev_alloc_skb_ip_align(adapter->netdev, in vmxnet3_rq_alloc_rx_buf()
650 &adapter->pdev->dev, in vmxnet3_rq_alloc_rx_buf()
653 if (dma_mapping_error(&adapter->pdev->dev, in vmxnet3_rq_alloc_rx_buf()
675 &adapter->pdev->dev, in vmxnet3_rq_alloc_rx_buf()
678 if (dma_mapping_error(&adapter->pdev->dev, in vmxnet3_rq_alloc_rx_buf()
707 netdev_dbg(adapter->netdev, in vmxnet3_rq_alloc_rx_buf()
736 struct vmxnet3_adapter *adapter) in vmxnet3_map_pkt() argument
763 netdev_dbg(adapter->netdev, in vmxnet3_map_pkt()
790 tbi->dma_addr = dma_map_single(&adapter->pdev->dev, in vmxnet3_map_pkt()
793 if (dma_mapping_error(&adapter->pdev->dev, tbi->dma_addr)) in vmxnet3_map_pkt()
805 netdev_dbg(adapter->netdev, in vmxnet3_map_pkt()
832 tbi->dma_addr = skb_frag_dma_map(&adapter->pdev->dev, frag, in vmxnet3_map_pkt()
835 if (dma_mapping_error(&adapter->pdev->dev, tbi->dma_addr)) in vmxnet3_map_pkt()
847 netdev_dbg(adapter->netdev, in vmxnet3_map_pkt()
871 vmxnet3_tq_init_all(struct vmxnet3_adapter *adapter) in vmxnet3_tq_init_all() argument
875 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_tq_init_all()
876 vmxnet3_tq_init(&adapter->tx_queue[i], adapter); in vmxnet3_tq_init_all()
900 struct vmxnet3_adapter *adapter) in vmxnet3_parse_hdr() argument
905 if (VMXNET3_VERSION_GE_4(adapter) && skb->encapsulation) { in vmxnet3_parse_hdr()
922 if (VMXNET3_VERSION_GE_4(adapter) && in vmxnet3_parse_hdr()
1003 struct vmxnet3_adapter *adapter) in vmxnet3_copy_hdr() argument
1012 netdev_dbg(adapter->netdev, in vmxnet3_copy_hdr()
1082 struct vmxnet3_adapter *adapter, struct net_device *netdev) in vmxnet3_tq_xmit() argument
1150 ret = vmxnet3_parse_hdr(skb, tq, &ctx, adapter); in vmxnet3_tq_xmit()
1179 netdev_dbg(adapter->netdev, in vmxnet3_tq_xmit()
1181 " next2fill %u\n", adapter->netdev->name, in vmxnet3_tq_xmit()
1184 vmxnet3_tq_stop(tq, adapter); in vmxnet3_tq_xmit()
1190 vmxnet3_copy_hdr(skb, tq, &ctx, adapter); in vmxnet3_tq_xmit()
1193 if (vmxnet3_map_pkt(skb, &ctx, tq, adapter->pdev, adapter)) in vmxnet3_tq_xmit()
1209 if (VMXNET3_VERSION_GE_4(adapter) && skb->encapsulation) { in vmxnet3_tq_xmit()
1211 if (VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_tq_xmit()
1229 if (VMXNET3_VERSION_GE_4(adapter) && in vmxnet3_tq_xmit()
1233 if (VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_tq_xmit()
1278 netdev_dbg(adapter->netdev, in vmxnet3_tq_xmit()
1288 VMXNET3_WRITE_BAR0_REG(adapter, in vmxnet3_tq_xmit()
1289 adapter->tx_prod_offset + tq->qid * 8, in vmxnet3_tq_xmit()
1304 vmxnet3_create_pp(struct vmxnet3_adapter *adapter, in vmxnet3_create_pp() argument
1307 bool xdp_prog = vmxnet3_xdp_enabled(adapter); in vmxnet3_create_pp()
1313 .dev = &adapter->pdev->dev, in vmxnet3_create_pp()
1325 err = xdp_rxq_info_reg(&rq->xdp_rxq, adapter->netdev, rq->qid, in vmxnet3_create_pp()
1364 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_xmit_frame() local
1366 BUG_ON(skb->queue_mapping > adapter->num_tx_queues); in vmxnet3_xmit_frame()
1368 &adapter->tx_queue[skb->queue_mapping], in vmxnet3_xmit_frame()
1369 adapter, netdev); in vmxnet3_xmit_frame()
1374 vmxnet3_rx_csum(struct vmxnet3_adapter *adapter, in vmxnet3_rx_csum() argument
1378 if (!gdesc->rcd.cnc && adapter->netdev->features & NETIF_F_RXCSUM) { in vmxnet3_rx_csum()
1422 struct vmxnet3_rx_ctx *ctx, struct vmxnet3_adapter *adapter) in vmxnet3_rx_error() argument
1448 vmxnet3_get_hdr_len(struct vmxnet3_adapter *adapter, struct sk_buff *skb, in vmxnet3_get_hdr_len() argument
1504 struct vmxnet3_adapter *adapter, int quota) in vmxnet3_rq_rx_complete() argument
1507 adapter->rx_prod_offset, adapter->rx_prod2_offset in vmxnet3_rq_rx_complete()
1548 ring_idx = VMXNET3_GET_RING_IDX(adapter, rcd->rqID); in vmxnet3_rq_rx_complete()
1558 vmxnet3_rx_error(rq, rcd, ctx, adapter); in vmxnet3_rq_rx_complete()
1562 if (rcd->sop && rcd->eop && vmxnet3_xdp_enabled(adapter)) { in vmxnet3_rq_rx_complete()
1566 if (VMXNET3_RX_DATA_RING(adapter, rcd->rqID)) { in vmxnet3_rq_rx_complete()
1574 act = vmxnet3_process_xdp(adapter, rq, rcd, rbi, rxd, in vmxnet3_rq_rx_complete()
1602 netdev_dbg(adapter->netdev, in vmxnet3_rq_rx_complete()
1612 VMXNET3_RX_DATA_RING(adapter, rcd->rqID); in vmxnet3_rq_rx_complete()
1615 if (rxDataRingUsed && vmxnet3_xdp_enabled(adapter)) { in vmxnet3_rq_rx_complete()
1621 act = vmxnet3_process_xdp_small(adapter, rq, in vmxnet3_rq_rx_complete()
1633 new_skb = netdev_alloc_skb_ip_align(adapter->netdev, in vmxnet3_rq_rx_complete()
1646 if (rxDataRingUsed && adapter->rxdataring_enabled) { in vmxnet3_rq_rx_complete()
1659 dma_map_single(&adapter->pdev->dev, in vmxnet3_rq_rx_complete()
1662 if (dma_mapping_error(&adapter->pdev->dev, in vmxnet3_rq_rx_complete()
1676 dma_unmap_single(&adapter->pdev->dev, in vmxnet3_rq_rx_complete()
1691 if (VMXNET3_VERSION_GE_2(adapter) && in vmxnet3_rq_rx_complete()
1736 new_dma_addr = dma_map_page(&adapter->pdev->dev, in vmxnet3_rq_rx_complete()
1740 if (dma_mapping_error(&adapter->pdev->dev, in vmxnet3_rq_rx_complete()
1750 dma_unmap_page(&adapter->pdev->dev, in vmxnet3_rq_rx_complete()
1768 u32 mtu = adapter->netdev->mtu; in vmxnet3_rq_rx_complete()
1773 (adapter->netdev->features & NETIF_F_RXHASH)) { in vmxnet3_rq_rx_complete()
1796 vmxnet3_rx_csum(adapter, skb, in vmxnet3_rq_rx_complete()
1798 skb->protocol = eth_type_trans(skb, adapter->netdev); in vmxnet3_rq_rx_complete()
1800 !(adapter->netdev->features & NETIF_F_LRO)) in vmxnet3_rq_rx_complete()
1811 hlen = vmxnet3_get_hdr_len(adapter, skb, in vmxnet3_rq_rx_complete()
1832 if ((adapter->netdev->features & NETIF_F_LRO) && in vmxnet3_rq_rx_complete()
1862 if (!(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_OOORX_COMP))) in vmxnet3_rq_rx_complete()
1893 VMXNET3_WRITE_BAR0_REG(adapter, in vmxnet3_rq_rx_complete()
1911 struct vmxnet3_adapter *adapter) in vmxnet3_rq_cleanup() argument
1938 dma_unmap_single(&adapter->pdev->dev, rxd->addr, in vmxnet3_rq_cleanup()
1944 dma_unmap_page(&adapter->pdev->dev, rxd->addr, in vmxnet3_rq_cleanup()
1962 vmxnet3_rq_cleanup_all(struct vmxnet3_adapter *adapter) in vmxnet3_rq_cleanup_all() argument
1966 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_rq_cleanup_all()
1967 vmxnet3_rq_cleanup(&adapter->rx_queue[i], adapter); in vmxnet3_rq_cleanup_all()
1968 rcu_assign_pointer(adapter->xdp_bpf_prog, NULL); in vmxnet3_rq_cleanup_all()
1973 struct vmxnet3_adapter *adapter) in vmxnet3_rq_destroy() argument
1989 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_rq_destroy()
2004 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_rq_destroy()
2011 dma_free_coherent(&adapter->pdev->dev, rq->comp_ring.size in vmxnet3_rq_destroy()
2023 vmxnet3_rq_destroy_all_rxdataring(struct vmxnet3_adapter *adapter) in vmxnet3_rq_destroy_all_rxdataring() argument
2027 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_rq_destroy_all_rxdataring()
2028 struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i]; in vmxnet3_rq_destroy_all_rxdataring()
2031 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_rq_destroy_all_rxdataring()
2044 struct vmxnet3_adapter *adapter) in vmxnet3_rq_init() argument
2052 if (i % adapter->rx_buf_per_pkt == 0) { in vmxnet3_rq_init()
2053 rq->buf_info[0][i].buf_type = vmxnet3_xdp_enabled(adapter) ? in vmxnet3_rq_init()
2056 rq->buf_info[0][i].len = adapter->skb_buf_size; in vmxnet3_rq_init()
2077 err = vmxnet3_create_pp(adapter, rq, in vmxnet3_rq_init()
2083 adapter) == 0) { in vmxnet3_rq_init()
2091 vmxnet3_rq_alloc_rx_buf(rq, 1, rq->rx_ring[1].size - 1, adapter); in vmxnet3_rq_init()
2108 vmxnet3_rq_init_all(struct vmxnet3_adapter *adapter) in vmxnet3_rq_init_all() argument
2112 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_rq_init_all()
2113 err = vmxnet3_rq_init(&adapter->rx_queue[i], adapter); in vmxnet3_rq_init_all()
2115 dev_err(&adapter->netdev->dev, "%s: failed to " in vmxnet3_rq_init_all()
2117 adapter->netdev->name, i); in vmxnet3_rq_init_all()
2127 vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter) in vmxnet3_rq_create() argument
2137 &adapter->pdev->dev, sz, in vmxnet3_rq_create()
2141 netdev_err(adapter->netdev, in vmxnet3_rq_create()
2147 if ((adapter->rxdataring_enabled) && (rq->data_ring.desc_size != 0)) { in vmxnet3_rq_create()
2150 dma_alloc_coherent(&adapter->pdev->dev, sz, in vmxnet3_rq_create()
2154 netdev_err(adapter->netdev, in vmxnet3_rq_create()
2156 adapter->rxdataring_enabled = false; in vmxnet3_rq_create()
2164 rq->comp_ring.base = dma_alloc_coherent(&adapter->pdev->dev, sz, in vmxnet3_rq_create()
2168 netdev_err(adapter->netdev, "failed to allocate rx comp ring\n"); in vmxnet3_rq_create()
2174 dev_to_node(&adapter->pdev->dev)); in vmxnet3_rq_create()
2184 vmxnet3_rq_destroy(rq, adapter); in vmxnet3_rq_create()
2190 vmxnet3_rq_create_all(struct vmxnet3_adapter *adapter) in vmxnet3_rq_create_all() argument
2194 adapter->rxdataring_enabled = VMXNET3_VERSION_GE_3(adapter); in vmxnet3_rq_create_all()
2196 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_rq_create_all()
2197 err = vmxnet3_rq_create(&adapter->rx_queue[i], adapter); in vmxnet3_rq_create_all()
2199 dev_err(&adapter->netdev->dev, in vmxnet3_rq_create_all()
2201 adapter->netdev->name, i); in vmxnet3_rq_create_all()
2206 if (!adapter->rxdataring_enabled) in vmxnet3_rq_create_all()
2207 vmxnet3_rq_destroy_all_rxdataring(adapter); in vmxnet3_rq_create_all()
2211 vmxnet3_rq_destroy_all(adapter); in vmxnet3_rq_create_all()
2219 vmxnet3_do_poll(struct vmxnet3_adapter *adapter, int budget) in vmxnet3_do_poll() argument
2222 if (unlikely(adapter->shared->ecr)) in vmxnet3_do_poll()
2223 vmxnet3_process_events(adapter); in vmxnet3_do_poll()
2224 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_do_poll()
2225 vmxnet3_tq_tx_complete(&adapter->tx_queue[i], adapter); in vmxnet3_do_poll()
2227 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_do_poll()
2228 rcd_done += vmxnet3_rq_rx_complete(&adapter->rx_queue[i], in vmxnet3_do_poll()
2229 adapter, budget); in vmxnet3_do_poll()
2241 rxd_done = vmxnet3_do_poll(rx_queue->adapter, budget); in vmxnet3_poll()
2245 vmxnet3_enable_all_intrs(rx_queue->adapter); in vmxnet3_poll()
2260 struct vmxnet3_adapter *adapter = rq->adapter; in vmxnet3_poll_rx_only() local
2266 if (adapter->share_intr == VMXNET3_INTR_BUDDYSHARE) { in vmxnet3_poll_rx_only()
2268 &adapter->tx_queue[rq - adapter->rx_queue]; in vmxnet3_poll_rx_only()
2269 vmxnet3_tq_tx_complete(tq, adapter); in vmxnet3_poll_rx_only()
2272 rxd_done = vmxnet3_rq_rx_complete(rq, adapter, budget); in vmxnet3_poll_rx_only()
2276 vmxnet3_enable_intr(adapter, rq->comp_ring.intr_idx); in vmxnet3_poll_rx_only()
2293 struct vmxnet3_adapter *adapter = tq->adapter; in vmxnet3_msix_tx() local
2295 if (adapter->intr.mask_mode == VMXNET3_IMM_ACTIVE) in vmxnet3_msix_tx()
2296 vmxnet3_disable_intr(adapter, tq->comp_ring.intr_idx); in vmxnet3_msix_tx()
2299 if (adapter->share_intr == VMXNET3_INTR_TXSHARE) { in vmxnet3_msix_tx()
2301 for (i = 0; i < adapter->num_tx_queues; i++) { in vmxnet3_msix_tx()
2302 struct vmxnet3_tx_queue *txq = &adapter->tx_queue[i]; in vmxnet3_msix_tx()
2303 vmxnet3_tq_tx_complete(txq, adapter); in vmxnet3_msix_tx()
2306 vmxnet3_tq_tx_complete(tq, adapter); in vmxnet3_msix_tx()
2308 vmxnet3_enable_intr(adapter, tq->comp_ring.intr_idx); in vmxnet3_msix_tx()
2323 struct vmxnet3_adapter *adapter = rq->adapter; in vmxnet3_msix_rx() local
2326 if (adapter->intr.mask_mode == VMXNET3_IMM_ACTIVE) in vmxnet3_msix_rx()
2327 vmxnet3_disable_intr(adapter, rq->comp_ring.intr_idx); in vmxnet3_msix_rx()
2350 struct vmxnet3_adapter *adapter = netdev_priv(dev); in vmxnet3_msix_event() local
2353 if (adapter->intr.mask_mode == VMXNET3_IMM_ACTIVE) in vmxnet3_msix_event()
2354 vmxnet3_disable_intr(adapter, adapter->intr.event_intr_idx); in vmxnet3_msix_event()
2356 if (adapter->shared->ecr) in vmxnet3_msix_event()
2357 vmxnet3_process_events(adapter); in vmxnet3_msix_event()
2359 vmxnet3_enable_intr(adapter, adapter->intr.event_intr_idx); in vmxnet3_msix_event()
2372 struct vmxnet3_adapter *adapter = netdev_priv(dev); in vmxnet3_intr() local
2374 if (adapter->intr.type == VMXNET3_IT_INTX) { in vmxnet3_intr()
2375 u32 icr = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_ICR); in vmxnet3_intr()
2383 if (adapter->intr.mask_mode == VMXNET3_IMM_ACTIVE) in vmxnet3_intr()
2384 vmxnet3_disable_all_intrs(adapter); in vmxnet3_intr()
2386 napi_schedule(&adapter->rx_queue[0].napi); in vmxnet3_intr()
2397 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_netpoll() local
2399 switch (adapter->intr.type) { in vmxnet3_netpoll()
2403 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_netpoll()
2404 vmxnet3_msix_rx(0, &adapter->rx_queue[i]); in vmxnet3_netpoll()
2410 vmxnet3_intr(0, adapter->netdev); in vmxnet3_netpoll()
2418 vmxnet3_request_irqs(struct vmxnet3_adapter *adapter) in vmxnet3_request_irqs() argument
2420 struct vmxnet3_intr *intr = &adapter->intr; in vmxnet3_request_irqs()
2425 if (adapter->intr.type == VMXNET3_IT_MSIX) { in vmxnet3_request_irqs()
2426 for (i = 0; i < adapter->num_tx_queues; i++) { in vmxnet3_request_irqs()
2427 if (adapter->share_intr != VMXNET3_INTR_BUDDYSHARE) { in vmxnet3_request_irqs()
2428 sprintf(adapter->tx_queue[i].name, "%s-tx-%d", in vmxnet3_request_irqs()
2429 adapter->netdev->name, vector); in vmxnet3_request_irqs()
2433 adapter->tx_queue[i].name, in vmxnet3_request_irqs()
2434 &adapter->tx_queue[i]); in vmxnet3_request_irqs()
2436 sprintf(adapter->tx_queue[i].name, "%s-rxtx-%d", in vmxnet3_request_irqs()
2437 adapter->netdev->name, vector); in vmxnet3_request_irqs()
2440 dev_err(&adapter->netdev->dev, in vmxnet3_request_irqs()
2443 adapter->tx_queue[i].name, err); in vmxnet3_request_irqs()
2449 if (adapter->share_intr == VMXNET3_INTR_TXSHARE) { in vmxnet3_request_irqs()
2450 for (; i < adapter->num_tx_queues; i++) in vmxnet3_request_irqs()
2451 adapter->tx_queue[i].comp_ring.intr_idx in vmxnet3_request_irqs()
2456 adapter->tx_queue[i].comp_ring.intr_idx in vmxnet3_request_irqs()
2460 if (adapter->share_intr == VMXNET3_INTR_BUDDYSHARE) in vmxnet3_request_irqs()
2463 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_request_irqs()
2464 if (adapter->share_intr != VMXNET3_INTR_BUDDYSHARE) in vmxnet3_request_irqs()
2465 sprintf(adapter->rx_queue[i].name, "%s-rx-%d", in vmxnet3_request_irqs()
2466 adapter->netdev->name, vector); in vmxnet3_request_irqs()
2468 sprintf(adapter->rx_queue[i].name, "%s-rxtx-%d", in vmxnet3_request_irqs()
2469 adapter->netdev->name, vector); in vmxnet3_request_irqs()
2472 adapter->rx_queue[i].name, in vmxnet3_request_irqs()
2473 &(adapter->rx_queue[i])); in vmxnet3_request_irqs()
2475 netdev_err(adapter->netdev, in vmxnet3_request_irqs()
2478 adapter->rx_queue[i].name, err); in vmxnet3_request_irqs()
2482 adapter->rx_queue[i].comp_ring.intr_idx = vector++; in vmxnet3_request_irqs()
2486 adapter->netdev->name, vector); in vmxnet3_request_irqs()
2489 intr->event_msi_vector_name, adapter->netdev); in vmxnet3_request_irqs()
2493 adapter->num_rx_queues = 1; in vmxnet3_request_irqs()
2494 err = request_irq(adapter->pdev->irq, vmxnet3_intr, 0, in vmxnet3_request_irqs()
2495 adapter->netdev->name, adapter->netdev); in vmxnet3_request_irqs()
2498 adapter->num_rx_queues = 1; in vmxnet3_request_irqs()
2499 err = request_irq(adapter->pdev->irq, vmxnet3_intr, in vmxnet3_request_irqs()
2500 IRQF_SHARED, adapter->netdev->name, in vmxnet3_request_irqs()
2501 adapter->netdev); in vmxnet3_request_irqs()
2507 netdev_err(adapter->netdev, in vmxnet3_request_irqs()
2512 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_request_irqs()
2513 struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i]; in vmxnet3_request_irqs()
2515 rq->qid2 = i + adapter->num_rx_queues; in vmxnet3_request_irqs()
2516 rq->dataRingQid = i + 2 * adapter->num_rx_queues; in vmxnet3_request_irqs()
2522 if (adapter->intr.type != VMXNET3_IT_MSIX) { in vmxnet3_request_irqs()
2523 adapter->intr.event_intr_idx = 0; in vmxnet3_request_irqs()
2524 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_request_irqs()
2525 adapter->tx_queue[i].comp_ring.intr_idx = 0; in vmxnet3_request_irqs()
2526 adapter->rx_queue[0].comp_ring.intr_idx = 0; in vmxnet3_request_irqs()
2529 netdev_info(adapter->netdev, in vmxnet3_request_irqs()
2539 vmxnet3_free_irqs(struct vmxnet3_adapter *adapter) in vmxnet3_free_irqs() argument
2541 struct vmxnet3_intr *intr = &adapter->intr; in vmxnet3_free_irqs()
2550 if (adapter->share_intr != VMXNET3_INTR_BUDDYSHARE) { in vmxnet3_free_irqs()
2551 for (i = 0; i < adapter->num_tx_queues; i++) { in vmxnet3_free_irqs()
2553 &(adapter->tx_queue[i])); in vmxnet3_free_irqs()
2554 if (adapter->share_intr == VMXNET3_INTR_TXSHARE) in vmxnet3_free_irqs()
2559 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_free_irqs()
2561 &(adapter->rx_queue[i])); in vmxnet3_free_irqs()
2565 adapter->netdev); in vmxnet3_free_irqs()
2571 free_irq(adapter->pdev->irq, adapter->netdev); in vmxnet3_free_irqs()
2574 free_irq(adapter->pdev->irq, adapter->netdev); in vmxnet3_free_irqs()
2583 vmxnet3_restore_vlan(struct vmxnet3_adapter *adapter) in vmxnet3_restore_vlan() argument
2585 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; in vmxnet3_restore_vlan()
2591 for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) in vmxnet3_restore_vlan()
2599 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_vlan_rx_add_vid() local
2602 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; in vmxnet3_vlan_rx_add_vid()
2606 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_vlan_rx_add_vid()
2607 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_vlan_rx_add_vid()
2609 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_vlan_rx_add_vid()
2612 set_bit(vid, adapter->active_vlans); in vmxnet3_vlan_rx_add_vid()
2621 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_vlan_rx_kill_vid() local
2624 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; in vmxnet3_vlan_rx_kill_vid()
2628 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_vlan_rx_kill_vid()
2629 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_vlan_rx_kill_vid()
2631 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_vlan_rx_kill_vid()
2634 clear_bit(vid, adapter->active_vlans); in vmxnet3_vlan_rx_kill_vid()
2666 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_set_mc() local
2669 &adapter->shared->devRead.rxFilterConf; in vmxnet3_set_mc()
2676 u32 *vfTable = adapter->shared->devRead.rxFilterConf.vfTable; in vmxnet3_set_mc()
2681 vmxnet3_restore_vlan(adapter); in vmxnet3_set_mc()
2697 &adapter->pdev->dev, in vmxnet3_set_mc()
2701 if (!dma_mapping_error(&adapter->pdev->dev, in vmxnet3_set_mc()
2721 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_set_mc()
2724 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_set_mc()
2726 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_set_mc()
2730 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_set_mc()
2732 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_set_mc()
2735 dma_unmap_single(&adapter->pdev->dev, new_table_pa, in vmxnet3_set_mc()
2741 vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter) in vmxnet3_rq_destroy_all() argument
2745 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_rq_destroy_all()
2746 vmxnet3_rq_destroy(&adapter->rx_queue[i], adapter); in vmxnet3_rq_destroy_all()
2751 * Set up driver_shared based on settings in adapter.
2755 vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter) in vmxnet3_setup_driver_shared() argument
2757 struct Vmxnet3_DriverShared *shared = adapter->shared; in vmxnet3_setup_driver_shared()
2778 devRead->misc.ddPA = cpu_to_le64(adapter->adapter_pa); in vmxnet3_setup_driver_shared()
2782 if (adapter->netdev->features & NETIF_F_RXCSUM) in vmxnet3_setup_driver_shared()
2785 if (adapter->netdev->features & NETIF_F_LRO) { in vmxnet3_setup_driver_shared()
2789 if (adapter->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) in vmxnet3_setup_driver_shared()
2792 if (adapter->netdev->features & (NETIF_F_GSO_UDP_TUNNEL | in vmxnet3_setup_driver_shared()
2796 devRead->misc.mtu = cpu_to_le32(adapter->netdev->mtu); in vmxnet3_setup_driver_shared()
2797 devRead->misc.queueDescPA = cpu_to_le64(adapter->queue_desc_pa); in vmxnet3_setup_driver_shared()
2799 adapter->num_tx_queues * sizeof(struct Vmxnet3_TxQueueDesc) + in vmxnet3_setup_driver_shared()
2800 adapter->num_rx_queues * sizeof(struct Vmxnet3_RxQueueDesc)); in vmxnet3_setup_driver_shared()
2803 devRead->misc.numTxQueues = adapter->num_tx_queues; in vmxnet3_setup_driver_shared()
2804 for (i = 0; i < adapter->num_tx_queues; i++) { in vmxnet3_setup_driver_shared()
2805 struct vmxnet3_tx_queue *tq = &adapter->tx_queue[i]; in vmxnet3_setup_driver_shared()
2806 BUG_ON(adapter->tx_queue[i].tx_ring.base == NULL); in vmxnet3_setup_driver_shared()
2807 tqc = &adapter->tqd_start[i].conf; in vmxnet3_setup_driver_shared()
2821 devRead->misc.numRxQueues = adapter->num_rx_queues; in vmxnet3_setup_driver_shared()
2822 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_setup_driver_shared()
2823 struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i]; in vmxnet3_setup_driver_shared()
2824 rqc = &adapter->rqd_start[i].conf; in vmxnet3_setup_driver_shared()
2834 if (VMXNET3_VERSION_GE_3(adapter)) { in vmxnet3_setup_driver_shared()
2843 memset(adapter->rss_conf, 0, sizeof(*adapter->rss_conf)); in vmxnet3_setup_driver_shared()
2845 if (adapter->rss) { in vmxnet3_setup_driver_shared()
2846 struct UPT1_RSSConf *rssConf = adapter->rss_conf; in vmxnet3_setup_driver_shared()
2849 devRead->misc.numRxQueues = adapter->num_rx_queues; in vmxnet3_setup_driver_shared()
2861 i, adapter->num_rx_queues); in vmxnet3_setup_driver_shared()
2866 cpu_to_le64(adapter->rss_conf_pa); in vmxnet3_setup_driver_shared()
2872 if (!VMXNET3_VERSION_GE_6(adapter) || in vmxnet3_setup_driver_shared()
2873 !adapter->queuesExtEnabled) { in vmxnet3_setup_driver_shared()
2874 devRead->intrConf.autoMask = adapter->intr.mask_mode == in vmxnet3_setup_driver_shared()
2876 devRead->intrConf.numIntrs = adapter->intr.num_intrs; in vmxnet3_setup_driver_shared()
2877 for (i = 0; i < adapter->intr.num_intrs; i++) in vmxnet3_setup_driver_shared()
2878 devRead->intrConf.modLevels[i] = adapter->intr.mod_levels[i]; in vmxnet3_setup_driver_shared()
2880 devRead->intrConf.eventIntrIdx = adapter->intr.event_intr_idx; in vmxnet3_setup_driver_shared()
2883 devReadExt->intrConfExt.autoMask = adapter->intr.mask_mode == in vmxnet3_setup_driver_shared()
2885 devReadExt->intrConfExt.numIntrs = adapter->intr.num_intrs; in vmxnet3_setup_driver_shared()
2886 for (i = 0; i < adapter->intr.num_intrs; i++) in vmxnet3_setup_driver_shared()
2887 devReadExt->intrConfExt.modLevels[i] = adapter->intr.mod_levels[i]; in vmxnet3_setup_driver_shared()
2889 devReadExt->intrConfExt.eventIntrIdx = adapter->intr.event_intr_idx; in vmxnet3_setup_driver_shared()
2895 vmxnet3_restore_vlan(adapter); in vmxnet3_setup_driver_shared()
2896 vmxnet3_write_mac_addr(adapter, adapter->netdev->dev_addr); in vmxnet3_setup_driver_shared()
2902 vmxnet3_init_bufsize(struct vmxnet3_adapter *adapter) in vmxnet3_init_bufsize() argument
2904 struct Vmxnet3_DriverShared *shared = adapter->shared; in vmxnet3_init_bufsize()
2908 if (!VMXNET3_VERSION_GE_7(adapter)) in vmxnet3_init_bufsize()
2911 cmdInfo->ringBufSize = adapter->ringBufSize; in vmxnet3_init_bufsize()
2912 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_init_bufsize()
2913 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_init_bufsize()
2915 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_init_bufsize()
2919 vmxnet3_init_coalesce(struct vmxnet3_adapter *adapter) in vmxnet3_init_coalesce() argument
2921 struct Vmxnet3_DriverShared *shared = adapter->shared; in vmxnet3_init_coalesce()
2925 if (!VMXNET3_VERSION_GE_3(adapter)) in vmxnet3_init_coalesce()
2928 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_init_coalesce()
2931 cpu_to_le32(sizeof(*adapter->coal_conf)); in vmxnet3_init_coalesce()
2932 cmdInfo->varConf.confPA = cpu_to_le64(adapter->coal_conf_pa); in vmxnet3_init_coalesce()
2934 if (adapter->default_coal_mode) { in vmxnet3_init_coalesce()
2935 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_init_coalesce()
2938 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_init_coalesce()
2942 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_init_coalesce()
2946 vmxnet3_init_rssfields(struct vmxnet3_adapter *adapter) in vmxnet3_init_rssfields() argument
2948 struct Vmxnet3_DriverShared *shared = adapter->shared; in vmxnet3_init_rssfields()
2952 if (!VMXNET3_VERSION_GE_4(adapter)) in vmxnet3_init_rssfields()
2955 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_init_rssfields()
2957 if (adapter->default_rss_fields) { in vmxnet3_init_rssfields()
2958 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_init_rssfields()
2960 adapter->rss_fields = in vmxnet3_init_rssfields()
2961 VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_init_rssfields()
2963 if (VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_init_rssfields()
2964 if ((adapter->rss_fields & VMXNET3_RSS_FIELDS_UDPIP4 || in vmxnet3_init_rssfields()
2965 adapter->rss_fields & VMXNET3_RSS_FIELDS_UDPIP6) && in vmxnet3_init_rssfields()
2966 vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_init_rssfields()
2968 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_UDP_RSS; in vmxnet3_init_rssfields()
2970 adapter->dev_caps[0] &= ~(1UL << VMXNET3_CAP_UDP_RSS); in vmxnet3_init_rssfields()
2973 if ((adapter->rss_fields & VMXNET3_RSS_FIELDS_ESPIP4) && in vmxnet3_init_rssfields()
2974 vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_init_rssfields()
2976 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_ESP_RSS_IPV4; in vmxnet3_init_rssfields()
2978 adapter->dev_caps[0] &= ~(1UL << VMXNET3_CAP_ESP_RSS_IPV4); in vmxnet3_init_rssfields()
2981 if ((adapter->rss_fields & VMXNET3_RSS_FIELDS_ESPIP6) && in vmxnet3_init_rssfields()
2982 vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_init_rssfields()
2984 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_ESP_RSS_IPV6; in vmxnet3_init_rssfields()
2986 adapter->dev_caps[0] &= ~(1UL << VMXNET3_CAP_ESP_RSS_IPV6); in vmxnet3_init_rssfields()
2989 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DCR, adapter->dev_caps[0]); in vmxnet3_init_rssfields()
2990 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_DCR0_REG); in vmxnet3_init_rssfields()
2991 adapter->dev_caps[0] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_init_rssfields()
2993 cmdInfo->setRssFields = adapter->rss_fields; in vmxnet3_init_rssfields()
2994 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_init_rssfields()
2999 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_init_rssfields()
3001 adapter->rss_fields = in vmxnet3_init_rssfields()
3002 VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_init_rssfields()
3005 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_init_rssfields()
3009 vmxnet3_activate_dev(struct vmxnet3_adapter *adapter) in vmxnet3_activate_dev() argument
3015 netdev_dbg(adapter->netdev, "%s: skb_buf_size %d, rx_buf_per_pkt %d," in vmxnet3_activate_dev()
3016 " ring sizes %u %u %u\n", adapter->netdev->name, in vmxnet3_activate_dev()
3017 adapter->skb_buf_size, adapter->rx_buf_per_pkt, in vmxnet3_activate_dev()
3018 adapter->tx_queue[0].tx_ring.size, in vmxnet3_activate_dev()
3019 adapter->rx_queue[0].rx_ring[0].size, in vmxnet3_activate_dev()
3020 adapter->rx_queue[0].rx_ring[1].size); in vmxnet3_activate_dev()
3022 vmxnet3_tq_init_all(adapter); in vmxnet3_activate_dev()
3023 err = vmxnet3_rq_init_all(adapter); in vmxnet3_activate_dev()
3025 netdev_err(adapter->netdev, in vmxnet3_activate_dev()
3030 err = vmxnet3_request_irqs(adapter); in vmxnet3_activate_dev()
3032 netdev_err(adapter->netdev, in vmxnet3_activate_dev()
3037 vmxnet3_setup_driver_shared(adapter); in vmxnet3_activate_dev()
3039 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAL, VMXNET3_GET_ADDR_LO( in vmxnet3_activate_dev()
3040 adapter->shared_pa)); in vmxnet3_activate_dev()
3041 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAH, VMXNET3_GET_ADDR_HI( in vmxnet3_activate_dev()
3042 adapter->shared_pa)); in vmxnet3_activate_dev()
3043 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_activate_dev()
3044 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_activate_dev()
3046 ret = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_activate_dev()
3047 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_activate_dev()
3050 netdev_err(adapter->netdev, in vmxnet3_activate_dev()
3056 vmxnet3_init_bufsize(adapter); in vmxnet3_activate_dev()
3057 vmxnet3_init_coalesce(adapter); in vmxnet3_activate_dev()
3058 vmxnet3_init_rssfields(adapter); in vmxnet3_activate_dev()
3060 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_activate_dev()
3061 VMXNET3_WRITE_BAR0_REG(adapter, in vmxnet3_activate_dev()
3062 adapter->rx_prod_offset + i * VMXNET3_REG_ALIGN, in vmxnet3_activate_dev()
3063 adapter->rx_queue[i].rx_ring[0].next2fill); in vmxnet3_activate_dev()
3064 VMXNET3_WRITE_BAR0_REG(adapter, (adapter->rx_prod2_offset + in vmxnet3_activate_dev()
3066 adapter->rx_queue[i].rx_ring[1].next2fill); in vmxnet3_activate_dev()
3070 vmxnet3_set_mc(adapter->netdev); in vmxnet3_activate_dev()
3076 vmxnet3_check_link(adapter, true); in vmxnet3_activate_dev()
3077 netif_tx_wake_all_queues(adapter->netdev); in vmxnet3_activate_dev()
3078 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_activate_dev()
3079 napi_enable(&adapter->rx_queue[i].napi); in vmxnet3_activate_dev()
3080 vmxnet3_enable_all_intrs(adapter); in vmxnet3_activate_dev()
3081 clear_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state); in vmxnet3_activate_dev()
3085 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAL, 0); in vmxnet3_activate_dev()
3086 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DSAH, 0); in vmxnet3_activate_dev()
3087 vmxnet3_free_irqs(adapter); in vmxnet3_activate_dev()
3091 vmxnet3_rq_cleanup_all(adapter); in vmxnet3_activate_dev()
3097 vmxnet3_reset_dev(struct vmxnet3_adapter *adapter) in vmxnet3_reset_dev() argument
3100 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_reset_dev()
3101 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV); in vmxnet3_reset_dev()
3102 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_reset_dev()
3107 vmxnet3_quiesce_dev(struct vmxnet3_adapter *adapter) in vmxnet3_quiesce_dev() argument
3111 if (test_and_set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state)) in vmxnet3_quiesce_dev()
3115 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_quiesce_dev()
3116 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_quiesce_dev()
3118 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_quiesce_dev()
3119 vmxnet3_disable_all_intrs(adapter); in vmxnet3_quiesce_dev()
3121 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_quiesce_dev()
3122 napi_disable(&adapter->rx_queue[i].napi); in vmxnet3_quiesce_dev()
3123 netif_tx_disable(adapter->netdev); in vmxnet3_quiesce_dev()
3124 adapter->link_speed = 0; in vmxnet3_quiesce_dev()
3125 netif_carrier_off(adapter->netdev); in vmxnet3_quiesce_dev()
3127 vmxnet3_tq_cleanup_all(adapter); in vmxnet3_quiesce_dev()
3128 vmxnet3_rq_cleanup_all(adapter); in vmxnet3_quiesce_dev()
3129 vmxnet3_free_irqs(adapter); in vmxnet3_quiesce_dev()
3135 vmxnet3_write_mac_addr(struct vmxnet3_adapter *adapter, const u8 *mac) in vmxnet3_write_mac_addr() argument
3140 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_MACL, tmp); in vmxnet3_write_mac_addr()
3143 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_MACH, tmp); in vmxnet3_write_mac_addr()
3151 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_set_mac_addr() local
3154 vmxnet3_write_mac_addr(adapter, addr->sa_data); in vmxnet3_set_mac_addr()
3163 vmxnet3_alloc_pci_resources(struct vmxnet3_adapter *adapter) in vmxnet3_alloc_pci_resources() argument
3167 struct pci_dev *pdev = adapter->pdev; in vmxnet3_alloc_pci_resources()
3171 dev_err(&pdev->dev, "Failed to enable adapter: error %d\n", err); in vmxnet3_alloc_pci_resources()
3179 "Failed to request region for adapter: error %d\n", err); in vmxnet3_alloc_pci_resources()
3187 adapter->hw_addr0 = ioremap(mmio_start, mmio_len); in vmxnet3_alloc_pci_resources()
3188 if (!adapter->hw_addr0) { in vmxnet3_alloc_pci_resources()
3196 adapter->hw_addr1 = ioremap(mmio_start, mmio_len); in vmxnet3_alloc_pci_resources()
3197 if (!adapter->hw_addr1) { in vmxnet3_alloc_pci_resources()
3205 iounmap(adapter->hw_addr0); in vmxnet3_alloc_pci_resources()
3215 vmxnet3_free_pci_resources(struct vmxnet3_adapter *adapter) in vmxnet3_free_pci_resources() argument
3217 BUG_ON(!adapter->pdev); in vmxnet3_free_pci_resources()
3219 iounmap(adapter->hw_addr0); in vmxnet3_free_pci_resources()
3220 iounmap(adapter->hw_addr1); in vmxnet3_free_pci_resources()
3221 pci_release_selected_regions(adapter->pdev, (1 << 2) - 1); in vmxnet3_free_pci_resources()
3222 pci_disable_device(adapter->pdev); in vmxnet3_free_pci_resources()
3227 vmxnet3_adjust_rx_ring_size(struct vmxnet3_adapter *adapter) in vmxnet3_adjust_rx_ring_size() argument
3231 if (!VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_adjust_rx_ring_size()
3232 if (adapter->netdev->mtu <= VMXNET3_MAX_SKB_BUF_SIZE - in vmxnet3_adjust_rx_ring_size()
3234 adapter->skb_buf_size = adapter->netdev->mtu + in vmxnet3_adjust_rx_ring_size()
3236 if (adapter->skb_buf_size < VMXNET3_MIN_T0_BUF_SIZE) in vmxnet3_adjust_rx_ring_size()
3237 adapter->skb_buf_size = VMXNET3_MIN_T0_BUF_SIZE; in vmxnet3_adjust_rx_ring_size()
3239 adapter->rx_buf_per_pkt = 1; in vmxnet3_adjust_rx_ring_size()
3241 adapter->skb_buf_size = VMXNET3_MAX_SKB_BUF_SIZE; in vmxnet3_adjust_rx_ring_size()
3242 sz = adapter->netdev->mtu - VMXNET3_MAX_SKB_BUF_SIZE + in vmxnet3_adjust_rx_ring_size()
3244 adapter->rx_buf_per_pkt = 1 + (sz + PAGE_SIZE - 1) / PAGE_SIZE; in vmxnet3_adjust_rx_ring_size()
3247 adapter->skb_buf_size = min((int)adapter->netdev->mtu + VMXNET3_MAX_ETH_HDR_SIZE, in vmxnet3_adjust_rx_ring_size()
3249 adapter->rx_buf_per_pkt = 1; in vmxnet3_adjust_rx_ring_size()
3250 adapter->ringBufSize.ring1BufSizeType0 = cpu_to_le16(adapter->skb_buf_size); in vmxnet3_adjust_rx_ring_size()
3251 adapter->ringBufSize.ring1BufSizeType1 = 0; in vmxnet3_adjust_rx_ring_size()
3252 adapter->ringBufSize.ring2BufSizeType1 = cpu_to_le16(PAGE_SIZE); in vmxnet3_adjust_rx_ring_size()
3259 sz = adapter->rx_buf_per_pkt * VMXNET3_RING_SIZE_ALIGN; in vmxnet3_adjust_rx_ring_size()
3260 ring0_size = adapter->rx_queue[0].rx_ring[0].size; in vmxnet3_adjust_rx_ring_size()
3264 ring1_size = adapter->rx_queue[0].rx_ring[1].size; in vmxnet3_adjust_rx_ring_size()
3269 if (VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_adjust_rx_ring_size()
3275 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_adjust_rx_ring_size()
3276 struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i]; in vmxnet3_adjust_rx_ring_size()
3286 vmxnet3_create_queues(struct vmxnet3_adapter *adapter, u32 tx_ring_size, in vmxnet3_create_queues() argument
3292 for (i = 0; i < adapter->num_tx_queues; i++) { in vmxnet3_create_queues()
3293 struct vmxnet3_tx_queue *tq = &adapter->tx_queue[i]; in vmxnet3_create_queues()
3298 tq->shared = &adapter->tqd_start[i].ctrl; in vmxnet3_create_queues()
3300 tq->adapter = adapter; in vmxnet3_create_queues()
3302 err = vmxnet3_tq_create(tq, adapter); in vmxnet3_create_queues()
3311 adapter->rx_queue[0].rx_ring[0].size = rx_ring_size; in vmxnet3_create_queues()
3312 adapter->rx_queue[0].rx_ring[1].size = rx_ring2_size; in vmxnet3_create_queues()
3313 vmxnet3_adjust_rx_ring_size(adapter); in vmxnet3_create_queues()
3315 adapter->rxdataring_enabled = VMXNET3_VERSION_GE_3(adapter); in vmxnet3_create_queues()
3316 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_create_queues()
3317 struct vmxnet3_rx_queue *rq = &adapter->rx_queue[i]; in vmxnet3_create_queues()
3320 rq->shared = &adapter->rqd_start[i].ctrl; in vmxnet3_create_queues()
3321 rq->adapter = adapter; in vmxnet3_create_queues()
3323 err = vmxnet3_rq_create(rq, adapter); in vmxnet3_create_queues()
3326 netdev_err(adapter->netdev, in vmxnet3_create_queues()
3331 netdev_info(adapter->netdev, in vmxnet3_create_queues()
3334 adapter->num_rx_queues = i; in vmxnet3_create_queues()
3341 if (!adapter->rxdataring_enabled) in vmxnet3_create_queues()
3342 vmxnet3_rq_destroy_all_rxdataring(adapter); in vmxnet3_create_queues()
3346 vmxnet3_tq_destroy_all(adapter); in vmxnet3_create_queues()
3353 struct vmxnet3_adapter *adapter; in vmxnet3_open() local
3356 adapter = netdev_priv(netdev); in vmxnet3_open()
3358 for (i = 0; i < adapter->num_tx_queues; i++) in vmxnet3_open()
3359 spin_lock_init(&adapter->tx_queue[i].tx_lock); in vmxnet3_open()
3361 if (VMXNET3_VERSION_GE_3(adapter)) { in vmxnet3_open()
3365 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_open()
3366 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_open()
3368 txdata_desc_size = VMXNET3_READ_BAR1_REG(adapter, in vmxnet3_open()
3370 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_open()
3375 adapter->txdata_desc_size = in vmxnet3_open()
3378 adapter->txdata_desc_size = txdata_desc_size; in vmxnet3_open()
3381 adapter->txdata_desc_size = sizeof(struct Vmxnet3_TxDataDesc); in vmxnet3_open()
3384 err = vmxnet3_create_queues(adapter, in vmxnet3_open()
3385 adapter->tx_ring_size, in vmxnet3_open()
3386 adapter->rx_ring_size, in vmxnet3_open()
3387 adapter->rx_ring2_size, in vmxnet3_open()
3388 adapter->txdata_desc_size, in vmxnet3_open()
3389 adapter->rxdata_desc_size); in vmxnet3_open()
3393 err = vmxnet3_activate_dev(adapter); in vmxnet3_open()
3400 vmxnet3_rq_destroy_all(adapter); in vmxnet3_open()
3401 vmxnet3_tq_destroy_all(adapter); in vmxnet3_open()
3410 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_close() local
3416 while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) in vmxnet3_close()
3419 vmxnet3_quiesce_dev(adapter); in vmxnet3_close()
3421 vmxnet3_rq_destroy_all(adapter); in vmxnet3_close()
3422 vmxnet3_tq_destroy_all(adapter); in vmxnet3_close()
3424 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); in vmxnet3_close()
3432 vmxnet3_force_close(struct vmxnet3_adapter *adapter) in vmxnet3_force_close() argument
3440 BUG_ON(test_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)); in vmxnet3_force_close()
3443 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_force_close()
3444 napi_enable(&adapter->rx_queue[i].napi); in vmxnet3_force_close()
3449 clear_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state); in vmxnet3_force_close()
3450 dev_close(adapter->netdev); in vmxnet3_force_close()
3457 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_change_mtu() local
3466 while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) in vmxnet3_change_mtu()
3470 vmxnet3_quiesce_dev(adapter); in vmxnet3_change_mtu()
3471 vmxnet3_reset_dev(adapter); in vmxnet3_change_mtu()
3474 vmxnet3_rq_destroy_all(adapter); in vmxnet3_change_mtu()
3475 vmxnet3_adjust_rx_ring_size(adapter); in vmxnet3_change_mtu()
3476 err = vmxnet3_rq_create_all(adapter); in vmxnet3_change_mtu()
3484 err = vmxnet3_activate_dev(adapter); in vmxnet3_change_mtu()
3494 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); in vmxnet3_change_mtu()
3496 vmxnet3_force_close(adapter); in vmxnet3_change_mtu()
3503 vmxnet3_declare_features(struct vmxnet3_adapter *adapter) in vmxnet3_declare_features() argument
3505 struct net_device *netdev = adapter->netdev; in vmxnet3_declare_features()
3512 if (VMXNET3_VERSION_GE_4(adapter)) { in vmxnet3_declare_features()
3523 if (VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_declare_features()
3526 if (vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_declare_features()
3528 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_GENEVE_CHECKSUM_OFFLOAD; in vmxnet3_declare_features()
3530 if (vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_declare_features()
3532 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_VXLAN_CHECKSUM_OFFLOAD; in vmxnet3_declare_features()
3534 if (vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_declare_features()
3536 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_GENEVE_TSO; in vmxnet3_declare_features()
3538 if (vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_declare_features()
3540 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_VXLAN_TSO; in vmxnet3_declare_features()
3542 if (vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_declare_features()
3544 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_GENEVE_OUTER_CHECKSUM_OFFLOAD; in vmxnet3_declare_features()
3546 if (vmxnet3_check_ptcapability(adapter->ptcap_supported[0], in vmxnet3_declare_features()
3548 adapter->dev_caps[0] |= 1UL << VMXNET3_CAP_VXLAN_OUTER_CHECKSUM_OFFLOAD; in vmxnet3_declare_features()
3551 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DCR, adapter->dev_caps[0]); in vmxnet3_declare_features()
3552 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_declare_features()
3553 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_DCR0_REG); in vmxnet3_declare_features()
3554 adapter->dev_caps[0] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_declare_features()
3555 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_declare_features()
3557 if (!(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_GENEVE_CHECKSUM_OFFLOAD)) && in vmxnet3_declare_features()
3558 !(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_VXLAN_CHECKSUM_OFFLOAD)) && in vmxnet3_declare_features()
3559 !(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_GENEVE_TSO)) && in vmxnet3_declare_features()
3560 !(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_VXLAN_TSO))) { in vmxnet3_declare_features()
3564 if (!(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_GENEVE_OUTER_CHECKSUM_OFFLOAD)) && in vmxnet3_declare_features()
3565 !(adapter->dev_caps[0] & (1UL << VMXNET3_CAP_VXLAN_OUTER_CHECKSUM_OFFLOAD))) { in vmxnet3_declare_features()
3579 vmxnet3_read_mac_addr(struct vmxnet3_adapter *adapter, u8 *mac) in vmxnet3_read_mac_addr() argument
3583 tmp = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACL); in vmxnet3_read_mac_addr()
3586 tmp = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_MACH); in vmxnet3_read_mac_addr()
3603 vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter, int nvec) in vmxnet3_acquire_msix_vectors() argument
3605 int ret = pci_enable_msix_range(adapter->pdev, in vmxnet3_acquire_msix_vectors()
3606 adapter->intr.msix_entries, nvec, nvec); in vmxnet3_acquire_msix_vectors()
3609 dev_err(&adapter->netdev->dev, in vmxnet3_acquire_msix_vectors()
3613 ret = pci_enable_msix_range(adapter->pdev, in vmxnet3_acquire_msix_vectors()
3614 adapter->intr.msix_entries, in vmxnet3_acquire_msix_vectors()
3620 dev_err(&adapter->netdev->dev, in vmxnet3_acquire_msix_vectors()
3631 vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter) in vmxnet3_alloc_intr_resources() argument
3637 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_alloc_intr_resources()
3638 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_alloc_intr_resources()
3640 cfg = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_alloc_intr_resources()
3641 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_alloc_intr_resources()
3642 adapter->intr.type = cfg & 0x3; in vmxnet3_alloc_intr_resources()
3643 adapter->intr.mask_mode = (cfg >> 2) & 0x3; in vmxnet3_alloc_intr_resources()
3645 if (adapter->intr.type == VMXNET3_IT_AUTO) { in vmxnet3_alloc_intr_resources()
3646 adapter->intr.type = VMXNET3_IT_MSIX; in vmxnet3_alloc_intr_resources()
3650 if (adapter->intr.type == VMXNET3_IT_MSIX) { in vmxnet3_alloc_intr_resources()
3653 nvec = adapter->share_intr == VMXNET3_INTR_TXSHARE ? in vmxnet3_alloc_intr_resources()
3654 1 : adapter->num_tx_queues; in vmxnet3_alloc_intr_resources()
3655 nvec += adapter->share_intr == VMXNET3_INTR_BUDDYSHARE ? in vmxnet3_alloc_intr_resources()
3656 0 : adapter->num_rx_queues; in vmxnet3_alloc_intr_resources()
3662 adapter->intr.msix_entries[i].entry = i; in vmxnet3_alloc_intr_resources()
3664 nvec_allocated = vmxnet3_acquire_msix_vectors(adapter, nvec); in vmxnet3_alloc_intr_resources()
3673 if (adapter->share_intr != VMXNET3_INTR_BUDDYSHARE in vmxnet3_alloc_intr_resources()
3674 || adapter->num_rx_queues != 1) { in vmxnet3_alloc_intr_resources()
3675 adapter->share_intr = VMXNET3_INTR_TXSHARE; in vmxnet3_alloc_intr_resources()
3676 netdev_err(adapter->netdev, in vmxnet3_alloc_intr_resources()
3678 adapter->num_rx_queues = 1; in vmxnet3_alloc_intr_resources()
3682 adapter->intr.num_intrs = nvec_allocated; in vmxnet3_alloc_intr_resources()
3687 dev_info(&adapter->pdev->dev, in vmxnet3_alloc_intr_resources()
3691 adapter->intr.type = VMXNET3_IT_MSI; in vmxnet3_alloc_intr_resources()
3694 if (adapter->intr.type == VMXNET3_IT_MSI) { in vmxnet3_alloc_intr_resources()
3695 if (!pci_enable_msi(adapter->pdev)) { in vmxnet3_alloc_intr_resources()
3696 adapter->num_rx_queues = 1; in vmxnet3_alloc_intr_resources()
3697 adapter->intr.num_intrs = 1; in vmxnet3_alloc_intr_resources()
3703 adapter->num_rx_queues = 1; in vmxnet3_alloc_intr_resources()
3704 dev_info(&adapter->netdev->dev, in vmxnet3_alloc_intr_resources()
3706 adapter->intr.type = VMXNET3_IT_INTX; in vmxnet3_alloc_intr_resources()
3709 adapter->intr.num_intrs = 1; in vmxnet3_alloc_intr_resources()
3714 vmxnet3_free_intr_resources(struct vmxnet3_adapter *adapter) in vmxnet3_free_intr_resources() argument
3716 if (adapter->intr.type == VMXNET3_IT_MSIX) in vmxnet3_free_intr_resources()
3717 pci_disable_msix(adapter->pdev); in vmxnet3_free_intr_resources()
3718 else if (adapter->intr.type == VMXNET3_IT_MSI) in vmxnet3_free_intr_resources()
3719 pci_disable_msi(adapter->pdev); in vmxnet3_free_intr_resources()
3721 BUG_ON(adapter->intr.type != VMXNET3_IT_INTX); in vmxnet3_free_intr_resources()
3728 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_tx_timeout() local
3729 adapter->tx_timeout_count++; in vmxnet3_tx_timeout()
3731 netdev_err(adapter->netdev, "tx hang\n"); in vmxnet3_tx_timeout()
3732 schedule_work(&adapter->work); in vmxnet3_tx_timeout()
3739 struct vmxnet3_adapter *adapter; in vmxnet3_reset_work() local
3741 adapter = container_of(data, struct vmxnet3_adapter, work); in vmxnet3_reset_work()
3744 if (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) in vmxnet3_reset_work()
3749 if (netif_running(adapter->netdev)) { in vmxnet3_reset_work()
3750 netdev_notice(adapter->netdev, "resetting\n"); in vmxnet3_reset_work()
3751 vmxnet3_quiesce_dev(adapter); in vmxnet3_reset_work()
3752 vmxnet3_reset_dev(adapter); in vmxnet3_reset_work()
3753 vmxnet3_activate_dev(adapter); in vmxnet3_reset_work()
3755 netdev_info(adapter->netdev, "already closed\n"); in vmxnet3_reset_work()
3759 netif_wake_queue(adapter->netdev); in vmxnet3_reset_work()
3760 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); in vmxnet3_reset_work()
3791 struct vmxnet3_adapter *adapter; in vmxnet3_probe_device() local
3822 adapter = netdev_priv(netdev); in vmxnet3_probe_device()
3823 adapter->netdev = netdev; in vmxnet3_probe_device()
3824 adapter->pdev = pdev; in vmxnet3_probe_device()
3826 adapter->tx_ring_size = VMXNET3_DEF_TX_RING_SIZE; in vmxnet3_probe_device()
3827 adapter->rx_ring_size = VMXNET3_DEF_RX_RING_SIZE; in vmxnet3_probe_device()
3828 adapter->rx_ring2_size = VMXNET3_DEF_RX_RING2_SIZE; in vmxnet3_probe_device()
3836 spin_lock_init(&adapter->cmd_lock); in vmxnet3_probe_device()
3837 adapter->adapter_pa = dma_map_single(&adapter->pdev->dev, adapter, in vmxnet3_probe_device()
3840 if (dma_mapping_error(&adapter->pdev->dev, adapter->adapter_pa)) { in vmxnet3_probe_device()
3845 adapter->shared = dma_alloc_coherent( in vmxnet3_probe_device()
3846 &adapter->pdev->dev, in vmxnet3_probe_device()
3848 &adapter->shared_pa, GFP_KERNEL); in vmxnet3_probe_device()
3849 if (!adapter->shared) { in vmxnet3_probe_device()
3855 err = vmxnet3_alloc_pci_resources(adapter); in vmxnet3_probe_device()
3859 ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_VRRS); in vmxnet3_probe_device()
3861 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3864 adapter->version = VMXNET3_REV_7 + 1; in vmxnet3_probe_device()
3866 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3869 adapter->version = VMXNET3_REV_6 + 1; in vmxnet3_probe_device()
3871 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3874 adapter->version = VMXNET3_REV_5 + 1; in vmxnet3_probe_device()
3876 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3879 adapter->version = VMXNET3_REV_4 + 1; in vmxnet3_probe_device()
3881 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3884 adapter->version = VMXNET3_REV_3 + 1; in vmxnet3_probe_device()
3886 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3889 adapter->version = VMXNET3_REV_2 + 1; in vmxnet3_probe_device()
3891 VMXNET3_WRITE_BAR1_REG(adapter, in vmxnet3_probe_device()
3894 adapter->version = VMXNET3_REV_1 + 1; in vmxnet3_probe_device()
3897 "Incompatible h/w version (0x%x) for adapter\n", ver); in vmxnet3_probe_device()
3901 dev_dbg(&pdev->dev, "Using device version %d\n", adapter->version); in vmxnet3_probe_device()
3903 ver = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_UVRS); in vmxnet3_probe_device()
3905 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_UVRS, 1); in vmxnet3_probe_device()
3908 "Incompatible upt version (0x%x) for adapter\n", ver); in vmxnet3_probe_device()
3913 if (VMXNET3_VERSION_GE_7(adapter)) { in vmxnet3_probe_device()
3914 adapter->devcap_supported[0] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_DCR); in vmxnet3_probe_device()
3915 adapter->ptcap_supported[0] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_PTCR); in vmxnet3_probe_device()
3916 if (adapter->devcap_supported[0] & (1UL << VMXNET3_CAP_LARGE_BAR)) { in vmxnet3_probe_device()
3917 adapter->dev_caps[0] = adapter->devcap_supported[0] & in vmxnet3_probe_device()
3920 if (!(adapter->ptcap_supported[0] & (1UL << VMXNET3_DCR_ERROR)) && in vmxnet3_probe_device()
3921 adapter->ptcap_supported[0] & (1UL << VMXNET3_CAP_OOORX_COMP) && in vmxnet3_probe_device()
3922 adapter->devcap_supported[0] & (1UL << VMXNET3_CAP_OOORX_COMP)) { in vmxnet3_probe_device()
3923 adapter->dev_caps[0] |= adapter->devcap_supported[0] & in vmxnet3_probe_device()
3926 if (adapter->dev_caps[0]) in vmxnet3_probe_device()
3927 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_DCR, adapter->dev_caps[0]); in vmxnet3_probe_device()
3929 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_probe_device()
3930 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, VMXNET3_CMD_GET_DCR0_REG); in vmxnet3_probe_device()
3931 adapter->dev_caps[0] = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_probe_device()
3932 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_probe_device()
3935 if (VMXNET3_VERSION_GE_7(adapter) && in vmxnet3_probe_device()
3936 adapter->dev_caps[0] & (1UL << VMXNET3_CAP_LARGE_BAR)) { in vmxnet3_probe_device()
3937 adapter->tx_prod_offset = VMXNET3_REG_LB_TXPROD; in vmxnet3_probe_device()
3938 adapter->rx_prod_offset = VMXNET3_REG_LB_RXPROD; in vmxnet3_probe_device()
3939 adapter->rx_prod2_offset = VMXNET3_REG_LB_RXPROD2; in vmxnet3_probe_device()
3941 adapter->tx_prod_offset = VMXNET3_REG_TXPROD; in vmxnet3_probe_device()
3942 adapter->rx_prod_offset = VMXNET3_REG_RXPROD; in vmxnet3_probe_device()
3943 adapter->rx_prod2_offset = VMXNET3_REG_RXPROD2; in vmxnet3_probe_device()
3946 if (VMXNET3_VERSION_GE_6(adapter)) { in vmxnet3_probe_device()
3947 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_probe_device()
3948 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_probe_device()
3950 queues = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_probe_device()
3951 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_probe_device()
3953 adapter->num_rx_queues = min(num_rx_queues, ((queues >> 8) & 0xff)); in vmxnet3_probe_device()
3954 adapter->num_tx_queues = min(num_tx_queues, (queues & 0xff)); in vmxnet3_probe_device()
3956 adapter->num_rx_queues = min(num_rx_queues, in vmxnet3_probe_device()
3958 adapter->num_tx_queues = min(num_tx_queues, in vmxnet3_probe_device()
3961 if (adapter->num_rx_queues > VMXNET3_MAX_RX_QUEUES || in vmxnet3_probe_device()
3962 adapter->num_tx_queues > VMXNET3_MAX_TX_QUEUES) { in vmxnet3_probe_device()
3963 adapter->queuesExtEnabled = true; in vmxnet3_probe_device()
3965 adapter->queuesExtEnabled = false; in vmxnet3_probe_device()
3968 adapter->queuesExtEnabled = false; in vmxnet3_probe_device()
3971 adapter->num_rx_queues = min(num_rx_queues, in vmxnet3_probe_device()
3973 adapter->num_tx_queues = min(num_tx_queues, in vmxnet3_probe_device()
3978 adapter->num_tx_queues, adapter->num_rx_queues); in vmxnet3_probe_device()
3980 adapter->rx_buf_per_pkt = 1; in vmxnet3_probe_device()
3982 size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues; in vmxnet3_probe_device()
3983 size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues; in vmxnet3_probe_device()
3984 adapter->tqd_start = dma_alloc_coherent(&adapter->pdev->dev, size, in vmxnet3_probe_device()
3985 &adapter->queue_desc_pa, in vmxnet3_probe_device()
3988 if (!adapter->tqd_start) { in vmxnet3_probe_device()
3993 adapter->rqd_start = (struct Vmxnet3_RxQueueDesc *)(adapter->tqd_start + in vmxnet3_probe_device()
3994 adapter->num_tx_queues); in vmxnet3_probe_device()
3996 adapter->pm_conf = dma_alloc_coherent(&adapter->pdev->dev, in vmxnet3_probe_device()
3998 &adapter->pm_conf_pa, in vmxnet3_probe_device()
4000 if (adapter->pm_conf == NULL) { in vmxnet3_probe_device()
4007 adapter->rss_conf = dma_alloc_coherent(&adapter->pdev->dev, in vmxnet3_probe_device()
4009 &adapter->rss_conf_pa, in vmxnet3_probe_device()
4011 if (adapter->rss_conf == NULL) { in vmxnet3_probe_device()
4017 if (VMXNET3_VERSION_GE_3(adapter)) { in vmxnet3_probe_device()
4018 adapter->coal_conf = in vmxnet3_probe_device()
4019 dma_alloc_coherent(&adapter->pdev->dev, in vmxnet3_probe_device()
4022 &adapter->coal_conf_pa, in vmxnet3_probe_device()
4024 if (!adapter->coal_conf) { in vmxnet3_probe_device()
4028 adapter->coal_conf->coalMode = VMXNET3_COALESCE_DISABLED; in vmxnet3_probe_device()
4029 adapter->default_coal_mode = true; in vmxnet3_probe_device()
4032 if (VMXNET3_VERSION_GE_4(adapter)) { in vmxnet3_probe_device()
4033 adapter->default_rss_fields = true; in vmxnet3_probe_device()
4034 adapter->rss_fields = VMXNET3_RSS_FIELDS_DEFAULT; in vmxnet3_probe_device()
4038 vmxnet3_declare_features(adapter); in vmxnet3_probe_device()
4042 adapter->rxdata_desc_size = VMXNET3_VERSION_GE_3(adapter) ? in vmxnet3_probe_device()
4045 if (adapter->num_tx_queues == adapter->num_rx_queues) in vmxnet3_probe_device()
4046 adapter->share_intr = VMXNET3_INTR_BUDDYSHARE; in vmxnet3_probe_device()
4048 adapter->share_intr = VMXNET3_INTR_DONTSHARE; in vmxnet3_probe_device()
4050 vmxnet3_alloc_intr_resources(adapter); in vmxnet3_probe_device()
4053 if (adapter->num_rx_queues > 1 && in vmxnet3_probe_device()
4054 adapter->intr.type == VMXNET3_IT_MSIX) { in vmxnet3_probe_device()
4055 adapter->rss = true; in vmxnet3_probe_device()
4060 adapter->rss = false; in vmxnet3_probe_device()
4064 vmxnet3_read_mac_addr(adapter, mac); in vmxnet3_probe_device()
4073 if (VMXNET3_VERSION_GE_6(adapter)) in vmxnet3_probe_device()
4078 INIT_WORK(&adapter->work, vmxnet3_reset_work); in vmxnet3_probe_device()
4079 set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state); in vmxnet3_probe_device()
4081 if (adapter->intr.type == VMXNET3_IT_MSIX) { in vmxnet3_probe_device()
4083 for (i = 0; i < adapter->num_rx_queues; i++) { in vmxnet3_probe_device()
4084 netif_napi_add(adapter->netdev, in vmxnet3_probe_device()
4085 &adapter->rx_queue[i].napi, in vmxnet3_probe_device()
4089 netif_napi_add(adapter->netdev, &adapter->rx_queue[0].napi, in vmxnet3_probe_device()
4093 netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues); in vmxnet3_probe_device()
4094 netif_set_real_num_rx_queues(adapter->netdev, adapter->num_rx_queues); in vmxnet3_probe_device()
4100 dev_err(&pdev->dev, "Failed to register adapter\n"); in vmxnet3_probe_device()
4104 vmxnet3_check_link(adapter, false); in vmxnet3_probe_device()
4108 if (VMXNET3_VERSION_GE_3(adapter)) { in vmxnet3_probe_device()
4109 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_probe_device()
4111 adapter->coal_conf, adapter->coal_conf_pa); in vmxnet3_probe_device()
4113 vmxnet3_free_intr_resources(adapter); in vmxnet3_probe_device()
4116 dma_free_coherent(&adapter->pdev->dev, sizeof(struct UPT1_RSSConf), in vmxnet3_probe_device()
4117 adapter->rss_conf, adapter->rss_conf_pa); in vmxnet3_probe_device()
4120 dma_free_coherent(&adapter->pdev->dev, sizeof(struct Vmxnet3_PMConf), in vmxnet3_probe_device()
4121 adapter->pm_conf, adapter->pm_conf_pa); in vmxnet3_probe_device()
4123 dma_free_coherent(&adapter->pdev->dev, size, adapter->tqd_start, in vmxnet3_probe_device()
4124 adapter->queue_desc_pa); in vmxnet3_probe_device()
4126 vmxnet3_free_pci_resources(adapter); in vmxnet3_probe_device()
4128 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_probe_device()
4130 adapter->shared, adapter->shared_pa); in vmxnet3_probe_device()
4132 dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa, in vmxnet3_probe_device()
4144 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_remove_device() local
4156 if (!VMXNET3_VERSION_GE_6(adapter)) { in vmxnet3_remove_device()
4159 if (VMXNET3_VERSION_GE_6(adapter)) { in vmxnet3_remove_device()
4160 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_remove_device()
4161 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_remove_device()
4163 rx_queues = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); in vmxnet3_remove_device()
4164 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_remove_device()
4175 cancel_work_sync(&adapter->work); in vmxnet3_remove_device()
4179 vmxnet3_free_intr_resources(adapter); in vmxnet3_remove_device()
4180 vmxnet3_free_pci_resources(adapter); in vmxnet3_remove_device()
4181 if (VMXNET3_VERSION_GE_3(adapter)) { in vmxnet3_remove_device()
4182 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_remove_device()
4184 adapter->coal_conf, adapter->coal_conf_pa); in vmxnet3_remove_device()
4187 dma_free_coherent(&adapter->pdev->dev, sizeof(struct UPT1_RSSConf), in vmxnet3_remove_device()
4188 adapter->rss_conf, adapter->rss_conf_pa); in vmxnet3_remove_device()
4190 dma_free_coherent(&adapter->pdev->dev, sizeof(struct Vmxnet3_PMConf), in vmxnet3_remove_device()
4191 adapter->pm_conf, adapter->pm_conf_pa); in vmxnet3_remove_device()
4193 size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues; in vmxnet3_remove_device()
4195 dma_free_coherent(&adapter->pdev->dev, size, adapter->tqd_start, in vmxnet3_remove_device()
4196 adapter->queue_desc_pa); in vmxnet3_remove_device()
4197 dma_free_coherent(&adapter->pdev->dev, in vmxnet3_remove_device()
4199 adapter->shared, adapter->shared_pa); in vmxnet3_remove_device()
4200 dma_unmap_single(&adapter->pdev->dev, adapter->adapter_pa, in vmxnet3_remove_device()
4208 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_shutdown_device() local
4214 while (test_and_set_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state)) in vmxnet3_shutdown_device()
4218 &adapter->state)) { in vmxnet3_shutdown_device()
4219 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); in vmxnet3_shutdown_device()
4222 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_shutdown_device()
4223 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_shutdown_device()
4225 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_shutdown_device()
4226 vmxnet3_disable_all_intrs(adapter); in vmxnet3_shutdown_device()
4228 clear_bit(VMXNET3_STATE_BIT_RESETTING, &adapter->state); in vmxnet3_shutdown_device()
4239 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_suspend() local
4252 for (i = 0; i < adapter->num_rx_queues; i++) in vmxnet3_suspend()
4253 napi_disable(&adapter->rx_queue[i].napi); in vmxnet3_suspend()
4255 vmxnet3_disable_all_intrs(adapter); in vmxnet3_suspend()
4256 vmxnet3_free_irqs(adapter); in vmxnet3_suspend()
4257 vmxnet3_free_intr_resources(adapter); in vmxnet3_suspend()
4262 pmConf = adapter->pm_conf; in vmxnet3_suspend()
4265 if (adapter->wol & WAKE_UCAST) { in vmxnet3_suspend()
4275 if (adapter->wol & WAKE_ARP) { in vmxnet3_suspend()
4325 if (adapter->wol & WAKE_MAGIC) in vmxnet3_suspend()
4330 adapter->shared->devRead.pmConfDesc.confVer = cpu_to_le32(1); in vmxnet3_suspend()
4331 adapter->shared->devRead.pmConfDesc.confLen = cpu_to_le32(sizeof( in vmxnet3_suspend()
4333 adapter->shared->devRead.pmConfDesc.confPA = in vmxnet3_suspend()
4334 cpu_to_le64(adapter->pm_conf_pa); in vmxnet3_suspend()
4336 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_suspend()
4337 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_suspend()
4339 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_suspend()
4343 adapter->wol); in vmxnet3_suspend()
4358 struct vmxnet3_adapter *adapter = netdev_priv(netdev); in vmxnet3_resume() local
4371 vmxnet3_alloc_intr_resources(adapter); in vmxnet3_resume()
4377 /* Need not check adapter state as other reset tasks cannot run during in vmxnet3_resume()
4380 spin_lock_irqsave(&adapter->cmd_lock, flags); in vmxnet3_resume()
4381 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, in vmxnet3_resume()
4383 spin_unlock_irqrestore(&adapter->cmd_lock, flags); in vmxnet3_resume()
4384 vmxnet3_tq_cleanup_all(adapter); in vmxnet3_resume()
4385 vmxnet3_rq_cleanup_all(adapter); in vmxnet3_resume()
4387 vmxnet3_reset_dev(adapter); in vmxnet3_resume()
4388 err = vmxnet3_activate_dev(adapter); in vmxnet3_resume()
4392 vmxnet3_force_close(adapter); in vmxnet3_resume()