Multithreaded-software/external/soem/oshw/rtk/nicdrv.c
int ecx_getindex(ecx_portt *port)
{
   int idx;
   int cnt;

   mtx_lock (port->getindex_mutex);

   idx = port->lastidx + 1;
   /* index can't be larger than buffer array */
   if (idx >= EC_MAXBUF)
   {
      idx = 0;
   }
   cnt = 0;
   /* try to find unused index */
   while ((port->rxbufstat[idx] != EC_BUF_EMPTY) && (cnt < EC_MAXBUF))
   {
      idx++;
      cnt++;
      if (idx >= EC_MAXBUF)
      {
         idx = 0;
      }
   }
   port->rxbufstat[idx] = EC_BUF_ALLOC;
   if (port->redstate != ECT_RED_NONE)
   {
      port->redport->rxbufstat[idx] = EC_BUF_ALLOC;
   }
   port->lastidx = idx;

   mtx_unlock (port->getindex_mutex);

   return idx;
}
/** Get new frame identifier index and allocate corresponding rx buffer.
 * @param[in] port        = port context struct
 * @return new index.
 */
Get new frame identifier index and allocate corresponding rx buffer.
@param[in] port        = port context struct
@return new index.
Get new frame identifier index and allocate corresponding rx buffer . @param [ in ] port = port context struct @return new index .
int ecx_getindex(ecx_portt *port)
{
   int idx;
   int cnt;
   mtx_lock (port->getindex_mutex);
   idx = port->lastidx + 1;
   if (idx >= EC_MAXBUF)
   {
      idx = 0;
   }
   cnt = 0;
   while ((port->rxbufstat[idx] != EC_BUF_EMPTY) && (cnt < EC_MAXBUF))
   {
      idx++;
      cnt++;
      if (idx >= EC_MAXBUF)
      {
         idx = 0;
      }
   }
   port->rxbufstat[idx] = EC_BUF_ALLOC;
   if (port->redstate != ECT_RED_NONE)
   {
      port->redport->rxbufstat[idx] = EC_BUF_ALLOC;
   }
   port->lastidx = idx;
   mtx_unlock (port->getindex_mutex);
   return idx;
}
int ecx_getindex ( ecx_portt * port ) { int idx ; int cnt ; mtx_lock ( port -> getindex_mutex ) ; idx = port -> lastidx + 1 ; if ( idx >= EC_MAXBUF ) { idx = 0 ; } cnt = 0 ; while ( ( port -> rxbufstat [ idx ] != EC_BUF_EMPTY ) && ( cnt < EC_MAXBUF ) ) { idx ++ ; cnt ++ ; if ( idx >= EC_MAXBUF ) { idx = 0 ; } } port -> rxbufstat [ idx ] = EC_BUF_ALLOC ; if ( port -> redstate != ECT_RED_NONE ) { port -> redport -> rxbufstat [ idx ] = EC_BUF_ALLOC ; } port -> lastidx = idx ; mtx_unlock ( port -> getindex_mutex ) ; return idx ; }
Get new frame identifier index and allocate corresponding rx buffer.
Get new frame identifier index and allocate corresponding rx buffer .
/* index can't be larger than buffer array */ /* try to find unused index */