ap_queue.c (003d248fee72eb8d86aefaf3b6e47fe8acfda0b6) ap_queue.c (8794c5961394b7fb8a69f43eaad9566e5496c0c8)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright IBM Corp. 2016
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 *
6 * Adjunct processor bus, queue related code.
7 */
8

--- 45 unchanged lines hidden (view full) ---

54 }
55}
56
57/**
58 * __ap_send(): Send message to adjunct processor queue.
59 * @qid: The AP queue number
60 * @psmid: The program supplied message identifier
61 * @msg: The message text
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright IBM Corp. 2016
4 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
5 *
6 * Adjunct processor bus, queue related code.
7 */
8

--- 45 unchanged lines hidden (view full) ---

54 }
55}
56
57/**
58 * __ap_send(): Send message to adjunct processor queue.
59 * @qid: The AP queue number
60 * @psmid: The program supplied message identifier
61 * @msg: The message text
62 * @length: The message length
62 * @msglen: The message length
63 * @special: Special Bit
64 *
65 * Returns AP queue status structure.
66 * Condition code 1 on NQAP can't happen because the L bit is 1.
67 * Condition code 2 on NQAP also means the send is incomplete,
68 * because a segment boundary was reached. The NQAP is repeated.
69 */
70static inline struct ap_queue_status
63 * @special: Special Bit
64 *
65 * Returns AP queue status structure.
66 * Condition code 1 on NQAP can't happen because the L bit is 1.
67 * Condition code 2 on NQAP also means the send is incomplete,
68 * because a segment boundary was reached. The NQAP is repeated.
69 */
70static inline struct ap_queue_status
71__ap_send(ap_qid_t qid, unsigned long psmid, void *msg, size_t length,
71__ap_send(ap_qid_t qid, unsigned long psmid, void *msg, size_t msglen,
72 int special)
73{
74 if (special)
75 qid |= 0x400000UL;
72 int special)
73{
74 if (special)
75 qid |= 0x400000UL;
76 return ap_nqap(qid, psmid, msg, length);
76 return ap_nqap(qid, psmid, msg, msglen);
77}
78
77}
78
79int ap_send(ap_qid_t qid, unsigned long psmid, void *msg, size_t length)
79int ap_send(ap_qid_t qid, unsigned long psmid, void *msg, size_t msglen)
80{
81 struct ap_queue_status status;
82
80{
81 struct ap_queue_status status;
82
83 status = __ap_send(qid, psmid, msg, length, 0);
83 status = __ap_send(qid, psmid, msg, msglen, 0);
84 switch (status.response_code) {
85 case AP_RESPONSE_NORMAL:
86 return 0;
87 case AP_RESPONSE_Q_FULL:
88 case AP_RESPONSE_RESET_IN_PROGRESS:
89 return -EBUSY;
90 case AP_RESPONSE_REQ_FAC_NOT_INST:
91 return -EINVAL;
92 default: /* Device is gone. */
93 return -ENODEV;
94 }
95}
96EXPORT_SYMBOL(ap_send);
97
84 switch (status.response_code) {
85 case AP_RESPONSE_NORMAL:
86 return 0;
87 case AP_RESPONSE_Q_FULL:
88 case AP_RESPONSE_RESET_IN_PROGRESS:
89 return -EBUSY;
90 case AP_RESPONSE_REQ_FAC_NOT_INST:
91 return -EINVAL;
92 default: /* Device is gone. */
93 return -ENODEV;
94 }
95}
96EXPORT_SYMBOL(ap_send);
97
98int ap_recv(ap_qid_t qid, unsigned long *psmid, void *msg, size_t length)
98int ap_recv(ap_qid_t qid, unsigned long *psmid, void *msg, size_t msglen)
99{
100 struct ap_queue_status status;
101
102 if (!msg)
103 return -EINVAL;
99{
100 struct ap_queue_status status;
101
102 if (!msg)
103 return -EINVAL;
104 status = ap_dqap(qid, psmid, msg, length, NULL, NULL);
104 status = ap_dqap(qid, psmid, msg, msglen, NULL, NULL, NULL);
105 switch (status.response_code) {
106 case AP_RESPONSE_NORMAL:
107 return 0;
108 case AP_RESPONSE_NO_PENDING_REPLY:
109 if (status.queue_empty)
110 return -ENOENT;
111 return -EBUSY;
112 case AP_RESPONSE_RESET_IN_PROGRESS:

--- 32 unchanged lines hidden (view full) ---

145 * the msg is totally received. As we use the very same buffer
146 * the msg is overwritten with each invocation. That's intended
147 * and the receiver of the msg is informed with a msg rc code
148 * of EMSGSIZE in such a case.
149 */
150 do {
151 status = ap_dqap(aq->qid, &aq->reply->psmid,
152 aq->reply->msg, aq->reply->bufsize,
105 switch (status.response_code) {
106 case AP_RESPONSE_NORMAL:
107 return 0;
108 case AP_RESPONSE_NO_PENDING_REPLY:
109 if (status.queue_empty)
110 return -ENOENT;
111 return -EBUSY;
112 case AP_RESPONSE_RESET_IN_PROGRESS:

--- 32 unchanged lines hidden (view full) ---

145 * the msg is totally received. As we use the very same buffer
146 * the msg is overwritten with each invocation. That's intended
147 * and the receiver of the msg is informed with a msg rc code
148 * of EMSGSIZE in such a case.
149 */
150 do {
151 status = ap_dqap(aq->qid, &aq->reply->psmid,
152 aq->reply->msg, aq->reply->bufsize,
153 &reslen, &resgr0);
153 &aq->reply->len, &reslen, &resgr0);
154 parts++;
155 } while (status.response_code == 0xFF && resgr0 != 0);
156
157 switch (status.response_code) {
158 case AP_RESPONSE_NORMAL:
159 aq->queue_count = max_t(int, 0, aq->queue_count - 1);
160 if (!status.queue_empty && !aq->queue_count)
161 aq->queue_count++;

--- 778 unchanged lines hidden ---
154 parts++;
155 } while (status.response_code == 0xFF && resgr0 != 0);
156
157 switch (status.response_code) {
158 case AP_RESPONSE_NORMAL:
159 aq->queue_count = max_t(int, 0, aq->queue_count - 1);
160 if (!status.queue_empty && !aq->queue_count)
161 aq->queue_count++;

--- 778 unchanged lines hidden ---