response_manager.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. /*! \file response_manager.h
  20. * \brief Host Driver: Response queues for host instructions.
  21. */
  22. #ifndef __RESPONSE_MANAGER_H__
  23. #define __RESPONSE_MANAGER_H__
  24. /** Maximum ordered requests to process in every invocation of
  25. * lio_process_ordered_list(). The function will continue to process requests
  26. * as long as it can find one that has finished processing. If it keeps
  27. * finding requests that have completed, the function can run for ever. The
  28. * value defined here sets an upper limit on the number of requests it can
  29. * process before it returns control to the poll thread.
  30. */
  31. #define MAX_ORD_REQS_TO_PROCESS 4096
  32. /** Head of a response list. There are several response lists in the
  33. * system. One for each response order- Unordered, ordered
  34. * and 1 for noresponse entries on each instruction queue.
  35. */
  36. struct octeon_response_list {
  37. /** List structure to add delete pending entries to */
  38. struct list_head head;
  39. /** A lock for this response list */
  40. spinlock_t lock;
  41. atomic_t pending_req_count;
  42. };
  43. /** The type of response list.
  44. */
  45. enum {
  46. OCTEON_ORDERED_LIST = 0,
  47. OCTEON_UNORDERED_NONBLOCKING_LIST = 1,
  48. OCTEON_UNORDERED_BLOCKING_LIST = 2,
  49. OCTEON_ORDERED_SC_LIST = 3
  50. };
  51. /** Response Order values for a Octeon Request. */
  52. enum {
  53. OCTEON_RESP_ORDERED = 0,
  54. OCTEON_RESP_UNORDERED = 1,
  55. OCTEON_RESP_NORESPONSE = 2
  56. };
  57. /** Error codes used in Octeon Host-Core communication.
  58. *
  59. * 31 16 15 0
  60. * ---------------------------------
  61. * | | |
  62. * ---------------------------------
  63. * Error codes are 32-bit wide. The upper 16-bits, called Major Error Number,
  64. * are reserved to identify the group to which the error code belongs. The
  65. * lower 16-bits, called Minor Error Number, carry the actual code.
  66. *
  67. * So error codes are (MAJOR NUMBER << 16)| MINOR_NUMBER.
  68. */
  69. /*------------ Error codes used by host driver -----------------*/
  70. #define DRIVER_MAJOR_ERROR_CODE 0x0000
  71. /** A value of 0x00000000 indicates no error i.e. success */
  72. #define DRIVER_ERROR_NONE 0x00000000
  73. #define DRIVER_ERROR_REQ_PENDING 0x00000001
  74. #define DRIVER_ERROR_REQ_TIMEOUT 0x00000003
  75. #define DRIVER_ERROR_REQ_EINTR 0x00000004
  76. #define DRIVER_ERROR_REQ_ENXIO 0x00000006
  77. #define DRIVER_ERROR_REQ_ENOMEM 0x0000000C
  78. #define DRIVER_ERROR_REQ_EINVAL 0x00000016
  79. #define DRIVER_ERROR_REQ_FAILED 0x000000ff
  80. /** Status for a request.
  81. * If a request is not queued to Octeon by the driver, the driver returns
  82. * an error condition that's describe by one of the OCTEON_REQ_ERR_* value
  83. * below. If the request is successfully queued, the driver will return
  84. * a OCTEON_REQUEST_PENDING status. OCTEON_REQUEST_TIMEOUT and
  85. * OCTEON_REQUEST_INTERRUPTED are only returned by the driver if the
  86. * response for request failed to arrive before a time-out period or if
  87. * the request processing * got interrupted due to a signal respectively.
  88. */
  89. enum {
  90. OCTEON_REQUEST_DONE = (DRIVER_ERROR_NONE),
  91. OCTEON_REQUEST_PENDING = (DRIVER_ERROR_REQ_PENDING),
  92. OCTEON_REQUEST_TIMEOUT = (DRIVER_ERROR_REQ_TIMEOUT),
  93. OCTEON_REQUEST_INTERRUPTED = (DRIVER_ERROR_REQ_EINTR),
  94. OCTEON_REQUEST_NO_DEVICE = (0x00000021),
  95. OCTEON_REQUEST_NOT_RUNNING,
  96. OCTEON_REQUEST_INVALID_IQ,
  97. OCTEON_REQUEST_INVALID_BUFCNT,
  98. OCTEON_REQUEST_INVALID_RESP_ORDER,
  99. OCTEON_REQUEST_NO_MEMORY,
  100. OCTEON_REQUEST_INVALID_BUFSIZE,
  101. OCTEON_REQUEST_NO_PENDING_ENTRY,
  102. OCTEON_REQUEST_NO_IQ_SPACE = (0x7FFFFFFF)
  103. };
  104. /** Initialize the response lists. The number of response lists to create is
  105. * given by count.
  106. * @param octeon_dev - the octeon device structure.
  107. */
  108. int octeon_setup_response_list(struct octeon_device *octeon_dev);
  109. void octeon_delete_response_list(struct octeon_device *octeon_dev);
  110. /** Check the status of first entry in the ordered list. If the instruction at
  111. * that entry finished processing or has timed-out, the entry is cleaned.
  112. * @param octeon_dev - the octeon device structure.
  113. * @param force_quit - the request is forced to timeout if this is 1
  114. * @return 1 if the ordered list is empty, 0 otherwise.
  115. */
  116. int lio_process_ordered_list(struct octeon_device *octeon_dev,
  117. u32 force_quit);
  118. #endif