[V3 PATCH 06/16] powerpc/pseries/vas: Define VAS/NXGZIP HCALLs and structs

2021-04-17 Thread Haren Myneni


This patch adds HCALLs and other definitions. Also define structs
that are used in VAS implementation on powerVM.

Signed-off-by: Haren Myneni 
---
 arch/powerpc/include/asm/hvcall.h|  7 ++
 arch/powerpc/include/asm/vas.h   | 28 
 arch/powerpc/platforms/pseries/vas.h | 96 
 3 files changed, 131 insertions(+)
 create mode 100644 arch/powerpc/platforms/pseries/vas.h

diff --git a/arch/powerpc/include/asm/hvcall.h 
b/arch/powerpc/include/asm/hvcall.h
index ed6086d57b22..accbb7f6f272 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -294,6 +294,13 @@
 #define H_RESIZE_HPT_COMMIT0x370
 #define H_REGISTER_PROC_TBL0x37C
 #define H_SIGNAL_SYS_RESET 0x380
+#defineH_ALLOCATE_VAS_WINDOW   0x388
+#defineH_MODIFY_VAS_WINDOW 0x38C
+#defineH_DEALLOCATE_VAS_WINDOW 0x390
+#defineH_QUERY_VAS_WINDOW  0x394
+#defineH_QUERY_VAS_CAPABILITIES0x398
+#defineH_QUERY_NX_CAPABILITIES 0x39C
+#defineH_GET_NX_FAULT  0x3A0
 #define H_INT_GET_SOURCE_INFO   0x3A8
 #define H_INT_SET_SOURCE_CONFIG 0x3AC
 #define H_INT_GET_SOURCE_CONFIG 0x3B0
diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index f928bf4c7e98..d15784506a54 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -179,6 +179,7 @@ struct vas_tx_win_attr {
bool rx_win_ord_mode;
 };
 
+#ifdef CONFIG_PPC_POWERNV
 /*
  * Helper to map a chip id to VAS id.
  * For POWER9, this is a 1:1 mapping. In the future this maybe a 1:N
@@ -243,6 +244,33 @@ int vas_paste_crb(struct vas_window *win, int offset, bool 
re);
 int vas_register_api_powernv(struct module *mod, enum vas_cop_type cop_type,
 const char *name);
 void vas_unregister_api_powernv(void);
+#endif
+
+#ifdef CONFIG_PPC_PSERIES
+
+/* VAS Capabilities */
+#define VAS_GZIP_QOS_FEAT  0x1
+#define VAS_GZIP_DEF_FEAT  0x2
+#define VAS_GZIP_QOS_FEAT_BIT  (1UL << (63 - VAS_GZIP_QOS_FEAT)) /* Bit 1 */
+#define VAS_GZIP_DEF_FEAT_BIT  (1UL << (63 - VAS_GZIP_DEF_FEAT)) /* Bit 2 */
+
+/* NX Capabilities */
+#defineVAS_NX_GZIP_FEAT0x1
+#defineVAS_NX_GZIP_FEAT_BIT(1UL << (63 - VAS_NX_GZIP_FEAT)) /* Bit 
1 */
+#defineVAS_DESCR_LEN   8
+
+struct vas_all_capabs_be {
+   __be64  descriptor;
+   __be64  feat_type;
+} __packed __aligned(0x1000);
+
+struct vas_all_capabs {
+   charname[VAS_DESCR_LEN + 1];
+   u64 descriptor;
+   u64 feat_type;
+};
+
+#endif
 
 /*
  * Register / unregister coprocessor type to VAS API which will be exported
diff --git a/arch/powerpc/platforms/pseries/vas.h 
b/arch/powerpc/platforms/pseries/vas.h
new file mode 100644
index ..208682fffa57
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright 2020-21 IBM Corp.
+ */
+
+#ifndef _VAS_H
+#define _VAS_H
+#include 
+#include 
+#include 
+
+/*
+ * VAS window modify flags
+ */
+#defineVAS_MOD_WIN_CLOSE   (1UL << 63)
+#defineVAS_MOD_WIN_JOBS_KILL   (1UL << (63 - 1))
+#defineVAS_MOD_WIN_DR  (1UL << (63 - 3))
+#defineVAS_MOD_WIN_PR  (1UL << (63 - 4))
+#defineVAS_MOD_WIN_SF  (1UL << (63 - 5))
+#defineVAS_MOD_WIN_TA  (1UL << (63 - 6))
+#defineVAS_MOD_WIN_FLAGS   (VAS_MOD_WIN_JOBS_KILL | VAS_MOD_WIN_DR 
| \
+   VAS_MOD_WIN_PR | VAS_MOD_WIN_SF)
+
+#defineVAS_WIN_ACTIVE  0x0
+#defineVAS_WIN_CLOSED  0x1
+#defineVAS_WIN_INACTIVE0x2 /* Inactive due to HW failure */
+/* Process of being modified, deallocated, or quiesced */
+#defineVAS_WIN_MOD_IN_PROCESS  0x3
+
+#defineVAS_COPY_PASTE_USER_MODE0x0001
+#defineVAS_COP_OP_USER_MODE0x0010
+
+/*
+ * Co-processor feature - GZIP QoS windows or GZIP default windows
+ */
+enum vas_cop_feat_type {
+   VAS_GZIP_QOS_FEAT_TYPE,
+   VAS_GZIP_DEF_FEAT_TYPE,
+   VAS_MAX_FEAT_TYPE,
+};
+
+struct vas_ct_capabs_be {
+   __be64  descriptor;
+   u8  win_type;   /* Default or QoS type */
+   u8  user_mode;
+   __be16  max_lpar_creds;
+   __be16  max_win_creds;
+   union {
+   __be16  reserved;
+   __be16  def_lpar_creds; /* Used for default capabilities */
+   };
+   __be16  target_lpar_creds;
+} __packed __aligned(0x1000);
+
+struct vas_ct_capabs {
+   charname[VAS_DESCR_LEN + 1];
+   u64 descriptor;
+   u8  win_type;   /* Default or QoS type */
+   u8  user_mode;  /* User mode copy/paste or COP HCALL */
+   u16 max_lpar_creds; /* Max credits available in LPAR */
+   /* Max credits can be assigned per win

[V2 PATCH 06/16] powerpc/pseries/vas: Define VAS/NXGZIP HCALLs and structs

2021-04-13 Thread Haren Myneni


This patch adds HCALLs and other definitions. Also define structs
that are used in VAS implementation on powerVM.

Signed-off-by: Haren Myneni 
---
 arch/powerpc/include/asm/hvcall.h|  7 ++
 arch/powerpc/include/asm/vas.h   | 28 
 arch/powerpc/platforms/pseries/vas.h | 96 
 3 files changed, 131 insertions(+)
 create mode 100644 arch/powerpc/platforms/pseries/vas.h

diff --git a/arch/powerpc/include/asm/hvcall.h 
b/arch/powerpc/include/asm/hvcall.h
index ed6086d57b22..accbb7f6f272 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -294,6 +294,13 @@
 #define H_RESIZE_HPT_COMMIT0x370
 #define H_REGISTER_PROC_TBL0x37C
 #define H_SIGNAL_SYS_RESET 0x380
+#defineH_ALLOCATE_VAS_WINDOW   0x388
+#defineH_MODIFY_VAS_WINDOW 0x38C
+#defineH_DEALLOCATE_VAS_WINDOW 0x390
+#defineH_QUERY_VAS_WINDOW  0x394
+#defineH_QUERY_VAS_CAPABILITIES0x398
+#defineH_QUERY_NX_CAPABILITIES 0x39C
+#defineH_GET_NX_FAULT  0x3A0
 #define H_INT_GET_SOURCE_INFO   0x3A8
 #define H_INT_SET_SOURCE_CONFIG 0x3AC
 #define H_INT_GET_SOURCE_CONFIG 0x3B0
diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index f928bf4c7e98..d15784506a54 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -179,6 +179,7 @@ struct vas_tx_win_attr {
bool rx_win_ord_mode;
 };
 
+#ifdef CONFIG_PPC_POWERNV
 /*
  * Helper to map a chip id to VAS id.
  * For POWER9, this is a 1:1 mapping. In the future this maybe a 1:N
@@ -243,6 +244,33 @@ int vas_paste_crb(struct vas_window *win, int offset, bool 
re);
 int vas_register_api_powernv(struct module *mod, enum vas_cop_type cop_type,
 const char *name);
 void vas_unregister_api_powernv(void);
+#endif
+
+#ifdef CONFIG_PPC_PSERIES
+
+/* VAS Capabilities */
+#define VAS_GZIP_QOS_FEAT  0x1
+#define VAS_GZIP_DEF_FEAT  0x2
+#define VAS_GZIP_QOS_FEAT_BIT  (1UL << (63 - VAS_GZIP_QOS_FEAT)) /* Bit 1 */
+#define VAS_GZIP_DEF_FEAT_BIT  (1UL << (63 - VAS_GZIP_DEF_FEAT)) /* Bit 2 */
+
+/* NX Capabilities */
+#defineVAS_NX_GZIP_FEAT0x1
+#defineVAS_NX_GZIP_FEAT_BIT(1UL << (63 - VAS_NX_GZIP_FEAT)) /* Bit 
1 */
+#defineVAS_DESCR_LEN   8
+
+struct vas_all_capabs_be {
+   __be64  descriptor;
+   __be64  feat_type;
+} __packed __aligned(0x1000);
+
+struct vas_all_capabs {
+   charname[VAS_DESCR_LEN + 1];
+   u64 descriptor;
+   u64 feat_type;
+};
+
+#endif
 
 /*
  * Register / unregister coprocessor type to VAS API which will be exported
diff --git a/arch/powerpc/platforms/pseries/vas.h 
b/arch/powerpc/platforms/pseries/vas.h
new file mode 100644
index ..208682fffa57
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright 2020-21 IBM Corp.
+ */
+
+#ifndef _VAS_H
+#define _VAS_H
+#include 
+#include 
+#include 
+
+/*
+ * VAS window modify flags
+ */
+#defineVAS_MOD_WIN_CLOSE   (1UL << 63)
+#defineVAS_MOD_WIN_JOBS_KILL   (1UL << (63 - 1))
+#defineVAS_MOD_WIN_DR  (1UL << (63 - 3))
+#defineVAS_MOD_WIN_PR  (1UL << (63 - 4))
+#defineVAS_MOD_WIN_SF  (1UL << (63 - 5))
+#defineVAS_MOD_WIN_TA  (1UL << (63 - 6))
+#defineVAS_MOD_WIN_FLAGS   (VAS_MOD_WIN_JOBS_KILL | VAS_MOD_WIN_DR 
| \
+   VAS_MOD_WIN_PR | VAS_MOD_WIN_SF)
+
+#defineVAS_WIN_ACTIVE  0x0
+#defineVAS_WIN_CLOSED  0x1
+#defineVAS_WIN_INACTIVE0x2 /* Inactive due to HW failure */
+/* Process of being modified, deallocated, or quiesced */
+#defineVAS_WIN_MOD_IN_PROCESS  0x3
+
+#defineVAS_COPY_PASTE_USER_MODE0x0001
+#defineVAS_COP_OP_USER_MODE0x0010
+
+/*
+ * Co-processor feature - GZIP QoS windows or GZIP default windows
+ */
+enum vas_cop_feat_type {
+   VAS_GZIP_QOS_FEAT_TYPE,
+   VAS_GZIP_DEF_FEAT_TYPE,
+   VAS_MAX_FEAT_TYPE,
+};
+
+struct vas_ct_capabs_be {
+   __be64  descriptor;
+   u8  win_type;   /* Default or QoS type */
+   u8  user_mode;
+   __be16  max_lpar_creds;
+   __be16  max_win_creds;
+   union {
+   __be16  reserved;
+   __be16  def_lpar_creds; /* Used for default capabilities */
+   };
+   __be16  target_lpar_creds;
+} __packed __aligned(0x1000);
+
+struct vas_ct_capabs {
+   charname[VAS_DESCR_LEN + 1];
+   u64 descriptor;
+   u8  win_type;   /* Default or QoS type */
+   u8  user_mode;  /* User mode copy/paste or COP HCALL */
+   u16 max_lpar_creds; /* Max credits available in LPAR */
+   /* Max credits can be assigned per win

[PATCH 06/16] powerpc/pseries/vas: Define VAS/NXGZIP HCALLs and structs

2021-04-10 Thread Haren Myneni


This patch adds HCALLs and other definitions. Also define structs
that are used in VAS implementation on powerVM.

Signed-off-by: Haren Myneni 
---
 arch/powerpc/include/asm/hvcall.h|  7 ++
 arch/powerpc/include/asm/vas.h   | 28 
 arch/powerpc/platforms/pseries/vas.h | 96 
 3 files changed, 131 insertions(+)
 create mode 100644 arch/powerpc/platforms/pseries/vas.h

diff --git a/arch/powerpc/include/asm/hvcall.h 
b/arch/powerpc/include/asm/hvcall.h
index ed6086d57b22..accbb7f6f272 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -294,6 +294,13 @@
 #define H_RESIZE_HPT_COMMIT0x370
 #define H_REGISTER_PROC_TBL0x37C
 #define H_SIGNAL_SYS_RESET 0x380
+#defineH_ALLOCATE_VAS_WINDOW   0x388
+#defineH_MODIFY_VAS_WINDOW 0x38C
+#defineH_DEALLOCATE_VAS_WINDOW 0x390
+#defineH_QUERY_VAS_WINDOW  0x394
+#defineH_QUERY_VAS_CAPABILITIES0x398
+#defineH_QUERY_NX_CAPABILITIES 0x39C
+#defineH_GET_NX_FAULT  0x3A0
 #define H_INT_GET_SOURCE_INFO   0x3A8
 #define H_INT_SET_SOURCE_CONFIG 0x3AC
 #define H_INT_GET_SOURCE_CONFIG 0x3B0
diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index f928bf4c7e98..d15784506a54 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -179,6 +179,7 @@ struct vas_tx_win_attr {
bool rx_win_ord_mode;
 };
 
+#ifdef CONFIG_PPC_POWERNV
 /*
  * Helper to map a chip id to VAS id.
  * For POWER9, this is a 1:1 mapping. In the future this maybe a 1:N
@@ -243,6 +244,33 @@ int vas_paste_crb(struct vas_window *win, int offset, bool 
re);
 int vas_register_api_powernv(struct module *mod, enum vas_cop_type cop_type,
 const char *name);
 void vas_unregister_api_powernv(void);
+#endif
+
+#ifdef CONFIG_PPC_PSERIES
+
+/* VAS Capabilities */
+#define VAS_GZIP_QOS_FEAT  0x1
+#define VAS_GZIP_DEF_FEAT  0x2
+#define VAS_GZIP_QOS_FEAT_BIT  (1UL << (63 - VAS_GZIP_QOS_FEAT)) /* Bit 1 */
+#define VAS_GZIP_DEF_FEAT_BIT  (1UL << (63 - VAS_GZIP_DEF_FEAT)) /* Bit 2 */
+
+/* NX Capabilities */
+#defineVAS_NX_GZIP_FEAT0x1
+#defineVAS_NX_GZIP_FEAT_BIT(1UL << (63 - VAS_NX_GZIP_FEAT)) /* Bit 
1 */
+#defineVAS_DESCR_LEN   8
+
+struct vas_all_capabs_be {
+   __be64  descriptor;
+   __be64  feat_type;
+} __packed __aligned(0x1000);
+
+struct vas_all_capabs {
+   charname[VAS_DESCR_LEN + 1];
+   u64 descriptor;
+   u64 feat_type;
+};
+
+#endif
 
 /*
  * Register / unregister coprocessor type to VAS API which will be exported
diff --git a/arch/powerpc/platforms/pseries/vas.h 
b/arch/powerpc/platforms/pseries/vas.h
new file mode 100644
index ..208682fffa57
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/vas.h
@@ -0,0 +1,96 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright 2020-21 IBM Corp.
+ */
+
+#ifndef _VAS_H
+#define _VAS_H
+#include 
+#include 
+#include 
+
+/*
+ * VAS window modify flags
+ */
+#defineVAS_MOD_WIN_CLOSE   (1UL << 63)
+#defineVAS_MOD_WIN_JOBS_KILL   (1UL << (63 - 1))
+#defineVAS_MOD_WIN_DR  (1UL << (63 - 3))
+#defineVAS_MOD_WIN_PR  (1UL << (63 - 4))
+#defineVAS_MOD_WIN_SF  (1UL << (63 - 5))
+#defineVAS_MOD_WIN_TA  (1UL << (63 - 6))
+#defineVAS_MOD_WIN_FLAGS   (VAS_MOD_WIN_JOBS_KILL | VAS_MOD_WIN_DR 
| \
+   VAS_MOD_WIN_PR | VAS_MOD_WIN_SF)
+
+#defineVAS_WIN_ACTIVE  0x0
+#defineVAS_WIN_CLOSED  0x1
+#defineVAS_WIN_INACTIVE0x2 /* Inactive due to HW failure */
+/* Process of being modified, deallocated, or quiesced */
+#defineVAS_WIN_MOD_IN_PROCESS  0x3
+
+#defineVAS_COPY_PASTE_USER_MODE0x0001
+#defineVAS_COP_OP_USER_MODE0x0010
+
+/*
+ * Co-processor feature - GZIP QoS windows or GZIP default windows
+ */
+enum vas_cop_feat_type {
+   VAS_GZIP_QOS_FEAT_TYPE,
+   VAS_GZIP_DEF_FEAT_TYPE,
+   VAS_MAX_FEAT_TYPE,
+};
+
+struct vas_ct_capabs_be {
+   __be64  descriptor;
+   u8  win_type;   /* Default or QoS type */
+   u8  user_mode;
+   __be16  max_lpar_creds;
+   __be16  max_win_creds;
+   union {
+   __be16  reserved;
+   __be16  def_lpar_creds; /* Used for default capabilities */
+   };
+   __be16  target_lpar_creds;
+} __packed __aligned(0x1000);
+
+struct vas_ct_capabs {
+   charname[VAS_DESCR_LEN + 1];
+   u64 descriptor;
+   u8  win_type;   /* Default or QoS type */
+   u8  user_mode;  /* User mode copy/paste or COP HCALL */
+   u16 max_lpar_creds; /* Max credits available in LPAR */
+   /* Max credits can be assigned per win