Incorporated Joe's review comments. Currently lport and rport event callbacks are part of rport_ops and are not exported to the LLDDs. This patch enables LLDDs to provide a driver specific callback routine which can be called when the remote port is ready.
Signed-off-by: Bhanu Gollapudi <[email protected]> --- drivers/scsi/libfc/fc_lport.c | 8 +++----- drivers/scsi/libfc/fc_rport.c | 16 +++++++++------- include/scsi/libfc.h | 31 +++++++++++++++++++++---------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c index 97e8a35..5f368bb 100644 --- a/drivers/scsi/libfc/fc_lport.c +++ b/drivers/scsi/libfc/fc_lport.c @@ -1227,10 +1227,6 @@ static void fc_lport_enter_ns(struct fc_lport *lport, enum fc_lport_state state) fc_lport_error(lport, fp); } -static struct fc_rport_operations fc_lport_rport_ops = { - .event_callback = fc_lport_rport_callback, -}; - /** * fc_rport_enter_dns() - Create a fc_rport for the name server * @lport: The local port requesting a remote port for the name server @@ -1253,7 +1249,6 @@ static void fc_lport_enter_dns(struct fc_lport *lport) if (!rdata) goto err; - rdata->ops = &fc_lport_rport_ops; lport->tt.rport_login(rdata); return; @@ -1534,6 +1529,9 @@ int fc_lport_init(struct fc_lport *lport) if (!lport->tt.lport_reset) lport->tt.lport_reset = fc_lport_reset; + if (!lport->tt.lport_event_callback) + lport->tt.lport_event_callback = fc_lport_rport_callback; + fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; fc_host_node_name(lport->host) = lport->wwnn; fc_host_port_name(lport->host) = lport->wwpn; diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c index c6a15e3..5e4d3e7 100644 --- a/drivers/scsi/libfc/fc_rport.c +++ b/drivers/scsi/libfc/fc_rport.c @@ -145,8 +145,12 @@ static struct fc_rport_priv *fc_rport_create(struct fc_lport *lport, rdata->maxframe_size = FC_MIN_MAX_PAYLOAD; INIT_DELAYED_WORK(&rdata->retry_work, fc_rport_timeout); INIT_WORK(&rdata->event_work, fc_rport_work); - if (port_id != FC_FID_DIR_SERV) + if (port_id != FC_FID_DIR_SERV) { + rdata->event_callback = lport->tt.rport_event_callback; list_add(&rdata->peers, &lport->disc.rports); + } else { + rdata->event_callback = lport->tt.lport_event_callback; + } return rdata; } @@ -242,13 +246,11 @@ static void fc_rport_work(struct work_struct *work) struct fc_rport_libfc_priv *rpriv; enum fc_rport_event event; struct fc_lport *lport = rdata->local_port; - struct fc_rport_operations *rport_ops; struct fc_rport_identifiers ids; struct fc_rport *rport; mutex_lock(&rdata->rp_mutex); event = rdata->event; - rport_ops = rdata->ops; rport = rdata->rport; FC_RPORT_DBG(rdata, "work event %u\n", event); @@ -283,9 +285,9 @@ static void fc_rport_work(struct work_struct *work) rpriv->r_a_tov = rdata->r_a_tov; mutex_unlock(&rdata->rp_mutex); - if (rport_ops && rport_ops->event_callback) { + if (rdata->event_callback) { FC_RPORT_DBG(rdata, "callback ev %d\n", event); - rport_ops->event_callback(lport, rdata, event); + rdata->event_callback(lport, rdata, event); } kref_put(&rdata->kref, lport->tt.rport_destroy); break; @@ -302,9 +304,9 @@ static void fc_rport_work(struct work_struct *work) mutex_unlock(&lport->disc.disc_mutex); } - if (rport_ops && rport_ops->event_callback) { + if (rdata->event_callback) { FC_RPORT_DBG(rdata, "callback ev %d\n", event); - rport_ops->event_callback(lport, rdata, event); + rdata->event_callback(lport, rdata, event); } cancel_delayed_work_sync(&rdata->retry_work); diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h index 0889c0e..1445bdc 100644 --- a/include/scsi/libfc.h +++ b/include/scsi/libfc.h @@ -148,15 +148,6 @@ enum fc_rport_event { struct fc_rport_priv; /** - * struct fc_rport_operations - Operations for a remote port - * @event_callback: Function to be called for remote port events - */ -struct fc_rport_operations { - void (*event_callback)(struct fc_lport *, struct fc_rport_priv *, - enum fc_rport_event); -}; - -/** * struct fc_rport_libfc_priv - libfc internal information about a remote port * @local_port: The associated local port * @rp_state: Indicates READY for I/O or DELETE when blocked @@ -209,10 +200,12 @@ struct fc_rport_priv { struct mutex rp_mutex; struct delayed_work retry_work; enum fc_rport_event event; - struct fc_rport_operations *ops; struct list_head peers; struct work_struct event_work; u32 supported_classes; + void (*event_callback)(struct fc_lport *, + struct fc_rport_priv *, + enum fc_rport_event); }; /** @@ -585,6 +578,15 @@ struct libfc_function_template { int (*lport_reset)(struct fc_lport *); /* + * lport callback routine after the remote port is logged in + * + * STATUS: OPTIONAL + */ + void (*lport_event_callback)(struct fc_lport *, + struct fc_rport_priv *, + enum fc_rport_event); + + /* * Create a remote port with a given port ID * * STATUS: OPTIONAL @@ -634,6 +636,15 @@ struct libfc_function_template { void (*rport_destroy)(struct kref *); /* + * Callback routine after the remote port is logged in + * + * STATUS: OPTIONAL + */ + void (*rport_event_callback)(struct fc_lport *, + struct fc_rport_priv *, + enum fc_rport_event); + + /* * Send a fcp cmd from fsp pkt. * Called with the SCSI host lock unlocked and irqs disabled. * -- 1.5.6.5 _______________________________________________ devel mailing list [email protected] http://www.open-fcoe.org/mailman/listinfo/devel
