Patchwork [Open-FCoE,2/3] fcoe: Capture role from FIP claim and claim response

login
register
mail settings
Submitter Mark Rustad
Date March 19, 2013, 11:18 p.m.
Message ID <20130319231800.2080.18134.stgit@host1-mdrustad.localdomain>
Download mbox | patch
Permalink /patch/18/
State Changes Requested
Headers show

Comments

Mark Rustad - March 19, 2013, 11:18 p.m.
Capture the node roles from the FIP claim and claim response
frames. This makes it possible to avoid logging into nodes
that are not in a compatible role. For example, there is
no reason for an initiator to login to another initiator.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Jack Morgan <jack.morgan@intel.com>
---

 drivers/scsi/fcoe/fcoe_ctlr.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 7583425..da03dde 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -2192,11 +2192,13 @@  static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
 	struct fip_wwn_desc *wwn = NULL;
 	struct fip_vn_desc *vn = NULL;
 	struct fip_size_desc *size = NULL;
+	struct fip_fc4_feat *ff;
 	struct fcoe_rport *frport;
 	size_t rlen;
 	size_t dlen;
 	u32 desc_mask = 0;
 	u32 dtype;
+	u32 fcp_feat;
 	u8 sub;
 
 	memset(rdata, 0, sizeof(*rdata) + sizeof(*frport));
@@ -2277,6 +2279,15 @@  static int fcoe_ctlr_vn_parse(struct fcoe_ctlr *fip,
 		case FIP_DT_FC4F:
 			if (dlen != sizeof(struct fip_fc4_feat))
 				goto len_err;
+
+			rdata->ids.roles = 0;
+			ff = (struct fip_fc4_feat *)desc;
+			fcp_feat = ntohl(ff->fd_ff.fd_feat[FC_TYPE_FCP * 4 / 32]);
+			fcp_feat >>= (FC_TYPE_FCP * 4) % 32;
+			if (fcp_feat & FCP_FEAT_INIT)
+				rdata->ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
+			if (fcp_feat & FCP_FEAT_TARG)
+				rdata->ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
 			break;
 		case FIP_DT_FCOE_SIZE:
 			if (dlen != sizeof(struct fip_size_desc))
@@ -2422,6 +2433,7 @@  static void fcoe_ctlr_vn_add(struct fcoe_ctlr *fip, struct fc_rport_priv *new)
 		lport->tt.rport_logoff(rdata);
 	ids->port_name = new->ids.port_name;
 	ids->node_name = new->ids.node_name;
+	ids->roles = new->ids.roles;
 	mutex_unlock(&lport->disc.disc_mutex);
 
 	frport = fcoe_ctlr_rport(rdata);