Lines Matching refs:fnic

173 	struct fnic *fnic = lport_priv(lp);  in fnic_get_host_speed()  local
174 u32 port_speed = vnic_dev_port_speed(fnic->vdev); in fnic_get_host_speed()
191 struct fnic *fnic = lport_priv(lp); in fnic_get_stats() local
196 if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT)) in fnic_get_stats()
198 fnic->stats_time = jiffies; in fnic_get_stats()
200 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_get_stats()
201 ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); in fnic_get_stats()
202 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_get_stats()
205 FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, in fnic_get_stats()
210 vs = fnic->stats; in fnic_get_stats()
219 (jiffies - fnic->stats_reset_time) / HZ; in fnic_get_stats()
220 stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000); in fnic_get_stats()
221 stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000); in fnic_get_stats()
304 struct fnic *fnic = lport_priv(lp); in fnic_reset_host_stats() local
312 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_reset_host_stats()
313 ret = vnic_dev_stats_clear(fnic->vdev); in fnic_reset_host_stats()
314 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_reset_host_stats()
317 FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, in fnic_reset_host_stats()
322 fnic->stats_reset_time = jiffies; in fnic_reset_host_stats()
328 void fnic_log_q_error(struct fnic *fnic) in fnic_log_q_error() argument
333 for (i = 0; i < fnic->raw_wq_count; i++) { in fnic_log_q_error()
334 error_status = ioread32(&fnic->wq[i].ctrl->error_status); in fnic_log_q_error()
336 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
341 for (i = 0; i < fnic->rq_count; i++) { in fnic_log_q_error()
342 error_status = ioread32(&fnic->rq[i].ctrl->error_status); in fnic_log_q_error()
344 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
349 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_log_q_error()
350 error_status = ioread32(&fnic->wq_copy[i].ctrl->error_status); in fnic_log_q_error()
352 shost_printk(KERN_ERR, fnic->lport->host, in fnic_log_q_error()
358 void fnic_handle_link_event(struct fnic *fnic) in fnic_handle_link_event() argument
362 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_handle_link_event()
363 if (fnic->stop_rx_link_events) { in fnic_handle_link_event()
364 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_handle_link_event()
367 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_handle_link_event()
369 queue_work(fnic_event_queue, &fnic->link_work); in fnic_handle_link_event()
373 static int fnic_notify_set(struct fnic *fnic) in fnic_notify_set() argument
377 switch (vnic_dev_get_intr_mode(fnic->vdev)) { in fnic_notify_set()
379 err = vnic_dev_notify_set(fnic->vdev, FNIC_INTX_NOTIFY); in fnic_notify_set()
382 err = vnic_dev_notify_set(fnic->vdev, -1); in fnic_notify_set()
385 err = vnic_dev_notify_set(fnic->vdev, FNIC_MSIX_ERR_NOTIFY); in fnic_notify_set()
388 shost_printk(KERN_ERR, fnic->lport->host, in fnic_notify_set()
391 vnic_dev_get_intr_mode(fnic->vdev)); in fnic_notify_set()
401 struct fnic *fnic = (struct fnic *)data; in fnic_notify_timer() local
403 fnic_handle_link_event(fnic); in fnic_notify_timer()
404 mod_timer(&fnic->notify_timer, in fnic_notify_timer()
410 struct fnic *fnic = (struct fnic *)data; in fnic_fip_notify_timer() local
412 fnic_handle_fip_timer(fnic); in fnic_fip_notify_timer()
415 static void fnic_notify_timer_start(struct fnic *fnic) in fnic_notify_timer_start() argument
417 switch (vnic_dev_get_intr_mode(fnic->vdev)) { in fnic_notify_timer_start()
423 mod_timer(&fnic->notify_timer, jiffies); in fnic_notify_timer_start()
467 static int fnic_cleanup(struct fnic *fnic) in fnic_cleanup() argument
472 vnic_dev_disable(fnic->vdev); in fnic_cleanup()
473 for (i = 0; i < fnic->intr_count; i++) in fnic_cleanup()
474 vnic_intr_mask(&fnic->intr[i]); in fnic_cleanup()
476 for (i = 0; i < fnic->rq_count; i++) { in fnic_cleanup()
477 err = vnic_rq_disable(&fnic->rq[i]); in fnic_cleanup()
481 for (i = 0; i < fnic->raw_wq_count; i++) { in fnic_cleanup()
482 err = vnic_wq_disable(&fnic->wq[i]); in fnic_cleanup()
486 for (i = 0; i < fnic->wq_copy_count; i++) { in fnic_cleanup()
487 err = vnic_wq_copy_disable(&fnic->wq_copy[i]); in fnic_cleanup()
493 fnic_wq_copy_cmpl_handler(fnic, -1); in fnic_cleanup()
494 fnic_wq_cmpl_handler(fnic, -1); in fnic_cleanup()
495 fnic_rq_cmpl_handler(fnic, -1); in fnic_cleanup()
498 for (i = 0; i < fnic->raw_wq_count; i++) in fnic_cleanup()
499 vnic_wq_clean(&fnic->wq[i], fnic_free_wq_buf); in fnic_cleanup()
500 for (i = 0; i < fnic->rq_count; i++) in fnic_cleanup()
501 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); in fnic_cleanup()
502 for (i = 0; i < fnic->wq_copy_count; i++) in fnic_cleanup()
503 vnic_wq_copy_clean(&fnic->wq_copy[i], in fnic_cleanup()
506 for (i = 0; i < fnic->cq_count; i++) in fnic_cleanup()
507 vnic_cq_clean(&fnic->cq[i]); in fnic_cleanup()
508 for (i = 0; i < fnic->intr_count; i++) in fnic_cleanup()
509 vnic_intr_clean(&fnic->intr[i]); in fnic_cleanup()
511 mempool_destroy(fnic->io_req_pool); in fnic_cleanup()
513 mempool_destroy(fnic->io_sgl_pool[i]); in fnic_cleanup()
518 static void fnic_iounmap(struct fnic *fnic) in fnic_iounmap() argument
520 if (fnic->bar0.vaddr) in fnic_iounmap()
521 iounmap(fnic->bar0.vaddr); in fnic_iounmap()
530 struct fnic *fnic = lport_priv(lport); in fnic_get_mac() local
532 return fnic->data_src_addr; in fnic_get_mac()
535 static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) in fnic_set_vlan() argument
538 old_vlan = vnic_dev_set_default_vlan(fnic->vdev, vlan_id); in fnic_set_vlan()
545 struct fnic *fnic; in fnic_probe() local
555 lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic)); in fnic_probe()
562 fnic = lport_priv(lp); in fnic_probe()
563 fnic->lport = lp; in fnic_probe()
564 fnic->ctlr.lp = lp; in fnic_probe()
566 snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, in fnic_probe()
571 err = fnic_stats_debugfs_init(fnic); in fnic_probe()
573 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
575 fnic_stats_debugfs_remove(fnic); in fnic_probe()
579 pci_set_drvdata(pdev, fnic); in fnic_probe()
581 fnic->pdev = pdev; in fnic_probe()
585 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
592 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
607 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
614 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
622 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
631 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
637 fnic->bar0.vaddr = pci_iomap(pdev, 0, 0); in fnic_probe()
638 fnic->bar0.bus_addr = pci_resource_start(pdev, 0); in fnic_probe()
639 fnic->bar0.len = pci_resource_len(pdev, 0); in fnic_probe()
641 if (!fnic->bar0.vaddr) { in fnic_probe()
642 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
649 fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0); in fnic_probe()
650 if (!fnic->vdev) { in fnic_probe()
651 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
658 err = fnic_dev_wait(fnic->vdev, vnic_dev_open, in fnic_probe()
661 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
666 err = vnic_dev_init(fnic->vdev, 0); in fnic_probe()
668 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
673 err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); in fnic_probe()
675 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
680 memcpy(fnic->data_src_addr, fnic->ctlr.ctl_src_addr, ETH_ALEN); in fnic_probe()
683 err = fnic_get_vnic_config(fnic); in fnic_probe()
685 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
692 if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD) { in fnic_probe()
695 fnic->config.io_throttle_count)); in fnic_probe()
697 fnic->fnic_max_tag_id = host->can_queue; in fnic_probe()
699 host->max_lun = fnic->config.luns_per_tgt; in fnic_probe()
703 fnic_get_res_counts(fnic); in fnic_probe()
705 err = fnic_set_intr_mode(fnic); in fnic_probe()
707 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
713 err = fnic_alloc_vnic_resources(fnic); in fnic_probe()
715 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
723 spin_lock_init(&fnic->fnic_lock); in fnic_probe()
726 spin_lock_init(&fnic->wq_lock[i]); in fnic_probe()
729 spin_lock_init(&fnic->wq_copy_lock[i]); in fnic_probe()
730 fnic->wq_copy_desc_low[i] = DESC_CLEAN_LOW_WATERMARK; in fnic_probe()
731 fnic->fw_ack_recd[i] = 0; in fnic_probe()
732 fnic->fw_ack_index[i] = -1; in fnic_probe()
736 spin_lock_init(&fnic->io_req_lock[i]); in fnic_probe()
738 fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); in fnic_probe()
739 if (!fnic->io_req_pool) in fnic_probe()
745 fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool; in fnic_probe()
750 fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX] = pool; in fnic_probe()
753 fnic->vlan_hw_insert = 1; in fnic_probe()
754 fnic->vlan_id = 0; in fnic_probe()
757 fnic->ctlr.send = fnic_eth_send; in fnic_probe()
758 fnic->ctlr.update_mac = fnic_update_mac; in fnic_probe()
759 fnic->ctlr.get_src_addr = fnic_get_mac; in fnic_probe()
760 if (fnic->config.flags & VFCF_FIP_CAPABLE) { in fnic_probe()
761 shost_printk(KERN_INFO, fnic->lport->host, in fnic_probe()
764 vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0); in fnic_probe()
765 vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS); in fnic_probe()
766 vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); in fnic_probe()
767 fnic->set_vlan = fnic_set_vlan; in fnic_probe()
768 fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO); in fnic_probe()
769 setup_timer(&fnic->fip_timer, fnic_fip_notify_timer, in fnic_probe()
770 (unsigned long)fnic); in fnic_probe()
771 spin_lock_init(&fnic->vlans_lock); in fnic_probe()
772 INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame); in fnic_probe()
773 INIT_WORK(&fnic->event_work, fnic_handle_event); in fnic_probe()
774 skb_queue_head_init(&fnic->fip_frame_queue); in fnic_probe()
775 INIT_LIST_HEAD(&fnic->evlist); in fnic_probe()
776 INIT_LIST_HEAD(&fnic->vlans); in fnic_probe()
778 shost_printk(KERN_INFO, fnic->lport->host, in fnic_probe()
780 fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP); in fnic_probe()
781 fnic->ctlr.state = FIP_ST_NON_FIP; in fnic_probe()
783 fnic->state = FNIC_IN_FC_MODE; in fnic_probe()
785 atomic_set(&fnic->in_flight, 0); in fnic_probe()
786 fnic->state_flags = FNIC_FLAGS_NONE; in fnic_probe()
789 fnic_set_nic_config(fnic, 0, 0, 0, 0, 0, 0, 1); in fnic_probe()
792 err = fnic_notify_set(fnic); in fnic_probe()
794 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
800 if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) in fnic_probe()
801 setup_timer(&fnic->notify_timer, in fnic_probe()
802 fnic_notify_timer, (unsigned long)fnic); in fnic_probe()
805 for (i = 0; i < fnic->rq_count; i++) { in fnic_probe()
806 err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); in fnic_probe()
808 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
821 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
830 lp->max_retry_count = fnic->config.flogi_retries; in fnic_probe()
831 lp->max_rport_retry_count = fnic->config.plogi_retries; in fnic_probe()
834 if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) in fnic_probe()
838 lp->e_d_tov = fnic->config.ed_tov; in fnic_probe()
839 lp->r_a_tov = fnic->config.ra_tov; in fnic_probe()
841 fc_set_wwnn(lp, fnic->config.node_wwn); in fnic_probe()
842 fc_set_wwpn(lp, fnic->config.port_wwn); in fnic_probe()
844 fcoe_libfc_config(lp, &fnic->ctlr, &fnic_transport_template, 0); in fnic_probe()
853 fnic->stats_reset_time = jiffies; in fnic_probe()
857 if (fc_set_mfs(lp, fnic->config.maxdatafieldsize + in fnic_probe()
863 fc_host_dev_loss_tmo(lp->host) = fnic->config.port_down_timeout / 1000; in fnic_probe()
866 DRV_NAME " v" DRV_VERSION " over %s", fnic->name); in fnic_probe()
869 list_add_tail(&fnic->list, &fnic_list); in fnic_probe()
872 INIT_WORK(&fnic->link_work, fnic_handle_link); in fnic_probe()
873 INIT_WORK(&fnic->frame_work, fnic_handle_frame); in fnic_probe()
874 skb_queue_head_init(&fnic->frame_queue); in fnic_probe()
875 skb_queue_head_init(&fnic->tx_queue); in fnic_probe()
878 for (i = 0; i < fnic->raw_wq_count; i++) in fnic_probe()
879 vnic_wq_enable(&fnic->wq[i]); in fnic_probe()
880 for (i = 0; i < fnic->rq_count; i++) in fnic_probe()
881 vnic_rq_enable(&fnic->rq[i]); in fnic_probe()
882 for (i = 0; i < fnic->wq_copy_count; i++) in fnic_probe()
883 vnic_wq_copy_enable(&fnic->wq_copy[i]); in fnic_probe()
887 vnic_dev_enable(fnic->vdev); in fnic_probe()
889 err = fnic_request_intr(fnic); in fnic_probe()
891 shost_printk(KERN_ERR, fnic->lport->host, in fnic_probe()
896 for (i = 0; i < fnic->intr_count; i++) in fnic_probe()
897 vnic_intr_unmask(&fnic->intr[i]); in fnic_probe()
899 fnic_notify_timer_start(fnic); in fnic_probe()
909 for (i = 0; i < fnic->rq_count; i++) in fnic_probe()
910 vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); in fnic_probe()
911 vnic_dev_notify_unset(fnic->vdev); in fnic_probe()
913 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]); in fnic_probe()
915 mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]); in fnic_probe()
917 mempool_destroy(fnic->io_req_pool); in fnic_probe()
919 fnic_free_vnic_resources(fnic); in fnic_probe()
921 fnic_clear_intr_mode(fnic); in fnic_probe()
923 vnic_dev_close(fnic->vdev); in fnic_probe()
925 vnic_dev_unregister(fnic->vdev); in fnic_probe()
927 fnic_iounmap(fnic); in fnic_probe()
933 fnic_stats_debugfs_remove(fnic); in fnic_probe()
941 struct fnic *fnic = pci_get_drvdata(pdev); in fnic_remove() local
942 struct fc_lport *lp = fnic->lport; in fnic_remove()
951 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_remove()
952 fnic->stop_rx_link_events = 1; in fnic_remove()
953 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_remove()
955 if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) in fnic_remove()
956 del_timer_sync(&fnic->notify_timer); in fnic_remove()
963 skb_queue_purge(&fnic->frame_queue); in fnic_remove()
964 skb_queue_purge(&fnic->tx_queue); in fnic_remove()
966 if (fnic->config.flags & VFCF_FIP_CAPABLE) { in fnic_remove()
967 del_timer_sync(&fnic->fip_timer); in fnic_remove()
968 skb_queue_purge(&fnic->fip_frame_queue); in fnic_remove()
969 fnic_fcoe_reset_vlans(fnic); in fnic_remove()
970 fnic_fcoe_evlist_free(fnic); in fnic_remove()
978 fc_fabric_logoff(fnic->lport); in fnic_remove()
980 spin_lock_irqsave(&fnic->fnic_lock, flags); in fnic_remove()
981 fnic->in_remove = 1; in fnic_remove()
982 spin_unlock_irqrestore(&fnic->fnic_lock, flags); in fnic_remove()
984 fcoe_ctlr_destroy(&fnic->ctlr); in fnic_remove()
986 fnic_stats_debugfs_remove(fnic); in fnic_remove()
993 fnic_cleanup(fnic); in fnic_remove()
995 BUG_ON(!skb_queue_empty(&fnic->frame_queue)); in fnic_remove()
996 BUG_ON(!skb_queue_empty(&fnic->tx_queue)); in fnic_remove()
999 list_del(&fnic->list); in fnic_remove()
1002 fc_remove_host(fnic->lport->host); in fnic_remove()
1003 scsi_remove_host(fnic->lport->host); in fnic_remove()
1004 fc_exch_mgr_free(fnic->lport); in fnic_remove()
1005 vnic_dev_notify_unset(fnic->vdev); in fnic_remove()
1006 fnic_free_intr(fnic); in fnic_remove()
1007 fnic_free_vnic_resources(fnic); in fnic_remove()
1008 fnic_clear_intr_mode(fnic); in fnic_remove()
1009 vnic_dev_close(fnic->vdev); in fnic_remove()
1010 vnic_dev_unregister(fnic->vdev); in fnic_remove()
1011 fnic_iounmap(fnic); in fnic_remove()