Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706938

[PATCH v6 08/17] powerpc/vas: Define vas_win_id()

From Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH v6 08/17] powerpc/vas: Define vas_win_id()
Date 2017-08-09 01:10 +0200
Message-ID <uclNo-6X2-21@gated-at.bofh.it> (permalink)
References <uclNn-6X2-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 arch/powerpc/include/asm/vas.h              |  5 +++++
 arch/powerpc/platforms/powernv/vas-window.c |  9 +++++++++
 arch/powerpc/platforms/powernv/vas.h        | 28 ++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index 2b35b95..30667db 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -35,6 +35,11 @@ enum vas_cop_type {
 };
 
 /*
+ * Return a system-wide unique id for the VAS window @win.
+ */
+extern uint32_t vas_win_id(struct vas_window *win);
+
+/*
  * Return the power bus paste address associated with @win so the caller
  * can map that address into their address space.
  */
diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c
index 3a4599f..42c1d4f 100644
--- a/arch/powerpc/platforms/powernv/vas-window.c
+++ b/arch/powerpc/platforms/powernv/vas-window.c
@@ -575,3 +575,12 @@ int vas_win_close(struct vas_window *window)
 {
 	return -1;
 }
+
+/*
+ * Return a system-wide unique window id for the window @win.
+ */
+uint32_t vas_win_id(struct vas_window *win)
+{
+	return encode_pswid(win->vinst->vas_id, win->winid);
+}
+EXPORT_SYMBOL_GPL(vas_win_id);
diff --git a/arch/powerpc/platforms/powernv/vas.h b/arch/powerpc/platforms/powernv/vas.h
index 7b2bcd0..3eadf90 100644
--- a/arch/powerpc/platforms/powernv/vas.h
+++ b/arch/powerpc/platforms/powernv/vas.h
@@ -440,4 +440,32 @@ static inline uint64_t 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 */
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 00/17] powerpc/vas: Enable VAS Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 07/17] powerpc/vas: Define vas_win_paste_addr() Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 12/17] powerpc/vas: Define vas_tx_win_open() Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 01/17] powerpc/vas: Define macros, register fields and structures Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 11/17] powerpc/vas: Define vas_win_close() interface Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 13/17] powerpc/vas: Define copy/paste interfaces Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 14/17] powerpc: Add support for setting SPRN_TIDR Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 08/17] powerpc/vas: Define vas_win_id() Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 17/17] powerpc/vas: Document FTW API/usage Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 16/17] powerpc/vas: Implement a simple FTW driver Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 10/17] powerpc/vas: Define vas_rx_win_open() interface Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 03/17] powerpc/vas: Define vas_init() and vas_exit() Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:10 +0200
  [PATCH v6 09/17] powerpc/vas: Define vas_rx_win_open() interface Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:20 +0200
  [PATCH v6 05/17] powerpc/vas: Define helpers to init window context Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:20 +0200
  [PATCH v6 06/17] powerpc/vas: Define helpers to alloc/free windows Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:20 +0200
  [PATCH v6 04/17] powerpc/vas: Define helpers to access MMIO regions Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:20 +0200
  [PATCH v6 02/17] powerpc/vas: Move GET_FIELD/SET_FIELD to vas.h Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> - 2017-08-09 01:20 +0200

csiph-web