Lines Matching refs:bnad

80 bnad_add_to_list(struct bnad *bnad)  in bnad_add_to_list()  argument
83 list_add_tail(&bnad->list_entry, &bnad_list); in bnad_add_to_list()
84 bnad->id = bna_id++; in bnad_add_to_list()
89 bnad_remove_from_list(struct bnad *bnad) in bnad_remove_from_list() argument
92 list_del(&bnad->list_entry); in bnad_remove_from_list()
100 bnad_cq_cleanup(struct bnad *bnad, struct bna_ccb *ccb) in bnad_cq_cleanup() argument
116 bnad_tx_buff_unmap(struct bnad *bnad, in bnad_tx_buff_unmap() argument
130 dma_unmap_single(&bnad->pcidev->dev, in bnad_tx_buff_unmap()
145 dma_unmap_page(&bnad->pcidev->dev, in bnad_tx_buff_unmap()
164 bnad_txq_cleanup(struct bnad *bnad, struct bna_tcb *tcb) in bnad_txq_cleanup() argument
174 bnad_tx_buff_unmap(bnad, unmap_q, tcb->q_depth, i); in bnad_txq_cleanup()
186 bnad_txcmpl_process(struct bnad *bnad, struct bna_tcb *tcb) in bnad_txcmpl_process() argument
216 cons = bnad_tx_buff_unmap(bnad, unmap_q, q_depth, cons); in bnad_txcmpl_process()
230 bnad_tx_complete(struct bnad *bnad, struct bna_tcb *tcb) in bnad_tx_complete() argument
232 struct net_device *netdev = bnad->netdev; in bnad_tx_complete()
238 sent = bnad_txcmpl_process(bnad, tcb); in bnad_tx_complete()
246 BNAD_UPDATE_CTR(bnad, netif_queue_wakeup); in bnad_tx_complete()
265 struct bnad *bnad = tcb->bnad; in bnad_msix_tx() local
267 bnad_tx_complete(bnad, tcb); in bnad_msix_tx()
273 bnad_rxq_alloc_uninit(struct bnad *bnad, struct bna_rcb *rcb) in bnad_rxq_alloc_uninit() argument
285 bnad_rxq_alloc_init(struct bnad *bnad, struct bna_rcb *rcb) in bnad_rxq_alloc_init() argument
290 bnad_rxq_alloc_uninit(bnad, rcb); in bnad_rxq_alloc_init()
318 bnad_rxq_cleanup_page(struct bnad *bnad, struct bnad_rx_unmap *unmap) in bnad_rxq_cleanup_page() argument
323 dma_unmap_page(&bnad->pcidev->dev, in bnad_rxq_cleanup_page()
333 bnad_rxq_cleanup_skb(struct bnad *bnad, struct bnad_rx_unmap *unmap) in bnad_rxq_cleanup_skb() argument
338 dma_unmap_single(&bnad->pcidev->dev, in bnad_rxq_cleanup_skb()
348 bnad_rxq_cleanup(struct bnad *bnad, struct bna_rcb *rcb) in bnad_rxq_cleanup() argument
357 bnad_rxq_cleanup_skb(bnad, unmap); in bnad_rxq_cleanup()
359 bnad_rxq_cleanup_page(bnad, unmap); in bnad_rxq_cleanup()
361 bnad_rxq_alloc_uninit(bnad, rcb); in bnad_rxq_cleanup()
365 bnad_rxq_refill_page(struct bnad *bnad, struct bna_rcb *rcb, u32 nalloc) in bnad_rxq_refill_page() argument
396 BNAD_UPDATE_CTR(bnad, rxbuf_alloc_failed); in bnad_rxq_refill_page()
401 dma_addr = dma_map_page(&bnad->pcidev->dev, page, page_offset, in bnad_rxq_refill_page()
403 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) { in bnad_rxq_refill_page()
405 BNAD_UPDATE_CTR(bnad, rxbuf_map_failed); in bnad_rxq_refill_page()
439 bnad_rxq_refill_skb(struct bnad *bnad, struct bna_rcb *rcb, u32 nalloc) in bnad_rxq_refill_skb() argument
456 skb = netdev_alloc_skb_ip_align(bnad->netdev, buff_sz); in bnad_rxq_refill_skb()
459 BNAD_UPDATE_CTR(bnad, rxbuf_alloc_failed); in bnad_rxq_refill_skb()
464 dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data, in bnad_rxq_refill_skb()
466 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) { in bnad_rxq_refill_skb()
468 BNAD_UPDATE_CTR(bnad, rxbuf_map_failed); in bnad_rxq_refill_skb()
495 bnad_rxq_post(struct bnad *bnad, struct bna_rcb *rcb) in bnad_rxq_post() argument
505 bnad_rxq_refill_skb(bnad, rcb, to_alloc); in bnad_rxq_post()
507 bnad_rxq_refill_page(bnad, rcb, to_alloc); in bnad_rxq_post()
525 bnad_cq_drop_packet(struct bnad *bnad, struct bna_rcb *rcb, in bnad_cq_drop_packet() argument
538 bnad_rxq_cleanup_skb(bnad, unmap); in bnad_cq_drop_packet()
540 bnad_rxq_cleanup_page(bnad, unmap); in bnad_cq_drop_packet()
548 struct bnad *bnad; in bnad_cq_setup_skb_frags() local
554 bnad = rcb->bnad; in bnad_cq_setup_skb_frags()
564 dma_unmap_page(&bnad->pcidev->dev, in bnad_cq_setup_skb_frags()
585 bnad_cq_setup_skb(struct bnad *bnad, struct sk_buff *skb, in bnad_cq_setup_skb() argument
590 dma_unmap_single(&bnad->pcidev->dev, in bnad_cq_setup_skb()
595 skb->protocol = eth_type_trans(skb, bnad->netdev); in bnad_cq_setup_skb()
602 bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget) in bnad_cq_process() argument
615 prefetch(bnad->netdev); in bnad_cq_process()
698 bnad_cq_drop_packet(bnad, rcb, sop_ci, nvecs); in bnad_cq_process()
705 bnad_cq_setup_skb(bnad, skb, unmap, len); in bnad_cq_process()
716 ((bnad->netdev->features & NETIF_F_RXCSUM) && in bnad_cq_process()
726 (bnad->netdev->features & NETIF_F_HW_VLAN_CTAG_RX)) in bnad_cq_process()
747 bnad_rxq_post(bnad, ccb->rcb[0]); in bnad_cq_process()
749 bnad_rxq_post(bnad, ccb->rcb[1]); in bnad_cq_process()
755 bnad_netif_rx_schedule_poll(struct bnad *bnad, struct bna_ccb *ccb) in bnad_netif_rx_schedule_poll() argument
774 bnad_netif_rx_schedule_poll(ccb->bnad, ccb); in bnad_msix_rx()
788 struct bnad *bnad = (struct bnad *)data; in bnad_msix_mbox_handler() local
790 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_msix_mbox_handler()
791 if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags))) { in bnad_msix_mbox_handler()
792 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_msix_mbox_handler()
796 bna_intr_status_get(&bnad->bna, intr_status); in bnad_msix_mbox_handler()
798 if (BNA_IS_MBOX_ERR_INTR(&bnad->bna, intr_status)) in bnad_msix_mbox_handler()
799 bna_mbox_handler(&bnad->bna, intr_status); in bnad_msix_mbox_handler()
801 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_msix_mbox_handler()
812 struct bnad *bnad = (struct bnad *)data; in bnad_isr() local
817 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_isr()
818 if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags))) { in bnad_isr()
819 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_isr()
823 bna_intr_status_get(&bnad->bna, intr_status); in bnad_isr()
826 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_isr()
830 if (BNA_IS_MBOX_ERR_INTR(&bnad->bna, intr_status)) in bnad_isr()
831 bna_mbox_handler(&bnad->bna, intr_status); in bnad_isr()
833 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_isr()
840 for (i = 0; i < bnad->num_tx; i++) { in bnad_isr()
841 for (j = 0; j < bnad->num_txq_per_tx; j++) { in bnad_isr()
842 tcb = bnad->tx_info[i].tcb[j]; in bnad_isr()
844 bnad_tx_complete(bnad, bnad->tx_info[i].tcb[j]); in bnad_isr()
848 for (i = 0; i < bnad->num_rx; i++) { in bnad_isr()
849 rx_info = &bnad->rx_info[i]; in bnad_isr()
852 for (j = 0; j < bnad->num_rxp_per_rx; j++) { in bnad_isr()
855 bnad_netif_rx_schedule_poll(bnad, in bnad_isr()
867 bnad_enable_mbox_irq(struct bnad *bnad) in bnad_enable_mbox_irq() argument
869 clear_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags); in bnad_enable_mbox_irq()
871 BNAD_UPDATE_CTR(bnad, mbox_intr_enabled); in bnad_enable_mbox_irq()
879 bnad_disable_mbox_irq(struct bnad *bnad) in bnad_disable_mbox_irq() argument
881 set_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags); in bnad_disable_mbox_irq()
883 BNAD_UPDATE_CTR(bnad, mbox_intr_disabled); in bnad_disable_mbox_irq()
887 bnad_set_netdev_perm_addr(struct bnad *bnad) in bnad_set_netdev_perm_addr() argument
889 struct net_device *netdev = bnad->netdev; in bnad_set_netdev_perm_addr()
891 ether_addr_copy(netdev->perm_addr, bnad->perm_addr); in bnad_set_netdev_perm_addr()
893 ether_addr_copy(netdev->dev_addr, bnad->perm_addr); in bnad_set_netdev_perm_addr()
900 bnad_cb_mbox_intr_enable(struct bnad *bnad) in bnad_cb_mbox_intr_enable() argument
902 bnad_enable_mbox_irq(bnad); in bnad_cb_mbox_intr_enable()
906 bnad_cb_mbox_intr_disable(struct bnad *bnad) in bnad_cb_mbox_intr_disable() argument
908 bnad_disable_mbox_irq(bnad); in bnad_cb_mbox_intr_disable()
912 bnad_cb_ioceth_ready(struct bnad *bnad) in bnad_cb_ioceth_ready() argument
914 bnad->bnad_completions.ioc_comp_status = BNA_CB_SUCCESS; in bnad_cb_ioceth_ready()
915 complete(&bnad->bnad_completions.ioc_comp); in bnad_cb_ioceth_ready()
919 bnad_cb_ioceth_failed(struct bnad *bnad) in bnad_cb_ioceth_failed() argument
921 bnad->bnad_completions.ioc_comp_status = BNA_CB_FAIL; in bnad_cb_ioceth_failed()
922 complete(&bnad->bnad_completions.ioc_comp); in bnad_cb_ioceth_failed()
926 bnad_cb_ioceth_disabled(struct bnad *bnad) in bnad_cb_ioceth_disabled() argument
928 bnad->bnad_completions.ioc_comp_status = BNA_CB_SUCCESS; in bnad_cb_ioceth_disabled()
929 complete(&bnad->bnad_completions.ioc_comp); in bnad_cb_ioceth_disabled()
935 struct bnad *bnad = (struct bnad *)arg; in bnad_cb_enet_disabled() local
937 netif_carrier_off(bnad->netdev); in bnad_cb_enet_disabled()
938 complete(&bnad->bnad_completions.enet_comp); in bnad_cb_enet_disabled()
942 bnad_cb_ethport_link_status(struct bnad *bnad, in bnad_cb_ethport_link_status() argument
950 if (!test_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags)) in bnad_cb_ethport_link_status()
951 BNAD_UPDATE_CTR(bnad, cee_toggle); in bnad_cb_ethport_link_status()
952 set_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags); in bnad_cb_ethport_link_status()
954 if (test_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags)) in bnad_cb_ethport_link_status()
955 BNAD_UPDATE_CTR(bnad, cee_toggle); in bnad_cb_ethport_link_status()
956 clear_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags); in bnad_cb_ethport_link_status()
960 if (!netif_carrier_ok(bnad->netdev)) { in bnad_cb_ethport_link_status()
962 netdev_info(bnad->netdev, "link up\n"); in bnad_cb_ethport_link_status()
963 netif_carrier_on(bnad->netdev); in bnad_cb_ethport_link_status()
964 BNAD_UPDATE_CTR(bnad, link_toggle); in bnad_cb_ethport_link_status()
965 for (tx_id = 0; tx_id < bnad->num_tx; tx_id++) { in bnad_cb_ethport_link_status()
966 for (tcb_id = 0; tcb_id < bnad->num_txq_per_tx; in bnad_cb_ethport_link_status()
969 bnad->tx_info[tx_id].tcb[tcb_id]; in bnad_cb_ethport_link_status()
982 bnad->netdev, in bnad_cb_ethport_link_status()
984 BNAD_UPDATE_CTR(bnad, in bnad_cb_ethport_link_status()
988 bnad->netdev, in bnad_cb_ethport_link_status()
990 BNAD_UPDATE_CTR(bnad, in bnad_cb_ethport_link_status()
997 if (netif_carrier_ok(bnad->netdev)) { in bnad_cb_ethport_link_status()
998 netdev_info(bnad->netdev, "link down\n"); in bnad_cb_ethport_link_status()
999 netif_carrier_off(bnad->netdev); in bnad_cb_ethport_link_status()
1000 BNAD_UPDATE_CTR(bnad, link_toggle); in bnad_cb_ethport_link_status()
1008 struct bnad *bnad = (struct bnad *)arg; in bnad_cb_tx_disabled() local
1010 complete(&bnad->bnad_completions.tx_comp); in bnad_cb_tx_disabled()
1014 bnad_cb_tcb_setup(struct bnad *bnad, struct bna_tcb *tcb) in bnad_cb_tcb_setup() argument
1024 bnad_cb_tcb_destroy(struct bnad *bnad, struct bna_tcb *tcb) in bnad_cb_tcb_destroy() argument
1034 bnad_cb_ccb_setup(struct bnad *bnad, struct bna_ccb *ccb) in bnad_cb_ccb_setup() argument
1044 bnad_cb_ccb_destroy(struct bnad *bnad, struct bna_ccb *ccb) in bnad_cb_ccb_destroy() argument
1053 bnad_cb_tx_stall(struct bnad *bnad, struct bna_tx *tx) in bnad_cb_tx_stall() argument
1067 netif_stop_subqueue(bnad->netdev, txq_id); in bnad_cb_tx_stall()
1072 bnad_cb_tx_resume(struct bnad *bnad, struct bna_tx *tx) in bnad_cb_tx_resume() argument
1089 if (netif_carrier_ok(bnad->netdev)) { in bnad_cb_tx_resume()
1090 netif_wake_subqueue(bnad->netdev, txq_id); in bnad_cb_tx_resume()
1091 BNAD_UPDATE_CTR(bnad, netif_queue_wakeup); in bnad_cb_tx_resume()
1100 if (is_zero_ether_addr(bnad->perm_addr)) { in bnad_cb_tx_resume()
1101 bna_enet_perm_mac_get(&bnad->bna.enet, bnad->perm_addr); in bnad_cb_tx_resume()
1102 bnad_set_netdev_perm_addr(bnad); in bnad_cb_tx_resume()
1114 struct bnad *bnad = NULL; in bnad_tx_cleanup() local
1124 bnad = tcb->bnad; in bnad_tx_cleanup()
1131 bnad_txq_cleanup(bnad, tcb); in bnad_tx_cleanup()
1138 queue_delayed_work(bnad->work_q, &tx_info->tx_cleanup_work, in bnad_tx_cleanup()
1143 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_tx_cleanup()
1145 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_tx_cleanup()
1149 bnad_cb_tx_cleanup(struct bnad *bnad, struct bna_tx *tx) in bnad_cb_tx_cleanup() argument
1161 queue_delayed_work(bnad->work_q, &tx_info->tx_cleanup_work, 0); in bnad_cb_tx_cleanup()
1165 bnad_cb_rx_stall(struct bnad *bnad, struct bna_rx *rx) in bnad_cb_rx_stall() argument
1194 struct bnad *bnad = NULL; in bnad_rx_cleanup() local
1204 bnad = rx_ctrl->ccb->bnad; in bnad_rx_cleanup()
1212 bnad_cq_cleanup(bnad, rx_ctrl->ccb); in bnad_rx_cleanup()
1213 bnad_rxq_cleanup(bnad, rx_ctrl->ccb->rcb[0]); in bnad_rx_cleanup()
1215 bnad_rxq_cleanup(bnad, rx_ctrl->ccb->rcb[1]); in bnad_rx_cleanup()
1218 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_rx_cleanup()
1220 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_rx_cleanup()
1224 bnad_cb_rx_cleanup(struct bnad *bnad, struct bna_rx *rx) in bnad_cb_rx_cleanup() argument
1243 queue_work(bnad->work_q, &rx_info->rx_cleanup_work); in bnad_cb_rx_cleanup()
1247 bnad_cb_rx_post(struct bnad *bnad, struct bna_rx *rx) in bnad_cb_rx_post() argument
1268 bnad_rxq_alloc_init(bnad, rcb); in bnad_cb_rx_post()
1271 bnad_rxq_post(bnad, rcb); in bnad_cb_rx_post()
1279 struct bnad *bnad = (struct bnad *)arg; in bnad_cb_rx_disabled() local
1281 complete(&bnad->bnad_completions.rx_comp); in bnad_cb_rx_disabled()
1285 bnad_cb_rx_mcast_add(struct bnad *bnad, struct bna_rx *rx) in bnad_cb_rx_mcast_add() argument
1287 bnad->bnad_completions.mcast_comp_status = BNA_CB_SUCCESS; in bnad_cb_rx_mcast_add()
1288 complete(&bnad->bnad_completions.mcast_comp); in bnad_cb_rx_mcast_add()
1292 bnad_cb_stats_get(struct bnad *bnad, enum bna_cb_status status, in bnad_cb_stats_get() argument
1296 BNAD_UPDATE_CTR(bnad, hw_stats_updates); in bnad_cb_stats_get()
1298 if (!netif_running(bnad->netdev) || in bnad_cb_stats_get()
1299 !test_bit(BNAD_RF_STATS_TIMER_RUNNING, &bnad->run_flags)) in bnad_cb_stats_get()
1302 mod_timer(&bnad->stats_timer, in bnad_cb_stats_get()
1307 bnad_cb_enet_mtu_set(struct bnad *bnad) in bnad_cb_enet_mtu_set() argument
1309 bnad->bnad_completions.mtu_comp_status = BNA_CB_SUCCESS; in bnad_cb_enet_mtu_set()
1310 complete(&bnad->bnad_completions.mtu_comp); in bnad_cb_enet_mtu_set()
1326 bnad_mem_free(struct bnad *bnad, in bnad_mem_free() argument
1340 dma_free_coherent(&bnad->pcidev->dev, in bnad_mem_free()
1352 bnad_mem_alloc(struct bnad *bnad, in bnad_mem_alloc() argument
1372 dma_alloc_coherent(&bnad->pcidev->dev, in bnad_mem_alloc()
1394 bnad_mem_free(bnad, mem_info); in bnad_mem_alloc()
1400 bnad_mbox_irq_free(struct bnad *bnad) in bnad_mbox_irq_free() argument
1405 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_mbox_irq_free()
1406 bnad_disable_mbox_irq(bnad); in bnad_mbox_irq_free()
1407 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_mbox_irq_free()
1409 irq = BNAD_GET_MBOX_IRQ(bnad); in bnad_mbox_irq_free()
1410 free_irq(irq, bnad); in bnad_mbox_irq_free()
1419 bnad_mbox_irq_alloc(struct bnad *bnad) in bnad_mbox_irq_alloc() argument
1426 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_mbox_irq_alloc()
1427 if (bnad->cfg_flags & BNAD_CF_MSIX) { in bnad_mbox_irq_alloc()
1429 irq = bnad->msix_table[BNAD_MAILBOX_MSIX_INDEX].vector; in bnad_mbox_irq_alloc()
1433 irq = bnad->pcidev->irq; in bnad_mbox_irq_alloc()
1437 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_mbox_irq_alloc()
1438 sprintf(bnad->mbox_irq_name, "%s", BNAD_NAME); in bnad_mbox_irq_alloc()
1444 set_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags); in bnad_mbox_irq_alloc()
1446 BNAD_UPDATE_CTR(bnad, mbox_intr_disabled); in bnad_mbox_irq_alloc()
1449 bnad->mbox_irq_name, bnad); in bnad_mbox_irq_alloc()
1455 bnad_txrx_irq_free(struct bnad *bnad, struct bna_intr_info *intr_info) in bnad_txrx_irq_free() argument
1463 bnad_txrx_irq_alloc(struct bnad *bnad, enum bnad_intr_source src, in bnad_txrx_irq_alloc() argument
1470 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_txrx_irq_alloc()
1471 cfg_flags = bnad->cfg_flags; in bnad_txrx_irq_alloc()
1472 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_txrx_irq_alloc()
1489 (bnad->num_tx * bnad->num_txq_per_tx) + in bnad_txrx_irq_alloc()
1525 bnad_tx_msix_unregister(struct bnad *bnad, struct bnad_tx_info *tx_info, in bnad_tx_msix_unregister() argument
1536 free_irq(bnad->msix_table[vector_num].vector, tx_info->tcb[i]); in bnad_tx_msix_unregister()
1544 bnad_tx_msix_register(struct bnad *bnad, struct bnad_tx_info *tx_info, in bnad_tx_msix_register() argument
1553 sprintf(tx_info->tcb[i]->name, "%s TXQ %d", bnad->netdev->name, in bnad_tx_msix_register()
1555 err = request_irq(bnad->msix_table[vector_num].vector, in bnad_tx_msix_register()
1567 bnad_tx_msix_unregister(bnad, tx_info, (i - 1)); in bnad_tx_msix_register()
1575 bnad_rx_msix_unregister(struct bnad *bnad, struct bnad_rx_info *rx_info, in bnad_rx_msix_unregister() argument
1586 free_irq(bnad->msix_table[vector_num].vector, in bnad_rx_msix_unregister()
1595 bnad_rx_msix_register(struct bnad *bnad, struct bnad_rx_info *rx_info, in bnad_rx_msix_register() argument
1605 bnad->netdev->name, in bnad_rx_msix_register()
1607 err = request_irq(bnad->msix_table[vector_num].vector, in bnad_rx_msix_register()
1619 bnad_rx_msix_unregister(bnad, rx_info, (i - 1)); in bnad_rx_msix_register()
1625 bnad_tx_res_free(struct bnad *bnad, struct bna_res_info *res_info) in bnad_tx_res_free() argument
1631 bnad_mem_free(bnad, &res_info[i].res_u.mem_info); in bnad_tx_res_free()
1633 bnad_txrx_irq_free(bnad, &res_info[i].res_u.intr_info); in bnad_tx_res_free()
1639 bnad_tx_res_alloc(struct bnad *bnad, struct bna_res_info *res_info, in bnad_tx_res_alloc() argument
1646 err = bnad_mem_alloc(bnad, in bnad_tx_res_alloc()
1649 err = bnad_txrx_irq_alloc(bnad, BNAD_INTR_TX, tx_id, in bnad_tx_res_alloc()
1657 bnad_tx_res_free(bnad, res_info); in bnad_tx_res_alloc()
1663 bnad_rx_res_free(struct bnad *bnad, struct bna_res_info *res_info) in bnad_rx_res_free() argument
1669 bnad_mem_free(bnad, &res_info[i].res_u.mem_info); in bnad_rx_res_free()
1671 bnad_txrx_irq_free(bnad, &res_info[i].res_u.intr_info); in bnad_rx_res_free()
1677 bnad_rx_res_alloc(struct bnad *bnad, struct bna_res_info *res_info, in bnad_rx_res_alloc() argument
1685 err = bnad_mem_alloc(bnad, in bnad_rx_res_alloc()
1688 err = bnad_txrx_irq_alloc(bnad, BNAD_INTR_RX, rx_id, in bnad_rx_res_alloc()
1696 bnad_rx_res_free(bnad, res_info); in bnad_rx_res_alloc()
1705 struct bnad *bnad = (struct bnad *)data; in bnad_ioc_timeout() local
1708 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_ioc_timeout()
1709 bfa_nw_ioc_timeout(&bnad->bna.ioceth.ioc); in bnad_ioc_timeout()
1710 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_ioc_timeout()
1716 struct bnad *bnad = (struct bnad *)data; in bnad_ioc_hb_check() local
1719 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_ioc_hb_check()
1720 bfa_nw_ioc_hb_check(&bnad->bna.ioceth.ioc); in bnad_ioc_hb_check()
1721 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_ioc_hb_check()
1727 struct bnad *bnad = (struct bnad *)data; in bnad_iocpf_timeout() local
1730 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_iocpf_timeout()
1731 bfa_nw_iocpf_timeout(&bnad->bna.ioceth.ioc); in bnad_iocpf_timeout()
1732 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_iocpf_timeout()
1738 struct bnad *bnad = (struct bnad *)data; in bnad_iocpf_sem_timeout() local
1741 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_iocpf_sem_timeout()
1742 bfa_nw_iocpf_sem_timeout(&bnad->bna.ioceth.ioc); in bnad_iocpf_sem_timeout()
1743 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_iocpf_sem_timeout()
1760 struct bnad *bnad = (struct bnad *)data; in bnad_dim_timeout() local
1766 if (!netif_carrier_ok(bnad->netdev)) in bnad_dim_timeout()
1769 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_dim_timeout()
1770 for (i = 0; i < bnad->num_rx; i++) { in bnad_dim_timeout()
1771 rx_info = &bnad->rx_info[i]; in bnad_dim_timeout()
1774 for (j = 0; j < bnad->num_rxp_per_rx; j++) { in bnad_dim_timeout()
1783 if (test_bit(BNAD_RF_DIM_TIMER_RUNNING, &bnad->run_flags)) in bnad_dim_timeout()
1784 mod_timer(&bnad->dim_timer, in bnad_dim_timeout()
1786 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_dim_timeout()
1793 struct bnad *bnad = (struct bnad *)data; in bnad_stats_timeout() local
1796 if (!netif_running(bnad->netdev) || in bnad_stats_timeout()
1797 !test_bit(BNAD_RF_STATS_TIMER_RUNNING, &bnad->run_flags)) in bnad_stats_timeout()
1800 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_stats_timeout()
1801 bna_hw_stats_get(&bnad->bna); in bnad_stats_timeout()
1802 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_stats_timeout()
1810 bnad_dim_timer_start(struct bnad *bnad) in bnad_dim_timer_start() argument
1812 if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED && in bnad_dim_timer_start()
1813 !test_bit(BNAD_RF_DIM_TIMER_RUNNING, &bnad->run_flags)) { in bnad_dim_timer_start()
1814 setup_timer(&bnad->dim_timer, bnad_dim_timeout, in bnad_dim_timer_start()
1815 (unsigned long)bnad); in bnad_dim_timer_start()
1816 set_bit(BNAD_RF_DIM_TIMER_RUNNING, &bnad->run_flags); in bnad_dim_timer_start()
1817 mod_timer(&bnad->dim_timer, in bnad_dim_timer_start()
1827 bnad_stats_timer_start(struct bnad *bnad) in bnad_stats_timer_start() argument
1831 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_stats_timer_start()
1832 if (!test_and_set_bit(BNAD_RF_STATS_TIMER_RUNNING, &bnad->run_flags)) { in bnad_stats_timer_start()
1833 setup_timer(&bnad->stats_timer, bnad_stats_timeout, in bnad_stats_timer_start()
1834 (unsigned long)bnad); in bnad_stats_timer_start()
1835 mod_timer(&bnad->stats_timer, in bnad_stats_timer_start()
1838 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_stats_timer_start()
1846 bnad_stats_timer_stop(struct bnad *bnad) in bnad_stats_timer_stop() argument
1851 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_stats_timer_stop()
1852 if (test_and_clear_bit(BNAD_RF_STATS_TIMER_RUNNING, &bnad->run_flags)) in bnad_stats_timer_stop()
1854 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_stats_timer_stop()
1856 del_timer_sync(&bnad->stats_timer); in bnad_stats_timer_stop()
1878 struct bnad *bnad = rx_ctrl->bnad; in bnad_napi_poll_rx() local
1883 if (!netif_carrier_ok(bnad->netdev)) in bnad_napi_poll_rx()
1886 rcvd = bnad_cq_process(bnad, rx_ctrl->ccb, budget); in bnad_napi_poll_rx()
1903 bnad_napi_add(struct bnad *bnad, u32 rx_id) in bnad_napi_add() argument
1909 for (i = 0; i < bnad->num_rxp_per_rx; i++) { in bnad_napi_add()
1910 rx_ctrl = &bnad->rx_info[rx_id].rx_ctrl[i]; in bnad_napi_add()
1911 netif_napi_add(bnad->netdev, &rx_ctrl->napi, in bnad_napi_add()
1917 bnad_napi_delete(struct bnad *bnad, u32 rx_id) in bnad_napi_delete() argument
1922 for (i = 0; i < bnad->num_rxp_per_rx; i++) in bnad_napi_delete()
1923 netif_napi_del(&bnad->rx_info[rx_id].rx_ctrl[i].napi); in bnad_napi_delete()
1928 bnad_destroy_tx(struct bnad *bnad, u32 tx_id) in bnad_destroy_tx() argument
1930 struct bnad_tx_info *tx_info = &bnad->tx_info[tx_id]; in bnad_destroy_tx()
1931 struct bna_res_info *res_info = &bnad->tx_res_info[tx_id].res_info[0]; in bnad_destroy_tx()
1937 init_completion(&bnad->bnad_completions.tx_comp); in bnad_destroy_tx()
1938 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_destroy_tx()
1940 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_destroy_tx()
1941 wait_for_completion(&bnad->bnad_completions.tx_comp); in bnad_destroy_tx()
1944 bnad_tx_msix_unregister(bnad, tx_info, in bnad_destroy_tx()
1945 bnad->num_txq_per_tx); in bnad_destroy_tx()
1947 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_destroy_tx()
1949 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_destroy_tx()
1954 bnad_tx_res_free(bnad, res_info); in bnad_destroy_tx()
1959 bnad_setup_tx(struct bnad *bnad, u32 tx_id) in bnad_setup_tx() argument
1962 struct bnad_tx_info *tx_info = &bnad->tx_info[tx_id]; in bnad_setup_tx()
1963 struct bna_res_info *res_info = &bnad->tx_res_info[tx_id].res_info[0]; in bnad_setup_tx()
1966 struct bna_tx_config *tx_config = &bnad->tx_config[tx_id]; in bnad_setup_tx()
1981 tx_config->num_txq = bnad->num_txq_per_tx; in bnad_setup_tx()
1982 tx_config->txq_depth = bnad->txq_depth; in bnad_setup_tx()
1984 tx_config->coalescing_timeo = bnad->tx_coalescing_timeo; in bnad_setup_tx()
1987 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_tx()
1988 bna_tx_res_req(bnad->num_txq_per_tx, in bnad_setup_tx()
1989 bnad->txq_depth, res_info); in bnad_setup_tx()
1990 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_tx()
1994 bnad->num_txq_per_tx, (sizeof(struct bnad_tx_unmap) * in bnad_setup_tx()
1995 bnad->txq_depth)); in bnad_setup_tx()
1998 err = bnad_tx_res_alloc(bnad, res_info, tx_id); in bnad_setup_tx()
2003 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_tx()
2004 tx = bna_tx_create(&bnad->bna, bnad, tx_config, &tx_cbfn, res_info, in bnad_setup_tx()
2006 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_tx()
2018 err = bnad_tx_msix_register(bnad, tx_info, in bnad_setup_tx()
2019 tx_id, bnad->num_txq_per_tx); in bnad_setup_tx()
2024 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_tx()
2026 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_tx()
2031 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_tx()
2033 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_tx()
2037 bnad_tx_res_free(bnad, res_info); in bnad_setup_tx()
2044 bnad_init_rx_config(struct bnad *bnad, struct bna_rx_config *rx_config) in bnad_init_rx_config() argument
2048 rx_config->num_paths = bnad->num_rxp_per_rx; in bnad_init_rx_config()
2049 rx_config->coalescing_timeo = bnad->rx_coalescing_timeo; in bnad_init_rx_config()
2051 if (bnad->num_rxp_per_rx > 1) { in bnad_init_rx_config()
2059 bnad->num_rxp_per_rx - 1; in bnad_init_rx_config()
2068 rx_config->frame_size = BNAD_FRAME_SIZE(bnad->netdev->mtu); in bnad_init_rx_config()
2078 if (BNAD_PCI_DEV_IS_CAT2(bnad) && in bnad_init_rx_config()
2087 rx_config->q0_depth = bnad->rxq_depth * rx_config->q0_num_vecs; in bnad_init_rx_config()
2092 rx_config->q0_depth = bnad->rxq_depth; in bnad_init_rx_config()
2097 rx_config->q1_depth = bnad->rxq_depth; in bnad_init_rx_config()
2102 (bnad->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) ? in bnad_init_rx_config()
2107 bnad_rx_ctrl_init(struct bnad *bnad, u32 rx_id) in bnad_rx_ctrl_init() argument
2109 struct bnad_rx_info *rx_info = &bnad->rx_info[rx_id]; in bnad_rx_ctrl_init()
2112 for (i = 0; i < bnad->num_rxp_per_rx; i++) in bnad_rx_ctrl_init()
2113 rx_info->rx_ctrl[i].bnad = bnad; in bnad_rx_ctrl_init()
2118 bnad_reinit_rx(struct bnad *bnad) in bnad_reinit_rx() argument
2120 struct net_device *netdev = bnad->netdev; in bnad_reinit_rx()
2126 for (rx_id = 0; rx_id < bnad->num_rx; rx_id++) { in bnad_reinit_rx()
2127 if (!bnad->rx_info[rx_id].rx) in bnad_reinit_rx()
2129 bnad_destroy_rx(bnad, rx_id); in bnad_reinit_rx()
2132 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_reinit_rx()
2133 bna_enet_mtu_set(&bnad->bna.enet, in bnad_reinit_rx()
2134 BNAD_FRAME_SIZE(bnad->netdev->mtu), NULL); in bnad_reinit_rx()
2135 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_reinit_rx()
2137 for (rx_id = 0; rx_id < bnad->num_rx; rx_id++) { in bnad_reinit_rx()
2139 current_err = bnad_setup_rx(bnad, rx_id); in bnad_reinit_rx()
2147 if (bnad->rx_info[0].rx && !err) { in bnad_reinit_rx()
2148 bnad_restore_vlans(bnad, 0); in bnad_reinit_rx()
2149 bnad_enable_default_bcast(bnad); in bnad_reinit_rx()
2150 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_reinit_rx()
2151 bnad_mac_addr_set_locked(bnad, netdev->dev_addr); in bnad_reinit_rx()
2152 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_reinit_rx()
2161 bnad_destroy_rx(struct bnad *bnad, u32 rx_id) in bnad_destroy_rx() argument
2163 struct bnad_rx_info *rx_info = &bnad->rx_info[rx_id]; in bnad_destroy_rx()
2164 struct bna_rx_config *rx_config = &bnad->rx_config[rx_id]; in bnad_destroy_rx()
2165 struct bna_res_info *res_info = &bnad->rx_res_info[rx_id].res_info[0]; in bnad_destroy_rx()
2173 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_destroy_rx()
2174 if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED && in bnad_destroy_rx()
2175 test_bit(BNAD_RF_DIM_TIMER_RUNNING, &bnad->run_flags)) { in bnad_destroy_rx()
2176 clear_bit(BNAD_RF_DIM_TIMER_RUNNING, &bnad->run_flags); in bnad_destroy_rx()
2179 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_destroy_rx()
2181 del_timer_sync(&bnad->dim_timer); in bnad_destroy_rx()
2184 init_completion(&bnad->bnad_completions.rx_comp); in bnad_destroy_rx()
2185 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_destroy_rx()
2187 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_destroy_rx()
2188 wait_for_completion(&bnad->bnad_completions.rx_comp); in bnad_destroy_rx()
2191 bnad_rx_msix_unregister(bnad, rx_info, rx_config->num_paths); in bnad_destroy_rx()
2193 bnad_napi_delete(bnad, rx_id); in bnad_destroy_rx()
2195 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_destroy_rx()
2200 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_destroy_rx()
2202 bnad_rx_res_free(bnad, res_info); in bnad_destroy_rx()
2207 bnad_setup_rx(struct bnad *bnad, u32 rx_id) in bnad_setup_rx() argument
2210 struct bnad_rx_info *rx_info = &bnad->rx_info[rx_id]; in bnad_setup_rx()
2211 struct bna_res_info *res_info = &bnad->rx_res_info[rx_id].res_info[0]; in bnad_setup_rx()
2214 struct bna_rx_config *rx_config = &bnad->rx_config[rx_id]; in bnad_setup_rx()
2230 bnad_init_rx_config(bnad, rx_config); in bnad_setup_rx()
2233 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_rx()
2235 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_rx()
2252 err = bnad_rx_res_alloc(bnad, res_info, rx_id); in bnad_setup_rx()
2256 bnad_rx_ctrl_init(bnad, rx_id); in bnad_setup_rx()
2259 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_rx()
2260 rx = bna_rx_create(&bnad->bna, bnad, rx_config, &rx_cbfn, res_info, in bnad_setup_rx()
2264 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_rx()
2268 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_rx()
2277 bnad_napi_add(bnad, rx_id); in bnad_setup_rx()
2281 err = bnad_rx_msix_register(bnad, rx_info, rx_id, in bnad_setup_rx()
2287 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_setup_rx()
2290 if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED) in bnad_setup_rx()
2291 bna_rx_dim_reconfig(&bnad->bna, bna_napi_dim_vector); in bnad_setup_rx()
2297 bnad_dim_timer_start(bnad); in bnad_setup_rx()
2301 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_setup_rx()
2306 bnad_destroy_rx(bnad, rx_id); in bnad_setup_rx()
2312 bnad_tx_coalescing_timeo_set(struct bnad *bnad) in bnad_tx_coalescing_timeo_set() argument
2316 tx_info = &bnad->tx_info[0]; in bnad_tx_coalescing_timeo_set()
2320 bna_tx_coalescing_timeo_set(tx_info->tx, bnad->tx_coalescing_timeo); in bnad_tx_coalescing_timeo_set()
2325 bnad_rx_coalescing_timeo_set(struct bnad *bnad) in bnad_rx_coalescing_timeo_set() argument
2330 for (i = 0; i < bnad->num_rx; i++) { in bnad_rx_coalescing_timeo_set()
2331 rx_info = &bnad->rx_info[i]; in bnad_rx_coalescing_timeo_set()
2335 bnad->rx_coalescing_timeo); in bnad_rx_coalescing_timeo_set()
2343 bnad_mac_addr_set_locked(struct bnad *bnad, const u8 *mac_addr) in bnad_mac_addr_set_locked() argument
2351 if (!bnad->rx_info[0].rx) in bnad_mac_addr_set_locked()
2354 ret = bna_rx_ucast_set(bnad->rx_info[0].rx, mac_addr); in bnad_mac_addr_set_locked()
2363 bnad_enable_default_bcast(struct bnad *bnad) in bnad_enable_default_bcast() argument
2365 struct bnad_rx_info *rx_info = &bnad->rx_info[0]; in bnad_enable_default_bcast()
2369 init_completion(&bnad->bnad_completions.mcast_comp); in bnad_enable_default_bcast()
2371 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_enable_default_bcast()
2374 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_enable_default_bcast()
2377 wait_for_completion(&bnad->bnad_completions.mcast_comp); in bnad_enable_default_bcast()
2381 if (bnad->bnad_completions.mcast_comp_status != BNA_CB_SUCCESS) in bnad_enable_default_bcast()
2389 bnad_restore_vlans(struct bnad *bnad, u32 rx_id) in bnad_restore_vlans() argument
2394 for_each_set_bit(vid, bnad->active_vlans, VLAN_N_VID) { in bnad_restore_vlans()
2395 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_restore_vlans()
2396 bna_rx_vlan_add(bnad->rx_info[rx_id].rx, vid); in bnad_restore_vlans()
2397 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_restore_vlans()
2403 bnad_netdev_qstats_fill(struct bnad *bnad, struct rtnl_link_stats64 *stats) in bnad_netdev_qstats_fill() argument
2407 for (i = 0; i < bnad->num_rx; i++) { in bnad_netdev_qstats_fill()
2408 for (j = 0; j < bnad->num_rxp_per_rx; j++) { in bnad_netdev_qstats_fill()
2409 if (bnad->rx_info[i].rx_ctrl[j].ccb) { in bnad_netdev_qstats_fill()
2410 stats->rx_packets += bnad->rx_info[i]. in bnad_netdev_qstats_fill()
2412 stats->rx_bytes += bnad->rx_info[i]. in bnad_netdev_qstats_fill()
2414 if (bnad->rx_info[i].rx_ctrl[j].ccb->rcb[1] && in bnad_netdev_qstats_fill()
2415 bnad->rx_info[i].rx_ctrl[j].ccb-> in bnad_netdev_qstats_fill()
2418 bnad->rx_info[i].rx_ctrl[j]. in bnad_netdev_qstats_fill()
2421 bnad->rx_info[i].rx_ctrl[j]. in bnad_netdev_qstats_fill()
2427 for (i = 0; i < bnad->num_tx; i++) { in bnad_netdev_qstats_fill()
2428 for (j = 0; j < bnad->num_txq_per_tx; j++) { in bnad_netdev_qstats_fill()
2429 if (bnad->tx_info[i].tcb[j]) { in bnad_netdev_qstats_fill()
2431 bnad->tx_info[i].tcb[j]->txq->tx_packets; in bnad_netdev_qstats_fill()
2433 bnad->tx_info[i].tcb[j]->txq->tx_bytes; in bnad_netdev_qstats_fill()
2443 bnad_netdev_hwstats_fill(struct bnad *bnad, struct rtnl_link_stats64 *stats) in bnad_netdev_hwstats_fill() argument
2449 mac_stats = &bnad->stats.bna_stats->hw_stats.mac_stats; in bnad_netdev_hwstats_fill()
2468 bmap = bna_rx_rid_mask(&bnad->bna); in bnad_netdev_hwstats_fill()
2472 bnad->stats.bna_stats-> in bnad_netdev_hwstats_fill()
2481 bnad_mbox_irq_sync(struct bnad *bnad) in bnad_mbox_irq_sync() argument
2486 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_mbox_irq_sync()
2487 if (bnad->cfg_flags & BNAD_CF_MSIX) in bnad_mbox_irq_sync()
2488 irq = bnad->msix_table[BNAD_MAILBOX_MSIX_INDEX].vector; in bnad_mbox_irq_sync()
2490 irq = bnad->pcidev->irq; in bnad_mbox_irq_sync()
2491 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_mbox_irq_sync()
2498 bnad_tso_prepare(struct bnad *bnad, struct sk_buff *skb) in bnad_tso_prepare() argument
2504 BNAD_UPDATE_CTR(bnad, tso_err); in bnad_tso_prepare()
2522 BNAD_UPDATE_CTR(bnad, tso4); in bnad_tso_prepare()
2530 BNAD_UPDATE_CTR(bnad, tso6); in bnad_tso_prepare()
2542 bnad_q_num_init(struct bnad *bnad) in bnad_q_num_init() argument
2549 if (!(bnad->cfg_flags & BNAD_CF_MSIX)) in bnad_q_num_init()
2552 bnad->num_rx = 1; in bnad_q_num_init()
2553 bnad->num_tx = 1; in bnad_q_num_init()
2554 bnad->num_rxp_per_rx = rxps; in bnad_q_num_init()
2555 bnad->num_txq_per_tx = BNAD_TXQ_NUM; in bnad_q_num_init()
2565 bnad_q_num_adjust(struct bnad *bnad, int msix_vectors, int temp) in bnad_q_num_adjust() argument
2567 bnad->num_txq_per_tx = 1; in bnad_q_num_adjust()
2568 if ((msix_vectors >= (bnad->num_tx * bnad->num_txq_per_tx) + in bnad_q_num_adjust()
2570 (bnad->cfg_flags & BNAD_CF_MSIX)) { in bnad_q_num_adjust()
2571 bnad->num_rxp_per_rx = msix_vectors - in bnad_q_num_adjust()
2572 (bnad->num_tx * bnad->num_txq_per_tx) - in bnad_q_num_adjust()
2575 bnad->num_rxp_per_rx = 1; in bnad_q_num_adjust()
2580 bnad_ioceth_disable(struct bnad *bnad) in bnad_ioceth_disable() argument
2585 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_ioceth_disable()
2586 init_completion(&bnad->bnad_completions.ioc_comp); in bnad_ioceth_disable()
2587 bna_ioceth_disable(&bnad->bna.ioceth, BNA_HARD_CLEANUP); in bnad_ioceth_disable()
2588 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_ioceth_disable()
2590 wait_for_completion_timeout(&bnad->bnad_completions.ioc_comp, in bnad_ioceth_disable()
2593 err = bnad->bnad_completions.ioc_comp_status; in bnad_ioceth_disable()
2598 bnad_ioceth_enable(struct bnad *bnad) in bnad_ioceth_enable() argument
2603 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_ioceth_enable()
2604 init_completion(&bnad->bnad_completions.ioc_comp); in bnad_ioceth_enable()
2605 bnad->bnad_completions.ioc_comp_status = BNA_CB_WAITING; in bnad_ioceth_enable()
2606 bna_ioceth_enable(&bnad->bna.ioceth); in bnad_ioceth_enable()
2607 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_ioceth_enable()
2609 wait_for_completion_timeout(&bnad->bnad_completions.ioc_comp, in bnad_ioceth_enable()
2612 err = bnad->bnad_completions.ioc_comp_status; in bnad_ioceth_enable()
2619 bnad_res_free(struct bnad *bnad, struct bna_res_info *res_info, in bnad_res_free() argument
2625 bnad_mem_free(bnad, &res_info[i].res_u.mem_info); in bnad_res_free()
2630 bnad_res_alloc(struct bnad *bnad, struct bna_res_info *res_info, in bnad_res_alloc() argument
2636 err = bnad_mem_alloc(bnad, &res_info[i].res_u.mem_info); in bnad_res_alloc()
2643 bnad_res_free(bnad, res_info, res_val_max); in bnad_res_alloc()
2649 bnad_enable_msix(struct bnad *bnad) in bnad_enable_msix() argument
2654 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_enable_msix()
2655 if (!(bnad->cfg_flags & BNAD_CF_MSIX)) { in bnad_enable_msix()
2656 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_enable_msix()
2659 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_enable_msix()
2661 if (bnad->msix_table) in bnad_enable_msix()
2664 bnad->msix_table = in bnad_enable_msix()
2665 kcalloc(bnad->msix_num, sizeof(struct msix_entry), GFP_KERNEL); in bnad_enable_msix()
2667 if (!bnad->msix_table) in bnad_enable_msix()
2670 for (i = 0; i < bnad->msix_num; i++) in bnad_enable_msix()
2671 bnad->msix_table[i].entry = i; in bnad_enable_msix()
2673 ret = pci_enable_msix_range(bnad->pcidev, bnad->msix_table, in bnad_enable_msix()
2674 1, bnad->msix_num); in bnad_enable_msix()
2677 } else if (ret < bnad->msix_num) { in bnad_enable_msix()
2678 dev_warn(&bnad->pcidev->dev, in bnad_enable_msix()
2680 ret, bnad->msix_num); in bnad_enable_msix()
2682 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_enable_msix()
2684 bnad_q_num_adjust(bnad, (ret - BNAD_MAILBOX_MSIX_VECTORS) / 2, in bnad_enable_msix()
2686 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_enable_msix()
2688 bnad->msix_num = BNAD_NUM_TXQ + BNAD_NUM_RXP + in bnad_enable_msix()
2691 if (bnad->msix_num > ret) { in bnad_enable_msix()
2692 pci_disable_msix(bnad->pcidev); in bnad_enable_msix()
2697 pci_intx(bnad->pcidev, 0); in bnad_enable_msix()
2702 dev_warn(&bnad->pcidev->dev, in bnad_enable_msix()
2705 kfree(bnad->msix_table); in bnad_enable_msix()
2706 bnad->msix_table = NULL; in bnad_enable_msix()
2707 bnad->msix_num = 0; in bnad_enable_msix()
2708 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_enable_msix()
2709 bnad->cfg_flags &= ~BNAD_CF_MSIX; in bnad_enable_msix()
2710 bnad_q_num_init(bnad); in bnad_enable_msix()
2711 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_enable_msix()
2715 bnad_disable_msix(struct bnad *bnad) in bnad_disable_msix() argument
2720 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_disable_msix()
2721 cfg_flags = bnad->cfg_flags; in bnad_disable_msix()
2722 if (bnad->cfg_flags & BNAD_CF_MSIX) in bnad_disable_msix()
2723 bnad->cfg_flags &= ~BNAD_CF_MSIX; in bnad_disable_msix()
2724 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_disable_msix()
2727 pci_disable_msix(bnad->pcidev); in bnad_disable_msix()
2728 kfree(bnad->msix_table); in bnad_disable_msix()
2729 bnad->msix_table = NULL; in bnad_disable_msix()
2738 struct bnad *bnad = netdev_priv(netdev); in bnad_open() local
2742 mutex_lock(&bnad->conf_mutex); in bnad_open()
2745 err = bnad_setup_tx(bnad, 0); in bnad_open()
2750 err = bnad_setup_rx(bnad, 0); in bnad_open()
2758 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_open()
2759 bna_enet_mtu_set(&bnad->bna.enet, in bnad_open()
2760 BNAD_FRAME_SIZE(bnad->netdev->mtu), NULL); in bnad_open()
2761 bna_enet_pause_config(&bnad->bna.enet, &pause_config); in bnad_open()
2762 bna_enet_enable(&bnad->bna.enet); in bnad_open()
2763 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_open()
2766 bnad_enable_default_bcast(bnad); in bnad_open()
2769 bnad_restore_vlans(bnad, 0); in bnad_open()
2772 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_open()
2773 bnad_mac_addr_set_locked(bnad, netdev->dev_addr); in bnad_open()
2774 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_open()
2777 bnad_stats_timer_start(bnad); in bnad_open()
2779 mutex_unlock(&bnad->conf_mutex); in bnad_open()
2784 bnad_destroy_tx(bnad, 0); in bnad_open()
2787 mutex_unlock(&bnad->conf_mutex); in bnad_open()
2794 struct bnad *bnad = netdev_priv(netdev); in bnad_stop() local
2797 mutex_lock(&bnad->conf_mutex); in bnad_stop()
2800 bnad_stats_timer_stop(bnad); in bnad_stop()
2802 init_completion(&bnad->bnad_completions.enet_comp); in bnad_stop()
2804 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_stop()
2805 bna_enet_disable(&bnad->bna.enet, BNA_HARD_CLEANUP, in bnad_stop()
2807 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_stop()
2809 wait_for_completion(&bnad->bnad_completions.enet_comp); in bnad_stop()
2811 bnad_destroy_tx(bnad, 0); in bnad_stop()
2812 bnad_destroy_rx(bnad, 0); in bnad_stop()
2815 bnad_mbox_irq_sync(bnad); in bnad_stop()
2817 mutex_unlock(&bnad->conf_mutex); in bnad_stop()
2825 bnad_txq_wi_prepare(struct bnad *bnad, struct bna_tcb *tcb, in bnad_txq_wi_prepare() argument
2836 if (test_bit(BNAD_RF_CEE_RUNNING, &bnad->run_flags)) { in bnad_txq_wi_prepare()
2845 if (unlikely(gso_size > bnad->netdev->mtu)) { in bnad_txq_wi_prepare()
2846 BNAD_UPDATE_CTR(bnad, tx_skb_mss_too_long); in bnad_txq_wi_prepare()
2853 BNAD_UPDATE_CTR(bnad, tx_skb_tso_too_short); in bnad_txq_wi_prepare()
2859 if (bnad_tso_prepare(bnad, skb)) { in bnad_txq_wi_prepare()
2860 BNAD_UPDATE_CTR(bnad, tx_skb_tso_prepare); in bnad_txq_wi_prepare()
2872 if (unlikely(skb->len > (bnad->netdev->mtu + VLAN_ETH_HLEN))) { in bnad_txq_wi_prepare()
2873 BNAD_UPDATE_CTR(bnad, tx_skb_non_tso_too_long); in bnad_txq_wi_prepare()
2895 BNAD_UPDATE_CTR(bnad, tcpcsum_offload); in bnad_txq_wi_prepare()
2900 BNAD_UPDATE_CTR(bnad, tx_skb_tcp_hdr); in bnad_txq_wi_prepare()
2909 BNAD_UPDATE_CTR(bnad, udpcsum_offload); in bnad_txq_wi_prepare()
2913 BNAD_UPDATE_CTR(bnad, tx_skb_udp_hdr); in bnad_txq_wi_prepare()
2918 BNAD_UPDATE_CTR(bnad, tx_skb_csum_err); in bnad_txq_wi_prepare()
2938 struct bnad *bnad = netdev_priv(netdev); in bnad_start_xmit() local
2954 BNAD_UPDATE_CTR(bnad, tx_skb_too_short); in bnad_start_xmit()
2959 BNAD_UPDATE_CTR(bnad, tx_skb_headlen_zero); in bnad_start_xmit()
2964 BNAD_UPDATE_CTR(bnad, tx_skb_headlen_zero); in bnad_start_xmit()
2968 tcb = bnad->tx_info[0].tcb[txq_id]; in bnad_start_xmit()
2976 BNAD_UPDATE_CTR(bnad, tx_skb_stopping); in bnad_start_xmit()
2989 BNAD_UPDATE_CTR(bnad, tx_skb_max_vectors); in bnad_start_xmit()
2998 sent = bnad_txcmpl_process(bnad, tcb); in bnad_start_xmit()
3005 BNAD_UPDATE_CTR(bnad, netif_queue_stop); in bnad_start_xmit()
3015 BNAD_UPDATE_CTR(bnad, netif_queue_stop); in bnad_start_xmit()
3019 BNAD_UPDATE_CTR(bnad, netif_queue_wakeup); in bnad_start_xmit()
3027 if (bnad_txq_wi_prepare(bnad, tcb, skb, txqent)) { in bnad_start_xmit()
3039 dma_addr = dma_map_single(&bnad->pcidev->dev, skb->data, in bnad_start_xmit()
3041 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) { in bnad_start_xmit()
3043 BNAD_UPDATE_CTR(bnad, tx_skb_map_failed); in bnad_start_xmit()
3057 bnad_tx_buff_unmap(bnad, unmap_q, q_depth, in bnad_start_xmit()
3060 BNAD_UPDATE_CTR(bnad, tx_skb_frag_zero); in bnad_start_xmit()
3075 dma_addr = skb_frag_dma_map(&bnad->pcidev->dev, frag, in bnad_start_xmit()
3077 if (dma_mapping_error(&bnad->pcidev->dev, dma_addr)) { in bnad_start_xmit()
3079 bnad_tx_buff_unmap(bnad, unmap_q, q_depth, in bnad_start_xmit()
3082 BNAD_UPDATE_CTR(bnad, tx_skb_map_failed); in bnad_start_xmit()
3096 bnad_tx_buff_unmap(bnad, unmap_q, q_depth, tcb->producer_index); in bnad_start_xmit()
3098 BNAD_UPDATE_CTR(bnad, tx_skb_len_mismatch); in bnad_start_xmit()
3125 struct bnad *bnad = netdev_priv(netdev); in bnad_get_stats64() local
3128 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_get_stats64()
3130 bnad_netdev_qstats_fill(bnad, stats); in bnad_get_stats64()
3131 bnad_netdev_hwstats_fill(bnad, stats); in bnad_get_stats64()
3133 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_get_stats64()
3139 bnad_set_rx_ucast_fltr(struct bnad *bnad) in bnad_set_rx_ucast_fltr() argument
3141 struct net_device *netdev = bnad->netdev; in bnad_set_rx_ucast_fltr()
3148 if (netdev_uc_empty(bnad->netdev)) { in bnad_set_rx_ucast_fltr()
3149 bna_rx_ucast_listset(bnad->rx_info[0].rx, 0, NULL); in bnad_set_rx_ucast_fltr()
3153 if (uc_count > bna_attr(&bnad->bna)->num_ucmac) in bnad_set_rx_ucast_fltr()
3166 ret = bna_rx_ucast_listset(bnad->rx_info[0].rx, entry, mac_list); in bnad_set_rx_ucast_fltr()
3176 bnad->cfg_flags |= BNAD_CF_DEFAULT; in bnad_set_rx_ucast_fltr()
3177 bna_rx_ucast_listset(bnad->rx_info[0].rx, 0, NULL); in bnad_set_rx_ucast_fltr()
3181 bnad_set_rx_mcast_fltr(struct bnad *bnad) in bnad_set_rx_mcast_fltr() argument
3183 struct net_device *netdev = bnad->netdev; in bnad_set_rx_mcast_fltr()
3194 if (mc_count > bna_attr(&bnad->bna)->num_mcmac) in bnad_set_rx_mcast_fltr()
3206 ret = bna_rx_mcast_listset(bnad->rx_info[0].rx, mc_count + 1, mac_list); in bnad_set_rx_mcast_fltr()
3215 bnad->cfg_flags |= BNAD_CF_ALLMULTI; in bnad_set_rx_mcast_fltr()
3216 bna_rx_mcast_delall(bnad->rx_info[0].rx); in bnad_set_rx_mcast_fltr()
3222 struct bnad *bnad = netdev_priv(netdev); in bnad_set_rx_mode() local
3226 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_set_rx_mode()
3228 if (bnad->rx_info[0].rx == NULL) { in bnad_set_rx_mode()
3229 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_set_rx_mode()
3234 bnad->cfg_flags &= ~(BNAD_CF_PROMISC | BNAD_CF_DEFAULT | in bnad_set_rx_mode()
3240 bnad->cfg_flags |= BNAD_CF_PROMISC; in bnad_set_rx_mode()
3242 bnad_set_rx_mcast_fltr(bnad); in bnad_set_rx_mode()
3244 if (bnad->cfg_flags & BNAD_CF_ALLMULTI) in bnad_set_rx_mode()
3247 bnad_set_rx_ucast_fltr(bnad); in bnad_set_rx_mode()
3249 if (bnad->cfg_flags & BNAD_CF_DEFAULT) in bnad_set_rx_mode()
3255 bna_rx_mode_set(bnad->rx_info[0].rx, new_mode, mode_mask); in bnad_set_rx_mode()
3257 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_set_rx_mode()
3269 struct bnad *bnad = netdev_priv(netdev); in bnad_set_mac_address() local
3273 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_set_mac_address()
3275 err = bnad_mac_addr_set_locked(bnad, sa->sa_data); in bnad_set_mac_address()
3279 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_set_mac_address()
3285 bnad_mtu_set(struct bnad *bnad, int frame_size) in bnad_mtu_set() argument
3289 init_completion(&bnad->bnad_completions.mtu_comp); in bnad_mtu_set()
3291 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_mtu_set()
3292 bna_enet_mtu_set(&bnad->bna.enet, frame_size, bnad_cb_enet_mtu_set); in bnad_mtu_set()
3293 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_mtu_set()
3295 wait_for_completion(&bnad->bnad_completions.mtu_comp); in bnad_mtu_set()
3297 return bnad->bnad_completions.mtu_comp_status; in bnad_mtu_set()
3304 struct bnad *bnad = netdev_priv(netdev); in bnad_change_mtu() local
3310 mutex_lock(&bnad->conf_mutex); in bnad_change_mtu()
3319 if (BNAD_PCI_DEV_IS_CAT2(bnad) && in bnad_change_mtu()
3320 netif_running(bnad->netdev)) { in bnad_change_mtu()
3324 rx_count = bnad_reinit_rx(bnad); in bnad_change_mtu()
3330 err = bnad_mtu_set(bnad, new_frame); in bnad_change_mtu()
3334 mutex_unlock(&bnad->conf_mutex); in bnad_change_mtu()
3341 struct bnad *bnad = netdev_priv(netdev); in bnad_vlan_rx_add_vid() local
3344 if (!bnad->rx_info[0].rx) in bnad_vlan_rx_add_vid()
3347 mutex_lock(&bnad->conf_mutex); in bnad_vlan_rx_add_vid()
3349 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_vlan_rx_add_vid()
3350 bna_rx_vlan_add(bnad->rx_info[0].rx, vid); in bnad_vlan_rx_add_vid()
3351 set_bit(vid, bnad->active_vlans); in bnad_vlan_rx_add_vid()
3352 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_vlan_rx_add_vid()
3354 mutex_unlock(&bnad->conf_mutex); in bnad_vlan_rx_add_vid()
3362 struct bnad *bnad = netdev_priv(netdev); in bnad_vlan_rx_kill_vid() local
3365 if (!bnad->rx_info[0].rx) in bnad_vlan_rx_kill_vid()
3368 mutex_lock(&bnad->conf_mutex); in bnad_vlan_rx_kill_vid()
3370 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_vlan_rx_kill_vid()
3371 clear_bit(vid, bnad->active_vlans); in bnad_vlan_rx_kill_vid()
3372 bna_rx_vlan_del(bnad->rx_info[0].rx, vid); in bnad_vlan_rx_kill_vid()
3373 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_vlan_rx_kill_vid()
3375 mutex_unlock(&bnad->conf_mutex); in bnad_vlan_rx_kill_vid()
3382 struct bnad *bnad = netdev_priv(dev); in bnad_set_features() local
3388 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_set_features()
3391 bna_rx_vlan_strip_enable(bnad->rx_info[0].rx); in bnad_set_features()
3393 bna_rx_vlan_strip_disable(bnad->rx_info[0].rx); in bnad_set_features()
3395 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_set_features()
3405 struct bnad *bnad = netdev_priv(netdev); in bnad_netpoll() local
3411 if (!(bnad->cfg_flags & BNAD_CF_MSIX)) { in bnad_netpoll()
3412 bna_intx_disable(&bnad->bna, curr_mask); in bnad_netpoll()
3413 bnad_isr(bnad->pcidev->irq, netdev); in bnad_netpoll()
3414 bna_intx_enable(&bnad->bna, curr_mask); in bnad_netpoll()
3422 for (i = 0; i < bnad->num_rx; i++) { in bnad_netpoll()
3423 rx_info = &bnad->rx_info[i]; in bnad_netpoll()
3426 for (j = 0; j < bnad->num_rxp_per_rx; j++) { in bnad_netpoll()
3429 bnad_netif_rx_schedule_poll(bnad, in bnad_netpoll()
3455 bnad_netdev_init(struct bnad *bnad, bool using_dac) in bnad_netdev_init() argument
3457 struct net_device *netdev = bnad->netdev; in bnad_netdev_init()
3473 netdev->mem_start = bnad->mmio_start; in bnad_netdev_init()
3474 netdev->mem_end = bnad->mmio_start + bnad->mmio_len - 1; in bnad_netdev_init()
3487 bnad_init(struct bnad *bnad, in bnad_init() argument
3495 bnad->netdev = netdev; in bnad_init()
3496 bnad->pcidev = pdev; in bnad_init()
3497 bnad->mmio_start = pci_resource_start(pdev, 0); in bnad_init()
3498 bnad->mmio_len = pci_resource_len(pdev, 0); in bnad_init()
3499 bnad->bar0 = ioremap_nocache(bnad->mmio_start, bnad->mmio_len); in bnad_init()
3500 if (!bnad->bar0) { in bnad_init()
3504 dev_info(&pdev->dev, "bar0 mapped to %p, len %llu\n", bnad->bar0, in bnad_init()
3505 (unsigned long long) bnad->mmio_len); in bnad_init()
3507 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_init()
3509 bnad->cfg_flags = BNAD_CF_MSIX; in bnad_init()
3511 bnad->cfg_flags |= BNAD_CF_DIM_ENABLED; in bnad_init()
3513 bnad_q_num_init(bnad); in bnad_init()
3514 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_init()
3516 bnad->msix_num = (bnad->num_tx * bnad->num_txq_per_tx) + in bnad_init()
3517 (bnad->num_rx * bnad->num_rxp_per_rx) + in bnad_init()
3520 bnad->txq_depth = BNAD_TXQ_DEPTH; in bnad_init()
3521 bnad->rxq_depth = BNAD_RXQ_DEPTH; in bnad_init()
3523 bnad->tx_coalescing_timeo = BFI_TX_COALESCING_TIMEO; in bnad_init()
3524 bnad->rx_coalescing_timeo = BFI_RX_COALESCING_TIMEO; in bnad_init()
3526 sprintf(bnad->wq_name, "%s_wq_%d", BNAD_NAME, bnad->id); in bnad_init()
3527 bnad->work_q = create_singlethread_workqueue(bnad->wq_name); in bnad_init()
3528 if (!bnad->work_q) { in bnad_init()
3529 iounmap(bnad->bar0); in bnad_init()
3542 bnad_uninit(struct bnad *bnad) in bnad_uninit() argument
3544 if (bnad->work_q) { in bnad_uninit()
3545 flush_workqueue(bnad->work_q); in bnad_uninit()
3546 destroy_workqueue(bnad->work_q); in bnad_uninit()
3547 bnad->work_q = NULL; in bnad_uninit()
3550 if (bnad->bar0) in bnad_uninit()
3551 iounmap(bnad->bar0); in bnad_uninit()
3561 bnad_lock_init(struct bnad *bnad) in bnad_lock_init() argument
3563 spin_lock_init(&bnad->bna_lock); in bnad_lock_init()
3564 mutex_init(&bnad->conf_mutex); in bnad_lock_init()
3569 bnad_lock_uninit(struct bnad *bnad) in bnad_lock_uninit() argument
3571 mutex_destroy(&bnad->conf_mutex); in bnad_lock_uninit()
3577 bnad_pci_init(struct bnad *bnad, in bnad_pci_init() argument
3620 struct bnad *bnad; in bnad_pci_probe() local
3638 netdev = alloc_etherdev(sizeof(struct bnad)); in bnad_pci_probe()
3643 bnad = netdev_priv(netdev); in bnad_pci_probe()
3644 bnad_lock_init(bnad); in bnad_pci_probe()
3645 bnad_add_to_list(bnad); in bnad_pci_probe()
3647 mutex_lock(&bnad->conf_mutex); in bnad_pci_probe()
3654 err = bnad_pci_init(bnad, pdev, &using_dac); in bnad_pci_probe()
3662 err = bnad_init(bnad, pdev, netdev); in bnad_pci_probe()
3667 bnad_netdev_init(bnad, using_dac); in bnad_pci_probe()
3674 bnad_debugfs_init(bnad); in bnad_pci_probe()
3677 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3678 bna_res_req(&bnad->res_info[0]); in bnad_pci_probe()
3679 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3682 err = bnad_res_alloc(bnad, &bnad->res_info[0], BNA_RES_T_MAX); in bnad_pci_probe()
3686 bna = &bnad->bna; in bnad_pci_probe()
3689 pcidev_info.pci_slot = PCI_SLOT(bnad->pcidev->devfn); in bnad_pci_probe()
3690 pcidev_info.pci_func = PCI_FUNC(bnad->pcidev->devfn); in bnad_pci_probe()
3691 pcidev_info.device_id = bnad->pcidev->device; in bnad_pci_probe()
3692 pcidev_info.pci_bar_kva = bnad->bar0; in bnad_pci_probe()
3694 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3695 bna_init(bna, bnad, &pcidev_info, &bnad->res_info[0]); in bnad_pci_probe()
3696 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3698 bnad->stats.bna_stats = &bna->stats; in bnad_pci_probe()
3700 bnad_enable_msix(bnad); in bnad_pci_probe()
3701 err = bnad_mbox_irq_alloc(bnad); in bnad_pci_probe()
3706 setup_timer(&bnad->bna.ioceth.ioc.ioc_timer, bnad_ioc_timeout, in bnad_pci_probe()
3707 (unsigned long)bnad); in bnad_pci_probe()
3708 setup_timer(&bnad->bna.ioceth.ioc.hb_timer, bnad_ioc_hb_check, in bnad_pci_probe()
3709 (unsigned long)bnad); in bnad_pci_probe()
3710 setup_timer(&bnad->bna.ioceth.ioc.iocpf_timer, bnad_iocpf_timeout, in bnad_pci_probe()
3711 (unsigned long)bnad); in bnad_pci_probe()
3712 setup_timer(&bnad->bna.ioceth.ioc.sem_timer, bnad_iocpf_sem_timeout, in bnad_pci_probe()
3713 (unsigned long)bnad); in bnad_pci_probe()
3720 err = bnad_ioceth_enable(bnad); in bnad_pci_probe()
3726 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3729 bnad_q_num_adjust(bnad, bna_attr(bna)->num_txq - 1, in bnad_pci_probe()
3735 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3739 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3740 bna_mod_res_req(&bnad->bna, &bnad->mod_res_info[0]); in bnad_pci_probe()
3741 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3743 err = bnad_res_alloc(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX); in bnad_pci_probe()
3749 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3750 bna_mod_init(&bnad->bna, &bnad->mod_res_info[0]); in bnad_pci_probe()
3751 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3754 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3755 bna_enet_perm_mac_get(&bna->enet, bnad->perm_addr); in bnad_pci_probe()
3756 bnad_set_netdev_perm_addr(bnad); in bnad_pci_probe()
3757 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3759 mutex_unlock(&bnad->conf_mutex); in bnad_pci_probe()
3767 set_bit(BNAD_RF_NETDEV_REGISTERED, &bnad->run_flags); in bnad_pci_probe()
3772 mutex_unlock(&bnad->conf_mutex); in bnad_pci_probe()
3776 mutex_lock(&bnad->conf_mutex); in bnad_pci_probe()
3777 bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX); in bnad_pci_probe()
3779 bnad_ioceth_disable(bnad); in bnad_pci_probe()
3780 del_timer_sync(&bnad->bna.ioceth.ioc.ioc_timer); in bnad_pci_probe()
3781 del_timer_sync(&bnad->bna.ioceth.ioc.sem_timer); in bnad_pci_probe()
3782 del_timer_sync(&bnad->bna.ioceth.ioc.hb_timer); in bnad_pci_probe()
3783 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_probe()
3785 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_probe()
3786 bnad_mbox_irq_free(bnad); in bnad_pci_probe()
3787 bnad_disable_msix(bnad); in bnad_pci_probe()
3789 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX); in bnad_pci_probe()
3792 kfree(bnad->regdata); in bnad_pci_probe()
3793 bnad_debugfs_uninit(bnad); in bnad_pci_probe()
3794 bnad_uninit(bnad); in bnad_pci_probe()
3798 mutex_unlock(&bnad->conf_mutex); in bnad_pci_probe()
3799 bnad_remove_from_list(bnad); in bnad_pci_probe()
3800 bnad_lock_uninit(bnad); in bnad_pci_probe()
3809 struct bnad *bnad; in bnad_pci_remove() local
3816 bnad = netdev_priv(netdev); in bnad_pci_remove()
3817 bna = &bnad->bna; in bnad_pci_remove()
3819 if (test_and_clear_bit(BNAD_RF_NETDEV_REGISTERED, &bnad->run_flags)) in bnad_pci_remove()
3822 mutex_lock(&bnad->conf_mutex); in bnad_pci_remove()
3823 bnad_ioceth_disable(bnad); in bnad_pci_remove()
3824 del_timer_sync(&bnad->bna.ioceth.ioc.ioc_timer); in bnad_pci_remove()
3825 del_timer_sync(&bnad->bna.ioceth.ioc.sem_timer); in bnad_pci_remove()
3826 del_timer_sync(&bnad->bna.ioceth.ioc.hb_timer); in bnad_pci_remove()
3827 spin_lock_irqsave(&bnad->bna_lock, flags); in bnad_pci_remove()
3829 spin_unlock_irqrestore(&bnad->bna_lock, flags); in bnad_pci_remove()
3831 bnad_res_free(bnad, &bnad->mod_res_info[0], BNA_MOD_RES_T_MAX); in bnad_pci_remove()
3832 bnad_res_free(bnad, &bnad->res_info[0], BNA_RES_T_MAX); in bnad_pci_remove()
3833 bnad_mbox_irq_free(bnad); in bnad_pci_remove()
3834 bnad_disable_msix(bnad); in bnad_pci_remove()
3836 mutex_unlock(&bnad->conf_mutex); in bnad_pci_remove()
3837 bnad_remove_from_list(bnad); in bnad_pci_remove()
3838 bnad_lock_uninit(bnad); in bnad_pci_remove()
3840 kfree(bnad->regdata); in bnad_pci_remove()
3841 bnad_debugfs_uninit(bnad); in bnad_pci_remove()
3842 bnad_uninit(bnad); in bnad_pci_remove()