bool SCI_Transporter::init_remote() { DBUG_ENTER("SCI_Transporter::init_remote"); sci_error_t err; Uint32 offset = 0; if(!m_mapped ) { DBUG_PRINT("info", ("Map remote segments")); for(Uint32 i=0; i < m_adapters ; i++) { m_TargetSegm[i].rhm[i].remoteHandle=0; SCIConnectSegment(sciAdapters[i].scidesc, &(m_TargetSegm[i].rhm[i].remoteHandle), m_remoteNodes[i], remoteSegmentId(localNodeId, remoteNodeId), i, 0, 0, 0, 0, &err); if(err != SCI_ERR_OK) { NdbSleep_MilliSleep(10); DBUG_PRINT("error", ("Error connecting segment, err 0x%x", err)); DBUG_RETURN(false); } } // Map the remote memory segment into program space for(Uint32 i=0; i < m_adapters ; i++) { m_TargetSegm[i].mappedMemory = SCIMapRemoteSegment((m_TargetSegm[i].rhm[i].remoteHandle), &(m_TargetSegm[i].rhm[i].map), offset, m_BufferSize, NULL, FLAGS, &err); if(err!= SCI_ERR_OK) { DBUG_PRINT("error", ("Cannot map a segment to the remote node %d. Error code 0x%x", m_RemoteSciNodeId, err)); //NDB SHOULD TERMINATE AND COMPUTER REBOOTED! report_error(TE_SCI_CANNOT_MAP_REMOTESEGMENT); DBUG_RETURN(false); } } m_mapped=true; setupRemoteSegment(); setConnected(); DBUG_PRINT("info", ("connected and mapped to segment, remoteNode: %d", remoteNodeId)); DBUG_PRINT("info", ("remoteSegId: %d", remoteSegmentId(localNodeId, remoteNodeId))); DBUG_RETURN(true); } else { DBUG_RETURN(getConnectionStatus()); } }
unsigned int ShmemClientNode(void) { volatile unsigned int *remoteMapAddr1; volatile unsigned int *remoteMapAddr2; printf("here?\n"); /* Create a segmentId */ remoteSegmentId1 = 1;//(remoteNodeId1 << 16) | localNodeId1; /* Connect to remote segment */ printf("Connect to remote segment .... \n"); printf("segid = %d node %d \n",remoteSegmentId1, remoteNodeId1 ); do { SCIConnectSegment(sdOne, &remoteSegmentOne, remoteNodeId1, remoteSegmentId1, localAdapterNo, NO_CALLBACK, NULL, SCI_INFINITE_TIMEOUT, NO_FLAGS, &error); } while (error != SCI_ERR_OK); printf("connected\n"); // remoteSegmentId2 = (remoteNodeId2 << 16) | localNodeId2; // printf("segid = %d\n",remoteSegmentId2 ); printf("segid = %d node %d \n",remoteSegmentId1, remoteNodeId1 ); do { SCIConnectSegment(sdTwo, &remoteSegmentTwo, remoteNodeId2, remoteSegmentId1, standbyAdapterNo, NO_CALLBACK, NULL, SCI_INFINITE_TIMEOUT, NO_FLAGS, &error); } while (error != SCI_ERR_OK); printf("connected 3\n"); printf("Remote segment (id=0x%x) is connected.\n", remoteSegmentId2); /* Map remote segment to user space */ remoteMapAddr1 = (unsigned int*)SCIMapRemoteSegment(remoteSegmentOne,&remoteMapOne,offset,segmentSize,NULL,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Remote segment (id=0x%x) is mapped to user space @ 0x%x. \n", remoteSegmentId1, remoteMapAddr1); } else { fprintf(stderr,"SCIMapRemoteSegment failed - Error code 0x%x\n",error); return 0; } remoteMapAddr2 = (unsigned int *)SCIMapRemoteSegment(remoteSegmentTwo,&remoteMapTwo,offset,segmentSize,NULL,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("Remote segment (id=0x%x) is mapped to user space @ 0x%x. \n", remoteSegmentId2, remoteMapAddr2); } else { fprintf(stderr,"SCIMapRemoteSegment failed - Error code 0x%x\n",error); return 0; } /* Start data transfer and error checking */ error = (sci_error_t)TransferData(remoteMapOne,remoteMapAddr1, remoteMapAddr2,segmentSize); if (error == SCI_ERR_OK) { printf("Data transfer done!\n\n"); } else { fprintf(stderr,"Data transfer failed - Error code 0x%x\n\n",error); return 0; } /* Send an interrupt to remote node telling that the data transfer is ready */ error = SendInterrupt(sdOne,localAdapterNo,localNodeId1,remoteNodeId1, DATA_TRANSFER_READY); if (error == SCI_ERR_OK) { printf("\nInterrupt message sent to remote node\n"); } else { printf("\nInterrupt synchronization failed\n"); return 0; } PrintClientData(); /* Unmap remote segment */ SCIUnmapSegment(remoteMapOne,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The remote segment is unmapped\n"); } else { fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error); return 0; } SCIUnmapSegment(remoteMapTwo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The remote segment is unmapped\n"); } else { fprintf(stderr,"SCIUnmapSegment failed - Error code 0x%x\n",error); return 0; } /* Disconnect segment */ SCIDisconnectSegment(remoteSegmentOne,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The segment is disconnected\n"); } else { fprintf(stderr,"SCIDisconnectSegment failed - Error code 0x%x\n",error); return 0; } SCIDisconnectSegment(remoteSegmentTwo,NO_FLAGS,&error); if (error == SCI_ERR_OK) { printf("The segment is disconnected\n"); } else { fprintf(stderr,"SCIDisconnectSegment failed - Error code 0x%x\n",error); return 0; } return 1; }
int connexion_sci_client(client_t *cl) { int seg_size; sci_error_t retval; int ret; ret = SUCCESS; log_message("beginning - no_sci client = %d\n", cl->no_sci); log_message("connection to IT END_IO %ld on node %d\n", real_id(smdsv.THIS_NODE_ID,IT_END_IO) , cl->no_sci); SCIConnectInterrupt(cl->vd_finio, &cl->remote_fin_io_interrupt, cl->no_sci, ADAPTER_NO, real_id(smdsv.THIS_NODE_ID,IT_END_IO), SCI_INFINITE_TIMEOUT, NO_FLAGS,&retval); if (retval != SCI_ERR_OK) { log_error(" SCIConnectInterrupt IT_END_IO failed\n"); log_error("%s\n",Sci_error(retval)); ret = ERROR; } log_message("connection succeeded\n"); log_message("connection to IT ERROR_IO %ld on node %d\n", real_id(smdsv.THIS_NODE_ID,IT_ERROR_IO) , cl->no_sci); SCIConnectInterrupt(cl->vd_errorio, &cl->remote_error_io_interrupt, cl->no_sci, ADAPTER_NO, real_id(smdsv.THIS_NODE_ID,IT_ERROR_IO), SCI_INFINITE_TIMEOUT, NO_FLAGS,&retval); if (retval != SCI_ERR_OK) { log_error(" SCIConnectInterrupt IT_ERROR_IO failed\n"); log_error("%s\n",Sci_error(retval)); ret = ERROR; } log_message("connection succeeded\n"); log_message("connection to IT READY %ld on node %d\n", real_id(smdsv.THIS_NODE_ID,IT_READY) , cl->no_sci); SCIConnectInterrupt(cl->vd_ready, &cl->remote_ready_interrupt, cl->no_sci, ADAPTER_NO, real_id(smdsv.THIS_NODE_ID,IT_READY), SCI_INFINITE_TIMEOUT, NO_FLAGS,&retval); if (retval != SCI_ERR_OK) { log_error(" SCIConnectInterrupt IT_READY failed\n"); log_error("%s\n",Sci_error(retval)); ret = ERROR; } log_message("connection succeeded\n"); log_message("connection to seg DATA_READ_SEG_ID %ld on node %d (cb_arg=%p)\n", real_id(smdsv.THIS_NODE_ID, DATA_READ_SEG_ID), cl->no_sci, cl); SCIConnectSegment(cl->vd_dataread, &cl->rs_data_read_segment, cl->no_sci, real_id(smdsv.THIS_NODE_ID, DATA_READ_SEG_ID), ADAPTER_NO, remote_segment_cb, (void *)cl, SCI_INFINITE_TIMEOUT, SCI_FLAG_USE_CALLBACK, &retval); if (retval != SCI_ERR_OK) { log_error(" SCIConnectSegment DATA_READ_SEG_ID failed\n"); log_error("%s\n",Sci_error(retval)); ret = ERROR; } seg_size = SCIGetRemoteSegmentSize(cl->rs_data_read_segment); log_message("connection succeeded seg %ld size = %d bytes \n", real_id(smdsv.THIS_NODE_ID, DATA_READ_SEG_ID), seg_size); cl->addr_data_read_segment = (volatile int*)SCIMapRemoteSegment(cl->rs_data_read_segment, &cl->map_data_read_segment, 0 /* offset */, seg_size, 0 /* address hint */, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) { log_error("SCIMapRemoteSegment DATA_READ_SEG_ID failed\n"); log_error("%s\n",Sci_error(retval)); ret = ERROR; } /* SCICreateMapSequence(cl->map_data_read_segment, &cl->seq_data_read_segment, NO_FLAGS, &retval); if (retval != SCI_ERR_OK) { log_message("SCICreateMapSequenceDATA_READ_SEG_ID failed\n"); log_message("%s\n",Sci_error(retval)); ret = ERROR; }*/ return ret; }