pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)

{

    int i;

    uint32_t len_log2;

    uint32_t ring_size;



    if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {

        return -1;

    }

    ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;

    len_log2 = pvscsi_log2(ring_size - 1);



    m->msg_len_mask = MASK(len_log2);



    m->filled_msg_ptr = 0;



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

        m->msg_ring_pages_pa[i] = ri->ringPPNs[i] << VMW_PAGE_SHIFT;

    }



    RS_SET_FIELD(m, msgProdIdx, 0);

    RS_SET_FIELD(m, msgConsIdx, 0);

    RS_SET_FIELD(m, msgNumEntriesLog2, len_log2);



    trace_pvscsi_ring_init_msg(len_log2);



    /* Flush ring state page changes */

    smp_wmb();



    return 0;

}

pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)

{

    int i;

    uint32_t len_log2;

    uint32_t ring_size;



    if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {

        return -1;

    }

    ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;

    len_log2 = pvscsi_log2(ring_size - 1);



    m->msg_len_mask = MASK(len_log2);



    m->filled_msg_ptr = 0;



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

        m->msg_ring_pages_pa[i] = ri->ringPPNs[i] << VMW_PAGE_SHIFT;

    }



    RS_SET_FIELD(m, msgProdIdx, 0);

    RS_SET_FIELD(m, msgConsIdx, 0);

    RS_SET_FIELD(m, msgNumEntriesLog2, len_log2);



    trace_pvscsi_ring_init_msg(len_log2);



    

    smp_wmb();



    return 0;

}

FUNC_0(PVSCSIRingInfo *VAR_0, PVSCSICmdDescSetupMsgRing *VAR_1)

{

    int VAR_2;

    uint32_t len_log2;

    uint32_t ring_size;



    if (VAR_1->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {

        return -1;

    }

    ring_size = VAR_1->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;

    len_log2 = pvscsi_log2(ring_size - 1);



    VAR_0->msg_len_mask = MASK(len_log2);



    VAR_0->filled_msg_ptr = 0;



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

        VAR_0->msg_ring_pages_pa[VAR_2] = VAR_1->ringPPNs[VAR_2] << VMW_PAGE_SHIFT;

    }



    RS_SET_FIELD(VAR_0, msgProdIdx, 0);

    RS_SET_FIELD(VAR_0, msgConsIdx, 0);

    RS_SET_FIELD(VAR_0, msgNumEntriesLog2, len_log2);



    trace_pvscsi_ring_init_msg(len_log2);



    

    smp_wmb();



    return 0;

}

FUNC_0(PVSCSIRingInfo *VAR_0, PVSCSICmdDescSetupMsgRing *VAR_1)
{ int VAR_2; uint32_t len_log2; uint32_t ring_size; if (VAR_1->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) { return -1; } ring_size = VAR_1->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE; len_log2 = pvscsi_log2(ring_size - 1); VAR_0->msg_len_mask = MASK(len_log2); VAR_0->filled_msg_ptr = 0; for (VAR_2 = 0; VAR_2 < VAR_1->numPages; VAR_2++) { VAR_0->msg_ring_pages_pa[VAR_2] = VAR_1->ringPPNs[VAR_2] << VMW_PAGE_SHIFT; } RS_SET_FIELD(VAR_0, msgProdIdx, 0); RS_SET_FIELD(VAR_0, msgConsIdx, 0); RS_SET_FIELD(VAR_0, msgNumEntriesLog2, len_log2); trace_pvscsi_ring_init_msg(len_log2); smp_wmb(); return 0; }