Patchwork [3/4] uefi: uefidump: add the iSCSI subtype-19 support on messaging device path type for uefidump(LP: #1255387)

login
register
mail settings
Submitter Ivan Hu
Date Dec. 5, 2013, 10:04 a.m.
Message ID <1386237861-22685-1-git-send-email-ivan.hu@canonical.com>
Download mbox | patch
Permalink /patch/296757/
State Accepted
Headers show

Comments

Ivan Hu - Dec. 5, 2013, 10:04 a.m.
Add the iSCSI subtype 19 support on messaging device path follow the section 9.3.5.21 on UEFI spec2.4.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 src/lib/include/fwts_uefi.h  |   11 ++++++++++-
 src/uefi/uefidump/uefidump.c |   15 +++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
Colin King - Dec. 5, 2013, 11:11 a.m.
On 05/12/13 10:04, Ivan Hu wrote:
> Add the iSCSI subtype 19 support on messaging device path follow the section 9.3.5.21 on UEFI spec2.4.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  |   11 ++++++++++-
>  src/uefi/uefidump/uefidump.c |   15 +++++++++++++++
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index c83df33..864ce43 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -207,6 +207,7 @@ typedef enum {
>  	FWTS_UEFI_USB_WWID_DEVICE_PATH_SUBTYPE =	(0x10),
>  	FWTS_UEFI_LOGICAL_UNIT_DEVICE_PATH_SUBTYPE =	(0x11),
>  	FWTS_UEFI_SATA_DEVICE_PATH_SUBTYPE = 		(0x12),
> +	FWTS_UEFI_ISCSI_DEVICE_PATH_SUBTYPE = 		(0x13),
>  	FWTS_UEFI_VLAN_DEVICE_PATH_SUBTYPE = 		(0x14),
>  	FWTS_UEFI_FIBRE_CHANNEL_EX_DEVICE_PATH_SUBTYPE = (0x15),
>  	FWTS_UEFI_SAS_EX_DEVICE_PATH_SUBTYPE =		(0x16)
> @@ -408,7 +409,6 @@ typedef struct {
>  	uint16_t vlanid;
>  } fwts_uefi_vlan_dev_path;
>  
> -
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
>  	uint64_t sas_addr;
> @@ -419,6 +419,15 @@ typedef struct {
>  
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
> +	uint16_t protocol;
> +	uint16_t options;
> +	uint64_t lun;
> +	uint16_t tpg_tag;
> +	char iscsi_tn[0];
> +} __attribute__((packed)) fwts_uefi_iscsi_dev_path;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>  	uint32_t partition_number;
>  	uint64_t partition_start;
>  	uint64_t partition_size;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 1be5d60..e965043 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -391,6 +391,21 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>  					s->sas_addr, s->lun, s->dev_topology_info, s->rtp);
>  			}
>  			break;
> +		case FWTS_UEFI_ISCSI_DEVICE_PATH_SUBTYPE:
> +			if (dev_path_len >= sizeof(fwts_uefi_iscsi_dev_path)) {
> +				fwts_uefi_iscsi_dev_path *i = (fwts_uefi_iscsi_dev_path *)dev_path;
> +				path = uefidump_vprintf(path, "\\iSCSI(0x%" PRIx16 ",0x%" PRIx16 ",0x%" PRIx64 ",0x%" PRIx16,
> +					i->protocol, i->options, i->lun, i->tpg_tag);
> +
> +				/* Adding iSCSI target name */
> +				uint16_t len = i->dev_path.length[0] | (((uint16_t)i->dev_path.length[1]) << 8);
> +				if (len - sizeof(fwts_uefi_iscsi_dev_path) > 223) {
> +					path = uefidump_vprintf(path, ")");
> +					break;
> +				}
> +				path = uefidump_vprintf(path, ",%s)", i->iscsi_tn);
> +			}
> +			break;
>  		default:
>  			path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>  			break;
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung - Dec. 9, 2013, 4:51 a.m.
On 12/05/2013 06:04 PM, Ivan Hu wrote:
> Add the iSCSI subtype 19 support on messaging device path follow the section 9.3.5.21 on UEFI spec2.4.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  src/lib/include/fwts_uefi.h  |   11 ++++++++++-
>  src/uefi/uefidump/uefidump.c |   15 +++++++++++++++
>  2 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
> index c83df33..864ce43 100644
> --- a/src/lib/include/fwts_uefi.h
> +++ b/src/lib/include/fwts_uefi.h
> @@ -207,6 +207,7 @@ typedef enum {
>  	FWTS_UEFI_USB_WWID_DEVICE_PATH_SUBTYPE =	(0x10),
>  	FWTS_UEFI_LOGICAL_UNIT_DEVICE_PATH_SUBTYPE =	(0x11),
>  	FWTS_UEFI_SATA_DEVICE_PATH_SUBTYPE = 		(0x12),
> +	FWTS_UEFI_ISCSI_DEVICE_PATH_SUBTYPE = 		(0x13),
>  	FWTS_UEFI_VLAN_DEVICE_PATH_SUBTYPE = 		(0x14),
>  	FWTS_UEFI_FIBRE_CHANNEL_EX_DEVICE_PATH_SUBTYPE = (0x15),
>  	FWTS_UEFI_SAS_EX_DEVICE_PATH_SUBTYPE =		(0x16)
> @@ -408,7 +409,6 @@ typedef struct {
>  	uint16_t vlanid;
>  } fwts_uefi_vlan_dev_path;
>  
> -
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
>  	uint64_t sas_addr;
> @@ -419,6 +419,15 @@ typedef struct {
>  
>  typedef struct {
>  	fwts_uefi_dev_path dev_path;
> +	uint16_t protocol;
> +	uint16_t options;
> +	uint64_t lun;
> +	uint16_t tpg_tag;
> +	char iscsi_tn[0];
> +} __attribute__((packed)) fwts_uefi_iscsi_dev_path;
> +
> +typedef struct {
> +	fwts_uefi_dev_path dev_path;
>  	uint32_t partition_number;
>  	uint64_t partition_start;
>  	uint64_t partition_size;
> diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
> index 1be5d60..e965043 100644
> --- a/src/uefi/uefidump/uefidump.c
> +++ b/src/uefi/uefidump/uefidump.c
> @@ -391,6 +391,21 @@ static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
>  					s->sas_addr, s->lun, s->dev_topology_info, s->rtp);
>  			}
>  			break;
> +		case FWTS_UEFI_ISCSI_DEVICE_PATH_SUBTYPE:
> +			if (dev_path_len >= sizeof(fwts_uefi_iscsi_dev_path)) {
> +				fwts_uefi_iscsi_dev_path *i = (fwts_uefi_iscsi_dev_path *)dev_path;
> +				path = uefidump_vprintf(path, "\\iSCSI(0x%" PRIx16 ",0x%" PRIx16 ",0x%" PRIx64 ",0x%" PRIx16,
> +					i->protocol, i->options, i->lun, i->tpg_tag);
> +
> +				/* Adding iSCSI target name */
> +				uint16_t len = i->dev_path.length[0] | (((uint16_t)i->dev_path.length[1]) << 8);
> +				if (len - sizeof(fwts_uefi_iscsi_dev_path) > 223) {
> +					path = uefidump_vprintf(path, ")");
> +					break;
> +				}
> +				path = uefidump_vprintf(path, ",%s)", i->iscsi_tn);
> +			}
> +			break;
>  		default:
>  			path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
>  			break;
> 

Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/lib/include/fwts_uefi.h b/src/lib/include/fwts_uefi.h
index c83df33..864ce43 100644
--- a/src/lib/include/fwts_uefi.h
+++ b/src/lib/include/fwts_uefi.h
@@ -207,6 +207,7 @@  typedef enum {
 	FWTS_UEFI_USB_WWID_DEVICE_PATH_SUBTYPE =	(0x10),
 	FWTS_UEFI_LOGICAL_UNIT_DEVICE_PATH_SUBTYPE =	(0x11),
 	FWTS_UEFI_SATA_DEVICE_PATH_SUBTYPE = 		(0x12),
+	FWTS_UEFI_ISCSI_DEVICE_PATH_SUBTYPE = 		(0x13),
 	FWTS_UEFI_VLAN_DEVICE_PATH_SUBTYPE = 		(0x14),
 	FWTS_UEFI_FIBRE_CHANNEL_EX_DEVICE_PATH_SUBTYPE = (0x15),
 	FWTS_UEFI_SAS_EX_DEVICE_PATH_SUBTYPE =		(0x16)
@@ -408,7 +409,6 @@  typedef struct {
 	uint16_t vlanid;
 } fwts_uefi_vlan_dev_path;
 
-
 typedef struct {
 	fwts_uefi_dev_path dev_path;
 	uint64_t sas_addr;
@@ -419,6 +419,15 @@  typedef struct {
 
 typedef struct {
 	fwts_uefi_dev_path dev_path;
+	uint16_t protocol;
+	uint16_t options;
+	uint64_t lun;
+	uint16_t tpg_tag;
+	char iscsi_tn[0];
+} __attribute__((packed)) fwts_uefi_iscsi_dev_path;
+
+typedef struct {
+	fwts_uefi_dev_path dev_path;
 	uint32_t partition_number;
 	uint64_t partition_start;
 	uint64_t partition_size;
diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index 1be5d60..e965043 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -391,6 +391,21 @@  static char *uefidump_build_dev_path(char *path, fwts_uefi_dev_path *dev_path, c
 					s->sas_addr, s->lun, s->dev_topology_info, s->rtp);
 			}
 			break;
+		case FWTS_UEFI_ISCSI_DEVICE_PATH_SUBTYPE:
+			if (dev_path_len >= sizeof(fwts_uefi_iscsi_dev_path)) {
+				fwts_uefi_iscsi_dev_path *i = (fwts_uefi_iscsi_dev_path *)dev_path;
+				path = uefidump_vprintf(path, "\\iSCSI(0x%" PRIx16 ",0x%" PRIx16 ",0x%" PRIx64 ",0x%" PRIx16,
+					i->protocol, i->options, i->lun, i->tpg_tag);
+
+				/* Adding iSCSI target name */
+				uint16_t len = i->dev_path.length[0] | (((uint16_t)i->dev_path.length[1]) << 8);
+				if (len - sizeof(fwts_uefi_iscsi_dev_path) > 223) {
+					path = uefidump_vprintf(path, ")");
+					break;
+				}
+				path = uefidump_vprintf(path, ",%s)", i->iscsi_tn);
+			}
+			break;
 		default:
 			path = uefidump_vprintf(path, "\\Unknown-MESSAGING-DEV-PATH(0x%" PRIx8 ")", dev_path->subtype);
 			break;