4 * Copyright(c) 2017 Cavium, Inc.. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Cavium, Inc. nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 * ! \file lio_response_manager.h
37 * \brief Host Driver: Response queues for host instructions.
40 #ifndef __LIO_RESPONSE_MANAGER_H__
41 #define __LIO_RESPONSE_MANAGER_H__
44 * Maximum ordered requests to process in every invocation of
45 * lio_process_ordered_list(). The function will continue to process requests
46 * as long as it can find one that has finished processing. If it keeps
47 * finding requests that have completed, the function can run for ever. The
48 * value defined here sets an upper limit on the number of requests it can
49 * process before it returns control to the poll thread.
51 #define LIO_MAX_ORD_REQS_TO_PROCESS 4096
54 * Head of a response list. There are several response lists in the
55 * system. One for each response order- Unordered, ordered
56 * and 1 for noresponse entries on each instruction queue.
59 struct lio_response_list {
60 /* List structure to add delete pending entries to */
61 struct lio_stailq_head head;
63 /* A lock for this response list */
66 volatile int pending_req_count;
69 /* The type of response list. */
72 LIO_UNORDERED_NONBLOCKING_LIST = 1,
73 LIO_UNORDERED_BLOCKING_LIST = 2,
74 LIO_ORDERED_SC_LIST = 3
78 * Error codes used in Octeon Host-Core communication.
81 * ---------------------------------
83 * ---------------------------------
84 * Error codes are 32-bit wide. The upper 16-bits, called Major Error Number,
85 * are reserved to identify the group to which the error code belongs. The
86 * lower 16-bits, called Minor Error Number, carry the actual code.
88 * So error codes are (MAJOR NUMBER << 16)| MINOR_NUMBER.
91 /*------ Error codes used by firmware (bits 15..0 set by firmware */
92 #define LIO_FW_MAJOR_ERROR_CODE 0x0001
94 /* A value of 0x00000000 indicates no error i.e. success */
95 #define LIO_DRIVER_ERROR_NONE 0x00000000
97 #define LIO_DRIVER_ERROR_REQ_PENDING 0x00000001
98 #define LIO_DRIVER_ERROR_REQ_TIMEOUT 0x00000003
99 #define LIO_DRIVER_ERROR_REQ_EINTR 0x00000004
102 * Status for a request.
103 * If a request is not queued to Octeon by the driver, the driver returns
104 * an error condition that's describe by one of the OCTEON_REQ_ERR_* value
105 * below. If the request is successfully queued, the driver will return
106 * a LIO_REQUEST_PENDING status. LIO_REQUEST_TIMEOUT and
107 * LIO_REQUEST_INTERRUPTED are only returned by the driver if the
108 * response for request failed to arrive before a time-out period or if
109 * the request processing * got interrupted due to a signal respectively.
112 LIO_REQUEST_DONE = (LIO_DRIVER_ERROR_NONE),
113 LIO_REQUEST_PENDING = (LIO_DRIVER_ERROR_REQ_PENDING),
114 LIO_REQUEST_TIMEOUT = (LIO_DRIVER_ERROR_REQ_TIMEOUT),
115 LIO_REQUEST_INTERRUPTED = (LIO_DRIVER_ERROR_REQ_EINTR),
116 LIO_REQUEST_NO_DEVICE = (0x00000021),
117 LIO_REQUEST_NOT_RUNNING,
118 LIO_REQUEST_INVALID_IQ,
119 LIO_REQUEST_INVALID_BUFCNT,
120 LIO_REQUEST_INVALID_RESP_ORDER,
121 LIO_REQUEST_NO_MEMORY,
122 LIO_REQUEST_INVALID_BUFSIZE,
123 LIO_REQUEST_NO_PENDING_ENTRY,
124 LIO_REQUEST_NO_IQ_SPACE = (0x7FFFFFFF)
127 #define LIO_STAILQ_FIRST_ENTRY(ptr, type, elem) \
128 (type *)((char *)((ptr)->stqh_first) - offsetof(type, elem))
130 #define LIO_FW_STATUS_CODE(status) \
131 ((LIO_FW_MAJOR_ERROR_CODE << 16) | (status))
134 * Initialize the response lists. The number of response lists to create is
136 * @param octeon_dev - the octeon device structure.
138 int lio_setup_response_list(struct octeon_device *octeon_dev);
139 void lio_delete_response_list(struct octeon_device *octeon_dev);
142 * Check the status of first entry in the ordered list. If the instruction at
143 * that entry finished processing or has timed-out, the entry is cleaned.
144 * @param octeon_dev - the octeon device structure.
145 * @param force_quit - the request is forced to timeout if this is 1
146 * @return 1 if the ordered list is empty, 0 otherwise.
148 int lio_process_ordered_list(struct octeon_device *octeon_dev,
149 uint32_t force_quit);
151 #endif /* __LIO_RESPONSE_MANAGER_H__ */