Lines Matching refs:fnic
178 struct fnic *fnic = lport_priv(lp); in fnic_get_host_speed() local
179 u32 port_speed = vnic_dev_port_speed(fnic->vdev); in fnic_get_host_speed()
209 struct fnic *fnic = lport_priv(lp); in fnic_get_stats() local
214 if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT)) in fnic_get_stats()
216 fnic->stats_time = jiffies; in fnic_get_stats()
218 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_get_stats()
219 ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); in fnic_get_stats()
220 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_get_stats()
223 FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, in fnic_get_stats()
228 vs = fnic->stats; in fnic_get_stats()
237 (jiffies - fnic->stats_reset_time) / HZ; in fnic_get_stats()
238 stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000); in fnic_get_stats()
239 stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000); in fnic_get_stats()
322 struct fnic *fnic = lport_priv(lp); in fnic_reset_host_stats() local
330 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_reset_host_stats()
331 ret = vnic_dev_stats_clear(fnic->vdev); in fnic_reset_host_stats()
332 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_reset_host_stats()
335 FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, in fnic_reset_host_stats()
340 fnic->stats_reset_time = jiffies; in fnic_reset_host_stats()
346 void fnic_log_q_error(struct fnic *fnic) in fnic_log_q_error() argument
351 for (i = 0; i < fnic->raw_wq_count; i++) { in fnic_log_q_error()
352 error_status = ioread32(&fnic->wq[i].ctrl->error_status); in fnic_log_q_error()
354 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
359 for (i = 0; i < fnic->rq_count; i++) { in fnic_log_q_error()
360 error_status = ioread32(&fnic->rq[i].ctrl->error_status); in fnic_log_q_error()
362 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
367 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_log_q_error()
368 error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status); in fnic_log_q_error()
370 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
376 void fnic_handle_link_event(struct fnic *fnic) in fnic_handle_link_event() argument
380 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_handle_link_event()
381 if (fnic->stop_rx_link_events) { in fnic_handle_link_event()
382 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_handle_link_event()
385 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_handle_link_event()
387 queue_work(fnic_event_queue, &fnic->link_work); in fnic_handle_link_event()
391 static int fnic_notify_set(struct fnic *fnic) in fnic_notify_set() argument
395 switch (vnic_dev_get_intr_mode(fnic->vdev)) { in fnic_notify_set()
397 err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY); in fnic_notify_set()
400 err = vnic_dev_notify_set(fnic->vdev, -1); in fnic_notify_set()
403 err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY); in fnic_notify_set()
406 shost_printk(KERN_ERR, fnic->lport->host, in fnic_notify_set()
409 vnic_dev_get_intr_mode(fnic->vdev)); in fnic_notify_set()
419 struct fnic *fnic = from_timer(fnic, t, notify_timer); in fnic_notify_timer() local
421 fnic_handle_link_event(fnic); in fnic_notify_timer()
422 mod_timer(&fnic->notify_timer, in fnic_notify_timer()
428 struct fnic *fnic = from_timer(fnic, t, fip_timer); in fnic_fip_notify_timer() local
430 fnic_handle_fip_timer(fnic); in fnic_fip_notify_timer()
433 static void fnic_notify_timer_start(struct fnic *fnic) in fnic_notify_timer_start() argument
435 switch (vnic_dev_get_intr_mode(fnic->vdev)) { in fnic_notify_timer_start()
441 mod_timer(&fnic->notify_timer, jiffies); in fnic_notify_timer_start()
485 static int fnic_cleanup(struct fnic *fnic) in fnic_cleanup() argument
490 vnic_dev_disable(fnic->vdev); in fnic_cleanup()
491 for (i = 0; i < fnic->intr_count; i++) in fnic_cleanup()
492 vnic_intr_mask(&fnic->intr[i]); in fnic_cleanup()
494 for (i = 0; i < fnic->rq_count; i++) { in fnic_cleanup()
495 err = vnic_rq_disable(&fnic->rq[i]); in fnic_cleanup()
499 for (i = 0; i < fnic->raw_wq_count; i++) { in fnic_cleanup()
500 err = vnic_wq_disable(&fnic->wq[i]); in fnic_cleanup()
504 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_cleanup()
505 err = vnic_wq_copy_disable(&fnic->wq_copy[i]); in fnic_cleanup()
511 fnic_wq_copy_cmpl_handler(fnic, io_completions); in fnic_cleanup()
512 fnic_wq_cmpl_handler(fnic, -1); in fnic_cleanup()
513 fnic_rq_cmpl_handler(fnic, -1); in fnic_cleanup()
516 for (i = 0; i < fnic->raw_wq_count; i++) in fnic_cleanup()
517 vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf); in fnic_cleanup()
518 for (i = 0; i < fnic->rq_count; i++) in fnic_cleanup()
519 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); in fnic_cleanup()
520 for (i = 0; i < fnic->wq_copy_count; i++) in fnic_cleanup()
521 vnic_wq_copy_clean(&fnic->wq_copy[i], in fnic_cleanup()
524 for (i = 0; i < fnic->cq_count; i++) in fnic_cleanup()
525 vnic_cq_clean(&fnic->cq[i]); in fnic_cleanup()
526 for (i = 0; i < fnic->intr_count; i++) in fnic_cleanup()
527 vnic_intr_clean(&fnic->intr[i]); in fnic_cleanup()
529 mempool_destroy(fnic->io_req_pool); in fnic_cleanup()
531 mempool_destroy(fnic->io_sgl_pool[i]); in fnic_cleanup()
536 static void fnic_iounmap(struct fnic *fnic) in fnic_iounmap() argument
538 if (fnic->bar0.vaddr) in fnic_iounmap()
539 iounmap(fnic->bar0.vaddr); in fnic_iounmap()
548 struct fnic *fnic = lport_priv(lport); in fnic_get_mac() local
550 return fnic->data_src_addr; in fnic_get_mac()
553 static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) in fnic_set_vlan() argument
555 vnic_dev_set_default_vlan(fnic->vdev, vlan_id); in fnic_set_vlan()
562 struct fnic *fnic; in fnic_probe() local
572 lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic)); in fnic_probe()
579 fnic = lport_priv(lp); in fnic_probe()
580 fnic->lport = lp; in fnic_probe()
581 fnic->ctlr.lp = lp; in fnic_probe()
583 snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, in fnic_probe()
588 fnic_stats_debugfs_init(fnic); in fnic_probe()
591 pci_set_drvdata(pdev, fnic); in fnic_probe()
593 fnic->pdev = pdev; in fnic_probe()
597 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
604 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
619 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
628 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
634 fnic->bar0.vaddr = pci_iomap(pdev, 0, 0); in fnic_probe()
635 fnic->bar0.bus_addr = pci_resource_start(pdev, 0); in fnic_probe()
636 fnic->bar0.len = pci_resource_len(pdev, 0); in fnic_probe()
638 if (!fnic->bar0.vaddr) { in fnic_probe()
639 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
646 fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0); in fnic_probe()
647 if (!fnic->vdev) { in fnic_probe()
648 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
655 err = vnic_dev_cmd_init(fnic->vdev); in fnic_probe()
657 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
663 err = fnic_dev_wait(fnic->vdev, vnic_dev_open, in fnic_probe()
666 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
671 err = vnic_dev_init(fnic->vdev, 0); in fnic_probe()
673 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
678 err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); in fnic_probe()
680 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
685 memcpy(fnic->data_src_addr, fnic->ctlr.ctl_src_addr, ETH_ALEN); in fnic_probe()
688 err = fnic_get_vnic_config(fnic); in fnic_probe()
690 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
697 if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD) { in fnic_probe()
700 fnic->config.io_throttle_count)); in fnic_probe()
702 fnic->fnic_max_tag_id = host->can_queue; in fnic_probe()
704 host->max_lun = fnic->config.luns_per_tgt; in fnic_probe()
708 fnic_get_res_counts(fnic); in fnic_probe()
710 err = fnic_set_intr_mode(fnic); in fnic_probe()
712 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
718 err = fnic_alloc_vnic_resources(fnic); in fnic_probe()
720 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
728 spin_lock_init(&fnic->fnic_lock); in fnic_probe()
731 spin_lock_init(&fnic->wq_lock[i]); in fnic_probe()
734 spin_lock_init(&fnic->wq_copy_lock[i]); in fnic_probe()
735 fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK; in fnic_probe()
736 fnic->fw_ack_recd[i] = 0; in fnic_probe()
737 fnic->fw_ack_index[i] = -1; in fnic_probe()
741 spin_lock_init(&fnic->io_req_lock[i]); in fnic_probe()
743 fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); in fnic_probe()
744 if (!fnic->io_req_pool) in fnic_probe()
750 fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool; in fnic_probe()
755 fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool; in fnic_probe()
758 fnic->vlan_hw_insert = 1; in fnic_probe()
759 fnic->vlan_id = 0; in fnic_probe()
762 fnic->ctlr.send = fnic_eth_send; in fnic_probe()
763 fnic->ctlr.update_mac = fnic_update_mac; in fnic_probe()
764 fnic->ctlr.get_src_addr = fnic_get_mac; in fnic_probe()
765 if (fnic->config.flags & VFCF_FIP_CAPABLE) { in fnic_probe()
766 shost_printk(KERN_INFO, fnic->lport->host, in fnic_probe()
769 vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0); in fnic_probe()
770 vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS); in fnic_probe()
771 vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); in fnic_probe()
772 fnic->set_vlan = fnic_set_vlan; in fnic_probe()
773 fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO); in fnic_probe()
774 timer_setup(&fnic->fip_timer, fnic_fip_notify_timer, 0); in fnic_probe()
775 spin_lock_init(&fnic->vlans_lock); in fnic_probe()
776 INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame); in fnic_probe()
777 INIT_WORK(&fnic->event_work, fnic_handle_event); in fnic_probe()
778 skb_queue_head_init(&fnic->fip_frame_queue); in fnic_probe()
779 INIT_LIST_HEAD(&fnic->evlist); in fnic_probe()
780 INIT_LIST_HEAD(&fnic->vlans); in fnic_probe()
782 shost_printk(KERN_INFO, fnic->lport->host, in fnic_probe()
784 fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP); in fnic_probe()
785 fnic->ctlr.state = FIP_ST_NON_FIP; in fnic_probe()
787 fnic->state = FNIC_IN_FC_MODE; in fnic_probe()
789 atomic_set(&fnic->in_flight, 0); in fnic_probe()
790 fnic->state_flags = FNIC_FLAGS_NONE; in fnic_probe()
793 fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1); in fnic_probe()
796 err = fnic_notify_set(fnic); in fnic_probe()
798 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
804 if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) in fnic_probe()
805 timer_setup(&fnic->notify_timer, fnic_notify_timer, 0); in fnic_probe()
808 for (i = 0; i < fnic->rq_count; i++) { in fnic_probe()
809 vnic_rq_enable(&fnic->rq[i]); in fnic_probe()
810 err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); in fnic_probe()
812 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
825 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
834 lp->max_retry_count = fnic->config.flogi_retries; in fnic_probe()
835 lp->max_rport_retry_count = fnic->config.plogi_retries; in fnic_probe()
838 if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) in fnic_probe()
842 lp->e_d_tov = fnic->config.ed_tov; in fnic_probe()
843 lp->r_a_tov = fnic->config.ra_tov; in fnic_probe()
845 fc_set_wwnn(lp, fnic->config.node_wwn); in fnic_probe()
846 fc_set_wwpn(lp, fnic->config.port_wwn); in fnic_probe()
848 fcoe_libfc_config(lp, &fnic->ctlr, &fnic_transport_template, 0); in fnic_probe()
857 fnic->stats_reset_time = jiffies; in fnic_probe()
861 if (fc_set_mfs(lp, fnic->config.maxdatafieldsize + in fnic_probe()
867 fc_host_dev_loss_tmo(lp->host) = fnic->config.port_down_timeout / 1000; in fnic_probe()
870 DRV_NAME " v" DRV_VERSION " over %s", fnic->name); in fnic_probe()
873 list_add_tail(&fnic->list, &fnic_list); in fnic_probe()
876 INIT_WORK(&fnic->link_work, fnic_handle_link); in fnic_probe()
877 INIT_WORK(&fnic->frame_work, fnic_handle_frame); in fnic_probe()
878 skb_queue_head_init(&fnic->frame_queue); in fnic_probe()
879 skb_queue_head_init(&fnic->tx_queue); in fnic_probe()
882 for (i = 0; i < fnic->raw_wq_count; i++) in fnic_probe()
883 vnic_wq_enable(&fnic->wq[i]); in fnic_probe()
884 for (i = 0; i < fnic->wq_copy_count; i++) in fnic_probe()
885 vnic_wq_copy_enable(&fnic->wq_copy[i]); in fnic_probe()
889 err = fnic_request_intr(fnic); in fnic_probe()
891 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
896 vnic_dev_enable(fnic->vdev); in fnic_probe()
898 for (i = 0; i < fnic->intr_count; i++) in fnic_probe()
899 vnic_intr_unmask(&fnic->intr[i]); in fnic_probe()
901 fnic_notify_timer_start(fnic); in fnic_probe()
911 for (i = 0; i < fnic->rq_count; i++) in fnic_probe()
912 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); in fnic_probe()
913 vnic_dev_notify_unset(fnic->vdev); in fnic_probe()
915 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]); in fnic_probe()
917 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]); in fnic_probe()
919 mempool_destroy(fnic->io_req_pool); in fnic_probe()
921 fnic_free_vnic_resources(fnic); in fnic_probe()
923 fnic_clear_intr_mode(fnic); in fnic_probe()
925 vnic_dev_close(fnic->vdev); in fnic_probe()
928 vnic_dev_unregister(fnic->vdev); in fnic_probe()
930 fnic_iounmap(fnic); in fnic_probe()
936 fnic_stats_debugfs_remove(fnic); in fnic_probe()
944 struct fnic *fnic = pci_get_drvdata(pdev); in fnic_remove() local
945 struct fc_lport *lp = fnic->lport; in fnic_remove()
954 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_remove()
955 fnic->stop_rx_link_events = 1; in fnic_remove()
956 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_remove()
958 if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) in fnic_remove()
959 del_timer_sync(&fnic->notify_timer); in fnic_remove()
966 skb_queue_purge(&fnic->frame_queue); in fnic_remove()
967 skb_queue_purge(&fnic->tx_queue); in fnic_remove()
969 if (fnic->config.flags & VFCF_FIP_CAPABLE) { in fnic_remove()
970 del_timer_sync(&fnic->fip_timer); in fnic_remove()
971 skb_queue_purge(&fnic->fip_frame_queue); in fnic_remove()
972 fnic_fcoe_reset_vlans(fnic); in fnic_remove()
973 fnic_fcoe_evlist_free(fnic); in fnic_remove()
981 fc_fabric_logoff(fnic->lport); in fnic_remove()
983 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_remove()
984 fnic->in_remove = 1; in fnic_remove()
985 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_remove()
987 fcoe_ctlr_destroy(&fnic->ctlr); in fnic_remove()
989 fnic_stats_debugfs_remove(fnic); in fnic_remove()
996 fnic_cleanup(fnic); in fnic_remove()
998 BUG_ON(!skb_queue_empty(&fnic->frame_queue)); in fnic_remove()
999 BUG_ON(!skb_queue_empty(&fnic->tx_queue)); in fnic_remove()
1002 list_del(&fnic->list); in fnic_remove()
1005 fc_remove_host(fnic->lport->host); in fnic_remove()
1006 scsi_remove_host(fnic->lport->host); in fnic_remove()
1007 fc_exch_mgr_free(fnic->lport); in fnic_remove()
1008 vnic_dev_notify_unset(fnic->vdev); in fnic_remove()
1009 fnic_free_intr(fnic); in fnic_remove()
1010 fnic_free_vnic_resources(fnic); in fnic_remove()
1011 fnic_clear_intr_mode(fnic); in fnic_remove()
1012 vnic_dev_close(fnic->vdev); in fnic_remove()
1013 vnic_dev_unregister(fnic->vdev); in fnic_remove()
1014 fnic_iounmap(fnic); in fnic_remove()