[v5,4/7] vas: Define helper to compute window paste address

Submitted by Sukadev Bhattiprolu on Jan. 26, 2017, 1:32 a.m.

Details

Message ID 1485394353-30319-5-git-send-email-sukadev@linux.vnet.ibm.com
State New
Headers show

Commit Message

Sukadev Bhattiprolu Jan. 26, 2017, 1:32 a.m.
Define a helper, get_window_base_addr(), to compute the base power bus
address for all windows on a given chip. This address along with the
window 'shift' value (described in the code) can be used to compute
the physical "paste address" of a send window.

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 core/vas.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)

Patch hide | download patch | download mbox

diff --git a/core/vas.c b/core/vas.c
index 63a3f42..6d475f9 100644
--- a/core/vas.c
+++ b/core/vas.c
@@ -187,6 +187,76 @@  out:
 }
 
 /*
+ * Compute and return the _base_ Power bus address of all windows for the
+ * on the chip @chip. Linux will use this base address to compute the
+ * hardware  paste address of a window using:
+ *
+ * 	paste_addr = base + (winid << shift)
+ *
+ * where winid is the window index and 'shift' is RMA_LSMP_WINID_SHIFT.
+ *
+ * Refer to Tables 1.1 through 1.4 in Section 1.3.3.1 (Send Message w/Paste
+ * Commands (cl_rma_w)) of VAS P9 Workbook for the PowerBus Address usage
+ * in VAS.
+ *
+ * With 64K mode and Large SMP Mode the bits are used as follows:
+ *
+ *      Bits    Values          Comments
+ *      --------------------------------------
+ *      0:7     0b 0000_0000    Reserved
+ *      8:12    0b 0000_1       System id/Foreign Index 0:4
+ *      13:14   0b 00           Foreign Index 5:6
+ *
+ *      15:18   0 throuh 15     Node id (0 through 15)
+ *      19:21   0 through 7     Chip id (0 throuh 7)
+ *      22:23   0b 00           Unused, Foreign index 7:8
+ *
+ *      24:31   0b 0000_0000    RPN 0:7, Reserved
+ *      32:47   0 through 64K   Send Window Id (RMA_LSMP_WINID_MASK)
+ *      48:51   0b 0000         Spare
+ *
+ *      52      0b 0            Reserved
+ *      53      0b 1            Report Enable (Set to 1 for NX).
+ *      54      0b 0            Reserved
+ *
+ *      55:56   0b 00           Snoop Bus
+ *      57:63   0b 0000_000     Reserved
+ *
+ * Except for a few bits, the small SMP mode computation is similar.
+ *
+ * TODO: Detect and compute address for small SMP mode.
+ *
+ * Example: For Node 0, Chip 0, Window id 4, Report Enable 1:
+ *
+ *     Byte0    Byte1    Byte2    Byte3    Byte4    Byte5    Byte6    Byte7
+ *     00000000 00001000 00000000 00000000 00000000 00000100 00000100 00000000
+ *                                         |               |      |
+ *                                         +-------+-------+      v
+ *                                                 |          Report Enable
+ *                                                 v
+ *                                             Window id 4
+ *
+ *     Thus, the paste address is 0x00080000_00040400.
+ */
+#define RMA_LSMP_64K_SYS_ID	PPC_BITMASK(8, 12)
+#define RMA_LSMP_64K_NODE_ID	PPC_BITMASK(15, 18)
+#define RMA_LSMP_64K_CHIP_ID	PPC_BITMASK(19, 21)
+#define RMA_LSMP_WINID_MASK	PPC_BITMASK(32, 47)
+#define RMA_LSMP_WINID_SHIFT	(63-47)
+
+static inline uint64_t get_window_base_addr(struct proc_chip *chip)
+{
+	uint64_t val;
+
+	val = 0ULL;
+	val = SETFIELD(RMA_LSMP_64K_SYS_ID, val, 1);
+	val = SETFIELD(RMA_LSMP_64K_NODE_ID, val, P9_GCID2NODEID(chip->id));
+	val = SETFIELD(RMA_LSMP_64K_CHIP_ID, val, P9_GCID2CHIPID(chip->id));
+
+	return val;
+}
+
+/*
  * Initialize VAS on one chip
  */
 static int init_one_chip(struct proc_chip *chip)