Lines Matching refs:fnic

174 	struct fnic *fnic = lport_priv(lp);  in fnic_get_host_speed()  local
175 u32 port_speed = vnic_dev_port_speed(fnic->vdev); in fnic_get_host_speed()
192 struct fnic *fnic = lport_priv(lp); in fnic_get_stats() local
197 if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT)) in fnic_get_stats()
199 fnic->stats_time = jiffies; in fnic_get_stats()
201 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_get_stats()
202 ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); in fnic_get_stats()
203 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_get_stats()
206 FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, in fnic_get_stats()
211 vs = fnic->stats; in fnic_get_stats()
220 (jiffies - fnic->stats_reset_time) / HZ; in fnic_get_stats()
221 stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000); in fnic_get_stats()
222 stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000); in fnic_get_stats()
305 struct fnic *fnic = lport_priv(lp); in fnic_reset_host_stats() local
313 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_reset_host_stats()
314 ret = vnic_dev_stats_clear(fnic->vdev); in fnic_reset_host_stats()
315 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_reset_host_stats()
318 FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, in fnic_reset_host_stats()
323 fnic->stats_reset_time = jiffies; in fnic_reset_host_stats()
329 void fnic_log_q_error(struct fnic *fnic) in fnic_log_q_error() argument
334 for (i = 0; i < fnic->raw_wq_count; i++) { in fnic_log_q_error()
335 error_status = ioread32(&fnic->wq[i].ctrl->error_status); in fnic_log_q_error()
337 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
342 for (i = 0; i < fnic->rq_count; i++) { in fnic_log_q_error()
343 error_status = ioread32(&fnic->rq[i].ctrl->error_status); in fnic_log_q_error()
345 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
350 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_log_q_error()
351 error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status); in fnic_log_q_error()
353 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
359 void fnic_handle_link_event(struct fnic *fnic) in fnic_handle_link_event() argument
363 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_handle_link_event()
364 if (fnic->stop_rx_link_events) { in fnic_handle_link_event()
365 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_handle_link_event()
368 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_handle_link_event()
370 queue_work(fnic_event_queue, &fnic->link_work); in fnic_handle_link_event()
374 static int fnic_notify_set(struct fnic *fnic) in fnic_notify_set() argument
378 switch (vnic_dev_get_intr_mode(fnic->vdev)) { in fnic_notify_set()
380 err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY); in fnic_notify_set()
383 err = vnic_dev_notify_set(fnic->vdev, -1); in fnic_notify_set()
386 err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY); in fnic_notify_set()
389 shost_printk(KERN_ERR, fnic->lport->host, in fnic_notify_set()
392 vnic_dev_get_intr_mode(fnic->vdev)); in fnic_notify_set()
402 struct fnic *fnic = (struct fnic *)data; in fnic_notify_timer() local
404 fnic_handle_link_event(fnic); in fnic_notify_timer()
405 mod_timer(&fnic->notify_timer, in fnic_notify_timer()
411 struct fnic *fnic = (struct fnic *)data; in fnic_fip_notify_timer() local
413 fnic_handle_fip_timer(fnic); in fnic_fip_notify_timer()
416 static void fnic_notify_timer_start(struct fnic *fnic) in fnic_notify_timer_start() argument
418 switch (vnic_dev_get_intr_mode(fnic->vdev)) { in fnic_notify_timer_start()
424 mod_timer(&fnic->notify_timer, jiffies); in fnic_notify_timer_start()
468 static int fnic_cleanup(struct fnic *fnic) in fnic_cleanup() argument
473 vnic_dev_disable(fnic->vdev); in fnic_cleanup()
474 for (i = 0; i < fnic->intr_count; i++) in fnic_cleanup()
475 vnic_intr_mask(&fnic->intr[i]); in fnic_cleanup()
477 for (i = 0; i < fnic->rq_count; i++) { in fnic_cleanup()
478 err = vnic_rq_disable(&fnic->rq[i]); in fnic_cleanup()
482 for (i = 0; i < fnic->raw_wq_count; i++) { in fnic_cleanup()
483 err = vnic_wq_disable(&fnic->wq[i]); in fnic_cleanup()
487 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_cleanup()
488 err = vnic_wq_copy_disable(&fnic->wq_copy[i]); in fnic_cleanup()
494 fnic_wq_copy_cmpl_handler(fnic, -1); in fnic_cleanup()
495 fnic_wq_cmpl_handler(fnic, -1); in fnic_cleanup()
496 fnic_rq_cmpl_handler(fnic, -1); in fnic_cleanup()
499 for (i = 0; i < fnic->raw_wq_count; i++) in fnic_cleanup()
500 vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf); in fnic_cleanup()
501 for (i = 0; i < fnic->rq_count; i++) in fnic_cleanup()
502 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); in fnic_cleanup()
503 for (i = 0; i < fnic->wq_copy_count; i++) in fnic_cleanup()
504 vnic_wq_copy_clean(&fnic->wq_copy[i], in fnic_cleanup()
507 for (i = 0; i < fnic->cq_count; i++) in fnic_cleanup()
508 vnic_cq_clean(&fnic->cq[i]); in fnic_cleanup()
509 for (i = 0; i < fnic->intr_count; i++) in fnic_cleanup()
510 vnic_intr_clean(&fnic->intr[i]); in fnic_cleanup()
512 mempool_destroy(fnic->io_req_pool); in fnic_cleanup()
514 mempool_destroy(fnic->io_sgl_pool[i]); in fnic_cleanup()
519 static void fnic_iounmap(struct fnic *fnic) in fnic_iounmap() argument
521 if (fnic->bar0.vaddr) in fnic_iounmap()
522 iounmap(fnic->bar0.vaddr); in fnic_iounmap()
531 struct fnic *fnic = lport_priv(lport); in fnic_get_mac() local
533 return fnic->data_src_addr; in fnic_get_mac()
536 static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) in fnic_set_vlan() argument
539 old_vlan = vnic_dev_set_default_vlan(fnic->vdev, vlan_id); in fnic_set_vlan()
546 struct fnic *fnic; in fnic_probe() local
556 lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic)); in fnic_probe()
563 fnic = lport_priv(lp); in fnic_probe()
564 fnic->lport = lp; in fnic_probe()
565 fnic->ctlr.lp = lp; in fnic_probe()
567 snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, in fnic_probe()
572 err = fnic_stats_debugfs_init(fnic); in fnic_probe()
574 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
576 fnic_stats_debugfs_remove(fnic); in fnic_probe()
580 pci_set_drvdata(pdev, fnic); in fnic_probe()
582 fnic->pdev = pdev; in fnic_probe()
586 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
593 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
608 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
615 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
623 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
632 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
638 fnic->bar0.vaddr = pci_iomap(pdev, 0, 0); in fnic_probe()
639 fnic->bar0.bus_addr = pci_resource_start(pdev, 0); in fnic_probe()
640 fnic->bar0.len = pci_resource_len(pdev, 0); in fnic_probe()
642 if (!fnic->bar0.vaddr) { in fnic_probe()
643 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
650 fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0); in fnic_probe()
651 if (!fnic->vdev) { in fnic_probe()
652 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
659 err = fnic_dev_wait(fnic->vdev, vnic_dev_open, in fnic_probe()
662 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
667 err = vnic_dev_init(fnic->vdev, 0); in fnic_probe()
669 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
674 err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); in fnic_probe()
676 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
681 memcpy(fnic->data_src_addr, fnic->ctlr.ctl_src_addr, ETH_ALEN); in fnic_probe()
684 err = fnic_get_vnic_config(fnic); in fnic_probe()
686 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
693 if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD) { in fnic_probe()
696 fnic->config.io_throttle_count)); in fnic_probe()
698 fnic->fnic_max_tag_id = host->can_queue; in fnic_probe()
700 err = scsi_init_shared_tag_map(host, fnic->fnic_max_tag_id); in fnic_probe()
702 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
707 host->max_lun = fnic->config.luns_per_tgt; in fnic_probe()
711 fnic_get_res_counts(fnic); in fnic_probe()
713 err = fnic_set_intr_mode(fnic); in fnic_probe()
715 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
721 err = fnic_alloc_vnic_resources(fnic); in fnic_probe()
723 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
731 spin_lock_init(&fnic->fnic_lock); in fnic_probe()
734 spin_lock_init(&fnic->wq_lock[i]); in fnic_probe()
737 spin_lock_init(&fnic->wq_copy_lock[i]); in fnic_probe()
738 fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK; in fnic_probe()
739 fnic->fw_ack_recd[i] = 0; in fnic_probe()
740 fnic->fw_ack_index[i] = -1; in fnic_probe()
744 spin_lock_init(&fnic->io_req_lock[i]); in fnic_probe()
746 fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); in fnic_probe()
747 if (!fnic->io_req_pool) in fnic_probe()
753 fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool; in fnic_probe()
758 fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool; in fnic_probe()
761 fnic->vlan_hw_insert = 1; in fnic_probe()
762 fnic->vlan_id = 0; in fnic_probe()
765 fnic->ctlr.send = fnic_eth_send; in fnic_probe()
766 fnic->ctlr.update_mac = fnic_update_mac; in fnic_probe()
767 fnic->ctlr.get_src_addr = fnic_get_mac; in fnic_probe()
768 if (fnic->config.flags & VFCF_FIP_CAPABLE) { in fnic_probe()
769 shost_printk(KERN_INFO, fnic->lport->host, in fnic_probe()
772 vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0); in fnic_probe()
773 vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS); in fnic_probe()
774 vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); in fnic_probe()
775 fnic->set_vlan = fnic_set_vlan; in fnic_probe()
776 fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO); in fnic_probe()
777 setup_timer(&fnic->fip_timer, fnic_fip_notify_timer, in fnic_probe()
778 (unsigned long)fnic); in fnic_probe()
779 spin_lock_init(&fnic->vlans_lock); in fnic_probe()
780 INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame); in fnic_probe()
781 INIT_WORK(&fnic->event_work, fnic_handle_event); in fnic_probe()
782 skb_queue_head_init(&fnic->fip_frame_queue); in fnic_probe()
783 INIT_LIST_HEAD(&fnic->evlist); in fnic_probe()
784 INIT_LIST_HEAD(&fnic->vlans); in fnic_probe()
786 shost_printk(KERN_INFO, fnic->lport->host, in fnic_probe()
788 fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP); in fnic_probe()
789 fnic->ctlr.state = FIP_ST_NON_FIP; in fnic_probe()
791 fnic->state = FNIC_IN_FC_MODE; in fnic_probe()
793 atomic_set(&fnic->in_flight, 0); in fnic_probe()
794 fnic->state_flags = FNIC_FLAGS_NONE; in fnic_probe()
797 fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1); in fnic_probe()
800 err = fnic_notify_set(fnic); in fnic_probe()
802 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
808 if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) in fnic_probe()
809 setup_timer(&fnic->notify_timer, in fnic_probe()
810 fnic_notify_timer, (unsigned long)fnic); in fnic_probe()
813 for (i = 0; i < fnic->rq_count; i++) { in fnic_probe()
814 err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); in fnic_probe()
816 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
829 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
838 lp->max_retry_count = fnic->config.flogi_retries; in fnic_probe()
839 lp->max_rport_retry_count = fnic->config.plogi_retries; in fnic_probe()
842 if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) in fnic_probe()
846 lp->e_d_tov = fnic->config.ed_tov; in fnic_probe()
847 lp->r_a_tov = fnic->config.ra_tov; in fnic_probe()
849 fc_set_wwnn(lp, fnic->config.node_wwn); in fnic_probe()
850 fc_set_wwpn(lp, fnic->config.port_wwn); in fnic_probe()
852 fcoe_libfc_config(lp, &fnic->ctlr, &fnic_transport_template, 0); in fnic_probe()
861 fnic->stats_reset_time = jiffies; in fnic_probe()
865 if (fc_set_mfs(lp, fnic->config.maxdatafieldsize + in fnic_probe()
871 fc_host_dev_loss_tmo(lp->host) = fnic->config.port_down_timeout / 1000; in fnic_probe()
874 DRV_NAME " v" DRV_VERSION " over %s", fnic->name); in fnic_probe()
877 list_add_tail(&fnic->list, &fnic_list); in fnic_probe()
880 INIT_WORK(&fnic->link_work, fnic_handle_link); in fnic_probe()
881 INIT_WORK(&fnic->frame_work, fnic_handle_frame); in fnic_probe()
882 skb_queue_head_init(&fnic->frame_queue); in fnic_probe()
883 skb_queue_head_init(&fnic->tx_queue); in fnic_probe()
886 for (i = 0; i < fnic->raw_wq_count; i++) in fnic_probe()
887 vnic_wq_enable(&fnic->wq[i]); in fnic_probe()
888 for (i = 0; i < fnic->rq_count; i++) in fnic_probe()
889 vnic_rq_enable(&fnic->rq[i]); in fnic_probe()
890 for (i = 0; i < fnic->wq_copy_count; i++) in fnic_probe()
891 vnic_wq_copy_enable(&fnic->wq_copy[i]); in fnic_probe()
895 vnic_dev_enable(fnic->vdev); in fnic_probe()
897 err = fnic_request_intr(fnic); in fnic_probe()
899 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
904 for (i = 0; i < fnic->intr_count; i++) in fnic_probe()
905 vnic_intr_unmask(&fnic->intr[i]); in fnic_probe()
907 fnic_notify_timer_start(fnic); in fnic_probe()
917 for (i = 0; i < fnic->rq_count; i++) in fnic_probe()
918 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); in fnic_probe()
919 vnic_dev_notify_unset(fnic->vdev); in fnic_probe()
921 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]); in fnic_probe()
923 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]); in fnic_probe()
925 mempool_destroy(fnic->io_req_pool); in fnic_probe()
927 fnic_free_vnic_resources(fnic); in fnic_probe()
929 fnic_clear_intr_mode(fnic); in fnic_probe()
931 vnic_dev_close(fnic->vdev); in fnic_probe()
933 vnic_dev_unregister(fnic->vdev); in fnic_probe()
935 fnic_iounmap(fnic); in fnic_probe()
941 fnic_stats_debugfs_remove(fnic); in fnic_probe()
949 struct fnic *fnic = pci_get_drvdata(pdev); in fnic_remove() local
950 struct fc_lport *lp = fnic->lport; in fnic_remove()
959 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_remove()
960 fnic->stop_rx_link_events = 1; in fnic_remove()
961 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_remove()
963 if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) in fnic_remove()
964 del_timer_sync(&fnic->notify_timer); in fnic_remove()
971 skb_queue_purge(&fnic->frame_queue); in fnic_remove()
972 skb_queue_purge(&fnic->tx_queue); in fnic_remove()
974 if (fnic->config.flags & VFCF_FIP_CAPABLE) { in fnic_remove()
975 del_timer_sync(&fnic->fip_timer); in fnic_remove()
976 skb_queue_purge(&fnic->fip_frame_queue); in fnic_remove()
977 fnic_fcoe_reset_vlans(fnic); in fnic_remove()
978 fnic_fcoe_evlist_free(fnic); in fnic_remove()
986 fc_fabric_logoff(fnic->lport); in fnic_remove()
988 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_remove()
989 fnic->in_remove = 1; in fnic_remove()
990 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_remove()
992 fcoe_ctlr_destroy(&fnic->ctlr); in fnic_remove()
994 fnic_stats_debugfs_remove(fnic); in fnic_remove()
1001 fnic_cleanup(fnic); in fnic_remove()
1003 BUG_ON(!skb_queue_empty(&fnic->frame_queue)); in fnic_remove()
1004 BUG_ON(!skb_queue_empty(&fnic->tx_queue)); in fnic_remove()
1007 list_del(&fnic->list); in fnic_remove()
1010 fc_remove_host(fnic->lport->host); in fnic_remove()
1011 scsi_remove_host(fnic->lport->host); in fnic_remove()
1012 fc_exch_mgr_free(fnic->lport); in fnic_remove()
1013 vnic_dev_notify_unset(fnic->vdev); in fnic_remove()
1014 fnic_free_intr(fnic); in fnic_remove()
1015 fnic_free_vnic_resources(fnic); in fnic_remove()
1016 fnic_clear_intr_mode(fnic); in fnic_remove()
1017 vnic_dev_close(fnic->vdev); in fnic_remove()
1018 vnic_dev_unregister(fnic->vdev); in fnic_remove()
1019 fnic_iounmap(fnic); in fnic_remove()