tests/daemon-proxy/mproxyd.cpp
/*
 * MPD - Management Proxy Daemon
 * This thread passes messages from userpf->mgmtpf.
 */
Management Proxy Daemon
This thread passes messages from userpf->mgmtpf.
Management Proxy Daemon This thread passes messages from userpf - > mgmtpf .
void *mpd(void *handle_ptr)
{
    int xferCount = 0;
    int ret;
    struct s_handles *h = (struct s_handles *)handle_ptr;
    size_t prev_sz = INIT_BUF_SZ;
    struct sw_chan args = { prev_sz, 0, true, 0, 0 };
    args.data = (uint32_t *)malloc(prev_sz);
    std::cout << "[XOCL->XCLMGMT Intercept ON (HAL)]\n";
    for( ;; ) {
        args.is_tx = true;
        args.sz = prev_sz;
        ret = read( h->userfd, &args, (sizeof(struct sw_chan) + args.sz) );
        if( ret <= 0 ) {
            if( errno != EMSGSIZE ) {
                std::cout << "MPD: transfer failed for other reason\n";
                exit(1);
            }
            if( resize_buffer( args.data, args.sz ) != 0 ) {
                exit(1);
            }
            prev_sz = args.sz; 
            ret = read( h->userfd, &args, (sizeof(struct sw_chan) + args.sz) );
            if( ret < 0 ) {
                std::cout << "MPD: second transfer failed, exiting.\n";
                exit(1);
            }
        }
        std::cout << "[MPD-TX]\n";
        args.is_tx = false;
        ret = write( h->mgmtfd, &args, (sizeof(struct sw_chan) + args.sz) );
        if( ret <= 0 ) {
            std::cout << "MSD: transfer error: " << strerror(errno) << std::endl;
            exit(1);
        }
        std::cout << "[MSD-RX]: " << xferCount << std::endl;
        xferCount++;
    }
    std::cout << "Exit thread XOCL->XCLMGMT\n";
}
void * mpd ( void * handle_ptr ) { int xferCount = 0 ; int ret ; struct s_handles * h = ( struct s_handles * ) handle_ptr ; size_t prev_sz = INIT_BUF_SZ ; struct sw_chan args = { prev_sz , 0 , true , 0 , 0 } ; args . data = ( uint32_t * ) malloc ( prev_sz ) ; std :: cout << " \n " ; for ( ; ; ) { args . is_tx = true ; args . sz = prev_sz ; ret = read ( h -> userfd , & args , ( sizeof ( struct sw_chan ) + args . sz ) ) ; if ( ret <= 0 ) { if ( errno != EMSGSIZE ) { std :: cout << " \n " ; exit ( 1 ) ; } if ( resize_buffer ( args . data , args . sz ) != 0 ) { exit ( 1 ) ; } prev_sz = args . sz ; ret = read ( h -> userfd , & args , ( sizeof ( struct sw_chan ) + args . sz ) ) ; if ( ret < 0 ) { std :: cout << " \n " ; exit ( 1 ) ; } } std :: cout << " \n " ; args . is_tx = false ; ret = write ( h -> mgmtfd , & args , ( sizeof ( struct sw_chan ) + args . sz ) ) ; if ( ret <= 0 ) { std :: cout << " " << strerror ( errno ) << std :: endl ; exit ( 1 ) ; } std :: cout << " " << xferCount << std :: endl ; xferCount ++ ; } std :: cout << " \n " ; }
MPD - Management Proxy Daemon
 This thread passes messages from userpf->mgmtpf.
MPD - Management Proxy Daemon This thread passes messages from userpf - > mgmtpf .
// sw channel xfer error // buffer was of insufficient size, resizing // store the newly alloc'd size