opal/mca/common/libfabric/libfabric/prov/usnic/src/usnic_direct/usd_ib_cmd.c
/*
 * Issue query commands for device and port and interpret the resaults
 */
Issue query commands for device and port and interpret the resaults
Issue query commands for device and port and interpret the resaults
int
usd_ib_query_dev(
    struct usd_device *dev)
{
    struct ibv_query_device_resp dresp;
    struct ibv_query_port_resp presp;
    struct usd_device_attrs *dap;
    unsigned speed;
    int ret;
    ret = usd_ib_cmd_query_device(dev, &dresp);
    if (ret != 0)
        return ret;
    ret = usd_ib_cmd_query_port(dev, &presp);
    if (ret != 0)
        return ret;
    dap = &dev->ud_attrs;
    dap->uda_link_state =
        (presp.state == 4) ? USD_LINK_UP : USD_LINK_DOWN;
    if (dap->uda_link_state == USD_LINK_UP) {
#define MKSW(S,W) (((S)<<8)|(W))
        speed = MKSW(presp.active_speed, presp.active_width);
        switch (speed) {
        case MKSW(2, 2):
        case MKSW(8, 1):
            dap->uda_bandwidth = 10000;
            break;
        case MKSW(8, 2):
        case MKSW(32, 2):
            dap->uda_bandwidth = 40000;
            break;
        default:
            printf("Warning: unrecognized speed/width %d/%d, assuming 10G\n",
                   presp.active_speed, presp.active_width);
            dap->uda_bandwidth = 10000;
            break;
        }
    } else {
        switch (dap->uda_device_id) {
        case 0x4f: 
        case 0x84: 
        case 0x85: 
        case 0x12c: 
        case 0x137: 
        case 0x138: 
            dap->uda_bandwidth = 10000;
            break;
        case 0xcd:  
        case 0x14d: 
            dap->uda_bandwidth = 40000;
            break;
        default:
            dap->uda_bandwidth = 0;
        }
    }
    dap->uda_vendor_id = dresp.vendor_id;
    dap->uda_vendor_part_id = dresp.vendor_part_id;
    dap->uda_device_id = dresp.hw_ver;
    dap->uda_max_qp = dresp.max_qp;
    dap->uda_max_cq = dresp.max_cq;
    return 0;
}
int usd_ib_query_dev ( struct usd_device * dev ) { struct ibv_query_device_resp dresp ; struct ibv_query_port_resp presp ; struct usd_device_attrs * dap ; unsigned speed ; int ret ; ret = usd_ib_cmd_query_device ( dev , & dresp ) ; if ( ret != 0 ) return ret ; ret = usd_ib_cmd_query_port ( dev , & presp ) ; if ( ret != 0 ) return ret ; dap = & dev -> ud_attrs ; dap -> uda_link_state = ( presp . state == 4 ) ? USD_LINK_UP : USD_LINK_DOWN ; if ( dap -> uda_link_state == USD_LINK_UP ) { #define MKSW ( S , W )  (((S)<<8)|(W)) speed = MKSW ( presp . active_speed , presp . active_width ) ; switch ( speed ) { case MKSW ( 2 , 2 ) : case MKSW ( 8 , 1 ) : dap -> uda_bandwidth = 10000 ; break ; case MKSW ( 8 , 2 ) : case MKSW ( 32 , 2 ) : dap -> uda_bandwidth = 40000 ; break ; default : printf ( " \n " , presp . active_speed , presp . active_width ) ; dap -> uda_bandwidth = 10000 ; break ; } } else { switch ( dap -> uda_device_id ) { case 0x4f : case 0x84 : case 0x85 : case 0x12c : case 0x137 : case 0x138 : dap -> uda_bandwidth = 10000 ; break ; case 0xcd : case 0x14d : dap -> uda_bandwidth = 40000 ; break ; default : dap -> uda_bandwidth = 0 ; } } dap -> uda_vendor_id = dresp . vendor_id ; dap -> uda_vendor_part_id = dresp . vendor_part_id ; dap -> uda_device_id = dresp . hw_ver ; dap -> uda_max_qp = dresp . max_qp ; dap -> uda_max_cq = dresp . max_cq ; return 0 ; }
Issue query commands for device and port and interpret the resaults
Issue query commands for device and port and interpret the resaults
/* copy out the attributes we care about */ /*
     * If link it up derive bandwidth from speed and width.
     * If link is down, driver reports bad speed, try to deduce from the
     * NIC device ID.
     */ /* from pci_ids.h */ /* Vasona */ /* Cotati */ /* Lexington */ /* Calistoga */ /* Mountain View */ /* Walnut Creek */ /* icehouse */ /* clearlake */