Introduce support for Fabric Discovery and...
Subsystems (2)
Karan Tilak Kumar
maintainerv7 cover Introduce support for Fabric Discovery and...
...Login Services
Hi Martin, reviewers,
This cover letter describes the feature: add support for Fabric Discovery and Login Services (FDLS) to fnic driver.
This functionality is needed to support port channel RSCN (PC-RSCN) handling and serves as a base to create FC-NVME initiators (planned later), and eCPU handling (planned later).
It is used to discover the fabric and target ports associated with the fabric.
It will then login to the target ports that are zoned to it. The driver uses the tport structure presented by FDLS.
Port channel RSCN is a Cisco vendor specific RSCN event. It is applicable only to Cisco UCS fabrics.
In cases where the eCPU in the UCS VIC (Unified Computing Services Virtual Interface Card) hangs, a fabric log out is sent to the fabric. Upon successful log out from the fabric, the IO path is failed over to a new path.
Generally from a feature perspective, the code is divided into adding support for this functionality initially. Then, code has been added to modify the IO path and interfaces. Finally, support for port channel RSCN handling has been added.
Here are the headers of some of the salient patches:
o add headers and definitions for FDLS
o add support for fabric based solicited requests and responses
o add support for target based solicited requests and responses
o add support for unsolicited requests and responses
o add support for FDMI
o add support for FIP
o add functionality in fnic to support FDLS
o modify IO path to use FDLS and tport
o modify fnic interfaces to use FDLS
o add support to handle port channel RSCN
Even though the patches have been made into a series, some patches are heavier than others. But, every effort has been made to keep the purpose of each patch as a single-purpose, and to compile cleanly. All the individual patches compile cleanly. The compiler used is GCC 13.3. Some function calls have been coded as placeholders with appropriate comments to avoid compiler warnings.
This patchset has been tested as a whole. Therefore, the tested-by fields have been added only to one patch in the set. I've refrained from adding tested-by to most of the patches, so as to not mislead the reviewer/reader.
A brief note on the unit tests:
o. Perform zone in zone out testing in a loop: remove a target port from the zone, add it to the zone in a loop. 1000+ iterations of this test have been successful.
o. Configure multipathing, and run link flaps on single link. IOs drop briefly, but pick up as expected.
o. Configure multipathing, and run link flaps on two links, with a 30 second delay in between. IOs drop briefly, but pick up as expected. o. Module load/unload test.
o. Repeat the above tests with 1 queue and 64 queues.
All tests were successful.
Please consider this patch series for the next merge window.
Changes between v1 and v2:
Replace pr_err with printk.
Replace simultaneous use of fc_tport_abts_s and tport_abts with
just tport_abts.
Incorporate review comments by Hannes:
Replace pr_info with dev_info.
Replace pr_err with dev_err.
Restore usage of tagset iterators.
Replace fnic_del_tport_timer_sync macro calls with function calls.
Use the correct kernel-doc format.
Replace definitions with standard definitions from fc_els.h.
Replace htonll() with get_unaligned_be64().
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 indentation.
Replace fnic_del_fabric_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.
Modify functions with returns in the middle to if else clauses.
Remove double newline.
Fix indentation in fnic_send_frame.
Add fnic_del_fabric_timer_sync as an inline function. Add fnic_del_tport_timer_sync as an inline function. Modify fc_abts_s variable name to fc_fabric_abts_s. Modify fc_fabric_abts_s to be a global frame. Rename pfc_abts to fabric_abts.
Remove redundant patch description.
Replace htonll() with get_unaligned_be64(). Replace raw values with macro names.
Remove fnic_del_fabric_timer_sync macro.
Remove fnic_del_tport_timer_sync macro.
Add fnic_del_fabric_timer_sync function declaration. Add fnic_del_tport_timer_sync function declaration. Move FDMI function declaration.
Modify patch heading and description appropriately.
Incorporate review comments from John:
Remove unreferenced variable.
Use standard definitions of true and false. Replace if else clauses with switch statement. Use kzalloc instead of kmalloc.
Modify fnic_send_fcoe_frame to not send a return value. Replace int return value with void.
Fix warning from kernel test robot:
Remove version.h
Changes between v2 and v3:
Incorporate review comments from Hannes:
Replace redundant structure definitions with standard definitions.
Replace static OXIDs with pool-based OXIDs for fabric. Replace static OXIDs with pool-based OXIDs for targets. Remove multiple endian macro copies.
Modify locking as applicable.
Incorporate review comments from John:
Replace GFP_ATOMIC with GFP_KERNEL where applicable.
Replace fnic->host with fnic->lport->host in some patches to prevent compilation errors.
Fix issues found by kernel test robot.
Refactor fnic_std_ba_acc definition to fix compilation warning. Refactor fnic_fdls_remove_tport to fix null pointer exception. Modify scsi_unload to fix null pointer exception during fnic_remove.
Changes between v3 and v4:
Fix kernel test robot warnings.
Rebase code to 6.12/scsi-queue.
Changes between v4 and v5:
Remove unnecessary tabs from the bottom of fip.h. Incorporate review comments from Martin:
Remove newline at the end of files. Modify attribution appropriately. Refactor call to fnic_fdls_start_flogi. Refactor call to fdls_get_tgt_oxid_pool. Modify fnic_get_stats to suppress compiler warning.
Changes between v5 and v6:
Rebase to 6.14/scsi-queue.
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Refactor function definitions to top of file. Modify OXID allocation and reclaim design. Allocate OXID from a mempool.
Allocate frames from a mempool.
Modify frame initialization.
Modify frame send by avoiding memcpy in hot path. Add comments.
Replace tag walk with scsi_host_busy_iter. Replace custom definitions with standard definitions. Split FDMI patch into PCI patch and FDMI patch. Refactor FDMI macros into fnic_main.c. Replace FDMI custom definition with standard definition.
Changes between v6 and v7:
Fix test robot warnings.
Thanks and regards,
Karan
Karan Tilak Kumar (15):
scsi: fnic: Replace shost_printk with dev_info/dev_err
scsi: fnic: Add headers and definitions for FDLS
scsi: fnic: Add support for fabric based solicited requests and
responses
scsi: fnic: Add support for target based solicited requests and
responses
scsi: fnic: Add support for unsolicited requests and responses
scsi: fnic: Add Cisco hardware model names
scsi: fnic: Add and integrate support for FDMI
scsi: fnic: Add and integrate support for FIP
scsi: fnic: Add functionality in fnic to support FDLS
scsi: fnic: Modify IO path to use FDLS
scsi: fnic: Modify fnic interfaces to use FDLS
scsi: fnic: Add stats and related functionality
scsi: fnic: Code cleanup
scsi: fnic: Add support to handle port channel RSCN
scsi: fnic: Increment driver version
drivers/scsi/fnic/Makefile | 5 +- drivers/scsi/fnic/fdls_disc.c | 5019 +++++++++++++++++++++ drivers/scsi/fnic/fdls_fc.h | 253 ++ drivers/scsi/fnic/fip.c | 1008 +++++ drivers/scsi/fnic/fip.h | 157 + drivers/scsi/fnic/fnic.h | 290 +- drivers/scsi/fnic/fnic_attrs.c | 12 +- drivers/scsi/fnic/fnic_debugfs.c | 30 +- drivers/scsi/fnic/fnic_fcs.c | 1743 +++---- drivers/scsi/fnic/fnic_fdls.h | 434 ++ drivers/scsi/fnic/fnic_fip.h | 48 - drivers/scsi/fnic/fnic_io.h | 14 +- drivers/scsi/fnic/fnic_isr.c | 28 +- drivers/scsi/fnic/fnic_main.c | 731 +-- drivers/scsi/fnic/fnic_pci_subsys_devid.c | 131 + drivers/scsi/fnic/fnic_res.c | 77 +- drivers/scsi/fnic/fnic_scsi.c | 1161 +++-- drivers/scsi/fnic/fnic_stats.h | 49 +- drivers/scsi/fnic/fnic_trace.c | 81 +- 19 files changed, 9340 insertions(+), 1931 deletions(-) create mode 100644 drivers/scsi/fnic/fdls_disc.c create mode 100644 drivers/scsi/fnic/fdls_fc.h create mode 100644 drivers/scsi/fnic/fip.c create mode 100644 drivers/scsi/fnic/fip.h create mode 100644 drivers/scsi/fnic/fnic_fdls.h delete mode 100644 drivers/scsi/fnic/fnic_fip.h create mode 100644 drivers/scsi/fnic/fnic_pci_subsys_devid.c
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 1/15 scsi: fnic: Replace shost_printk with dev_info/dev_err
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.
---
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(-)
drivers/scsi/fnic/fnic_main.c +28 -56
@@ -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 );
@@ -834,8 +811,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 ; }
@@ -850,8 +826,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; }
@@ -863,8 +838,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; }
@@ -882,8 +856,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; }
@@ -893,8 +866,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; }
drivers/scsi/fnic/fnic_res.c +23 -46
125 lines not on this page · raw message
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 2/15 scsi: fnic: Add headers and definitions for FDLS
In reply to Karan Tilak KumarAdd headers and definitions for FDLS (Fabric Discovery and Login Services).
---
Changes between v5 and v6:
Rebase to 6.14/scsi-queue.
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Replace custom definitions with standard definitions. Remove FDMI macro definitions.
Replace FDMI with standard FDMI definition.
Changes between v4 and v5:
Incorporate review comments from Martin:
Remove newline at the end of fnic_fdls.h.
Modify attribution appropriately.
Changes between v2 and v3:
Incorporate review comments from Hannes:
Replace redundant structure definitions with standard definitions.
Remove multiple endian macro copies.
Remove static OXIDs macro definitions.
Changes between v1 and v2:
Incorporate review comments from Hannes:
Remove redundant patch description.
Replace htonll() with get_unaligned_be64(). Replace raw values with macro names.
Remove fnic_del_fabric_timer_sync macro.
Remove fnic_del_tport_timer_sync macro.
Add fnic_del_fabric_timer_sync function declaration. Add fnic_del_tport_timer_sync function declaration. Replace definitions with standard definitions from fc_els.h. Move FDMI function declaration to this patch.
Incorporate review comments from John:
Replace int return value with void.
--- drivers/scsi/fnic/fdls_fc.h | 253 ++++++++++++++++++++ drivers/scsi/fnic/fnic_fdls.h | 433 ++++++++++++++++++++++++++++++++++ 2 files changed, 686 insertions(+) create mode 100644 drivers/scsi/fnic/fdls_fc.h create mode 100644 drivers/scsi/fnic/fnic_fdls.h
drivers/scsi/fnic/fdls_fc.h new file +253 -0
@@ -0,0 +1,253 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright 2008 Cisco Systems, Inc. All rights reserved. +* Copyright 2007 Nuova Systems, Inc. All rights reserved. +*/ + +#ifndef _FDLS_FC_H_ +#define _FDLS_FC_H_ + +/* This file contains the declarations for FC fabric services +* and target discovery +* +* Request and Response for +* 1. FLOGI +* 2. PLOGI to Fabric Controller +* 3. GPN_ID, GPN_FT +* 4. RSCN +* 5. PLOGI to Target +* 6. PRLI to Target +*/ + +#include <scsi/scsi.h> +#include <scsi/fc/fc_els.h> +#include <uapi/scsi/fc/fc_fs.h> +#include <uapi/scsi/fc/fc_ns.h> +#include <uapi/scsi/fc/fc_gs.h> +#include <uapi/linux/if_ether.h> +#include <scsi/fc/fc_ms.h> +#include <linux/minmax.h> +#include <linux/if_ether.h> +#include <scsi/fc/fc_encaps.h> +#include <scsi/fc/fc_fcoe.h> + +#define FDLS_MIN_FRAMES (32) +#define FDLS_MIN_FRAME_ELEM (4) +#define FNIC_FCP_SP_RD_XRDY_DIS 0x00000002 +#define FNIC_FCP_SP_TARGET 0x00000010 +#define FNIC_FCP_SP_INITIATOR 0x00000020 +#define FNIC_FCP_SP_CONF_CMPL 0x00000080 +#define FNIC_FCP_SP_RETRY 0x00000100 + +#define FNIC_FC_CONCUR_SEQS (0xFF) +#define FNIC_FC_RO_INFO (0x1F) + +/* Little Endian */ +#define FNIC_UNASSIGNED_OXID (0xffff) +#define FNIC_UNASSIGNED_RXID (0xffff) +#define FNIC_ELS_REQ_FCTL (0x000029) +#define FNIC_ELS_REP_FCTL (0x000099) + +#define FNIC_FCP_RSP_FCTL (0x000099) +#define FNIC_REQ_ABTS_FCTL (0x000009) + +#define FNIC_FC_PH_VER_HI (0x20) +#define FNIC_FC_PH_VER_LO (0x20) +#define FNIC_FC_PH_VER (0x2020) +#define FNIC_FC_B2B_CREDIT (0x0A) +#define FNIC_FC_B2B_RDF_SZ (0x0800) + +#define FNIC_LOGI_RDF_SIZE (_logi) ((_logi).fl_csp.sp_bb_data) +#define FNIC_LOGI_R_A_TOV (_logi) ((_logi).fl_csp.sp_r_a_tov) +#define FNIC_LOGI_E_D_TOV (_logi) ((_logi).fl_csp.sp_e_d_tov) +#define FNIC_LOGI_FEATURES (_logi) (be16_to_cpu((_logi).fl_csp.sp_features)) +#define FNIC_LOGI_PORT_NAME (_logi) ((_logi).fl_wwpn) +#define FNIC_LOGI_NODE_NAME (_logi) ((_logi).fl_wwnn) + +#define FNIC_LOGI_SET_RDF_SIZE (_logi, _rdf_size) \ + (FNIC_LOGI_RDF_SIZE(_logi) = cpu_to_be16(_rdf_size)) +#define FNIC_LOGI_SET_E_D_TOV (_logi, _e_d_tov) \ + (FNIC_LOGI_E_D_TOV(_logi) = cpu_to_be32(_e_d_tov)) +#define FNIC_LOGI_SET_R_A_TOV (_logi, _r_a_tov) \ + (FNIC_LOGI_R_A_TOV(_logi) = cpu_to_be32(_r_a_tov)) + +#define FNIC_STD_SET_S_ID (_fchdr, _sid) memcpy((_fchdr).fh_s_id, _sid, 3) +#define FNIC_STD_SET_D_ID (_fchdr, _did) memcpy((_fchdr).fh_d_id, _did, 3) +#define FNIC_STD_SET_OX_ID (_fchdr, _oxid) ((_fchdr).fh_ox_id = cpu_to_be16(_oxid)) +#define FNIC_STD_SET_RX_ID (_fchdr, _rxid) ((_fchdr).fh_rx_id = cpu_to_be16(_rxid)) + +#define FNIC_STD_SET_R_CTL (_fchdr, _rctl) ((_fchdr).fh_r_ctl = _rctl) +#define FNIC_STD_SET_TYPE (_fchdr, _type) ((_fchdr).fh_type = _type) +#define FNIC_STD_SET_F_CTL (_fchdr, _fctl) \ + put_unaligned_be24(_fctl, &((_fchdr).fh_f_ctl)) + +#define FNIC_STD_SET_NPORT_NAME (_ptr, _wwpn) put_unaligned_be64(_wwpn, _ptr) +#define FNIC_STD_SET_NODE_NAME (_ptr, _wwnn) put_unaligned_be64(_wwnn, _ptr) +#define FNIC_STD_SET_PORT_ID (__req, __portid) \ + memcpy(__req.fr_fid.fp_fid, __portid, 3) +#define FNIC_STD_SET_PORT_NAME (_req, _pName) \ + (put_unaligned_be64(_pName, &_req.fr_wwn)) + +#define FNIC_STD_GET_OX_ID (_fchdr) (be16_to_cpu((_fchdr)->fh_ox_id)) +#define FNIC_STD_GET_RX_ID (_fchdr) (be16_to_cpu((_fchdr)->fh_rx_id)) +#define FNIC_STD_GET_S_ID (_fchdr) ((_fchdr)->fh_s_id) +#define FNIC_STD_GET_D_ID (_fchdr) ((_fchdr)->fh_d_id) +#define FNIC_STD_GET_TYPE (_fchdr) ((_fchdr)->fh_type) +#define FNIC_STD_GET_F_CTL (_fchdr) ((_fchdr)->fh_f_ctl) +#define FNIC_STD_GET_R_CTL (_fchdr) ((_fchdr)->fh_r_ctl) + +#define FNIC_STD_GET_FC_CT_CMD (__fcct_hdr) (be16_to_cpu(__fcct_hdr->ct_cmd)) + +#define FNIC_FCOE_MAX_FRAME_SZ (2048) +#define FNIC_FCOE_MIN_FRAME_SZ (280) +#define FNIC_FC_MAX_PAYLOAD_LEN (2048) +#define FNIC_MIN_DATA_FIELD_SIZE (256) + +#define FNIC_FC_EDTOV_NSEC (0x400) +#define FNIC_NSEC_TO_MSEC (0x1000000) +#define FCP_PRLI_FUNC_TARGET (0x0010) + +#define FNIC_FC_R_CTL_SOLICITED_DATA (0x21) +#define FNIC_FC_F_CTL_LAST_END_SEQ (0x98) +#define FNIC_FC_F_CTL_LAST_END_SEQ_INT (0x99) +#define FNIC_FC_F_CTL_FIRST_LAST_SEQINIT (0x29) +#define FNIC_FC_R_CTL_FC4_SCTL (0x03) +#define FNIC_FC_CS_CTL (0x00) + +#define FNIC_FC_FRAME_UNSOLICITED (_fchdr) \ + (_fchdr->fh_r_ctl == FC_RCTL_ELS_REQ) +#define FNIC_FC_FRAME_SOLICITED_DATA (_fchdr) \ + (_fchdr->fh_r_ctl == FNIC_FC_R_CTL_SOLICITED_DATA) +#define FNIC_FC_FRAME_SOLICITED_CTRL_REPLY (_fchdr) \ + (_fchdr->fh_r_ctl == FC_RCTL_ELS_REP) +#define FNIC_FC_FRAME_FCTL_LAST_END_SEQ (_fchdr) \ + (_fchdr->fh_f_ctl[0] == FNIC_FC_F_CTL_LAST_END_SEQ) +#define FNIC_FC_FRAME_FCTL_LAST_END_SEQ_INT (_fchdr) \ + (_fchdr->fh_f_ctl[0] == FNIC_FC_F_CTL_LAST_END_SEQ_INT) +#define FNIC_FC_FRAME_FCTL_FIRST_LAST_SEQINIT (_fchdr) \ + (_fchdr->fh_f_ctl[0] == FNIC_FC_F_CTL_FIRST_LAST_SEQINIT) +#define FNIC_FC_FRAME_FC4_SCTL (_fchdr) \ + (_fchdr->fh_r_ctl == FNIC_FC_R_CTL_FC4_SCTL) +#define FNIC_FC_FRAME_TYPE_BLS (_fchdr) (_fchdr->fh_type == FC_TYPE_BLS) +#define FNIC_FC_FRAME_TYPE_ELS (_fchdr) (_fchdr->fh_type == FC_TYPE_ELS) +#define FNIC_FC_FRAME_TYPE_FC_GS (_fchdr) (_fchdr->fh_type == FC_TYPE_CT) +#define FNIC_FC_FRAME_CS_CTL (_fchdr) (_fchdr->fh_cs_ctl == FNIC_FC_CS_CTL) + +#define FNIC_FC_C3_RDF (0xfff) +#define FNIC_FC_PLOGI_RSP_RDF (_plogi_rsp) \ + (min(_plogi_rsp->u.csp_plogi.b2b_rdf_size, \ + (_plogi_rsp->spc3[4] & FNIC_FC_C3_RDF))) +#define FNIC_FC_PLOGI_RSP_CONCUR_SEQ (_plogi_rsp) \ + (min((uint16_t) (be16_to_cpu(_plogi_rsp->els.fl_csp.sp_tot_seq)), \ + (uint16_t) (be16_to_cpu(_plogi_rsp->els.fl_cssp[2].cp_con_seq) & 0xff))) + +/* FLOGI/PLOGI struct */ +struct fc_std_flogi { +struct fc_frame_header fchdr; +struct fc_els_flogi els; +} __packed; + +struct fc_std_els_acc_rsp { +struct fc_frame_header fchdr; +struct fc_els_ls_acc acc; +} __packed; + +struct fc_std_els_rjt_rsp { +struct fc_frame_header fchdr; +struct fc_els_ls_rjt rej; +} __packed; + +struct fc_std_els_adisc { +struct fc_frame_header fchdr; +struct fc_els_adisc els; +} __packed; + +struct fc_std_rls_acc { +struct fc_frame_header fchdr; +struct fc_els_rls_resp els; +} __packed; + +struct fc_std_abts_ba_acc { +struct fc_frame_header fchdr; +struct fc_ba_acc acc; +} __packed; + +struct fc_std_abts_ba_rjt { +struct fc_frame_header fchdr; +struct fc_ba_rjt rjt; +} __packed; + +struct fc_std_els_prli { +struct fc_frame_header fchdr; +struct fc_els_prli els_prli; +struct fc_els_spp sp; +} __packed; + +struct fc_std_rpn_id { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +struct fc_ns_rn_id rpn_id; +} __packed; + +struct fc_std_fdmi_rhba { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +struct fc_fdmi_rhba rhba; +} __packed; + +struct fc_std_fdmi_rpa { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +struct fc_fdmi_rpa rpa; +} __packed; + +struct fc_std_rft_id { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +struct fc_ns_rft_id rft_id; +} __packed; + +struct fc_std_rff_id { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +struct fc_ns_rff_id rff_id; +} __packed; + +struct fc_std_gpn_ft { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +struct fc_ns_gid_ft gpn_ft; +} __packed; + +/* Accept CT_IU for GPN_FT */ +struct fc_gpn_ft_rsp_iu { +uint8_t ctrl; +uint8_t fcid[3 ]; +uint32_t rsvd; +__be64 wwpn; +} __packed; + +struct fc_std_rls { +struct fc_frame_header fchdr; +struct fc_els_rls els; +} __packed; + +struct fc_std_scr { +struct fc_frame_header fchdr; +struct fc_els_scr scr; +} __packed; + +struct fc_std_rscn { +struct fc_frame_header fchdr; +struct fc_els_rscn els; +} __packed; + +struct fc_std_logo { +struct fc_frame_header fchdr; +struct fc_els_logo els; +} __packed; + +#define FNIC_ETH_FCOE_HDRS_OFFSET \ + (sizeof(struct ethhdr) + sizeof(struct fcoe_hdr)) + +#endif /* _FDLS_FC_H */
drivers/scsi/fnic/fnic_fdls.h new file +433 -0
433 lines not on this page · raw message
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 3/15 scsi: fnic: Add support for fabric based solicited requests and responses
In reply to Karan Tilak KumarAdd fdls_disc.c to support fabric based solicited requests and responses.
Clean up obsolete code but keep the function template so as to not break compilation.
Remove duplicate definitions from header files. Modify definitions of data members.
Closes:
https://lore.kernel.org/oe-kbuild-all/202406112309.8GiDUvIM-lkp@
intel.com/
Closes:
https://lore.kernel.org/oe-kbuild-all/202406120201.VakI9Dly-lkp@
intel.com/
Closes:
https://lore.kernel.org/oe-kbuild-all/202412080837.2JU0r2Ny-lkp@
intel.com/
---
Changes between v6 and v7:
Fix issue found by kernel test robot.
Changes between v5 and v6:
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Refactor function definitions to top of file. Modify OXID allocation and reclaim design. Allocate OXID from a pool.
Modify frame initialization.
Modify frame send by avoiding memcpy in hot path.
Changes between v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately. Modify fnic_fdls_timer_callback to call flogi.
Changes between v2 and v3:
Fix issue found by kernel test robot. Incorporate review comments from Hannes:
Replace redundant structure definitions with standard definitions.
Replace static OXIDs with pool-based OXIDs for fabric.
Changes between v1 and v2:
Incorporate review comments from Hannes:
Remove double newline.
Fix indentation in fnic_send_frame.
Use the correct kernel-doc format.
Replace htonll() with get_unaligned_be64(). Add fnic_del_fabric_timer_sync as an inline function. Add fnic_del_tport_timer_sync as an inline function. Modify fc_abts_s variable name to fc_fabric_abts_s. Modify fc_fabric_abts_s to be a global frame. Rename pfc_abts to fabric_abts.
Replace definitions with standard definitions from fc_els.h.
Incorporate review comments from John:
Replace kmalloc with kzalloc.
Modify fnic_send_fcoe_frame to not send a return value.
Replace simultaneous use of pointer and structure with just pointer.
Fix issue found by kernel test robot.
--- drivers/scsi/fnic/Makefile | 1 + drivers/scsi/fnic/fdls_disc.c | 2180 +++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 104 +- drivers/scsi/fnic/fnic_fcs.c | 421 ++++--- drivers/scsi/fnic/fnic_fdls.h | 1 - drivers/scsi/fnic/fnic_io.h | 11 - drivers/scsi/fnic/fnic_main.c | 60 +- drivers/scsi/fnic/fnic_scsi.c | 6 +- 8 files changed, 2592 insertions(+), 192 deletions(-) create mode 100644 drivers/scsi/fnic/fdls_disc.c
drivers/scsi/fnic/Makefile +1 -0
@@ -7,6 +7,7 @@ fnic-y := \ fnic_main.o \ fnic_res.o \ fnic_fcs.o \ + fdls_disc.o \ fnic_scsi.o \ fnic_trace.o \ fnic_debugfs.o \
drivers/scsi/fnic/fdls_disc.c new file +2180 -0
2,180 lines not on this page · raw message
drivers/scsi/fnic/fnic.h +102 -2
180 lines not on this page · raw message
drivers/scsi/fnic/fnic_fcs.c +251 -170
504 lines not on this page · raw message
drivers/scsi/fnic/fnic_fdls.h +0 -1
@@ -402,7 +402,6 @@ int fnic_send_fip_frame(struct fnic_iport_s *iport, void *frame, int frame_size);void fnic_fdls_learn_fcoe_macs (struct fnic_iport_s *iport,void *rx_frame,uint8_t *fcid); -void fnic_fdls_add_tport (struct fnic_iport_s *iport,struct fnic_tport_s *tport,unsigned long flags); void fnic_fdls_remove_tport(struct fnic_iport_s *iport,
drivers/scsi/fnic/fnic_io.h +0 -11
@@ -55,15 +55,4 @@ struct fnic_io_req {unsigned int tag; struct scsi_cmnd *sc; /* midlayer's cmd pointer */ }; - -enum fnic_port_speeds { -DCEM_PORTSPEED_NONE =0 , -DCEM_PORTSPEED_1G =1000 , -DCEM_PORTSPEED_10G =10000 , -DCEM_PORTSPEED_20G =20000 , -DCEM_PORTSPEED_25G =25000 , -DCEM_PORTSPEED_40G =40000 , - DCEM_PORTSPEED_4x10G =41000 , -DCEM_PORTSPEED_100G =100000 , -};#endif /* _FNIC_IO_H_ */
drivers/scsi/fnic/fnic_main.c +55 -5
107 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.47.0
Part of the diff is not shown here. View the raw message.
Karan Tilak Kumar
maintainerPATCH v7 4/15 scsi: fnic: Add support for target based solicited requests and responses
In reply to Karan Tilak KumarAdd support for target based solicited requests and responses. Add support for tport definitions and processing. Add support for restarting the IT nexus.
Closes:
https://lore.kernel.org/oe-kbuild-all/202406120146.xchlZbqX-lkp@
intel.com/
Closes:
https://lore.kernel.org/oe-kbuild-all/202412081427.SlsFIJY4-lkp@
intel.com/
---
Changes between v6 and v7:
Fix issue found by kernel test robot.
Changes between v5 and v6:
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Allocate OXID from a pool.
Modify frame initialization.
Modify frame send by avoiding memcpy in hot path.
Changes between v4 and v5:
Incorporate review comments from Martin:
Call fdls_get_tgt_oxid_pool.
Modify attribution appropriately.
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 | 1535 +++++++++++++++++++++++++++++++-- drivers/scsi/fnic/fnic.h | 6 + drivers/scsi/fnic/fnic_fdls.h | 2 +- 3 files changed, 1454 insertions(+), 89 deletions(-)
drivers/scsi/fnic/fdls_disc.c +1447 -88
@@ -32,6 +32,13 @@ static void fdls_process_flogi_rsp(struct fnic_iport_s *iport, void *rx_frame);static void fnic_fdls_start_plogi (struct fnic_iport_s *iport);static void fnic_fdls_start_flogi (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 fdls_init_plogi_frame (uint8_t *frame,struct fnic_iport_s *iport);
@@ -382,6 +389,29 @@ 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_init_plogi_frame (uint8_t *frame,struct fnic_iport_s *iport) {
@@ -454,6 +484,52 @@ static void fdls_init_fabric_abts_frame(uint8_t *frame, .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; } +void +fdls_send_tport_abts (struct fnic_iport_s *iport, +struct fnic_tport_s *tport) +{ +uint8_t *frame; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header *ptport_abts; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_frame_header ); + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send tport ABTS" ); +return ; + } + + ptport_abts = (struct fc_frame_header *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *ptport_abts = (struct fc_frame_header ) { + .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 =cpu_to_be16 (FNIC_UNASSIGNED_RXID ), + .fh_parm_offset =0x00000000 ,/* bit:0 = 0 Abort a exchange */ + }; + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (*ptport_abts, s_id); +FNIC_STD_SET_D_ID (*ptport_abts, d_id); + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_OX_ID (*ptport_abts, tport->active_oxid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send tport abts: tport->state: %d " , + iport->fcid, tport->state); + +fnic_send_fcoe_frame (iport, frame, frame_size); + +/* 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 *frame;
@@ -816,6 +892,196 @@ 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) +{ +uint8_t *frame; +struct fc_std_els_adisc *padisc; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_adisc ); + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send TGT ADISC" ); + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + goto err_out; + } + + padisc = (struct fc_std_els_adisc *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +memcpy (padisc->els.adisc_port_id, s_id,3 ); +FNIC_STD_SET_S_ID (padisc->fchdr, s_id); +FNIC_STD_SET_D_ID (padisc->fchdr, d_id); + +FNIC_STD_SET_F_CTL (padisc->fchdr,FNIC_ELS_REQ_FCTL <<16 ); +FNIC_STD_SET_R_CTL (padisc->fchdr,FC_RCTL_ELS_REQ ); +FNIC_STD_SET_TYPE (padisc->fchdr,FC_TYPE_ELS ); + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_ADISC , &tport->active_oxid); +if (oxid ==FNIC_UNASSIGNED_OXID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate OXID to send TGT ADISC" , + iport->fcid); +mempool_free (frame, fnic->frame_pool); + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + goto err_out; + } +FNIC_STD_SET_OX_ID (padisc->fchdr, oxid); +FNIC_STD_SET_RX_ID (padisc->fchdr,FNIC_UNASSIGNED_RXID ); + + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_NPORT_NAME (&padisc->els.adisc_wwpn, + iport->wwpn); +FNIC_STD_SET_NODE_NAME (&padisc->els.adisc_wwnn, + iport->wwnn); + + padisc->els.adisc_cmd =ELS_ADISC ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send ADISC to tgt fcid: 0x%x" , + iport->fcid, tport->fcid); + +fnic_send_fcoe_frame (iport, frame, frame_size); + +err_out: +/* 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) +{ +uint8_t *frame; +struct fc_std_flogi *pplogi; +struct fnic *fnic = iport->fnic; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_flogi ); +uint8_t d_id[3 ]; +uint32_t timeout; + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send TGT PLOGI" ); + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + goto err_out; + } + + pplogi = (struct fc_std_flogi *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_plogi_frame (frame, iport); + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_PLOGI , &tport->active_oxid); +if (oxid ==FNIC_UNASSIGNED_OXID ) { +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); +mempool_free (frame, fnic->frame_pool); + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + goto err_out; + } +FNIC_STD_SET_OX_ID (pplogi->fchdr, oxid); + + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +hton24 (d_id, tport->fcid); +FNIC_STD_SET_D_ID (pplogi->fchdr, d_id); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send tgt PLOGI to tgt: 0x%x with oxid: 0x%x" , + iport->fcid, tport->fcid, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); + +err_out: + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); +/* 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) {uint8_t *frame;
@@ -940,6 +1206,70 @@ 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) +{ +uint8_t *frame; +struct fc_std_els_prli *pprli; +struct fnic *fnic = iport->fnic; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_prli ); +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint32_t timeout; + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send TGT PRLI" ); + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + goto err_out; + } + + pprli = (struct fc_std_els_prli *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *pprli = (struct fc_std_els_prli ) { + .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 =cpu_to_be16 (FNIC_UNASSIGNED_RXID )}, + .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 )} + }; + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_PRLI , &tport->active_oxid); +if (oxid ==FNIC_UNASSIGNED_OXID ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate OXID to send TGT PRLI to 0x%x" , + iport->fcid, tport->fcid); +mempool_free (frame, fnic->frame_pool); + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + goto err_out; + } + + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_OX_ID (pprli->fchdr, oxid); +FNIC_STD_SET_S_ID (pprli->fchdr, s_id); +FNIC_STD_SET_D_ID (pprli->fchdr, d_id); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send PRLI to tgt: 0x%x with oxid: 0x%x" , + iport->fcid, tport->fcid, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); + +err_out: + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); +/* 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
@@ -995,36 +1325,253 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport)fdls_start_fabric_timer (iport,2 * iport->e_d_tov); } -void fdls_fabric_timer_callback (struct timer_list *t) +/** +* 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 fnic_fdls_fabric_s *fabric =from_timer (fabric, t, retry_timer); -struct fnic_iport_s *iport = - container_of(fabric, struct fnic_iport_s, fabric); +uint8_t *frame; +struct fc_std_logo *plogo;struct fnic *fnic = iport->fnic; -unsigned long flags; +uint8_t d_id[3 ]; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_logo ); + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send fabric LOGO" ); +return ; + } + + plogo = (struct fc_std_logo *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_logo_frame (frame, iport); + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_LOGO , &tport->active_oxid); +if (oxid ==FNIC_UNASSIGNED_OXID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate OXID to send tgt LOGO" , + iport->fcid); +mempool_free (frame, fnic->frame_pool); +return ; + } +FNIC_STD_SET_OX_ID (plogo->fchdr, oxid); + +hton24 (d_id, tport->fcid); +FNIC_STD_SET_D_ID (plogo->fchdr, d_id);FNIC_FCS_DBG (KERN_INFO , fnic->lport->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); +"0x%x: FDLS send tgt LOGO with oxid: 0x%x" , + iport->fcid, oxid); -spin_lock_irqsave (&fnic->fnic_lock, flags); +fnic_send_fcoe_frame (iport, frame, frame_size); +} -if (!iport->fabric.timer_pending) { -spin_unlock_irqrestore (&fnic->fnic_lock, flags); +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 (iport->fabric.del_timer_inprogress) { - iport->fabric.del_timer_inprogress =0 ; -spin_unlock_irqrestore (&fnic->fnic_lock, flags); +if (nexus_restart_count >=FNIC_TPORT_MAX_NEXUS_RESTART ) {FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"fabric_del_timer inprogress(%d). Skip timer cb" , - iport->fabric.del_timer_inprogress); +"Exceeded nexus restart retries tport: 0x%x" , + fcid);return ; } - iport->fabric.timer_pending =0 ; +/* +* 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 =FC_DEF_R_A_TOV ; + tport->e_d_tov =FC_DEF_E_D_TOV ; + tport->fcid = fcid; + tport->wwpn = wwpn; + tport->iport = iport; + +FNIC_FCS_DBG (KERN_DEBUG , 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); +struct fnic_iport_s *iport = + container_of(fabric, struct fnic_iport_s, fabric); +struct fnic *fnic = iport->fnic; +unsigned long flags; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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); + +spin_lock_irqsave (&fnic->fnic_lock, flags); + +if (!iport->fabric.timer_pending) { +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +return ; + } + +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, +"fabric_del_timer inprogress(%d). Skip timer cb" , + iport->fabric.del_timer_inprogress); +return ; + } + + iport->fabric.timer_pending =0 ;/* The fabric state indicates which frames have time out, and we retry */ switch (iport->fabric.state) {
@@ -1100,89 +1647,571 @@ void fdls_fabric_timer_callback(struct timer_list *t)/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req);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_oxid_free (iport, &iport->active_oxid_fabric_req); +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_oxid_free (iport, &iport->active_oxid_fabric_req); +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_oxid_free (iport, &iport->active_oxid_fabric_req); +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 : +fnic_fdls_start_flogi (iport);/* Placeholder call */ +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 = tport->active_oxid; + +/* 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_oxid_free (iport, &tport->active_oxid); +fdls_send_tgt_plogi (iport, tport); + }else { +/* exceeded plogi retry count */ +fdls_schedule_oxid_free (iport, &tport->active_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_oxid_free (iport, &tport->active_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_oxid_free (iport, &tport->active_oxid); +fdls_send_tgt_adisc (iport, tport); + }else { +/* exceeded retry count */ +fdls_schedule_oxid_free (iport, &tport->active_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, +"oxid: 0x%x Unknown tport state: 0x%x" , oxid, 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_rjt_rsp *els_rjt = (struct fc_std_els_rjt_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 (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { +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 =FNIC_STD_GET_OX_ID (fchdr); +fdls_free_oxid (iport, oxid, &tport->active_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->rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->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_rjt_rsp *els_rjt = (struct fc_std_els_rjt_rsp *)fchdr; +uint16_t 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 (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI response from target: 0x%x. Dropping frame" , + tgt_fcid); +return ; + } + + oxid =FNIC_STD_GET_OX_ID (fchdr); +fdls_free_oxid (iport, oxid, &tport->active_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->rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->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: %u 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_rjt_rsp *els_rjt = (struct fc_std_els_rjt_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 (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { +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 =FNIC_STD_GET_OX_ID (fchdr); +fdls_free_oxid (iport, oxid, &tport->active_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_oxid_free (iport, &iport->active_oxid_fabric_req); -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_oxid_free (iport, &iport->active_oxid_fabric_req); +case ELS_LS_RJT : +if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->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_oxid_free (iport, &iport->active_oxid_fabric_req); -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_fdls_start_flogi (iport);/* Placeholder call */ +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); -} +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); + +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 ; -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 ; -} +/* Learn Service Params */ + tport->fcp_csp =be32_to_cpu (prli_rsp->sp.spp_params); + tport->retry_counter =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 ; +if (tport->fcp_csp &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); }
@@ -1460,7 +2489,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 ;
@@ -1473,7 +2503,103 @@ 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 =be64_to_cpu (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 &FC_NS_FID_LAST ) +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 &FC_NS_FID_LAST ) +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,
@@ -1483,6 +2609,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;uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);
@@ -1528,12 +2657,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 :
@@ -1927,6 +3118,142 @@ 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; +int frame_type; + + 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 =FNIC_STD_GET_OX_ID (fchdr); + +/*This abort rsp is for ADISC */ + frame_type =FNIC_FRAME_TYPE (oxid); +switch (frame_type) { +case FNIC_FRAME_TYPE_TGT_ADISC : +if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { +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 ==FC_RCTL_BA_RJT ) { +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 ==FC_RCTL_BA_ACC )) { +fdls_free_oxid (iport, oxid, &tport->active_oxid); +fdls_send_tgt_adisc (iport, tport); +return ; + } +fdls_free_oxid (iport, oxid, &tport->active_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); +/* Restart 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 ); + } +break ; +case FNIC_FRAME_TYPE_TGT_PLOGI : +if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { +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 ==FC_RCTL_BA_RJT ) { +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,FNIC_STD_GET_OX_ID (fchdr)); +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 ==FC_RCTL_BA_ACC )) { +fdls_free_oxid (iport, oxid, &tport->active_oxid); +fdls_send_tgt_plogi (iport, tport); +return ; + } + +fdls_free_oxid (iport, oxid, &tport->active_oxid); +fdls_delete_tport (iport, tport); +/* Restart 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 ); + } +break ; +case FNIC_FRAME_TYPE_TGT_PRLI : +if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { +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 ==FC_RCTL_BA_RJT ) { +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,FNIC_STD_GET_OX_ID (fchdr)); +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 ==FC_RCTL_BA_ACC )) { +fdls_free_oxid (iport, oxid, &tport->active_oxid); +fdls_send_tgt_prli (iport, tport); +return ; + } +fdls_free_oxid (iport, oxid, &tport->active_oxid); +fdls_send_tgt_plogi (iport, tport);/* go back to plogi */ +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); +break ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received ABTS response for unknown frame %p" , iport); +break ; + } + +}/* * Performs a validation for all FCOE frames and return the frame type */
@@ -2109,6 +3436,20 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_LOGO :return FNIC_FABRIC_LOGO_RSP ; +case FNIC_FRAME_TYPE_TGT_PLOGI : +return FNIC_TPORT_PLOGI_RSP ; +case FNIC_FRAME_TYPE_TGT_PRLI : +return FNIC_TPORT_PRLI_RSP ; +case FNIC_FRAME_TYPE_TGT_ADISC : +return FNIC_TPORT_ADISC_RSP ; +case FNIC_FRAME_TYPE_TGT_LOGO : +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in tport solicited exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_LOGO_RSP ;default :/* Drop the Rx frame and log/stats it */ FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
@@ -2164,6 +3505,24 @@ 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_BLS_ABTS_RSP : +fdls_process_tgt_abts_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 ;
drivers/scsi/fnic/fnic.h +6 -0
@@ -84,6 +84,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.
@@ -138,6 +141,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
@@ -336,6 +340,8 @@ struct fnic {struct list_head tx_queue;mempool_t *frame_pool;mempool_t *frame_elem_pool; +struct work_struct tport_work; +struct list_head tport_event_list;/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);
drivers/scsi/fnic/fnic_fdls.h +1 -1
@@ -388,7 +388,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport);int fnic_fdls_validate_and_get_frame_type (struct fnic_iport_s *iport,struct fc_frame_header *fchdr);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);
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 5/15 scsi: fnic: Add support for unsolicited requests and responses
In reply to Karan Tilak KumarAdd support for unsolicited requests and responses. Add support to accept and reject frames.
Closes:
https://lore.kernel.org/oe-kbuild-all/202409291705.MugERX98-lkp@
intel.com/
---
Changes between v5 and v6:
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Allocate OXID from a pool.
Modify frame initialization.
Changes between v4 and v5:
Incorporate review comments from Martin:
Remove unnecessary fdls_get_tgt_oxid_pool call. Modify attribution appropriately.
Changes between v3 and v4:
Fix kernel test robot warnings.
Changes between v2 and v3:
Add fnic_std_ba_acc removed from previous patch. Incorporate review comments from Hannes:
Replace redundant definitions with standard definitions.
Changes between v1 and v2:
Incorporate review comments from Hannes:
Replace fnic_del_tport_timer_sync macro calls with function calls.
Fix indentation.
Replace definitions with standard definitions from fc_els.h.
--- drivers/scsi/fnic/fdls_disc.c | 683 ++++++++++++++++++++++++++++++++++ 1 file changed, 683 insertions(+)
drivers/scsi/fnic/fdls_disc.c +683 -0
@@ -42,6 +42,8 @@ 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 fdls_init_plogi_frame (uint8_t *frame,struct fnic_iport_s *iport); +static void fdls_init_els_acc_frame (uint8_t *frame,struct fnic_iport_s *iport); +static void fdls_init_els_rjt_frame (uint8_t *frame,struct fnic_iport_s *iport);static void fdls_init_logo_frame (uint8_t *frame,struct fnic_iport_s *iport);static void fdls_init_fabric_abts_frame (uint8_t *frame,struct fnic_iport_s *iport);
@@ -447,6 +449,39 @@ void fdls_init_plogi_frame(uint8_t *frame,FNIC_STD_SET_S_ID (pplogi->fchdr, s_id); } +static void fdls_init_els_acc_frame (uint8_t *frame, +struct fnic_iport_s *iport) +{ +struct fc_std_els_acc_rsp *pels_acc; +uint8_t s_id[3 ]; + + pels_acc = (struct fc_std_els_acc_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *pels_acc = (struct fc_std_els_acc_rsp ) { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .acc.la_cmd =ELS_LS_ACC , + }; + +hton24 (s_id, iport->fcid); +FNIC_STD_SET_S_ID (pels_acc->fchdr, s_id); +FNIC_STD_SET_RX_ID (pels_acc->fchdr,FNIC_UNASSIGNED_RXID ); +} + +static void fdls_init_els_rjt_frame (uint8_t *frame, +struct fnic_iport_s *iport) +{ +struct fc_std_els_rjt_rsp *pels_rjt; + + pels_rjt = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *pels_rjt = (struct fc_std_els_rjt_rsp ) { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .rej.er_cmd =ELS_LS_RJT , + }; + +FNIC_STD_SET_RX_ID (pels_rjt->fchdr,FNIC_UNASSIGNED_RXID ); +} +static void fdls_init_logo_frame (uint8_t *frame,struct fnic_iport_s *iport) {
@@ -484,6 +519,73 @@ static void fdls_init_fabric_abts_frame(uint8_t *frame, .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; } + +static void +fdls_send_rscn_resp (struct fnic_iport_s *iport, +struct fc_frame_header *rscn_fchdr) +{ +uint8_t *frame; +struct fc_std_els_acc_rsp *pels_acc; +struct fnic *fnic = iport->fnic; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_acc_rsp ); + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send RSCN response" ); +return ; + } + + pels_acc = (struct fc_std_els_acc_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_els_acc_frame (frame, iport); + +FNIC_STD_SET_D_ID (pels_acc->fchdr, rscn_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (rscn_fchdr); +FNIC_STD_SET_OX_ID (pels_acc->fchdr, oxid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send RSCN response with oxid: 0x%x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} + +static void +fdls_send_logo_resp (struct fnic_iport_s *iport, +struct fc_frame_header *req_fchdr) +{ +uint8_t *frame; +struct fc_std_els_acc_rsp *plogo_resp; +struct fnic *fnic = iport->fnic; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_acc_rsp ); + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send LOGO response" ); +return ; + } + + plogo_resp = (struct fc_std_els_acc_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_els_acc_frame (frame, iport); + +FNIC_STD_SET_D_ID (plogo_resp->fchdr, req_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (req_fchdr); +FNIC_STD_SET_OX_ID (plogo_resp->fchdr, oxid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send LOGO response with oxid: 0x%x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} +void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport)
@@ -3118,6 +3220,232 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_abts_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +uint8_t *frame; +struct fc_std_abts_ba_acc *pba_acc; +uint32_t nport_id; +uint16_t oxid; +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_abts_ba_acc ); + + nport_id =ntoh24 (fchdr->fh_s_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abort from SID 0x%8x" , nport_id); + + tport =fnic_find_tport_by_fcid (iport, nport_id); +if (tport) { + oxid =FNIC_STD_GET_OX_ID (fchdr); +if (tport->active_oxid == oxid) { + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; +fdls_free_oxid (iport, oxid, &tport->active_oxid); + } + } + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate frame to send response for ABTS req" , + iport->fcid); +return ; + } + + pba_acc = (struct fc_std_abts_ba_acc *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *pba_acc = (struct fc_std_abts_ba_acc ) { + .fchdr = {.fh_r_ctl =FC_RCTL_BA_ACC , + .fh_f_ctl = {FNIC_FCP_RSP_FCTL ,0 ,0 }}, + .acc = {.ba_low_seq_cnt =0 , .ba_high_seq_cnt =cpu_to_be16 (0xFFFF )} + }; + +FNIC_STD_SET_S_ID (pba_acc->fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (pba_acc->fchdr, fchdr->fh_s_id); +FNIC_STD_SET_OX_ID (pba_acc->fchdr,FNIC_STD_GET_OX_ID (fchdr)); +FNIC_STD_SET_RX_ID (pba_acc->fchdr,FNIC_STD_GET_RX_ID (fchdr)); + + pba_acc->acc.ba_rx_id =cpu_to_be16 (FNIC_STD_GET_RX_ID (fchdr)); + pba_acc->acc.ba_ox_id =cpu_to_be16 (FNIC_STD_GET_OX_ID (fchdr)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send BA ACC with oxid: 0x%x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} + +static void +fdls_process_unsupported_els_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint8_t *frame; +struct fc_std_els_rjt_rsp *pls_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_rjt_rsp ); + +if (iport->fcid != d_id) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping unsupported ELS with illegal frame bits 0x%x\n" , + d_id); +return ; + } + +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, +"Dropping unsupported ELS request in iport state: %d" , + iport->state); +return ; + } + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send response to unsupported ELS request" ); +return ; + } + + pls_rsp = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_els_rjt_frame (frame, iport); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Process unsupported ELS request from SID: 0x%x" , + iport->fcid,ntoh24 (fchdr->fh_s_id)); + +/* We don't support this ELS request, send a reject */ + pls_rsp->rej.er_reason =0x0B ; + pls_rsp->rej.er_explan =0x0 ; + pls_rsp->rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID (pls_rsp->fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (pls_rsp->fchdr, fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (pls_rsp->fchdr, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} + +static void +fdls_process_rls_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +uint8_t *frame; +struct fc_std_rls_acc *prls_acc_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_rls_acc ); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"Received RLS req in iport state: %d. Dropping the frame." , + iport->state); +return ; + } + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send RLS accept" ); +return ; + } + prls_acc_rsp = (struct fc_std_rls_acc *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + +FNIC_STD_SET_S_ID (prls_acc_rsp->fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (prls_acc_rsp->fchdr, fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (prls_acc_rsp->fchdr, oxid); +FNIC_STD_SET_RX_ID (prls_acc_rsp->fchdr,FNIC_UNASSIGNED_RXID ); + +FNIC_STD_SET_F_CTL (prls_acc_rsp->fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (prls_acc_rsp->fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (prls_acc_rsp->fchdr,FC_TYPE_ELS ); + + prls_acc_rsp->els.rls_cmd =ELS_LS_ACC ; + prls_acc_rsp->els.rls_lesb.lesb_link_fail = +cpu_to_be32 (iport->fnic->link_down_cnt); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} + +static void +fdls_process_els_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr, +uint32_t len) +{ +uint8_t *frame; +struct fc_std_els_acc_rsp *pels_acc; +uint16_t oxid; +uint8_t *fc_payload; +uint8_t type; +struct fnic *fnic = iport->fnic; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET ; + + fc_payload = (uint8_t *) fchdr +sizeof (struct fc_frame_header ); + type = *fc_payload; + +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, +"Dropping ELS frame type: 0x%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, +"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, +"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, +"sending LS_ACC for 0x%x ELS frame\n" , type); +break ; + } + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send ELS response for 0x%x" , + type); +return ; + } + +if (type ==ELS_ECHO ) { +/* Brocade sends a longer payload, copy all frame back */ +memcpy (frame, fchdr, len); + } + + pels_acc = (struct fc_std_els_acc_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_els_acc_frame (frame, iport); + +FNIC_STD_SET_D_ID (pels_acc->fchdr, fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (pels_acc->fchdr, oxid); + +if (type ==ELS_ECHO ) + frame_size += len; +else + frame_size +=sizeof (struct fc_std_els_acc_rsp ); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} +static void fdls_process_tgt_abts_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)
@@ -3254,6 +3582,336 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, } } + +static void +fdls_process_plogi_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint8_t *frame; +struct fc_std_els_rjt_rsp *pplogi_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_rjt_rsp ); + +if (iport->fcid != d_id) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI with illegal frame bits. Dropping frame from 0x%x" , + d_id); +return ; + } + +if (iport->state !=FNIC_IPORT_STATE_READY ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI request in iport state: %d Dropping frame" , + iport->state); +return ; + } + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send response to PLOGI request" ); +return ; + } + + pplogi_rsp = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_els_rjt_frame (frame, iport); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Process PLOGI request from SID: 0x%x" , + iport->fcid,ntoh24 (fchdr->fh_s_id)); + +/* We don't support PLOGI request, send a reject */ + pplogi_rsp->rej.er_reason =0x0B ; + pplogi_rsp->rej.er_explan =0x0 ; + pplogi_rsp->rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID (pplogi_rsp->fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (pplogi_rsp->fchdr, fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (pplogi_rsp->fchdr, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); +} + +static void +fdls_process_logo_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +struct fc_std_logo *logo = (struct fc_std_logo *)fchdr; +uint32_t nport_id; +uint64_t nport_name; +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + + nport_id =ntoh24 (logo->els.fl_n_port_id); + nport_name =be64_to_cpu (logo->els.fl_n_port_wwn); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"Dropping LOGO req from 0x%x in iport state: %d" , + nport_id, iport->state); +return ; + } + + tport =fnic_find_tport_by_fcid (iport, nport_id); + +if (!tport) { +/* We are not logged in with the nport, log and drop... */ +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received LOGO from an nport not logged in: 0x%x(0x%llx)" , + nport_id, nport_name); +return ; + } +if (tport->fcid != nport_id) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received LOGO with invalid target port fcid: 0x%x(0x%llx)" , + nport_id, nport_name); +return ; + } +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_ERR , 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 ; + } + +/* got a logo in response to adisc to a target which has logged out */ +if (tport->state ==FDLS_TGT_STATE_ADISC ) { + tport->retry_counter =0 ; + oxid = tport->active_oxid; +fdls_free_oxid (iport, oxid, &tport->active_oxid); +fdls_delete_tport (iport, tport); +fdls_send_logo_resp (iport, &logo->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, +"Sending GPNFT in response to LOGO from Target:0x%x" , + nport_id); +fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT ); +return ; + } + }else { +fdls_delete_tport (iport, tport); + } +if (iport->state ==FNIC_IPORT_STATE_READY ) { +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, +"Sending GPNFT in response to LOGO from Target:0x%x" , + nport_id); +fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT ); + } + } +} + +static void +fdls_process_rscn (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +struct fc_std_rscn *rscn; +struct fc_els_rscn_page *rscn_port =NULL ; +int num_ports; +struct fnic_tport_s *tport, *next; +uint32_t nport_id; +uint8_t fcid[3 ]; +int newports =0 ; +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fnic *fnic = iport->fnic; +uint16_t rscn_payload_len; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"FDLS RSCN received in state(%d). Dropping" , +fdls_get_state (fdls)); +return ; + } + + rscn = (struct fc_std_rscn *)fchdr; + rscn_payload_len =be16_to_cpu (rscn->els.rscn_plen); + +/* frame validation */ +if ((rscn_payload_len %4 !=0 ) || (rscn_payload_len <8 ) + || (rscn_payload_len >1024 ) + || (rscn->els.rscn_page_len !=4 )) { + num_ports =0 ; +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"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, +"RSCN received for num_ports: %d payload_len: %d page_len: %d " , + num_ports, rscn_payload_len, rscn->els.rscn_page_len); + +/* +* RSCN have at least one Port_ID page , but may not have any port_id +* in it. If no port_id is specified in the Port_ID page , we send +* ADISC to all the tports +*/ + +while (num_ports) { + +memcpy (fcid, rscn_port->rscn_fid,3 ); + + nport_id =ntoh24 (fcid); + rscn_port++; + num_ports--; +/* if this happens then we need to send ADISC to all the tports. */ +if (nport_id ==0 ) { +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, +"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, +"RSCN port id list: 0x%x" , nport_id); + +if (!tport) { + newports++; +continue ; + } +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, +"FDLS process RSCN sending GPN_FT: newports: %d" , newports); +fdls_send_gpn_ft (iport,FDLS_STATE_RSCN_GPN_FT ); +fdls_send_rscn_resp (iport, fchdr); +} +static void +fdls_process_adisc_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_els_adisc *padisc_acc; +struct fc_std_els_adisc *adisc_req = (struct fc_std_els_adisc *)fchdr; +uint64_t frame_wwnn; +uint64_t frame_wwpn; +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint8_t *rjt_frame; +uint8_t *acc_frame; +struct fc_std_els_rjt_rsp *prjts_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint16_t rjt_frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_rjt_rsp ); +uint16_t acc_frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_els_adisc ); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"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, +"Dropping ADISC req from fcid: 0x%x in iport state: %d" , + tgt_fcid, iport->state); +return ; + } + + frame_wwnn =be64_to_cpu (adisc_req->els.adisc_wwnn); + frame_wwpn =be64_to_cpu (adisc_req->els.adisc_wwpn); + +if ((frame_wwnn != tport->wwnn) || (frame_wwpn != tport->wwpn)) { +/* send reject */ +FNIC_FCS_DBG (KERN_ERR , fnic->lport->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, +"local tport wwpn: 0x%llx wwnn: 0x%llx. Sending RJT" , + tport->wwpn, tport->wwnn); + + rjt_frame =fdls_alloc_frame (iport); +if (rjt_frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate rjt_frame to send response to ADISC request" ); +return ; + } + + prjts_rsp = (struct fc_std_els_rjt_rsp *) (rjt_frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_els_rjt_frame (rjt_frame, iport); + + prjts_rsp->rej.er_reason =0x03 ;/* logical error */ + prjts_rsp->rej.er_explan =0x1E ;/* N_port login required */ + prjts_rsp->rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID (prjts_rsp->fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (prjts_rsp->fchdr, fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (prjts_rsp->fchdr, oxid); + +fnic_send_fcoe_frame (iport, rjt_frame, rjt_frame_size); +return ; + } + + acc_frame =fdls_alloc_frame (iport); +if (acc_frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send ADISC accept" ); +return ; + } + + padisc_acc = (struct fc_std_els_adisc *) (acc_frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + +FNIC_STD_SET_S_ID (padisc_acc->fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (padisc_acc->fchdr, fchdr->fh_s_id); + +FNIC_STD_SET_F_CTL (padisc_acc->fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (padisc_acc->fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (padisc_acc->fchdr,FC_TYPE_ELS ); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (padisc_acc->fchdr, oxid); +FNIC_STD_SET_RX_ID (padisc_acc->fchdr,FNIC_UNASSIGNED_RXID ); + + padisc_acc->els.adisc_cmd =ELS_LS_ACC ; + +FNIC_STD_SET_NPORT_NAME (&padisc_acc->els.adisc_wwpn, + iport->wwpn); +FNIC_STD_SET_NODE_NAME (&padisc_acc->els.adisc_wwnn, + iport->wwnn); +memcpy (padisc_acc->els.adisc_port_id, fchdr->fh_d_id,3 ); + +fnic_send_fcoe_frame (iport, acc_frame, acc_frame_size); +} +/* * Performs a validation for all FCOE frames and return the frame type */
@@ -3529,6 +4187,31 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,case FNIC_FABRIC_BLS_ABTS_RSP :fdls_process_fabric_abts_rsp (iport, fchdr);break ; +case FNIC_BLS_ABTS_REQ : +fdls_process_abts_req (iport, fchdr); +break ; +case FNIC_ELS_UNSUPPORTED_REQ : +fdls_process_unsupported_els_req (iport, fchdr); +break ; +case FNIC_ELS_PLOGI_REQ : +fdls_process_plogi_req (iport, fchdr); +break ; +case FNIC_ELS_RSCN_REQ : +fdls_process_rscn (iport, fchdr); +break ; +case FNIC_ELS_LOGO_REQ : +fdls_process_logo_req (iport, fchdr); +break ; +case FNIC_ELS_RRQ : +case FNIC_ELS_ECHO_REQ : +fdls_process_els_req (iport, fchdr, len); +break ; +case FNIC_ELS_ADISC : +fdls_process_adisc_req (iport, fchdr); +break ; +case FNIC_ELS_RLS : +fdls_process_rls_req (iport, fchdr); +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);
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 6/15 scsi: fnic: Add Cisco hardware model names
In reply to Karan Tilak KumarAdd model IDs for Cisco VIC.
---
Changes between v5 and v6:
Incorporate review comments from Hannes:
Split patch into PCI changes and FDMI changes.
--- drivers/scsi/fnic/Makefile | 3 +- drivers/scsi/fnic/fnic.h | 71 ++++++++++++ drivers/scsi/fnic/fnic_main.c | 10 ++ drivers/scsi/fnic/fnic_pci_subsys_devid.c | 131 ++++++++++++++++++++++ 4 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 drivers/scsi/fnic/fnic_pci_subsys_devid.c
drivers/scsi/fnic/Makefile +2 -1
@@ -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
drivers/scsi/fnic/fnic.h +71 -0
89 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +10 -0
@@ -611,6 +611,7 @@ 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;/* * Allocate SCSI Host and set up association between host,
@@ -644,6 +645,15 @@ 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); +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" );
drivers/scsi/fnic/fnic_pci_subsys_devid.c new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 7/15 scsi: fnic: Add and integrate support for FDMI
In reply to Karan Tilak KumarAdd 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.
Closes:
https://lore.kernel.org/oe-kbuild-all/202406110734.p2v8dq9v-lkp
@intel.com/
---
Changes between v5 and v6:
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Split patch into PCI changes and FDMI changes. Allocate OXID from a pool.
Modify frame initialization.
Changes between v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately.
Remove spurious newline at the end of fdls_disc.c. Remove spurious newline at the end of fnic_main.c.
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/fdls_disc.c | 658 ++++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 1 + drivers/scsi/fnic/fnic_main.c | 19 +- 3 files changed, 676 insertions(+), 2 deletions(-)
drivers/scsi/fnic/fdls_disc.c +658 -0
@@ -18,6 +18,52 @@#define PORT_SPEED_BIT_14 14#define PORT_SPEED_BIT_15 15 +/* FNIC FDMI Register HBA Macros */ +#define FNIC_FDMI_NUM_PORTS 1 +#define FNIC_FDMI_NUM_HBA_ATTRS 9 +#define FNIC_FDMI_TYPE_NODE_NAME 0X1 +#define FNIC_FDMI_TYPE_MANUFACTURER 0X2 +#define FNIC_FDMI_MANUFACTURER "Cisco Systems" +#define FNIC_FDMI_TYPE_SERIAL_NUMBER 0X3 +#define FNIC_FDMI_TYPE_MODEL 0X4 +#define FNIC_FDMI_TYPE_MODEL_DES 0X5 +#define FNIC_FDMI_MODEL_DESCRIPTION "Cisco Virtual Interface Card" +#define FNIC_FDMI_TYPE_HARDWARE_VERSION 0X6 +#define FNIC_FDMI_TYPE_DRIVER_VERSION 0X7 +#define FNIC_FDMI_TYPE_ROM_VERSION 0X8 +#define FNIC_FDMI_TYPE_FIRMWARE_VERSION 0X9 +#define FNIC_FDMI_NN_LEN 8 +#define FNIC_FDMI_MANU_LEN 20 +#define FNIC_FDMI_SERIAL_LEN 16 +#define FNIC_FDMI_MODEL_LEN 12 +#define FNIC_FDMI_MODEL_DES_LEN 56 +#define FNIC_FDMI_HW_VER_LEN 16 +#define FNIC_FDMI_DR_VER_LEN 28 +#define FNIC_FDMI_ROM_VER_LEN 8 +#define FNIC_FDMI_FW_VER_LEN 16 + +/* FNIC FDMI Register PA Macros */ +#define FNIC_FDMI_TYPE_FC4_TYPES 0X1 +#define FNIC_FDMI_TYPE_SUPPORTED_SPEEDS 0X2 +#define FNIC_FDMI_TYPE_CURRENT_SPEED 0X3 +#define FNIC_FDMI_TYPE_MAX_FRAME_SIZE 0X4 +#define FNIC_FDMI_TYPE_OS_NAME 0X5 +#define FNIC_FDMI_TYPE_HOST_NAME 0X6 +#define FNIC_FDMI_NUM_PORT_ATTRS 6 +#define FNIC_FDMI_FC4_LEN 32 +#define FNIC_FDMI_SUPP_SPEED_LEN 4 +#define FNIC_FDMI_CUR_SPEED_LEN 4 +#define FNIC_FDMI_MFS_LEN 4 +#define FNIC_FDMI_MFS 0x800 +#define FNIC_FDMI_OS_NAME_LEN 16 +#define FNIC_FDMI_HN_LEN 24 + +#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 +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY)
@@ -26,6 +72,8 @@#define SCHEDULE_OXID_FREE_RETRY_TIME (300)/* Private Functions */ +static void fdls_fdmi_register_hba (struct fnic_iport_s *iport); +static void fdls_fdmi_register_pa (struct fnic_iport_s *iport);static void fdls_send_rpn_id (struct fnic_iport_s *iport); static void fdls_process_flogi_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr,
@@ -39,6 +87,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 fdls_init_plogi_frame (uint8_t *frame,struct fnic_iport_s *iport);
@@ -721,6 +770,52 @@ 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 *frame; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header *pfabric_abts; +unsigned long fdmi_tov; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_frame_header ); + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send FDMI ABTS" ); +return ; + } + + pfabric_abts = (struct fc_frame_header *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_fabric_abts_frame (frame, iport); + +hton24 (d_id,FC_FID_MGMT_SERV ); +FNIC_STD_SET_D_ID (*pfabric_abts, d_id); + +if (iport->fabric.fdmi_pending &FDLS_FDMI_PLOGI_PENDING ) { + oxid = iport->active_oxid_fdmi_plogi; +FNIC_STD_SET_OX_ID (*pfabric_abts, oxid); +fnic_send_fcoe_frame (iport, frame, frame_size); + }else { +if (iport->fabric.fdmi_pending &FDLS_FDMI_REG_HBA_PENDING ) { + oxid = iport->active_oxid_fdmi_rhba; +FNIC_STD_SET_OX_ID (*pfabric_abts, oxid); +fnic_send_fcoe_frame (iport, frame, frame_size); + } +if (iport->fabric.fdmi_pending &FDLS_FDMI_RPA_PENDING ) { + oxid = iport->active_oxid_fdmi_rpa; +FNIC_STD_SET_OX_ID (*pfabric_abts, oxid); +fnic_send_fcoe_frame (iport, frame, frame_size); + } + } + + 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) {uint8_t *frame;
@@ -823,6 +918,54 @@ 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) +{ +uint8_t *frame; +struct fc_std_flogi *pplogi; +struct fnic *fnic = iport->fnic; +uint16_t oxid; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET + +sizeof (struct fc_std_flogi ); +uint8_t d_id[3 ]; +u64 fdmi_tov; + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send FDMI PLOGI" ); + goto err_out; + } + + pplogi = (struct fc_std_flogi *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); +fdls_init_plogi_frame (frame, iport); + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FDMI_PLOGI , + &iport->active_oxid_fdmi_plogi); + +if (oxid ==FNIC_UNASSIGNED_OXID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate OXID to send FDMI PLOGI" , + iport->fcid); +mempool_free (frame, fnic->frame_pool); + goto err_out; + } +FNIC_STD_SET_OX_ID (pplogi->fchdr, oxid); + +hton24 (d_id,FC_FID_MGMT_SERV ); +FNIC_STD_SET_D_ID (pplogi->fchdr, d_id); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send FDMI PLOGI with oxid: 0x%x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, frame, frame_size); + +err_out: + 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) {uint8_t *frame;
@@ -1644,6 +1787,300 @@ struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport,return NULL ; } +static void +fnic_fdmi_attr_set (void *attr_start,u16 type,u16 len, +void *data,u32 *off) +{ +u16 size = len +FC_FDMI_ATTR_ENTRY_HEADER_LEN ; +struct fc_fdmi_attr_entry *fdmi_attr = (struct fc_fdmi_attr_entry *) + ((u8 *)attr_start + *off); + +put_unaligned_be16 (type, &fdmi_attr->type); +put_unaligned_be16 (size, &fdmi_attr->len); +memcpy (fdmi_attr->value, data, len); + *off += size; +} + +static void fdls_fdmi_register_hba (struct fnic_iport_s *iport) +{ +uint8_t *frame; +struct fc_std_fdmi_rhba *prhba; +struct fc_fdmi_attr_entry *fdmi_attr; +uint8_t fcid[3 ]; +int err; +struct fnic *fnic = iport->fnic; +struct vnic_devcmd_fw_info *fw_info =NULL ; +uint16_t oxid; +u32 attr_off_bytes, len; +u8 data[64 ]; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET ; + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send FDMI RHBA" ); +return ; + } + + prhba = (struct fc_std_fdmi_rhba *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *prhba = (struct fc_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 =cpu_to_be16 (FNIC_UNASSIGNED_RXID ) + }, + .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 ) + }, + }; + +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (prhba->fchdr, fcid); + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FDMI_RHBA , + &iport->active_oxid_fdmi_rhba); + +if (oxid ==FNIC_UNASSIGNED_OXID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate OXID to send FDMI RHBA" , + iport->fcid); +mempool_free (frame, fnic->frame_pool); +return ; + } +FNIC_STD_SET_OX_ID (prhba->fchdr, oxid); + +put_unaligned_be64 (iport->wwpn, &prhba->rhba.hbaid.id); +put_unaligned_be32 (FNIC_FDMI_NUM_PORTS , &prhba->rhba.port.numport); +put_unaligned_be64 (iport->wwpn, &prhba->rhba.port.port[0 ].portname); +put_unaligned_be32 (FNIC_FDMI_NUM_HBA_ATTRS , + &prhba->rhba.hba_attrs.numattrs); + + fdmi_attr = prhba->rhba.hba_attrs.attr; + attr_off_bytes =0 ; + +put_unaligned_be64 (iport->wwnn, data); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_NODE_NAME , +FNIC_FDMI_NN_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"NN set, off=%d" , attr_off_bytes); + +strscpy_pad (data,FNIC_FDMI_MANUFACTURER ,FNIC_FDMI_MANU_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MANUFACTURER , +FNIC_FDMI_MANU_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MFG set <%s>, off=%d" , data, attr_off_bytes); + + err =vnic_dev_fw_info (fnic->vdev, &fw_info); +if (!err) { +strscpy_pad (data, fw_info->hw_serial_number, +FNIC_FDMI_SERIAL_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_SERIAL_NUMBER , +FNIC_FDMI_SERIAL_LEN , data, &attr_off_bytes); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"SERIAL set <%s>, off=%d" , data, attr_off_bytes); + + } + +if (fnic->subsys_desc_len >=FNIC_FDMI_MODEL_LEN ) + fnic->subsys_desc_len =FNIC_FDMI_MODEL_LEN -1 ; +strscpy_pad (data, fnic->subsys_desc,FNIC_FDMI_MODEL_LEN ); + data[FNIC_FDMI_MODEL_LEN -1 ] =0 ; +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MODEL ,FNIC_FDMI_MODEL_LEN , + data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MODEL set <%s>, off=%d" , data, attr_off_bytes); + +strscpy_pad (data,FNIC_FDMI_MODEL_DESCRIPTION ,FNIC_FDMI_MODEL_DES_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MODEL_DES , +FNIC_FDMI_MODEL_DES_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MODEL_DESC set <%s>, off=%d" , data, attr_off_bytes); + +if (!err) { +strscpy_pad (data, fw_info->hw_version,FNIC_FDMI_HW_VER_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_HARDWARE_VERSION , +FNIC_FDMI_HW_VER_LEN , data, &attr_off_bytes); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"HW_VER set <%s>, off=%d" , data, attr_off_bytes); + + } + +strscpy_pad (data,DRV_VERSION ,FNIC_FDMI_DR_VER_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_DRIVER_VERSION , +FNIC_FDMI_DR_VER_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"DRV_VER set <%s>, off=%d" , data, attr_off_bytes); + +strscpy_pad (data,"N/A" ,FNIC_FDMI_ROM_VER_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_ROM_VERSION , +FNIC_FDMI_ROM_VER_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ROM_VER set <%s>, off=%d" , data, attr_off_bytes); + +if (!err) { +strscpy_pad (data, fw_info->fw_version,FNIC_FDMI_FW_VER_LEN ); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_FIRMWARE_VERSION , +FNIC_FDMI_FW_VER_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FW_VER set <%s>, off=%d" , data, attr_off_bytes); + } + + len =sizeof (struct fc_std_fdmi_rhba ) + attr_off_bytes; + frame_size += len; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send FDMI RHBA with oxid: 0x%x fs: %d" , iport->fcid, + oxid, frame_size); + +fnic_send_fcoe_frame (iport, frame, frame_size); + iport->fabric.fdmi_pending |=FDLS_FDMI_REG_HBA_PENDING ; +} + +static void fdls_fdmi_register_pa (struct fnic_iport_s *iport) +{ +uint8_t *frame; +struct fc_std_fdmi_rpa *prpa; +struct fc_fdmi_attr_entry *fdmi_attr; +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; +u32 attr_off_bytes, len; +u8 tmp_data[16 ], data[64 ]; +uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET ; + + frame =fdls_alloc_frame (iport); +if (frame ==NULL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame to send FDMI RPA" ); +return ; + } + + prpa = (struct fc_std_fdmi_rpa *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET ); + *prpa = (struct fc_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 =cpu_to_be16 (FNIC_UNASSIGNED_RXID ) + }, + .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 ) + }, + }; + +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (prpa->fchdr, fcid); + + oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FDMI_RPA , + &iport->active_oxid_fdmi_rpa); + +if (oxid ==FNIC_UNASSIGNED_OXID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate OXID to send FDMI RPA" , + iport->fcid); +mempool_free (frame, fnic->frame_pool); +return ; + } +FNIC_STD_SET_OX_ID (prpa->fchdr, oxid); + +put_unaligned_be64 (iport->wwpn, &prpa->rpa.port.portname); +put_unaligned_be32 (FNIC_FDMI_NUM_PORT_ATTRS , + &prpa->rpa.hba_attrs.numattrs); + +/* 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 ; + } + attr_off_bytes =0 ; + + fdmi_attr = prpa->rpa.hba_attrs.attr; + +put_unaligned_be64 (iport->wwnn, data); + +memset (data,0 ,FNIC_FDMI_FC4_LEN ); + data[2 ] =1 ; +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_FC4_TYPES , +FNIC_FDMI_FC4_LEN , data, &attr_off_bytes); + +put_unaligned_be32 (port_speed_bm, data); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_SUPPORTED_SPEEDS , +FNIC_FDMI_SUPP_SPEED_LEN , data, &attr_off_bytes); + +put_unaligned_be32 (port_speed_bm, data); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_CURRENT_SPEED , +FNIC_FDMI_CUR_SPEED_LEN , data, &attr_off_bytes); + +put_unaligned_be32 (FNIC_FDMI_MFS , data); +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MAX_FRAME_SIZE , +FNIC_FDMI_MFS_LEN , data, &attr_off_bytes); + +snprintf (tmp_data,FNIC_FDMI_OS_NAME_LEN -1 ,"host%d" , + fnic->lport->host->host_no); +strscpy_pad (data, tmp_data,FNIC_FDMI_OS_NAME_LEN ); + data[FNIC_FDMI_OS_NAME_LEN -1 ] =0 ; +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_OS_NAME , +FNIC_FDMI_OS_NAME_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"OS name set <%s>, off=%d" , data, attr_off_bytes); + +sprintf (fc_host_system_hostname (fnic->lport->host),"%s" ,utsname ()->nodename); +strscpy_pad (data,fc_host_system_hostname (fnic->lport->host), +FNIC_FDMI_HN_LEN ); + data[FNIC_FDMI_HN_LEN -1 ] =0 ; +fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_HOST_NAME , +FNIC_FDMI_HN_LEN , data, &attr_off_bytes); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Host name set <%s>, off=%d" , data, attr_off_bytes); + + len =sizeof (struct fc_std_fdmi_rpa ) + attr_off_bytes; + frame_size += len; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send FDMI RPA with oxid: 0x%x fs: %d" , iport->fcid, + oxid, frame_size); + +fnic_send_fcoe_frame (iport, frame, frame_size); + 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);
@@ -1817,6 +2254,64 @@ 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); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending); + +if (!iport->fabric.fdmi_pending) { +/* timer expired after fdmi responses received. */ +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending); + +/* 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 ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending); + +/* ABTS pending for an active fdmi request that is pending. +* That means FDMI ABTS timed out +* Schedule to free the OXID after 2*r_a_tov and proceed +*/ +if (iport->fabric.fdmi_pending &FDLS_FDMI_PLOGI_PENDING ) { +fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_plogi); + }else { +if (iport->fabric.fdmi_pending &FDLS_FDMI_REG_HBA_PENDING ) +fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_rhba); +if (iport->fabric.fdmi_pending &FDLS_FDMI_RPA_PENDING ) +fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_rpa); + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending); + + 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); + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending); +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;
@@ -1956,6 +2451,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 fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,
@@ -3090,6 +3594,144 @@ 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_rjt_rsp *els_rjt = (struct fc_std_els_rjt_rsp *)fchdr; +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fnic *fnic = iport->fnic; +u64 fdmi_tov; +uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr); + +if (iport->active_oxid_fdmi_plogi != oxid) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" , +fdls_get_state (fdls), oxid, iport->active_oxid_fdmi_plogi); +return ; + } + + iport->fabric.fdmi_pending &= ~FDLS_FDMI_PLOGI_PENDING ; +fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_plogi); + +if (ntoh24 (fchdr->fh_s_id) ==FC_FID_MGMT_SERV ) { +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->rej.er_reason); + +if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->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; +uint16_t oxid; + +if (!iport->fabric.fdmi_pending) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received FDMI ack while not waiting: 0x%x\n" , +FNIC_STD_GET_OX_ID (fchdr)); +return ; + } + + oxid =FNIC_STD_GET_OX_ID (fchdr); + +if ((iport->active_oxid_fdmi_rhba != oxid) && + (iport->active_oxid_fdmi_rpa != oxid)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Incorrect OXID in response. oxid recvd: 0x%x, active oxids(rhba,rpa): 0x%x, 0x%x\n" , + oxid, iport->active_oxid_fdmi_rhba, iport->active_oxid_fdmi_rpa); +return ; + } +if (FNIC_FRAME_TYPE (oxid) ==FNIC_FRAME_TYPE_FDMI_RHBA ) { + iport->fabric.fdmi_pending &= ~FDLS_FDMI_REG_HBA_PENDING ; +fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rhba); + }else { + iport->fabric.fdmi_pending &= ~FDLS_FDMI_RPA_PENDING ; +fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa); + } + +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; +uint16_t oxid; + + s_id =ntoh24 (FNIC_STD_GET_S_ID (fchdr)); + +if (!(s_id !=FC_FID_MGMT_SERV )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp with invalid SID: 0x%x. Dropping frame" , + s_id); +return ; + } + + oxid =FNIC_STD_GET_OX_ID (fchdr); + +switch (FNIC_FRAME_TYPE (oxid)) { +case FNIC_FRAME_TYPE_FDMI_PLOGI : +fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_plogi); +break ; +case FNIC_FRAME_TYPE_FDMI_RHBA : +fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rhba); +break ; +case FNIC_FRAME_TYPE_FDMI_RPA : +fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa); +break ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp with invalid oxid: 0x%x. Dropping frame" , + oxid); +break ; + } + +del_timer_sync (&iport->fabric.fdmi_timer); + iport->fabric.fdmi_pending &= ~FDLS_FDMI_ABORT_PENDING ; + +fdls_send_fdmi_plogi (iport); +} +static void fdls_process_fabric_abts_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)
@@ -4094,6 +4736,12 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_LOGO :return FNIC_FABRIC_LOGO_RSP ; +case FNIC_FRAME_TYPE_FDMI_PLOGI : +return FNIC_FDMI_PLOGI_RSP ; +case FNIC_FRAME_TYPE_FDMI_RHBA : +return FNIC_FDMI_REG_HBA_RSP ; +case FNIC_FRAME_TYPE_FDMI_RPA : +return FNIC_FDMI_RPA_RSP ;case FNIC_FRAME_TYPE_TGT_PLOGI :return FNIC_TPORT_PLOGI_RSP ;case FNIC_FRAME_TYPE_TGT_PRLI :
@@ -4148,6 +4796,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 ;
@@ -4187,6 +4838,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,case FNIC_FABRIC_BLS_ABTS_RSP :fdls_process_fabric_abts_rsp (iport, fchdr);break ; +case FNIC_FDMI_BLS_ABTS_RSP : +fdls_process_fdmi_abts_rsp (iport, fchdr); +break ;case FNIC_BLS_ABTS_REQ :fdls_process_abts_req (iport, fchdr);break ;
@@ -4212,6 +4866,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);
drivers/scsi/fnic/fnic.h +1 -0
@@ -205,6 +205,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;
drivers/scsi/fnic/fnic_main.c +17 -2
@@ -64,6 +64,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 );
@@ -612,6 +615,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned long flags;int hwq;char *desc, *subsys_desc; +int len;/* * Allocate SCSI Host and set up association between host,
@@ -646,9 +650,17 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)fnic_stats_debugfs_init (fnic);/* Find model name from PCIe subsys ID */ -if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) {dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); -else { + +/* 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);
@@ -1051,6 +1063,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
Signature · 1 line
2.47.0
Re: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 618
Quoted 5 lines · Karan Tilak Kumar
drivers/scsi/fnic/fnic_main.c +1
-0@@ -612,6 +615,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned long flags;int hwq;char *desc, *subsys_desc; +int len;
Do not introduce unnecessary levels of indirection. Get rid of this len variable.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 656
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +3
-2/* * Allocate SCSI Host and set up association between host, @@ -646,9 +650,17 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)fnic_stats_debugfs_init (fnic);/* Find model name from PCIe subsys ID */ -if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) {dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); -else { + +/* Update FDMI model */
This comment adds no information. Delete it.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 657
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ fnic->subsys_desc_len =strlen (subsys_desc);
Keep in mind that strlen() does not count the NUL-terminator.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 658
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ len =ARRAY_SIZE (fnic->subsys_desc);
Use sizeof() when you are talking about bytes or chars. For snprintf() and other string functions, it's always sizeof() and never ARRAY_SIZE().
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 661
Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +3
-0+if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; +memcpy (fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len);
So this is an 0-14 character buffer. If fnic->subsys_desc_len is set to 14, then the string is not NUL terminated. This is how the buffer is used in fdls_fdmi_register_hba()
strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN); data[FNIC_FDMI_MODEL_LEN - 1] = 0;
This suggests that fnic->subsys_desc is expected to be NUL-terminated. However FNIC_FDMI_MODEL_LEN is 12. So in that case the last 3 characters are removed. LOL. It's harmless but so very annoying.
Also strscpy_pad() will ensure that data[FNIC_FDMI_MODEL_LEN - 1] is set to zero so that line could be deleted.
regards,
dan carpenter
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
Quoted 10 lines · Dan Carpenter
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 618
Quoted 5 lines · Karan Tilak Kumar
drivers/scsi/fnic/fnic_main.c +1
-0@@ -612,6 +615,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned long flags;int hwq;char *desc, *subsys_desc; +int len;Do not introduce unnecessary levels of indirection. Get rid of this len variable.
Thanks Dan.
We will address this in a future patch.
Quoted 6 lines
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +0
-0/* * Allocate SCSI Host and set up association between host, @@ -646,9 +650,17 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)fnic_stats_debugfs_init (fnic);
Quoted 9 lines
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 656
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +3
-2/* Find model name from PCIe subsys ID */ -if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) {dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); -else { + +/* Update FDMI model */ This comment adds no information. Delete it.
Thanks Dan. We will address this in a future patch.
Quoted 20 lines
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 657
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ fnic->subsys_desc_len =strlen (subsys_desc);Keep in mind that
strlen()does not count the NUL-terminator.drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 658
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ len =ARRAY_SIZE (fnic->subsys_desc);Use
sizeof()when you are talking about bytes or chars. Forsnprintf()and other string functions, it's alwayssizeof()and neverARRAY_SIZE().drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 661
Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +3
-0+if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; +memcpy (fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len);So this is an 0-14 character buffer. If
fnic->subsys_desc_lenis set to 14, then the string is not NUL terminated. This is how the buffer is used infdls_fdmi_register_hba()
strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN); data[FNIC_FDMI_MODEL_LEN - 1] = 0;
Quoted 6 lines
This suggests that
fnic->subsys_descis expected to be NUL-terminated. HoweverFNIC_FDMI_MODEL_LENis 12. So in that case the last 3 characters are removed. LOL. It's harmless but so very annoying.Also
strscpy_pad()will ensure that data[FNIC_FDMI_MODEL_LEN - 1] is set to zero so that line could be deleted.
Thanks Dan. Cisco VIC model names do not exceed 9 characters. I understand your point about the theoretical case though. The data init line can be removed in a future patch.
Quoted 3 lines
regards,
dan carpenter
Thanks for your time and effort in reviewing this patch Dan. Appreciate your help.
Regards,
Karan
Re: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
In reply to Dan CarpenterJust a note to say that these patches are important to Red Hat and we are actively engaged in back porting and testing these patches in to RHEL-9 and RHEL-10.
I think these issues that Dan has pointed out are all issues which can be addressed in a follow up patch.
/John
Quoted 56 lines · Dan Carpenter
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 618
Quoted 5 lines · Karan Tilak Kumar
drivers/scsi/fnic/fnic_main.c +1
-0@@ -612,6 +615,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned long flags;int hwq;char *desc, *subsys_desc; +int len;Do not introduce unnecessary levels of indirection. Get rid of this len variable.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 656
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +3
-2/* * Allocate SCSI Host and set up association between host, @@ -646,9 +650,17 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)fnic_stats_debugfs_init (fnic);/* Find model name from PCIe subsys ID */ -if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) {dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); -else { + +/* Update FDMI model */ This comment adds no information. Delete it.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 657
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ fnic->subsys_desc_len =strlen (subsys_desc);Keep in mind that
strlen()does not count the NUL-terminator.drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 658
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ len =ARRAY_SIZE (fnic->subsys_desc);Use
sizeof()when you are talking about bytes or chars. Forsnprintf()and other string functions, it's alwayssizeof()and neverARRAY_SIZE().drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 661
Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +3
-0+if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; +memcpy (fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len);So this is an 0-14 character buffer. If
fnic->subsys_desc_lenis set to 14, then the string is not NUL terminated. This is how the buffer is used infdls_fdmi_register_hba()strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN); data[FNIC_FDMI_MODEL_LEN - 1] = 0;This suggests that
fnic->subsys_descis expected to be NUL-terminated. HoweverFNIC_FDMI_MODEL_LENis 12. So in that case the last 3 characters are removed. LOL. It's harmless but so very annoying.Also
strscpy_pad()will ensure that data[FNIC_FDMI_MODEL_LEN - 1] is set to zero so that line could be deleted.regards,
dan carpenter
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
Quoted 66 lines · John Meneghini
Just a note to say that these patches are important to Red Hat and we are actively engaged in back porting and testing these patches in to RHEL-9 and RHEL-10.
I think these issues that Dan has pointed out are all issues which can be addressed in a follow up patch.
/John
Quoted 56 lines · Dan Carpenter
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 618
Quoted 5 lines · Karan Tilak Kumar
drivers/scsi/fnic/fnic_main.c +1
-0@@ -612,6 +615,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)unsigned long flags;int hwq;char *desc, *subsys_desc; +int len;Do not introduce unnecessary levels of indirection. Get rid of this len variable.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 656
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +3
-2/* * Allocate SCSI Host and set up association between host, @@ -646,9 +650,17 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)fnic_stats_debugfs_init (fnic);/* Find model name from PCIe subsys ID */ -if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) {dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); -else { + +/* Update FDMI model */ This comment adds no information. Delete it.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 657
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ fnic->subsys_desc_len =strlen (subsys_desc);Keep in mind that
strlen()does not count the NUL-terminator.drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 658
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+ len =ARRAY_SIZE (fnic->subsys_desc);Use
sizeof()when you are talking about bytes or chars. Forsnprintf()and other string functions, it's alwayssizeof()and neverARRAY_SIZE().drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 661
Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +3
-0+if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; +memcpy (fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len);So this is an 0-14 character buffer. If
fnic->subsys_desc_lenis set to 14, then the string is not NUL terminated. This is how the buffer is used infdls_fdmi_register_hba()strscpy_pad(data, fnic->subsys_desc, FNIC_FDMI_MODEL_LEN); data[FNIC_FDMI_MODEL_LEN - 1] = 0;This suggests that
fnic->subsys_descis expected to be NUL-terminated. HoweverFNIC_FDMI_MODEL_LENis 12. So in that case the last 3 characters are removed. LOL. It's harmless but so very annoying.Also
strscpy_pad()will ensure that data[FNIC_FDMI_MODEL_LEN - 1] is set to zero so that line could be deleted.regards,
dan carpenter
Thanks for your inputs, John.
Regards,
Karan
Re: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
In reply to John MeneghiniQuoted 6 lines · John Meneghini
Just a note to say that these patches are important to Red Hat and we are actively engaged in back porting and testing these patches in to RHEL-9 and RHEL-10.
I think these issues that Dan has pointed out are all issues which can be addressed in a follow up patch.
I mean we already merged this. I only got involved because of static checker issues in linux-next.
What I'm complaining about is not so much any specific issue but just that the process was not followed. Normally this patch would not be merged. If anyone sent a patch like this to drivers/staging it would have triggered Greg's patch-bot automated response:
- Your patch did many different things all at once, making it difficult to review. All Linux kernel patches need to only do one thing at a time. If you need to do multiple things (such as clean up all coding style issues in a file/driver), do it in a sequence of patches, each one doing only one thing. This will make it easier to review the patches to ensure that they are correct, and to help alleviate any merge issues that larger patches can cause.
This rule is the same in every subsystem. No one wants to merge a patch like this. But what happened is the patch sat on the list and only Hannes and Martin were doing any review. Karan was left doing all the work with no help or guidance. Eventually Martin has to give up right? The patchset isn't up to normal standards but it's basically okay and Martin can't do every single thing by himself and eventually it's pretty clear no one else is coming to help. It is what it is etc.
Please understand this in the gentlest way. Next time if something is important then assign an engineer to help out. It would have taken a day to prepare this patchset for merging. You had seven months. It's not fair to show up five days before the merge window asking for special exemptions from the review process. Maintainers and reviewers are already overworked, they shouldn't have to work around your deadlines.
From what I've seen Karan is absolutely doing a good job addressing the problems I reported so it's fine. But normally this is not how it works.
regards,
dan carpenter
Re: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
Hi Dan.
I absolutely agree with all of your comments and I appreciate your review. I agree that all of the issues you've pointed out, with the the exception of one, need to be addressed. The issues pointed out - especially the string manipulation issues - can turn into CVEs. We don't want to be checking bugs like this into Linux. Certainly, nothing should be merged that does not pass the static checker, et al, automated tools we have.
My comment here was only to say that I don't think it's reasonable to ask Karan to break this change into a series of 100 small, reviewable changes.
To explain: the fnic driver is Cisco's driver. Cisco has always taken responsibility for this driver and Karan is one of the many Cisco Maintainers. What's happening is, after a long period of time where the code has been somewhat neglected, Cisco has decided to do a major update of their upstream driver. These changes are really more like a new driver, with some major new features, than a series of bug fixes or updates. This is happening because - at the insistence of some of the Distros, like Red Hat - Cisco is being told they need to bring their upstream drivers in line with their out-of-box drivers.
Karan can confirm if this is the case. My question for Karan is: are there any more major driver changes coming for fnic, or is this the majority of it?
If this were simply a new feature or a series of bug fixes I agree the changes need to be organized into a series of small, reviewable patches. However, under the circumstances, I am willing to hold my nose and say: just get your driver updated and into order, and then we will hold the Maintainers (not Martin) accountable.
So I guess I am recommending an exception to the rule, just this once, in regard to breaking the overall change into a smaller and smaller patch series. I would prefer, instead, that any and all changes needed to address further review comments be presented as a small series of patches, broken down into reviewable chunks, on top of the exiting patch series. It can be decided later if these patches can or should be squashed into the respective 17 commits.
Anyways, those are my thoughts.
Thanks again for your help with this review. I agree Karan needs help and support, and I will try to be more public about they ways I am doing that - which have been mostly in the back-ground.
/John
Quoted 45 lines · Dan Carpenter
Quoted 6 lines · John Meneghini
Just a note to say that these patches are important to Red Hat and we are actively engaged in back porting and testing these patches in to RHEL-9 and RHEL-10.
I think these issues that Dan has pointed out are all issues which can be addressed in a follow up patch.
I mean we already merged this. I only got involved because of static checker issues in linux-next.
What I'm complaining about is not so much any specific issue but just that the process was not followed. Normally this patch would not be merged. If anyone sent a patch like this to
drivers/stagingit would have triggered Greg's patch-bot automated response:- Your patch did many different things all at once, making it difficult to review. All Linux kernel patches need to only do one thing at a time. If you need to do multiple things (such as clean up all coding style issues in a file/driver), do it in a sequence of patches, each one doing only one thing. This will make it easier to review the patches to ensure that they are correct, and to help alleviate any merge issues that larger patches can cause.
This rule is the same in every subsystem. No one wants to merge a patch like this. But what happened is the patch sat on the list and only Hannes and Martin were doing any review. Karan was left doing all the work with no help or guidance. Eventually Martin has to give up right? The patchset isn't up to normal standards but it's basically okay and Martin can't do every single thing by himself and eventually it's pretty clear no one else is coming to help. It is what it is etc.
Please understand this in the gentlest way. Next time if something is important then assign an engineer to help out. It would have taken a day to prepare this patchset for merging. You had seven months. It's not fair to show up five days before the merge window asking for special exemptions from the review process. Maintainers and reviewers are already overworked, they shouldn't have to work around your deadlines.
From what I've seen Karan is absolutely doing a good job addressing the
problems I reported so it's fine. But normally this is not how it works.regards,
dan carpenter
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
Quoted 22 lines · John Meneghini
Hi Dan.
I absolutely agree with all of your comments and I appreciate your review. I agree that all of the issues you've pointed out, with the the exception of one, need to be addressed. The issues pointed out - especially the string manipulation issues - can turn into CVEs. We don't want to be checking bugs like this into Linux. Certainly, nothing should be merged that does not pass the static checker, et al, automated tools we have.
My comment here was only to say that I don't think it's reasonable to ask Karan to break this change into a series of 100 small, reviewable changes.
To explain: the fnic driver is Cisco's driver. Cisco has always taken responsibility for this driver and Karan is one of the many Cisco Maintainers. What's happening is, after a long period of time where the code has been somewhat neglected, Cisco has decided to do a major update of their upstream driver. These changes are really more like a new driver, with some major new features, than a series of bug fixes or updates. This is happening because - at the insistence of some of the Distros, like Red Hat - Cisco is being told they need to bring their upstream drivers in line with their out-of-box drivers.
Quoted 3 lines
Karan can confirm if this is the case. My question for Karan is: are there any more major driver changes coming for fnic, or is this the majority of it?
This current set of changes is the biggest set.
We have a few more small features planned for the future, not for 6.14. They are quite limited in their scope.
Regards,
Karan
Re: [PATCH v7 07/15] scsi: fnic: Add and integrate support for FDMI
In reply to John MeneghiniQuoted 11 lines · John Meneghini
Hi Dan.
I absolutely agree with all of your comments and I appreciate your review. I agree that all of the issues you've pointed out, with the the exception of one, need to be addressed. The issues pointed out - especially the string manipulation issues - can turn into CVEs. We don't want to be checking bugs like this into Linux. Certainly, nothing should be merged that does not pass the static checker, et al, automated tools we have.
My comment here was only to say that I don't think it's reasonable to ask Karan to break this change into a series of 100 small, reviewable changes.
100 small changes is hyperbole. It would have made this set of 15 patches into probably 23 patches. A day's work perhaps.
Creating reviewable patches is part of the process because it forces you to review the code yourself. It makes reviewing the code easier and safer and faster.
I feel like if people had asked in Jun last year, you have two options:
Option A: Would you rather do one day's work cleaning this code up to make it easy to review? Option B: Would you rather resend it as-is every month for seven months? I feel like most people would choose option A.
But the real problem is that we don't have enough SCSI maintainers... Even a quite junior maintainer would help. In drivers/staging, we have a bunch of random volunteers who chime in on stuff like this. It is what it is.
regards,
dan carpenter
Karan Tilak Kumar
maintainerPATCH v7 8/15 scsi: fnic: Add and integrate support for FIP
In reply to Karan Tilak KumarAdd and integrate support for FCoE Initialization (protocol) FIP. This protocol will be exercised on Cisco UCS rack servers.
Add support to specifically print FIP related debug messages.
Replace existing definitions to handle new data structures.
Clean up old and obsolete definitions.
Closes:
https://lore.kernel.org/oe-kbuild-all/202409291955.FcMZfNSt-lkp@
intel.com/
Closes:
https://lore.kernel.org/oe-kbuild-all/202412081904.pXwdx15J-lkp@
intel.com/
---
Changes between v6 and v7:
Fix kernel test robot warning.
Changes between v5 and v6:
Rebase to 6.14/scsi-queue.
Incorporate review comments from Martin:
Remove GCC 13.3 warnings.
Incorporate review comments from Hannes:
Allocate OXID from a pool.
Modify frame initialization.
Replace headers with standard headers.
Changes between v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately.
Remove unnecessary tabs from the bottom of fip.h.
Changes between v3 and v4:
Fix kernel test robot warnings.
Changes between v2 and v3:
Incorporate review comments from Hannes:
Replace redundant definitions with standard definitions.
Incorporate review comments from John:
Replace GFP_ATOMIC with GFP_KERNEL where applicable.
Changes between v1 and v2:
Incorporate review comments from Hannes from other patches:
Use the correct kernel-doc format.
Replace htonll() with get_unaligned_be64(). Replace definitions with standard definitions from fc_els.h.
Incorporate review comments from John:
Remove unreferenced variable.
Use standard definitions of true and false. Replace if else clauses with switch statement. Use kzalloc instead of kmalloc.
--- drivers/scsi/fnic/Makefile | 1 + drivers/scsi/fnic/fip.c | 983 ++++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fip.h | 157 ++++++ drivers/scsi/fnic/fnic.h | 23 +- drivers/scsi/fnic/fnic_fcs.c | 853 ++++------------------------- drivers/scsi/fnic/fnic_fip.h | 48 -- drivers/scsi/fnic/fnic_main.c | 48 +- 7 files changed, 1289 insertions(+), 824 deletions(-) create mode 100644 drivers/scsi/fnic/fip.c create mode 100644 drivers/scsi/fnic/fip.h delete mode 100644 drivers/scsi/fnic/fnic_fip.h
drivers/scsi/fnic/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-$(CONFIG_FCOE_FNIC) += fnic.o fnic-y := \ + fip.o\ fnic_attrs.o \ fnic_isr.o \ fnic_main.o \
drivers/scsi/fnic/fip.c new file +983 -0
983 lines not on this page · raw message
drivers/scsi/fnic/fip.h new file +157 -0
157 lines not on this page · raw message
drivers/scsi/fnic/fnic.h +14 -9
@@ -235,6 +235,12 @@ do { \ "fnic<%d>: %s: %d: " fmt, fnic_num,\ __func__, __LINE__, ##args);) +#define FNIC_FIP_DBG(kern_level, host, fnic_num, fmt, args...) \ + FNIC_CHECK_LOGGING(FNIC_FCS_LOGGING, \ + shost_printk(kern_level, host, \ + "fnic<%d>: %s: %d: " fmt, fnic_num,\ + __func__, __LINE__, ##args);) + #define FNIC_SCSI_DBG(kern_level, host, fnic_num, fmt, args...) \ FNIC_CHECK_LOGGING(FNIC_SCSI_LOGGING, \ shost_printk(kern_level, host, \
@@ -416,13 +422,15 @@ struct fnic {/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);struct work_struct fip_frame_work; -struct sk_buff_head fip_frame_queue; +struct work_struct fip_timer_work; +struct list_head fip_frame_queue;struct timer_list fip_timer; -struct list_head vlans;spinlock_t vlans_lock; - -struct work_struct event_work; -struct list_head evlist; +struct timer_list retry_fip_timer; +struct timer_list fcs_ka_timer; +struct timer_list enode_ka_timer; +struct timer_list vn_ka_timer; +struct list_head vlan_list;/*** FIP related data members -- end ***/ /* copy work queue cache line section */
@@ -472,9 +480,6 @@ int fnic_rq_cmpl_handler(struct fnic *fnic, int);int fnic_alloc_rq_frame (struct vnic_rq *rq);void fnic_free_rq_buf (struct vnic_rq *rq,struct vnic_rq_buf *buf);void fnic_flush_tx (struct work_struct *work); -void fnic_eth_send (struct fcoe_ctlr *,struct sk_buff *skb); -void fnic_set_port_id (struct fc_lport *,u32 ,struct fc_frame *); -void fnic_update_mac (struct fc_lport *,u8 *new);void fnic_update_mac_locked (struct fnic *,u8 *new);int fnic_queuecommand (struct Scsi_Host *,struct scsi_cmnd *);
@@ -503,7 +508,7 @@ int fnic_is_abts_pending(struct fnic *, struct scsi_cmnd *);void fnic_handle_fip_frame (struct work_struct *work);void fnic_handle_fip_event (struct fnic *fnic);void fnic_fcoe_reset_vlans (struct fnic *fnic); -void fnic_fcoe_evlist_free (struct fnic *fnic); +extern void fnic_handle_fip_timer (struct timer_list *t);static inline int fnic_chk_state_flags_locked (struct fnic *fnic,unsigned long st_flags)
drivers/scsi/fnic/fnic_fcs.c +119 -734
996 lines not on this page · raw message
drivers/scsi/fnic/fnic_fip.h deleted +0 -48
48 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +15 -33
99 lines not on this page · raw message
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 9/15 scsi: fnic: Add functionality in fnic to support FDLS
In reply to Karan Tilak KumarAdd interfaces in fnic to use FDLS services. Modify link up and link down functionality to use FDLS. Replace existing interfaces to handle new functionality provided by FDLS.
Modify data types of some data members to handle new functionality.
Add processing of tports and handling of tports.
Closes:
https://lore.kernel.org/oe-kbuild-all/202409292037.ZYWZwIK6-lkp@
intel.com/
---
Changes between v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately.
Remove placeholder start flogi call.
Remove spurious newlines from the bottom of fdls_disc.c. Remove spurious newlines from the bottom of fnic_fcs.c. Remove spurious newlines from the bottom of fnic_scsi.c.
Changes between v3 and v4:
Fix kernel test robot warnings.
Changes between v2 and v3:
Refactor fnic_fdls_remove_tport to fix null pointer exception. Incorporate review comments from Hannes:
Replace redundant definitions with standard definitions.
Changes between v1 and v2:
Incorporate review comments from Hannes:
Replace fnic_del_tport_timer_sync macro calls with function calls.
--- drivers/scsi/fnic/fdls_disc.c | 75 +++++- drivers/scsi/fnic/fip.c | 27 +- drivers/scsi/fnic/fnic.h | 20 +- drivers/scsi/fnic/fnic_fcs.c | 482 ++++++++++++++++++++++++---------- drivers/scsi/fnic/fnic_main.c | 11 +- drivers/scsi/fnic/fnic_scsi.c | 127 +++++++-- 6 files changed, 568 insertions(+), 174 deletions(-)
drivers/scsi/fnic/fdls_disc.c +74 -1
@@ -397,6 +397,13 @@ static bool fdls_is_oxid_tgt_req(uint16_t oxid)return true; } +static void fdls_reset_oxid_pool (struct fnic_iport_s *iport) +{ +struct fnic_oxid_pool_s *oxid_pool = &iport->oxid_pool; + + oxid_pool->next_idx =0 ; +} +void fnic_del_fabric_timer_sync (struct fnic *fnic) { fnic->iport.fabric.del_timer_inprogress =1 ;
@@ -2248,7 +2255,6 @@ void fdls_fabric_timer_callback(struct timer_list *t) }break ;default : -fnic_fdls_start_flogi (iport);/* Placeholder call */ break ; }spin_unlock_irqrestore (&fnic->fnic_lock, flags);
@@ -3471,6 +3477,12 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,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, +"0x%x: FLOGI registration failed" , iport->fcid); +break ; + } +memcpy (&fcmac[3 ], fcid,3 ); FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num, "Adding vNIC device MAC addr: %02x:%02x:%02x:%02x:%02x:%02x",
@@ -4448,6 +4460,30 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)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) +{ +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 (), +FCH_EVT_LIPRESET ,0 ); + } + +if (!iport->usefip) { +if (iport->flags &FNIC_FIRST_LINK_UP ) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +fnic_scsi_fcpio_reset (iport->fnic); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + + iport->flags &= ~FNIC_FIRST_LINK_UP ; + } +fnic_fdls_start_flogi (iport); + }else +fnic_fdls_start_plogi (iport); +} +static void fdls_process_adisc_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)
@@ -4878,3 +4914,40 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,break ; } } + +void fnic_fdls_disc_init (struct fnic_iport_s *iport) +{ +fdls_reset_oxid_pool (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_INIT ); +} + +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, +"0x%x: FDLS processing link down" , iport->fcid); + +fdls_set_state ((&iport->fabric),FDLS_STATE_LINKDOWN ); + iport->fabric.flags =0 ; + +if (IS_FNIC_FCP_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +fnic_scsi_fcpio_reset (iport->fnic); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"removing rport: 0x%x" , tport->fcid); +fdls_delete_tport (iport, tport); + } + } + +if ((fnic_fdmi_support ==1 ) && (iport->fabric.fdmi_pending >0 )) { +del_timer_sync (&iport->fabric.fdmi_timer); + iport->fabric.fdmi_pending =0 ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS finish processing link down" , iport->fcid); +}
drivers/scsi/fnic/fip.c +26 -1
@@ -534,6 +534,7 @@ void fnic_fcoe_process_flogi_resp(struct fnic *fnic, struct fip_header *fiph)FNIC_FIP_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"iport->state:%d\n" , iport->state); +fnic_fdls_disc_start (iport);if (!((iport->selected_fcf.ka_disabled) || (iport->selected_fcf.fka_adv_period ==0 ))) {u64 tov;
@@ -617,6 +618,7 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph)struct fip_cvl *cvl_msg = (struct fip_cvl *)fiph;int i;int found = false; +int max_count =0 ;FNIC_FIP_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"fnic 0x%p clear virtual link handler\n" , fnic);
@@ -658,6 +660,26 @@ void fnic_fcoe_process_cvl(struct fnic *fnic, struct fip_header *fiph)return ;fnic_common_fip_cleanup (fnic); +while (fnic->reset_in_progress ==IN_PROGRESS ) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +wait_for_completion_timeout (&fnic->reset_completion_wait, +msecs_to_jiffies (5000 )); +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, +"Rthr waited too long. Skipping handle link event %p\n" , + fnic); +return ; + } +FNIC_FIP_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fnic reset in progress. Link event needs to wait %p" , + fnic); + } + fnic->reset_in_progress =IN_PROGRESS ; +fnic_fdls_link_down (iport); + fnic->reset_in_progress =NOT_IN_PROGRESS ; +complete (&fnic->reset_completion_wait);fnic_fcoe_send_vlan_req (fnic); } }
@@ -717,8 +739,10 @@ void fnic_work_on_fip_timer(struct work_struct *work) "FCF Discovery timeout\n");if (memcmp (iport->selected_fcf.fcf_mac, zmac,ETH_ALEN ) !=0 ) { -if (iport->flags &FNIC_FIRST_LINK_UP ) +if (iport->flags &FNIC_FIRST_LINK_UP ) { +fnic_scsi_fcpio_reset (iport->fnic); iport->flags &= ~FNIC_FIRST_LINK_UP ; + }fnic_fcoe_start_flogi (fnic); if (!((iport->selected_fcf.ka_disabled)
@@ -961,6 +985,7 @@ void fnic_work_on_fcs_ka_timer(struct work_struct *work)fnic_common_fip_cleanup (fnic);spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); +fnic_fdls_link_down (iport); iport->state =FNIC_IPORT_STATE_FIP ;spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags);
drivers/scsi/fnic/fnic.h +18 -2
@@ -84,6 +84,7 @@#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +#define FNIC_FW_RESET_TIMEOUT 60000/* mSec */ /* Retry supported by rport (returned by PRLI service parameters) */ #define FNIC_FC_RP_FLAGS_RETRY 0x1
@@ -205,6 +206,12 @@ 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) +enum reset_states { +NOT_IN_PROGRESS =0 , +IN_PROGRESS , +RESET_ERROR +}; +extern unsigned int fnic_fdmi_support;extern unsigned int fnic_log_level;extern unsigned int io_completions;
@@ -357,6 +364,7 @@ struct fnic {unsigned int wq_count;unsigned int cq_count; +struct completion reset_completion_wait;struct mutex sgreset_mutex;spinlock_t sgreset_lock;/* lock for sgreset */ struct scsi_cmnd *sgreset_sc;
@@ -374,6 +382,8 @@ struct fnic {struct completion *remove_wait;/* device remove thread blocks */ +struct completion *fw_reset_done; +u32 reset_in_progress;atomic_t in_flight;/* io counter */ bool internal_reset_inprogress;u32 _reserved;/* fill hole */
@@ -387,6 +397,7 @@ struct fnic {u64 fcp_input_bytes;/* internal statistic */ u64 fcp_output_bytes;/* internal statistic */ u32 link_down_cnt; +u32 soft_reset_count;int link_status;struct list_head list;
@@ -409,7 +420,7 @@ struct fnic {struct work_struct link_work;struct work_struct frame_work;struct work_struct flush_work; -struct sk_buff_head frame_queue; +struct list_head frame_queue;struct list_head tx_queue;mempool_t *frame_pool;mempool_t *frame_elem_pool;
@@ -471,6 +482,7 @@ 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);void fnic_handle_link (struct work_struct *work);void fnic_handle_event (struct work_struct *work);void fdls_reclaim_oxid_handler (struct work_struct *work);
@@ -485,7 +497,8 @@ void fnic_update_mac_locked(struct fnic *, u8 *new);int fnic_queuecommand (struct Scsi_Host *,struct scsi_cmnd *);int fnic_abort_cmd (struct scsi_cmnd *);int fnic_device_reset (struct scsi_cmnd *); -int fnic_host_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 *);
@@ -520,6 +533,9 @@ 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); +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);struct fnic_scsi_iter_data {struct fnic *fnic;
drivers/scsi/fnic/fnic_fcs.c +336 -146
626 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +6 -5
@@ -111,7 +111,7 @@ static const struct scsi_host_template fnic_host_template = { .eh_timed_out = fc_eh_timed_out, .eh_abort_handler = fnic_abort_cmd, .eh_device_reset_handler = fnic_device_reset, - .eh_host_reset_handler = fnic_host_reset, + .eh_host_reset_handler = fnic_eh_host_reset_handler, .slave_alloc = fnic_slave_alloc, .change_queue_depth = scsi_change_queue_depth, .this_id = -1,
@@ -936,9 +936,12 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)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_WORK (&fnic->flush_work, fnic_flush_tx); -skb_queue_head_init (&fnic->frame_queue); + +INIT_LIST_HEAD (&fnic->frame_queue);INIT_LIST_HEAD (&fnic->tx_queue); +INIT_LIST_HEAD (&fnic->tport_event_list);fc_fabric_login (lp);
@@ -1032,7 +1035,7 @@ static void fnic_remove(struct pci_dev *pdev)* be no event queued for this fnic device in the workqueue */ flush_workqueue (fnic_event_queue); -skb_queue_purge (&fnic->frame_queue); +fnic_free_txq (&fnic->frame_queue);fnic_free_txq (&fnic->tx_queue);if (fnic->config.flags &VFCF_FIP_CAPABLE ) {
@@ -1070,8 +1073,6 @@ static void fnic_remove(struct pci_dev *pdev)*/ fnic_cleanup (fnic); -BUG_ON (!skb_queue_empty (&fnic->frame_queue)); -spin_lock_irqsave (&fnic_list_lock, flags);list_del (&fnic->list);spin_unlock_irqrestore (&fnic_list_lock, flags);
drivers/scsi/fnic/fnic_scsi.c +108 -19
164 lines not on this page · raw message
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 10/15 scsi: fnic: Modify IO path to use FDLS
In reply to Karan Tilak KumarModify IO path to use FDLS.
Add helper functions to process IOs.
Remove unused template functions.
Cleanup obsolete code.
Refactor old function definitions.
Closes:
https://lore.kernel.org/oe-kbuild-all/202410210147.fQp7tYeb-lkp@
intel.com/
---
Changes between v5 and v6:
Fix test robot kernel warnings. Incorporate review comments by Hannes:
Remove usage of fnic_transport_template. Replace tag walk with scsi_host_busy_iter. Add comments.
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 | 19 +- drivers/scsi/fnic/fnic_io.h | 3 + drivers/scsi/fnic/fnic_main.c | 10 +- drivers/scsi/fnic/fnic_scsi.c | 839 +++++++++++++++++++-------------- drivers/scsi/fnic/fnic_stats.h | 2 - 5 files changed, 504 insertions(+), 369 deletions(-)
drivers/scsi/fnic/fnic.h +12 -7
@@ -479,7 +479,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);
@@ -499,11 +498,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 );
@@ -515,7 +512,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);
@@ -536,6 +534,13 @@ 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);struct fnic_scsi_iter_data {struct fnic *fnic;
drivers/scsi/fnic/fnic_io.h +3 -0
@@ -7,6 +7,7 @@#define _FNIC_IO_H_#include <scsi/fc/fc_fcp.h> +#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*/
drivers/scsi/fnic/fnic_main.c +1 -9
@@ -85,12 +85,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 = { - .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;static int fnic_slave_alloc (struct scsi_device *sdev)
@@ -163,7 +157,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),
@@ -906,8 +900,6 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)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 ;
drivers/scsi/fnic/fnic_scsi.c +488 -351
1,347 lines not on this page · raw message
drivers/scsi/fnic/fnic_stats.h +0 -2
@@ -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_ */
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 11/15 scsi: fnic: Modify fnic interfaces to use FDLS
In reply to Karan Tilak KumarModify 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.
---
Changes between v5 and v6:
Rebase to 6.14/scsi-queue.
Incorporate review comments from Martin:
Fix GCC 13.3 warnings.
Changes between v4 and v5:
Incorporate review comments from Martin:
Modify fnic_get_stats to suppress compiler warning. Modify attribution appropriately.
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 | 14 +- 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 | 498 +++++++++++++++++-------------- drivers/scsi/fnic/fnic_res.c | 30 +- drivers/scsi/fnic/fnic_scsi.c | 39 +++ drivers/scsi/fnic/fnic_stats.h | 2 + drivers/scsi/fnic/fnic_trace.c | 6 + 9 files changed, 398 insertions(+), 247 deletions(-)
drivers/scsi/fnic/fnic.h +8 -6
@@ -85,6 +85,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
@@ -344,6 +345,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;
@@ -464,11 +466,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[];
@@ -500,6 +497,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 );
@@ -512,7 +510,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 *);
@@ -541,6 +539,10 @@ 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); +int fnic_get_debug_info (struct stats_debug_info *info, +struct fnic *fnic);struct fnic_scsi_iter_data {struct fnic *fnic;
drivers/scsi/fnic/fnic_attrs.c +8 -4
@@ -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);
drivers/scsi/fnic/fnic_debugfs.c +27 -1
@@ -7,6 +7,9 @@#include <linux/vmalloc.h> #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; }/*
drivers/scsi/fnic/fnic_fcs.c +16 -0
@@ -63,6 +63,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;
drivers/scsi/fnic/fnic_main.c +275 -223
812 lines not on this page · raw message
drivers/scsi/fnic/fnic_res.c +17 -13
@@ -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 ; }
drivers/scsi/fnic/fnic_scsi.c +39 -0
@@ -1944,6 +1944,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.
drivers/scsi/fnic/fnic_stats.h +2 -0
@@ -3,6 +3,7 @@ #ifndef _FNIC_STATS_H_ #define _FNIC_STATS_H_ #define FNIC_MQ_MAX_QUEUES 64 +#include <scsi/scsi_transport_fc.h> struct stats_timestamps { struct timespec64 last_reset_time;
@@ -116,6 +117,7 @@ struct fnic_stats {struct reset_stats reset_stats;struct fw_stats fw_stats;struct vlan_stats vlan_stats; +struct fc_host_statistics host_stats;struct misc_stats misc_stats; };
drivers/scsi/fnic/fnic_trace.c +6 -0
@@ -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 *
Signature · 1 line
2.47.0
Re: [PATCH v7 11/15] scsi: fnic: Modify fnic interfaces to use FDLS
Quoted 2 lines · Karan Tilak Kumar
Modify fnic driver interfaces to use FDLS and supporting functions.
What does FDLS mean?
Quoted 8 lines
Refactor code in
fnic_probeandfnic_remove. Get fnic fromshost_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.
Patches should do one thing at a time. There shouldn't be any unrelated refactorings to complicate the review process.
Honestly, this patch is process failure. :( It looks like only Martin and Hannes are reviewing this stuff.
Ideally Martin and Hannes would be focused on the more technical issues instead of basic things like "One thing per Patch" that someone at Cisco could have handled. There are also many style issues that you will find if you run checkpatch.pl --strict on this patch. I started to point out the style issues in my review but I deleted those comments. Just use --strict and you will see it.
We are forcing Martin to be the bad guy. It's super discouraging to have to NAK a v7 patch. This is what leads to maintainer burnout.
Quoted 44 lines
Reviewed-by Sesidhar Baddela <[email protected]>Reviewed-by Arulprabhu Ponnusamy <[email protected]>Reviewed-by Gian Carlo Boffa <[email protected]>Co-developed-by Arun Easi <[email protected]>Signed-off-by Arun Easi <[email protected]>Co-developed-by Karan Tilak Kumar <[email protected]>Signed-off-by Karan Tilak Kumar <[email protected]>---
Changes between v5 and v6:
Rebase to 6.14/scsi-queue.
Incorporate review comments from Martin:
Fix GCC 13.3 warnings.Changes between v4 and v5:
Incorporate review comments from Martin:
Modifyfnic_get_statsto suppress compiler warning. Modify attribution appropriately.Changes between v2 and v3:
Modifyscsi_unloadto fix null pointer exception duringfnic_remove. Replacefnic->hostwithfnic->lport->hostto prevent compilation errors.Changes between v1 and v2:
Incorporate review comments from Hannes from other patches:
Replacepr_infowithdev_info.
Replacepr_errwithdev_err.--- drivers/scsi/fnic/fnic.h | 14 +- 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 | 498 +++++++++++++++++-------------- drivers/scsi/fnic/fnic_res.c | 30 +- drivers/scsi/fnic/fnic_scsi.c | 39 +++ drivers/scsi/fnic/fnic_stats.h | 2 + drivers/scsi/fnic/fnic_trace.c | 6 + 9 files changed, 398 insertions(+), 247 deletions(-)drivers/scsi/fnic/fnic.h +0
-0
drivers/scsi/fnic/fnic.h line 88
Quoted 4 lines
drivers/scsi/fnic/fnic.h +1
-0@@ -85,6 +85,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
Unrelated. Also why? The original define made more sense.
Quoted 12 lines
drivers/scsi/fnic/fnic.h +1
-0/* Retry supported by rport (returned by PRLI service parameters) */ #define FNIC_FC_RP_FLAGS_RETRY 0x1@@ -344,6 +345,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;
drivers/scsi/fnic/fnic.h struct fnic { · line 471
Quoted 8 lines
drivers/scsi/fnic/fnic.h +0
-5@@ -464,11 +466,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); -} -
Unrelated.
Quoted 36 lines
drivers/scsi/fnic/fnic.h +6
-1extern struct workqueue_struct *fnic_event_queue;extern struct workqueue_struct *fnic_fip_queue;extern const struct attribute_group *fnic_host_groups[];@@ -500,6 +497,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 );@@ -512,7 +510,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 *);@@ -541,6 +539,10 @@ 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); +int fnic_get_debug_info (struct stats_debug_info *info, +struct fnic *fnic);struct fnic_scsi_iter_data {struct fnic *fnic;drivers/scsi/fnic/fnic_attrs.c +0
-0
drivers/scsi/fnic/fnic_attrs.c line 15
Quoted 7 lines
drivers/scsi/fnic/fnic_attrs.c +2
-2@@ -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)));
No space after a cast. This is because casting is a high precedence operation. The newline is unnecessary.
struct fnic *fnic = *((struct fnic **)shost_priv(class_to_shost(dev)));
Put this stuff in a function so we don't have to open code this everywhere.
struct fnic *shost_fnic(struct Scsi_Host *shost)
{
return *((struct fnic **)shost_priv(shost);
}Quoted 6 lines
drivers/scsi/fnic/fnic_attrs.c +0
-0return 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)
drivers/scsi/fnic/fnic_attrs.c static ssize_t fnic_show_drv_version(struct device *dev, · line 35
Quoted 10 lines
drivers/scsi/fnic/fnic_attrs.c +6
-2{ -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" );
The white space is weird.
drivers/scsi/fnic/fnic_debugfs.c line 11
Quoted 13 lines
drivers/scsi/fnic/fnic_attrs.c +0
-0} static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);drivers/scsi/fnic/fnic_debugfs.c +2
-0@@ -7,6 +7,9 @@#include <linux/vmalloc.h> #include "fnic.h" +extern int fnic_get_debug_info (struct stats_debug_info *debug_buffer, +struct fnic *fnic);
Hopefully checkpatch will catch things like this.
Quoted 49 lines
drivers/scsi/fnic/fnic_debugfs.c +19
-1+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",
drivers/scsi/fnic/fnic_debugfs.c static const struct file_operations fnic_reset_debugfs_fops = { · line 721
Quoted 10 lines
drivers/scsi/fnic/fnic_debugfs.c +6
-0S_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;
Ugh. Don't do "rc = 0; return rc;". But mostly all the changes to fnic_stats_debugfs_init() are just wrong. It means that the driver cannot load if CONFIG_DEBUGFS is disabled. The original code was correct. Debugfs is weird like that. I will send a patch to revert this.
Quoted 56 lines
drivers/scsi/fnic/fnic_debugfs.c +0
-0}/* drivers/scsi/fnic/fnic_fcs.c +16
-0@@ -63,6 +63,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;drivers/scsi/fnic/fnic_main.c +6
-1@@ -67,6 +67,11 @@ unsigned int fnic_fdmi_support = 1;module_param (fnic_fdmi_support, int,0644 );MODULE_PARM_DESC (fnic_fdmi_support,"FDMI support" ); +static 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" );@@ -146,7 +151,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,
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 166
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c +1
-1@@ -158,79 +163,79 @@ 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,
This line should have been deleted. It will be initialized to zero automatically.
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 170
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +2
-2.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,
Same. Just delete the line.
Quoted 47 lines
drivers/scsi/fnic/fnic_main.c +24
-2};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 ;
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 225
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +7
-0+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 ;
This change could have been done in its own patch.
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 234
Quoted 9 lines
drivers/scsi/fnic/fnic_main.c +3
-0default : +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 */
What does this comment mean? What is it a placeholder for?
Quoted 29 lines
drivers/scsi/fnic/fnic_main.c +0
-27static 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;
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 239
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +2
-7- 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 fnic *fnic = *((struct fnic **)shost_priv (host)); +struct fc_host_statistics *stats = &fnic->fnic_stats.host_stats;return stats;
This is a checkpatch warning because there should be a blank line after the decarations. It's a bit tricky because you will need to apply the patch and then re-run checkpatch.pl -f on the patched file to see this warning.
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +1
-2}@@ -311,8 +316,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;
drivers/scsi/fnic/fnic_main.c static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) · line 538
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c +5
-0@@ -527,9 +531,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,
The - 1 is wrong. It should be:
snprintf(fnic->name, sizeof(fnic->name), "%s%d", DRV_NAME,
Quoted 25 lines
drivers/scsi/fnic/fnic_main.c +10
-1+ 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 +558,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;
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 574
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +4
-0@@ -550,13 +568,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) *
^^^^^^^^^^^^^^^^^^^^
The name of this variable is "table_size" but apparently it is the size - 1. This is only used in debug output so just change the previous line to:
fnic->sw_copy_wq[hwq].ioreq_table_size = fnic->fnic_max_tag_id + 1;
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 579
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c +5
-0+ 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);
dev_dbg(). This patch has a number of these debug printks which are at dev_info() levels.
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 586
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +7
-0+ +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 ;
Propogate the error code. Don't return -EPERM. Do we need to clean up the fnic->sw_copy_wq[hwq].io_req_table allocations?
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +6
-0+ } +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);
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 602
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10
-0+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 ;
Just say:
fc_host_supported_speeds(fnic->lport->host) = FC_PORTSPEED_8GBIT;
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 604
Quoted 2 lines
drivers/scsi/fnic/fnic_main.c +2
-0+ +dev_info (&fnic->pdev->dev,"shost_data: 0x%p\n" , fnic->lport->host->shost_data);
Delete this line.
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 605
Quoted 1 line
drivers/scsi/fnic/fnic_main.c +1
-0+if (fnic->lport->host->shost_data !=NULL ) {
Checkpatch.
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 617
Quoted 12 lines
drivers/scsi/fnic/fnic_main.c +12
-0+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);
Do we need to clean up the fnic->sw_copy_wq[hwq].io_req_table allocations?
Quoted 15 lines
drivers/scsi/fnic/fnic_main.c +4
-2+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 ];
drivers/scsi/fnic/fnic_main.c void fnic_mq_map_queues_cpus(struct Scsi_Host *host) · line 651
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +1
-2@@ -581,31 +648,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 ;
I can't see how this is required or related but I could be wrong.
Quoted 14 lines
drivers/scsi/fnic/fnic_main.c +1
-3struct 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
drivers/scsi/fnic/fnic_main.c void fnic_mq_map_queues_cpus(struct Scsi_Host *host) · line 668
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +4
-4+* 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;
This patch renames all the error labels from describing what they do, to being in ComeFrom style. In my opinion, the original names were MUCH better. I added a section on label names to the Documentation/process/coding-style.rst file but I wasn't going to complain about here. Except, the issue is that it's totally unrelated to FDLS and unrelated changes should have been flagged during review.
Quoted 117 lines
drivers/scsi/fnic/fnic_main.c +14
-23} - host = lp->host; - fnic =lport_priv (lp); + iport = &fnic->iport; fnic_id =ida_alloc (&fnic_ida,GFP_KERNEL );if (fnic_id <0 ) {@@ -613,17 +676,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 +700,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 +721,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 +729,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 +740,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 +748,68 @@ 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" );
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 795
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +9
-1- 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 *));
White space.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 806
Quoted 11 lines
drivers/scsi/fnic/fnic_main.c +11
-0+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);
dev_dbg()
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 810
Quoted 4 lines
drivers/scsi/fnic/fnic_main.c +4
-0+ } +break ; +default : +dev_info (&fnic->pdev->dev,"fnic: %d has no role defined\n" , fnic->fnic_num);
dev_err()
Quoted 207 lines
drivers/scsi/fnic/fnic_main.c +50
-86+ err = -EINVAL ; + goto err_out_fnic_role; }/* Setup PCI resources */ @@ -741,23 +821,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 +846,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 ]);@@ -810,8 +876,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_LIST_HEAD (&fnic->fip_frame_queue);@@ -823,8 +888,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 ;@@ -838,7 +901,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 */ @@ -851,80 +914,43 @@ 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; } } -/* Enable all queues */ -for (i =0 ; i < fnic->raw_wq_count; i++) -vnic_wq_enable (&fnic->wq[i]); -for (i =0 ; i < fnic->rq_count; i++) { -if (!ioread32 (&fnic->rq[i].ctrl->enable)) -vnic_rq_enable (&fnic->rq[i]); - } -for (i =0 ; i < fnic->wq_copy_count; i++) -vnic_wq_copy_enable (&fnic->hw_copy_wq[i]); +init_completion (&fnic->reset_completion_wait); - 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; - } - - -/* 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 ); +/* 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 ) - 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); - -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; - } + iport->service_params |=FNIC_FCP_SP_RETRY ; -fc_lport_init_stats (lp); - fnic->stats_reset_time = jiffies; + 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; -fc_lport_config (lp); + iport->max_payload_size = fnic->config.maxdatafieldsize; -if (fc_set_mfs (lp, fnic->config.maxdatafieldsize + -sizeof (struct fc_frame_header ))) { - err = -EINVAL ; - goto err_out_free_exch_mgr; +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 ; } -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); + iport->flags |=FNIC_FIRST_LINK_UP ; -spin_lock_irqsave (&fnic_list_lock, flags); -list_add_tail (&fnic->list, &fnic_list); -spin_unlock_irqrestore (&fnic_list_lock, flags); +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);@@ -935,71 +961,110 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)INIT_LIST_HEAD (&fnic->tx_queue);INIT_LIST_HEAD (&fnic->tport_event_list); -fc_fabric_login (lp); +INIT_DELAYED_WORK (&iport->oxid_pool.schedule_oxid_free_retry, + fdls_schedule_oxid_free_retry_work); + +/* Initialize the oxid reclaim list and work struct */ +INIT_LIST_HEAD (&iport->oxid_pool.oxid_reclaim_list); +INIT_DELAYED_WORK (&iport->oxid_pool.oxid_reclaim_work, fdls_reclaim_oxid_handler); + +/* Enable all queues */ +for (i =0 ; i < fnic->raw_wq_count; i++) +vnic_wq_enable (&fnic->wq[i]); +for (i =0 ; i < fnic->rq_count; i++) { +if (!ioread32 (&fnic->rq[i].ctrl->enable)) +vnic_rq_enable (&fnic->rq[i]); + } +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);
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 993
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10
-0+if (err) { +dev_err (&fnic->pdev->dev,"Unable to request irq.\n" ); + goto err_out_fnic_request_intr; + } + +fnic_notify_timer_start (fnic); + +fnic_fdls_init (fnic, (fnic->config.flags &VFCF_FIP_CAPABLE )); + +if (IS_FNIC_FCP_INITIATOR (fnic) &&fnic_scsi_drv_init (fnic))
We know that IS_FNIC_FCP_INITIATOR() is true. Presumably this is stub code which will make sense in the future. These kinds of known true stub code conditions are discouraged because we can not predict the future or review future code which we have not seen. For exmample, this call to fnic_scsi_drv_init() is cleaned up by
scsi_remove_host(fnic->lport->host);
But we would expect the condition to be consistent in both the allocation code and the tear down code.
if (IS_FNIC_FCP_INITIATOR(fnic)) scsi_remove_host(lp->host);
In fact, ideally the tear down here would match the code in the remove function.
if (IS_FNIC_FCP_INITIATOR(fnic)) fnic_scsi_unload(fnic);
Does that matter? It doesn't matter *now* but to answer that question properly depends on the future code which has not been writtten.
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 999
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +6
-0+ goto err_out_scsi_drv_init; + + 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;
This goto frees the fnic_stats_debugfs_init() stuff which we failed to allocate. It's harmless, but generally, we would only free resources which have been successfully allocated.
Quoted 183 lines
drivers/scsi/fnic/fnic_main.c +50
-58+ } +for (i =0 ; i < fnic->intr_count; i++)vnic_intr_unmask (&fnic->intr[i]); -fnic_notify_timer_start (fnic); +spin_lock_irqsave (&fnic_list_lock, flags); +list_add_tail (&fnic->list, &fnic_list); +spin_unlock_irqrestore (&fnic_list_lock, flags);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_fnic_notify_set:mempool_destroy (fnic->frame_elem_pool); err_out_fdls_frame_elem_pool:mempool_destroy (fnic->frame_pool); err_out_fdls_frame_pool: -err_out_free_max_pool: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;/* * Sometimes when probe() fails and do not exit with an error code, @@ -1009,26 +1074,21 @@ static void fnic_remove(struct pci_dev *pdev)if (!fnic)return ; -/* -* 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);@@ -1043,19 +1103,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);/* @@ -1069,11 +1116,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);@@ -1083,8 +1128,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 = {
drivers/scsi/fnic/fnic_main.c static void __exit fnic_cleanup_module(void) · line 1291
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +2
-1@@ -1236,8 +1286,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);
I don't think this change is necessary or related. But if it is then it needs to be split into its own patch with a Fixes tag.
Quoted 9 lines
drivers/scsi/fnic/fnic_main.c +1
-0+ }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);drivers/scsi/fnic/fnic_res.c +0
-0
drivers/scsi/fnic/fnic_res.c int fnic_get_vnic_config(struct fnic *fnic) · line 62
Quoted 5 lines
drivers/scsi/fnic/fnic_res.c +2
-0@@ -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" );
dev_dbg() perhaps? I'm not sure on this one.
Quoted 78 lines
drivers/scsi/fnic/fnic_res.c +15
-13+ 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 ; }drivers/scsi/fnic/fnic_scsi.c +22
-0@@ -1944,6 +1944,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);
drivers/scsi/fnic/fnic_scsi.c void fnic_terminate_rport_io(struct fc_rport *rport) · line 1978
Quoted 10 lines
drivers/scsi/fnic/fnic_scsi.c +10
-0+ 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 ;
This initialization is not required.
Quoted 35 lines
drivers/scsi/fnic/fnic_scsi.c +7
-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. drivers/scsi/fnic/fnic_stats.h +2
-0@@ -3,6 +3,7 @@ #ifndef _FNIC_STATS_H_ #define _FNIC_STATS_H_ #define FNIC_MQ_MAX_QUEUES 64 +#include <scsi/scsi_transport_fc.h> struct stats_timestamps { struct timespec64 last_reset_time;@@ -116,6 +117,7 @@ struct fnic_stats {struct reset_stats reset_stats;struct fw_stats fw_stats;struct vlan_stats vlan_stats; +struct fc_host_statistics host_stats;struct misc_stats misc_stats; };drivers/scsi/fnic/fnic_trace.c +0
-0
drivers/scsi/fnic/fnic_trace.c int fnic_get_stats_data(struct stats_debug_info *debug, · line 465
Quoted 8 lines
drivers/scsi/fnic/fnic_trace.c +5
-0@@ -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 ; +}
We don't add placeholder functions. There was a better way to break this up and someone should have helped you with this.
regards,
dan carpenter
Quoted 7 lines
drivers/scsi/fnic/fnic_trace.c +1
-0+/* * fnic_trace_buf_init - Initialize fnic trace buffer logging facility * Signature · 1 line
2.47.0
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v7 11/15] scsi: fnic: Modify fnic interfaces to use FDLS
Quoted 6 lines · Dan Carpenter
Quoted 2 lines · Karan Tilak Kumar
Modify fnic driver interfaces to use FDLS and supporting functions.
What does FDLS mean?
FDLS stands for Fabric Discovery and Login Services. Please refer to the cover letter that has more details regarding this new feature.
Quoted 71 lines
Quoted 8 lines
Refactor code in
fnic_probeandfnic_remove. Get fnic fromshost_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.Patches should do one thing at a time. There shouldn't be any unrelated refactorings to complicate the review process.
Honestly, this patch is process failure. :( It looks like only Martin and Hannes are reviewing this stuff.
Ideally Martin and Hannes would be focused on the more technical issues instead of basic things like "One thing per Patch" that someone at Cisco could have handled. There are also many style issues that you will find if you run checkpatch.pl --strict on this patch. I started to point out the style issues in my review but I deleted those comments. Just use --strict and you will see it.
We are forcing Martin to be the bad guy. It's super discouraging to have to NAK a v7 patch. This is what leads to maintainer burnout.
Quoted 46 lines
Reviewed-by Sesidhar Baddela <[email protected]>Reviewed-by Arulprabhu Ponnusamy <[email protected]>Reviewed-by Gian Carlo Boffa <[email protected]>Co-developed-by Arun Easi <[email protected]>Signed-off-by Arun Easi <[email protected]>Co-developed-by Karan Tilak Kumar <[email protected]>Signed-off-by Karan Tilak Kumar <[email protected]>---
Changes between v5 and v6:
Rebase to 6.14/scsi-queue.
Incorporate review comments from Martin:
Fix GCC 13.3 warnings.Changes between v4 and v5:
Incorporate review comments from Martin:
Modifyfnic_get_statsto suppress compiler warning. Modify attribution appropriately.Changes between v2 and v3:
Modifyscsi_unloadto fix null pointer exception duringfnic_remove. Replacefnic->hostwithfnic->lport->hostto prevent compilation errors.Changes between v1 and v2:
Incorporate review comments from Hannes from other patches:
Replacepr_infowithdev_info.
Replacepr_errwithdev_err.--- drivers/scsi/fnic/fnic.h | 14 +- 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 | 498 +++++++++++++++++-------------- drivers/scsi/fnic/fnic_res.c | 30 +- drivers/scsi/fnic/fnic_scsi.c | 39 +++ drivers/scsi/fnic/fnic_stats.h | 2 + drivers/scsi/fnic/fnic_trace.c | 6 + 9 files changed, 398 insertions(+), 247 deletions(-)drivers/scsi/fnic/fnic.h +0
-0@@ -85,6 +85,7 @@#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR)
Quoted 4 lines
drivers/scsi/fnic/fnic.h line 88
Quoted 2 lines
drivers/scsi/fnic/fnic.h +1
-0#define FNIC_FW_RESET_TIMEOUT 60000/* mSec */ +#define FNIC_FCOE_MAX_CMD_LEN 16Unrelated. Also why? The original define made more sense.
Thanks for your comment Dan.
I'm unclear as to the original define. Please clarify.
Quoted 15 lines
Quoted 15 lines
drivers/scsi/fnic/fnic.h +1
-0/* Retry supported by rport (returned by PRLI service parameters) */ #define FNIC_FC_RP_FLAGS_RETRY 0x1@@ -344,6 +345,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;@@ -464,11 +466,6 @@ struct fnic {____cacheline_aligned struct vnic_intr intr[FNIC_MSIX_INTR_MAX ]; };
Quoted 8 lines
drivers/scsi/fnic/fnic.h struct fnic { · line 471
Quoted 5 lines
drivers/scsi/fnic/fnic.h +0
-5-static inline struct fnic *fnic_from_ctlr (struct fcoe_ctlr *fip) -{ - return container_of(fip, struct fnic, ctlr); -} -Unrelated.
Thanks for your comment Dan.
Since this patch is a part of a patch series, I tried to make sure
that each patch compiles independently without any compilation errors or warnings. Based on some other reviewers' comments elsewhere, if functions are not being referenced, those functions are deleted right away.
Quoted 49 lines
Quoted 36 lines
drivers/scsi/fnic/fnic.h +6
-1extern struct workqueue_struct *fnic_event_queue;extern struct workqueue_struct *fnic_fip_queue;extern const struct attribute_group *fnic_host_groups[];@@ -500,6 +497,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 );@@ -512,7 +510,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 *);@@ -541,6 +539,10 @@ 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); +int fnic_get_debug_info (struct stats_debug_info *info, +struct fnic *fnic);struct fnic_scsi_iter_data {struct fnic *fnic;drivers/scsi/fnic/fnic_attrs.c +0
-0drivers/scsi/fnic/fnic_attrs.c line 15
Quoted 7 lines
drivers/scsi/fnic/fnic_attrs.c +2
-2@@ -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)));No space after a cast. This is because casting is a high precedence operation. The newline is unnecessary.
struct fnic *fnic = *((struct fnic **)shost_priv(class_to_shost(dev)));
Quoted 7 lines
Put this stuff in a function so we don't have to open code this everywhere.
struct fnic *shost_fnic(struct
Scsi_Host*shost)
{
return *((struct fnic **)shost_priv(shost);
}
Thanks for your comment Dan. This is being referenced in only two places. I don't believe a function is necessary here.
As to the whitespaces, thanks for pointing out the --strict option. So far, I was resolving checkpatch.pl warnings and errors. I was not aware of the --strict option.
All the indentation errors and warnings that have been fixed starting from v1, were fixed using "indent -linux".
Is there a flag or any alternative to fix whitespaces and alignment issues? Please advise.
I can fix the whitespace issues in a future patch.
Quoted 11 lines
Quoted 11 lines
drivers/scsi/fnic/fnic_attrs.c +2
-1return 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)));
Quoted 9 lines
drivers/scsi/fnic/fnic_attrs.c static ssize_t fnic_show_drv_version(struct device *dev, · line 35
Quoted 5 lines
drivers/scsi/fnic/fnic_attrs.c +4
-1-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" );The white space is weird.
Quoted 1 line
drivers/scsi/fnic/fnic_attrs.c +0
-0}
Addressed above.
Quoted 9 lines
Quoted 9 lines
drivers/scsi/fnic/fnic_attrs.c +0
-0static DEVICE_ATTR(fnic_state, S_IRUGO, fnic_show_state, NULL);drivers/scsi/fnic/fnic_debugfs.c +0
-0@@ -7,6 +7,9 @@#include <linux/vmalloc.h> #include "fnic.h"
Quoted 4 lines
drivers/scsi/fnic/fnic_debugfs.c line 11
Quoted 2 lines
drivers/scsi/fnic/fnic_debugfs.c +2
-0+extern int fnic_get_debug_info (struct stats_debug_info *debug_buffer, +struct fnic *fnic);Hopefully checkpatch will catch things like this.
Addressed above.
Quoted 56 lines
Quoted 56 lines
drivers/scsi/fnic/fnic_debugfs.c +22
-1+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;
Quoted 10 lines
drivers/scsi/fnic/fnic_debugfs.c static const struct file_operations fnic_reset_debugfs_fops = { · line 721
Quoted 3 lines
drivers/scsi/fnic/fnic_debugfs.c +3
-0+ } + rc =0 ; +return rc;Ugh. Don't do "rc = 0; return rc;". But mostly all the changes to
fnic_stats_debugfs_init()are just wrong. It means that the driver cannot load ifCONFIG_DEBUGFSis disabled. The original code was correct. Debugfs is weird like that. I will send a patch to revert this.Quoted 1 line
drivers/scsi/fnic/fnic_debugfs.c +0
-0}
Thanks for your comment Dan.
I've added my reviewed-by to the patch that you sent out. Thanks for your change.
Quoted 54 lines
Quoted 54 lines
drivers/scsi/fnic/fnic_debugfs.c +0
-0/* drivers/scsi/fnic/fnic_fcs.c +16
-0@@ -63,6 +63,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;drivers/scsi/fnic/fnic_main.c +6
-1@@ -67,6 +67,11 @@ unsigned int fnic_fdmi_support = 1;module_param (fnic_fdmi_support, int,0644 );MODULE_PARM_DESC (fnic_fdmi_support,"FDMI support" ); +static 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" );@@ -146,7 +151,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,@@ -158,79 +163,79 @@ static struct fc_function_template fnic_fc_functions = {
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 166
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c +1
-1.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,This line should have been deleted. It will be initialized to zero automatically.
Thanks Dan. fnic_get_stats gets added in a subsequent patch in the series. I get your point though.
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 170
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +2
-2.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,Same. Just delete the line.
Thanks Dan.
This will be addressed in a future patch.
Quoted 58 lines
Quoted 47 lines
drivers/scsi/fnic/fnic_main.c +24
-2};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 ;drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 225
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +7
-0+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 ;
Quoted 1 line
This change could have been done in its own patch.
Thanks for your comment Dan. I understand.
Quoted 11 lines
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 234
Quoted 9 lines
drivers/scsi/fnic/fnic_main.c +3
-0default : +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 */ What does this comment mean? What is it a placeholder for?
Thanks Dan. As mentioned in the cover letter, a few functions were placed as placeholders to prevent compilation errors and warnings. I would see warnings like: Function defined but not used, or, there would be a loader error mentioning that the function was not defined. I get your point however.
Quoted 36 lines
Quoted 36 lines
drivers/scsi/fnic/fnic_main.c +0
-34static 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 ); -
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c static struct fc_function_template fnic_fc_functions = { · line 239
Quoted 3 lines
drivers/scsi/fnic/fnic_main.c +2
-0+struct fnic *fnic = *((struct fnic **)shost_priv (host)); +struct fc_host_statistics *stats = &fnic->fnic_stats.host_stats;return stats;This is a checkpatch warning because there should be a blank line after the decarations. It's a bit tricky because you will need to apply the patch and then re-run checkpatch.pl -f on the patched file to see this warning.
Thanks for pointing it out Dan. I was not aware of this.
Quoted 24 lines
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c +1
-2}@@ -311,8 +316,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;drivers/scsi/fnic/fnic_main.c static void fnic_set_vlan(struct fnic *fnic, u16 vlan_id) · line 538
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c +5
-0@@ -527,9 +531,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,The - 1 is wrong. It should be:
Quoted 4 lines
snprintf(fnic->name,
sizeof(fnic->name), "%s%d",DRV_NAME,Quoted 2 lines
drivers/scsi/fnic/fnic_main.c +2
-0+ host->host_no); +
Thanks for your comment Dan.
This will be addressed in a future patch.
Quoted 32 lines
Quoted 23 lines
drivers/scsi/fnic/fnic_main.c +8
-1+ 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 +558,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;drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 574
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +4
-0@@ -550,13 +568,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) *^^^^^^^^^^^^^^^^^^^^
Quoted 7 lines
The name of this variable is "
table_size" but apparently it is the size - 1. This is only used in debug output so just change the previous line to:fnic->sw_copy_wq[hwq].ioreq_table_size =
fnic->fnic_max_tag_id+ 1;Quoted 2 lines
drivers/scsi/fnic/fnic_main.c +2
-0+ sizeof(struct fnic_io_req *), GFP_KERNEL); + }
Thanks Dan. We will address this in a future patch.
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 579
Quoted 2 lines
drivers/scsi/fnic/fnic_main.c +2
-0+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);
dev_dbg(). This patch has a number of these debug printks which are atdev_info()levels.
Thanks Dan. We will address this in a future patch.
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 586
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c +7
-0+ +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 ;Propogate the error code. Don't return
-EPERM. Do we need to clean up the fnic->sw_copy_wq[hwq].io_req_table allocations?
Thanks Dan. We will address this in a future patch.
Quoted 17 lines
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +6
-0+ } +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);drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 602
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10
-0+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 ;
Quoted 8 lines
Just say:
fc_host_supported_speeds(fnic->lport->host)=FC_PORTSPEED_8GBIT;drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 603
Quoted 2 lines
drivers/scsi/fnic/fnic_main.c +2
-0+ +dev_info (&fnic->pdev->dev,"shost_data: 0x%p\n" , fnic->lport->host->shost_data);Delete this line.
Thanks Dan. We will address this in a future patch.
Quoted 4 lines
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 605
Quoted 2 lines
drivers/scsi/fnic/fnic_main.c +1
-0+if (fnic->lport->host->shost_data !=NULL ) {Checkpatch.
Thanks Dan. We will address this in a future patch.
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c static int fnic_scsi_drv_init(struct fnic *fnic) · line 617
Quoted 12 lines
drivers/scsi/fnic/fnic_main.c +12
-0+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);
Quoted 2 lines
Do we need to clean up the fnic->sw_copy_wq[hwq].io_req_table allocations?
Thanks Dan. We have not seen any issues so far.
We will re-examine this for a future patch.
Quoted 16 lines
Quoted 16 lines
drivers/scsi/fnic/fnic_main.c +4
-2+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 +648,27 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host)
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c void fnic_mq_map_queues_cpus(struct Scsi_Host *host) · line 651
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c +1
-2static 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 ;I can't see how this is required or related but I could be wrong.
Thanks Dan. I see your point.
Quoted 25 lines
Quoted 14 lines
drivers/scsi/fnic/fnic_main.c +1
-3struct 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 drivers/scsi/fnic/fnic_main.c void fnic_mq_map_queues_cpus(struct Scsi_Host *host) · line 668
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +4
-4+* 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;
Quoted 6 lines
This patch renames all the error labels from describing what they do, to being in ComeFrom style. In my opinion, the original names were MUCH better. I added a section on label names to the
Documentation/process/coding-style.rstfile but I wasn't going to complain about here. Except, the issue is that it's totally unrelated to FDLS and unrelated changes should have been flagged during review.
Thanks Dan. I understand.
I have reviewed the file. This can be addressed in a future patch.
Quoted 121 lines
Quoted 121 lines
drivers/scsi/fnic/fnic_main.c +17
-24} - host = lp->host; - fnic =lport_priv (lp); + iport = &fnic->iport; fnic_id =ida_alloc (&fnic_ida,GFP_KERNEL );if (fnic_id <0 ) {@@ -613,17 +676,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 +700,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 +721,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 +729,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 +740,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 +748,68 @@ 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; + } +
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 795
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +6
-0+switch (fnic->config.flags &0xff0 ) { +case VFCF_FC_INITIATOR : + { + host = +scsi_host_alloc (&fnic_host_template, +sizeof (struct fnic *));White space.
Addressed above.
Quoted 13 lines
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 806
Quoted 12 lines
drivers/scsi/fnic/fnic_main.c +11
-0+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);
Quoted 1 line
dev_dbg()
Thanks Dan. We would like to keep this as it is.
Quoted 7 lines
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 810
Quoted 5 lines
drivers/scsi/fnic/fnic_main.c +4
-0+ } +break ; +default : +dev_info (&fnic->pdev->dev,"fnic: %d has no role defined\n" , fnic->fnic_num);
dev_err()
Thanks Dan. We will address this in a future patch.
Quoted 233 lines
Quoted 208 lines
drivers/scsi/fnic/fnic_main.c +50
-86+ err = -EINVAL ; + goto err_out_fnic_role; }/* Setup PCI resources */ @@ -741,23 +821,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 +846,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 ]);@@ -810,8 +876,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_LIST_HEAD (&fnic->fip_frame_queue);@@ -823,8 +888,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 ;@@ -838,7 +901,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 */ @@ -851,80 +914,43 @@ 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; } } -/* Enable all queues */ -for (i =0 ; i < fnic->raw_wq_count; i++) -vnic_wq_enable (&fnic->wq[i]); -for (i =0 ; i < fnic->rq_count; i++) { -if (!ioread32 (&fnic->rq[i].ctrl->enable)) -vnic_rq_enable (&fnic->rq[i]); - } -for (i =0 ; i < fnic->wq_copy_count; i++) -vnic_wq_copy_enable (&fnic->hw_copy_wq[i]); +init_completion (&fnic->reset_completion_wait); - 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; - } - - -/* 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 ); +/* 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 ) - 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); - -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; - } + iport->service_params |=FNIC_FCP_SP_RETRY ; -fc_lport_init_stats (lp); - fnic->stats_reset_time = jiffies; + 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; -fc_lport_config (lp); + iport->max_payload_size = fnic->config.maxdatafieldsize; -if (fc_set_mfs (lp, fnic->config.maxdatafieldsize + -sizeof (struct fc_frame_header ))) { - err = -EINVAL ; - goto err_out_free_exch_mgr; +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 ; } -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); + iport->flags |=FNIC_FIRST_LINK_UP ; -spin_lock_irqsave (&fnic_list_lock, flags); -list_add_tail (&fnic->list, &fnic_list); -spin_unlock_irqrestore (&fnic_list_lock, flags); +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);@@ -935,71 +961,110 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)INIT_LIST_HEAD (&fnic->tx_queue);INIT_LIST_HEAD (&fnic->tport_event_list); -fc_fabric_login (lp); +INIT_DELAYED_WORK (&iport->oxid_pool.schedule_oxid_free_retry, + fdls_schedule_oxid_free_retry_work); + +/* Initialize the oxid reclaim list and work struct */ +INIT_LIST_HEAD (&iport->oxid_pool.oxid_reclaim_list); +INIT_DELAYED_WORK (&iport->oxid_pool.oxid_reclaim_work, fdls_reclaim_oxid_handler); + +/* Enable all queues */ +for (i =0 ; i < fnic->raw_wq_count; i++) +vnic_wq_enable (&fnic->wq[i]); +for (i =0 ; i < fnic->rq_count; i++) { +if (!ioread32 (&fnic->rq[i].ctrl->enable)) +vnic_rq_enable (&fnic->rq[i]); + } +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);drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 993
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c +10
-0+if (err) { +dev_err (&fnic->pdev->dev,"Unable to request irq.\n" ); + goto err_out_fnic_request_intr; + } + +fnic_notify_timer_start (fnic); + +fnic_fdls_init (fnic, (fnic->config.flags &VFCF_FIP_CAPABLE )); + +if (IS_FNIC_FCP_INITIATOR (fnic) &&fnic_scsi_drv_init (fnic))We know that
IS_FNIC_FCP_INITIATOR()is true. Presumably this is stub code which will make sense in the future. These kinds of known true stub code conditions are discouraged because we can not predict the future or review future code which we have not seen. For exmample, this call tofnic_scsi_drv_init()is cleaned up by
scsi_remove_host(fnic->lport->host);But we would expect the condition to be consistent in both the allocation code and the tear down code.
if (
IS_FNIC_FCP_INITIATOR(fnic))scsi_remove_host(lp->host);
Quoted 8 lines
In fact, ideally the tear down here would match the code in the remove function.
if (
IS_FNIC_FCP_INITIATOR(fnic))fnic_scsi_unload(fnic);Does that matter? It doesn't matter *now* but to answer that question properly depends on the future code which has not been writtten.
Thanks Dan. You are right.
As mentioned in the cover letter, we have a feature that we are planning to submit
upstream: NVME initiator.
I understand your point. This will be addressed in a future patch.
Quoted 10 lines
drivers/scsi/fnic/fnic_main.c static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · line 999
Quoted 6 lines
drivers/scsi/fnic/fnic_main.c +6
-0+ goto err_out_scsi_drv_init; + + 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;This goto frees the
fnic_stats_debugfs_init()stuff which we failed to allocate. It's harmless, but generally, we would only free resources which have been successfully allocated.
Thanks Dan. So far, we have not faced any issues w.r.t this, even while dev testing. We would like to keep this as it is.
Quoted 181 lines
Quoted 181 lines
drivers/scsi/fnic/fnic_main.c +50
-58+ } +for (i =0 ; i < fnic->intr_count; i++)vnic_intr_unmask (&fnic->intr[i]); -fnic_notify_timer_start (fnic); +spin_lock_irqsave (&fnic_list_lock, flags); +list_add_tail (&fnic->list, &fnic_list); +spin_unlock_irqrestore (&fnic_list_lock, flags);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_fnic_notify_set:mempool_destroy (fnic->frame_elem_pool); err_out_fdls_frame_elem_pool:mempool_destroy (fnic->frame_pool); err_out_fdls_frame_pool: -err_out_free_max_pool: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;/* * Sometimes when probe() fails and do not exit with an error code, @@ -1009,26 +1074,21 @@ static void fnic_remove(struct pci_dev *pdev)if (!fnic)return ; -/* -* 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);@@ -1043,19 +1103,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);/* @@ -1069,11 +1116,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);@@ -1083,8 +1128,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); }
Quoted 12 lines
drivers/scsi/fnic/fnic_main.c static void __exit fnic_cleanup_module(void) · line 1291
Quoted 9 lines
drivers/scsi/fnic/fnic_main.c +2
-1static struct pci_driver fnic_driver = {@@ -1236,8 +1286,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);I don't think this change is necessary or related. But if it is then it needs to be split into its own patch with a Fixes tag.
Thanks Dan.
We believe it is necessary to flush the frames in the fip queue before cleaning up. We would like to keep this as it is.
Quoted 12 lines
Quoted 12 lines
drivers/scsi/fnic/fnic_main.c +1
-0+ }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);drivers/scsi/fnic/fnic_res.c +0
-0@@ -58,6 +58,11 @@ int fnic_get_vnic_config(struct fnic *fnic)GET_CONFIG (intr_mode);GET_CONFIG (wq_copy_count);
Quoted 4 lines
drivers/scsi/fnic/fnic_res.c int fnic_get_vnic_config(struct fnic *fnic) · line 62
Quoted 2 lines
drivers/scsi/fnic/fnic_res.c +2
-0+if ((c->flags & (VFCF_FC_INITIATOR )) ==0 ) { +dev_info (&fnic->pdev->dev,"vNIC role not defined (def role: FC Init)\n" );
dev_dbg()perhaps? I'm not sure on this one.
Thanks Dan. This helps us catch issues exposed potentially from UCSM GUI, that we would normally not see. We would like to keep this as is.
Quoted 82 lines
Quoted 82 lines
drivers/scsi/fnic/fnic_res.c +15
-13+ 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 ; }drivers/scsi/fnic/fnic_scsi.c +26
-0@@ -1944,6 +1944,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);
Quoted 8 lines
drivers/scsi/fnic/fnic_scsi.c void fnic_terminate_rport_io(struct fc_rport *rport) · line 1978
Quoted 6 lines
drivers/scsi/fnic/fnic_scsi.c +6
-0+fnic_delete_fcp_tports (fnic); +} + +void fnic_scsi_unload_cleanup (struct fnic *fnic) +{ +int hwq =0 ;This initialization is not required.
Thanks Dan. We will address this in a future patch.
Quoted 38 lines
Quoted 38 lines
drivers/scsi/fnic/fnic_scsi.c +7
-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. drivers/scsi/fnic/fnic_stats.h +2
-0@@ -3,6 +3,7 @@ #ifndef _FNIC_STATS_H_ #define _FNIC_STATS_H_ #define FNIC_MQ_MAX_QUEUES 64 +#include <scsi/scsi_transport_fc.h> struct stats_timestamps { struct timespec64 last_reset_time;@@ -116,6 +117,7 @@ struct fnic_stats {struct reset_stats reset_stats;struct fw_stats fw_stats;struct vlan_stats vlan_stats; +struct fc_host_statistics host_stats;struct misc_stats misc_stats; };drivers/scsi/fnic/fnic_trace.c +0
-0@@ -458,6 +458,12 @@ int fnic_get_stats_data(struct stats_debug_info *debug, }
Quoted 8 lines
drivers/scsi/fnic/fnic_trace.c int fnic_get_stats_data(struct stats_debug_info *debug, · line 465
Quoted 5 lines
drivers/scsi/fnic/fnic_trace.c +5
-0+int fnic_get_debug_info (struct stats_debug_info *info,struct fnic *fnic) +{ +/* Placeholder function */ +return 0 ; +}We don't add placeholder functions. There was a better way to break this up and someone should have helped you with this.
Thanks Dan.
As mentioned above, and in our cover letter, this patch is a part of a series. Emphasis was placed on preventing compilation errors and warnings for each patch in the series, and these placeholders were added for that sake. Warnings were mentioned above.
Quoted 11 lines
regards,
dan carpenterQuoted 7 lines
drivers/scsi/fnic/fnic_trace.c +1
-1+/* * fnic_trace_buf_init - Initialize fnic trace buffer logging facility * -- 2.47.0
Thanks for taking the time in reviewing this code Dan. Appreciate your help.
Regards,
Karan
Re: [PATCH v7 11/15] scsi: fnic: Modify fnic interfaces to use FDLS
Quoted 13 lines · Karan Tilak Kumar (kartilak)
Quoted 11 lines · Dan Carpenter
drivers/scsi/fnic/fnic_main.c static void __exit fnic_cleanup_module(void) · line 1291
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c +2
-1@@ -1236,8 +1286,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);I don't think this change is necessary or related. But if it is then it needs to be split into its own patch with a Fixes tag.
Quoted 3 lines
Thanks Dan.
We believe it is necessary to flush the frames in the fip queue before cleaning up. We would like to keep this as it is.
The issue with the patch is that it should have been split up into probably five separate small patches. Each change needs to be considered on its own and explained why it's required. This flush_workqueue() change wasn't even mentioned in the commit message at all. I don't blame *you* for that because you didn't know but someone should have told you.
With regards to flush_workqueue(), I have looked some more today and the flush_workqueue() is not required so this chunk does not need to be backported to -stable kernels. But if it had been required, there is no way we could have done that with it all mixed together with other changes.
I think there is a tool out somewhere which complains about code like this because I've seen a lot of patches removing the extra call to flush_workqueue().
97d26ae764a4 ("bcache: remove unnecessary flush_workqueue") fb4b9685779f ("EDAC/wq: Remove unneeded flush_workqueue()") d81c7cdd7a6d ("net/tls: Remove redundant workqueue flush before destroy") etc..
regards,
dan carpenter
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v7 11/15] scsi: fnic: Modify fnic interfaces to use FDLS
Quoted 35 lines · Dan Carpenter
Quoted 13 lines · Karan Tilak Kumar (kartilak)
Quoted 11 lines · Dan Carpenter
drivers/scsi/fnic/fnic_main.c static void __exit fnic_cleanup_module(void) · line 1291
Quoted 8 lines
drivers/scsi/fnic/fnic_main.c +2
-1@@ -1236,8 +1286,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);I don't think this change is necessary or related. But if it is then it needs to be split into its own patch with a Fixes tag.
Quoted 3 lines
Thanks Dan.
We believe it is necessary to flush the frames in the fip queue before cleaning up. We would like to keep this as it is.The issue with the patch is that it should have been split up into probably five separate small patches. Each change needs to be considered on its own and explained why it's required. This
flush_workqueue()change wasn't even mentioned in the commit message at all. I don't blame *you* for that because you didn't know but someone should have told you.With regards to
flush_workqueue(), I have looked some more today and theflush_workqueue()is not required so this chunk does not need to be backported to -stable kernels. But if it had been required, there is no way we could have done that with it all mixed together with other changes.I think there is a tool out somewhere which complains about code like this because I've seen a lot of patches removing the extra call to
flush_workqueue().
Quoted 8 lines
97d26ae764a4("bcache: remove unnecessaryflush_workqueue")fb4b9685779f("EDAC/wq: Remove unneededflush_workqueue()")d81c7cdd7a6d("net/tls: Remove redundant workqueue flush before destroy") etc..regards,
dan carpenter
Thanks for those references, Dan. Appreciate you taking the time to dig them up. The Cisco team will review this information.
Regards,
Karan
Karan Tilak Kumar
maintainerPATCH v7 12/15 scsi: fnic: Add stats and related functionality
In reply to Karan Tilak KumarAdd statistics and related functionality for FDLS. Add supporting functions to display stats.
----
Changes between v2 and v3:
Replace fnic->host with fnic->lport->host to prevent compilation
errors.
---
drivers/scsi/fnic/fdls_disc.c | 32 +++++++++++++-
drivers/scsi/fnic/fnic_fdls.h | 6 ++-
drivers/scsi/fnic/fnic_main.c | 34 ++++++++++++++-
drivers/scsi/fnic/fnic_scsi.c | 19 +++++++-
drivers/scsi/fnic/fnic_stats.h | 45 ++++++++++++++++++-
drivers/scsi/fnic/fnic_trace.c | 79 +++++++++++++++++++++++++++++-----
6 files changed, 196 insertions(+), 19 deletions(-)drivers/scsi/fnic/fdls_disc.c +30 -2
@@ -877,6 +877,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) oxid);fnic_send_fcoe_frame (iport, frame, frame_size); +atomic64_inc (&iport->iport_stats.fabric_flogi_sent); err_out:/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ fdls_start_fabric_timer (iport,2 * iport->e_d_tov);
@@ -919,6 +920,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) oxid);fnic_send_fcoe_frame (iport, frame, frame_size); +atomic64_inc (&iport->iport_stats.fabric_plogi_sent); err_out:/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */
@@ -1080,6 +1082,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) oxid);fnic_send_fcoe_frame (iport, frame, frame_size); +atomic64_inc (&iport->iport_stats.fabric_scr_sent); err_out:/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */
@@ -1201,6 +1204,8 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport)"0x%x: FDLS send ADISC to tgt fcid: 0x%x" , iport->fcid, tport->fcid); +atomic64_inc (&iport->iport_stats.tport_adisc_sent); +fnic_send_fcoe_frame (iport, frame, frame_size); err_out:
@@ -1310,6 +1315,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) iport->fcid, tport->fcid, oxid);fnic_send_fcoe_frame (iport, frame, frame_size); +atomic64_inc (&iport->iport_stats.tport_plogi_sent); err_out: timeout =max (2 * iport->e_d_tov, iport->plogi_timeout);
@@ -1515,6 +1521,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) iport->fcid, tport->fcid, oxid);fnic_send_fcoe_frame (iport, frame, frame_size); +atomic64_inc (&iport->iport_stats.tport_prli_sent); err_out: timeout =max (2 * iport->e_d_tov, iport->plogi_timeout);
@@ -1626,6 +1633,8 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) iport->fcid, oxid);fnic_send_fcoe_frame (iport, frame, frame_size); + +atomic64_inc (&iport->iport_stats.tport_logo_sent); }static void fdls_tgt_discovery_start (struct fnic_iport_s *iport)
@@ -2515,6 +2524,7 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,switch (adisc_rsp->els.adisc_cmd) {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, "tport 0x%p Canceling fabric disc timer\n",
@@ -2537,6 +2547,7 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,break ;case ELS_LS_RJT : +atomic64_inc (&iport->iport_stats.tport_adisc_ls_rejects);if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (tport->retry_counter <FDLS_RETRY_COUNT )) {
@@ -2608,11 +2619,13 @@ 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,"PLOGI accepted by target: 0x%x" , tgt_fcid);break ;case ELS_LS_RJT : +atomic64_inc (&iport->iport_stats.tport_plogi_ls_rejects);if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (tport->retry_counter < iport->max_plogi_retries)) {
@@ -2630,6 +2643,7 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport,return ;default : +atomic64_inc (&iport->iport_stats.tport_plogi_misc_rejects);FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"PLOGI not accepted from target fcid: 0x%x" , tgt_fcid);
@@ -2733,6 +2747,7 @@ 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,"PRLI accepted from target: 0x%x" , tgt_fcid);
@@ -2749,6 +2764,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, }break ;case ELS_LS_RJT : +atomic64_inc (&iport->iport_stats.tport_prli_ls_rejects);if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (tport->retry_counter <FDLS_RETRY_COUNT )) {
@@ -2772,6 +2788,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport,break ;default : +atomic64_inc (&iport->iport_stats.tport_prli_misc_rejects);FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"PRLI not accepted from target: 0x%x" , tgt_fcid);return ;
@@ -3075,6 +3092,7 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,switch (scr_rsp->scr.scr_cmd) {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,"Canceling fabric disc timer %p\n" , iport);
@@ -3086,7 +3104,7 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,break ;case ELS_LS_RJT : - +atomic64_inc (&iport->iport_stats.fabric_scr_ls_rejects);if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (fdls->retry_counter <FDLS_RETRY_COUNT )) {
@@ -3111,6 +3129,7 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,break ;default : +atomic64_inc (&iport->iport_stats.fabric_scr_misc_rejects);break ; } }
@@ -3434,6 +3453,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,switch (flogi_rsp->els.fl_cmd) {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, "iport fcid: 0x%x Canceling fabric disc timer\n",
@@ -3507,6 +3527,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,break ;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, "FLOGI returned ELS_LS_RJT BUSY. Retry from timer routine %p",
@@ -3534,6 +3555,7 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"FLOGI response not accepted: 0x%x" , flogi_rsp->els.fl_cmd); +atomic64_inc (&iport->iport_stats.fabric_flogi_misc_rejects);break ; } }
@@ -3564,6 +3586,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,switch (plogi_rsp->els.fl_cmd) {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, "iport fcid: 0x%x fabric PLOGI response: Accepted\n",
@@ -3576,7 +3599,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,fdls_send_rpn_id (iport);break ;case ELS_LS_RJT : - +atomic64_inc (&iport->iport_stats.fabric_plogi_ls_rejects);if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->rej.er_reason ==ELS_RJT_UNAB )) && (iport->fabric.retry_counter < iport->max_plogi_retries)) {
@@ -3602,6 +3625,7 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"PLOGI response not accepted: 0x%x" , plogi_rsp->els.fl_cmd); +atomic64_inc (&iport->iport_stats.fabric_plogi_misc_rejects);break ; } }
@@ -3945,6 +3969,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport,FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"Dropping unsupported ELS with illegal frame bits 0x%x\n" , d_id); +atomic64_inc (&iport->iport_stats.unsupported_frames_dropped);return ; }
@@ -3953,6 +3978,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport,FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"Dropping unsupported ELS request in iport state: %d" , iport->state); +atomic64_inc (&iport->iport_stats.unsupported_frames_dropped);return ; }
@@ -4381,6 +4407,8 @@ fdls_process_rscn(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)struct fnic *fnic = iport->fnic;uint16_t rscn_payload_len; +atomic64_inc (&iport->iport_stats.num_rscns); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num,"FDLS process RSCN %p" , iport);
drivers/scsi/fnic/fnic_fdls.h +4 -2
@@ -305,10 +305,12 @@ struct fnic_iport_s {uint16_t max_payload_size;spinlock_t deleted_tport_lst_lock;struct completion *flogi_reg_done; +struct fnic_iport_stats iport_stats;char str_wwpn[20 ];char str_wwnn[20 ]; - }; -struct rport_dd_data_s { +}; + +struct rport_dd_data_s {struct fnic_tport_s *tport;struct fnic_iport_s *iport; };
drivers/scsi/fnic/fnic_main.c +33 -1
@@ -163,7 +163,7 @@ 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 = NULL, + .get_fc_host_stats = fnic_get_stats, .reset_fc_host_stats = fnic_reset_host_stats, .dd_fcrport_size = sizeof(struct rport_dd_data_s), .terminate_rport_io = fnic_terminate_rport_io,
@@ -174,9 +174,11 @@ static void fnic_get_host_speed(struct Scsi_Host *shost) {struct fnic *fnic = *((struct fnic **)shost_priv (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,"port_speed: %d Mbps" , port_speed); +atomic64_set (&fnic_stats->misc_stats.port_speed_in_mbps, port_speed);/* Add in other values as they get defined in fw */ switch (port_speed) {
@@ -234,8 +236,38 @@ static void fnic_get_host_speed(struct Scsi_Host *shost)/* Placeholder function */ static struct fc_host_statistics *fnic_get_stats (struct Scsi_Host *host) { +int ret;struct fnic *fnic = *((struct fnic **)shost_priv (host));struct fc_host_statistics *stats = &fnic->fnic_stats.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 );return stats; }
drivers/scsi/fnic/fnic_scsi.c +17 -2
@@ -490,6 +490,7 @@ int fnic_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc)if (ret) {FNIC_SCSI_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num,"rport is not ready\n" ); +atomic64_inc (&fnic_stats->misc_stats.tport_not_ready); sc->result = ret;done (sc);return 0 ;
@@ -1128,6 +1129,15 @@ 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_stats->host_stats.fcp_input_requests++; + fnic->fcp_input_bytes += xfer_len; + }else if (sc->sc_data_direction ==DMA_TO_DEVICE ) { + fnic_stats->host_stats.fcp_output_requests++; + fnic->fcp_output_bytes += xfer_len; + }else + fnic_stats->host_stats.fcp_control_requests++; +/* Call SCSI completion function to complete the IO */ scsi_done (sc);
@@ -1977,8 +1987,8 @@ void fnic_scsi_unload_cleanup(struct fnic *fnic) {int hwq =0 ; -fc_remove_host (fnic->host); -scsi_remove_host (fnic->host); +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); }
@@ -2057,6 +2067,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc) 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,"iport NOT in READY state" ); ret =FAILED ;
@@ -2140,6 +2151,7 @@ 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.tport_not_ready); task_req =FCPIO_ITMF_ABT_TASK_TERM ; }
@@ -2577,6 +2589,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,"iport NOT in READY state" );spin_unlock_irqrestore (&fnic->fnic_lock, flags);
@@ -2594,6 +2607,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)/* Check if remote port up */ if (fc_remote_port_chkready (rport)) { +atomic64_inc (&fnic_stats->misc_stats.tport_not_ready); goto fnic_device_reset_end; }
@@ -3071,6 +3085,7 @@ void fnic_scsi_fcpio_reset(struct fnic *fnic)"FW reset completion timed out after %d ms)\n" , FNIC_FW_RESET_TIMEOUT); } +atomic64_inc (&fnic->fnic_stats.reset_stats.fw_reset_timeouts); } fnic->fw_reset_done =NULL ; }
drivers/scsi/fnic/fnic_stats.h +44 -1
64 lines not on this page · raw message
drivers/scsi/fnic/fnic_trace.c +68 -11
115 lines not on this page · raw message
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 13/15 scsi: fnic: Code cleanup
In reply to Karan Tilak KumarReplace existing host structure with fnic host. Add headers from scsi to support new functionality. Remove unused code and declarations.
---
Changes between v5 and v6:
Replace additional fnic->lport->host with fnic->host to prevent compilation errors.
Incorporate review comments from Hannes:
Refactor fnic_transport_template into another patch.
Changes between v2 and v3:
Replace additional fnic->lport->host with fnic->host to prevent
compilation errors.
---
drivers/scsi/fnic/fdls_disc.c | 664 +++++++++++++++----------------
drivers/scsi/fnic/fip.c | 92 ++---
drivers/scsi/fnic/fip.h | 2 +-
drivers/scsi/fnic/fnic.h | 13 +-
drivers/scsi/fnic/fnic_debugfs.c | 2 +-
drivers/scsi/fnic/fnic_fcs.c | 125 +++---
drivers/scsi/fnic/fnic_isr.c | 28 +-
drivers/scsi/fnic/fnic_main.c | 67 ++--
drivers/scsi/fnic/fnic_scsi.c | 241 +++++------
9 files changed, 611 insertions(+), 623 deletions(-)drivers/scsi/fnic/fdls_disc.c +332 -332
@@ -104,7 +104,7 @@ uint8_t *fdls_alloc_frame(struct fnic_iport_s *iport) frame =mempool_alloc (fnic->frame_pool,GFP_ATOMIC );if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame" );return NULL ; }
@@ -136,7 +136,7 @@ uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, int oxid_frame_type,*/ idx =find_next_zero_bit (oxid_pool->bitmap,FNIC_OXID_POOL_SZ , oxid_pool->next_idx);if (idx ==FNIC_OXID_POOL_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 FNIC_UNASSIGNED_OXID ;
@@ -148,7 +148,7 @@ uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport, int oxid_frame_type, oxid =FNIC_OXID_ENCODE (idx, oxid_frame_type); *active_oxid = oxid; -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"alloc oxid: 0x%x, iport state: %d\n" , oxid, iport->state);return oxid;
@@ -169,7 +169,7 @@ static void fdls_free_oxid_idx(struct fnic_iport_s *iport, uint16_t oxid_idx)lockdep_assert_held (&fnic->fnic_lock); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"free oxid idx: 0x%x\n" , oxid_idx);WARN_ON (!test_and_clear_bit (oxid_idx, oxid_pool->bitmap));
@@ -194,7 +194,7 @@ void fdls_reclaim_oxid_handler(struct work_struct *work)struct reclaim_entry_s *reclaim_entry, *next;unsigned long delay_j, cur_jiffies; -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Reclaim oxid callback\n" );spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);
@@ -223,7 +223,7 @@ void fdls_reclaim_oxid_handler(struct work_struct *work) delay_j = reclaim_entry->expires - cur_jiffies;schedule_delayed_work (&oxid_pool->oxid_reclaim_work, delay_j); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Scheduling next callback at:%ld jiffies\n" , delay_j); }
@@ -266,7 +266,7 @@ void fdls_schedule_oxid_free(struct fnic_iport_s *iport, uint16_t *active_oxid)lockdep_assert_held (&fnic->fnic_lock); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Schedule oxid free. oxid: 0x%x\n" , *active_oxid); *active_oxid =FNIC_UNASSIGNED_OXID ;
@@ -275,7 +275,7 @@ void fdls_schedule_oxid_free(struct fnic_iport_s *iport, uint16_t *active_oxid)kzalloc (sizeof (struct reclaim_entry_s ),GFP_ATOMIC );if (!reclaim_entry) { -FNIC_FCS_DBG (KERN_WARNING , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_WARNING , fnic->host, fnic->fnic_num,"Failed to allocate memory for reclaim struct for oxid idx: %d\n" , oxid_idx);
@@ -314,7 +314,7 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)for_each_set_bit (idx, oxid_pool->pending_schedule_free,FNIC_OXID_POOL_SZ ) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Schedule oxid free. oxid idx: %d\n" , idx);spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags);
@@ -323,7 +323,7 @@ void fdls_schedule_oxid_free_retry_work(struct work_struct *work)spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);if (!reclaim_entry) { -FNIC_FCS_DBG (KERN_WARNING , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_WARNING , fnic->host, fnic->fnic_num,"Failed to allocate memory for reclaim struct for oxid idx: 0x%x\n" , idx);
@@ -430,7 +430,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);
@@ -443,7 +443,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); }
@@ -455,7 +455,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);
@@ -589,7 +589,7 @@ fdls_send_rscn_resp(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send RSCN response" );return ; }
@@ -602,7 +602,7 @@ fdls_send_rscn_resp(struct fnic_iport_s *iport, oxid =FNIC_STD_GET_OX_ID (rscn_fchdr);FNIC_STD_SET_OX_ID (pels_acc->fchdr, 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 RSCN response with oxid: 0x%x" , iport->fcid, oxid);
@@ -622,7 +622,7 @@ fdls_send_logo_resp(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send LOGO response" );return ; }
@@ -635,7 +635,7 @@ fdls_send_logo_resp(struct fnic_iport_s *iport, oxid =FNIC_STD_GET_OX_ID (req_fchdr);FNIC_STD_SET_OX_ID (plogo_resp->fchdr, 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 LOGO response with oxid: 0x%x" , iport->fcid, oxid);
@@ -656,7 +656,7 @@ fdls_send_tport_abts(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send tport ABTS" );return ; }
@@ -679,7 +679,7 @@ fdls_send_tport_abts(struct fnic_iport_s *iport,FNIC_STD_SET_OX_ID (*ptport_abts, tport->active_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 tport abts: tport->state: %d " , iport->fcid, tport->state);
@@ -701,7 +701,7 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send fabric ABTS" );return ; }
@@ -764,7 +764,7 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) oxid = iport->active_oxid_fabric_req;FNIC_STD_SET_OX_ID (*pfabric_abts, 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 abts. iport->fabric.state: %d oxid: 0x%x" , iport->fcid, iport->fabric.state, oxid);
@@ -790,7 +790,7 @@ static void fdls_send_fdmi_abts(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send FDMI ABTS" );return ; }
@@ -834,7 +834,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send FLOGI" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -863,7 +863,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 FLOGI" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -872,7 +872,7 @@ static void fdls_send_fabric_flogi(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (pflogi->fchdr, 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: 0x%x" , iport->fcid, oxid);
@@ -894,7 +894,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send PLOGI" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -906,7 +906,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FABRIC_PLOGI , &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 fabric PLOGI" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -915,7 +915,7 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (pplogi->fchdr, 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: 0x%x" , iport->fcid, oxid);
@@ -940,7 +940,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send FDMI PLOGI" ); goto err_out; }
@@ -952,7 +952,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport) &iport->active_oxid_fdmi_plogi);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 FDMI PLOGI" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -963,7 +963,7 @@ static void fdls_send_fdmi_plogi(struct fnic_iport_s *iport)hton24 (d_id,FC_FID_MGMT_SERV );FNIC_STD_SET_D_ID (pplogi->fchdr, d_id); -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 FDMI PLOGI with oxid: 0x%x" , iport->fcid, oxid);
@@ -987,7 +987,7 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send RPN_ID" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1014,7 +1014,7 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 RPN_ID" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1023,7 +1023,7 @@ static void fdls_send_rpn_id(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (prpn_id->fchdr, 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: 0x%x" , iport->fcid, oxid);
@@ -1046,7 +1046,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send SCR" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1068,7 +1068,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_FABRIC_SCR , &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 SCR" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1077,7 +1077,7 @@ static void fdls_send_scr(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (pscr->fchdr, 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: 0x%x" , iport->fcid, oxid);
@@ -1101,7 +1101,7 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send GPN FT" ); iport->fabric.flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1126,7 +1126,7 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 GPN FT" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1135,7 +1135,7 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) }FNIC_STD_SET_OX_ID (pgpn_ft->fchdr, 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: 0x%x" , iport->fcid, oxid);
@@ -1161,7 +1161,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send TGT ADISC" ); tport->flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1181,7 +1181,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_ADISC , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 TGT ADISC" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1200,7 +1200,7 @@ fdls_send_tgt_adisc(struct fnic_iport_s *iport, struct fnic_tport_s *tport) padisc->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,"0x%x: FDLS send ADISC to tgt fcid: 0x%x" , iport->fcid, tport->fcid);
@@ -1220,7 +1220,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;
@@ -1235,7 +1235,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);
@@ -1251,7 +1251,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;
@@ -1261,7 +1261,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);
@@ -1285,7 +1285,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send TGT PLOGI" ); tport->flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1296,7 +1296,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_PLOGI , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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);mempool_free (frame, fnic->frame_pool);
@@ -1310,7 +1310,7 @@ fdls_send_tgt_plogi(struct fnic_iport_s *iport, struct fnic_tport_s *tport)hton24 (d_id, tport->fcid);FNIC_STD_SET_D_ID (pplogi->fchdr, d_id); -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 tgt PLOGI to tgt: 0x%x with oxid: 0x%x" , iport->fcid, tport->fcid, oxid);
@@ -1333,7 +1333,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);
@@ -1352,7 +1352,7 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send RFT" );return ; }
@@ -1376,7 +1376,7 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 RFT" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1384,7 +1384,7 @@ static void fdls_send_register_fc4_types(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (prft_id->fchdr, 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 RFT with oxid: 0x%x" , iport->fcid, oxid);
@@ -1413,7 +1413,7 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send RFF" );return ; }
@@ -1439,7 +1439,7 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 RFF" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1447,14 +1447,14 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) }FNIC_STD_SET_OX_ID (prff_id->fchdr, 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 RFF with oxid: 0x%x" , iport->fcid, oxid);if (IS_FNIC_FCP_INITIATOR (fnic)) { prff_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); }
@@ -1479,7 +1479,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send TGT PRLI" ); tport->flags |=FNIC_FDLS_RETRY_FRAME ; goto err_out;
@@ -1499,7 +1499,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_PRLI , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"0x%x: Failed to allocate OXID to send TGT PRLI to 0x%x" , iport->fcid, tport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1516,7 +1516,7 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport)FNIC_STD_SET_S_ID (pprli->fchdr, s_id);FNIC_STD_SET_D_ID (pprli->fchdr, d_id); -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 PRLI to tgt: 0x%x with oxid: 0x%x" , iport->fcid, tport->fcid, oxid);
@@ -1550,7 +1550,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send fabric LOGO" );return ; }
@@ -1562,7 +1562,7 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport) &iport->active_oxid_fabric_req);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 fabric LOGO" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1575,7 +1575,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,"0x%x: FDLS send fabric LOGO with oxid: 0x%x" , iport->fcid, oxid);
@@ -1607,7 +1607,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send fabric LOGO" );return ; }
@@ -1617,7 +1617,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport) oxid =fdls_alloc_oxid (iport,FNIC_FRAME_TYPE_TGT_LOGO , &tport->active_oxid);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 tgt LOGO" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1628,7 +1628,7 @@ void fdls_tgt_logout(struct fnic_iport_s *iport, struct fnic_tport_s *tport)hton24 (d_id, tport->fcid);FNIC_STD_SET_D_ID (plogo->fchdr, d_id); -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 tgt LOGO with oxid: 0x%x" , iport->fcid, oxid);
@@ -1643,7 +1643,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) {
@@ -1697,7 +1697,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);
@@ -1707,13 +1707,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 ;
@@ -1730,7 +1730,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 ; }
@@ -1759,12 +1759,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 ;
@@ -1777,12 +1777,12 @@ static struct fnic_tport_s *fdls_create_tport(struct fnic_iport_s *iport, tport->wwpn = wwpn; tport->iport = iport; -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_DEBUG , 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);
@@ -1833,7 +1833,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send FDMI RHBA" );return ; }
@@ -1861,7 +1861,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) &iport->active_oxid_fdmi_rhba);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 FDMI RHBA" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -1882,14 +1882,14 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_NODE_NAME ,FNIC_FDMI_NN_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"NN set, off=%d" , attr_off_bytes);strscpy_pad (data,FNIC_FDMI_MANUFACTURER ,FNIC_FDMI_MANU_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MANUFACTURER ,FNIC_FDMI_MANU_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"MFG set <%s>, off=%d" , data, attr_off_bytes); err =vnic_dev_fw_info (fnic->vdev, &fw_info);
@@ -1898,7 +1898,7 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport) FNIC_FDMI_SERIAL_LEN);fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_SERIAL_NUMBER ,FNIC_FDMI_SERIAL_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"SERIAL set <%s>, off=%d" , data, attr_off_bytes); }
@@ -1910,21 +1910,21 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MODEL ,FNIC_FDMI_MODEL_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"MODEL set <%s>, off=%d" , data, attr_off_bytes);strscpy_pad (data,FNIC_FDMI_MODEL_DESCRIPTION ,FNIC_FDMI_MODEL_DES_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_MODEL_DES ,FNIC_FDMI_MODEL_DES_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"MODEL_DESC set <%s>, off=%d" , data, attr_off_bytes);if (!err) {strscpy_pad (data, fw_info->hw_version,FNIC_FDMI_HW_VER_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_HARDWARE_VERSION ,FNIC_FDMI_HW_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"HW_VER set <%s>, off=%d" , data, attr_off_bytes); }
@@ -1933,14 +1933,14 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_DRIVER_VERSION ,FNIC_FDMI_DR_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"DRV_VER set <%s>, off=%d" , data, attr_off_bytes);strscpy_pad (data,"N/A" ,FNIC_FDMI_ROM_VER_LEN );fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_ROM_VERSION ,FNIC_FDMI_ROM_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"ROM_VER set <%s>, off=%d" , data, attr_off_bytes);if (!err) {
@@ -1948,14 +1948,14 @@ static void fdls_fdmi_register_hba(struct fnic_iport_s *iport)fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_FIRMWARE_VERSION ,FNIC_FDMI_FW_VER_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"FW_VER set <%s>, off=%d" , data, attr_off_bytes); } len =sizeof (struct fc_std_fdmi_rhba ) + attr_off_bytes; frame_size += len; -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 FDMI RHBA with oxid: 0x%x fs: %d" , iport->fcid, oxid, frame_size);
@@ -1979,7 +1979,7 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send FDMI RPA" );return ; }
@@ -2007,7 +2007,7 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) &iport->active_oxid_fdmi_rpa);if (oxid ==FNIC_UNASSIGNED_OXID ) { -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 FDMI RPA" , iport->fcid);mempool_free (frame, fnic->frame_pool);
@@ -2067,29 +2067,29 @@ static void fdls_fdmi_register_pa(struct fnic_iport_s *iport) FNIC_FDMI_MFS_LEN, data, &attr_off_bytes);snprintf (tmp_data,FNIC_FDMI_OS_NAME_LEN -1 ,"host%d" , - fnic->lport->host->host_no); + fnic->host->host_no);strscpy_pad (data, tmp_data,FNIC_FDMI_OS_NAME_LEN ); data[FNIC_FDMI_OS_NAME_LEN -1 ] =0 ;fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_OS_NAME ,FNIC_FDMI_OS_NAME_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"OS name set <%s>, off=%d" , data, attr_off_bytes); -sprintf (fc_host_system_hostname (fnic->lport->host),"%s" ,utsname ()->nodename); -strscpy_pad (data,fc_host_system_hostname (fnic->lport->host), +sprintf (fc_host_system_hostname (fnic->host),"%s" ,utsname ()->nodename); +strscpy_pad (data,fc_host_system_hostname (fnic->host),FNIC_FDMI_HN_LEN ); data[FNIC_FDMI_HN_LEN -1 ] =0 ;fnic_fdmi_attr_set (fdmi_attr,FNIC_FDMI_TYPE_HOST_NAME ,FNIC_FDMI_HN_LEN , data, &attr_off_bytes); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Host name set <%s>, off=%d" , data, attr_off_bytes); len =sizeof (struct fc_std_fdmi_rpa ) + attr_off_bytes; frame_size += len; -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 FDMI RPA with oxid: 0x%x fs: %d" , iport->fcid, oxid, frame_size);
@@ -2105,7 +2105,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);
@@ -2120,7 +2120,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 ;
@@ -2148,7 +2148,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 ;
@@ -2170,7 +2170,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 ;
@@ -2201,7 +2201,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)else {/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req); -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); }
@@ -2218,7 +2218,7 @@ void fdls_fabric_timer_callback(struct timer_list *t) }else {/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req); -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 */ }
@@ -2235,7 +2235,7 @@ void fdls_fabric_timer_callback(struct timer_list *t)else {/* ABTS has timed out */ fdls_schedule_oxid_free (iport, &iport->active_oxid_fabric_req); -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 */ }
@@ -2257,7 +2257,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); }
@@ -2279,7 +2279,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t)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,"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending);if (!iport->fabric.fdmi_pending) {
@@ -2287,7 +2287,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t)spin_unlock_irqrestore (&fnic->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,"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending);/* if not abort pending, send an abort */
@@ -2296,7 +2296,7 @@ void fdls_fdmi_timer_callback(struct timer_list *t)spin_unlock_irqrestore (&fnic->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,"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending);/* ABTS pending for an active fdmi request that is pending.
@@ -2311,18 +2311,18 @@ void fdls_fdmi_timer_callback(struct timer_list *t)if (iport->fabric.fdmi_pending &FDLS_FDMI_RPA_PENDING )fdls_schedule_oxid_free (iport, &iport->active_oxid_fdmi_rpa); } -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending); 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, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"retry fdmi timer %d" , iport->fabric.fdmi_retry);fdls_send_fdmi_plogi (iport); } -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"fdmi timer callback : 0x%x\n" , iport->fabric.fdmi_pending);spin_unlock_irqrestore (&fnic->fnic_lock, flags); }
@@ -2338,7 +2338,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 ;
@@ -2371,13 +2371,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);
@@ -2438,14 +2438,14 @@ static void fdls_tport_timer_callback(struct timer_list *t) }else {/* exceeded retry count */ fdls_schedule_oxid_free (iport, &tport->active_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,"oxid: 0x%x Unknown tport state: 0x%x" , oxid, tport->state);break ; }
@@ -2495,26 +2495,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 (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { -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 ; }
@@ -2526,7 +2526,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);
@@ -2536,12 +2536,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 ;
@@ -2551,14 +2551,14 @@ fdls_process_tgt_adisc_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->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);
@@ -2582,33 +2582,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 (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { -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 ;
@@ -2620,7 +2620,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 ;
@@ -2629,14 +2629,14 @@ fdls_process_tgt_plogi_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->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);
@@ -2644,18 +2644,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);
@@ -2673,13 +2673,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: %u iport max_payload_size: %d tport mfs: %d" , max_payload_size, iport->max_payload_size, tport->max_payload_size);
@@ -2707,12 +2707,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 ;
@@ -2720,24 +2720,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 (FNIC_STD_GET_OX_ID (fchdr) != tport->active_oxid) { -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 ; }
@@ -2748,11 +2748,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;
@@ -2769,7 +2769,7 @@ fdls_process_tgt_prli_rsp(struct fnic_iport_s *iport, || (els_rjt->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);
@@ -2777,7 +2777,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);
@@ -2789,18 +2789,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);
@@ -2816,7 +2816,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);
@@ -2829,14 +2829,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);
@@ -2856,21 +2856,21 @@ fdls_process_rff_id_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);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);
@@ -2879,7 +2879,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); }
@@ -2893,18 +2893,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); }
@@ -2929,14 +2929,14 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);return ;
@@ -2944,7 +2944,7 @@ fdls_process_rft_id_rsp(struct fnic_iport_s *iport, 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);
@@ -2953,7 +2953,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); }
@@ -2967,19 +2967,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); }
@@ -3004,20 +3004,20 @@ fdls_process_rpn_id_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);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);fdls_free_oxid (iport, oxid, &iport->active_oxid_fabric_req);
@@ -3025,7 +3025,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); }
@@ -3039,17 +3039,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); }
@@ -3072,18 +3072,18 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;uint16_t oxid =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,"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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req); }
@@ -3094,7 +3094,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); }
@@ -3108,17 +3108,17 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->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);
@@ -3146,7 +3146,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 =
@@ -3160,7 +3160,7 @@ fdls_process_gpn_ft_tgt_list(struct fnic_iport_s *iport, fcid =ntoh24 (gpn_ft_tgt->fcid); wwpn =be64_to_cpu (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) {
@@ -3207,7 +3207,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); }
@@ -3217,7 +3217,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);
@@ -3246,7 +3246,7 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;uint16_t oxid =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,"FDLS process GPN_FT response: iport state: %d len: %d" , iport->state, len);
@@ -3266,14 +3266,14 @@ 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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req); }
@@ -3286,10 +3286,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);
@@ -3304,7 +3304,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 ;
@@ -3314,22 +3314,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);
@@ -3343,7 +3343,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);
@@ -3353,7 +3353,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 ;
@@ -3378,7 +3378,7 @@ fdls_process_fabric_logo_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req); }
@@ -3387,7 +3387,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 ;
@@ -3397,25 +3397,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); }
@@ -3433,17 +3433,17 @@ fdls_process_flogi_rsp(struct fnic_iport_s *iport,struct fnic *fnic = iport->fnic;uint16_t oxid =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,"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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fabric), oxid, iport->active_oxid_fabric_req);return ;
@@ -3455,7 +3455,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);
@@ -3465,7 +3465,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 */
@@ -3475,7 +3475,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: %u set: %d" , rdf_size, iport->max_payload_size);
@@ -3485,26 +3485,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 ]);
@@ -3512,7 +3512,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
@@ -3520,7 +3520,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)); }
@@ -3529,7 +3529,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);
@@ -3537,11 +3537,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);
@@ -3552,7 +3552,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);
@@ -3571,13 +3571,13 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);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 ; }if (iport->active_oxid_fabric_req != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fabric_req);return ;
@@ -3588,7 +3588,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);
@@ -3603,15 +3603,15 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport,if (((els_rjt->rej.er_reason ==ELS_RJT_BUSY ) || (els_rjt->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);
@@ -3622,7 +3622,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);
@@ -3641,7 +3641,7 @@ static void fdls_process_fdmi_plogi_rsp(struct fnic_iport_s *iport,uint16_t oxid =FNIC_STD_GET_OX_ID (fchdr);if (iport->active_oxid_fdmi_plogi != oxid) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. state: %d, oxid recvd: 0x%x, active oxid: 0x%x\n" ,fdls_get_state (fdls), oxid, iport->active_oxid_fdmi_plogi);return ;
@@ -3655,9 +3655,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);
@@ -3668,7 +3668,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->rej.er_reason);
@@ -3692,7 +3692,7 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,uint16_t oxid;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: 0x%x\n" ,FNIC_STD_GET_OX_ID (fchdr));return ;
@@ -3702,7 +3702,7 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,if ((iport->active_oxid_fdmi_rhba != oxid) && (iport->active_oxid_fdmi_rpa != oxid)) { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Incorrect OXID in response. oxid recvd: 0x%x, active oxids(rhba,rpa): 0x%x, 0x%x\n" , oxid, iport->active_oxid_fdmi_rhba, iport->active_oxid_fdmi_rpa);return ;
@@ -3715,13 +3715,13 @@ static void fdls_process_fdmi_reg_ack(struct fnic_iport_s *iport,fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa); } -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); }
@@ -3737,7 +3737,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 !=FC_FID_MGMT_SERV )) { -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 ;
@@ -3756,7 +3756,7 @@ static void fdls_process_fdmi_abts_rsp(struct fnic_iport_s *iport,fdls_free_oxid (iport, oxid, &iport->active_oxid_fdmi_rpa);break ;default : -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 oxid: 0x%x. Dropping frame" , oxid);break ;
@@ -3785,7 +3785,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,if (!((s_id ==FC_FID_DIR_SERV ) || (s_id ==FC_FID_FLOGI ) || (s_id ==FC_FID_FCTRL ))) { -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 ;
@@ -3793,14 +3793,14 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, oxid =FNIC_STD_GET_OX_ID (fchdr);if (iport->active_oxid_fabric_req != oxid) { -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 oxid: 0x%x. Dropping frame" , oxid);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); }
@@ -3808,11 +3808,11 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ;if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -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 ==FC_RCTL_BA_RJT ) { -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,FNIC_STD_GET_OX_ID (&ba_rjt->fchdr), ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -3827,7 +3827,7 @@ 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" );break ;case FNIC_FRAME_TYPE_FABRIC_LOGO :
@@ -3838,7 +3838,7 @@ 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" );break ;case FNIC_FRAME_TYPE_FABRIC_RPN :
@@ -3852,7 +3852,7 @@ 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,"SCR exhausted retries. Start fabric PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */
@@ -3862,7 +3862,7 @@ 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,"RFT exhausted retries. Start fabric PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */
@@ -3872,7 +3872,7 @@ 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,"RFF exhausted retries. Start fabric PLOGI %p" , iport);fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */
@@ -3882,7 +3882,7 @@ 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,"GPN FT exhausted retries. Start fabric PLOGI %p" , iport);break ;
@@ -3891,7 +3891,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport,* We should not be here since we already validated rx oxid with * our active_oxid_fabric_req */ -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"Invalid OXID/active oxid 0x%x\n" , oxid);WARN_ON (true);return ;
@@ -3911,7 +3911,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)sizeof (struct fc_std_abts_ba_acc ); 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 0x%8x" , nport_id); tport =fnic_find_tport_by_fcid (iport, nport_id);
@@ -3925,7 +3925,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"0x%x: Failed to allocate frame to send response for ABTS req" , iport->fcid);return ;
@@ -3946,7 +3946,7 @@ fdls_process_abts_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) pba_acc->acc.ba_rx_id =cpu_to_be16 (FNIC_STD_GET_RX_ID (fchdr)); pba_acc->acc.ba_ox_id =cpu_to_be16 (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,"0x%x: FDLS send BA ACC with oxid: 0x%x" , iport->fcid, oxid);
@@ -3966,7 +3966,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport,sizeof (struct fc_std_els_rjt_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,"Dropping unsupported ELS with illegal frame bits 0x%x\n" , d_id);atomic64_inc (&iport->iport_stats.unsupported_frames_dropped);
@@ -3975,7 +3975,7 @@ 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);
@@ -3984,7 +3984,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send response to unsupported ELS request" );return ; }
@@ -3992,7 +3992,7 @@ fdls_process_unsupported_els_req(struct fnic_iport_s *iport, pls_rsp = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET );fdls_init_els_rjt_frame (frame, iport); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"0x%x: Process unsupported ELS request from SID: 0x%x" , iport->fcid,ntoh24 (fchdr->fh_s_id));
@@ -4019,12 +4019,12 @@ fdls_process_rls_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr)uint16_t frame_size =FNIC_ETH_FCOE_HDRS_OFFSET +sizeof (struct fc_std_rls_acc ); -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 ;
@@ -4032,7 +4032,7 @@ fdls_process_rls_req(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send RLS accept" );return ; }
@@ -4073,33 +4073,33 @@ 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: 0x%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 0x%x ELS frame\n" , type);break ; } frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send ELS response for 0x%x" , type);return ;
@@ -4145,17 +4145,17 @@ 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 ;
@@ -4170,15 +4170,15 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,switch (frame_type) {case FNIC_FRAME_TYPE_TGT_ADISC :if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -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 ==FC_RCTL_BA_RJT ) { -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);
@@ -4190,7 +4190,7 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,return ; }fdls_free_oxid (iport, oxid, &tport->active_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);
@@ -4203,14 +4203,14 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,break ;case FNIC_FRAME_TYPE_TGT_PLOGI :if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -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 ==FC_RCTL_BA_RJT ) { -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,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,"reason code: 0x%x reason code explanation: 0x%x" , ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -4233,14 +4233,14 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,break ;case FNIC_FRAME_TYPE_TGT_PRLI :if (fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) { -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 ==FC_RCTL_BA_RJT ) { -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,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,"reason code: 0x%x reason code explanation: 0x%x" , ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan);
@@ -4256,7 +4256,7 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport,fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI );break ;default : -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);break ; }
@@ -4276,14 +4276,14 @@ fdls_process_plogi_req(struct fnic_iport_s *iport,sizeof (struct fc_std_els_rjt_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 from 0x%x" , d_id);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 ;
@@ -4291,7 +4291,7 @@ fdls_process_plogi_req(struct fnic_iport_s *iport, frame =fdls_alloc_frame (iport);if (frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send response to PLOGI request" );return ; }
@@ -4299,7 +4299,7 @@ fdls_process_plogi_req(struct fnic_iport_s *iport, pplogi_rsp = (struct fc_std_els_rjt_rsp *) (frame +FNIC_ETH_FCOE_HDRS_OFFSET );fdls_init_els_rjt_frame (frame, iport); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"0x%x: Process PLOGI request from SID: 0x%x" , iport->fcid,ntoh24 (fchdr->fh_s_id));
@@ -4329,11 +4329,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 =be64_to_cpu (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 ;
@@ -4343,19 +4343,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(0x%llx)" , nport_id, nport_name);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(0x%llx)" , nport_id, nport_name);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);
@@ -4372,7 +4372,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 );
@@ -4385,7 +4385,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 );
@@ -4409,11 +4409,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 ;
@@ -4427,21 +4427,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);
@@ -4465,14 +4465,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) {
@@ -4483,7 +4483,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: newports: %d" , newports);fdls_send_gpn_ft (iport,FDLS_STATE_RSCN_GPN_FT );fdls_send_rscn_resp (iport, fchdr);
@@ -4494,8 +4494,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 ); }
@@ -4533,20 +4533,20 @@ fdls_process_adisc_req(struct fnic_iport_s *iport,uint16_t acc_frame_size =FNIC_ETH_FCOE_HDRS_OFFSET +sizeof (struct fc_std_els_adisc ); -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 ;
@@ -4557,16 +4557,16 @@ 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); rjt_frame =fdls_alloc_frame (iport);if (rjt_frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate rjt_frame to send response to ADISC request" );return ; }
@@ -4589,7 +4589,7 @@ fdls_process_adisc_req(struct fnic_iport_s *iport, acc_frame =fdls_alloc_frame (iport);if (acc_frame ==NULL ) { -FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_ERR , fnic->host, fnic->fnic_num,"Failed to allocate frame to send ADISC accept" );return ; }
@@ -4643,7 +4643,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,/* some common validation */ 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 ; }
@@ -4653,14 +4653,14 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if ((fchdr->fh_r_ctl ==FC_RCTL_BA_ACC ) || (fchdr->fh_r_ctl ==FC_RCTL_BA_RJT )) {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 ; }if (fdls_is_oxid_fabric_req (oxid)) {if (!(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,"Received unexpected ABTS RSP(oxid:0x%x) from 0x%x. Dropping frame" , oxid, s_id);return -1 ;
@@ -4671,7 +4671,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, }else if (fdls_is_oxid_tgt_req (oxid)) {return FNIC_TPORT_BLS_ABTS_RSP ; } -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 unknown oxid(0x%x) from 0x%x. Dropping frame" , oxid, s_id);return -1 ;
@@ -4680,7 +4680,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,/* BLS ABTS Req */ if ((fchdr->fh_r_ctl ==FC_RCTL_BA_ABTS ) && (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 ; }
@@ -4692,7 +4692,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 ; }
@@ -4701,12 +4701,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_FID_FCTRL ) -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 ;
@@ -4721,7 +4721,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 ;
@@ -4730,14 +4730,14 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,/* solicited response from fabric or target */ oxid_frame_type =FNIC_FRAME_TYPE (oxid); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num,"oxid frame code: 0x%x, oxid: 0x%x\n" , oxid_frame_type, oxid);switch (oxid_frame_type) {case FNIC_FRAME_TYPE_FABRIC_FLOGI :if (type ==ELS_LS_ACC ) {if ((s_id !=FC_FID_FLOGI ) || (!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 ; }
@@ -4748,7 +4748,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if (type ==ELS_LS_ACC ) {if ((s_id !=FC_FID_DIR_SERV ) || (!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 ; }
@@ -4759,7 +4759,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,if (type ==ELS_LS_ACC ) {if ((s_id !=FC_FID_FCTRL ) || (!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 ; }
@@ -4768,7 +4768,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_RPN :if ((s_id !=FC_FID_DIR_SERV ) || (!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 ; }
@@ -4776,7 +4776,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_RFT :if ((s_id !=FC_FID_DIR_SERV ) || (!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 ; }
@@ -4784,7 +4784,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_RFF :if ((s_id !=FC_FID_DIR_SERV ) || (!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 ; }
@@ -4792,7 +4792,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,case FNIC_FRAME_TYPE_FABRIC_GPN_FT :if ((s_id !=FC_FID_DIR_SERV ) || (!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 ; }
@@ -4814,7 +4814,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,return FNIC_TPORT_ADISC_RSP ;case FNIC_FRAME_TYPE_TGT_LOGO :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 tport solicited exchange range type: 0x%x." , fchdr->fh_type);return -1 ;
@@ -4822,7 +4822,7 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,return FNIC_TPORT_LOGO_RSP ;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 ; }
@@ -4892,7 +4892,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 ;
@@ -4935,9 +4935,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 ; }
@@ -4954,7 +4954,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 );
@@ -4965,7 +4965,7 @@ void fnic_fdls_link_down(struct fnic_iport_s *iport)fnic_scsi_fcpio_reset (iport->fnic);spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags);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); }
@@ -4976,6 +4976,6 @@ 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); }
drivers/scsi/fnic/fip.c +46 -46
354 lines not on this page · raw message
drivers/scsi/fnic/fip.h +1 -1
@@ -140,7 +140,7 @@ fnic_debug_dump_fip_frame(struct fnic *fnic, struct ethhdr *eth,u16 op =be16_to_cpu (fiph->fip_op);u8 sub = fiph->fip_subcode; -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_DEBUG , fnic->host, fnic->fnic_num,"FIP %s packet contents: op: 0x%x sub: 0x%x (len = %d)" , pfx, op, sub, len);
drivers/scsi/fnic/fnic.h +3 -10
@@ -10,8 +10,6 @@#include <linux/netdevice.h> #include <linux/workqueue.h> #include <linux/bitops.h> -#include <scsi/libfc.h> -#include <scsi/libfcoe.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_transport.h> #include <scsi/scsi_transport_fc.h>
@@ -346,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 ];
@@ -380,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;
@@ -572,7 +565,7 @@ fnic_scsi_io_iter(struct fnic *fnic, .data1 = data1, .data2 = data2, }; -scsi_host_busy_iter (fnic->lport->host, fnic_io_iter_handler, &iter_data); +scsi_host_busy_iter (fnic->host, fnic_io_iter_handler, &iter_data); }#ifdef FNIC_DEBUG
@@ -582,7 +575,7 @@ fnic_debug_dump(struct fnic *fnic, uint8_t *u8arr, int len)int i;for (i =0 ; i < len; i = i+8 ) { -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_DEBUG , fnic->host, fnic->fnic_num,"%d: %02x %02x %02x %02x %02x %02x %02x %02x" , i /8 , u8arr[i +0 ], u8arr[i +1 ], u8arr[i +2 ], u8arr[i +3 ], u8arr[i +4 ], u8arr[i +5 ], u8arr[i +6 ], u8arr[i +7 ]);
@@ -597,7 +590,7 @@ fnic_debug_dump_fc_frame(struct fnic *fnic, struct fc_frame_header *fchdr, s_id =ntoh24 (fchdr->fh_s_id); d_id =ntoh24 (fchdr->fh_d_id); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, +FNIC_FCS_DBG (KERN_DEBUG , fnic->host, fnic->fnic_num,"%s packet contents: sid/did/type/oxid = 0x%x/0x%x/0x%x/0x%x (len = %d)\n" , pfx, s_id, d_id, fchdr->fh_type,FNIC_STD_GET_OX_ID (fchdr), len);
drivers/scsi/fnic/fnic_debugfs.c +1 -1
@@ -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" );
drivers/scsi/fnic/fnic_fcs.c +60 -65
94 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +33 -34
67 lines not on this page · raw message
drivers/scsi/fnic/fnic_scsi.c +121 -120
241 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.47.0
Part of the diff is not shown here. View the raw message.
Karan Tilak Kumar
maintainerPATCH v7 14/15 scsi: fnic: Add support to handle port channel RSCN
In reply to Karan Tilak KumarAdd 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.
---
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 | 56 +++++++++++++++++++++++++++++------ drivers/scsi/fnic/fnic.h | 25 ++++++++++++++++ drivers/scsi/fnic/fnic_fcs.c | 36 ++++++++++++++++++++++ drivers/scsi/fnic/fnic_main.c | 30 +++++++++++++++++++ 4 files changed, 138 insertions(+), 9 deletions(-)
drivers/scsi/fnic/fdls_disc.c +47 -9
@@ -4405,6 +4405,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);
@@ -4427,16 +4430,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, +if ((rscn_payload_len ==0xFFFF ) + && (sid ==FC_FID_FCTRL )) { + rscn_type =PC_RSCN ; +FNIC_FCS_DBG (KERN_INFO , fnic->host, fnic->fnic_num, +"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); - } +/* 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 );
@@ -4483,10 +4494,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, +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: newports: %d" , newports);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)
drivers/scsi/fnic/fnic.h +25 -0
@@ -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;
@@ -424,6 +447,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);
@@ -508,6 +532,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);
drivers/scsi/fnic/fnic_fcs.c +36 -0
@@ -1071,3 +1071,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); +}
drivers/scsi/fnic/fnic_main.c +30 -0
@@ -45,6 +45,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 ) },
@@ -89,6 +93,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)
@@ -1275,6 +1285,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");
@@ -1295,6 +1318,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 (fdls_frame_elem_cache);
@@ -1317,6 +1343,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);
Signature · 1 line
2.47.0
Karan Tilak Kumar
maintainerPATCH v7 15/15 scsi: fnic: Increment driver version
In reply to Karan Tilak KumarIncrement driver version to 1.8.0.0
--- drivers/scsi/fnic/fnic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/fnic/fnic.h +1 -1
@@ -30,7 +30,7 @@#define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver" -#define DRV_VERSION "1.7.0.0" +#define DRV_VERSION "1.8.0.0"#define PFX DRV_NAME ": "#define DFX DRV_NAME "%d: "
Signature · 1 line
2.47.0
Martin K. Petersen
AppliedKaran,
Quoted 2 lines
This cover letter describes the feature: add support for Fabric Discovery and Login Services (FDLS) to fnic driver.
Applied to 6.14/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering