static int table_reverse_lookup(struct gnix_fid_av *av_priv, struct gnix_address gnix_addr, fi_addr_t *fi_addr) { struct gnix_av_addr_entry *entry; int i; for (i = 0; i < av_priv->count; i++) { entry = &av_priv->table[i]; /* * for SEP endpoint entry we may have a delta in the cdm_id * component of the address to process */ if ((entry->name_type & GNIX_EPN_TYPE_SEP) && (entry->gnix_addr.device_addr == gnix_addr.device_addr)) { int index = gnix_addr.cdm_id - entry->gnix_addr.cdm_id; if ((index >= 0) && (index < entry->rx_ctx_cnt)) { /* we have a match */ *fi_addr = fi_rx_addr(i, index, av_priv->rx_ctx_bits); return FI_SUCCESS; } } else if (GNIX_ADDR_EQUAL(entry->gnix_addr, gnix_addr)) { *fi_addr = i; return FI_SUCCESS; } } return -FI_ENOENT; }
static int map_reverse_lookup(struct gnix_fid_av *int_av, struct gnix_address gnix_addr, fi_addr_t *fi_addr) { GNIX_HASHTABLE_ITERATOR(int_av->map_ht, iter); struct gnix_av_addr_entry *entry; while ((entry = _gnix_ht_iterator_next(&iter))) { if (GNIX_ADDR_EQUAL(entry->gnix_addr, gnix_addr)) { *fi_addr = GNIX_HASHTABLE_ITERATOR_KEY(iter); return FI_SUCCESS; } } return -FI_ENOENT; }
static int table_reverse_lookup(struct gnix_fid_av *av_priv, struct gnix_address gnix_addr, fi_addr_t *fi_addr) { struct gnix_av_addr_entry *entry; int i; for (i = 0; i < av_priv->count; i++) { entry = &av_priv->table[i]; if (GNIX_ADDR_EQUAL(entry->gnix_addr, gnix_addr)) { *fi_addr = i; return FI_SUCCESS; } } return -FI_ENOENT; }
static int map_reverse_lookup(struct gnix_fid_av *av_priv, struct gnix_address gnix_addr, fi_addr_t *fi_addr) { GNIX_HASHTABLE_ITERATOR(av_priv->map_ht, iter); struct gnix_av_addr_entry *entry; fi_addr_t rx_addr; while ((entry = _gnix_ht_iterator_next(&iter))) { /* * for SEP endpoint entry we may have a delta in the cdm_id * component of the address to process */ if ((entry->name_type & GNIX_EPN_TYPE_SEP) && (entry->gnix_addr.device_addr == gnix_addr.device_addr)) { int index = gnix_addr.cdm_id - entry->gnix_addr.cdm_id; if ((index >= 0) && (index < entry->rx_ctx_cnt)) { /* we have a match */ memcpy(&rx_addr, &entry->gnix_addr, sizeof(fi_addr_t)); *fi_addr = fi_rx_addr(rx_addr, index, av_priv->rx_ctx_bits); return FI_SUCCESS; } } else { if (GNIX_ADDR_EQUAL(entry->gnix_addr, gnix_addr)) { *fi_addr = GNIX_HASHTABLE_ITERATOR_KEY(iter); return FI_SUCCESS; } } } return -FI_ENOENT; }
int _gnix_cm_nic_send(struct gnix_cm_nic *cm_nic, char *sbuf, size_t len, struct gnix_address target_addr) { int ret = FI_SUCCESS; struct gnix_datagram *dgram = NULL; ssize_t __attribute__((unused)) plen; uint8_t tag; struct gnix_work_req *work_req; GNIX_TRACE(FI_LOG_EP_CTRL, "\n"); if ((cm_nic == NULL) || (sbuf == NULL)) return -FI_EINVAL; if (len > GNI_DATAGRAM_MAXSIZE) return -FI_ENOSPC; ret = _gnix_dgram_alloc(cm_nic->dgram_hndl, GNIX_DGRAM_BND, &dgram); if (ret != FI_SUCCESS) { GNIX_WARN(FI_LOG_EP_CTRL, "_gnix_dgram_alloc returned %s\n", fi_strerror(-ret)); goto exit; } dgram->target_addr = target_addr; dgram->callback_fn = __process_datagram; dgram->cache = cm_nic; tag = GNIX_CM_NIC_BND_TAG; __dgram_set_tag(dgram, tag); plen = _gnix_dgram_pack_buf(dgram, GNIX_DGRAM_IN_BUF, sbuf, len); assert (plen == len); /* If connecting with the same CM NIC, skip datagram exchange. The * caller could be holding an endpoint lock, so schedule connection * completion for later. */ if (GNIX_ADDR_EQUAL(target_addr, cm_nic->my_name.gnix_addr)) { char tmp_buf[GNIX_CM_NIC_MAX_MSG_SIZE]; /* Pack output buffer with input data. */ _gnix_dgram_unpack_buf(dgram, GNIX_DGRAM_IN_BUF, tmp_buf, GNIX_CM_NIC_MAX_MSG_SIZE); _gnix_dgram_pack_buf(dgram, GNIX_DGRAM_OUT_BUF, tmp_buf, GNIX_CM_NIC_MAX_MSG_SIZE); work_req = calloc(1, sizeof(*work_req)); if (work_req == NULL) { _gnix_dgram_free(dgram); return -FI_ENOMEM; } work_req->progress_fn = __gnix_cm_nic_intra_progress_fn; work_req->data = dgram; work_req->completer_fn = NULL; fastlock_acquire(&cm_nic->wq_lock); dlist_insert_before(&work_req->list, &cm_nic->cm_nic_wq); fastlock_release(&cm_nic->wq_lock); GNIX_INFO(FI_LOG_EP_CTRL, "Initiated intra-CM NIC connect\n"); } else { ret = _gnix_dgram_bnd_post(dgram); if (ret == -FI_EBUSY) { ret = -FI_EAGAIN; _gnix_dgram_free(dgram); } } exit: return ret; }