2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-11-26 03:09:12 +00:00

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2010-10-07 13:17:52 +01:00
parent 88dd921e24
commit 1775a6f25e
3 changed files with 28 additions and 9 deletions

View File

@ -71,6 +71,8 @@ extern const char * fc_id_ntoa ( const struct fc_port_id *id );
extern int fc_id_aton ( const char *id_text, struct fc_port_id *id );
extern const char * fc_ntoa ( const struct fc_name *wwn );
extern int fc_aton ( const char *wwn_text, struct fc_name *wwn );
extern struct sockaddr * fc_fill_sockaddr ( struct sockaddr_fc *sa_fc,
struct fc_port_id *id );
/******************************************************************************
*

View File

@ -146,6 +146,26 @@ int fc_aton ( const char *wwn_text, struct fc_name *wwn ) {
}
}
/**
* Fill Fibre Channel socket address
*
* @v sa_fc Fibre Channel socket address to fill in
* @v id Fibre Channel port ID
* @ret sa Socket address
*/
struct sockaddr * fc_fill_sockaddr ( struct sockaddr_fc *sa_fc,
struct fc_port_id *id ) {
union {
struct sockaddr sa;
struct sockaddr_fc fc;
} *u = container_of ( sa_fc, typeof ( *u ), fc );
memset ( sa_fc, 0, sizeof ( *sa_fc ) );
sa_fc->sfc_family = AF_FC;
memcpy ( &sa_fc->sfc_port_id, id, sizeof ( sa_fc->sfc_port_id ) );
return &u->sa;
}
/******************************************************************************
*
* Fibre Channel link state
@ -549,6 +569,8 @@ static int fc_xchg_rx ( struct fc_exchange *xchg, struct io_buffer *iobuf,
struct fc_port *port = xchg->port;
struct fc_frame_header *fchdr = iobuf->data;
struct xfer_metadata fc_meta;
struct sockaddr_fc src;
struct sockaddr_fc dest;
int rc;
/* Record peer exchange ID */
@ -605,6 +627,8 @@ static int fc_xchg_rx ( struct fc_exchange *xchg, struct io_buffer *iobuf,
fc_meta.flags |= XFER_FL_ABS_OFFSET;
fc_meta.offset = ntohl ( fchdr->parameter );
}
fc_meta.src = fc_fill_sockaddr ( &src, &fchdr->s_id );
fc_meta.dest = fc_fill_sockaddr ( &dest, &fchdr->d_id );
/* Reset timeout */
start_timer_fixed ( &xchg->timer, FC_TIMEOUT );

View File

@ -119,25 +119,18 @@ static struct fc_els_handler * fc_els_detect ( struct fc_els *els,
* @ret rc Return status code
*/
int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) {
union {
struct sockaddr sa;
struct sockaddr_fc fc;
} dest;
struct xfer_metadata meta;
struct sockaddr_fc dest;
int rc;
DBGC2 ( els, FCELS_FMT " transmitting:\n", FCELS_ARGS ( els ) );
DBGC2_HDA ( els, 0, data, len );
/* Construct metadata */
memset ( &dest, 0, sizeof ( dest ) );
dest.fc.sfc_family = AF_FC;
memcpy ( &dest.fc.sfc_port_id, &els->peer_port_id,
sizeof ( dest.fc.sfc_port_id ) );
memset ( &meta, 0, sizeof ( meta ) );
meta.flags = ( fc_els_is_request ( els ) ?
XFER_FL_OVER : ( XFER_FL_RESPONSE | XFER_FL_OUT ) );
meta.dest = &dest.sa;
meta.dest = fc_fill_sockaddr ( &dest, &els->peer_port_id );
/* Transmit frame */
if ( ( rc = xfer_deliver_raw_meta ( &els->xchg, data, len,