Patchwork [Open-FCoE,1/3] libfc, fcoe, bnx2fc: Always use fcoe_disc_init for discovery layer initialization

login
register
mail settings
Submitter Robert Love
Date March 19, 2013, 6:09 p.m.
Message ID <20130319180949.24759.98165.stgit@fritz>
Download mbox | patch
Permalink /patch/13/
State Accepted
Headers show

Comments

Robert Love - March 19, 2013, 6:09 p.m.
Currently libfcoe is doing some libfc discovery layer initialization outside of
libfc. This patch moves this code into libfc and sets up a split in discovery
(one time) initialization code and (re-configurable) settings that will come in
the next patch.

Signed-off-by: Robert Love <robert.w.love@intel.com>
Tested-by: Jack Morgan <jack.morgan@intel.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c |    2 +-
 drivers/scsi/fcoe/fcoe_ctlr.c     |   11 ++++++-----
 drivers/scsi/libfc/fc_disc.c      |    5 +++--
 include/scsi/libfc.h              |    2 +-
 4 files changed, 11 insertions(+), 9 deletions(-)
Bhanu Prakash Gollapudi - March 22, 2013, 2:56 a.m.
On 03/19/2013 11:09 AM, Robert Love wrote:
> Currently libfcoe is doing some libfc discovery layer initialization outside of
> libfc. This patch moves this code into libfc and sets up a split in discovery
> (one time) initialization code and (re-configurable) settings that will come in
> the next patch.
>
> Signed-off-by: Robert Love <robert.w.love@intel.com>
> Tested-by: Jack Morgan <jack.morgan@intel.com>
> ---
>   drivers/scsi/bnx2fc/bnx2fc_fcoe.c |    2 +-
>   drivers/scsi/fcoe/fcoe_ctlr.c     |   11 ++++++-----
>   drivers/scsi/libfc/fc_disc.c      |    5 +++--
>   include/scsi/libfc.h              |    2 +-
>   4 files changed, 11 insertions(+), 9 deletions(-)

Changes in this patch set look good to me.

Reviewed-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>

However, while trying out new fcoemon changes, I ran into an issue where 
fcm_bus_create() is unable to find ctlr. fcoe_find_ctlr() fails to get a 
ctlr, although I find it in /sys/bus/fcoe/devices directory.  I'll debug 
it further to see whats going on.

But that issue is independent of these changes.

thanks,
Bhanu

>
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index 4d5c721..0470cb5 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -932,7 +932,7 @@ static int bnx2fc_libfc_config(struct fc_lport *lport)
>   	fc_elsct_init(lport);
>   	fc_exch_init(lport);
>   	fc_rport_init(lport);
> -	fc_disc_init(lport);
> +	fc_disc_init(lport, lport);
>   	return 0;
>   }
>   
> diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
> index 9732168..18600b7 100644
> --- a/drivers/scsi/fcoe/fcoe_ctlr.c
> +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
> @@ -2821,6 +2821,8 @@ unlock:
>   int fcoe_libfc_config(struct fc_lport *lport, struct fcoe_ctlr *fip,
>   		      const struct libfc_function_template *tt, int init_fcp)
>   {
> +	void *priv = lport;
> +
>   	/* Set the function pointers set by the LLDD */
>   	memcpy(&lport->tt, tt, sizeof(*tt));
>   	if (init_fcp && fc_fcp_init(lport))
> @@ -2837,12 +2839,11 @@ int fcoe_libfc_config(struct fc_lport *lport, struct fcoe_ctlr *fip,
>   		lport->tt.disc_start = fcoe_ctlr_disc_start;
>   		lport->tt.disc_stop = fcoe_ctlr_disc_stop;
>   		lport->tt.disc_stop_final = fcoe_ctlr_disc_stop_final;
> -		mutex_init(&lport->disc.disc_mutex);
> -		INIT_LIST_HEAD(&lport->disc.rports);
> -		lport->disc.priv = fip;
> -	} else {
> -		fc_disc_init(lport);
> +		priv = fip;
>   	}
> +
> +	fc_disc_init(lport, priv);
> +
>   	return 0;
>   }
>   EXPORT_SYMBOL_GPL(fcoe_libfc_config);
> diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
> index 8e561e6..141c54b 100644
> --- a/drivers/scsi/libfc/fc_disc.c
> +++ b/drivers/scsi/libfc/fc_disc.c
> @@ -714,8 +714,9 @@ static void fc_disc_stop_final(struct fc_lport *lport)
>   /**
>    * fc_disc_init() - Initialize the discovery layer for a local port
>    * @lport: The local port that needs the discovery layer to be initialized
> + * @priv: Private data structre for users of the discovery layer
>    */
> -int fc_disc_init(struct fc_lport *lport)
> +int fc_disc_init(struct fc_lport *lport, void *priv)
>   {
>   	struct fc_disc *disc;
>   
> @@ -736,7 +737,7 @@ int fc_disc_init(struct fc_lport *lport)
>   	mutex_init(&disc->disc_mutex);
>   	INIT_LIST_HEAD(&disc->rports);
>   
> -	disc->priv = lport;
> +	disc->priv = priv;
>   
>   	return 0;
>   }
> diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
> index 399162b..add2a49 100644
> --- a/include/scsi/libfc.h
> +++ b/include/scsi/libfc.h
> @@ -1074,7 +1074,7 @@ void fc_rport_terminate_io(struct fc_rport *);
>   /*
>    * DISCOVERY LAYER
>    *****************************/
> -int fc_disc_init(struct fc_lport *);
> +int fc_disc_init(struct fc_lport *, void *);
>   
>   static inline struct fc_lport *fc_disc_lport(struct fc_disc *disc)
>   {
>
> _______________________________________________
> fcoe-devel mailing list
> fcoe-devel@open-fcoe.org
> http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel
>

Patch

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 4d5c721..0470cb5 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -932,7 +932,7 @@  static int bnx2fc_libfc_config(struct fc_lport *lport)
 	fc_elsct_init(lport);
 	fc_exch_init(lport);
 	fc_rport_init(lport);
-	fc_disc_init(lport);
+	fc_disc_init(lport, lport);
 	return 0;
 }
 
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 9732168..18600b7 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2821,6 +2821,8 @@  unlock:
 int fcoe_libfc_config(struct fc_lport *lport, struct fcoe_ctlr *fip,
 		      const struct libfc_function_template *tt, int init_fcp)
 {
+	void *priv = lport;
+
 	/* Set the function pointers set by the LLDD */
 	memcpy(&lport->tt, tt, sizeof(*tt));
 	if (init_fcp && fc_fcp_init(lport))
@@ -2837,12 +2839,11 @@  int fcoe_libfc_config(struct fc_lport *lport, struct fcoe_ctlr *fip,
 		lport->tt.disc_start = fcoe_ctlr_disc_start;
 		lport->tt.disc_stop = fcoe_ctlr_disc_stop;
 		lport->tt.disc_stop_final = fcoe_ctlr_disc_stop_final;
-		mutex_init(&lport->disc.disc_mutex);
-		INIT_LIST_HEAD(&lport->disc.rports);
-		lport->disc.priv = fip;
-	} else {
-		fc_disc_init(lport);
+		priv = fip;
 	}
+
+	fc_disc_init(lport, priv);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(fcoe_libfc_config);
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c
index 8e561e6..141c54b 100644
--- a/drivers/scsi/libfc/fc_disc.c
+++ b/drivers/scsi/libfc/fc_disc.c
@@ -714,8 +714,9 @@  static void fc_disc_stop_final(struct fc_lport *lport)
 /**
  * fc_disc_init() - Initialize the discovery layer for a local port
  * @lport: The local port that needs the discovery layer to be initialized
+ * @priv: Private data structre for users of the discovery layer
  */
-int fc_disc_init(struct fc_lport *lport)
+int fc_disc_init(struct fc_lport *lport, void *priv)
 {
 	struct fc_disc *disc;
 
@@ -736,7 +737,7 @@  int fc_disc_init(struct fc_lport *lport)
 	mutex_init(&disc->disc_mutex);
 	INIT_LIST_HEAD(&disc->rports);
 
-	disc->priv = lport;
+	disc->priv = priv;
 
 	return 0;
 }
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 399162b..add2a49 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -1074,7 +1074,7 @@  void fc_rport_terminate_io(struct fc_rport *);
 /*
  * DISCOVERY LAYER
  *****************************/
-int fc_disc_init(struct fc_lport *);
+int fc_disc_init(struct fc_lport *, void *);
 
 static inline struct fc_lport *fc_disc_lport(struct fc_disc *disc)
 {