pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)

{

    int i;

    uint32_t txr_len_log2, rxr_len_log2;

    uint32_t req_ring_size, cmp_ring_size;

    m->rs_pa = ri->ringsStatePPN << VMW_PAGE_SHIFT;



    if ((ri->reqRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)

        || (ri->cmpRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)) {

        return -1;

    }

    req_ring_size = ri->reqRingNumPages * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;

    cmp_ring_size = ri->cmpRingNumPages * PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE;

    txr_len_log2 = pvscsi_log2(req_ring_size - 1);

    rxr_len_log2 = pvscsi_log2(cmp_ring_size - 1);



    m->txr_len_mask = MASK(txr_len_log2);

    m->rxr_len_mask = MASK(rxr_len_log2);



    m->consumed_ptr = 0;

    m->filled_cmp_ptr = 0;



    for (i = 0; i < ri->reqRingNumPages; i++) {

        m->req_ring_pages_pa[i] = ri->reqRingPPNs[i] << VMW_PAGE_SHIFT;

    }



    for (i = 0; i < ri->cmpRingNumPages; i++) {

        m->cmp_ring_pages_pa[i] = ri->cmpRingPPNs[i] << VMW_PAGE_SHIFT;

    }



    RS_SET_FIELD(m, reqProdIdx, 0);

    RS_SET_FIELD(m, reqConsIdx, 0);

    RS_SET_FIELD(m, reqNumEntriesLog2, txr_len_log2);



    RS_SET_FIELD(m, cmpProdIdx, 0);

    RS_SET_FIELD(m, cmpConsIdx, 0);

    RS_SET_FIELD(m, cmpNumEntriesLog2, rxr_len_log2);



    trace_pvscsi_ring_init_data(txr_len_log2, rxr_len_log2);



    /* Flush ring state page changes */

    smp_wmb();



    return 0;

}

pvscsi_ring_init_data(PVSCSIRingInfo *m, PVSCSICmdDescSetupRings *ri)

{

    int i;

    uint32_t txr_len_log2, rxr_len_log2;

    uint32_t req_ring_size, cmp_ring_size;

    m->rs_pa = ri->ringsStatePPN << VMW_PAGE_SHIFT;



    if ((ri->reqRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)

        || (ri->cmpRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)) {

        return -1;

    }

    req_ring_size = ri->reqRingNumPages * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;

    cmp_ring_size = ri->cmpRingNumPages * PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE;

    txr_len_log2 = pvscsi_log2(req_ring_size - 1);

    rxr_len_log2 = pvscsi_log2(cmp_ring_size - 1);



    m->txr_len_mask = MASK(txr_len_log2);

    m->rxr_len_mask = MASK(rxr_len_log2);



    m->consumed_ptr = 0;

    m->filled_cmp_ptr = 0;



    for (i = 0; i < ri->reqRingNumPages; i++) {

        m->req_ring_pages_pa[i] = ri->reqRingPPNs[i] << VMW_PAGE_SHIFT;

    }



    for (i = 0; i < ri->cmpRingNumPages; i++) {

        m->cmp_ring_pages_pa[i] = ri->cmpRingPPNs[i] << VMW_PAGE_SHIFT;

    }



    RS_SET_FIELD(m, reqProdIdx, 0);

    RS_SET_FIELD(m, reqConsIdx, 0);

    RS_SET_FIELD(m, reqNumEntriesLog2, txr_len_log2);



    RS_SET_FIELD(m, cmpProdIdx, 0);

    RS_SET_FIELD(m, cmpConsIdx, 0);

    RS_SET_FIELD(m, cmpNumEntriesLog2, rxr_len_log2);



    trace_pvscsi_ring_init_data(txr_len_log2, rxr_len_log2);



    

    smp_wmb();



    return 0;

}

FUNC_0(PVSCSIRingInfo *VAR_0, PVSCSICmdDescSetupRings *VAR_1)

{

    int VAR_2;

    uint32_t txr_len_log2, rxr_len_log2;

    uint32_t req_ring_size, cmp_ring_size;

    VAR_0->rs_pa = VAR_1->ringsStatePPN << VMW_PAGE_SHIFT;



    if ((VAR_1->reqRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)

        || (VAR_1->cmpRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)) {

        return -1;

    }

    req_ring_size = VAR_1->reqRingNumPages * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;

    cmp_ring_size = VAR_1->cmpRingNumPages * PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE;

    txr_len_log2 = pvscsi_log2(req_ring_size - 1);

    rxr_len_log2 = pvscsi_log2(cmp_ring_size - 1);



    VAR_0->txr_len_mask = MASK(txr_len_log2);

    VAR_0->rxr_len_mask = MASK(rxr_len_log2);



    VAR_0->consumed_ptr = 0;

    VAR_0->filled_cmp_ptr = 0;



    for (VAR_2 = 0; VAR_2 < VAR_1->reqRingNumPages; VAR_2++) {

        VAR_0->req_ring_pages_pa[VAR_2] = VAR_1->reqRingPPNs[VAR_2] << VMW_PAGE_SHIFT;

    }



    for (VAR_2 = 0; VAR_2 < VAR_1->cmpRingNumPages; VAR_2++) {

        VAR_0->cmp_ring_pages_pa[VAR_2] = VAR_1->cmpRingPPNs[VAR_2] << VMW_PAGE_SHIFT;

    }



    RS_SET_FIELD(VAR_0, reqProdIdx, 0);

    RS_SET_FIELD(VAR_0, reqConsIdx, 0);

    RS_SET_FIELD(VAR_0, reqNumEntriesLog2, txr_len_log2);



    RS_SET_FIELD(VAR_0, cmpProdIdx, 0);

    RS_SET_FIELD(VAR_0, cmpConsIdx, 0);

    RS_SET_FIELD(VAR_0, cmpNumEntriesLog2, rxr_len_log2);



    trace_pvscsi_ring_init_data(txr_len_log2, rxr_len_log2);



    

    smp_wmb();



    return 0;

}

FUNC_0(PVSCSIRingInfo *VAR_0, PVSCSICmdDescSetupRings *VAR_1)
{ int VAR_2; uint32_t txr_len_log2, rxr_len_log2; uint32_t req_ring_size, cmp_ring_size; VAR_0->rs_pa = VAR_1->ringsStatePPN << VMW_PAGE_SHIFT; if ((VAR_1->reqRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)
|| (VAR_1->cmpRingNumPages > PVSCSI_SETUP_RINGS_MAX_NUM_PAGES)) { return -1; } req_ring_size = VAR_1->reqRingNumPages * PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; cmp_ring_size = VAR_1->cmpRingNumPages * PVSCSI_MAX_NUM_CMP_ENTRIES_PER_PAGE; txr_len_log2 = pvscsi_log2(req_ring_size - 1); rxr_len_log2 = pvscsi_log2(cmp_ring_size - 1); VAR_0->txr_len_mask = MASK(txr_len_log2); VAR_0->rxr_len_mask = MASK(rxr_len_log2); VAR_0->consumed_ptr = 0; VAR_0->filled_cmp_ptr = 0; for (VAR_2 = 0; VAR_2 < VAR_1->reqRingNumPages; VAR_2++) { VAR_0->req_ring_pages_pa[VAR_2] = VAR_1->reqRingPPNs[VAR_2] << VMW_PAGE_SHIFT; } for (VAR_2 = 0; VAR_2 < VAR_1->cmpRingNumPages; VAR_2++) { VAR_0->cmp_ring_pages_pa[VAR_2] = VAR_1->cmpRingPPNs[VAR_2] << VMW_PAGE_SHIFT; } RS_SET_FIELD(VAR_0, reqProdIdx, 0); RS_SET_FIELD(VAR_0, reqConsIdx, 0); RS_SET_FIELD(VAR_0, reqNumEntriesLog2, txr_len_log2); RS_SET_FIELD(VAR_0, cmpProdIdx, 0); RS_SET_FIELD(VAR_0, cmpConsIdx, 0); RS_SET_FIELD(VAR_0, cmpNumEntriesLog2, rxr_len_log2); trace_pvscsi_ring_init_data(txr_len_log2, rxr_len_log2); smp_wmb(); return 0; }