Browse Source

[fc] Include port IDs in metadata for received Fibre Channel frames

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
1775a6f25e
3 changed files with 28 additions and 9 deletions
  1. 2
    0
      src/include/ipxe/fc.h
  2. 24
    0
      src/net/fc.c
  3. 2
    9
      src/net/fcels.c

+ 2
- 0
src/include/ipxe/fc.h View File

71
 extern int fc_id_aton ( const char *id_text, struct fc_port_id *id );
71
 extern int fc_id_aton ( const char *id_text, struct fc_port_id *id );
72
 extern const char * fc_ntoa ( const struct fc_name *wwn );
72
 extern const char * fc_ntoa ( const struct fc_name *wwn );
73
 extern int fc_aton ( const char *wwn_text, struct fc_name *wwn );
73
 extern int fc_aton ( const char *wwn_text, struct fc_name *wwn );
74
+extern struct sockaddr * fc_fill_sockaddr ( struct sockaddr_fc *sa_fc,
75
+					    struct fc_port_id *id );
74
 
76
 
75
 /******************************************************************************
77
 /******************************************************************************
76
  *
78
  *

+ 24
- 0
src/net/fc.c View File

146
 	}
146
 	}
147
 }
147
 }
148
 
148
 
149
+/**
150
+ * Fill Fibre Channel socket address
151
+ *
152
+ * @v sa_fc		Fibre Channel socket address to fill in
153
+ * @v id		Fibre Channel port ID
154
+ * @ret sa		Socket address
155
+ */
156
+struct sockaddr * fc_fill_sockaddr ( struct sockaddr_fc *sa_fc,
157
+				     struct fc_port_id *id ) {
158
+	union {
159
+		struct sockaddr sa;
160
+		struct sockaddr_fc fc;
161
+	} *u = container_of ( sa_fc, typeof ( *u ), fc );
162
+
163
+	memset ( sa_fc, 0, sizeof ( *sa_fc ) );
164
+	sa_fc->sfc_family = AF_FC;
165
+	memcpy ( &sa_fc->sfc_port_id, id, sizeof ( sa_fc->sfc_port_id ) );
166
+	return &u->sa;
167
+}
168
+
149
 /******************************************************************************
169
 /******************************************************************************
150
  *
170
  *
151
  * Fibre Channel link state
171
  * Fibre Channel link state
549
 	struct fc_port *port = xchg->port;
569
 	struct fc_port *port = xchg->port;
550
 	struct fc_frame_header *fchdr = iobuf->data;
570
 	struct fc_frame_header *fchdr = iobuf->data;
551
 	struct xfer_metadata fc_meta;
571
 	struct xfer_metadata fc_meta;
572
+	struct sockaddr_fc src;
573
+	struct sockaddr_fc dest;
552
 	int rc;
574
 	int rc;
553
 
575
 
554
 	/* Record peer exchange ID */
576
 	/* Record peer exchange ID */
605
 		fc_meta.flags |= XFER_FL_ABS_OFFSET;
627
 		fc_meta.flags |= XFER_FL_ABS_OFFSET;
606
 		fc_meta.offset = ntohl ( fchdr->parameter );
628
 		fc_meta.offset = ntohl ( fchdr->parameter );
607
 	}
629
 	}
630
+	fc_meta.src = fc_fill_sockaddr ( &src, &fchdr->s_id );
631
+	fc_meta.dest = fc_fill_sockaddr ( &dest, &fchdr->d_id );
608
 
632
 
609
 	/* Reset timeout */
633
 	/* Reset timeout */
610
 	start_timer_fixed ( &xchg->timer, FC_TIMEOUT );
634
 	start_timer_fixed ( &xchg->timer, FC_TIMEOUT );

+ 2
- 9
src/net/fcels.c View File

119
  * @ret rc		Return status code
119
  * @ret rc		Return status code
120
  */
120
  */
121
 int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) {
121
 int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) {
122
-	union {
123
-		struct sockaddr sa;
124
-		struct sockaddr_fc fc;
125
-	} dest;
126
 	struct xfer_metadata meta;
122
 	struct xfer_metadata meta;
123
+	struct sockaddr_fc dest;
127
 	int rc;
124
 	int rc;
128
 
125
 
129
 	DBGC2 ( els, FCELS_FMT " transmitting:\n", FCELS_ARGS ( els ) );
126
 	DBGC2 ( els, FCELS_FMT " transmitting:\n", FCELS_ARGS ( els ) );
130
 	DBGC2_HDA ( els, 0, data, len );
127
 	DBGC2_HDA ( els, 0, data, len );
131
 
128
 
132
 	/* Construct metadata */
129
 	/* Construct metadata */
133
-	memset ( &dest, 0, sizeof ( dest ) );
134
-	dest.fc.sfc_family = AF_FC;
135
-	memcpy ( &dest.fc.sfc_port_id, &els->peer_port_id,
136
-		 sizeof ( dest.fc.sfc_port_id ) );
137
 	memset ( &meta, 0, sizeof ( meta ) );
130
 	memset ( &meta, 0, sizeof ( meta ) );
138
 	meta.flags = ( fc_els_is_request ( els ) ?
131
 	meta.flags = ( fc_els_is_request ( els ) ?
139
 		       XFER_FL_OVER : ( XFER_FL_RESPONSE | XFER_FL_OUT ) );
132
 		       XFER_FL_OVER : ( XFER_FL_RESPONSE | XFER_FL_OUT ) );
140
-	meta.dest = &dest.sa;
133
+	meta.dest = fc_fill_sockaddr ( &dest, &els->peer_port_id );
141
 
134
 
142
 	/* Transmit frame */
135
 	/* Transmit frame */
143
 	if ( ( rc = xfer_deliver_raw_meta ( &els->xchg, data, len,
136
 	if ( ( rc = xfer_deliver_raw_meta ( &els->xchg, data, len,

Loading…
Cancel
Save