static void insert_lid2sl_table(struct sa_query_result *r) { unsigned int i; for (i = 0; i < r->result_cnt; i++) { ib_path_rec_t *p_pr = (ib_path_rec_t *)sa_get_query_rec(r->p_result_madw, i); lid2sl_table[cl_ntoh16(p_pr->dlid)] = ib_path_rec_sl(p_pr); } }
static int get_pathrecord_info(struct mca_btl_openib_sa_qp_cache *cache, ib_sa_mad_t *req_mad, ib_sa_mad_t *resp_mad, struct ibv_send_wr *swr, uint16_t lid, uint16_t rem_lid) { struct ibv_send_wr *bswr; struct ibv_wc wc; struct timeval get_sl_rec_last_sent, get_sl_rec_last_poll; struct ibv_recv_wr *brwr; int got_sl_value, get_sl_rec_retries, rc, ne, i; ib_path_rec_t *req_path_record = ib_sa_mad_get_payload_ptr(req_mad); ib_path_rec_t *resp_path_record = ib_sa_mad_get_payload_ptr(resp_mad); got_sl_value = 0; get_sl_rec_retries = 0; rc = ibv_post_recv(cache->qp, &(cache->rwr), &brwr); if (0 != rc) { BTL_ERROR(("error posting receive on QP [0x%x] errno says: %s [%d]", cache->qp->qp_num, strerror(errno), errno)); return OPAL_ERROR; } while (0 == got_sl_value) { rc = ibv_post_send(cache->qp, swr, &bswr); if (0 != rc) { BTL_ERROR(("error posting send on QP [0x%x] errno says: %s [%d]", cache->qp->qp_num, strerror(errno), errno)); return OPAL_ERROR; } gettimeofday(&get_sl_rec_last_sent, NULL); while (0 == got_sl_value) { ne = ibv_poll_cq(cache->cq, 1, &wc); if (ne > 0 && IBV_WC_SUCCESS == wc.status && IBV_WC_RECV == wc.opcode && wc.byte_len >= MAD_BLOCK_SIZE && resp_mad->trans_id == req_mad->trans_id) { if (0 == resp_mad->status && req_path_record->slid == htons(lid) && req_path_record->dlid == htons(rem_lid)) { /* Everything matches, so we have the desired SL */ cache->sl_values[rem_lid] = ib_path_rec_sl(resp_path_record); got_sl_value = 1; /* still must repost recieve buf */ } else { /* Probably bad status, unlikely bad lid match. We will */ /* ignore response and let it time out so that we do a */ /* retry, but after a delay. We must make a new TID so */ /* the SM doesn't see it as the same request. */ req_mad->trans_id += hton64(1); } rc = ibv_post_recv(cache->qp, &(cache->rwr), &brwr); if (0 != rc) { BTL_ERROR(("error posing receive on QP[%x] errno says: %s [%d]", cache->qp->qp_num, strerror(errno), errno)); return OPAL_ERROR; } } else if (0 == ne) { /* poll did not find anything */ gettimeofday(&get_sl_rec_last_poll, NULL); i = get_sl_rec_last_poll.tv_sec - get_sl_rec_last_sent.tv_sec; i = (i * 1000000) + get_sl_rec_last_poll.tv_usec - get_sl_rec_last_sent.tv_usec; if (i > GET_SL_REC_RETRIES_TIMEOUT_MS) { get_sl_rec_retries++; BTL_VERBOSE(("[%d/%d] retries to get PathRecord", get_sl_rec_retries, MAX_GET_SL_REC_RETRIES)); if (get_sl_rec_retries > MAX_GET_SL_REC_RETRIES) { BTL_ERROR(("No response from SA after %d retries", MAX_GET_SL_REC_RETRIES)); return OPAL_ERROR; } break; /* retransmit request */ } usleep(100); /* otherwise pause before polling again */ } else if (ne < 0) { BTL_ERROR(("error polling CQ with %d: %s\n", ne, strerror(errno))); return OPAL_ERROR; } } } return 0; }