summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powernv/vas.h
diff options
context:
space:
mode:
authorSukadev Bhattiprolu2017-11-08 03:23:57 +0100
committerMichael Ellerman2017-11-11 23:03:10 +0100
commit61f3cca8cda979646c24accd9dbf3e2de7ea6ceb (patch)
treeaa66625a3155327928bce31a68561945badafbba /arch/powerpc/platforms/powernv/vas.h
parentpowerpc/vas: Define vas_win_paste_addr() (diff)
downloadkernel-qcow2-linux-61f3cca8cda979646c24accd9dbf3e2de7ea6ceb.tar.gz
kernel-qcow2-linux-61f3cca8cda979646c24accd9dbf3e2de7ea6ceb.tar.xz
kernel-qcow2-linux-61f3cca8cda979646c24accd9dbf3e2de7ea6ceb.zip
powerpc/vas: Define vas_win_id()
Define an interface to return a system-wide unique id for a given VAS window. The vas_win_id() will be used in a follow-on patch to generate an unique handle for a user space receive window. Applications can use this handle to pair send and receive windows for fast thread-wakeup. The hardware refers to this system-wide unique id as a Partition Send Window ID which is expected to be used during fault handling. Hence the "pswid" in the function names. Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms/powernv/vas.h')
-rw-r--r--arch/powerpc/platforms/powernv/vas.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h
index 756cbc5335bc..ae0100fd35bb 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -447,4 +447,32 @@ static inline u64 read_hvwc_reg(struct vas_window *win,
return in_be64(win->hvwc_map+reg);
}
+/*
+ * Encode/decode the Partition Send Window ID (PSWID) for a window in
+ * a way that we can uniquely identify any window in the system. i.e.
+ * we should be able to locate the 'struct vas_window' given the PSWID.
+ *
+ * Bits Usage
+ * 0:7 VAS id (8 bits)
+ * 8:15 Unused, 0 (3 bits)
+ * 16:31 Window id (16 bits)
+ */
+static inline u32 encode_pswid(int vasid, int winid)
+{
+ u32 pswid = 0;
+
+ pswid |= vasid << (31 - 7);
+ pswid |= winid;
+
+ return pswid;
+}
+
+static inline void decode_pswid(u32 pswid, int *vasid, int *winid)
+{
+ if (vasid)
+ *vasid = pswid >> (31 - 7) & 0xFF;
+
+ if (winid)
+ *winid = pswid & 0xFFFF;
+}
#endif /* _VAS_H */