All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] qla2xxx: Split qla2x00_configure_local_loop()
@ 2020-04-05 22:59 Bart Van Assche
  2020-04-06  7:25 ` Daniel Wagner
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bart Van Assche @ 2020-04-05 22:59 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Nilesh Javali, Himanshu Madhani,
	Quinn Tran, Martin Wilck, Daniel Wagner, Roman Bolshakov

The size of the function qla2x00_configure_local_loop() hurts its
readability. Hence split that function. This patch does not change
any functionality.

Cc: Nilesh Javali <njavali@marvell.com>
Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Quinn Tran <qutran@marvell.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_init.c | 92 ++++++++++++++++++---------------
 1 file changed, 50 insertions(+), 42 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 5b2deaa730bf..80390d3f3236 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -5081,6 +5081,54 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
 	return (rval);
 }
 
+static int qla2x00_configure_n2n_loop(scsi_qla_host_t *vha)
+{
+	struct qla_hw_data *ha = vha->hw;
+	unsigned long flags;
+	fc_port_t *fcport;
+	int rval;
+
+	if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) {
+		/* borrowing */
+		u32 *bp, sz;
+
+		memset(ha->init_cb, 0, ha->init_cb_size);
+		sz = min_t(int, sizeof(struct els_plogi_payload),
+			   ha->init_cb_size);
+		rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma,
+						    ha->init_cb, sz);
+		if (rval == QLA_SUCCESS) {
+			__be32 *q = &ha->plogi_els_payld.data[0];
+
+			bp = (uint32_t *)ha->init_cb;
+			cpu_to_be32_array(q, bp, sz / 4);
+			memcpy(bp, q, sizeof(ha->plogi_els_payld.data));
+		} else {
+			ql_dbg(ql_dbg_init, vha, 0x00d1,
+			       "PLOGI ELS param read fail.\n");
+			goto skip_login;
+		}
+	}
+
+	list_for_each_entry(fcport, &vha->vp_fcports, list) {
+		if (fcport->n2n_flag) {
+			qla24xx_fcport_handle_login(vha, fcport);
+			return QLA_SUCCESS;
+		}
+	}
+
+skip_login:
+	spin_lock_irqsave(&vha->work_lock, flags);
+	vha->scan.scan_retry++;
+	spin_unlock_irqrestore(&vha->work_lock, flags);
+
+	if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
+		set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
+		set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
+	}
+	return QLA_FUNCTION_FAILED;
+}
+
 /*
  * qla2x00_configure_local_loop
  *	Updates Fibre Channel Device Database with local loop devices.
@@ -5098,7 +5146,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
 	int		found_devs;
 	int		found;
 	fc_port_t	*fcport, *new_fcport;
-
 	uint16_t	index;
 	uint16_t	entries;
 	struct gid_list_info *gid;
@@ -5108,47 +5155,8 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
 	unsigned long flags;
 
 	/* Inititae N2N login. */
-	if (N2N_TOPO(ha)) {
-		if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) {
-			/* borrowing */
-			u32 *bp, sz;
-
-			memset(ha->init_cb, 0, ha->init_cb_size);
-			sz = min_t(int, sizeof(struct els_plogi_payload),
-			    ha->init_cb_size);
-			rval = qla24xx_get_port_login_templ(vha,
-			    ha->init_cb_dma, (void *)ha->init_cb, sz);
-			if (rval == QLA_SUCCESS) {
-				__be32 *q = &ha->plogi_els_payld.data[0];
-
-				bp = (uint32_t *)ha->init_cb;
-				cpu_to_be32_array(q, bp, sz / 4);
-
-				memcpy(bp, q, sizeof(ha->plogi_els_payld.data));
-			} else {
-				ql_dbg(ql_dbg_init, vha, 0x00d1,
-				    "PLOGI ELS param read fail.\n");
-				goto skip_login;
-			}
-		}
-
-		list_for_each_entry(fcport, &vha->vp_fcports, list) {
-			if (fcport->n2n_flag) {
-				qla24xx_fcport_handle_login(vha, fcport);
-				return QLA_SUCCESS;
-			}
-		}
-skip_login:
-		spin_lock_irqsave(&vha->work_lock, flags);
-		vha->scan.scan_retry++;
-		spin_unlock_irqrestore(&vha->work_lock, flags);
-
-		if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
-			set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
-			set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
-		}
-		return QLA_FUNCTION_FAILED;
-	}
+	if (N2N_TOPO(ha))
+		return qla2x00_configure_n2n_loop(vha);
 
 	found_devs = 0;
 	new_fcport = NULL;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] qla2xxx: Split qla2x00_configure_local_loop()
  2020-04-05 22:59 [PATCH] qla2xxx: Split qla2x00_configure_local_loop() Bart Van Assche
@ 2020-04-06  7:25 ` Daniel Wagner
  2020-04-06 14:39 ` Himanshu Madhani
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Wagner @ 2020-04-06  7:25 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Nilesh Javali, Himanshu Madhani, Quinn Tran, Martin Wilck,
	Roman Bolshakov

Hi Bart,

On Sun, Apr 05, 2020 at 03:59:05PM -0700, Bart Van Assche wrote:
> The size of the function qla2x00_configure_local_loop() hurts its
> readability. Hence split that function. This patch does not change
> any functionality.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <hmadhani@marvell.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Looks good to me.

Reviewed-by: Daniel Wagner <dwagner@suse.de>

Thanks,
Daniel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] qla2xxx: Split qla2x00_configure_local_loop()
  2020-04-05 22:59 [PATCH] qla2xxx: Split qla2x00_configure_local_loop() Bart Van Assche
  2020-04-06  7:25 ` Daniel Wagner
@ 2020-04-06 14:39 ` Himanshu Madhani
  2020-04-08 21:57 ` Roman Bolshakov
  2020-04-14  2:22 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Himanshu Madhani @ 2020-04-06 14:39 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Nilesh Javali, Himanshu Madhani, Quinn Tran,
	Martin Wilck, Daniel Wagner, Roman Bolshakov

On 4/5/20 5:59 PM, Bart Van Assche wrote:
> The size of the function qla2x00_configure_local_loop() hurts its
> readability. Hence split that function. This patch does not change
> any functionality.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <hmadhani@marvell.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/qla2xxx/qla_init.c | 92 ++++++++++++++++++---------------
>   1 file changed, 50 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> index 5b2deaa730bf..80390d3f3236 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -5081,6 +5081,54 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
>   	return (rval);
>   }
>   
> +static int qla2x00_configure_n2n_loop(scsi_qla_host_t *vha)
> +{
> +	struct qla_hw_data *ha = vha->hw;
> +	unsigned long flags;
> +	fc_port_t *fcport;
> +	int rval;
> +
> +	if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) {
> +		/* borrowing */
> +		u32 *bp, sz;
> +
> +		memset(ha->init_cb, 0, ha->init_cb_size);
> +		sz = min_t(int, sizeof(struct els_plogi_payload),
> +			   ha->init_cb_size);
> +		rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma,
> +						    ha->init_cb, sz);
> +		if (rval == QLA_SUCCESS) {
> +			__be32 *q = &ha->plogi_els_payld.data[0];
> +
> +			bp = (uint32_t *)ha->init_cb;
> +			cpu_to_be32_array(q, bp, sz / 4);
> +			memcpy(bp, q, sizeof(ha->plogi_els_payld.data));
> +		} else {
> +			ql_dbg(ql_dbg_init, vha, 0x00d1,
> +			       "PLOGI ELS param read fail.\n");
> +			goto skip_login;
> +		}
> +	}
> +
> +	list_for_each_entry(fcport, &vha->vp_fcports, list) {
> +		if (fcport->n2n_flag) {
> +			qla24xx_fcport_handle_login(vha, fcport);
> +			return QLA_SUCCESS;
> +		}
> +	}
> +
> +skip_login:
> +	spin_lock_irqsave(&vha->work_lock, flags);
> +	vha->scan.scan_retry++;
> +	spin_unlock_irqrestore(&vha->work_lock, flags);
> +
> +	if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
> +		set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
> +		set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
> +	}
> +	return QLA_FUNCTION_FAILED;
> +}
> +
>   /*
>    * qla2x00_configure_local_loop
>    *	Updates Fibre Channel Device Database with local loop devices.
> @@ -5098,7 +5146,6 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
>   	int		found_devs;
>   	int		found;
>   	fc_port_t	*fcport, *new_fcport;
> -
>   	uint16_t	index;
>   	uint16_t	entries;
>   	struct gid_list_info *gid;
> @@ -5108,47 +5155,8 @@ qla2x00_configure_local_loop(scsi_qla_host_t *vha)
>   	unsigned long flags;
>   
>   	/* Inititae N2N login. */
> -	if (N2N_TOPO(ha)) {
> -		if (test_and_clear_bit(N2N_LOGIN_NEEDED, &vha->dpc_flags)) {
> -			/* borrowing */
> -			u32 *bp, sz;
> -
> -			memset(ha->init_cb, 0, ha->init_cb_size);
> -			sz = min_t(int, sizeof(struct els_plogi_payload),
> -			    ha->init_cb_size);
> -			rval = qla24xx_get_port_login_templ(vha,
> -			    ha->init_cb_dma, (void *)ha->init_cb, sz);
> -			if (rval == QLA_SUCCESS) {
> -				__be32 *q = &ha->plogi_els_payld.data[0];
> -
> -				bp = (uint32_t *)ha->init_cb;
> -				cpu_to_be32_array(q, bp, sz / 4);
> -
> -				memcpy(bp, q, sizeof(ha->plogi_els_payld.data));
> -			} else {
> -				ql_dbg(ql_dbg_init, vha, 0x00d1,
> -				    "PLOGI ELS param read fail.\n");
> -				goto skip_login;
> -			}
> -		}
> -
> -		list_for_each_entry(fcport, &vha->vp_fcports, list) {
> -			if (fcport->n2n_flag) {
> -				qla24xx_fcport_handle_login(vha, fcport);
> -				return QLA_SUCCESS;
> -			}
> -		}
> -skip_login:
> -		spin_lock_irqsave(&vha->work_lock, flags);
> -		vha->scan.scan_retry++;
> -		spin_unlock_irqrestore(&vha->work_lock, flags);
> -
> -		if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
> -			set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
> -			set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
> -		}
> -		return QLA_FUNCTION_FAILED;
> -	}
> +	if (N2N_TOPO(ha))
> +		return qla2x00_configure_n2n_loop(vha);
>   
>   	found_devs = 0;
>   	new_fcport = NULL;
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

-- Himanshu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] qla2xxx: Split qla2x00_configure_local_loop()
  2020-04-05 22:59 [PATCH] qla2xxx: Split qla2x00_configure_local_loop() Bart Van Assche
  2020-04-06  7:25 ` Daniel Wagner
  2020-04-06 14:39 ` Himanshu Madhani
@ 2020-04-08 21:57 ` Roman Bolshakov
  2020-04-14  2:22 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Roman Bolshakov @ 2020-04-08 21:57 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Nilesh Javali, Himanshu Madhani, Quinn Tran, Martin Wilck,
	Daniel Wagner

On Sun, Apr 05, 2020 at 03:59:05PM -0700, Bart Van Assche wrote:
> The size of the function qla2x00_configure_local_loop() hurts its
> readability. Hence split that function. This patch does not change
> any functionality.
> 

Hi Bart,

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>

Thanks,
Roman

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] qla2xxx: Split qla2x00_configure_local_loop()
  2020-04-05 22:59 [PATCH] qla2xxx: Split qla2x00_configure_local_loop() Bart Van Assche
                   ` (2 preceding siblings ...)
  2020-04-08 21:57 ` Roman Bolshakov
@ 2020-04-14  2:22 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2020-04-14  2:22 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi,
	Nilesh Javali, Himanshu Madhani, Quinn Tran, Martin Wilck,
	Daniel Wagner, Roman Bolshakov


Bart,

> The size of the function qla2x00_configure_local_loop() hurts its
> readability. Hence split that function. This patch does not change any
> functionality.

Applied to 5.8/scsi-queue, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-04-14  2:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-05 22:59 [PATCH] qla2xxx: Split qla2x00_configure_local_loop() Bart Van Assche
2020-04-06  7:25 ` Daniel Wagner
2020-04-06 14:39 ` Himanshu Madhani
2020-04-08 21:57 ` Roman Bolshakov
2020-04-14  2:22 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.