mirror of https://github.com/ipxe/ipxe.git
[fc] Include port IDs in metadata for received Fibre Channel frames
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/1/head
parent
88dd921e24
commit
1775a6f25e
|
@ -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 int fc_id_aton ( const char *id_text, struct fc_port_id *id );
|
||||||
extern const char * fc_ntoa ( const struct fc_name *wwn );
|
extern const char * fc_ntoa ( const struct fc_name *wwn );
|
||||||
extern int fc_aton ( const char *wwn_text, 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 );
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
|
|
24
src/net/fc.c
24
src/net/fc.c
|
@ -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
|
* 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_port *port = xchg->port;
|
||||||
struct fc_frame_header *fchdr = iobuf->data;
|
struct fc_frame_header *fchdr = iobuf->data;
|
||||||
struct xfer_metadata fc_meta;
|
struct xfer_metadata fc_meta;
|
||||||
|
struct sockaddr_fc src;
|
||||||
|
struct sockaddr_fc dest;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Record peer exchange ID */
|
/* 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.flags |= XFER_FL_ABS_OFFSET;
|
||||||
fc_meta.offset = ntohl ( fchdr->parameter );
|
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 */
|
/* Reset timeout */
|
||||||
start_timer_fixed ( &xchg->timer, FC_TIMEOUT );
|
start_timer_fixed ( &xchg->timer, FC_TIMEOUT );
|
||||||
|
|
|
@ -119,25 +119,18 @@ static struct fc_els_handler * fc_els_detect ( struct fc_els *els,
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) {
|
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 xfer_metadata meta;
|
||||||
|
struct sockaddr_fc dest;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
DBGC2 ( els, FCELS_FMT " transmitting:\n", FCELS_ARGS ( els ) );
|
DBGC2 ( els, FCELS_FMT " transmitting:\n", FCELS_ARGS ( els ) );
|
||||||
DBGC2_HDA ( els, 0, data, len );
|
DBGC2_HDA ( els, 0, data, len );
|
||||||
|
|
||||||
/* Construct metadata */
|
/* 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 ) );
|
memset ( &meta, 0, sizeof ( meta ) );
|
||||||
meta.flags = ( fc_els_is_request ( els ) ?
|
meta.flags = ( fc_els_is_request ( els ) ?
|
||||||
XFER_FL_OVER : ( XFER_FL_RESPONSE | XFER_FL_OUT ) );
|
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 */
|
/* Transmit frame */
|
||||||
if ( ( rc = xfer_deliver_raw_meta ( &els->xchg, data, len,
|
if ( ( rc = xfer_deliver_raw_meta ( &els->xchg, data, len,
|
||||||
|
|
Loading…
Reference in New Issue