public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE
@ 2023-08-18 15:54 Andy Shevchenko
  2023-08-18 16:38 ` Justin Tee
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andy Shevchenko @ 2023-08-18 15:54 UTC (permalink / raw)
  To: Martin K. Petersen, Justin Tee, linux-scsi, linux-kernel
  Cc: James Smart, Dick Kennedy, James E.J. Bottomley, Andy Shevchenko

The lpfc_vmid_host_uuid is not defined as uuid_t and its usage is not
the same as for uuid_t operations (like exporting or importing).
Hence replace call to uuid_is_null() by respective memchr_inv() without
abusing casting.

With that, replace LPFC_COMPRESS_VMID_SIZE with plain number and
respective sizeof() to make code robust to changes in the future,
if any.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v3: dropped LPFC_COMPRESS_VMID_SIZE completely at the same time
 drivers/scsi/lpfc/lpfc.h     |  3 +--
 drivers/scsi/lpfc/lpfc_els.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index bc1c5f6df090..af15f7a22d25 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -309,7 +309,6 @@ struct lpfc_hba;
 #define LPFC_VMID_TIMER   300	/* timer interval in seconds */
 
 #define LPFC_MAX_VMID_SIZE      256
-#define LPFC_COMPRESS_VMID_SIZE 16
 
 union lpfc_vmid_io_tag {
 	u32 app_id;	/* App Id vmid */
@@ -667,7 +666,7 @@ struct lpfc_vport {
 	uint32_t cfg_first_burst_size;
 	uint32_t dev_loss_tmo_changed;
 	/* VMID parameters */
-	u8 lpfc_vmid_host_uuid[LPFC_COMPRESS_VMID_SIZE];
+	u8 lpfc_vmid_host_uuid[16];
 	u32 max_vmid;	/* maximum VMIDs allowed per port */
 	u32 cur_vmid_cnt;	/* Current VMID count */
 #define LPFC_MIN_VMID	4
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index b5cd6d1c0a5a..54e47f268235 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -1331,7 +1331,8 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
 	if (phba->cfg_vmid_priority_tagging) {
 		sp->cmn.priority_tagging = 1;
 		/* lpfc_vmid_host_uuid is combination of wwpn and wwnn */
-		if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid)) {
+		if (!memchr_inv(vport->lpfc_vmid_host_uuid, 0,
+				sizeof(vport->lpfc_vmid_host_uuid))) {
 			memcpy(vport->lpfc_vmid_host_uuid, phba->wwpn,
 			       sizeof(phba->wwpn));
 			memcpy(&vport->lpfc_vmid_host_uuid[8], phba->wwnn,
@@ -12357,9 +12358,10 @@ lpfc_vmid_uvem(struct lpfc_vport *vport,
 	elsiocb->vmid_tag.vmid_context = vmid_context;
 	pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
 
-	if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid))
+	if (!memchr_inv(vport->lpfc_vmid_host_uuid, 0,
+			sizeof(vport->lpfc_vmid_host_uuid)))
 		memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid,
-		       LPFC_COMPRESS_VMID_SIZE);
+		       sizeof(vport->lpfc_vmid_host_uuid));
 
 	*((u32 *)(pcmd)) = ELS_CMD_UVEM;
 	len = (u32 *)(pcmd + 4);
@@ -12369,13 +12371,13 @@ lpfc_vmid_uvem(struct lpfc_vport *vport,
 	vem_id_desc->tag = be32_to_cpu(VEM_ID_DESC_TAG);
 	vem_id_desc->length = be32_to_cpu(LPFC_UVEM_VEM_ID_DESC_SIZE);
 	memcpy(vem_id_desc->vem_id, vport->lpfc_vmid_host_uuid,
-	       LPFC_COMPRESS_VMID_SIZE);
+	       sizeof(vem_id_desc->vem_id));
 
 	inst_desc = (struct instantiated_ve_desc *)(pcmd + 32);
 	inst_desc->tag = be32_to_cpu(INSTANTIATED_VE_DESC_TAG);
 	inst_desc->length = be32_to_cpu(LPFC_UVEM_VE_MAP_DESC_SIZE);
 	memcpy(inst_desc->global_vem_id, vmid->host_vmid,
-	       LPFC_COMPRESS_VMID_SIZE);
+	       sizeof(inst_desc->global_vem_id));
 
 	bf_set(lpfc_instantiated_nport_id, inst_desc, vport->fc_myDID);
 	bf_set(lpfc_instantiated_local_id, inst_desc,
-- 
2.40.0.1.gaa8946217a0b


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

* Re: [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE
  2023-08-18 15:54 [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE Andy Shevchenko
@ 2023-08-18 16:38 ` Justin Tee
  2023-08-21 21:08 ` Martin K. Petersen
  2023-08-25  1:12 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Justin Tee @ 2023-08-18 16:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Martin K. Petersen, linux-scsi, linux-kernel, James Smart,
	Dick Kennedy, James E.J. Bottomley

[-- Attachment #1: Type: text/plain, Size: 4969 bytes --]

Hi Andy,

Thanks!

Reviewed-by: Justin Tee <justin.tee@broadcom.com>

Regards,
Justin


On Fri, Aug 18, 2023 at 8:55 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> The lpfc_vmid_host_uuid is not defined as uuid_t and its usage is not
> the same as for uuid_t operations (like exporting or importing).
> Hence replace call to uuid_is_null() by respective memchr_inv() without
> abusing casting.
>
> With that, replace LPFC_COMPRESS_VMID_SIZE with plain number and
> respective sizeof() to make code robust to changes in the future,
> if any.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v3: dropped LPFC_COMPRESS_VMID_SIZE completely at the same time
>  drivers/scsi/lpfc/lpfc.h     |  3 +--
>  drivers/scsi/lpfc/lpfc_els.c | 12 +++++++-----
>  2 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
> index bc1c5f6df090..af15f7a22d25 100644
> --- a/drivers/scsi/lpfc/lpfc.h
> +++ b/drivers/scsi/lpfc/lpfc.h
> @@ -309,7 +309,6 @@ struct lpfc_hba;
>  #define LPFC_VMID_TIMER   300  /* timer interval in seconds */
>
>  #define LPFC_MAX_VMID_SIZE      256
> -#define LPFC_COMPRESS_VMID_SIZE 16
>
>  union lpfc_vmid_io_tag {
>         u32 app_id;     /* App Id vmid */
> @@ -667,7 +666,7 @@ struct lpfc_vport {
>         uint32_t cfg_first_burst_size;
>         uint32_t dev_loss_tmo_changed;
>         /* VMID parameters */
> -       u8 lpfc_vmid_host_uuid[LPFC_COMPRESS_VMID_SIZE];
> +       u8 lpfc_vmid_host_uuid[16];
>         u32 max_vmid;   /* maximum VMIDs allowed per port */
>         u32 cur_vmid_cnt;       /* Current VMID count */
>  #define LPFC_MIN_VMID  4
> diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
> index b5cd6d1c0a5a..54e47f268235 100644
> --- a/drivers/scsi/lpfc/lpfc_els.c
> +++ b/drivers/scsi/lpfc/lpfc_els.c
> @@ -1331,7 +1331,8 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,
>         if (phba->cfg_vmid_priority_tagging) {
>                 sp->cmn.priority_tagging = 1;
>                 /* lpfc_vmid_host_uuid is combination of wwpn and wwnn */
> -               if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid)) {
> +               if (!memchr_inv(vport->lpfc_vmid_host_uuid, 0,
> +                               sizeof(vport->lpfc_vmid_host_uuid))) {
>                         memcpy(vport->lpfc_vmid_host_uuid, phba->wwpn,
>                                sizeof(phba->wwpn));
>                         memcpy(&vport->lpfc_vmid_host_uuid[8], phba->wwnn,
> @@ -12357,9 +12358,10 @@ lpfc_vmid_uvem(struct lpfc_vport *vport,
>         elsiocb->vmid_tag.vmid_context = vmid_context;
>         pcmd = (u8 *)elsiocb->cmd_dmabuf->virt;
>
> -       if (uuid_is_null((uuid_t *)vport->lpfc_vmid_host_uuid))
> +       if (!memchr_inv(vport->lpfc_vmid_host_uuid, 0,
> +                       sizeof(vport->lpfc_vmid_host_uuid)))
>                 memcpy(vport->lpfc_vmid_host_uuid, vmid->host_vmid,
> -                      LPFC_COMPRESS_VMID_SIZE);
> +                      sizeof(vport->lpfc_vmid_host_uuid));
>
>         *((u32 *)(pcmd)) = ELS_CMD_UVEM;
>         len = (u32 *)(pcmd + 4);
> @@ -12369,13 +12371,13 @@ lpfc_vmid_uvem(struct lpfc_vport *vport,
>         vem_id_desc->tag = be32_to_cpu(VEM_ID_DESC_TAG);
>         vem_id_desc->length = be32_to_cpu(LPFC_UVEM_VEM_ID_DESC_SIZE);
>         memcpy(vem_id_desc->vem_id, vport->lpfc_vmid_host_uuid,
> -              LPFC_COMPRESS_VMID_SIZE);
> +              sizeof(vem_id_desc->vem_id));
>
>         inst_desc = (struct instantiated_ve_desc *)(pcmd + 32);
>         inst_desc->tag = be32_to_cpu(INSTANTIATED_VE_DESC_TAG);
>         inst_desc->length = be32_to_cpu(LPFC_UVEM_VE_MAP_DESC_SIZE);
>         memcpy(inst_desc->global_vem_id, vmid->host_vmid,
> -              LPFC_COMPRESS_VMID_SIZE);
> +              sizeof(inst_desc->global_vem_id));
>
>         bf_set(lpfc_instantiated_nport_id, inst_desc, vport->fc_myDID);
>         bf_set(lpfc_instantiated_local_id, inst_desc,
> --
> 2.40.0.1.gaa8946217a0b
>

-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4203 bytes --]

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

* Re: [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE
  2023-08-18 15:54 [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE Andy Shevchenko
  2023-08-18 16:38 ` Justin Tee
@ 2023-08-21 21:08 ` Martin K. Petersen
  2023-08-25  1:12 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-08-21 21:08 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Martin K. Petersen, Justin Tee, linux-scsi, linux-kernel,
	James Smart, Dick Kennedy, James E.J. Bottomley


Andy,

> The lpfc_vmid_host_uuid is not defined as uuid_t and its usage is not
> the same as for uuid_t operations (like exporting or importing). Hence
> replace call to uuid_is_null() by respective memchr_inv() without
> abusing casting.
>
> With that, replace LPFC_COMPRESS_VMID_SIZE with plain number and
> respective sizeof() to make code robust to changes in the future, if
> any.

Applied to 6.6/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE
  2023-08-18 15:54 [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE Andy Shevchenko
  2023-08-18 16:38 ` Justin Tee
  2023-08-21 21:08 ` Martin K. Petersen
@ 2023-08-25  1:12 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2023-08-25  1:12 UTC (permalink / raw)
  To: Justin Tee, linux-scsi, linux-kernel, Andy Shevchenko
  Cc: Martin K . Petersen, James Smart, Dick Kennedy,
	James E.J. Bottomley

On Fri, 18 Aug 2023 18:54:52 +0300, Andy Shevchenko wrote:

> The lpfc_vmid_host_uuid is not defined as uuid_t and its usage is not
> the same as for uuid_t operations (like exporting or importing).
> Hence replace call to uuid_is_null() by respective memchr_inv() without
> abusing casting.
> 
> With that, replace LPFC_COMPRESS_VMID_SIZE with plain number and
> respective sizeof() to make code robust to changes in the future,
> if any.
> 
> [...]

Applied to 6.6/scsi-queue, thanks!

[1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE
      https://git.kernel.org/mkp/scsi/c/19d7102a9539

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2023-08-25  1:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-18 15:54 [PATCH v3 1/1] scsi: lpfc: Do not abuse UUID APIs and LPFC_COMPRESS_VMID_SIZE Andy Shevchenko
2023-08-18 16:38 ` Justin Tee
2023-08-21 21:08 ` Martin K. Petersen
2023-08-25  1:12 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox