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