From 1f6ff364ceda516f88351a8ab640e656beed0b26 Mon Sep 17 00:00:00 2001 From: Abhijeet Joglekar Date: Fri, 27 Feb 2009 10:54:35 -0800 Subject: [SCSI] libfc: Pass lport in exch_mgr_reset fc_exch_mgr structure is private to fc_exch.c. To export exch_mgr_reset to transport, transport needs access to the exch manager. Change exch_mgr_reset to use lport param which is the shared structure between libFC and transport. Alternatively, fc_exch_mgr definition can be moved to libfc.h so that lport can be accessed from mp*. Signed-off-by: Abhijeet Joglekar Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/scsi/libfc.h') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 9f2876397dd..042f4ade73d 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -472,7 +472,7 @@ struct libfc_function_template { * If s_id is non-zero, reset only exchanges originating from that FID. * If d_id is non-zero, reset only exchanges sending to that FID. */ - void (*exch_mgr_reset)(struct fc_exch_mgr *, + void (*exch_mgr_reset)(struct fc_lport *, u32 s_id, u32 d_id); void (*rport_flush_queue)(void); @@ -916,7 +916,7 @@ struct fc_seq *fc_seq_start_next(struct fc_seq *sp); * If s_id is non-zero, reset only exchanges originating from that FID. * If d_id is non-zero, reset only exchanges sending to that FID. */ -void fc_exch_mgr_reset(struct fc_exch_mgr *, u32 s_id, u32 d_id); +void fc_exch_mgr_reset(struct fc_lport *, u32 s_id, u32 d_id); /* * Functions for fc_functions_template -- cgit v1.2.3 From bc0e17f691085315ae9303eb5b0883fe16dfe6b1 Mon Sep 17 00:00:00 2001 From: Vasu Dev Date: Fri, 27 Feb 2009 10:54:57 -0800 Subject: [SCSI] libfc, fcoe: fixed locking issues with lport->lp_mutex around lport->link_status The fcoe_xmit could call fc_pause in case the pending skb queue len is larger than FCOE_MAX_QUEUE_DEPTH, the fc_pause was trying to grab lport->lp_muex to change lport->link_status and that had these issues :- 1. The fcoe_xmit was getting called with bh disabled, thus causing "BUG: scheduling while atomic" when grabbing lport->lp_muex with bh disabled. 2. fc_linkup and fc_linkdown function calls lport_enter function with lport->lp_mutex held and these enter function in turn calls fcoe_xmit to send lport related FC frame, e.g. fc_linkup => fc_lport_enter_flogi to send flogi req. In this case grabbing the same lport->lp_mutex again in fc_puase from fcoe_xmit would cause deadlock. The lport->lp_mutex was used for setting FC_PAUSE in fcoe_xmit path but FC_PAUSE bit was not used anywhere beside just setting and clear this bit in lport->link_status, instead used a separate field qfull in fc_lport to eliminate need for lport->lp_mutex to track pending queue full condition and in turn avoid above described two locking issues. Also added check for lp->qfull in fc_fcp_lport_queue_ready to trigger SCSI_MLQUEUE_HOST_BUSY when lp->qfull is set to prevent more scsi-ml cmds while lp->qfull is set. This patch eliminated FC_LINK_UP and FC_PAUSE and instead used dedicated fields in fc_lport for this, this simplified all related conditional code. Also removed fc_pause and fc_unpause functions and instead used newly added lport->qfull directly in fcoe. Signed-off-by: Vasu Dev Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'include/scsi/libfc.h') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 042f4ade73d..b9e6c1cd891 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -68,9 +68,6 @@ /* * FC HBA status */ -#define FC_PAUSE (1 << 1) -#define FC_LINK_UP (1 << 0) - enum fc_lport_state { LPORT_ST_NONE = 0, LPORT_ST_FLOGI, @@ -603,7 +600,8 @@ struct fc_lport { /* Operational Information */ struct libfc_function_template tt; - u16 link_status; + u8 link_up; + u8 qfull; enum fc_lport_state state; unsigned long boot_time; @@ -703,12 +701,6 @@ void fc_linkup(struct fc_lport *); */ void fc_linkdown(struct fc_lport *); -/* - * Pause and unpause traffic. - */ -void fc_pause(struct fc_lport *); -void fc_unpause(struct fc_lport *); - /* * Configure the local port. */ -- cgit v1.2.3 From 5101ff99f59aefb72e0c96e82aa32048ac9f8425 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Fri, 27 Feb 2009 10:55:18 -0800 Subject: [SCSI] libfc: Don't violate transport template for rogue port creation Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/scsi/libfc.h') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index b9e6c1cd891..37df48e13b9 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -489,6 +489,11 @@ struct libfc_function_template { * Remote Port interfaces */ + /* + * Create a remote port + */ + struct fc_rport *(*rport_create)(struct fc_disc_port *); + /* * Initiates the RP state machine. It is called from the LP module. * This function will issue the following commands to the N_Port -- cgit v1.2.3 From 0ae4d4ae47d2ccbcad813b0d6d8fe12590c7d648 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Fri, 27 Feb 2009 10:55:39 -0800 Subject: [SCSI] libfc: Cleanup libfc_function_template comments Made the comments more like the comments for struct scsi_host_template. Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 107 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 41 deletions(-) (limited to 'include/scsi/libfc.h') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 37df48e13b9..282829cdf35 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -336,31 +336,17 @@ struct fc_exch { struct libfc_function_template { - /** - * Mandatory Fields - * - * These handlers must be implemented by the LLD. - */ - /* * Interface to send a FC frame - */ - int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp); - - /** - * Optional Fields * - * The LLD may choose to implement any of the following handlers. - * If LLD doesn't specify hander and leaves its pointer NULL then - * the default libfc function will be used for that handler. - */ - - /** - * ELS/CT interfaces + * STATUS: REQUIRED */ + int (*frame_send)(struct fc_lport *lp, struct fc_frame *fp); /* - * elsct_send - sends ELS/CT frame + * Interface to send ELS/CT frames + * + * STATUS: OPTIONAL */ struct fc_seq *(*elsct_send)(struct fc_lport *lport, struct fc_rport *rport, @@ -370,9 +356,6 @@ struct libfc_function_template { struct fc_frame *fp, void *arg), void *arg, u32 timer_msec); - /** - * Exhance Manager interfaces - */ /* * Send the FC frame payload using a new exchange and sequence. @@ -404,6 +387,8 @@ struct libfc_function_template { * timer_msec argument is specified. The timer is canceled when * it fires or when the exchange is done. The exchange timeout handler * is registered by EM layer. + * + * STATUS: OPTIONAL */ struct fc_seq *(*exch_seq_send)(struct fc_lport *lp, struct fc_frame *fp, @@ -415,14 +400,18 @@ struct libfc_function_template { void *arg, unsigned int timer_msec); /* - * send a frame using existing sequence and exchange. + * Send a frame using an existing sequence and exchange. + * + * STATUS: OPTIONAL */ int (*seq_send)(struct fc_lport *lp, struct fc_seq *sp, struct fc_frame *fp); /* - * Send ELS response using mainly infomation - * in exchange and sequence in EM layer. + * Send an ELS response using infomation from a previous + * exchange and sequence. + * + * STATUS: OPTIONAL */ void (*seq_els_rsp_send)(struct fc_seq *sp, enum fc_els_cmd els_cmd, struct fc_seq_els_data *els_data); @@ -434,6 +423,8 @@ struct libfc_function_template { * A timer_msec can be specified for abort timeout, if non-zero * timer_msec value is specified then exchange resp handler * will be called with timeout error if no response to abort. + * + * STATUS: OPTIONAL */ int (*seq_exch_abort)(const struct fc_seq *req_sp, unsigned int timer_msec); @@ -441,6 +432,8 @@ struct libfc_function_template { /* * Indicate that an exchange/sequence tuple is complete and the memory * allocated for the related objects may be freed. + * + * STATUS: OPTIONAL */ void (*exch_done)(struct fc_seq *sp); @@ -448,6 +441,8 @@ struct libfc_function_template { * Assigns a EM and a free XID for an new exchange and then * allocates a new exchange and sequence pair. * The fp can be used to determine free XID. + * + * STATUS: OPTIONAL */ struct fc_exch *(*exch_get)(struct fc_lport *lp, struct fc_frame *fp); @@ -455,12 +450,16 @@ struct libfc_function_template { * Release previously assigned XID by exch_get API. * The LLD may implement this if XID is assigned by LLD * in exch_get(). + * + * STATUS: OPTIONAL */ void (*exch_put)(struct fc_lport *lp, struct fc_exch_mgr *mp, u16 ex_id); /* * Start a new sequence on the same exchange/sequence tuple. + * + * STATUS: OPTIONAL */ struct fc_seq *(*seq_start_next)(struct fc_seq *sp); @@ -468,26 +467,33 @@ struct libfc_function_template { * Reset an exchange manager, completing all sequences and exchanges. * If s_id is non-zero, reset only exchanges originating from that FID. * If d_id is non-zero, reset only exchanges sending to that FID. + * + * STATUS: OPTIONAL */ void (*exch_mgr_reset)(struct fc_lport *, u32 s_id, u32 d_id); - void (*rport_flush_queue)(void); - /** - * Local Port interfaces + /* + * Flush the rport work queue. Generally used before shutdown. + * + * STATUS: OPTIONAL */ + void (*rport_flush_queue)(void); /* - * Receive a frame to a local port. + * Receive a frame for a local port. + * + * STATUS: OPTIONAL */ void (*lport_recv)(struct fc_lport *lp, struct fc_seq *sp, struct fc_frame *fp); - int (*lport_reset)(struct fc_lport *); - - /** - * Remote Port interfaces + /* + * Reset the local port. + * + * STATUS: OPTIONAL */ + int (*lport_reset)(struct fc_lport *); /* * Create a remote port @@ -502,26 +508,33 @@ struct libfc_function_template { * - PLOGI * - PRLI * - RTV + * + * STATUS: OPTIONAL */ int (*rport_login)(struct fc_rport *rport); /* * Logoff, and remove the rport from the transport if * it had been added. This will send a LOGO to the target. + * + * STATUS: OPTIONAL */ int (*rport_logoff)(struct fc_rport *rport); /* * Recieve a request from a remote port. + * + * STATUS: OPTIONAL */ void (*rport_recv_req)(struct fc_seq *, struct fc_frame *, struct fc_rport *); - struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32); - - /** - * FCP interfaces + /* + * lookup an rport by it's port ID. + * + * STATUS: OPTIONAL */ + struct fc_rport *(*rport_lookup)(const struct fc_lport *, u32); /* * Send a fcp cmd from fsp pkt. @@ -529,30 +542,38 @@ struct libfc_function_template { * * The resp handler is called when FCP_RSP received. * + * STATUS: OPTIONAL */ int (*fcp_cmd_send)(struct fc_lport *lp, struct fc_fcp_pkt *fsp, void (*resp)(struct fc_seq *, struct fc_frame *fp, void *arg)); /* - * Used at least durring linkdown and reset + * Cleanup the FCP layer, used durring link down and reset + * + * STATUS: OPTIONAL */ void (*fcp_cleanup)(struct fc_lport *lp); /* * Abort all I/O on a local port + * + * STATUS: OPTIONAL */ void (*fcp_abort_io)(struct fc_lport *lp); - /** - * Discovery interfaces + /* + * Receive a request for the discovery layer. + * + * STATUS: OPTIONAL */ - void (*disc_recv_req)(struct fc_seq *, struct fc_frame *, struct fc_lport *); /* * Start discovery for a local port. + * + * STATUS: OPTIONAL */ void (*disc_start)(void (*disc_callback)(struct fc_lport *, enum fc_disc_event), @@ -561,6 +582,8 @@ struct libfc_function_template { /* * Stop discovery for a given lport. This will remove * all discovered rports + * + * STATUS: OPTIONAL */ void (*disc_stop) (struct fc_lport *); @@ -568,6 +591,8 @@ struct libfc_function_template { * Stop discovery for a given lport. This will block * until all discovered rports are deleted from the * FC transport class + * + * STATUS: OPTIONAL */ void (*disc_stop_final) (struct fc_lport *); }; -- cgit v1.2.3 From 34f42a070fc98f5dc07e9fa2338b7b8d1dc347eb Mon Sep 17 00:00:00 2001 From: Robert Love Date: Fri, 27 Feb 2009 10:55:45 -0800 Subject: [SCSI] libfc, fcoe: Fix kerneldoc comments 1) Added '()' for function names in kerneldoc comments 2) Changed comment bookends from '**/' to '*/'. The comment on the the mailing list was that '**/' "is consistently unconventional. Not wrong, just odd." The Documentation/kernel-doc-nano-HOWTO.txt states that kerneldoc comment blocks should end with '**/' but most (if not all) instance I found under drivers/scsi/ were only using the '*/' so I converted to that style. 3) Removed incorrect linebreaks in kerneldoc comments where found 4) Removed a few unnecessary blank comment lines in kerneldoc comment blocks Signed-off-by: Robert Love Signed-off-by: James Bottomley --- include/scsi/libfc.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include/scsi/libfc.h') diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 282829cdf35..a2e126b86e3 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -665,7 +665,7 @@ struct fc_lport { struct delayed_work disc_work; }; -/** +/* * FC_LPORT HELPER FUNCTIONS *****************************/ static inline void *lport_priv(const struct fc_lport *lp) @@ -697,7 +697,7 @@ static inline void fc_lport_state_enter(struct fc_lport *lp, } -/** +/* * LOCAL PORT LAYER *****************************/ int fc_lport_init(struct fc_lport *lp); @@ -747,19 +747,19 @@ int fc_lport_reset(struct fc_lport *); int fc_set_mfs(struct fc_lport *lp, u32 mfs); -/** +/* * REMOTE PORT LAYER *****************************/ int fc_rport_init(struct fc_lport *lp); void fc_rport_terminate_io(struct fc_rport *rp); -/** +/* * DISCOVERY LAYER *****************************/ int fc_disc_init(struct fc_lport *lp); -/** +/* * SCSI LAYER *****************************/ /* @@ -820,7 +820,7 @@ int fc_change_queue_type(struct scsi_device *sdev, int tag_type); */ void fc_fcp_destroy(struct fc_lport *); -/** +/* * ELS/CT interface *****************************/ /* @@ -829,7 +829,7 @@ void fc_fcp_destroy(struct fc_lport *); int fc_elsct_init(struct fc_lport *lp); -/** +/* * EXCHANGE MANAGER LAYER *****************************/ /* -- cgit v1.2.3