Update resource table with physical device address of vrings in QNX
authorvwan@ti.com <vwan@ti.com>
Tue, 15 Apr 2014 00:27:00 +0000 (17:27 -0700)
committerChris Ring <cring@ti.com>
Tue, 15 Apr 2014 20:03:00 +0000 (13:03 -0700)
The physical device address of vrings needs to be updated in the
resource table in QNX, after memory has been allocated for these
vrings. This is so that Resource_getVringDA() on the slave side
can return the correct physical device address.

Signed-off-by: VW <vwan@ti.com>
qnx/src/ipc3x_dev/ti/syslink/resources/RscTable.c

index 18acc6f400c89857d50b5358cf17cc1e6f431a2f..d805116b546a1860f8b04353a81435434f2a347c 100644 (file)
@@ -532,6 +532,11 @@ RscTable_process (UInt16 procId, Bool tryAlloc, UInt32 * numBlocks)
                     vring = (struct fw_rsc_vdev_vring *)
                                 ((UInt32)vdev + sizeof(*vdev) +
                                  (sizeof(*vring) * j));
+                    /*
+                     * Making a copy of original vring, given obj->vrings[j].da
+                     * is used as slave virtual address in RscTable_getInfo(),
+                     * and that is what the original vring definition contains.
+                     */
                     Memory_copy (&obj->vrings[j], vring, sizeof (*vring));
                     printf ("RscTable_process: vring [%d] @ [0x%08x]\n",
                             vring->num, vring->da);
@@ -576,6 +581,19 @@ RscTable_process (UInt16 procId, Bool tryAlloc, UInt32 * numBlocks)
 
                     obj->vringPa = pa;
                     obj->vringBufsPa = pa + vr_size;
+
+                    /*
+                     * Override the vring 'da' field in resource table.
+                     * This allows the slave to look it up when creating
+                     * the VirtQueues
+                     */
+                    for (j = 0; j < vdev->num_of_vrings; j++) {
+                        vring = (struct fw_rsc_vdev_vring *)
+                                ((UInt32)vdev + sizeof(*vdev) +
+                                 (sizeof(*vring) * j));
+                        vring->da = obj->vringPa + (j *
+                            vr_size / vdev->num_of_vrings);
+                    }
                 }
                 break;
             }