Commit 211c06d8 authored by Harald Freudenberger's avatar Harald Freudenberger Committed by Heiko Carstens

s390/ap: make tapq gr2 response a struct

This patch introduces a new struct ap_tapq_gr2 which covers
the response in GR2 on TAPQ invocation. This makes it much
easier and less error-prone for the calling functions to
access the right field without shifting and masking.
Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Reviewed-by: default avatarTony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: default avatarHolger Dengler <dengler@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent d7b1813a
...@@ -86,6 +86,34 @@ static inline bool ap_instructions_available(void) ...@@ -86,6 +86,34 @@ static inline bool ap_instructions_available(void)
return reg1 != 0; return reg1 != 0;
} }
/* TAPQ register GR2 response struct */
struct ap_tapq_gr2 {
union {
unsigned long value;
struct {
unsigned int fac : 32; /* facility bits */
unsigned int apinfo : 32; /* ap type, ... */
};
struct {
unsigned int s : 1; /* APSC */
unsigned int m : 1; /* AP4KM */
unsigned int c : 1; /* AP4KC */
unsigned int mode : 3;
unsigned int n : 1; /* APXA */
unsigned int : 1;
unsigned int class : 8;
unsigned int bs : 2; /* SE bind/assoc */
unsigned int : 14;
unsigned int at : 8; /* ap type */
unsigned int nd : 8; /* nr of domains */
unsigned int : 4;
unsigned int ml : 4; /* apxl ml */
unsigned int : 4;
unsigned int qd : 4; /* queue depth */
};
};
};
/** /**
* ap_tapq(): Test adjunct processor queue. * ap_tapq(): Test adjunct processor queue.
* @qid: The AP queue number * @qid: The AP queue number
...@@ -93,7 +121,7 @@ static inline bool ap_instructions_available(void) ...@@ -93,7 +121,7 @@ static inline bool ap_instructions_available(void)
* *
* Returns AP queue status structure. * Returns AP queue status structure.
*/ */
static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info) static inline struct ap_queue_status ap_tapq(ap_qid_t qid, struct ap_tapq_gr2 *info)
{ {
union ap_queue_status_reg reg1; union ap_queue_status_reg reg1;
unsigned long reg2; unsigned long reg2;
...@@ -108,7 +136,7 @@ static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info) ...@@ -108,7 +136,7 @@ static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info)
: [qid] "d" (qid) : [qid] "d" (qid)
: "cc", "0", "1", "2"); : "cc", "0", "1", "2");
if (info) if (info)
*info = reg2; info->value = reg2;
return reg1.status; return reg1.status;
} }
...@@ -116,13 +144,12 @@ static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info) ...@@ -116,13 +144,12 @@ static inline struct ap_queue_status ap_tapq(ap_qid_t qid, unsigned long *info)
* ap_test_queue(): Test adjunct processor queue. * ap_test_queue(): Test adjunct processor queue.
* @qid: The AP queue number * @qid: The AP queue number
* @tbit: Test facilities bit * @tbit: Test facilities bit
* @info: Pointer to queue descriptor * @info: Ptr to tapq gr2 struct
* *
* Returns AP queue status structure. * Returns AP queue status structure.
*/ */
static inline struct ap_queue_status ap_test_queue(ap_qid_t qid, static inline struct ap_queue_status ap_test_queue(ap_qid_t qid, int tbit,
int tbit, struct ap_tapq_gr2 *info)
unsigned long *info)
{ {
if (tbit) if (tbit)
qid |= 1UL << 23; /* set T bit*/ qid |= 1UL << 23; /* set T bit*/
......
...@@ -343,18 +343,7 @@ static bool ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac, ...@@ -343,18 +343,7 @@ static bool ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac,
int *q_depth, int *q_ml, bool *q_decfg, bool *q_cstop) int *q_depth, int *q_ml, bool *q_decfg, bool *q_cstop)
{ {
struct ap_queue_status status; struct ap_queue_status status;
union { struct ap_tapq_gr2 tapq_info;
unsigned long value;
struct {
unsigned int fac : 32; /* facility bits */
unsigned int at : 8; /* ap type */
unsigned int _res1 : 8;
unsigned int _res2 : 4;
unsigned int ml : 4; /* apxl ml */
unsigned int _res3 : 4;
unsigned int qd : 4; /* queue depth */
} tapq_gr2;
} tapq_info;
tapq_info.value = 0; tapq_info.value = 0;
...@@ -364,7 +353,7 @@ static bool ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac, ...@@ -364,7 +353,7 @@ static bool ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac,
return false; return false;
/* call TAPQ on this APQN */ /* call TAPQ on this APQN */
status = ap_test_queue(qid, ap_apft_available(), &tapq_info.value); status = ap_test_queue(qid, ap_apft_available(), &tapq_info);
switch (status.response_code) { switch (status.response_code) {
case AP_RESPONSE_NORMAL: case AP_RESPONSE_NORMAL:
case AP_RESPONSE_RESET_IN_PROGRESS: case AP_RESPONSE_RESET_IN_PROGRESS:
...@@ -378,10 +367,10 @@ static bool ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac, ...@@ -378,10 +367,10 @@ static bool ap_queue_info(ap_qid_t qid, int *q_type, unsigned int *q_fac,
*/ */
if (WARN_ON_ONCE(!tapq_info.value)) if (WARN_ON_ONCE(!tapq_info.value))
return false; return false;
*q_type = tapq_info.tapq_gr2.at; *q_type = tapq_info.at;
*q_fac = tapq_info.tapq_gr2.fac; *q_fac = tapq_info.fac;
*q_depth = tapq_info.tapq_gr2.qd; *q_depth = tapq_info.qd;
*q_ml = tapq_info.tapq_gr2.ml; *q_ml = tapq_info.ml;
*q_decfg = status.response_code == AP_RESPONSE_DECONFIGURED; *q_decfg = status.response_code == AP_RESPONSE_DECONFIGURED;
*q_cstop = status.response_code == AP_RESPONSE_CHECKSTOPPED; *q_cstop = status.response_code == AP_RESPONSE_CHECKSTOPPED;
switch (*q_type) { switch (*q_type) {
......
...@@ -2115,8 +2115,8 @@ static void vfio_ap_filter_apid_by_qtype(unsigned long *apm, unsigned long *aqm) ...@@ -2115,8 +2115,8 @@ static void vfio_ap_filter_apid_by_qtype(unsigned long *apm, unsigned long *aqm)
{ {
bool apid_cleared; bool apid_cleared;
struct ap_queue_status status; struct ap_queue_status status;
unsigned long apid, apqi, info; unsigned long apid, apqi;
int qtype, qtype_mask = 0xff000000; struct ap_tapq_gr2 info;
for_each_set_bit_inv(apid, apm, AP_DEVICES) { for_each_set_bit_inv(apid, apm, AP_DEVICES) {
apid_cleared = false; apid_cleared = false;
...@@ -2133,15 +2133,13 @@ static void vfio_ap_filter_apid_by_qtype(unsigned long *apm, unsigned long *aqm) ...@@ -2133,15 +2133,13 @@ static void vfio_ap_filter_apid_by_qtype(unsigned long *apm, unsigned long *aqm)
case AP_RESPONSE_DECONFIGURED: case AP_RESPONSE_DECONFIGURED:
case AP_RESPONSE_CHECKSTOPPED: case AP_RESPONSE_CHECKSTOPPED:
case AP_RESPONSE_BUSY: case AP_RESPONSE_BUSY:
qtype = info & qtype_mask;
/* /*
* The vfio_ap device driver only * The vfio_ap device driver only
* supports CEX4 and newer adapters, so * supports CEX4 and newer adapters, so
* remove the APID if the adapter is * remove the APID if the adapter is
* older than a CEX4. * older than a CEX4.
*/ */
if (qtype < AP_DEVICE_TYPE_CEX4) { if (info.at < AP_DEVICE_TYPE_CEX4) {
clear_bit_inv(apid, apm); clear_bit_inv(apid, apm);
apid_cleared = true; apid_cleared = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment