1 /********************************************************************** 2 * Author: Cavium, Inc. 3 * 4 * Contact: support@cavium.com 5 * Please include "LiquidIO" in the subject. 6 * 7 * Copyright (c) 2003-2016 Cavium, Inc. 8 * 9 * This file is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License, Version 2, as 11 * published by the Free Software Foundation. 12 * 13 * This file is distributed in the hope that it will be useful, but 14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or 16 * NONINFRINGEMENT. See the GNU General Public License for more 17 * details. 18 **********************************************************************/ 19 20 /*! \file response_manager.h 21 * \brief Host Driver: Response queues for host instructions. 22 */ 23 24 #ifndef __RESPONSE_MANAGER_H__ 25 #define __RESPONSE_MANAGER_H__ 26 27 /** Maximum ordered requests to process in every invocation of 28 * lio_process_ordered_list(). The function will continue to process requests 29 * as long as it can find one that has finished processing. If it keeps 30 * finding requests that have completed, the function can run for ever. The 31 * value defined here sets an upper limit on the number of requests it can 32 * process before it returns control to the poll thread. 33 */ 34 #define MAX_ORD_REQS_TO_PROCESS 4096 35 36 /** Head of a response list. There are several response lists in the 37 * system. One for each response order- Unordered, ordered 38 * and 1 for noresponse entries on each instruction queue. 39 */ 40 struct octeon_response_list { 41 /** List structure to add delete pending entries to */ 42 struct list_head head; 43 44 /** A lock for this response list */ 45 spinlock_t lock; 46 47 atomic_t pending_req_count; 48 }; 49 50 /** The type of response list. 51 */ 52 enum { 53 OCTEON_ORDERED_LIST = 0, 54 OCTEON_UNORDERED_NONBLOCKING_LIST = 1, 55 OCTEON_UNORDERED_BLOCKING_LIST = 2, 56 OCTEON_ORDERED_SC_LIST = 3 57 }; 58 59 /** Response Order values for a Octeon Request. */ 60 enum { 61 OCTEON_RESP_ORDERED = 0, 62 OCTEON_RESP_UNORDERED = 1, 63 OCTEON_RESP_NORESPONSE = 2 64 }; 65 66 /** Error codes used in Octeon Host-Core communication. 67 * 68 * 31 16 15 0 69 * --------------------------------- 70 * | | | 71 * --------------------------------- 72 * Error codes are 32-bit wide. The upper 16-bits, called Major Error Number, 73 * are reserved to identify the group to which the error code belongs. The 74 * lower 16-bits, called Minor Error Number, carry the actual code. 75 * 76 * So error codes are (MAJOR NUMBER << 16)| MINOR_NUMBER. 77 */ 78 79 /*------------ Error codes used by host driver -----------------*/ 80 #define DRIVER_MAJOR_ERROR_CODE 0x0000 81 /*------ Error codes used by firmware (bits 15..0 set by firmware */ 82 #define FIRMWARE_MAJOR_ERROR_CODE 0x0001 83 84 /** A value of 0x00000000 indicates no error i.e. success */ 85 #define DRIVER_ERROR_NONE 0x00000000 86 87 #define DRIVER_ERROR_REQ_PENDING 0x00000001 88 #define DRIVER_ERROR_REQ_TIMEOUT 0x00000003 89 #define DRIVER_ERROR_REQ_EINTR 0x00000004 90 #define DRIVER_ERROR_REQ_ENXIO 0x00000006 91 #define DRIVER_ERROR_REQ_ENOMEM 0x0000000C 92 #define DRIVER_ERROR_REQ_EINVAL 0x00000016 93 #define DRIVER_ERROR_REQ_FAILED 0x000000ff 94 95 /** Status for a request. 96 * If a request is not queued to Octeon by the driver, the driver returns 97 * an error condition that's describe by one of the OCTEON_REQ_ERR_* value 98 * below. If the request is successfully queued, the driver will return 99 * a OCTEON_REQUEST_PENDING status. OCTEON_REQUEST_TIMEOUT and 100 * OCTEON_REQUEST_INTERRUPTED are only returned by the driver if the 101 * response for request failed to arrive before a time-out period or if 102 * the request processing * got interrupted due to a signal respectively. 103 */ 104 enum { 105 OCTEON_REQUEST_DONE = (DRIVER_ERROR_NONE), 106 OCTEON_REQUEST_PENDING = (DRIVER_ERROR_REQ_PENDING), 107 OCTEON_REQUEST_TIMEOUT = (DRIVER_ERROR_REQ_TIMEOUT), 108 OCTEON_REQUEST_INTERRUPTED = (DRIVER_ERROR_REQ_EINTR), 109 OCTEON_REQUEST_NO_DEVICE = (0x00000021), 110 OCTEON_REQUEST_NOT_RUNNING, 111 OCTEON_REQUEST_INVALID_IQ, 112 OCTEON_REQUEST_INVALID_BUFCNT, 113 OCTEON_REQUEST_INVALID_RESP_ORDER, 114 OCTEON_REQUEST_NO_MEMORY, 115 OCTEON_REQUEST_INVALID_BUFSIZE, 116 OCTEON_REQUEST_NO_PENDING_ENTRY, 117 OCTEON_REQUEST_NO_IQ_SPACE = (0x7FFFFFFF) 118 119 }; 120 121 #define FIRMWARE_STATUS_CODE(status) \ 122 ((FIRMWARE_MAJOR_ERROR_CODE << 16) | (status)) 123 124 /** Initialize the response lists. The number of response lists to create is 125 * given by count. 126 * @param octeon_dev - the octeon device structure. 127 */ 128 int octeon_setup_response_list(struct octeon_device *octeon_dev); 129 130 void octeon_delete_response_list(struct octeon_device *octeon_dev); 131 132 /** Check the status of first entry in the ordered list. If the instruction at 133 * that entry finished processing or has timed-out, the entry is cleaned. 134 * @param octeon_dev - the octeon device structure. 135 * @param force_quit - the request is forced to timeout if this is 1 136 * @return 1 if the ordered list is empty, 0 otherwise. 137 */ 138 int lio_process_ordered_list(struct octeon_device *octeon_dev, 139 u32 force_quit); 140 141 #endif 142