Skip to contentSkip to conversation

qla2xxx: Add name and management server queries to fill in new fc_rport attributes.

RFC New Chad Dupuis 1 participant 1 message Oct 28, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 2/2 qla2xxx: Add name and management server queries to fill in new fc_rport attributes.

This patch adds in the name server and mangement server queries to the qla2xxx driver to get the needed information from the fabric to fill in the new fc_rport attributes exported for HBAAPI v2 user space libraries:

Get Port Type (GPT)
Get FC-4 Types (GFT_ID)
Get Symbolic Port Name (GSPN)
Get Fabric Name (GFN)

If the name server or management server query succeeds then the fc_rport attribute is assigned before fc_remote_port_rolechng() is called. Otherwise, the default fc_rport attribute is left alone.

---
 drivers/scsi/qla2xxx/qla_def.h  |   67 +++++++++++
 drivers/scsi/qla2xxx/qla_gbl.h  |    4 +
 drivers/scsi/qla2xxx/qla_gs.c   |  241 +++++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla2xxx/qla_init.c |   38 ++++++-
 4 files changed, 349 insertions(+), 1 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +67 -0
index 6168628..79f1d4a 100644
@@ -1658,6 +1658,7 @@ typedef struct {
 	uint8_t fabric_port_name[WWN_SIZE];
 	uint16_t fp_speed;
 	uint8_t fc4_type;
+	uint32_t supported_speeds;
 } sw_info_t;
 
 /* FCP-4 types */
@@ -1707,6 +1708,15 @@ typedef struct fc_port {
 
 	uint16_t vp_idx;
 	uint8_t fc4_type;
+
+	/* Additional HBAAPI information */
+	u8  supported_fc4s[FC_FC4_LIST_SIZE];
+	u32 supported_speeds;
+	enum fc_port_type rport_type; /* Stores HBAAPI port_type */
+	u32 speed;
+	u8  active_fc4s[FC_FC4_LIST_SIZE];
+	char symbolic_name[FC_SYMBOLIC_NAME_SIZE];
+	uint8_t fabric_name[8];
 } fc_port_t;
 
 /*
@@ -1793,6 +1803,30 @@ typedef struct fc_port {
 #define GFF_ID_REQ_SIZE	(16 + 4)
 #define GFF_ID_RSP_SIZE (16 + 128)
 
+#define GSPN_SYM_NAME_SIZE	255
+#define GSPN_ID_CMD		0x0118
+#define GSPN_ID_REQ_SIZE	(16 + 4)
+#define GSPN_ID_RSP_SIZE	(16 + 1 + GSPN_SYM_NAME_SIZE)
+
+#define GFN_CMD		0x0114
+#define GFN_REQ_SIZE	(16 + 8)
+#define GFN_RSP_SIZE	(16 + 8)
+
+/* Possible port types reported by GPT_ID */
+#define GPT_PT_UNIDENTIFIED	0x00
+#define GPT_PT_N_PORT		0x01
+#define GPT_PT_NL_PORT		0x02
+#define GPT_PT_F_NL_PORT	0x03
+#define GPT_PT_NX_PORT		0x7F
+#define GPT_PT_F_PORT		0x81
+#define GPT_PT_FL_PORT		0x82
+#define GPT_PT_E_PORT		0x84
+#define GPT_PT_B_PORT		0x85
+
+#define GPT_ID_CMD	0x011A
+#define GPT_ID_REQ_SIZE	(16 + 1 + 3)
+#define GPT_ID_RSP_SIZE	(16 + 1 + 3)
+
 /*
  * HBA attribute types.
  */
@@ -1998,6 +2032,25 @@ struct ct_sns_req {
 			uint8_t reserved;
 			uint8_t port_name[3];
 		} gff_id;
+
+		struct {
+			uint8_t reserved;
+			uint8_t port_name[3];
+		} gspn_id;
+
+		struct {
+			uint8_t element_name[8];
+		} gfn;
+
+		struct {
+			uint8_t reserved;
+			uint8_t port_name[3];
+		} gft_id;
+
+		struct {
+			uint8_t reserved;
+			uint8_t port_name[3];
+		} gpt_id;
 	} req;
 };
 
@@ -2075,6 +2128,20 @@ struct ct_sns_rsp {
 		struct {
 			uint8_t fc4_features[128];
 		} gff_id;
+
+		struct {
+			uint8_t length;
+			uint8_t symbolic_name[GSPN_SYM_NAME_SIZE];
+		} gspn_id;
+
+		struct {
+			uint8_t fabric_name[8];
+		} gfn;
+
+		struct {
+			uint8_t port_type;
+			uint8_t reserved[3];
+		} gpt_id;
 	} rsp;
 };
 
drivers/scsi/qla2xxx/qla_gbl.h +4 -0
index 1370f05..01cf0a4 100644
@@ -457,6 +457,10 @@ extern int qla2x00_fdmi_register(scsi_qla_host_t *);
 extern int qla2x00_gfpn_id(scsi_qla_host_t *, sw_info_t *);
 extern int qla2x00_gpsc(scsi_qla_host_t *, sw_info_t *);
 extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
+extern int qla2x00_gspn_id(scsi_qla_host_t *, fc_port_t *);
+extern int qla2x00_gfn(scsi_qla_host_t *, fc_port_t *);
+extern int qla2x00_gft_id(scsi_qla_host_t *, fc_port_t *);
+extern int qla2x00_gpt_id(scsi_qla_host_t *, fc_port_t *);
 
 /*
  * Global Function Prototypes in qla_attr.c source file.
drivers/scsi/qla2xxx/qla_gs.c +241 -0

250 lines not on this page · raw message

drivers/scsi/qla2xxx/qla_init.c +37 -1
index e9b800e..6094ce6 100644
@@ -2535,6 +2535,13 @@ qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags)
 	fcport->loop_id = FC_NO_LOOP_ID;
 	atomic_set(&fcport->state, FCS_UNCONFIGURED);
 	fcport->supported_classes = FC_COS_UNSPECIFIED;
+	memset(fcport->supported_fc4s, 0, sizeof(fcport->supported_fc4s));
+	fcport->supported_speeds = FC_PORTSPEED_UNKNOWN;
+	fcport->rport_type = FC_PORTTYPE_UNKNOWN;
+	fcport->speed = FC_PORTSPEED_UNKNOWN;
+	memset(fcport->active_fc4s, 0, sizeof(fcport->active_fc4s));
+	memset(fcport->symbolic_name, 0, sizeof(fcport->symbolic_name));
+	memset(fcport->fabric_name, 0, sizeof(fcport->fabric_name));
 
 	return fcport;
 }
@@ -2872,6 +2879,33 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
 }
 
 static void
+qla2x00_update_rport_attrs(scsi_qla_host_t *vha, fc_port_t *fcport,
+	struct fc_rport *rport)
+{
+	rport->supported_classes = fcport->supported_classes;
+	rport->maxframe_size = vha->hw->init_cb->frame_payload_size;
+	rport->supported_speeds = fcport->supported_speeds;
+	rport->speed = fcport->speed;
+
+	qla2x00_gft_id(vha, fcport);
+	memcpy(rport->supported_fc4s, fcport->supported_fc4s,
+	    sizeof(rport->supported_fc4s));
+	/* For now just use the information from gft_id for active_fc4s */
+	memcpy(rport->active_fc4s, fcport->supported_fc4s,
+	    sizeof(rport->active_fc4s));
+
+	qla2x00_gpt_id(vha, fcport);
+	rport->port_type = fcport->rport_type;
+
+	qla2x00_gspn_id(vha, fcport);
+	memcpy(rport->symbolic_name, fcport->symbolic_name,
+	    sizeof(rport->symbolic_name));
+
+	qla2x00_gfn(vha, fcport);
+	memcpy(&rport->fabric_name, fcport->fabric_name, 8);
+}
+
+static void
 qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
 {
 	struct fc_rport_identifiers rport_ids;
@@ -2895,7 +2929,7 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
 	*((fc_port_t **)rport->dd_data) = fcport;
 	spin_unlock_irq(fcport->vha->host->host_lock);
 
-	rport->supported_classes = fcport->supported_classes;
+	qla2x00_update_rport_attrs(vha, fcport, rport);
 
 	rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
 	if (fcport->port_type == FCT_INITIATOR)
@@ -3224,6 +3258,8 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha,
 				    swl[swl_idx].fabric_port_name, WWN_SIZE);
 				new_fcport->fp_speed = swl[swl_idx].fp_speed;
 				new_fcport->fc4_type = swl[swl_idx].fc4_type;
+				new_fcport->supported_speeds =
+				    swl[swl_idx].supported_speeds;
 
 				if (swl[swl_idx].d_id.b.rsvd_1 != 0) {
 					last_dev = 1;
Signature · 1 line
1.6.4.2