Introduce support for Fabric Discovery and...
Subsystems (2)
Karan Tilak Kumar
maintainerv5 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. There are some unused function warnings, but since the function calls happen in later patches, those warnings go away. Some functions are written as placeholders for earlier patches that indicate some warnings. However, those warnings get fixed in later patches.
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.
Thanks and regards,
Karan
Karan Tilak Kumar (14):
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 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 | 4505 +++++++++++++++++++++ drivers/scsi/fnic/fdls_fc.h | 381 ++ drivers/scsi/fnic/fip.c | 876 ++++ drivers/scsi/fnic/fip.h | 345 ++ drivers/scsi/fnic/fnic.h | 217 +- drivers/scsi/fnic/fnic_attrs.c | 12 +- drivers/scsi/fnic/fnic_debugfs.c | 30 +- drivers/scsi/fnic/fnic_fcs.c | 1768 ++++---- drivers/scsi/fnic/fnic_fdls.h | 431 ++ drivers/scsi/fnic/fnic_io.h | 14 +- drivers/scsi/fnic/fnic_isr.c | 28 +- drivers/scsi/fnic/fnic_main.c | 674 +-- drivers/scsi/fnic/fnic_pci_subsys_devid.c | 131 + drivers/scsi/fnic/fnic_res.c | 77 +- drivers/scsi/fnic/fnic_scsi.c | 1168 ++++-- drivers/scsi/fnic/fnic_stats.h | 49 +- drivers/scsi/fnic/fnic_trace.c | 83 +- 18 files changed, 8917 insertions(+), 1877 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 create mode 100644 drivers/scsi/fnic/fnic_pci_subsys_devid.c
Signature · 1 line
2.31.1
Karan Tilak Kumar
maintainerPATCH v5 1/14 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 );
@@ -835,8 +812,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)INIT_LIST_HEAD (&fnic->evlist);INIT_LIST_HEAD (&fnic->vlans); }else { -shost_printk (KERN_INFO , fnic->lport->host, -"firmware uses non-FIP mode\n" ); +dev_info (&fnic->pdev->dev,"firmware uses non-FIP mode\n" );fcoe_ctlr_init (&fnic->ctlr,FIP_MODE_NON_FIP ); fnic->ctlr.state =FIP_ST_NON_FIP ; }
@@ -851,8 +827,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)/* Setup notification buffer area */ err =fnic_notify_set (fnic);if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"Failed to alloc notify buffer, aborting.\n" ); +dev_err (&fnic->pdev->dev,"Failed to alloc notify buffer, aborting.\n" ); goto err_out_free_max_pool; }
@@ -864,8 +839,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)for (i =0 ; i < fnic->rq_count; i++) { err =vnic_rq_fill (&fnic->rq[i], fnic_alloc_rq_frame);if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"fnic_alloc_rq_frame can't alloc " +dev_err (&fnic->pdev->dev,"fnic_alloc_rq_frame can't alloc " "frame\n" ); goto err_out_rq_buf; }
@@ -883,8 +857,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err =fnic_request_intr (fnic);if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"Unable to request irq.\n" ); +dev_err (&fnic->pdev->dev,"Unable to request irq.\n" ); goto err_out_request_intr; }
@@ -894,8 +867,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)*/ err =scsi_add_host (lp->host, &pdev->dev);if (err) { -shost_printk (KERN_ERR , fnic->lport->host, -"fnic: scsi_add_host failed...exiting\n" ); +dev_err (&fnic->pdev->dev,"fnic: scsi_add_host failed...exiting\n" ); goto err_out_scsi_add_host; }
drivers/scsi/fnic/fnic_res.c +23 -46
125 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH v5 01/14] scsi: fnic: Replace shost_printk with dev_info/dev_err
Quoted 10 lines · Karan Tilak Kumar
Sending host information to
shost_printkprior to host initialization in fnic is unnecessary. Replaceshost_printkand a printk prior to this initialization withdev_infoanddev_erraccordingly.Reviewed-by Sesidhar Baddela <[email protected]>Reviewed-by Arulprabhu Ponnusamy <[email protected]>Reviewed-by Gian Carlo Boffa <[email protected]>Signed-off-by Karan Tilak Kumar <[email protected]>---
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Karan Tilak Kumar
maintainerPATCH v5 2/14 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 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 | 381 ++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_fdls.h | 430 ++++++++++++++++++++++++++++++++++ 2 files changed, 811 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 +381 -0
@@ -0,0 +1,381 @@ +/* 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 <scsi/fc/fc_ms.h> + +#ifndef MIN +#define MIN (x, y) (x < y ? x : y) +#endif /* MIN */ + +#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_E_D_TOV (0x7d0) +#define FNIC_FC_CONCUR_SEQS (0xFF) +#define FNIC_FC_RO_INFO (0x1F) + +/* Little Endian */ +#define FNIC_UNSUPPORTED_RESP_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_FC_FEATURES (0x0080) + +#define ETH_TYPE_FCOE 0x8906 +#define ETH_TYPE_FIP 0x8914 + +#define FC_DIR_SERVER 0xFFFFFC +#define FC_FABRIC_CONTROLLER 0xFFFFFD +#define FC_DOMAIN_CONTR 0xFFFFFE + +#define FNIC_FC_GPN_LAST_ENTRY (0x80) + +#define FNIC_BA_ACC_RCTL 0x84 +#define FNIC_BA_RJT_RCTL 0x85 +#define FC_ABTS_RCTL 0x81 + +/* FNIC FDMI Register HBA Macros */ +#define FNIC_FDMI_NUM_PORTS 0x1000000 +#define FNIC_FDMI_NUM_HBA_ATTRS 0x9000000 +#define FNIC_FDMI_TYPE_NODE_NAME 0X100 +#define FNIC_FDMI_TYPE_MANUFACTURER 0X200 +#define FNIC_FDMI_MANUFACTURER "Cisco Systems" +#define FNIC_FDMI_TYPE_SERIAL_NUMBER 0X300 +#define FNIC_FDMI_TYPE_MODEL 0X400 +#define FNIC_FDMI_TYPE_MODEL_DES 0X500 +#define FNIC_FDMI_MODEL_DESCRIPTION "Cisco Virtual Interface Card" +#define FNIC_FDMI_TYPE_HARDWARE_VERSION 0X600 +#define FNIC_FDMI_TYPE_DRIVER_VERSION 0X700 +#define FNIC_FDMI_TYPE_ROM_VERSION 0X800 +#define FNIC_FDMI_TYPE_FIRMWARE_VERSION 0X900 +#define FNIC_FDMI_NN_LEN 0xc00 +#define FNIC_FDMI_MANU_LEN 0x1800 +#define FNIC_FDMI_SERIAL_LEN 0x1400 +#define FNIC_FDMI_MODEL_LEN 0x1000 +#define FNIC_FDMI_MODEL_DES_LEN 0x3c00 +#define FNIC_FDMI_HW_VER_LEN 0x1400 +#define FNIC_FDMI_DR_VER_LEN 0x2000 +#define FNIC_FDMI_ROM_VER_LEN 0xc00 +#define FNIC_FDMI_FW_VER_LEN 0x1400 + +/* FNIC FDMI Register PA Macros */ +#define FNIC_FDMI_TYPE_FC4_TYPES 0X100 +#define FNIC_FDMI_TYPE_SUPPORTED_SPEEDS 0X200 +#define FNIC_FDMI_TYPE_CURRENT_SPEED 0X300 +#define FNIC_FDMI_TYPE_MAX_FRAME_SIZE 0X400 +#define FNIC_FDMI_TYPE_OS_NAME 0X500 +#define FNIC_FDMI_TYPE_HOST_NAME 0X600 +#define FNIC_FDMI_NUM_PORT_ATTRS 0x6000000 +#define FNIC_FDMI_FC4_LEN 0x2400 +#define FNIC_FDMI_SUPP_SPEED_LEN 0x800 +#define FNIC_FDMI_CUR_SPEED_LEN 0x800 +#define FNIC_FDMI_MFS_LEN 0x800 +#define FNIC_FDMI_MFS 0x0080000 +#define FNIC_FDMI_OS_NAME_LEN 0x1400 +#define FNIC_FDMI_HN_LEN 0x1C00 + +#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) ((_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_NPORT_NAME (_logi, _pName) \ + (FNIC_LOGI_PORT_NAME(_logi) = get_unaligned_be64(&_pName)) +#define FNIC_LOGI_SET_NODE_NAME (_logi, _pName) \ + (FNIC_LOGI_NODE_NAME(_logi) = get_unaligned_be64(&_pName)) +#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) = htonl(_e_d_tov)) +#define FNIC_LOGI_SET_R_A_TOV (_logi, _r_a_tov) \ + (FNIC_LOGI_R_A_TOV(_logi) = htonl(_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 = _oxid) +#define FNIC_STD_SET_RX_ID (_fchdr, _rxid) ((_fchdr)->fh_rx_id = _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) ((_fchdr)->fh_ox_id) +#define FNIC_STD_GET_RX_ID (_fchdr) ((_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_SOF (0x2E) +#define FNIC_FCOE_EOF (0x42) + +#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_R_A_TOV_DEF (10 * 1000)/* msec */ +#define FNIC_E_D_TOV_DEF (2 * 1000)/* msec */ + +#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(_plogi_rsp->els.fl_csp.sp_tot_seq, \ + (be16_to_cpu(_plogi_rsp->els.fl_cssp[2].cp_con_seq) & 0xff))) + +/* Frame header */ +struct fnic_eth_hdr_s { +uint8_t dst_mac[6 ]; +uint8_t src_mac[6 ]; +uint16_t ether_type; +} __packed; + +struct fnic_fcoe_hdr_s { +uint8_t ver; +uint8_t rsvd[12 ]; +uint8_t sof; +} __packed; + +/* FLOGI/PLOGI struct */ +struct fc_std_flogi { +struct fc_frame_header fchdr; +struct fc_els_flogi els; +} __packed; + +#define FC_ELS_RSP_ACC_SIZE (sizeof(struct fc_frame_header) + \ + sizeof(struct fc_els_ls_acc)) +#define FC_ELS_RSP_REJ_SIZE (sizeof(struct fc_frame_header) + \ + sizeof(struct fc_els_ls_rjt)) + +struct fc_std_els_rsp { +struct fc_frame_header fchdr; +union { +u8 rsp_cmd; +struct fc_els_ls_acc acc; +struct fc_els_ls_rjt rej; + } u; +} __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; +uint64_t hba_identifier; +uint32_t num_ports; +uint64_t port_name; +uint32_t num_hba_attributes; +uint16_t type_nn; +uint16_t length_nn; +uint64_t node_name; +uint16_t type_manu; +uint16_t length_manu; +uint8_t manufacturer[20 ]; +uint16_t type_serial; +uint16_t length_serial; +uint8_t serial_num[16 ]; +uint16_t type_model; +uint16_t length_model; +uint8_t model[12 ]; +uint16_t type_model_des; +uint16_t length_model_des; +uint8_t model_description[56 ]; +uint16_t type_hw_ver; +uint16_t length_hw_ver; +uint8_t hardware_ver[16 ]; +uint16_t type_dr_ver; +uint16_t length_dr_ver; +uint8_t driver_ver[28 ]; +uint16_t type_rom_ver; +uint16_t length_rom_ver; +uint8_t rom_ver[8 ]; +uint16_t type_fw_ver; +uint16_t length_fw_ver; +uint8_t firmware_ver[16 ]; +} __packed; + +struct fc_std_fdmi_rpa { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +uint64_t port_name; +uint32_t num_port_attributes; +uint16_t type_fc4; +uint16_t length_fc4; +uint8_t fc4_type[32 ]; +uint16_t type_supp_speed; +uint16_t length_supp_speed; +uint32_t supported_speed; +uint16_t type_cur_speed; +uint16_t length_cur_speed; +uint32_t current_speed; +uint16_t type_max_frame_size; +uint16_t length_max_frame_size; +uint32_t max_frame_size; +uint16_t type_os_name; +uint16_t length_os_name; +uint8_t os_name[16 ]; +uint16_t type_host_name; +uint16_t length_host_name; +uint8_t host_name[24 ]; +} __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; +uint64_t 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_FCOE_FCHDR_OFFSET \ + (sizeof(struct fnic_eth_hdr_s) + sizeof(struct fnic_fcoe_hdr_s)) + +#endif /* _FDLS_FC_H */
drivers/scsi/fnic/fnic_fdls.h new file +430 -0
430 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH v5 02/14] scsi: fnic: Add headers and definitions for FDLS
Quoted 73 lines · Karan Tilak Kumar
Add headers and definitions for FDLS (Fabric Discovery and Login Services).
Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Remove newline at the end offnic_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.
Replacehtonll()withget_unaligned_be64(). Replace raw values with macro names.
Removefnic_del_fabric_timer_syncmacro.
Removefnic_del_tport_timer_syncmacro.
Addfnic_del_fabric_timer_syncfunction declaration. Addfnic_del_tport_timer_syncfunction declaration. Replace definitions with standard definitions fromfc_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 | 381 ++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_fdls.h | 430 ++++++++++++++++++++++++++++++++++ 2 files changed, 811 insertions(+)create mode 100644
drivers/scsi/fnic/fdls_fc.hcreate mode 100644drivers/scsi/fnic/fnic_fdls.hdrivers/scsi/fnic/fdls_fc.h new file +22
-0@@ -0,0 +1,381 @@ +/* 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>
drivers/scsi/fnic/fdls_fc.h line 32
Quoted 10 lines
drivers/scsi/fnic/fdls_fc.h new file +10
-0+#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 <scsi/fc/fc_ms.h> + +#ifndef MIN +#define MIN (x, y) (x < y ? x : y) +#endif /* MIN */ +
#include <linux/minmax.h>
drivers/scsi/fnic/fdls_fc.h line 39
Quoted 7 lines
drivers/scsi/fnic/fdls_fc.h new file +7
-0+#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_E_D_TOV (0x7d0)
Please keep E_D_TOV in decimal for better readability. And anyway you can use FC_DEF_E_T_TOV (which is already defined and has the same value)
Quoted 13 lines
drivers/scsi/fnic/fdls_fc.h new file +13
-0+#define FNIC_FC_CONCUR_SEQS (0xFF) +#define FNIC_FC_RO_INFO (0x1F) + +/* Little Endian */ +#define FNIC_UNSUPPORTED_RESP_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)
drivers/scsi/fnic/fdls_fc.h line 62
Quoted 10 lines
drivers/scsi/fnic/fdls_fc.h new file +10
-0+#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_FC_FEATURES (0x0080) + +#define ETH_TYPE_FCOE 0x8906 +#define ETH_TYPE_FIP 0x8914 +
#include <linux/if_ether.h>ETH_P_FIPETH_P_FCOE
drivers/scsi/fnic/fdls_fc.h line 66
Quoted 4 lines
drivers/scsi/fnic/fdls_fc.h new file +4
-0+#define FC_DIR_SERVER 0xFFFFFC +#define FC_FABRIC_CONTROLLER 0xFFFFFD +#define FC_DOMAIN_CONTR 0xFFFFFE +
Please use values from 'enum fc_well_known_fid'
drivers/scsi/fnic/fdls_fc.h line 72
Quoted 6 lines
drivers/scsi/fnic/fdls_fc.h new file +6
-0+#define FNIC_FC_GPN_LAST_ENTRY (0x80) + +#define FNIC_BA_ACC_RCTL 0x84 +#define FNIC_BA_RJT_RCTL 0x85 +#define FC_ABTS_RCTL 0x81 +
#include <scsi/fc/fc_fs.h>
Quoted 30 lines
drivers/scsi/fnic/fdls_fc.h new file +30
-0+/* FNIC FDMI Register HBA Macros */ +#define FNIC_FDMI_NUM_PORTS 0x1000000 +#define FNIC_FDMI_NUM_HBA_ATTRS 0x9000000 +#define FNIC_FDMI_TYPE_NODE_NAME 0X100 +#define FNIC_FDMI_TYPE_MANUFACTURER 0X200 +#define FNIC_FDMI_MANUFACTURER "Cisco Systems" +#define FNIC_FDMI_TYPE_SERIAL_NUMBER 0X300 +#define FNIC_FDMI_TYPE_MODEL 0X400 +#define FNIC_FDMI_TYPE_MODEL_DES 0X500 +#define FNIC_FDMI_MODEL_DESCRIPTION "Cisco Virtual Interface Card" +#define FNIC_FDMI_TYPE_HARDWARE_VERSION 0X600 +#define FNIC_FDMI_TYPE_DRIVER_VERSION 0X700 +#define FNIC_FDMI_TYPE_ROM_VERSION 0X800 +#define FNIC_FDMI_TYPE_FIRMWARE_VERSION 0X900 +#define FNIC_FDMI_NN_LEN 0xc00 +#define FNIC_FDMI_MANU_LEN 0x1800 +#define FNIC_FDMI_SERIAL_LEN 0x1400 +#define FNIC_FDMI_MODEL_LEN 0x1000 +#define FNIC_FDMI_MODEL_DES_LEN 0x3c00 +#define FNIC_FDMI_HW_VER_LEN 0x1400 +#define FNIC_FDMI_DR_VER_LEN 0x2000 +#define FNIC_FDMI_ROM_VER_LEN 0xc00 +#define FNIC_FDMI_FW_VER_LEN 0x1400 + +/* FNIC FDMI Register PA Macros */ +#define FNIC_FDMI_TYPE_FC4_TYPES 0X100 +#define FNIC_FDMI_TYPE_SUPPORTED_SPEEDS 0X200 +#define FNIC_FDMI_TYPE_CURRENT_SPEED 0X300 +#define FNIC_FDMI_TYPE_MAX_FRAME_SIZE 0X400 +#define FNIC_FDMI_TYPE_OS_NAME 0X500
drivers/scsi/fnic/fdls_fc.h line 112
Quoted 10 lines
drivers/scsi/fnic/fdls_fc.h new file +10
-0+#define FNIC_FDMI_TYPE_HOST_NAME 0X600 +#define FNIC_FDMI_NUM_PORT_ATTRS 0x6000000 +#define FNIC_FDMI_FC4_LEN 0x2400 +#define FNIC_FDMI_SUPP_SPEED_LEN 0x800 +#define FNIC_FDMI_CUR_SPEED_LEN 0x800 +#define FNIC_FDMI_MFS_LEN 0x800 +#define FNIC_FDMI_MFS 0x0080000 +#define FNIC_FDMI_OS_NAME_LEN 0x1400 +#define FNIC_FDMI_HN_LEN 0x1C00 +
Do these need to be defined here?
Wouldn't it be better to move them into the source file handling FDMI? I doubt that they need to be available for every file ...
Quoted 45 lines
drivers/scsi/fnic/fdls_fc.h new file +45
-0+#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) ((_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_NPORT_NAME (_logi, _pName) \ + (FNIC_LOGI_PORT_NAME(_logi) = get_unaligned_be64(&_pName)) +#define FNIC_LOGI_SET_NODE_NAME (_logi, _pName) \ + (FNIC_LOGI_NODE_NAME(_logi) = get_unaligned_be64(&_pName)) +#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) = htonl(_e_d_tov)) +#define FNIC_LOGI_SET_R_A_TOV (_logi, _r_a_tov) \ + (FNIC_LOGI_R_A_TOV(_logi) = htonl(_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 = _oxid) +#define FNIC_STD_SET_RX_ID (_fchdr, _rxid) ((_fchdr)->fh_rx_id = _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) ((_fchdr)->fh_ox_id) +#define FNIC_STD_GET_RX_ID (_fchdr) ((_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)) +
drivers/scsi/fnic/fdls_fc.h line 167
Quoted 10 lines
drivers/scsi/fnic/fdls_fc.h new file +10
-0+#define FNIC_FCOE_SOF (0x2E) +#define FNIC_FCOE_EOF (0x42) + +#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_R_A_TOV_DEF (10 * 1000)/* msec */ +#define FNIC_E_D_TOV_DEF (2 * 1000)/* msec */ +
?? You already had defined FNIC_E_D_TOV above ...
Quoted 154 lines
drivers/scsi/fnic/fdls_fc.h new file +154
-0+#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(_plogi_rsp->els.fl_csp.sp_tot_seq, \ + (be16_to_cpu(_plogi_rsp->els.fl_cssp[2].cp_con_seq) & 0xff))) + +/* Frame header */ +struct fnic_eth_hdr_s { +uint8_t dst_mac[6 ]; +uint8_t src_mac[6 ]; +uint16_t ether_type; +} __packed; + +struct fnic_fcoe_hdr_s { +uint8_t ver; +uint8_t rsvd[12 ]; +uint8_t sof; +} __packed; + +/* FLOGI/PLOGI struct */ +struct fc_std_flogi { +struct fc_frame_header fchdr; +struct fc_els_flogi els; +} __packed; + +#define FC_ELS_RSP_ACC_SIZE (sizeof(struct fc_frame_header) + \ + sizeof(struct fc_els_ls_acc)) +#define FC_ELS_RSP_REJ_SIZE (sizeof(struct fc_frame_header) + \ + sizeof(struct fc_els_ls_rjt)) + +struct fc_std_els_rsp { +struct fc_frame_header fchdr; +union { +u8 rsp_cmd; +struct fc_els_ls_acc acc; +struct fc_els_ls_rjt rej; + } u; +} __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; +uint64_t hba_identifier; +uint32_t num_ports; +uint64_t port_name; +uint32_t num_hba_attributes; +uint16_t type_nn; +uint16_t length_nn; +uint64_t node_name; +uint16_t type_manu; +uint16_t length_manu; +uint8_t manufacturer[20 ]; +uint16_t type_serial; +uint16_t length_serial; +uint8_t serial_num[16 ]; +uint16_t type_model; +uint16_t length_model; +uint8_t model[12 ]; +uint16_t type_model_des; +uint16_t length_model_des; +uint8_t model_description[56 ]; +uint16_t type_hw_ver; +uint16_t length_hw_ver; +uint8_t hardware_ver[16 ]; +uint16_t type_dr_ver; +uint16_t length_dr_ver; +uint8_t driver_ver[28 ]; +uint16_t type_rom_ver; +uint16_t length_rom_ver; +uint8_t rom_ver[8 ]; +uint16_t type_fw_ver; +uint16_t length_fw_ver; +uint8_t firmware_ver[16 ]; +} __packed; + +struct fc_std_fdmi_rpa { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +uint64_t port_name; +uint32_t num_port_attributes; +uint16_t type_fc4; +uint16_t length_fc4; +uint8_t fc4_type[32 ]; +uint16_t type_supp_speed; +uint16_t length_supp_speed; +uint32_t supported_speed; +uint16_t type_cur_speed; +uint16_t length_cur_speed; +uint32_t current_speed; +uint16_t type_max_frame_size;
drivers/scsi/fnic/fdls_fc.h line 331
Quoted 10 lines
drivers/scsi/fnic/fdls_fc.h new file +10
-0+uint16_t length_max_frame_size; +uint32_t max_frame_size; +uint16_t type_os_name; +uint16_t length_os_name; +uint8_t os_name[16 ]; +uint16_t type_host_name; +uint16_t length_host_name; +uint8_t host_name[24 ]; +} __packed; +
Weelll ....
There _is_ an FDMI structure definition ininclude/scsi/fc/fc_ms.h.
Remainder looks ok.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v5 02/14] scsi: fnic: Add headers and definitions for FDLS
Quoted 79 lines · Hannes Reinecke
Quoted 77 lines · Karan Tilak Kumar
Add headers and definitions for FDLS (Fabric Discovery and Login Services).
Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Remove newline at the end offnic_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.
Replacehtonll()withget_unaligned_be64(). Replace raw values with macro names.
Removefnic_del_fabric_timer_syncmacro.
Removefnic_del_tport_timer_syncmacro.
Addfnic_del_fabric_timer_syncfunction declaration. Addfnic_del_tport_timer_syncfunction declaration. Replace definitions with standard definitions fromfc_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 | 381 ++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic_fdls.h | 430 ++++++++++++++++++++++++++++++++++ 2 files changed, 811 insertions(+)create mode 100644
drivers/scsi/fnic/fdls_fc.hcreate mode 100644drivers/scsi/fnic/fnic_fdls.hdrivers/scsi/fnic/fdls_fc.h new file +26
-0@@ -0,0 +1,381 @@ +/* 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>
Quoted 8 lines
drivers/scsi/fnic/fdls_fc.h line 32
Quoted 6 lines
drivers/scsi/fnic/fdls_fc.h new file +6
-0+#include <scsi/fc/fc_ms.h> + +#ifndef MIN +#define MIN (x, y) (x < y ? x : y) +#endif /* MIN */ +#include <
linux/minmax.h>
Thanks for your comment, Hannes.
I'll fix this in the next version.
Quoted 11 lines
drivers/scsi/fnic/fdls_fc.h line 39
Quoted 7 lines
drivers/scsi/fnic/fdls_fc.h new file +7
-0+#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_E_D_TOV (0x7d0)Please keep
E_D_TOVin decimal for better readability. And anyway you can useFC_DEF_E_T_TOV(which is already defined and has the same value)
Sure Hannes. I'll fix this in the next version.
Quoted 19 lines
Quoted 19 lines
drivers/scsi/fnic/fdls_fc.h new file +19
-0+#define FNIC_FC_CONCUR_SEQS (0xFF) +#define FNIC_FC_RO_INFO (0x1F) + +/* Little Endian */ +#define FNIC_UNSUPPORTED_RESP_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_FC_FEATURES (0x0080)
Quoted 8 lines
drivers/scsi/fnic/fdls_fc.h line 62
Quoted 4 lines
drivers/scsi/fnic/fdls_fc.h new file +4
-0+ +#define ETH_TYPE_FCOE 0x8906 +#define ETH_TYPE_FIP 0x8914 +#include <
linux/if_ether.h>ETH_P_FIPETH_P_FCOE
Sure Hannes. I'll fix this in the next version.
Quoted 6 lines
drivers/scsi/fnic/fdls_fc.h line 66
Quoted 4 lines
drivers/scsi/fnic/fdls_fc.h new file +4
-0+#define FC_DIR_SERVER 0xFFFFFC +#define FC_FABRIC_CONTROLLER 0xFFFFFD +#define FC_DOMAIN_CONTR 0xFFFFFE +Please use values from 'enum
fc_well_known_fid'
Sure Hannes. I'll fix this in the next version.
Quoted 8 lines
drivers/scsi/fnic/fdls_fc.h line 72
Quoted 6 lines
drivers/scsi/fnic/fdls_fc.h new file +6
-0+#define FNIC_FC_GPN_LAST_ENTRY (0x80) + +#define FNIC_BA_ACC_RCTL 0x84 +#define FNIC_BA_RJT_RCTL 0x85 +#define FC_ABTS_RCTL 0x81 +#include <
scsi/fc/fc_fs.h>
Sure Hannes. I'll fix this in the next version.
Quoted 35 lines
Quoted 35 lines
drivers/scsi/fnic/fdls_fc.h new file +35
-0+/* FNIC FDMI Register HBA Macros */ +#define FNIC_FDMI_NUM_PORTS 0x1000000 +#define FNIC_FDMI_NUM_HBA_ATTRS 0x9000000 +#define FNIC_FDMI_TYPE_NODE_NAME 0X100 +#define FNIC_FDMI_TYPE_MANUFACTURER 0X200 +#define FNIC_FDMI_MANUFACTURER "Cisco Systems" +#define FNIC_FDMI_TYPE_SERIAL_NUMBER 0X300 +#define FNIC_FDMI_TYPE_MODEL 0X400 +#define FNIC_FDMI_TYPE_MODEL_DES 0X500 +#define FNIC_FDMI_MODEL_DESCRIPTION "Cisco Virtual Interface Card" +#define FNIC_FDMI_TYPE_HARDWARE_VERSION 0X600 +#define FNIC_FDMI_TYPE_DRIVER_VERSION 0X700 +#define FNIC_FDMI_TYPE_ROM_VERSION 0X800 +#define FNIC_FDMI_TYPE_FIRMWARE_VERSION 0X900 +#define FNIC_FDMI_NN_LEN 0xc00 +#define FNIC_FDMI_MANU_LEN 0x1800 +#define FNIC_FDMI_SERIAL_LEN 0x1400 +#define FNIC_FDMI_MODEL_LEN 0x1000 +#define FNIC_FDMI_MODEL_DES_LEN 0x3c00 +#define FNIC_FDMI_HW_VER_LEN 0x1400 +#define FNIC_FDMI_DR_VER_LEN 0x2000 +#define FNIC_FDMI_ROM_VER_LEN 0xc00 +#define FNIC_FDMI_FW_VER_LEN 0x1400 + +/* FNIC FDMI Register PA Macros */ +#define FNIC_FDMI_TYPE_FC4_TYPES 0X100 +#define FNIC_FDMI_TYPE_SUPPORTED_SPEEDS 0X200 +#define FNIC_FDMI_TYPE_CURRENT_SPEED 0X300 +#define FNIC_FDMI_TYPE_MAX_FRAME_SIZE 0X400 +#define FNIC_FDMI_TYPE_OS_NAME 0X500 +#define FNIC_FDMI_TYPE_HOST_NAME 0X600 +#define FNIC_FDMI_NUM_PORT_ATTRS 0x6000000 +#define FNIC_FDMI_FC4_LEN 0x2400 +#define FNIC_FDMI_SUPP_SPEED_LEN 0x800 +#define FNIC_FDMI_CUR_SPEED_LEN 0x800
Quoted 8 lines
drivers/scsi/fnic/fdls_fc.h line 112
Quoted 5 lines
drivers/scsi/fnic/fdls_fc.h new file +5
-0+#define FNIC_FDMI_MFS_LEN 0x800 +#define FNIC_FDMI_MFS 0x0080000 +#define FNIC_FDMI_OS_NAME_LEN 0x1400 +#define FNIC_FDMI_HN_LEN 0x1C00 +Do these need to be defined here?
Wouldn't it be better to move them into the source file handling FDMI? I doubt that they need to be available for every file ...
Thanks Hannes. Yes, they can be moved. I'll fix it in the next version.
Quoted 49 lines
Quoted 49 lines
drivers/scsi/fnic/fdls_fc.h new file +49
-0+#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) ((_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_NPORT_NAME (_logi, _pName) \ + (FNIC_LOGI_PORT_NAME(_logi) = get_unaligned_be64(&_pName)) +#define FNIC_LOGI_SET_NODE_NAME (_logi, _pName) \ + (FNIC_LOGI_NODE_NAME(_logi) = get_unaligned_be64(&_pName)) +#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) = htonl(_e_d_tov)) +#define FNIC_LOGI_SET_R_A_TOV (_logi, _r_a_tov) \ + (FNIC_LOGI_R_A_TOV(_logi) = htonl(_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 = _oxid) +#define FNIC_STD_SET_RX_ID (_fchdr, _rxid) ((_fchdr)->fh_rx_id = _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) ((_fchdr)->fh_ox_id) +#define FNIC_STD_GET_RX_ID (_fchdr) ((_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_SOF (0x2E) +#define FNIC_FCOE_EOF (0x42) + +#define FNIC_FCOE_MAX_FRAME_SZ (2048)
Quoted 8 lines
drivers/scsi/fnic/fdls_fc.h line 167
Quoted 6 lines
drivers/scsi/fnic/fdls_fc.h new file +6
-0+#define FNIC_FCOE_MIN_FRAME_SZ (280) +#define FNIC_FC_MAX_PAYLOAD_LEN (2048) +#define FNIC_MIN_DATA_FIELD_SIZE (256) +#define FNIC_R_A_TOV_DEF (10 * 1000)/* msec */ +#define FNIC_E_D_TOV_DEF (2 * 1000)/* msec */ +?? You already had defined
FNIC_E_D_TOVabove ...
Thanks for the observation, Hannes. Yes, this is redundant. I'll remove it in the next version.
Quoted 169 lines
Quoted 154 lines
drivers/scsi/fnic/fdls_fc.h new file +154
-0+#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(_plogi_rsp->els.fl_csp.sp_tot_seq, \ + (be16_to_cpu(_plogi_rsp->els.fl_cssp[2].cp_con_seq) & 0xff))) + +/* Frame header */ +struct fnic_eth_hdr_s { +uint8_t dst_mac[6 ]; +uint8_t src_mac[6 ]; +uint16_t ether_type; +} __packed; + +struct fnic_fcoe_hdr_s { +uint8_t ver; +uint8_t rsvd[12 ]; +uint8_t sof; +} __packed; + +/* FLOGI/PLOGI struct */ +struct fc_std_flogi { +struct fc_frame_header fchdr; +struct fc_els_flogi els; +} __packed; + +#define FC_ELS_RSP_ACC_SIZE (sizeof(struct fc_frame_header) + \ + sizeof(struct fc_els_ls_acc)) +#define FC_ELS_RSP_REJ_SIZE (sizeof(struct fc_frame_header) + \ + sizeof(struct fc_els_ls_rjt)) + +struct fc_std_els_rsp { +struct fc_frame_header fchdr; +union { +u8 rsp_cmd; +struct fc_els_ls_acc acc; +struct fc_els_ls_rjt rej; + } u; +} __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; +uint64_t hba_identifier; +uint32_t num_ports; +uint64_t port_name; +uint32_t num_hba_attributes; +uint16_t type_nn; +uint16_t length_nn; +uint64_t node_name; +uint16_t type_manu; +uint16_t length_manu; +uint8_t manufacturer[20 ]; +uint16_t type_serial; +uint16_t length_serial; +uint8_t serial_num[16 ]; +uint16_t type_model; +uint16_t length_model; +uint8_t model[12 ]; +uint16_t type_model_des; +uint16_t length_model_des; +uint8_t model_description[56 ]; +uint16_t type_hw_ver; +uint16_t length_hw_ver; +uint8_t hardware_ver[16 ]; +uint16_t type_dr_ver; +uint16_t length_dr_ver; +uint8_t driver_ver[28 ]; +uint16_t type_rom_ver; +uint16_t length_rom_ver; +uint8_t rom_ver[8 ]; +uint16_t type_fw_ver; +uint16_t length_fw_ver; +uint8_t firmware_ver[16 ]; +} __packed; + +struct fc_std_fdmi_rpa { +struct fc_frame_header fchdr; +struct fc_ct_hdr fc_std_ct_hdr; +uint64_t port_name; +uint32_t num_port_attributes; +uint16_t type_fc4; +uint16_t length_fc4; +uint8_t fc4_type[32 ]; +uint16_t type_supp_speed; +uint16_t length_supp_speed; +uint32_t supported_speed; +uint16_t type_cur_speed; +uint16_t length_cur_speed; +uint32_t current_speed; +uint16_t type_max_frame_size;drivers/scsi/fnic/fdls_fc.h line 331
Quoted 10 lines
drivers/scsi/fnic/fdls_fc.h new file +10
-0+uint16_t length_max_frame_size; +uint32_t max_frame_size; +uint16_t type_os_name; +uint16_t length_os_name; +uint8_t os_name[16 ]; +uint16_t type_host_name; +uint16_t length_host_name; +uint8_t host_name[24 ]; +} __packed; +Weelll ....
There _is_ an FDMI structure definition ininclude/scsi/fc/fc_ms.h.
Quoted 1 line
Remainder looks ok.
Thanks Hannes. We are reviewing this internally.
Quoted 9 lines
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
[email protected] +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Thanks for your time and effort in reviewing this Hannes. Appreciate it.
Regards,
Karan
Karan Tilak Kumar
maintainerPATCH v5 3/14 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/
---
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 | 1906 +++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 26 +- drivers/scsi/fnic/fnic_fcs.c | 400 ++++--- drivers/scsi/fnic/fnic_fdls.h | 5 +- drivers/scsi/fnic/fnic_io.h | 11 - drivers/scsi/fnic/fnic_main.c | 10 +- drivers/scsi/fnic/fnic_scsi.c | 6 +- 8 files changed, 2171 insertions(+), 194 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 +1906 -0
1,906 lines not on this page · raw message
drivers/scsi/fnic/fnic.h +24 -2
@@ -24,6 +24,7 @@#include "vnic_intr.h" #include "vnic_stats.h" #include "vnic_scsi.h" +#include "fnic_fdls.h" #define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
@@ -31,6 +32,7 @@#define PFX DRV_NAME ": "#define DFX DRV_NAME "%d: " +#define FABRIC_LOGO_MAX_RETRY 3#define DESC_CLEAN_LOW_WATERMARK 8#define FNIC_UCSM_DFLT_THROTTLE_CNT_BLD 16/* UCSM default throttle count */ #define FNIC_MIN_IO_REQ 256/* Min IO throttle count */
@@ -75,6 +77,8 @@#define FNIC_DEV_RST_TERM_DONE BIT(20)#define FNIC_DEV_RST_ABTS_PENDING BIT(21) +#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +/* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock.
@@ -213,12 +217,26 @@ enum fnic_state {struct mempool ; +enum fnic_role_e { +FNIC_ROLE_FCP_INITIATOR =0 , +}; +enum fnic_evt {FNIC_EVT_START_VLAN_DISC =1 ,FNIC_EVT_START_FCF_DISC =2 ,FNIC_EVT_MAX , }; +struct fnic_frame_list { +/* +* Link to frame lists +*/ +struct list_head links; +void *fp; +int frame_len; +int rx_ethhdr_stripped; +}; +struct fnic_event {struct list_head list;struct fnic *fnic;
@@ -235,6 +253,8 @@ struct fnic_cpy_wq {/* Per-instance private data structure */ struct fnic {int fnic_num; +enum fnic_role_e role; +struct fnic_iport_s iport;struct fc_lport *lport;struct fcoe_ctlr ctlr;/* FIP FCoE controller structure */ struct vnic_dev_bar bar0;
@@ -278,6 +298,7 @@ struct fnic {unsigned long state_flags;/* protected by host lock */ enum fnic_state state;spinlock_t fnic_lock; +unsigned long lock_flags;u16 vlan_id;/* VLAN tag including priority */ u8 data_src_addr[ETH_ALEN ];
@@ -307,7 +328,7 @@ struct fnic {struct work_struct frame_work;struct work_struct flush_work;struct sk_buff_head frame_queue; -struct sk_buff_head tx_queue; +struct list_head tx_queue;/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);
@@ -397,7 +418,6 @@ 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 fnic *fnic);static inline int fnic_chk_state_flags_locked (struct fnic *fnic,unsigned long st_flags)
@@ -406,4 +426,6 @@ fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags) }void __fnic_set_state_flags (struct fnic *,unsigned long ,unsigned long );void fnic_dump_fchost_stats (struct Scsi_Host *,struct fc_host_statistics *); +void fnic_free_txq (struct list_head *head); +#endif /* _FNIC_H_ */
drivers/scsi/fnic/fnic_fcs.c +230 -170
480 lines not on this page · raw message
drivers/scsi/fnic/fnic_fdls.h +2 -3
@@ -382,8 +382,8 @@ inline void fnic_del_tport_timer_sync(struct fnic *fnic, struct fnic_tport_s *tport);void fdls_send_fabric_logo (struct fnic_iport_s *iport);int fnic_fdls_validate_and_get_frame_type (struct fnic_iport_s *iport, -void *rx_frame,int len, -int fchdr_offset); +void *rx_frame,int len, +int fchdr_offset);void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport); bool fdls_delete_tport(struct fnic_iport_s *iport,
@@ -399,7 +399,6 @@ int fnic_send_fip_frame(struct fnic_iport_s *iport, void *payload, int payload_sz);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 +5 -5
@@ -31,6 +31,8 @@#include "fnic_io.h" #include "fnic_fip.h" #include "fnic.h" +#include "fnic_fdls.h" +#include "fdls_fc.h" #define PCI_DEVICE_ID_CISCO_FNIC 0x0045
@@ -80,7 +82,6 @@ module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR);MODULE_PARM_DESC (fnic_max_qdepth,"Queue depth to report for each LUN" );static struct libfc_function_template fnic_transport_template = { - .frame_send = fnic_send, .lport_set_port_id = fnic_set_port_id, .fcp_abort_io = fnic_empty_scsi_cleanup, .fcp_cleanup = fnic_empty_scsi_cleanup,
@@ -413,7 +414,7 @@ static void fnic_fip_notify_timer(struct timer_list *t) {struct fnic *fnic =from_timer (fnic, t, fip_timer); -fnic_handle_fip_timer (fnic); +/* Placeholder function */ }static void fnic_notify_timer_start (struct fnic *fnic)
@@ -921,7 +922,7 @@ 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);skb_queue_head_init (&fnic->frame_queue); -skb_queue_head_init (&fnic->tx_queue); +INIT_LIST_HEAD (&fnic->tx_queue);fc_fabric_login (lp);
@@ -1004,7 +1005,7 @@ static void fnic_remove(struct pci_dev *pdev)*/ flush_workqueue (fnic_event_queue);skb_queue_purge (&fnic->frame_queue); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue);if (fnic->config.flags &VFCF_FIP_CAPABLE ) {del_timer_sync (&fnic->fip_timer);
@@ -1036,7 +1037,6 @@ static void fnic_remove(struct pci_dev *pdev)fnic_cleanup (fnic);BUG_ON (!skb_queue_empty (&fnic->frame_queue)); -BUG_ON (!skb_queue_empty (&fnic->tx_queue));spin_lock_irqsave (&fnic_list_lock, flags);list_del (&fnic->list);
drivers/scsi/fnic/fnic_scsi.c +3 -3
@@ -184,7 +184,7 @@ int fnic_fw_reset_handler(struct fnic *fnic)fnic_set_state_flags (fnic,FNIC_FLAGS_FWRESET );skb_queue_purge (&fnic->frame_queue); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue);/* wait for io cmpl */ while (atomic_read (&fnic->in_flight))
@@ -674,7 +674,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,*/ if (fnic->remove_wait || ret) {spin_unlock_irqrestore (&fnic->fnic_lock, flags); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue); goto reset_cmpl_handler_end; }
@@ -1717,7 +1717,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)return true; } -static void fnic_rport_exch_reset (struct fnic *fnic,u32 port_id) +void fnic_rport_exch_reset (struct fnic *fnic,u32 port_id) {struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats;struct fnic_rport_abort_io_iter_data iter_data = {
Signature · 1 line
2.31.1
Re: [PATCH v5 03/14] scsi: fnic: Add support for fabric based solicited requests and responses
Quoted 262 lines · Karan Tilak Kumar
Add
fdls_disc.cto 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.Reported-by kernel test robot <[email protected]>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/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately. Modifyfnic_fdls_timer_callbackto 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 infnic_send_frame.
Use the correct kernel-doc format.
Replacehtonll()withget_unaligned_be64(). Addfnic_del_fabric_timer_syncas an inline function. Addfnic_del_tport_timer_syncas an inline function. Modifyfc_abts_svariable name tofc_fabric_abts_s. Modifyfc_fabric_abts_sto be a global frame. Renamepfc_abtstofabric_abts.
Replace definitions with standard definitions fromfc_els.h.
Incorporate review comments from John:
Replace kmalloc with kzalloc.
Modifyfnic_send_fcoe_frameto 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 | 1906 +++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 26 +- drivers/scsi/fnic/fnic_fcs.c | 400 ++++--- drivers/scsi/fnic/fnic_fdls.h | 5 +- drivers/scsi/fnic/fnic_io.h | 11 - drivers/scsi/fnic/fnic_main.c | 10 +- drivers/scsi/fnic/fnic_scsi.c | 6 +- 8 files changed, 2171 insertions(+), 194 deletions(-)create mode 100644
drivers/scsi/fnic/fdls_disc.cdrivers/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 +176
-0@@ -0,0 +1,1906 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2008 Cisco Systems, Inc. All rights reserved. +* Copyright 2007 Nuova Systems, Inc. All rights reserved. +*/ + +#include <linux/workqueue.h> +#include "fnic.h" +#include "fdls_fc.h" +#include "fnic_fdls.h" +#include <scsi/fc/fc_fcp.h> +#include <linux/utsname.h> + +/* Frame initialization */ +/* +* Variables: +* sid +*/ +struct fc_std_flogi fnic_std_flogi_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_d_id = {0xFF ,0xFF ,0xFE }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .els.fl_cmd =ELS_FLOGI , + .els.fl_csp = {.sp_hi_ver =FNIC_FC_PH_VER_HI , + .sp_lo_ver =FNIC_FC_PH_VER_LO , + .sp_bb_cred =cpu_to_be16 (FNIC_FC_B2B_CREDIT ), + .sp_bb_data =cpu_to_be16 (FNIC_FC_B2B_RDF_SZ )}, + .els.fl_cssp[2 ].cp_class =cpu_to_be16 (FC_CPC_VALID |FC_CPC_SEQ ) +}; + +/* +* Variables: +* sid, did(nport logins), ox_id(nport logins), nport_name, node_name +*/ +struct fc_std_flogi fnic_std_plogi_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_d_id = {0xFF ,0xFF ,0xFC }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .els = { + .fl_cmd =ELS_PLOGI , + .fl_csp = {.sp_hi_ver =FNIC_FC_PH_VER_HI , + .sp_lo_ver =FNIC_FC_PH_VER_LO , + .sp_bb_cred =cpu_to_be16 (FNIC_FC_B2B_CREDIT ), + .sp_features =cpu_to_be16 (FC_SP_FT_CIRO ), + .sp_bb_data =cpu_to_be16 (FNIC_FC_B2B_RDF_SZ ), + .sp_tot_seq =cpu_to_be16 (FNIC_FC_CONCUR_SEQS ), + .sp_rel_off =cpu_to_be16 (FNIC_FC_RO_INFO ), + .sp_e_d_tov =cpu_to_be32 (FNIC_E_D_TOV )}, + .fl_cssp[2 ].cp_class =cpu_to_be16 (FC_CPC_VALID |FC_CPC_SEQ ), + .fl_cssp[2 ].cp_rdfs =cpu_to_be16 (0x800 ), + .fl_cssp[2 ].cp_con_seq =cpu_to_be16 (0xFF ), + .fl_cssp[2 ].cp_open_seq =1 } +}; + +/* +* Variables: +* sid, port_id, port_name +*/ +struct fc_std_rpn_id fnic_std_rpn_id_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_RPN_ID )} +}; + +/* +* Variables: +* fh_s_id, port_id, port_name +*/ +struct fc_std_rft_id fnic_std_rft_id_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_RFT_ID )} +}; + +/* +* Variables: +* fh_s_id, port_id, port_name +*/ +struct fc_std_rff_id fnic_std_rff_id_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_RFF_ID )}, + .rff_id.fr_feat =0x2 , + .rff_id.fr_type =FC_TYPE_FCP +}; + +/* +* Variables: +* sid +*/ +struct fc_std_gpn_ft fnic_std_gpn_ft_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_GPN_FT )}, + .gpn_ft.fn_fc4_type =0x08 +}; + +/* +* Variables: +* sid +*/ +struct fc_std_scr fnic_std_scr_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , + .fh_d_id = {0xFF ,0xFF ,0xFD }, .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .scr = {.scr_cmd =ELS_SCR , + .scr_reg_func =ELS_SCRF_FULL } +}; + +/* +* Variables: +* did, ox_id, rx_id, fcid, wwpn +*/ +struct fc_std_logo fnic_std_logo_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }}, + .els.fl_cmd =ELS_LOGO , +}; + +struct fc_frame_header fc_std_fabric_abts = { + .fh_r_ctl =FC_RCTL_BA_ABTS ,/* ABTS */ + .fh_d_id = {0xFF ,0xFF ,0xFF }, .fh_s_id = {0x00 ,0x00 ,0x00 }, + .fh_cs_ctl =0x00 , .fh_type =FC_TYPE_BLS , + .fh_f_ctl = {FNIC_REQ_ABTS_FCTL ,0 ,0 }, .fh_seq_id =0x00 , + .fh_df_ctl =0x00 , .fh_seq_cnt =0x0000 , .fh_rx_id =0xFFFF , + .fh_parm_offset =0x00000000 ,/* bit:0 = 0 Abort a exchange */ +}; + +#define RETRIES_EXHAUSTED (iport) \ + (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY) + +/* +* For fabric requests and fdmi, once OXIDs are allocated from the pool +* (and a range) they are encoded with expected rsp type as +* they come in convenience with identifying the received frames +* and debugging with switches (OXID pool base will be chosen +* such a way bits 6-11 are always 0) oxid(16 bits) - +* bits 0-5: idx into the pool(bitmap) +* bits 6-11: expected response types +*/ +#define FDLS_OXID_ENCODE (oxid, rsp_type) ((oxid) | (rsp_type << 6)) +#define FDLS_OXID_RSP_TYPE_UNMASKED (oxid) ((oxid) & ~0x0FC0) +#define FDLS_OXID_TO_RSP_TYPE (oxid) (((oxid) >> 6) & 0x3F) +/* meta->size has to be power-of-2 */ +#define FDLS_OXID_TO_IDX (meta, oxid) ((oxid) & (meta->sz - 1)) + +/* Private Functions */ +static void fdls_process_flogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr, +void *rx_frame); +static void fnic_fdls_start_plogi (struct fnic_iport_s *iport); +static void fnic_fdls_start_flogi (struct fnic_iport_s *iport); +static void fdls_start_fabric_timer (struct fnic_iport_s *iport, +int timeout); +static void +fdls_init_fabric_oxid_pool (struct fnic_fabric_oxid_pool_s *oxid_pool, +int oxid_base,int sz); + +void fdls_init_oxid_pool (struct fnic_iport_s *iport)
drivers/scsi/fnic/fdls_disc.c line 186
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+{ +fdls_init_fabric_oxid_pool (&iport->fabric_oxid_pool, +FDLS_FABRIC_OXID_POOL_BASE , +FDLS_FABRIC_OXID_POOL_SZ ); + +fdls_init_fabric_oxid_pool (&iport->fdmi_oxid_pool, +FDLS_FDMI_OXID_POOL_BASE , +FDLS_FDMI_OXID_POOL_SZ ); +} +
Where are these functions defined?
Please rearrange the patch series such that these functions are defined with an earlier patch.
Quoted 12 lines
drivers/scsi/fnic/fdls_disc.c new file +12
-0+uint16_t fdls_alloc_oxid (struct fnic_iport_s *iport, +struct fnic_oxid_pool_meta_s *meta, +unsigned long *bitmap) +{ +struct fnic *fnic = iport->fnic; +struct reclaim_entry_s *reclaim_entry, *next; +int idx; +uint16_t oxid; +unsigned long expiry_ts; + +/* first walk through the oxid slots and reclaim any expired */ + list_for_each_entry_safe(reclaim_entry, next,
drivers/scsi/fnic/fdls_disc.c line 208
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ &(meta->reclaim_list), links) { + expiry_ts = reclaim_entry->timestamp + +msecs_to_jiffies (2 * iport->r_a_tov); +if (time_after (jiffies, expiry_ts)) { +list_del (&reclaim_entry->links); +fdls_free_oxid (iport, meta, bitmap, reclaim_entry->oxid); +kfree (reclaim_entry); + } + } +
That is quite inefficient. You walk the free list every time you want to allocate an new OXID. This increased the time to fetch an OXID, and ties the reclaim to the allocation.
It might be an idea to decouple both, and have a reclaim timer which then walks the reclaim list once the first has expired, restarting at the time the next-to-last oldest entry expires.
That would allow you to not having to walk the reclaim list during allocation.
Quoted 5 lines
drivers/scsi/fnic/fdls_disc.c new file +5
-0+/* Allocate next available oxid from bitmap */ + idx =find_next_zero_bit (bitmap, meta->sz, meta->next_idx); + +if (idx == meta->sz) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
drivers/scsi/fnic/fdls_disc.c line 223
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+"Alloc oxid: all oxid slots are busy iport state:%d\n" , + iport->state); +return 0xFFFF ; + } + +/* adding the oxid index to pool base will give the oxid */ + oxid = idx + meta->oxid_base; +set_bit (idx, bitmap); + meta->next_idx = (idx +1 ) % meta->sz;/* cycle through the bitmap */ +
That's a bit odd; you walk the free list to find expired oxids, yet use a bitmap to lookup free ones.
I would have expected the same mechanism for both; otherwise, how do you
ensure that the list and the bitmap is kept in sync?
Plus you actually have a race condition; first you look for the next free oxid, and then (in a separate step!) you do the set_bit() operation to actually claim it.
You should be doing a 'test_and_set_bit()' here, and re-run the loop
once that failed (as then the selected OXID had been taken by another thread).
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c new file +9
-0+return oxid; +} + +void fdls_free_oxid (struct fnic_iport_s *iport, +struct fnic_oxid_pool_meta_s *meta, +unsigned long *bitmap,uint16_t oxid) +{ +struct fnic *fnic = iport->fnic; +int idx;
drivers/scsi/fnic/fdls_disc.c line 242
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ + idx =FDLS_OXID_TO_IDX (meta, oxid); + +if (!test_bit (idx, bitmap)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Free oxid: already freed, iport state:%d\n" , + iport->state); + } +clear_bit (idx, bitmap); +}
test_and_clear_bit(), please.
Otherwise you have a race condition.
drivers/scsi/fnic/fdls_disc.c line 253
Quoted 11 lines
drivers/scsi/fnic/fdls_disc.c new file +11
-0+ +static void +fdls_init_fabric_oxid_pool (struct fnic_fabric_oxid_pool_s *oxid_pool, +int oxid_base,int sz) +{ +memset (oxid_pool,0 ,sizeof (struct fnic_fabric_oxid_pool_s )); + oxid_pool->meta.oxid_base = oxid_base; + oxid_pool->meta.sz = sz; +INIT_LIST_HEAD (&oxid_pool->meta.reclaim_list); +} +
Ah, here are the functions. Please move them to the top of the file.
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c new file +9
-0+/* +* fdls_alloc_fabric_oxid - Allocate fabric oxid from a pool +* @iport: Handle to fnic iport +* @oxid_pool: Pool to allocate from +* @exp_rsp_type: Response type that we expect +* +* Wrapper for fabric and fdmi oxid allocations. +* Called with fnic_lock held. +* Encode the allocated OXID with expected rsp type for easier
drivers/scsi/fnic/fdls_disc.c line 272
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+* identification of the rx response and convenient debugging with switches +*/ +uint16_t fdls_alloc_fabric_oxid (struct fnic_iport_s *iport, +struct fnic_fabric_oxid_pool_s *oxid_pool, +int exp_rsp_type) +{ +uint16_t oxid; + + oxid =fdls_alloc_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap); +
Ho-hum.
So you are guaranteed to get an OXID from the pool? Really?
Shouldn't you check if you actually got a valid OXID back?
Quoted 26 lines
drivers/scsi/fnic/fdls_disc.c new file +26
-0+ oxid =FDLS_OXID_ENCODE (oxid, exp_rsp_type); + +/* Save the corresponding active oxid for abort, if needed. +* Since fabric requests are serialized, they need only one. +* fdmi_reg_hba and fdmi_hpa can go in parallel. Save them +* separately. +*/ +switch (exp_rsp_type) { +default : + oxid_pool->active_oxid_fabric_req = oxid; +break ; + } + +return oxid; +} + +inline void fdls_free_fabric_oxid (struct fnic_iport_s *iport, +struct fnic_fabric_oxid_pool_s + *oxid_pool,uint16_t oxid) +{ +fdls_free_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap, oxid); +} + +static void fdls_schedule_oxid_free (struct fnic_oxid_pool_meta_s *meta, +uint16_t oxid) +{
drivers/scsi/fnic/fdls_disc.c line 308
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+struct reclaim_entry_s *reclaim_entry; + + reclaim_entry = (struct reclaim_entry_s *) +kzalloc (sizeof (struct reclaim_entry_s ),GFP_KERNEL ); + reclaim_entry->oxid = oxid; + reclaim_entry->timestamp = jiffies; + +list_add_tail (&reclaim_entry->links, &meta->reclaim_list); +} +
As mentioned above; you already know when the oxid will expire at this point. So you might as well trigger a workqueue (or a timer) reclaiming the OXID once the timer expires.
Quoted 146 lines
drivers/scsi/fnic/fdls_disc.c new file +146
-0+static inline void fdls_schedule_fabric_oxid_free (struct fnic_iport_s + *iport) +{ +fdls_schedule_oxid_free (&iport->fabric_oxid_pool.meta, + iport->fabric_oxid_pool.active_oxid_fabric_req); +} + +int fnic_fdls_expected_rsp (struct fnic_iport_s *iport,uint16_t oxid) +{ +struct fnic *fnic = iport->fnic; + +/* Received oxid should match with one of the following */ +if ((oxid != iport->fabric_oxid_pool.active_oxid_fabric_req) && + (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_plogi) && + (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_rhba) && + (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_rpa)) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received oxid(0x%x) not matching in oxid pool (0x%x) state:%d" , + oxid, iport->fabric_oxid_pool.active_oxid_fabric_req, + iport->fabric.state); +return 0xFFFF ; + } + +return FDLS_OXID_TO_RSP_TYPE (oxid); +} + +static int fdls_is_oxid_in_fabric_range (uint16_t oxid) +{ +uint16_t oxid_unmasked =FDLS_OXID_RSP_TYPE_UNMASKED (oxid); + +return ((oxid_unmasked >=FDLS_FABRIC_OXID_POOL_BASE ) && + (oxid_unmasked <=FDLS_FABRIC_OXID_POOL_END )); +} + +inline void fnic_del_fabric_timer_sync (struct fnic *fnic) +{ + fnic->iport.fabric.del_timer_inprogress =1 ; +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +del_timer_sync (&fnic->iport.fabric.retry_timer); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + fnic->iport.fabric.del_timer_inprogress =0 ; +} + +inline void fnic_del_tport_timer_sync (struct fnic *fnic, +struct fnic_tport_s *tport) +{ + tport->del_timer_inprogress =1 ; +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +del_timer_sync (&tport->retry_timer); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + tport->del_timer_inprogress =0 ; +} + +static void +fdls_start_fabric_timer (struct fnic_iport_s *iport,int timeout) +{ +u64 fabric_tov; +struct fnic *fnic = iport->fnic; + +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" , + iport->fcid); +fnic_del_fabric_timer_sync (fnic); + iport->fabric.timer_pending =0 ; + } + +if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) + iport->fabric.retry_counter++; + + 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, +"fabric timer is %d " , timeout); +} + +static void fdls_send_fabric_abts (struct fnic_iport_s *iport) +{ +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header fabric_abort = fc_std_fabric_abts; +struct fc_frame_header *fabric_abts = &fabric_abort; +uint16_t oxid; + +switch (iport->fabric.state) { +case FDLS_STATE_FABRIC_LOGO : + fabric_abts->fh_d_id[2 ] =0xFE ; +break ; + +case FDLS_STATE_FABRIC_FLOGI : + fabric_abts->fh_d_id[2 ] =0xFE ; +break ; + +case FDLS_STATE_FABRIC_PLOGI : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_RPN_ID : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_SCR : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFD ; +break ; + +case FDLS_STATE_REGISTER_FC4_TYPES : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_REGISTER_FC4_FEATURES : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_GPN_FT : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; +default : +return ; + } + + oxid = iport->fabric_oxid_pool.active_oxid_fabric_req; +FNIC_STD_SET_OX_ID (fabric_abts,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending fabric abts. iport->fabric.state: %d, oxid:%x" , + iport->fabric.state, oxid); + + iport->fabric.flags |=FNIC_FDLS_FABRIC_ABORT_ISSUED ; + +fnic_send_fcoe_frame (iport, fabric_abts, +sizeof (struct fc_frame_header )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov);
drivers/scsi/fnic/fdls_disc.c line 464
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ iport->fabric.timer_pending =1 ; +} + +static void fdls_send_fabric_flogi (struct fnic_iport_s *iport) +{ +struct fc_std_flogi flogi; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&flogi, &fnic_std_flogi_req,sizeof (struct fc_std_flogi ));
Wouldn't it be better to move the static 'fnic_std_flogi_req' definition as an initialisation for 'flogi' here?
That would save you the 'memcpy', and the slightly awkward coding style. (Having a statically defined structure which is later then copied over to the actual structure is very uncommon, at least in the linux kernel.)
Quoted 23 lines
drivers/scsi/fnic/fdls_disc.c new file +23
-0+FNIC_LOGI_SET_NPORT_NAME (&flogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&flogi.els, iport->wwnn); +FNIC_LOGI_SET_RDF_SIZE (&flogi.els, iport->max_payload_size); +FNIC_LOGI_SET_R_A_TOV (&flogi.els, iport->r_a_tov); +FNIC_LOGI_SET_E_D_TOV (&flogi.els, iport->e_d_tov); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_FLOGI_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send flogi %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&flogi.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send fabric flogi with oxid:%x" , iport->fcid, + oxid); + +fnic_send_fcoe_frame (iport, &flogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}
drivers/scsi/fnic/fdls_disc.c line 497
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_fabric_plogi (struct fnic_iport_s *iport) +{ +struct fc_std_flogi plogi; +struct fc_frame_header *fchdr = &plogi.fchdr; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&plogi, &fnic_std_plogi_req,sizeof (struct fc_std_flogi ));
Same comment as above for the memcpy()
Quoted 25 lines
drivers/scsi/fnic/fdls_disc.c new file +25
-0+ +hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID (fchdr, fcid); +FNIC_LOGI_SET_NPORT_NAME (&plogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&plogi.els, iport->wwnn); +FNIC_LOGI_SET_RDF_SIZE (&plogi.els, iport->max_payload_size); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_PLOGI_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fabric plogi %p" , + iport); +return ; + } +FNIC_STD_SET_OX_ID (fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send fabric PLOGI with oxid:%x" , iport->fcid, + oxid); + +fnic_send_fcoe_frame (iport, &plogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov);
drivers/scsi/fnic/fdls_disc.c line 532
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+} + +static void fdls_send_rpn_id (struct fnic_iport_s *iport) +{ +struct fc_std_rpn_id rpn_id; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&rpn_id, &fnic_std_rpn_id_req,sizeof (struct fc_std_rpn_id ));
And here.
Quoted 23 lines
drivers/scsi/fnic/fdls_disc.c new file +23
-0+ +hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID ((&rpn_id.fchdr), fcid); +FNIC_STD_SET_PORT_ID ((&rpn_id.rpn_id), fcid); +FNIC_STD_SET_PORT_NAME ((&rpn_id.rpn_id), iport->wwpn); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_RPN_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send rpn id %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&rpn_id.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send RPN ID with oxid:%x" , iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &rpn_id,sizeof (struct fc_std_rpn_id )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}
drivers/scsi/fnic/fdls_disc.c line 565
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_scr (struct fnic_iport_s *iport) +{ +struct fc_std_scr scr; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&scr, &fnic_std_scr_req,sizeof (struct fc_std_scr )); +
And here.
Quoted 20 lines
drivers/scsi/fnic/fdls_disc.c new file +20
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&scr.fchdr), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_SCR_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send scr %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&scr.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send SCR with oxid:%x" , iport->fcid, oxid); + + +fnic_send_fcoe_frame (iport, &scr,sizeof (struct fc_std_scr )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}
drivers/scsi/fnic/fdls_disc.c line 595
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_gpn_ft (struct fnic_iport_s *iport,int fdls_state) +{ +struct fc_std_gpn_ft gpn_ft; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&gpn_ft, &fnic_std_gpn_ft_req,sizeof (struct fc_std_gpn_ft )); +
And here.
Quoted 21 lines
drivers/scsi/fnic/fdls_disc.c new file +21
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&gpn_ft.fchdr), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_GPN_FT_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send GPN FT %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&gpn_ft.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send GPN FT with oxid:%x" , iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &gpn_ft,sizeof (struct fc_std_gpn_ft )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +fdls_set_state ((&iport->fabric), fdls_state); +} +
drivers/scsi/fnic/fdls_disc.c line 626
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+static void fdls_send_register_fc4_types (struct fnic_iport_s *iport) +{ +struct fc_std_rft_id rft_id; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memset (&rft_id,0 ,sizeof (struct fc_std_rft_id )); +memcpy (&rft_id, &fnic_std_rft_id_req,sizeof (struct fc_std_rft_id )); +hton24 (fcid, iport->fcid);
And here.
Quoted 27 lines
drivers/scsi/fnic/fdls_disc.c new file +27
-0+ +FNIC_STD_SET_S_ID ((&rft_id.fchdr), fcid); +FNIC_STD_SET_PORT_ID ((&rft_id.rft_id), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_RFT_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send RFT %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&rft_id.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS sending FC4 Typeswith oxid:%x" , iport->fcid, + oxid); + +if (IS_FNIC_FCP_INITIATOR (fnic)) + rft_id.rft_id.fr_fts.ff_type_map[0 ] = +cpu_to_be32 (1 <<FC_TYPE_FCP ); + + rft_id.rft_id.fr_fts.ff_type_map[1 ] = +cpu_to_be32 (1 << (FC_TYPE_CT %FC_NS_BPW )); + +fnic_send_fcoe_frame (iport, &rft_id,sizeof (struct fc_std_rft_id )); +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}
drivers/scsi/fnic/fdls_disc.c line 663
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_register_fc4_features (struct fnic_iport_s *iport) +{ +struct fc_std_rff_id rff_id; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&rff_id, &fnic_std_rff_id_req,sizeof (struct fc_std_rff_id )); +
And here.
Quoted 41 lines
drivers/scsi/fnic/fdls_disc.c new file +41
-0+hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID ((&rff_id.fchdr), fcid); +FNIC_STD_SET_PORT_ID ((&rff_id.rff_id), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_RFF_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send RFF %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&rff_id.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS sending FC4 features with %x" , iport->fcid, + oxid); + +if (IS_FNIC_FCP_INITIATOR (fnic)) { + rff_id.rff_id.fr_type =FC_TYPE_FCP ; + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Unknown type" , iport->fcid); + } + +fnic_send_fcoe_frame (iport, &rff_id,sizeof (struct fc_std_rff_id )); +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +} + +/** +* fdls_send_fabric_logo - Send flogo to the fcf +* @iport: Handle to fnic iport +* +* This function does not change or check the fabric state. +* It the caller's responsibility to set the appropriate iport fabric +* state when this is called. Normally it is FDLS_STATE_FABRIC_LOGO. +* Currently this assumes to be called with fnic lock held. +*/ +void fdls_send_fabric_logo (struct fnic_iport_s *iport) +{ +struct fc_std_logo logo;
drivers/scsi/fnic/fdls_disc.c line 714
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+uint8_t s_id[3 ]; +uint8_t d_id[3 ] = {0xFF ,0xFF ,0xFE }; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to fabric from iport->fcid: 0x%x" , + iport->fcid); +memcpy (&logo, &fnic_std_logo_req,sizeof (struct fc_std_logo )); +
And here.
Quoted 945 lines
drivers/scsi/fnic/fdls_disc.c new file +945
-0+hton24 (s_id, iport->fcid); + +FNIC_STD_SET_S_ID ((&logo.fchdr), s_id); +FNIC_STD_SET_D_ID ((&logo.fchdr), d_id); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_LOGO_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fabric logo %p" , + iport); +return ; + } +FNIC_STD_SET_OX_ID ((&logo.fchdr),htons (oxid)); + +memcpy (&logo.els.fl_n_port_id, s_id,3 ); +FNIC_STD_SET_NPORT_NAME (&logo.els.fl_n_port_wwn, +le64_to_cpu (iport->wwpn)); + +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); + + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to fabric from fcid %x with oxid %x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); +} + +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) { +case FDLS_STATE_FABRIC_FLOGI : +/* Flogi received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter < iport->max_flogi_retries)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_fabric_flogi (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* Flogi has time out 2*ed_tov send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out +* Mark the OXID to be freed after 2 * r_a_tov and retry the req +*/ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter < iport->max_flogi_retries) { + 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, +"Exceeded max FLOGI retries" ); + } +break ; +case FDLS_STATE_FABRIC_PLOGI : +/* Plogi received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter < iport->max_plogi_retries)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_fabric_plogi (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* Plogi has timed out 2*ed_tov send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out +* Mark the OXID to be freed after 2 * r_a_tov and retry the req +*/ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter < iport->max_plogi_retries) { + 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, +"Exceeded max PLOGI retries" ); + } +break ; +case FDLS_STATE_RPN_ID : +/* Rpn_id 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_rpn_id (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* RPN has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_SCR : +/* 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_scr (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* scr has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport); + } +break ; +case FDLS_STATE_REGISTER_FC4_TYPES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_types (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* RFT_ID timed out send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_REGISTER_FC4_FEATURES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_features (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* SCR has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_RSCN_GPN_FT : +case FDLS_STATE_SEND_GPNFT : +case FDLS_STATE_GPN_FT : +/* GPN_FT received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_gpn_ft (iport, iport->fabric.state); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* gpn_ft has timed out. Send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { +fdls_send_gpn_ft (iport, iport->fabric.state); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timeout for fabric GPN_FT. Check name server: %p" , + iport); + } + } +break ; +default : +fnic_fdls_start_flogi (iport);/* Placeholder call */ +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_rff_id_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic *fnic = iport->fnic; +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_rff_id *rff_rsp = (struct fc_std_rff_id *) fchdr; +uint16_t rsp; +uint8_t reason_code; + +if (fdls_get_state (fdls) !=FDLS_STATE_REGISTER_FC4_FEATURES ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"RFF_ID resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + + rsp =FNIC_STD_GET_FC_CT_CMD ((&rff_rsp->fc_std_ct_hdr)); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process RFF ID response: 0x%04x" , iport->fcid, + (uint32_t ) rsp); + +fdls_free_fabric_oxid (iport, &iport->fdmi_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (rsp) { +case FC_FS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + fdls->retry_counter =0 ; +fdls_set_state ((&iport->fabric),FDLS_STATE_SCR ); +fdls_send_scr (iport); +break ; +case FC_FS_RJT : + reason_code = rff_rsp->fc_std_ct_hdr.ct_reason; +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, +"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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; +default : +break ; + } +} + +static void +fdls_process_rft_id_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_rft_id *rft_rsp = (struct fc_std_rft_id *) fchdr; +uint16_t rsp; +uint8_t reason_code; +struct fnic *fnic = iport->fnic; + +if (fdls_get_state (fdls) !=FDLS_STATE_REGISTER_FC4_TYPES ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"RFT_ID resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + + rsp =FNIC_STD_GET_FC_CT_CMD ((&rft_rsp->fc_std_ct_hdr)); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process RFT ID response: 0x%04x" , iport->fcid, + (uint32_t ) rsp); + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (rsp) { +case FC_FS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + fdls->retry_counter =0 ; +fdls_send_register_fc4_features (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_REGISTER_FC4_FEATURES ); +break ; +case FC_FS_RJT : + reason_code = rft_rsp->fc_std_ct_hdr.ct_reason; +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: 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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; +default : +break ; + } +} + +static void +fdls_process_rpn_id_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_rpn_id *rpn_rsp = (struct fc_std_rpn_id *) fchdr; +uint16_t rsp; +uint8_t reason_code; +struct fnic *fnic = iport->fnic; + +if (fdls_get_state (fdls) !=FDLS_STATE_RPN_ID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"RPN_ID resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + + rsp =FNIC_STD_GET_FC_CT_CMD ((&rpn_rsp->fc_std_ct_hdr)); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process RPN ID response: 0x%04x" , iport->fcid, + (uint32_t ) rsp); + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (rsp) { +case FC_FS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + fdls->retry_counter =0 ; +fdls_send_register_fc4_types (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_REGISTER_FC4_TYPES ); +break ; +case FC_FS_RJT : + reason_code = rpn_rsp->fc_std_ct_hdr.ct_reason; +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, +"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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; +default : +break ; + } +} + +static void +fdls_process_scr_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_scr *scr_rsp = (struct fc_std_scr *) fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *) fchdr; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"SCR resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (scr_rsp->scr.scr_cmd) { +case ELS_LS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + iport->fabric.retry_counter =0 ; +fdls_send_gpn_ft (iport,FDLS_STATE_GPN_FT ); +break ; + +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (fdls->retry_counter <FDLS_RETRY_COUNT )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; + +default : +break ; + } +} + +static void +fdls_process_gpn_ft_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr,int len) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_gpn_ft *gpn_ft_rsp = (struct fc_std_gpn_ft *) fchdr; +uint16_t rsp; +uint8_t reason_code; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS process GPN_FT response: iport state: %d len: %d" , + iport->state, len); + +/* +* GPNFT response :- +* FDLS_STATE_GPN_FT : GPNFT send after SCR state +* during fabric discovery(FNIC_IPORT_STATE_FABRIC_DISC) +* FDLS_STATE_RSCN_GPN_FT : GPNFT send in response to RSCN +* FDLS_STATE_SEND_GPNFT : GPNFT send after deleting a Target, +* e.g. after receiving Target LOGO +* FDLS_STATE_TGT_DISCOVERY :Target discovery is currently in progress +* from previous GPNFT response,a new GPNFT response has come. +*/ +if (!(((iport->state ==FNIC_IPORT_STATE_FABRIC_DISC ) + && (fdls_get_state (fdls) ==FDLS_STATE_GPN_FT )) + || ((iport->state ==FNIC_IPORT_STATE_READY ) + && ((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, +"GPNFT resp recvd in fab state(%d) iport_state(%d). Dropping." , +fdls_get_state (fdls), iport->state); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + + iport->state =FNIC_IPORT_STATE_READY ; + rsp =FNIC_STD_GET_FC_CT_CMD ((&gpn_ft_rsp->fc_std_ct_hdr)); + +switch (rsp) { + +case FC_FS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: GPNFT_RSP accept" , iport->fcid); +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); +break ; + +default : +break ; + } +} + +/** +* fdls_process_fabric_logo_rsp - Handle an flogo response from the fcf +* @iport: Handle to fnic iport +* @fchdr: Incoming frame +*/ +static void +fdls_process_fabric_logo_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_flogi *flogo_rsp = (struct fc_std_flogi *) fchdr; +struct fnic *fnic = iport->fnic; + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +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, +"Flogo response. Fabric not in LOGO state. Dropping! %p" , + iport); +return ; + } + + iport->fabric.state =FDLS_STATE_FLOGO_DONE ; + iport->state =FNIC_IPORT_STATE_LINK_WAIT ; + +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"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, +"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, +"FLOGO response not accepted or rejected: 0x%x" , + flogo_rsp->els.fl_cmd); + } +} + +static void +fdls_process_flogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr,void *rx_frame) +{ +struct fnic_fdls_fabric_s *fabric = &iport->fabric; +struct fc_std_flogi *flogi_rsp = (struct fc_std_flogi *) fchdr; +uint8_t *fcid; +int rdf_size; +uint8_t fcmac[6 ] = {0x0E ,0XFC ,0x00 ,0x00 ,0x00 ,0x00 }; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"FLOGI response received in state (%d). Dropping frame" , +fdls_get_state (fabric)); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (flogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +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" , + iport->fcid); +fnic_del_fabric_timer_sync (fnic); + } + + iport->fabric.timer_pending =0 ; + 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, +"0x%x: FLOGI response accepted" , iport->fcid); + +/* Learn the Service Params */ + rdf_size =ntohs (FNIC_LOGI_RDF_SIZE (&flogi_rsp->els)); +if ((rdf_size >=FNIC_MIN_DATA_FIELD_SIZE ) + && (rdf_size <FNIC_FC_MAX_PAYLOAD_LEN )) + iport->max_payload_size =MIN (rdf_size, + iport->max_payload_size); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"max_payload_size from fabric: %d set: %d" , rdf_size, + iport->max_payload_size); + + iport->r_a_tov =ntohl (FNIC_LOGI_R_A_TOV (&flogi_rsp->els)); + iport->e_d_tov =ntohl (FNIC_LOGI_E_D_TOV (&flogi_rsp->els)); + +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, +"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) = +get_unaligned_be64 (&FNIC_LOGI_NODE_NAME (&flogi_rsp->els)); +fc_host_port_id (iport->fnic->lport->host) = iport->fcid; + } + +fnic_fdls_learn_fcoe_macs (iport, rx_frame, fcid); + +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" , + fcmac[0 ], fcmac[1 ], fcmac[2 ], fcmac[3 ], fcmac[4 ], + fcmac[5 ]); +vnic_dev_add_addr (iport->fnic->vdev, fcmac); + +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, +"FLOGI response received. Starting PLOGI" ); + }else { +/* From FDLS_STATE_FABRIC_FLOGI state fabric can only go to +* FDLS_STATE_LINKDOWN +* 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, +"FLOGI response received in state (%d). Dropping frame" , +fdls_get_state (fabric)); + } +break ; + +case ELS_LS_RJT : +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" , + iport); + +/* Retry Flogi again from the timer routine. */ + fabric->flags |=FNIC_FDLS_RETRY_FRAME ; + + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"iport 0x%p Canceling fabric disc timer\n" , + iport); +fnic_del_fabric_timer_sync (fnic); + } + fabric->timer_pending =0 ; + fabric->retry_counter =0 ; + } +break ; + +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FLOGI response not accepted: 0x%x" , + flogi_rsp->els.fl_cmd); +break ; + } +} + +static void +fdls_process_fabric_plogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *) fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *) fchdr; +struct fnic *fnic = iport->fnic; + +if (fdls_get_state ((&iport->fabric)) !=FDLS_STATE_FABRIC_PLOGI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Fabric PLOGI response received in state (%d). Dropping frame" , +fdls_get_state (&iport->fabric)); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (plogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +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" , + iport->fcid); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + iport->fabric.retry_counter =0 ; +fdls_set_state (&iport->fabric,FDLS_STATE_RPN_ID ); +fdls_send_rpn_id (iport); +break ; +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (iport->fabric.retry_counter < iport->max_plogi_retries)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"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, +"iport fcid: 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 ; +return ; + } +break ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI response not accepted: 0x%x" , + plogi_rsp->els.fl_cmd); +break ; + } +} + +static void +fdls_process_fabric_abts_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t s_id; +struct fc_std_abts_ba_acc *ba_acc = + (struct fc_std_abts_ba_acc *) fchdr; +struct fc_std_abts_ba_rjt *ba_rjt; +uint32_t fabric_state = iport->fabric.state; +struct fnic *fnic = iport->fnic; +int expected_rsp; +uint16_t oxid; + + s_id =ntoh24 (fchdr->fh_s_id); + ba_rjt = (struct fc_std_abts_ba_rjt *) fchdr; + +if (!((s_id ==FC_DIR_SERVER ) || (s_id ==FC_DOMAIN_CONTR ) + || (s_id ==FC_FABRIC_CONTROLLER ))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp with invalid SID: 0x%x. Dropping frame" , + s_id); +return ; + } + +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; + +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp BA_ACC for fabric_state: %d OX_ID: 0x%x" , + fabric_state,be16_to_cpu (ba_acc->acc.ba_ox_id)); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"BA_RJT fs: %d OX_ID: 0x%x rc: 0x%x rce: 0x%x" , + fabric_state,be16_to_cpu (ba_rjt->fchdr.fh_ox_id), + ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan); + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); + expected_rsp =FDLS_OXID_TO_RSP_TYPE (oxid); +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, oxid); + +/* currently error handling/retry logic is same for ABTS BA_ACC & BA_RJT */ +switch (fabric_state) { +case FDLS_STATE_FABRIC_FLOGI : +if (expected_rsp ==FNIC_FABRIC_FLOGI_RSP ) { +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, +"Exceeded max FLOGI retries" ); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x FABRIC_FLOGI state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_FABRIC_LOGO : +if (expected_rsp ==FNIC_FABRIC_LOGO_RSP ) { +if (!RETRIES_EXHAUSTED (iport)) +fdls_send_fabric_logo (iport); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x FABRIC_FLOGI state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_FABRIC_PLOGI : +if (expected_rsp ==FNIC_FABRIC_PLOGI_RSP ) { +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, +"Exceeded max PLOGI retries" ); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x FABRIC_PLOGI state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +case FDLS_STATE_RPN_ID : +if (expected_rsp ==FNIC_FABRIC_RPN_RSP ) { +if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { +fdls_send_rpn_id (iport); + }else { +/* go back to fabric Plogi */ +fnic_fdls_start_plogi (iport); + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x RPN_ID state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +case FDLS_STATE_SCR : +if (expected_rsp ==FNIC_FABRIC_SCR_RSP ) { +if (iport->fabric.retry_counter <=FDLS_RETRY_COUNT ) +fdls_send_scr (iport); +else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"abts rsp fab SCR after two tries. Start fabric PLOGI %p" , + iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x SCR state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_REGISTER_FC4_TYPES : +if (expected_rsp ==FNIC_FABRIC_RFT_RSP ) { +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, +"abts rsp fab RFT_ID two tries. Start fabric PLOGI %p" , + iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x RFT state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_REGISTER_FC4_FEATURES : +if (expected_rsp ==FNIC_FABRIC_RFF_RSP ) { +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, +"abts rsp fab SCR after two tries. Start fabric PLOGI %p" , + iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x RFF state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +case FDLS_STATE_GPN_FT : +if (expected_rsp ==FNIC_FABRIC_GPN_FT_RSP ) { +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, +"abts rsp fab GPN_FT after two tries %p" , + iport); + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x GPN_FT state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +default : +return ;
drivers/scsi/fnic/fdls_disc.c line 1669
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ } +} + +/* +* Performs a validation for all FCOE frames and return the frame type +*/ +int +fnic_fdls_validate_and_get_frame_type (struct fnic_iport_s *iport, +void *rx_frame,int len, +int fchdr_offset)
Indentation.
Quoted 320 lines
drivers/scsi/fnic/fdls_disc.c new file +237
-0+{ +struct fc_frame_header *fchdr; +uint8_t type; +uint8_t *fc_payload; +uint16_t oxid; +uint32_t s_id; +uint32_t d_id; +struct fnic *fnic = iport->fnic; +struct fnic_fdls_fabric_s *fabric = &iport->fabric; +int rsp_type; + + fchdr = + (struct fc_frame_header *) ((uint8_t *) rx_frame + fchdr_offset); + oxid =FNIC_STD_GET_OX_ID (fchdr); + fc_payload = (uint8_t *) fchdr +sizeof (struct fc_frame_header ); + type = *fc_payload; + s_id =ntoh24 (fchdr->fh_s_id); + d_id =ntoh24 (fchdr->fh_d_id); + +/* some common validation */ +if (iport->fcid) +if (fdls_get_state (fabric) >FDLS_STATE_FABRIC_FLOGI ) { +if ((iport->fcid != d_id) || (!FNIC_FC_FRAME_CS_CTL (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"invalid frame received. Dropping frame" ); +return -1 ; + } + } + +/* ABTS response */ +if ((fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) + || (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL )) { +if (!(FNIC_FC_FRAME_TYPE_BLS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received ABTS invalid frame. Dropping frame" ); +return -1 ; + + } +return FNIC_BLS_ABTS_RSP ; + } +if ((fchdr->fh_r_ctl ==FC_ABTS_RCTL ) + && (FNIC_FC_FRAME_TYPE_BLS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Receiving Abort Request from s_id: 0x%x" , s_id); +return FNIC_BLS_ABTS_REQ ; + } + +/* unsolicited requests frames */ +if (FNIC_FC_FRAME_UNSOLICITED (fchdr)) { +switch (type) { +case ELS_LOGO : +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, +"Received LOGO invalid frame. Dropping frame" ); +return -1 ; + } +return FNIC_ELS_LOGO_REQ ; +case ELS_RSCN : +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, +"Received RSCN invalid FCTL. Dropping frame" ); +return -1 ; + } +if (s_id !=FC_FABRIC_CONTROLLER ) +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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 ; +case ELS_PLOGI : +return FNIC_ELS_PLOGI_REQ ; +case ELS_ECHO : +return FNIC_ELS_ECHO_REQ ; +case ELS_ADISC : +return FNIC_ELS_ADISC ; +case ELS_RLS : +return FNIC_ELS_RLS ; +case ELS_RRQ : +return FNIC_ELS_RRQ ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unsupported frame (type:0x%02x) from fcid: 0x%x" , + type, s_id); +return FNIC_ELS_UNSUPPORTED_REQ ; + } + } + +/*response from fabric */ + rsp_type =fnic_fdls_expected_rsp (iport,ntohs (oxid)); + +switch (rsp_type) { + +case FNIC_FABRIC_FLOGI_RSP : +if (type ==ELS_LS_ACC ) { +if ((s_id !=FC_DOMAIN_CONTR ) + || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } + } +break ; + +case FNIC_FABRIC_PLOGI_RSP : +if (type ==ELS_LS_ACC ) { +if ((s_id !=FC_DIR_SERVER ) + || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } + } +break ; + +case FNIC_FABRIC_SCR_RSP : +if (type ==ELS_LS_ACC ) { +if ((s_id !=FC_FABRIC_CONTROLLER ) + || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } + } +break ; + +case FNIC_FABRIC_RPN_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_RFT_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_RFF_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_GPN_FT_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_LOGO_RSP : +break ; +default : +/* Drop the Rx frame and log/stats it */ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Solicited response: unknown OXID: 0x%x" , oxid); +return -1 ; + } + +return rsp_type; +} + +void fnic_fdls_recv_frame (struct fnic_iport_s *iport,void *rx_frame, +int len,int fchdr_offset) +{ +uint16_t oxid; +struct fc_frame_header *fchdr; +uint32_t s_id =0 ; +uint32_t d_id =0 ; +struct fnic *fnic = iport->fnic; +int frame_type; + + fchdr = + (struct fc_frame_header *) ((uint8_t *) rx_frame + fchdr_offset); + s_id =ntoh24 (fchdr->fh_s_id); + d_id =ntoh24 (fchdr->fh_d_id); + + frame_type = +fnic_fdls_validate_and_get_frame_type (iport, rx_frame, len, + fchdr_offset); + +/*if we are in flogo drop everything else */ +if (iport->fabric.state ==FDLS_STATE_FABRIC_LOGO && + frame_type !=FNIC_FABRIC_LOGO_RSP ) +return ; + +switch (frame_type) { +case FNIC_FABRIC_FLOGI_RSP : +fdls_process_flogi_rsp (iport, fchdr, rx_frame); +break ; +case FNIC_FABRIC_PLOGI_RSP : +fdls_process_fabric_plogi_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_RPN_RSP : +fdls_process_rpn_id_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_RFT_RSP : +fdls_process_rft_id_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_RFF_RSP : +fdls_process_rff_id_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_SCR_RSP : +fdls_process_scr_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_GPN_FT_RSP : +fdls_process_gpn_ft_rsp (iport, fchdr, len); +break ; +case FNIC_FABRIC_LOGO_RSP : +fdls_process_fabric_logo_rsp (iport, fchdr); +break ; + +case FNIC_BLS_ABTS_RSP : + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +if (fdls_is_oxid_in_fabric_range (oxid) && + (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +fdls_process_fabric_abts_rsp (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); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown FCoE frame of len: %d. Dropping frame" , len); +break ; + } +}drivers/scsi/fnic/fnic.h +22
-1@@ -24,6 +24,7 @@#include "vnic_intr.h" #include "vnic_stats.h" #include "vnic_scsi.h" +#include "fnic_fdls.h" #define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"@@ -31,6 +32,7 @@#define PFX DRV_NAME ": "#define DFX DRV_NAME "%d: " +#define FABRIC_LOGO_MAX_RETRY 3#define DESC_CLEAN_LOW_WATERMARK 8#define FNIC_UCSM_DFLT_THROTTLE_CNT_BLD 16/* UCSM default throttle count */ #define FNIC_MIN_IO_REQ 256/* Min IO throttle count */ @@ -75,6 +77,8 @@#define FNIC_DEV_RST_TERM_DONE BIT(20)#define FNIC_DEV_RST_ABTS_PENDING BIT(21) +#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +/* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. @@ -213,12 +217,26 @@ enum fnic_state {struct mempool ; +enum fnic_role_e { +FNIC_ROLE_FCP_INITIATOR =0 , +}; +enum fnic_evt {FNIC_EVT_START_VLAN_DISC =1 ,FNIC_EVT_START_FCF_DISC =2 ,FNIC_EVT_MAX , }; +struct fnic_frame_list { +/* +* Link to frame lists +*/ +struct list_head links; +void *fp; +int frame_len; +int rx_ethhdr_stripped; +}; +struct fnic_event {struct list_head list;struct fnic *fnic;@@ -235,6 +253,8 @@ struct fnic_cpy_wq {/* Per-instance private data structure */ struct fnic {int fnic_num; +enum fnic_role_e role; +struct fnic_iport_s iport;struct fc_lport *lport;struct fcoe_ctlr ctlr;/* FIP FCoE controller structure */ struct vnic_dev_bar bar0;@@ -278,6 +298,7 @@ struct fnic {unsigned long state_flags;/* protected by host lock */ enum fnic_state state;spinlock_t fnic_lock; +unsigned long lock_flags;u16 vlan_id;/* VLAN tag including priority */ u8 data_src_addr[ETH_ALEN ];@@ -307,7 +328,7 @@ struct fnic {struct work_struct frame_work;struct work_struct flush_work;struct sk_buff_head frame_queue; -struct sk_buff_head tx_queue; +struct list_head tx_queue;/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);
drivers/scsi/fnic/fnic.h void fnic_handle_fip_frame(struct work_struct *work); · line 400
Quoted 4 lines
drivers/scsi/fnic/fnic.h +0
-1@@ -397,7 +418,6 @@ 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 fnic *fnic);
Why is this here?
Quoted 258 lines
drivers/scsi/fnic/fnic.h +2
-0static inline int fnic_chk_state_flags_locked (struct fnic *fnic,unsigned long st_flags)@@ -406,4 +426,6 @@ fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags) }void __fnic_set_state_flags (struct fnic *,unsigned long ,unsigned long );void fnic_dump_fchost_stats (struct Scsi_Host *,struct fc_host_statistics *); +void fnic_free_txq (struct list_head *head); +#endif /* _FNIC_H_ */ drivers/scsi/fnic/fnic_fcs.c +116
-75@@ -20,6 +20,8 @@#include "fnic_io.h" #include "fnic.h" #include "fnic_fip.h" +#include "fnic_fdls.h" +#include "fdls_fc.h" #include "cq_enet_desc.h" #include "cq_exch_desc.h" @@ -28,12 +30,90 @@ struct workqueue_struct *fnic_fip_queue;struct workqueue_struct *fnic_event_queue;static void fnic_set_eth_mode (struct fnic *); -static void fnic_fcoe_send_vlan_req (struct fnic *fnic);static void fnic_fcoe_start_fcf_disc (struct fnic *fnic);static void fnic_fcoe_process_vlan_resp (struct fnic *fnic,struct sk_buff *);static int fnic_fcoe_vlan_check (struct fnic *fnic,u16 flag);static int fnic_fcoe_handle_fip_frame (struct fnic *fnic,struct sk_buff *skb); +/* Frame initialization */ +/* +* Variables: +* dst_mac, src_mac +*/ +struct fnic_eth_hdr_s fnic_eth_hdr_fcoe = { + .ether_type =0x0689 +}; + +/* +* Variables: +* None +*/ +struct fnic_fcoe_hdr_s fnic_fcoe_hdr = { + .sof =0x2E +}; + +uint8_t FCOE_ALL_FCF_MAC [6 ] = {0x0e ,0xfc ,0x00 ,0xff ,0xff ,0xfe }; + +/* +* Internal Functions +* This function will initialize the src_mac address to be +* used in outgoing frames +*/ +static inline void fnic_fdls_set_fcoe_srcmac (struct fnic *fnic, +uint8_t *src_mac) +{ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Setting src mac: %02x:%02x:%02x:%02x:%02x:%02x" , + src_mac[0 ], src_mac[1 ], src_mac[2 ], src_mac[3 ], + src_mac[4 ], src_mac[5 ]); + +memcpy (fnic->iport.fpma, src_mac,6 ); +} + +/* +* This function will initialize the dst_mac address to be +* used in outgoing frames +*/ +static inline void fnic_fdls_set_fcoe_dstmac (struct fnic *fnic, +uint8_t *dst_mac) +{ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Setting dst mac: %02x:%02x:%02x:%02x:%02x:%02x" , + dst_mac[0 ], dst_mac[1 ], dst_mac[2 ], dst_mac[3 ], + dst_mac[4 ], dst_mac[5 ]); + +memcpy (fnic->iport.fcfmac, dst_mac,6 ); +} + +/* +* FPMA can be either taken from ethhdr(dst_mac) or flogi resp +* or derive from FC_MAP and FCID combination. While it should be +* same, revisit this if there is any possibility of not-correct. +*/ +void fnic_fdls_learn_fcoe_macs (struct fnic_iport_s *iport,void *rx_frame, +uint8_t *fcid) +{ +struct fnic *fnic = iport->fnic; +struct fnic_eth_hdr_s *ethhdr = (struct fnic_eth_hdr_s *) rx_frame; +uint8_t fcmac[6 ] = {0x0E ,0xFC ,0x00 ,0x00 ,0x00 ,0x00 }; + +memcpy (&fcmac[3 ], fcid,3 ); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"learn fcoe: dst_mac: %02x:%02x:%02x:%02x:%02x:%02x" , + ethhdr->dst_mac[0 ], ethhdr->dst_mac[1 ], + ethhdr->dst_mac[2 ], ethhdr->dst_mac[3 ], + ethhdr->dst_mac[4 ], ethhdr->dst_mac[5 ]); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"learn fcoe: fc_mac: %02x:%02x:%02x:%02x:%02x:%02x" , + fcmac[0 ], fcmac[1 ], fcmac[2 ], fcmac[3 ], fcmac[4 ], + fcmac[5 ]); + +fnic_fdls_set_fcoe_srcmac (fnic, fcmac); +fnic_fdls_set_fcoe_dstmac (fnic, ethhdr->src_mac); +} +void fnic_handle_link (struct work_struct *work) { struct fnic *fnic = container_of(work, struct fnic, link_work);@@ -363,7 +443,7 @@ static inline int is_fnic_fip_flogi_reject(struct fcoe_ctlr *fip,return 0 ; } -static void fnic_fcoe_send_vlan_req (struct fnic *fnic) +void fnic_fcoe_send_vlan_req (struct fnic *fnic) {struct fcoe_ctlr *fip = &fnic->ctlr;struct fnic_stats *fnic_stats = &fnic->fnic_stats;@@ -1068,116 +1148,119 @@ void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb)/* * Send FC frame. */ -static int fnic_send_frame (struct fnic *fnic,struct fc_frame *fp) +static int fnic_send_frame (struct fnic *fnic,void *frame,int frame_len) {struct vnic_wq *wq = &fnic->wq[0 ]; -struct sk_buff *skb;dma_addr_t pa; -struct ethhdr *eth_hdr; -struct vlan_ethhdr *vlan_hdr; -struct fcoe_hdr *fcoe_hdr; -struct fc_frame_header *fh; -u32 tot_len, eth_hdr_len;int ret =0 ;unsigned long flags; - fh =fc_frame_header_get (fp); - skb =fp_skb (fp); - -if (unlikely (fh->fh_r_ctl ==FC_RCTL_ELS_REQ ) && -fcoe_ctlr_els_send (&fnic->ctlr, fnic->lport, skb)) -return 0 ; - -if (!fnic->vlan_hw_insert) { - eth_hdr_len =sizeof (*vlan_hdr) +sizeof (*fcoe_hdr); - vlan_hdr =skb_push (skb, eth_hdr_len); - eth_hdr = (struct ethhdr *)vlan_hdr; - vlan_hdr->h_vlan_proto =htons (ETH_P_8021Q ); - vlan_hdr->h_vlan_encapsulated_proto =htons (ETH_P_FCOE ); - vlan_hdr->h_vlan_TCI =htons (fnic->vlan_id); - fcoe_hdr = (struct fcoe_hdr *)(vlan_hdr +1 ); - }else { - eth_hdr_len =sizeof (*eth_hdr) +sizeof (*fcoe_hdr); - eth_hdr =skb_push (skb, eth_hdr_len); - eth_hdr->h_proto =htons (ETH_P_FCOE ); - fcoe_hdr = (struct fcoe_hdr *)(eth_hdr +1 ); - } - -if (fnic->ctlr.map_dest) -fc_fcoe_set_mac (eth_hdr->h_dest, fh->fh_d_id); -else -memcpy (eth_hdr->h_dest, fnic->ctlr.dest_addr,ETH_ALEN ); -memcpy (eth_hdr->h_source, fnic->data_src_addr,ETH_ALEN ); - - tot_len = skb->len; -BUG_ON (tot_len %4 ); + pa =dma_map_single (&fnic->pdev->dev, frame, frame_len,DMA_TO_DEVICE ); -memset (fcoe_hdr,0 ,sizeof (*fcoe_hdr)); - fcoe_hdr->fcoe_sof =fr_sof (fp); -if (FC_FCOE_VER ) -FC_FCOE_ENCAPS_VER (fcoe_hdr,FC_FCOE_VER ); - - pa =dma_map_single (&fnic->pdev->dev, eth_hdr, tot_len,DMA_TO_DEVICE ); -if (dma_mapping_error (&fnic->pdev->dev, pa)) { - ret = -ENOMEM ; -printk (KERN_ERR "DMA map failed with error %d\n" , ret); - goto free_skb_on_err; - } - -if ((fnic_fc_trace_set_data (fnic->lport->host->host_no,FNIC_FC_SEND , - (char *)eth_hdr, tot_len)) !=0 ) { -printk (KERN_ERR "fnic ctlr frame trace error!!!" ); +if ((fnic_fc_trace_set_data (fnic->fnic_num, +FNIC_FC_SEND |0x80 , (char *) frame, + frame_len)) !=0 ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fnic ctlr frame trace error" ); }spin_lock_irqsave (&fnic->wq_lock[0 ], flags);if (!vnic_wq_desc_avail (wq)) { -dma_unmap_single (&fnic->pdev->dev, pa, tot_len,DMA_TO_DEVICE ); +dma_unmap_single (&fnic->pdev->dev, pa, frame_len,DMA_TO_DEVICE ); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"vnic work queue descriptor is not available" ); ret =-1 ; - goto irq_restore; + goto fnic_send_frame_end; } -fnic_queue_wq_desc (wq, skb, pa, tot_len,fr_eof (fp), -0 /* hw inserts cos value */ , - fnic->vlan_id,1 ,1 ,1 ); +/* hw inserts cos value */ +fnic_queue_wq_desc (wq, frame, pa, frame_len,FNIC_FCOE_EOF , +0 , fnic->vlan_id,1 ,1 ,1 ); -irq_restore: +fnic_send_frame_end:spin_unlock_irqrestore (&fnic->wq_lock[0 ], flags); - -free_skb_on_err: -if (ret) -dev_kfree_skb_any (fp_skb (fp)); -return ret; } -/* -* fnic_send -* Routine to send a raw frame -*/ -int fnic_send (struct fc_lport *lp,struct fc_frame *fp) +static int +fdls_send_fcoe_frame (struct fnic *fnic,void *payload,int payload_sz, +uint8_t *srcmac,uint8_t *dstmac) { -struct fnic *fnic =lport_priv (lp); -unsigned long flags; +uint8_t *frame; +struct fnic_eth_hdr_s *ethhdr; +struct fnic_frame_list *frame_elem; +int max_framesz =FNIC_FCOE_FRAME_MAXSZ ; +int len =0 ; +int ret; -if (fnic->in_remove) { -dev_kfree_skb (fp_skb (fp)); -return -1 ; + frame =kzalloc (max_framesz,GFP_ATOMIC ); +if (!frame) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame for flogi\n" ); +return -ENOMEM ; } + ethhdr = (struct fnic_eth_hdr_s *) frame; + +memcpy (frame, (uint8_t *) &fnic_eth_hdr_fcoe, +sizeof (struct fnic_eth_hdr_s )); + len =sizeof (struct fnic_eth_hdr_s );
drivers/scsi/fnic/fnic_fcs.c void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb) · line 1217
Quoted 10 lines
drivers/scsi/fnic/fnic_fcs.c +10
-0+ +memcpy (ethhdr->src_mac, srcmac,ETH_ALEN ); +memcpy (ethhdr->dst_mac, dstmac,ETH_ALEN ); + +memcpy (frame + len, (uint8_t *) &fnic_fcoe_hdr, +sizeof (struct fnic_fcoe_hdr_s )); + len +=sizeof (struct fnic_fcoe_hdr_s ); + +memcpy (frame + len, (uint8_t *) payload, payload_sz); + len += payload_sz;
Ouch.kmalloc() in the hot path. And memcpy the constructed data onto it. Please, don't.
Use the constructed data directly.
drivers/scsi/fnic/fnic_fcs.c void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb) · line 1225
Quoted 12 lines
drivers/scsi/fnic/fnic_fcs.c +3
-4/* * Queue frame if in a transitional state. * This occurs while registering the Port_ID / MAC address after FLOGI. */ -spin_lock_irqsave (&fnic->fnic_lock, flags); -if (fnic->state !=FNIC_IN_FC_MODE && fnic->state !=FNIC_IN_ETH_MODE ) { -skb_queue_tail (&fnic->tx_queue,fp_skb (fp)); -spin_unlock_irqrestore (&fnic->fnic_lock, flags); +if ((fnic->state !=FNIC_IN_FC_MODE ) + && (fnic->state !=FNIC_IN_ETH_MODE )) { + frame_elem =kzalloc (sizeof (struct fnic_frame_list ),GFP_ATOMIC );
And another one. Please, don't.
If you need an interdiate structure use a mempool, and allocate from there.
Ideally you would not require that structure, though, but rather use the constructed frame directly.
Quoted 343 lines
drivers/scsi/fnic/fnic_fcs.c +101
-91+if (!frame_elem) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate memory for fnic_frame_list: %lu\n" , +sizeof (struct fnic_frame_list )); +return -ENOMEM ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Queuing frame: 0x%p\n" , frame); + + frame_elem->fp = frame; + frame_elem->frame_len = len; +list_add_tail (&frame_elem->links, &fnic->tx_queue);return 0 ; } -spin_unlock_irqrestore (&fnic->fnic_lock, flags); -return fnic_send_frame (fnic, fp); + ret =fnic_send_frame (fnic, frame, len); +return ret; +} + +void fnic_send_fcoe_frame (struct fnic_iport_s *iport,void *payload, +int payload_sz) +{ +struct fnic *fnic = iport->fnic; +uint8_t *dstmac, *srcmac; + +/* If module unload is in-progress, don't send */ +if (fnic->in_remove) +return ; + +if (iport->fabric.flags &FNIC_FDLS_FPMA_LEARNT ) { + srcmac = iport->fpma; + dstmac = iport->fcfmac; + }else { + srcmac = iport->hwmac; + dstmac =FCOE_ALL_FCF_MAC ; + } + +fdls_send_fcoe_frame (fnic, payload, payload_sz, srcmac, dstmac); }/** @@ -1193,15 +1276,66 @@ int fnic_send(struct fc_lport *lp, struct fc_frame *fp)void fnic_flush_tx (struct work_struct *work) { struct fnic *fnic = container_of(work, struct fnic, flush_work); -struct sk_buff *skb;struct fc_frame *fp; +struct fnic_frame_list *cur_frame, *next; -while ((skb =skb_dequeue (&fnic->tx_queue))) { - fp = (struct fc_frame *)skb; -fnic_send_frame (fnic, fp); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Flush queued frames" ); + +list_for_each_entry_safe (cur_frame, next, &fnic->tx_queue, links) { + fp = cur_frame->fp; +list_del (&cur_frame->links); +fnic_send_frame (fnic, fp, cur_frame->frame_len); } } +int +fnic_fdls_register_portid (struct fnic_iport_s *iport,u32 port_id, +void *fp) +{ +struct fnic *fnic = iport->fnic; +struct fnic_eth_hdr_s *ethhdr; +int ret; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Setting port id: 0x%x fp: 0x%p fnic state: %d" , port_id, + fp, fnic->state); + +if (fp) { + ethhdr = (struct fnic_eth_hdr_s *) fp; +vnic_dev_add_addr (fnic->vdev, ethhdr->dst_mac); + } + +/* Change state to reflect transition to FC mode */ +if (fnic->state ==FNIC_IN_ETH_MODE || fnic->state ==FNIC_IN_FC_MODE ) + fnic->state =FNIC_IN_ETH_TRANS_FC_MODE ; +else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unexpected fnic state while processing FLOGI response\n" ); +return -1 ; + } + +/* +* Send FLOGI registration to firmware to set up FC mode. +* The new address will be set up when registration completes. +*/ + ret =fnic_flogi_reg_handler (fnic, port_id); +if (ret <0 ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FLOGI registration error ret: %d fnic state: %d\n" , + ret, fnic->state); +if (fnic->state ==FNIC_IN_ETH_TRANS_FC_MODE ) + fnic->state =FNIC_IN_ETH_MODE ; + +return -1 ; + } + iport->fabric.flags |=FNIC_FDLS_FPMA_LEARNT ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FLOGI registration success\n" ); +return 0 ; +} +/** * fnic_set_eth_mode() - put fnic into ethernet mode. * @fnic: fnic device @@ -1240,6 +1374,17 @@ static void fnic_set_eth_mode(struct fnic *fnic)spin_unlock_irqrestore (&fnic->fnic_lock, flags); } +void fnic_free_txq (struct list_head *head) +{ +struct fnic_frame_list *cur_frame, *next; + +list_for_each_entry_safe (cur_frame, next, head, links) { +list_del (&cur_frame->links); +kfree (cur_frame->fp); +kfree (cur_frame); + } +} +static void fnic_wq_complete_frame_send (struct vnic_wq *wq,struct cq_desc *cq_desc,struct vnic_wq_buf *buf,void *opaque)@@ -1319,88 +1464,3 @@ void fnic_fcoe_reset_vlans(struct fnic *fnic)spin_unlock_irqrestore (&fnic->vlans_lock, flags); } -void fnic_handle_fip_timer (struct fnic *fnic) -{ -unsigned long flags; -struct fcoe_vlan *vlan; -struct fnic_stats *fnic_stats = &fnic->fnic_stats; -u64 sol_time; - -spin_lock_irqsave (&fnic->fnic_lock, flags); -if (fnic->stop_rx_link_events) { -spin_unlock_irqrestore (&fnic->fnic_lock, flags); -return ; - } -spin_unlock_irqrestore (&fnic->fnic_lock, flags); - -if (fnic->ctlr.mode ==FIP_MODE_NON_FIP ) -return ; - -spin_lock_irqsave (&fnic->vlans_lock, flags); -if (list_empty (&fnic->vlans)) { -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -/* no vlans available, try again */ -if (unlikely (fnic_log_level &FNIC_FCS_LOGGING )) -if (printk_ratelimit ()) -shost_printk (KERN_DEBUG , fnic->lport->host, -"Start VLAN Discovery\n" ); -fnic_event_enq (fnic,FNIC_EVT_START_VLAN_DISC ); -return ; - } - - vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, -"fip_timer: vlan %d state %d sol_count %d\n" , - vlan->vid, vlan->state, vlan->sol_count); -switch (vlan->state) { -case FIP_VLAN_USED : -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, -"FIP VLAN is selected for FC transaction\n" ); -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -break ; -case FIP_VLAN_FAILED : -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -/* if all vlans are in failed state, restart vlan disc */ -if (unlikely (fnic_log_level &FNIC_FCS_LOGGING )) -if (printk_ratelimit ()) -shost_printk (KERN_DEBUG , fnic->lport->host, -"Start VLAN Discovery\n" ); -fnic_event_enq (fnic,FNIC_EVT_START_VLAN_DISC ); -break ; -case FIP_VLAN_SENT : -if (vlan->sol_count >=FCOE_CTLR_MAX_SOL ) { -/* -* no response on this vlan, remove from the list. -* Try the next vlan -*/ -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"Dequeue this VLAN ID %d from list\n" , - vlan->vid); -list_del (&vlan->list); -kfree (vlan); - vlan =NULL ; -if (list_empty (&fnic->vlans)) { -/* we exhausted all vlans, restart vlan disc */ -spin_unlock_irqrestore (&fnic->vlans_lock, - flags); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"fip_timer: vlan list empty, " -"trigger vlan disc\n" ); -fnic_event_enq (fnic,FNIC_EVT_START_VLAN_DISC ); -return ; - } -/* check the next vlan */ - vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, - list); - fnic->set_vlan (fnic, vlan->vid); - vlan->state =FIP_VLAN_SENT ;/* sent now */ - } -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -atomic64_inc (&fnic_stats->vlan_stats.sol_expiry_count); - vlan->sol_count++; - sol_time = jiffies +msecs_to_jiffies - (FCOE_CTLR_START_DELAY ); -mod_timer (&fnic->fip_timer,round_jiffies (sol_time)); -break ; - } -}drivers/scsi/fnic/fnic_fdls.h +2
-3@@ -382,8 +382,8 @@ inline void fnic_del_tport_timer_sync(struct fnic *fnic, struct fnic_tport_s *tport);void fdls_send_fabric_logo (struct fnic_iport_s *iport);int fnic_fdls_validate_and_get_frame_type (struct fnic_iport_s *iport, -void *rx_frame,int len, -int fchdr_offset); +void *rx_frame,int len, +int fchdr_offset);void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport); bool fdls_delete_tport(struct fnic_iport_s *iport,@@ -399,7 +399,6 @@ int fnic_send_fip_frame(struct fnic_iport_s *iport, void *payload, int payload_sz);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 +5
-5@@ -31,6 +31,8 @@#include "fnic_io.h" #include "fnic_fip.h" #include "fnic.h" +#include "fnic_fdls.h" +#include "fdls_fc.h" #define PCI_DEVICE_ID_CISCO_FNIC 0x0045@@ -80,7 +82,6 @@ module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR);MODULE_PARM_DESC (fnic_max_qdepth,"Queue depth to report for each LUN" );static struct libfc_function_template fnic_transport_template = { - .frame_send = fnic_send, .lport_set_port_id = fnic_set_port_id, .fcp_abort_io = fnic_empty_scsi_cleanup, .fcp_cleanup = fnic_empty_scsi_cleanup,@@ -413,7 +414,7 @@ static void fnic_fip_notify_timer(struct timer_list *t) {struct fnic *fnic =from_timer (fnic, t, fip_timer); -fnic_handle_fip_timer (fnic); +/* Placeholder function */ }static void fnic_notify_timer_start (struct fnic *fnic)@@ -921,7 +922,7 @@ 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);skb_queue_head_init (&fnic->frame_queue); -skb_queue_head_init (&fnic->tx_queue); +INIT_LIST_HEAD (&fnic->tx_queue);fc_fabric_login (lp);@@ -1004,7 +1005,7 @@ static void fnic_remove(struct pci_dev *pdev)*/ flush_workqueue (fnic_event_queue);skb_queue_purge (&fnic->frame_queue); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue);if (fnic->config.flags &VFCF_FIP_CAPABLE ) {del_timer_sync (&fnic->fip_timer);@@ -1036,7 +1037,6 @@ static void fnic_remove(struct pci_dev *pdev)fnic_cleanup (fnic);BUG_ON (!skb_queue_empty (&fnic->frame_queue)); -BUG_ON (!skb_queue_empty (&fnic->tx_queue));spin_lock_irqsave (&fnic_list_lock, flags);list_del (&fnic->list);drivers/scsi/fnic/fnic_scsi.c +2
-2@@ -184,7 +184,7 @@ int fnic_fw_reset_handler(struct fnic *fnic)fnic_set_state_flags (fnic,FNIC_FLAGS_FWRESET );skb_queue_purge (&fnic->frame_queue); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue);/* wait for io cmpl */ while (atomic_read (&fnic->in_flight))@@ -674,7 +674,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,*/ if (fnic->remove_wait || ret) {spin_unlock_irqrestore (&fnic->fnic_lock, flags); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue); goto reset_cmpl_handler_end; }
drivers/scsi/fnic/fnic_scsi.c static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) · line 1723
Quoted 8 lines
drivers/scsi/fnic/fnic_scsi.c +1
-1@@ -1717,7 +1717,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)return true; } -static void fnic_rport_exch_reset (struct fnic *fnic,u32 port_id) +void fnic_rport_exch_reset (struct fnic *fnic,u32 port_id) {struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats;struct fnic_rport_abort_io_iter_data iter_data = {
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v5 03/14] scsi: fnic: Add support for fabric based solicited requests and responses
Quoted 301 lines · Hannes Reinecke
Quoted 262 lines · Karan Tilak Kumar
Add
fdls_disc.cto 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.Reported-by kernel test robot <[email protected]>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/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately. Modifyfnic_fdls_timer_callbackto 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 infnic_send_frame.
Use the correct kernel-doc format.
Replacehtonll()withget_unaligned_be64(). Addfnic_del_fabric_timer_syncas an inline function. Addfnic_del_tport_timer_syncas an inline function. Modifyfc_abts_svariable name tofc_fabric_abts_s. Modifyfc_fabric_abts_sto be a global frame. Renamepfc_abtstofabric_abts.
Replace definitions with standard definitions fromfc_els.h.
Incorporate review comments from John:
Replace kmalloc with kzalloc.
Modifyfnic_send_fcoe_frameto 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 | 1906 +++++++++++++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 26 +- drivers/scsi/fnic/fnic_fcs.c | 400 ++++--- drivers/scsi/fnic/fnic_fdls.h | 5 +- drivers/scsi/fnic/fnic_io.h | 11 - drivers/scsi/fnic/fnic_main.c | 10 +- drivers/scsi/fnic/fnic_scsi.c | 6 +- 8 files changed, 2171 insertions(+), 194 deletions(-)create mode 100644
drivers/scsi/fnic/fdls_disc.cdrivers/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 +176
-0@@ -0,0 +1,1906 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2008 Cisco Systems, Inc. All rights reserved. +* Copyright 2007 Nuova Systems, Inc. All rights reserved. +*/ + +#include <linux/workqueue.h> +#include "fnic.h" +#include "fdls_fc.h" +#include "fnic_fdls.h" +#include <scsi/fc/fc_fcp.h> +#include <linux/utsname.h> + +/* Frame initialization */ +/* +* Variables: +* sid +*/ +struct fc_std_flogi fnic_std_flogi_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_d_id = {0xFF ,0xFF ,0xFE }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .els.fl_cmd =ELS_FLOGI , + .els.fl_csp = {.sp_hi_ver =FNIC_FC_PH_VER_HI , + .sp_lo_ver =FNIC_FC_PH_VER_LO , + .sp_bb_cred =cpu_to_be16 (FNIC_FC_B2B_CREDIT ), + .sp_bb_data =cpu_to_be16 (FNIC_FC_B2B_RDF_SZ )}, + .els.fl_cssp[2 ].cp_class =cpu_to_be16 (FC_CPC_VALID |FC_CPC_SEQ ) +}; + +/* +* Variables: +* sid, did(nport logins), ox_id(nport logins), nport_name, node_name +*/ +struct fc_std_flogi fnic_std_plogi_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_d_id = {0xFF ,0xFF ,0xFC }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .els = { + .fl_cmd =ELS_PLOGI , + .fl_csp = {.sp_hi_ver =FNIC_FC_PH_VER_HI , + .sp_lo_ver =FNIC_FC_PH_VER_LO , + .sp_bb_cred =cpu_to_be16 (FNIC_FC_B2B_CREDIT ), + .sp_features =cpu_to_be16 (FC_SP_FT_CIRO ), + .sp_bb_data =cpu_to_be16 (FNIC_FC_B2B_RDF_SZ ), + .sp_tot_seq =cpu_to_be16 (FNIC_FC_CONCUR_SEQS ), + .sp_rel_off =cpu_to_be16 (FNIC_FC_RO_INFO ), + .sp_e_d_tov =cpu_to_be32 (FNIC_E_D_TOV )}, + .fl_cssp[2 ].cp_class =cpu_to_be16 (FC_CPC_VALID |FC_CPC_SEQ ), + .fl_cssp[2 ].cp_rdfs =cpu_to_be16 (0x800 ), + .fl_cssp[2 ].cp_con_seq =cpu_to_be16 (0xFF ), + .fl_cssp[2 ].cp_open_seq =1 } +}; + +/* +* Variables: +* sid, port_id, port_name +*/ +struct fc_std_rpn_id fnic_std_rpn_id_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_RPN_ID )} +}; + +/* +* Variables: +* fh_s_id, port_id, port_name +*/ +struct fc_std_rft_id fnic_std_rft_id_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_RFT_ID )} +}; + +/* +* Variables: +* fh_s_id, port_id, port_name +*/ +struct fc_std_rff_id fnic_std_rff_id_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_RFF_ID )}, + .rff_id.fr_feat =0x2 , + .rff_id.fr_type =FC_TYPE_FCP +}; + +/* +* Variables: +* sid +*/ +struct fc_std_gpn_ft fnic_std_gpn_ft_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFC }, .fh_type =FC_TYPE_CT , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_DIR , + .ct_fs_subtype =FC_NS_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_NS_GPN_FT )}, + .gpn_ft.fn_fc4_type =0x08 +}; + +/* +* Variables: +* sid +*/ +struct fc_std_scr fnic_std_scr_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , + .fh_d_id = {0xFF ,0xFF ,0xFD }, .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .scr = {.scr_cmd =ELS_SCR , + .scr_reg_func =ELS_SCRF_FULL } +}; + +/* +* Variables: +* did, ox_id, rx_id, fcid, wwpn +*/ +struct fc_std_logo fnic_std_logo_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }}, + .els.fl_cmd =ELS_LOGO , +}; + +struct fc_frame_header fc_std_fabric_abts = { + .fh_r_ctl =FC_RCTL_BA_ABTS ,/* ABTS */ + .fh_d_id = {0xFF ,0xFF ,0xFF }, .fh_s_id = {0x00 ,0x00 ,0x00 }, + .fh_cs_ctl =0x00 , .fh_type =FC_TYPE_BLS , + .fh_f_ctl = {FNIC_REQ_ABTS_FCTL ,0 ,0 }, .fh_seq_id =0x00 , + .fh_df_ctl =0x00 , .fh_seq_cnt =0x0000 , .fh_rx_id =0xFFFF , + .fh_parm_offset =0x00000000 ,/* bit:0 = 0 Abort a exchange */ +}; + +#define RETRIES_EXHAUSTED (iport) \ + (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY) + +/* +* For fabric requests and fdmi, once OXIDs are allocated from the pool +* (and a range) they are encoded with expected rsp type as +* they come in convenience with identifying the received frames +* and debugging with switches (OXID pool base will be chosen +* such a way bits 6-11 are always 0) oxid(16 bits) - +* bits 0-5: idx into the pool(bitmap) +* bits 6-11: expected response types +*/ +#define FDLS_OXID_ENCODE (oxid, rsp_type) ((oxid) | (rsp_type << 6)) +#define FDLS_OXID_RSP_TYPE_UNMASKED (oxid) ((oxid) & ~0x0FC0) +#define FDLS_OXID_TO_RSP_TYPE (oxid) (((oxid) >> 6) & 0x3F) +/* meta->size has to be power-of-2 */ +#define FDLS_OXID_TO_IDX (meta, oxid) ((oxid) & (meta->sz - 1)) + +/* Private Functions */ +static void fdls_process_flogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr, +void *rx_frame); +static void fnic_fdls_start_plogi (struct fnic_iport_s *iport); +static void fnic_fdls_start_flogi (struct fnic_iport_s *iport); +static void fdls_start_fabric_timer (struct fnic_iport_s *iport, +int timeout); +static void +fdls_init_fabric_oxid_pool (struct fnic_fabric_oxid_pool_s *oxid_pool, +int oxid_base,int sz); + +void fdls_init_oxid_pool (struct fnic_iport_s *iport)drivers/scsi/fnic/fdls_disc.c line 186
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+{ +fdls_init_fabric_oxid_pool (&iport->fabric_oxid_pool, +FDLS_FABRIC_OXID_POOL_BASE , +FDLS_FABRIC_OXID_POOL_SZ ); + +fdls_init_fabric_oxid_pool (&iport->fdmi_oxid_pool, +FDLS_FDMI_OXID_POOL_BASE , +FDLS_FDMI_OXID_POOL_SZ ); +} +Where are these functions defined?
Please rearrange the patch series such that these functions are defined with an earlier patch.Quoted 12 lines
drivers/scsi/fnic/fdls_disc.c new file +12
-0+uint16_t fdls_alloc_oxid (struct fnic_iport_s *iport, +struct fnic_oxid_pool_meta_s *meta, +unsigned long *bitmap) +{ +struct fnic *fnic = iport->fnic; +struct reclaim_entry_s *reclaim_entry, *next; +int idx; +uint16_t oxid; +unsigned long expiry_ts; + +/* first walk through the oxid slots and reclaim any expired */ + list_for_each_entry_safe(reclaim_entry, next,drivers/scsi/fnic/fdls_disc.c line 208
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ &(meta->reclaim_list), links) { + expiry_ts = reclaim_entry->timestamp + +msecs_to_jiffies (2 * iport->r_a_tov); +if (time_after (jiffies, expiry_ts)) { +list_del (&reclaim_entry->links); +fdls_free_oxid (iport, meta, bitmap, reclaim_entry->oxid); +kfree (reclaim_entry); + } + } +
Quoted 8 lines
That is quite inefficient. You walk the free list every time you want to allocate an new OXID. This increased the time to fetch an OXID, and ties the reclaim to the allocation.
It might be an idea to decouple both, and have a reclaim timer which then walks the reclaim list once the first has expired, restarting at the time the next-to-last oldest entry expires.
That would allow you to not having to walk the reclaim list during allocation.
Thanks for your insights, Hannes.
We are discussing this internally.
Quoted 17 lines
Quoted 5 lines
drivers/scsi/fnic/fdls_disc.c new file +5
-0+/* Allocate next available oxid from bitmap */ + idx =find_next_zero_bit (bitmap, meta->sz, meta->next_idx); + +if (idx == meta->sz) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,drivers/scsi/fnic/fdls_disc.c line 223
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+"Alloc oxid: all oxid slots are busy iport state:%d\n" , + iport->state); +return 0xFFFF ; + } + +/* adding the oxid index to pool base will give the oxid */ + oxid = idx + meta->oxid_base; +set_bit (idx, bitmap); + meta->next_idx = (idx +1 ) % meta->sz;/* cycle through the bitmap */ +That's a bit odd; you walk the free list to find expired oxids, yet use a bitmap to lookup free ones.
Quoted 8 lines
I would have expected the same mechanism for both; otherwise, how do you ensure that the list and the bitmap is kept in sync?
Plus you actually have a race condition; first you look for the next free oxid, and then (in a separate step!) you do theset_bit()operation to actually claim it.
You should be doing a 'test_and_set_bit()' here, and re-run the loop once that failed (as then the selected OXID had been taken by another thread).
Thanks for your insights, Hannes.
We are discussing this internally.
Quoted 14 lines
Quoted 14 lines
drivers/scsi/fnic/fdls_disc.c new file +14
-0+return oxid; +} + +void fdls_free_oxid (struct fnic_iport_s *iport, +struct fnic_oxid_pool_meta_s *meta, +unsigned long *bitmap,uint16_t oxid) +{ +struct fnic *fnic = iport->fnic; +int idx; + + idx =FDLS_OXID_TO_IDX (meta, oxid); + +if (!test_bit (idx, bitmap)) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c line 242
Quoted 5 lines
drivers/scsi/fnic/fdls_disc.c new file +5
-0+"Free oxid: already freed, iport state:%d\n" , + iport->state); + } +clear_bit (idx, bitmap); +}
test_and_clear_bit(), please.
Otherwise you have a race condition.
Thanks for your observation, Hannes.
We'll fix this in the next version.
Quoted 4 lines
Quoted 4 lines
drivers/scsi/fnic/fdls_disc.c new file +4
-0+ +static void +fdls_init_fabric_oxid_pool (struct fnic_fabric_oxid_pool_s *oxid_pool, +int oxid_base,int sz)
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c line 253
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c new file +7
-0+{ +memset (oxid_pool,0 ,sizeof (struct fnic_fabric_oxid_pool_s )); + oxid_pool->meta.oxid_base = oxid_base; + oxid_pool->meta.sz = sz; +INIT_LIST_HEAD (&oxid_pool->meta.reclaim_list); +} +Ah, here are the functions. Please move them to the top of the file.
Sure Hannes. I'll fix this in the next version.
Quoted 23 lines
Quoted 9 lines
drivers/scsi/fnic/fdls_disc.c new file +9
-0+/* +* fdls_alloc_fabric_oxid - Allocate fabric oxid from a pool +* @iport: Handle to fnic iport +* @oxid_pool: Pool to allocate from +* @exp_rsp_type: Response type that we expect +* +* Wrapper for fabric and fdmi oxid allocations. +* Called with fnic_lock held. +* Encode the allocated OXID with expected rsp type for easier drivers/scsi/fnic/fdls_disc.c line 272
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+* identification of the rx response and convenient debugging with switches +*/ +uint16_t fdls_alloc_fabric_oxid (struct fnic_iport_s *iport, +struct fnic_fabric_oxid_pool_s *oxid_pool, +int exp_rsp_type) +{ +uint16_t oxid; + + oxid =fdls_alloc_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap); +Ho-hum.
So you are guaranteed to get an OXID from the pool? Really?
Quoted 1 line
Shouldn't you check if you actually got a valid OXID back?
Thanks Hannes. We'll review this internally to check and confirm.
Quoted 31 lines
Quoted 31 lines
drivers/scsi/fnic/fdls_disc.c new file +31
-0+ oxid =FDLS_OXID_ENCODE (oxid, exp_rsp_type); + +/* Save the corresponding active oxid for abort, if needed. +* Since fabric requests are serialized, they need only one. +* fdmi_reg_hba and fdmi_hpa can go in parallel. Save them +* separately. +*/ +switch (exp_rsp_type) { +default : + oxid_pool->active_oxid_fabric_req = oxid; +break ; + } + +return oxid; +} + +inline void fdls_free_fabric_oxid (struct fnic_iport_s *iport, +struct fnic_fabric_oxid_pool_s + *oxid_pool,uint16_t oxid) +{ +fdls_free_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap, oxid); +} + +static void fdls_schedule_oxid_free (struct fnic_oxid_pool_meta_s *meta, +uint16_t oxid) +{ +struct reclaim_entry_s *reclaim_entry; + + reclaim_entry = (struct reclaim_entry_s *) +kzalloc (sizeof (struct reclaim_entry_s ),GFP_KERNEL ); + reclaim_entry->oxid = oxid;
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c line 308
Quoted 5 lines
drivers/scsi/fnic/fdls_disc.c new file +5
-0+ reclaim_entry->timestamp = jiffies; + +list_add_tail (&reclaim_entry->links, &meta->reclaim_list); +} +As mentioned above; you already know when the oxid will expire at this point. So you might as well trigger a workqueue (or a timer) reclaiming the OXID once the timer expires.
Thanks Hannes. We're reviewing this.
Quoted 154 lines
Quoted 154 lines
drivers/scsi/fnic/fdls_disc.c new file +154
-0+static inline void fdls_schedule_fabric_oxid_free (struct fnic_iport_s + *iport) +{ +fdls_schedule_oxid_free (&iport->fabric_oxid_pool.meta, + iport->fabric_oxid_pool.active_oxid_fabric_req); +} + +int fnic_fdls_expected_rsp (struct fnic_iport_s *iport,uint16_t oxid) +{ +struct fnic *fnic = iport->fnic; + +/* Received oxid should match with one of the following */ +if ((oxid != iport->fabric_oxid_pool.active_oxid_fabric_req) && + (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_plogi) && + (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_rhba) && + (oxid != iport->fdmi_oxid_pool.active_oxid_fdmi_rpa)) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received oxid(0x%x) not matching in oxid pool (0x%x) state:%d" , + oxid, iport->fabric_oxid_pool.active_oxid_fabric_req, + iport->fabric.state); +return 0xFFFF ; + } + +return FDLS_OXID_TO_RSP_TYPE (oxid); +} + +static int fdls_is_oxid_in_fabric_range (uint16_t oxid) +{ +uint16_t oxid_unmasked =FDLS_OXID_RSP_TYPE_UNMASKED (oxid); + +return ((oxid_unmasked >=FDLS_FABRIC_OXID_POOL_BASE ) && + (oxid_unmasked <=FDLS_FABRIC_OXID_POOL_END )); +} + +inline void fnic_del_fabric_timer_sync (struct fnic *fnic) +{ + fnic->iport.fabric.del_timer_inprogress =1 ; +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +del_timer_sync (&fnic->iport.fabric.retry_timer); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + fnic->iport.fabric.del_timer_inprogress =0 ; +} + +inline void fnic_del_tport_timer_sync (struct fnic *fnic, +struct fnic_tport_s *tport) +{ + tport->del_timer_inprogress =1 ; +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +del_timer_sync (&tport->retry_timer); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + tport->del_timer_inprogress =0 ; +} + +static void +fdls_start_fabric_timer (struct fnic_iport_s *iport,int timeout) +{ +u64 fabric_tov; +struct fnic *fnic = iport->fnic; + +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" , + iport->fcid); +fnic_del_fabric_timer_sync (fnic); + iport->fabric.timer_pending =0 ; + } + +if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) + iport->fabric.retry_counter++; + + 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, +"fabric timer is %d " , timeout); +} + +static void fdls_send_fabric_abts (struct fnic_iport_s *iport) +{ +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header fabric_abort = fc_std_fabric_abts; +struct fc_frame_header *fabric_abts = &fabric_abort; +uint16_t oxid; + +switch (iport->fabric.state) { +case FDLS_STATE_FABRIC_LOGO : + fabric_abts->fh_d_id[2 ] =0xFE ; +break ; + +case FDLS_STATE_FABRIC_FLOGI : + fabric_abts->fh_d_id[2 ] =0xFE ; +break ; + +case FDLS_STATE_FABRIC_PLOGI : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_RPN_ID : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_SCR : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFD ; +break ; + +case FDLS_STATE_REGISTER_FC4_TYPES : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_REGISTER_FC4_FEATURES : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; + +case FDLS_STATE_GPN_FT : +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID (fabric_abts, fcid); + fabric_abts->fh_d_id[2 ] =0xFC ; +break ; +default : +return ; + } + + oxid = iport->fabric_oxid_pool.active_oxid_fabric_req; +FNIC_STD_SET_OX_ID (fabric_abts,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending fabric abts. iport->fabric.state: %d, oxid:%x" , + iport->fabric.state, oxid); + + iport->fabric.flags |=FNIC_FDLS_FABRIC_ABORT_ISSUED ; + +fnic_send_fcoe_frame (iport, fabric_abts, +sizeof (struct fc_frame_header )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); + iport->fabric.timer_pending =1 ; +} + +static void fdls_send_fabric_flogi (struct fnic_iport_s *iport) +{ +struct fc_std_flogi flogi; +struct fnic *fnic = iport->fnic; +uint16_t oxid;
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c line 464
Quoted 2 lines
drivers/scsi/fnic/fdls_disc.c new file +2
-0+ +memcpy (&flogi, &fnic_std_flogi_req,sizeof (struct fc_std_flogi ));Wouldn't it be better to move the static '
fnic_std_flogi_req' definition as an initialisation for 'flogi' here?
That would save you the 'memcpy', and the slightly awkward coding style. (Having a statically defined structure which is later then copied over to the actual structure is very uncommon, at least in the linux kernel.)
Thanks for your insights, Hannes.
We are reviewing this approach internally for this one and the ones that follow.
Quoted 1,216 lines
Quoted 23 lines
drivers/scsi/fnic/fdls_disc.c new file +23
-0+FNIC_LOGI_SET_NPORT_NAME (&flogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&flogi.els, iport->wwnn); +FNIC_LOGI_SET_RDF_SIZE (&flogi.els, iport->max_payload_size); +FNIC_LOGI_SET_R_A_TOV (&flogi.els, iport->r_a_tov); +FNIC_LOGI_SET_E_D_TOV (&flogi.els, iport->e_d_tov); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_FLOGI_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send flogi %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&flogi.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send fabric flogi with oxid:%x" , iport->fcid, + oxid); + +fnic_send_fcoe_frame (iport, &flogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}drivers/scsi/fnic/fdls_disc.c line 497
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_fabric_plogi (struct fnic_iport_s *iport) +{ +struct fc_std_flogi plogi; +struct fc_frame_header *fchdr = &plogi.fchdr; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&plogi, &fnic_std_plogi_req,sizeof (struct fc_std_flogi ));Same comment as above for the
memcpy()Quoted 25 lines
drivers/scsi/fnic/fdls_disc.c new file +25
-0+ +hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID (fchdr, fcid); +FNIC_LOGI_SET_NPORT_NAME (&plogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&plogi.els, iport->wwnn); +FNIC_LOGI_SET_RDF_SIZE (&plogi.els, iport->max_payload_size); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_PLOGI_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fabric plogi %p" , + iport); +return ; + } +FNIC_STD_SET_OX_ID (fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send fabric PLOGI with oxid:%x" , iport->fcid, + oxid); + +fnic_send_fcoe_frame (iport, &plogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov);drivers/scsi/fnic/fdls_disc.c line 532
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+} + +static void fdls_send_rpn_id (struct fnic_iport_s *iport) +{ +struct fc_std_rpn_id rpn_id; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&rpn_id, &fnic_std_rpn_id_req,sizeof (struct fc_std_rpn_id ));And here.
Quoted 23 lines
drivers/scsi/fnic/fdls_disc.c new file +23
-0+ +hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID ((&rpn_id.fchdr), fcid); +FNIC_STD_SET_PORT_ID ((&rpn_id.rpn_id), fcid); +FNIC_STD_SET_PORT_NAME ((&rpn_id.rpn_id), iport->wwpn); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_RPN_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send rpn id %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&rpn_id.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send RPN ID with oxid:%x" , iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &rpn_id,sizeof (struct fc_std_rpn_id )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}drivers/scsi/fnic/fdls_disc.c line 565
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_scr (struct fnic_iport_s *iport) +{ +struct fc_std_scr scr; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&scr, &fnic_std_scr_req,sizeof (struct fc_std_scr )); +And here.
Quoted 20 lines
drivers/scsi/fnic/fdls_disc.c new file +20
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&scr.fchdr), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_SCR_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send scr %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&scr.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send SCR with oxid:%x" , iport->fcid, oxid); + + +fnic_send_fcoe_frame (iport, &scr,sizeof (struct fc_std_scr )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}drivers/scsi/fnic/fdls_disc.c line 595
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_gpn_ft (struct fnic_iport_s *iport,int fdls_state) +{ +struct fc_std_gpn_ft gpn_ft; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&gpn_ft, &fnic_std_gpn_ft_req,sizeof (struct fc_std_gpn_ft )); +And here.
Quoted 21 lines
drivers/scsi/fnic/fdls_disc.c new file +21
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&gpn_ft.fchdr), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_GPN_FT_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send GPN FT %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&gpn_ft.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS send GPN FT with oxid:%x" , iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &gpn_ft,sizeof (struct fc_std_gpn_ft )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +fdls_set_state ((&iport->fabric), fdls_state); +} +drivers/scsi/fnic/fdls_disc.c line 626
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+static void fdls_send_register_fc4_types (struct fnic_iport_s *iport) +{ +struct fc_std_rft_id rft_id; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memset (&rft_id,0 ,sizeof (struct fc_std_rft_id )); +memcpy (&rft_id, &fnic_std_rft_id_req,sizeof (struct fc_std_rft_id )); +hton24 (fcid, iport->fcid);And here.
Quoted 27 lines
drivers/scsi/fnic/fdls_disc.c new file +27
-0+ +FNIC_STD_SET_S_ID ((&rft_id.fchdr), fcid); +FNIC_STD_SET_PORT_ID ((&rft_id.rft_id), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_RFT_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send RFT %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&rft_id.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS sending FC4 Typeswith oxid:%x" , iport->fcid, + oxid); + +if (IS_FNIC_FCP_INITIATOR (fnic)) + rft_id.rft_id.fr_fts.ff_type_map[0 ] = +cpu_to_be32 (1 <<FC_TYPE_FCP ); + + rft_id.rft_id.fr_fts.ff_type_map[1 ] = +cpu_to_be32 (1 << (FC_TYPE_CT %FC_NS_BPW )); + +fnic_send_fcoe_frame (iport, &rft_id,sizeof (struct fc_std_rft_id )); +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +}drivers/scsi/fnic/fdls_disc.c line 663
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+ +static void fdls_send_register_fc4_features (struct fnic_iport_s *iport) +{ +struct fc_std_rff_id rff_id; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +memcpy (&rff_id, &fnic_std_rff_id_req,sizeof (struct fc_std_rff_id )); +And here.
Quoted 41 lines
drivers/scsi/fnic/fdls_disc.c new file +41
-0+hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID ((&rff_id.fchdr), fcid); +FNIC_STD_SET_PORT_ID ((&rff_id.rff_id), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_RFF_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send RFF %p" , iport); +return ; + } +FNIC_STD_SET_OX_ID (&rff_id.fchdr,htons (oxid)); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS sending FC4 features with %x" , iport->fcid, + oxid); + +if (IS_FNIC_FCP_INITIATOR (fnic)) { + rff_id.rff_id.fr_type =FC_TYPE_FCP ; + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Unknown type" , iport->fcid); + } + +fnic_send_fcoe_frame (iport, &rff_id,sizeof (struct fc_std_rff_id )); +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); +} + +/** +* fdls_send_fabric_logo - Send flogo to the fcf +* @iport: Handle to fnic iport +* +* This function does not change or check the fabric state. +* It the caller's responsibility to set the appropriate iport fabric +* state when this is called. Normally it is FDLS_STATE_FABRIC_LOGO. +* Currently this assumes to be called with fnic lock held. +*/ +void fdls_send_fabric_logo (struct fnic_iport_s *iport) +{ +struct fc_std_logo logo;drivers/scsi/fnic/fdls_disc.c line 714
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c new file +10
-0+uint8_t s_id[3 ]; +uint8_t d_id[3 ] = {0xFF ,0xFF ,0xFE }; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to fabric from iport->fcid: 0x%x" , + iport->fcid); +memcpy (&logo, &fnic_std_logo_req,sizeof (struct fc_std_logo )); +And here.
Quoted 949 lines
drivers/scsi/fnic/fdls_disc.c new file +949
-0+hton24 (s_id, iport->fcid); + +FNIC_STD_SET_S_ID ((&logo.fchdr), s_id); +FNIC_STD_SET_D_ID ((&logo.fchdr), d_id); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fabric_oxid_pool, +FNIC_FABRIC_LOGO_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fabric logo %p" , + iport); +return ; + } +FNIC_STD_SET_OX_ID ((&logo.fchdr),htons (oxid)); + +memcpy (&logo.els.fl_n_port_id, s_id,3 ); +FNIC_STD_SET_NPORT_NAME (&logo.els.fl_n_port_wwn, +le64_to_cpu (iport->wwpn)); + +fdls_start_fabric_timer (iport,2 * iport->e_d_tov); + + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to fabric from fcid %x with oxid %x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); +} + +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) { +case FDLS_STATE_FABRIC_FLOGI : +/* Flogi received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter < iport->max_flogi_retries)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_fabric_flogi (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* Flogi has time out 2*ed_tov send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out +* Mark the OXID to be freed after 2 * r_a_tov and retry the req +*/ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter < iport->max_flogi_retries) { + 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, +"Exceeded max FLOGI retries" ); + } +break ; +case FDLS_STATE_FABRIC_PLOGI : +/* Plogi received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter < iport->max_plogi_retries)) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_fabric_plogi (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* Plogi has timed out 2*ed_tov send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out +* Mark the OXID to be freed after 2 * r_a_tov and retry the req +*/ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter < iport->max_plogi_retries) { + 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, +"Exceeded max PLOGI retries" ); + } +break ; +case FDLS_STATE_RPN_ID : +/* Rpn_id 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_rpn_id (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* RPN has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_SCR : +/* 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_scr (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* scr has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport); + } +break ; +case FDLS_STATE_REGISTER_FC4_TYPES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_types (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* RFT_ID timed out send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_REGISTER_FC4_FEATURES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_features (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* SCR has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_RSCN_GPN_FT : +case FDLS_STATE_SEND_GPNFT : +case FDLS_STATE_GPN_FT : +/* GPN_FT received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_gpn_ft (iport, iport->fabric.state); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* gpn_ft has timed out. Send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { +fdls_send_gpn_ft (iport, iport->fabric.state); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timeout for fabric GPN_FT. Check name server: %p" , + iport); + } + } +break ; +default : +fnic_fdls_start_flogi (iport);/* Placeholder call */ +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_rff_id_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic *fnic = iport->fnic; +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_rff_id *rff_rsp = (struct fc_std_rff_id *) fchdr; +uint16_t rsp; +uint8_t reason_code; + +if (fdls_get_state (fdls) !=FDLS_STATE_REGISTER_FC4_FEATURES ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"RFF_ID resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + + rsp =FNIC_STD_GET_FC_CT_CMD ((&rff_rsp->fc_std_ct_hdr)); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process RFF ID response: 0x%04x" , iport->fcid, + (uint32_t ) rsp); + +fdls_free_fabric_oxid (iport, &iport->fdmi_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (rsp) { +case FC_FS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + fdls->retry_counter =0 ; +fdls_set_state ((&iport->fabric),FDLS_STATE_SCR ); +fdls_send_scr (iport); +break ; +case FC_FS_RJT : + reason_code = rff_rsp->fc_std_ct_hdr.ct_reason; +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, +"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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; +default : +break ; + } +} + +static void +fdls_process_rft_id_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_rft_id *rft_rsp = (struct fc_std_rft_id *) fchdr; +uint16_t rsp; +uint8_t reason_code; +struct fnic *fnic = iport->fnic; + +if (fdls_get_state (fdls) !=FDLS_STATE_REGISTER_FC4_TYPES ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"RFT_ID resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + + rsp =FNIC_STD_GET_FC_CT_CMD ((&rft_rsp->fc_std_ct_hdr)); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process RFT ID response: 0x%04x" , iport->fcid, + (uint32_t ) rsp); + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (rsp) { +case FC_FS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + fdls->retry_counter =0 ; +fdls_send_register_fc4_features (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_REGISTER_FC4_FEATURES ); +break ; +case FC_FS_RJT : + reason_code = rft_rsp->fc_std_ct_hdr.ct_reason; +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: 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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; +default : +break ; + } +} + +static void +fdls_process_rpn_id_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_rpn_id *rpn_rsp = (struct fc_std_rpn_id *) fchdr; +uint16_t rsp; +uint8_t reason_code; +struct fnic *fnic = iport->fnic; + +if (fdls_get_state (fdls) !=FDLS_STATE_RPN_ID ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"RPN_ID resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + + rsp =FNIC_STD_GET_FC_CT_CMD ((&rpn_rsp->fc_std_ct_hdr)); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process RPN ID response: 0x%04x" , iport->fcid, + (uint32_t ) rsp); + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (rsp) { +case FC_FS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + fdls->retry_counter =0 ; +fdls_send_register_fc4_types (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_REGISTER_FC4_TYPES ); +break ; +case FC_FS_RJT : + reason_code = rpn_rsp->fc_std_ct_hdr.ct_reason; +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, +"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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; +default : +break ; + } +} + +static void +fdls_process_scr_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_scr *scr_rsp = (struct fc_std_scr *) fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *) fchdr; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"SCR resp recvd in state(%d). Dropping." , +fdls_get_state (fdls)); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (scr_rsp->scr.scr_cmd) { +case ELS_LS_ACC : +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + iport->fabric.retry_counter =0 ; +fdls_send_gpn_ft (iport,FDLS_STATE_GPN_FT ); +break ; + +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (fdls->retry_counter <FDLS_RETRY_COUNT )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"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, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + fdls->timer_pending =0 ; + fdls->retry_counter =0 ; + } +break ; + +default : +break ; + } +} + +static void +fdls_process_gpn_ft_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr,int len) +{ +struct fnic_fdls_fabric_s *fdls = &iport->fabric; +struct fc_std_gpn_ft *gpn_ft_rsp = (struct fc_std_gpn_ft *) fchdr; +uint16_t rsp; +uint8_t reason_code; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS process GPN_FT response: iport state: %d len: %d" , + iport->state, len); + +/* +* GPNFT response :- +* FDLS_STATE_GPN_FT : GPNFT send after SCR state +* during fabric discovery(FNIC_IPORT_STATE_FABRIC_DISC) +* FDLS_STATE_RSCN_GPN_FT : GPNFT send in response to RSCN +* FDLS_STATE_SEND_GPNFT : GPNFT send after deleting a Target, +* e.g. after receiving Target LOGO +* FDLS_STATE_TGT_DISCOVERY :Target discovery is currently in progress +* from previous GPNFT response,a new GPNFT response has come. +*/ +if (!(((iport->state ==FNIC_IPORT_STATE_FABRIC_DISC ) + && (fdls_get_state (fdls) ==FDLS_STATE_GPN_FT )) + || ((iport->state ==FNIC_IPORT_STATE_READY ) + && ((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, +"GPNFT resp recvd in fab state(%d) iport_state(%d). Dropping." , +fdls_get_state (fdls), iport->state); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + + iport->state =FNIC_IPORT_STATE_READY ; + rsp =FNIC_STD_GET_FC_CT_CMD ((&gpn_ft_rsp->fc_std_ct_hdr)); + +switch (rsp) { + +case FC_FS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: GPNFT_RSP accept" , iport->fcid); +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); +break ; + +default : +break ; + } +} + +/** +* fdls_process_fabric_logo_rsp - Handle an flogo response from the fcf +* @iport: Handle to fnic iport +* @fchdr: Incoming frame +*/ +static void +fdls_process_fabric_logo_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_flogi *flogo_rsp = (struct fc_std_flogi *) fchdr; +struct fnic *fnic = iport->fnic; + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +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, +"Flogo response. Fabric not in LOGO state. Dropping! %p" , + iport); +return ; + } + + iport->fabric.state =FDLS_STATE_FLOGO_DONE ; + iport->state =FNIC_IPORT_STATE_LINK_WAIT ; + +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"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, +"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, +"FLOGO response not accepted or rejected: 0x%x" , + flogo_rsp->els.fl_cmd); + } +} + +static void +fdls_process_flogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr,void *rx_frame) +{ +struct fnic_fdls_fabric_s *fabric = &iport->fabric; +struct fc_std_flogi *flogi_rsp = (struct fc_std_flogi *) fchdr; +uint8_t *fcid; +int rdf_size; +uint8_t fcmac[6 ] = {0x0E ,0XFC ,0x00 ,0x00 ,0x00 ,0x00 }; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"FLOGI response received in state (%d). Dropping frame" , +fdls_get_state (fabric)); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (flogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +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" , + iport->fcid); +fnic_del_fabric_timer_sync (fnic); + } + + iport->fabric.timer_pending =0 ; + 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, +"0x%x: FLOGI response accepted" , iport->fcid); + +/* Learn the Service Params */ + rdf_size =ntohs (FNIC_LOGI_RDF_SIZE (&flogi_rsp->els)); +if ((rdf_size >=FNIC_MIN_DATA_FIELD_SIZE ) + && (rdf_size <FNIC_FC_MAX_PAYLOAD_LEN )) + iport->max_payload_size =MIN (rdf_size, + iport->max_payload_size); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"max_payload_size from fabric: %d set: %d" , rdf_size, + iport->max_payload_size); + + iport->r_a_tov =ntohl (FNIC_LOGI_R_A_TOV (&flogi_rsp->els)); + iport->e_d_tov =ntohl (FNIC_LOGI_E_D_TOV (&flogi_rsp->els)); + +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, +"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) = +get_unaligned_be64 (&FNIC_LOGI_NODE_NAME (&flogi_rsp->els)); +fc_host_port_id (iport->fnic->lport->host) = iport->fcid; + } + +fnic_fdls_learn_fcoe_macs (iport, rx_frame, fcid); + +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" , + fcmac[0 ], fcmac[1 ], fcmac[2 ], fcmac[3 ], fcmac[4 ], + fcmac[5 ]); +vnic_dev_add_addr (iport->fnic->vdev, fcmac); + +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, +"FLOGI response received. Starting PLOGI" ); + }else { +/* From FDLS_STATE_FABRIC_FLOGI state fabric can only go to +* FDLS_STATE_LINKDOWN +* 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, +"FLOGI response received in state (%d). Dropping frame" , +fdls_get_state (fabric)); + } +break ; + +case ELS_LS_RJT : +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" , + iport); + +/* Retry Flogi again from the timer routine. */ + fabric->flags |=FNIC_FDLS_RETRY_FRAME ; + + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->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, +"iport 0x%p Canceling fabric disc timer\n" , + iport); +fnic_del_fabric_timer_sync (fnic); + } + fabric->timer_pending =0 ; + fabric->retry_counter =0 ; + } +break ; + +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FLOGI response not accepted: 0x%x" , + flogi_rsp->els.fl_cmd); +break ; + } +} + +static void +fdls_process_fabric_plogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *) fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *) fchdr; +struct fnic *fnic = iport->fnic; + +if (fdls_get_state ((&iport->fabric)) !=FDLS_STATE_FABRIC_PLOGI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Fabric PLOGI response received in state (%d). Dropping frame" , +fdls_get_state (&iport->fabric)); +return ; + } + +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +switch (plogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +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" , + iport->fcid); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + iport->fabric.retry_counter =0 ; +fdls_set_state (&iport->fabric,FDLS_STATE_RPN_ID ); +fdls_send_rpn_id (iport); +break ; +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (iport->fabric.retry_counter < iport->max_plogi_retries)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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, +"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, +"iport fcid: 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 ; +return ; + } +break ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI response not accepted: 0x%x" , + plogi_rsp->els.fl_cmd); +break ; + } +} + +static void +fdls_process_fabric_abts_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t s_id; +struct fc_std_abts_ba_acc *ba_acc = + (struct fc_std_abts_ba_acc *) fchdr; +struct fc_std_abts_ba_rjt *ba_rjt; +uint32_t fabric_state = iport->fabric.state; +struct fnic *fnic = iport->fnic; +int expected_rsp; +uint16_t oxid; + + s_id =ntoh24 (fchdr->fh_s_id); + ba_rjt = (struct fc_std_abts_ba_rjt *) fchdr; + +if (!((s_id ==FC_DIR_SERVER ) || (s_id ==FC_DOMAIN_CONTR ) + || (s_id ==FC_FABRIC_CONTROLLER ))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp with invalid SID: 0x%x. Dropping frame" , + s_id); +return ; + } + +if (iport->fabric.timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Canceling fabric disc timer %p\n" , iport); +fnic_del_fabric_timer_sync (fnic); + } + iport->fabric.timer_pending =0 ; + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; + +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp BA_ACC for fabric_state: %d OX_ID: 0x%x" , + fabric_state,be16_to_cpu (ba_acc->acc.ba_ox_id)); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"BA_RJT fs: %d OX_ID: 0x%x rc: 0x%x rce: 0x%x" , + fabric_state,be16_to_cpu (ba_rjt->fchdr.fh_ox_id), + ba_rjt->rjt.br_reason, ba_rjt->rjt.br_explan); + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); + expected_rsp =FDLS_OXID_TO_RSP_TYPE (oxid); +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, oxid); + +/* currently error handling/retry logic is same for ABTS BA_ACC & BA_RJT */ +switch (fabric_state) { +case FDLS_STATE_FABRIC_FLOGI : +if (expected_rsp ==FNIC_FABRIC_FLOGI_RSP ) { +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, +"Exceeded max FLOGI retries" ); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x FABRIC_FLOGI state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_FABRIC_LOGO : +if (expected_rsp ==FNIC_FABRIC_LOGO_RSP ) { +if (!RETRIES_EXHAUSTED (iport)) +fdls_send_fabric_logo (iport); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x FABRIC_FLOGI state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_FABRIC_PLOGI : +if (expected_rsp ==FNIC_FABRIC_PLOGI_RSP ) { +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, +"Exceeded max PLOGI retries" ); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x FABRIC_PLOGI state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +case FDLS_STATE_RPN_ID : +if (expected_rsp ==FNIC_FABRIC_RPN_RSP ) { +if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { +fdls_send_rpn_id (iport); + }else { +/* go back to fabric Plogi */ +fnic_fdls_start_plogi (iport); + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x RPN_ID state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +case FDLS_STATE_SCR : +if (expected_rsp ==FNIC_FABRIC_SCR_RSP ) { +if (iport->fabric.retry_counter <=FDLS_RETRY_COUNT ) +fdls_send_scr (iport); +else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"abts rsp fab SCR after two tries. Start fabric PLOGI %p" , + iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x SCR state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_REGISTER_FC4_TYPES : +if (expected_rsp ==FNIC_FABRIC_RFT_RSP ) { +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, +"abts rsp fab RFT_ID two tries. Start fabric PLOGI %p" , + iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x RFT state. Drop frame" , + fchdr->fh_ox_id); + } +break ; +case FDLS_STATE_REGISTER_FC4_FEATURES : +if (expected_rsp ==FNIC_FABRIC_RFF_RSP ) { +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, +"abts rsp fab SCR after two tries. Start fabric PLOGI %p" , + iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x RFF state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +case FDLS_STATE_GPN_FT : +if (expected_rsp ==FNIC_FABRIC_GPN_FT_RSP ) { +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, +"abts rsp fab GPN_FT after two tries %p" , + iport); + } + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown abts rsp OX_ID: 0x%x GPN_FT state. Drop frame" , + fchdr->fh_ox_id); + } +break ; + +default : +return ; + } +} + +/*
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c line 1669
Quoted 6 lines
drivers/scsi/fnic/fdls_disc.c new file +6
-0+* Performs a validation for all FCOE frames and return the frame type +*/ +int +fnic_fdls_validate_and_get_frame_type (struct fnic_iport_s *iport, +void *rx_frame,int len, +int fchdr_offset)Indentation.
Thanks Hannes. I'll fix this in the next version.
Quoted 317 lines
Quoted 317 lines
drivers/scsi/fnic/fdls_disc.c new file +237
-0+{ +struct fc_frame_header *fchdr; +uint8_t type; +uint8_t *fc_payload; +uint16_t oxid; +uint32_t s_id; +uint32_t d_id; +struct fnic *fnic = iport->fnic; +struct fnic_fdls_fabric_s *fabric = &iport->fabric; +int rsp_type; + + fchdr = + (struct fc_frame_header *) ((uint8_t *) rx_frame + fchdr_offset); + oxid =FNIC_STD_GET_OX_ID (fchdr); + fc_payload = (uint8_t *) fchdr +sizeof (struct fc_frame_header ); + type = *fc_payload; + s_id =ntoh24 (fchdr->fh_s_id); + d_id =ntoh24 (fchdr->fh_d_id); + +/* some common validation */ +if (iport->fcid) +if (fdls_get_state (fabric) >FDLS_STATE_FABRIC_FLOGI ) { +if ((iport->fcid != d_id) || (!FNIC_FC_FRAME_CS_CTL (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"invalid frame received. Dropping frame" ); +return -1 ; + } + } + +/* ABTS response */ +if ((fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) + || (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL )) { +if (!(FNIC_FC_FRAME_TYPE_BLS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received ABTS invalid frame. Dropping frame" ); +return -1 ; + + } +return FNIC_BLS_ABTS_RSP ; + } +if ((fchdr->fh_r_ctl ==FC_ABTS_RCTL ) + && (FNIC_FC_FRAME_TYPE_BLS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Receiving Abort Request from s_id: 0x%x" , s_id); +return FNIC_BLS_ABTS_REQ ; + } + +/* unsolicited requests frames */ +if (FNIC_FC_FRAME_UNSOLICITED (fchdr)) { +switch (type) { +case ELS_LOGO : +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, +"Received LOGO invalid frame. Dropping frame" ); +return -1 ; + } +return FNIC_ELS_LOGO_REQ ; +case ELS_RSCN : +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, +"Received RSCN invalid FCTL. Dropping frame" ); +return -1 ; + } +if (s_id !=FC_FABRIC_CONTROLLER ) +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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 ; +case ELS_PLOGI : +return FNIC_ELS_PLOGI_REQ ; +case ELS_ECHO : +return FNIC_ELS_ECHO_REQ ; +case ELS_ADISC : +return FNIC_ELS_ADISC ; +case ELS_RLS : +return FNIC_ELS_RLS ; +case ELS_RRQ : +return FNIC_ELS_RRQ ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unsupported frame (type:0x%02x) from fcid: 0x%x" , + type, s_id); +return FNIC_ELS_UNSUPPORTED_REQ ; + } + } + +/*response from fabric */ + rsp_type =fnic_fdls_expected_rsp (iport,ntohs (oxid)); + +switch (rsp_type) { + +case FNIC_FABRIC_FLOGI_RSP : +if (type ==ELS_LS_ACC ) { +if ((s_id !=FC_DOMAIN_CONTR ) + || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } + } +break ; + +case FNIC_FABRIC_PLOGI_RSP : +if (type ==ELS_LS_ACC ) { +if ((s_id !=FC_DIR_SERVER ) + || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } + } +break ; + +case FNIC_FABRIC_SCR_RSP : +if (type ==ELS_LS_ACC ) { +if ((s_id !=FC_FABRIC_CONTROLLER ) + || (!FNIC_FC_FRAME_TYPE_ELS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } + } +break ; + +case FNIC_FABRIC_RPN_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_RFT_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_RFF_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_GPN_FT_RSP : +if ((s_id !=FC_DIR_SERVER ) || (!FNIC_FC_FRAME_TYPE_FC_GS (fchdr))) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown frame. Dropping frame" ); +return -1 ; + } +break ; + +case FNIC_FABRIC_LOGO_RSP : +break ; +default : +/* Drop the Rx frame and log/stats it */ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Solicited response: unknown OXID: 0x%x" , oxid); +return -1 ; + } + +return rsp_type; +} + +void fnic_fdls_recv_frame (struct fnic_iport_s *iport,void *rx_frame, +int len,int fchdr_offset) +{ +uint16_t oxid; +struct fc_frame_header *fchdr; +uint32_t s_id =0 ; +uint32_t d_id =0 ; +struct fnic *fnic = iport->fnic; +int frame_type; + + fchdr = + (struct fc_frame_header *) ((uint8_t *) rx_frame + fchdr_offset); + s_id =ntoh24 (fchdr->fh_s_id); + d_id =ntoh24 (fchdr->fh_d_id); + + frame_type = +fnic_fdls_validate_and_get_frame_type (iport, rx_frame, len, + fchdr_offset); + +/*if we are in flogo drop everything else */ +if (iport->fabric.state ==FDLS_STATE_FABRIC_LOGO && + frame_type !=FNIC_FABRIC_LOGO_RSP ) +return ; + +switch (frame_type) { +case FNIC_FABRIC_FLOGI_RSP : +fdls_process_flogi_rsp (iport, fchdr, rx_frame); +break ; +case FNIC_FABRIC_PLOGI_RSP : +fdls_process_fabric_plogi_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_RPN_RSP : +fdls_process_rpn_id_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_RFT_RSP : +fdls_process_rft_id_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_RFF_RSP : +fdls_process_rff_id_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_SCR_RSP : +fdls_process_scr_rsp (iport, fchdr); +break ; +case FNIC_FABRIC_GPN_FT_RSP : +fdls_process_gpn_ft_rsp (iport, fchdr, len); +break ; +case FNIC_FABRIC_LOGO_RSP : +fdls_process_fabric_logo_rsp (iport, fchdr); +break ; + +case FNIC_BLS_ABTS_RSP : + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +if (fdls_is_oxid_in_fabric_range (oxid) && + (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +fdls_process_fabric_abts_rsp (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); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received unknown FCoE frame of len: %d. Dropping frame" , len); +break ; + } +}drivers/scsi/fnic/fnic.h +22
-1@@ -24,6 +24,7 @@#include "vnic_intr.h" #include "vnic_stats.h" #include "vnic_scsi.h" +#include "fnic_fdls.h" #define DRV_NAME "fnic"#define DRV_DESCRIPTION "Cisco FCoE HBA Driver"@@ -31,6 +32,7 @@#define PFX DRV_NAME ": "#define DFX DRV_NAME "%d: " +#define FABRIC_LOGO_MAX_RETRY 3#define DESC_CLEAN_LOW_WATERMARK 8#define FNIC_UCSM_DFLT_THROTTLE_CNT_BLD 16/* UCSM default throttle count */ #define FNIC_MIN_IO_REQ 256/* Min IO throttle count */ @@ -75,6 +77,8 @@#define FNIC_DEV_RST_TERM_DONE BIT(20)#define FNIC_DEV_RST_ABTS_PENDING BIT(21) +#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +/* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. @@ -213,12 +217,26 @@ enum fnic_state {struct mempool ; +enum fnic_role_e { +FNIC_ROLE_FCP_INITIATOR =0 , +}; +enum fnic_evt {FNIC_EVT_START_VLAN_DISC =1 ,FNIC_EVT_START_FCF_DISC =2 ,FNIC_EVT_MAX , }; +struct fnic_frame_list { +/* +* Link to frame lists +*/ +struct list_head links; +void *fp; +int frame_len; +int rx_ethhdr_stripped; +}; +struct fnic_event {struct list_head list;struct fnic *fnic;@@ -235,6 +253,8 @@ struct fnic_cpy_wq {/* Per-instance private data structure */ struct fnic {int fnic_num; +enum fnic_role_e role; +struct fnic_iport_s iport;struct fc_lport *lport;struct fcoe_ctlr ctlr;/* FIP FCoE controller structure */ struct vnic_dev_bar bar0;@@ -278,6 +298,7 @@ struct fnic {unsigned long state_flags;/* protected by host lock */ enum fnic_state state;spinlock_t fnic_lock; +unsigned long lock_flags;u16 vlan_id;/* VLAN tag including priority */ u8 data_src_addr[ETH_ALEN ];@@ -307,7 +328,7 @@ struct fnic {struct work_struct frame_work;struct work_struct flush_work;struct sk_buff_head frame_queue; -struct sk_buff_head tx_queue; +struct list_head tx_queue;
Quoted 9 lines
drivers/scsi/fnic/fnic.h void fnic_handle_fip_frame(struct work_struct *work); · line 400
Quoted 7 lines
drivers/scsi/fnic/fnic.h +0
-1/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);@@ -397,7 +418,6 @@ 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 fnic *fnic);Why is this here?
Could you please clarify Hannes? Do you mean why fnic_handle_fip_timer is being deleted? Or that the FIP members need to be in a later patch? Please let us know.
Quoted 265 lines
Quoted 265 lines
drivers/scsi/fnic/fnic.h +2
-0static inline int fnic_chk_state_flags_locked (struct fnic *fnic,unsigned long st_flags)@@ -406,4 +426,6 @@ fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags) }void __fnic_set_state_flags (struct fnic *,unsigned long ,unsigned long );void fnic_dump_fchost_stats (struct Scsi_Host *,struct fc_host_statistics *); +void fnic_free_txq (struct list_head *head); +#endif /* _FNIC_H_ */ drivers/scsi/fnic/fnic_fcs.c +123
-75@@ -20,6 +20,8 @@#include "fnic_io.h" #include "fnic.h" #include "fnic_fip.h" +#include "fnic_fdls.h" +#include "fdls_fc.h" #include "cq_enet_desc.h" #include "cq_exch_desc.h" @@ -28,12 +30,90 @@ struct workqueue_struct *fnic_fip_queue;struct workqueue_struct *fnic_event_queue;static void fnic_set_eth_mode (struct fnic *); -static void fnic_fcoe_send_vlan_req (struct fnic *fnic);static void fnic_fcoe_start_fcf_disc (struct fnic *fnic);static void fnic_fcoe_process_vlan_resp (struct fnic *fnic,struct sk_buff *);static int fnic_fcoe_vlan_check (struct fnic *fnic,u16 flag);static int fnic_fcoe_handle_fip_frame (struct fnic *fnic,struct sk_buff *skb); +/* Frame initialization */ +/* +* Variables: +* dst_mac, src_mac +*/ +struct fnic_eth_hdr_s fnic_eth_hdr_fcoe = { + .ether_type =0x0689 +}; + +/* +* Variables: +* None +*/ +struct fnic_fcoe_hdr_s fnic_fcoe_hdr = { + .sof =0x2E +}; + +uint8_t FCOE_ALL_FCF_MAC [6 ] = {0x0e ,0xfc ,0x00 ,0xff ,0xff ,0xfe }; + +/* +* Internal Functions +* This function will initialize the src_mac address to be +* used in outgoing frames +*/ +static inline void fnic_fdls_set_fcoe_srcmac (struct fnic *fnic, +uint8_t *src_mac) +{ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Setting src mac: %02x:%02x:%02x:%02x:%02x:%02x" , + src_mac[0 ], src_mac[1 ], src_mac[2 ], src_mac[3 ], + src_mac[4 ], src_mac[5 ]); + +memcpy (fnic->iport.fpma, src_mac,6 ); +} + +/* +* This function will initialize the dst_mac address to be +* used in outgoing frames +*/ +static inline void fnic_fdls_set_fcoe_dstmac (struct fnic *fnic, +uint8_t *dst_mac) +{ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Setting dst mac: %02x:%02x:%02x:%02x:%02x:%02x" , + dst_mac[0 ], dst_mac[1 ], dst_mac[2 ], dst_mac[3 ], + dst_mac[4 ], dst_mac[5 ]); + +memcpy (fnic->iport.fcfmac, dst_mac,6 ); +} + +/* +* FPMA can be either taken from ethhdr(dst_mac) or flogi resp +* or derive from FC_MAP and FCID combination. While it should be +* same, revisit this if there is any possibility of not-correct. +*/ +void fnic_fdls_learn_fcoe_macs (struct fnic_iport_s *iport,void *rx_frame, +uint8_t *fcid) +{ +struct fnic *fnic = iport->fnic; +struct fnic_eth_hdr_s *ethhdr = (struct fnic_eth_hdr_s *) rx_frame; +uint8_t fcmac[6 ] = {0x0E ,0xFC ,0x00 ,0x00 ,0x00 ,0x00 }; + +memcpy (&fcmac[3 ], fcid,3 ); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"learn fcoe: dst_mac: %02x:%02x:%02x:%02x:%02x:%02x" , + ethhdr->dst_mac[0 ], ethhdr->dst_mac[1 ], + ethhdr->dst_mac[2 ], ethhdr->dst_mac[3 ], + ethhdr->dst_mac[4 ], ethhdr->dst_mac[5 ]); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"learn fcoe: fc_mac: %02x:%02x:%02x:%02x:%02x:%02x" , + fcmac[0 ], fcmac[1 ], fcmac[2 ], fcmac[3 ], fcmac[4 ], + fcmac[5 ]); + +fnic_fdls_set_fcoe_srcmac (fnic, fcmac); +fnic_fdls_set_fcoe_dstmac (fnic, ethhdr->src_mac); +} +void fnic_handle_link (struct work_struct *work) { struct fnic *fnic = container_of(work, struct fnic, link_work);@@ -363,7 +443,7 @@ static inline int is_fnic_fip_flogi_reject(struct fcoe_ctlr *fip,return 0 ; } -static void fnic_fcoe_send_vlan_req (struct fnic *fnic) +void fnic_fcoe_send_vlan_req (struct fnic *fnic) {struct fcoe_ctlr *fip = &fnic->ctlr;struct fnic_stats *fnic_stats = &fnic->fnic_stats;@@ -1068,116 +1148,119 @@ void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb)/* * Send FC frame. */ -static int fnic_send_frame (struct fnic *fnic,struct fc_frame *fp) +static int fnic_send_frame (struct fnic *fnic,void *frame,int frame_len) {struct vnic_wq *wq = &fnic->wq[0 ]; -struct sk_buff *skb;dma_addr_t pa; -struct ethhdr *eth_hdr; -struct vlan_ethhdr *vlan_hdr; -struct fcoe_hdr *fcoe_hdr; -struct fc_frame_header *fh; -u32 tot_len, eth_hdr_len;int ret =0 ;unsigned long flags; - fh =fc_frame_header_get (fp); - skb =fp_skb (fp); - -if (unlikely (fh->fh_r_ctl ==FC_RCTL_ELS_REQ ) && -fcoe_ctlr_els_send (&fnic->ctlr, fnic->lport, skb)) -return 0 ; - -if (!fnic->vlan_hw_insert) { - eth_hdr_len =sizeof (*vlan_hdr) +sizeof (*fcoe_hdr); - vlan_hdr =skb_push (skb, eth_hdr_len); - eth_hdr = (struct ethhdr *)vlan_hdr; - vlan_hdr->h_vlan_proto =htons (ETH_P_8021Q ); - vlan_hdr->h_vlan_encapsulated_proto =htons (ETH_P_FCOE ); - vlan_hdr->h_vlan_TCI =htons (fnic->vlan_id); - fcoe_hdr = (struct fcoe_hdr *)(vlan_hdr +1 ); - }else { - eth_hdr_len =sizeof (*eth_hdr) +sizeof (*fcoe_hdr); - eth_hdr =skb_push (skb, eth_hdr_len); - eth_hdr->h_proto =htons (ETH_P_FCOE ); - fcoe_hdr = (struct fcoe_hdr *)(eth_hdr +1 ); - } - -if (fnic->ctlr.map_dest) -fc_fcoe_set_mac (eth_hdr->h_dest, fh->fh_d_id); -else -memcpy (eth_hdr->h_dest, fnic->ctlr.dest_addr,ETH_ALEN ); -memcpy (eth_hdr->h_source, fnic->data_src_addr,ETH_ALEN ); - - tot_len = skb->len; -BUG_ON (tot_len %4 ); + pa =dma_map_single (&fnic->pdev->dev, frame, frame_len,DMA_TO_DEVICE ); -memset (fcoe_hdr,0 ,sizeof (*fcoe_hdr)); - fcoe_hdr->fcoe_sof =fr_sof (fp); -if (FC_FCOE_VER ) -FC_FCOE_ENCAPS_VER (fcoe_hdr,FC_FCOE_VER ); - - pa =dma_map_single (&fnic->pdev->dev, eth_hdr, tot_len,DMA_TO_DEVICE ); -if (dma_mapping_error (&fnic->pdev->dev, pa)) { - ret = -ENOMEM ; -printk (KERN_ERR "DMA map failed with error %d\n" , ret); - goto free_skb_on_err; - } - -if ((fnic_fc_trace_set_data (fnic->lport->host->host_no,FNIC_FC_SEND , - (char *)eth_hdr, tot_len)) !=0 ) { -printk (KERN_ERR "fnic ctlr frame trace error!!!" ); +if ((fnic_fc_trace_set_data (fnic->fnic_num, +FNIC_FC_SEND |0x80 , (char *) frame, + frame_len)) !=0 ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fnic ctlr frame trace error" ); }spin_lock_irqsave (&fnic->wq_lock[0 ], flags);if (!vnic_wq_desc_avail (wq)) { -dma_unmap_single (&fnic->pdev->dev, pa, tot_len,DMA_TO_DEVICE ); +dma_unmap_single (&fnic->pdev->dev, pa, frame_len,DMA_TO_DEVICE ); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"vnic work queue descriptor is not available" ); ret =-1 ; - goto irq_restore; + goto fnic_send_frame_end; } -fnic_queue_wq_desc (wq, skb, pa, tot_len,fr_eof (fp), -0 /* hw inserts cos value */ , - fnic->vlan_id,1 ,1 ,1 ); +/* hw inserts cos value */ +fnic_queue_wq_desc (wq, frame, pa, frame_len,FNIC_FCOE_EOF , +0 , fnic->vlan_id,1 ,1 ,1 ); -irq_restore: +fnic_send_frame_end:spin_unlock_irqrestore (&fnic->wq_lock[0 ], flags); - -free_skb_on_err: -if (ret) -dev_kfree_skb_any (fp_skb (fp)); -return ret; } -/* -* fnic_send -* Routine to send a raw frame -*/ -int fnic_send (struct fc_lport *lp,struct fc_frame *fp) +static int +fdls_send_fcoe_frame (struct fnic *fnic,void *payload,int payload_sz, +uint8_t *srcmac,uint8_t *dstmac) { -struct fnic *fnic =lport_priv (lp); -unsigned long flags; +uint8_t *frame; +struct fnic_eth_hdr_s *ethhdr; +struct fnic_frame_list *frame_elem; +int max_framesz =FNIC_FCOE_FRAME_MAXSZ ; +int len =0 ; +int ret; -if (fnic->in_remove) { -dev_kfree_skb (fp_skb (fp)); -return -1 ; + frame =kzalloc (max_framesz,GFP_ATOMIC ); +if (!frame) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate frame for flogi\n" ); +return -ENOMEM ; } + ethhdr = (struct fnic_eth_hdr_s *) frame; + +memcpy (frame, (uint8_t *) &fnic_eth_hdr_fcoe, +sizeof (struct fnic_eth_hdr_s )); + len =sizeof (struct fnic_eth_hdr_s ); + +memcpy (ethhdr->src_mac, srcmac,ETH_ALEN ); +memcpy (ethhdr->dst_mac, dstmac,ETH_ALEN ); + +memcpy (frame + len, (uint8_t *) &fnic_fcoe_hdr, +sizeof (struct fnic_fcoe_hdr_s )); + len +=sizeof (struct fnic_fcoe_hdr_s );
Quoted 8 lines
drivers/scsi/fnic/fnic_fcs.c void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb) · line 1217
Quoted 3 lines
drivers/scsi/fnic/fnic_fcs.c +3
-0+ +memcpy (frame + len, (uint8_t *) payload, payload_sz); + len += payload_sz;Ouch.
kmalloc()in the hot path. And memcpy the constructed data onto it. Please, don't.
Use the constructed data directly.
Thanks for your insights, Hannes.
We are discussing this internally.
Quoted 17 lines
drivers/scsi/fnic/fnic_fcs.c void fnic_eth_send(struct fcoe_ctlr *fip, struct sk_buff *skb) · line 1225
Quoted 12 lines
drivers/scsi/fnic/fnic_fcs.c +3
-4/* * Queue frame if in a transitional state. * This occurs while registering the Port_ID / MAC address after FLOGI. */ -spin_lock_irqsave (&fnic->fnic_lock, flags); -if (fnic->state !=FNIC_IN_FC_MODE && fnic->state !=FNIC_IN_ETH_MODE ) { -skb_queue_tail (&fnic->tx_queue,fp_skb (fp)); -spin_unlock_irqrestore (&fnic->fnic_lock, flags); +if ((fnic->state !=FNIC_IN_FC_MODE ) + && (fnic->state !=FNIC_IN_ETH_MODE )) { + frame_elem =kzalloc (sizeof (struct fnic_frame_list ),GFP_ATOMIC );And another one. Please, don't.
If you need an interdiate structure use a mempool, and allocate from there. Ideally you would not require that structure, though, but rather use the constructed frame directly.
Thanks for your insights, Hannes.
We are discussing approaches internally.
Quoted 355 lines
Quoted 344 lines
drivers/scsi/fnic/fnic_fcs.c +101
-91+if (!frame_elem) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate memory for fnic_frame_list: %lu\n" , +sizeof (struct fnic_frame_list )); +return -ENOMEM ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Queuing frame: 0x%p\n" , frame); + + frame_elem->fp = frame; + frame_elem->frame_len = len; +list_add_tail (&frame_elem->links, &fnic->tx_queue);return 0 ; } -spin_unlock_irqrestore (&fnic->fnic_lock, flags); -return fnic_send_frame (fnic, fp); + ret =fnic_send_frame (fnic, frame, len); +return ret; +} + +void fnic_send_fcoe_frame (struct fnic_iport_s *iport,void *payload, +int payload_sz) +{ +struct fnic *fnic = iport->fnic; +uint8_t *dstmac, *srcmac; + +/* If module unload is in-progress, don't send */ +if (fnic->in_remove) +return ; + +if (iport->fabric.flags &FNIC_FDLS_FPMA_LEARNT ) { + srcmac = iport->fpma; + dstmac = iport->fcfmac; + }else { + srcmac = iport->hwmac; + dstmac =FCOE_ALL_FCF_MAC ; + } + +fdls_send_fcoe_frame (fnic, payload, payload_sz, srcmac, dstmac); }/** @@ -1193,15 +1276,66 @@ int fnic_send(struct fc_lport *lp, struct fc_frame *fp)void fnic_flush_tx (struct work_struct *work) { struct fnic *fnic = container_of(work, struct fnic, flush_work); -struct sk_buff *skb;struct fc_frame *fp; +struct fnic_frame_list *cur_frame, *next; -while ((skb =skb_dequeue (&fnic->tx_queue))) { - fp = (struct fc_frame *)skb; -fnic_send_frame (fnic, fp); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Flush queued frames" ); + +list_for_each_entry_safe (cur_frame, next, &fnic->tx_queue, links) { + fp = cur_frame->fp; +list_del (&cur_frame->links); +fnic_send_frame (fnic, fp, cur_frame->frame_len); } } +int +fnic_fdls_register_portid (struct fnic_iport_s *iport,u32 port_id, +void *fp) +{ +struct fnic *fnic = iport->fnic; +struct fnic_eth_hdr_s *ethhdr; +int ret; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Setting port id: 0x%x fp: 0x%p fnic state: %d" , port_id, + fp, fnic->state); + +if (fp) { + ethhdr = (struct fnic_eth_hdr_s *) fp; +vnic_dev_add_addr (fnic->vdev, ethhdr->dst_mac); + } + +/* Change state to reflect transition to FC mode */ +if (fnic->state ==FNIC_IN_ETH_MODE || fnic->state ==FNIC_IN_FC_MODE ) + fnic->state =FNIC_IN_ETH_TRANS_FC_MODE ; +else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unexpected fnic state while processing FLOGI response\n" ); +return -1 ; + } + +/* +* Send FLOGI registration to firmware to set up FC mode. +* The new address will be set up when registration completes. +*/ + ret =fnic_flogi_reg_handler (fnic, port_id); +if (ret <0 ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FLOGI registration error ret: %d fnic state: %d\n" , + ret, fnic->state); +if (fnic->state ==FNIC_IN_ETH_TRANS_FC_MODE ) + fnic->state =FNIC_IN_ETH_MODE ; + +return -1 ; + } + iport->fabric.flags |=FNIC_FDLS_FPMA_LEARNT ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FLOGI registration success\n" ); +return 0 ; +} +/** * fnic_set_eth_mode() - put fnic into ethernet mode. * @fnic: fnic device @@ -1240,6 +1374,17 @@ static void fnic_set_eth_mode(struct fnic *fnic)spin_unlock_irqrestore (&fnic->fnic_lock, flags); } +void fnic_free_txq (struct list_head *head) +{ +struct fnic_frame_list *cur_frame, *next; + +list_for_each_entry_safe (cur_frame, next, head, links) { +list_del (&cur_frame->links); +kfree (cur_frame->fp); +kfree (cur_frame); + } +} +static void fnic_wq_complete_frame_send (struct vnic_wq *wq,struct cq_desc *cq_desc,struct vnic_wq_buf *buf,void *opaque)@@ -1319,88 +1464,3 @@ void fnic_fcoe_reset_vlans(struct fnic *fnic)spin_unlock_irqrestore (&fnic->vlans_lock, flags); } -void fnic_handle_fip_timer (struct fnic *fnic) -{ -unsigned long flags; -struct fcoe_vlan *vlan; -struct fnic_stats *fnic_stats = &fnic->fnic_stats; -u64 sol_time; - -spin_lock_irqsave (&fnic->fnic_lock, flags); -if (fnic->stop_rx_link_events) { -spin_unlock_irqrestore (&fnic->fnic_lock, flags); -return ; - } -spin_unlock_irqrestore (&fnic->fnic_lock, flags); - -if (fnic->ctlr.mode ==FIP_MODE_NON_FIP ) -return ; - -spin_lock_irqsave (&fnic->vlans_lock, flags); -if (list_empty (&fnic->vlans)) { -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -/* no vlans available, try again */ -if (unlikely (fnic_log_level &FNIC_FCS_LOGGING )) -if (printk_ratelimit ()) -shost_printk (KERN_DEBUG , fnic->lport->host, -"Start VLAN Discovery\n" ); -fnic_event_enq (fnic,FNIC_EVT_START_VLAN_DISC ); -return ; - } - - vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, list); -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, -"fip_timer: vlan %d state %d sol_count %d\n" , - vlan->vid, vlan->state, vlan->sol_count); -switch (vlan->state) { -case FIP_VLAN_USED : -FNIC_FCS_DBG (KERN_DEBUG , fnic->lport->host, fnic->fnic_num, -"FIP VLAN is selected for FC transaction\n" ); -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -break ; -case FIP_VLAN_FAILED : -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -/* if all vlans are in failed state, restart vlan disc */ -if (unlikely (fnic_log_level &FNIC_FCS_LOGGING )) -if (printk_ratelimit ()) -shost_printk (KERN_DEBUG , fnic->lport->host, -"Start VLAN Discovery\n" ); -fnic_event_enq (fnic,FNIC_EVT_START_VLAN_DISC ); -break ; -case FIP_VLAN_SENT : -if (vlan->sol_count >=FCOE_CTLR_MAX_SOL ) { -/* -* no response on this vlan, remove from the list. -* Try the next vlan -*/ -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"Dequeue this VLAN ID %d from list\n" , - vlan->vid); -list_del (&vlan->list); -kfree (vlan); - vlan =NULL ; -if (list_empty (&fnic->vlans)) { -/* we exhausted all vlans, restart vlan disc */ -spin_unlock_irqrestore (&fnic->vlans_lock, - flags); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"fip_timer: vlan list empty, " -"trigger vlan disc\n" ); -fnic_event_enq (fnic,FNIC_EVT_START_VLAN_DISC ); -return ; - } -/* check the next vlan */ - vlan = list_first_entry(&fnic->vlans, struct fcoe_vlan, - list); - fnic->set_vlan (fnic, vlan->vid); - vlan->state =FIP_VLAN_SENT ;/* sent now */ - } -spin_unlock_irqrestore (&fnic->vlans_lock, flags); -atomic64_inc (&fnic_stats->vlan_stats.sol_expiry_count); - vlan->sol_count++; - sol_time = jiffies +msecs_to_jiffies - (FCOE_CTLR_START_DELAY ); -mod_timer (&fnic->fip_timer,round_jiffies (sol_time)); -break ; - } -}drivers/scsi/fnic/fnic_fdls.h +2
-3@@ -382,8 +382,8 @@ inline void fnic_del_tport_timer_sync(struct fnic *fnic, struct fnic_tport_s *tport);void fdls_send_fabric_logo (struct fnic_iport_s *iport);int fnic_fdls_validate_and_get_frame_type (struct fnic_iport_s *iport, -void *rx_frame,int len, -int fchdr_offset); +void *rx_frame,int len, +int fchdr_offset);void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport); bool fdls_delete_tport(struct fnic_iport_s *iport,@@ -399,7 +399,6 @@ int fnic_send_fip_frame(struct fnic_iport_s *iport, void *payload, int payload_sz);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 +5
-5@@ -31,6 +31,8 @@#include "fnic_io.h" #include "fnic_fip.h" #include "fnic.h" +#include "fnic_fdls.h" +#include "fdls_fc.h" #define PCI_DEVICE_ID_CISCO_FNIC 0x0045@@ -80,7 +82,6 @@ module_param(fnic_max_qdepth, uint, S_IRUGO|S_IWUSR);MODULE_PARM_DESC (fnic_max_qdepth,"Queue depth to report for each LUN" );static struct libfc_function_template fnic_transport_template = { - .frame_send = fnic_send, .lport_set_port_id = fnic_set_port_id, .fcp_abort_io = fnic_empty_scsi_cleanup, .fcp_cleanup = fnic_empty_scsi_cleanup,@@ -413,7 +414,7 @@ static void fnic_fip_notify_timer(struct timer_list *t) {struct fnic *fnic =from_timer (fnic, t, fip_timer); -fnic_handle_fip_timer (fnic); +/* Placeholder function */ }static void fnic_notify_timer_start (struct fnic *fnic)@@ -921,7 +922,7 @@ 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);skb_queue_head_init (&fnic->frame_queue); -skb_queue_head_init (&fnic->tx_queue); +INIT_LIST_HEAD (&fnic->tx_queue);fc_fabric_login (lp);@@ -1004,7 +1005,7 @@ static void fnic_remove(struct pci_dev *pdev)*/ flush_workqueue (fnic_event_queue);skb_queue_purge (&fnic->frame_queue); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue);if (fnic->config.flags &VFCF_FIP_CAPABLE ) {del_timer_sync (&fnic->fip_timer);@@ -1036,7 +1037,6 @@ static void fnic_remove(struct pci_dev *pdev)fnic_cleanup (fnic);BUG_ON (!skb_queue_empty (&fnic->frame_queue)); -BUG_ON (!skb_queue_empty (&fnic->tx_queue));spin_lock_irqsave (&fnic_list_lock, flags);list_del (&fnic->list);drivers/scsi/fnic/fnic_scsi.c +2
-2@@ -184,7 +184,7 @@ int fnic_fw_reset_handler(struct fnic *fnic)fnic_set_state_flags (fnic,FNIC_FLAGS_FWRESET );skb_queue_purge (&fnic->frame_queue); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue);/* wait for io cmpl */ while (atomic_read (&fnic->in_flight))@@ -674,7 +674,7 @@ static int fnic_fcpio_fw_reset_cmpl_handler(struct fnic *fnic,*/ if (fnic->remove_wait || ret) {spin_unlock_irqrestore (&fnic->fnic_lock, flags); -skb_queue_purge (&fnic->tx_queue); +fnic_free_txq (&fnic->tx_queue); goto reset_cmpl_handler_end; }drivers/scsi/fnic/fnic_scsi.c static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data) · line 1723
Quoted 8 lines
drivers/scsi/fnic/fnic_scsi.c +1
-1@@ -1717,7 +1717,7 @@ static bool fnic_rport_abort_io_iter(struct scsi_cmnd *sc, void *data)return true; } -static void fnic_rport_exch_reset (struct fnic *fnic,u32 port_id) +void fnic_rport_exch_reset (struct fnic *fnic,u32 port_id) {struct terminate_stats *term_stats = &fnic->fnic_stats.term_stats;struct fnic_rport_abort_io_iter_data iter_data = {Cheers,
Quoted 6 lines
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Regards,
Karan
Karan Tilak Kumar
maintainerPATCH v5 4/14 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/
---
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 | 1569 +++++++++++++++++++++++++++++++-- drivers/scsi/fnic/fnic.h | 6 + drivers/scsi/fnic/fnic_fdls.h | 2 +- 3 files changed, 1502 insertions(+), 75 deletions(-)
drivers/scsi/fnic/fdls_disc.c +1495 -74
@@ -11,6 +11,10 @@#include <scsi/fc/fc_fcp.h> #include <linux/utsname.h> +#define FC_FC4_TYPE_SCSI 0x08 + +static void fdls_send_rpn_id (struct fnic_iport_s *iport); +/* Frame initialization */ /* * Variables:
@@ -66,6 +70,20 @@ struct fc_std_rpn_id fnic_std_rpn_id_req = { .ct_cmd = cpu_to_be16(FC_NS_RPN_ID)} }; +/* +* Variables: +* did, sid, oxid +*/ +struct fc_std_els_prli fnic_std_prli_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, .fh_rx_id =0xFFFF }, + .els_prli = {.prli_cmd =ELS_PRLI , + .prli_spp_len =16 , + .prli_len =cpu_to_be16 (0x14 )}, + .sp = {.spp_type =0x08 , .spp_flags =0x0020 , + .spp_params =cpu_to_be32 (0xA2 )} +}; +/* * Variables: * fh_s_id, port_id, port_name
@@ -143,9 +161,19 @@ struct fc_frame_header fc_std_fabric_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +struct fc_frame_header fc_std_tport_abts = { + .fh_r_ctl =FC_RCTL_BA_ABTS ,/* ABTS */ + .fh_cs_ctl =0x00 , .fh_type =FC_TYPE_BLS , + .fh_f_ctl = {FNIC_REQ_ABTS_FCTL ,0 ,0 }, .fh_seq_id =0x00 , + .fh_df_ctl =0x00 , .fh_seq_cnt =0x0000 , .fh_rx_id =0xFFFF , + .fh_parm_offset =0x00000000 ,/* bit:0 = 0 Abort a exchange */ +}; +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY) +#define FNIC_TPORT_MAX_NEXUS_RESTART (8) +/* * For fabric requests and fdmi, once OXIDs are allocated from the pool * (and a range) they are encoded with expected rsp type as
@@ -167,6 +195,14 @@ 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
@@ -182,6 +218,8 @@ void fdls_init_oxid_pool(struct fnic_iport_s *iport)fdls_init_fabric_oxid_pool (&iport->fdmi_oxid_pool,FDLS_FDMI_OXID_POOL_BASE ,FDLS_FDMI_OXID_POOL_SZ ); + +fdls_init_tgt_oxid_pool (iport); } uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport,
@@ -313,6 +351,13 @@ static inline void fdls_schedule_fabric_oxid_free(struct fnic_iport_s iport->fabric_oxid_pool.active_oxid_fabric_req); } +static inline void fdls_schedule_tgt_oxid_free (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s + *oxid_pool,uint16_t oxid) +{ +fdls_schedule_oxid_free (&oxid_pool->meta, oxid); +} +int fnic_fdls_expected_rsp (struct fnic_iport_s *iport,uint16_t oxid) {struct fnic *fnic = iport->fnic;
@@ -340,6 +385,62 @@ static int fdls_is_oxid_in_fabric_range(uint16_t oxid) (oxid_unmasked <= FDLS_FABRIC_OXID_POOL_END)); } +void fdls_init_tgt_oxid_pool (struct fnic_iport_s *iport) +{ +memset (&iport->plogi_oxid_pool,0 ,sizeof (iport->plogi_oxid_pool)); + iport->plogi_oxid_pool.meta.oxid_base =FDLS_PLOGI_OXID_BASE ; + iport->plogi_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->plogi_oxid_pool.meta.reclaim_list); + +memset (&iport->prli_oxid_pool,0 ,sizeof (iport->prli_oxid_pool)); + iport->prli_oxid_pool.meta.oxid_base =FDLS_PRLI_OXID_BASE ; + iport->prli_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->prli_oxid_pool.meta.reclaim_list); + +memset (&iport->adisc_oxid_pool,0 ,sizeof (iport->adisc_oxid_pool)); + iport->adisc_oxid_pool.meta.oxid_base =FDLS_ADISC_OXID_BASE ; + iport->adisc_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->adisc_oxid_pool.meta.reclaim_list); +} + +inline uint16_t fdls_alloc_tgt_oxid (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s *oxid_pool) +{ +uint16_t oxid; + + oxid =fdls_alloc_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap); +return oxid; +} + +inline void fdls_free_tgt_oxid (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s *oxid_pool, +uint16_t oxid) +{ +fdls_free_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap, oxid); +} + +static struct fnic_tgt_oxid_pool_s *fdls_get_tgt_oxid_pool (struct fnic_tport_s + *tport) +{ +struct fnic_iport_s *iport = (struct fnic_iport_s *)tport->iport; +struct fnic_tgt_oxid_pool_s *oxid_pool =NULL ; + +switch (tport->state) { +case FDLS_TGT_STATE_PLOGI : + oxid_pool = &iport->plogi_oxid_pool; +break ; +case FDLS_TGT_STATE_PRLI : + oxid_pool = &iport->prli_oxid_pool; +break ; +case FDLS_TGT_STATE_ADISC : + oxid_pool = &iport->adisc_oxid_pool; +break ; +default : +break ; + } +return oxid_pool; +} +inline void fnic_del_fabric_timer_sync (struct fnic *fnic) { fnic->iport.fabric.del_timer_inprogress =1 ;
@@ -383,6 +484,56 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) "fabric timer is %d ", timeout); } +static void +fdls_start_tport_timer (struct fnic_iport_s *iport, +struct fnic_tport_s *tport,int timeout) +{ +u64 fabric_tov; +struct fnic *fnic = iport->fnic; + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + tport->timer_pending =0 ; + } + +if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) + tport->retry_counter++; + + fabric_tov = jiffies +msecs_to_jiffies (timeout); +mod_timer (&tport->retry_timer,round_jiffies (fabric_tov)); + tport->timer_pending =1 ; +} + +void +fdls_send_tport_abts (struct fnic_iport_s *iport, +struct fnic_tport_s *tport) +{ +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header tport_abort = fc_std_tport_abts; +struct fc_frame_header *tport_abts = &tport_abort; + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (tport_abts, s_id); +FNIC_STD_SET_D_ID (tport_abts, d_id); + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + + tport_abts->fh_ox_id = tport->oxid_used; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending tport abts: tport->state: %d " , + tport->state); + +fnic_send_fcoe_frame (iport, tport_abts,sizeof (struct fc_frame_header )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport,2 * iport->e_d_tov); +} +static void fdls_send_fabric_abts (struct fnic_iport_s *iport) {uint8_t fcid[3 ];
@@ -614,6 +765,176 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state)fdls_set_state ((&iport->fabric), fdls_state); } +static void +fdls_send_tgt_adisc (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_els_adisc adisc; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +memset (&adisc,0 ,sizeof (struct fc_std_els_adisc )); +FNIC_STD_SET_R_CTL (&adisc.fchdr,0x22 ); +FNIC_STD_SET_TYPE (&adisc.fchdr,0x01 ); +FNIC_STD_SET_F_CTL (&adisc.fchdr,FNIC_ELS_REQ_FCTL <<16 ); +FNIC_STD_SET_RX_ID (&adisc.fchdr,cpu_to_be16 (0xFFFF )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (&adisc.fchdr, s_id); +FNIC_STD_SET_D_ID (&adisc.fchdr, d_id); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->adisc_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send ADISC %p" , iport); +return ; + } + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_OX_ID ((&adisc.fchdr), oxid); +FNIC_STD_SET_NPORT_NAME (&adisc.els.adisc_wwpn, +le64_to_cpu (iport->wwpn)); +FNIC_STD_SET_NODE_NAME (&adisc.els.adisc_wwnn,le64_to_cpu (iport->wwnn)); + +memcpy (adisc.els.adisc_port_id, s_id,3 ); + adisc.els.adisc_cmd =ELS_ADISC ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"sending ADISC to tgt fcid: 0x%x" , tport->fcid); + + +fnic_send_fcoe_frame (iport, &adisc,sizeof (struct fc_std_els_adisc )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport,2 * iport->e_d_tov); +} + +bool fdls_delete_tport (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fnic_tport_event_s *tport_del_evt; +struct fnic *fnic = iport->fnic; + +if ((tport->state ==FDLS_TGT_STATE_OFFLINING ) + || (tport->state ==FDLS_TGT_STATE_OFFLINE )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: tport state is offlining/offline\n" , + tport->fcid); +return false; + } + +fdls_set_tport_state (tport,FDLS_TGT_STATE_OFFLINING ); +/* +* By setting this flag, the tport will not be seen in a look-up +* in an RSCN. Even if we move to multithreaded model, this tport +* will be destroyed and a new RSCN will have to create a new one +*/ + tport->flags |=FNIC_FDLS_TPORT_TERMINATING ; + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + tport->timer_pending =0 ; + } + +if (IS_FNIC_FCP_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +fnic_rport_exch_reset (iport->fnic, tport->fcid); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + +if (tport->flags &FNIC_FDLS_SCSI_REGISTERED ) { + tport_del_evt = +kzalloc (sizeof (struct fnic_tport_event_s ),GFP_ATOMIC ); +if (!tport_del_evt) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate memory for tport fcid: 0x%0x\n" , + tport->fcid); +return false; + } + tport_del_evt->event =TGT_EV_RPORT_DEL ; + tport_del_evt->arg1 = (void *) tport; +list_add_tail (&tport_del_evt->links, &fnic->tport_event_list); +queue_work (fnic_event_queue, &fnic->tport_work); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport 0x%x not reg with scsi_transport. Freeing locally" , + tport->fcid); +list_del (&tport->links); +kfree (tport); + } + } +return true; +} + +static void +fdls_send_tgt_plogi (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_flogi plogi; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint32_t timeout; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Send tgt PLOGI to fcid: 0x%x" , tport->fcid); + +memcpy (&plogi, &fnic_std_plogi_req,sizeof (struct fc_std_flogi )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID (&plogi.fchdr, s_id); +FNIC_STD_SET_D_ID (&plogi.fchdr, d_id); +FNIC_LOGI_SET_RDF_SIZE (&plogi.els, iport->max_payload_size); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->plogi_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate oxid to send PLOGI to fcid: 0x%x" , + iport->fcid, tport->fcid); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"send tgt PLOGI: tgt fcid: 0x%x oxid: 0x%x" , tport->fcid, +ntohs (oxid)); + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_OX_ID ((&plogi.fchdr), oxid); +FNIC_LOGI_SET_NPORT_NAME (&plogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&plogi.els, iport->wwnn); + + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); + + +fnic_send_fcoe_frame (iport, &plogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport, timeout); +} + +static uint16_t +fnic_fc_plogi_rsp_rdf (struct fnic_iport_s *iport, +struct fc_std_flogi *plogi_rsp) +{ +uint16_t b2b_rdf_size = +be16_to_cpu (FNIC_LOGI_RDF_SIZE (&plogi_rsp->els)); +uint16_t spc3_rdf_size = +be16_to_cpu (plogi_rsp->els.fl_cssp[2 ].cp_rdfs) &FNIC_FC_C3_RDF ; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MFS: b2b_rdf_size: 0x%x spc3_rdf_size: 0x%x" , + b2b_rdf_size, spc3_rdf_size); + +return MIN (b2b_rdf_size, spc3_rdf_size); +} +static void fdls_send_register_fc4_types (struct fnic_iport_s *iport) {struct fc_std_rft_id rft_id;
@@ -690,6 +1011,48 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport)fdls_start_fabric_timer (iport,2 * iport->e_d_tov); } +static void +fdls_send_tgt_prli (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_els_prli prli; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint32_t timeout; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending PRLI to tgt: 0x%x" , tport->fcid); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->prli_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send PRLI %p" , iport); +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending PRLI to tgt: 0x%x OXID: 0x%x" , tport->fcid, +ntohs (oxid)); + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; +memcpy (&prli, &fnic_std_prli_req,sizeof (struct fc_std_els_prli )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID ((&prli.fchdr), s_id); +FNIC_STD_SET_D_ID ((&prli.fchdr), d_id); +FNIC_STD_SET_OX_ID ((&prli.fchdr), oxid); + + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); + +fdls_get_tgt_oxid_pool (tport); +fnic_send_fcoe_frame (iport, &prli,sizeof (struct fc_std_els_prli )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport, timeout); +} +/** * fdls_send_fabric_logo - Send flogo to the fcf * @iport: Handle to fnic iport
@@ -742,6 +1105,212 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport)fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); } +/** +* fdls_tgt_logout - Send plogo to the remote port +* @iport: Handle to fnic iport +* @tport: Handle to remote port +* +* This function does not change or check the fabric/tport state. +* It the caller's responsibility to set the appropriate tport/fabric +* state when this is called. Normally that is fdls_tgt_state_plogo. +* This could be used to send plogo to nameserver process +* also not just target processes +*/ +void fdls_tgt_logout (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_logo logo; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to tport fcid: 0x%x" , tport->fcid); +memcpy (&logo, &fnic_std_logo_req,sizeof (struct fc_std_logo )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID ((&logo.fchdr), s_id); +FNIC_STD_SET_D_ID ((&logo.fchdr), d_id); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->plogi_oxid_pool)); +FNIC_STD_SET_OX_ID ((&logo.fchdr), oxid); + +memcpy (&logo.els.fl_n_port_id, s_id,3 ); +FNIC_STD_SET_NPORT_NAME (&logo.els.fl_n_port_wwn, +le64_to_cpu (iport->wwpn)); + + +fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); +} + +static void fdls_tgt_discovery_start (struct fnic_iport_s *iport) +{ +struct fnic_tport_s *tport, *next; +u32 old_link_down_cnt = iport->fnic->link_down_cnt; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Starting FDLS target discovery" , iport->fcid); + +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { +if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state !=FNIC_IPORT_STATE_READY )) { +break ; + } +/* if we marked the tport as deleted due to GPN_FT +* We should not send ADISC anymore +*/ +if ((tport->state ==FDLS_TGT_STATE_OFFLINING ) || + (tport->state ==FDLS_TGT_STATE_OFFLINE )) +continue ; + +/* For tports which have received RSCN */ +if (tport->flags &FNIC_FDLS_TPORT_SEND_ADISC ) { + tport->retry_counter =0 ; +fdls_set_tport_state (tport,FDLS_TGT_STATE_ADISC ); + tport->flags &= ~FNIC_FDLS_TPORT_SEND_ADISC ; +fdls_send_tgt_adisc (iport, tport); +continue ; + } +if (fdls_get_tport_state (tport) !=FDLS_TGT_STATE_INIT ) { +/* Not a new port, skip */ +continue ; + } + tport->retry_counter =0 ; +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); +fdls_send_tgt_plogi (iport, tport); + } +fdls_set_state ((&iport->fabric),FDLS_STATE_TGT_DISCOVERY ); +} + +/* +* Function to restart the IT nexus if we received any out of +* sequence PLOGI/PRLI response from the target. +* The memory for the new tport structure is allocated +* inside fdls_create_tport and added to the iport's tport list. +* This will get freed later during tport_offline/linkdown +* or module unload. The new_tport pointer will go out of scope +* safely since the memory it is +* pointing to it will be freed later +*/ +static void fdls_target_restart_nexus (struct fnic_tport_s *tport) +{ +struct fnic_iport_s *iport = tport->iport; +struct fnic_tport_s *new_tport =NULL ; +uint32_t fcid; +uint64_t wwpn; +int nexus_restart_count; +struct fnic *fnic = iport->fnic; +bool retval = true; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid: 0x%x state: %d restart_count: %d" , + tport->fcid, tport->state, tport->nexus_restart_count); + + fcid = tport->fcid; + wwpn = tport->wwpn; + nexus_restart_count = tport->nexus_restart_count; + + retval =fdls_delete_tport (iport, tport); +if (retval != true) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Error deleting tport: 0x%x" , fcid); +return ; + } + +if (nexus_restart_count >=FNIC_TPORT_MAX_NEXUS_RESTART ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Exceeded nexus restart retries tport: 0x%x" , + fcid); +return ; + } + +/* +* Allocate memory for the new tport and add it to +* iport's tport list. +* This memory will be freed during tport_offline/linkdown +* or module unload. The pointer new_tport is safe to go +* out of scope when this function returns, since the memory +* it is pointing to is guaranteed to be freed later +* as mentioned above. +*/ + new_tport =fdls_create_tport (iport, fcid, wwpn); +if (!new_tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Error creating new tport: 0x%x" , fcid); +return ; + } + + new_tport->nexus_restart_count = nexus_restart_count +1 ; +fdls_send_tgt_plogi (iport, new_tport); +fdls_set_tport_state (new_tport,FDLS_TGT_STATE_PLOGI ); +} + +struct fnic_tport_s *fnic_find_tport_by_fcid (struct fnic_iport_s *iport, +uint32_t fcid) +{ +struct fnic_tport_s *tport, *next; + +list_for_each_entry_safe (tport, next, &(iport->tport_list), links) { +if ((tport->fcid == fcid) + && !(tport->flags &FNIC_FDLS_TPORT_TERMINATING )) +return tport; + } +return NULL ; +} + +static struct fnic_tport_s *fdls_create_tport (struct fnic_iport_s *iport, +uint32_t fcid,uint64_t wwpn) +{ +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS create tport: fcid: 0x%x wwpn: 0x%llx" , fcid, wwpn); + + tport =kzalloc (sizeof (struct fnic_tport_s ),GFP_ATOMIC ); +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Memory allocation failure while creating tport: 0x%x\n" , + fcid); +return NULL ; + } + + tport->max_payload_size =FNIC_FCOE_MAX_FRAME_SZ ; + tport->r_a_tov =FNIC_R_A_TOV_DEF ; + tport->e_d_tov =FNIC_E_D_TOV_DEF ; + tport->fcid = fcid; + tport->wwpn = wwpn; + tport->iport = iport; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Need to setup tport timer callback" ); + +timer_setup (&tport->retry_timer, fdls_tport_timer_callback,0 ); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Added tport 0x%x" , tport->fcid); +fdls_set_tport_state (tport,FDLS_TGT_STATE_INIT ); +list_add_tail (&tport->links, &iport->tport_list); +atomic_set (&tport->in_flight,0 ); +return tport; +} + +struct fnic_tport_s *fnic_find_tport_by_wwpn (struct fnic_iport_s *iport, +uint64_t wwpn) +{ +struct fnic_tport_s *tport, *next; + +list_for_each_entry_safe (tport, next, &(iport->tport_list), links) { +if ((tport->wwpn == wwpn) + && !(tport->flags &FNIC_FDLS_TPORT_TERMINATING )) +return tport; + } +return NULL ; +} +void fdls_fabric_timer_callback (struct timer_list *t) {struct fnic_fdls_fabric_s *fabric =from_timer (fabric, t, retry_timer);
@@ -847,90 +1416,588 @@ void fdls_fabric_timer_callback(struct timer_list *t)/* ABTS has timed out */ fdls_schedule_fabric_oxid_free (iport);FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timed out. Starting PLOGI: %p" , iport); -fnic_fdls_start_plogi (iport); +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport); + } +break ; +case FDLS_STATE_REGISTER_FC4_TYPES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_types (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* RFT_ID timed out send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_REGISTER_FC4_FEATURES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_features (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* SCR has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_RSCN_GPN_FT : +case FDLS_STATE_SEND_GPNFT : +case FDLS_STATE_GPN_FT : +/* GPN_FT received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_gpn_ft (iport, iport->fabric.state); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* gpn_ft has timed out. Send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { +fdls_send_gpn_ft (iport, iport->fabric.state); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timeout for fabric GPN_FT. Check name server: %p" , + iport); + } + } +break ; +default : +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 =ntohs (tport->oxid_used); + +/* We retry plogi/prli/adisc frames depending on the tport state */ +switch (tport->state) { +case FDLS_TGT_STATE_PLOGI : +/* PLOGI frame received a LS_RJT with busy, we retry from here */ +if ((tport->flags &FNIC_FDLS_RETRY_FRAME ) + && (tport->retry_counter < iport->max_plogi_retries)) { + tport->flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_tgt_plogi (iport, tport); + }else if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +/* Plogi frame has timed out, send abts */ +fdls_send_tport_abts (iport, tport); + }else if (tport->retry_counter < iport->max_plogi_retries) { +/* +* ABTS has timed out +*/ +fdls_schedule_tgt_oxid_free (iport, + &iport->plogi_oxid_pool, + oxid); +fdls_send_tgt_plogi (iport, tport); + }else { +/* exceeded plogi retry count */ +fdls_schedule_tgt_oxid_free (iport, + &iport->plogi_oxid_pool, + oxid); +fdls_send_delete_tport_msg (tport); + } +break ; +case FDLS_TGT_STATE_PRLI : +/* PRLI received a LS_RJT with busy , hence we retry from here */ +if ((tport->flags &FNIC_FDLS_RETRY_FRAME ) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { + tport->flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_tgt_prli (iport, tport); + }else if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +/* PRLI has time out, send abts */ +fdls_send_tport_abts (iport, tport); + }else { +/* ABTS has timed out for prli, we go back to PLOGI */ +fdls_schedule_tgt_oxid_free (iport, + &iport->prli_oxid_pool, + oxid); +fdls_send_tgt_plogi (iport, tport); +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); + } +break ; +case FDLS_TGT_STATE_ADISC : +/* ADISC timed out send an ABTS */ +if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +fdls_send_tport_abts (iport, tport); + }else if ((tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED ) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { +/* +* ABTS has timed out +*/ +fdls_schedule_tgt_oxid_free (iport, + &iport->adisc_oxid_pool, + oxid); +fdls_send_tgt_adisc (iport, tport); + }else { +/* exceeded retry count */ +fdls_schedule_tgt_oxid_free (iport, + &iport->adisc_oxid_pool, + oxid); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC not responding. Deleting target port: 0x%x" , + tport->fcid); +fdls_send_delete_tport_msg (tport); + } +break ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown tport state: 0x%x" , tport->state); +break ; + } +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +} + +static void fnic_fdls_start_flogi (struct fnic_iport_s *iport) +{ + iport->fabric.retry_counter =0 ; +fdls_send_fabric_flogi (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_FLOGI ); + iport->fabric.flags =0 ; +} + +static void fnic_fdls_start_plogi (struct fnic_iport_s *iport) +{ + iport->fabric.retry_counter =0 ; +fdls_send_fabric_plogi (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_PLOGI ); + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; +} + +static void +fdls_process_tgt_adisc_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint64_t frame_wwnn; +uint64_t frame_wwpn; +uint16_t oxid; +struct fc_std_els_adisc *adisc_rsp = (struct fc_std_els_adisc *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +struct fnic *fnic = iport->fnic; + + fcid =FNIC_STD_GET_S_ID (fchdr); + tgt_fcid =ntoh24 (fcid); + tport =fnic_find_tport_by_fcid (iport, tgt_fcid); + +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Tgt ADISC response tport not found: 0x%x" , tgt_fcid); +return ; + } +if ((iport->state !=FNIC_IPORT_STATE_READY ) + || (tport->state !=FDLS_TGT_STATE_ADISC ) + || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping this ADISC response" ); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"iport state: %d tport state: %d Is abort issued on PRLI? %d" , + iport->state, tport->state, + (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )); +return ; + } +if (ntohs (fchdr->fh_ox_id) !=ntohs (tport->oxid_used)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping frame from target: 0x%x" , + tgt_fcid); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Reason: Stale ADISC/Aborted ADISC/OOO frame delivery" ); +return ; + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, oxid); + +switch (adisc_rsp->els.adisc_cmd) { +case ELS_LS_ACC : +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport 0x%p Canceling fabric disc timer\n" , + tport); +fnic_del_tport_timer_sync (fnic, tport); + } + tport->timer_pending =0 ; + tport->retry_counter =0 ; + frame_wwnn =get_unaligned_be64 (&adisc_rsp->els.adisc_wwnn); + frame_wwpn =get_unaligned_be64 (&adisc_rsp->els.adisc_wwpn); +if ((frame_wwnn == tport->wwnn) && (frame_wwpn == tport->wwpn)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC accepted from target: 0x%x. Target logged in" , + tgt_fcid); +fdls_set_tport_state (tport,FDLS_TGT_STATE_READY ); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Error mismatch frame: ADISC" ); + } +break ; + +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , + tgt_fcid); + +/* Retry ADISC again from the timer routine. */ + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC returned ELS_LS_RJT from target: 0x%x" , + tgt_fcid); +fdls_delete_tport (iport, tport); + } +break ; + } +} + + +static void +fdls_process_tgt_plogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint16_t oxid; +struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +int max_payload_size; +struct fnic *fnic = iport->fnic; + + fcid =FNIC_STD_GET_S_ID (fchdr); + tgt_fcid =ntoh24 (fcid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS processing target PLOGI response: tgt_fcid: 0x%x" , + tgt_fcid); + + tport =fnic_find_tport_by_fcid (iport, tgt_fcid); +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport not found: 0x%x" , tgt_fcid); +return ; + } +if ((iport->state !=FNIC_IPORT_STATE_READY ) + || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping frame! iport state: %d tport state: %d" , + iport->state, tport->state); +return ; + } + +if (tport->state !=FDLS_TGT_STATE_PLOGI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI rsp recvd in wrong state. Drop the frame and restart nexus" ); +fdls_target_restart_nexus (tport); +return ; + } + +if (fchdr->fh_ox_id != tport->oxid_used) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI response from target: 0x%x. Dropping frame" , + tgt_fcid); +return ; + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +fdls_free_tgt_oxid (iport, &iport->plogi_oxid_pool, oxid); + +switch (plogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI accepted by target: 0x%x" , tgt_fcid); +break ; + +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (tport->retry_counter < iport->max_plogi_retries)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , + tgt_fcid); +/* Retry plogi again from the timer routine. */ + tport->flags |=FNIC_FDLS_RETRY_FRAME ; +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI returned ELS_LS_RJT from target: 0x%x" , + tgt_fcid); +fdls_delete_tport (iport, tport); +return ; + +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI not accepted from target fcid: 0x%x" , + tgt_fcid); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Found the PLOGI target: 0x%x and state: %d" , + (unsigned int ) tgt_fcid, tport->state); + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + } + + tport->timer_pending =0 ; + tport->wwpn =get_unaligned_be64 (&FNIC_LOGI_PORT_NAME (&plogi_rsp->els)); + tport->wwnn =get_unaligned_be64 (&FNIC_LOGI_NODE_NAME (&plogi_rsp->els)); + +/* Learn the Service Params */ + +/* Max frame size - choose the lowest */ + max_payload_size =fnic_fc_plogi_rsp_rdf (iport, plogi_rsp); + tport->max_payload_size = +MIN (max_payload_size, iport->max_payload_size); + +if (tport->max_payload_size <FNIC_MIN_DATA_FIELD_SIZE ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MFS: tport max frame size below spec bounds: %d" , + tport->max_payload_size); + tport->max_payload_size =FNIC_MIN_DATA_FIELD_SIZE ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MAX frame size: %d iport max_payload_size: %d tport mfs: %d" , + max_payload_size, iport->max_payload_size, + tport->max_payload_size); + + tport->max_concur_seqs =FNIC_FC_PLOGI_RSP_CONCUR_SEQ (plogi_rsp); + + tport->retry_counter =0 ; +fdls_set_tport_state (tport,FDLS_TGT_STATE_PRLI ); +fdls_send_tgt_prli (iport, tport); +} + +static void +fdls_process_tgt_prli_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint16_t oxid; +struct fc_std_els_prli *prli_rsp = (struct fc_std_els_prli *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +struct fnic_tport_event_s *tport_add_evt; +struct fnic *fnic = iport->fnic; +bool mismatched_tgt = false; + + fcid =FNIC_STD_GET_S_ID (fchdr); + tgt_fcid =ntoh24 (fcid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS process tgt PRLI response: 0x%x" , tgt_fcid); + + tport =fnic_find_tport_by_fcid (iport, tgt_fcid); +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport not found: 0x%x" , tgt_fcid); +/* Handle or just drop? */ +return ; + } + +if ((iport->state !=FNIC_IPORT_STATE_READY ) + || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping frame! iport st: %d tport st: %d tport fcid: 0x%x" , + iport->state, tport->state, tport->fcid); +return ; + } + +if (tport->state !=FDLS_TGT_STATE_PRLI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI rsp recvd in wrong state. Drop frame. Restarting nexus" ); +fdls_target_restart_nexus (tport); +return ; + } + +if (fchdr->fh_ox_id != tport->oxid_used) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping PRLI response from target: 0x%x " , + tgt_fcid); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Reason: Stale PRLI response/Aborted PDISC/OOO frame delivery" ); +return ; + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +fdls_free_tgt_oxid (iport, &iport->prli_oxid_pool, oxid); + +switch (prli_rsp->els_prli.prli_cmd) { +case ELS_LS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI accepted from target: 0x%x" , tgt_fcid); + +if (prli_rsp->sp.spp_type !=FC_FC4_TYPE_SCSI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"mismatched target zoned with FC SCSI initiator: 0x%x" , + tgt_fcid); + mismatched_tgt = true; } -break ; -case FDLS_STATE_REGISTER_FC4_TYPES : -/* scr received a LS_RJT with busy we retry from here */ -if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) - && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; -fdls_send_register_fc4_types (iport); - }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { -/* RFT_ID timed out send abts */ -fdls_send_fabric_abts (iport); - }else { -/* ABTS has timed out */ -fdls_schedule_fabric_oxid_free (iport); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timed out. Starting PLOGI: %p" , iport); -fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ +if (mismatched_tgt) { +fdls_tgt_logout (iport, tport); +fdls_delete_tport (iport, tport); +return ; }break ; -case FDLS_STATE_REGISTER_FC4_FEATURES : -/* scr received a LS_RJT with busy we retry from here */ -if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) - && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; -fdls_send_register_fc4_features (iport); - }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) -/* SCR has timed out. Send abts */ -fdls_send_fabric_abts (iport); -else { -/* ABTS has timed out */ -fdls_schedule_fabric_oxid_free (iport); +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timed out. Starting PLOGI %p" , iport); -fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ - } -break ; -case FDLS_STATE_RSCN_GPN_FT : -case FDLS_STATE_SEND_GPNFT : -case FDLS_STATE_GPN_FT : -/* GPN_FT received a LS_RJT with busy we retry from here */ -if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) - && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; -fdls_send_gpn_ft (iport, iport->fabric.state); - }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { -/* gpn_ft has timed out. Send abts */ -fdls_send_fabric_abts (iport); +"PRLI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , + tgt_fcid); + +/*Retry Plogi again from the timer routine. */ + tport->flags |=FNIC_FDLS_RETRY_FRAME ; +return ; }else { -/* ABTS has timed out */ -fdls_schedule_fabric_oxid_free (iport); -if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { -fdls_send_gpn_ft (iport, iport->fabric.state); - }else { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timeout for fabric GPN_FT. Check name server: %p" , - iport); - } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI returned ELS_LS_RJT from target: 0x%x" , + tgt_fcid); + +fdls_tgt_logout (iport, tport); +fdls_delete_tport (iport, tport); +return ; }break ; +default : -fnic_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); -} -static void fnic_fdls_start_flogi (struct fnic_iport_s *iport) -{ - iport->fabric.retry_counter =0 ; -fdls_send_fabric_flogi (iport); -fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_FLOGI ); - iport->fabric.flags =0 ; -} +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Found the PRLI target: 0x%x and state: %d" , + (unsigned int ) tgt_fcid, tport->state); -static void fnic_fdls_start_plogi (struct fnic_iport_s *iport) -{ - iport->fabric.retry_counter =0 ; -fdls_send_fabric_plogi (iport); -fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_PLOGI ); - iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + } + tport->timer_pending =0 ; + +/* Learn Service Params */ + tport->fcp_csp =be32_to_cpu (prli_rsp->sp.spp_params); + tport->retry_counter =0 ; + +if (prli_rsp->sp.spp_params &FCP_SPPF_RETRY ) + tport->tgt_flags |=FNIC_FC_RP_FLAGS_RETRY ; + +/* Check if the device plays Target Mode Function */ +if (!(tport->fcp_csp &FCP_PRLI_FUNC_TARGET )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Remote port(0x%x): no target support. Deleting it\n" , + tgt_fcid); +fdls_tgt_logout (iport, tport); +fdls_delete_tport (iport, tport); +return ; + } + +fdls_set_tport_state (tport,FDLS_TGT_STATE_READY ); + +/* Inform the driver about new target added */ + tport_add_evt =kzalloc (sizeof (struct fnic_tport_event_s ),GFP_ATOMIC ); +if (!tport_add_evt) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport event memory allocation failure: 0x%0x\n" , + tport->fcid); +return ; + } + tport_add_evt->event =TGT_EV_RPORT_ADD ; + tport_add_evt->arg1 = (void *) tport; +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"iport fcid: 0x%x add tport event fcid: 0x%x\n" , + tport->fcid, iport->fcid); +list_add_tail (&tport_add_evt->links, &fnic->tport_event_list); +queue_work (fnic_event_queue, &fnic->tport_work); } +static void fdls_process_rff_id_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)
@@ -1179,7 +2246,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 ;
@@ -1192,6 +2260,104 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_gpn_ft_tgt_list (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr,int len) +{ +struct fc_gpn_ft_rsp_iu *gpn_ft_tgt; +struct fnic_tport_s *tport, *next; +uint32_t fcid; +uint64_t wwpn; +int rem_len = len; +u32 old_link_down_cnt = iport->fnic->link_down_cnt; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process GPN_FT tgt list" , iport->fcid); + + gpn_ft_tgt = + (struct fc_gpn_ft_rsp_iu *)((uint8_t *) fchdr + +sizeof (struct fc_frame_header ) + +sizeof (struct fc_ct_hdr )); + len -=sizeof (struct fc_frame_header ) +sizeof (struct fc_ct_hdr ); + +while (rem_len >0 ) { + + fcid =ntoh24 (gpn_ft_tgt->fcid); + wwpn =ntohll (gpn_ft_tgt->wwpn); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport: 0x%x: ctrl:0x%x" , fcid, gpn_ft_tgt->ctrl); + +if (fcid == iport->fcid) { +if (gpn_ft_tgt->ctrl &FNIC_FC_GPN_LAST_ENTRY ) +break ; + gpn_ft_tgt++; + rem_len -=sizeof (struct fc_gpn_ft_rsp_iu ); +continue ; + } + + tport =fnic_find_tport_by_wwpn (iport, wwpn); +if (!tport) { +/* +* New port registered with the switch or first time query +*/ + tport =fdls_create_tport (iport, fcid, wwpn); +if (!tport) +return ; + } +/* +* check if this was an existing tport with same fcid +* but whose wwpn has changed now ,then remove it and +* create a new one +*/ +if (tport->fcid != fcid) { +fdls_delete_tport (iport, tport); + tport =fdls_create_tport (iport, fcid, wwpn); +if (!tport) +return ; + } + +/* +* If this GPN_FT rsp is after RSCN then mark the tports which +* matches with the new GPN_FT list, if some tport is not +* found in GPN_FT we went to delete that tport later. +*/ +if (fdls_get_state ((&iport->fabric)) ==FDLS_STATE_RSCN_GPN_FT ) + tport->flags |=FNIC_FDLS_TPORT_IN_GPN_FT_LIST ; + +if (gpn_ft_tgt->ctrl &FNIC_FC_GPN_LAST_ENTRY ) +break ; + + gpn_ft_tgt++; + rem_len -=sizeof (struct fc_gpn_ft_rsp_iu ); + } +if (rem_len <=0 ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"GPN_FT response: malformed/corrupt frame rxlen: %d remlen: %d" , + len, rem_len); + } + +/*remove those ports which was not listed in GPN_FT */ +if (fdls_get_state ((&iport->fabric)) ==FDLS_STATE_RSCN_GPN_FT ) { +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { + +if (!(tport->flags &FNIC_FDLS_TPORT_IN_GPN_FT_LIST )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Remove port: 0x%x not found in GPN_FT list" , + tport->fcid); +fdls_delete_tport (iport, tport); + }else { + tport->flags &= ~FNIC_FDLS_TPORT_IN_GPN_FT_LIST ; + } +if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state !=FNIC_IPORT_STATE_READY )) { +return ; + } + } + } +} +static void fdls_process_gpn_ft_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr,int len)
@@ -1200,6 +2366,9 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,struct fc_std_gpn_ft *gpn_ft_rsp = (struct fc_std_gpn_ft *) fchdr;uint16_t rsp;uint8_t reason_code; +int count =0 ; +struct fnic_tport_s *tport, *next; +u32 old_link_down_cnt = iport->fnic->link_down_cnt;struct fnic *fnic = iport->fnic; FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
@@ -1239,12 +2408,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 :
@@ -1494,8 +2725,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) {uint32_t s_id; -struct fc_std_abts_ba_acc *ba_acc = - (struct fc_std_abts_ba_acc *) fchdr; +struct fc_std_abts_ba_acc *ba_acc = (struct fc_std_abts_ba_acc *)fchdr;struct fc_std_abts_ba_rjt *ba_rjt;uint32_t fabric_state = iport->fabric.state;struct fnic *fnic = iport->fnic;
@@ -1660,6 +2890,148 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_tgt_abts_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t s_id; +struct fnic_tport_s *tport; +uint32_t tport_state; +struct fc_std_abts_ba_acc *ba_acc; +struct fc_std_abts_ba_rjt *ba_rjt; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + + s_id =ntoh24 (fchdr->fh_s_id); + ba_acc = (struct fc_std_abts_ba_acc *)fchdr; + ba_rjt = (struct fc_std_abts_ba_rjt *)fchdr; + + tport =fnic_find_tport_by_fcid (iport, s_id); +if (!tport) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received tgt abts rsp with invalid SID: 0x%x" , s_id); +return ; + } + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"tport 0x%p Canceling fabric disc timer\n" , tport); +fnic_del_tport_timer_sync (fnic, tport); + } +if (iport->state !=FNIC_IPORT_STATE_READY ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received tgt abts rsp in iport state(%d). Dropping." , + iport->state); +return ; + } + tport->timer_pending =0 ; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + tport_state = tport->state; + oxid =ntohs (fchdr->fh_ox_id); + +/*This abort rsp is for ADISC */ +if ((oxid >=FDLS_ADISC_OXID_BASE ) && (oxid <FDLS_TGT_OXID_POOL_END )) { +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"OX_ID: 0x%x tgt_fcid: 0x%x rcvd tgt adisc abts resp BA_ACC" , +be16_to_cpu (ba_acc->acc.ba_ox_id), + tport->fcid); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"ADISC BA_RJT rcvd tport_fcid: 0x%x tport_state: %d " , + tport->fcid, tport_state); +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"reason code: 0x%x reason code explanation:0x%x " , + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } +if ((tport->retry_counter <FDLS_RETRY_COUNT ) + && (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL )) { +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, + oxid); +fdls_send_tgt_adisc (iport, tport); +return ; + } + +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, oxid); +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"ADISC not responding. Deleting target port: 0x%x" , + tport->fcid); +fdls_delete_tport (iport, tport); +if ((iport->state ==FNIC_IPORT_STATE_READY ) + && (iport->fabric.state !=FDLS_STATE_SEND_GPNFT ) + && (iport->fabric.state !=FDLS_STATE_RSCN_GPN_FT )) { +fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT ); + } +/*Restart a discovery of targets */ +return ; + } + +/*This abort rsp is for PLOGI */ +if ((oxid >=FDLS_PLOGI_OXID_BASE ) && (oxid <FDLS_PRLI_OXID_BASE )) { +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received tgt PLOGI abts response BA_ACC tgt_fcid: 0x%x" , + tport->fcid); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x" , + tport->fcid, fchdr->fh_ox_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"reason code: 0x%x reason code explanation: 0x%x" , + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } +if ((tport->retry_counter < iport->max_plogi_retries) + && (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL )) { +fdls_free_tgt_oxid (iport, &iport->plogi_oxid_pool, + oxid); +fdls_send_tgt_plogi (iport, tport); +return ; + } + +fdls_free_tgt_oxid (iport, &iport->plogi_oxid_pool, oxid); +fdls_delete_tport (iport, tport); +/*Restart a discovery of targets */ +if ((iport->state ==FNIC_IPORT_STATE_READY ) + && (iport->fabric.state !=FDLS_STATE_SEND_GPNFT ) + && (iport->fabric.state !=FDLS_STATE_RSCN_GPN_FT )) { +fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT ); + } +return ; + } + +/*This abort rsp is for PRLI */ +if ((oxid >=FDLS_PRLI_OXID_BASE ) && (oxid <FDLS_ADISC_OXID_BASE )) { +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Received tgt PRLI abts response BA_ACC" , + tport->fcid); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x " , + tport->fcid, fchdr->fh_ox_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"reason code: 0x%x reason code explanation: 0x%x" , + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } +if ((tport->retry_counter <FDLS_RETRY_COUNT ) + && (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL )) { +fdls_free_tgt_oxid (iport, &iport->prli_oxid_pool, oxid); +fdls_send_tgt_prli (iport, tport); +return ; + } +fdls_free_tgt_oxid (iport, &iport->prli_oxid_pool, oxid); +fdls_send_tgt_plogi (iport, tport);/* go back to plogi */ +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received ABTS response for unknown frame %p" , iport); +} +/* * Performs a validation for all FCOE frames and return the frame type */
@@ -1757,6 +3129,39 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, } } +/* ELS response from a target */ +if ((ntohs (oxid) >=FDLS_PLOGI_OXID_BASE ) + && (ntohs (oxid) <FDLS_PRLI_OXID_BASE )) { +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in PLOGI exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_PLOGI_RSP ; + } +if ((ntohs (oxid) >=FDLS_PRLI_OXID_BASE ) + && (ntohs (oxid) <FDLS_ADISC_OXID_BASE )) { +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in PRLI exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_PRLI_RSP ; + } + +if ((ntohs (oxid) >=FDLS_ADISC_OXID_BASE ) + && (ntohs (oxid) <FDLS_TGT_OXID_POOL_END )) { +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in ADISC exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_ADISC_RSP ; + } +/*response from fabric */ rsp_type =fnic_fdls_expected_rsp (iport,ntohs (oxid));
@@ -1885,6 +3290,21 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,case FNIC_FABRIC_GPN_FT_RSP :fdls_process_gpn_ft_rsp (iport, fchdr, len);break ; +case FNIC_TPORT_PLOGI_RSP : +fdls_process_tgt_plogi_rsp (iport, fchdr); +break ; +case FNIC_TPORT_PRLI_RSP : +fdls_process_tgt_prli_rsp (iport, fchdr); +break ; +case FNIC_TPORT_ADISC_RSP : +fdls_process_tgt_adisc_rsp (iport, fchdr); +break ; +case FNIC_TPORT_LOGO_RSP : +/* Logo response from tgt which we have deleted */ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Logo response from tgt: 0x%x" , +ntoh24 (fchdr->fh_s_id)); +break ;case FNIC_FABRIC_LOGO_RSP :fdls_process_fabric_logo_rsp (iport, fchdr);break ;
@@ -1894,7 +3314,8 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,if (fdls_is_oxid_in_fabric_range (oxid) && (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) {fdls_process_fabric_abts_rsp (iport, fchdr); - } + }else +fdls_process_tgt_abts_rsp (iport, fchdr);break ;default : FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
drivers/scsi/fnic/fnic.h +6 -0
@@ -79,6 +79,9 @@#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +/* Retry supported by rport (returned by PRLI service parameters) */ +#define FNIC_FC_RP_FLAGS_RETRY 0x1 +/* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock.
@@ -133,6 +136,7 @@ static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)extern unsigned int fnic_log_level;extern unsigned int io_completions; +extern struct workqueue_struct *fnic_event_queue;#define FNIC_MAIN_LOGGING 0x01#define FNIC_FCS_LOGGING 0x02
@@ -329,6 +333,8 @@ struct fnic {struct work_struct flush_work;struct sk_buff_head frame_queue;struct list_head tx_queue; +struct work_struct tport_work; +struct list_head tport_event_list;/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);
drivers/scsi/fnic/fnic_fdls.h +1 -1
@@ -385,7 +385,7 @@ int fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, void *rx_frame, int len, int fchdr_offset);void fdls_send_tport_abts (struct fnic_iport_s *iport, -struct fnic_tport_s *tport); +struct fnic_tport_s *tport);bool fdls_delete_tport (struct fnic_iport_s *iport,struct fnic_tport_s *tport);void fdls_fdmi_timer_callback (struct timer_list *t);
Signature · 1 line
2.31.1
Re: [PATCH v5 04/14] scsi: fnic: Add support for target based solicited requests and responses
Quoted 169 lines · Karan Tilak Kumar
Add support for target based solicited requests and responses. Add support for tport definitions and processing. Add support for restarting the IT nexus.
Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/202406120146.xchlZbqX-lkp@
intel.com/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Callfdls_get_tgt_oxid_pool.
Modify attribution appropriately.Changes between v2 and v3:
Fix issue found by kernel test robot.
Removefnic_std_ba_accdefinition 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.
Replacehtonll()withget_unaligned_be64(). Replacefnic_del_fabric_timer_syncmacro calls to function calls.
Replacefnic_del_tport_timer_syncmacro calls to function calls.
Renamefc_abts_stofc_tport_abts_s.
Modifyfc_tport_abts_sto be a global frame. Rename variablepfc_abtstotport_abts.
Replace definitions with standard definitions fromfc_els.h.
Modify functions with returns in the middle to if else clauses.
Replace simultaneous use offc_tport_abts_sandtport_abtswith justtport_abts.--- drivers/scsi/fnic/fdls_disc.c | 1569 +++++++++++++++++++++++++++++++-- drivers/scsi/fnic/fnic.h | 6 + drivers/scsi/fnic/fnic_fdls.h | 2 +- 3 files changed, 1502 insertions(+), 75 deletions(-)drivers/scsi/fnic/fdls_disc.c +61
-0@@ -11,6 +11,10 @@#include <scsi/fc/fc_fcp.h> #include <linux/utsname.h> +#define FC_FC4_TYPE_SCSI 0x08 + +static void fdls_send_rpn_id (struct fnic_iport_s *iport); +/* Frame initialization */ /* * Variables: @@ -66,6 +70,20 @@ struct fc_std_rpn_id fnic_std_rpn_id_req = { .ct_cmd = cpu_to_be16(FC_NS_RPN_ID)} }; +/* +* Variables: +* did, sid, oxid +*/ +struct fc_std_els_prli fnic_std_prli_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, .fh_rx_id =0xFFFF }, + .els_prli = {.prli_cmd =ELS_PRLI , + .prli_spp_len =16 , + .prli_len =cpu_to_be16 (0x14 )}, + .sp = {.spp_type =0x08 , .spp_flags =0x0020 , + .spp_params =cpu_to_be32 (0xA2 )} +}; +/* * Variables: * fh_s_id, port_id, port_name @@ -143,9 +161,19 @@ struct fc_frame_header fc_std_fabric_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +struct fc_frame_header fc_std_tport_abts = { + .fh_r_ctl =FC_RCTL_BA_ABTS ,/* ABTS */ + .fh_cs_ctl =0x00 , .fh_type =FC_TYPE_BLS , + .fh_f_ctl = {FNIC_REQ_ABTS_FCTL ,0 ,0 }, .fh_seq_id =0x00 , + .fh_df_ctl =0x00 , .fh_seq_cnt =0x0000 , .fh_rx_id =0xFFFF , + .fh_parm_offset =0x00000000 ,/* bit:0 = 0 Abort a exchange */ +}; +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY) +#define FNIC_TPORT_MAX_NEXUS_RESTART (8) +/* * For fabric requests and fdmi, once OXIDs are allocated from the pool * (and a range) they are encoded with expected rsp type as @@ -167,6 +195,14 @@ 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@@ -182,6 +218,8 @@ void fdls_init_oxid_pool(struct fnic_iport_s *iport)fdls_init_fabric_oxid_pool (&iport->fdmi_oxid_pool,FDLS_FDMI_OXID_POOL_BASE ,FDLS_FDMI_OXID_POOL_SZ ); + +fdls_init_tgt_oxid_pool (iport); } uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport,@@ -313,6 +351,13 @@ static inline void fdls_schedule_fabric_oxid_free(struct fnic_iport_s iport->fabric_oxid_pool.active_oxid_fabric_req); } +static inline void fdls_schedule_tgt_oxid_free (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s + *oxid_pool,uint16_t oxid) +{ +fdls_schedule_oxid_free (&oxid_pool->meta, oxid); +} +int fnic_fdls_expected_rsp (struct fnic_iport_s *iport,uint16_t oxid) {struct fnic *fnic = iport->fnic;@@ -340,6 +385,62 @@ static int fdls_is_oxid_in_fabric_range(uint16_t oxid) (oxid_unmasked <= FDLS_FABRIC_OXID_POOL_END)); } +void fdls_init_tgt_oxid_pool (struct fnic_iport_s *iport) +{ +memset (&iport->plogi_oxid_pool,0 ,sizeof (iport->plogi_oxid_pool)); + iport->plogi_oxid_pool.meta.oxid_base =FDLS_PLOGI_OXID_BASE ; + iport->plogi_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->plogi_oxid_pool.meta.reclaim_list); + +memset (&iport->prli_oxid_pool,0 ,sizeof (iport->prli_oxid_pool)); + iport->prli_oxid_pool.meta.oxid_base =FDLS_PRLI_OXID_BASE ; + iport->prli_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->prli_oxid_pool.meta.reclaim_list); + +memset (&iport->adisc_oxid_pool,0 ,sizeof (iport->adisc_oxid_pool)); + iport->adisc_oxid_pool.meta.oxid_base =FDLS_ADISC_OXID_BASE ; + iport->adisc_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->adisc_oxid_pool.meta.reclaim_list);
drivers/scsi/fnic/fdls_disc.c static int fdls_is_oxid_in_fabric_range(uint16_t oxid) · line 413
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+} + +inline uint16_t fdls_alloc_tgt_oxid (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s *oxid_pool) +{ +uint16_t oxid; + + oxid =fdls_alloc_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap); +return oxid; +}
Do a 'return fdls_alloc_oxid()' and drop the intermediate variable.
Quoted 120 lines
drivers/scsi/fnic/fdls_disc.c +106
-0+ +inline void fdls_free_tgt_oxid (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s *oxid_pool, +uint16_t oxid) +{ +fdls_free_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap, oxid); +} + +static struct fnic_tgt_oxid_pool_s *fdls_get_tgt_oxid_pool (struct fnic_tport_s + *tport) +{ +struct fnic_iport_s *iport = (struct fnic_iport_s *)tport->iport; +struct fnic_tgt_oxid_pool_s *oxid_pool =NULL ; + +switch (tport->state) { +case FDLS_TGT_STATE_PLOGI : + oxid_pool = &iport->plogi_oxid_pool; +break ; +case FDLS_TGT_STATE_PRLI : + oxid_pool = &iport->prli_oxid_pool; +break ; +case FDLS_TGT_STATE_ADISC : + oxid_pool = &iport->adisc_oxid_pool; +break ; +default : +break ; + } +return oxid_pool; +} +inline void fnic_del_fabric_timer_sync (struct fnic *fnic) { fnic->iport.fabric.del_timer_inprogress =1 ;@@ -383,6 +484,56 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) "fabric timer is %d ", timeout); } +static void +fdls_start_tport_timer (struct fnic_iport_s *iport, +struct fnic_tport_s *tport,int timeout) +{ +u64 fabric_tov; +struct fnic *fnic = iport->fnic; + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + tport->timer_pending =0 ; + } + +if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) + tport->retry_counter++; + + fabric_tov = jiffies +msecs_to_jiffies (timeout); +mod_timer (&tport->retry_timer,round_jiffies (fabric_tov)); + tport->timer_pending =1 ; +} + +void +fdls_send_tport_abts (struct fnic_iport_s *iport, +struct fnic_tport_s *tport) +{ +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header tport_abort = fc_std_tport_abts; +struct fc_frame_header *tport_abts = &tport_abort; + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (tport_abts, s_id); +FNIC_STD_SET_D_ID (tport_abts, d_id); + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + + tport_abts->fh_ox_id = tport->oxid_used; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending tport abts: tport->state: %d " , + tport->state); + +fnic_send_fcoe_frame (iport, tport_abts,sizeof (struct fc_frame_header )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport,2 * iport->e_d_tov); +} +static void fdls_send_fabric_abts (struct fnic_iport_s *iport) {uint8_t fcid[3 ];@@ -614,6 +765,176 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state)fdls_set_state ((&iport->fabric), fdls_state); } +static void +fdls_send_tgt_adisc (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_els_adisc adisc; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +memset (&adisc,0 ,sizeof (struct fc_std_els_adisc )); +FNIC_STD_SET_R_CTL (&adisc.fchdr,0x22 ); +FNIC_STD_SET_TYPE (&adisc.fchdr,0x01 ); +FNIC_STD_SET_F_CTL (&adisc.fchdr,FNIC_ELS_REQ_FCTL <<16 ); +FNIC_STD_SET_RX_ID (&adisc.fchdr,cpu_to_be16 (0xFFFF )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (&adisc.fchdr, s_id); +FNIC_STD_SET_D_ID (&adisc.fchdr, d_id); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->adisc_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send ADISC %p" , iport); +return ; + }
drivers/scsi/fnic/fdls_disc.c static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) · line 803
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_OX_ID ((&adisc.fchdr), oxid); +FNIC_STD_SET_NPORT_NAME (&adisc.els.adisc_wwpn, +le64_to_cpu (iport->wwpn)); +FNIC_STD_SET_NODE_NAME (&adisc.els.adisc_wwnn,le64_to_cpu (iport->wwnn)); + +memcpy (adisc.els.adisc_port_id, s_id,3 );
That feels wrong. Isn't port_id a three-byte value in big endian?
Quoted 157 lines
drivers/scsi/fnic/fdls_disc.c +150
-0+ adisc.els.adisc_cmd =ELS_ADISC ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"sending ADISC to tgt fcid: 0x%x" , tport->fcid); + + +fnic_send_fcoe_frame (iport, &adisc,sizeof (struct fc_std_els_adisc )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport,2 * iport->e_d_tov); +} + +bool fdls_delete_tport (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fnic_tport_event_s *tport_del_evt; +struct fnic *fnic = iport->fnic; + +if ((tport->state ==FDLS_TGT_STATE_OFFLINING ) + || (tport->state ==FDLS_TGT_STATE_OFFLINE )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: tport state is offlining/offline\n" , + tport->fcid); +return false; + } + +fdls_set_tport_state (tport,FDLS_TGT_STATE_OFFLINING ); +/* +* By setting this flag, the tport will not be seen in a look-up +* in an RSCN. Even if we move to multithreaded model, this tport +* will be destroyed and a new RSCN will have to create a new one +*/ + tport->flags |=FNIC_FDLS_TPORT_TERMINATING ; + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + tport->timer_pending =0 ; + } + +if (IS_FNIC_FCP_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +fnic_rport_exch_reset (iport->fnic, tport->fcid); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + +if (tport->flags &FNIC_FDLS_SCSI_REGISTERED ) { + tport_del_evt = +kzalloc (sizeof (struct fnic_tport_event_s ),GFP_ATOMIC ); +if (!tport_del_evt) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate memory for tport fcid: 0x%0x\n" , + tport->fcid); +return false; + } + tport_del_evt->event =TGT_EV_RPORT_DEL ; + tport_del_evt->arg1 = (void *) tport; +list_add_tail (&tport_del_evt->links, &fnic->tport_event_list); +queue_work (fnic_event_queue, &fnic->tport_work); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport 0x%x not reg with scsi_transport. Freeing locally" , + tport->fcid); +list_del (&tport->links); +kfree (tport); + } + } +return true; +} + +static void +fdls_send_tgt_plogi (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_flogi plogi; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint32_t timeout; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Send tgt PLOGI to fcid: 0x%x" , tport->fcid); + +memcpy (&plogi, &fnic_std_plogi_req,sizeof (struct fc_std_flogi )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID (&plogi.fchdr, s_id); +FNIC_STD_SET_D_ID (&plogi.fchdr, d_id); +FNIC_LOGI_SET_RDF_SIZE (&plogi.els, iport->max_payload_size); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->plogi_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate oxid to send PLOGI to fcid: 0x%x" , + iport->fcid, tport->fcid); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"send tgt PLOGI: tgt fcid: 0x%x oxid: 0x%x" , tport->fcid, +ntohs (oxid)); + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_OX_ID ((&plogi.fchdr), oxid); +FNIC_LOGI_SET_NPORT_NAME (&plogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&plogi.els, iport->wwnn); + + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); + + +fnic_send_fcoe_frame (iport, &plogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport, timeout); +} + +static uint16_t +fnic_fc_plogi_rsp_rdf (struct fnic_iport_s *iport, +struct fc_std_flogi *plogi_rsp) +{ +uint16_t b2b_rdf_size = +be16_to_cpu (FNIC_LOGI_RDF_SIZE (&plogi_rsp->els)); +uint16_t spc3_rdf_size = +be16_to_cpu (plogi_rsp->els.fl_cssp[2 ].cp_rdfs) &FNIC_FC_C3_RDF ; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MFS: b2b_rdf_size: 0x%x spc3_rdf_size: 0x%x" , + b2b_rdf_size, spc3_rdf_size); + +return MIN (b2b_rdf_size, spc3_rdf_size); +} +static void fdls_send_register_fc4_types (struct fnic_iport_s *iport) {struct fc_std_rft_id rft_id;@@ -690,6 +1011,48 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport)fdls_start_fabric_timer (iport,2 * iport->e_d_tov); } +static void +fdls_send_tgt_prli (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_els_prli prli; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint32_t timeout; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending PRLI to tgt: 0x%x" , tport->fcid); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->prli_oxid_pool)); +if (oxid ==0xFFFF ) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
drivers/scsi/fnic/fdls_disc.c static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) · line 1039
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ "Failed to allocate OXID to send PRLI %p", iport); +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending PRLI to tgt: 0x%x OXID: 0x%x" , tport->fcid, +ntohs (oxid)); + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; +memcpy (&prli, &fnic_std_prli_req,sizeof (struct fc_std_els_prli ));
Memcpy again.
Quoted 35 lines
drivers/scsi/fnic/fdls_disc.c +28
-0+ +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID ((&prli.fchdr), s_id); +FNIC_STD_SET_D_ID ((&prli.fchdr), d_id); +FNIC_STD_SET_OX_ID ((&prli.fchdr), oxid); + + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); + +fdls_get_tgt_oxid_pool (tport); +fnic_send_fcoe_frame (iport, &prli,sizeof (struct fc_std_els_prli )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport, timeout); +} +/** * fdls_send_fabric_logo - Send flogo to the fcf * @iport: Handle to fnic iport @@ -742,6 +1105,212 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport)fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); } +/** +* fdls_tgt_logout - Send plogo to the remote port +* @iport: Handle to fnic iport +* @tport: Handle to remote port +* +* This function does not change or check the fabric/tport state. +* It the caller's responsibility to set the appropriate tport/fabric +* state when this is called. Normally that is fdls_tgt_state_plogo. +* This could be used to send plogo to nameserver process +* also not just target processes +*/ +void fdls_tgt_logout (struct fnic_iport_s *iport,struct fnic_tport_s *tport)
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1129
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+{ +struct fc_std_logo logo; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to tport fcid: 0x%x" , tport->fcid); +memcpy (&logo, &fnic_std_logo_req,sizeof (struct fc_std_logo ));
And here.
Quoted 120 lines
drivers/scsi/fnic/fdls_disc.c +120
-0+ +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID ((&logo.fchdr), s_id); +FNIC_STD_SET_D_ID ((&logo.fchdr), d_id); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->plogi_oxid_pool)); +FNIC_STD_SET_OX_ID ((&logo.fchdr), oxid); + +memcpy (&logo.els.fl_n_port_id, s_id,3 ); +FNIC_STD_SET_NPORT_NAME (&logo.els.fl_n_port_wwn, +le64_to_cpu (iport->wwpn)); + + +fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); +} + +static void fdls_tgt_discovery_start (struct fnic_iport_s *iport) +{ +struct fnic_tport_s *tport, *next; +u32 old_link_down_cnt = iport->fnic->link_down_cnt; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Starting FDLS target discovery" , iport->fcid); + +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { +if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state !=FNIC_IPORT_STATE_READY )) { +break ; + } +/* if we marked the tport as deleted due to GPN_FT +* We should not send ADISC anymore +*/ +if ((tport->state ==FDLS_TGT_STATE_OFFLINING ) || + (tport->state ==FDLS_TGT_STATE_OFFLINE )) +continue ; + +/* For tports which have received RSCN */ +if (tport->flags &FNIC_FDLS_TPORT_SEND_ADISC ) { + tport->retry_counter =0 ; +fdls_set_tport_state (tport,FDLS_TGT_STATE_ADISC ); + tport->flags &= ~FNIC_FDLS_TPORT_SEND_ADISC ; +fdls_send_tgt_adisc (iport, tport); +continue ; + } +if (fdls_get_tport_state (tport) !=FDLS_TGT_STATE_INIT ) { +/* Not a new port, skip */ +continue ; + } + tport->retry_counter =0 ; +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); +fdls_send_tgt_plogi (iport, tport); + } +fdls_set_state ((&iport->fabric),FDLS_STATE_TGT_DISCOVERY ); +} + +/* +* Function to restart the IT nexus if we received any out of +* sequence PLOGI/PRLI response from the target. +* The memory for the new tport structure is allocated +* inside fdls_create_tport and added to the iport's tport list. +* This will get freed later during tport_offline/linkdown +* or module unload. The new_tport pointer will go out of scope +* safely since the memory it is +* pointing to it will be freed later +*/ +static void fdls_target_restart_nexus (struct fnic_tport_s *tport) +{ +struct fnic_iport_s *iport = tport->iport; +struct fnic_tport_s *new_tport =NULL ; +uint32_t fcid; +uint64_t wwpn; +int nexus_restart_count; +struct fnic *fnic = iport->fnic; +bool retval = true; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid: 0x%x state: %d restart_count: %d" , + tport->fcid, tport->state, tport->nexus_restart_count); + + fcid = tport->fcid; + wwpn = tport->wwpn; + nexus_restart_count = tport->nexus_restart_count; + + retval =fdls_delete_tport (iport, tport); +if (retval != true) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Error deleting tport: 0x%x" , fcid); +return ; + } + +if (nexus_restart_count >=FNIC_TPORT_MAX_NEXUS_RESTART ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Exceeded nexus restart retries tport: 0x%x" , + fcid); +return ; + } + +/* +* Allocate memory for the new tport and add it to +* iport's tport list. +* This memory will be freed during tport_offline/linkdown +* or module unload. The pointer new_tport is safe to go +* out of scope when this function returns, since the memory +* it is pointing to is guaranteed to be freed later +* as mentioned above. +*/ + new_tport =fdls_create_tport (iport, fcid, wwpn); +if (!new_tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Error creating new tport: 0x%x" , fcid); +return ; + } + + new_tport->nexus_restart_count = nexus_restart_count +1 ; +fdls_send_tgt_plogi (iport, new_tport); +fdls_set_tport_state (new_tport,FDLS_TGT_STATE_PLOGI ); +}
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1259
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ +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;
Odd. Can you have two entries with the same fcid in the list?
Quoted 40 lines
drivers/scsi/fnic/fdls_disc.c +40
-0+ } +return NULL ; +} + +static struct fnic_tport_s *fdls_create_tport (struct fnic_iport_s *iport, +uint32_t fcid,uint64_t wwpn) +{ +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS create tport: fcid: 0x%x wwpn: 0x%llx" , fcid, wwpn); + + tport =kzalloc (sizeof (struct fnic_tport_s ),GFP_ATOMIC ); +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Memory allocation failure while creating tport: 0x%x\n" , + fcid); +return NULL ; + } + + tport->max_payload_size =FNIC_FCOE_MAX_FRAME_SZ ; + tport->r_a_tov =FNIC_R_A_TOV_DEF ; + tport->e_d_tov =FNIC_E_D_TOV_DEF ; + tport->fcid = fcid; + tport->wwpn = wwpn; + tport->iport = iport; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Need to setup tport timer callback" ); + +timer_setup (&tport->retry_timer, fdls_tport_timer_callback,0 ); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Added tport 0x%x" , tport->fcid); +fdls_set_tport_state (tport,FDLS_TGT_STATE_INIT ); +list_add_tail (&tport->links, &iport->tport_list); +atomic_set (&tport->in_flight,0 ); +return tport; +}
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1309
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ +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;
Same argument here.
I would have expected wwpns to be unique ...
Quoted 1,133 lines
drivers/scsi/fnic/fdls_disc.c +930
-74+ } +return NULL ; +} +void fdls_fabric_timer_callback (struct timer_list *t) {struct fnic_fdls_fabric_s *fabric =from_timer (fabric, t, retry_timer);@@ -847,90 +1416,588 @@ void fdls_fabric_timer_callback(struct timer_list *t)/* ABTS has timed out */ fdls_schedule_fabric_oxid_free (iport);FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timed out. Starting PLOGI: %p" , iport); -fnic_fdls_start_plogi (iport); +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport); + } +break ; +case FDLS_STATE_REGISTER_FC4_TYPES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_types (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* RFT_ID timed out send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI: %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_REGISTER_FC4_FEATURES : +/* scr received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_register_fc4_features (iport); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) +/* SCR has timed out. Send abts */ +fdls_send_fabric_abts (iport); +else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timed out. Starting PLOGI %p" , iport); +fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ + } +break ; +case FDLS_STATE_RSCN_GPN_FT : +case FDLS_STATE_SEND_GPNFT : +case FDLS_STATE_GPN_FT : +/* GPN_FT received a LS_RJT with busy we retry from here */ +if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) + && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { + iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_gpn_ft (iport, iport->fabric.state); + }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { +/* gpn_ft has timed out. Send abts */ +fdls_send_fabric_abts (iport); + }else { +/* ABTS has timed out */ +fdls_schedule_fabric_oxid_free (iport); +if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { +fdls_send_gpn_ft (iport, iport->fabric.state); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ABTS timeout for fabric GPN_FT. Check name server: %p" , + iport); + } + } +break ; +default : +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 =ntohs (tport->oxid_used); + +/* We retry plogi/prli/adisc frames depending on the tport state */ +switch (tport->state) { +case FDLS_TGT_STATE_PLOGI : +/* PLOGI frame received a LS_RJT with busy, we retry from here */ +if ((tport->flags &FNIC_FDLS_RETRY_FRAME ) + && (tport->retry_counter < iport->max_plogi_retries)) { + tport->flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_tgt_plogi (iport, tport); + }else if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +/* Plogi frame has timed out, send abts */ +fdls_send_tport_abts (iport, tport); + }else if (tport->retry_counter < iport->max_plogi_retries) { +/* +* ABTS has timed out +*/ +fdls_schedule_tgt_oxid_free (iport, + &iport->plogi_oxid_pool, + oxid); +fdls_send_tgt_plogi (iport, tport); + }else { +/* exceeded plogi retry count */ +fdls_schedule_tgt_oxid_free (iport, + &iport->plogi_oxid_pool, + oxid); +fdls_send_delete_tport_msg (tport); + } +break ; +case FDLS_TGT_STATE_PRLI : +/* PRLI received a LS_RJT with busy , hence we retry from here */ +if ((tport->flags &FNIC_FDLS_RETRY_FRAME ) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { + tport->flags &= ~FNIC_FDLS_RETRY_FRAME ; +fdls_send_tgt_prli (iport, tport); + }else if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +/* PRLI has time out, send abts */ +fdls_send_tport_abts (iport, tport); + }else { +/* ABTS has timed out for prli, we go back to PLOGI */ +fdls_schedule_tgt_oxid_free (iport, + &iport->prli_oxid_pool, + oxid); +fdls_send_tgt_plogi (iport, tport); +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); + } +break ; +case FDLS_TGT_STATE_ADISC : +/* ADISC timed out send an ABTS */ +if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +fdls_send_tport_abts (iport, tport); + }else if ((tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED ) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { +/* +* ABTS has timed out +*/ +fdls_schedule_tgt_oxid_free (iport, + &iport->adisc_oxid_pool, + oxid); +fdls_send_tgt_adisc (iport, tport); + }else { +/* exceeded retry count */ +fdls_schedule_tgt_oxid_free (iport, + &iport->adisc_oxid_pool, + oxid); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC not responding. Deleting target port: 0x%x" , + tport->fcid); +fdls_send_delete_tport_msg (tport); + } +break ; +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Unknown tport state: 0x%x" , tport->state); +break ; + } +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +} + +static void fnic_fdls_start_flogi (struct fnic_iport_s *iport) +{ + iport->fabric.retry_counter =0 ; +fdls_send_fabric_flogi (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_FLOGI ); + iport->fabric.flags =0 ; +} + +static void fnic_fdls_start_plogi (struct fnic_iport_s *iport) +{ + iport->fabric.retry_counter =0 ; +fdls_send_fabric_plogi (iport); +fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_PLOGI ); + iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; +} + +static void +fdls_process_tgt_adisc_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint64_t frame_wwnn; +uint64_t frame_wwpn; +uint16_t oxid; +struct fc_std_els_adisc *adisc_rsp = (struct fc_std_els_adisc *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +struct fnic *fnic = iport->fnic; + + fcid =FNIC_STD_GET_S_ID (fchdr); + tgt_fcid =ntoh24 (fcid); + tport =fnic_find_tport_by_fcid (iport, tgt_fcid); + +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Tgt ADISC response tport not found: 0x%x" , tgt_fcid); +return ; + } +if ((iport->state !=FNIC_IPORT_STATE_READY ) + || (tport->state !=FDLS_TGT_STATE_ADISC ) + || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping this ADISC response" ); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"iport state: %d tport state: %d Is abort issued on PRLI? %d" , + iport->state, tport->state, + (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )); +return ; + } +if (ntohs (fchdr->fh_ox_id) !=ntohs (tport->oxid_used)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping frame from target: 0x%x" , + tgt_fcid); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Reason: Stale ADISC/Aborted ADISC/OOO frame delivery" ); +return ; + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, oxid); + +switch (adisc_rsp->els.adisc_cmd) { +case ELS_LS_ACC : +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport 0x%p Canceling fabric disc timer\n" , + tport); +fnic_del_tport_timer_sync (fnic, tport); + } + tport->timer_pending =0 ; + tport->retry_counter =0 ; + frame_wwnn =get_unaligned_be64 (&adisc_rsp->els.adisc_wwnn); + frame_wwpn =get_unaligned_be64 (&adisc_rsp->els.adisc_wwpn); +if ((frame_wwnn == tport->wwnn) && (frame_wwpn == tport->wwpn)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC accepted from target: 0x%x. Target logged in" , + tgt_fcid); +fdls_set_tport_state (tport,FDLS_TGT_STATE_READY ); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Error mismatch frame: ADISC" ); + } +break ; + +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , + tgt_fcid); + +/* Retry ADISC again from the timer routine. */ + tport->flags |=FNIC_FDLS_RETRY_FRAME ; + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"ADISC returned ELS_LS_RJT from target: 0x%x" , + tgt_fcid); +fdls_delete_tport (iport, tport); + } +break ; + } +} + + +static void +fdls_process_tgt_plogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint16_t oxid; +struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +int max_payload_size; +struct fnic *fnic = iport->fnic; + + fcid =FNIC_STD_GET_S_ID (fchdr); + tgt_fcid =ntoh24 (fcid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS processing target PLOGI response: tgt_fcid: 0x%x" , + tgt_fcid); + + tport =fnic_find_tport_by_fcid (iport, tgt_fcid); +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport not found: 0x%x" , tgt_fcid); +return ; + } +if ((iport->state !=FNIC_IPORT_STATE_READY ) + || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping frame! iport state: %d tport state: %d" , + iport->state, tport->state); +return ; + } + +if (tport->state !=FDLS_TGT_STATE_PLOGI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI rsp recvd in wrong state. Drop the frame and restart nexus" ); +fdls_target_restart_nexus (tport); +return ; + } + +if (fchdr->fh_ox_id != tport->oxid_used) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI response from target: 0x%x. Dropping frame" , + tgt_fcid); +return ; + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +fdls_free_tgt_oxid (iport, &iport->plogi_oxid_pool, oxid); + +switch (plogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI accepted by target: 0x%x" , tgt_fcid); +break ; + +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (tport->retry_counter < iport->max_plogi_retries)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , + tgt_fcid); +/* Retry plogi again from the timer routine. */ + tport->flags |=FNIC_FDLS_RETRY_FRAME ; +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI returned ELS_LS_RJT from target: 0x%x" , + tgt_fcid); +fdls_delete_tport (iport, tport); +return ; + +default : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI not accepted from target fcid: 0x%x" , + tgt_fcid); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Found the PLOGI target: 0x%x and state: %d" , + (unsigned int ) tgt_fcid, tport->state); + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + } + + tport->timer_pending =0 ; + tport->wwpn =get_unaligned_be64 (&FNIC_LOGI_PORT_NAME (&plogi_rsp->els)); + tport->wwnn =get_unaligned_be64 (&FNIC_LOGI_NODE_NAME (&plogi_rsp->els)); + +/* Learn the Service Params */ + +/* Max frame size - choose the lowest */ + max_payload_size =fnic_fc_plogi_rsp_rdf (iport, plogi_rsp); + tport->max_payload_size = +MIN (max_payload_size, iport->max_payload_size); + +if (tport->max_payload_size <FNIC_MIN_DATA_FIELD_SIZE ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MFS: tport max frame size below spec bounds: %d" , + tport->max_payload_size); + tport->max_payload_size =FNIC_MIN_DATA_FIELD_SIZE ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MAX frame size: %d iport max_payload_size: %d tport mfs: %d" , + max_payload_size, iport->max_payload_size, + tport->max_payload_size); + + tport->max_concur_seqs =FNIC_FC_PLOGI_RSP_CONCUR_SEQ (plogi_rsp); + + tport->retry_counter =0 ; +fdls_set_tport_state (tport,FDLS_TGT_STATE_PRLI ); +fdls_send_tgt_prli (iport, tport); +} + +static void +fdls_process_tgt_prli_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t tgt_fcid; +struct fnic_tport_s *tport; +uint8_t *fcid; +uint16_t oxid; +struct fc_std_els_prli *prli_rsp = (struct fc_std_els_prli *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +struct fnic_tport_event_s *tport_add_evt; +struct fnic *fnic = iport->fnic; +bool mismatched_tgt = false; + + fcid =FNIC_STD_GET_S_ID (fchdr); + tgt_fcid =ntoh24 (fcid); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS process tgt PRLI response: 0x%x" , tgt_fcid); + + tport =fnic_find_tport_by_fcid (iport, tgt_fcid); +if (!tport) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport not found: 0x%x" , tgt_fcid); +/* Handle or just drop? */ +return ; + } + +if ((iport->state !=FNIC_IPORT_STATE_READY ) + || (tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping frame! iport st: %d tport st: %d tport fcid: 0x%x" , + iport->state, tport->state, tport->fcid); +return ; + } + +if (tport->state !=FDLS_TGT_STATE_PRLI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI rsp recvd in wrong state. Drop frame. Restarting nexus" ); +fdls_target_restart_nexus (tport); +return ; + } + +if (fchdr->fh_ox_id != tport->oxid_used) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping PRLI response from target: 0x%x " , + tgt_fcid); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Reason: Stale PRLI response/Aborted PDISC/OOO frame delivery" ); +return ; + } + + oxid =ntohs (FNIC_STD_GET_OX_ID (fchdr)); +fdls_free_tgt_oxid (iport, &iport->prli_oxid_pool, oxid); + +switch (prli_rsp->els_prli.prli_cmd) { +case ELS_LS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI accepted from target: 0x%x" , tgt_fcid); + +if (prli_rsp->sp.spp_type !=FC_FC4_TYPE_SCSI ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"mismatched target zoned with FC SCSI initiator: 0x%x" , + tgt_fcid); + mismatched_tgt = true; } -break ; -case FDLS_STATE_REGISTER_FC4_TYPES : -/* scr received a LS_RJT with busy we retry from here */ -if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) - && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; -fdls_send_register_fc4_types (iport); - }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { -/* RFT_ID timed out send abts */ -fdls_send_fabric_abts (iport); - }else { -/* ABTS has timed out */ -fdls_schedule_fabric_oxid_free (iport); -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timed out. Starting PLOGI: %p" , iport); -fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ +if (mismatched_tgt) { +fdls_tgt_logout (iport, tport); +fdls_delete_tport (iport, tport); +return ; }break ; -case FDLS_STATE_REGISTER_FC4_FEATURES : -/* scr received a LS_RJT with busy we retry from here */ -if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) - && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; -fdls_send_register_fc4_features (iport); - }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) -/* SCR has timed out. Send abts */ -fdls_send_fabric_abts (iport); -else { -/* ABTS has timed out */ -fdls_schedule_fabric_oxid_free (iport); +case ELS_LS_RJT : +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (tport->retry_counter <FDLS_RETRY_COUNT )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timed out. Starting PLOGI %p" , iport); -fnic_fdls_start_plogi (iport);/* go back to fabric Plogi */ - } -break ; -case FDLS_STATE_RSCN_GPN_FT : -case FDLS_STATE_SEND_GPNFT : -case FDLS_STATE_GPN_FT : -/* GPN_FT received a LS_RJT with busy we retry from here */ -if ((iport->fabric.flags &FNIC_FDLS_RETRY_FRAME ) - && (iport->fabric.retry_counter <FDLS_RETRY_COUNT )) { - iport->fabric.flags &= ~FNIC_FDLS_RETRY_FRAME ; -fdls_send_gpn_ft (iport, iport->fabric.state); - }else if (!(iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) { -/* gpn_ft has timed out. Send abts */ -fdls_send_fabric_abts (iport); +"PRLI ret ELS_LS_RJT BUSY. Retry from timer routine: 0x%x" , + tgt_fcid); + +/*Retry Plogi again from the timer routine. */ + tport->flags |=FNIC_FDLS_RETRY_FRAME ; +return ; }else { -/* ABTS has timed out */ -fdls_schedule_fabric_oxid_free (iport); -if (iport->fabric.retry_counter <FDLS_RETRY_COUNT ) { -fdls_send_gpn_ft (iport, iport->fabric.state); - }else { -FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, -"ABTS timeout for fabric GPN_FT. Check name server: %p" , - iport); - } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI returned ELS_LS_RJT from target: 0x%x" , + tgt_fcid); + +fdls_tgt_logout (iport, tport); +fdls_delete_tport (iport, tport); +return ; }break ; +default : -fnic_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); -} -static void fnic_fdls_start_flogi (struct fnic_iport_s *iport) -{ - iport->fabric.retry_counter =0 ; -fdls_send_fabric_flogi (iport); -fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_FLOGI ); - iport->fabric.flags =0 ; -} +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Found the PRLI target: 0x%x and state: %d" , + (unsigned int ) tgt_fcid, tport->state); -static void fnic_fdls_start_plogi (struct fnic_iport_s *iport) -{ - iport->fabric.retry_counter =0 ; -fdls_send_fabric_plogi (iport); -fdls_set_state ((&iport->fabric),FDLS_STATE_FABRIC_PLOGI ); - iport->fabric.flags &= ~FNIC_FDLS_FABRIC_ABORT_ISSUED ; +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + } + tport->timer_pending =0 ; + +/* Learn Service Params */ + tport->fcp_csp =be32_to_cpu (prli_rsp->sp.spp_params); + tport->retry_counter =0 ; + +if (prli_rsp->sp.spp_params &FCP_SPPF_RETRY ) + tport->tgt_flags |=FNIC_FC_RP_FLAGS_RETRY ; + +/* Check if the device plays Target Mode Function */ +if (!(tport->fcp_csp &FCP_PRLI_FUNC_TARGET )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Remote port(0x%x): no target support. Deleting it\n" , + tgt_fcid); +fdls_tgt_logout (iport, tport); +fdls_delete_tport (iport, tport); +return ; + } + +fdls_set_tport_state (tport,FDLS_TGT_STATE_READY ); + +/* Inform the driver about new target added */ + tport_add_evt =kzalloc (sizeof (struct fnic_tport_event_s ),GFP_ATOMIC ); +if (!tport_add_evt) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport event memory allocation failure: 0x%0x\n" , + tport->fcid); +return ; + } + tport_add_evt->event =TGT_EV_RPORT_ADD ; + tport_add_evt->arg1 = (void *) tport; +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"iport fcid: 0x%x add tport event fcid: 0x%x\n" , + tport->fcid, iport->fcid); +list_add_tail (&tport_add_evt->links, &fnic->tport_event_list); +queue_work (fnic_event_queue, &fnic->tport_work); } +static void fdls_process_rff_id_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)@@ -1179,7 +2246,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 ;@@ -1192,6 +2260,104 @@ fdls_process_scr_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_gpn_ft_tgt_list (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr,int len) +{ +struct fc_gpn_ft_rsp_iu *gpn_ft_tgt; +struct fnic_tport_s *tport, *next; +uint32_t fcid; +uint64_t wwpn; +int rem_len = len; +u32 old_link_down_cnt = iport->fnic->link_down_cnt; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: FDLS process GPN_FT tgt list" , iport->fcid); + + gpn_ft_tgt = + (struct fc_gpn_ft_rsp_iu *)((uint8_t *) fchdr + +sizeof (struct fc_frame_header ) + +sizeof (struct fc_ct_hdr )); + len -=sizeof (struct fc_frame_header ) +sizeof (struct fc_ct_hdr ); + +while (rem_len >0 ) { + + fcid =ntoh24 (gpn_ft_tgt->fcid); + wwpn =ntohll (gpn_ft_tgt->wwpn); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport: 0x%x: ctrl:0x%x" , fcid, gpn_ft_tgt->ctrl); + +if (fcid == iport->fcid) { +if (gpn_ft_tgt->ctrl &FNIC_FC_GPN_LAST_ENTRY ) +break ; + gpn_ft_tgt++; + rem_len -=sizeof (struct fc_gpn_ft_rsp_iu ); +continue ; + } + + tport =fnic_find_tport_by_wwpn (iport, wwpn); +if (!tport) { +/* +* New port registered with the switch or first time query +*/ + tport =fdls_create_tport (iport, fcid, wwpn); +if (!tport) +return ; + } +/* +* check if this was an existing tport with same fcid +* but whose wwpn has changed now ,then remove it and +* create a new one +*/ +if (tport->fcid != fcid) { +fdls_delete_tport (iport, tport); + tport =fdls_create_tport (iport, fcid, wwpn); +if (!tport) +return ; + } + +/* +* If this GPN_FT rsp is after RSCN then mark the tports which +* matches with the new GPN_FT list, if some tport is not +* found in GPN_FT we went to delete that tport later. +*/ +if (fdls_get_state ((&iport->fabric)) ==FDLS_STATE_RSCN_GPN_FT ) + tport->flags |=FNIC_FDLS_TPORT_IN_GPN_FT_LIST ; + +if (gpn_ft_tgt->ctrl &FNIC_FC_GPN_LAST_ENTRY ) +break ; + + gpn_ft_tgt++; + rem_len -=sizeof (struct fc_gpn_ft_rsp_iu ); + } +if (rem_len <=0 ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"GPN_FT response: malformed/corrupt frame rxlen: %d remlen: %d" , + len, rem_len); + } + +/*remove those ports which was not listed in GPN_FT */ +if (fdls_get_state ((&iport->fabric)) ==FDLS_STATE_RSCN_GPN_FT ) { +list_for_each_entry_safe (tport, next, &iport->tport_list, links) { + +if (!(tport->flags &FNIC_FDLS_TPORT_IN_GPN_FT_LIST )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Remove port: 0x%x not found in GPN_FT list" , + tport->fcid); +fdls_delete_tport (iport, tport); + }else { + tport->flags &= ~FNIC_FDLS_TPORT_IN_GPN_FT_LIST ; + } +if ((old_link_down_cnt != iport->fnic->link_down_cnt) + || (iport->state !=FNIC_IPORT_STATE_READY )) { +return ; + } + } + } +} +static void fdls_process_gpn_ft_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr,int len)@@ -1200,6 +2366,9 @@ fdls_process_gpn_ft_rsp(struct fnic_iport_s *iport,struct fc_std_gpn_ft *gpn_ft_rsp = (struct fc_std_gpn_ft *) fchdr;uint16_t rsp;uint8_t reason_code; +int count =0 ; +struct fnic_tport_s *tport, *next; +u32 old_link_down_cnt = iport->fnic->link_down_cnt;struct fnic *fnic = iport->fnic; FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,@@ -1239,12 +2408,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 :@@ -1494,8 +2725,7 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, struct fc_frame_header *fchdr) {uint32_t s_id; -struct fc_std_abts_ba_acc *ba_acc = - (struct fc_std_abts_ba_acc *) fchdr; +struct fc_std_abts_ba_acc *ba_acc = (struct fc_std_abts_ba_acc *)fchdr;struct fc_std_abts_ba_rjt *ba_rjt;uint32_t fabric_state = iport->fabric.state;struct fnic *fnic = iport->fnic;@@ -1660,6 +2890,148 @@ fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, } } +static void +fdls_process_tgt_abts_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t s_id; +struct fnic_tport_s *tport; +uint32_t tport_state; +struct fc_std_abts_ba_acc *ba_acc; +struct fc_std_abts_ba_rjt *ba_rjt; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + + s_id =ntoh24 (fchdr->fh_s_id); + ba_acc = (struct fc_std_abts_ba_acc *)fchdr; + ba_rjt = (struct fc_std_abts_ba_rjt *)fchdr; + + tport =fnic_find_tport_by_fcid (iport, s_id); +if (!tport) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received tgt abts rsp with invalid SID: 0x%x" , s_id); +return ; + } + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"tport 0x%p Canceling fabric disc timer\n" , tport); +fnic_del_tport_timer_sync (fnic, tport); + } +if (iport->state !=FNIC_IPORT_STATE_READY ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received tgt abts rsp in iport state(%d). Dropping." , + iport->state); +return ; + } + tport->timer_pending =0 ; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + tport_state = tport->state; + oxid =ntohs (fchdr->fh_ox_id); + +/*This abort rsp is for ADISC */ +if ((oxid >=FDLS_ADISC_OXID_BASE ) && (oxid <FDLS_TGT_OXID_POOL_END )) { +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"OX_ID: 0x%x tgt_fcid: 0x%x rcvd tgt adisc abts resp BA_ACC" , +be16_to_cpu (ba_acc->acc.ba_ox_id), + tport->fcid); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"ADISC BA_RJT rcvd tport_fcid: 0x%x tport_state: %d " , + tport->fcid, tport_state); +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"reason code: 0x%x reason code explanation:0x%x " , + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } +if ((tport->retry_counter <FDLS_RETRY_COUNT ) + && (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL )) { +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, + oxid); +fdls_send_tgt_adisc (iport, tport); +return ; + } + +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, oxid); +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"ADISC not responding. Deleting target port: 0x%x" , + tport->fcid); +fdls_delete_tport (iport, tport); +if ((iport->state ==FNIC_IPORT_STATE_READY ) + && (iport->fabric.state !=FDLS_STATE_SEND_GPNFT ) + && (iport->fabric.state !=FDLS_STATE_RSCN_GPN_FT )) { +fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT ); + } +/*Restart a discovery of targets */ +return ; + } + +/*This abort rsp is for PLOGI */ +if ((oxid >=FDLS_PLOGI_OXID_BASE ) && (oxid <FDLS_PRLI_OXID_BASE )) { +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received tgt PLOGI abts response BA_ACC tgt_fcid: 0x%x" , + tport->fcid); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PLOGI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x" , + tport->fcid, fchdr->fh_ox_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"reason code: 0x%x reason code explanation: 0x%x" , + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } +if ((tport->retry_counter < iport->max_plogi_retries) + && (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL )) { +fdls_free_tgt_oxid (iport, &iport->plogi_oxid_pool, + oxid); +fdls_send_tgt_plogi (iport, tport); +return ; + } + +fdls_free_tgt_oxid (iport, &iport->plogi_oxid_pool, oxid); +fdls_delete_tport (iport, tport); +/*Restart a discovery of targets */ +if ((iport->state ==FNIC_IPORT_STATE_READY ) + && (iport->fabric.state !=FDLS_STATE_SEND_GPNFT ) + && (iport->fabric.state !=FDLS_STATE_RSCN_GPN_FT )) { +fdls_send_gpn_ft (iport,FDLS_STATE_SEND_GPNFT ); + } +return ; + } + +/*This abort rsp is for PRLI */ +if ((oxid >=FDLS_PRLI_OXID_BASE ) && (oxid <FDLS_ADISC_OXID_BASE )) { +if (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Received tgt PRLI abts response BA_ACC" , + tport->fcid); + }else if (fchdr->fh_r_ctl ==FNIC_BA_RJT_RCTL ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"PRLI BA_RJT received for tport_fcid: 0x%x OX_ID: 0x%x " , + tport->fcid, fchdr->fh_ox_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"reason code: 0x%x reason code explanation: 0x%x" , + ba_rjt->rjt.br_reason, + ba_rjt->rjt.br_explan); + } +if ((tport->retry_counter <FDLS_RETRY_COUNT ) + && (fchdr->fh_r_ctl ==FNIC_BA_ACC_RCTL )) { +fdls_free_tgt_oxid (iport, &iport->prli_oxid_pool, oxid); +fdls_send_tgt_prli (iport, tport); +return ; + } +fdls_free_tgt_oxid (iport, &iport->prli_oxid_pool, oxid); +fdls_send_tgt_plogi (iport, tport);/* go back to plogi */ +fdls_set_tport_state (tport,FDLS_TGT_STATE_PLOGI ); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received ABTS response for unknown frame %p" , iport); +} +/* * Performs a validation for all FCOE frames and return the frame type */ @@ -1757,6 +3129,39 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, } } +/* ELS response from a target */ +if ((ntohs (oxid) >=FDLS_PLOGI_OXID_BASE ) + && (ntohs (oxid) <FDLS_PRLI_OXID_BASE )) { +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in PLOGI exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_PLOGI_RSP ; + } +if ((ntohs (oxid) >=FDLS_PRLI_OXID_BASE ) + && (ntohs (oxid) <FDLS_ADISC_OXID_BASE )) { +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in PRLI exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_PRLI_RSP ; + } + +if ((ntohs (oxid) >=FDLS_ADISC_OXID_BASE ) + && (ntohs (oxid) <FDLS_TGT_OXID_POOL_END )) { +if (!FNIC_FC_FRAME_TYPE_ELS (fchdr)) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Dropping Unknown frame in ADISC exchange range type: 0x%x." , + fchdr->fh_type); +return -1 ; + } +return FNIC_TPORT_ADISC_RSP ; + } +/*response from fabric */ rsp_type =fnic_fdls_expected_rsp (iport,ntohs (oxid));@@ -1885,6 +3290,21 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,case FNIC_FABRIC_GPN_FT_RSP :fdls_process_gpn_ft_rsp (iport, fchdr, len);break ; +case FNIC_TPORT_PLOGI_RSP : +fdls_process_tgt_plogi_rsp (iport, fchdr); +break ; +case FNIC_TPORT_PRLI_RSP : +fdls_process_tgt_prli_rsp (iport, fchdr); +break ; +case FNIC_TPORT_ADISC_RSP : +fdls_process_tgt_adisc_rsp (iport, fchdr); +break ; +case FNIC_TPORT_LOGO_RSP : +/* Logo response from tgt which we have deleted */ +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Logo response from tgt: 0x%x" , +ntoh24 (fchdr->fh_s_id)); +break ;case FNIC_FABRIC_LOGO_RSP :fdls_process_fabric_logo_rsp (iport, fchdr);break ;@@ -1894,7 +3314,8 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,if (fdls_is_oxid_in_fabric_range (oxid) && (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) {fdls_process_fabric_abts_rsp (iport, fchdr); - } + }else +fdls_process_tgt_abts_rsp (iport, fchdr);break ;default : FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,drivers/scsi/fnic/fnic.h +6
-0@@ -79,6 +79,9 @@#define IS_FNIC_FCP_INITIATOR (fnic) (fnic->role == FNIC_ROLE_FCP_INITIATOR) +/* Retry supported by rport (returned by PRLI service parameters) */ +#define FNIC_FC_RP_FLAGS_RETRY 0x1 +/* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. @@ -133,6 +136,7 @@ static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)extern unsigned int fnic_log_level;extern unsigned int io_completions; +extern struct workqueue_struct *fnic_event_queue;#define FNIC_MAIN_LOGGING 0x01#define FNIC_FCS_LOGGING 0x02@@ -329,6 +333,8 @@ struct fnic {struct work_struct flush_work;struct sk_buff_head frame_queue;struct list_head tx_queue; +struct work_struct tport_work; +struct list_head tport_event_list;/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);drivers/scsi/fnic/fnic_fdls.h +0
-0
drivers/scsi/fnic/fnic_fdls.h int fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, · line 391
Quoted 8 lines
drivers/scsi/fnic/fnic_fdls.h +1
-1@@ -385,7 +385,7 @@ int fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport, void *rx_frame, int len, int fchdr_offset);void fdls_send_tport_abts (struct fnic_iport_s *iport, -struct fnic_tport_s *tport); +struct fnic_tport_s *tport);bool fdls_delete_tport (struct fnic_iport_s *iport,struct fnic_tport_s *tport);void fdls_fdmi_timer_callback (struct timer_list *t);
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v5 04/14] scsi: fnic: Add support for target based solicited requests and responses
Quoted 175 lines · Hannes Reinecke
Quoted 173 lines · Karan Tilak Kumar
Add support for target based solicited requests and responses. Add support for tport definitions and processing. Add support for restarting the IT nexus.
Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/202406120146.xchlZbqX-lkp@
intel.com/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Callfdls_get_tgt_oxid_pool.
Modify attribution appropriately.Changes between v2 and v3:
Fix issue found by kernel test robot.
Removefnic_std_ba_accdefinition 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.
Replacehtonll()withget_unaligned_be64(). Replacefnic_del_fabric_timer_syncmacro calls to function calls.
Replacefnic_del_tport_timer_syncmacro calls to function calls.
Renamefc_abts_stofc_tport_abts_s.
Modifyfc_tport_abts_sto be a global frame. Rename variablepfc_abtstotport_abts.
Replace definitions with standard definitions fromfc_els.h.
Modify functions with returns in the middle to if else clauses.
Replace simultaneous use offc_tport_abts_sandtport_abtswith justtport_abts.--- drivers/scsi/fnic/fdls_disc.c | 1569 +++++++++++++++++++++++++++++++-- drivers/scsi/fnic/fnic.h | 6 + drivers/scsi/fnic/fnic_fdls.h | 2 +- 3 files changed, 1502 insertions(+), 75 deletions(-)drivers/scsi/fnic/fdls_disc.c +65
-0@@ -11,6 +11,10 @@#include <scsi/fc/fc_fcp.h> #include <linux/utsname.h> +#define FC_FC4_TYPE_SCSI 0x08 + +static void fdls_send_rpn_id (struct fnic_iport_s *iport); +/* Frame initialization */ /* * Variables: @@ -66,6 +70,20 @@ struct fc_std_rpn_id fnic_std_rpn_id_req = { .ct_cmd = cpu_to_be16(FC_NS_RPN_ID)} }; +/* +* Variables: +* did, sid, oxid +*/ +struct fc_std_els_prli fnic_std_prli_req = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REQ , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, .fh_rx_id =0xFFFF }, + .els_prli = {.prli_cmd =ELS_PRLI , + .prli_spp_len =16 , + .prli_len =cpu_to_be16 (0x14 )}, + .sp = {.spp_type =0x08 , .spp_flags =0x0020 , + .spp_params =cpu_to_be32 (0xA2 )} +}; +/* * Variables: * fh_s_id, port_id, port_name @@ -143,9 +161,19 @@ struct fc_frame_header fc_std_fabric_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +struct fc_frame_header fc_std_tport_abts = { + .fh_r_ctl =FC_RCTL_BA_ABTS ,/* ABTS */ + .fh_cs_ctl =0x00 , .fh_type =FC_TYPE_BLS , + .fh_f_ctl = {FNIC_REQ_ABTS_FCTL ,0 ,0 }, .fh_seq_id =0x00 , + .fh_df_ctl =0x00 , .fh_seq_cnt =0x0000 , .fh_rx_id =0xFFFF , + .fh_parm_offset =0x00000000 ,/* bit:0 = 0 Abort a exchange */ +}; +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY) +#define FNIC_TPORT_MAX_NEXUS_RESTART (8) +/* * For fabric requests and fdmi, once OXIDs are allocated from the pool * (and a range) they are encoded with expected rsp type as @@ -167,6 +195,14 @@ 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@@ -182,6 +218,8 @@ void fdls_init_oxid_pool(struct fnic_iport_s *iport)fdls_init_fabric_oxid_pool (&iport->fdmi_oxid_pool,FDLS_FDMI_OXID_POOL_BASE ,FDLS_FDMI_OXID_POOL_SZ ); + +fdls_init_tgt_oxid_pool (iport); } uint16_t fdls_alloc_oxid(struct fnic_iport_s *iport,@@ -313,6 +351,13 @@ static inline void fdls_schedule_fabric_oxid_free(struct fnic_iport_s iport->fabric_oxid_pool.active_oxid_fabric_req); } +static inline void fdls_schedule_tgt_oxid_free (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s + *oxid_pool,uint16_t oxid) +{ +fdls_schedule_oxid_free (&oxid_pool->meta, oxid); +} +int fnic_fdls_expected_rsp (struct fnic_iport_s *iport,uint16_t oxid) {struct fnic *fnic = iport->fnic;@@ -340,6 +385,62 @@ static int fdls_is_oxid_in_fabric_range(uint16_t oxid) (oxid_unmasked <= FDLS_FABRIC_OXID_POOL_END)); } +void fdls_init_tgt_oxid_pool (struct fnic_iport_s *iport) +{ +memset (&iport->plogi_oxid_pool,0 ,sizeof (iport->plogi_oxid_pool)); + iport->plogi_oxid_pool.meta.oxid_base =FDLS_PLOGI_OXID_BASE ; + iport->plogi_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->plogi_oxid_pool.meta.reclaim_list); + +memset (&iport->prli_oxid_pool,0 ,sizeof (iport->prli_oxid_pool)); + iport->prli_oxid_pool.meta.oxid_base =FDLS_PRLI_OXID_BASE ; + iport->prli_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->prli_oxid_pool.meta.reclaim_list); + +memset (&iport->adisc_oxid_pool,0 ,sizeof (iport->adisc_oxid_pool)); + iport->adisc_oxid_pool.meta.oxid_base =FDLS_ADISC_OXID_BASE ; + iport->adisc_oxid_pool.meta.sz =FDLS_TGT_OXID_BLOCK_SZ ; +INIT_LIST_HEAD (&iport->adisc_oxid_pool.meta.reclaim_list); +} + +inline uint16_t fdls_alloc_tgt_oxid (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s *oxid_pool)
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c static int fdls_is_oxid_in_fabric_range(uint16_t oxid) · line 413
Quoted 6 lines
drivers/scsi/fnic/fdls_disc.c +6
-0+{ +uint16_t oxid; + + oxid =fdls_alloc_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap); +return oxid; +}Do a 'return
fdls_alloc_oxid()' and drop the intermediate variable.
Thanks Hannes. Sure, I'll do this in the next version.
Quoted 123 lines
Quoted 123 lines
drivers/scsi/fnic/fdls_disc.c +109
-0+ +inline void fdls_free_tgt_oxid (struct fnic_iport_s *iport, +struct fnic_tgt_oxid_pool_s *oxid_pool, +uint16_t oxid) +{ +fdls_free_oxid (iport, &oxid_pool->meta, oxid_pool->bitmap, oxid); +} + +static struct fnic_tgt_oxid_pool_s *fdls_get_tgt_oxid_pool (struct fnic_tport_s + *tport) +{ +struct fnic_iport_s *iport = (struct fnic_iport_s *)tport->iport; +struct fnic_tgt_oxid_pool_s *oxid_pool =NULL ; + +switch (tport->state) { +case FDLS_TGT_STATE_PLOGI : + oxid_pool = &iport->plogi_oxid_pool; +break ; +case FDLS_TGT_STATE_PRLI : + oxid_pool = &iport->prli_oxid_pool; +break ; +case FDLS_TGT_STATE_ADISC : + oxid_pool = &iport->adisc_oxid_pool; +break ; +default : +break ; + } +return oxid_pool; +} +inline void fnic_del_fabric_timer_sync (struct fnic *fnic) { fnic->iport.fabric.del_timer_inprogress =1 ;@@ -383,6 +484,56 @@ fdls_start_fabric_timer(struct fnic_iport_s *iport, int timeout) "fabric timer is %d ", timeout); } +static void +fdls_start_tport_timer (struct fnic_iport_s *iport, +struct fnic_tport_s *tport,int timeout) +{ +u64 fabric_tov; +struct fnic *fnic = iport->fnic; + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + tport->timer_pending =0 ; + } + +if (!(tport->flags &FNIC_FDLS_TGT_ABORT_ISSUED )) + tport->retry_counter++; + + fabric_tov = jiffies +msecs_to_jiffies (timeout); +mod_timer (&tport->retry_timer,round_jiffies (fabric_tov)); + tport->timer_pending =1 ; +} + +void +fdls_send_tport_abts (struct fnic_iport_s *iport, +struct fnic_tport_s *tport) +{ +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +struct fc_frame_header tport_abort = fc_std_tport_abts; +struct fc_frame_header *tport_abts = &tport_abort; + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (tport_abts, s_id); +FNIC_STD_SET_D_ID (tport_abts, d_id); + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + + tport_abts->fh_ox_id = tport->oxid_used; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending tport abts: tport->state: %d " , + tport->state); + +fnic_send_fcoe_frame (iport, tport_abts,sizeof (struct fc_frame_header )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport,2 * iport->e_d_tov); +} +static void fdls_send_fabric_abts (struct fnic_iport_s *iport) {uint8_t fcid[3 ];@@ -614,6 +765,176 @@ static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state)fdls_set_state ((&iport->fabric), fdls_state); } +static void +fdls_send_tgt_adisc (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_els_adisc adisc; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +memset (&adisc,0 ,sizeof (struct fc_std_els_adisc )); +FNIC_STD_SET_R_CTL (&adisc.fchdr,0x22 ); +FNIC_STD_SET_TYPE (&adisc.fchdr,0x01 ); +FNIC_STD_SET_F_CTL (&adisc.fchdr,FNIC_ELS_REQ_FCTL <<16 ); +FNIC_STD_SET_RX_ID (&adisc.fchdr,cpu_to_be16 (0xFFFF )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); +FNIC_STD_SET_S_ID (&adisc.fchdr, s_id); +FNIC_STD_SET_D_ID (&adisc.fchdr, d_id); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->adisc_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send ADISC %p" , iport); +return ; + } + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ;
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c static void fdls_send_gpn_ft(struct fnic_iport_s *iport, int fdls_state) · line 803
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+ +FNIC_STD_SET_OX_ID ((&adisc.fchdr), oxid); +FNIC_STD_SET_NPORT_NAME (&adisc.els.adisc_wwpn, +le64_to_cpu (iport->wwpn)); +FNIC_STD_SET_NODE_NAME (&adisc.els.adisc_wwnn,le64_to_cpu (iport->wwnn)); + +memcpy (adisc.els.adisc_port_id, s_id,3 );That feels wrong. Isn't
port_ida three-byte value in big endian?
This is a byte-to-byte copy after hton24 converts the value to big endian. Please let us know your thoughts here.
Quoted 160 lines
Quoted 160 lines
drivers/scsi/fnic/fdls_disc.c +153
-0+ adisc.els.adisc_cmd =ELS_ADISC ; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"sending ADISC to tgt fcid: 0x%x" , tport->fcid); + + +fnic_send_fcoe_frame (iport, &adisc,sizeof (struct fc_std_els_adisc )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport,2 * iport->e_d_tov); +} + +bool fdls_delete_tport (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fnic_tport_event_s *tport_del_evt; +struct fnic *fnic = iport->fnic; + +if ((tport->state ==FDLS_TGT_STATE_OFFLINING ) + || (tport->state ==FDLS_TGT_STATE_OFFLINE )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: tport state is offlining/offline\n" , + tport->fcid); +return false; + } + +fdls_set_tport_state (tport,FDLS_TGT_STATE_OFFLINING ); +/* +* By setting this flag, the tport will not be seen in a look-up +* in an RSCN. Even if we move to multithreaded model, this tport +* will be destroyed and a new RSCN will have to create a new one +*/ + tport->flags |=FNIC_FDLS_TPORT_TERMINATING ; + +if (tport->timer_pending) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport fcid 0x%x: Canceling disc timer\n" , + tport->fcid); +fnic_del_tport_timer_sync (fnic, tport); + tport->timer_pending =0 ; + } + +if (IS_FNIC_FCP_INITIATOR (fnic)) { +spin_unlock_irqrestore (&fnic->fnic_lock, fnic->lock_flags); +fnic_rport_exch_reset (iport->fnic, tport->fcid); +spin_lock_irqsave (&fnic->fnic_lock, fnic->lock_flags); + +if (tport->flags &FNIC_FDLS_SCSI_REGISTERED ) { + tport_del_evt = +kzalloc (sizeof (struct fnic_tport_event_s ),GFP_ATOMIC ); +if (!tport_del_evt) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate memory for tport fcid: 0x%0x\n" , + tport->fcid); +return false; + } + tport_del_evt->event =TGT_EV_RPORT_DEL ; + tport_del_evt->arg1 = (void *) tport; +list_add_tail (&tport_del_evt->links, &fnic->tport_event_list); +queue_work (fnic_event_queue, &fnic->tport_work); + }else { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"tport 0x%x not reg with scsi_transport. Freeing locally" , + tport->fcid); +list_del (&tport->links); +kfree (tport); + } + } +return true; +} + +static void +fdls_send_tgt_plogi (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_flogi plogi; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint32_t timeout; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Send tgt PLOGI to fcid: 0x%x" , tport->fcid); + +memcpy (&plogi, &fnic_std_plogi_req,sizeof (struct fc_std_flogi )); + +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID (&plogi.fchdr, s_id); +FNIC_STD_SET_D_ID (&plogi.fchdr, d_id); +FNIC_LOGI_SET_RDF_SIZE (&plogi.els, iport->max_payload_size); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->plogi_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"0x%x: Failed to allocate oxid to send PLOGI to fcid: 0x%x" , + iport->fcid, tport->fcid); +return ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"send tgt PLOGI: tgt fcid: 0x%x oxid: 0x%x" , tport->fcid, +ntohs (oxid)); + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; + +FNIC_STD_SET_OX_ID ((&plogi.fchdr), oxid); +FNIC_LOGI_SET_NPORT_NAME (&plogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&plogi.els, iport->wwnn); + + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); + + +fnic_send_fcoe_frame (iport, &plogi,sizeof (struct fc_std_flogi )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport, timeout); +} + +static uint16_t +fnic_fc_plogi_rsp_rdf (struct fnic_iport_s *iport, +struct fc_std_flogi *plogi_rsp) +{ +uint16_t b2b_rdf_size = +be16_to_cpu (FNIC_LOGI_RDF_SIZE (&plogi_rsp->els)); +uint16_t spc3_rdf_size = +be16_to_cpu (plogi_rsp->els.fl_cssp[2 ].cp_rdfs) &FNIC_FC_C3_RDF ; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"MFS: b2b_rdf_size: 0x%x spc3_rdf_size: 0x%x" , + b2b_rdf_size, spc3_rdf_size); + +return MIN (b2b_rdf_size, spc3_rdf_size); +} +static void fdls_send_register_fc4_types (struct fnic_iport_s *iport) {struct fc_std_rft_id rft_id;@@ -690,6 +1011,48 @@ static void fdls_send_register_fc4_features(struct fnic_iport_s *iport)fdls_start_fabric_timer (iport,2 * iport->e_d_tov); } +static void +fdls_send_tgt_prli (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_els_prli prli; +uint8_t s_id[3 ]; +uint8_t d_id[3 ]; +uint16_t oxid; +struct fnic *fnic = iport->fnic; +uint32_t timeout; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending PRLI to tgt: 0x%x" , tport->fcid); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->prli_oxid_pool)); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send PRLI %p" , iport); +return ; + }
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c static void fdls_send_register_fc4_features(struct fnic_iport_s *iport) · line 1039
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS sending PRLI to tgt: 0x%x OXID: 0x%x" , tport->fcid, +ntohs (oxid)); + + tport->oxid_used = oxid; + tport->flags &= ~FNIC_FDLS_TGT_ABORT_ISSUED ; +memcpy (&prli, &fnic_std_prli_req,sizeof (struct fc_std_els_prli ));Memcpy again.
Thanks Hannes. Sure, I'll fix this in the next version.
Quoted 39 lines
Quoted 39 lines
drivers/scsi/fnic/fdls_disc.c +31
-0+ +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID ((&prli.fchdr), s_id); +FNIC_STD_SET_D_ID ((&prli.fchdr), d_id); +FNIC_STD_SET_OX_ID ((&prli.fchdr), oxid); + + timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); + +fdls_get_tgt_oxid_pool (tport); +fnic_send_fcoe_frame (iport, &prli,sizeof (struct fc_std_els_prli )); +/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ +fdls_start_tport_timer (iport, tport, timeout); +} +/** * fdls_send_fabric_logo - Send flogo to the fcf * @iport: Handle to fnic iport @@ -742,6 +1105,212 @@ void fdls_send_fabric_logo(struct fnic_iport_s *iport)fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); } +/** +* fdls_tgt_logout - Send plogo to the remote port +* @iport: Handle to fnic iport +* @tport: Handle to remote port +* +* This function does not change or check the fabric/tport state. +* It the caller's responsibility to set the appropriate tport/fabric +* state when this is called. Normally that is fdls_tgt_state_plogo. +* This could be used to send plogo to nameserver process +* also not just target processes +*/ +void fdls_tgt_logout (struct fnic_iport_s *iport,struct fnic_tport_s *tport) +{ +struct fc_std_logo logo; +uint8_t s_id[3 ];
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1129
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+uint8_t d_id[3 ]; +struct fnic *fnic = iport->fnic; +uint16_t oxid; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending logo to tport fcid: 0x%x" , tport->fcid); +memcpy (&logo, &fnic_std_logo_req,sizeof (struct fc_std_logo ));And here.
Thanks Hannes. Sure, I'll fix this in the next version.
Quoted 22 lines
Quoted 22 lines
drivers/scsi/fnic/fdls_disc.c +22
-0+ +hton24 (s_id, iport->fcid); +hton24 (d_id, tport->fcid); + +FNIC_STD_SET_S_ID ((&logo.fchdr), s_id); +FNIC_STD_SET_D_ID ((&logo.fchdr), d_id); + + oxid =htons (fdls_alloc_tgt_oxid (iport, &iport->plogi_oxid_pool)); +FNIC_STD_SET_OX_ID ((&logo.fchdr), oxid); + +memcpy (&logo.els.fl_n_port_id, s_id,3 ); +FNIC_STD_SET_NPORT_NAME (&logo.els.fl_n_port_wwn, +le64_to_cpu (iport->wwpn)); + + +fnic_send_fcoe_frame (iport, &logo,sizeof (struct fc_std_logo )); +} + + +struct fnic_tport_s *fnic_find_tport_by_fcid (struct fnic_iport_s *iport, +uint32_t fcid) +{
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1259
Quoted 6 lines
drivers/scsi/fnic/fdls_disc.c +6
-0+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;Odd. Can you have two entries with the same fcid in the list?
No, there cannot be two entries with the same fcid in the list. Please let us know your thoughts here.
Quoted 8 lines
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c +8
-0+ } +return NULL ; +} + + +struct fnic_tport_s *fnic_find_tport_by_wwpn (struct fnic_iport_s *iport, +uint64_t wwpn) +{
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1309
Quoted 6 lines
drivers/scsi/fnic/fdls_disc.c +6
-0+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;Same argument here.
I would have expected wwpns to be unique ...
No, there cannot be two entries with the same wwpns in the list. Please let us know your thoughts here.
Quoted 3 lines
drivers/scsi/fnic/fdls_disc.c void fdls_send_fabric_logo(struct fnic_iport_s *iport) · line 1262
Quoted 3 lines
drivers/scsi/fnic/fdls_disc.c +3
-0+ } +return NULL ; +}
Regards,
Karan
Karan Tilak Kumar
maintainerPATCH v5 5/14 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 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 | 579 +++++++++++++++++++++++++++++++++- 1 file changed, 576 insertions(+), 3 deletions(-)
drivers/scsi/fnic/fdls_disc.c +576 -3
@@ -142,6 +142,22 @@ struct fc_std_scr fnic_std_scr_req = { .scr_reg_func = ELS_SCRF_FULL} }; +/* +* Variables: +* did, ox_id, rx_id +*/ +struct fc_std_els_rsp fnic_std_els_acc = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_d_id = {0xFF ,0xFF ,0xFD }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .u.acc.la_cmd =ELS_LS_ACC , +}; + +struct fc_std_els_rsp fnic_std_els_rjt = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .u.rej.er_cmd =ELS_LS_RJT , +}; +/* * Variables: * did, ox_id, rx_id, fcid, wwpn
@@ -169,6 +185,12 @@ struct fc_frame_header fc_std_tport_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +static struct fc_std_abts_ba_acc fnic_std_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 =0xFFFF } +}; +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY)
@@ -202,7 +224,6 @@ 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
@@ -507,6 +528,50 @@ fdls_start_tport_timer(struct fnic_iport_s *iport, tport->timer_pending =1 ; } +static void +fdls_send_rscn_resp (struct fnic_iport_s *iport, +struct fc_frame_header *rscn_fchdr) +{ +struct fc_std_els_rsp els_acc; +uint16_t oxid; +uint8_t fcid[3 ]; + +memcpy (&els_acc, &fnic_std_els_acc,FC_ELS_RSP_ACC_SIZE ); + +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&els_acc.fchdr), fcid); +FNIC_STD_SET_D_ID ((&els_acc.fchdr), rscn_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (rscn_fchdr); +FNIC_STD_SET_OX_ID ((&els_acc.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&els_acc.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &els_acc,FC_ELS_RSP_ACC_SIZE ); +} + +static void +fdls_send_logo_resp (struct fnic_iport_s *iport, +struct fc_frame_header *req_fchdr) +{ +struct fc_std_els_rsp logo_resp; +uint16_t oxid; +uint8_t fcid[3 ]; + +memcpy (&logo_resp, &fnic_std_els_acc,sizeof (struct fc_std_els_rsp )); + +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&logo_resp.fchdr), fcid); +FNIC_STD_SET_D_ID ((&logo_resp.fchdr), req_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (req_fchdr); +FNIC_STD_SET_OX_ID ((&logo_resp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&logo_resp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &logo_resp,FC_ELS_RSP_ACC_SIZE ); +} +void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport)
@@ -1047,7 +1112,6 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); -fdls_get_tgt_oxid_pool (tport);fnic_send_fcoe_frame (iport, &prli,sizeof (struct fc_std_els_prli ));/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ fdls_start_tport_timer (iport, tport, timeout);
@@ -2890,6 +2954,192 @@ 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) +{ +struct fc_std_abts_ba_acc ba_acc; +uint32_t nport_id; +uint16_t oxid; +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; +struct fnic_tgt_oxid_pool_s *oxid_pool; + + nport_id =ntoh24 (fchdr->fh_s_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abort from SID %8x" , nport_id); + + tport =fnic_find_tport_by_fcid (iport, nport_id); +if (tport) { + oxid =FNIC_STD_GET_OX_ID (fchdr); +if (tport->oxid_used == oxid) { + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + oxid_pool =fdls_get_tgt_oxid_pool (tport); +fdls_free_tgt_oxid (iport, oxid_pool,ntohs (oxid)); + } + } + +memcpy (&ba_acc, &fnic_std_ba_acc,sizeof (struct fc_std_abts_ba_acc )); +FNIC_STD_SET_S_ID ((&ba_acc.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&ba_acc.fchdr), fchdr->fh_s_id); + + ba_acc.fchdr.fh_rx_id = fchdr->fh_rx_id; + ba_acc.acc.ba_rx_id = ba_acc.fchdr.fh_rx_id; + ba_acc.fchdr.fh_ox_id = fchdr->fh_ox_id; + ba_acc.acc.ba_ox_id = ba_acc.fchdr.fh_ox_id; + +fnic_send_fcoe_frame (iport, &ba_acc,sizeof (struct fc_std_abts_ba_acc )); +} + +static void +fdls_process_unsupported_els_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_els_rsp ls_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; + +memcpy (&ls_rsp, &fnic_std_els_rjt,FC_ELS_RSP_REJ_SIZE ); + +if (iport->fcid != d_id) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"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 ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process unsupported ELS request from SID: 0x%x" , +ntoh24 (fchdr->fh_s_id)); +/* We don't support this ELS request, send a reject */ + ls_rsp.u.rej.er_reason =0x0B ; + ls_rsp.u.rej.er_explan =0x0 ; + ls_rsp.u.rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID ((&ls_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&ls_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&ls_rsp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&ls_rsp.fchdr),FNIC_UNSUPPORTED_RESP_OXID ); + +fnic_send_fcoe_frame (iport, &ls_rsp,FC_ELS_RSP_REJ_SIZE ); +} + +static void +fdls_process_rls_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +struct fc_std_rls_acc rls_acc_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +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 ; + } + +memset (&rls_acc_rsp,0 ,sizeof (struct fc_std_rls_acc )); + +FNIC_STD_SET_S_ID ((&rls_acc_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&rls_acc_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&rls_acc_rsp.fchdr), oxid); +FNIC_STD_SET_RX_ID ((&rls_acc_rsp.fchdr),0xffff ); +FNIC_STD_SET_F_CTL (&rls_acc_rsp.fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (&rls_acc_rsp.fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (&rls_acc_rsp.fchdr,FC_TYPE_ELS ); + rls_acc_rsp.els.rls_cmd =ELS_LS_ACC ; + rls_acc_rsp.els.rls_lesb.lesb_link_fail = +htonl (iport->fnic->link_down_cnt); + +fnic_send_fcoe_frame (iport, &rls_acc_rsp, +sizeof (struct fc_std_rls_acc )); +} + +static void +fdls_process_els_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr, +uint32_t len) +{ +struct fc_std_els_rsp *els_acc; +uint16_t oxid; +uint8_t fcid[3 ]; +uint8_t *fc_payload; +uint8_t *dst_frame; +uint8_t type; +struct fnic *fnic = iport->fnic; + + 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 :%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 %x ELS frame\n" , type); +break ; + } + dst_frame =kzalloc (len,GFP_ATOMIC ); +if (!dst_frame) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate ELS response for %x" , type); +return ; + } +if (type ==ELS_ECHO ) { +/* Brocade sends a longer payload, copy all frame back */ +memcpy (dst_frame, fchdr, len); + } + + els_acc = (struct fc_std_els_rsp *)dst_frame; +memcpy (els_acc, &fnic_std_els_acc,FC_ELS_RSP_ACC_SIZE ); + +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&els_acc->fchdr), fcid); +FNIC_STD_SET_D_ID ((&els_acc->fchdr), fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&els_acc->fchdr), oxid); +FNIC_STD_SET_RX_ID ((&els_acc->fchdr),0xffff ); + +if (type ==ELS_ECHO ) +fnic_send_fcoe_frame (iport, els_acc, len); +else +fnic_send_fcoe_frame (iport, els_acc,FC_ELS_RSP_ACC_SIZE ); + +kfree (dst_frame); +} +static void fdls_process_tgt_abts_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)
@@ -3032,6 +3282,303 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, "Received ABTS response for unknown frame %p", iport); } +static void +fdls_process_plogi_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_els_rsp plogi_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; + +memcpy (&plogi_rsp, &fnic_std_els_rjt,sizeof (struct fc_std_els_rsp )); + +if (iport->fcid != d_id) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI with illegal frame bits. Dropping frame %p" , + iport); +return ; + } + +if (iport->state !=FNIC_IPORT_STATE_READY ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI request in iport state: %d Dropping frame" , + iport->state); +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process PLOGI request from SID: 0x%x" , +ntoh24 (fchdr->fh_s_id)); + +/* We don't support PLOGI request, send a reject */ + plogi_rsp.u.rej.er_reason =0x0B ; + plogi_rsp.u.rej.er_explan =0x0 ; + plogi_rsp.u.rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID ((&plogi_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&plogi_rsp.fchdr), fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&plogi_rsp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&plogi_rsp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &plogi_rsp,FC_ELS_RSP_REJ_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 = 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 =ntohs (tport->oxid_used); +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, 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 adisc_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; +struct fc_std_els_rsp rjts_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +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 =ntohll (adisc_req->els.adisc_wwnn); + frame_wwpn =ntohll (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); + +memcpy (&rjts_rsp, &fnic_std_els_rjt, +sizeof (struct fc_std_els_rsp )); + + rjts_rsp.u.rej.er_reason =0x03 ;/* logical error */ + rjts_rsp.u.rej.er_explan =0x1E ;/* N_port login required */ + rjts_rsp.u.rej.er_vendor =0x0 ; +FNIC_STD_SET_S_ID ((&rjts_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&rjts_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&rjts_rsp.fchdr), oxid); +FNIC_STD_SET_RX_ID ((&rjts_rsp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &rjts_rsp,FC_ELS_RSP_REJ_SIZE ); +return ; + } +memset (&adisc_acc.fchdr,0 ,sizeof (struct fc_frame_header )); +FNIC_STD_SET_S_ID (&adisc_acc.fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (&adisc_acc.fchdr, fchdr->fh_s_id); +FNIC_STD_SET_F_CTL (&adisc_acc.fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (&adisc_acc.fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (&adisc_acc.fchdr,FC_TYPE_ELS ); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (&adisc_acc.fchdr, oxid); +FNIC_STD_SET_RX_ID (&adisc_acc.fchdr,FNIC_UNASSIGNED_RXID ); + adisc_acc.els.adisc_cmd =ELS_LS_ACC ; + +FNIC_STD_SET_NPORT_NAME (&adisc_acc.els.adisc_wwpn, +le64_to_cpu (iport->wwpn)); +FNIC_STD_SET_NODE_NAME (&adisc_acc.els.adisc_wwnn, +le64_to_cpu (iport->wwnn)); +memcpy (adisc_acc.els.adisc_port_id, fchdr->fh_d_id,3 ); + +fnic_send_fcoe_frame (iport, &adisc_acc, +sizeof (struct fc_std_els_adisc )); +} +/* * Performs a validation for all FCOE frames and return the frame type */
@@ -3314,8 +3861,34 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,if (fdls_is_oxid_in_fabric_range (oxid) && (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) {fdls_process_fabric_abts_rsp (iport, fchdr); - }else + }else {fdls_process_tgt_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,
Signature · 1 line
2.31.1
Re: [PATCH v5 05/14] scsi: fnic: Add support for unsolicited requests and responses
Quoted 93 lines · Karan Tilak Kumar
Add support for unsolicited requests and responses. Add support to accept and reject frames.
Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/202409291705.MugERX98-lkp@
intel.com/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Remove unnecessaryfdls_get_tgt_oxid_poolcall. Modify attribution appropriately.Changes between v3 and v4:
Fix kernel test robot warnings.Changes between v2 and v3:
Addfnic_std_ba_accremoved from previous patch. Incorporate review comments from Hannes:
Replace redundant definitions with standard definitions.Changes between v1 and v2:
Incorporate review comments from Hannes:
Replacefnic_del_tport_timer_syncmacro calls with function calls.
Fix indentation.
Replace definitions with standard definitions fromfc_els.h.--- drivers/scsi/fnic/fdls_disc.c | 579 +++++++++++++++++++++++++++++++++- 1 file changed, 576 insertions(+), 3 deletions(-)drivers/scsi/fnic/fdls_disc.c +22
-1@@ -142,6 +142,22 @@ struct fc_std_scr fnic_std_scr_req = { .scr_reg_func = ELS_SCRF_FULL} }; +/* +* Variables: +* did, ox_id, rx_id +*/ +struct fc_std_els_rsp fnic_std_els_acc = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_d_id = {0xFF ,0xFF ,0xFD }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .u.acc.la_cmd =ELS_LS_ACC , +}; + +struct fc_std_els_rsp fnic_std_els_rjt = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .u.rej.er_cmd =ELS_LS_RJT , +}; +/* * Variables: * did, ox_id, rx_id, fcid, wwpn @@ -169,6 +185,12 @@ struct fc_frame_header fc_std_tport_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +static struct fc_std_abts_ba_acc fnic_std_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 =0xFFFF } +}; +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY)@@ -202,7 +224,6 @@ 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@@ -507,6 +528,50 @@ fdls_start_tport_timer(struct fnic_iport_s *iport, tport->timer_pending =1 ; }
drivers/scsi/fnic/fdls_disc.c fdls_start_tport_timer(struct fnic_iport_s *iport, · line 540
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+static void +fdls_send_rscn_resp (struct fnic_iport_s *iport, +struct fc_frame_header *rscn_fchdr) +{ +struct fc_std_els_rsp els_acc; +uint16_t oxid; +uint8_t fcid[3 ]; + +memcpy (&els_acc, &fnic_std_els_acc,FC_ELS_RSP_ACC_SIZE ); +
As indicated previously; move the static initializer into the function and avoid the memcpy.
Quoted 11 lines
drivers/scsi/fnic/fdls_disc.c +11
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&els_acc.fchdr), fcid); +FNIC_STD_SET_D_ID ((&els_acc.fchdr), rscn_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (rscn_fchdr); +FNIC_STD_SET_OX_ID ((&els_acc.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&els_acc.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &els_acc,FC_ELS_RSP_ACC_SIZE ); +}
drivers/scsi/fnic/fdls_disc.c fdls_start_tport_timer(struct fnic_iport_s *iport, · line 561
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ +static void +fdls_send_logo_resp (struct fnic_iport_s *iport, +struct fc_frame_header *req_fchdr) +{ +struct fc_std_els_rsp logo_resp; +uint16_t oxid; +uint8_t fcid[3 ]; + +memcpy (&logo_resp, &fnic_std_els_acc,sizeof (struct fc_std_els_rsp ));
Same here.
Quoted 43 lines
drivers/scsi/fnic/fdls_disc.c +28
-1+ +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&logo_resp.fchdr), fcid); +FNIC_STD_SET_D_ID ((&logo_resp.fchdr), req_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (req_fchdr); +FNIC_STD_SET_OX_ID ((&logo_resp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&logo_resp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &logo_resp,FC_ELS_RSP_ACC_SIZE ); +} +void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport)@@ -1047,7 +1112,6 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); -fdls_get_tgt_oxid_pool (tport);fnic_send_fcoe_frame (iport, &prli,sizeof (struct fc_std_els_prli ));/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ fdls_start_tport_timer (iport, tport, timeout);@@ -2890,6 +2954,192 @@ 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) +{ +struct fc_std_abts_ba_acc ba_acc; +uint32_t nport_id; +uint16_t oxid; +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; +struct fnic_tgt_oxid_pool_s *oxid_pool; + + nport_id =ntoh24 (fchdr->fh_s_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abort from SID %8x" , nport_id); + + tport =fnic_find_tport_by_fcid (iport, nport_id);
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 2981
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+if (tport) { + oxid =FNIC_STD_GET_OX_ID (fchdr); +if (tport->oxid_used == oxid) { + tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + oxid_pool =fdls_get_tgt_oxid_pool (tport); +fdls_free_tgt_oxid (iport, oxid_pool,ntohs (oxid)); + } + } + +memcpy (&ba_acc, &fnic_std_ba_acc,sizeof (struct fc_std_abts_ba_acc ));
And here.
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 2988
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+FNIC_STD_SET_S_ID ((&ba_acc.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&ba_acc.fchdr), fchdr->fh_s_id); + + ba_acc.fchdr.fh_rx_id = fchdr->fh_rx_id; + ba_acc.acc.ba_rx_id = ba_acc.fchdr.fh_rx_id; + ba_acc.fchdr.fh_ox_id = fchdr->fh_ox_id; + ba_acc.acc.ba_ox_id = ba_acc.fchdr.fh_ox_id;
Especially as you have to set fields in the request afterwards anyway.
Quoted 4 lines
drivers/scsi/fnic/fdls_disc.c +4
-0+ +fnic_send_fcoe_frame (iport, &ba_acc,sizeof (struct fc_std_abts_ba_acc )); +} +
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 3002
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+static void +fdls_process_unsupported_els_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_els_rsp ls_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; + +memcpy (&ls_rsp, &fnic_std_els_rjt,FC_ELS_RSP_REJ_SIZE );
memcpy again.
Quoted 43 lines
drivers/scsi/fnic/fdls_disc.c +43
-0+ +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 ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process unsupported ELS request from SID: 0x%x" , +ntoh24 (fchdr->fh_s_id)); +/* We don't support this ELS request, send a reject */ + ls_rsp.u.rej.er_reason =0x0B ; + ls_rsp.u.rej.er_explan =0x0 ; + ls_rsp.u.rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID ((&ls_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&ls_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&ls_rsp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&ls_rsp.fchdr),FNIC_UNSUPPORTED_RESP_OXID ); + +fnic_send_fcoe_frame (iport, &ls_rsp,FC_ELS_RSP_REJ_SIZE ); +} + +static void +fdls_process_rls_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +struct fc_std_rls_acc rls_acc_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process RLS request %d" , iport->fnic->fnic_num);
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 3055
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ +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 ; + } + +memset (&rls_acc_rsp,0 ,sizeof (struct fc_std_rls_acc ));
???
What is this? Memsetting only parts of the request? Why not the full request?
Quoted 60 lines
drivers/scsi/fnic/fdls_disc.c +60
-0+ +FNIC_STD_SET_S_ID ((&rls_acc_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&rls_acc_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&rls_acc_rsp.fchdr), oxid); +FNIC_STD_SET_RX_ID ((&rls_acc_rsp.fchdr),0xffff ); +FNIC_STD_SET_F_CTL (&rls_acc_rsp.fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (&rls_acc_rsp.fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (&rls_acc_rsp.fchdr,FC_TYPE_ELS ); + rls_acc_rsp.els.rls_cmd =ELS_LS_ACC ; + rls_acc_rsp.els.rls_lesb.lesb_link_fail = +htonl (iport->fnic->link_down_cnt); + +fnic_send_fcoe_frame (iport, &rls_acc_rsp, +sizeof (struct fc_std_rls_acc )); +} + +static void +fdls_process_els_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr, +uint32_t len) +{ +struct fc_std_els_rsp *els_acc; +uint16_t oxid; +uint8_t fcid[3 ]; +uint8_t *fc_payload; +uint8_t *dst_frame; +uint8_t type; +struct fnic *fnic = iport->fnic; + + 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 :%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 %x ELS frame\n" , type); +break ; + } + dst_frame =kzalloc (len,GFP_ATOMIC ); +if (!dst_frame) { + FNIC_FCS_DBG(KERN_INFO, fnic->lport->host, fnic->fnic_num,
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 3125
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+ "Failed to allocate ELS response for %x", type); +return ; + } +if (type ==ELS_ECHO ) { +/* Brocade sends a longer payload, copy all frame back */ +memcpy (dst_frame, fchdr, len); + } + + els_acc = (struct fc_std_els_rsp *)dst_frame; +memcpy (els_acc, &fnic_std_els_acc,FC_ELS_RSP_ACC_SIZE );
Memcpy again.
Quoted 24 lines
drivers/scsi/fnic/fdls_disc.c +17
-0+ +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&els_acc->fchdr), fcid); +FNIC_STD_SET_D_ID ((&els_acc->fchdr), fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&els_acc->fchdr), oxid); +FNIC_STD_SET_RX_ID ((&els_acc->fchdr),0xffff ); + +if (type ==ELS_ECHO ) +fnic_send_fcoe_frame (iport, els_acc, len); +else +fnic_send_fcoe_frame (iport, els_acc,FC_ELS_RSP_ACC_SIZE ); + +kfree (dst_frame); +} +static void fdls_process_tgt_abts_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)@@ -3032,6 +3282,303 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, "Received ABTS response for unknown frame %p", iport); }
drivers/scsi/fnic/fdls_disc.c fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, · line 3294
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+static void +fdls_process_plogi_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_els_rsp plogi_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; + +memcpy (&plogi_rsp, &fnic_std_els_rjt,sizeof (struct fc_std_els_rsp ));
And here.
Quoted 244 lines
drivers/scsi/fnic/fdls_disc.c +244
-0+ +if (iport->fcid != d_id) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI with illegal frame bits. Dropping frame %p" , + iport); +return ; + } + +if (iport->state !=FNIC_IPORT_STATE_READY ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI request in iport state: %d Dropping frame" , + iport->state); +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process PLOGI request from SID: 0x%x" , +ntoh24 (fchdr->fh_s_id)); + +/* We don't support PLOGI request, send a reject */ + plogi_rsp.u.rej.er_reason =0x0B ; + plogi_rsp.u.rej.er_explan =0x0 ; + plogi_rsp.u.rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID ((&plogi_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&plogi_rsp.fchdr), fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&plogi_rsp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&plogi_rsp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &plogi_rsp,FC_ELS_RSP_REJ_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 = 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 =ntohs (tport->oxid_used); +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, 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 adisc_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; +struct fc_std_els_rsp rjts_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +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 =ntohll (adisc_req->els.adisc_wwnn); + frame_wwpn =ntohll (adisc_req->els.adisc_wwpn); + +if ((frame_wwnn != tport->wwnn) || (frame_wwpn != tport->wwpn)) { +/* send reject */
drivers/scsi/fnic/fdls_disc.c fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, · line 3548
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+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); + +memcpy (&rjts_rsp, &fnic_std_els_rjt, +sizeof (struct fc_std_els_rsp )); +
And here.
Quoted 62 lines
drivers/scsi/fnic/fdls_disc.c +53
-1+ rjts_rsp.u.rej.er_reason =0x03 ;/* logical error */ + rjts_rsp.u.rej.er_explan =0x1E ;/* N_port login required */ + rjts_rsp.u.rej.er_vendor =0x0 ; +FNIC_STD_SET_S_ID ((&rjts_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&rjts_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&rjts_rsp.fchdr), oxid); +FNIC_STD_SET_RX_ID ((&rjts_rsp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &rjts_rsp,FC_ELS_RSP_REJ_SIZE ); +return ; + } +memset (&adisc_acc.fchdr,0 ,sizeof (struct fc_frame_header )); +FNIC_STD_SET_S_ID (&adisc_acc.fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (&adisc_acc.fchdr, fchdr->fh_s_id); +FNIC_STD_SET_F_CTL (&adisc_acc.fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (&adisc_acc.fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (&adisc_acc.fchdr,FC_TYPE_ELS ); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (&adisc_acc.fchdr, oxid); +FNIC_STD_SET_RX_ID (&adisc_acc.fchdr,FNIC_UNASSIGNED_RXID ); + adisc_acc.els.adisc_cmd =ELS_LS_ACC ; + +FNIC_STD_SET_NPORT_NAME (&adisc_acc.els.adisc_wwpn, +le64_to_cpu (iport->wwpn)); +FNIC_STD_SET_NODE_NAME (&adisc_acc.els.adisc_wwnn, +le64_to_cpu (iport->wwnn)); +memcpy (adisc_acc.els.adisc_port_id, fchdr->fh_d_id,3 ); + +fnic_send_fcoe_frame (iport, &adisc_acc, +sizeof (struct fc_std_els_adisc )); +} +/* * Performs a validation for all FCOE frames and return the frame type */ @@ -3314,8 +3861,34 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,if (fdls_is_oxid_in_fabric_range (oxid) && (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) {fdls_process_fabric_abts_rsp (iport, fchdr); - }else + }else {fdls_process_tgt_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 :
drivers/scsi/fnic/fdls_disc.c void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, · line 3894
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+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,
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Karan Tilak Kumar (kartilak)
maintainerRE: [PATCH v5 05/14] scsi: fnic: Add support for unsolicited requests and responses
Quoted 95 lines · Hannes Reinecke
Quoted 93 lines · Karan Tilak Kumar
Add support for unsolicited requests and responses. Add support to accept and reject frames.
Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/202409291705.MugERX98-lkp@
intel.com/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Remove unnecessaryfdls_get_tgt_oxid_poolcall. Modify attribution appropriately.Changes between v3 and v4:
Fix kernel test robot warnings.Changes between v2 and v3:
Addfnic_std_ba_accremoved from previous patch. Incorporate review comments from Hannes:
Replace redundant definitions with standard definitions.Changes between v1 and v2:
Incorporate review comments from Hannes:
Replacefnic_del_tport_timer_syncmacro calls with function calls.
Fix indentation.
Replace definitions with standard definitions fromfc_els.h.--- drivers/scsi/fnic/fdls_disc.c | 579 +++++++++++++++++++++++++++++++++- 1 file changed, 576 insertions(+), 3 deletions(-)drivers/scsi/fnic/fdls_disc.c +22
-1@@ -142,6 +142,22 @@ struct fc_std_scr fnic_std_scr_req = { .scr_reg_func = ELS_SCRF_FULL} }; +/* +* Variables: +* did, ox_id, rx_id +*/ +struct fc_std_els_rsp fnic_std_els_acc = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_d_id = {0xFF ,0xFF ,0xFD }, + .fh_type =FC_TYPE_ELS , .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .u.acc.la_cmd =ELS_LS_ACC , +}; + +struct fc_std_els_rsp fnic_std_els_rjt = { + .fchdr = {.fh_r_ctl =FC_RCTL_ELS_REP , .fh_type =FC_TYPE_ELS , + .fh_f_ctl = {FNIC_ELS_REP_FCTL ,0 ,0 }}, + .u.rej.er_cmd =ELS_LS_RJT , +}; +/* * Variables: * did, ox_id, rx_id, fcid, wwpn @@ -169,6 +185,12 @@ struct fc_frame_header fc_std_tport_abts = { .fh_parm_offset = 0x00000000, /* bit:0 = 0 Abort a exchange */ }; +static struct fc_std_abts_ba_acc fnic_std_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 =0xFFFF } +}; +#define RETRIES_EXHAUSTED (iport) \ (iport->fabric.retry_counter == FABRIC_LOGO_MAX_RETRY)@@ -202,7 +224,6 @@ 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@@ -507,6 +528,50 @@ fdls_start_tport_timer(struct fnic_iport_s *iport, tport->timer_pending =1 ; }
Quoted 12 lines
drivers/scsi/fnic/fdls_disc.c fdls_start_tport_timer(struct fnic_iport_s *iport, · line 540
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+static void +fdls_send_rscn_resp (struct fnic_iport_s *iport, +struct fc_frame_header *rscn_fchdr) +{ +struct fc_std_els_rsp els_acc; +uint16_t oxid; +uint8_t fcid[3 ]; + +memcpy (&els_acc, &fnic_std_els_acc,FC_ELS_RSP_ACC_SIZE ); +As indicated previously; move the static initializer into the function and avoid the memcpy.
Sure Hannes. I'll fix this in the next version.
Quoted 14 lines
Quoted 14 lines
drivers/scsi/fnic/fdls_disc.c +14
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&els_acc.fchdr), fcid); +FNIC_STD_SET_D_ID ((&els_acc.fchdr), rscn_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (rscn_fchdr); +FNIC_STD_SET_OX_ID ((&els_acc.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&els_acc.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &els_acc,FC_ELS_RSP_ACC_SIZE ); +} + +static void +fdls_send_logo_resp(struct fnic_iport_s *iport,
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_start_tport_timer(struct fnic_iport_s *iport, · line 561
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+ struct fc_frame_header *req_fchdr) +{ +struct fc_std_els_rsp logo_resp; +uint16_t oxid; +uint8_t fcid[3 ]; + +memcpy (&logo_resp, &fnic_std_els_acc,sizeof (struct fc_std_els_rsp ));Same here.
Sure Hannes. I'll fix this in the next version.
Quoted 46 lines
Quoted 46 lines
drivers/scsi/fnic/fdls_disc.c +31
-1+ +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&logo_resp.fchdr), fcid); +FNIC_STD_SET_D_ID ((&logo_resp.fchdr), req_fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (req_fchdr); +FNIC_STD_SET_OX_ID ((&logo_resp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&logo_resp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &logo_resp,FC_ELS_RSP_ACC_SIZE ); +} +void fdls_send_tport_abts (struct fnic_iport_s *iport,struct fnic_tport_s *tport)@@ -1047,7 +1112,6 @@ fdls_send_tgt_prli(struct fnic_iport_s *iport, struct fnic_tport_s *tport) timeout =max (2 * iport->e_d_tov, iport->plogi_timeout); -fdls_get_tgt_oxid_pool (tport);fnic_send_fcoe_frame (iport, &prli,sizeof (struct fc_std_els_prli ));/* Even if fnic_send_fcoe_frame() fails we want to retry after timeout */ fdls_start_tport_timer (iport, tport, timeout);@@ -2890,6 +2954,192 @@ 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) +{ +struct fc_std_abts_ba_acc ba_acc; +uint32_t nport_id; +uint16_t oxid; +struct fnic_tport_s *tport; +struct fnic *fnic = iport->fnic; +struct fnic_tgt_oxid_pool_s *oxid_pool; + + nport_id =ntoh24 (fchdr->fh_s_id); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abort from SID %8x" , nport_id); + + tport =fnic_find_tport_by_fcid (iport, nport_id); +if (tport) { + oxid =FNIC_STD_GET_OX_ID (fchdr); +if (tport->oxid_used == oxid) {
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 2981
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+ tport->flags |=FNIC_FDLS_TGT_ABORT_ISSUED ; + oxid_pool =fdls_get_tgt_oxid_pool (tport); +fdls_free_tgt_oxid (iport, oxid_pool,ntohs (oxid)); + } + } + +memcpy (&ba_acc, &fnic_std_ba_acc,sizeof (struct fc_std_abts_ba_acc ));And here.
Sure Hannes. I'll fix this in the next version.
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 2988
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+FNIC_STD_SET_S_ID ((&ba_acc.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&ba_acc.fchdr), fchdr->fh_s_id); + + ba_acc.fchdr.fh_rx_id = fchdr->fh_rx_id; + ba_acc.acc.ba_rx_id = ba_acc.fchdr.fh_rx_id; + ba_acc.fchdr.fh_ox_id = fchdr->fh_ox_id; + ba_acc.acc.ba_ox_id = ba_acc.fchdr.fh_ox_id;Especially as you have to set fields in the request afterwards anyway.
Sure. I understand. Thanks.
Quoted 7 lines
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+ +fnic_send_fcoe_frame (iport, &ba_acc,sizeof (struct fc_std_abts_ba_acc )); +} + +static void +fdls_process_unsupported_els_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr)
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 3002
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+{ +struct fc_std_els_rsp ls_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; + +memcpy (&ls_rsp, &fnic_std_els_rjt,FC_ELS_RSP_REJ_SIZE );memcpy again.
Sure Hannes. I'll fix this in the next version.
Quoted 48 lines
Quoted 48 lines
drivers/scsi/fnic/fdls_disc.c +48
-0+ +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 ; + } + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process unsupported ELS request from SID: 0x%x" , +ntoh24 (fchdr->fh_s_id)); +/* We don't support this ELS request, send a reject */ + ls_rsp.u.rej.er_reason =0x0B ; + ls_rsp.u.rej.er_explan =0x0 ; + ls_rsp.u.rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID ((&ls_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&ls_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&ls_rsp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&ls_rsp.fchdr),FNIC_UNSUPPORTED_RESP_OXID ); + +fnic_send_fcoe_frame (iport, &ls_rsp,FC_ELS_RSP_REJ_SIZE ); +} + +static void +fdls_process_rls_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr) +{ +struct fc_std_rls_acc rls_acc_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +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.",
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 3055
Quoted 5 lines
drivers/scsi/fnic/fdls_disc.c +5
-0+ iport->state); +return ; + } + +memset (&rls_acc_rsp,0 ,sizeof (struct fc_std_rls_acc ));???
What is this? Memsetting only parts of the request? Why not the full request?
Sure Hannes.
This should go away with the new version of changes.
Quoted 63 lines
Quoted 63 lines
drivers/scsi/fnic/fdls_disc.c +63
-0+ +FNIC_STD_SET_S_ID ((&rls_acc_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&rls_acc_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&rls_acc_rsp.fchdr), oxid); +FNIC_STD_SET_RX_ID ((&rls_acc_rsp.fchdr),0xffff ); +FNIC_STD_SET_F_CTL (&rls_acc_rsp.fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (&rls_acc_rsp.fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (&rls_acc_rsp.fchdr,FC_TYPE_ELS ); + rls_acc_rsp.els.rls_cmd =ELS_LS_ACC ; + rls_acc_rsp.els.rls_lesb.lesb_link_fail = +htonl (iport->fnic->link_down_cnt); + +fnic_send_fcoe_frame (iport, &rls_acc_rsp, +sizeof (struct fc_std_rls_acc )); +} + +static void +fdls_process_els_req (struct fnic_iport_s *iport,struct fc_frame_header *fchdr, +uint32_t len) +{ +struct fc_std_els_rsp *els_acc; +uint16_t oxid; +uint8_t fcid[3 ]; +uint8_t *fc_payload; +uint8_t *dst_frame; +uint8_t type; +struct fnic *fnic = iport->fnic; + + 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 :%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 %x ELS frame\n" , type); +break ; + } + dst_frame =kzalloc (len,GFP_ATOMIC ); +if (!dst_frame) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate ELS response for %x" , type); +return ; + }
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_fabric_abts_rsp(struct fnic_iport_s *iport, · line 3125
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+if (type ==ELS_ECHO ) { +/* Brocade sends a longer payload, copy all frame back */ +memcpy (dst_frame, fchdr, len); + } + + els_acc = (struct fc_std_els_rsp *)dst_frame; +memcpy (els_acc, &fnic_std_els_acc,FC_ELS_RSP_ACC_SIZE );Memcpy again.
Sure Hannes. I'll fix this in the next version.
Quoted 24 lines
Quoted 24 lines
drivers/scsi/fnic/fdls_disc.c +17
-0+ +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&els_acc->fchdr), fcid); +FNIC_STD_SET_D_ID ((&els_acc->fchdr), fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&els_acc->fchdr), oxid); +FNIC_STD_SET_RX_ID ((&els_acc->fchdr),0xffff ); + +if (type ==ELS_ECHO ) +fnic_send_fcoe_frame (iport, els_acc, len); +else +fnic_send_fcoe_frame (iport, els_acc,FC_ELS_RSP_ACC_SIZE ); + +kfree (dst_frame); +} +static void fdls_process_tgt_abts_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)@@ -3032,6 +3282,303 @@ fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, "Received ABTS response for unknown frame %p", iport); }
Quoted 11 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, · line 3294
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+static void +fdls_process_plogi_req (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_els_rsp plogi_rsp; +uint16_t oxid; +uint32_t d_id =ntoh24 (fchdr->fh_d_id); +struct fnic *fnic = iport->fnic; + +memcpy (&plogi_rsp, &fnic_std_els_rjt,sizeof (struct fc_std_els_rsp ));And here.
Sure Hannes. I'll fix this in the next version.
Quoted 247 lines
Quoted 247 lines
drivers/scsi/fnic/fdls_disc.c +247
-0+ +if (iport->fcid != d_id) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI with illegal frame bits. Dropping frame %p" , + iport); +return ; + } + +if (iport->state !=FNIC_IPORT_STATE_READY ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received PLOGI request in iport state: %d Dropping frame" , + iport->state); +return ; + } +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Process PLOGI request from SID: 0x%x" , +ntoh24 (fchdr->fh_s_id)); + +/* We don't support PLOGI request, send a reject */ + plogi_rsp.u.rej.er_reason =0x0B ; + plogi_rsp.u.rej.er_explan =0x0 ; + plogi_rsp.u.rej.er_vendor =0x0 ; + +FNIC_STD_SET_S_ID ((&plogi_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&plogi_rsp.fchdr), fchdr->fh_s_id); + + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&plogi_rsp.fchdr), oxid); + +FNIC_STD_SET_RX_ID ((&plogi_rsp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &plogi_rsp,FC_ELS_RSP_REJ_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 = 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 =ntohs (tport->oxid_used); +fdls_free_tgt_oxid (iport, &iport->adisc_oxid_pool, 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 adisc_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; +struct fc_std_els_rsp rjts_rsp; +uint16_t oxid; +struct fnic *fnic = iport->fnic; + +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 =ntohll (adisc_req->els.adisc_wwnn); + frame_wwpn =ntohll (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);
Quoted 8 lines
drivers/scsi/fnic/fdls_disc.c fdls_process_tgt_abts_rsp(struct fnic_iport_s *iport, · line 3548
Quoted 7 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+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); + +memcpy (&rjts_rsp, &fnic_std_els_rjt, +sizeof (struct fc_std_els_rsp )); +And here.
Sure Hannes. I'll fix this in the next version.
Quoted 75 lines
Quoted 62 lines
drivers/scsi/fnic/fdls_disc.c +53
-1+ rjts_rsp.u.rej.er_reason =0x03 ;/* logical error */ + rjts_rsp.u.rej.er_explan =0x1E ;/* N_port login required */ + rjts_rsp.u.rej.er_vendor =0x0 ; +FNIC_STD_SET_S_ID ((&rjts_rsp.fchdr), fchdr->fh_d_id); +FNIC_STD_SET_D_ID ((&rjts_rsp.fchdr), fchdr->fh_s_id); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID ((&rjts_rsp.fchdr), oxid); +FNIC_STD_SET_RX_ID ((&rjts_rsp.fchdr),FNIC_UNASSIGNED_RXID ); + +fnic_send_fcoe_frame (iport, &rjts_rsp,FC_ELS_RSP_REJ_SIZE ); +return ; + } +memset (&adisc_acc.fchdr,0 ,sizeof (struct fc_frame_header )); +FNIC_STD_SET_S_ID (&adisc_acc.fchdr, fchdr->fh_d_id); +FNIC_STD_SET_D_ID (&adisc_acc.fchdr, fchdr->fh_s_id); +FNIC_STD_SET_F_CTL (&adisc_acc.fchdr,FNIC_ELS_REP_FCTL <<16 ); +FNIC_STD_SET_R_CTL (&adisc_acc.fchdr,FC_RCTL_ELS_REP ); +FNIC_STD_SET_TYPE (&adisc_acc.fchdr,FC_TYPE_ELS ); + oxid =FNIC_STD_GET_OX_ID (fchdr); +FNIC_STD_SET_OX_ID (&adisc_acc.fchdr, oxid); +FNIC_STD_SET_RX_ID (&adisc_acc.fchdr,FNIC_UNASSIGNED_RXID ); + adisc_acc.els.adisc_cmd =ELS_LS_ACC ; + +FNIC_STD_SET_NPORT_NAME (&adisc_acc.els.adisc_wwpn, +le64_to_cpu (iport->wwpn)); +FNIC_STD_SET_NODE_NAME (&adisc_acc.els.adisc_wwnn, +le64_to_cpu (iport->wwnn)); +memcpy (adisc_acc.els.adisc_port_id, fchdr->fh_d_id,3 ); + +fnic_send_fcoe_frame (iport, &adisc_acc, +sizeof (struct fc_std_els_adisc )); +} +/* * Performs a validation for all FCOE frames and return the frame type */ @@ -3314,8 +3861,34 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,if (fdls_is_oxid_in_fabric_range (oxid) && (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) {fdls_process_fabric_abts_rsp (iport, fchdr); - }else + }else {fdls_process_tgt_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 :drivers/scsi/fnic/fdls_disc.c void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame, · line 3894
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +7
-0+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,Cheers,
Quoted 6 lines
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Regards,
Karan
Karan Tilak Kumar
maintainerPATCH v5 6/14 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 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/Makefile | 3 +- drivers/scsi/fnic/fdls_disc.c | 468 ++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 72 ++++ drivers/scsi/fnic/fnic_main.c | 25 ++ drivers/scsi/fnic/fnic_pci_subsys_devid.c | 131 ++++++ 5 files changed, 698 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/fdls_disc.c +468 -0
569 lines not on this page · raw message
drivers/scsi/fnic/fnic.h +72 -0
95 lines not on this page · raw message
drivers/scsi/fnic/fnic_main.c +25 -0
@@ -62,6 +62,9 @@ unsigned int fnic_log_level;module_param (fnic_log_level, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (fnic_log_level,"bit mask of fnic logging levels" ); +unsigned int fnic_fdmi_support =1 ; +module_param (fnic_fdmi_support, int,0644 ); +MODULE_PARM_DESC (fnic_fdmi_support,"FDMI support" );unsigned int io_completions =FNIC_DFLT_IO_COMPLETIONS ;module_param (io_completions, int,S_IRUGO |S_IWUSR );
@@ -607,6 +610,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)int i;unsigned long flags;int hwq; +char *desc, *subsys_desc; +int len;/* * Allocate SCSI Host and set up association between host,
@@ -640,6 +645,23 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->fnic_num = fnic_id;fnic_stats_debugfs_init (fnic); +/* Find model name from PCIe subsys ID */ +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) { +dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); + +/* Update FDMI model */ + fnic->subsys_desc_len =strlen (subsys_desc); + len =ARRAY_SIZE (fnic->subsys_desc); +if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; +memcpy (fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len); +dev_info (&fnic->pdev->dev,"FDMI Model: %s\n" , fnic->subsys_desc); + }else { + fnic->subsys_desc_len =0 ; +dev_info (&fnic->pdev->dev,"Model: %s subsys_id: 0x%04x\n" ,"Unknown" , + pdev->subsystem_device); + } + err =pci_enable_device (pdev);if (err) {dev_err (&fnic->pdev->dev,"Cannot enable PCI device, aborting.\n" );
@@ -1014,6 +1036,9 @@ static void fnic_remove(struct pci_dev *pdev)fnic_fcoe_evlist_free (fnic); } +if ((fnic_fdmi_support ==1 ) && (fnic->iport.fabric.fdmi_pending >0 )) +del_timer_sync (&fnic->iport.fabric.fdmi_timer); +/* * Log off the fabric. This stops all remote ports, dns port, * logs off the fabric. This flushes all rport, disc, lport work
drivers/scsi/fnic/fnic_pci_subsys_devid.c new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH v5 06/14] scsi: fnic: Add and integrate support for FDMI
Quoted 270 lines · Karan Tilak Kumar
Add support for Fabric-Device Management Interface (FDMI) by introducing PCI device IDs for Cisco Hardware.
Introduce a module parameter to enable/disable FDMI support.
Integrate support for FDMI.Reported-by kernel test robot <[email protected]>Closes:
https://lore.kernel.org/oe-kbuild-all/202406110734.p2v8dq9v-lkp
@intel.com/Reviewed-by Sesidhar Baddela <[email protected]>Co-developed-by Gian Carlo Boffa <[email protected]>Signed-off-by Gian Carlo Boffa <[email protected]>Co-developed-by Arulprabhu Ponnusamy <[email protected]>Signed-off-by Arulprabhu Ponnusamy <[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 v4 and v5:
Incorporate review comments from Martin:
Modify attribution appropriately.
Remove spurious newline at the end offdls_disc.c. Remove spurious newline at the end offnic_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:
Replacepr_infowithdev_info.
Replacehtonll()withget_unaligned_be64(). Replace definitions with standard definitions fromfc_els.h. Use standard definitions fromscsi_transport_fc.hfor port speeds.
Refactor definitions in struct fnic to avoid cache holes. Replace memcmp with not equal to operator.
Fix warning from kernel test robot:
Removeversion.h--- drivers/scsi/fnic/Makefile | 3 +- drivers/scsi/fnic/fdls_disc.c | 468 ++++++++++++++++++++++ drivers/scsi/fnic/fnic.h | 72 ++++ drivers/scsi/fnic/fnic_main.c | 25 ++ drivers/scsi/fnic/fnic_pci_subsys_devid.c | 131 ++++++ 5 files changed, 698 insertions(+), 1 deletion(-)create mode 100644
drivers/scsi/fnic/fnic_pci_subsys_devid.cdrivers/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.odrivers/scsi/fnic/fdls_disc.c +145
-0@@ -9,11 +9,23 @@#include "fdls_fc.h" #include "fnic_fdls.h" #include <scsi/fc/fc_fcp.h> +#include <scsi/scsi_transport_fc.h> #include <linux/utsname.h> #define FC_FC4_TYPE_SCSI 0x08 +#define PORT_SPEED_BIT_8 8 +#define PORT_SPEED_BIT_9 9 +#define PORT_SPEED_BIT_14 14 +#define PORT_SPEED_BIT_15 15static void fdls_send_rpn_id (struct fnic_iport_s *iport); +static void fdls_fdmi_register_hba (struct fnic_iport_s *iport); +static void fdls_fdmi_register_pa (struct fnic_iport_s *iport); +#define FDLS_FDMI_PLOGI_PENDING 0x1 +#define FDLS_FDMI_REG_HBA_PENDING 0x2 +#define FDLS_FDMI_RPA_PENDING 0x4 +#define FDLS_FDMI_ABORT_PENDING 0x8 +#define FDLS_FDMI_MAX_RETRY 3/* Frame initialization */ /* @@ -84,6 +96,70 @@ struct fc_std_els_prli fnic_std_prli_req = { .spp_params = cpu_to_be32(0xA2)} }; +/* +* Variables: +* sid, port_id, port_name +*/ +struct fc_std_fdmi_rhba fnic_std_fdmi_rhba = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0XFF ,0XFA }, + .fh_type =FC_TYPE_CT , .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_MGMT , + .ct_fs_subtype =FC_FDMI_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_FDMI_RHBA )}, + .num_ports =FNIC_FDMI_NUM_PORTS , + .num_hba_attributes =FNIC_FDMI_NUM_HBA_ATTRS , + .type_nn =FNIC_FDMI_TYPE_NODE_NAME , + .length_nn =FNIC_FDMI_NN_LEN , + .type_manu =FNIC_FDMI_TYPE_MANUFACTURER , + .length_manu =FNIC_FDMI_MANU_LEN , + .manufacturer =FNIC_FDMI_MANUFACTURER , + .type_serial =FNIC_FDMI_TYPE_SERIAL_NUMBER , + .length_serial =FNIC_FDMI_SERIAL_LEN , + .type_model =FNIC_FDMI_TYPE_MODEL , + .length_model =FNIC_FDMI_MODEL_LEN , + .type_model_des =FNIC_FDMI_TYPE_MODEL_DES , + .length_model_des =FNIC_FDMI_MODEL_DES_LEN , + .model_description =FNIC_FDMI_MODEL_DESCRIPTION , + .type_hw_ver =FNIC_FDMI_TYPE_HARDWARE_VERSION , + .length_hw_ver =FNIC_FDMI_HW_VER_LEN , + .type_dr_ver =FNIC_FDMI_TYPE_DRIVER_VERSION , + .length_dr_ver =FNIC_FDMI_DR_VER_LEN , + .type_rom_ver =FNIC_FDMI_TYPE_ROM_VERSION , + .length_rom_ver =FNIC_FDMI_ROM_VER_LEN , + .type_fw_ver =FNIC_FDMI_TYPE_FIRMWARE_VERSION , + .length_fw_ver =FNIC_FDMI_FW_VER_LEN , +}; + +/* +* Variables +*sid, port_id, port_name +*/ +struct fc_std_fdmi_rpa fnic_std_fdmi_rpa = { + .fchdr = {.fh_r_ctl =FC_RCTL_DD_UNSOL_CTL , + .fh_d_id = {0xFF ,0xFF ,0xFA }, + .fh_type =FC_TYPE_CT , .fh_f_ctl = {FNIC_ELS_REQ_FCTL ,0 ,0 }, + .fh_rx_id =0xFFFF }, + .fc_std_ct_hdr = {.ct_rev =FC_CT_REV , .ct_fs_type =FC_FST_MGMT , + .ct_fs_subtype =FC_FDMI_SUBTYPE , + .ct_cmd =cpu_to_be16 (FC_FDMI_RPA )}, + .num_port_attributes =FNIC_FDMI_NUM_PORT_ATTRS , + .type_fc4 =FNIC_FDMI_TYPE_FC4_TYPES , + .length_fc4 =FNIC_FDMI_FC4_LEN , + .type_supp_speed =FNIC_FDMI_TYPE_SUPPORTED_SPEEDS , + .length_supp_speed =FNIC_FDMI_SUPP_SPEED_LEN , + .type_cur_speed =FNIC_FDMI_TYPE_CURRENT_SPEED , + .length_cur_speed =FNIC_FDMI_CUR_SPEED_LEN , + .type_max_frame_size =FNIC_FDMI_TYPE_MAX_FRAME_SIZE , + .length_max_frame_size =FNIC_FDMI_MFS_LEN , + .max_frame_size =FNIC_FDMI_MFS , + .type_os_name =FNIC_FDMI_TYPE_OS_NAME , + .length_os_name =FNIC_FDMI_OS_NAME_LEN , + .type_host_name =FNIC_FDMI_TYPE_HOST_NAME , + .length_host_name =FNIC_FDMI_HN_LEN , +}; +/* * Variables: * fh_s_id, port_id, port_name @@ -224,6 +300,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@@ -337,6 +414,15 @@ uint16_t fdls_alloc_fabric_oxid(struct fnic_iport_s *iport,* separately. */ switch (exp_rsp_type) { +case FNIC_FDMI_PLOGI_RSP : + oxid_pool->active_oxid_fdmi_plogi = oxid; +break ; +case FNIC_FDMI_REG_HBA_RSP : + oxid_pool->active_oxid_fdmi_rhba = oxid; +break ; +case FNIC_FDMI_RPA_RSP : + oxid_pool->active_oxid_fdmi_rpa = oxid; +break ;default : oxid_pool->active_oxid_fabric_req = oxid;break ;@@ -372,6 +458,21 @@ static inline void fdls_schedule_fabric_oxid_free(struct fnic_iport_s iport->fabric_oxid_pool.active_oxid_fabric_req); } +static inline void fdls_schedule_fdmi_oxid_free (struct fnic_iport_s *iport) +{ +if (iport->fabric.fdmi_pending &FDLS_FDMI_PLOGI_PENDING ) +fdls_schedule_oxid_free (&iport->fdmi_oxid_pool.meta, + iport->fdmi_oxid_pool.active_oxid_fdmi_plogi); + +if (iport->fabric.fdmi_pending &FDLS_FDMI_REG_HBA_PENDING ) +fdls_schedule_oxid_free (&iport->fdmi_oxid_pool.meta, + iport->fdmi_oxid_pool.active_oxid_fdmi_rhba); + +if (iport->fabric.fdmi_pending &FDLS_FDMI_RPA_PENDING ) +fdls_schedule_oxid_free (&iport->fdmi_oxid_pool.meta, + iport->fdmi_oxid_pool.active_oxid_fdmi_rpa); +} +static inline void fdls_schedule_tgt_oxid_free (struct fnic_iport_s *iport,struct fnic_tgt_oxid_pool_s *oxid_pool,uint16_t oxid)@@ -406,6 +507,14 @@ static int fdls_is_oxid_in_fabric_range(uint16_t oxid) (oxid_unmasked <= FDLS_FABRIC_OXID_POOL_END)); } +static int fdls_is_oxid_in_fdmi_range (uint16_t oxid) +{ +uint16_t oxid_unmasked =FDLS_OXID_RSP_TYPE_UNMASKED (oxid); + +return ((oxid_unmasked >=FDLS_FDMI_OXID_POOL_BASE ) && + (oxid_unmasked <=FDLS_FDMI_OXID_POOL_END )); +} +void fdls_init_tgt_oxid_pool (struct fnic_iport_s *iport) {memset (&iport->plogi_oxid_pool,0 ,sizeof (iport->plogi_oxid_pool));@@ -671,6 +780,42 @@ static void fdls_send_fabric_abts(struct fnic_iport_s *iport) iport->fabric.timer_pending =1 ; } +static void fdls_send_fdmi_abts (struct fnic_iport_s *iport) +{ +uint8_t fcid[3 ]; +struct fc_frame_header fabric_abort = fc_std_fabric_abts; +struct fc_frame_header *fabric_abts = &fabric_abort; +struct fnic_fabric_oxid_pool_s *oxid_pool = &iport->fdmi_oxid_pool; +int fdmi_tov; +uint16_t oxid; + +hton24 (fcid,0XFFFFFA ); + +if (iport->fabric.fdmi_pending &FDLS_FDMI_PLOGI_PENDING ) { + oxid =htons (oxid_pool->active_oxid_fdmi_plogi); +FNIC_STD_SET_OX_ID (fabric_abts, oxid); +fnic_send_fcoe_frame (iport, fabric_abts, +sizeof (struct fc_frame_header )); + }else { +if (iport->fabric.fdmi_pending &FDLS_FDMI_REG_HBA_PENDING ) { + oxid =htons (oxid_pool->active_oxid_fdmi_rhba); +FNIC_STD_SET_OX_ID (fabric_abts, oxid); +fnic_send_fcoe_frame (iport, fabric_abts, +sizeof (struct fc_frame_header )); + } +if (iport->fabric.fdmi_pending &FDLS_FDMI_RPA_PENDING ) { + oxid =htons (oxid_pool->active_oxid_fdmi_rpa); +FNIC_STD_SET_OX_ID (fabric_abts, oxid); +fnic_send_fcoe_frame (iport, fabric_abts, +sizeof (struct fc_frame_header )); + } + } + + fdmi_tov = jiffies +msecs_to_jiffies (2 * iport->e_d_tov); +mod_timer (&iport->fabric.fdmi_timer,round_jiffies (fdmi_tov)); + iport->fabric.fdmi_pending |=FDLS_FDMI_ABORT_PENDING ; +} +static void fdls_send_fabric_flogi (struct fnic_iport_s *iport) {struct fc_std_flogi flogi;@@ -738,6 +883,47 @@ static void fdls_send_fabric_plogi(struct fnic_iport_s *iport)fdls_start_fabric_timer (iport,2 * iport->e_d_tov); }
drivers/scsi/fnic/fdls_disc.c static void fdls_send_fabric_plogi(struct fnic_iport_s *iport) · line 895
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+static void fdls_send_fdmi_plogi (struct fnic_iport_s *iport) +{ +struct fc_std_flogi plogi; +struct fc_frame_header *fchdr = &plogi.fchdr; +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +u64 fdmi_tov; +uint16_t oxid; + +memcpy (&plogi, &fnic_std_plogi_req,sizeof (plogi));
Memcpy again.
Quoted 40 lines
drivers/scsi/fnic/fdls_disc.c +33
-0+ + oxid =fdls_alloc_fabric_oxid (iport, &iport->fdmi_oxid_pool, +FNIC_FDMI_PLOGI_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fdmi plogi %p" , + iport); +return ; + } + +hton24 (fcid, iport->fcid); + +FNIC_STD_SET_S_ID (fchdr, fcid); +hton24 (fcid,0XFFFFFA ); +FNIC_STD_SET_D_ID (fchdr, fcid); +FNIC_STD_SET_OX_ID (fchdr,htons (oxid)); +FNIC_LOGI_SET_NPORT_NAME (&plogi.els, iport->wwpn); +FNIC_LOGI_SET_NODE_NAME (&plogi.els, iport->wwnn); +FNIC_LOGI_SET_RDF_SIZE (&plogi.els, iport->max_payload_size); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"fcid: 0x%x: FDLS send FDMI PLOGI with oxid:%x" , + iport->fcid, oxid); + +fnic_send_fcoe_frame (iport, &plogi,sizeof (struct fc_std_flogi )); + + fdmi_tov = jiffies +msecs_to_jiffies (2 * iport->e_d_tov); +mod_timer (&iport->fabric.fdmi_timer,round_jiffies (fdmi_tov)); + iport->fabric.fdmi_pending =FDLS_FDMI_PLOGI_PENDING ; +} +static void fdls_send_rpn_id (struct fnic_iport_s *iport) {struct fc_std_rpn_id rpn_id;@@ -1375,6 +1561,126 @@ struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport,return NULL ; } +static void fdls_fdmi_register_hba (struct fnic_iport_s *iport) +{
drivers/scsi/fnic/fdls_disc.c struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport, · line 1575
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+struct fc_std_fdmi_rhba fdmi_rhba; +uint8_t fcid[3 ]; +uint16_t len; +int err; +struct fnic *fnic = iport->fnic; +struct vnic_devcmd_fw_info *fw_info =NULL ; +uint16_t oxid; + +memcpy (&fdmi_rhba, &fnic_std_fdmi_rhba, +sizeof (struct fc_std_fdmi_rhba ));
And here.
Quoted 46 lines
drivers/scsi/fnic/fdls_disc.c +46
-0+ +hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&fdmi_rhba.fchdr), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fdmi_oxid_pool, +FNIC_FDMI_REG_HBA_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fdmi reg hba %p" , + iport); +return ; + } +FNIC_STD_SET_OX_ID (&fdmi_rhba.fchdr,htons (oxid)); + + fdmi_rhba.hba_identifier =get_unaligned_be64 (&iport->wwpn); + fdmi_rhba.port_name =get_unaligned_be64 (&iport->wwpn); + fdmi_rhba.node_name =get_unaligned_be64 (&iport->wwnn); + + err =vnic_dev_fw_info (fnic->vdev, &fw_info); +if (!err) { +snprintf (fdmi_rhba.serial_num,sizeof (fdmi_rhba.serial_num) -1 , +"%s" , fw_info->hw_serial_number); +snprintf (fdmi_rhba.hardware_ver, +sizeof (fdmi_rhba.hardware_ver) -1 ,"%s" , + fw_info->hw_version); +strscpy (fdmi_rhba.firmware_ver, fw_info->fw_version, +sizeof (fdmi_rhba.firmware_ver) -1 ); + + len =ARRAY_SIZE (fdmi_rhba.model); +if (fnic->subsys_desc_len >= len) + fnic->subsys_desc_len = len -1 ; +memcpy (&fdmi_rhba.model, fnic->subsys_desc, + fnic->subsys_desc_len); + fdmi_rhba.model[fnic->subsys_desc_len] =0x00 ; + } + +snprintf (fdmi_rhba.driver_ver,sizeof (fdmi_rhba.driver_ver) -1 ,"%s" , +DRV_VERSION ); +snprintf (fdmi_rhba.rom_ver,sizeof (fdmi_rhba.rom_ver) -1 ,"%s" ,"N/A" ); + +fnic_send_fcoe_frame (iport, &fdmi_rhba, +sizeof (struct fc_std_fdmi_rhba )); + iport->fabric.fdmi_pending |=FDLS_FDMI_REG_HBA_PENDING ; +} + +static void fdls_fdmi_register_pa (struct fnic_iport_s *iport)
drivers/scsi/fnic/fdls_disc.c struct fnic_tport_s *fnic_find_tport_by_wwpn(struct fnic_iport_s *iport, · line 1631
Quoted 10 lines
drivers/scsi/fnic/fdls_disc.c +10
-0+{ +struct fc_std_fdmi_rpa fdmi_rpa; + +uint8_t fcid[3 ]; +struct fnic *fnic = iport->fnic; +u32 port_speed_bm; +u32 port_speed =vnic_dev_port_speed (fnic->vdev); +uint16_t oxid; + +memcpy (&fdmi_rpa, &fnic_std_fdmi_rpa,sizeof (struct fc_std_fdmi_rpa ));
And here.
Quoted 330 lines
drivers/scsi/fnic/fdls_disc.c +214
-0+hton24 (fcid, iport->fcid); +FNIC_STD_SET_S_ID ((&fdmi_rpa.fchdr), fcid); + + oxid =fdls_alloc_fabric_oxid (iport, &iport->fdmi_oxid_pool, +FNIC_FDMI_RPA_RSP ); +if (oxid ==0xFFFF ) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Failed to allocate OXID to send fdmi rpa %p" , + iport); +return ; + } +FNIC_STD_SET_OX_ID (&fdmi_rpa.fchdr,htons (oxid)); + + fdmi_rpa.port_name =get_unaligned_be64 (&iport->wwpn); + +/* MDS does not support GIGE speed. +* Bit shift standard definitions from scsi_transport_fc.h to +* match FC spec. +*/ +switch (port_speed) { +case DCEM_PORTSPEED_10G : +case DCEM_PORTSPEED_20G : +/* There is no bit for 20G */ + port_speed_bm =FC_PORTSPEED_10GBIT <<PORT_SPEED_BIT_14 ; +break ; +case DCEM_PORTSPEED_25G : + port_speed_bm =FC_PORTSPEED_25GBIT <<PORT_SPEED_BIT_8 ; +break ; +case DCEM_PORTSPEED_40G : +case DCEM_PORTSPEED_4x10G: + port_speed_bm =FC_PORTSPEED_40GBIT <<PORT_SPEED_BIT_9 ; +break ; +case DCEM_PORTSPEED_100G : + port_speed_bm =FC_PORTSPEED_100GBIT <<PORT_SPEED_BIT_8 ; +break ; +default : + port_speed_bm =FC_PORTSPEED_1GBIT <<PORT_SPEED_BIT_15 ; +break ; + } + fdmi_rpa.supported_speed =htonl (port_speed_bm); + fdmi_rpa.current_speed =htonl (port_speed_bm); + fdmi_rpa.fc4_type[2 ] =1 ; +snprintf (fdmi_rpa.os_name,sizeof (fdmi_rpa.os_name) -1 ,"host%d" , + fnic->lport->host->host_no); +sprintf (fc_host_system_hostname (fnic->lport->host),"%s" ,utsname ()->nodename); +snprintf (fdmi_rpa.host_name,sizeof (fdmi_rpa.host_name) -1 ,"%s" , +fc_host_system_hostname (fnic->lport->host)); + +fnic_send_fcoe_frame (iport, &fdmi_rpa,sizeof (struct fc_std_fdmi_rpa )); + iport->fabric.fdmi_pending |=FDLS_FDMI_RPA_PENDING ; +} +void fdls_fabric_timer_callback (struct timer_list *t) {struct fnic_fdls_fabric_s *fabric =from_timer (fabric, t, retry_timer);@@ -1548,6 +1854,43 @@ void fdls_fabric_timer_callback(struct timer_list *t)spin_unlock_irqrestore (&fnic->fnic_lock, flags); } +void fdls_fdmi_timer_callback (struct timer_list *t) +{ +struct fnic_fdls_fabric_s *fabric =from_timer (fabric, t, fdmi_timer); +struct fnic_iport_s *iport = + container_of(fabric, struct fnic_iport_s, fabric); +struct fnic *fnic = iport->fnic; +unsigned long flags; + +spin_lock_irqsave (&fnic->fnic_lock, flags); + +if (!iport->fabric.fdmi_pending) { +/* timer expired after fdmi responses received. */ +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +return ; + } + +/* if not abort pending, send an abort */ +if (!(iport->fabric.fdmi_pending &FDLS_FDMI_ABORT_PENDING )) { +fdls_send_fdmi_abts (iport); +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +return ; + } + +/* Abort timed out */ +fdls_schedule_fdmi_oxid_free (iport); + + iport->fabric.fdmi_pending =0 ; +/* If max retries not exhaused, start over from fdmi plogi */ +if (iport->fabric.fdmi_retry <FDLS_FDMI_MAX_RETRY ) { + iport->fabric.fdmi_retry++; +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"retry fdmi timer %d" , iport->fabric.fdmi_retry); +fdls_send_fdmi_plogi (iport); + } +spin_unlock_irqrestore (&fnic->fnic_lock, flags); +} +static void fdls_send_delete_tport_msg (struct fnic_tport_s *tport) {struct fnic_iport_s *iport = (struct fnic_iport_s *) tport->iport;@@ -1697,6 +2040,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@@ -2784,6 +3136,109 @@ fdls_process_fabric_plogi_rsp(struct fnic_iport_s *iport, } } +static void fdls_process_fdmi_plogi_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +struct fc_std_flogi *plogi_rsp = (struct fc_std_flogi *)fchdr; +struct fc_std_els_rsp *els_rjt = (struct fc_std_els_rsp *)fchdr; +struct fnic *fnic = iport->fnic; +u64 fdmi_tov; + + iport->fabric.fdmi_pending &= ~FDLS_FDMI_PLOGI_PENDING ; +fdls_free_fabric_oxid (iport, &iport->fabric_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +if (ntoh24 (fchdr->fh_s_id) ==0XFFFFFA ) { +del_timer_sync (&iport->fabric.fdmi_timer); + iport->fabric.fdmi_pending =0 ; +switch (plogi_rsp->els.fl_cmd) { +case ELS_LS_ACC : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"FDLS process fdmi PLOGI response status: ELS_LS_ACC\n" ); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Sending fdmi registration for port 0x%x\n" , + iport->fcid); + +fdls_fdmi_register_hba (iport); +fdls_fdmi_register_pa (iport); + fdmi_tov = jiffies +msecs_to_jiffies (5000 ); +mod_timer (&iport->fabric.fdmi_timer, +round_jiffies (fdmi_tov)); +break ; +case ELS_LS_RJT : +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Fabric FDMI PLOGI returned ELS_LS_RJT reason: 0x%x" , + els_rjt->u.rej.er_reason); + +if (((els_rjt->u.rej.er_reason ==ELS_RJT_BUSY ) + || (els_rjt->u.rej.er_reason ==ELS_RJT_UNAB )) + && (iport->fabric.fdmi_retry <7 )) { + iport->fabric.fdmi_retry++; +fdls_send_fdmi_plogi (iport); + } +break ; +default : +break ; + } + } +} + +static void fdls_process_fdmi_reg_ack (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr, +int rsp_type) +{ +struct fnic *fnic = iport->fnic; + +if (!iport->fabric.fdmi_pending) { +FNIC_FCS_DBG (KERN_ERR , fnic->lport->host, fnic->fnic_num, +"Received FDMI ack while not waiting:%x\n" , +ntohs (FNIC_STD_GET_OX_ID (fchdr))); +return ; + } + +if (rsp_type ==FNIC_FDMI_REG_HBA_RSP ) + iport->fabric.fdmi_pending &= ~FDLS_FDMI_REG_HBA_PENDING ; +else + iport->fabric.fdmi_pending &= ~FDLS_FDMI_RPA_PENDING ; + +fdls_free_fabric_oxid (iport, &iport->fdmi_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); + +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"iport fcid: 0x%x: Received FDMI registration ack\n" , + iport->fcid); + +if (!iport->fabric.fdmi_pending) { +del_timer_sync (&iport->fabric.fdmi_timer); +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"iport fcid: 0x%x: Canceling FDMI timer\n" , + iport->fcid); + } +} + +static void fdls_process_fdmi_abts_rsp (struct fnic_iport_s *iport, +struct fc_frame_header *fchdr) +{ +uint32_t s_id; +struct fnic *fnic = iport->fnic; + + s_id =ntoh24 (FNIC_STD_GET_S_ID (fchdr)); + +if (!(s_id !=0xFFFFFA )) { +FNIC_FCS_DBG (KERN_INFO , fnic->lport->host, fnic->fnic_num, +"Received abts rsp with invalid SID: 0x%x. Dropping frame" , + s_id); +return ; + } + +del_timer_sync (&iport->fabric.fdmi_timer); + iport->fabric.fdmi_pending &= ~FDLS_FDMI_ABORT_PENDING ; + +fdls_free_fabric_oxid (iport, &iport->fdmi_oxid_pool, +ntohs (FNIC_STD_GET_OX_ID (fchdr))); +fdls_send_fdmi_plogi (iport); +} +static void fdls_process_fabric_abts_rsp (struct fnic_iport_s *iport,struct fc_frame_header *fchdr)@@ -3780,6 +4235,9 @@ fnic_fdls_validate_and_get_frame_type(struct fnic_iport_s *iport,break ;case FNIC_FABRIC_LOGO_RSP : +case FNIC_FDMI_PLOGI_RSP : +case FNIC_FDMI_REG_HBA_RSP : +case FNIC_FDMI_RPA_RSP :break ;default :/* Drop the Rx frame and log/stats it */ @@ -3822,6 +4280,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 ;@@ -3861,6 +4322,9 @@ void fnic_fdls_recv_frame(struct fnic_iport_s *iport, void *rx_frame,if (fdls_is_oxid_in_fabric_range (oxid) && (iport->fabric.flags &FNIC_FDLS_FABRIC_ABORT_ISSUED )) {fdls_process_fabric_abts_rsp (iport, fchdr); + }else if (fdls_is_oxid_in_fdmi_range (oxid) && + iport->fabric.fdmi_pending) { +fdls_process_fdmi_abts_rsp (iport, fchdr); }else {fdls_process_tgt_abts_rsp (iport, fchdr); }@@ -3890,6 +4354,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 +56
-0@@ -82,6 +82,72 @@/* Retry supported by rport (returned by PRLI service parameters) */ #define FNIC_FC_RP_FLAGS_RETRY 0x1 +/* Cisco vendor id */ +#define PCI_VENDOR_ID_CISCO 0x1137 +#define PCI_DEVICE_ID_CISCO_VIC_FC 0x0045/* fc vnic */ + +/* sereno pcie switch */ +#define PCI_DEVICE_ID_CISCO_SERENO 0x004e +#define PCI_DEVICE_ID_CISCO_CRUZ 0x007a/* Cruz */ +#define PCI_DEVICE_ID_CISCO_BODEGA 0x0131/* Bodega */ +#define PCI_DEVICE_ID_CISCO_BEVERLY 0x025f/* Beverly */ + +/* Sereno */ +#define PCI_SUBDEVICE_ID_CISCO_VASONA 0x004f/* vasona mezz */ +#define PCI_SUBDEVICE_ID_CISCO_COTATI 0x0084/* cotati mlom */ +#define PCI_SUBDEVICE_ID_CISCO_LEXINGTON 0x0085/* lexington pcie */ +#define PCI_SUBDEVICE_ID_CISCO_ICEHOUSE 0x00cd/* Icehouse */ +#define PCI_SUBDEVICE_ID_CISCO_KIRKWOODLAKE 0x00ce/* KirkwoodLake pcie */ +#define PCI_SUBDEVICE_ID_CISCO_SUSANVILLE 0x012e/* Susanville MLOM */ +#define PCI_SUBDEVICE_ID_CISCO_TORRANCE 0x0139/* Torrance MLOM */ + +/* Cruz */ +#define PCI_SUBDEVICE_ID_CISCO_CALISTOGA 0x012c/* Calistoga MLOM */ +#define PCI_SUBDEVICE_ID_CISCO_MOUNTAINVIEW 0x0137/* Cruz Mezz */ +/* Cruz MountTian SIOC */ +#define PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN 0x014b +#define PCI_SUBDEVICE_ID_CISCO_CLEARLAKE 0x014d/* ClearLake pcie */ +/* Cruz MountTian2 SIOC */ +#define PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN2 0x0157 +#define PCI_SUBDEVICE_ID_CISCO_CLAREMONT 0x015d/* Claremont MLOM */ + +/* Bodega */ +/* VIC 1457 PCIe mLOM */ +#define PCI_SUBDEVICE_ID_CISCO_BRADBURY 0x0218 +#define PCI_SUBDEVICE_ID_CISCO_BRENTWOOD 0x0217/* VIC 1455 PCIe */ +/* VIC 1487 PCIe mLOM */ +#define PCI_SUBDEVICE_ID_CISCO_BURLINGAME 0x021a +#define PCI_SUBDEVICE_ID_CISCO_BAYSIDE 0x0219/* VIC 1485 PCIe */ +/* VIC 1440 Mezz mLOM */ +#define PCI_SUBDEVICE_ID_CISCO_BAKERSFIELD 0x0215 +#define PCI_SUBDEVICE_ID_CISCO_BOONVILLE 0x0216/* VIC 1480 Mezz */ +#define PCI_SUBDEVICE_ID_CISCO_BENICIA 0x024a/* VIC 1495 */ +#define PCI_SUBDEVICE_ID_CISCO_BEAUMONT 0x024b/* VIC 1497 */ +#define PCI_SUBDEVICE_ID_CISCO_BRISBANE 0x02af/* VIC 1467 */ +#define PCI_SUBDEVICE_ID_CISCO_BENTON 0x02b0/* VIC 1477 */ +#define PCI_SUBDEVICE_ID_CISCO_TWIN_RIVER 0x02cf/* VIC 14425 */ +#define PCI_SUBDEVICE_ID_CISCO_TWIN_PEAK 0x02d0/* VIC 14825 */ + +/* Beverly */ +#define PCI_SUBDEVICE_ID_CISCO_BERN 0x02de/* VIC 15420 */ +#define PCI_SUBDEVICE_ID_CISCO_STOCKHOLM 0x02dd/* VIC 15428 */ +#define PCI_SUBDEVICE_ID_CISCO_KRAKOW 0x02dc/* VIC 15411 */ +#define PCI_SUBDEVICE_ID_CISCO_LUCERNE 0x02db/* VIC 15231 */ +#define PCI_SUBDEVICE_ID_CISCO_TURKU 0x02e8/* VIC 15238 */ +#define PCI_SUBDEVICE_ID_CISCO_TURKU_PLUS 0x02f3/* VIC 15237 */ +#define PCI_SUBDEVICE_ID_CISCO_ZURICH 0x02df/* VIC 15230 */ +#define PCI_SUBDEVICE_ID_CISCO_RIGA 0x02e0/* VIC 15427 */ +#define PCI_SUBDEVICE_ID_CISCO_GENEVA 0x02e1/* VIC 15422 */
drivers/scsi/fnic/fnic.h line 150
Quoted 10 lines
drivers/scsi/fnic/fnic.h +10
-0+#define PCI_SUBDEVICE_ID_CISCO_HELSINKI 0x02e4/* VIC 15235 */ +#define PCI_SUBDEVICE_ID_CISCO_GOTHENBURG 0x02f2/* VIC 15425 */ + +struct fnic_pcie_device { +u32 device; +u8 *desc; +u32 subsystem_device; +u8 *subsys_desc; +}; +
Not sure what this has to do with FDMI ... maybe move to a separate patch?
Quoted 213 lines
drivers/scsi/fnic/fnic.h +6
-0/* * fnic private data per SCSI command. * These fields are locked by the hashed io_req_lock. @@ -134,6 +200,7 @@ static inline u64 fnic_flags_and_state(struct scsi_cmnd *cmd)#define fnic_clear_state_flags (fnicp, st_flags) \ __fnic_set_state_flags(fnicp, st_flags, 1) +extern unsigned int fnic_fdmi_support;extern unsigned int fnic_log_level;extern unsigned int io_completions;extern struct workqueue_struct *fnic_event_queue;@@ -336,6 +403,9 @@ struct fnic {struct work_struct tport_work;struct list_head tport_event_list; +char subsys_desc[14 ]; +int subsys_desc_len; +/*** FIP related data members -- start ***/ void (*set_vlan)(struct fnic *,u16 vlan);struct work_struct fip_frame_work;@@ -433,5 +503,7 @@ fnic_chk_state_flags_locked(struct fnic *fnic, unsigned long st_flags)void __fnic_set_state_flags (struct fnic *,unsigned long ,unsigned long );void fnic_dump_fchost_stats (struct Scsi_Host *,struct fc_host_statistics *);void fnic_free_txq (struct list_head *head); +int fnic_get_desc_by_devid (struct pci_dev *pdev,char **desc, +char **subsys_desc);#endif /* _FNIC_H_ */ drivers/scsi/fnic/fnic_main.c +25
-0@@ -62,6 +62,9 @@ unsigned int fnic_log_level;module_param (fnic_log_level, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (fnic_log_level,"bit mask of fnic logging levels" ); +unsigned int fnic_fdmi_support =1 ; +module_param (fnic_fdmi_support, int,0644 ); +MODULE_PARM_DESC (fnic_fdmi_support,"FDMI support" );unsigned int io_completions =FNIC_DFLT_IO_COMPLETIONS ;module_param (io_completions, int,S_IRUGO |S_IWUSR );@@ -607,6 +610,8 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)int i;unsigned long flags;int hwq; +char *desc, *subsys_desc; +int len;/* * Allocate SCSI Host and set up association between host, @@ -640,6 +645,23 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) fnic->fnic_num = fnic_id;fnic_stats_debugfs_init (fnic); +/* Find model name from PCIe subsys ID */ +if (fnic_get_desc_by_devid (pdev, &desc, &subsys_desc) ==0 ) { +dev_info (&fnic->pdev->dev,"Model: %s\n" , subsys_desc); + +/* Update FDMI model */ + fnic->subsys_desc_len =strlen (subsys_desc); + len =ARRAY_SIZE (fnic->subsys_desc); +if (fnic->subsys_desc_len > len) + fnic->subsys_desc_len = len; +memcpy (fnic->subsys_desc, subsys_desc, fnic->subsys_desc_len); +dev_info (&fnic->pdev->dev,"FDMI Model: %s\n" , fnic->subsys_desc); + }else { + fnic->subsys_desc_len =0 ; +dev_info (&fnic->pdev->dev,"Model: %s subsys_id: 0x%04x\n" ,"Unknown" , + pdev->subsystem_device); + } + err =pci_enable_device (pdev);if (err) {dev_err (&fnic->pdev->dev,"Cannot enable PCI device, aborting.\n" );@@ -1014,6 +1036,9 @@ static void fnic_remove(struct pci_dev *pdev)fnic_fcoe_evlist_free (fnic); } +if ((fnic_fdmi_support ==1 ) && (fnic->iport.fabric.fdmi_pending >0 )) +del_timer_sync (&fnic->iport.fabric.fdmi_timer); +/* * Log off the fabric. This stops all remote ports, dns port, * logs off the fabric. This flushes all rport, disc, lport work drivers/scsi/fnic/fnic_pci_subsys_devid.c new file +121
-0@@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2008 Cisco Systems, Inc. All rights reserved. +* Copyright 2007 Nuova Systems, Inc. All rights reserved. +*/ + +#include <linux/module.h> +#include <linux/mempool.h> +#include <linux/string.h> +#include <linux/slab.h> +#include <linux/errno.h> +#include <linux/init.h> +#include <linux/pci.h> +#include <linux/interrupt.h> +#include <linux/irq.h> +#include <linux/spinlock.h> +#include <linux/workqueue.h> +#include <linux/kthread.h> +#include <linux/if_ether.h> +#include "fnic.h" + +static struct fnic_pcie_device fnic_pcie_device_table[] = { + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" ,PCI_SUBDEVICE_ID_CISCO_VASONA , +"VIC 1280" }, + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" ,PCI_SUBDEVICE_ID_CISCO_COTATI , +"VIC 1240" }, + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" , +PCI_SUBDEVICE_ID_CISCO_LEXINGTON ,"VIC 1225" }, + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" ,PCI_SUBDEVICE_ID_CISCO_ICEHOUSE , +"VIC 1285" }, + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" , +PCI_SUBDEVICE_ID_CISCO_KIRKWOODLAKE ,"VIC 1225T" }, + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" , +PCI_SUBDEVICE_ID_CISCO_SUSANVILLE ,"VIC 1227" }, + {PCI_DEVICE_ID_CISCO_SERENO ,"Sereno" ,PCI_SUBDEVICE_ID_CISCO_TORRANCE , +"VIC 1227T" }, + + {PCI_DEVICE_ID_CISCO_CRUZ ,"Cruz" ,PCI_SUBDEVICE_ID_CISCO_CALISTOGA , +"VIC 1340" }, + {PCI_DEVICE_ID_CISCO_CRUZ ,"Cruz" ,PCI_SUBDEVICE_ID_CISCO_MOUNTAINVIEW , +"VIC 1380" }, + {PCI_DEVICE_ID_CISCO_CRUZ ,"Cruz" ,PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN , +"C3260-SIOC" }, + {PCI_DEVICE_ID_CISCO_CRUZ ,"Cruz" ,PCI_SUBDEVICE_ID_CISCO_CLEARLAKE , +"VIC 1385" }, + {PCI_DEVICE_ID_CISCO_CRUZ ,"Cruz" ,PCI_SUBDEVICE_ID_CISCO_MOUNTTIAN2 , +"C3260-SIOC" }, + {PCI_DEVICE_ID_CISCO_CRUZ ,"Cruz" ,PCI_SUBDEVICE_ID_CISCO_CLAREMONT , +"VIC 1387" }, + + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" ,PCI_SUBDEVICE_ID_CISCO_BRADBURY , +"VIC 1457" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" , +PCI_SUBDEVICE_ID_CISCO_BRENTWOOD ,"VIC 1455" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" , +PCI_SUBDEVICE_ID_CISCO_BURLINGAME ,"VIC 1487" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" ,PCI_SUBDEVICE_ID_CISCO_BAYSIDE , +"VIC 1485" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" , +PCI_SUBDEVICE_ID_CISCO_BAKERSFIELD ,"VIC 1440" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" , +PCI_SUBDEVICE_ID_CISCO_BOONVILLE ,"VIC 1480" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" ,PCI_SUBDEVICE_ID_CISCO_BENICIA , +"VIC 1495" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" ,PCI_SUBDEVICE_ID_CISCO_BEAUMONT , +"VIC 1497" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" ,PCI_SUBDEVICE_ID_CISCO_BRISBANE , +"VIC 1467" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" ,PCI_SUBDEVICE_ID_CISCO_BENTON , +"VIC 1477" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" , +PCI_SUBDEVICE_ID_CISCO_TWIN_RIVER ,"VIC 14425" }, + {PCI_DEVICE_ID_CISCO_BODEGA ,"Bodega" , +PCI_SUBDEVICE_ID_CISCO_TWIN_PEAK ,"VIC 14825" }, + + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" ,PCI_SUBDEVICE_ID_CISCO_BERN , +"VIC 15420" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" , +PCI_SUBDEVICE_ID_CISCO_STOCKHOLM ,"VIC 15428" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" ,PCI_SUBDEVICE_ID_CISCO_KRAKOW , +"VIC 15411" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" , +PCI_SUBDEVICE_ID_CISCO_LUCERNE ,"VIC 15231" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" ,PCI_SUBDEVICE_ID_CISCO_TURKU , +"VIC 15238" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" ,PCI_SUBDEVICE_ID_CISCO_GENEVA , +"VIC 15422" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" , +PCI_SUBDEVICE_ID_CISCO_HELSINKI ,"VIC 15235" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" , +PCI_SUBDEVICE_ID_CISCO_GOTHENBURG ,"VIC 15425" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" , +PCI_SUBDEVICE_ID_CISCO_TURKU_PLUS ,"VIC 15237" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" ,PCI_SUBDEVICE_ID_CISCO_ZURICH , +"VIC 15230" }, + {PCI_DEVICE_ID_CISCO_BEVERLY ,"Beverly" ,PCI_SUBDEVICE_ID_CISCO_RIGA , +"VIC 15427" }, + + {0 ,} +}; + +int fnic_get_desc_by_devid (struct pci_dev *pdev,char **desc, +char **subsys_desc) +{ +unsigned short device =PCI_DEVICE_ID_CISCO_VIC_FC ; +int max =ARRAY_SIZE (fnic_pcie_device_table); +struct fnic_pcie_device *t = fnic_pcie_device_table; +int index =0 ; + +if (pdev->device != device) +return 1 ; + +while (t->device !=0 ) { +if (memcmp + ((char *) &pdev->subsystem_device, + (char *) &t->subsystem_device,sizeof (short )) ==0 ) +break ; + t++; + index++; + } +
drivers/scsi/fnic/fnic_pci_subsys_devid.c line 131
Quoted 10 lines
drivers/scsi/fnic/fnic_pci_subsys_devid.c new file +10
-0+if (index >= max -1 ) { + *desc =NULL ; + *subsys_desc =NULL ; +return 1 ; + } + + *desc = fnic_pcie_device_table[index].desc; + *subsys_desc = fnic_pcie_device_table[index].subsys_desc; +return 0 ; +}
Same here. Maybe move the PCI registration stuff to a different patch.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich