OpenCores
URL https://opencores.org/ocsvn/funbase_ip_library/funbase_ip_library/trunk

Subversion Repositories funbase_ip_library

[/] [funbase_ip_library/] [trunk/] [TUT/] [ip.swp.api/] [mcapi_transport_hibi_fdev/] [1.0/] [src/] [trans_hibi_fdev.c] - Diff between revs 172 and 175

Show entire file | Details | Blame | View Log

Rev 172 Rev 175
Line 163... Line 163...
int mcapi_debug = 0;
int mcapi_debug = 0;
 
 
/* global my node id number */
/* global my node id number */
mcapi_uint_t my_node_id = 255;
mcapi_uint_t my_node_id = 255;
 
 
 
int cfg_fdev = 0;
//int cpu0_dev;
//int cpu0_dev;
 
 
 
typedef struct {
 
  mcapi_endpoint_t recv_ep;
 
  int pkt_fdev;
 
} pkt_chan;
 
 
 
typedef struct {
 
  mcapi_endpoint_t recv_ep;
 
  int scl_fdev;
 
} scl_chan;
 
 
 
 
 
 
 
pkt_chan pkt_channels[MAX_CHANNELS];
 
scl_chan scl_channels[MAX_CHANNELS];
 
 
 
 
 
 
 
int scl_chan_idx, pkt_chan_idx  = 0;
 
 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//                                                                          //
//                                                                          //
//                   mcapi_trans API                                        //
//                   mcapi_trans API                                        //
//                                                                          //
//                                                                          //
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
Line 207... Line 226...
  PARAMETERS: node_num: the node number
  PARAMETERS: node_num: the node number
  RETURN VALUE: boolean: success or failure
  RETURN VALUE: boolean: success or failure
***************************************************************************/
***************************************************************************/
mcapi_boolean_t mcapi_trans_initialize(mcapi_uint_t node_num)
mcapi_boolean_t mcapi_trans_initialize(mcapi_uint_t node_num)
{
{
        int i = 0;
 
        mcapi_boolean_t rc = MCAPI_TRUE;
        mcapi_boolean_t rc = MCAPI_TRUE;
 
 
        mcapi_trans_initialize_database();
        mcapi_trans_initialize_database();
 
 
        //rc = mcapi_trans_initialize_();
        //rc = mcapi_trans_initialize_();
Line 221... Line 240...
        }
        }
 
 
 
 
        my_node_id = node_num;
        my_node_id = node_num;
 
 
        printf("opening devices \n");
        // open file device for receiving channel configurations
        for(i = 0; i < FDEV_COUNT ; i++)
        cfg_fdev = open(dev_names[my_node_id], O_RDWR, 0x700);
        {
        ioctl(cfg_fdev,SET_HIBI_RX_ADDR, (void*) (hibiEndAddresses[my_node_id] ));
                fdevs[i] = open(dev_names[i], O_RDWR, 0x700);
        ioctl(cfg_fdev,SET_HIBI_RX_PACKETS,(void*) 4);
                if (fdevs[i] == -1) rc = MCAPI_FALSE;
        ioctl(cfg_fdev,SET_HIBI_RX_BLOCKING,(void*) HIBI_READ_BLOCKING_MODE);
 
 
        }
        //create task to poll this
 
 
 
 
 
        //printf("opening devices \n");
 
        /*for(i = 0; i < FDEV_COUNT ; i++)
 
        {
 
                fdevs[i] = open(dev_names[i], O_RDWR, 0x700);
 
                if (fdevs[i] == -1) rc = MCAPI_FALSE;
 
 
 
        }
 
*/
  return rc;
  return rc;
}
}
 
 
/***************************************************************************
/***************************************************************************
  NAME: mcapi_trans_initialize_database
  NAME: mcapi_trans_initialize_database
Line 1088... Line 1116...
 
 
 
 
  /* unlock the database */
  /* unlock the database */
  // mcapi_trans_access_database_post();
  // mcapi_trans_access_database_post();
 
 
 
  //Open device for local endpoint to receive messages
 
   //int fdev = 0;
 
   fdevs[node_num] = open(dev_names[node_num], O_RDWR, 0x700);
 
 
  ioctl(fdevs[node_num],SET_HIBI_RX_ADDR,(void*) (hibiBaseAddresses[node_num] | port_num)  );
  ioctl(fdevs[node_num],SET_HIBI_RX_ADDR,(void*) (hibiBaseAddresses[node_num] | port_num)  );
  ioctl(fdevs[node_num],SET_HIBI_RX_PACKETS,(void*) DEFAULT_MSG_SIZE);
  ioctl(fdevs[node_num],SET_HIBI_RX_PACKETS,(void*) DEFAULT_MSG_SIZE);
  ioctl(fdevs[node_num],SET_HIBI_RX_BLOCKING,(void*) HIBI_READ_BLOCKING_MODE);
  ioctl(fdevs[node_num],SET_HIBI_RX_BLOCKING,(void*) HIBI_READ_BLOCKING_MODE);
 
 
Line 1277... Line 1308...
***************************************************************************/
***************************************************************************/
 void mcapi_trans_msg_send_i( mcapi_endpoint_t  send_endpoint, mcapi_endpoint_t  receive_endpoint,
 void mcapi_trans_msg_send_i( mcapi_endpoint_t  send_endpoint, mcapi_endpoint_t  receive_endpoint,
                            char* buffer, size_t buffer_size, mcapi_request_t* request,
                            char* buffer, size_t buffer_size, mcapi_request_t* request,
                             mcapi_status_t* mcapi_status)
                             mcapi_status_t* mcapi_status)
{
{
  int port_id,node_id = 0;
  int port_id,node_id ,fdev = 0;
  uint16_t sn,se;
  uint16_t sn,se;
  uint16_t rn,re;
  uint16_t rn,re;
  /* if errors were found at the mcapi layer, then the request is considered complete */
  /* if errors were found at the mcapi layer, then the request is considered complete */
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
  mcapi_boolean_t rv = MCAPI_FALSE;
  mcapi_boolean_t rv = MCAPI_FALSE;
Line 1305... Line 1336...
    //assert (c_db->nodes[sn].node_d.endpoints[se].recv_queue.channel_type == MCAPI_NO_CHAN);
    //assert (c_db->nodes[sn].node_d.endpoints[se].recv_queue.channel_type == MCAPI_NO_CHAN);
    //assert (c_db->nodes[rn].node_d.endpoints[re].recv_queue.channel_type == MCAPI_NO_CHAN);
    //assert (c_db->nodes[rn].node_d.endpoints[re].recv_queue.channel_type == MCAPI_NO_CHAN);
 
 
 
 
 
 
    printf("TRANS: Sending message...\n");
    //printf("TRANS: Sending message...\n");
    // TODO: FILE_DEVICE send_data
    // TODO: FILE_DEVICE send_data
    port_id = receive_endpoint & 0x0000FFFF;
    port_id = receive_endpoint & 0x0000FFFF;
    node_id = receive_endpoint >> 16;
    node_id = receive_endpoint >> 16;
 
 
 
        fdev = open(dev_names[node_id], O_RDWR, 0x700);
 
 
 
 
    if(port_id != 0)
    if(port_id != 0)
    {
    {
        lseek(fdevs[node_id], port_id, SEEK_SET);
        lseek(fdevs[node_id], port_id, SEEK_SET);
    }
    }
    write(fdevs[node_id], buffer , buffer_size);
    write(fdevs[node_id], buffer , buffer_size);
 
 
 
        close(fdevs[node_id]);
 
 
    //if (!mcapi_trans_send_internal (sn,se,rn,re,buffer,buffer_size,MCAPI_FALSE,0)) {
    //if (!mcapi_trans_send_internal (sn,se,rn,re,buffer,buffer_size,MCAPI_FALSE,0)) {
      /* assume couldn't get a buffer */
      /* assume couldn't get a buffer */
    // *mcapi_status = MCAPI_ENO_BUFFER;
    // *mcapi_status = MCAPI_ENO_BUFFER;
    //}
    //}
 
 
Line 1411... Line 1447...
  ioctl(fdevs[rn],SET_HIBI_RX_PACKETS,(void*) DEFAULT_MSG_SIZE);
  ioctl(fdevs[rn],SET_HIBI_RX_PACKETS,(void*) DEFAULT_MSG_SIZE);
  ioctl(fdevs[rn],SET_HIBI_RX_BLOCKING,(void*) HIBI_READ_BLOCKING_MODE);
  ioctl(fdevs[rn],SET_HIBI_RX_BLOCKING,(void*) HIBI_READ_BLOCKING_MODE);
 
 
 
 
  // TODO: FILE_DEV get received data from hibi_pe_dma
  // TODO: FILE_DEV get received data from hibi_pe_dma
  read(fdevs[0], (char*) &buffer, buffer_size);
  read(fdevs[rp], (char*) &buffer, buffer_size);
 
 
  // initialize msg channel
  // initialize msg channel
  //initCh(hibi_address_table[my_node_id] + receive_endpoint & 0x0000FFFF, receive_endpoint & 0x0000FFFF, (int)(rx_data), buffer_size);
  //initCh(hibi_address_table[my_node_id] + receive_endpoint & 0x0000FFFF, receive_endpoint & 0x0000FFFF, (int)(rx_data), buffer_size);
 
 
  setup_request_internal(&receive_endpoint,request,mcapi_status,completed,buffer_size,(void**)((void*)&buffer),RECV);
  setup_request_internal(&receive_endpoint,request,mcapi_status,completed,buffer_size,(void**)((void*)&buffer),RECV);
Line 1471... Line 1507...
void mcapi_trans_connect_pktchan_i( mcapi_endpoint_t  send_endpoint,
void mcapi_trans_connect_pktchan_i( mcapi_endpoint_t  send_endpoint,
                                   mcapi_endpoint_t  receive_endpoint,
                                   mcapi_endpoint_t  receive_endpoint,
                                    mcapi_request_t* request,mcapi_status_t* mcapi_status)
                                    mcapi_request_t* request,mcapi_status_t* mcapi_status)
{
{
 
 
 
  int port_id, node_id =0;
 
  char buffer;
 
 
  /* if errors were found at the mcapi layer, then the request is considered complete */
  /* if errors were found at the mcapi layer, then the request is considered complete */
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
 
 
  /* lock the database */
  /* lock the database */
  // mcapi_trans_access_database_pre();
  // mcapi_trans_access_database_pre();
Line 1483... Line 1522...
    mcapi_trans_connect_channel_internal (send_endpoint,receive_endpoint,MCAPI_PKT_CHAN);
    mcapi_trans_connect_channel_internal (send_endpoint,receive_endpoint,MCAPI_PKT_CHAN);
    completed = MCAPI_TRUE;
    completed = MCAPI_TRUE;
  }
  }
  setup_request_internal(&receive_endpoint,request,mcapi_status,completed,0,NULL,0);
  setup_request_internal(&receive_endpoint,request,mcapi_status,completed,0,NULL,0);
 
 
 
 
 
  port_id = receive_endpoint & 0x0000FFFF;
 
  node_id = receive_endpoint >> 16;
 
 
 
 
 
  // Open file device for packet channel and store receive endpoint
 
  pkt_channels[pkt_chan_idx].pkt_fdev = open((void*) fdevs[node_id], O_RDWR, 0x700);
 
  pkt_channels[pkt_chan_idx].recv_ep = receive_endpoint;
 
  pkt_chan_idx++;
 
 
 
  //Send connect message to receive nodes config channel TODO:set correct size
 
  write(fdevs[node_id],(void*) 11 ,  4);
 
 
 
  // Receive acknoledge
 
  read(cfg_fdev, (char*) &buffer, 1);
 
 
    /* unlock the database */
    /* unlock the database */
  // mcapi_trans_access_database_post();
  // mcapi_trans_access_database_post();
}
}
 
 
/***************************************************************************
/***************************************************************************
Line 1501... Line 1556...
***************************************************************************/
***************************************************************************/
 void mcapi_trans_open_pktchan_recv_i( mcapi_pktchan_recv_hndl_t* recv_handle,
 void mcapi_trans_open_pktchan_recv_i( mcapi_pktchan_recv_hndl_t* recv_handle,
                                       mcapi_endpoint_t receive_endpoint,
                                       mcapi_endpoint_t receive_endpoint,
                                       mcapi_request_t* request,mcapi_status_t* mcapi_status)
                                       mcapi_request_t* request,mcapi_status_t* mcapi_status)
{
{
    //initCh(hibi_address_table[my_node_id]+(receive_endpoint & 0x0000FFFF)  , receive_endpoint & 0x0000FFFF, (int)(rx_data), 1);
 
  uint16_t rn,re;
  uint16_t rn,re;
   /* if errors were found at the mcapi layer, then the request is considered complete */
   /* if errors were found at the mcapi layer, then the request is considered complete */
   mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
   mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
   mcapi_boolean_t rv = MCAPI_FALSE;
   mcapi_boolean_t rv = MCAPI_FALSE;
 
 
Line 1520... Line 1574...
     mcapi_trans_open_channel_internal (rn,re);
     mcapi_trans_open_channel_internal (rn,re);
 
 
     /* fill in the channel handle */
     /* fill in the channel handle */
     *recv_handle = mcapi_trans_encode_handle_internal(rn,re);
     *recv_handle = mcapi_trans_encode_handle_internal(rn,re);
 
 
 
         // TODO: read(configure)
 
 
 
 
     /* has the channel been connected yet? */
     /* has the channel been connected yet? */
     if ( c_db->nodes[rn].node_d.endpoints[re].recv_queue.channel_type == MCAPI_PKT_CHAN) {
     if ( c_db->nodes[rn].node_d.endpoints[re].recv_queue.channel_type == MCAPI_PKT_CHAN) {
       completed = MCAPI_TRUE;
       completed = MCAPI_TRUE;
     }
     }
Line 1600... Line 1656...
***************************************************************************/
***************************************************************************/
void mcapi_trans_pktchan_send_i( mcapi_pktchan_send_hndl_t send_handle,
void mcapi_trans_pktchan_send_i( mcapi_pktchan_send_hndl_t send_handle,
                                void* buffer, size_t size, mcapi_request_t* request,
                                void* buffer, size_t size, mcapi_request_t* request,
                                 mcapi_status_t* mcapi_status)
                                 mcapi_status_t* mcapi_status)
{
{
 
  int i;
  uint16_t sn,se,rn,re;
  uint16_t sn,se,rn,re;
   /* if errors were found at the mcapi layer, then the request is considered complete */
   /* if errors were found at the mcapi layer, then the request is considered complete */
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
  mcapi_boolean_t rv = MCAPI_FALSE;
  mcapi_boolean_t rv = MCAPI_FALSE;
 
 
Line 1622... Line 1679...
    /*   if (!mcapi_trans_send_internal (sn,se,rn,re,(char*)buffer,size,MCAPI_FALSE,0)) { */
    /*   if (!mcapi_trans_send_internal (sn,se,rn,re,(char*)buffer,size,MCAPI_FALSE,0)) { */
    /*       *mcapi_status = MCAPI_ENO_BUFFER; */
    /*       *mcapi_status = MCAPI_ENO_BUFFER; */
    /*     } */
    /*     } */
 
 
 
 
    write(fdevs[0], buffer , size);
  for(i=0; i < pkt_chan_idx;) {
 
        if (pkt_channels[i].recv_ep == re) break;
 
        i++;
 
  }
 
 
 
  write(pkt_channels[i].pkt_fdev, buffer , size);
 
 
 
 
    completed = MCAPI_TRUE;
    completed = MCAPI_TRUE;
  }
  }
 
 
Line 1883... Line 1945...
***************************************************************************/
***************************************************************************/
void mcapi_trans_connect_sclchan_i( mcapi_endpoint_t  send_endpoint,
void mcapi_trans_connect_sclchan_i( mcapi_endpoint_t  send_endpoint,
                                    mcapi_endpoint_t  receive_endpoint,
                                    mcapi_endpoint_t  receive_endpoint,
                                    mcapi_request_t* request,mcapi_status_t* mcapi_status)
                                    mcapi_request_t* request,mcapi_status_t* mcapi_status)
{
{
 
  int node_id, port_id = 0;
 
  char buffer;
 
 
  /* if errors were found at the mcapi layer, then the request is considered complete */
  /* if errors were found at the mcapi layer, then the request is considered complete */
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
  mcapi_boolean_t completed =  (*mcapi_status == MCAPI_SUCCESS) ? MCAPI_FALSE : MCAPI_TRUE;
 
 
  /* lock the database */
  /* lock the database */
  // mcapi_trans_access_database_pre();
  // mcapi_trans_access_database_pre();
Line 1895... Line 1960...
    mcapi_trans_connect_channel_internal (send_endpoint,receive_endpoint,MCAPI_SCL_CHAN);
    mcapi_trans_connect_channel_internal (send_endpoint,receive_endpoint,MCAPI_SCL_CHAN);
    completed = MCAPI_TRUE;
    completed = MCAPI_TRUE;
  }
  }
  setup_request_internal(&receive_endpoint,request,mcapi_status,completed,0,NULL,0);
  setup_request_internal(&receive_endpoint,request,mcapi_status,completed,0,NULL,0);
 
 
 
 
 
  port_id = receive_endpoint & 0x0000FFFF;
 
  node_id = receive_endpoint >> 16;
 
 
 
  // Open file device for packet channel and store receive endpoint
 
  scl_channels[scl_chan_idx].scl_fdev = open((void*)fdevs[node_id], O_RDWR, 0x700);
 
  scl_channels[scl_chan_idx].recv_ep = receive_endpoint;
 
  scl_chan_idx++;
 
 
 
  //Send connect message to receive nodes config channel TODO: Set correct size
 
  write(fdevs[node_id],(void*) 11 , 4);
 
 
 
  // Receive acknoledge
 
  read(cfg_fdev, (char*) &buffer, 1);
 
 
  /* unlock the database */
  /* unlock the database */
  // mcapi_trans_access_database_post();
  // mcapi_trans_access_database_post();
}
}
 
 
/***************************************************************************
/***************************************************************************
Line 2004... Line 2084...
  RETURN VALUE: MCAPI_TRUE/MCAPI_FALSE
  RETURN VALUE: MCAPI_TRUE/MCAPI_FALSE
***************************************************************************/
***************************************************************************/
mcapi_boolean_t mcapi_trans_sclchan_send(
mcapi_boolean_t mcapi_trans_sclchan_send(
    mcapi_sclchan_send_hndl_t send_handle, uint64_t dataword, uint32_t size)
    mcapi_sclchan_send_hndl_t send_handle, uint64_t dataword, uint32_t size)
{
{
 
  int i = 0;
  uint16_t sn,se,rn,re;
  uint16_t sn,se,rn,re;
  int rc = MCAPI_FALSE;
  int rc = MCAPI_FALSE;
  mcapi_boolean_t rv = MCAPI_FALSE;
  mcapi_boolean_t rv = MCAPI_FALSE;
 
 
  mcapi_dprintf(2,"  mcapi_trans_sclchan_send send_handle=%x\n",send_handle);
  mcapi_dprintf(2,"  mcapi_trans_sclchan_send send_handle=%x\n",send_handle);
Line 2020... Line 2101...
  rv = mcapi_trans_decode_handle_internal(c_db->nodes[sn].node_d.endpoints[se].recv_queue.recv_endpt,&rn,&re);
  rv = mcapi_trans_decode_handle_internal(c_db->nodes[sn].node_d.endpoints[se].recv_queue.recv_endpt,&rn,&re);
  //assert(rv);
  //assert(rv);
 
 
  rc = mcapi_trans_send_internal (sn,se,rn,re,NULL,size,MCAPI_TRUE,dataword);
  rc = mcapi_trans_send_internal (sn,se,rn,re,NULL,size,MCAPI_TRUE,dataword);
 
 
 
 for(i=0; i < scl_chan_idx;) {
 
        if (pkt_channels[i].recv_ep == re) break;
 
        i++;
 
  }
 
 
  write(fdevs[0], &dataword , size);
  write(scl_channels[i].scl_fdev, &dataword , size);
 
 
  /* unlock the database */
  /* unlock the database */
  // mcapi_trans_access_database_post();
  // mcapi_trans_access_database_post();
 
 
  return rc;
  return rc;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.