Changeset 3762 in Sophya for trunk/AddOn/TAcq


Ignore:
Timestamp:
May 2, 2010, 12:32:43 AM (15 years ago)
Author:
ansari
Message:

ajout de messages de hand-shake dans les echanges , Reza 01/05/2010

Location:
trunk/AddOn/TAcq
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/AddOn/TAcq/racqueth.cc

    r3759 r3762  
    4141  nbDma_= vec_pciw.size();
    4242
     43 //  true -> direct transfer of data to ethernet
     44  fgdirectsend_ = (par_.pci2eth_fgdirect && (swapall_==BR_Copy) ) ? true : false; 
    4345  char msg[BRTCPMSGLEN];
    4446  cout << "PCIEToEthernet/Info: Establishing TCP/IP connections ... " << endl;
     
    4850      ClientSocket sok(destname_[j], tcpportid_);
    4951      for(int ii=0; ii<BRTCPMSGLEN; ii++) msg[ii]='\0';
    50       sprintf(msg,"BAORadio-PCIEToEthernet %d %d",0,i);
     52      uint_4 dmasz = (fgdirectsend_)  ? vec_pciw_[0]->TransferSize() : 0;
     53      sprintf(msg,"BAORadio-PCIEToEthernet  %d %d %d %d %d", par_.MMgrNbPaquet(), par_.MMgrPaquetSize(), dmasz, 0,i);
     54      //           123456789012345678901234567890
    5155      sok.Send(msg,BRTCPMSGLEN);
    5256      sok.Receive(msg,BRTCPMSGLEN);
     
    5660      vskt.push_back(sok);   
    5761    }
    58     vvec_skt_.push_back(vskt);   
     62    vvec_skt_.push_back(vskt);
     63    vec_cntpaq_.push_back(0);
    5964  }
    6065  totrdsnd_ = 0;
     
    112117  }
    113118
    114   bool fgdirectsend = (par_.pci2eth_fgdirect && (swapall_==BR_Copy) ) ? true : false;   //  true -> direct transfer of data to ethernet
    115   if (fgdirectsend)
     119  if (fgdirectsend_)
    116120    cout << " PCIEToEthernet::run() Direct transfer mode DMA to Ethernet ... " << endl;
    117121  bool fgredpaq=par_.fgreducpsize;
     
    178182    if ((prtlev_>0)&&(npaqfaitg%prtmod==0))
    179183      cout << " PCIEToEthernet::run()/Info NPaqFait= " << npaqfaitg << endl;
    180     if (fgdirectsend) {  // Pas de copie / reduction de taille de paquet, on rebalance tel quel ...
     184    if (fgdirectsend_) {  // Pas de copie / reduction de taille de paquet, on rebalance tel quel ...
    181185      for (int fib=0; fib<(int) nbDma_ ;fib++) {
    182186        //DBG cout << " DEBUG*B fib=" << fib << " Datas[fib]=" << hex << Datas[fib] << dec << endl;
     
    285289        cout << " kb" << endl;
    286290       
    287     if (!fgdirectsend) pcheck[dma].Print(cout);
     291    if (!fgdirectsend_) pcheck[dma].Print(cout);
    288292  }
    289293  cout << " --------------------------------------------------------------------" << endl;
     
    315319  vector<ClientSocket>& vskt = vvec_skt_[fib];
    316320  size_t rc=0;
     321  if (vec_cntpaq_[fib]%par_.MMgrNbPaquet() == 0) {
     322    char msg[BRTCPMSGLEN2];
     323    sprintf(msg,"PCIEToEthernet-SendCnt %d",vec_cntpaq_[fib]);
     324    for(size_t j=0; j<vskt.size(); j++) {
     325      vskt[j].Send(msg, BRTCPMSGLEN2);
     326    }
     327    if (vec_cntpaq_[fib]>0) {
     328      for(size_t j=0; j<vskt.size(); j++) {
     329        vskt[j].Receive(msg, BRTCPMSGLEN2);
     330        msg[BRTCPMSGLEN2-1]='\0';
     331        if (strncmp(msg,"EthernetReader-RecvCnt",22) != 0)
     332          cout << " PCIEToEthernet::SendToTargets/ BAD HandShake message : " << msg << endl;
     333      }
     334    }
     335  }
     336  if (eths_bsz_<16) {
     337    for(size_t j=0; j<vskt.size(); j++) {
     338      rc += vskt[j].Send((const char *)data, len);
     339      totrdsnd_ += eths_bsz_;
     340    }
     341    vec_cntpaq_[fib]++;
     342    return rc;
     343  }
    317344  size_t nblk = len/eths_bsz_;
    318345  size_t fblk = len%eths_bsz_;
     
    333360    }
    334361  }
     362  vec_cntpaq_[fib]++;
    335363  return rc;
    336364}
     
    372400    if (strncmp(msg,"BAORadio-PCIEToEthernet",23)!=0)
    373401      throw SocketException("EthernetReader:ERROR/  Bad message from PCIEToEthernet client !");
     402    int ia,ib,ic,id,ie;
     403    sscanf(msg+25,"%d %d %d %d %d",&ia,&ib,&ic,&id,&ie);
     404    if (((uint_4)ia!=par_.MMgrNbPaquet()) || ((uint_4)ib!=par_.MMgrPaquetSize())) {
     405      strcpy(msg,"BAORadio-EthernetReader-BAD MMgrNbPaquet/MMgrPaquetSize()");
     406      sok.Send(msg,BRTCPMSGLEN);
     407      throw SocketException("EthernetReader:ERROR/  Bad MMgrNbPaquet/MMgrPaquetSize() from PCIEToEthernet client !");
     408    }
    374409    for(int ii=0; ii<BRTCPMSGLEN; ii++) msg[ii]='\0';
    375410    strcpy(msg,"BAORadio-EthernetReader-OK");
     
    377412    vsok_.push_back(sok);
    378413    cout << " EthernetReader/Info connection/link" << fib << " established." << endl;
     414    vec_cntpaq_.push_back(0);
    379415  }
    380416
     
    510546size_t EthernetReader::ReceiveFromSocket(int fib, char* data, size_t len)
    511547{
    512   size_t nblk = len/ethr_bsz_;
    513   size_t fblk = len%ethr_bsz_;
    514   size_t off = 0;
    515548  size_t rc =0;
    516   if (nblk>0) {
    517     for(size_t i=0; i<nblk; i++)  {
    518       rc += vsok_[fib].Receive(data+off, ethr_bsz_);
    519       off += ethr_bsz_; 
    520     }
    521   }
    522   if (fblk>0) {
    523     rc += vsok_[fib].Receive(data+off, fblk);
    524   }
     549  if (vec_cntpaq_[fib]%par_.MMgrNbPaquet() == 0) {
     550    char msg[BRTCPMSGLEN2];
     551    msg[0]='\0';
     552    vsok_[fib].Receive(msg, BRTCPMSGLEN2);
     553    if (strncmp(msg,"PCIEToEthernet-SendCnt",22) != 0)
     554      cout << " EthernetReader::ReceiveFromSocket/ BAD HandShake message : " << msg << endl;
     555  } 
     556
     557  if (ethr_bsz_<16) {
     558    rc += vsok_[fib].Receive(data, len);
     559  }
     560  else {
     561    size_t nblk = len/ethr_bsz_;
     562    size_t fblk = len%ethr_bsz_;
     563    size_t off = 0;
     564    if (nblk>0) {
     565      for(size_t i=0; i<nblk; i++)  {
     566        rc += vsok_[fib].Receive(data+off, ethr_bsz_);
     567        off += ethr_bsz_; 
     568      }
     569    }
     570    if (fblk>0) {
     571      rc += vsok_[fib].Receive(data+off, fblk);
     572    }
     573  }
     574  vec_cntpaq_[fib]++;
     575
     576  if (vec_cntpaq_[fib]%par_.MMgrNbPaquet() == 0) {
     577    char msg[BRTCPMSGLEN2];
     578    sprintf(msg,"EthernetReader-RecvCnt %d",vec_cntpaq_[fib]);
     579    vsok_[fib].Send(msg, BRTCPMSGLEN2);
     580  } 
    525581  return rc;
    526582}
  • trunk/AddOn/TAcq/racqueth.h

    r3759 r3762  
    4040#define BRTCPMSGLEN 128
    4141#endif
     42#ifndef BRTCPMSGLEN2
     43#define BRTCPMSGLEN2 64
     44#endif
    4245
    4346
     
    7174  int tcpportid_;
    7275  vector< vector<ClientSocket> > vvec_skt_;
     76  vector< uint_4 > vec_cntpaq_;
    7377  uint_4 packSize_;
    7478  uint_4 packSizeInMgr_;
    7579  uint_4 nbDma_;
    7680  uint_8 totrdsnd_;
     81  bool fgdirectsend_;  //  true -> direct transfer of DMA data to ethernet
    7782  size_t eths_bsz_;
    7883  int prtlev_;
     
    116121  int tcpportid_;
    117122  vector< Socket > vsok_;  //  Les sockets de lecture pour chaque fibre/lien
     123  vector< uint_4 > vec_cntpaq_;
    118124  bool stop_;
    119125  bool rdsamefc_;  // if true, read paquets with same value of FrameCounter on different fibers/link
Note: See TracChangeset for help on using the changeset viewer.