1 /* Copyright (C) 2010 - 2013 UNISYS CORPORATION
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or (at
7 * your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for more
19 #include <linux/uuid.h>
22 * Whenever this file is changed a corresponding change must be made in
23 * the Console/ServicePart/visordiag_early/supervisor_channel.h file
24 * which is needed for Linux kernel compiles. These two files must be
28 /* define the following to prevent include nesting in kernel header
29 * files of similar abbreviated content
31 #define __SUPERVISOR_CHANNEL_H__
33 #include "commontypes.h"
35 #define SIGNATURE_16(A, B) ((A) | (B<<8))
36 #define SIGNATURE_32(A, B, C, D) \
37 (SIGNATURE_16(A, B) | (SIGNATURE_16(C, D) << 16))
38 #define SIGNATURE_64(A, B, C, D, E, F, G, H) \
39 (SIGNATURE_32(A, B, C, D) | ((U64)(SIGNATURE_32(E, F, G, H)) << 32))
42 #define lengthof(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
45 #define COVERQ(v, d) (((v)+(d)-1) / (d))
48 #define COVER(v, d) ((d)*COVERQ(v, d))
51 #define ULTRA_CHANNEL_PROTOCOL_SIGNATURE SIGNATURE_32('E', 'C', 'N', 'L')
54 CHANNELSRV_UNINITIALIZED
= 0, /* channel is in an undefined state */
55 CHANNELSRV_READY
= 1 /* channel has been initialized by server */
56 } CHANNEL_SERVERSTATE
;
59 CHANNELCLI_DETACHED
= 0,
60 CHANNELCLI_DISABLED
= 1, /* client can see channel but is NOT
61 * allowed to use it unless given TBD
62 * explicit request (should actually be
64 CHANNELCLI_ATTACHING
= 2, /* legacy EFI client request
65 * for EFI server to attach */
66 CHANNELCLI_ATTACHED
= 3, /* idle, but client may want
67 * to use channel any time */
68 CHANNELCLI_BUSY
= 4, /* client either wants to use or is
70 CHANNELCLI_OWNED
= 5 /* "no worries" state - client can
71 * access channel anytime */
72 } CHANNEL_CLIENTSTATE
;
73 static inline const u8
*
74 ULTRA_CHANNELCLI_STRING(u32 v
)
77 case CHANNELCLI_DETACHED
:
78 return (const u8
*) ("DETACHED");
79 case CHANNELCLI_DISABLED
:
80 return (const u8
*) ("DISABLED");
81 case CHANNELCLI_ATTACHING
:
82 return (const u8
*) ("ATTACHING");
83 case CHANNELCLI_ATTACHED
:
84 return (const u8
*) ("ATTACHED");
86 return (const u8
*) ("BUSY");
87 case CHANNELCLI_OWNED
:
88 return (const u8
*) ("OWNED");
92 return (const u8
*) ("?");
95 #define ULTRA_CHANNELSRV_IS_READY(x) ((x) == CHANNELSRV_READY)
96 #define ULTRA_CHANNEL_SERVER_READY(pChannel) \
97 (ULTRA_CHANNELSRV_IS_READY(readl(&(pChannel)->SrvState)))
99 #define ULTRA_VALID_CHANNELCLI_TRANSITION(o, n) \
100 (((((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_DISABLED)) || \
101 (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_DISABLED)) || \
102 (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_DISABLED)) || \
103 (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_DETACHED)) || \
104 (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_DETACHED)) || \
105 (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_ATTACHING)) || \
106 (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_ATTACHED)) || \
107 (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_ATTACHED)) || \
108 (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_ATTACHED)) || \
109 (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_BUSY)) || \
110 (((o) == CHANNELCLI_DETACHED) && ((n) == CHANNELCLI_OWNED)) || \
111 (((o) == CHANNELCLI_DISABLED) && ((n) == CHANNELCLI_OWNED)) || \
112 (((o) == CHANNELCLI_ATTACHING) && ((n) == CHANNELCLI_OWNED)) || \
113 (((o) == CHANNELCLI_ATTACHED) && ((n) == CHANNELCLI_OWNED)) || \
114 (((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \
117 #define ULTRA_CHANNEL_CLIENT_CHK_TRANSITION(old, new, chanId, logCtx, \
120 if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new)) \
121 UltraLogEvent(logCtx, \
122 CHANNELSTATE_DIAG_EVENTID_TRANSITERR, \
123 CHANNELSTATE_DIAG_SEVERITY, \
124 CHANNELSTATE_DIAG_SUBSYS, \
125 __func__, __LINE__, \
126 "%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \
127 chanId, "CliState<x>", \
128 ULTRA_CHANNELCLI_STRING(old), \
130 ULTRA_CHANNELCLI_STRING(new), \
132 PathName_Last_N_Nodes((u8 *)file, 4), \
136 #define ULTRA_CHANNEL_CLIENT_TRANSITION(pChan, chanId, \
139 ULTRA_CHANNEL_CLIENT_CHK_TRANSITION( \
140 readl(&(((CHANNEL_HEADER __iomem *) \
141 (pChan))->CliStateOS)), \
143 chanId, logCtx, __FILE__, __LINE__); \
144 UltraLogEvent(logCtx, CHANNELSTATE_DIAG_EVENTID_TRANSITOK, \
145 CHANNELSTATE_DIAG_SEVERITY, \
146 CHANNELSTATE_DIAG_SUBSYS, \
147 __func__, __LINE__, \
148 "%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \
149 chanId, "CliStateOS", \
150 ULTRA_CHANNELCLI_STRING( \
151 readl(&((CHANNEL_HEADER __iomem *) \
152 (pChan))->CliStateOS)), \
153 readl(&((CHANNEL_HEADER __iomem *) \
154 (pChan))->CliStateOS), \
155 ULTRA_CHANNELCLI_STRING(newstate), \
157 PathName_Last_N_Nodes(__FILE__, 4), __LINE__); \
158 writel(newstate, &((CHANNEL_HEADER __iomem *) \
159 (pChan))->CliStateOS); \
163 #define ULTRA_CHANNEL_CLIENT_ACQUIRE_OS(pChan, chanId, logCtx) \
164 ULTRA_channel_client_acquire_os(pChan, chanId, logCtx, \
165 (char *)__FILE__, __LINE__, \
167 #define ULTRA_CHANNEL_CLIENT_RELEASE_OS(pChan, chanId, logCtx) \
168 ULTRA_channel_client_release_os(pChan, chanId, logCtx, \
169 (char *)__FILE__, __LINE__, (char *)__func__)
171 /* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */
172 /* throttling invalid boot channel statetransition error due to client
174 #define ULTRA_CLIERRORBOOT_THROTTLEMSG_DISABLED 0x01
176 /* throttling invalid boot channel statetransition error due to client
178 #define ULTRA_CLIERRORBOOT_THROTTLEMSG_NOTATTACHED 0x02
180 /* throttling invalid boot channel statetransition error due to busy channel */
181 #define ULTRA_CLIERRORBOOT_THROTTLEMSG_BUSY 0x04
183 /* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorOS: */
184 /* throttling invalid guest OS channel statetransition error due to
186 #define ULTRA_CLIERROROS_THROTTLEMSG_DISABLED 0x01
188 /* throttling invalid guest OS channel statetransition error due to
189 * client not attached */
190 #define ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED 0x02
192 /* throttling invalid guest OS channel statetransition error due to
194 #define ULTRA_CLIERROROS_THROTTLEMSG_BUSY 0x04
196 /* Values for ULTRA_CHANNEL_PROTOCOL.Features: This define exists so
197 * that windows guest can look at the FeatureFlags in the io channel,
198 * and configure the windows driver to use interrupts or not based on
199 * this setting. This flag is set in uislib after the
200 * ULTRA_VHBA_init_channel is called. All feature bits for all
201 * channels should be defined here. The io channel feature bits are
202 * defined right here */
203 #define ULTRA_IO_DRIVER_ENABLES_INTS (0x1ULL << 1)
204 #define ULTRA_IO_CHANNEL_IS_POLLING (0x1ULL << 3)
205 #define ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS (0x1ULL << 4)
206 #define ULTRA_IO_DRIVER_DISABLES_INTS (0x1ULL << 5)
207 #define ULTRA_IO_DRIVER_SUPPORTS_ENHANCED_RCVBUF_CHECKING (0x1ULL << 6)
209 #pragma pack(push, 1) /* both GCC and VC now allow this pragma */
210 /* Common Channel Header */
211 typedef struct _CHANNEL_HEADER
{
212 U64 Signature
; /* Signature */
213 u32 LegacyState
; /* DEPRECATED - being replaced by */
214 /* / SrvState, CliStateBoot, and CliStateOS below */
215 u32 HeaderSize
; /* sizeof(CHANNEL_HEADER) */
216 U64 Size
; /* Total size of this channel in bytes */
217 U64 Features
; /* Flags to modify behavior */
218 uuid_le Type
; /* Channel type: data, bus, control, etc. */
219 U64 PartitionHandle
; /* ID of guest partition */
220 U64 Handle
; /* Device number of this channel in client */
221 U64 oChannelSpace
; /* Offset in bytes to channel specific area */
222 u32 VersionId
; /* CHANNEL_HEADER Version ID */
223 u32 PartitionIndex
; /* Index of guest partition */
224 uuid_le ZoneGuid
; /* Guid of Channel's zone */
225 u32 oClientString
; /* offset from channel header to
226 * nul-terminated ClientString (0 if
227 * ClientString not present) */
228 u32 CliStateBoot
; /* CHANNEL_CLIENTSTATE of pre-boot
229 * EFI client of this channel */
230 u32 CmdStateCli
; /* CHANNEL_COMMANDSTATE (overloaded in
231 * Windows drivers, see ServerStateUp,
232 * ServerStateDown, etc) */
233 u32 CliStateOS
; /* CHANNEL_CLIENTSTATE of Guest OS
234 * client of this channel */
235 u32 ChannelCharacteristics
; /* CHANNEL_CHARACTERISTIC_<xxx> */
236 u32 CmdStateSrv
; /* CHANNEL_COMMANDSTATE (overloaded in
237 * Windows drivers, see ServerStateUp,
238 * ServerStateDown, etc) */
239 u32 SrvState
; /* CHANNEL_SERVERSTATE */
240 u8 CliErrorBoot
; /* bits to indicate err states for
241 * boot clients, so err messages can
243 u8 CliErrorOS
; /* bits to indicate err states for OS
244 * clients, so err messages can be
246 u8 Filler
[1]; /* Pad out to 128 byte cacheline */
247 /* Please add all new single-byte values below here */
249 } CHANNEL_HEADER
, *pCHANNEL_HEADER
, ULTRA_CHANNEL_PROTOCOL
;
251 #define ULTRA_CHANNEL_ENABLE_INTS (0x1ULL << 0)
253 /* Subheader for the Signal Type variation of the Common Channel */
254 typedef struct _SIGNAL_QUEUE_HEADER
{
256 u32 VersionId
; /* SIGNAL_QUEUE_HEADER Version ID */
257 u32 Type
; /* Queue type: storage, network */
258 U64 Size
; /* Total size of this queue in bytes */
259 U64 oSignalBase
; /* Offset to signal queue area */
260 U64 FeatureFlags
; /* Flags to modify behavior */
261 U64 NumSignalsSent
; /* Total # of signals placed in this queue */
262 U64 NumOverflows
; /* Total # of inserts failed due to
264 u32 SignalSize
; /* Total size of a signal for this queue */
265 u32 MaxSignalSlots
; /* Max # of slots in queue, 1 slot is
267 u32 MaxSignals
; /* Max # of signals in queue
268 * (MaxSignalSlots-1) */
269 u32 Head
; /* Queue head signal # */
271 U64 NumSignalsReceived
; /* Total # of signals removed from this queue */
272 u32 Tail
; /* Queue tail signal # (on separate
274 u32 Reserved1
; /* Reserved field */
275 U64 Reserved2
; /* Resrved field */
277 U64 NumInterruptsReceived
; /* Total # of Interrupts received. This
278 * is incremented by the ISR in the
279 * guest windows driver */
280 U64 NumEmptyCnt
; /* Number of times that visor_signal_remove
281 * is called and returned Empty
283 u32 ErrorFlags
; /* Error bits set during SignalReinit
284 * to denote trouble with client's
286 u8 Filler
[12]; /* Pad out to 64 byte cacheline */
287 } SIGNAL_QUEUE_HEADER
, *pSIGNAL_QUEUE_HEADER
;
291 #define SignalInit(chan, QHDRFLD, QDATAFLD, QDATATYPE, ver, typ) \
293 MEMSET(&chan->QHDRFLD, 0, sizeof(chan->QHDRFLD)); \
294 chan->QHDRFLD.VersionId = ver; \
295 chan->QHDRFLD.Type = typ; \
296 chan->QHDRFLD.Size = sizeof(chan->QDATAFLD); \
297 chan->QHDRFLD.SignalSize = sizeof(QDATATYPE); \
298 chan->QHDRFLD.oSignalBase = (UINTN)(chan->QDATAFLD)- \
299 (UINTN)(&chan->QHDRFLD); \
300 chan->QHDRFLD.MaxSignalSlots = \
301 sizeof(chan->QDATAFLD)/sizeof(QDATATYPE); \
302 chan->QHDRFLD.MaxSignals = chan->QHDRFLD.MaxSignalSlots-1; \
305 /* Generic function useful for validating any type of channel when it is
306 * received by the client that will be accessing the channel.
307 * Note that <logCtx> is only needed for callers in the EFI environment, and
308 * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
311 ULTRA_check_channel_client(void __iomem
*pChannel
,
312 uuid_le expectedTypeGuid
,
314 U64 expectedMinBytes
,
315 u32 expectedVersionId
,
316 U64 expectedSignature
,
317 char *fileName
, int lineNumber
, void *logCtx
)
319 if (uuid_le_cmp(expectedTypeGuid
, NULL_UUID_LE
) != 0)
320 /* caller wants us to verify type GUID */
321 if (MEMCMP_IO(&(((CHANNEL_HEADER __iomem
*) (pChannel
))->Type
),
322 &expectedTypeGuid
, sizeof(uuid_le
)) != 0) {
323 CHANNEL_GUID_MISMATCH(expectedTypeGuid
, channelName
,
324 "type", expectedTypeGuid
,
325 ((CHANNEL_HEADER __iomem
*)
326 (pChannel
))->Type
, fileName
,
330 if (expectedMinBytes
> 0) /* caller wants us to verify
332 if (readq(&((CHANNEL_HEADER __iomem
*)
333 (pChannel
))->Size
) < expectedMinBytes
) {
334 CHANNEL_U64_MISMATCH(expectedTypeGuid
, channelName
,
335 "size", expectedMinBytes
,
336 readq(&((CHANNEL_HEADER __iomem
*)
342 if (expectedVersionId
> 0) /* caller wants us to verify
344 if (readl(&((CHANNEL_HEADER __iomem
*) (pChannel
))->VersionId
)
345 != expectedVersionId
) {
346 CHANNEL_U32_MISMATCH(expectedTypeGuid
, channelName
,
347 "version", expectedVersionId
,
348 readl(&((CHANNEL_HEADER __iomem
*)
349 (pChannel
))->VersionId
),
350 fileName
, lineNumber
, logCtx
);
353 if (expectedSignature
> 0) /* caller wants us to verify
354 * channel signature */
355 if (readq(&((CHANNEL_HEADER __iomem
*) (pChannel
))->Signature
)
356 != expectedSignature
) {
357 CHANNEL_U64_MISMATCH(expectedTypeGuid
, channelName
,
358 "signature", expectedSignature
,
359 readq(&((CHANNEL_HEADER __iomem
*)
360 (pChannel
))->Signature
),
368 /* Generic function useful for validating any type of channel when it is about
369 * to be initialized by the server of the channel.
370 * Note that <logCtx> is only needed for callers in the EFI environment, and
371 * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages.
374 ULTRA_check_channel_server(uuid_le typeGuid
,
376 U64 expectedMinBytes
,
378 char *fileName
, int lineNumber
, void *logCtx
)
380 if (expectedMinBytes
> 0) /* caller wants us to verify
382 if (actualBytes
< expectedMinBytes
) {
383 CHANNEL_U64_MISMATCH(typeGuid
, channelName
, "size",
384 expectedMinBytes
, actualBytes
,
385 fileName
, lineNumber
, logCtx
);
391 /* Given a file pathname <s> (with '/' or '\' separating directory nodes),
392 * returns a pointer to the beginning of a node within that pathname such
393 * that the number of nodes from that pointer to the end of the string is
394 * NOT more than <n>. Note that if the pathname has less than <n> nodes
395 * in it, the return pointer will be to the beginning of the string.
398 PathName_Last_N_Nodes(u8
*s
, unsigned int n
)
401 unsigned int node_count
= 0;
403 if ((*p
== '/') || (*p
== '\\'))
412 break; /* should never happen, unless someone
413 * is changing the string while we are
415 if ((*p
== '/') || (*p
== '\\'))
422 ULTRA_channel_client_acquire_os(void __iomem
*pChannel
, u8
*chanId
,
423 void *logCtx
, char *file
, int line
, char *func
)
425 CHANNEL_HEADER __iomem
*pChan
= pChannel
;
427 if (readl(&pChan
->CliStateOS
) == CHANNELCLI_DISABLED
) {
428 if ((readb(&pChan
->CliErrorOS
)
429 & ULTRA_CLIERROROS_THROTTLEMSG_DISABLED
) == 0) {
430 /* we are NOT throttling this message */
431 writeb(readb(&pChan
->CliErrorOS
) |
432 ULTRA_CLIERROROS_THROTTLEMSG_DISABLED
,
434 /* throttle until acquire successful */
436 UltraLogEvent(logCtx
,
437 CHANNELSTATE_DIAG_EVENTID_TRANSITERR
,
438 CHANNELSTATE_DIAG_SEVERITY
,
439 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
440 "%s Channel StateTransition INVALID! - acquire failed because OS client DISABLED @%s:%d\n",
441 chanId
, PathName_Last_N_Nodes(
442 (u8
*) file
, 4), line
);
446 if ((readl(&pChan
->CliStateOS
) != CHANNELCLI_OWNED
)
447 && (readl(&pChan
->CliStateBoot
) == CHANNELCLI_DISABLED
)) {
448 /* Our competitor is DISABLED, so we can transition to OWNED */
449 UltraLogEvent(logCtx
, CHANNELSTATE_DIAG_EVENTID_TRANSITOK
,
450 CHANNELSTATE_DIAG_SEVERITY
,
451 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
452 "%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n",
453 chanId
, "CliStateOS",
454 ULTRA_CHANNELCLI_STRING(
455 readl(&pChan
->CliStateOS
)),
456 readl(&pChan
->CliStateOS
),
457 ULTRA_CHANNELCLI_STRING(CHANNELCLI_OWNED
),
459 PathName_Last_N_Nodes((u8
*) file
, 4), line
);
460 writel(CHANNELCLI_OWNED
, &pChan
->CliStateOS
);
463 if (readl(&pChan
->CliStateOS
) == CHANNELCLI_OWNED
) {
464 if (readb(&pChan
->CliErrorOS
) != 0) {
465 /* we are in an error msg throttling state;
467 UltraLogEvent(logCtx
,
468 CHANNELSTATE_DIAG_EVENTID_TRANSITOK
,
469 CHANNELSTATE_DIAG_SEVERITY
,
470 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
471 "%s Channel OS client acquire now successful @%s:%d\n",
472 chanId
, PathName_Last_N_Nodes((u8
*) file
,
474 writeb(0, &pChan
->CliErrorOS
);
479 /* We have to do it the "hard way". We transition to BUSY,
480 * and can use the channel iff our competitor has not also
481 * transitioned to BUSY. */
482 if (readl(&pChan
->CliStateOS
) != CHANNELCLI_ATTACHED
) {
483 if ((readb(&pChan
->CliErrorOS
)
484 & ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED
) == 0) {
485 /* we are NOT throttling this message */
486 writeb(readb(&pChan
->CliErrorOS
) |
487 ULTRA_CLIERROROS_THROTTLEMSG_NOTATTACHED
,
489 /* throttle until acquire successful */
490 UltraLogEvent(logCtx
,
491 CHANNELSTATE_DIAG_EVENTID_TRANSITERR
,
492 CHANNELSTATE_DIAG_SEVERITY
,
493 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
494 "%s Channel StateTransition INVALID! - acquire failed because OS client NOT ATTACHED (state=%s(%d)) @%s:%d\n",
496 ULTRA_CHANNELCLI_STRING(
497 readl(&pChan
->CliStateOS
)),
498 readl(&pChan
->CliStateOS
),
499 PathName_Last_N_Nodes((u8
*) file
, 4),
504 writel(CHANNELCLI_BUSY
, &pChan
->CliStateOS
);
506 if (readl(&pChan
->CliStateBoot
) == CHANNELCLI_BUSY
) {
507 if ((readb(&pChan
->CliErrorOS
)
508 & ULTRA_CLIERROROS_THROTTLEMSG_BUSY
) == 0) {
509 /* we are NOT throttling this message */
510 writeb(readb(&pChan
->CliErrorOS
) |
511 ULTRA_CLIERROROS_THROTTLEMSG_BUSY
,
513 /* throttle until acquire successful */
514 UltraLogEvent(logCtx
,
515 CHANNELSTATE_DIAG_EVENTID_TRANSITBUSY
,
516 CHANNELSTATE_DIAG_SEVERITY
,
517 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
518 "%s Channel StateTransition failed - host OS acquire failed because boot BUSY @%s:%d\n",
519 chanId
, PathName_Last_N_Nodes((u8
*) file
,
523 writel(CHANNELCLI_ATTACHED
, &pChan
->CliStateOS
);
527 if (readb(&pChan
->CliErrorOS
) != 0) {
528 /* we are in an error msg throttling state; come out of it */
529 UltraLogEvent(logCtx
, CHANNELSTATE_DIAG_EVENTID_TRANSITOK
,
530 CHANNELSTATE_DIAG_SEVERITY
,
531 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
532 "%s Channel OS client acquire now successful @%s:%d\n",
533 chanId
, PathName_Last_N_Nodes((u8
*) file
, 4),
535 writeb(0, &pChan
->CliErrorOS
);
541 ULTRA_channel_client_release_os(void __iomem
*pChannel
, u8
*chanId
,
542 void *logCtx
, char *file
, int line
, char *func
)
544 CHANNEL_HEADER __iomem
*pChan
= pChannel
;
545 if (readb(&pChan
->CliErrorOS
) != 0) {
546 /* we are in an error msg throttling state; come out of it */
547 UltraLogEvent(logCtx
, CHANNELSTATE_DIAG_EVENTID_TRANSITOK
,
548 CHANNELSTATE_DIAG_SEVERITY
,
549 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
550 "%s Channel OS client error state cleared @%s:%d\n",
551 chanId
, PathName_Last_N_Nodes((u8
*) file
, 4),
553 writeb(0, &pChan
->CliErrorOS
);
555 if (readl(&pChan
->CliStateOS
) == CHANNELCLI_OWNED
)
557 if (readl(&pChan
->CliStateOS
) != CHANNELCLI_BUSY
) {
558 UltraLogEvent(logCtx
, CHANNELSTATE_DIAG_EVENTID_TRANSITERR
,
559 CHANNELSTATE_DIAG_SEVERITY
,
560 CHANNELSTATE_DIAG_SUBSYS
, func
, line
,
561 "%s Channel StateTransition INVALID! - release failed because OS client NOT BUSY (state=%s(%d)) @%s:%d\n",
563 ULTRA_CHANNELCLI_STRING(
564 readl(&pChan
->CliStateOS
)),
565 readl(&pChan
->CliStateOS
),
566 PathName_Last_N_Nodes((u8
*) file
, 4), line
);
569 writel(CHANNELCLI_ATTACHED
, &pChan
->CliStateOS
); /* release busy */
573 * Routine Description:
574 * Tries to insert the prebuilt signal pointed to by pSignal into the nth
575 * Queue of the Channel pointed to by pChannel
578 * pChannel: (IN) points to the IO Channel
579 * Queue: (IN) nth Queue of the IO Channel
580 * pSignal: (IN) pointer to the signal
583 * - pChannel, Queue and pSignal are valid.
584 * - If insertion fails due to a full queue, the caller will determine the
585 * retry policy (e.g. wait & try again, report an error, etc.).
587 * Return value: 1 if the insertion succeeds, 0 if the queue was
591 unsigned char visor_signal_insert(CHANNEL_HEADER __iomem
*pChannel
, u32 Queue
,
595 * Routine Description:
596 * Removes one signal from Channel pChannel's nth Queue at the
597 * time of the call and copies it into the memory pointed to by
601 * pChannel: (IN) points to the IO Channel
602 * Queue: (IN) nth Queue of the IO Channel
603 * pSignal: (IN) pointer to where the signals are to be copied
606 * - pChannel and Queue are valid.
607 * - pSignal points to a memory area large enough to hold queue's SignalSize
609 * Return value: 1 if the removal succeeds, 0 if the queue was
613 unsigned char visor_signal_remove(CHANNEL_HEADER __iomem
*pChannel
, u32 Queue
,
617 * Routine Description:
618 * Removes all signals present in Channel pChannel's nth Queue at the
619 * time of the call and copies them into the memory pointed to by
620 * pSignal. Returns the # of signals copied as the value of the routine.
623 * pChannel: (IN) points to the IO Channel
624 * Queue: (IN) nth Queue of the IO Channel
625 * pSignal: (IN) pointer to where the signals are to be copied
628 * - pChannel and Queue are valid.
629 * - pSignal points to a memory area large enough to hold Queue's MaxSignals
630 * # of signals, each of which is Queue's SignalSize.
633 * # of signals copied.
635 unsigned int SignalRemoveAll(pCHANNEL_HEADER pChannel
, u32 Queue
,
639 * Routine Description:
640 * Determine whether a signal queue is empty.
643 * pChannel: (IN) points to the IO Channel
644 * Queue: (IN) nth Queue of the IO Channel
647 * 1 if the signal queue is empty, 0 otherwise.
649 unsigned char visor_signalqueue_empty(CHANNEL_HEADER __iomem
*pChannel
,