david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[infiniband] Use correct transaction identifier in CM responses

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2016-03-04 12:24:22 +00:00
parent 8336186564
commit bd1687465c
3 changed files with 31 additions and 17 deletions

View File

@ -525,6 +525,12 @@ union ib_mad_class_specific {
struct ib_smp_class_specific smp;
} __attribute__ (( packed ));
/** A management datagram transaction identifier */
struct ib_mad_tid {
uint32_t high;
uint32_t low;
} __attribute__ (( packed ));
/** A management datagram common header
*
* Defined in section 13.4.2 of the IBA.
@ -536,7 +542,7 @@ struct ib_mad_hdr {
uint8_t method;
uint16_t status;
union ib_mad_class_specific class_specific;
uint32_t tid[2];
struct ib_mad_tid tid;
uint16_t attr_id;
uint8_t reserved[2];
uint32_t attr_mod;

View File

@ -65,6 +65,7 @@ static struct ib_connection * ib_cm_find ( uint32_t local_id ) {
*
* @v ibdev Infiniband device
* @v mi Management interface
* @v tid Transaction identifier
* @v av Address vector
* @v local_id Local communication ID
* @v remote_id Remote communication ID
@ -72,6 +73,7 @@ static struct ib_connection * ib_cm_find ( uint32_t local_id ) {
*/
static int ib_cm_send_rtu ( struct ib_device *ibdev,
struct ib_mad_interface *mi,
struct ib_mad_tid *tid,
struct ib_address_vector *av,
uint32_t local_id, uint32_t remote_id ) {
union ib_mad mad;
@ -83,6 +85,7 @@ static int ib_cm_send_rtu ( struct ib_device *ibdev,
mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
mad.hdr.class_version = IB_CM_CLASS_VERSION;
mad.hdr.method = IB_MGMT_METHOD_SEND;
memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
mad.hdr.attr_id = htons ( IB_CM_ATTR_READY_TO_USE );
rtu->local_id = htonl ( local_id );
rtu->remote_id = htonl ( remote_id );
@ -121,7 +124,8 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
conn = ib_cm_find ( local_id );
if ( conn ) {
/* Try to send "ready to use" reply */
if ( ( rc = ib_cm_send_rtu ( ibdev, mi, av, conn->local_id,
if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
conn->local_id,
conn->remote_id ) ) != 0 ) {
/* Ignore errors; the remote end will retry */
}
@ -135,6 +139,7 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
*
* @v ibdev Infiniband device
* @v mi Management interface
* @v tid Transaction identifier
* @v av Address vector
* @v local_id Local communication ID
* @v remote_id Remote communication ID
@ -142,6 +147,7 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
*/
static int ib_cm_send_drep ( struct ib_device *ibdev,
struct ib_mad_interface *mi,
struct ib_mad_tid *tid,
struct ib_address_vector *av,
uint32_t local_id, uint32_t remote_id ) {
union ib_mad mad;
@ -153,6 +159,7 @@ static int ib_cm_send_drep ( struct ib_device *ibdev,
mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
mad.hdr.class_version = IB_CM_CLASS_VERSION;
mad.hdr.method = IB_MGMT_METHOD_SEND;
memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
mad.hdr.attr_id = htons ( IB_CM_ATTR_DISCONNECT_REPLY );
drep->local_id = htonl ( local_id );
drep->remote_id = htonl ( remote_id );
@ -197,7 +204,7 @@ static void ib_cm_recv_dreq ( struct ib_device *ibdev,
}
/* Send reply */
if ( ( rc = ib_cm_send_drep ( ibdev, mi, av, local_id,
if ( ( rc = ib_cm_send_drep ( ibdev, mi, &mad->hdr.tid, av, local_id,
remote_id ) ) != 0 ) {
/* Ignore errors; the remote end will retry */
}
@ -294,7 +301,8 @@ static void ib_cm_req_complete ( struct ib_device *ibdev,
}
/* Send "ready to use" reply */
if ( ( rc = ib_cm_send_rtu ( ibdev, mi, av, conn->local_id,
if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
conn->local_id,
conn->remote_id ) ) != 0 ) {
/* Treat as non-fatal */
rc = 0;

View File

@ -106,7 +106,7 @@ static int ib_mi_handle ( struct ib_device *ibdev,
/* Otherwise, ignore it */
DBGC ( mi, "MI %p RX TID %08x%08x ignored\n",
mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
return -ENOTSUP;
}
@ -152,7 +152,7 @@ static void ib_mi_complete_recv ( struct ib_device *ibdev,
goto out;
}
DBGC ( mi, "MI %p RX TID %08x%08x (%02x,%02x,%02x,%04x) status "
"%04x\n", mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
"%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
hdr->mgmt_class, hdr->class_version, hdr->method,
ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
@ -192,12 +192,12 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
/* Set common fields */
hdr->base_version = IB_MGMT_BASE_VERSION;
if ( ( hdr->tid[0] == 0 ) && ( hdr->tid[1] == 0 ) ) {
hdr->tid[0] = htonl ( IB_MI_TID_MAGIC );
hdr->tid[1] = htonl ( ++next_tid );
if ( ( hdr->tid.high == 0 ) && ( hdr->tid.low == 0 ) ) {
hdr->tid.high = htonl ( IB_MI_TID_MAGIC );
hdr->tid.low = htonl ( ++next_tid );
}
DBGC ( mi, "MI %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
"%04x\n", mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
"%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
hdr->mgmt_class, hdr->class_version, hdr->method,
ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
@ -217,8 +217,8 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
smp->return_path.hops[hop_pointer] = ibdev->port;
} else {
DBGC ( mi, "MI %p TX TID %08x%08x invalid hop pointer "
"%d\n", mi, ntohl ( hdr->tid[0] ),
ntohl ( hdr->tid[1] ), hop_pointer );
"%d\n", mi, ntohl ( hdr->tid.high ),
ntohl ( hdr->tid.low ), hop_pointer );
return -EINVAL;
}
}
@ -228,7 +228,7 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
if ( ! iobuf ) {
DBGC ( mi, "MI %p could not allocate buffer for TID "
"%08x%08x\n",
mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
return -ENOMEM;
}
memcpy ( iob_put ( iobuf, sizeof ( *mad ) ), mad, sizeof ( *mad ) );
@ -236,7 +236,7 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
/* Send I/O buffer */
if ( ( rc = ib_post_send ( ibdev, mi->qp, av, iobuf ) ) != 0 ) {
DBGC ( mi, "MI %p TX TID %08x%08x failed: %s\n",
mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
strerror ( rc ) );
free_iob ( iobuf );
return rc;
@ -261,7 +261,7 @@ static void ib_mi_timer_expired ( struct retry_timer *timer, int expired ) {
/* Abandon transaction if we have tried too many times */
if ( expired ) {
DBGC ( mi, "MI %p abandoning TID %08x%08x\n",
mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
madx->op->complete ( ibdev, mi, madx, -ETIMEDOUT, NULL, NULL );
return;
}
@ -408,8 +408,8 @@ void ib_destroy_mi ( struct ib_device *ibdev, struct ib_mad_interface *mi ) {
/* Flush any outstanding requests */
list_for_each_entry_safe ( madx, tmp, &mi->madx, list ) {
DBGC ( mi, "MI %p destroyed while TID %08x%08x in progress\n",
mi, ntohl ( madx->mad.hdr.tid[0] ),
ntohl ( madx->mad.hdr.tid[1] ) );
mi, ntohl ( madx->mad.hdr.tid.high ),
ntohl ( madx->mad.hdr.tid.low ) );
madx->op->complete ( ibdev, mi, madx, -ECANCELED, NULL, NULL );
}