From patchwork Fri Sep 27 18:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831148 Received: from rcdn-iport-4.cisco.com (rcdn-iport-4.cisco.com [173.37.86.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1B331C1ADC; Fri, 27 Sep 2024 18:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.75 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727462931; cv=none; b=B1+qFS+cX+2cFxBQlRxGF76JkqLWh4RFH6F+XVQ0bNwb+a9Dwjxx2Zr8Fq5I2KBLTdxM2f6hVZUGyW6V7a0MytfoG0R2fdCruObTcP8HW+42hh4ZtWs/h0hMC7lR3ELFSPZzc8pDEtvEuPLVrr11C3LsZYu/jY7+JS31U0TIitg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727462931; c=relaxed/simple; bh=FL29DEJ7//KTVNlUuj662o9nl66JfsI0hn5QS+5Y8bA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qaeGn2tqiUg3rYv/Qv052Gq+f6AABn4n04CFB4gMioLVM9UyKhV+1u6D7rVN9tHZsDpJ3qh6cLwDTKjaCZGHRJWsTl8zzMndIe6Q1b6ScmqUW9xZl87hTNFF9VaEnQa7HM0bW3SiqGJpCvDqDJgqgSgVTenk+SjUSAkb6ISDsuE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=QzFHuGiV; arc=none smtp.client-ip=173.37.86.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="QzFHuGiV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=16814; q=dns/txt; s=iport; t=1727462928; x=1728672528; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1cuA1NUCS/oxhHCgVIshTQK43Mv/mmjZzGoNN+9wPcE=; b=QzFHuGiVLVzHMOiH07P0Yys3TNspTk46RP+bvJXSvgDp3nagod5CTM7Z TD2SY95ife4saB3X9i/qFJ7/7/Xiq+9rozx1mRqNlodwtGrjeZbeWndtR TkcP9/wh1KWELkauAK3wMyDC94ZVx2hqEFSHeNzl9DfN9aWlBUtdMk7Ce c=; X-CSE-ConnectionGUID: iFLgkd1JTMe2K9d9N1RpJA== X-CSE-MsgGUID: 1uJ+0q1zQlCoUgHlWH1DLQ== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="267170692" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-4.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:47:40 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQai022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:47:40 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar Subject: [PATCH v3 01/14] scsi: fnic: Replace shost_printk with dev_info/dev_err Date: Fri, 27 Sep 2024 11:46:00 -0700 Message-Id: <20240927184613.52172-2-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Sending host information to shost_printk prior to host initialization in fnic is unnecessary. Replace shost_printk and a printk prior to this initialization with dev_info and dev_err accordingly. Reviewed-by: Sesidhar Baddela Reviewed-by: Arulprabhu Ponnusamy Reviewed-by: Gian Carlo Boffa Signed-off-by: Karan Tilak Kumar --- Changes between v1 and v2: Incorporate review comments from Hannes: Replace pr_info with dev_info. Replace pr_err with dev_err. Modify patch heading and description appropriately. --- drivers/scsi/fnic/fnic_main.c | 84 ++++++++++++----------------------- drivers/scsi/fnic/fnic_res.c | 69 ++++++++++------------------ 2 files changed, 51 insertions(+), 102 deletions(-) diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 29eead383eb9..2933b4c36e58 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -344,25 +344,19 @@ void fnic_log_q_error(struct fnic *fnic) for (i = 0; i < fnic->raw_wq_count; i++) { error_status = ioread32(&fnic->wq[i].ctrl->error_status); if (error_status) - shost_printk(KERN_ERR, fnic->lport->host, - "WQ[%d] error_status" - " %d\n", i, error_status); + dev_err(&fnic->pdev->dev, "WQ[%d] error_status %d\n", i, error_status); } for (i = 0; i < fnic->rq_count; i++) { error_status = ioread32(&fnic->rq[i].ctrl->error_status); if (error_status) - shost_printk(KERN_ERR, fnic->lport->host, - "RQ[%d] error_status" - " %d\n", i, error_status); + dev_err(&fnic->pdev->dev, "RQ[%d] error_status %d\n", i, error_status); } for (i = 0; i < fnic->wq_copy_count; i++) { error_status = ioread32(&fnic->hw_copy_wq[i].ctrl->error_status); if (error_status) - shost_printk(KERN_ERR, fnic->lport->host, - "CWQ[%d] error_status" - " %d\n", i, error_status); + dev_err(&fnic->pdev->dev, "CWQ[%d] error_status %d\n", i, error_status); } } @@ -396,8 +390,7 @@ static int fnic_notify_set(struct fnic *fnic) err = vnic_dev_notify_set(fnic->vdev, fnic->wq_copy_count + fnic->copy_wq_base); break; default: - shost_printk(KERN_ERR, fnic->lport->host, - "Interrupt mode should be set up" + dev_err(&fnic->pdev->dev, "Interrupt mode should be set up" " before devcmd notify set %d\n", vnic_dev_get_intr_mode(fnic->vdev)); err = -1; @@ -567,12 +560,10 @@ static int fnic_scsi_drv_init(struct fnic *fnic) host->nr_hw_queues = fnic->wq_copy_count; - shost_printk(KERN_INFO, host, - "fnic: can_queue: %d max_lun: %llu", + dev_info(&fnic->pdev->dev, "fnic: can_queue: %d max_lun: %llu", host->can_queue, host->max_lun); - shost_printk(KERN_INFO, host, - "fnic: max_id: %d max_cmd_len: %d nr_hw_queues: %d", + dev_info(&fnic->pdev->dev, "fnic: max_id: %d max_cmd_len: %d nr_hw_queues: %d", host->max_id, host->max_cmd_len, host->nr_hw_queues); return 0; @@ -622,7 +613,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) */ lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic)); if (!lp) { - printk(KERN_ERR PFX "Unable to alloc libfc local port\n"); + dev_err(&pdev->dev, "Unable to alloc libfc local port\n"); err = -ENOMEM; goto err_out; } @@ -632,7 +623,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic_id = ida_alloc(&fnic_ida, GFP_KERNEL); if (fnic_id < 0) { - pr_err("Unable to alloc fnic ID\n"); + dev_err(&pdev->dev, "Unable to alloc fnic ID\n"); err = fnic_id; goto err_out_ida_alloc; } @@ -650,15 +641,13 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = pci_enable_device(pdev); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Cannot enable PCI device, aborting.\n"); + dev_err(&fnic->pdev->dev, "Cannot enable PCI device, aborting.\n"); goto err_out_free_hba; } err = pci_request_regions(pdev, DRV_NAME); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Cannot enable PCI resources, aborting\n"); + dev_err(&fnic->pdev->dev, "Cannot enable PCI resources, aborting\n"); goto err_out_disable_device; } @@ -672,8 +661,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) { err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "No usable DMA configuration " + dev_err(&fnic->pdev->dev, "No usable DMA configuration " "aborting\n"); goto err_out_release_regions; } @@ -681,8 +669,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Map vNIC resources from BAR0 */ if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { - shost_printk(KERN_ERR, fnic->lport->host, - "BAR0 not memory-map'able, aborting.\n"); + dev_err(&fnic->pdev->dev, "BAR0 not memory-map'able, aborting.\n"); err = -ENODEV; goto err_out_release_regions; } @@ -692,8 +679,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->bar0.len = pci_resource_len(pdev, 0); if (!fnic->bar0.vaddr) { - shost_printk(KERN_ERR, fnic->lport->host, - "Cannot memory-map BAR0 res hdr, " + dev_err(&fnic->pdev->dev, "Cannot memory-map BAR0 res hdr, " "aborting.\n"); err = -ENODEV; goto err_out_release_regions; @@ -701,8 +687,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0); if (!fnic->vdev) { - shost_printk(KERN_ERR, fnic->lport->host, - "vNIC registration failed, " + dev_err(&fnic->pdev->dev, "vNIC registration failed, " "aborting.\n"); err = -ENODEV; goto err_out_iounmap; @@ -710,8 +695,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = vnic_dev_cmd_init(fnic->vdev); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "vnic_dev_cmd_init() returns %d, aborting\n", + dev_err(&fnic->pdev->dev, "vnic_dev_cmd_init() returns %d, aborting\n", err); goto err_out_vnic_unregister; } @@ -719,22 +703,19 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = fnic_dev_wait(fnic->vdev, vnic_dev_open, vnic_dev_open_done, CMD_OPENF_RQ_ENABLE_THEN_POST); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "vNIC dev open failed, aborting.\n"); + dev_err(&fnic->pdev->dev, "vNIC dev open failed, aborting.\n"); goto err_out_dev_cmd_deinit; } err = vnic_dev_init(fnic->vdev, 0); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "vNIC dev init failed, aborting.\n"); + dev_err(&fnic->pdev->dev, "vNIC dev init failed, aborting.\n"); goto err_out_dev_close; } err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "vNIC get MAC addr failed \n"); + dev_err(&fnic->pdev->dev, "vNIC get MAC addr failed\n"); goto err_out_dev_close; } /* set data_src for point-to-point mode and to keep it non-zero */ @@ -743,8 +724,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Get vNIC configuration */ err = fnic_get_vnic_config(fnic); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Get vNIC configuration failed, " + dev_err(&fnic->pdev->dev, "Get vNIC configuration failed, " "aborting.\n"); goto err_out_dev_close; } @@ -756,16 +736,14 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = fnic_set_intr_mode(fnic); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Failed to set intr mode, " + dev_err(&fnic->pdev->dev, "Failed to set intr mode, " "aborting.\n"); goto err_out_dev_close; } err = fnic_alloc_vnic_resources(fnic); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Failed to alloc vNIC resources, " + dev_err(&fnic->pdev->dev, "Failed to alloc vNIC resources, " "aborting.\n"); goto err_out_clear_intr; } @@ -778,7 +756,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) * sizeof(struct fnic_io_req *), GFP_KERNEL); } - shost_printk(KERN_INFO, fnic->lport->host, "fnic copy wqs: %d, Q0 ioreq table size: %d\n", + dev_info(&fnic->pdev->dev, "fnic copy wqs: %d, Q0 ioreq table size: %d\n", fnic->wq_copy_count, fnic->sw_copy_wq[0].ioreq_table_size); /* initialize all fnic locks */ @@ -818,8 +796,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->ctlr.update_mac = fnic_update_mac; fnic->ctlr.get_src_addr = fnic_get_mac; if (fnic->config.flags & VFCF_FIP_CAPABLE) { - shost_printk(KERN_INFO, fnic->lport->host, - "firmware supports FIP\n"); + dev_info(&fnic->pdev->dev, "firmware supports FIP\n"); /* enable directed and multicast */ vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0); vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS); @@ -835,8 +812,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) INIT_LIST_HEAD(&fnic->evlist); INIT_LIST_HEAD(&fnic->vlans); } else { - shost_printk(KERN_INFO, fnic->lport->host, - "firmware uses non-FIP mode\n"); + dev_info(&fnic->pdev->dev, "firmware uses non-FIP mode\n"); fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP); fnic->ctlr.state = FIP_ST_NON_FIP; } @@ -851,8 +827,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Setup notification buffer area */ err = fnic_notify_set(fnic); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Failed to alloc notify buffer, aborting.\n"); + dev_err(&fnic->pdev->dev, "Failed to alloc notify buffer, aborting.\n"); goto err_out_free_max_pool; } @@ -864,8 +839,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) for (i = 0; i < fnic->rq_count; i++) { err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "fnic_alloc_rq_frame can't alloc " + dev_err(&fnic->pdev->dev, "fnic_alloc_rq_frame can't alloc " "frame\n"); goto err_out_rq_buf; } @@ -883,8 +857,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = fnic_request_intr(fnic); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "Unable to request irq.\n"); + dev_err(&fnic->pdev->dev, "Unable to request irq.\n"); goto err_out_request_intr; } @@ -894,8 +867,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) */ err = scsi_add_host(lp->host, &pdev->dev); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "fnic: scsi_add_host failed...exiting\n"); + dev_err(&fnic->pdev->dev, "fnic: scsi_add_host failed...exiting\n"); goto err_out_scsi_add_host; } diff --git a/drivers/scsi/fnic/fnic_res.c b/drivers/scsi/fnic/fnic_res.c index 33dd27f6f24e..dd24e25574db 100644 --- a/drivers/scsi/fnic/fnic_res.c +++ b/drivers/scsi/fnic/fnic_res.c @@ -30,9 +30,7 @@ int fnic_get_vnic_config(struct fnic *fnic) offsetof(struct vnic_fc_config, m), \ sizeof(c->m), &c->m); \ if (err) { \ - shost_printk(KERN_ERR, fnic->lport->host, \ - "Error getting %s, %d\n", #m, \ - err); \ + dev_err(&fnic->pdev->dev, "Error getting %s, %d\n", #m, err); \ return err; \ } \ } while (0); @@ -139,40 +137,29 @@ int fnic_get_vnic_config(struct fnic *fnic) c->wq_copy_count = min_t(u16, FNIC_WQ_COPY_MAX, c->wq_copy_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC MAC addr %pM " + dev_info(&fnic->pdev->dev, "vNIC MAC addr %pM " "wq/wq_copy/rq %d/%d/%d\n", fnic->ctlr.ctl_src_addr, c->wq_enet_desc_count, c->wq_copy_desc_count, c->rq_desc_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC node wwn %llx port wwn %llx\n", + dev_info(&fnic->pdev->dev, "vNIC node wwn %llx port wwn %llx\n", c->node_wwn, c->port_wwn); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC ed_tov %d ra_tov %d\n", + dev_info(&fnic->pdev->dev, "vNIC ed_tov %d ra_tov %d\n", c->ed_tov, c->ra_tov); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC mtu %d intr timer %d\n", + dev_info(&fnic->pdev->dev, "vNIC mtu %d intr timer %d\n", c->maxdatafieldsize, c->intr_timer); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC flags 0x%x luns per tgt %d\n", + dev_info(&fnic->pdev->dev, "vNIC flags 0x%x luns per tgt %d\n", c->flags, c->luns_per_tgt); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC flogi_retries %d flogi timeout %d\n", + dev_info(&fnic->pdev->dev, "vNIC flogi_retries %d flogi timeout %d\n", c->flogi_retries, c->flogi_timeout); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC plogi retries %d plogi timeout %d\n", + dev_info(&fnic->pdev->dev, "vNIC plogi retries %d plogi timeout %d\n", c->plogi_retries, c->plogi_timeout); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC io throttle count %d link dn timeout %d\n", + dev_info(&fnic->pdev->dev, "vNIC io throttle count %d link dn timeout %d\n", c->io_throttle_count, c->link_down_timeout); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC port dn io retries %d port dn timeout %d\n", + dev_info(&fnic->pdev->dev, "vNIC port dn io retries %d port dn timeout %d\n", c->port_down_io_retries, c->port_down_timeout); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC wq_copy_count: %d\n", c->wq_copy_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC intr mode: %d\n", c->intr_mode); + dev_info(&fnic->pdev->dev, "vNIC wq_copy_count: %d\n", c->wq_copy_count); + dev_info(&fnic->pdev->dev, "vNIC intr mode: %d\n", c->intr_mode); return 0; } @@ -206,18 +193,12 @@ void fnic_get_res_counts(struct fnic *fnic) fnic->intr_count = vnic_dev_get_res_count(fnic->vdev, RES_TYPE_INTR_CTRL); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC fw resources wq_count: %d\n", fnic->wq_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC fw resources raw_wq_count: %d\n", fnic->raw_wq_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC fw resources wq_copy_count: %d\n", fnic->wq_copy_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC fw resources rq_count: %d\n", fnic->rq_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC fw resources cq_count: %d\n", fnic->cq_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC fw resources intr_count: %d\n", fnic->intr_count); + dev_info(&fnic->pdev->dev, "vNIC fw resources wq_count: %d\n", fnic->wq_count); + dev_info(&fnic->pdev->dev, "vNIC fw resources raw_wq_count: %d\n", fnic->raw_wq_count); + dev_info(&fnic->pdev->dev, "vNIC fw resources wq_copy_count: %d\n", fnic->wq_copy_count); + dev_info(&fnic->pdev->dev, "vNIC fw resources rq_count: %d\n", fnic->rq_count); + dev_info(&fnic->pdev->dev, "vNIC fw resources cq_count: %d\n", fnic->cq_count); + dev_info(&fnic->pdev->dev, "vNIC fw resources intr_count: %d\n", fnic->intr_count); } void fnic_free_vnic_resources(struct fnic *fnic) @@ -253,19 +234,17 @@ int fnic_alloc_vnic_resources(struct fnic *fnic) intr_mode = vnic_dev_get_intr_mode(fnic->vdev); - shost_printk(KERN_INFO, fnic->lport->host, "vNIC interrupt mode: %s\n", + dev_info(&fnic->pdev->dev, "vNIC interrupt mode: %s\n", intr_mode == VNIC_DEV_INTR_MODE_INTX ? "legacy PCI INTx" : intr_mode == VNIC_DEV_INTR_MODE_MSI ? "MSI" : intr_mode == VNIC_DEV_INTR_MODE_MSIX ? "MSI-X" : "unknown"); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC resources avail: wq %d cp_wq %d raw_wq %d rq %d", + dev_info(&fnic->pdev->dev, "res avail: wq %d cp_wq %d raw_wq %d rq %d", fnic->wq_count, fnic->wq_copy_count, fnic->raw_wq_count, fnic->rq_count); - shost_printk(KERN_INFO, fnic->lport->host, - "vNIC resources avail: cq %d intr %d cpy-wq desc count %d\n", + dev_info(&fnic->pdev->dev, "res avail: cq %d intr %d cpy-wq desc count %d\n", fnic->cq_count, fnic->intr_count, fnic->config.wq_copy_desc_count); @@ -340,8 +319,7 @@ int fnic_alloc_vnic_resources(struct fnic *fnic) RES_TYPE_INTR_PBA_LEGACY, 0); if (!fnic->legacy_pba && intr_mode == VNIC_DEV_INTR_MODE_INTX) { - shost_printk(KERN_ERR, fnic->lport->host, - "Failed to hook legacy pba resource\n"); + dev_err(&fnic->pdev->dev, "Failed to hook legacy pba resource\n"); err = -ENODEV; goto err_out_cleanup; } @@ -444,8 +422,7 @@ int fnic_alloc_vnic_resources(struct fnic *fnic) /* init the stats memory by making the first call here */ err = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); if (err) { - shost_printk(KERN_ERR, fnic->lport->host, - "vnic_dev_stats_dump failed - x%x\n", err); + dev_err(&fnic->pdev->dev, "vnic_dev_stats_dump failed - x%x\n", err); goto err_out_cleanup; } From patchwork Fri Sep 27 18:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831147 Received: from rcdn-iport-1.cisco.com (rcdn-iport-1.cisco.com [173.37.86.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80ED1171E76; Fri, 27 Sep 2024 18:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727462972; cv=none; b=S6dp5W5amOV93CzqxdIuwlB4amil+Hv8XRtL/bqBI6cU5YRHd6xEFRWCVPiPabHd9LKFFY9dn2rFcuNUeMoFlItzk5pUz9T4Bd149doDqCisSM1vZjTkoBbVWJ++rPVVJGJBodiG590uUkmm3UFKurBx9c4+EEUn9wPPJaY5iJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727462972; c=relaxed/simple; bh=qieGd5q2+W+n5VOxFBhGNGE4B3bb8D4maTfLcz7dY6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JeT6YUDWQ17+R5G2x7qwvQr6e4HbuEnYkXhakqO58JkKwHxWiTF07zklm2oMxuTVWLXHUek1u0CKvI1EzCzsMys4IDinus2RHwSOT+rTEOat7lyFit2pAjEH57uTZrdGVcLSh9+ykPQryuLzIHlmT+bdLN6OK6zPtbDjiL4KSxY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=cRbHPy3y; arc=none smtp.client-ip=173.37.86.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="cRbHPy3y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=61258; q=dns/txt; s=iport; t=1727462968; x=1728672568; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/ecmX85UIjIAA0HknGX+hBrQl+X5E9XBfAbMuGrSreE=; b=cRbHPy3yZUHfTvBwfljZm4ifjBUHvaoV6lW/SezQQqRIEbaVir14JXdH JBQrO7aD/wSSKrVgwkdks/scS4Pnl5QaVnn/tJ+fYeKJv4CTlour71vhZ fnhMFjDXw/WczkWxeGXr2o42Om6AaoM9TSL1JMZnAuhLfVs5BRzHG1CAD M=; X-CSE-ConnectionGUID: yovB9Q0wRPS37iQzZtq1UA== X-CSE-MsgGUID: 6Q3akn9kQyKyHsCCAirXRA== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="266928692" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-1.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:49:21 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQal022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:49:20 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar , kernel test robot Subject: [PATCH v3 04/14] scsi: fnic: Add support for target based solicited requests and responses Date: Fri, 27 Sep 2024 11:46:03 -0700 Message-Id: <20240927184613.52172-5-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Add support for target based solicited requests and responses. Add support for tport definitions and processing. Add support for restarting the IT nexus. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406120146.xchlZbqX-lkp@ intel.com/ Reviewed-by: Sesidhar Baddela Signed-off-by: Gian Carlo Boffa Signed-off-by: Arulprabhu Ponnusamy Signed-off-by: Arun Easi Signed-off-by: Karan Tilak Kumar --- Changes between v2 and v3: Fix issue found by kernel test robot. Remove fnic_std_ba_acc definition to fix compilation warning. Incorporate review comments from Hannes: Replace redundant definitions with standard definitions. Replace static OXIDs with pool-based OXIDs for targets. Changes between v1 and v2: Incorporate review comments from Hannes: Use the correct kernel-doc format. Replace htonll() with get_unaligned_be64(). Replace fnic_del_fabric_timer_sync macro calls to function calls. Replace fnic_del_tport_timer_sync macro calls to function calls. Rename fc_abts_s to fc_tport_abts_s. Modify fc_tport_abts_s to be a global frame. Rename variable pfc_abts to tport_abts. Replace definitions with standard definitions from fc_els.h. Modify functions with returns in the middle to if else clauses. Replace simultaneous use of fc_tport_abts_s and tport_abts with just tport_abts. --- drivers/scsi/fnic/fdls_disc.c | 1567 +++++++++++++++++++++++++++++++-- drivers/scsi/fnic/fnic.h | 6 + drivers/scsi/fnic/fnic_fdls.h | 2 +- 3 files changed, 1501 insertions(+), 74 deletions(-) diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c index d203398b2743..0757b9ab1a28 100644 --- a/drivers/scsi/fnic/fdls_disc.c +++ b/drivers/scsi/fnic/fdls_disc.c @@ -11,6 +11,10 @@ #include #include +#define FC_FC4_TYPE_SCSI 0x08 + +static void fdls_send_rpn_id(struct fnic_iport_s *iport); + /* Frame initialization */ /* * Variables: @@ -66,6 +70,20 @@ struct fc_std_rpn_id fnic_std_rpn_id_req = { .ct_cmd = cpu_to_be16(FC_NS_RPN_ID)} }; +/* + * Variables: + * did, sid, oxid + */ +struct fc_std_els_prli fnic_std_prli_req = { + .fchdr = {.fh_r_ctl = FC_RCTL_ELS_REQ, .fh_type = FC_TYPE_ELS, + .fh_f_ctl = {FNIC_ELS_REQ_FCTL, 0, 0}, .fh_rx_id = 0xFFFF}, + .els_prli = {.prli_cmd = ELS_PRLI, + .prli_spp_len = 16, + .prli_len = cpu_to_be16(0x14)}, + .sp = {.spp_type = 0x08, .spp_flags = 0x0020, + .spp_params = cpu_to_be32(0xA2)} +}; + /* * Variables: * fh_s_id, port_id, port_name @@ -143,9 +161,19 @@ struct fc_frame_header fc_std_fabric_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +struct fc_frame_header fc_std_tport_abts = { + .fh_r_ctl = FC_RCTL_BA_ABTS, /* ABTS */ + .fh_cs_ctl = 0x00, .fh_type = FC_TYPE_BLS, + .fh_f_ctl = {FNIC_REQ_ABTS_FCTL, 0, 0}, .fh_seq_id = 0x00, + .fh_df_ctl = 0x00, .fh_seq_cnt = 0x0000, .fh_rx_id = 0xFFFF, + .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ +}; + #define RETRIES_EXHAUSTED(iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY) +#define FNIC_TPORT_MAX_NEXUS_RESTART (8) + /* * For fabric requests and fdmi, once OXIDs are allocated from the pool * (and a range) they are encoded with expected rsp type as @@ -166,6 +194,14 @@ static void fdls_process_flogi_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr, void *rx_frame); static void fnic_fdls_start_plogi(struct fnic_iport_s *iport); +static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, + uint32_t fcid, + uint64_t wwpn); +static void fdls_target_restart_nexus(struct fnic_tport_s *tport); +static void fdls_start_tport_timer(struct fnic_iport_s *iport, + struct fnic_tport_s *tport, int timeout); +static void fdls_tport_timer_callback(struct timer_list *t); + static void fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout); static void @@ -181,6 +217,8 @@ void fdls_init_oxid_pool(struct fnic_iport_s *iport) fdls_init_fabric_oxid_pool(&iport->fdmi_oxid_pool, FDLS_FDMI_OXID_POOL_BASE, FDLS_FDMI_OXID_POOL_SZ); + + fdls_init_tgt_oxid_pool(iport); } uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, @@ -312,6 +350,13 @@ static inline void fdls_schedule_fabric_oxid_free(struct fnic_iport_s iport->fabric_oxid_pool.active_oxid_fabric_req); } +static inline void fdls_schedule_tgt_oxid_free(struct fnic_iport_s *iport, + struct fnic_tgt_oxid_pool_s + *oxid_pool, uint16_t oxid) +{ + fdls_schedule_oxid_free(&oxid_pool->meta, oxid); +} + int fnic_fdls_expected_rsp(struct fnic_iport_s *iport, uint16_t oxid) { struct fnic *fnic = iport->fnic; @@ -339,6 +384,62 @@ static int fdls_is_oxid_in_fabric_range(uint16_t oxid) (oxid_unmasked <= FDLS_FABRIC_OXID_POOL_END)); } +void fdls_init_tgt_oxid_pool(struct fnic_iport_s *iport) +{ + memset(&iport->plogi_oxid_pool, 0, sizeof(iport->plogi_oxid_pool)); + iport->plogi_oxid_pool.meta.oxid_base = FDLS_PLOGI_OXID_BASE; + iport->plogi_oxid_pool.meta.sz = FDLS_TGT_OXID_BLOCK_SZ; + INIT_LIST_HEAD(&iport->plogi_oxid_pool.meta.reclaim_list); + + memset(&iport->prli_oxid_pool, 0, sizeof(iport->prli_oxid_pool)); + iport->prli_oxid_pool.meta.oxid_base = FDLS_PRLI_OXID_BASE; + iport->prli_oxid_pool.meta.sz = FDLS_TGT_OXID_BLOCK_SZ; + INIT_LIST_HEAD(&iport->prli_oxid_pool.meta.reclaim_list); + + memset(&iport->adisc_oxid_pool, 0, sizeof(iport->adisc_oxid_pool)); + iport->adisc_oxid_pool.meta.oxid_base = FDLS_ADISC_OXID_BASE; + iport->adisc_oxid_pool.meta.sz = FDLS_TGT_OXID_BLOCK_SZ; + INIT_LIST_HEAD(&iport->adisc_oxid_pool.meta.reclaim_list); +} + +inline uint16_t fdls_alloc_tgt_oxid(struct fnic_iport_s *iport, + struct fnic_tgt_oxid_pool_s *oxid_pool) +{ + uint16_t oxid; + + oxid = fdls_alloc_oxid(iport, &oxid_pool->meta, oxid_pool->bitmap); + return oxid; +} + +inline void fdls_free_tgt_oxid(struct fnic_iport_s *iport, + struct fnic_tgt_oxid_pool_s *oxid_pool, + uint16_t oxid) +{ + fdls_free_oxid(iport, &oxid_pool->meta, oxid_pool->bitmap, oxid); +} + +static struct fnic_tgt_oxid_pool_s *fdls_get_tgt_oxid_pool(struct fnic_tport_s + *tport) +{ + struct fnic_iport_s *iport = (struct fnic_iport_s *)tport->iport; + struct fnic_tgt_oxid_pool_s *oxid_pool = NULL; + + switch (tport->state) { + case FDLS_TGT_STATE_PLOGI: + oxid_pool = &iport->plogi_oxid_pool; + break; + case FDLS_TGT_STATE_PRLI: + oxid_pool = &iport->prli_oxid_pool; + break; + case FDLS_TGT_STATE_ADISC: + oxid_pool = &iport->adisc_oxid_pool; + break; + default: + break; + } + return oxid_pool; +} + inline void fnic_del_fabric_timer_sync(struct fnic *fnic) { fnic->iport.fabric.del_timer_inprogress = 1; @@ -382,6 +483,56 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) "fabric timer is %d ", timeout); } +static void +fdls_start_tport_timer(struct fnic_iport_s *iport, + struct fnic_tport_s *tport, int timeout) +{ + u64 fabric_tov; + struct fnic *fnic = iport->fnic; + + if (tport->timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid 0x%x: Canceling disc timer\n", + tport->fcid); + fnic_del_tport_timer_sync(fnic, tport); + tport->timer_pending = 0; + } + + if (!(tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) + tport->retry_counter++; + + fabric_tov = jiffies + msecs_to_jiffies(timeout); + mod_timer(&tport->retry_timer, round_jiffies(fabric_tov)); + tport->timer_pending = 1; +} + +void +fdls_send_tport_abts(struct fnic_iport_s *iport, + struct fnic_tport_s *tport) +{ + uint8_t s_id[3]; + uint8_t d_id[3]; + struct fnic *fnic = iport->fnic; + struct fc_frame_header tport_abort = fc_std_tport_abts; + struct fc_frame_header *tport_abts = &tport_abort; + + hton24(s_id, iport->fcid); + hton24(d_id, tport->fcid); + FNIC_STD_SET_S_ID(tport_abts, s_id); + FNIC_STD_SET_D_ID(tport_abts, d_id); + tport->flags |= FNIC_FDLS_TGT_ABORT_ISSUED; + + tport_abts->fh_ox_id = tport->oxid_used; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS sending tport abts: tport->state: %d ", + tport->state); + + fnic_send_fcoe_frame(iport, tport_abts, sizeof(struct fc_frame_header)); + /* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ + fdls_start_tport_timer(iport, tport, 2 * iport->e_d_tov); +} + static void fdls_send_fabric_abts(struct fnic_iport_s *iport) { uint8_t fcid[3]; @@ -613,6 +764,176 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) fdls_set_state((&iport->fabric), fdls_state); } +static void +fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) +{ + struct fc_std_els_adisc adisc; + uint8_t s_id[3]; + uint8_t d_id[3]; + uint16_t oxid; + struct fnic *fnic = iport->fnic; + + memset(&adisc, 0, sizeof(struct fc_std_els_adisc)); + FNIC_STD_SET_R_CTL(&adisc.fchdr, 0x22); + FNIC_STD_SET_TYPE(&adisc.fchdr, 0x01); + FNIC_STD_SET_F_CTL(&adisc.fchdr, FNIC_ELS_REQ_FCTL << 16); + FNIC_STD_SET_RX_ID(&adisc.fchdr, cpu_to_be16(0xFFFF)); + + hton24(s_id, iport->fcid); + hton24(d_id, tport->fcid); + FNIC_STD_SET_S_ID(&adisc.fchdr, s_id); + FNIC_STD_SET_D_ID(&adisc.fchdr, d_id); + + oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->adisc_oxid_pool)); + if (oxid == 0xFFFF) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate OXID to send ADISC %p", iport); + return; + } + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED; + + FNIC_STD_SET_OX_ID((&adisc.fchdr), oxid); + FNIC_STD_SET_NPORT_NAME(&adisc.els.adisc_wwpn, + le64_to_cpu(iport->wwpn)); + FNIC_STD_SET_NODE_NAME(&adisc.els.adisc_wwnn, le64_to_cpu(iport->wwnn)); + + memcpy(adisc.els.adisc_port_id, s_id, 3); + adisc.els.adisc_cmd = ELS_ADISC; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "sending ADISC to tgt fcid: 0x%x", tport->fcid); + + + fnic_send_fcoe_frame(iport, &adisc, sizeof(struct fc_std_els_adisc)); + /* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ + fdls_start_tport_timer(iport, tport, 2 * iport->e_d_tov); +} + +bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) +{ + struct fnic_tport_event_s *tport_del_evt; + struct fnic *fnic = iport->fnic; + + if ((tport->state == FDLS_TGT_STATE_OFFLINING) + || (tport->state == FDLS_TGT_STATE_OFFLINE)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid 0x%x: tport state is offlining/offline\n", + tport->fcid); + return false; + } + + fdls_set_tport_state(tport, FDLS_TGT_STATE_OFFLINING); + /* + * By setting this flag, the tport will not be seen in a look-up + * in an RSCN. Even if we move to multithreaded model, this tport + * will be destroyed and a new RSCN will have to create a new one + */ + tport->flags |= FNIC_FDLS_TPORT_TERMINATING; + + if (tport->timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid 0x%x: Canceling disc timer\n", + tport->fcid); + fnic_del_tport_timer_sync(fnic, tport); + tport->timer_pending = 0; + } + + if (IS_FNIC_FCP_INITIATOR(fnic)) { + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); + fnic_rport_exch_reset(iport->fnic, tport->fcid); + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); + + if (tport->flags & FNIC_FDLS_SCSI_REGISTERED) { + tport_del_evt = + kzalloc(sizeof(struct fnic_tport_event_s), GFP_ATOMIC); + if (!tport_del_evt) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate memory for tport fcid: 0x%0x\n", + tport->fcid); + return false; + } + tport_del_evt->event = TGT_EV_RPORT_DEL; + tport_del_evt->arg1 = (void *) tport; + list_add_tail(&tport_del_evt->links, &fnic->tport_event_list); + queue_work(fnic_event_queue, &fnic->tport_work); + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport 0x%x not reg with scsi_transport. Freeing locally", + tport->fcid); + list_del(&tport->links); + kfree(tport); + } + } + return true; +} + +static void +fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) +{ + struct fc_std_flogi plogi; + uint8_t s_id[3]; + uint8_t d_id[3]; + uint16_t oxid; + struct fnic *fnic = iport->fnic; + uint32_t timeout; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Send tgt PLOGI to fcid: 0x%x", tport->fcid); + + memcpy(&plogi, &fnic_std_plogi_req, sizeof(struct fc_std_flogi)); + + hton24(s_id, iport->fcid); + hton24(d_id, tport->fcid); + + FNIC_STD_SET_S_ID(&plogi.fchdr, s_id); + FNIC_STD_SET_D_ID(&plogi.fchdr, d_id); + FNIC_LOGI_SET_RDF_SIZE(&plogi.els, iport->max_payload_size); + + oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->plogi_oxid_pool)); + if (oxid == 0xFFFF) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: Failed to allocate oxid to send PLOGI to fcid: 0x%x", + iport->fcid, tport->fcid); + return; + } + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "send tgt PLOGI: tgt fcid: 0x%x oxid: 0x%x", tport->fcid, + ntohs(oxid)); + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED; + + FNIC_STD_SET_OX_ID((&plogi.fchdr), oxid); + FNIC_LOGI_SET_NPORT_NAME(&plogi.els, iport->wwpn); + FNIC_LOGI_SET_NODE_NAME(&plogi.els, iport->wwnn); + + timeout = max(2 * iport->e_d_tov, iport->plogi_timeout); + + + fnic_send_fcoe_frame(iport, &plogi, sizeof(struct fc_std_flogi)); + /* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ + fdls_start_tport_timer(iport, tport, timeout); +} + +static uint16_t +fnic_fc_plogi_rsp_rdf(struct fnic_iport_s *iport, + struct fc_std_flogi *plogi_rsp) +{ + uint16_t b2b_rdf_size = + be16_to_cpu(FNIC_LOGI_RDF_SIZE(&plogi_rsp->els)); + uint16_t spc3_rdf_size = + be16_to_cpu(plogi_rsp->els.fl_cssp[2].cp_rdfs) & FNIC_FC_C3_RDF; + struct fnic *fnic = iport->fnic; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "MFS: b2b_rdf_size: 0x%x spc3_rdf_size: 0x%x", + b2b_rdf_size, spc3_rdf_size); + + return MIN(b2b_rdf_size, spc3_rdf_size); +} + static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) { struct fc_std_rft_id rft_id; @@ -689,6 +1010,48 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) fdls_start_fabric_timer(iport, 2 * iport->e_d_tov); } +static void +fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) +{ + struct fc_std_els_prli prli; + uint8_t s_id[3]; + uint8_t d_id[3]; + uint16_t oxid; + struct fnic *fnic = iport->fnic; + uint32_t timeout; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS sending PRLI to tgt: 0x%x", tport->fcid); + + oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->prli_oxid_pool)); + if (oxid == 0xFFFF) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate OXID to send PRLI %p", iport); + return; + } + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS sending PRLI to tgt: 0x%x OXID: 0x%x", tport->fcid, + ntohs(oxid)); + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED; + memcpy(&prli, &fnic_std_prli_req, sizeof(struct fc_std_els_prli)); + + hton24(s_id, iport->fcid); + hton24(d_id, tport->fcid); + + FNIC_STD_SET_S_ID((&prli.fchdr), s_id); + FNIC_STD_SET_D_ID((&prli.fchdr), d_id); + FNIC_STD_SET_OX_ID((&prli.fchdr), oxid); + + timeout = max(2 * iport->e_d_tov, iport->plogi_timeout); + + + fnic_send_fcoe_frame(iport, &prli, sizeof(struct fc_std_els_prli)); + /* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ + fdls_start_tport_timer(iport, tport, timeout); +} + /** * fdls_send_fabric_logo - Send flogo to the fcf * @iport: Handle to fnic iport @@ -741,6 +1104,212 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) fnic_send_fcoe_frame(iport, &logo, sizeof(struct fc_std_logo)); } +/** + * fdls_tgt_logout - Send plogo to the remote port + * @iport: Handle to fnic iport + * @tport: Handle to remote port + * + * This function does not change or check the fabric/tport state. + * It the caller's responsibility to set the appropriate tport/fabric + * state when this is called. Normally that is fdls_tgt_state_plogo. + * This could be used to send plogo to nameserver process + * also not just target processes + */ +void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) +{ + struct fc_std_logo logo; + uint8_t s_id[3]; + uint8_t d_id[3]; + struct fnic *fnic = iport->fnic; + uint16_t oxid; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Sending logo to tport fcid: 0x%x", tport->fcid); + memcpy(&logo, &fnic_std_logo_req, sizeof(struct fc_std_logo)); + + hton24(s_id, iport->fcid); + hton24(d_id, tport->fcid); + + FNIC_STD_SET_S_ID((&logo.fchdr), s_id); + FNIC_STD_SET_D_ID((&logo.fchdr), d_id); + + oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->plogi_oxid_pool)); + FNIC_STD_SET_OX_ID((&logo.fchdr), oxid); + + memcpy(&logo.els.fl_n_port_id, s_id, 3); + FNIC_STD_SET_NPORT_NAME(&logo.els.fl_n_port_wwn, + le64_to_cpu(iport->wwpn)); + + + fnic_send_fcoe_frame(iport, &logo, sizeof(struct fc_std_logo)); +} + +static void fdls_tgt_discovery_start(struct fnic_iport_s *iport) +{ + struct fnic_tport_s *tport, *next; + u32 old_link_down_cnt = iport->fnic->link_down_cnt; + struct fnic *fnic = iport->fnic; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: Starting FDLS target discovery", iport->fcid); + + list_for_each_entry_safe(tport, next, &iport->tport_list, links) { + if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state != FNIC_IPORT_STATE_READY)) { + break; + } + /* if we marked the tport as deleted due to GPN_FT + * We should not send ADISC anymore + */ + if ((tport->state == FDLS_TGT_STATE_OFFLINING) || + (tport->state == FDLS_TGT_STATE_OFFLINE)) + continue; + + /* For tports which have received RSCN */ + if (tport->flags & FNIC_FDLS_TPORT_SEND_ADISC) { + tport->retry_counter = 0; + fdls_set_tport_state(tport, FDLS_TGT_STATE_ADISC); + tport->flags &= ~FNIC_FDLS_TPORT_SEND_ADISC; + fdls_send_tgt_adisc(iport, tport); + continue; + } + if (fdls_get_tport_state(tport) != FDLS_TGT_STATE_INIT) { + /* Not a new port, skip */ + continue; + } + tport->retry_counter = 0; + fdls_set_tport_state(tport, FDLS_TGT_STATE_PLOGI); + fdls_send_tgt_plogi(iport, tport); + } + fdls_set_state((&iport->fabric), FDLS_STATE_TGT_DISCOVERY); +} + +/* + * Function to restart the IT nexus if we received any out of + * sequence PLOGI/PRLI response from the target. + * The memory for the new tport structure is allocated + * inside fdls_create_tport and added to the iport's tport list. + * This will get freed later during tport_offline/linkdown + * or module unload. The new_tport pointer will go out of scope + * safely since the memory it is + * pointing to it will be freed later + */ +static void fdls_target_restart_nexus(struct fnic_tport_s *tport) +{ + struct fnic_iport_s *iport = tport->iport; + struct fnic_tport_s *new_tport = NULL; + uint32_t fcid; + uint64_t wwpn; + int nexus_restart_count; + struct fnic *fnic = iport->fnic; + bool retval = true; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid: 0x%x state: %d restart_count: %d", + tport->fcid, tport->state, tport->nexus_restart_count); + + fcid = tport->fcid; + wwpn = tport->wwpn; + nexus_restart_count = tport->nexus_restart_count; + + retval = fdls_delete_tport(iport, tport); + if (retval != true) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Error deleting tport: 0x%x", fcid); + return; + } + + if (nexus_restart_count >= FNIC_TPORT_MAX_NEXUS_RESTART) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Exceeded nexus restart retries tport: 0x%x", + fcid); + return; + } + + /* + * Allocate memory for the new tport and add it to + * iport's tport list. + * This memory will be freed during tport_offline/linkdown + * or module unload. The pointer new_tport is safe to go + * out of scope when this function returns, since the memory + * it is pointing to is guaranteed to be freed later + * as mentioned above. + */ + new_tport = fdls_create_tport(iport, fcid, wwpn); + if (!new_tport) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Error creating new tport: 0x%x", fcid); + return; + } + + new_tport->nexus_restart_count = nexus_restart_count + 1; + fdls_send_tgt_plogi(iport, new_tport); + fdls_set_tport_state(new_tport, FDLS_TGT_STATE_PLOGI); +} + +struct fnic_tport_s *fnic_find_tport_by_fcid(struct fnic_iport_s *iport, + uint32_t fcid) +{ + struct fnic_tport_s *tport, *next; + + list_for_each_entry_safe(tport, next, &(iport->tport_list), links) { + if ((tport->fcid == fcid) + && !(tport->flags & FNIC_FDLS_TPORT_TERMINATING)) + return tport; + } + return NULL; +} + +static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, + uint32_t fcid, uint64_t wwpn) +{ + struct fnic_tport_s *tport; + struct fnic *fnic = iport->fnic; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS create tport: fcid: 0x%x wwpn: 0x%llx", fcid, wwpn); + + tport = kzalloc(sizeof(struct fnic_tport_s), GFP_ATOMIC); + if (!tport) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Memory allocation failure while creating tport: 0x%x\n", + fcid); + return NULL; + } + + tport->max_payload_size = FNIC_FCOE_MAX_FRAME_SZ; + tport->r_a_tov = FNIC_R_A_TOV_DEF; + tport->e_d_tov = FNIC_E_D_TOV_DEF; + tport->fcid = fcid; + tport->wwpn = wwpn; + tport->iport = iport; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Need to setup tport timer callback"); + + timer_setup(&tport->retry_timer, fdls_tport_timer_callback, 0); + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Added tport 0x%x", tport->fcid); + fdls_set_tport_state(tport, FDLS_TGT_STATE_INIT); + list_add_tail(&tport->links, &iport->tport_list); + atomic_set(&tport->in_flight, 0); + return tport; +} + +struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport, + uint64_t wwpn) +{ + struct fnic_tport_s *tport, *next; + + list_for_each_entry_safe(tport, next, &(iport->tport_list), links) { + if ((tport->wwpn == wwpn) + && !(tport->flags & FNIC_FDLS_TPORT_TERMINATING)) + return tport; + } + return NULL; +} + void fdls_fabric_timer_callback(struct timer_list *t) { struct fnic_fdls_fabric_s *fabric = from_timer(fabric, t, retry_timer); @@ -846,89 +1415,587 @@ void fdls_fabric_timer_callback(struct timer_list *t) /* ABTS has timed out */ fdls_schedule_fabric_oxid_free(iport); FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "ABTS timed out. Starting PLOGI: %p", iport); - fnic_fdls_start_plogi(iport); + "ABTS timed out. Starting PLOGI: %p", iport); + fnic_fdls_start_plogi(iport); + } + break; + case FDLS_STATE_REGISTER_FC4_TYPES: + /* scr received a LS_RJT with busy we retry from here */ + if ((iport->fabric.flags & FNIC_FDLS_RETRY_FRAME) + && (iport->fabric.retry_counter < FDLS_RETRY_COUNT)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME; + fdls_send_register_fc4_types(iport); + } else if (!(iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) { + /* RFT_ID timed out send abts */ + fdls_send_fabric_abts(iport); + } else { + /* ABTS has timed out */ + fdls_schedule_fabric_oxid_free(iport); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ABTS timed out. Starting PLOGI: %p", iport); + fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ + } + break; + case FDLS_STATE_REGISTER_FC4_FEATURES: + /* scr received a LS_RJT with busy we retry from here */ + if ((iport->fabric.flags & FNIC_FDLS_RETRY_FRAME) + && (iport->fabric.retry_counter < FDLS_RETRY_COUNT)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME; + fdls_send_register_fc4_features(iport); + } else if (!(iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) + /* SCR has timed out. Send abts */ + fdls_send_fabric_abts(iport); + else { + /* ABTS has timed out */ + fdls_schedule_fabric_oxid_free(iport); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ABTS timed out. Starting PLOGI %p", iport); + fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ + } + break; + case FDLS_STATE_RSCN_GPN_FT: + case FDLS_STATE_SEND_GPNFT: + case FDLS_STATE_GPN_FT: + /* GPN_FT received a LS_RJT with busy we retry from here */ + if ((iport->fabric.flags & FNIC_FDLS_RETRY_FRAME) + && (iport->fabric.retry_counter < FDLS_RETRY_COUNT)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME; + fdls_send_gpn_ft(iport, iport->fabric.state); + } else if (!(iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) { + /* gpn_ft has timed out. Send abts */ + fdls_send_fabric_abts(iport); + } else { + /* ABTS has timed out */ + fdls_schedule_fabric_oxid_free(iport); + if (iport->fabric.retry_counter < FDLS_RETRY_COUNT) { + fdls_send_gpn_ft(iport, iport->fabric.state); + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ABTS timeout for fabric GPN_FT. Check name server: %p", + iport); + } + } + break; + default: + break; + } + spin_unlock_irqrestore(&fnic->fnic_lock, flags); +} + +static void fdls_send_delete_tport_msg(struct fnic_tport_s *tport) +{ + struct fnic_iport_s *iport = (struct fnic_iport_s *) tport->iport; + struct fnic *fnic = iport->fnic; + struct fnic_tport_event_s *tport_del_evt; + + if (!IS_FNIC_FCP_INITIATOR(fnic)) + return; + + tport_del_evt = kzalloc(sizeof(struct fnic_tport_event_s), GFP_ATOMIC); + if (!tport_del_evt) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate memory for tport event fcid: 0x%x", + tport->fcid); + return; + } + tport_del_evt->event = TGT_EV_TPORT_DELETE; + tport_del_evt->arg1 = (void *) tport; + list_add_tail(&tport_del_evt->links, &fnic->tport_event_list); + queue_work(fnic_event_queue, &fnic->tport_work); +} + +static void fdls_tport_timer_callback(struct timer_list *t) +{ + struct fnic_tport_s *tport = from_timer(tport, t, retry_timer); + struct fnic_iport_s *iport = (struct fnic_iport_s *) tport->iport; + struct fnic *fnic = iport->fnic; + uint16_t oxid; + unsigned long flags; + + spin_lock_irqsave(&fnic->fnic_lock, flags); + if (!tport->timer_pending) { + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + return; + } + + if (iport->state != FNIC_IPORT_STATE_READY) { + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + return; + } + + if (tport->del_timer_inprogress) { + tport->del_timer_inprogress = 0; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport_del_timer inprogress. Skip timer cb tport fcid: 0x%x\n", + tport->fcid); + return; + } + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid: 0x%x timer pending: %d state: %d retry counter: %d", + tport->fcid, tport->timer_pending, tport->state, + tport->retry_counter); + + tport->timer_pending = 0; + oxid = ntohs(tport->oxid_used); + + /* We retry plogi/prli/adisc frames depending on the tport state */ + switch (tport->state) { + case FDLS_TGT_STATE_PLOGI: + /* PLOGI frame received a LS_RJT with busy, we retry from here */ + if ((tport->flags & FNIC_FDLS_RETRY_FRAME) + && (tport->retry_counter < iport->max_plogi_retries)) { + tport->flags &= ~FNIC_FDLS_RETRY_FRAME; + fdls_send_tgt_plogi(iport, tport); + } else if (!(tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { + /* Plogi frame has timed out, send abts */ + fdls_send_tport_abts(iport, tport); + } else if (tport->retry_counter < iport->max_plogi_retries) { + /* + * ABTS has timed out + */ + fdls_schedule_tgt_oxid_free(iport, + &iport->plogi_oxid_pool, + oxid); + fdls_send_tgt_plogi(iport, tport); + } else { + /* exceeded plogi retry count */ + fdls_schedule_tgt_oxid_free(iport, + &iport->plogi_oxid_pool, + oxid); + fdls_send_delete_tport_msg(tport); + } + break; + case FDLS_TGT_STATE_PRLI: + /* PRLI received a LS_RJT with busy , hence we retry from here */ + if ((tport->flags & FNIC_FDLS_RETRY_FRAME) + && (tport->retry_counter < FDLS_RETRY_COUNT)) { + tport->flags &= ~FNIC_FDLS_RETRY_FRAME; + fdls_send_tgt_prli(iport, tport); + } else if (!(tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { + /* PRLI has time out, send abts */ + fdls_send_tport_abts(iport, tport); + } else { + /* ABTS has timed out for prli, we go back to PLOGI */ + fdls_schedule_tgt_oxid_free(iport, + &iport->prli_oxid_pool, + oxid); + fdls_send_tgt_plogi(iport, tport); + fdls_set_tport_state(tport, FDLS_TGT_STATE_PLOGI); + } + break; + case FDLS_TGT_STATE_ADISC: + /* ADISC timed out send an ABTS */ + if (!(tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { + fdls_send_tport_abts(iport, tport); + } else if ((tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED) + && (tport->retry_counter < FDLS_RETRY_COUNT)) { + /* + * ABTS has timed out + */ + fdls_schedule_tgt_oxid_free(iport, + &iport->adisc_oxid_pool, + oxid); + fdls_send_tgt_adisc(iport, tport); + } else { + /* exceeded retry count */ + fdls_schedule_tgt_oxid_free(iport, + &iport->adisc_oxid_pool, + oxid); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ADISC not responding. Deleting target port: 0x%x", + tport->fcid); + fdls_send_delete_tport_msg(tport); + } + break; + default: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Unknown tport state: 0x%x", tport->state); + break; + } + spin_unlock_irqrestore(&fnic->fnic_lock, flags); +} + +static void fnic_fdls_start_flogi(struct fnic_iport_s *iport) +{ + iport->fabric.retry_counter = 0; + fdls_send_fabric_flogi(iport); + fdls_set_state((&iport->fabric), FDLS_STATE_FABRIC_FLOGI); + iport->fabric.flags = 0; +} + +static void fnic_fdls_start_plogi(struct fnic_iport_s *iport) +{ + iport->fabric.retry_counter = 0; + fdls_send_fabric_plogi(iport); + fdls_set_state((&iport->fabric), FDLS_STATE_FABRIC_PLOGI); + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; +} + +static void +fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr) +{ + uint32_t tgt_fcid; + struct fnic_tport_s *tport; + uint8_t *fcid; + uint64_t frame_wwnn; + uint64_t frame_wwpn; + uint16_t oxid; + struct fc_std_els_adisc *adisc_rsp = (struct fc_std_els_adisc *)fchdr; + struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; + struct fnic *fnic = iport->fnic; + + fcid = FNIC_STD_GET_S_ID(fchdr); + tgt_fcid = ntoh24(fcid); + tport = fnic_find_tport_by_fcid(iport, tgt_fcid); + + if (!tport) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Tgt ADISC response tport not found: 0x%x", tgt_fcid); + return; + } + if ((iport->state != FNIC_IPORT_STATE_READY) + || (tport->state != FDLS_TGT_STATE_ADISC) + || (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping this ADISC response"); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "iport state: %d tport state: %d Is abort issued on PRLI? %d", + iport->state, tport->state, + (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)); + return; + } + if (ntohs(fchdr->fh_ox_id) != ntohs(tport->oxid_used)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping frame from target: 0x%x", + tgt_fcid); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Reason: Stale ADISC/Aborted ADISC/OOO frame delivery"); + return; + } + + oxid = ntohs(FNIC_STD_GET_OX_ID(fchdr)); + fdls_free_tgt_oxid(iport, &iport->adisc_oxid_pool, oxid); + + switch (adisc_rsp->els.adisc_cmd) { + case ELS_LS_ACC: + if (tport->timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport 0x%p Canceling fabric disc timer\n", + tport); + fnic_del_tport_timer_sync(fnic, tport); + } + tport->timer_pending = 0; + tport->retry_counter = 0; + frame_wwnn = get_unaligned_be64(&adisc_rsp->els.adisc_wwnn); + frame_wwpn = get_unaligned_be64(&adisc_rsp->els.adisc_wwpn); + if ((frame_wwnn == tport->wwnn) && (frame_wwpn == tport->wwpn)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ADISC accepted from target: 0x%x. Target logged in", + tgt_fcid); + fdls_set_tport_state(tport, FDLS_TGT_STATE_READY); + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Error mismatch frame: ADISC"); + } + break; + + case ELS_LS_RJT: + if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) + || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) + && (tport->retry_counter < FDLS_RETRY_COUNT)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ADISC ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x", + tgt_fcid); + + /* Retry ADISC again from the timer routine. */ + tport->flags |= FNIC_FDLS_RETRY_FRAME; + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "ADISC returned ELS_LS_RJT from target: 0x%x", + tgt_fcid); + fdls_delete_tport(iport, tport); + } + break; + } +} + + +static void +fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr) +{ + uint32_t tgt_fcid; + struct fnic_tport_s *tport; + uint8_t *fcid; + uint16_t oxid; + struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *)fchdr; + struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; + int max_payload_size; + struct fnic *fnic = iport->fnic; + + fcid = FNIC_STD_GET_S_ID(fchdr); + tgt_fcid = ntoh24(fcid); + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS processing target PLOGI response: tgt_fcid: 0x%x", + tgt_fcid); + + tport = fnic_find_tport_by_fcid(iport, tgt_fcid); + if (!tport) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport not found: 0x%x", tgt_fcid); + return; + } + if ((iport->state != FNIC_IPORT_STATE_READY) + || (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping frame! iport state: %d tport state: %d", + iport->state, tport->state); + return; + } + + if (tport->state != FDLS_TGT_STATE_PLOGI) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI rsp recvd in wrong state. Drop the frame and restart nexus"); + fdls_target_restart_nexus(tport); + return; + } + + if (fchdr->fh_ox_id != tport->oxid_used) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI response from target: 0x%x. Dropping frame", + tgt_fcid); + return; + } + + oxid = ntohs(FNIC_STD_GET_OX_ID(fchdr)); + fdls_free_tgt_oxid(iport, &iport->plogi_oxid_pool, oxid); + + switch (plogi_rsp->els.fl_cmd) { + case ELS_LS_ACC: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI accepted by target: 0x%x", tgt_fcid); + break; + + case ELS_LS_RJT: + if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) + || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) + && (tport->retry_counter < iport->max_plogi_retries)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x", + tgt_fcid); + /* Retry plogi again from the timer routine. */ + tport->flags |= FNIC_FDLS_RETRY_FRAME; + return; + } + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI returned ELS_LS_RJT from target: 0x%x", + tgt_fcid); + fdls_delete_tport(iport, tport); + return; + + default: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI not accepted from target fcid: 0x%x", + tgt_fcid); + return; + } + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Found the PLOGI target: 0x%x and state: %d", + (unsigned int) tgt_fcid, tport->state); + + if (tport->timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid 0x%x: Canceling disc timer\n", + tport->fcid); + fnic_del_tport_timer_sync(fnic, tport); + } + + tport->timer_pending = 0; + tport->wwpn = get_unaligned_be64(&FNIC_LOGI_PORT_NAME(&plogi_rsp->els)); + tport->wwnn = get_unaligned_be64(&FNIC_LOGI_NODE_NAME(&plogi_rsp->els)); + + /* Learn the Service Params */ + + /* Max frame size - choose the lowest */ + max_payload_size = fnic_fc_plogi_rsp_rdf(iport, plogi_rsp); + tport->max_payload_size = + MIN(max_payload_size, iport->max_payload_size); + + if (tport->max_payload_size < FNIC_MIN_DATA_FIELD_SIZE) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "MFS: tport max frame size below spec bounds: %d", + tport->max_payload_size); + tport->max_payload_size = FNIC_MIN_DATA_FIELD_SIZE; + } + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "MAX frame size: %d iport max_payload_size: %d tport mfs: %d", + max_payload_size, iport->max_payload_size, + tport->max_payload_size); + + tport->max_concur_seqs = FNIC_FC_PLOGI_RSP_CONCUR_SEQ(plogi_rsp); + + tport->retry_counter = 0; + fdls_set_tport_state(tport, FDLS_TGT_STATE_PRLI); + fdls_send_tgt_prli(iport, tport); +} + +static void +fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr) +{ + uint32_t tgt_fcid; + struct fnic_tport_s *tport; + uint8_t *fcid; + uint16_t oxid; + struct fc_std_els_prli *prli_rsp = (struct fc_std_els_prli *)fchdr; + struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; + struct fnic_tport_event_s *tport_add_evt; + struct fnic *fnic = iport->fnic; + bool mismatched_tgt = false; + + fcid = FNIC_STD_GET_S_ID(fchdr); + tgt_fcid = ntoh24(fcid); + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS process tgt PRLI response: 0x%x", tgt_fcid); + + tport = fnic_find_tport_by_fcid(iport, tgt_fcid); + if (!tport) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport not found: 0x%x", tgt_fcid); + /* Handle or just drop? */ + return; + } + + if ((iport->state != FNIC_IPORT_STATE_READY) + || (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping frame! iport st: %d tport st: %d tport fcid: 0x%x", + iport->state, tport->state, tport->fcid); + return; + } + + if (tport->state != FDLS_TGT_STATE_PRLI) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PRLI rsp recvd in wrong state. Drop frame. Restarting nexus"); + fdls_target_restart_nexus(tport); + return; + } + + if (fchdr->fh_ox_id != tport->oxid_used) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping PRLI response from target: 0x%x ", + tgt_fcid); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Reason: Stale PRLI response/Aborted PDISC/OOO frame delivery"); + return; + } + + oxid = ntohs(FNIC_STD_GET_OX_ID(fchdr)); + fdls_free_tgt_oxid(iport, &iport->prli_oxid_pool, oxid); + + switch (prli_rsp->els_prli.prli_cmd) { + case ELS_LS_ACC: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PRLI accepted from target: 0x%x", tgt_fcid); + + if (prli_rsp->sp.spp_type != FC_FC4_TYPE_SCSI) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "mismatched target zoned with FC SCSI initiator: 0x%x", + tgt_fcid); + mismatched_tgt = true; } - break; - case FDLS_STATE_REGISTER_FC4_TYPES: - /* scr received a LS_RJT with busy we retry from here */ - if ((iport->fabric.flags & FNIC_FDLS_RETRY_FRAME) - && (iport->fabric.retry_counter < FDLS_RETRY_COUNT)) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME; - fdls_send_register_fc4_types(iport); - } else if (!(iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) { - /* RFT_ID timed out send abts */ - fdls_send_fabric_abts(iport); - } else { - /* ABTS has timed out */ - fdls_schedule_fabric_oxid_free(iport); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "ABTS timed out. Starting PLOGI: %p", iport); - fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ + if (mismatched_tgt) { + fdls_tgt_logout(iport, tport); + fdls_delete_tport(iport, tport); + return; } break; - case FDLS_STATE_REGISTER_FC4_FEATURES: - /* scr received a LS_RJT with busy we retry from here */ - if ((iport->fabric.flags & FNIC_FDLS_RETRY_FRAME) - && (iport->fabric.retry_counter < FDLS_RETRY_COUNT)) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME; - fdls_send_register_fc4_features(iport); - } else if (!(iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) - /* SCR has timed out. Send abts */ - fdls_send_fabric_abts(iport); - else { - /* ABTS has timed out */ - fdls_schedule_fabric_oxid_free(iport); + case ELS_LS_RJT: + if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) + || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) + && (tport->retry_counter < FDLS_RETRY_COUNT)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "ABTS timed out. Starting PLOGI %p", iport); - fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ - } - break; - case FDLS_STATE_RSCN_GPN_FT: - case FDLS_STATE_SEND_GPNFT: - case FDLS_STATE_GPN_FT: - /* GPN_FT received a LS_RJT with busy we retry from here */ - if ((iport->fabric.flags & FNIC_FDLS_RETRY_FRAME) - && (iport->fabric.retry_counter < FDLS_RETRY_COUNT)) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME; - fdls_send_gpn_ft(iport, iport->fabric.state); - } else if (!(iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) { - /* gpn_ft has timed out. Send abts */ - fdls_send_fabric_abts(iport); + "PRLI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x", + tgt_fcid); + + /*Retry Plogi again from the timer routine. */ + tport->flags |= FNIC_FDLS_RETRY_FRAME; + return; } else { - /* ABTS has timed out */ - fdls_schedule_fabric_oxid_free(iport); - if (iport->fabric.retry_counter < FDLS_RETRY_COUNT) { - fdls_send_gpn_ft(iport, iport->fabric.state); - } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "ABTS timeout for fabric GPN_FT. Check name server: %p", - iport); - } + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PRLI returned ELS_LS_RJT from target: 0x%x", + tgt_fcid); + + fdls_tgt_logout(iport, tport); + fdls_delete_tport(iport, tport); + return; } break; + default: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PRLI not accepted from target: 0x%x", tgt_fcid); + return; break; } - spin_unlock_irqrestore(&fnic->fnic_lock, flags); -} -static void fnic_fdls_start_flogi(struct fnic_iport_s *iport) -{ - iport->fabric.retry_counter = 0; - fdls_send_fabric_flogi(iport); - fdls_set_state((&iport->fabric), FDLS_STATE_FABRIC_FLOGI); - iport->fabric.flags = 0; -} + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Found the PRLI target: 0x%x and state: %d", + (unsigned int) tgt_fcid, tport->state); -static void fnic_fdls_start_plogi(struct fnic_iport_s *iport) -{ - iport->fabric.retry_counter = 0; - fdls_send_fabric_plogi(iport); - fdls_set_state((&iport->fabric), FDLS_STATE_FABRIC_PLOGI); - iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; + if (tport->timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport fcid 0x%x: Canceling disc timer\n", + tport->fcid); + fnic_del_tport_timer_sync(fnic, tport); + } + tport->timer_pending = 0; + + /* Learn Service Params */ + tport->fcp_csp = be32_to_cpu(prli_rsp->sp.spp_params); + tport->retry_counter = 0; + + if (prli_rsp->sp.spp_params & FCP_SPPF_RETRY) + tport->tgt_flags |= FNIC_FC_RP_FLAGS_RETRY; + + /* Check if the device plays Target Mode Function */ + if (!(tport->fcp_csp & FCP_PRLI_FUNC_TARGET)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Remote port(0x%x): no target support. Deleting it\n", + tgt_fcid); + fdls_tgt_logout(iport, tport); + fdls_delete_tport(iport, tport); + return; + } + + fdls_set_tport_state(tport, FDLS_TGT_STATE_READY); + + /* Inform the driver about new target added */ + tport_add_evt = kzalloc(sizeof(struct fnic_tport_event_s), GFP_ATOMIC); + if (!tport_add_evt) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport event memory allocation failure: 0x%0x\n", + tport->fcid); + return; + } + tport_add_evt->event = TGT_EV_RPORT_ADD; + tport_add_evt->arg1 = (void *) tport; + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "iport fcid: 0x%x add tport event fcid: 0x%x\n", + tport->fcid, iport->fcid); + list_add_tail(&tport_add_evt->links, &fnic->tport_event_list); + queue_work(fnic_event_queue, &fnic->tport_work); } + static void fdls_process_rff_id_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) @@ -1177,7 +2244,8 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, iport); if (iport->fabric.timer_pending) { FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "Canceling fabric disc timer %p\n", iport); + "Canceling fabric disc timer %p\n", + iport); fnic_del_fabric_timer_sync(fnic); } fdls->timer_pending = 0; @@ -1190,6 +2258,104 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr, int len) +{ + struct fc_gpn_ft_rsp_iu *gpn_ft_tgt; + struct fnic_tport_s *tport, *next; + uint32_t fcid; + uint64_t wwpn; + int rem_len = len; + u32 old_link_down_cnt = iport->fnic->link_down_cnt; + struct fnic *fnic = iport->fnic; + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: FDLS process GPN_FT tgt list", iport->fcid); + + gpn_ft_tgt = + (struct fc_gpn_ft_rsp_iu *)((uint8_t *) fchdr + + sizeof(struct fc_frame_header) + + sizeof(struct fc_ct_hdr)); + len -= sizeof(struct fc_frame_header) + sizeof(struct fc_ct_hdr); + + while (rem_len > 0) { + + fcid = ntoh24(gpn_ft_tgt->fcid); + wwpn = ntohll(gpn_ft_tgt->wwpn); + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "tport: 0x%x: ctrl:0x%x", fcid, gpn_ft_tgt->ctrl); + + if (fcid == iport->fcid) { + if (gpn_ft_tgt->ctrl & FNIC_FC_GPN_LAST_ENTRY) + break; + gpn_ft_tgt++; + rem_len -= sizeof(struct fc_gpn_ft_rsp_iu); + continue; + } + + tport = fnic_find_tport_by_wwpn(iport, wwpn); + if (!tport) { + /* + * New port registered with the switch or first time query + */ + tport = fdls_create_tport(iport, fcid, wwpn); + if (!tport) + return; + } + /* + * check if this was an existing tport with same fcid + * but whose wwpn has changed now ,then remove it and + * create a new one + */ + if (tport->fcid != fcid) { + fdls_delete_tport(iport, tport); + tport = fdls_create_tport(iport, fcid, wwpn); + if (!tport) + return; + } + + /* + * If this GPN_FT rsp is after RSCN then mark the tports which + * matches with the new GPN_FT list, if some tport is not + * found in GPN_FT we went to delete that tport later. + */ + if (fdls_get_state((&iport->fabric)) == FDLS_STATE_RSCN_GPN_FT) + tport->flags |= FNIC_FDLS_TPORT_IN_GPN_FT_LIST; + + if (gpn_ft_tgt->ctrl & FNIC_FC_GPN_LAST_ENTRY) + break; + + gpn_ft_tgt++; + rem_len -= sizeof(struct fc_gpn_ft_rsp_iu); + } + if (rem_len <= 0) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "GPN_FT response: malformed/corrupt frame rxlen: %d remlen: %d", + len, rem_len); + } + + /*remove those ports which was not listed in GPN_FT */ + if (fdls_get_state((&iport->fabric)) == FDLS_STATE_RSCN_GPN_FT) { + list_for_each_entry_safe(tport, next, &iport->tport_list, links) { + + if (!(tport->flags & FNIC_FDLS_TPORT_IN_GPN_FT_LIST)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Remove port: 0x%x not found in GPN_FT list", + tport->fcid); + fdls_delete_tport(iport, tport); + } else { + tport->flags &= ~FNIC_FDLS_TPORT_IN_GPN_FT_LIST; + } + if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state != FNIC_IPORT_STATE_READY)) { + return; + } + } + } +} + static void fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr, int len) @@ -1198,6 +2364,9 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, struct fc_std_gpn_ft *gpn_ft_rsp = (struct fc_std_gpn_ft *) fchdr; uint16_t rsp; uint8_t reason_code; + int count = 0; + struct fnic_tport_s *tport, *next; + u32 old_link_down_cnt = iport->fnic->link_down_cnt; struct fnic *fnic = iport->fnic; FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, @@ -1237,12 +2406,74 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, case FC_FS_ACC: FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, "0x%x: GPNFT_RSP accept", iport->fcid); + if (iport->fabric.timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: Canceling fabric disc timer\n", + iport->fcid); + fnic_del_fabric_timer_sync(fnic); + } + iport->fabric.timer_pending = 0; + iport->fabric.retry_counter = 0; + fdls_process_gpn_ft_tgt_list(iport, fchdr, len); + + /* + * iport state can change only if link down event happened + * We don't need to undo fdls_process_gpn_ft_tgt_list, + * that will be taken care in next link up event + */ + if (iport->state != FNIC_IPORT_STATE_READY) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Halting target discovery: fab st: %d iport st: %d ", + fdls_get_state(fdls), iport->state); + break; + } + fdls_tgt_discovery_start(iport); break; case FC_FS_RJT: reason_code = gpn_ft_rsp->fc_std_ct_hdr.ct_reason; FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, "0x%x: GPNFT_RSP Reject reason: %d", iport->fcid, reason_code); + + if (((reason_code == FC_FS_RJT_BSY) + || (reason_code == FC_FS_RJT_UNABL)) + && (fdls->retry_counter < FDLS_RETRY_COUNT)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: GPNFT_RSP ret REJ/BSY. Retry from timer routine", + iport->fcid); + /* Retry again from the timer routine */ + fdls->flags |= FNIC_FDLS_RETRY_FRAME; + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: GPNFT_RSP reject", iport->fcid); + if (iport->fabric.timer_pending) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: Canceling fabric disc timer\n", + iport->fcid); + fnic_del_fabric_timer_sync(fnic); + } + iport->fabric.timer_pending = 0; + iport->fabric.retry_counter = 0; + /* + * If GPN_FT ls_rjt then we should delete + * all existing tports + */ + count = 0; + list_for_each_entry_safe(tport, next, &iport->tport_list, + links) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "GPN_FT_REJECT: Remove port: 0x%x", + tport->fcid); + fdls_delete_tport(iport, tport); + if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state != FNIC_IPORT_STATE_READY)) { + return; + } + count++; + } + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "GPN_FT_REJECT: Removed (0x%x) ports", count); + } break; default: @@ -1492,8 +2723,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) { uint32_t s_id; - struct fc_std_abts_ba_acc *ba_acc = - (struct fc_std_abts_ba_acc *) fchdr; + struct fc_std_abts_ba_acc *ba_acc = (struct fc_std_abts_ba_acc *)fchdr; struct fc_std_abts_ba_rjt *ba_rjt; uint32_t fabric_state = iport->fabric.state; struct fnic *fnic = iport->fnic; @@ -1658,6 +2888,148 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr) +{ + uint32_t s_id; + struct fnic_tport_s *tport; + uint32_t tport_state; + struct fc_std_abts_ba_acc *ba_acc; + struct fc_std_abts_ba_rjt *ba_rjt; + uint16_t oxid; + struct fnic *fnic = iport->fnic; + + s_id = ntoh24(fchdr->fh_s_id); + ba_acc = (struct fc_std_abts_ba_acc *)fchdr; + ba_rjt = (struct fc_std_abts_ba_rjt *)fchdr; + + tport = fnic_find_tport_by_fcid(iport, s_id); + if (!tport) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Received tgt abts rsp with invalid SID: 0x%x", s_id); + return; + } + + if (tport->timer_pending) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "tport 0x%p Canceling fabric disc timer\n", tport); + fnic_del_tport_timer_sync(fnic, tport); + } + if (iport->state != FNIC_IPORT_STATE_READY) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Received tgt abts rsp in iport state(%d). Dropping.", + iport->state); + return; + } + tport->timer_pending = 0; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED; + tport_state = tport->state; + oxid = ntohs(fchdr->fh_ox_id); + + /*This abort rsp is for ADISC */ + if ((oxid >= FDLS_ADISC_OXID_BASE) && (oxid < FDLS_TGT_OXID_POOL_END)) { + if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "OX_ID: 0x%x tgt_fcid: 0x%x rcvd tgt adisc abts resp BA_ACC", + be16_to_cpu(ba_acc->acc.ba_ox_id), + tport->fcid); + } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "ADISC BA_RJT rcvd tport_fcid: 0x%x tport_state: %d ", + tport->fcid, tport_state); + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "reason code: 0x%x reason code explanation:0x%x ", + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } + if ((tport->retry_counter < FDLS_RETRY_COUNT) + && (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL)) { + fdls_free_tgt_oxid(iport, &iport->adisc_oxid_pool, + oxid); + fdls_send_tgt_adisc(iport, tport); + return; + } + + fdls_free_tgt_oxid(iport, &iport->adisc_oxid_pool, oxid); + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "ADISC not responding. Deleting target port: 0x%x", + tport->fcid); + fdls_delete_tport(iport, tport); + if ((iport->state == FNIC_IPORT_STATE_READY) + && (iport->fabric.state != FDLS_STATE_SEND_GPNFT) + && (iport->fabric.state != FDLS_STATE_RSCN_GPN_FT)) { + fdls_send_gpn_ft(iport, FDLS_STATE_SEND_GPNFT); + } + /*Restart a discovery of targets */ + return; + } + + /*This abort rsp is for PLOGI */ + if ((oxid >= FDLS_PLOGI_OXID_BASE) && (oxid < FDLS_PRLI_OXID_BASE)) { + if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Received tgt PLOGI abts response BA_ACC tgt_fcid: 0x%x", + tport->fcid); + } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PLOGI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x", + tport->fcid, fchdr->fh_ox_id); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "reason code: 0x%x reason code explanation: 0x%x", + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } + if ((tport->retry_counter < iport->max_plogi_retries) + && (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL)) { + fdls_free_tgt_oxid(iport, &iport->plogi_oxid_pool, + oxid); + fdls_send_tgt_plogi(iport, tport); + return; + } + + fdls_free_tgt_oxid(iport, &iport->plogi_oxid_pool, oxid); + fdls_delete_tport(iport, tport); + /*Restart a discovery of targets */ + if ((iport->state == FNIC_IPORT_STATE_READY) + && (iport->fabric.state != FDLS_STATE_SEND_GPNFT) + && (iport->fabric.state != FDLS_STATE_RSCN_GPN_FT)) { + fdls_send_gpn_ft(iport, FDLS_STATE_SEND_GPNFT); + } + return; + } + + /*This abort rsp is for PRLI */ + if ((oxid >= FDLS_PRLI_OXID_BASE) && (oxid < FDLS_ADISC_OXID_BASE)) { + if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "0x%x: Received tgt PRLI abts response BA_ACC", + tport->fcid); + } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "PRLI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x ", + tport->fcid, fchdr->fh_ox_id); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "reason code: 0x%x reason code explanation: 0x%x", + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } + if ((tport->retry_counter < FDLS_RETRY_COUNT) + && (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL)) { + fdls_free_tgt_oxid(iport, &iport->prli_oxid_pool, oxid); + fdls_send_tgt_prli(iport, tport); + return; + } + fdls_free_tgt_oxid(iport, &iport->prli_oxid_pool, oxid); + fdls_send_tgt_plogi(iport, tport); /* go back to plogi */ + fdls_set_tport_state(tport, FDLS_TGT_STATE_PLOGI); + return; + } + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Received ABTS response for unknown frame %p", iport); +} + /* * Performs a validation for all FCOE frames and return the frame type */ @@ -1755,6 +3127,39 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, } } + /* ELS response from a target */ + if ((ntohs(oxid) >= FDLS_PLOGI_OXID_BASE) + && (ntohs(oxid) < FDLS_PRLI_OXID_BASE)) { + if (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping Unknown frame in PLOGI exchange range type: 0x%x.", + fchdr->fh_type); + return -1; + } + return FNIC_TPORT_PLOGI_RSP; + } + if ((ntohs(oxid) >= FDLS_PRLI_OXID_BASE) + && (ntohs(oxid) < FDLS_ADISC_OXID_BASE)) { + if (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping Unknown frame in PRLI exchange range type: 0x%x.", + fchdr->fh_type); + return -1; + } + return FNIC_TPORT_PRLI_RSP; + } + + if ((ntohs(oxid) >= FDLS_ADISC_OXID_BASE) + && (ntohs(oxid) < FDLS_TGT_OXID_POOL_END)) { + if (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Dropping Unknown frame in ADISC exchange range type: 0x%x.", + fchdr->fh_type); + return -1; + } + return FNIC_TPORT_ADISC_RSP; + } + /*response from fabric */ rsp_type = fnic_fdls_expected_rsp(iport, ntohs(oxid)); @@ -1883,6 +3288,21 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, case FNIC_FABRIC_GPN_FT_RSP: fdls_process_gpn_ft_rsp(iport, fchdr, len); break; + case FNIC_TPORT_PLOGI_RSP: + fdls_process_tgt_plogi_rsp(iport, fchdr); + break; + case FNIC_TPORT_PRLI_RSP: + fdls_process_tgt_prli_rsp(iport, fchdr); + break; + case FNIC_TPORT_ADISC_RSP: + fdls_process_tgt_adisc_rsp(iport, fchdr); + break; + case FNIC_TPORT_LOGO_RSP: + /* Logo response from tgt which we have deleted */ + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Logo response from tgt: 0x%x", + ntoh24(fchdr->fh_s_id)); + break; case FNIC_FABRIC_LOGO_RSP: fdls_process_fabric_logo_rsp(iport, fchdr); break; @@ -1892,7 +3312,8 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, if (fdls_is_oxid_in_fabric_range(oxid) && (iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) { fdls_process_fabric_abts_rsp(iport, fchdr); - } + } else + fdls_process_tgt_abts_rsp(iport, fchdr); break; default: FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index 2d5f438f2cc4..92cd17efa40f 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -79,6 +79,9 @@ #define IS_FNIC_FCP_INITIATOR(fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +/* Retry supported by rport (returned by PRLI service parameters) */ +#define FNIC_FC_RP_FLAGS_RETRY 0x1 + /* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. @@ -133,6 +136,7 @@ static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd) extern unsigned int fnic_log_level; extern unsigned int io_completions; +extern struct workqueue_struct *fnic_event_queue; #define FNIC_MAIN_LOGGING 0x01 #define FNIC_FCS_LOGGING 0x02 @@ -329,6 +333,8 @@ struct fnic { struct work_struct flush_work; struct sk_buff_head frame_queue; struct list_head tx_queue; + struct work_struct tport_work; + struct list_head tport_event_list; /*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *, u16 vlan); diff --git a/drivers/scsi/fnic/fnic_fdls.h b/drivers/scsi/fnic/fnic_fdls.h index f53c1d8dbe7e..108452f6852d 100644 --- a/drivers/scsi/fnic/fnic_fdls.h +++ b/drivers/scsi/fnic/fnic_fdls.h @@ -385,7 +385,7 @@ int fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, void *rx_frame, int len, int fchdr_offset); void fdls_send_tport_abts(struct fnic_iport_s *iport, - struct fnic_tport_s *tport); + struct fnic_tport_s *tport); bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport); void fdls_fdmi_timer_callback(struct timer_list *t); From patchwork Fri Sep 27 18:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831146 Received: from rcdn-iport-7.cisco.com (rcdn-iport-7.cisco.com [173.37.86.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEF38136E28; Fri, 27 Sep 2024 18:50:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463058; cv=none; b=Tq4ppoxBMlqwndqpMiCq5lOsO2R48e2jkPh30g+3UHaYYX3mWdP7s8iP6MMvZkqjUf9nXaynOCac1bonApaWYKJHk0oZed+vz0wLah8VviSo84iwv8O1k8CtL4YIf+BmTGZOZ7O4/YzQd5zVoyaxJBSnLz4yJ7H/GMbcbm2jvyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463058; c=relaxed/simple; bh=rbPCCRFZf7Ku38tW3bT36SPIiUB60gLAFTEo4Y8Gmnk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c6AN0v8Yg95SyWiBJttQYsymyeXKgTge3IMS6MVfYUCBMZz1uS6wZbixJIPC2sJcMDIPvFZQCLlRtmT5shjmcNH/wMPqietQy0iIVI05od+N+hfblX5+0RAH5pppVaY8LHRbSYva2w15NEGYQ97fiDOR84aUMPRRCW1oWrHBGO0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=YvcpQ1VL; arc=none smtp.client-ip=173.37.86.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="YvcpQ1VL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=33856; q=dns/txt; s=iport; t=1727463056; x=1728672656; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jqGullCTbBI7u33pLGVHkMIff2gBJyHRHPEPwtupdzs=; b=YvcpQ1VLXiSlsyyPAkyT7e/iJD/5/ZzZwft542DSTL/f43CFMaN4Zif8 VV050+x4JarJKAiZ1X2W8tkG90ujivAi1r2nrExN3B2ct9nulvkLq5rQT 7Us8Yuoo6902mUWwRDgDn5WhZhOWASAqK4/0/ohrUI4IO7BGpals5vCsn I=; X-CSE-ConnectionGUID: KhmDbP0lR7yMdsCf0SnYWg== X-CSE-MsgGUID: 82QNqEuAT5GWZQOBQJM30Q== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="266827746" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-7.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:50:49 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQan022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:50:48 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar , kernel test robot Subject: [PATCH v3 06/14] scsi: fnic: Add and integrate support for FDMI Date: Fri, 27 Sep 2024 11:46:05 -0700 Message-Id: <20240927184613.52172-7-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Add support for Fabric-Device Management Interface (FDMI) by introducing PCI device IDs for Cisco Hardware. Introduce a module parameter to enable/disable FDMI support. Integrate support for FDMI. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202406110734.p2v8dq9v-lkp @intel.com/ Reviewed-by: Sesidhar Baddela Signed-off-by: Gian Carlo Boffa Signed-off-by: Arulprabhu Ponnusamy Signed-off-by: Arun Easi Signed-off-by: Karan Tilak Kumar --- Changes between v2 and v3: Incorporate review comments from Hannes: Replace redundant definitions with standard definitions. Changes between v1 and v2: Incorporate review comments from Hannes from other patches: Replace pr_info with dev_info. Replace htonll() with get_unaligned_be64(). Replace definitions with standard definitions from fc_els.h. Use standard definitions from scsi_transport_fc.h for port speeds. Refactor definitions in struct fnic to avoid cache holes. Replace memcmp with not equal to operator. Fix warning from kernel test robot: Remove version.h --- drivers/scsi/fnic/Makefile | 3 +- drivers/scsi/fnic/fdls_disc.c | 469 ++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 72 ++++ drivers/scsi/fnic/fnic_fdls.h | 1 - drivers/scsi/fnic/fnic_main.c | 26 ++ drivers/scsi/fnic/fnic_pci_subsys_devid.c | 131 ++++++ 6 files changed, 700 insertions(+), 2 deletions(-) create mode 100644 drivers/scsi/fnic/fnic_pci_subsys_devid.c diff --git a/drivers/scsi/fnic/Makefile b/drivers/scsi/fnic/Makefile index 3bd6b1c8b643..af156c69da0c 100644 --- a/drivers/scsi/fnic/Makefile +++ b/drivers/scsi/fnic/Makefile @@ -16,4 +16,5 @@ fnic-y := \ vnic_intr.o \ vnic_rq.o \ vnic_wq_copy.o \ - vnic_wq.o + vnic_wq.o \ + fnic_pci_subsys_devid.o diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c index 94f55e45ece9..378f287fd178 100644 --- a/drivers/scsi/fnic/fdls_disc.c +++ b/drivers/scsi/fnic/fdls_disc.c @@ -9,11 +9,23 @@ #include "fdls_fc.h" #include "fnic_fdls.h" #include +#include #include #define FC_FC4_TYPE_SCSI 0x08 +#define PORT_SPEED_BIT_8 8 +#define PORT_SPEED_BIT_9 9 +#define PORT_SPEED_BIT_14 14 +#define PORT_SPEED_BIT_15 15 static void fdls_send_rpn_id(struct fnic_iport_s *iport); +static void fdls_fdmi_register_hba(struct fnic_iport_s *iport); +static void fdls_fdmi_register_pa(struct fnic_iport_s *iport); +#define FDLS_FDMI_PLOGI_PENDING 0x1 +#define FDLS_FDMI_REG_HBA_PENDING 0x2 +#define FDLS_FDMI_RPA_PENDING 0x4 +#define FDLS_FDMI_ABORT_PENDING 0x8 +#define FDLS_FDMI_MAX_RETRY 3 /* Frame initialization */ /* @@ -84,6 +96,70 @@ struct fc_std_els_prli fnic_std_prli_req = { .spp_params = cpu_to_be32(0xA2)} }; +/* + * Variables: + * sid, port_id, port_name + */ +struct fc_std_fdmi_rhba fnic_std_fdmi_rhba = { + .fchdr = {.fh_r_ctl = FC_RCTL_DD_UNSOL_CTL, + .fh_d_id = {0xFF, 0XFF, 0XFA}, + .fh_type = FC_TYPE_CT, .fh_f_ctl = {FNIC_ELS_REQ_FCTL, 0, 0}, + .fh_rx_id = 0xFFFF}, + .fc_std_ct_hdr = {.ct_rev = FC_CT_REV, .ct_fs_type = FC_FST_MGMT, + .ct_fs_subtype = FC_FDMI_SUBTYPE, + .ct_cmd = cpu_to_be16(FC_FDMI_RHBA)}, + .num_ports = FNIC_FDMI_NUM_PORTS, + .num_hba_attributes = FNIC_FDMI_NUM_HBA_ATTRS, + .type_nn = FNIC_FDMI_TYPE_NODE_NAME, + .length_nn = FNIC_FDMI_NN_LEN, + .type_manu = FNIC_FDMI_TYPE_MANUFACTURER, + .length_manu = FNIC_FDMI_MANU_LEN, + .manufacturer = FNIC_FDMI_MANUFACTURER, + .type_serial = FNIC_FDMI_TYPE_SERIAL_NUMBER, + .length_serial = FNIC_FDMI_SERIAL_LEN, + .type_model = FNIC_FDMI_TYPE_MODEL, + .length_model = FNIC_FDMI_MODEL_LEN, + .type_model_des = FNIC_FDMI_TYPE_MODEL_DES, + .length_model_des = FNIC_FDMI_MODEL_DES_LEN, + .model_description = FNIC_FDMI_MODEL_DESCRIPTION, + .type_hw_ver = FNIC_FDMI_TYPE_HARDWARE_VERSION, + .length_hw_ver = FNIC_FDMI_HW_VER_LEN, + .type_dr_ver = FNIC_FDMI_TYPE_DRIVER_VERSION, + .length_dr_ver = FNIC_FDMI_DR_VER_LEN, + .type_rom_ver = FNIC_FDMI_TYPE_ROM_VERSION, + .length_rom_ver = FNIC_FDMI_ROM_VER_LEN, + .type_fw_ver = FNIC_FDMI_TYPE_FIRMWARE_VERSION, + .length_fw_ver = FNIC_FDMI_FW_VER_LEN, +}; + +/* + * Variables + *sid, port_id, port_name + */ +struct fc_std_fdmi_rpa fnic_std_fdmi_rpa = { + .fchdr = {.fh_r_ctl = FC_RCTL_DD_UNSOL_CTL, + .fh_d_id = {0xFF, 0xFF, 0xFA}, + .fh_type = FC_TYPE_CT, .fh_f_ctl = {FNIC_ELS_REQ_FCTL, 0, 0}, + .fh_rx_id = 0xFFFF}, + .fc_std_ct_hdr = {.ct_rev = FC_CT_REV, .ct_fs_type = FC_FST_MGMT, + .ct_fs_subtype = FC_FDMI_SUBTYPE, + .ct_cmd = cpu_to_be16(FC_FDMI_RPA)}, + .num_port_attributes = FNIC_FDMI_NUM_PORT_ATTRS, + .type_fc4 = FNIC_FDMI_TYPE_FC4_TYPES, + .length_fc4 = FNIC_FDMI_FC4_LEN, + .type_supp_speed = FNIC_FDMI_TYPE_SUPPORTED_SPEEDS, + .length_supp_speed = FNIC_FDMI_SUPP_SPEED_LEN, + .type_cur_speed = FNIC_FDMI_TYPE_CURRENT_SPEED, + .length_cur_speed = FNIC_FDMI_CUR_SPEED_LEN, + .type_max_frame_size = FNIC_FDMI_TYPE_MAX_FRAME_SIZE, + .length_max_frame_size = FNIC_FDMI_MFS_LEN, + .max_frame_size = FNIC_FDMI_MFS, + .type_os_name = FNIC_FDMI_TYPE_OS_NAME, + .length_os_name = FNIC_FDMI_OS_NAME_LEN, + .type_host_name = FNIC_FDMI_TYPE_HOST_NAME, + .length_host_name = FNIC_FDMI_HN_LEN, +}; + /* * Variables: * fh_s_id, port_id, port_name @@ -223,6 +299,7 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport); static void fdls_start_tport_timer(struct fnic_iport_s *iport, struct fnic_tport_s *tport, int timeout); static void fdls_tport_timer_callback(struct timer_list *t); +static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport); static void fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout); static void @@ -336,6 +413,15 @@ uint16_t fdls_alloc_fabric_oxid(struct fnic_iport_s *iport, * separately. */ switch (exp_rsp_type) { + case FNIC_FDMI_PLOGI_RSP: + oxid_pool->active_oxid_fdmi_plogi = oxid; + break; + case FNIC_FDMI_REG_HBA_RSP: + oxid_pool->active_oxid_fdmi_rhba = oxid; + break; + case FNIC_FDMI_RPA_RSP: + oxid_pool->active_oxid_fdmi_rpa = oxid; + break; default: oxid_pool->active_oxid_fabric_req = oxid; break; @@ -371,6 +457,21 @@ static inline void fdls_schedule_fabric_oxid_free(struct fnic_iport_s iport->fabric_oxid_pool.active_oxid_fabric_req); } +static inline void fdls_schedule_fdmi_oxid_free(struct fnic_iport_s *iport) +{ + if (iport->fabric.fdmi_pending & FDLS_FDMI_PLOGI_PENDING) + fdls_schedule_oxid_free(&iport->fdmi_oxid_pool.meta, + iport->fdmi_oxid_pool.active_oxid_fdmi_plogi); + + if (iport->fabric.fdmi_pending & FDLS_FDMI_REG_HBA_PENDING) + fdls_schedule_oxid_free(&iport->fdmi_oxid_pool.meta, + iport->fdmi_oxid_pool.active_oxid_fdmi_rhba); + + if (iport->fabric.fdmi_pending & FDLS_FDMI_RPA_PENDING) + fdls_schedule_oxid_free(&iport->fdmi_oxid_pool.meta, + iport->fdmi_oxid_pool.active_oxid_fdmi_rpa); +} + static inline void fdls_schedule_tgt_oxid_free(struct fnic_iport_s *iport, struct fnic_tgt_oxid_pool_s *oxid_pool, uint16_t oxid) @@ -405,6 +506,14 @@ static int fdls_is_oxid_in_fabric_range(uint16_t oxid) (oxid_unmasked <= FDLS_FABRIC_OXID_POOL_END)); } +static int fdls_is_oxid_in_fdmi_range(uint16_t oxid) +{ + uint16_t oxid_unmasked = FDLS_OXID_RSP_TYPE_UNMASKED(oxid); + + return ((oxid_unmasked >= FDLS_FDMI_OXID_POOL_BASE) && + (oxid_unmasked <= FDLS_FDMI_OXID_POOL_END)); +} + void fdls_init_tgt_oxid_pool(struct fnic_iport_s *iport) { memset(&iport->plogi_oxid_pool, 0, sizeof(iport->plogi_oxid_pool)); @@ -670,6 +779,42 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) iport->fabric.timer_pending = 1; } +static void fdls_send_fdmi_abts(struct fnic_iport_s *iport) +{ + uint8_t fcid[3]; + struct fc_frame_header fabric_abort = fc_std_fabric_abts; + struct fc_frame_header *fabric_abts = &fabric_abort; + struct fnic_fabric_oxid_pool_s *oxid_pool = &iport->fdmi_oxid_pool; + int fdmi_tov; + uint16_t oxid; + + hton24(fcid, 0XFFFFFA); + + if (iport->fabric.fdmi_pending & FDLS_FDMI_PLOGI_PENDING) { + oxid = htons(oxid_pool->active_oxid_fdmi_plogi); + FNIC_STD_SET_OX_ID(fabric_abts, oxid); + fnic_send_fcoe_frame(iport, fabric_abts, + sizeof(struct fc_frame_header)); + } else { + if (iport->fabric.fdmi_pending & FDLS_FDMI_REG_HBA_PENDING) { + oxid = htons(oxid_pool->active_oxid_fdmi_rhba); + FNIC_STD_SET_OX_ID(fabric_abts, oxid); + fnic_send_fcoe_frame(iport, fabric_abts, + sizeof(struct fc_frame_header)); + } + if (iport->fabric.fdmi_pending & FDLS_FDMI_RPA_PENDING) { + oxid = htons(oxid_pool->active_oxid_fdmi_rpa); + FNIC_STD_SET_OX_ID(fabric_abts, oxid); + fnic_send_fcoe_frame(iport, fabric_abts, + sizeof(struct fc_frame_header)); + } + } + + fdmi_tov = jiffies + msecs_to_jiffies(2 * iport->e_d_tov); + mod_timer(&iport->fabric.fdmi_timer, round_jiffies(fdmi_tov)); + iport->fabric.fdmi_pending |= FDLS_FDMI_ABORT_PENDING; +} + static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) { struct fc_std_flogi flogi; @@ -737,6 +882,47 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) fdls_start_fabric_timer(iport, 2 * iport->e_d_tov); } +static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) +{ + struct fc_std_flogi plogi; + struct fc_frame_header *fchdr = &plogi.fchdr; + uint8_t fcid[3]; + struct fnic *fnic = iport->fnic; + u64 fdmi_tov; + uint16_t oxid; + + memcpy(&plogi, &fnic_std_plogi_req, sizeof(plogi)); + + oxid = fdls_alloc_fabric_oxid(iport, &iport->fdmi_oxid_pool, + FNIC_FDMI_PLOGI_RSP); + if (oxid == 0xFFFF) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate OXID to send fdmi plogi %p", + iport); + return; + } + + hton24(fcid, iport->fcid); + + FNIC_STD_SET_S_ID(fchdr, fcid); + hton24(fcid, 0XFFFFFA); + FNIC_STD_SET_D_ID(fchdr, fcid); + FNIC_STD_SET_OX_ID(fchdr, htons(oxid)); + FNIC_LOGI_SET_NPORT_NAME(&plogi.els, iport->wwpn); + FNIC_LOGI_SET_NODE_NAME(&plogi.els, iport->wwnn); + FNIC_LOGI_SET_RDF_SIZE(&plogi.els, iport->max_payload_size); + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "fcid: 0x%x: FDLS send FDMI PLOGI with oxid:%x", + iport->fcid, oxid); + + fnic_send_fcoe_frame(iport, &plogi, sizeof(struct fc_std_flogi)); + + fdmi_tov = jiffies + msecs_to_jiffies(2 * iport->e_d_tov); + mod_timer(&iport->fabric.fdmi_timer, round_jiffies(fdmi_tov)); + iport->fabric.fdmi_pending = FDLS_FDMI_PLOGI_PENDING; +} + static void fdls_send_rpn_id(struct fnic_iport_s *iport) { struct fc_std_rpn_id rpn_id; @@ -1375,6 +1561,126 @@ struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport, return NULL; } +static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) +{ + struct fc_std_fdmi_rhba fdmi_rhba; + uint8_t fcid[3]; + uint16_t len; + int err; + struct fnic *fnic = iport->fnic; + struct vnic_devcmd_fw_info *fw_info = NULL; + uint16_t oxid; + + memcpy(&fdmi_rhba, &fnic_std_fdmi_rhba, + sizeof(struct fc_std_fdmi_rhba)); + + hton24(fcid, iport->fcid); + FNIC_STD_SET_S_ID((&fdmi_rhba.fchdr), fcid); + + oxid = fdls_alloc_fabric_oxid(iport, &iport->fdmi_oxid_pool, + FNIC_FDMI_REG_HBA_RSP); + if (oxid == 0xFFFF) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate OXID to send fdmi reg hba %p", + iport); + return; + } + FNIC_STD_SET_OX_ID(&fdmi_rhba.fchdr, htons(oxid)); + + fdmi_rhba.hba_identifier = get_unaligned_be64(&iport->wwpn); + fdmi_rhba.port_name = get_unaligned_be64(&iport->wwpn); + fdmi_rhba.node_name = get_unaligned_be64(&iport->wwnn); + + err = vnic_dev_fw_info(fnic->vdev, &fw_info); + if (!err) { + snprintf(fdmi_rhba.serial_num, sizeof(fdmi_rhba.serial_num) - 1, + "%s", fw_info->hw_serial_number); + snprintf(fdmi_rhba.hardware_ver, + sizeof(fdmi_rhba.hardware_ver) - 1, "%s", + fw_info->hw_version); + strscpy(fdmi_rhba.firmware_ver, fw_info->fw_version, + sizeof(fdmi_rhba.firmware_ver) - 1); + + len = ARRAY_SIZE(fdmi_rhba.model); + if (fnic->subsys_desc_len >= len) + fnic->subsys_desc_len = len - 1; + memcpy(&fdmi_rhba.model, fnic->subsys_desc, + fnic->subsys_desc_len); + fdmi_rhba.model[fnic->subsys_desc_len] = 0x00; + } + + snprintf(fdmi_rhba.driver_ver, sizeof(fdmi_rhba.driver_ver) - 1, "%s", + DRV_VERSION); + snprintf(fdmi_rhba.rom_ver, sizeof(fdmi_rhba.rom_ver) - 1, "%s", "N/A"); + + fnic_send_fcoe_frame(iport, &fdmi_rhba, + sizeof(struct fc_std_fdmi_rhba)); + iport->fabric.fdmi_pending |= FDLS_FDMI_REG_HBA_PENDING; +} + +static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) +{ + struct fc_std_fdmi_rpa fdmi_rpa; + + uint8_t fcid[3]; + struct fnic *fnic = iport->fnic; + u32 port_speed_bm; + u32 port_speed = vnic_dev_port_speed(fnic->vdev); + uint16_t oxid; + + memcpy(&fdmi_rpa, &fnic_std_fdmi_rpa, sizeof(struct fc_std_fdmi_rpa)); + hton24(fcid, iport->fcid); + FNIC_STD_SET_S_ID((&fdmi_rpa.fchdr), fcid); + + oxid = fdls_alloc_fabric_oxid(iport, &iport->fdmi_oxid_pool, + FNIC_FDMI_RPA_RSP); + if (oxid == 0xFFFF) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Failed to allocate OXID to send fdmi rpa %p", + iport); + return; + } + FNIC_STD_SET_OX_ID(&fdmi_rpa.fchdr, htons(oxid)); + + fdmi_rpa.port_name = get_unaligned_be64(&iport->wwpn); + + /* MDS does not support GIGE speed. + * Bit shift standard definitions from scsi_transport_fc.h to + * match FC spec. + */ + switch (port_speed) { + case DCEM_PORTSPEED_10G: + case DCEM_PORTSPEED_20G: + /* There is no bit for 20G */ + port_speed_bm = FC_PORTSPEED_10GBIT << PORT_SPEED_BIT_14; + break; + case DCEM_PORTSPEED_25G: + port_speed_bm = FC_PORTSPEED_25GBIT << PORT_SPEED_BIT_8; + break; + case DCEM_PORTSPEED_40G: + case DCEM_PORTSPEED_4x10G: + port_speed_bm = FC_PORTSPEED_40GBIT << PORT_SPEED_BIT_9; + break; + case DCEM_PORTSPEED_100G: + port_speed_bm = FC_PORTSPEED_100GBIT << PORT_SPEED_BIT_8; + break; + default: + port_speed_bm = FC_PORTSPEED_1GBIT << PORT_SPEED_BIT_15; + break; + } + fdmi_rpa.supported_speed = htonl(port_speed_bm); + fdmi_rpa.current_speed = htonl(port_speed_bm); + fdmi_rpa.fc4_type[2] = 1; + snprintf(fdmi_rpa.os_name, sizeof(fdmi_rpa.os_name) - 1, "host%d", + fnic->lport->host->host_no); + sprintf(fc_host_system_hostname(fnic->lport->host), "%s", utsname()->nodename); + snprintf(fdmi_rpa.host_name, sizeof(fdmi_rpa.host_name) - 1, "%s", + fc_host_system_hostname(fnic->lport->host)); + + fnic_send_fcoe_frame(iport, &fdmi_rpa, sizeof(struct fc_std_fdmi_rpa)); + iport->fabric.fdmi_pending |= FDLS_FDMI_RPA_PENDING; +} + void fdls_fabric_timer_callback(struct timer_list *t) { struct fnic_fdls_fabric_s *fabric = from_timer(fabric, t, retry_timer); @@ -1547,6 +1853,43 @@ void fdls_fabric_timer_callback(struct timer_list *t) spin_unlock_irqrestore(&fnic->fnic_lock, flags); } +void fdls_fdmi_timer_callback(struct timer_list *t) +{ + struct fnic_fdls_fabric_s *fabric = from_timer(fabric, t, fdmi_timer); + struct fnic_iport_s *iport = + container_of(fabric, struct fnic_iport_s, fabric); + struct fnic *fnic = iport->fnic; + unsigned long flags; + + spin_lock_irqsave(&fnic->fnic_lock, flags); + + if (!iport->fabric.fdmi_pending) { + /* timer expired after fdmi responses received. */ + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + return; + } + + /* if not abort pending, send an abort */ + if (!(iport->fabric.fdmi_pending & FDLS_FDMI_ABORT_PENDING)) { + fdls_send_fdmi_abts(iport); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + return; + } + + /* Abort timed out */ + fdls_schedule_fdmi_oxid_free(iport); + + iport->fabric.fdmi_pending = 0; + /* If max retries not exhaused, start over from fdmi plogi */ + if (iport->fabric.fdmi_retry < FDLS_FDMI_MAX_RETRY) { + iport->fabric.fdmi_retry++; + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "retry fdmi timer %d", iport->fabric.fdmi_retry); + fdls_send_fdmi_plogi(iport); + } + spin_unlock_irqrestore(&fnic->fnic_lock, flags); +} + static void fdls_send_delete_tport_msg(struct fnic_tport_s *tport) { struct fnic_iport_s *iport = (struct fnic_iport_s *) tport->iport; @@ -1696,6 +2039,15 @@ static void fnic_fdls_start_plogi(struct fnic_iport_s *iport) fdls_send_fabric_plogi(iport); fdls_set_state((&iport->fabric), FDLS_STATE_FABRIC_PLOGI); iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; + + if ((fnic_fdmi_support == 1) && (!(iport->flags & FNIC_FDMI_ACTIVE))) { + /* we can do FDMI at the same time */ + iport->fabric.fdmi_retry = 0; + timer_setup(&iport->fabric.fdmi_timer, fdls_fdmi_timer_callback, + 0); + fdls_send_fdmi_plogi(iport); + iport->flags |= FNIC_FDMI_ACTIVE; + } } static void @@ -2783,6 +3135,109 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, } } +static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr) +{ + struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *)fchdr; + struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; + struct fnic *fnic = iport->fnic; + u64 fdmi_tov; + + iport->fabric.fdmi_pending &= ~FDLS_FDMI_PLOGI_PENDING; + fdls_free_fabric_oxid(iport, &iport->fabric_oxid_pool, + ntohs(FNIC_STD_GET_OX_ID(fchdr))); + + if (ntoh24(fchdr->fh_s_id) == 0XFFFFFA) { + del_timer_sync(&iport->fabric.fdmi_timer); + iport->fabric.fdmi_pending = 0; + switch (plogi_rsp->els.fl_cmd) { + case ELS_LS_ACC: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FDLS process fdmi PLOGI response status: ELS_LS_ACC\n"); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Sending fdmi registration for port 0x%x\n", + iport->fcid); + + fdls_fdmi_register_hba(iport); + fdls_fdmi_register_pa(iport); + fdmi_tov = jiffies + msecs_to_jiffies(5000); + mod_timer(&iport->fabric.fdmi_timer, + round_jiffies(fdmi_tov)); + break; + case ELS_LS_RJT: + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Fabric FDMI PLOGI returned ELS_LS_RJT reason: 0x%x", + els_rjt->u.rej.er_reason); + + if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) + || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) + && (iport->fabric.fdmi_retry < 7)) { + iport->fabric.fdmi_retry++; + fdls_send_fdmi_plogi(iport); + } + break; + default: + break; + } + } +} + +static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr, + int rsp_type) +{ + struct fnic *fnic = iport->fnic; + + if (!iport->fabric.fdmi_pending) { + FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Received FDMI ack while not waiting:%x\n", + ntohs(FNIC_STD_GET_OX_ID(fchdr))); + return; + } + + if (rsp_type == FNIC_FDMI_REG_HBA_RSP) + iport->fabric.fdmi_pending &= ~FDLS_FDMI_REG_HBA_PENDING; + else + iport->fabric.fdmi_pending &= ~FDLS_FDMI_RPA_PENDING; + + fdls_free_fabric_oxid(iport, &iport->fdmi_oxid_pool, + ntohs(FNIC_STD_GET_OX_ID(fchdr))); + + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "iport fcid: 0x%x: Received FDMI registration ack\n", + iport->fcid); + + if (!iport->fabric.fdmi_pending) { + del_timer_sync(&iport->fabric.fdmi_timer); + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "iport fcid: 0x%x: Canceling FDMI timer\n", + iport->fcid); + } +} + +static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport, + struct fc_frame_header *fchdr) +{ + uint32_t s_id; + struct fnic *fnic = iport->fnic; + + s_id = ntoh24(FNIC_STD_GET_S_ID(fchdr)); + + if (!(s_id != 0xFFFFFA)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Received abts rsp with invalid SID: 0x%x. Dropping frame", + s_id); + return; + } + + del_timer_sync(&iport->fabric.fdmi_timer); + iport->fabric.fdmi_pending &= ~FDLS_FDMI_ABORT_PENDING; + + fdls_free_fabric_oxid(iport, &iport->fdmi_oxid_pool, + ntohs(FNIC_STD_GET_OX_ID(fchdr))); + fdls_send_fdmi_plogi(iport); +} + static void fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) @@ -3779,6 +4234,9 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, break; case FNIC_FABRIC_LOGO_RSP: + case FNIC_FDMI_PLOGI_RSP: + case FNIC_FDMI_REG_HBA_RSP: + case FNIC_FDMI_RPA_RSP: break; default: /* Drop the Rx frame and log/stats it */ @@ -3821,6 +4279,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, case FNIC_FABRIC_PLOGI_RSP: fdls_process_fabric_plogi_rsp(iport, fchdr); break; + case FNIC_FDMI_PLOGI_RSP: + fdls_process_fdmi_plogi_rsp(iport, fchdr); + break; case FNIC_FABRIC_RPN_RSP: fdls_process_rpn_id_rsp(iport, fchdr); break; @@ -3860,6 +4321,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, if (fdls_is_oxid_in_fabric_range(oxid) && (iport->fabric.flags & FNIC_FDLS_FABRIC_ABORT_ISSUED)) { fdls_process_fabric_abts_rsp(iport, fchdr); + } else if (fdls_is_oxid_in_fdmi_range(oxid) && + iport->fabric.fdmi_pending) { + fdls_process_fdmi_abts_rsp(iport, fchdr); } else { fdls_process_tgt_abts_rsp(iport, fchdr); } @@ -3889,6 +4353,10 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, case FNIC_ELS_RLS: fdls_process_rls_req(iport, fchdr); break; + case FNIC_FDMI_REG_HBA_RSP: + case FNIC_FDMI_RPA_RSP: + fdls_process_fdmi_reg_ack(iport, fchdr, frame_type); + break; default: FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, "s_id: 0x%x d_did: 0x%x", s_id, d_id); @@ -3897,3 +4365,4 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, break; } } + diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index 92cd17efa40f..5d8315b24085 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -82,6 +82,72 @@ /* Retry supported by rport (returned by PRLI service parameters) */ #define FNIC_FC_RP_FLAGS_RETRY 0x1 +/* Cisco vendor id */ +#define PCI_VENDOR_ID_CISCO 0x1137 +#define PCI_DEVICE_ID_CISCO_VIC_FC 0x0045 /* fc vnic */ + +/* sereno pcie switch */ +#define PCI_DEVICE_ID_CISCO_SERENO 0x004e +#define PCI_DEVICE_ID_CISCO_CRUZ 0x007a /* Cruz */ +#define PCI_DEVICE_ID_CISCO_BODEGA 0x0131 /* Bodega */ +#define PCI_DEVICE_ID_CISCO_BEVERLY 0x025f /* Beverly */ + +/* Sereno */ +#define PCI_SUBDEVICE_ID_CISCO_VASONA 0x004f /* vasona mezz */ +#define PCI_SUBDEVICE_ID_CISCO_COTATI 0x0084 /* cotati mlom */ +#define PCI_SUBDEVICE_ID_CISCO_LEXINGTON 0x0085 /* lexington pcie */ +#define PCI_SUBDEVICE_ID_CISCO_ICEHOUSE 0x00cd /* Icehouse */ +#define PCI_SUBDEVICE_ID_CISCO_KIRKWOODLAKE 0x00ce /* KirkwoodLake pcie */ +#define PCI_SUBDEVICE_ID_CISCO_SUSANVILLE 0x012e /* Susanville MLOM */ +#define PCI_SUBDEVICE_ID_CISCO_TORRANCE 0x0139 /* Torrance MLOM */ + +/* Cruz */ +#define PCI_SUBDEVICE_ID_CISCO_CALISTOGA 0x012c /* Calistoga MLOM */ +#define PCI_SUBDEVICE_ID_CISCO_MOUNTAINVIEW 0x0137 /* Cruz Mezz */ +/* Cruz MountTian SIOC */ +#define PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN 0x014b +#define PCI_SUBDEVICE_ID_CISCO_CLEARLAKE 0x014d /* ClearLake pcie */ +/* Cruz MountTian2 SIOC */ +#define PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN2 0x0157 +#define PCI_SUBDEVICE_ID_CISCO_CLAREMONT 0x015d /* Claremont MLOM */ + +/* Bodega */ +/* VIC 1457 PCIe mLOM */ +#define PCI_SUBDEVICE_ID_CISCO_BRADBURY 0x0218 +#define PCI_SUBDEVICE_ID_CISCO_BRENTWOOD 0x0217 /* VIC 1455 PCIe */ +/* VIC 1487 PCIe mLOM */ +#define PCI_SUBDEVICE_ID_CISCO_BURLINGAME 0x021a +#define PCI_SUBDEVICE_ID_CISCO_BAYSIDE 0x0219 /* VIC 1485 PCIe */ +/* VIC 1440 Mezz mLOM */ +#define PCI_SUBDEVICE_ID_CISCO_BAKERSFIELD 0x0215 +#define PCI_SUBDEVICE_ID_CISCO_BOONVILLE 0x0216 /* VIC 1480 Mezz */ +#define PCI_SUBDEVICE_ID_CISCO_BENICIA 0x024a /* VIC 1495 */ +#define PCI_SUBDEVICE_ID_CISCO_BEAUMONT 0x024b /* VIC 1497 */ +#define PCI_SUBDEVICE_ID_CISCO_BRISBANE 0x02af /* VIC 1467 */ +#define PCI_SUBDEVICE_ID_CISCO_BENTON 0x02b0 /* VIC 1477 */ +#define PCI_SUBDEVICE_ID_CISCO_TWIN_RIVER 0x02cf /* VIC 14425 */ +#define PCI_SUBDEVICE_ID_CISCO_TWIN_PEAK 0x02d0 /* VIC 14825 */ + +/* Beverly */ +#define PCI_SUBDEVICE_ID_CISCO_BERN 0x02de /* VIC 15420 */ +#define PCI_SUBDEVICE_ID_CISCO_STOCKHOLM 0x02dd /* VIC 15428 */ +#define PCI_SUBDEVICE_ID_CISCO_KRAKOW 0x02dc /* VIC 15411 */ +#define PCI_SUBDEVICE_ID_CISCO_LUCERNE 0x02db /* VIC 15231 */ +#define PCI_SUBDEVICE_ID_CISCO_TURKU 0x02e8 /* VIC 15238 */ +#define PCI_SUBDEVICE_ID_CISCO_TURKU_PLUS 0x02f3 /* VIC 15237 */ +#define PCI_SUBDEVICE_ID_CISCO_ZURICH 0x02df /* VIC 15230 */ +#define PCI_SUBDEVICE_ID_CISCO_RIGA 0x02e0 /* VIC 15427 */ +#define PCI_SUBDEVICE_ID_CISCO_GENEVA 0x02e1 /* VIC 15422 */ +#define PCI_SUBDEVICE_ID_CISCO_HELSINKI 0x02e4 /* VIC 15235 */ +#define PCI_SUBDEVICE_ID_CISCO_GOTHENBURG 0x02f2 /* VIC 15425 */ + +struct fnic_pcie_device { + u32 device; + u8 *desc; + u32 subsystem_device; + u8 *subsys_desc; +}; + /* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. @@ -134,6 +200,7 @@ static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd) #define fnic_clear_state_flags(fnicp, st_flags) \ __fnic_set_state_flags(fnicp, st_flags, 1) +extern unsigned int fnic_fdmi_support; extern unsigned int fnic_log_level; extern unsigned int io_completions; extern struct workqueue_struct *fnic_event_queue; @@ -336,6 +403,9 @@ struct fnic { struct work_struct tport_work; struct list_head tport_event_list; + char subsys_desc[14]; + int subsys_desc_len; + /*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *, u16 vlan); struct work_struct fip_frame_work; @@ -433,5 +503,7 @@ fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags) void __fnic_set_state_flags(struct fnic *, unsigned long, unsigned long); void fnic_dump_fchost_stats(struct Scsi_Host *, struct fc_host_statistics *); void fnic_free_txq(struct list_head *head); +int fnic_get_desc_by_devid(struct pci_dev *pdev, char **desc, + char **subsys_desc); #endif /* _FNIC_H_ */ diff --git a/drivers/scsi/fnic/fnic_fdls.h b/drivers/scsi/fnic/fnic_fdls.h index 108452f6852d..d2c3ebce3209 100644 --- a/drivers/scsi/fnic/fnic_fdls.h +++ b/drivers/scsi/fnic/fnic_fdls.h @@ -427,4 +427,3 @@ struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport, uint64_t wwpn); #endif /* _FNIC_FDLS_H_ */ - diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index fd0b00fea813..b0ddb7a816f8 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -62,6 +62,9 @@ unsigned int fnic_log_level; module_param(fnic_log_level, int, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(fnic_log_level, "bit mask of fnic logging levels"); +unsigned int fnic_fdmi_support = 1; +module_param(fnic_fdmi_support, int, 0644); +MODULE_PARM_DESC(fnic_fdmi_support, "FDMI support"); unsigned int io_completions = FNIC_DFLT_IO_COMPLETIONS; module_param(io_completions, int, S_IRUGO|S_IWUSR); @@ -607,6 +610,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) int i; unsigned long flags; int hwq; + char *desc, *subsys_desc; + int len; /* * Allocate SCSI Host and set up association between host, @@ -640,6 +645,23 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->fnic_num = fnic_id; fnic_stats_debugfs_init(fnic); + /* Find model name from PCIe subsys ID */ + if (fnic_get_desc_by_devid(pdev, &desc, &subsys_desc) == 0) { + dev_info(&fnic->pdev->dev, "Model: %s\n", subsys_desc); + + /* Update FDMI model */ + fnic->subsys_desc_len = strlen(subsys_desc); + len = ARRAY_SIZE(fnic->subsys_desc); + if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; + memcpy(fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len); + dev_info(&fnic->pdev->dev, "FDMI Model: %s\n", fnic->subsys_desc); + } else { + fnic->subsys_desc_len = 0; + dev_info(&fnic->pdev->dev, "Model: %s subsys_id: 0x%04x\n", "Unknown", + pdev->subsystem_device); + } + err = pci_enable_device(pdev); if (err) { dev_err(&fnic->pdev->dev, "Cannot enable PCI device, aborting.\n"); @@ -1014,6 +1036,9 @@ static void fnic_remove(struct pci_dev *pdev) fnic_fcoe_evlist_free(fnic); } + if ((fnic_fdmi_support == 1) && (fnic->iport.fabric.fdmi_pending > 0)) + del_timer_sync(&fnic->iport.fabric.fdmi_timer); + /* * Log off the fabric. This stops all remote ports, dns port, * logs off the fabric. This flushes all rport, disc, lport work @@ -1199,3 +1224,4 @@ static void __exit fnic_cleanup_module(void) module_init(fnic_init_module); module_exit(fnic_cleanup_module); + diff --git a/drivers/scsi/fnic/fnic_pci_subsys_devid.c b/drivers/scsi/fnic/fnic_pci_subsys_devid.c new file mode 100644 index 000000000000..36a2c1268422 --- /dev/null +++ b/drivers/scsi/fnic/fnic_pci_subsys_devid.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2008 Cisco Systems, Inc. All rights reserved. + * Copyright 2007 Nuova Systems, Inc. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "fnic.h" + +static struct fnic_pcie_device fnic_pcie_device_table[] = { + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", PCI_SUBDEVICE_ID_CISCO_VASONA, + "VIC 1280"}, + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", PCI_SUBDEVICE_ID_CISCO_COTATI, + "VIC 1240"}, + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", + PCI_SUBDEVICE_ID_CISCO_LEXINGTON, "VIC 1225"}, + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", PCI_SUBDEVICE_ID_CISCO_ICEHOUSE, + "VIC 1285"}, + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", + PCI_SUBDEVICE_ID_CISCO_KIRKWOODLAKE, "VIC 1225T"}, + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", + PCI_SUBDEVICE_ID_CISCO_SUSANVILLE, "VIC 1227"}, + {PCI_DEVICE_ID_CISCO_SERENO, "Sereno", PCI_SUBDEVICE_ID_CISCO_TORRANCE, + "VIC 1227T"}, + + {PCI_DEVICE_ID_CISCO_CRUZ, "Cruz", PCI_SUBDEVICE_ID_CISCO_CALISTOGA, + "VIC 1340"}, + {PCI_DEVICE_ID_CISCO_CRUZ, "Cruz", PCI_SUBDEVICE_ID_CISCO_MOUNTAINVIEW, + "VIC 1380"}, + {PCI_DEVICE_ID_CISCO_CRUZ, "Cruz", PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN, + "C3260-SIOC"}, + {PCI_DEVICE_ID_CISCO_CRUZ, "Cruz", PCI_SUBDEVICE_ID_CISCO_CLEARLAKE, + "VIC 1385"}, + {PCI_DEVICE_ID_CISCO_CRUZ, "Cruz", PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN2, + "C3260-SIOC"}, + {PCI_DEVICE_ID_CISCO_CRUZ, "Cruz", PCI_SUBDEVICE_ID_CISCO_CLAREMONT, + "VIC 1387"}, + + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", PCI_SUBDEVICE_ID_CISCO_BRADBURY, + "VIC 1457"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", + PCI_SUBDEVICE_ID_CISCO_BRENTWOOD, "VIC 1455"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", + PCI_SUBDEVICE_ID_CISCO_BURLINGAME, "VIC 1487"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", PCI_SUBDEVICE_ID_CISCO_BAYSIDE, + "VIC 1485"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", + PCI_SUBDEVICE_ID_CISCO_BAKERSFIELD, "VIC 1440"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", + PCI_SUBDEVICE_ID_CISCO_BOONVILLE, "VIC 1480"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", PCI_SUBDEVICE_ID_CISCO_BENICIA, + "VIC 1495"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", PCI_SUBDEVICE_ID_CISCO_BEAUMONT, + "VIC 1497"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", PCI_SUBDEVICE_ID_CISCO_BRISBANE, + "VIC 1467"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", PCI_SUBDEVICE_ID_CISCO_BENTON, + "VIC 1477"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", + PCI_SUBDEVICE_ID_CISCO_TWIN_RIVER, "VIC 14425"}, + {PCI_DEVICE_ID_CISCO_BODEGA, "Bodega", + PCI_SUBDEVICE_ID_CISCO_TWIN_PEAK, "VIC 14825"}, + + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", PCI_SUBDEVICE_ID_CISCO_BERN, + "VIC 15420"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", + PCI_SUBDEVICE_ID_CISCO_STOCKHOLM, "VIC 15428"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", PCI_SUBDEVICE_ID_CISCO_KRAKOW, + "VIC 15411"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", + PCI_SUBDEVICE_ID_CISCO_LUCERNE, "VIC 15231"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", PCI_SUBDEVICE_ID_CISCO_TURKU, + "VIC 15238"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", PCI_SUBDEVICE_ID_CISCO_GENEVA, + "VIC 15422"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", + PCI_SUBDEVICE_ID_CISCO_HELSINKI, "VIC 15235"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", + PCI_SUBDEVICE_ID_CISCO_GOTHENBURG, "VIC 15425"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", + PCI_SUBDEVICE_ID_CISCO_TURKU_PLUS, "VIC 15237"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", PCI_SUBDEVICE_ID_CISCO_ZURICH, + "VIC 15230"}, + {PCI_DEVICE_ID_CISCO_BEVERLY, "Beverly", PCI_SUBDEVICE_ID_CISCO_RIGA, + "VIC 15427"}, + + {0,} +}; + +int fnic_get_desc_by_devid(struct pci_dev *pdev, char **desc, + char **subsys_desc) +{ + unsigned short device = PCI_DEVICE_ID_CISCO_VIC_FC; + int max = ARRAY_SIZE(fnic_pcie_device_table); + struct fnic_pcie_device *t = fnic_pcie_device_table; + int index = 0; + + if (pdev->device != device) + return 1; + + while (t->device != 0) { + if (memcmp + ((char *) &pdev->subsystem_device, + (char *) &t->subsystem_device, sizeof(short)) == 0) + break; + t++; + index++; + } + + if (index >= max - 1) { + *desc = NULL; + *subsys_desc = NULL; + return 1; + } + + *desc = fnic_pcie_device_table[index].desc; + *subsys_desc = fnic_pcie_device_table[index].subsys_desc; + return 0; +} From patchwork Fri Sep 27 18:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831145 Received: from rcdn-iport-6.cisco.com (rcdn-iport-6.cisco.com [173.37.86.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55632136E28; Fri, 27 Sep 2024 18:52:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.77 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463134; cv=none; b=LaC0NRrsNJdk0OZ4dZfGZ3UudIsiJpS3bTPyDPBvlme696z1blMOxP/Bzhgd+eoQgC5/JCfTdi65mEvdorqVszpjeU3mtUXHOJNvl4SId0DA/u36PjWI0Ly7Q7VhJQGDIB34f5d/jjaOrdFtS0lvPZ2UB17Z0JkhkHP+Vb/ICcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463134; c=relaxed/simple; bh=US4dD1Dh8L8/ImwjifP1Xq95qFtG4pgc5FXNGIlSq8E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ef/zENat6p/jNvEOIb9br4DIVyMgJt2rxngATo324JA0QMGMovpQEDFBx09PMx4/m9JmNGpNWnGKI4sK/WOHHFAkaIEPb32ocmgjwSCLoSNK3hezJuBWluzhm2Tmurb5yY6SVkd5NcqBgz8W3TTST8OK1vXpjOkzgFxSssgXUpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=KlIZU0Wi; arc=none smtp.client-ip=173.37.86.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="KlIZU0Wi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=51190; q=dns/txt; s=iport; t=1727463131; x=1728672731; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f/RaCdZhD7VYhyPpRPwG3ScR2VKipIVWAdA06NG6uvw=; b=KlIZU0WiZz12s9V9l6uAb288W80Ofz5nhBoeqN54MA5iKVRwsiB2K3Wl h+MzNrY4scLR/jOOzFtUW7JPrzyOQoAwBvZDUe27fNz/iJejt2NvsD/iY lgSx07zP1esZQ0/N5ANWS4kWJTlgxeE5W+PlpRWPy9fXtbxo/8pBVSb9B U=; X-CSE-ConnectionGUID: Bgn3EJvnQX+sLkVbIALguQ== X-CSE-MsgGUID: P52/WUN/TAuxMO0gnPj+5Q== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="267255980" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-6.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:52:10 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQaq022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:52:09 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar Subject: [PATCH v3 09/14] scsi: fnic: Modify IO path to use FDLS Date: Fri, 27 Sep 2024 11:46:08 -0700 Message-Id: <20240927184613.52172-10-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Modify IO path to use FDLS. Add helper functions to process IOs. Remove unused template functions. Cleanup obsolete code. Refactor old function definitions. Reviewed-by: Sesidhar Baddela Reviewed-by: Arulprabhu Ponnusamy Reviewed-by: Gian Carlo Boffa Reviewed-by: Arun Easi Signed-off-by: Karan Tilak Kumar --- Changes between v2 and v3: Replace fnic->host with fnic->lport->host to prevent compilation errors. Changes between v1 and v2: Replace pr_err with printk. Incorporate review comments by Hannes: Restore usage of tagset iterators. --- drivers/scsi/fnic/fnic.h | 20 +- drivers/scsi/fnic/fnic_io.h | 3 + drivers/scsi/fnic/fnic_main.c | 5 +- drivers/scsi/fnic/fnic_scsi.c | 846 +++++++++++++++++++-------------- drivers/scsi/fnic/fnic_stats.h | 2 - 5 files changed, 513 insertions(+), 363 deletions(-) diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index 4f38cbae1994..c6fe9eec9a0c 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -40,6 +40,7 @@ #define FNIC_DFLT_IO_REQ 256 /* Default scsi_cmnd tag map entries */ #define FNIC_DFLT_QUEUE_DEPTH 256 #define FNIC_STATS_RATE_LIMIT 4 /* limit rate at which stats are pulled up */ +#define LUN0_DELAY_TIME 9 /* * Tag bits used for special requests. @@ -472,7 +473,6 @@ int fnic_set_intr_mode_msix(struct fnic *fnic); void fnic_free_intr(struct fnic *fnic); int fnic_request_intr(struct fnic *fnic); -int fnic_send(struct fc_lport *, struct fc_frame *); void fnic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf); void fnic_handle_frame(struct work_struct *work); void fnic_tport_event_handler(struct work_struct *work); @@ -489,11 +489,9 @@ int fnic_abort_cmd(struct scsi_cmnd *); int fnic_device_reset(struct scsi_cmnd *); int fnic_eh_host_reset_handler(struct scsi_cmnd *sc); int fnic_host_reset(struct Scsi_Host *shost); -int fnic_reset(struct Scsi_Host *); -void fnic_scsi_cleanup(struct fc_lport *); -void fnic_scsi_abort_io(struct fc_lport *); -void fnic_empty_scsi_cleanup(struct fc_lport *); -void fnic_exch_mgr_reset(struct fc_lport *, u32, u32); +void fnic_reset(struct Scsi_Host *shost); +int fnic_issue_fc_host_lip(struct Scsi_Host *shost); +void fnic_scsi_fcpio_reset(struct fnic *fnic); int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index); int fnic_wq_cmpl_handler(struct fnic *fnic, int); int fnic_flogi_reg_handler(struct fnic *fnic, u32); @@ -505,7 +503,8 @@ const char *fnic_state_to_str(unsigned int state); void fnic_mq_map_queues_cpus(struct Scsi_Host *host); void fnic_log_q_error(struct fnic *fnic); void fnic_handle_link_event(struct fnic *fnic); - +void fnic_stats_debugfs_init(struct fnic *fnic); +void fnic_stats_debugfs_remove(struct fnic *fnic); int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *); void fnic_handle_fip_frame(struct work_struct *work); @@ -526,5 +525,12 @@ int fnic_get_desc_by_devid(struct pci_dev *pdev, char **desc, void fnic_fdls_link_status_change(struct fnic *fnic, int linkup); void fnic_delete_fcp_tports(struct fnic *fnic); void fnic_flush_tport_event_list(struct fnic *fnic); +int fnic_count_ioreqs_wq(struct fnic *fnic, u32 hwq, u32 portid); +unsigned int fnic_count_ioreqs(struct fnic *fnic, u32 portid); +unsigned int fnic_count_all_ioreqs(struct fnic *fnic); +unsigned int fnic_count_lun_ioreqs_wq(struct fnic *fnic, u32 hwq, + struct scsi_device *device); +unsigned int fnic_count_lun_ioreqs(struct fnic *fnic, + struct scsi_device *device); #endif /* _FNIC_H_ */ diff --git a/drivers/scsi/fnic/fnic_io.h b/drivers/scsi/fnic/fnic_io.h index 6fe642cb387b..0d974e040ab7 100644 --- a/drivers/scsi/fnic/fnic_io.h +++ b/drivers/scsi/fnic/fnic_io.h @@ -7,6 +7,7 @@ #define _FNIC_IO_H_ #include +#include "fnic_fdls.h" #define FNIC_DFLT_SG_DESC_CNT 32 #define FNIC_MAX_SG_DESC_CNT 256 /* Maximum descriptors per sgl */ @@ -41,6 +42,8 @@ enum fnic_ioreq_state { }; struct fnic_io_req { + struct fnic_iport_s *iport; + struct fnic_tport_s *tport; struct host_sg_desc *sgl_list; /* sgl list */ void *sgl_list_alloc; /* sgl list address used for free */ dma_addr_t sense_buf_pa; /* dma address for sense buffer*/ diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 24772d6a1cd0..4729edbba18c 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -85,9 +85,6 @@ module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(fnic_max_qdepth, "Queue depth to report for each LUN"); static struct libfc_function_template fnic_transport_template = { - .fcp_abort_io = fnic_empty_scsi_cleanup, - .fcp_cleanup = fnic_empty_scsi_cleanup, - .exch_mgr_reset = fnic_exch_mgr_reset }; struct workqueue_struct *fnic_fip_queue; @@ -162,7 +159,7 @@ static struct fc_function_template fnic_fc_functions = { .show_starget_port_id = 1, .show_rport_dev_loss_tmo = 1, .set_rport_dev_loss_tmo = fnic_set_rport_dev_loss_tmo, - .issue_fc_host_lip = fnic_reset, + .issue_fc_host_lip = fnic_issue_fc_host_lip, .get_fc_host_stats = fnic_get_stats, .reset_fc_host_stats = fnic_reset_host_stats, .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv), diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 5d5d1205e984..97b2535cc100 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -25,9 +25,12 @@ #include #include #include +#include #include "fnic_io.h" #include "fnic.h" +static void fnic_cleanup_io(struct fnic *fnic, int exclude_id); + const char *fnic_state_str[] = { [FNIC_IN_FC_MODE] = "FNIC_IN_FC_MODE", [FNIC_IN_FC_TRANS_ETH_MODE] = "FNIC_IN_FC_TRANS_ETH_MODE", @@ -65,6 +68,18 @@ static const char *fcpio_status_str[] = { [FCPIO_LUNMAP_CHNG_PEND] = "FCPIO_LUNHMAP_CHNG_PEND", }; +enum terminate_io_return { + TERM_SUCCESS = 0, + TERM_NO_SC = 1, + TERM_IO_REQ_NOT_FOUND, + TERM_ANOTHER_PORT, + TERM_GSTATE, + TERM_IO_BLOCKED, + TERM_OUT_OF_WQ_DESC, + TERM_TIMED_OUT, + TERM_MISC, +}; + const char *fnic_state_to_str(unsigned int state) { if (state >= ARRAY_SIZE(fnic_state_str) || !fnic_state_str[state]) @@ -90,8 +105,6 @@ static const char *fnic_fcpio_status_to_str(unsigned int status) return fcpio_status_str[status]; } -static void fnic_cleanup_io(struct fnic *fnic); - /* * Unmap the data buffer and sense buffer for an io_req, * also unmap and free the device-private scatter/gather list. @@ -114,6 +127,80 @@ static void fnic_release_ioreq_buf(struct fnic *fnic, SCSI_SENSE_BUFFERSIZE, DMA_FROM_DEVICE); } +int fnic_count_ioreqs_wq(struct fnic *fnic, u32 hwq, u32 portid) +{ + unsigned long flags = 0; + int i = 0, count = 0; + + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); + for (i = 0; i != fnic->sw_copy_wq[hwq].ioreq_table_size; ++i) { + if (fnic->sw_copy_wq[hwq].io_req_table[i] != NULL && + (!portid + || fnic->sw_copy_wq[hwq].io_req_table[i]->port_id == portid)) + count++; + } + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); + + return count; +} + +unsigned int fnic_count_ioreqs(struct fnic *fnic, u32 portid) +{ + int i; + unsigned int count = 0; + + for (i = 0; i < fnic->wq_copy_count; i++) + count += fnic_count_ioreqs_wq(fnic, i, portid); + + return count; +} + +unsigned int fnic_count_all_ioreqs(struct fnic *fnic) +{ + return fnic_count_ioreqs(fnic, 0); +} + +unsigned int fnic_count_lun_ioreqs_wq(struct fnic *fnic, u32 hwq, + struct scsi_device *device) +{ + struct fnic_io_req *io_req; + int i; + unsigned int count = 0; + unsigned long flags = 0; + + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); + for (i = 0; i != fnic->sw_copy_wq[hwq].ioreq_table_size; ++i) { + io_req = fnic->sw_copy_wq[hwq].io_req_table[i]; + + if (io_req != NULL) { + struct scsi_cmnd *sc = + scsi_host_find_tag(fnic->lport->host, io_req->tag); + + if (!sc) + continue; + + if (sc->device == device) + count++; + } + } + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); + + return count; +} + +unsigned int fnic_count_lun_ioreqs(struct fnic *fnic, + struct scsi_device *device) +{ + int hwq; + unsigned int count = 0; + + /*count if any pending IOs on this lun */ + for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) + count += fnic_count_lun_ioreqs_wq(fnic, hwq, device); + + return count; +} + /* Free up Copy Wq descriptors. Called with copy_wq lock held */ static int free_wq_copy_descs(struct fnic *fnic, struct vnic_wq_copy *wq, unsigned int hwq) { @@ -179,12 +266,11 @@ int fnic_fw_reset_handler(struct fnic *fnic) struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0]; int ret = 0; unsigned long flags; + unsigned int ioreq_count; /* indicate fwreset to io path */ fnic_set_state_flags(fnic, FNIC_FLAGS_FWRESET); - - fnic_free_txq(&fnic->frame_queue); - fnic_free_txq(&fnic->tx_queue); + ioreq_count = fnic_count_all_ioreqs(fnic); /* wait for io cmpl */ while (atomic_read(&fnic->in_flight)) @@ -231,10 +317,10 @@ int fnic_flogi_reg_handler(struct fnic *fnic, u32 fc_id) { struct vnic_wq_copy *wq = &fnic->hw_copy_wq[0]; enum fcpio_flogi_reg_format_type format; - struct fc_lport *lp = fnic->lport; u8 gw_mac[ETH_ALEN]; int ret = 0; unsigned long flags; + struct fnic_iport_s *iport = &fnic->iport; spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); @@ -246,28 +332,23 @@ int fnic_flogi_reg_handler(struct fnic *fnic, u32 fc_id) goto flogi_reg_ioreq_end; } - if (fnic->ctlr.map_dest) { - eth_broadcast_addr(gw_mac); - format = FCPIO_FLOGI_REG_DEF_DEST; - } else { - memcpy(gw_mac, fnic->ctlr.dest_addr, ETH_ALEN); - format = FCPIO_FLOGI_REG_GW_DEST; - } + memcpy(gw_mac, fnic->iport.fcfmac, ETH_ALEN); + format = FCPIO_FLOGI_REG_GW_DEST; - if ((fnic->config.flags & VFCF_FIP_CAPABLE) && !fnic->ctlr.map_dest) { + if (fnic->config.flags & VFCF_FIP_CAPABLE) { fnic_queue_wq_copy_desc_fip_reg(wq, SCSI_NO_TAG, fc_id, gw_mac, - fnic->data_src_addr, - lp->r_a_tov, lp->e_d_tov); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "FLOGI FIP reg issued fcid %x src %pM dest %pM\n", - fc_id, fnic->data_src_addr, gw_mac); + fnic->iport.fpma, + iport->r_a_tov, iport->e_d_tov); + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FLOGI FIP reg issued fcid: 0x%x src %p dest %p\n", + fc_id, fnic->iport.fpma, gw_mac); } else { fnic_queue_wq_copy_desc_flogi_reg(wq, SCSI_NO_TAG, format, fc_id, gw_mac); FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "FLOGI reg issued fcid 0x%x map %d dest 0x%p\n", - fc_id, fnic->ctlr.map_dest, gw_mac); + "FLOGI reg issued fcid 0x%x dest %p\n", + fc_id, gw_mac); } atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); @@ -295,13 +376,17 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, { struct scatterlist *sg; struct fc_rport *rport = starget_to_rport(scsi_target(sc->device)); - struct fc_rport_libfc_priv *rp = rport->dd_data; struct host_sg_desc *desc; struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; unsigned int i; int flags; u8 exch_flags; struct scsi_lun fc_lun; + struct fnic_tport_s *tport; + struct rport_dd_data_s *rdd_data; + + rdd_data = rport->dd_data; + tport = rdd_data->tport; if (sg_count) { /* For each SGE, create a device desc entry */ @@ -356,7 +441,7 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, exch_flags = 0; if ((fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) && - (rp->flags & FC_RP_FLAGS_RETRY)) + (tport->tgt_flags & FDLS_FC_RP_FLAGS_RETRY)) exch_flags |= FCPIO_ICMND_SRFLAG_RETRY; fnic_queue_wq_copy_desc_icmnd_16(wq, mqtag, @@ -371,8 +456,8 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, sc->cmnd, sc->cmd_len, scsi_bufflen(sc), fc_lun.scsi_lun, io_req->port_id, - rport->maxframe_size, rp->r_a_tov, - rp->e_d_tov); + tport->max_payload_size, + tport->r_a_tov, tport->e_d_tov); atomic64_inc(&fnic->fnic_stats.fw_stats.active_fw_reqs); if (atomic64_read(&fnic->fnic_stats.fw_stats.active_fw_reqs) > @@ -388,10 +473,10 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) struct request *const rq = scsi_cmd_to_rq(sc); uint32_t mqtag = 0; void (*done)(struct scsi_cmnd *) = scsi_done; - struct fc_lport *lp = shost_priv(sc->device->host); struct fc_rport *rport; struct fnic_io_req *io_req = NULL; - struct fnic *fnic = lport_priv(lp); + struct fnic *fnic = *((struct fnic **) shost_priv(sc->device->host)); + struct fnic_iport_s *iport = NULL; struct fnic_stats *fnic_stats = &fnic->fnic_stats; struct vnic_wq_copy *wq; int ret = 1; @@ -400,32 +485,14 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) unsigned long flags = 0; unsigned long ptr; int io_lock_acquired = 0; - struct fc_rport_libfc_priv *rp; uint16_t hwq = 0; - - mqtag = blk_mq_unique_tag(rq); - spin_lock_irqsave(&fnic->fnic_lock, flags); - - if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) { - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, - "fnic IO blocked flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n", - fnic->state_flags); - return SCSI_MLQUEUE_HOST_BUSY; - } - - if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) { - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, - "fnic flags: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n", - fnic->state_flags); - return SCSI_MLQUEUE_HOST_BUSY; - } + struct fnic_tport_s *tport = NULL; + struct rport_dd_data_s *rdd_data; + uint16_t lun0_delay = 0; rport = starget_to_rport(scsi_target(sc->device)); if (!rport) { - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, "returning DID_NO_CONNECT for IO as rport is NULL\n"); sc->result = DID_NO_CONNECT << 16; done(sc); @@ -434,50 +501,95 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) ret = fc_remote_port_chkready(rport); if (ret) { - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, "rport is not ready\n"); - atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); sc->result = ret; done(sc); return 0; } - rp = rport->dd_data; - if (!rp || rp->rp_state == RPORT_ST_DELETE) { - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "rport 0x%x removed, returning DID_NO_CONNECT\n", - rport->port_id); + mqtag = blk_mq_unique_tag(rq); + spin_lock_irqsave(&fnic->fnic_lock, flags); + iport = &fnic->iport; - atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); - sc->result = DID_NO_CONNECT<<16; + if (iport->state != FNIC_IPORT_STATE_READY) { + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "returning DID_NO_CONNECT for IO as iport state: %d\n", + iport->state); + sc->result = DID_NO_CONNECT << 16; done(sc); return 0; } - if (rp->rp_state != RPORT_ST_READY) { - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "rport 0x%x in state 0x%x, returning DID_IMM_RETRY\n", - rport->port_id, rp->rp_state); + /* fc_remote_port_add() may have added the tport to + * fc_transport but dd_data not yet set + */ + rdd_data = rport->dd_data; + tport = rdd_data->tport; + if (!tport || (rdd_data->iport != iport)) { + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "dd_data not yet set in SCSI for rport portid: 0x%x\n", + rport->port_id); + tport = fnic_find_tport_by_fcid(iport, rport->port_id); + if (!tport) { + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "returning DID_BUS_BUSY for IO as tport not found for: 0x%x\n", + rport->port_id); + sc->result = DID_BUS_BUSY << 16; + done(sc); + return 0; + } + + /* Re-assign same params as in fnic_fdls_add_tport */ + rport->maxframe_size = FNIC_FC_MAX_PAYLOAD_LEN; + rport->supported_classes = + FC_COS_CLASS3 | FC_RPORT_ROLE_FCP_TARGET; + /* the dd_data is allocated by fctransport of size dd_fcrport_size */ + rdd_data = rport->dd_data; + rdd_data->tport = tport; + rdd_data->iport = iport; + tport->rport = rport; + tport->flags |= FNIC_FDLS_SCSI_REGISTERED; + } - sc->result = DID_IMM_RETRY << 16; + if ((tport->state != FDLS_TGT_STATE_READY) + && (tport->state != FDLS_TGT_STATE_ADISC)) { + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "returning DID_NO_CONNECT for IO as tport state: %d\n", + tport->state); + sc->result = DID_NO_CONNECT << 16; done(sc); return 0; } - if (lp->state != LPORT_ST_READY || !(lp->link_up)) { + atomic_inc(&fnic->in_flight); + atomic_inc(&tport->in_flight); + + if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) { + atomic_dec(&fnic->in_flight); + atomic_dec(&tport->in_flight); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + return SCSI_MLQUEUE_HOST_BUSY; + } + + if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, - "state not ready: %d/link not up: %d Returning HOST_BUSY\n", - lp->state, lp->link_up); + "fnic flags FW reset: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n", + fnic->state_flags); return SCSI_MLQUEUE_HOST_BUSY; } - atomic_inc(&fnic->in_flight); + if (!tport->lun0_delay) { + lun0_delay = 1; + tport->lun0_delay++; + } spin_unlock_irqrestore(&fnic->fnic_lock, flags); + fnic_priv(sc)->state = FNIC_IOREQ_NOT_INITED; fnic_priv(sc)->flags = FNIC_NO_FLAGS; @@ -499,6 +611,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) goto out; } + io_req->tport = tport; /* Determine the type of scatter/gather list we need */ io_req->sgl_cnt = sg_count; io_req->sgl_type = FNIC_SGL_CACHE_DFLT; @@ -575,6 +688,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) mempool_free(io_req, fnic->io_req_pool); } atomic_dec(&fnic->in_flight); + atomic_dec(&tport->in_flight); return ret; } else { atomic64_inc(&fnic_stats->io_stats.active_ios); @@ -602,6 +716,14 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); atomic_dec(&fnic->in_flight); + atomic_dec(&tport->in_flight); + + if (lun0_delay) { + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "LUN0 delay\n"); + mdelay(LUN0_DELAY_TIME); + } + return ret; } @@ -625,7 +747,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, atomic64_inc(&reset_stats->fw_reset_completions); /* Clean up all outstanding io requests */ - fnic_cleanup_io(fnic); + fnic_cleanup_io(fnic, SCSI_NO_TAG); atomic64_set(&fnic->fnic_stats.fw_stats.active_fw_reqs, 0); atomic64_set(&fnic->fnic_stats.io_stats.active_ios, 0); @@ -646,12 +768,6 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, "reset failed with header status: %s\n", fnic_fcpio_status_to_str(hdr_status)); - /* - * Unable to change to eth mode, cannot send out flogi - * Change state to fc mode, so that subsequent Flogi - * requests from libFC will cause more attempts to - * reset the firmware. Free the cached flogi - */ fnic->state = FNIC_IN_FC_MODE; atomic64_inc(&reset_stats->fw_reset_failures); ret = -1; @@ -664,15 +780,14 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, ret = -1; } - /* Thread removing device blocks till firmware reset is complete */ - if (fnic->remove_wait) - complete(fnic->remove_wait); + if (fnic->fw_reset_done) + complete(fnic->fw_reset_done); /* * If fnic is being removed, or fw reset failed * free the flogi frame. Else, send it out */ - if (fnic->remove_wait || ret) { + if (ret) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); fnic_free_txq(&fnic->tx_queue); goto reset_cmpl_handler_end; @@ -711,12 +826,12 @@ static int fnic_fcpio_flogi_reg_cmpl_handler(struct fnic *fnic, /* Check flogi registration completion status */ if (!hdr_status) { FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "flog reg succeeded\n"); + "FLOGI reg succeeded\n"); fnic->state = FNIC_IN_FC_MODE; } else { FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "fnic flogi reg :failed %s\n", + "fnic flogi reg failed: %s\n", fnic_fcpio_status_to_str(hdr_status)); fnic->state = FNIC_IN_ETH_MODE; ret = -1; @@ -1023,15 +1138,6 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind jiffies_to_msecs(jiffies - start_time)), desc, cmd_trace, fnic_flags_and_state(sc)); - if (sc->sc_data_direction == DMA_FROM_DEVICE) { - fnic->lport->host_stats.fcp_input_requests++; - fnic->fcp_input_bytes += xfer_len; - } else if (sc->sc_data_direction == DMA_TO_DEVICE) { - fnic->lport->host_stats.fcp_output_requests++; - fnic->fcp_output_bytes += xfer_len; - } else - fnic->lport->host_stats.fcp_control_requests++; - /* Call SCSI completion function to complete the IO */ scsi_done(sc); @@ -1414,8 +1520,8 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) struct request *const rq = scsi_cmd_to_rq(sc); struct fnic *fnic = data; struct fnic_io_req *io_req; - unsigned long flags = 0; unsigned long start_time = 0; + unsigned long flags; struct fnic_stats *fnic_stats = &fnic->fnic_stats; uint16_t hwq = 0; int tag; @@ -1439,7 +1545,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) } if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && - !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { + !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { /* * We will be here only when FW completes reset * without sending completions for outstanding ios. @@ -1449,6 +1555,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) complete(io_req->dr_done); else if (io_req && io_req->abts_done) complete(io_req->abts_done); + spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); return true; } else if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { @@ -1458,19 +1565,19 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) fnic_priv(sc)->io_req = NULL; io_req->sc = NULL; + start_time = io_req->start_time; spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); /* * If there is a scsi_cmnd associated with this io_req, then * free the corresponding state */ - start_time = io_req->start_time; fnic_release_ioreq_buf(fnic, io_req, sc); mempool_free(io_req, fnic->io_req_pool); sc->result = DID_TRANSPORT_DISRUPTED << 16; FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, - "mqtag:0x%x tag: 0x%x sc:0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n", + "mqtag: 0x%x tag: 0x%x sc: 0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n", mqtag, tag, sc, (jiffies - start_time)); if (atomic64_read(&fnic->io_cmpl_skip)) @@ -1479,23 +1586,60 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) atomic64_inc(&fnic_stats->io_stats.io_completions); FNIC_TRACE(fnic_cleanup_io, - sc->device->host->host_no, tag, sc, - jiffies_to_msecs(jiffies - start_time), - 0, ((u64)sc->cmnd[0] << 32 | - (u64)sc->cmnd[2] << 24 | - (u64)sc->cmnd[3] << 16 | - (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), - fnic_flags_and_state(sc)); - + sc->device->host->host_no, tag, sc, + jiffies_to_msecs(jiffies - start_time), + 0, ((u64) sc->cmnd[0] << 32 | + (u64) sc->cmnd[2] << 24 | + (u64) sc->cmnd[3] << 16 | + (u64) sc->cmnd[4] << 8 | sc->cmnd[5]), + (((u64) fnic_priv(sc)->flags << 32) | fnic_priv(sc)-> + state)); + + /* Complete the command to SCSI */ scsi_done(sc); - return true; } -static void fnic_cleanup_io(struct fnic *fnic) +static void fnic_cleanup_io(struct fnic *fnic, int exclude_id) { + unsigned int io_count = 0; + unsigned long flags; + struct fnic_io_req *io_req = NULL; + struct scsi_cmnd *sc = NULL; + + io_count = fnic_count_all_ioreqs(fnic); + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + "Outstanding ioreq count: %d active io count: %lld Waiting\n", + io_count, + atomic64_read(&fnic->fnic_stats.io_stats.active_ios)); + scsi_host_busy_iter(fnic->lport->host, - fnic_cleanup_io_iter, fnic); + fnic_cleanup_io_iter, fnic); + + /* with sg3utils device reset, SC needs to be retrieved from ioreq */ + spin_lock_irqsave(&fnic->wq_copy_lock[0], flags); + io_req = fnic->sw_copy_wq[0].io_req_table[fnic->fnic_max_tag_id]; + if (io_req) { + sc = io_req->sc; + if (sc) { + if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) + && !(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { + fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; + if (io_req && io_req->dr_done) + complete(io_req->dr_done); + } + } + } + spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); + + while ((io_count = fnic_count_all_ioreqs(fnic))) { + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + "Outstanding ioreq count: %d active io count: %lld Waiting\n", + io_count, + atomic64_read(&fnic->fnic_stats.io_stats.active_ios)); + + schedule_timeout(msecs_to_jiffies(100)); + } } void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, @@ -1567,10 +1711,13 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, struct vnic_wq_copy *wq = &fnic->hw_copy_wq[hwq]; struct misc_stats *misc_stats = &fnic->fnic_stats.misc_stats; unsigned long flags; + struct fnic_tport_s *tport = io_req->tport; spin_lock_irqsave(&fnic->fnic_lock, flags); if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) { + atomic_dec(&fnic->in_flight); + atomic_dec(&tport->in_flight); spin_unlock_irqrestore(&fnic->fnic_lock, flags); return 1; } else @@ -1585,6 +1732,7 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, if (!vnic_wq_copy_desc_avail(wq)) { spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); atomic_dec(&fnic->in_flight); + atomic_dec(&tport->in_flight); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "fnic_queue_abort_io_req: failure: no descriptors\n"); atomic64_inc(&misc_stats->abts_cpwq_alloc_failures); @@ -1619,20 +1767,24 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) struct fnic *fnic = iter_data->fnic; int abt_tag = 0; struct fnic_io_req *io_req; - unsigned long flags; struct reset_stats *reset_stats = &fnic->fnic_stats.reset_stats; struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; struct scsi_lun fc_lun; enum fnic_ioreq_state old_ioreq_state; uint16_t hwq = 0; + unsigned long flags; abt_tag = blk_mq_unique_tag(rq); hwq = blk_mq_unique_tag_to_hwq(abt_tag); - spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); + if (!sc) { + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + "sc is NULL abt_tag: 0x%x hwq: %d\n", abt_tag, hwq); + return true; + } + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); io_req = fnic_priv(sc)->io_req; - if (!io_req || io_req->port_id != iter_data->port_id) { spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); return true; @@ -1655,37 +1807,38 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); return true; } + if (io_req->abts_done) { shost_printk(KERN_ERR, fnic->lport->host, - "fnic_rport_exch_reset: io_req->abts_done is set " - "state is %s\n", + "fnic_rport_exch_reset: io_req->abts_done is set state is %s\n", fnic_ioreq_state_to_str(fnic_priv(sc)->state)); } if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) { shost_printk(KERN_ERR, fnic->lport->host, - "rport_exch_reset " - "IO not yet issued %p tag 0x%x flags " - "%x state %d\n", - sc, abt_tag, fnic_priv(sc)->flags, fnic_priv(sc)->state); + "rport_exch_reset IO not yet issued %p abt_tag 0x%x", + sc, abt_tag); + shost_printk(KERN_ERR, fnic->lport->host, + "flags %x state %d\n", fnic_priv(sc)->flags, + fnic_priv(sc)->state); } old_ioreq_state = fnic_priv(sc)->state; fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; fnic_priv(sc)->abts_status = FCPIO_INVALID_CODE; + if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { atomic64_inc(&reset_stats->device_reset_terminates); abt_tag |= FNIC_TAG_DEV_RST; } FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "fnic_rport_exch_reset dev rst sc 0x%p\n", sc); - BUG_ON(io_req->abts_done); - + "fnic_rport_exch_reset: dev rst sc 0x%p\n", sc); + WARN_ON_ONCE(io_req->abts_done); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "fnic_rport_reset_exch: Issuing abts\n"); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - /* Now queue the abort command to firmware */ + /* Queue the abort command to firmware */ int_to_scsilun(sc->device->lun, &fc_lun); if (fnic_queue_abort_io_req(fnic, abt_tag, @@ -1714,11 +1867,14 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) atomic64_inc(&term_stats->terminates); iter_data->term_cnt++; } + return true; } void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) { + unsigned int io_count = 0; + unsigned long flags; struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats; struct fnic_rport_abort_io_iter_data iter_data = { .fnic = fnic, @@ -1726,53 +1882,75 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) .term_cnt = 0, }; - FNIC_SCSI_DBG(KERN_DEBUG, - fnic->lport->host, fnic->fnic_num, - "fnic_rport_exch_reset called portid 0x%06x\n", - port_id); + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + "fnic rport exchange reset for tport: 0x%06x\n", + port_id); if (fnic->in_remove) return; + io_count = fnic_count_ioreqs(fnic, port_id); + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + "Starting terminates: rport:0x%x portid-io-count: %d active-io-count: %lld\n", + port_id, io_count, + atomic64_read(&fnic->fnic_stats.io_stats.active_ios)); + + spin_lock_irqsave(&fnic->fnic_lock, flags); + atomic_inc(&fnic->in_flight); + if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_IO_BLOCKED))) { + atomic_dec(&fnic->in_flight); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + return; + } + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + scsi_host_busy_iter(fnic->lport->host, fnic_rport_abort_io_iter, &iter_data); + if (iter_data.term_cnt > atomic64_read(&term_stats->max_terminates)) atomic64_set(&term_stats->max_terminates, iter_data.term_cnt); + atomic_dec(&fnic->in_flight); + + while ((io_count = fnic_count_ioreqs(fnic, port_id))) + schedule_timeout(msecs_to_jiffies(1000)); + + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + "rport: 0x%x remaining portid-io-count: %d ", + port_id, io_count); } void fnic_terminate_rport_io(struct fc_rport *rport) { - struct fc_rport_libfc_priv *rdata; - struct fc_lport *lport; - struct fnic *fnic; + struct fnic_tport_s *tport; + struct rport_dd_data_s *rdd_data; + struct fnic_iport_s *iport = NULL; + struct fnic *fnic = NULL; if (!rport) { - printk(KERN_ERR "fnic_terminate_rport_io: rport is NULL\n"); + pr_err("rport is NULL\n"); return; } - rdata = rport->dd_data; - if (!rdata) { - printk(KERN_ERR "fnic_terminate_rport_io: rdata is NULL\n"); - return; - } - lport = rdata->local_port; - - if (!lport) { - printk(KERN_ERR "fnic_terminate_rport_io: lport is NULL\n"); - return; + rdd_data = rport->dd_data; + if (rdd_data) { + tport = rdd_data->tport; + if (!tport) { + pr_err( + "term rport io called after tport is deleted. Returning 0x%8x\n", + rport->port_id); + } else { + pr_err( + "term rport io called after tport is set 0x%8x\n", + rport->port_id); + pr_err( + "tport maybe rediscovered\n"); + + iport = (struct fnic_iport_s *) tport->iport; + fnic = iport->fnic; + fnic_rport_exch_reset(fnic, rport->port_id); + } } - fnic = lport_priv(lport); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "wwpn 0x%llx, wwnn0x%llx, rport 0x%p, portid 0x%06x\n", - rport->port_name, rport->node_name, rport, - rport->port_id); - - if (fnic->in_remove) - return; - - fnic_rport_exch_reset(fnic, rport->port_id); } /* @@ -1783,10 +1961,12 @@ void fnic_terminate_rport_io(struct fc_rport *rport) int fnic_abort_cmd(struct scsi_cmnd *sc) { struct request *const rq = scsi_cmd_to_rq(sc); - struct fc_lport *lp; + struct fnic_iport_s *iport; + struct fnic_tport_s *tport; struct fnic *fnic; struct fnic_io_req *io_req = NULL; struct fc_rport *rport; + struct rport_dd_data_s *rdd_data; unsigned long flags; unsigned long start_time = 0; int ret = SUCCESS; @@ -1806,11 +1986,11 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) fc_block_scsi_eh(sc); /* Get local-port, check ready and link up */ - lp = shost_priv(sc->device->host); - - fnic = lport_priv(lp); + fnic = *((struct fnic **) shost_priv(sc->device->host)); spin_lock_irqsave(&fnic->fnic_lock, flags); + iport = &fnic->iport; + fnic_stats = &fnic->fnic_stats; abts_stats = &fnic->fnic_stats.abts_stats; term_stats = &fnic->fnic_stats.term_stats; @@ -1821,7 +2001,43 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) fnic_priv(sc)->flags = FNIC_NO_FLAGS; - if (lp->state != LPORT_ST_READY || !(lp->link_up)) { + rdd_data = rport->dd_data; + tport = rdd_data->tport; + + if (!tport) { + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Abort cmd called after tport delete! rport fcid: 0x%x", + rport->port_id); + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "lun: %llu hwq: 0x%x mqtag: 0x%x Op: 0x%x flags: 0x%x\n", + sc->device->lun, hwq, mqtag, + sc->cmnd[0], fnic_priv(sc)->flags); + ret = FAILED; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + goto fnic_abort_cmd_end; + } + + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Abort cmd called rport fcid: 0x%x lun: %llu hwq: 0x%x mqtag: 0x%x", + rport->port_id, sc->device->lun, hwq, mqtag); + + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Op: 0x%x flags: 0x%x\n", + sc->cmnd[0], + fnic_priv(sc)->flags); + + if (iport->state != FNIC_IPORT_STATE_READY) { + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "iport NOT in READY state"); + ret = FAILED; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + goto fnic_abort_cmd_end; + } + + if ((tport->state != FDLS_TGT_STATE_READY) && + (tport->state != FDLS_TGT_STATE_ADISC)) { + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "tport state: %d\n", tport->state); ret = FAILED; spin_unlock_irqrestore(&fnic->fnic_lock, flags); goto fnic_abort_cmd_end; @@ -1843,6 +2059,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); io_req = fnic_priv(sc)->io_req; if (!io_req) { + ret = FAILED; spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); goto fnic_abort_cmd_end; } @@ -1893,7 +2110,6 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) if (fc_remote_port_chkready(rport) == 0) task_req = FCPIO_ITMF_ABT_TASK; else { - atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); task_req = FCPIO_ITMF_ABT_TASK_TERM; } @@ -2027,6 +2243,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic, unsigned long flags; uint16_t hwq = 0; uint32_t tag = 0; + struct fnic_tport_s *tport = io_req->tport; tag = io_req->tag; hwq = blk_mq_unique_tag_to_hwq(tag); @@ -2037,8 +2254,10 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic, FNIC_FLAGS_IO_BLOCKED))) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); return FAILED; - } else + } else { atomic_inc(&fnic->in_flight); + atomic_inc(&tport->in_flight); + } spin_unlock_irqrestore(&fnic->fnic_lock, flags); spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); @@ -2072,6 +2291,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic, lr_io_req_end: spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); atomic_dec(&fnic->in_flight); + atomic_inc(&tport->in_flight); return ret; } @@ -2274,11 +2494,11 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, int fnic_device_reset(struct scsi_cmnd *sc) { struct request *rq = scsi_cmd_to_rq(sc); - struct fc_lport *lp; struct fnic *fnic; struct fnic_io_req *io_req = NULL; struct fc_rport *rport; int status; + int count = 0; int ret = FAILED; unsigned long flags; unsigned long start_time = 0; @@ -2289,31 +2509,61 @@ int fnic_device_reset(struct scsi_cmnd *sc) DECLARE_COMPLETION_ONSTACK(tm_done); bool new_sc = 0; uint16_t hwq = 0; + struct fnic_iport_s *iport = NULL; + struct rport_dd_data_s *rdd_data; + struct fnic_tport_s *tport; + u32 old_soft_reset_count; + u32 old_link_down_cnt; + int exit_dr = 0; /* Wait for rport to unblock */ fc_block_scsi_eh(sc); /* Get local-port, check ready and link up */ - lp = shost_priv(sc->device->host); + fnic = *((struct fnic **) shost_priv(sc->device->host)); + iport = &fnic->iport; - fnic = lport_priv(lp); fnic_stats = &fnic->fnic_stats; reset_stats = &fnic->fnic_stats.reset_stats; atomic64_inc(&reset_stats->device_resets); rport = starget_to_rport(scsi_target(sc->device)); + + spin_lock_irqsave(&fnic->fnic_lock, flags); FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "fcid: 0x%x lun: 0x%llx hwq: %d mqtag: 0x%x flags: 0x%x Device reset\n", + "fcid: 0x%x lun: %llu hwq: %d mqtag: 0x%x flags: 0x%x Device reset\n", rport->port_id, sc->device->lun, hwq, mqtag, fnic_priv(sc)->flags); - if (lp->state != LPORT_ST_READY || !(lp->link_up)) + rdd_data = rport->dd_data; + tport = rdd_data->tport; + if (!tport) { + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Dev rst called after tport delete! rport fcid: 0x%x lun: %llu\n", + rport->port_id, sc->device->lun); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + goto fnic_device_reset_end; + } + + if (iport->state != FNIC_IPORT_STATE_READY) { + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "iport NOT in READY state"); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); goto fnic_device_reset_end; + } + + if ((tport->state != FDLS_TGT_STATE_READY) && + (tport->state != FDLS_TGT_STATE_ADISC)) { + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "tport state: %d\n", tport->state); + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + goto fnic_device_reset_end; + } + spin_unlock_irqrestore(&fnic->fnic_lock, flags); /* Check if remote port up */ if (fc_remote_port_chkready(rport)) { - atomic64_inc(&fnic_stats->misc_stats.rport_not_ready); goto fnic_device_reset_end; } @@ -2352,6 +2602,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) io_req->port_id = rport->port_id; io_req->tag = mqtag; fnic_priv(sc)->io_req = io_req; + io_req->tport = tport; io_req->sc = sc; if (fnic->sw_copy_wq[hwq].io_req_table[blk_mq_unique_tag_to_tag(mqtag)] != NULL) @@ -2383,6 +2634,11 @@ int fnic_device_reset(struct scsi_cmnd *sc) fnic_priv(sc)->flags |= FNIC_DEV_RST_ISSUED; spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); + spin_lock_irqsave(&fnic->fnic_lock, flags); + old_link_down_cnt = iport->fnic->link_down_cnt; + old_soft_reset_count = fnic->soft_reset_count; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + /* * Wait on the local completion for LUN reset. The io_req may be * freed while we wait since we hold no lock. @@ -2390,6 +2646,24 @@ int fnic_device_reset(struct scsi_cmnd *sc) wait_for_completion_timeout(&tm_done, msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); + /* + * Wake up can be due to the following reasons: + * 1) The device reset completed from target. + * 2) Device reset timed out. + * 3) A link-down/host_reset may have happened in between. + * 4) The device reset was aborted and io_req->dr_done was called. + */ + + exit_dr = 0; + spin_lock_irqsave(&fnic->fnic_lock, flags); + if ((old_link_down_cnt != fnic->link_down_cnt) || + (fnic->reset_in_progress) || + (fnic->soft_reset_count != old_soft_reset_count) || + (iport->state != FNIC_IPORT_STATE_READY)) + exit_dr = 1; + + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); io_req = fnic_priv(sc)->io_req; if (!io_req) { @@ -2398,6 +2672,13 @@ int fnic_device_reset(struct scsi_cmnd *sc) "io_req is null mqtag 0x%x sc 0x%p\n", mqtag, sc); goto fnic_device_reset_end; } + + if (exit_dr) { + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Host reset called for fnic. Exit device reset\n"); + io_req->dr_done = NULL; + goto fnic_device_reset_clean; + } io_req->dr_done = NULL; status = fnic_priv(sc)->lr_status; @@ -2411,50 +2692,8 @@ int fnic_device_reset(struct scsi_cmnd *sc) FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "Device reset timed out\n"); fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT; - spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); int_to_scsilun(sc->device->lun, &fc_lun); - /* - * Issue abort and terminate on device reset request. - * If q'ing of terminate fails, retry it after a delay. - */ - while (1) { - spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); - if (fnic_priv(sc)->flags & FNIC_DEV_RST_TERM_ISSUED) { - spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - break; - } - spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - if (fnic_queue_abort_io_req(fnic, - mqtag | FNIC_TAG_DEV_RST, - FCPIO_ITMF_ABT_TASK_TERM, - fc_lun.scsi_lun, io_req, hwq)) { - wait_for_completion_timeout(&tm_done, - msecs_to_jiffies(FNIC_ABT_TERM_DELAY_TIMEOUT)); - } else { - spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); - fnic_priv(sc)->flags |= FNIC_DEV_RST_TERM_ISSUED; - fnic_priv(sc)->state = FNIC_IOREQ_ABTS_PENDING; - io_req->abts_done = &tm_done; - spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "Abort and terminate issued on Device reset mqtag 0x%x sc 0x%p\n", - mqtag, sc); - break; - } - } - while (1) { - spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); - if (!(fnic_priv(sc)->flags & FNIC_DEV_RST_DONE)) { - spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - wait_for_completion_timeout(&tm_done, - msecs_to_jiffies(FNIC_LUN_RESET_TIMEOUT)); - break; - } else { - io_req = fnic_priv(sc)->io_req; - io_req->abts_done = NULL; - goto fnic_device_reset_clean; - } - } + goto fnic_device_reset_clean; } else { spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); } @@ -2480,8 +2719,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); io_req = fnic_priv(sc)->io_req; FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "Device reset failed" - " since could not abort all IOs\n"); + "Device reset failed: Cannot abort all IOs\n"); goto fnic_device_reset_clean; } @@ -2507,6 +2745,15 @@ int fnic_device_reset(struct scsi_cmnd *sc) mempool_free(io_req, fnic->io_req_pool); } + /* + * If link-event is seen while LUN reset is issued we need + * to complete the LUN reset here + */ + if (!new_sc) { + sc->result = DID_RESET << 16; + scsi_done(sc); + } + fnic_device_reset_end: FNIC_TRACE(fnic_device_reset, sc->device->host->host_no, rq->tag, sc, jiffies_to_msecs(jiffies - start_time), @@ -2520,6 +2767,17 @@ int fnic_device_reset(struct scsi_cmnd *sc) mutex_unlock(&fnic->sgreset_mutex); } + while ((ret == SUCCESS) && fnic_count_lun_ioreqs(fnic, sc->device)) { + if (count >= 2) { + ret = FAILED; + break; + } + FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + "Cannot clean up all IOs for the LUN\n"); + schedule_timeout(msecs_to_jiffies(1000)); + count++; + } + FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "Returning from device reset %s\n", (ret == SUCCESS) ? @@ -2531,50 +2789,54 @@ int fnic_device_reset(struct scsi_cmnd *sc) return ret; } -/* Clean up all IOs, clean up libFC local port */ -int fnic_reset(struct Scsi_Host *shost) +static void fnic_post_flogo_linkflap(struct fnic *fnic) +{ + unsigned long flags; + + fnic_fdls_link_status_change(fnic, 0); + spin_lock_irqsave(&fnic->fnic_lock, flags); + + if (fnic->link_status) { + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + fnic_fdls_link_status_change(fnic, 1); + return; + } + spin_unlock_irqrestore(&fnic->fnic_lock, flags); +} + +/* Logout from all the targets and simulate link flap */ +void fnic_reset(struct Scsi_Host *shost) { - struct fc_lport *lp; struct fnic *fnic; - int ret = 0; struct reset_stats *reset_stats; - lp = shost_priv(shost); - fnic = lport_priv(lp); + fnic = *((struct fnic **) shost_priv(shost)); reset_stats = &fnic->fnic_stats.reset_stats; FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "Issuing fnic reset\n"); + "Issuing fnic reset\n"); atomic64_inc(&reset_stats->fnic_resets); - - /* - * Reset local port, this will clean up libFC exchanges, - * reset remote port sessions, and if link is up, begin flogi - */ - ret = fc_lport_reset(lp); + fnic_post_flogo_linkflap(fnic); FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, - "Returning from fnic reset with: %s\n", - (ret == 0) ? "SUCCESS" : "FAILED"); + "Returning from fnic reset"); - if (ret == 0) - atomic64_inc(&reset_stats->fnic_reset_completions); - else - atomic64_inc(&reset_stats->fnic_reset_failures); + atomic64_inc(&reset_stats->fnic_reset_completions); +} + +int fnic_issue_fc_host_lip(struct Scsi_Host *shost) +{ + int ret = 0; + struct fnic *fnic = *((struct fnic **) shost_priv(shost)); + + FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "FC host lip issued"); + ret = fnic_host_reset(shost); return ret; } -/* - * SCSI Error handling calls driver's eh_host_reset if all prior - * error handling levels return FAILED. If host reset completes - * successfully, and if link is up, then Fabric login begins. - * - * Host Reset is the highest level of error recovery. If this fails, then - * host is offlined by SCSI. - * - */ int fnic_host_reset(struct Scsi_Host *shost) { int ret; @@ -2637,122 +2899,6 @@ int fnic_host_reset(struct Scsi_Host *shost) return ret; } -/* - * This fxn is called from libFC when host is removed - */ -void fnic_scsi_abort_io(struct fc_lport *lp) -{ - int err = 0; - unsigned long flags; - enum fnic_state old_state; - struct fnic *fnic = lport_priv(lp); - DECLARE_COMPLETION_ONSTACK(remove_wait); - - /* Issue firmware reset for fnic, wait for reset to complete */ -retry_fw_reset: - spin_lock_irqsave(&fnic->fnic_lock, flags); - if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) && - fnic->link_events) { - /* fw reset is in progress, poll for its completion */ - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - schedule_timeout(msecs_to_jiffies(100)); - goto retry_fw_reset; - } - - fnic->remove_wait = &remove_wait; - old_state = fnic->state; - fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; - fnic_update_mac_locked(fnic, fnic->ctlr.ctl_src_addr); - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - - err = fnic_fw_reset_handler(fnic); - if (err) { - spin_lock_irqsave(&fnic->fnic_lock, flags); - if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) - fnic->state = old_state; - fnic->remove_wait = NULL; - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - return; - } - - /* Wait for firmware reset to complete */ - wait_for_completion_timeout(&remove_wait, - msecs_to_jiffies(FNIC_RMDEVICE_TIMEOUT)); - - spin_lock_irqsave(&fnic->fnic_lock, flags); - fnic->remove_wait = NULL; - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "fnic_scsi_abort_io %s\n", - (fnic->state == FNIC_IN_ETH_MODE) ? - "SUCCESS" : "FAILED"); - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - -} - -/* - * This fxn called from libFC to clean up driver IO state on link down - */ -void fnic_scsi_cleanup(struct fc_lport *lp) -{ - unsigned long flags; - enum fnic_state old_state; - struct fnic *fnic = lport_priv(lp); - - /* issue fw reset */ -retry_fw_reset: - spin_lock_irqsave(&fnic->fnic_lock, flags); - if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)) { - /* fw reset is in progress, poll for its completion */ - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - schedule_timeout(msecs_to_jiffies(100)); - goto retry_fw_reset; - } - old_state = fnic->state; - fnic->state = FNIC_IN_FC_TRANS_ETH_MODE; - fnic_update_mac_locked(fnic, fnic->ctlr.ctl_src_addr); - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - - if (fnic_fw_reset_handler(fnic)) { - spin_lock_irqsave(&fnic->fnic_lock, flags); - if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) - fnic->state = old_state; - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - } - -} - -void fnic_empty_scsi_cleanup(struct fc_lport *lp) -{ -} - -void fnic_exch_mgr_reset(struct fc_lport *lp, u32 sid, u32 did) -{ - struct fnic *fnic = lport_priv(lp); - - /* Non-zero sid, nothing to do */ - if (sid) - goto call_fc_exch_mgr_reset; - - if (did) { - fnic_rport_exch_reset(fnic, did); - goto call_fc_exch_mgr_reset; - } - - /* - * sid = 0, did = 0 - * link down or device being removed - */ - if (!fnic->in_remove) - fnic_scsi_cleanup(lp); - else - fnic_scsi_abort_io(lp); - - /* call libFC exch mgr reset to reset its exchanges */ -call_fc_exch_mgr_reset: - fc_exch_mgr_reset(lp, sid, did); - -} - static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data) { struct request *const rq = scsi_cmd_to_rq(sc); diff --git a/drivers/scsi/fnic/fnic_stats.h b/drivers/scsi/fnic/fnic_stats.h index 9d7f98c452dd..1f1a1ec90a23 100644 --- a/drivers/scsi/fnic/fnic_stats.h +++ b/drivers/scsi/fnic/fnic_stats.h @@ -127,6 +127,4 @@ struct stats_debug_info { }; int fnic_get_stats_data(struct stats_debug_info *, struct fnic_stats *); -void fnic_stats_debugfs_init(struct fnic *); -void fnic_stats_debugfs_remove(struct fnic *); #endif /* _FNIC_STATS_H_ */ From patchwork Fri Sep 27 18:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831144 Received: from rcdn-iport-7.cisco.com (rcdn-iport-7.cisco.com [173.37.86.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC2D91C0DFB; Fri, 27 Sep 2024 18:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.78 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463175; cv=none; b=SQPOa+Q9diJZQddd6DfIzyIbGKyp2fOW8pcdedTSD8o6VvbVSsHq/D7nO3jDL7nXAgc/6zA6BH/Zq1LpYBrP9zQ+1h8R1DOU0E00YLHkyNPFdlJlR1ttDaf42yn8JHbKRzKnDXgAuI4HVG1pYqr5xhrzE1fV83Dpxca5Ie6R5QA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463175; c=relaxed/simple; bh=pCKPyP7vhFSfah/4xpTfCSjxsAiOkjXfLGshToImMp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nGrJJHB4DJgNLFbmDr6U5w4L7QMXV5+oa1zjLeLQMl2bOoSbcbNnSyNE4uoO9BxO9QTEsMNu1+1lRKlG7dhukDlUSpYnVtuQd7wqbT90epbaECLKzD82KSs7jN8mTUW4xvGZyRSgo1ghx3dZZtQ+6+lR8Yd3pc5wSLEi0Q8476g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=Vc/BUOjj; arc=none smtp.client-ip=173.37.86.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="Vc/BUOjj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=40129; q=dns/txt; s=iport; t=1727463172; x=1728672772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SEuUxXk/mOIXSfXZ7NdXvPszKKwb3h4PQLHn42OCS8Q=; b=Vc/BUOjjeTsQ420DMLS1ro80HhcJ8l0whmNK5Gg4vlUn3vkqDQHBJwhb yyfRoCenX7iE153gJgs1l3QbOkE9Ml3If3x2+71sdApkAFqE5xEtMzxIi 8GHU8HQZysFXUZdURd7T8oi2VBwLPfD+lhIIMCzpn0zPieJ/q1g23KPN+ Y=; X-CSE-ConnectionGUID: 2ZkhyADaTiinYOE3N5d+Ww== X-CSE-MsgGUID: CGZhBeeCRaywGbrz5cNxvA== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="266828145" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-7.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:52:51 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQar022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:52:51 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar Subject: [PATCH v3 10/14] scsi: fnic: Modify fnic interfaces to use FDLS Date: Fri, 27 Sep 2024 11:46:09 -0700 Message-Id: <20240927184613.52172-11-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Modify fnic driver interfaces to use FDLS and supporting functions. Refactor code in fnic_probe and fnic_remove. Get fnic from shost_priv. Add error handling in stats processing functions. Modify some print statements. Add support to do module unload cleanup. Use placeholder functions/modify function declarations to not break compilation. Reviewed-by: Sesidhar Baddela Reviewed-by: Arulprabhu Ponnusamy Reviewed-by: Gian Carlo Boffa Signed-off-by: Arun Easi Signed-off-by: Karan Tilak Kumar --- Changes between v2 and v3: Modify scsi_unload to fix null pointer exception during fnic_remove. Replace fnic->host with fnic->lport->host to prevent compilation errors. Changes between v1 and v2: Incorporate review comments from Hannes from other patches: Replace pr_info with dev_info. Replace pr_err with dev_err. --- drivers/scsi/fnic/fnic.h | 12 +- drivers/scsi/fnic/fnic_attrs.c | 12 +- drivers/scsi/fnic/fnic_debugfs.c | 28 +- drivers/scsi/fnic/fnic_fcs.c | 16 + drivers/scsi/fnic/fnic_main.c | 491 +++++++++++++++++-------------- drivers/scsi/fnic/fnic_res.c | 30 +- drivers/scsi/fnic/fnic_scsi.c | 39 +++ drivers/scsi/fnic/fnic_trace.c | 6 + 8 files changed, 384 insertions(+), 250 deletions(-) diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index c6fe9eec9a0c..58d864b59c89 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -81,6 +81,7 @@ #define IS_FNIC_FCP_INITIATOR(fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) #define FNIC_FW_RESET_TIMEOUT 60000 /* mSec */ +#define FNIC_FCOE_MAX_CMD_LEN 16 /* Retry supported by rport (returned by PRLI service parameters) */ #define FNIC_FC_RP_FLAGS_RETRY 0x1 @@ -340,6 +341,7 @@ struct fnic { int fnic_num; enum fnic_role_e role; struct fnic_iport_s iport; + struct Scsi_Host *host; struct fc_lport *lport; struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */ struct vnic_dev_bar bar0; @@ -458,11 +460,6 @@ struct fnic { ____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX]; }; -static inline struct fnic *fnic_from_ctlr(struct fcoe_ctlr *fip) -{ - return container_of(fip, struct fnic, ctlr); -} - extern struct workqueue_struct *fnic_event_queue; extern struct workqueue_struct *fnic_fip_queue; extern const struct attribute_group *fnic_host_groups[]; @@ -491,6 +488,7 @@ int fnic_eh_host_reset_handler(struct scsi_cmnd *sc); int fnic_host_reset(struct Scsi_Host *shost); void fnic_reset(struct Scsi_Host *shost); int fnic_issue_fc_host_lip(struct Scsi_Host *shost); +void fnic_get_host_port_state(struct Scsi_Host *shost); void fnic_scsi_fcpio_reset(struct fnic *fnic); int fnic_wq_copy_cmpl_handler(struct fnic *fnic, int copy_work_to_do, unsigned int cq_index); int fnic_wq_cmpl_handler(struct fnic *fnic, int); @@ -503,7 +501,7 @@ const char *fnic_state_to_str(unsigned int state); void fnic_mq_map_queues_cpus(struct Scsi_Host *host); void fnic_log_q_error(struct fnic *fnic); void fnic_handle_link_event(struct fnic *fnic); -void fnic_stats_debugfs_init(struct fnic *fnic); +int fnic_stats_debugfs_init(struct fnic *fnic); void fnic_stats_debugfs_remove(struct fnic *fnic); int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *); @@ -532,5 +530,7 @@ unsigned int fnic_count_lun_ioreqs_wq(struct fnic *fnic, u32 hwq, struct scsi_device *device); unsigned int fnic_count_lun_ioreqs(struct fnic *fnic, struct scsi_device *device); +void fnic_scsi_unload(struct fnic *fnic); +void fnic_scsi_unload_cleanup(struct fnic *fnic); #endif /* _FNIC_H_ */ diff --git a/drivers/scsi/fnic/fnic_attrs.c b/drivers/scsi/fnic/fnic_attrs.c index 0c5e57c7e322..705718f0809b 100644 --- a/drivers/scsi/fnic/fnic_attrs.c +++ b/drivers/scsi/fnic/fnic_attrs.c @@ -11,8 +11,8 @@ static ssize_t fnic_show_state(struct device *dev, struct device_attribute *attr, char *buf) { - struct fc_lport *lp = shost_priv(class_to_shost(dev)); - struct fnic *fnic = lport_priv(lp); + struct fnic *fnic = + *((struct fnic **) shost_priv(class_to_shost(dev))); return sysfs_emit(buf, "%s\n", fnic_state_str[fnic->state]); } @@ -26,9 +26,13 @@ static ssize_t fnic_show_drv_version(struct device *dev, static ssize_t fnic_show_link_state(struct device *dev, struct device_attribute *attr, char *buf) { - struct fc_lport *lp = shost_priv(class_to_shost(dev)); + struct fnic *fnic = + *((struct fnic **) shost_priv(class_to_shost(dev))); - return sysfs_emit(buf, "%s\n", (lp->link_up) ? "Link Up" : "Link Down"); + return sysfs_emit(buf, "%s\n", + ((fnic->iport.state != FNIC_IPORT_STATE_INIT) && + (fnic->iport.state != FNIC_IPORT_STATE_LINK_WAIT)) ? + "Link Up" : "Link Down"); } static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL); diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c index 2619a2d4f5f1..3748bbe190f7 100644 --- a/drivers/scsi/fnic/fnic_debugfs.c +++ b/drivers/scsi/fnic/fnic_debugfs.c @@ -7,6 +7,9 @@ #include #include "fnic.h" +extern int fnic_get_debug_info(struct stats_debug_info *debug_buffer, + struct fnic *fnic); + static struct dentry *fnic_trace_debugfs_root; static struct dentry *fnic_trace_debugfs_file; static struct dentry *fnic_trace_enable; @@ -593,6 +596,7 @@ static int fnic_stats_debugfs_open(struct inode *inode, debug->buf_size = buf_size; memset((void *)debug->debug_buffer, 0, buf_size); debug->buffer_len = fnic_get_stats_data(debug, fnic_stats); + debug->buffer_len += fnic_get_debug_info(debug, fnic); file->private_data = debug; @@ -673,26 +677,48 @@ static const struct file_operations fnic_reset_debugfs_fops = { * It will create file stats and reset_stats under statistics/host# directory * to log per fnic stats. */ -void fnic_stats_debugfs_init(struct fnic *fnic) +int fnic_stats_debugfs_init(struct fnic *fnic) { + int rc = -1; char name[16]; snprintf(name, sizeof(name), "host%d", fnic->lport->host->host_no); + if (!fnic_stats_debugfs_root) { + pr_debug("fnic_stats root doesn't exist\n"); + return rc; + } + fnic->fnic_stats_debugfs_host = debugfs_create_dir(name, fnic_stats_debugfs_root); + if (!fnic->fnic_stats_debugfs_host) { + pr_debug("Cannot create host directory\n"); + return rc; + } + fnic->fnic_stats_debugfs_file = debugfs_create_file("stats", S_IFREG|S_IRUGO|S_IWUSR, fnic->fnic_stats_debugfs_host, fnic, &fnic_stats_debugfs_fops); + if (!fnic->fnic_stats_debugfs_file) { + pr_debug("Cannot create host stats file\n"); + return rc; + } + fnic->fnic_reset_debugfs_file = debugfs_create_file("reset_stats", S_IFREG|S_IRUGO|S_IWUSR, fnic->fnic_stats_debugfs_host, fnic, &fnic_reset_debugfs_fops); + if (!fnic->fnic_reset_debugfs_file) { + pr_debug("Cannot create host stats file\n"); + return rc; + } + rc = 0; + return rc; } /* diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c index d3fdb8dd9c16..9fba2f654980 100644 --- a/drivers/scsi/fnic/fnic_fcs.c +++ b/drivers/scsi/fnic/fnic_fcs.c @@ -80,6 +80,22 @@ static inline void fnic_fdls_set_fcoe_dstmac(struct fnic *fnic, memcpy(fnic->iport.fcfmac, dst_mac, 6); } +void fnic_get_host_port_state(struct Scsi_Host *shost) +{ + struct fnic *fnic = *((struct fnic **) shost_priv(shost)); + struct fnic_iport_s *iport = &fnic->iport; + unsigned long flags; + + spin_lock_irqsave(&fnic->fnic_lock, flags); + if (!fnic->link_status) + fc_host_port_state(shost) = FC_PORTSTATE_LINKDOWN; + else if (iport->state == FNIC_IPORT_STATE_READY) + fc_host_port_state(shost) = FC_PORTSTATE_ONLINE; + else + fc_host_port_state(shost) = FC_PORTSTATE_OFFLINE; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); +} + void fnic_fdls_link_status_change(struct fnic *fnic, int linkup) { struct fnic_iport_s *iport = &fnic->iport; diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 4729edbba18c..719aa3e53ca9 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -66,6 +66,11 @@ unsigned int fnic_fdmi_support = 1; module_param(fnic_fdmi_support, int, 0644); MODULE_PARM_DESC(fnic_fdmi_support, "FDMI support"); +unsigned int fnic_tgt_id_binding = 1; +module_param(fnic_tgt_id_binding, uint, 0644); +MODULE_PARM_DESC(fnic_tgt_id_binding, + "Target ID binding (0 for none. 1 for binding by WWPN (default))"); + unsigned int io_completions = FNIC_DFLT_IO_COMPLETIONS; module_param(io_completions, int, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(io_completions, "Max CQ entries to process at a time"); @@ -84,9 +89,6 @@ static unsigned int fnic_max_qdepth = FNIC_DFLT_QUEUE_DEPTH; module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(fnic_max_qdepth, "Queue depth to report for each LUN"); -static struct libfc_function_template fnic_transport_template = { -}; - struct workqueue_struct *fnic_fip_queue; static int fnic_slave_alloc(struct scsi_device *sdev) @@ -148,7 +150,7 @@ static struct fc_function_template fnic_fc_functions = { .get_host_speed = fnic_get_host_speed, .show_host_speed = 1, .show_host_port_type = 1, - .get_host_port_state = fc_get_host_port_state, + .get_host_port_state = fnic_get_host_port_state, .show_host_port_state = 1, .show_host_symbolic_name = 1, .show_rport_maxframe_size = 1, @@ -160,79 +162,78 @@ static struct fc_function_template fnic_fc_functions = { .show_rport_dev_loss_tmo = 1, .set_rport_dev_loss_tmo = fnic_set_rport_dev_loss_tmo, .issue_fc_host_lip = fnic_issue_fc_host_lip, - .get_fc_host_stats = fnic_get_stats, + .get_fc_host_stats = NULL, .reset_fc_host_stats = fnic_reset_host_stats, - .dd_fcrport_size = sizeof(struct fc_rport_libfc_priv), + .dd_fcrport_size = sizeof(struct rport_dd_data_s), .terminate_rport_io = fnic_terminate_rport_io, - .bsg_request = fc_lport_bsg_request, + .bsg_request = NULL, }; static void fnic_get_host_speed(struct Scsi_Host *shost) { - struct fc_lport *lp = shost_priv(shost); - struct fnic *fnic = lport_priv(lp); + struct fnic *fnic = *((struct fnic **) shost_priv(shost)); u32 port_speed = vnic_dev_port_speed(fnic->vdev); + FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "port_speed: %d Mbps", port_speed); + /* Add in other values as they get defined in fw */ switch (port_speed) { + case DCEM_PORTSPEED_1G: + fc_host_speed(shost) = FC_PORTSPEED_1GBIT; + break; + case DCEM_PORTSPEED_2G: + fc_host_speed(shost) = FC_PORTSPEED_2GBIT; + break; + case DCEM_PORTSPEED_4G: + fc_host_speed(shost) = FC_PORTSPEED_4GBIT; + break; + case DCEM_PORTSPEED_8G: + fc_host_speed(shost) = FC_PORTSPEED_8GBIT; + break; case DCEM_PORTSPEED_10G: fc_host_speed(shost) = FC_PORTSPEED_10GBIT; break; + case DCEM_PORTSPEED_16G: + fc_host_speed(shost) = FC_PORTSPEED_16GBIT; + break; case DCEM_PORTSPEED_20G: fc_host_speed(shost) = FC_PORTSPEED_20GBIT; break; case DCEM_PORTSPEED_25G: fc_host_speed(shost) = FC_PORTSPEED_25GBIT; break; + case DCEM_PORTSPEED_32G: + fc_host_speed(shost) = FC_PORTSPEED_32GBIT; + break; case DCEM_PORTSPEED_40G: case DCEM_PORTSPEED_4x10G: fc_host_speed(shost) = FC_PORTSPEED_40GBIT; break; + case DCEM_PORTSPEED_50G: + fc_host_speed(shost) = FC_PORTSPEED_50GBIT; + break; + case DCEM_PORTSPEED_64G: + fc_host_speed(shost) = FC_PORTSPEED_64GBIT; + break; case DCEM_PORTSPEED_100G: fc_host_speed(shost) = FC_PORTSPEED_100GBIT; break; + case DCEM_PORTSPEED_128G: + fc_host_speed(shost) = FC_PORTSPEED_128GBIT; + break; default: + FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + "Unknown FC speed: %d Mbps", port_speed); fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; break; } } +/* Placeholder function */ static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host) { - int ret; - struct fc_lport *lp = shost_priv(host); - struct fnic *fnic = lport_priv(lp); - struct fc_host_statistics *stats = &lp->host_stats; - struct vnic_stats *vs; - unsigned long flags; - - if (time_before(jiffies, fnic->stats_time + HZ / FNIC_STATS_RATE_LIMIT)) - return stats; - fnic->stats_time = jiffies; - - spin_lock_irqsave(&fnic->fnic_lock, flags); - ret = vnic_dev_stats_dump(fnic->vdev, &fnic->stats); - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - - if (ret) { - FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, - "fnic: Get vnic stats failed" - " 0x%x", ret); - return stats; - } - vs = fnic->stats; - stats->tx_frames = vs->tx.tx_unicast_frames_ok; - stats->tx_words = vs->tx.tx_unicast_bytes_ok / 4; - stats->rx_frames = vs->rx.rx_unicast_frames_ok; - stats->rx_words = vs->rx.rx_unicast_bytes_ok / 4; - stats->error_frames = vs->tx.tx_errors + vs->rx.rx_errors; - stats->dumped_frames = vs->tx.tx_drops + vs->rx.rx_drop; - stats->invalid_crc_count = vs->rx.rx_crc_errors; - stats->seconds_since_last_reset = - (jiffies - fnic->stats_reset_time) / HZ; - stats->fcp_input_megabytes = div_u64(fnic->fcp_input_bytes, 1000000); - stats->fcp_output_megabytes = div_u64(fnic->fcp_output_bytes, 1000000); - + struct fc_host_statistics *stats; return stats; } @@ -313,8 +314,7 @@ void fnic_dump_fchost_stats(struct Scsi_Host *host, static void fnic_reset_host_stats(struct Scsi_Host *host) { int ret; - struct fc_lport *lp = shost_priv(host); - struct fnic *fnic = lport_priv(lp); + struct fnic *fnic = *((struct fnic **) shost_priv(host)); struct fc_host_statistics *stats; unsigned long flags; @@ -527,9 +527,23 @@ static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) vnic_dev_set_default_vlan(fnic->vdev, vlan_id); } +static void fnic_scsi_init(struct fnic *fnic) +{ + struct Scsi_Host *host = fnic->lport->host; + + snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, + host->host_no); + + host->transportt = fnic_fc_transport; +} + static int fnic_scsi_drv_init(struct fnic *fnic) { struct Scsi_Host *host = fnic->lport->host; + int err; + struct pci_dev *pdev = fnic->pdev; + struct fnic_iport_s *iport = &fnic->iport; + int hwq; /* Configure maximum outstanding IO reqs*/ if (fnic->config.io_throttle_count != FNIC_UCSM_DFLT_THROTTLE_CNT_BLD) @@ -540,7 +554,7 @@ static int fnic_scsi_drv_init(struct fnic *fnic) fnic->fnic_max_tag_id = host->can_queue; host->max_lun = fnic->config.luns_per_tgt; host->max_id = FNIC_MAX_FCP_TARGET; - host->max_cmd_len = FCOE_MAX_CMD_LEN; + host->max_cmd_len = FNIC_FCOE_MAX_CMD_LEN; host->nr_hw_queues = fnic->wq_copy_count; @@ -550,13 +564,62 @@ static int fnic_scsi_drv_init(struct fnic *fnic) dev_info(&fnic->pdev->dev, "fnic: max_id: %d max_cmd_len: %d nr_hw_queues: %d", host->max_id, host->max_cmd_len, host->nr_hw_queues); + for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) { + fnic->sw_copy_wq[hwq].ioreq_table_size = fnic->fnic_max_tag_id; + fnic->sw_copy_wq[hwq].io_req_table = + kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) * + sizeof(struct fnic_io_req *), GFP_KERNEL); + } + + dev_info(&fnic->pdev->dev, "fnic copy wqs: %d, Q0 ioreq table size: %d\n", + fnic->wq_copy_count, fnic->sw_copy_wq[0].ioreq_table_size); + + fnic_scsi_init(fnic); + + err = scsi_add_host(fnic->lport->host, &pdev->dev); + if (err) { + dev_err(&fnic->pdev->dev, "fnic: scsi add host failed: aborting\n"); + return -1; + } + fc_host_maxframe_size(fnic->lport->host) = iport->max_payload_size; + fc_host_dev_loss_tmo(fnic->lport->host) = + fnic->config.port_down_timeout / 1000; + sprintf(fc_host_symbolic_name(fnic->lport->host), + DRV_NAME " v" DRV_VERSION " over %s", fnic->name); + fc_host_port_type(fnic->lport->host) = FC_PORTTYPE_NPORT; + fc_host_node_name(fnic->lport->host) = iport->wwnn; + fc_host_port_name(fnic->lport->host) = iport->wwpn; + fc_host_supported_classes(fnic->lport->host) = FC_COS_CLASS3; + memset(fc_host_supported_fc4s(fnic->lport->host), 0, + sizeof(fc_host_supported_fc4s(fnic->lport->host))); + fc_host_supported_fc4s(fnic->lport->host)[2] = 1; + fc_host_supported_fc4s(fnic->lport->host)[7] = 1; + fc_host_supported_speeds(fnic->lport->host) = 0; + fc_host_supported_speeds(fnic->lport->host) |= FC_PORTSPEED_8GBIT; + + dev_info(&fnic->pdev->dev, "shost_data: 0x%p\n", fnic->lport->host->shost_data); + if (fnic->lport->host->shost_data != NULL) { + if (fnic_tgt_id_binding == 0) { + dev_info(&fnic->pdev->dev, "Setting target binding to NONE\n"); + fc_host_tgtid_bind_type(fnic->lport->host) = FC_TGTID_BIND_NONE; + } else { + dev_info(&fnic->pdev->dev, "Setting target binding to WWPN\n"); + fc_host_tgtid_bind_type(fnic->lport->host) = FC_TGTID_BIND_BY_WWPN; + } + } + + fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); + if (!fnic->io_req_pool) { + scsi_remove_host(fnic->lport->host); + return -ENOMEM; + } + return 0; } void fnic_mq_map_queues_cpus(struct Scsi_Host *host) { - struct fc_lport *lp = shost_priv(host); - struct fnic *fnic = lport_priv(lp); + struct fnic *fnic = *((struct fnic **) shost_priv(host)); struct pci_dev *l_pdev = fnic->pdev; int intr_mode = fnic->config.intr_mode; struct blk_mq_queue_map *qmap = &host->tag_set.map[HCTX_TYPE_DEFAULT]; @@ -581,31 +644,27 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host) static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - struct Scsi_Host *host; - struct fc_lport *lp; + struct Scsi_Host *host = NULL; struct fnic *fnic; mempool_t *pool; + struct fnic_iport_s *iport; int err = 0; int fnic_id = 0; int i; unsigned long flags; - int hwq; char *desc, *subsys_desc; int len; /* - * Allocate SCSI Host and set up association between host, - * local port, and fnic + * Allocate fnic */ - lp = libfc_host_alloc(&fnic_host_template, sizeof(struct fnic)); - if (!lp) { - dev_err(&pdev->dev, "Unable to alloc libfc local port\n"); + fnic = kzalloc(sizeof(struct fnic), GFP_KERNEL); + if (!fnic) { err = -ENOMEM; - goto err_out; + goto err_out_fnic_alloc; } - host = lp->host; - fnic = lport_priv(lp); + iport = &fnic->iport; fnic_id = ida_alloc(&fnic_ida, GFP_KERNEL); if (fnic_id < 0) { @@ -613,17 +672,9 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = fnic_id; goto err_out_ida_alloc; } - fnic->lport = lp; - fnic->ctlr.lp = lp; - fnic->link_events = 0; - fnic->pdev = pdev; - snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, - host->host_no); - - host->transportt = fnic_fc_transport; + fnic->pdev = pdev; fnic->fnic_num = fnic_id; - fnic_stats_debugfs_init(fnic); /* Find model name from PCIe subsys ID */ if (fnic_get_desc_by_devid(pdev, &desc, &subsys_desc) == 0) { @@ -645,13 +696,13 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = pci_enable_device(pdev); if (err) { dev_err(&fnic->pdev->dev, "Cannot enable PCI device, aborting.\n"); - goto err_out_free_hba; + goto err_out_pci_enable_device; } err = pci_request_regions(pdev, DRV_NAME); if (err) { dev_err(&fnic->pdev->dev, "Cannot enable PCI resources, aborting\n"); - goto err_out_disable_device; + goto err_out_pci_request_regions; } pci_set_master(pdev); @@ -666,7 +717,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) { dev_err(&fnic->pdev->dev, "No usable DMA configuration " "aborting\n"); - goto err_out_release_regions; + goto err_out_set_dma_mask; } } @@ -674,7 +725,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { dev_err(&fnic->pdev->dev, "BAR0 not memory-map'able, aborting.\n"); err = -ENODEV; - goto err_out_release_regions; + goto err_out_map_bar; } fnic->bar0.vaddr = pci_iomap(pdev, 0, 0); @@ -685,7 +736,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) dev_err(&fnic->pdev->dev, "Cannot memory-map BAR0 res hdr, " "aborting.\n"); err = -ENODEV; - goto err_out_release_regions; + goto err_out_fnic_map_bar; } fnic->vdev = vnic_dev_register(NULL, fnic, pdev, &fnic->bar0); @@ -693,43 +744,67 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) dev_err(&fnic->pdev->dev, "vNIC registration failed, " "aborting.\n"); err = -ENODEV; - goto err_out_iounmap; + goto err_out_dev_register; } err = vnic_dev_cmd_init(fnic->vdev); if (err) { dev_err(&fnic->pdev->dev, "vnic_dev_cmd_init() returns %d, aborting\n", err); - goto err_out_vnic_unregister; + goto err_out_dev_cmd_init; } err = fnic_dev_wait(fnic->vdev, vnic_dev_open, vnic_dev_open_done, CMD_OPENF_RQ_ENABLE_THEN_POST); if (err) { dev_err(&fnic->pdev->dev, "vNIC dev open failed, aborting.\n"); - goto err_out_dev_cmd_deinit; + goto err_out_dev_open; } err = vnic_dev_init(fnic->vdev, 0); if (err) { dev_err(&fnic->pdev->dev, "vNIC dev init failed, aborting.\n"); - goto err_out_dev_close; + goto err_out_dev_init; } - err = vnic_dev_mac_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); + err = vnic_dev_mac_addr(fnic->vdev, iport->hwmac); if (err) { dev_err(&fnic->pdev->dev, "vNIC get MAC addr failed\n"); - goto err_out_dev_close; + goto err_out_dev_mac_addr; } /* set data_src for point-to-point mode and to keep it non-zero */ - memcpy(fnic->data_src_addr, fnic->ctlr.ctl_src_addr, ETH_ALEN); + memcpy(fnic->data_src_addr, iport->hwmac, ETH_ALEN); /* Get vNIC configuration */ err = fnic_get_vnic_config(fnic); if (err) { dev_err(&fnic->pdev->dev, "Get vNIC configuration failed, " "aborting.\n"); - goto err_out_dev_close; + goto err_out_fnic_get_config; + } + + switch (fnic->config.flags & 0xff0) { + case VFCF_FC_INITIATOR: + { + host = + scsi_host_alloc(&fnic_host_template, + sizeof(struct fnic *)); + if (!host) { + dev_err(&fnic->pdev->dev, "Unable to allocate scsi host\n"); + err = -ENOMEM; + goto err_out_scsi_host_alloc; + } + *((struct fnic **) shost_priv(host)) = fnic; + + fnic->lport->host = host; + fnic->role = FNIC_ROLE_FCP_INITIATOR; + dev_info(&fnic->pdev->dev, "fnic: %d is scsi initiator\n", + fnic->fnic_num); + } + break; + default: + dev_info(&fnic->pdev->dev, "fnic: %d has no role defined\n", fnic->fnic_num); + goto err_out_fnic_role; } /* Setup PCI resources */ @@ -741,23 +816,14 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) { dev_err(&fnic->pdev->dev, "Failed to set intr mode, " "aborting.\n"); - goto err_out_dev_close; + goto err_out_fnic_set_intr_mode; } err = fnic_alloc_vnic_resources(fnic); if (err) { dev_err(&fnic->pdev->dev, "Failed to alloc vNIC resources, " "aborting.\n"); - goto err_out_clear_intr; - } - - fnic_scsi_drv_init(fnic); - - for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) { - fnic->sw_copy_wq[hwq].ioreq_table_size = fnic->fnic_max_tag_id; - fnic->sw_copy_wq[hwq].io_req_table = - kzalloc((fnic->sw_copy_wq[hwq].ioreq_table_size + 1) * - sizeof(struct fnic_io_req *), GFP_KERNEL); + goto err_out_fnic_alloc_vnic_res; } dev_info(&fnic->pdev->dev, "fnic copy wqs: %d, Q0 ioreq table size: %d\n", fnic->wq_copy_count, fnic->sw_copy_wq[0].ioreq_table_size); @@ -775,14 +841,9 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->fw_ack_index[i] = -1; } - err = -ENOMEM; - fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); - if (!fnic->io_req_pool) - goto err_out_free_resources; - pool = mempool_create_slab_pool(2, fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]); if (!pool) - goto err_out_free_ioreq_pool; + goto err_out_free_resources; fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT] = pool; pool = mempool_create_slab_pool(2, fnic_sgl_cache[FNIC_SGL_CACHE_MAX]); @@ -799,8 +860,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* enable directed and multicast */ vnic_dev_packet_filter(fnic->vdev, 1, 1, 0, 0, 0); vnic_dev_add_addr(fnic->vdev, FIP_ALL_ENODE_MACS); - vnic_dev_add_addr(fnic->vdev, fnic->ctlr.ctl_src_addr); - fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_AUTO); + vnic_dev_add_addr(fnic->vdev, iport->hwmac); spin_lock_init(&fnic->vlans_lock); INIT_WORK(&fnic->fip_frame_work, fnic_handle_fip_frame); INIT_WORK(&fnic->flush_work, fnic_flush_tx); @@ -813,8 +873,6 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->set_vlan = fnic_set_vlan; } else { dev_info(&fnic->pdev->dev, "firmware uses non-FIP mode\n"); - fcoe_ctlr_init(&fnic->ctlr, FIP_MODE_NON_FIP); - fnic->ctlr.state = FIP_ST_NON_FIP; } fnic->state = FNIC_IN_FC_MODE; @@ -828,7 +886,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = fnic_notify_set(fnic); if (err) { dev_err(&fnic->pdev->dev, "Failed to alloc notify buffer, aborting.\n"); - goto err_out_free_max_pool; + goto err_out_fnic_notify_set; } /* Setup notify timer when using MSI interrupts */ @@ -841,10 +899,52 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) { dev_err(&fnic->pdev->dev, "fnic_alloc_rq_frame can't alloc " "frame\n"); - goto err_out_rq_buf; + goto err_out_alloc_rq_buf; } } + init_completion(&fnic->reset_completion_wait); + + /* Start local port initialization */ + iport->max_flogi_retries = fnic->config.flogi_retries; + iport->max_plogi_retries = fnic->config.plogi_retries; + iport->plogi_timeout = fnic->config.plogi_timeout; + iport->service_params = + (FNIC_FCP_SP_INITIATOR | FNIC_FCP_SP_RD_XRDY_DIS | + FNIC_FCP_SP_CONF_CMPL); + if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) + iport->service_params |= FNIC_FCP_SP_RETRY; + + iport->boot_time = jiffies; + iport->e_d_tov = fnic->config.ed_tov; + iport->r_a_tov = fnic->config.ra_tov; + iport->link_supported_speeds = FNIC_PORTSPEED_10GBIT; + iport->wwpn = fnic->config.port_wwn; + iport->wwnn = fnic->config.node_wwn; + + iport->max_payload_size = fnic->config.maxdatafieldsize; + + if ((iport->max_payload_size < FNIC_MIN_DATA_FIELD_SIZE) || + (iport->max_payload_size > FNIC_FC_MAX_PAYLOAD_LEN) || + ((iport->max_payload_size % 4) != 0)) { + iport->max_payload_size = FNIC_FC_MAX_PAYLOAD_LEN; + } + + iport->flags |= FNIC_FIRST_LINK_UP; + + timer_setup(&(iport->fabric.retry_timer), fdls_fabric_timer_callback, + 0); + + fnic->stats_reset_time = jiffies; + + INIT_WORK(&fnic->link_work, fnic_handle_link); + INIT_WORK(&fnic->frame_work, fnic_handle_frame); + INIT_WORK(&fnic->tport_work, fnic_tport_event_handler); + + INIT_LIST_HEAD(&fnic->frame_queue); + INIT_LIST_HEAD(&fnic->tx_queue); + INIT_LIST_HEAD(&fnic->tport_event_list); + /* Enable all queues */ for (i = 0; i < fnic->raw_wq_count; i++) vnic_wq_enable(&fnic->wq[i]); @@ -855,158 +955,105 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) for (i = 0; i < fnic->wq_copy_count; i++) vnic_wq_copy_enable(&fnic->hw_copy_wq[i]); + vnic_dev_enable(fnic->vdev); + err = fnic_request_intr(fnic); if (err) { dev_err(&fnic->pdev->dev, "Unable to request irq.\n"); - goto err_out_request_intr; - } - - /* - * Initialization done with PCI system, hardware, firmware. - * Add host to SCSI - */ - err = scsi_add_host(lp->host, &pdev->dev); - if (err) { - dev_err(&fnic->pdev->dev, "fnic: scsi_add_host failed...exiting\n"); - goto err_out_scsi_add_host; + goto err_out_fnic_request_intr; } + fnic_notify_timer_start(fnic); - /* Start local port initiatialization */ - - lp->link_up = 0; - - lp->max_retry_count = fnic->config.flogi_retries; - lp->max_rport_retry_count = fnic->config.plogi_retries; - lp->service_params = (FCP_SPPF_INIT_FCN | FCP_SPPF_RD_XRDY_DIS | - FCP_SPPF_CONF_COMPL); - if (fnic->config.flags & VFCF_FCP_SEQ_LVL_ERR) - lp->service_params |= FCP_SPPF_RETRY; - - lp->boot_time = jiffies; - lp->e_d_tov = fnic->config.ed_tov; - lp->r_a_tov = fnic->config.ra_tov; - lp->link_supported_speeds = FC_PORTSPEED_10GBIT; - fc_set_wwnn(lp, fnic->config.node_wwn); - fc_set_wwpn(lp, fnic->config.port_wwn); - - fcoe_libfc_config(lp, &fnic->ctlr, &fnic_transport_template, 0); - - if (!fc_exch_mgr_alloc(lp, FC_CLASS_3, FCPIO_HOST_EXCH_RANGE_START, - FCPIO_HOST_EXCH_RANGE_END, NULL)) { - err = -ENOMEM; - goto err_out_fc_exch_mgr_alloc; - } - - fc_lport_init_stats(lp); - fnic->stats_reset_time = jiffies; + fnic_fdls_init(fnic, (fnic->config.flags & VFCF_FIP_CAPABLE)); - fc_lport_config(lp); + if (IS_FNIC_FCP_INITIATOR(fnic) && fnic_scsi_drv_init(fnic)) + goto err_out_scsi_drv_init; - if (fc_set_mfs(lp, fnic->config.maxdatafieldsize + - sizeof(struct fc_frame_header))) { - err = -EINVAL; - goto err_out_free_exch_mgr; + err = fnic_stats_debugfs_init(fnic); + if (err) { + dev_err(&fnic->pdev->dev, "Failed to initialize debugfs for stats\n"); + goto err_out_free_stats_debugfs; } - fc_host_maxframe_size(lp->host) = lp->mfs; - fc_host_dev_loss_tmo(lp->host) = fnic->config.port_down_timeout / 1000; - sprintf(fc_host_symbolic_name(lp->host), - DRV_NAME " v" DRV_VERSION " over %s", fnic->name); + for (i = 0; i < fnic->intr_count; i++) + vnic_intr_unmask(&fnic->intr[i]); spin_lock_irqsave(&fnic_list_lock, flags); list_add_tail(&fnic->list, &fnic_list); spin_unlock_irqrestore(&fnic_list_lock, flags); - INIT_WORK(&fnic->link_work, fnic_handle_link); - INIT_WORK(&fnic->frame_work, fnic_handle_frame); - INIT_WORK(&fnic->tport_work, fnic_tport_event_handler); - INIT_LIST_HEAD(&fnic->frame_queue); - INIT_LIST_HEAD(&fnic->tx_queue); - INIT_LIST_HEAD(&fnic->tport_event_list); - - fc_fabric_login(lp); - - vnic_dev_enable(fnic->vdev); - - for (i = 0; i < fnic->intr_count; i++) - vnic_intr_unmask(&fnic->intr[i]); - - fnic_notify_timer_start(fnic); - return 0; -err_out_free_exch_mgr: - fc_exch_mgr_free(lp); -err_out_fc_exch_mgr_alloc: - fc_remove_host(lp->host); - scsi_remove_host(lp->host); -err_out_scsi_add_host: +err_out_free_stats_debugfs: + fnic_stats_debugfs_remove(fnic); + scsi_remove_host(fnic->lport->host); +err_out_scsi_drv_init: fnic_free_intr(fnic); -err_out_request_intr: - for (i = 0; i < fnic->rq_count; i++) +err_out_fnic_request_intr: +err_out_alloc_rq_buf: + for (i = 0; i < fnic->rq_count; i++) { + if (ioread32(&fnic->rq[i].ctrl->enable)) + vnic_rq_disable(&fnic->rq[i]); vnic_rq_clean(&fnic->rq[i], fnic_free_rq_buf); -err_out_rq_buf: + } vnic_dev_notify_unset(fnic->vdev); -err_out_free_max_pool: +err_out_fnic_notify_set: mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_MAX]); err_out_free_dflt_pool: mempool_destroy(fnic->io_sgl_pool[FNIC_SGL_CACHE_DFLT]); -err_out_free_ioreq_pool: - mempool_destroy(fnic->io_req_pool); err_out_free_resources: - for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) - kfree(fnic->sw_copy_wq[hwq].io_req_table); fnic_free_vnic_resources(fnic); -err_out_clear_intr: +err_out_fnic_alloc_vnic_res: fnic_clear_intr_mode(fnic); -err_out_dev_close: +err_out_fnic_set_intr_mode: + if (IS_FNIC_FCP_INITIATOR(fnic)) + scsi_host_put(fnic->lport->host); +err_out_fnic_role: +err_out_scsi_host_alloc: +err_out_fnic_get_config: +err_out_dev_mac_addr: +err_out_dev_init: vnic_dev_close(fnic->vdev); -err_out_dev_cmd_deinit: -err_out_vnic_unregister: +err_out_dev_open: +err_out_dev_cmd_init: vnic_dev_unregister(fnic->vdev); -err_out_iounmap: +err_out_dev_register: fnic_iounmap(fnic); -err_out_release_regions: +err_out_fnic_map_bar: +err_out_map_bar: +err_out_set_dma_mask: pci_release_regions(pdev); -err_out_disable_device: +err_out_pci_request_regions: pci_disable_device(pdev); -err_out_free_hba: - fnic_stats_debugfs_remove(fnic); +err_out_pci_enable_device: ida_free(&fnic_ida, fnic->fnic_num); err_out_ida_alloc: - scsi_host_put(lp->host); -err_out: + kfree(fnic); +err_out_fnic_alloc: return err; } static void fnic_remove(struct pci_dev *pdev) { struct fnic *fnic = pci_get_drvdata(pdev); - struct fc_lport *lp = fnic->lport; unsigned long flags; - int hwq; - /* - * Mark state so that the workqueue thread stops forwarding - * received frames and link events to the local port. ISR and - * other threads that can queue work items will also stop - * creating work items on the fnic workqueue - */ spin_lock_irqsave(&fnic->fnic_lock, flags); fnic->stop_rx_link_events = 1; spin_unlock_irqrestore(&fnic->fnic_lock, flags); - if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) - del_timer_sync(&fnic->notify_timer); - /* * Flush the fnic event queue. After this call, there should * be no event queued for this fnic device in the workqueue */ flush_workqueue(fnic_event_queue); - fnic_free_txq(&fnic->frame_queue); - fnic_free_txq(&fnic->tx_queue); + + if (IS_FNIC_FCP_INITIATOR(fnic)) + fnic_scsi_unload(fnic); + + if (vnic_dev_get_intr_mode(fnic->vdev) == VNIC_DEV_INTR_MODE_MSI) + del_timer_sync(&fnic->notify_timer); if (fnic->config.flags & VFCF_FIP_CAPABLE) { del_timer_sync(&fnic->retry_fip_timer); @@ -1021,19 +1068,6 @@ static void fnic_remove(struct pci_dev *pdev) if ((fnic_fdmi_support == 1) && (fnic->iport.fabric.fdmi_pending > 0)) del_timer_sync(&fnic->iport.fabric.fdmi_timer); - /* - * Log off the fabric. This stops all remote ports, dns port, - * logs off the fabric. This flushes all rport, disc, lport work - * before returning - */ - fc_fabric_logoff(fnic->lport); - - spin_lock_irqsave(&fnic->fnic_lock, flags); - fnic->in_remove = 1; - spin_unlock_irqrestore(&fnic->fnic_lock, flags); - - fcoe_ctlr_destroy(&fnic->ctlr); - fc_lport_destroy(lp); fnic_stats_debugfs_remove(fnic); /* @@ -1047,11 +1081,9 @@ static void fnic_remove(struct pci_dev *pdev) list_del(&fnic->list); spin_unlock_irqrestore(&fnic_list_lock, flags); - fc_remove_host(fnic->lport->host); - scsi_remove_host(fnic->lport->host); - for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) - kfree(fnic->sw_copy_wq[hwq].io_req_table); - fc_exch_mgr_free(fnic->lport); + fnic_free_txq(&fnic->frame_queue); + fnic_free_txq(&fnic->tx_queue); + vnic_dev_notify_unset(fnic->vdev); fnic_free_intr(fnic); fnic_free_vnic_resources(fnic); @@ -1061,8 +1093,13 @@ static void fnic_remove(struct pci_dev *pdev) fnic_iounmap(fnic); pci_release_regions(pdev); pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); ida_free(&fnic_ida, fnic->fnic_num); - scsi_host_put(lp->host); + if (IS_FNIC_FCP_INITIATOR(fnic)) { + fnic_scsi_unload_cleanup(fnic); + scsi_host_put(fnic->lport->host); + } + kfree(fnic); } static struct pci_driver fnic_driver = { @@ -1190,8 +1227,10 @@ static void __exit fnic_cleanup_module(void) { pci_unregister_driver(&fnic_driver); destroy_workqueue(fnic_event_queue); - if (fnic_fip_queue) + if (fnic_fip_queue) { + flush_workqueue(fnic_fip_queue); destroy_workqueue(fnic_fip_queue); + } kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_MAX]); kmem_cache_destroy(fnic_sgl_cache[FNIC_SGL_CACHE_DFLT]); kmem_cache_destroy(fnic_io_req_cache); diff --git a/drivers/scsi/fnic/fnic_res.c b/drivers/scsi/fnic/fnic_res.c index dd24e25574db..763475587b7f 100644 --- a/drivers/scsi/fnic/fnic_res.c +++ b/drivers/scsi/fnic/fnic_res.c @@ -58,6 +58,11 @@ int fnic_get_vnic_config(struct fnic *fnic) GET_CONFIG(intr_mode); GET_CONFIG(wq_copy_count); + if ((c->flags & (VFCF_FC_INITIATOR)) == 0) { + dev_info(&fnic->pdev->dev, "vNIC role not defined (def role: FC Init)\n"); + c->flags |= VFCF_FC_INITIATOR; + } + c->wq_enet_desc_count = min_t(u32, VNIC_FNIC_WQ_DESCS_MAX, max_t(u32, VNIC_FNIC_WQ_DESCS_MIN, @@ -137,29 +142,28 @@ int fnic_get_vnic_config(struct fnic *fnic) c->wq_copy_count = min_t(u16, FNIC_WQ_COPY_MAX, c->wq_copy_count); - dev_info(&fnic->pdev->dev, "vNIC MAC addr %pM " - "wq/wq_copy/rq %d/%d/%d\n", - fnic->ctlr.ctl_src_addr, + dev_info(&fnic->pdev->dev, "fNIC MAC addr %p wq/wq_copy/rq %d/%d/%d\n", + fnic->data_src_addr, c->wq_enet_desc_count, c->wq_copy_desc_count, c->rq_desc_count); - dev_info(&fnic->pdev->dev, "vNIC node wwn %llx port wwn %llx\n", + dev_info(&fnic->pdev->dev, "fNIC node wwn 0x%llx port wwn 0x%llx\n", c->node_wwn, c->port_wwn); - dev_info(&fnic->pdev->dev, "vNIC ed_tov %d ra_tov %d\n", + dev_info(&fnic->pdev->dev, "fNIC ed_tov %d ra_tov %d\n", c->ed_tov, c->ra_tov); - dev_info(&fnic->pdev->dev, "vNIC mtu %d intr timer %d\n", + dev_info(&fnic->pdev->dev, "fNIC mtu %d intr timer %d\n", c->maxdatafieldsize, c->intr_timer); - dev_info(&fnic->pdev->dev, "vNIC flags 0x%x luns per tgt %d\n", + dev_info(&fnic->pdev->dev, "fNIC flags 0x%x luns per tgt %d\n", c->flags, c->luns_per_tgt); - dev_info(&fnic->pdev->dev, "vNIC flogi_retries %d flogi timeout %d\n", + dev_info(&fnic->pdev->dev, "fNIC flogi_retries %d flogi timeout %d\n", c->flogi_retries, c->flogi_timeout); - dev_info(&fnic->pdev->dev, "vNIC plogi retries %d plogi timeout %d\n", + dev_info(&fnic->pdev->dev, "fNIC plogi retries %d plogi timeout %d\n", c->plogi_retries, c->plogi_timeout); - dev_info(&fnic->pdev->dev, "vNIC io throttle count %d link dn timeout %d\n", + dev_info(&fnic->pdev->dev, "fNIC io throttle count %d link dn timeout %d\n", c->io_throttle_count, c->link_down_timeout); - dev_info(&fnic->pdev->dev, "vNIC port dn io retries %d port dn timeout %d\n", + dev_info(&fnic->pdev->dev, "fNIC port dn io retries %d port dn timeout %d\n", c->port_down_io_retries, c->port_down_timeout); - dev_info(&fnic->pdev->dev, "vNIC wq_copy_count: %d\n", c->wq_copy_count); - dev_info(&fnic->pdev->dev, "vNIC intr mode: %d\n", c->intr_mode); + dev_info(&fnic->pdev->dev, "fNIC wq_copy_count: %d\n", c->wq_copy_count); + dev_info(&fnic->pdev->dev, "fNIC intr mode: %d\n", c->intr_mode); return 0; } diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index 97b2535cc100..6801348789c5 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -1953,6 +1953,45 @@ void fnic_terminate_rport_io(struct fc_rport *rport) } } +/* + * FCP-SCSI specific handling for module unload + * + */ +void fnic_scsi_unload(struct fnic *fnic) +{ + unsigned long flags; + + /* + * Mark state so that the workqueue thread stops forwarding + * received frames and link events to the local port. ISR and + * other threads that can queue work items will also stop + * creating work items on the fnic workqueue + */ + spin_lock_irqsave(&fnic->fnic_lock, flags); + fnic->iport.state = FNIC_IPORT_STATE_LINK_WAIT; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + + if (fdls_get_state(&fnic->iport.fabric) != FDLS_STATE_INIT) + fnic_scsi_fcpio_reset(fnic); + + spin_lock_irqsave(&fnic->fnic_lock, flags); + fnic->in_remove = 1; + spin_unlock_irqrestore(&fnic->fnic_lock, flags); + + fnic_flush_tport_event_list(fnic); + fnic_delete_fcp_tports(fnic); +} + +void fnic_scsi_unload_cleanup(struct fnic *fnic) +{ + int hwq = 0; + + fc_remove_host(fnic->host); + scsi_remove_host(fnic->host); + for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) + kfree(fnic->sw_copy_wq[hwq].io_req_table); +} + /* * This function is exported to SCSI for sending abort cmnds. * A SCSI IO is represented by a io_req in the driver. diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index aaa4ea02fb7c..d717886808df 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c @@ -458,6 +458,12 @@ int fnic_get_stats_data(struct stats_debug_info *debug, } +int fnic_get_debug_info(struct stats_debug_info *info, struct fnic *fnic) +{ + /* Placeholder function */ + return 0; +} + /* * fnic_trace_buf_init - Initialize fnic trace buffer logging facility * From patchwork Fri Sep 27 18:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831143 Received: from alln-iport-1.cisco.com (alln-iport-1.cisco.com [173.37.142.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8737F1C231B; Fri, 27 Sep 2024 18:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.142.88 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463337; cv=none; b=XiaFQZ5Niois43ZkvAP2O7HEt4aupGSq6gNY40L/INy/DemH4O8Gu1IV5Pr1rV3dVQXwYkCsMj0vjN/olcaYy6eBJC7IFaJFcajkpEDiRoDIRgWSBvlQA/Ebao2XBueaEKD58pGlPwfXXX1nmh56Q+YyXTmFaO67CZL/xCC9M80= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463337; c=relaxed/simple; bh=IMKcGyKr+UcEx/u43omkKz5ph75QNhJykXluusL9JXc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ArQ+4il5S2TEzN5uw7qLFbQall4+UQJok74mMbTsV9Zk4F2MUqfgh22OMJaZ11nyK1LxEEt6gsHiMCrbHijFBSiPDxCWUWPxCeCY8AedkJIVfCnQV7xWRuTNkr4mWCDMKQC2FiMIK2RY0SeEj++kBlzON7tB47lYTmGssGzJ3ig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=fr/mifcf; arc=none smtp.client-ip=173.37.142.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="fr/mifcf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=179482; q=dns/txt; s=iport; t=1727463329; x=1728672929; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M0M0mBE2Wk6vc6qVIC4ME0lh05u/HUuzopt8a0ZyvI8=; b=fr/mifcfFLOI3N99zKkpElzlhec15i8ZXs0B5b5pt+ujDbW9jYWv/KqO Mqf5dTN/BBHYsdqJ7NTRYy43BJUFtCaFAr5wJNC7MkO+3AbNCUDgh2iK6 IgTSbiLsvIRz+1VHKgGr2YcQv0GmfqkgD3Wmbc+kwi5ZHrDkZCzhB1cwW 8=; X-CSE-ConnectionGUID: 55TwV29KQPu2VKGDJOnXJw== X-CSE-MsgGUID: tJtM3tKWRwe2LtTR9MUbfw== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="355647557" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by alln-iport-1.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:54:20 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQat022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:54:19 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar Subject: [PATCH v3 12/14] scsi: fnic: Code cleanup Date: Fri, 27 Sep 2024 11:46:11 -0700 Message-Id: <20240927184613.52172-13-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Replace existing host structure with fnic host. Add headers from scsi to support new functionality. Remove unused code and declarations. Reviewed-by: Sesidhar Baddela Reviewed-by: Arulprabhu Ponnusamy Reviewed-by: Gian Carlo Boffa Signed-off-by: Karan Tilak Kumar ---- Changes between v2 and v3: Replace additional fnic->lport->host with fnic->host to prevent compilation errors. --- drivers/scsi/fnic/fdls_disc.c | 556 ++++++++++++++++--------------- drivers/scsi/fnic/fip.c | 81 +++-- drivers/scsi/fnic/fnic.h | 11 +- drivers/scsi/fnic/fnic_debugfs.c | 2 +- drivers/scsi/fnic/fnic_fcs.c | 126 +++---- drivers/scsi/fnic/fnic_isr.c | 28 +- drivers/scsi/fnic/fnic_main.c | 67 ++-- drivers/scsi/fnic/fnic_scsi.c | 235 ++++++------- 8 files changed, 555 insertions(+), 551 deletions(-) diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c index 28a11d93f7e6..5701583ea7a4 100644 --- a/drivers/scsi/fnic/fdls_disc.c +++ b/drivers/scsi/fnic/fdls_disc.c @@ -345,7 +345,7 @@ uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, idx = find_next_zero_bit(bitmap, meta->sz, meta->next_idx); if (idx == meta->sz) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Alloc oxid: all oxid slots are busy iport state:%d\n", iport->state); return 0xFFFF; @@ -369,7 +369,7 @@ void fdls_free_oxid(struct fnic_iport_s *iport, idx = FDLS_OXID_TO_IDX(meta, oxid); if (!test_bit(idx, bitmap)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Free oxid: already freed, iport state:%d\n", iport->state); } @@ -488,7 +488,7 @@ int fnic_fdls_expected_rsp(struct fnic_iport_s *iport, uint16_t oxid) (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_plogi) && (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_rhba) && (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_rpa)) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received oxid(0x%x) not matching in oxid pool (0x%x) state:%d", oxid, iport->fabric_oxid_pool.active_oxid_fabric_req, iport->fabric.state); @@ -596,7 +596,7 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) struct fnic *fnic = iport->fnic; if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x: Canceling fabric disc timer\n", iport->fcid); fnic_del_fabric_timer_sync(fnic); @@ -609,7 +609,7 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) fabric_tov = jiffies + msecs_to_jiffies(timeout); mod_timer(&iport->fabric.retry_timer, round_jiffies(fabric_tov)); iport->fabric.timer_pending = 1; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fabric timer is %d ", timeout); } @@ -621,7 +621,7 @@ fdls_start_tport_timer(struct fnic_iport_s *iport, struct fnic *fnic = iport->fnic; if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid 0x%x: Canceling disc timer\n", tport->fcid); fnic_del_tport_timer_sync(fnic, tport); @@ -698,7 +698,7 @@ fdls_send_tport_abts(struct fnic_iport_s *iport, tport_abts->fh_ox_id = tport->oxid_used; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS sending tport abts: tport->state: %d ", tport->state); @@ -766,7 +766,7 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) oxid = iport->fabric_oxid_pool.active_oxid_fabric_req; FNIC_STD_SET_OX_ID(fabric_abts, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS sending fabric abts. iport->fabric.state: %d, oxid:%x", iport->fabric.state, oxid); @@ -831,13 +831,13 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_FLOGI_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send flogi %p", iport); return; } FNIC_STD_SET_OX_ID(&flogi.fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS send fabric flogi with oxid:%x", iport->fcid, oxid); @@ -856,6 +856,8 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) uint16_t oxid; memcpy(&plogi, &fnic_std_plogi_req, sizeof(struct fc_std_flogi)); + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "0x%x: FDLS send fabric PLOGI", iport->fcid); hton24(fcid, iport->fcid); @@ -867,14 +869,14 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_PLOGI_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send fabric plogi %p", iport); return; } FNIC_STD_SET_OX_ID(fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS send fabric PLOGI with oxid:%x", iport->fcid, oxid); @@ -898,7 +900,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fdmi_oxid_pool, FNIC_FDMI_PLOGI_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send fdmi plogi %p", iport); return; @@ -914,7 +916,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) FNIC_LOGI_SET_NODE_NAME(&plogi.els, iport->wwnn); FNIC_LOGI_SET_RDF_SIZE(&plogi.els, iport->max_payload_size); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fcid: 0x%x: FDLS send FDMI PLOGI with oxid:%x", iport->fcid, oxid); @@ -933,6 +935,8 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) uint16_t oxid; memcpy(&rpn_id, &fnic_std_rpn_id_req, sizeof(struct fc_std_rpn_id)); + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "0x%x: FDLS send RPN ID", iport->fcid); hton24(fcid, iport->fcid); @@ -943,13 +947,13 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_RPN_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send rpn id %p", iport); return; } FNIC_STD_SET_OX_ID(&rpn_id.fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS send RPN ID with oxid:%x", iport->fcid, oxid); fnic_send_fcoe_frame(iport, &rpn_id, sizeof(struct fc_std_rpn_id)); @@ -965,6 +969,8 @@ static void fdls_send_scr(struct fnic_iport_s *iport) uint16_t oxid; memcpy(&scr, &fnic_std_scr_req, sizeof(struct fc_std_scr)); + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "0x%x: FDLS send SCR", iport->fcid); hton24(fcid, iport->fcid); FNIC_STD_SET_S_ID((&scr.fchdr), fcid); @@ -972,13 +978,13 @@ static void fdls_send_scr(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_SCR_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send scr %p", iport); return; } FNIC_STD_SET_OX_ID(&scr.fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS send SCR with oxid:%x", iport->fcid, oxid); atomic64_inc(&iport->iport_stats.fabric_scr_sent); @@ -1002,13 +1008,13 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_GPN_FT_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send GPN FT %p", iport); return; } FNIC_STD_SET_OX_ID(&gpn_ft.fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS send GPN FT with oxid:%x", iport->fcid, oxid); fnic_send_fcoe_frame(iport, &gpn_ft, sizeof(struct fc_std_gpn_ft)); @@ -1039,7 +1045,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->adisc_oxid_pool)); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send ADISC %p", iport); return; } @@ -1055,7 +1061,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) memcpy(adisc.els.adisc_port_id, s_id, 3); adisc.els.adisc_cmd = ELS_ADISC; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "sending ADISC to tgt fcid: 0x%x", tport->fcid); atomic64_inc(&iport->iport_stats.tport_adisc_sent); @@ -1071,7 +1077,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) if ((tport->state == FDLS_TGT_STATE_OFFLINING) || (tport->state == FDLS_TGT_STATE_OFFLINE)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid 0x%x: tport state is offlining/offline\n", tport->fcid); return false; @@ -1086,7 +1092,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) tport->flags |= FNIC_FDLS_TPORT_TERMINATING; if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid 0x%x: Canceling disc timer\n", tport->fcid); fnic_del_tport_timer_sync(fnic, tport); @@ -1102,7 +1108,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) tport_del_evt = kzalloc(sizeof(struct fnic_tport_event_s), GFP_ATOMIC); if (!tport_del_evt) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate memory for tport fcid: 0x%0x\n", tport->fcid); return false; @@ -1112,7 +1118,7 @@ bool fdls_delete_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport) list_add_tail(&tport_del_evt->links, &fnic->tport_event_list); queue_work(fnic_event_queue, &fnic->tport_work); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport 0x%x not reg with scsi_transport. Freeing locally", tport->fcid); list_del(&tport->links); @@ -1132,7 +1138,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) struct fnic *fnic = iport->fnic; uint32_t timeout; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Send tgt PLOGI to fcid: 0x%x", tport->fcid); memcpy(&plogi, &fnic_std_plogi_req, sizeof(struct fc_std_flogi)); @@ -1146,13 +1152,13 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->plogi_oxid_pool)); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Failed to allocate oxid to send PLOGI to fcid: 0x%x", iport->fcid, tport->fcid); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "send tgt PLOGI: tgt fcid: 0x%x oxid: 0x%x", tport->fcid, ntohs(oxid)); tport->oxid_used = oxid; @@ -1180,7 +1186,7 @@ fnic_fc_plogi_rsp_rdf(struct fnic_iport_s *iport, be16_to_cpu(plogi_rsp->els.fl_cssp[2].cp_rdfs) & FNIC_FC_C3_RDF; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "MFS: b2b_rdf_size: 0x%x spc3_rdf_size: 0x%x", b2b_rdf_size, spc3_rdf_size); @@ -1204,13 +1210,13 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_RFT_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send RFT %p", iport); return; } FNIC_STD_SET_OX_ID(&rft_id.fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS sending FC4 Typeswith oxid:%x", iport->fcid, oxid); @@ -1233,6 +1239,8 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) uint16_t oxid; memcpy(&rff_id, &fnic_std_rff_id_req, sizeof(struct fc_std_rff_id)); + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "0x%x: FDLS sending FC4 features", iport->fcid); hton24(fcid, iport->fcid); @@ -1242,20 +1250,20 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_RFF_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send RFF %p", iport); return; } FNIC_STD_SET_OX_ID(&rff_id.fchdr, htons(oxid)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS sending FC4 features with %x", iport->fcid, oxid); if (IS_FNIC_FCP_INITIATOR(fnic)) { rff_id.rff_id.fr_type = FC_TYPE_FCP; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Unknown type", iport->fcid); } @@ -1273,16 +1281,16 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) struct fnic *fnic = iport->fnic; uint32_t timeout; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS sending PRLI to tgt: 0x%x", tport->fcid); oxid = htons(fdls_alloc_tgt_oxid(iport, &iport->prli_oxid_pool)); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send PRLI %p", iport); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS sending PRLI to tgt: 0x%x OXID: 0x%x", tport->fcid, ntohs(oxid)); @@ -1322,7 +1330,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) struct fnic *fnic = iport->fnic; uint16_t oxid; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Sending logo to fabric from iport->fcid: 0x%x", iport->fcid); memcpy(&logo, &fnic_std_logo_req, sizeof(struct fc_std_logo)); @@ -1335,7 +1343,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fabric_oxid_pool, FNIC_FABRIC_LOGO_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send fabric logo %p", iport); return; @@ -1350,7 +1358,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Sending logo to fabric from fcid %x with oxid %x", iport->fcid, oxid); @@ -1376,7 +1384,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) struct fnic *fnic = iport->fnic; uint16_t oxid; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Sending logo to tport fcid: 0x%x", tport->fcid); memcpy(&logo, &fnic_std_logo_req, sizeof(struct fc_std_logo)); @@ -1403,7 +1411,7 @@ static void fdls_tgt_discovery_start(struct fnic_iport_s *iport) u32 old_link_down_cnt = iport->fnic->link_down_cnt; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Starting FDLS target discovery", iport->fcid); list_for_each_entry_safe(tport, next, &iport->tport_list, links) { @@ -1457,7 +1465,7 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport) struct fnic *fnic = iport->fnic; bool retval = true; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid: 0x%x state: %d restart_count: %d", tport->fcid, tport->state, tport->nexus_restart_count); @@ -1467,13 +1475,13 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport) retval = fdls_delete_tport(iport, tport); if (retval != true) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Error deleting tport: 0x%x", fcid); return; } if (nexus_restart_count >= FNIC_TPORT_MAX_NEXUS_RESTART) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Exceeded nexus restart retries tport: 0x%x", fcid); return; @@ -1490,7 +1498,7 @@ static void fdls_target_restart_nexus(struct fnic_tport_s *tport) */ new_tport = fdls_create_tport(iport, fcid, wwpn); if (!new_tport) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Error creating new tport: 0x%x", fcid); return; } @@ -1519,12 +1527,12 @@ static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS create tport: fcid: 0x%x wwpn: 0x%llx", fcid, wwpn); tport = kzalloc(sizeof(struct fnic_tport_s), GFP_ATOMIC); if (!tport) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Memory allocation failure while creating tport: 0x%x\n", fcid); return NULL; @@ -1537,12 +1545,12 @@ static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, tport->wwpn = wwpn; tport->iport = iport; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Need to setup tport timer callback"); timer_setup(&tport->retry_timer, fdls_tport_timer_callback, 0); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Added tport 0x%x", tport->fcid); fdls_set_tport_state(tport, FDLS_TGT_STATE_INIT); list_add_tail(&tport->links, &iport->tport_list); @@ -1582,7 +1590,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fdmi_oxid_pool, FNIC_FDMI_REG_HBA_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send fdmi reg hba %p", iport); return; @@ -1637,7 +1645,7 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) oxid = fdls_alloc_fabric_oxid(iport, &iport->fdmi_oxid_pool, FNIC_FDMI_RPA_RSP); if (oxid == 0xFFFF) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate OXID to send fdmi rpa %p", iport); return; @@ -1674,10 +1682,10 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) fdmi_rpa.current_speed = htonl(port_speed_bm); fdmi_rpa.fc4_type[2] = 1; snprintf(fdmi_rpa.os_name, sizeof(fdmi_rpa.os_name) - 1, "host%d", - fnic->lport->host->host_no); - sprintf(fc_host_system_hostname(fnic->lport->host), "%s", utsname()->nodename); + fnic->host->host_no); + sprintf(fc_host_system_hostname(fnic->host), "%s", utsname()->nodename); snprintf(fdmi_rpa.host_name, sizeof(fdmi_rpa.host_name) - 1, "%s", - fc_host_system_hostname(fnic->lport->host)); + fc_host_system_hostname(fnic->host)); fnic_send_fcoe_frame(iport, &fdmi_rpa, sizeof(struct fc_std_fdmi_rpa)); iport->fabric.fdmi_pending |= FDLS_FDMI_RPA_PENDING; @@ -1691,7 +1699,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) struct fnic *fnic = iport->fnic; unsigned long flags; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tp: %d fab state: %d fab retry counter: %d max_flogi_retries: %d", iport->fabric.timer_pending, iport->fabric.state, iport->fabric.retry_counter, iport->max_flogi_retries); @@ -1706,7 +1714,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) if (iport->fabric.del_timer_inprogress) { iport->fabric.del_timer_inprogress = 0; spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fabric_del_timer inprogress(%d). Skip timer cb", iport->fabric.del_timer_inprogress); return; @@ -1734,7 +1742,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; fdls_send_fabric_flogi(iport); } else - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Exceeded max FLOGI retries"); } break; @@ -1756,7 +1764,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; fdls_send_fabric_plogi(iport); } else - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Exceeded max PLOGI retries"); } break; @@ -1787,7 +1795,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) else { /* ABTS has timed out */ fdls_schedule_fabric_oxid_free(iport); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ABTS timed out. Starting PLOGI: %p", iport); fnic_fdls_start_plogi(iport); } @@ -1804,7 +1812,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) } else { /* ABTS has timed out */ fdls_schedule_fabric_oxid_free(iport); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ABTS timed out. Starting PLOGI: %p", iport); fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ } @@ -1821,7 +1829,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) else { /* ABTS has timed out */ fdls_schedule_fabric_oxid_free(iport); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ABTS timed out. Starting PLOGI %p", iport); fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ } @@ -1843,7 +1851,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) if (iport->fabric.retry_counter < FDLS_RETRY_COUNT) { fdls_send_gpn_ft(iport, iport->fabric.state); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ABTS timeout for fabric GPN_FT. Check name server: %p", iport); } @@ -1885,7 +1893,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t) /* If max retries not exhaused, start over from fdmi plogi */ if (iport->fabric.fdmi_retry < FDLS_FDMI_MAX_RETRY) { iport->fabric.fdmi_retry++; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "retry fdmi timer %d", iport->fabric.fdmi_retry); fdls_send_fdmi_plogi(iport); } @@ -1903,7 +1911,7 @@ static void fdls_send_delete_tport_msg(struct fnic_tport_s *tport) tport_del_evt = kzalloc(sizeof(struct fnic_tport_event_s), GFP_ATOMIC); if (!tport_del_evt) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate memory for tport event fcid: 0x%x", tport->fcid); return; @@ -1936,13 +1944,13 @@ static void fdls_tport_timer_callback(struct timer_list *t) if (tport->del_timer_inprogress) { tport->del_timer_inprogress = 0; spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport_del_timer inprogress. Skip timer cb tport fcid: 0x%x\n", tport->fcid); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid: 0x%x timer pending: %d state: %d retry counter: %d", tport->fcid, tport->timer_pending, tport->state, tport->retry_counter); @@ -2013,14 +2021,14 @@ static void fdls_tport_timer_callback(struct timer_list *t) fdls_schedule_tgt_oxid_free(iport, &iport->adisc_oxid_pool, oxid); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ADISC not responding. Deleting target port: 0x%x", tport->fcid); fdls_send_delete_tport_msg(tport); } break; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown tport state: 0x%x", tport->state); break; } @@ -2071,26 +2079,26 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, tport = fnic_find_tport_by_fcid(iport, tgt_fcid); if (!tport) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Tgt ADISC response tport not found: 0x%x", tgt_fcid); return; } if ((iport->state != FNIC_IPORT_STATE_READY) || (tport->state != FDLS_TGT_STATE_ADISC) || (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping this ADISC response"); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport state: %d tport state: %d Is abort issued on PRLI? %d", iport->state, tport->state, (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)); return; } if (ntohs(fchdr->fh_ox_id) != ntohs(tport->oxid_used)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping frame from target: 0x%x", tgt_fcid); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Reason: Stale ADISC/Aborted ADISC/OOO frame delivery"); return; } @@ -2102,7 +2110,7 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, case ELS_LS_ACC: atomic64_inc(&iport->iport_stats.tport_adisc_ls_accepts); if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport 0x%p Canceling fabric disc timer\n", tport); fnic_del_tport_timer_sync(fnic, tport); @@ -2112,12 +2120,12 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, frame_wwnn = get_unaligned_be64(&adisc_rsp->els.adisc_wwnn); frame_wwpn = get_unaligned_be64(&adisc_rsp->els.adisc_wwpn); if ((frame_wwnn == tport->wwnn) && (frame_wwpn == tport->wwpn)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ADISC accepted from target: 0x%x. Target logged in", tgt_fcid); fdls_set_tport_state(tport, FDLS_TGT_STATE_READY); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Error mismatch frame: ADISC"); } break; @@ -2127,14 +2135,14 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport, if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) && (tport->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ADISC ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x", tgt_fcid); /* Retry ADISC again from the timer routine. */ tport->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "ADISC returned ELS_LS_RJT from target: 0x%x", tgt_fcid); fdls_delete_tport(iport, tport); @@ -2160,33 +2168,33 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, fcid = FNIC_STD_GET_S_ID(fchdr); tgt_fcid = ntoh24(fcid); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS processing target PLOGI response: tgt_fcid: 0x%x", tgt_fcid); tport = fnic_find_tport_by_fcid(iport, tgt_fcid); if (!tport) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport not found: 0x%x", tgt_fcid); return; } if ((iport->state != FNIC_IPORT_STATE_READY) || (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping frame! iport state: %d tport state: %d", iport->state, tport->state); return; } if (tport->state != FDLS_TGT_STATE_PLOGI) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI rsp recvd in wrong state. Drop the frame and restart nexus"); fdls_target_restart_nexus(tport); return; } if (fchdr->fh_ox_id != tport->oxid_used) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI response from target: 0x%x. Dropping frame", tgt_fcid); return; @@ -2198,7 +2206,7 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, switch (plogi_rsp->els.fl_cmd) { case ELS_LS_ACC: atomic64_inc(&iport->iport_stats.tport_plogi_ls_accepts); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI accepted by target: 0x%x", tgt_fcid); break; @@ -2207,14 +2215,14 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) && (tport->retry_counter < iport->max_plogi_retries)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x", tgt_fcid); /* Retry plogi again from the timer routine. */ tport->flags |= FNIC_FDLS_RETRY_FRAME; return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI returned ELS_LS_RJT from target: 0x%x", tgt_fcid); fdls_delete_tport(iport, tport); @@ -2222,18 +2230,18 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, default: atomic64_inc(&iport->iport_stats.tport_plogi_misc_rejects); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI not accepted from target fcid: 0x%x", tgt_fcid); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Found the PLOGI target: 0x%x and state: %d", (unsigned int) tgt_fcid, tport->state); if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid 0x%x: Canceling disc timer\n", tport->fcid); fnic_del_tport_timer_sync(fnic, tport); @@ -2251,13 +2259,13 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport, MIN(max_payload_size, iport->max_payload_size); if (tport->max_payload_size < FNIC_MIN_DATA_FIELD_SIZE) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "MFS: tport max frame size below spec bounds: %d", tport->max_payload_size); tport->max_payload_size = FNIC_MIN_DATA_FIELD_SIZE; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "MAX frame size: %d iport max_payload_size: %d tport mfs: %d", max_payload_size, iport->max_payload_size, tport->max_payload_size); @@ -2286,12 +2294,12 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, fcid = FNIC_STD_GET_S_ID(fchdr); tgt_fcid = ntoh24(fcid); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS process tgt PRLI response: 0x%x", tgt_fcid); tport = fnic_find_tport_by_fcid(iport, tgt_fcid); if (!tport) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport not found: 0x%x", tgt_fcid); /* Handle or just drop? */ return; @@ -2299,24 +2307,24 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, if ((iport->state != FNIC_IPORT_STATE_READY) || (tport->flags & FNIC_FDLS_TGT_ABORT_ISSUED)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping frame! iport st: %d tport st: %d tport fcid: 0x%x", iport->state, tport->state, tport->fcid); return; } if (tport->state != FDLS_TGT_STATE_PRLI) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PRLI rsp recvd in wrong state. Drop frame. Restarting nexus"); fdls_target_restart_nexus(tport); return; } if (fchdr->fh_ox_id != tport->oxid_used) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping PRLI response from target: 0x%x ", tgt_fcid); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Reason: Stale PRLI response/Aborted PDISC/OOO frame delivery"); return; } @@ -2327,11 +2335,11 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, switch (prli_rsp->els_prli.prli_cmd) { case ELS_LS_ACC: atomic64_inc(&iport->iport_stats.tport_prli_ls_accepts); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PRLI accepted from target: 0x%x", tgt_fcid); if (prli_rsp->sp.spp_type != FC_FC4_TYPE_SCSI) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "mismatched target zoned with FC SCSI initiator: 0x%x", tgt_fcid); mismatched_tgt = true; @@ -2348,7 +2356,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) && (tport->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PRLI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x", tgt_fcid); @@ -2356,7 +2364,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, tport->flags |= FNIC_FDLS_RETRY_FRAME; return; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PRLI returned ELS_LS_RJT from target: 0x%x", tgt_fcid); @@ -2368,18 +2376,18 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, default: atomic64_inc(&iport->iport_stats.tport_prli_misc_rejects); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PRLI not accepted from target: 0x%x", tgt_fcid); return; break; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Found the PRLI target: 0x%x and state: %d", (unsigned int) tgt_fcid, tport->state); if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport fcid 0x%x: Canceling disc timer\n", tport->fcid); fnic_del_tport_timer_sync(fnic, tport); @@ -2395,7 +2403,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, /* Check if the device plays Target Mode Function */ if (!(tport->fcp_csp & FCP_PRLI_FUNC_TARGET)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Remote port(0x%x): no target support. Deleting it\n", tgt_fcid); fdls_tgt_logout(iport, tport); @@ -2408,14 +2416,14 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, /* Inform the driver about new target added */ tport_add_evt = kzalloc(sizeof(struct fnic_tport_event_s), GFP_ATOMIC); if (!tport_add_evt) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport event memory allocation failure: 0x%0x\n", tport->fcid); return; } tport_add_evt->event = TGT_EV_RPORT_ADD; tport_add_evt->arg1 = (void *) tport; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x add tport event fcid: 0x%x\n", tport->fcid, iport->fcid); list_add_tail(&tport_add_evt->links, &fnic->tport_event_list); @@ -2434,14 +2442,14 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport, uint8_t reason_code; if (fdls_get_state(fdls) != FDLS_STATE_REGISTER_FC4_FEATURES) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RFF_ID resp recvd in state(%d). Dropping.", fdls_get_state(fdls)); return; } rsp = FNIC_STD_GET_FC_CT_CMD((&rff_rsp->fc_std_ct_hdr)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS process RFF ID response: 0x%04x", iport->fcid, (uint32_t) rsp); @@ -2451,7 +2459,7 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport, switch (rsp) { case FC_FS_ACC: if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2465,18 +2473,18 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport, if (((reason_code == FC_FS_RJT_BSY) || (reason_code == FC_FS_RJT_UNABL)) && (fdls->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RFF_ID ret ELS_LS_RJT BUSY. Retry from timer routine %p", iport); /* Retry again from the timer routine */ fdls->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RFF_ID returned ELS_LS_RJT. Halting discovery %p", iport); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2500,14 +2508,14 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport, struct fnic *fnic = iport->fnic; if (fdls_get_state(fdls) != FDLS_STATE_REGISTER_FC4_TYPES) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RFT_ID resp recvd in state(%d). Dropping.", fdls_get_state(fdls)); return; } rsp = FNIC_STD_GET_FC_CT_CMD((&rft_rsp->fc_std_ct_hdr)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS process RFT ID response: 0x%04x", iport->fcid, (uint32_t) rsp); @@ -2517,7 +2525,7 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport, switch (rsp) { case FC_FS_ACC: if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2531,19 +2539,19 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport, if (((reason_code == FC_FS_RJT_BSY) || (reason_code == FC_FS_RJT_UNABL)) && (fdls->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: RFT_ID ret ELS_LS_RJT BUSY. Retry from timer routine", iport->fcid); /* Retry again from the timer routine */ fdls->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: RFT_ID REJ. Halting discovery reason %d expl %d", iport->fcid, reason_code, rft_rsp->fc_std_ct_hdr.ct_explan); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2567,14 +2575,14 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport, struct fnic *fnic = iport->fnic; if (fdls_get_state(fdls) != FDLS_STATE_RPN_ID) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RPN_ID resp recvd in state(%d). Dropping.", fdls_get_state(fdls)); return; } rsp = FNIC_STD_GET_FC_CT_CMD((&rpn_rsp->fc_std_ct_hdr)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS process RPN ID response: 0x%04x", iport->fcid, (uint32_t) rsp); @@ -2584,7 +2592,7 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport, switch (rsp) { case FC_FS_ACC: if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2598,17 +2606,17 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport, if (((reason_code == FC_FS_RJT_BSY) || (reason_code == FC_FS_RJT_UNABL)) && (fdls->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RPN_ID returned REJ BUSY. Retry from timer routine %p", iport); /* Retry again from the timer routine */ fdls->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RPN_ID ELS_LS_RJT. Halting discovery %p", iport); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2630,12 +2638,12 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *) fchdr; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS process SCR response: 0x%04x", (uint32_t) scr_rsp->scr.scr_cmd); if (fdls_get_state(fdls) != FDLS_STATE_SCR) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "SCR resp recvd in state(%d). Dropping.", fdls_get_state(fdls)); return; @@ -2648,7 +2656,7 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, case ELS_LS_ACC: atomic64_inc(&iport->iport_stats.fabric_scr_ls_accepts); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -2662,17 +2670,17 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) && (fdls->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "SCR ELS_LS_RJT BUSY. Retry from timer routine %p", iport); /* Retry again from the timer routine */ fdls->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "SCR returned ELS_LS_RJT. Halting discovery %p", iport); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); @@ -2700,7 +2708,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, u32 old_link_down_cnt = iport->fnic->link_down_cnt; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS process GPN_FT tgt list", iport->fcid); gpn_ft_tgt = @@ -2714,7 +2722,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, fcid = ntoh24(gpn_ft_tgt->fcid); wwpn = ntohll(gpn_ft_tgt->wwpn); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "tport: 0x%x: ctrl:0x%x", fcid, gpn_ft_tgt->ctrl); if (fcid == iport->fcid) { @@ -2761,7 +2769,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, rem_len -= sizeof(struct fc_gpn_ft_rsp_iu); } if (rem_len <= 0) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "GPN_FT response: malformed/corrupt frame rxlen: %d remlen: %d", len, rem_len); } @@ -2771,7 +2779,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, list_for_each_entry_safe(tport, next, &iport->tport_list, links) { if (!(tport->flags & FNIC_FDLS_TPORT_IN_GPN_FT_LIST)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Remove port: 0x%x not found in GPN_FT list", tport->fcid); fdls_delete_tport(iport, tport); @@ -2799,7 +2807,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, u32 old_link_down_cnt = iport->fnic->link_down_cnt; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS process GPN_FT response: iport state: %d len: %d", iport->state, len); @@ -2819,7 +2827,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, && ((fdls_get_state(fdls) == FDLS_STATE_RSCN_GPN_FT) || (fdls_get_state(fdls) == FDLS_STATE_SEND_GPNFT) || (fdls_get_state(fdls) == FDLS_STATE_TGT_DISCOVERY))))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "GPNFT resp recvd in fab state(%d) iport_state(%d). Dropping.", fdls_get_state(fdls), iport->state); return; @@ -2834,10 +2842,10 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, switch (rsp) { case FC_FS_ACC: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: GPNFT_RSP accept", iport->fcid); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Canceling fabric disc timer\n", iport->fcid); fnic_del_fabric_timer_sync(fnic); @@ -2852,7 +2860,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, * that will be taken care in next link up event */ if (iport->state != FNIC_IPORT_STATE_READY) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Halting target discovery: fab st: %d iport st: %d ", fdls_get_state(fdls), iport->state); break; @@ -2862,22 +2870,22 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, case FC_FS_RJT: reason_code = gpn_ft_rsp->fc_std_ct_hdr.ct_reason; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: GPNFT_RSP Reject reason: %d", iport->fcid, reason_code); if (((reason_code == FC_FS_RJT_BSY) || (reason_code == FC_FS_RJT_UNABL)) && (fdls->retry_counter < FDLS_RETRY_COUNT)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: GPNFT_RSP ret REJ/BSY. Retry from timer routine", iport->fcid); /* Retry again from the timer routine */ fdls->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: GPNFT_RSP reject", iport->fcid); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Canceling fabric disc timer\n", iport->fcid); fnic_del_fabric_timer_sync(fnic); @@ -2891,7 +2899,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, count = 0; list_for_each_entry_safe(tport, next, &iport->tport_list, links) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "GPN_FT_REJECT: Remove port: 0x%x", tport->fcid); fdls_delete_tport(iport, tport); @@ -2901,7 +2909,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport, } count++; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "GPN_FT_REJECT: Removed (0x%x) ports", count); } break; @@ -2929,7 +2937,7 @@ fdls_process_fabric_logo_rsp(struct fnic_iport_s *iport, switch (flogo_rsp->els.fl_cmd) { case ELS_LS_ACC: if (iport->fabric.state != FDLS_STATE_FABRIC_LOGO) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Flogo response. Fabric not in LOGO state. Dropping! %p", iport); return; @@ -2939,25 +2947,25 @@ fdls_process_fabric_logo_rsp(struct fnic_iport_s *iport, iport->state = FNIC_IPORT_STATE_LINK_WAIT; if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport 0x%p Canceling fabric disc timer\n", iport); fnic_del_fabric_timer_sync(fnic); } iport->fabric.timer_pending = 0; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Flogo response from Fabric for did: 0x%x", ntoh24(fchdr->fh_d_id)); return; case ELS_LS_RJT: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Flogo response from Fabric for did: 0x%x returned ELS_LS_RJT", ntoh24(fchdr->fh_d_id)); return; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGO response not accepted or rejected: 0x%x", flogo_rsp->els.fl_cmd); } @@ -2974,11 +2982,11 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, uint8_t fcmac[6] = { 0x0E, 0XFC, 0x00, 0x00, 0x00, 0x00 }; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS processing FLOGI response", iport->fcid); if (fdls_get_state(fabric) != FDLS_STATE_FABRIC_FLOGI) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI response received in state (%d). Dropping frame", fdls_get_state(fabric)); return; @@ -2991,7 +2999,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, case ELS_LS_ACC: atomic64_inc(&iport->iport_stats.fabric_flogi_ls_accepts); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x Canceling fabric disc timer\n", iport->fcid); fnic_del_fabric_timer_sync(fnic); @@ -3001,7 +3009,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, iport->fabric.retry_counter = 0; fcid = FNIC_STD_GET_D_ID(fchdr); iport->fcid = ntoh24(fcid); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FLOGI response accepted", iport->fcid); /* Learn the Service Params */ @@ -3011,7 +3019,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, iport->max_payload_size = MIN(rdf_size, iport->max_payload_size); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "max_payload_size from fabric: %d set: %d", rdf_size, iport->max_payload_size); @@ -3021,26 +3029,26 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, if (FNIC_LOGI_FEATURES(&flogi_rsp->els) & FNIC_FC_EDTOV_NSEC) iport->e_d_tov = iport->e_d_tov / FNIC_NSEC_TO_MSEC; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "From fabric: R_A_TOV: %d E_D_TOV: %d", iport->r_a_tov, iport->e_d_tov); if (IS_FNIC_FCP_INITIATOR(fnic)) { - fc_host_fabric_name(iport->fnic->lport->host) = + fc_host_fabric_name(iport->fnic->host) = get_unaligned_be64(&FNIC_LOGI_NODE_NAME(&flogi_rsp->els)); - fc_host_port_id(iport->fnic->lport->host) = iport->fcid; + fc_host_port_id(iport->fnic->host) = iport->fcid; } fnic_fdls_learn_fcoe_macs(iport, rx_frame, fcid); if (fnic_fdls_register_portid(iport, iport->fcid, rx_frame) != 0) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FLOGI registration failed", iport->fcid); break; } memcpy(&fcmac[3], fcid, 3); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Adding vNIC device MAC addr: %02x:%02x:%02x:%02x:%02x:%02x", fcmac[0], fcmac[1], fcmac[2], fcmac[3], fcmac[4], fcmac[5]); @@ -3048,7 +3056,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, if (fdls_get_state(fabric) == FDLS_STATE_FABRIC_FLOGI) { fnic_fdls_start_plogi(iport); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI response received. Starting PLOGI"); } else { /* From FDLS_STATE_FABRIC_FLOGI state fabric can only go to @@ -3056,7 +3064,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, * state, hence we don't have to worry about undoing: * the fnic_fdls_register_portid and vnic_dev_add_addr */ - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI response received in state (%d). Dropping frame", fdls_get_state(fabric)); } @@ -3065,7 +3073,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, case ELS_LS_RJT: atomic64_inc(&iport->iport_stats.fabric_flogi_ls_rejects); if (fabric->retry_counter < iport->max_flogi_retries) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI returned ELS_LS_RJT BUSY. Retry from timer routine %p", iport); @@ -3073,11 +3081,11 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, fabric->flags |= FNIC_FDLS_RETRY_FRAME; } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI returned ELS_LS_RJT. Halting discovery %p", iport); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport 0x%p Canceling fabric disc timer\n", iport); fnic_del_fabric_timer_sync(fnic); @@ -3088,7 +3096,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport, break; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI response not accepted: 0x%x", flogi_rsp->els.fl_cmd); atomic64_inc(&iport->iport_stats.fabric_flogi_misc_rejects); @@ -3105,7 +3113,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, struct fnic *fnic = iport->fnic; if (fdls_get_state((&iport->fabric)) != FDLS_STATE_FABRIC_PLOGI) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Fabric PLOGI response received in state (%d). Dropping frame", fdls_get_state(&iport->fabric)); return; @@ -3118,7 +3126,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, case ELS_LS_ACC: atomic64_inc(&iport->iport_stats.fabric_plogi_ls_accepts); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x fabric PLOGI response: Accepted\n", iport->fcid); fnic_del_fabric_timer_sync(fnic); @@ -3133,15 +3141,15 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, if (((els_rjt->u.rej.er_reason == ELS_RJT_BUSY) || (els_rjt->u.rej.er_reason == ELS_RJT_UNAB)) && (iport->fabric.retry_counter < iport->max_plogi_retries)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Fabric PLOGI ELS_LS_RJT BUSY. Retry from timer routine", iport->fcid); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Fabric PLOGI ELS_LS_RJT. Halting discovery", iport->fcid); if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x Canceling fabric disc timer\n", iport->fcid); fnic_del_fabric_timer_sync(fnic); @@ -3152,7 +3160,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, } break; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI response not accepted: 0x%x", plogi_rsp->els.fl_cmd); atomic64_inc(&iport->iport_stats.fabric_plogi_misc_rejects); @@ -3177,9 +3185,9 @@ static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport, iport->fabric.fdmi_pending = 0; switch (plogi_rsp->els.fl_cmd) { case ELS_LS_ACC: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS process fdmi PLOGI response status: ELS_LS_ACC\n"); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Sending fdmi registration for port 0x%x\n", iport->fcid); @@ -3190,7 +3198,7 @@ static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport, round_jiffies(fdmi_tov)); break; case ELS_LS_RJT: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Fabric FDMI PLOGI returned ELS_LS_RJT reason: 0x%x", els_rjt->u.rej.er_reason); @@ -3214,7 +3222,7 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport, struct fnic *fnic = iport->fnic; if (!iport->fabric.fdmi_pending) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received FDMI ack while not waiting:%x\n", ntohs(FNIC_STD_GET_OX_ID(fchdr))); return; @@ -3228,13 +3236,13 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport, fdls_free_fabric_oxid(iport, &iport->fdmi_oxid_pool, ntohs(FNIC_STD_GET_OX_ID(fchdr))); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x: Received FDMI registration ack\n", iport->fcid); if (!iport->fabric.fdmi_pending) { del_timer_sync(&iport->fabric.fdmi_timer); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport fcid: 0x%x: Canceling FDMI timer\n", iport->fcid); } @@ -3249,7 +3257,7 @@ static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport, s_id = ntoh24(FNIC_STD_GET_S_ID(fchdr)); if (!(s_id != 0xFFFFFA)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received abts rsp with invalid SID: 0x%x. Dropping frame", s_id); return; @@ -3280,14 +3288,14 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (!((s_id == FC_DIR_SERVER) || (s_id == FC_DOMAIN_CONTR) || (s_id == FC_FABRIC_CONTROLLER))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received abts rsp with invalid SID: 0x%x. Dropping frame", s_id); return; } if (iport->fabric.timer_pending) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Canceling fabric disc timer %p\n", iport); fnic_del_fabric_timer_sync(fnic); } @@ -3295,11 +3303,11 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED; if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received abts rsp BA_ACC for fabric_state: %d OX_ID: 0x%x", fabric_state, be16_to_cpu(ba_acc->acc.ba_ox_id)); } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "BA_RJT fs: %d OX_ID: 0x%x rc: 0x%x rce: 0x%x", fabric_state, be16_to_cpu(ba_rjt->fchdr.fh_ox_id), ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan); @@ -3316,10 +3324,10 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (iport->fabric.retry_counter < iport->max_flogi_retries) fdls_send_fabric_flogi(iport); else - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Exceeded max FLOGI retries"); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x FABRIC_FLOGI state. Drop frame", fchdr->fh_ox_id); } @@ -3329,7 +3337,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (!RETRIES_EXHAUSTED(iport)) fdls_send_fabric_logo(iport); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x FABRIC_FLOGI state. Drop frame", fchdr->fh_ox_id); } @@ -3339,10 +3347,10 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (iport->fabric.retry_counter < iport->max_plogi_retries) fdls_send_fabric_plogi(iport); else - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Exceeded max PLOGI retries"); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x FABRIC_PLOGI state. Drop frame", fchdr->fh_ox_id); } @@ -3357,7 +3365,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, fnic_fdls_start_plogi(iport); } } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x RPN_ID state. Drop frame", fchdr->fh_ox_id); } @@ -3368,13 +3376,13 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (iport->fabric.retry_counter <= FDLS_RETRY_COUNT) fdls_send_scr(iport); else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "abts rsp fab SCR after two tries. Start fabric PLOGI %p", iport); fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ } } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x SCR state. Drop frame", fchdr->fh_ox_id); } @@ -3384,13 +3392,13 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (iport->fabric.retry_counter <= FDLS_RETRY_COUNT) { fdls_send_register_fc4_types(iport); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "abts rsp fab RFT_ID two tries. Start fabric PLOGI %p", iport); fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ } } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x RFT state. Drop frame", fchdr->fh_ox_id); } @@ -3400,13 +3408,13 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (iport->fabric.retry_counter <= FDLS_RETRY_COUNT) fdls_send_register_fc4_features(iport); else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "abts rsp fab SCR after two tries. Start fabric PLOGI %p", iport); fnic_fdls_start_plogi(iport); /* go back to fabric Plogi */ } } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x RFF state. Drop frame", fchdr->fh_ox_id); } @@ -3417,12 +3425,12 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, if (iport->fabric.retry_counter <= FDLS_RETRY_COUNT) { fdls_send_gpn_ft(iport, fabric_state); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "abts rsp fab GPN_FT after two tries %p", iport); } } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown abts rsp OX_ID: 0x%x GPN_FT state. Drop frame", fchdr->fh_ox_id); } @@ -3444,7 +3452,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) struct fnic_tgt_oxid_pool_s *oxid_pool; nport_id = ntoh24(fchdr->fh_s_id); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received abort from SID %8x", nport_id); tport = fnic_find_tport_by_fcid(iport, nport_id); @@ -3481,7 +3489,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport, memcpy(&ls_rsp, &fnic_std_els_rjt, FC_ELS_RSP_REJ_SIZE); if (iport->fcid != d_id) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping unsupported ELS with illegal frame bits 0x%x\n", d_id); atomic64_inc(&iport->iport_stats.unsupported_frames_dropped); @@ -3490,14 +3498,14 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport, if ((iport->state != FNIC_IPORT_STATE_READY) && (iport->state != FNIC_IPORT_STATE_FABRIC_DISC)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping unsupported ELS request in iport state: %d", iport->state); atomic64_inc(&iport->iport_stats.unsupported_frames_dropped); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Process unsupported ELS request from SID: 0x%x", ntoh24(fchdr->fh_s_id)); /* We don't support this ELS request, send a reject */ @@ -3522,12 +3530,12 @@ fdls_process_rls_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) uint16_t oxid; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Process RLS request %d", iport->fnic->fnic_num); if ((iport->state != FNIC_IPORT_STATE_READY) && (iport->state != FNIC_IPORT_STATE_FABRIC_DISC)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received RLS req in iport state: %d. Dropping the frame.", iport->state); return; @@ -3568,32 +3576,32 @@ fdls_process_els_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr, if ((iport->state != FNIC_IPORT_STATE_READY) && (iport->state != FNIC_IPORT_STATE_FABRIC_DISC)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping ELS frame type :%x in iport state: %d", type, iport->state); return; } switch (type) { case ELS_ECHO: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "sending LS_ACC for ECHO request %d\n", iport->fnic->fnic_num); break; case ELS_RRQ: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "sending LS_ACC for RRQ request %d\n", iport->fnic->fnic_num); break; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "sending LS_ACC for %x ELS frame\n", type); break; } dst_frame = kzalloc(len, GFP_ATOMIC); if (!dst_frame) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate ELS response for %x", type); return; } @@ -3639,18 +3647,18 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, tport = fnic_find_tport_by_fcid(iport, s_id); if (!tport) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received tgt abts rsp with invalid SID: 0x%x", s_id); return; } if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "tport 0x%p Canceling fabric disc timer\n", tport); fnic_del_tport_timer_sync(fnic, tport); } if (iport->state != FNIC_IPORT_STATE_READY) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received tgt abts rsp in iport state(%d). Dropping.", iport->state); return; @@ -3663,15 +3671,15 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, /*This abort rsp is for ADISC */ if ((oxid >= FDLS_ADISC_OXID_BASE) && (oxid < FDLS_TGT_OXID_POOL_END)) { if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "OX_ID: 0x%x tgt_fcid: 0x%x rcvd tgt adisc abts resp BA_ACC", be16_to_cpu(ba_acc->acc.ba_ox_id), tport->fcid); } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "ADISC BA_RJT rcvd tport_fcid: 0x%x tport_state: %d ", tport->fcid, tport_state); - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "reason code: 0x%x reason code explanation:0x%x ", ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan); @@ -3685,7 +3693,7 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, } fdls_free_tgt_oxid(iport, &iport->adisc_oxid_pool, oxid); - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "ADISC not responding. Deleting target port: 0x%x", tport->fcid); fdls_delete_tport(iport, tport); @@ -3701,14 +3709,14 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, /*This abort rsp is for PLOGI */ if ((oxid >= FDLS_PLOGI_OXID_BASE) && (oxid < FDLS_PRLI_OXID_BASE)) { if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received tgt PLOGI abts response BA_ACC tgt_fcid: 0x%x", tport->fcid); } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PLOGI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x", tport->fcid, fchdr->fh_ox_id); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "reason code: 0x%x reason code explanation: 0x%x", ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan); @@ -3735,14 +3743,14 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, /*This abort rsp is for PRLI */ if ((oxid >= FDLS_PRLI_OXID_BASE) && (oxid < FDLS_ADISC_OXID_BASE)) { if (fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: Received tgt PRLI abts response BA_ACC", tport->fcid); } else if (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PRLI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x ", tport->fcid, fchdr->fh_ox_id); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "reason code: 0x%x reason code explanation: 0x%x", ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan); @@ -3759,7 +3767,7 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received ABTS response for unknown frame %p", iport); } @@ -3775,19 +3783,19 @@ fdls_process_plogi_req(struct fnic_iport_s *iport, memcpy(&plogi_rsp, &fnic_std_els_rjt, sizeof(struct fc_std_els_rsp)); if (iport->fcid != d_id) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received PLOGI with illegal frame bits. Dropping frame %p", iport); return; } if (iport->state != FNIC_IPORT_STATE_READY) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received PLOGI request in iport state: %d Dropping frame", iport->state); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Process PLOGI request from SID: 0x%x", ntoh24(fchdr->fh_s_id)); @@ -3820,11 +3828,11 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) nport_id = ntoh24(logo->els.fl_n_port_id); nport_name = logo->els.fl_n_port_wwn; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Process LOGO request from fcid: 0x%x", nport_id); if (iport->state != FNIC_IPORT_STATE_READY) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Dropping LOGO req from 0x%x in iport state: %d", nport_id, iport->state); return; @@ -3834,19 +3842,19 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) if (!tport) { /* We are not logged in with the nport, log and drop... */ - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received LOGO from an nport not logged in: 0x%x", nport_id); return; } if (tport->fcid != nport_id) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Received LOGO with invalid target port fcid: 0x%x", nport_id); return; } if (tport->timer_pending) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "tport fcid 0x%x: Canceling disc timer\n", tport->fcid); fnic_del_tport_timer_sync(fnic, tport); @@ -3863,7 +3871,7 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) if ((iport->state == FNIC_IPORT_STATE_READY) && (fdls_get_state(&iport->fabric) != FDLS_STATE_SEND_GPNFT) && (fdls_get_state(&iport->fabric) != FDLS_STATE_RSCN_GPN_FT)) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Sending GPNFT in response to LOGO from Target:0x%x", nport_id); fdls_send_gpn_ft(iport, FDLS_STATE_SEND_GPNFT); @@ -3876,7 +3884,7 @@ fdls_process_logo_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) fdls_send_logo_resp(iport, &logo->fchdr); if ((fdls_get_state(&iport->fabric) != FDLS_STATE_SEND_GPNFT) && (fdls_get_state(&iport->fabric) != FDLS_STATE_RSCN_GPN_FT)) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Sending GPNFT in response to LOGO from Target:0x%x", nport_id); fdls_send_gpn_ft(iport, FDLS_STATE_SEND_GPNFT); @@ -3900,11 +3908,11 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) atomic64_inc(&iport->iport_stats.num_rscns); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS process RSCN %p", iport); if (iport->state != FNIC_IPORT_STATE_READY) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS RSCN received in state(%d). Dropping", fdls_get_state(fdls)); return; @@ -3918,21 +3926,21 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) || (rscn_payload_len > 1024) || (rscn->els.rscn_page_len != 4)) { num_ports = 0; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RSCN payload_len: 0x%x page_len: 0x%x", rscn_payload_len, rscn->els.rscn_page_len); /* if this happens then we need to send ADISC to all the tports. */ list_for_each_entry_safe(tport, next, &iport->tport_list, links) { if (tport->state == FDLS_TGT_STATE_READY) tport->flags |= FNIC_FDLS_TPORT_SEND_ADISC; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RSCN for port id: 0x%x", tport->fcid); } } else { num_ports = (rscn_payload_len - 4) / rscn->els.rscn_page_len; rscn_port = (struct fc_els_rscn_page *)(rscn + 1); } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RSCN received for num_ports: %d payload_len: %d page_len: %d ", num_ports, rscn_payload_len, rscn->els.rscn_page_len); @@ -3956,14 +3964,14 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) if (tport->state == FDLS_TGT_STATE_READY) tport->flags |= FNIC_FDLS_TPORT_SEND_ADISC; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RSCN for port id: 0x%x", tport->fcid); } break; } tport = fnic_find_tport_by_fcid(iport, nport_id); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "RSCN port id list: 0x%x", nport_id); if (!tport) { @@ -3974,7 +3982,7 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) tport->flags |= FNIC_FDLS_TPORT_SEND_ADISC; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FDLS process RSCN sending GPN_FT %p", iport); fdls_send_gpn_ft(iport, FDLS_STATE_RSCN_GPN_FT); fdls_send_rscn_resp(iport, fchdr); @@ -3985,8 +3993,8 @@ void fnic_fdls_disc_start(struct fnic_iport_s *iport) struct fnic *fnic = iport->fnic; if (IS_FNIC_FCP_INITIATOR(fnic)) { - fc_host_fabric_name(iport->fnic->lport->host) = 0; - fc_host_post_event(iport->fnic->lport->host, fc_get_event_number(), + fc_host_fabric_name(iport->fnic->host) = 0; + fc_host_post_event(iport->fnic->host, fc_get_event_number(), FCH_EVT_LIPRESET, 0); } @@ -4018,20 +4026,20 @@ fdls_process_adisc_req(struct fnic_iport_s *iport, uint16_t oxid; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Process ADISC request %d", iport->fnic->fnic_num); fcid = FNIC_STD_GET_S_ID(fchdr); tgt_fcid = ntoh24(fcid); tport = fnic_find_tport_by_fcid(iport, tgt_fcid); if (!tport) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "tport for fcid: 0x%x not found. Dropping ADISC req.", tgt_fcid); return; } if (iport->state != FNIC_IPORT_STATE_READY) { - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Dropping ADISC req from fcid: 0x%x in iport state: %d", tgt_fcid, iport->state); return; @@ -4042,10 +4050,10 @@ fdls_process_adisc_req(struct fnic_iport_s *iport, if ((frame_wwnn != tport->wwnn) || (frame_wwpn != tport->wwpn)) { /* send reject */ - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "ADISC req from fcid: 0x%x mismatch wwpn: 0x%llx wwnn: 0x%llx", tgt_fcid, frame_wwpn, frame_wwnn); - FNIC_FCS_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "local tport wwpn: 0x%llx wwnn: 0x%llx. Sending RJT", tport->wwpn, tport->wwnn); @@ -4115,7 +4123,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if (iport->fcid) if (fdls_get_state(fabric) > FDLS_STATE_FABRIC_FLOGI) { if ((iport->fcid != d_id) || (!FNIC_FC_FRAME_CS_CTL(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "invalid frame received. Dropping frame"); return -1; } @@ -4125,7 +4133,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if ((fchdr->fh_r_ctl == FNIC_BA_ACC_RCTL) || (fchdr->fh_r_ctl == FNIC_BA_RJT_RCTL)) { if (!(FNIC_FC_FRAME_TYPE_BLS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received ABTS invalid frame. Dropping frame"); return -1; @@ -4134,7 +4142,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, } if ((fchdr->fh_r_ctl == FC_ABTS_RCTL) && (FNIC_FC_FRAME_TYPE_BLS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Receiving Abort Request from s_id: 0x%x", s_id); return FNIC_BLS_ABTS_REQ; } @@ -4146,7 +4154,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if ((!FNIC_FC_FRAME_FCTL_FIRST_LAST_SEQINIT(fchdr)) || (!FNIC_FC_FRAME_UNSOLICITED(fchdr)) || (!FNIC_FC_FRAME_TYPE_ELS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received LOGO invalid frame. Dropping frame"); return -1; } @@ -4155,12 +4163,12 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if ((!FNIC_FC_FRAME_FCTL_FIRST_LAST_SEQINIT(fchdr)) || (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) || (!FNIC_FC_FRAME_UNSOLICITED(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received RSCN invalid FCTL. Dropping frame"); return -1; } if (s_id != FC_FABRIC_CONTROLLER) - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received RSCN from target FCTL: 0x%x type: 0x%x s_id: 0x%x.", fchdr->fh_f_ctl[0], fchdr->fh_type, s_id); return FNIC_ELS_RSCN_REQ; @@ -4175,7 +4183,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, case ELS_RRQ: return FNIC_ELS_RRQ; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unsupported frame (type:0x%02x) from fcid: 0x%x", type, s_id); return FNIC_ELS_UNSUPPORTED_REQ; @@ -4186,7 +4194,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if ((ntohs(oxid) >= FDLS_PLOGI_OXID_BASE) && (ntohs(oxid) < FDLS_PRLI_OXID_BASE)) { if (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping Unknown frame in PLOGI exchange range type: 0x%x.", fchdr->fh_type); return -1; @@ -4196,7 +4204,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if ((ntohs(oxid) >= FDLS_PRLI_OXID_BASE) && (ntohs(oxid) < FDLS_ADISC_OXID_BASE)) { if (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping Unknown frame in PRLI exchange range type: 0x%x.", fchdr->fh_type); return -1; @@ -4207,7 +4215,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if ((ntohs(oxid) >= FDLS_ADISC_OXID_BASE) && (ntohs(oxid) < FDLS_TGT_OXID_POOL_END)) { if (!FNIC_FC_FRAME_TYPE_ELS(fchdr)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping Unknown frame in ADISC exchange range type: 0x%x.", fchdr->fh_type); return -1; @@ -4224,7 +4232,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if (type == ELS_LS_ACC) { if ((s_id != FC_DOMAIN_CONTR) || (!FNIC_FC_FRAME_TYPE_ELS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4235,7 +4243,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if (type == ELS_LS_ACC) { if ((s_id != FC_DIR_SERVER) || (!FNIC_FC_FRAME_TYPE_ELS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4246,7 +4254,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, if (type == ELS_LS_ACC) { if ((s_id != FC_FABRIC_CONTROLLER) || (!FNIC_FC_FRAME_TYPE_ELS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4255,7 +4263,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, case FNIC_FABRIC_RPN_RSP: if ((s_id != FC_DIR_SERVER) || (!FNIC_FC_FRAME_TYPE_FC_GS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4263,7 +4271,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, case FNIC_FABRIC_RFT_RSP: if ((s_id != FC_DIR_SERVER) || (!FNIC_FC_FRAME_TYPE_FC_GS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4271,7 +4279,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, case FNIC_FABRIC_RFF_RSP: if ((s_id != FC_DIR_SERVER) || (!FNIC_FC_FRAME_TYPE_FC_GS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4279,7 +4287,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, case FNIC_FABRIC_GPN_FT_RSP: if ((s_id != FC_DIR_SERVER) || (!FNIC_FC_FRAME_TYPE_FC_GS(fchdr))) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown frame. Dropping frame"); return -1; } @@ -4292,7 +4300,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, break; default: /* Drop the Rx frame and log/stats it */ - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Solicited response: unknown OXID: 0x%x", oxid); return -1; } @@ -4360,7 +4368,7 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, break; case FNIC_TPORT_LOGO_RSP: /* Logo response from tgt which we have deleted */ - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Logo response from tgt: 0x%x", ntoh24(fchdr->fh_s_id)); break; @@ -4410,9 +4418,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, fdls_process_fdmi_reg_ack(iport, fchdr, frame_type); break; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "s_id: 0x%x d_did: 0x%x", s_id, d_id); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Received unknown FCoE frame of len: %d. Dropping frame", len); break; } @@ -4430,7 +4438,7 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport) struct fnic_tport_s *tport, *next; struct fnic *fnic = iport->fnic; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS processing link down", iport->fcid); fdls_set_state((&iport->fabric), FDLS_STATE_LINKDOWN); @@ -4443,7 +4451,7 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport) fdls_init_oxid_pool(iport); list_for_each_entry_safe(tport, next, &iport->tport_list, links) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "removing rport: 0x%x", tport->fcid); fdls_delete_tport(iport, tport); } @@ -4454,7 +4462,7 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport) iport->fabric.fdmi_pending = 0; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "0x%x: FDLS finish processing link down", iport->fcid); } diff --git a/drivers/scsi/fnic/fip.c b/drivers/scsi/fnic/fip.c index 1a12266845da..3d1175cc244e 100644 --- a/drivers/scsi/fnic/fip.c +++ b/drivers/scsi/fnic/fip.c @@ -29,7 +29,7 @@ void fnic_fcoe_reset_vlans(struct fnic *fnic) } spin_unlock_irqrestore(&fnic->vlans_lock, flags); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Reset vlan complete\n"); } @@ -46,17 +46,17 @@ void fnic_fcoe_send_vlan_req(struct fnic *fnic) int fr_len; struct fip_vlan_req_s vlan_req; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Enter send vlan req\n"); fnic_fcoe_reset_vlans(fnic); fnic->set_vlan(fnic, 0); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "set vlan done\n"); fr_len = sizeof(struct fip_vlan_req_s); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "got MAC 0x%x:%x:%x:%x:%x:%x\n", iport->hwmac[0], iport->hwmac[1], iport->hwmac[2], iport->hwmac[3], iport->hwmac[4], iport->hwmac[5]); @@ -70,12 +70,12 @@ void fnic_fcoe_send_vlan_req(struct fnic *fnic) iport->fip.state = FDLS_FIP_VLAN_DISCOVERY_STARTED; fnic_send_fip_frame(iport, &vlan_req, fr_len); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "vlan req sent\n"); vlan_tov = jiffies + msecs_to_jiffies(FCOE_CTLR_FIPVLAN_TOV); mod_timer(&fnic->retry_fip_timer, round_jiffies(vlan_tov)); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fip timer set\n"); } @@ -99,13 +99,12 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header_s *fiph) struct fip_vlan_desc_s *vlan_desc; unsigned long flags; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p got vlan resp\n", fnic); desc_len = ntohs(vlan_notif->fip.desc_len); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "desc_len %d\n", desc_len); - spin_lock_irqsave(&fnic->vlans_lock, flags); cur_desc = 0; @@ -116,22 +115,21 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header_s *fiph) if (vlan_desc->type == FIP_TYPE_VLAN) { if (vlan_desc->len != 1) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Invalid descriptor length(%x) in VLan response\n", vlan_desc->len); - } num_vlan++; vid = ntohs(vlan_desc->vlan); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "process_vlan_resp: FIP VLAN %d\n", vid); vlan = kzalloc(sizeof(*vlan), GFP_KERNEL); if (!vlan) { /* retry from timer */ - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Mem Alloc failure\n"); spin_unlock_irqrestore(&fnic->vlans_lock, @@ -143,7 +141,7 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header_s *fiph) list_add_tail(&vlan->list, &fnic->vlan_list); break; } else { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Invalid descriptor type(%x) in VLan response\n", vlan_desc->type); @@ -159,7 +157,7 @@ void fnic_fcoe_process_vlan_resp(struct fnic *fnic, struct fip_header_s *fiph) /* any VLAN descriptors present ? */ if (num_vlan == 0) { atomic64_inc(&fnic_stats->vlan_stats.resp_withno_vlanID); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p No VLAN descriptors in FIP VLAN response\n", fnic); } @@ -182,7 +180,7 @@ void fnic_fcoe_start_fcf_discovery(struct fnic *fnic) int fr_len; struct fip_discovery_s disc_sol; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p start fcf discovery\n", fnic); fr_len = sizeof(struct fip_discovery_s); memset(iport->selected_fcf.fcf_mac, 0, ETH_ALEN); @@ -200,9 +198,8 @@ void fnic_fcoe_start_fcf_discovery(struct fnic *fnic) fcs_tov = jiffies + msecs_to_jiffies(FCOE_CTLR_FCS_TOV); mod_timer(&fnic->retry_fip_timer, round_jiffies(fcs_tov)); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p Started FCF discovery", fnic); - } /** @@ -230,7 +227,7 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header_s *fiph) switch (iport->fip.state) { case FDLS_FIP_FCF_DISCOVERY_STARTED: if (ntohs(disc_adv->fip.flags) & FIP_FLAG_S) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p Solicited adv\n", fnic); @@ -238,7 +235,7 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header_s *fiph) iport->selected_fcf.fcf_priority) && (ntohs(disc_adv->fip.flags) & FIP_FLAG_A)) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p FCF Available\n", fnic); memcpy(iport->selected_fcf.fcf_mac, @@ -247,7 +244,7 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header_s *fiph) disc_adv->prio_desc.priority; iport->selected_fcf.fka_adv_period = ntohl(disc_adv->fka_adv_desc.fka_adv); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "adv time %d", iport->selected_fcf.fka_adv_period); iport->selected_fcf.ka_disabled = @@ -267,7 +264,7 @@ void fnic_fcoe_fip_discovery_resp(struct fnic *fnic, struct fip_header_s *fiph) iport->selected_fcf.fka_adv_period = ntohl(disc_adv->fka_adv_desc.fka_adv); FNIC_FIP_DBG(KERN_INFO, - fnic->lport->host, + fnic->host, fnic->fnic_num, "change fka to %d", iport->selected_fcf.fka_adv_period); @@ -335,7 +332,7 @@ void fnic_fcoe_start_flogi(struct fnic *fnic) struct fc_frame_header *fchdr = &flogi_req.flogi_desc.flogi.fchdr; fr_len = sizeof(struct fip_flogi_s); - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p Start fip FLOGI\n", fnic); memcpy(&flogi_req, &fip_flogi_tmpl, fr_len); @@ -380,11 +377,11 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) struct fnic_stats *fnic_stats = &fnic->fnic_stats; struct fc_frame_header *fchdr = &flogi_rsp->rsp_desc.flogi.fchdr; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p FIP FLOGI rsp\n", fnic); desc_len = ntohs(flogi_rsp->fip.desc_len); if (desc_len != 38) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Invalid Descriptor List len (%x). Dropping frame\n", desc_len); return; @@ -394,7 +391,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) && (flogi_rsp->rsp_desc.len == 36)) || !((flogi_rsp->mac_desc.type == 2) && (flogi_rsp->mac_desc.len == 2))) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping frame invalid type and len mix\n"); return; } @@ -407,7 +404,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) || (s_id != 0xFFFFFE) || (exp_rsp_type != FNIC_FABRIC_FLOGI_RSP) || (fchdr->fh_type != 0x01)) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping invalid frame: s_id %x F %x R %x t %x OX_ID %x\n", s_id, fchdr->fh_f_ctl[0], fchdr->fh_r_ctl, fchdr->fh_type, fchdr->fh_ox_id); @@ -415,7 +412,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) } if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p rsp for pending FLOGI\n", fnic); del_timer_sync(&fnic->retry_fip_timer); @@ -423,7 +420,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) if ((ntohs(flogi_rsp->fip.desc_len) == 38) && (flogi_rsp->rsp_desc.flogi.els.fl_cmd == ELS_LS_ACC)) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p FLOGI success\n", fnic); memcpy(iport->fpma, flogi_rsp->mac_desc.mac, ETH_ALEN); @@ -440,7 +437,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) if (fnic_fdls_register_portid(iport, iport->fcid, NULL) != 0) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p flogi registration failed\n", fnic); @@ -449,7 +446,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header_s *fiph) iport->fip.state = FDLS_FIP_FLOGI_COMPLETE; iport->state = FNIC_IPORT_STATE_FABRIC_DISC; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport->state:%d\n", iport->state); fnic_fdls_disc_start(iport); @@ -496,7 +493,7 @@ void fnic_common_fip_cleanup(struct fnic *fnic) if (!iport->usefip) return; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p fip cleanup\n", fnic); iport->fip.state = FDLS_FIP_INIT; @@ -538,7 +535,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header_s *fiph) int found = false; int max_count = 0; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p clear virtual link handler\n", fnic); if (!((cvl_msg->fcf_mac_desc.type == 2) @@ -546,7 +543,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header_s *fiph) || !((cvl_msg->name_desc.type == 4) && (cvl_msg->name_desc.len == 3))) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "invalid mix: ft %x fl %x ndt %x ndl %x", cvl_msg->fcf_mac_desc.type, cvl_msg->fcf_mac_desc.len, cvl_msg->name_desc.type, @@ -560,7 +557,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header_s *fiph) if (!((cvl_msg->vn_ports_desc[i].type == 11) && (cvl_msg->vn_ports_desc[i].len == 5))) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Invalid type and len mix type: %d len: %d\n", cvl_msg->vn_ports_desc[i].type, @@ -584,12 +581,12 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header_s *fiph) spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); max_count++; if (max_count >= FIP_FNIC_RESET_WAIT_COUNT) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Rthr waited too long. Skipping handle link event %p\n", fnic); return; } - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic reset in progress. Link event needs to wait %p", fnic); } @@ -638,7 +635,7 @@ void fnic_work_on_fip_timer(struct work_struct *work) struct fnic *fnic = container_of(work, struct fnic, fip_timer_work); struct fnic_iport_s *iport = &fnic->iport; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FIP timeout\n"); if (iport->fip.state == FDLS_FIP_VLAN_DISCOVERY_STARTED) { @@ -646,7 +643,7 @@ void fnic_work_on_fip_timer(struct work_struct *work) } else if (iport->fip.state == FDLS_FIP_FCF_DISCOVERY_STARTED) { u8 zmac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FCF Discovery timeout\n"); if (memcmp(iport->selected_fcf.fcf_mac, zmac, ETH_ALEN) != 0) { @@ -668,12 +665,12 @@ void fnic_work_on_fip_timer(struct work_struct *work) round_jiffies(fcf_tov)); } } else { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FCF Discovery timeout\n"); fnic_vlan_discovery_timeout(fnic); } } else if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) { - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI timeout\n"); if (iport->fip.flogi_retry < fnic->config.flogi_retries) fnic_fcoe_start_flogi(fnic); @@ -851,7 +848,7 @@ void fnic_work_on_fcs_ka_timer(struct work_struct *work) *fnic = container_of(work, struct fnic, fip_timer_work); struct fnic_iport_s *iport = &fnic->iport; - FNIC_FIP_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FIP_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p fcs ka timeout\n", fnic); fnic_common_fip_cleanup(fnic); diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index 33256d99023a..5ad9d6df92a8 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -10,8 +10,10 @@ #include #include #include -#include -#include +#include +#include +#include +#include #include "fnic_io.h" #include "fnic_res.h" #include "fnic_trace.h" @@ -342,8 +344,6 @@ struct fnic { enum fnic_role_e role; struct fnic_iport_s iport; struct Scsi_Host *host; - struct fc_lport *lport; - struct fcoe_ctlr ctlr; /* FIP FCoE controller structure */ struct vnic_dev_bar bar0; struct fnic_msix_entry msix[FNIC_MSIX_INTR_MAX]; @@ -376,9 +376,6 @@ struct fnic { u32 vlan_hw_insert:1; /* let hw insert the tag */ u32 in_remove:1; /* fnic device in removal */ u32 stop_rx_link_events:1; /* stop proc. rx frames, link events */ - u32 link_events:1; /* set when we get any link event*/ - - struct completion *remove_wait; /* device remove thread blocks */ struct completion *fw_reset_done; u32 reset_in_progress; diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c index 3748bbe190f7..caee32bc9190 100644 --- a/drivers/scsi/fnic/fnic_debugfs.c +++ b/drivers/scsi/fnic/fnic_debugfs.c @@ -682,7 +682,7 @@ int fnic_stats_debugfs_init(struct fnic *fnic) int rc = -1; char name[16]; - snprintf(name, sizeof(name), "host%d", fnic->lport->host->host_no); + snprintf(name, sizeof(name), "host%d", fnic->host->host_no); if (!fnic_stats_debugfs_root) { pr_debug("fnic_stats root doesn't exist\n"); diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c index 9fba2f654980..3e82d64483e2 100644 --- a/drivers/scsi/fnic/fnic_fcs.c +++ b/drivers/scsi/fnic/fnic_fcs.c @@ -16,7 +16,8 @@ #include #include #include -#include +#include +#include #include "fnic_io.h" #include "fnic.h" #include "fnic_fip.h" @@ -57,7 +58,7 @@ uint8_t FCOE_ALL_FCF_MAC[6] = { 0x0e, 0xfc, 0x00, 0xff, 0xff, 0xfe }; static inline void fnic_fdls_set_fcoe_srcmac(struct fnic *fnic, uint8_t *src_mac) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Setting src mac: %02x:%02x:%02x:%02x:%02x:%02x", src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5]); @@ -72,7 +73,7 @@ static inline void fnic_fdls_set_fcoe_srcmac(struct fnic *fnic, static inline void fnic_fdls_set_fcoe_dstmac(struct fnic *fnic, uint8_t *dst_mac) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Setting dst mac: %02x:%02x:%02x:%02x:%02x:%02x", dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]); @@ -100,7 +101,7 @@ void fnic_fdls_link_status_change(struct fnic *fnic, int linkup) { struct fnic_iport_s *iport = &fnic->iport; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "link up: %d, usefip: %d", linkup, iport->usefip); spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); @@ -108,12 +109,12 @@ void fnic_fdls_link_status_change(struct fnic *fnic, int linkup) if (linkup) { if (iport->usefip) { iport->state = FNIC_IPORT_STATE_FIP; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "link up: %d, usefip: %d", linkup, iport->usefip); fnic_fcoe_send_vlan_req(fnic); } else { iport->state = FNIC_IPORT_STATE_FABRIC_DISC; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport->state: %d", iport->state); fnic_fdls_disc_start(iport); } @@ -143,13 +144,13 @@ void fnic_fdls_learn_fcoe_macs(struct fnic_iport_s *iport, void *rx_frame, memcpy(&fcmac[3], fcid, 3); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "learn fcoe: dst_mac: %02x:%02x:%02x:%02x:%02x:%02x", ethhdr->dst_mac[0], ethhdr->dst_mac[1], ethhdr->dst_mac[2], ethhdr->dst_mac[3], ethhdr->dst_mac[4], ethhdr->dst_mac[5]); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "learn fcoe: fc_mac: %02x:%02x:%02x:%02x:%02x:%02x", fcmac[0], fcmac[1], fcmac[2], fcmac[3], fcmac[4], fcmac[5]); @@ -167,7 +168,7 @@ void fnic_fdls_init(struct fnic *fnic, int usefip) iport->fnic = fnic; iport->usefip = usefip; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iportsrcmac: %02x:%02x:%02x:%02x:%02x:%02x", iport->hwmac[0], iport->hwmac[1], iport->hwmac[2], iport->hwmac[3], iport->hwmac[4], iport->hwmac[5]); @@ -186,14 +187,14 @@ void fnic_handle_link(struct work_struct *work) int max_count = 0; if (vnic_dev_get_intr_mode(fnic->vdev) != VNIC_DEV_INTR_MODE_MSI) - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Interrupt mode is not MSI\n"); spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); if (fnic->stop_rx_link_events) { spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Stop link rx events\n"); return; } @@ -202,10 +203,10 @@ void fnic_handle_link(struct work_struct *work) if ((fnic->state != FNIC_IN_ETH_MODE) && (fnic->state != FNIC_IN_FC_MODE)) { spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic in transitional state: %d. link up: %d ignored", fnic->state, vnic_dev_link_status(fnic->vdev)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Current link status: %d iport state: %d\n", fnic->link_status, fnic->iport.state); return; @@ -217,36 +218,36 @@ void fnic_handle_link(struct work_struct *work) fnic->link_down_cnt = vnic_dev_link_down_cnt(fnic->vdev); while (fnic->reset_in_progress == IN_PROGRESS) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic reset in progress. Link event needs to wait\n"); spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "waiting for reset completion\n"); wait_for_completion_timeout(&fnic->reset_completion_wait, msecs_to_jiffies(5000)); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "woken up from reset completion wait\n"); spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); max_count++; if (max_count >= MAX_RESET_WAIT_COUNT) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Rstth waited for too long. Skipping handle link event\n"); spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); return; } } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Marking fnic reset in progress\n"); fnic->reset_in_progress = IN_PROGRESS; if ((vnic_dev_get_intr_mode(fnic->vdev) != VNIC_DEV_INTR_MODE_MSI) || (fnic->link_status != old_link_status)) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "old link status: %d link status: %d\n", old_link_status, (int) fnic->link_status); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "old down count %d down count: %d\n", old_link_down_cnt, (int) fnic->link_down_cnt); } @@ -255,36 +256,36 @@ void fnic_handle_link(struct work_struct *work) if (!fnic->link_status) { /* DOWN -> DOWN */ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "down->down\n"); } else { if (old_link_down_cnt != fnic->link_down_cnt) { /* UP -> DOWN -> UP */ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "up->down. Link down\n"); fnic_fdls_link_status_change(fnic, 0); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "down->up. Link up\n"); fnic_fdls_link_status_change(fnic, 1); } else { /* UP -> UP */ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "up->up\n"); } } } else if (fnic->link_status) { /* DOWN -> UP */ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "down->up. Link up\n"); fnic_fdls_link_status_change(fnic, 1); } else { /* UP -> DOWN */ spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "up->down. Link down\n"); fnic_fdls_link_status_change(fnic, 0); } @@ -293,7 +294,7 @@ void fnic_handle_link(struct work_struct *work) fnic->reset_in_progress = NOT_IN_PROGRESS; complete(&fnic->reset_completion_wait); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Marking fnic reset completion\n"); spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); } @@ -323,7 +324,7 @@ void fnic_handle_frame(struct work_struct *work) */ if (fnic->state != FNIC_IN_FC_MODE && fnic->state != FNIC_IN_ETH_MODE) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Cannot process frame in transitional state\n"); spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); return; @@ -351,7 +352,7 @@ void fnic_handle_fip_frame(struct work_struct *work) struct fnic *fnic = container_of(work, struct fnic, fip_frame_work); fnic_stats = &fnic->fnic_stats; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Processing FIP frame\n"); spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); @@ -430,7 +431,7 @@ void fnic_update_mac_locked(struct fnic *fnic, u8 *new) if (ether_addr_equal(data, new)) return; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Update MAC: %u\n", *new); if (!is_zero_ether_addr(data) && !ether_addr_equal(data, ctl)) @@ -500,7 +501,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc if (!fcs_ok) { atomic64_inc(&fnic_stats->misc_stats.frame_errors); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p fcs error. Dropping packet.\n", fnic); goto drop; } @@ -510,21 +511,21 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc if (fnic_import_rq_eth_pkt(fnic, fp)) return; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Dropping ether_type 0x%x", ntohs(eh->ether_type)); goto drop; } } else { /* wrong CQ type */ - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic rq_cmpl wrong cq type x%x\n", type); goto drop; } if (!fcs_ok || packet_error || !fcoe_fnic_crc_ok || fcoe_enc_error) { atomic64_inc(&fnic_stats->misc_stats.frame_errors); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fcoe %x fcsok %x pkterr %x ffco %x fee %x\n", fcoe, fcs_ok, packet_error, fcoe_fnic_crc_ok, fcoe_enc_error); @@ -534,7 +535,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc spin_lock_irqsave(&fnic->fnic_lock, flags); if (fnic->stop_rx_link_events) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic->stop_rx_link_events: %d\n", fnic->stop_rx_link_events); goto drop; @@ -546,7 +547,7 @@ static void fnic_rq_cmpl_frame_recv(struct vnic_rq *rq, struct cq_desc kzalloc(sizeof(struct fnic_frame_list), GFP_ATOMIC); if (!frame_elem) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unable to alloc frame element of size: %ld\n", sizeof(struct fnic_frame_list)); goto drop; @@ -592,7 +593,7 @@ int fnic_rq_cmpl_handler(struct fnic *fnic, int rq_work_to_do) if (cur_work_done && fnic->stop_rx_link_events != 1) { err = vnic_rq_fill(&fnic->rq[i], fnic_alloc_rq_frame); if (err) - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "fnic_alloc_rq_frame can't alloc" " frame\n"); } @@ -618,7 +619,7 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq) len = FNIC_FRAME_HT_ROOM; buf = kmalloc(len, GFP_ATOMIC); if (!buf) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unable to allocate RQ buffer of size: %d\n", len); return -ENOMEM; } @@ -626,7 +627,7 @@ int fnic_alloc_rq_frame(struct vnic_rq *rq) pa = dma_map_single(&fnic->pdev->dev, buf, len, DMA_FROM_DEVICE); if (dma_mapping_error(&fnic->pdev->dev, pa)) { ret = -ENOMEM; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "PCI mapping failed with error %d\n", ret); goto free_buf; } @@ -665,7 +666,7 @@ static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len) if ((fnic_fc_trace_set_data(fnic->fnic_num, FNIC_FC_SEND | 0x80, (char *) frame, frame_len)) != 0) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic ctlr frame trace error"); } @@ -673,7 +674,7 @@ static int fnic_send_frame(struct fnic *fnic, void *frame, int frame_len) if (!vnic_wq_desc_avail(wq)) { dma_unmap_single(&fnic->pdev->dev, pa, frame_len, DMA_TO_DEVICE); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "vnic work queue descriptor is not available"); ret = -1; goto fnic_send_frame_end; @@ -701,7 +702,7 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *payload, int payload_sz, frame = kzalloc(max_framesz, GFP_ATOMIC); if (!frame) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate frame for flogi\n"); return -ENOMEM; } @@ -729,12 +730,13 @@ fdls_send_fcoe_frame(struct fnic *fnic, void *payload, int payload_sz, && (fnic->state != FNIC_IN_ETH_MODE)) { frame_elem = kzalloc(sizeof(struct fnic_frame_list), GFP_ATOMIC); if (!frame_elem) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to allocate memory for fnic_frame_list: %lu\n", sizeof(struct fnic_frame_list)); return -ENOMEM; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Queuing frame: 0x%p\n", frame); frame_elem->fp = frame; @@ -756,7 +758,7 @@ fdls_send_fip_frame(struct fnic *fnic, void *payload, int payload_sz) frame = kzalloc(max_framesz, GFP_ATOMIC); if (!frame) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic 0x%p Failed to allocate fip frame\n", fnic); return -1; } @@ -815,7 +817,7 @@ void fnic_flush_tx(struct work_struct *work) struct fc_frame *fp; struct fnic_frame_list *cur_frame, *next; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Flush queued frames"); list_for_each_entry_safe(cur_frame, next, &fnic->tx_queue, links) { @@ -833,7 +835,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id, struct fnic_eth_hdr_s *ethhdr; int ret; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Setting port id: 0x%x fp: 0x%p fnic state: %d", port_id, fp, fnic->state); @@ -846,7 +848,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id, if (fnic->state == FNIC_IN_ETH_MODE || fnic->state == FNIC_IN_FC_MODE) fnic->state = FNIC_IN_ETH_TRANS_FC_MODE; else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unexpected fnic state while processing FLOGI response\n"); return -1; } @@ -857,7 +859,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id, */ ret = fnic_flogi_reg_handler(fnic, port_id); if (ret < 0) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI registration error ret: %d fnic state: %d\n", ret, fnic->state); if (fnic->state == FNIC_IN_ETH_TRANS_FC_MODE) @@ -867,7 +869,7 @@ fnic_fdls_register_portid(struct fnic_iport_s *iport, u32 port_id, } iport->fabric.flags |= FNIC_FDLS_FPMA_LEARNT; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI registration success\n"); return 0; } @@ -947,7 +949,7 @@ fnic_fdls_add_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport, struct fc_rport_identifiers ids; struct rport_dd_data_s *rdd_data; - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Adding rport fcid: 0x%x", tport->fcid); ids.node_name = tport->wwnn; @@ -956,15 +958,15 @@ fnic_fdls_add_tport(struct fnic_iport_s *iport, struct fnic_tport_s *tport, ids.roles = FC_RPORT_ROLE_FCP_TARGET; spin_unlock_irqrestore(&fnic->fnic_lock, flags); - rport = fc_remote_port_add(fnic->lport->host, 0, &ids); + rport = fc_remote_port_add(fnic->host, 0, &ids); spin_lock_irqsave(&fnic->fnic_lock, flags); if (!rport) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Failed to add rport for tport: 0x%x", tport->fcid); return; } - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Added rport fcid: 0x%x", tport->fcid); /* Mimic these assignments in queuecommand to avoid timing issues */ @@ -1003,7 +1005,7 @@ fnic_fdls_remove_tport(struct fnic_iport_s *iport, fc_remote_port_delete(rport); spin_lock_irqsave(&fnic->fnic_lock, flags); - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Deregistered and freed tport fcid: 0x%x from scsi transport fc", tport->fcid); @@ -1030,7 +1032,7 @@ void fnic_delete_fcp_tports(struct fnic *fnic) spin_lock_irqsave(&fnic->fnic_lock, flags); list_for_each_entry_safe(tport, next, &fnic->iport.tport_list, links) { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "removing fcp rport fcid: 0x%x", tport->fcid); fdls_set_tport_state(tport, FDLS_TGT_STATE_OFFLINING); fnic_del_tport_timer_sync(fnic, tport); @@ -1055,36 +1057,36 @@ void fnic_tport_event_handler(struct work_struct *work) tport = cur_evt->arg1; switch (cur_evt->event) { case TGT_EV_RPORT_ADD: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Add rport event"); if (tport->state == FDLS_TGT_STATE_READY) { fnic_fdls_add_tport(&fnic->iport, (struct fnic_tport_s *) cur_evt->arg1, flags); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Target not ready. Add rport event dropped: 0x%x", tport->fcid); } break; case TGT_EV_RPORT_DEL: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Remove rport event"); if (tport->state == FDLS_TGT_STATE_OFFLINING) { fnic_fdls_remove_tport(&fnic->iport, (struct fnic_tport_s *) cur_evt->arg1, flags); } else { - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "remove rport event dropped tport fcid: 0x%x", tport->fcid); } break; case TGT_EV_TPORT_DELETE: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Delete tport event"); fdls_delete_tport(tport->iport, tport); break; default: - FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown tport event"); break; } diff --git a/drivers/scsi/fnic/fnic_isr.c b/drivers/scsi/fnic/fnic_isr.c index ff85441c6cea..7ed50b11afa6 100644 --- a/drivers/scsi/fnic/fnic_isr.c +++ b/drivers/scsi/fnic/fnic_isr.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include "vnic_dev.h" #include "vnic_intr.h" @@ -222,7 +222,7 @@ int fnic_request_intr(struct fnic *fnic) fnic->msix[i].devname, fnic->msix[i].devid); if (err) { - FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "request_irq failed with error: %d\n", err); fnic_free_intr(fnic); @@ -250,10 +250,10 @@ int fnic_set_intr_mode_msix(struct fnic *fnic) * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs * (last INTR is used for WQ/RQ errors and notification area) */ - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "rq-array size: %d wq-array size: %d copy-wq array size: %d\n", n, m, o); - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "rq_count: %d raw_wq_count: %d wq_copy_count: %d cq_count: %d\n", fnic->rq_count, fnic->raw_wq_count, fnic->wq_copy_count, fnic->cq_count); @@ -265,17 +265,17 @@ int fnic_set_intr_mode_msix(struct fnic *fnic) vec_count = pci_alloc_irq_vectors(fnic->pdev, min_irqs, vecs, PCI_IRQ_MSIX | PCI_IRQ_AFFINITY); - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "allocated %d MSI-X vectors\n", vec_count); if (vec_count > 0) { if (vec_count < vecs) { - FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "interrupts number mismatch: vec_count: %d vecs: %d\n", vec_count, vecs); if (vec_count < min_irqs) { - FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "no interrupts for copy wq\n"); return 1; } @@ -287,7 +287,7 @@ int fnic_set_intr_mode_msix(struct fnic *fnic) fnic->wq_copy_count = vec_count - n - m - 1; fnic->wq_count = fnic->raw_wq_count + fnic->wq_copy_count; if (fnic->cq_count != vec_count - 1) { - FNIC_ISR_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "CQ count: %d does not match MSI-X vector count: %d\n", fnic->cq_count, vec_count); fnic->cq_count = vec_count - 1; @@ -295,23 +295,23 @@ int fnic_set_intr_mode_msix(struct fnic *fnic) fnic->intr_count = vec_count; fnic->err_intr_offset = fnic->rq_count + fnic->wq_count; - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "rq_count: %d raw_wq_count: %d copy_wq_base: %d\n", fnic->rq_count, fnic->raw_wq_count, fnic->copy_wq_base); - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "wq_copy_count: %d wq_count: %d cq_count: %d\n", fnic->wq_copy_count, fnic->wq_count, fnic->cq_count); - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "intr_count: %d err_intr_offset: %u", fnic->intr_count, fnic->err_intr_offset); vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSIX); - FNIC_ISR_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic using MSI-X\n"); return 0; } @@ -351,7 +351,7 @@ int fnic_set_intr_mode(struct fnic *fnic) fnic->intr_count = 1; fnic->err_intr_offset = 0; - FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Using MSI Interrupts\n"); vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_MSI); @@ -377,7 +377,7 @@ int fnic_set_intr_mode(struct fnic *fnic) fnic->cq_count = 3; fnic->intr_count = 3; - FNIC_ISR_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_ISR_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Using Legacy Interrupts\n"); vnic_dev_set_intr_mode(fnic->vdev, VNIC_DEV_INTR_MODE_INTX); diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index df578087351a..69be3eed0a50 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include "vnic_dev.h" @@ -175,7 +174,7 @@ static void fnic_get_host_speed(struct Scsi_Host *shost) u32 port_speed = vnic_dev_port_speed(fnic->vdev); struct fnic_stats *fnic_stats = &fnic->fnic_stats; - FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "port_speed: %d Mbps", port_speed); atomic64_set(&fnic_stats->misc_stats.port_speed_in_mbps, port_speed); @@ -225,7 +224,7 @@ static void fnic_get_host_speed(struct Scsi_Host *shost) fc_host_speed(shost) = FC_PORTSPEED_128GBIT; break; default: - FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Unknown FC speed: %d Mbps", port_speed); fc_host_speed(shost) = FC_PORTSPEED_UNKNOWN; break; @@ -251,7 +250,7 @@ static struct fc_host_statistics *fnic_get_stats(struct Scsi_Host *host) spin_unlock_irqrestore(&fnic->fnic_lock, flags); if (ret) { - FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fnic: Get vnic stats failed: 0x%x", ret); return stats; } @@ -360,7 +359,7 @@ static void fnic_reset_host_stats(struct Scsi_Host *host) spin_unlock_irqrestore(&fnic->fnic_lock, flags); if (ret) { - FNIC_MAIN_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fnic: Reset vnic stats failed" " 0x%x", ret); return; @@ -562,7 +561,7 @@ static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) static void fnic_scsi_init(struct fnic *fnic) { - struct Scsi_Host *host = fnic->lport->host; + struct Scsi_Host *host = fnic->host; snprintf(fnic->name, sizeof(fnic->name) - 1, "%s%d", DRV_NAME, host->host_no); @@ -572,7 +571,7 @@ static void fnic_scsi_init(struct fnic *fnic) static int fnic_scsi_drv_init(struct fnic *fnic) { - struct Scsi_Host *host = fnic->lport->host; + struct Scsi_Host *host = fnic->host; int err; struct pci_dev *pdev = fnic->pdev; struct fnic_iport_s *iport = &fnic->iport; @@ -609,41 +608,41 @@ static int fnic_scsi_drv_init(struct fnic *fnic) fnic_scsi_init(fnic); - err = scsi_add_host(fnic->lport->host, &pdev->dev); + err = scsi_add_host(fnic->host, &pdev->dev); if (err) { dev_err(&fnic->pdev->dev, "fnic: scsi add host failed: aborting\n"); return -1; } - fc_host_maxframe_size(fnic->lport->host) = iport->max_payload_size; - fc_host_dev_loss_tmo(fnic->lport->host) = + fc_host_maxframe_size(fnic->host) = iport->max_payload_size; + fc_host_dev_loss_tmo(fnic->host) = fnic->config.port_down_timeout / 1000; - sprintf(fc_host_symbolic_name(fnic->lport->host), + sprintf(fc_host_symbolic_name(fnic->host), DRV_NAME " v" DRV_VERSION " over %s", fnic->name); - fc_host_port_type(fnic->lport->host) = FC_PORTTYPE_NPORT; - fc_host_node_name(fnic->lport->host) = iport->wwnn; - fc_host_port_name(fnic->lport->host) = iport->wwpn; - fc_host_supported_classes(fnic->lport->host) = FC_COS_CLASS3; - memset(fc_host_supported_fc4s(fnic->lport->host), 0, - sizeof(fc_host_supported_fc4s(fnic->lport->host))); - fc_host_supported_fc4s(fnic->lport->host)[2] = 1; - fc_host_supported_fc4s(fnic->lport->host)[7] = 1; - fc_host_supported_speeds(fnic->lport->host) = 0; - fc_host_supported_speeds(fnic->lport->host) |= FC_PORTSPEED_8GBIT; - - dev_info(&fnic->pdev->dev, "shost_data: 0x%p\n", fnic->lport->host->shost_data); - if (fnic->lport->host->shost_data != NULL) { + fc_host_port_type(fnic->host) = FC_PORTTYPE_NPORT; + fc_host_node_name(fnic->host) = iport->wwnn; + fc_host_port_name(fnic->host) = iport->wwpn; + fc_host_supported_classes(fnic->host) = FC_COS_CLASS3; + memset(fc_host_supported_fc4s(fnic->host), 0, + sizeof(fc_host_supported_fc4s(fnic->host))); + fc_host_supported_fc4s(fnic->host)[2] = 1; + fc_host_supported_fc4s(fnic->host)[7] = 1; + fc_host_supported_speeds(fnic->host) = 0; + fc_host_supported_speeds(fnic->host) |= FC_PORTSPEED_8GBIT; + + dev_info(&fnic->pdev->dev, "shost_data: 0x%p\n", fnic->host->shost_data); + if (fnic->host->shost_data != NULL) { if (fnic_tgt_id_binding == 0) { dev_info(&fnic->pdev->dev, "Setting target binding to NONE\n"); - fc_host_tgtid_bind_type(fnic->lport->host) = FC_TGTID_BIND_NONE; + fc_host_tgtid_bind_type(fnic->host) = FC_TGTID_BIND_NONE; } else { dev_info(&fnic->pdev->dev, "Setting target binding to WWPN\n"); - fc_host_tgtid_bind_type(fnic->lport->host) = FC_TGTID_BIND_BY_WWPN; + fc_host_tgtid_bind_type(fnic->host) = FC_TGTID_BIND_BY_WWPN; } } fnic->io_req_pool = mempool_create_slab_pool(2, fnic_io_req_cache); if (!fnic->io_req_pool) { - scsi_remove_host(fnic->lport->host); + scsi_remove_host(fnic->host); return -ENOMEM; } @@ -658,16 +657,16 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host) struct blk_mq_queue_map *qmap = &host->tag_set.map[HCTX_TYPE_DEFAULT]; if (intr_mode == VNIC_DEV_INTR_MODE_MSI || intr_mode == VNIC_DEV_INTR_MODE_INTX) { - FNIC_MAIN_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "intr_mode is not msix\n"); return; } - FNIC_MAIN_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "qmap->nr_queues: %d\n", qmap->nr_queues); if (l_pdev == NULL) { - FNIC_MAIN_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_MAIN_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "l_pdev is null\n"); return; } @@ -829,7 +828,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } *((struct fnic **) shost_priv(host)) = fnic; - fnic->lport->host = host; + fnic->host = host; fnic->role = FNIC_ROLE_FCP_INITIATOR; dev_info(&fnic->pdev->dev, "fnic: %d is scsi initiator\n", fnic->fnic_num); @@ -1020,7 +1019,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_free_stats_debugfs: fnic_stats_debugfs_remove(fnic); - scsi_remove_host(fnic->lport->host); + scsi_remove_host(fnic->host); err_out_scsi_drv_init: fnic_free_intr(fnic); err_out_fnic_request_intr: @@ -1041,7 +1040,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic_clear_intr_mode(fnic); err_out_fnic_set_intr_mode: if (IS_FNIC_FCP_INITIATOR(fnic)) - scsi_host_put(fnic->lport->host); + scsi_host_put(fnic->host); err_out_fnic_role: err_out_scsi_host_alloc: err_out_fnic_get_config: @@ -1130,7 +1129,7 @@ static void fnic_remove(struct pci_dev *pdev) ida_free(&fnic_ida, fnic->fnic_num); if (IS_FNIC_FCP_INITIATOR(fnic)) { fnic_scsi_unload_cleanup(fnic); - scsi_host_put(fnic->lport->host); + scsi_host_put(fnic->host); } kfree(fnic); } diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c index a1bd73550ed4..245ee1817827 100644 --- a/drivers/scsi/fnic/fnic_scsi.c +++ b/drivers/scsi/fnic/fnic_scsi.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include "fnic_io.h" @@ -174,7 +173,7 @@ unsigned int fnic_count_lun_ioreqs_wq(struct fnic *fnic, u32 hwq, if (io_req != NULL) { struct scsi_cmnd *sc = - scsi_host_find_tag(fnic->lport->host, io_req->tag); + scsi_host_find_tag(fnic->host, io_req->tag); if (!sc) continue; @@ -297,11 +296,11 @@ int fnic_fw_reset_handler(struct fnic *fnic) if (!ret) { atomic64_inc(&fnic->fnic_stats.reset_stats.fw_resets); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Issued fw reset\n"); } else { fnic_clear_state_flags(fnic, FNIC_FLAGS_FWRESET); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Failed to issue fw reset\n"); } @@ -340,13 +339,13 @@ int fnic_flogi_reg_handler(struct fnic *fnic, u32 fc_id) fc_id, gw_mac, fnic->iport.fpma, iport->r_a_tov, iport->e_d_tov); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI FIP reg issued fcid: 0x%x src %p dest %p\n", fc_id, fnic->iport.fpma, gw_mac); } else { fnic_queue_wq_copy_desc_flogi_reg(wq, SCSI_NO_TAG, format, fc_id, gw_mac); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FLOGI reg issued fcid 0x%x dest %p\n", fc_id, gw_mac); } @@ -427,7 +426,7 @@ static inline int fnic_queue_wq_copy_desc(struct fnic *fnic, free_wq_copy_descs(fnic, wq, hwq); if (unlikely(!vnic_wq_copy_desc_avail(wq))) { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic_queue_wq_copy_desc failure - no descriptors\n"); atomic64_inc(&misc_stats->io_cpwq_alloc_failures); return SCSI_MLQUEUE_HOST_BUSY; @@ -492,7 +491,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) rport = starget_to_rport(scsi_target(sc->device)); if (!rport) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "returning DID_NO_CONNECT for IO as rport is NULL\n"); sc->result = DID_NO_CONNECT << 16; done(sc); @@ -501,7 +500,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) ret = fc_remote_port_chkready(rport); if (ret) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "rport is not ready\n"); atomic64_inc(&fnic_stats->misc_stats.tport_not_ready); sc->result = ret; @@ -515,7 +514,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) if (iport->state != FNIC_IPORT_STATE_READY) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "returning DID_NO_CONNECT for IO as iport state: %d\n", iport->state); sc->result = DID_NO_CONNECT << 16; @@ -529,13 +528,13 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) rdd_data = rport->dd_data; tport = rdd_data->tport; if (!tport || (rdd_data->iport != iport)) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "dd_data not yet set in SCSI for rport portid: 0x%x\n", rport->port_id); tport = fnic_find_tport_by_fcid(iport, rport->port_id); if (!tport) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "returning DID_BUS_BUSY for IO as tport not found for: 0x%x\n", rport->port_id); sc->result = DID_BUS_BUSY << 16; @@ -558,7 +557,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) if ((tport->state != FDLS_TGT_STATE_READY) && (tport->state != FDLS_TGT_STATE_ADISC)) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "returning DID_NO_CONNECT for IO as tport state: %d\n", tport->state); sc->result = DID_NO_CONNECT << 16; @@ -578,7 +577,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) if (unlikely(fnic_chk_state_flags_locked(fnic, FNIC_FLAGS_FWRESET))) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "fnic flags FW reset: 0x%lx. Returning SCSI_MLQUEUE_HOST_BUSY\n", fnic->state_flags); return SCSI_MLQUEUE_HOST_BUSY; @@ -720,7 +719,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc) atomic_dec(&tport->in_flight); if (lun0_delay) { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "LUN0 delay\n"); mdelay(LUN0_DELAY_TIME); } @@ -760,12 +759,12 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, if (fnic->state == FNIC_IN_FC_TRANS_ETH_MODE) { /* Check status of reset completion */ if (!hdr_status) { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "reset cmpl success\n"); /* Ready to send flogi out */ fnic->state = FNIC_IN_ETH_MODE; } else { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "reset failed with header status: %s\n", fnic_fcpio_status_to_str(hdr_status)); @@ -774,7 +773,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic, ret = -1; } } else { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Unexpected state while processing reset completion: %s\n", fnic_state_to_str(fnic->state)); atomic64_inc(&reset_stats->fw_reset_failures); @@ -826,19 +825,19 @@ static int fnic_fcpio_flogi_reg_cmpl_handler(struct fnic *fnic, /* Check flogi registration completion status */ if (!hdr_status) { - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "FLOGI reg succeeded\n"); fnic->state = FNIC_IN_FC_MODE; } else { FNIC_SCSI_DBG(KERN_DEBUG, - fnic->lport->host, fnic->fnic_num, + fnic->host, fnic->fnic_num, "fnic flogi reg failed: %s\n", fnic_fcpio_status_to_str(hdr_status)); fnic->state = FNIC_IN_ETH_MODE; ret = -1; } } else { - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Unexpected fnic state %s while" " processing flogi reg completion\n", fnic_state_to_str(fnic->state)); @@ -911,7 +910,7 @@ static inline void fnic_fcpio_ack_handler(struct fnic *fnic, spin_unlock_irqrestore(&fnic->wq_copy_lock[wq_index], flags); FNIC_TRACE(fnic_fcpio_ack_handler, - fnic->lport->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3], + fnic->host->host_no, 0, 0, ox_id_tag[2], ox_id_tag[3], ox_id_tag[4], ox_id_tag[5]); } @@ -949,36 +948,36 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind hwq = blk_mq_unique_tag_to_hwq(mqtag); if (hwq != cq_index) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", hwq, mqtag, tag, cq_index); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hdr status: %s icmnd completion on the wrong queue\n", fnic_fcpio_status_to_str(hdr_status)); } if (tag >= fnic->fnic_max_tag_id) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", hwq, mqtag, tag, cq_index); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hdr status: %s Out of range tag\n", fnic_fcpio_status_to_str(hdr_status)); return; } spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); - sc = scsi_host_find_tag(fnic->lport->host, id); + sc = scsi_host_find_tag(fnic->host, id); WARN_ON_ONCE(!sc); if (!sc) { atomic64_inc(&fnic_stats->io_stats.sc_null); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "icmnd_cmpl sc is null - " "hdr status = %s tag = 0x%x desc = 0x%p\n", fnic_fcpio_status_to_str(hdr_status), id, desc); FNIC_TRACE(fnic_fcpio_icmnd_cmpl_handler, - fnic->lport->host->host_no, id, + fnic->host->host_no, id, ((u64)icmnd_cmpl->_resvd0[1] << 16 | (u64)icmnd_cmpl->_resvd0[0]), ((u64)hdr_status << 16 | @@ -1001,7 +1000,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind atomic64_inc(&fnic_stats->io_stats.ioreq_null); fnic_priv(sc)->flags |= FNIC_IO_REQ_NULL; spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "icmnd_cmpl io_req is null - " "hdr status = %s tag = 0x%x sc 0x%p\n", fnic_fcpio_status_to_str(hdr_status), id, sc); @@ -1028,7 +1027,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind if(FCPIO_ABORTED == hdr_status) fnic_priv(sc)->flags |= FNIC_IO_ABORTED; - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "icmnd_cmpl abts pending " "hdr status = %s tag = 0x%x sc = 0x%p " "scsi_status = %x residual = %d\n", @@ -1120,7 +1119,7 @@ static void fnic_fcpio_icmnd_cmpl_handler(struct fnic *fnic, unsigned int cq_ind if (hdr_status != FCPIO_SUCCESS) { atomic64_inc(&fnic_stats->io_stats.io_failures); - shost_printk(KERN_ERR, fnic->lport->host, "hdr status = %s\n", + shost_printk(KERN_ERR, fnic->host, "hdr status = %s\n", fnic_fcpio_status_to_str(hdr_status)); } @@ -1213,27 +1212,27 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde hwq = blk_mq_unique_tag_to_hwq(id & FNIC_TAG_MASK); if (hwq != cq_index) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", hwq, mqtag, tag, cq_index); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hdr status: %s ITMF completion on the wrong queue\n", fnic_fcpio_status_to_str(hdr_status)); } if (tag > fnic->fnic_max_tag_id) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", hwq, mqtag, tag, cq_index); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hdr status: %s Tag out of range\n", fnic_fcpio_status_to_str(hdr_status)); return; } else if ((tag == fnic->fnic_max_tag_id) && !(id & FNIC_TAG_DEV_RST)) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x cq index: %d ", hwq, mqtag, tag, cq_index); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hdr status: %s Tag out of range\n", fnic_fcpio_status_to_str(hdr_status)); return; @@ -1249,14 +1248,14 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde if (io_req) sc = io_req->sc; } else { - sc = scsi_host_find_tag(fnic->lport->host, id & FNIC_TAG_MASK); + sc = scsi_host_find_tag(fnic->host, id & FNIC_TAG_MASK); } WARN_ON_ONCE(!sc); if (!sc) { atomic64_inc(&fnic_stats->io_stats.sc_null); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "itmf_cmpl sc is null - hdr status = %s tag = 0x%x\n", fnic_fcpio_status_to_str(hdr_status), tag); return; @@ -1268,7 +1267,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde atomic64_inc(&fnic_stats->io_stats.ioreq_null); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); fnic_priv(sc)->flags |= FNIC_IO_ABT_TERM_REQ_NULL; - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "itmf_cmpl io_req is null - " "hdr status = %s tag = 0x%x sc 0x%p\n", fnic_fcpio_status_to_str(hdr_status), tag, sc); @@ -1279,7 +1278,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde if ((id & FNIC_TAG_ABORT) && (id & FNIC_TAG_DEV_RST)) { /* Abort and terminate completion of device reset req */ /* REVISIT : Add asserts about various flags */ - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Abt/term completion received\n", hwq, mqtag, tag, fnic_fcpio_status_to_str(hdr_status)); @@ -1291,7 +1290,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); } else if (id & FNIC_TAG_ABORT) { /* Completion of abort cmd */ - shost_printk(KERN_DEBUG, fnic->lport->host, + shost_printk(KERN_DEBUG, fnic->host, "hwq: %d mqtag: 0x%x tag: 0x%x Abort header status: %s\n", hwq, mqtag, tag, fnic_fcpio_status_to_str(hdr_status)); @@ -1306,7 +1305,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde &term_stats->terminate_fw_timeouts); break; case FCPIO_ITMF_REJECTED: - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "abort reject recd. id %d\n", (int)(id & FNIC_TAG_MASK)); break; @@ -1341,7 +1340,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) atomic64_inc(&misc_stats->no_icmnd_itmf_cmpls); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "abts cmpl recd. id %d status %s\n", (int)(id & FNIC_TAG_MASK), fnic_fcpio_status_to_str(hdr_status)); @@ -1354,11 +1353,11 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde if (io_req->abts_done) { complete(io_req->abts_done); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - shost_printk(KERN_INFO, fnic->lport->host, + shost_printk(KERN_INFO, fnic->host, "hwq: %d mqtag: 0x%x tag: 0x%x Waking up abort thread\n", hwq, mqtag, tag); } else { - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Completing IO\n", hwq, mqtag, tag, fnic_fcpio_status_to_str(hdr_status)); @@ -1389,7 +1388,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde } } else if (id & FNIC_TAG_DEV_RST) { /* Completion of device reset */ - shost_printk(KERN_INFO, fnic->lport->host, + shost_printk(KERN_INFO, fnic->host, "hwq: %d mqtag: 0x%x tag: 0x%x DR hst: %s\n", hwq, mqtag, tag, fnic_fcpio_status_to_str(hdr_status)); @@ -1401,7 +1400,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde sc->device->host->host_no, id, sc, jiffies_to_msecs(jiffies - start_time), desc, 0, fnic_flags_and_state(sc)); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s Terminate pending\n", hwq, mqtag, tag, fnic_fcpio_status_to_str(hdr_status)); @@ -1414,7 +1413,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde sc->device->host->host_no, id, sc, jiffies_to_msecs(jiffies - start_time), desc, 0, fnic_flags_and_state(sc)); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "dev reset cmpl recd after time out. " "id %d status %s\n", (int)(id & FNIC_TAG_MASK), @@ -1423,7 +1422,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde } fnic_priv(sc)->state = FNIC_IOREQ_CMD_COMPLETE; fnic_priv(sc)->flags |= FNIC_DEV_RST_DONE; - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x hst: %s DR completion received\n", hwq, mqtag, tag, fnic_fcpio_status_to_str(hdr_status)); @@ -1432,7 +1431,7 @@ static void fnic_fcpio_itmf_cmpl_handler(struct fnic *fnic, unsigned int cq_inde spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); } else { - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "%s: Unexpected itmf io state: hwq: %d tag 0x%x %s\n", __func__, hwq, id, fnic_ioreq_state_to_str(fnic_priv(sc)->state)); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); @@ -1487,7 +1486,7 @@ static int fnic_fcpio_cmpl_handler(struct vnic_dev *vdev, break; default: - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "firmware completion type %d\n", desc->hdr.type); break; @@ -1548,7 +1547,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d mqtag: 0x%x tag: 0x%x flags: 0x%x No ioreq. Returning\n", hwq, mqtag, tag, fnic_priv(sc)->flags); return true; @@ -1586,7 +1585,7 @@ static bool fnic_cleanup_io_iter(struct scsi_cmnd *sc, void *data) mempool_free(io_req, fnic->io_req_pool); sc->result = DID_TRANSPORT_DISRUPTED << 16; - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "mqtag: 0x%x tag: 0x%x sc: 0x%p duration = %lu DID_TRANSPORT_DISRUPTED\n", mqtag, tag, sc, (jiffies - start_time)); @@ -1618,12 +1617,12 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id) struct scsi_cmnd *sc = NULL; io_count = fnic_count_all_ioreqs(fnic); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Outstanding ioreq count: %d active io count: %lld Waiting\n", io_count, atomic64_read(&fnic->fnic_stats.io_stats.active_ios)); - scsi_host_busy_iter(fnic->lport->host, + scsi_host_busy_iter(fnic->host, fnic_cleanup_io_iter, fnic); /* with sg3utils device reset, SC needs to be retrieved from ioreq */ @@ -1643,7 +1642,7 @@ static void fnic_cleanup_io(struct fnic *fnic, int exclude_id) spin_unlock_irqrestore(&fnic->wq_copy_lock[0], flags); while ((io_count = fnic_count_all_ioreqs(fnic))) { - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Outstanding ioreq count: %d active io count: %lld Waiting\n", io_count, atomic64_read(&fnic->fnic_stats.io_stats.active_ios)); @@ -1670,7 +1669,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, if (id >= fnic->fnic_max_tag_id) return; - sc = scsi_host_find_tag(fnic->lport->host, id); + sc = scsi_host_find_tag(fnic->host, id); if (!sc) return; @@ -1699,7 +1698,7 @@ void fnic_wq_copy_cleanup_handler(struct vnic_wq_copy *wq, wq_copy_cleanup_scsi_cmd: sc->result = DID_NO_CONNECT << 16; - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "wq_copy_cleanup_handler:" + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "wq_copy_cleanup_handler:" " DID_NO_CONNECT\n"); FNIC_TRACE(fnic_wq_copy_cleanup_handler, @@ -1743,7 +1742,7 @@ static inline int fnic_queue_abort_io_req(struct fnic *fnic, int tag, spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); atomic_dec(&fnic->in_flight); atomic_dec(&tport->in_flight); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fnic_queue_abort_io_req: failure: no descriptors\n"); atomic64_inc(&misc_stats->abts_cpwq_alloc_failures); return 1; @@ -1788,7 +1787,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) hwq = blk_mq_unique_tag_to_hwq(abt_tag); if (!sc) { - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "sc is NULL abt_tag: 0x%x hwq: %d\n", abt_tag, hwq); return true; } @@ -1802,7 +1801,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && !(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED)) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d abt_tag: 0x%x flags: 0x%x Device reset is not pending\n", hwq, abt_tag, fnic_priv(sc)->flags); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); @@ -1819,16 +1818,16 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) } if (io_req->abts_done) { - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "fnic_rport_exch_reset: io_req->abts_done is set state is %s\n", fnic_ioreq_state_to_str(fnic_priv(sc)->state)); } if (!(fnic_priv(sc)->flags & FNIC_IO_ISSUED)) { - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "rport_exch_reset IO not yet issued %p abt_tag 0x%x", sc, abt_tag); - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "flags %x state %d\n", fnic_priv(sc)->flags, fnic_priv(sc)->state); } @@ -1839,11 +1838,13 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { atomic64_inc(&reset_stats->device_reset_terminates); abt_tag |= FNIC_TAG_DEV_RST; + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, + "dev reset sc 0x%p\n", sc); } - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fnic_rport_exch_reset: dev rst sc 0x%p\n", sc); WARN_ON_ONCE(io_req->abts_done); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fnic_rport_reset_exch: Issuing abts\n"); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); @@ -1861,7 +1862,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) * lun reset */ spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d abt_tag: 0x%x flags: 0x%x Queuing abort failed\n", hwq, abt_tag, fnic_priv(sc)->flags); if (fnic_priv(sc)->state == FNIC_IOREQ_ABTS_PENDING) @@ -1892,7 +1893,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) .term_cnt = 0, }; - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fnic rport exchange reset for tport: 0x%06x\n", port_id); @@ -1900,7 +1901,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) return; io_count = fnic_count_ioreqs(fnic, port_id); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Starting terminates: rport:0x%x portid-io-count: %d active-io-count: %lld\n", port_id, io_count, atomic64_read(&fnic->fnic_stats.io_stats.active_ios)); @@ -1914,7 +1915,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) } spin_unlock_irqrestore(&fnic->fnic_lock, flags); - scsi_host_busy_iter(fnic->lport->host, fnic_rport_abort_io_iter, + scsi_host_busy_iter(fnic->host, fnic_rport_abort_io_iter, &iter_data); if (iter_data.term_cnt > atomic64_read(&term_stats->max_terminates)) @@ -1925,7 +1926,7 @@ void fnic_rport_exch_reset(struct fnic *fnic, u32 port_id) while ((io_count = fnic_count_ioreqs(fnic, port_id))) schedule_timeout(msecs_to_jiffies(1000)); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "rport: 0x%x remaining portid-io-count: %d ", port_id, io_count); } @@ -1996,8 +1997,8 @@ void fnic_scsi_unload_cleanup(struct fnic *fnic) { int hwq = 0; - fc_remove_host(fnic->lport->host); - scsi_remove_host(fnic->lport->host); + fc_remove_host(fnic->host); + scsi_remove_host(fnic->host); for (hwq = 0; hwq < fnic->wq_copy_count; hwq++) kfree(fnic->sw_copy_wq[hwq].io_req_table); } @@ -2054,10 +2055,10 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) tport = rdd_data->tport; if (!tport) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Abort cmd called after tport delete! rport fcid: 0x%x", rport->port_id); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "lun: %llu hwq: 0x%x mqtag: 0x%x Op: 0x%x flags: 0x%x\n", sc->device->lun, hwq, mqtag, sc->cmnd[0], fnic_priv(sc)->flags); @@ -2066,18 +2067,18 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) goto fnic_abort_cmd_end; } - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Abort cmd called rport fcid: 0x%x lun: %llu hwq: 0x%x mqtag: 0x%x", rport->port_id, sc->device->lun, hwq, mqtag); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Op: 0x%x flags: 0x%x\n", sc->cmnd[0], fnic_priv(sc)->flags); if (iport->state != FNIC_IPORT_STATE_READY) { atomic64_inc(&fnic_stats->misc_stats.iport_not_ready); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport NOT in READY state"); ret = FAILED; spin_unlock_irqrestore(&fnic->fnic_lock, flags); @@ -2086,7 +2087,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) if ((tport->state != FDLS_TGT_STATE_READY) && (tport->state != FDLS_TGT_STATE_ADISC)) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "tport state: %d\n", tport->state); ret = FAILED; spin_unlock_irqrestore(&fnic->fnic_lock, flags); @@ -2137,7 +2138,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) else atomic64_inc(&abts_stats->abort_issued_greater_than_60_sec); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "CDB Opcode: 0x%02x Abort issued time: %lu msec\n", sc->cmnd[0], abt_issued_time); /* @@ -2228,7 +2229,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) if (!(fnic_priv(sc)->flags & (FNIC_IO_ABORTED | FNIC_IO_DONE))) { spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Issuing host reset due to out of order IO\n"); ret = FAILED; @@ -2276,7 +2277,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) (u64)sc->cmnd[4] << 8 | sc->cmnd[5]), fnic_flags_and_state(sc)); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Returning from abort cmd type %x %s\n", task_req, (ret == SUCCESS) ? "SUCCESS" : "FAILED"); @@ -2317,7 +2318,7 @@ static inline int fnic_queue_dr_io_req(struct fnic *fnic, free_wq_copy_descs(fnic, wq, hwq); if (!vnic_wq_copy_desc_avail(wq)) { - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "queue_dr_io_req failure - no descriptors\n"); atomic64_inc(&misc_stats->devrst_cpwq_alloc_failures); ret = -EAGAIN; @@ -2385,7 +2386,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data) * Found IO that is still pending with firmware and * belongs to the LUN that we are resetting */ - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Found IO in %s on lun\n", fnic_ioreq_state_to_str(fnic_priv(sc)->state)); @@ -2395,14 +2396,14 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data) } if ((fnic_priv(sc)->flags & FNIC_DEVICE_RESET) && (!(fnic_priv(sc)->flags & FNIC_DEV_RST_ISSUED))) { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "dev rst not pending sc 0x%p\n", sc); spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); return true; } if (io_req->abts_done) - shost_printk(KERN_ERR, fnic->lport->host, + shost_printk(KERN_ERR, fnic->host, "%s: io_req->abts_done is set state is %s\n", __func__, fnic_ioreq_state_to_str(fnic_priv(sc)->state)); old_ioreq_state = fnic_priv(sc)->state; @@ -2418,7 +2419,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data) BUG_ON(io_req->abts_done); if (fnic_priv(sc)->flags & FNIC_DEVICE_RESET) { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "dev rst sc 0x%p\n", sc); } @@ -2440,7 +2441,7 @@ static bool fnic_pending_aborts_iter(struct scsi_cmnd *sc, void *data) fnic_priv(sc)->state = old_ioreq_state; spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); iter_data->ret = FAILED; - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "hwq: %d abt_tag: 0x%lx Abort could not be queued\n", hwq, abt_tag); return false; @@ -2519,7 +2520,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, iter_data.lr_sc = lr_sc; - scsi_host_busy_iter(fnic->lport->host, + scsi_host_busy_iter(fnic->host, fnic_pending_aborts_iter, &iter_data); if (iter_data.ret == FAILED) { ret = iter_data.ret; @@ -2532,7 +2533,7 @@ static int fnic_clean_pending_aborts(struct fnic *fnic, ret = 1; clean_pending_aborts_end: - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "exit status: %d\n", ret); return ret; } @@ -2582,7 +2583,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) rport = starget_to_rport(scsi_target(sc->device)); spin_lock_irqsave(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "fcid: 0x%x lun: %llu hwq: %d mqtag: 0x%x flags: 0x%x Device reset\n", rport->port_id, sc->device->lun, hwq, mqtag, fnic_priv(sc)->flags); @@ -2590,7 +2591,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) rdd_data = rport->dd_data; tport = rdd_data->tport; if (!tport) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Dev rst called after tport delete! rport fcid: 0x%x lun: %llu\n", rport->port_id, sc->device->lun); spin_unlock_irqrestore(&fnic->fnic_lock, flags); @@ -2599,7 +2600,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) if (iport->state != FNIC_IPORT_STATE_READY) { atomic64_inc(&fnic_stats->misc_stats.iport_not_ready); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "iport NOT in READY state"); spin_unlock_irqrestore(&fnic->fnic_lock, flags); goto fnic_device_reset_end; @@ -2607,7 +2608,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) if ((tport->state != FDLS_TGT_STATE_READY) && (tport->state != FDLS_TGT_STATE_ADISC)) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "tport state: %d\n", tport->state); spin_unlock_irqrestore(&fnic->fnic_lock, flags); goto fnic_device_reset_end; @@ -2670,7 +2671,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) fnic_priv(sc)->lr_status = FCPIO_INVALID_CODE; spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, "TAG %x\n", mqtag); + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "TAG %x\n", mqtag); /* * issue the device reset, if enqueue failed, clean up the ioreq @@ -2721,13 +2722,13 @@ int fnic_device_reset(struct scsi_cmnd *sc) io_req = fnic_priv(sc)->io_req; if (!io_req) { spin_unlock_irqrestore(&fnic->wq_copy_lock[hwq], flags); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "io_req is null mqtag 0x%x sc 0x%p\n", mqtag, sc); goto fnic_device_reset_end; } if (exit_dr) { - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Host reset called for fnic. Exit device reset\n"); io_req->dr_done = NULL; goto fnic_device_reset_clean; @@ -2742,7 +2743,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) */ if (status == FCPIO_INVALID_CODE) { atomic64_inc(&reset_stats->device_reset_timeouts); - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Device reset timed out\n"); fnic_priv(sc)->flags |= FNIC_DEV_RST_TIMED_OUT; int_to_scsilun(sc->device->lun, &fc_lun); @@ -2755,7 +2756,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) if (status != FCPIO_SUCCESS) { spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); FNIC_SCSI_DBG(KERN_DEBUG, - fnic->lport->host, fnic->fnic_num, + fnic->host, fnic->fnic_num, "Device reset completed - failed\n"); io_req = fnic_priv(sc)->io_req; goto fnic_device_reset_clean; @@ -2771,7 +2772,7 @@ int fnic_device_reset(struct scsi_cmnd *sc) if (fnic_clean_pending_aborts(fnic, sc, new_sc)) { spin_lock_irqsave(&fnic->wq_copy_lock[hwq], flags); io_req = fnic_priv(sc)->io_req; - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Device reset failed: Cannot abort all IOs\n"); goto fnic_device_reset_clean; } @@ -2825,13 +2826,13 @@ int fnic_device_reset(struct scsi_cmnd *sc) ret = FAILED; break; } - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "Cannot clean up all IOs for the LUN\n"); schedule_timeout(msecs_to_jiffies(1000)); count++; } - FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_DEBUG, fnic->host, fnic->fnic_num, "Returning from device reset %s\n", (ret == SUCCESS) ? "SUCCESS" : "FAILED"); @@ -2866,13 +2867,13 @@ void fnic_reset(struct Scsi_Host *shost) fnic = *((struct fnic **) shost_priv(shost)); reset_stats = &fnic->fnic_stats.reset_stats; - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Issuing fnic reset\n"); atomic64_inc(&reset_stats->fnic_resets); fnic_post_flogo_linkflap(fnic); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Returning from fnic reset"); atomic64_inc(&reset_stats->fnic_reset_completions); @@ -2883,7 +2884,7 @@ int fnic_issue_fc_host_lip(struct Scsi_Host *shost) int ret = 0; struct fnic *fnic = *((struct fnic **) shost_priv(shost)); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FC host lip issued"); ret = fnic_host_reset(shost); @@ -2909,7 +2910,7 @@ int fnic_host_reset(struct Scsi_Host *shost) spin_lock_irqsave(&fnic->fnic_lock, flags); if (fnic->reset_in_progress == IN_PROGRESS) { spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_WARNING, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_WARNING, fnic->host, fnic->fnic_num, "Firmware reset in progress. Skipping another host reset\n"); return SUCCESS; } @@ -2947,7 +2948,7 @@ int fnic_host_reset(struct Scsi_Host *shost) } spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "host reset return status: %d\n", ret); return ret; } @@ -2987,7 +2988,7 @@ static bool fnic_abts_pending_iter(struct scsi_cmnd *sc, void *data) * Found IO that is still pending with firmware and * belongs to the LUN that we are resetting */ - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "hwq: %d tag: 0x%x Found IO in state: %s on lun\n", hwq, tag, fnic_ioreq_state_to_str(fnic_priv(sc)->state)); @@ -3020,7 +3021,7 @@ int fnic_is_abts_pending(struct fnic *fnic, struct scsi_cmnd *lr_sc) } /* walk again to check, if IOs are still pending in fw */ - scsi_host_busy_iter(fnic->lport->host, + scsi_host_busy_iter(fnic->host, fnic_abts_pending_iter, &iter_data); return iter_data.ret; @@ -3041,7 +3042,7 @@ int fnic_eh_host_reset_handler(struct scsi_cmnd *sc) struct Scsi_Host *shost = sc->device->host; struct fnic *fnic = *((struct fnic **) shost_priv(shost)); - FNIC_SCSI_DBG(KERN_ERR, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_ERR, fnic->host, fnic->fnic_num, "SCSI error handling: fnic host reset"); ret = fnic_host_reset(shost); @@ -3062,7 +3063,7 @@ void fnic_scsi_fcpio_reset(struct fnic *fnic) if (unlikely(fnic->state == FNIC_IN_FC_TRANS_ETH_MODE)) { /* fw reset is in progress, poll for its completion */ spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "fnic is in unexpected state: %d for fw_reset\n", fnic->state); return; @@ -3075,7 +3076,7 @@ void fnic_scsi_fcpio_reset(struct fnic *fnic) fnic->fw_reset_done = &fw_reset_done; spin_unlock_irqrestore(&fnic->fnic_lock, flags); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Issuing fw reset\n"); if (fnic_fw_reset_handler(fnic)) { spin_lock_irqsave(&fnic->fnic_lock, flags); @@ -3083,14 +3084,14 @@ void fnic_scsi_fcpio_reset(struct fnic *fnic) fnic->state = old_state; spin_unlock_irqrestore(&fnic->fnic_lock, flags); } else { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Waiting for fw completion\n"); time_remain = wait_for_completion_timeout(&fw_reset_done, msecs_to_jiffies(FNIC_FW_RESET_TIMEOUT)); - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "Woken up after fw completion timeout\n"); if (time_remain == 0) { - FNIC_SCSI_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, + FNIC_SCSI_DBG(KERN_INFO, fnic->host, fnic->fnic_num, "FW reset completion timed out after %d ms)\n", FNIC_FW_RESET_TIMEOUT); } From patchwork Fri Sep 27 18:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karan Tilak Kumar X-Patchwork-Id: 831142 Received: from rcdn-iport-8.cisco.com (rcdn-iport-8.cisco.com [173.37.86.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53161C231B; Fri, 27 Sep 2024 18:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.37.86.79 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463385; cv=none; b=tZZgwtmRWIbya0+Tjr4WpiU5Awdz+/PVsKrGAq07iTxAz6+OvkanABi0Yn0TMjj3LX/C9yn/q8yv26e8nwXqTlqp7pMNNayS6BV/g5kr8Rpq3zdY/lnRSlXO5Har+hAZKxWl2gIRBy1jIgF0md1722cXQmyZ+JaiYwfKZ9sH9hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727463385; c=relaxed/simple; bh=NmqTBS2M114EHPAipTamt0kG8fUPzQBtoVqUb2vTBKc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BGgjAr62tZejRLqPGWnJHwdpOF7MTzT4QZ7SxwUY1O8o/3mTnH01eSSd/oI3wBN+VBhKc6LGLgGQT9WWXibac7wrwQMq2osniZUmYjcGRBhFPLFX2hyH5lKyd9LAzwrbDB/sJwtPT8bcVqmRbAX5cvB2+hOS/iO0xjeUv/ynPxE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com; spf=pass smtp.mailfrom=cisco.com; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b=QafpCPRG; arc=none smtp.client-ip=173.37.86.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cisco.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cisco.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=cisco.com header.i=@cisco.com header.b="QafpCPRG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cisco.com; i=@cisco.com; l=11044; q=dns/txt; s=iport; t=1727463384; x=1728672984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jzemj4JBh02dXKpfx/uKNeyANrVOknIJwK2dcRAp1/o=; b=QafpCPRGfUt13lG1jqyMd6PrHp7lp8vy+oOaiP2J2idt+CkPeHRMYUTJ jWUfbC6rnIZGvH1bj/OgaaHTzlIdKVxbjSuKoyau23iJE3dfL6Oo7I5lD EkZxusY8EroALwICT1DWFa/VN3L8i07NVth9GFv/lzRHMKy2mJgQIVmyQ 8=; X-CSE-ConnectionGUID: zZZwcscLR32BkEpw9orfqQ== X-CSE-MsgGUID: YR3XGh2dT9CsgB/4PKFBsg== X-IronPort-AV: E=Sophos;i="6.11,159,1725321600"; d="scan'208";a="258699879" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-8.cisco.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2024 18:55:15 +0000 Received: from localhost.cisco.com ([10.193.101.253]) (authenticated bits=0) by rcdn-core-5.cisco.com (8.15.2/8.15.2) with ESMTPSA id 48RIkQau022754 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 27 Sep 2024 18:55:14 GMT From: Karan Tilak Kumar To: sebaddel@cisco.com Cc: arulponn@cisco.com, djhawar@cisco.com, gcboffa@cisco.com, mkai2@cisco.com, satishkh@cisco.com, aeasi@cisco.com, jejb@linux.ibm.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Karan Tilak Kumar Subject: [PATCH v3 13/14] scsi: fnic: Add support to handle port channel RSCN Date: Fri, 27 Sep 2024 11:46:12 -0700 Message-Id: <20240927184613.52172-14-kartilak@cisco.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240927184613.52172-1-kartilak@cisco.com> References: <20240927184613.52172-1-kartilak@cisco.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Authenticated-User: kartilak@cisco.com X-Outbound-SMTP-Client: 10.193.101.253, [10.193.101.253] X-Outbound-Node: rcdn-core-5.cisco.com Add support to handle port channel RSCN. Port channel RSCN is a Cisco vendor specific RSCN event. It is applicable only to Cisco UCS fabrics. If there's a change in the port channel configuration, an RCSN is sent to fnic. This is used to serially reset the scsi initiator fnics so that there's no all paths down scenario. The affected fnics are added to a list that are reset with a small time gap between them. Reviewed-by: Sesidhar Baddela Reviewed-by: Arulprabhu Ponnusamy Reviewed-by: Gian Carlo Boffa Signed-off-by: Karan Tilak Kumar --- Changes between v2 and v3: Incorporate review comments from Hannes from other patches: Replace redundant definitions with standard definitions. Changes between v1 and v2: Replace pr_err with printk. Incorporate review comments from Hannes from other patches: Replace pr_err with dev_err. --- drivers/scsi/fnic/fdls_disc.c | 64 ++++++++++++++++++++++++++++------- drivers/scsi/fnic/fnic.h | 25 ++++++++++++++ drivers/scsi/fnic/fnic_fcs.c | 35 +++++++++++++++++++ drivers/scsi/fnic/fnic_main.c | 30 ++++++++++++++++ 4 files changed, 141 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/fnic/fdls_disc.c b/drivers/scsi/fnic/fdls_disc.c index 5701583ea7a4..6aa19f2a0a39 100644 --- a/drivers/scsi/fnic/fdls_disc.c +++ b/drivers/scsi/fnic/fdls_disc.c @@ -3904,6 +3904,9 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) int newports = 0; struct fnic_fdls_fabric_s *fdls = &iport->fabric; struct fnic *fnic = iport->fnic; + int rscn_type = NOT_PC_RSCN; + uint32_t sid = ntoh24(fchdr->fh_s_id); + unsigned long reset_fnic_list_lock_flags = 0; uint16_t rscn_payload_len; atomic64_inc(&iport->iport_stats.num_rscns); @@ -3926,16 +3929,24 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) || (rscn_payload_len > 1024) || (rscn->els.rscn_page_len != 4)) { num_ports = 0; - FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, - "RSCN payload_len: 0x%x page_len: 0x%x", - rscn_payload_len, rscn->els.rscn_page_len); - /* if this happens then we need to send ADISC to all the tports. */ - list_for_each_entry_safe(tport, next, &iport->tport_list, links) { - if (tport->state == FDLS_TGT_STATE_READY) - tport->flags |= FNIC_FDLS_TPORT_SEND_ADISC; + if ((rscn_payload_len == 0xFFFF) + && (sid == FC_FABRIC_CONTROLLER)) { + rscn_type = PC_RSCN; FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, - "RSCN for port id: 0x%x", tport->fcid); - } + "pcrscn: PCRSCN received. sid: 0x%x payload len: 0x%x", + sid, rscn_payload_len); + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "RSCN payload_len: 0x%x page_len: 0x%x", + rscn_payload_len, rscn->els.rscn_page_len); + /* if this happens then we need to send ADISC to all the tports. */ + list_for_each_entry_safe(tport, next, &iport->tport_list, links) { + if (tport->state == FDLS_TGT_STATE_READY) + tport->flags |= FNIC_FDLS_TPORT_SEND_ADISC; + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "RSCN for port id: 0x%x", tport->fcid); + } + } /* end else */ } else { num_ports = (rscn_payload_len - 4) / rscn->els.rscn_page_len; rscn_port = (struct fc_els_rscn_page *)(rscn + 1); @@ -3982,10 +3993,37 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) tport->flags |= FNIC_FDLS_TPORT_SEND_ADISC; } - FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, - "FDLS process RSCN sending GPN_FT %p", iport); - fdls_send_gpn_ft(iport, FDLS_STATE_RSCN_GPN_FT); - fdls_send_rscn_resp(iport, fchdr); + if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON && + rscn_type == PC_RSCN && fnic->role == FNIC_ROLE_FCP_INITIATOR) { + + if (fnic->pc_rscn_handling_status == PC_RSCN_HANDLING_IN_PROGRESS) { + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "PCRSCN handling already in progress. Skip host reset: %d", + iport->fnic->fnic_num); + return; + } + + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "Processing PCRSCN. Queuing fnic for host reset: %d", + iport->fnic->fnic_num); + fnic->pc_rscn_handling_status = PC_RSCN_HANDLING_IN_PROGRESS; + + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags); + + spin_lock_irqsave(&reset_fnic_list_lock, + reset_fnic_list_lock_flags); + list_add_tail(&fnic->links, &reset_fnic_list); + spin_unlock_irqrestore(&reset_fnic_list_lock, + reset_fnic_list_lock_flags); + + queue_work(reset_fnic_work_queue, &reset_fnic_work); + spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags); + } else { + FNIC_FCS_DBG(KERN_INFO, fnic->host, fnic->fnic_num, + "FDLS process RSCN sending GPN_FT %p", iport); + fdls_send_gpn_ft(iport, FDLS_STATE_RSCN_GPN_FT); + fdls_send_rscn_resp(iport, fchdr); + } } void fnic_fdls_disc_start(struct fnic_iport_s *iport) diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h index 5ad9d6df92a8..5fd506fcea35 100644 --- a/drivers/scsi/fnic/fnic.h +++ b/drivers/scsi/fnic/fnic.h @@ -211,11 +211,33 @@ enum reset_states { RESET_ERROR }; +enum rscn_type { + NOT_PC_RSCN = 0, + PC_RSCN +}; + +enum pc_rscn_handling_status { + PC_RSCN_HANDLING_NOT_IN_PROGRESS = 0, + PC_RSCN_HANDLING_IN_PROGRESS +}; + +enum pc_rscn_handling_feature { + PC_RSCN_HANDLING_FEATURE_OFF = 0, + PC_RSCN_HANDLING_FEATURE_ON +}; + extern unsigned int fnic_fdmi_support; extern unsigned int fnic_log_level; extern unsigned int io_completions; extern struct workqueue_struct *fnic_event_queue; +extern unsigned int pc_rscn_handling_feature_flag; +extern spinlock_t reset_fnic_list_lock; +extern struct list_head reset_fnic_list; +extern struct workqueue_struct *reset_fnic_work_queue; +extern struct work_struct reset_fnic_work; + + #define FNIC_MAIN_LOGGING 0x01 #define FNIC_FCS_LOGGING 0x02 #define FNIC_SCSI_LOGGING 0x04 @@ -396,6 +418,7 @@ struct fnic { int link_status; struct list_head list; + struct list_head links; struct pci_dev *pdev; struct vnic_fc_config config; struct vnic_dev *vdev; @@ -422,6 +445,7 @@ struct fnic { char subsys_desc[14]; int subsys_desc_len; + int pc_rscn_handling_status; /*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *, u16 vlan); @@ -503,6 +527,7 @@ void fnic_stats_debugfs_remove(struct fnic *fnic); int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *); void fnic_handle_fip_frame(struct work_struct *work); +void fnic_reset_work_handler(struct work_struct *work); void fnic_handle_fip_event(struct fnic *fnic); void fnic_fcoe_reset_vlans(struct fnic *fnic); extern void fnic_handle_fip_timer(struct timer_list *t); diff --git a/drivers/scsi/fnic/fnic_fcs.c b/drivers/scsi/fnic/fnic_fcs.c index 3e82d64483e2..f55ebbc1bc1c 100644 --- a/drivers/scsi/fnic/fnic_fcs.c +++ b/drivers/scsi/fnic/fnic_fcs.c @@ -1109,4 +1109,39 @@ void fnic_flush_tport_event_list(struct fnic *fnic) spin_unlock_irqrestore(&fnic->fnic_lock, flags); } +void fnic_reset_work_handler(struct work_struct *work) +{ + struct fnic *cur_fnic, *next_fnic; + unsigned long reset_fnic_list_lock_flags; + int host_reset_ret_code; + + /* + * This is a single thread. It is per fnic module, not per fnic + * All the fnics that need to be reset + * have been serialized via the reset fnic list. + */ + spin_lock_irqsave(&reset_fnic_list_lock, reset_fnic_list_lock_flags); + list_for_each_entry_safe(cur_fnic, next_fnic, &reset_fnic_list, links) { + list_del(&cur_fnic->links); + spin_unlock_irqrestore(&reset_fnic_list_lock, + reset_fnic_list_lock_flags); + + dev_err(&cur_fnic->pdev->dev, "fnic: <%d>: issuing a host reset\n", + cur_fnic->fnic_num); + host_reset_ret_code = fnic_host_reset(cur_fnic->host); + dev_err(&cur_fnic->pdev->dev, + "fnic: <%d>: returned from host reset with status: %d\n", + cur_fnic->fnic_num, host_reset_ret_code); + + spin_lock_irqsave(&cur_fnic->fnic_lock, cur_fnic->lock_flags); + cur_fnic->pc_rscn_handling_status = + PC_RSCN_HANDLING_NOT_IN_PROGRESS; + spin_unlock_irqrestore(&cur_fnic->fnic_lock, cur_fnic->lock_flags); + + spin_lock_irqsave(&reset_fnic_list_lock, + reset_fnic_list_lock_flags); + } + spin_unlock_irqrestore(&reset_fnic_list_lock, + reset_fnic_list_lock_flags); +} diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c index 69be3eed0a50..c1d06abe86b1 100644 --- a/drivers/scsi/fnic/fnic_main.c +++ b/drivers/scsi/fnic/fnic_main.c @@ -44,6 +44,10 @@ static LIST_HEAD(fnic_list); static DEFINE_SPINLOCK(fnic_list_lock); static DEFINE_IDA(fnic_ida); +struct work_struct reset_fnic_work; +LIST_HEAD(reset_fnic_list); +DEFINE_SPINLOCK(reset_fnic_list_lock); + /* Supported devices by fnic module */ static struct pci_device_id fnic_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_FNIC) }, @@ -88,6 +92,12 @@ static unsigned int fnic_max_qdepth = FNIC_DFLT_QUEUE_DEPTH; module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR); MODULE_PARM_DESC(fnic_max_qdepth, "Queue depth to report for each LUN"); +unsigned int pc_rscn_handling_feature_flag = PC_RSCN_HANDLING_FEATURE_ON; +module_param(pc_rscn_handling_feature_flag, uint, 0644); +MODULE_PARM_DESC(pc_rscn_handling_feature_flag, + "PCRSCN handling (0 for none. 1 to handle PCRSCN (default))"); + +struct workqueue_struct *reset_fnic_work_queue; struct workqueue_struct *fnic_fip_queue; static int fnic_slave_alloc(struct scsi_device *sdev) @@ -1221,6 +1231,19 @@ static int __init fnic_init_module(void) goto err_create_fip_workq; } + if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON) { + reset_fnic_work_queue = + create_singlethread_workqueue("reset_fnic_work_queue"); + if (!reset_fnic_work_queue) { + pr_err("reset fnic work queue create failed\n"); + err = -ENOMEM; + goto err_create_reset_fnic_workq; + } + spin_lock_init(&reset_fnic_list_lock); + INIT_LIST_HEAD(&reset_fnic_list); + INIT_WORK(&reset_fnic_work, fnic_reset_work_handler); + } + fnic_fc_transport = fc_attach_transport(&fnic_fc_functions); if (!fnic_fc_transport) { printk(KERN_ERR PFX "fc_attach_transport error\n"); @@ -1241,6 +1264,9 @@ static int __init fnic_init_module(void) err_fc_transport: destroy_workqueue(fnic_fip_queue); err_create_fip_workq: + if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON) + destroy_workqueue(reset_fnic_work_queue); +err_create_reset_fnic_workq: destroy_workqueue(fnic_event_queue); err_create_fnic_workq: kmem_cache_destroy(fnic_io_req_cache); @@ -1259,6 +1285,10 @@ static void __exit fnic_cleanup_module(void) { pci_unregister_driver(&fnic_driver); destroy_workqueue(fnic_event_queue); + + if (pc_rscn_handling_feature_flag == PC_RSCN_HANDLING_FEATURE_ON) + destroy_workqueue(reset_fnic_work_queue); + if (fnic_fip_queue) { flush_workqueue(fnic_fip_queue); destroy_workqueue(fnic_fip_queue);