[GM API]: Question on waiting for callback completion

"rwillis" <[email protected]> Mon, 21 Apr 2003 15:58:30 -0700
Newsgroups gmane.network.myrinet.general
Message-ID <[email protected]>
 I noticed that I am missing callback events when I tell gm_recv to
immediately sleep while waiting for an event, by calling;

        gm_blocking_receive_no_spin(HND->myport).

If I poll, using;

	  while ( !gm_receive_pending(HND->myport) ) {}
            event = gm_receive(HND->myport);

then I always catch the Tx completed, and get the callback executed via
gm_unknwon().

 I am using this code to look for TX complete events, am I missing
something?

        // decode the event...
        switch ( gm_ntoh_u8(event->recv.type) )
        {
        //case GM_SENT_EVENT:
        case GM_SENT_TOKENS_EVENT:
            // transmission completed
            #ifdef GMIO_NO_USE_CALLBACK
            // send event has been completed, restore a tx token.
            HND->context.tx_tokens++;
            #else
            // call gm_unknown() to handle callback
            gm_unknown( HND->myport, event );
            #endif
            #ifdef _GMIO_DEBUG_
            printf("[gmio_recv]:(gmio_trans completed).\n");
            #endif
            *Rx_state = GMIO_RXS_TXGOOD;
            if (CheckTrans) {
                #ifdef _GMIO_DEBUG_
                printf("[gmio_recv]:CheckTrans asserted, returning now.\n");
                #endif
                msg = NULL;
                got_msg = 1;    // return to report transmission
            }
            break;

        case GM_FAST_RECV_EVENT:
        case GM_FAST_HIGH_RECV_EVENT:
        case GM_FAST_PEER_RECV_EVENT:
        case GM_FAST_HIGH_PEER_RECV_EVENT:
            // message is in the queue and can be reached using
            // event->recv.message as the pointer. THIS IS NOT AN RX BUFFER!
            *FastFlag = 1;
        case GM_RECV_EVENT:
        case GM_HIGH_RECV_EVENT:
            // include peer events as well, else they get re-gurgitated
            // by gm_unknown()
        case GM_PEER_RECV_EVENT:
        case GM_HIGH_PEER_RECV_EVENT:
            *sourcePORT = (t_uint32)gm_ntoh_u8(event->recv.sender_port_id);
            *sourceNODE = (t_uint32)gm_ntoh_u16(event->recv.sender_node_id);
            *msglength  = (t_uint32)gm_ntoh_u32(event->recv.length);
            *bufferSIZE = (t_uint32)gm_ntoh_u8(event->recv.size);
            *bufnum     = (t_uint8)gm_ntoh_u8(event->recv.tag);
            *Rx_state   = GMIO_RXS_GOOD;  // message arrived (high or low
prio)
            #ifdef _GMIO_DEBUG_
            printf ("[gmio_recv]:Received message of %d bytes\n",
                gm_ntoh_u32( event->recv.length ) );
            #endif
            HND->rx_tokens++;   // give the token back...

            if (*FastFlag == 1) {
                // get the data from the GM queue...
                msg = (void *)gm_ntohp(event->recv.message);
            }
            else {
                // get the data from a consumed Rx buffer...
                msg = (void *)gm_ntohp(event->recv.buffer);
            }
            got_msg = 1; // return with the msg
            break;
        default:
            #ifdef _GMIO_DEBUG_
            printf("[gmio_recv]:Note, unknown event [%d] ... re-cycling
through GM.\n",
                gm_ntoh_u8(event->recv.type));
            #endif
            *Rx_state = GMIO_RXS_UNKNOWN;
            gm_unknown( HND->myport, event );
        } // switch ( gm_ntoh_u8(event->recv.type) )

BTW, when I miss the callback, I get two events. The first is 4
(_GM_SLEEP_EVENT), then I get GM_SENT_TOKENS_EVENT as the second event, but
when gm_unknown() is called, it does not call my callback function !?.

 - Richard

=====================================================================
Richard Willis, B.Eng (EIT)		[email protected]
CTF Systems INC					Tel 604-941-8561
Suite-15 1750 McLean Ave		FAX 604-941-8565
Port Coquitlam, B.C.
CANADA V3C 1M9
=====================================================================