driver-cointerra.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * Copyright 2013-2014 Con Kolivas
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #ifndef COINTERRA_H
  10. #define COINTERRA_H
  11. #define CTA_READBUF_SIZE 8192
  12. #define CTA_MSG_SIZE 64
  13. #define CTA_READ_TIMEOUT 1
  14. #define CTA_READ_INTERVAL 100
  15. #define CTA_SCAN_INTERVAL 500
  16. #define CTA_RESET_TIMEOUT 1000
  17. #define CTA_INIT_DIFF 32
  18. #if 0
  19. /* FIXME: how big should this be? */
  20. #define CTA_MAX_QUEUE 2300
  21. #else
  22. #define CTA_MAX_QUEUE (32 / CTA_NROLL_TIME)
  23. #endif
  24. #define CTA_NROLL_TIME 2
  25. /* Offsets into buffer */
  26. #define CTA_MSG_TYPE 2
  27. #define CTA_RESET_TYPE 3
  28. #define CTA_RESET_DIFF 4
  29. #define CTA_RESET_LOAD 5
  30. #define CTA_RESET_PSLOAD 6
  31. #define CTA_DRIVER_TAG 3
  32. #define CTA_MCU_TAG 5
  33. #define CTA_MCU_CORE 5
  34. #define CTA_MCU_ASIC 6
  35. #define CTA_MCU_PIPE 8
  36. #define CTA_MATCH_NOFFSET 45
  37. #define CTA_MATCH_NONCE 60
  38. #define CTA_WDONE_NONCES 11
  39. #define CTA_MSG_RECVD 3
  40. #define CTA_WORK_MIDSTATE 9
  41. #define CTA_WORK_DATA 41
  42. #define CTA_WORK_NROLL 53
  43. #define CTA_WORK_DIFFBITS 55
  44. #define CTA_REQWORK_REQUESTS 3
  45. #define CTA_CORE_HASHRATES 3
  46. /* Received message types */
  47. #define CTA_RECV_UNUSED 0
  48. #define CTA_RECV_REQWORK 1
  49. #define CTA_RECV_MATCH 2
  50. #define CTA_RECV_WDONE 3
  51. #define CTA_RECV_STATREAD 4
  52. #define CTA_RECV_STATSET 5
  53. #define CTA_RECV_INFO 6
  54. #define CTA_RECV_MSG 7
  55. #define CTA_RECV_RDONE 8
  56. #define CTA_RECV_STATDEBUG 10
  57. /* Sent message types */
  58. #define CTA_SEND_UNUSED 0
  59. #define CTA_SEND_RESET 1
  60. #define CTA_SEND_WORK 2
  61. #define CTA_SEND_SETPERF 3
  62. #define CTA_SEND_REQUEST 4
  63. #define CTA_SEND_FMATCH 5
  64. #define CTA_SEND_IDENTIFY 6
  65. #define CTA_SEND_COREHASHRATE 7
  66. /* Types of reset in CTA_RESET_TYPE */
  67. #define CTA_RESET_NONE 0
  68. #define CTA_RESET_UPDATE 1
  69. #define CTA_RESET_NEW 2
  70. #define CTA_RESET_INIT 3
  71. #define CTA_INFO_HWREV 3
  72. #define CTA_INFO_SERNO 5
  73. #define CTA_INFO_NUMASICS 9
  74. #define CTA_INFO_NUMDIES 10
  75. #define CTA_INFO_NUMCORES 11
  76. #define CTA_INFO_BOARDNUMBER 13
  77. #define CTA_INFO_FWREV_MAJ 19
  78. #define CTA_INFO_FWREV_MIN 20
  79. #define CTA_INFO_FWREV_MIC 21
  80. #define CTA_INFO_FWDATE_YEAR 23
  81. #define CTA_INFO_FWDATE_MONTH 25
  82. #define CTA_INFO_FWDATE_DAY 26
  83. #define CTA_INFO_INITDIFFBITS 27
  84. #define CTA_INFO_MINDIFFBITS 28
  85. #define CTA_INFO_MAXDIFFBITS 29
  86. #define CTA_STAT_CORETEMPS 3
  87. #define CTA_STAT_AMBTEMP_LOW 19
  88. #define CTA_STAT_AMBTEMP_AVG 21
  89. #define CTA_STAT_AMBTEMP_HIGH 23
  90. #define CTA_STAT_PUMP_TACHS 25
  91. #define CTA_STAT_FAN_TACHS 29
  92. #define CTA_STAT_CORE_VOLTS 37
  93. #define CTA_STAT_VOLTS33 53
  94. #define CTA_STAT_VOLTS12 55
  95. #define CTA_STAT_INACTIVE 57
  96. #define CTA_STAT_ACTIVE 59
  97. #define CTA_STAT_PERFMODE 3
  98. #define CTA_STAT_FANSPEEDS 11
  99. #define CTA_STAT_DIES_ACTIVE 15
  100. #define CTA_STAT_PIPES_ENABLED 16
  101. #define CTA_STAT_MIN_FAN_SPEED 24
  102. #define CTA_STAT_UPTIME 25
  103. #define CTA_STAT_HEARTBEATS 29
  104. #define CTA_STAT_CORE_FREQS 45
  105. #define CTA_STAT_UNDERRUNS 3
  106. #define CTA_STAT_HW_ERRORS 5
  107. #define CTA_STAT_UPTIME_MS 21
  108. #define CTA_STAT_HASHES 25
  109. #define CTA_STAT_FLUSHED_HASHES 33
  110. #define CTA_STAT_AUTOVOLTAGE 41
  111. #define CTA_STAT_POWER_PERCENT 42
  112. #define CTA_STAT_POWER_USED 43
  113. #define CTA_STAT_VOLTAGE 45
  114. #define CTA_STAT_IPOWER_USED 47
  115. #define CTA_STAT_IVOLTAGE 49
  116. #define CTA_STAT_PS_TEMP1 51
  117. #define CTA_STAT_PS_TEMP2 53
  118. #define CTA_CORES 8
  119. #define CTA_PUMPS 2
  120. #define CTA_FANS 4
  121. #define CTA_REQ_MSGTYPE 3
  122. #define CTA_REQ_INTERVAL 5
  123. struct cointerra_info {
  124. struct libusb_device_handle *usbh;
  125. struct lowl_usb_endpoint *ep;
  126. uint8_t set_load;
  127. /* Info data */
  128. uint16_t hwrev;
  129. uint32_t serial;
  130. uint8_t asics;
  131. uint8_t dies;
  132. uint16_t cores;
  133. uint8_t board_number;
  134. uint8_t fwrev[3];
  135. uint16_t fw_year;
  136. uint8_t fw_month;
  137. uint8_t fw_day;
  138. uint8_t init_diffbits;
  139. uint8_t min_diffbits;
  140. uint8_t max_diffbits;
  141. /* Status readings data */
  142. uint16_t coretemp[CTA_CORES];
  143. uint16_t ambtemp_low;
  144. uint16_t ambtemp_avg;
  145. uint16_t ambtemp_high;
  146. uint16_t pump_tachs[CTA_PUMPS];
  147. uint16_t fan_tachs[CTA_FANS];
  148. uint16_t corevolts[CTA_CORES];
  149. uint16_t volts33;
  150. uint16_t volts12;
  151. uint16_t inactive;
  152. uint16_t active;
  153. uint16_t corefreqs[CTA_CORES];
  154. uint32_t uptime;
  155. /* Status settings data */
  156. uint8_t coreperf[CTA_CORES];
  157. uint8_t fanspeed[CTA_FANS];
  158. uint8_t dies_active;
  159. uint8_t pipes_enabled[CTA_CORES];
  160. /* Status debug data */
  161. uint16_t underruns;
  162. uint16_t hw_errors[CTA_CORES];
  163. /* Running total from debug messages */
  164. int tot_underruns;
  165. uint16_t tot_hw_errors[CTA_CORES];
  166. uint64_t tot_hashes;
  167. uint64_t tot_reset_hashes;
  168. uint64_t tot_flushed_hashes;
  169. uint8_t autovoltage;
  170. uint8_t current_ps_percent;
  171. uint16_t power_used;
  172. uint16_t power_voltage;
  173. uint16_t ipower_used;
  174. uint16_t ipower_voltage;
  175. uint16_t power_temps[2];
  176. bool autovoltage_complete;
  177. /* Calculated totals based on work done and nonces found */
  178. uint64_t hashes;
  179. uint64_t tot_calc_hashes;
  180. /* Calculated totals based on shares returned */
  181. uint64_t share_hashes;
  182. uint64_t tot_core_hashes[CTA_CORES];
  183. uint64_t tot_share_hashes;
  184. struct timeval core_hash_start;
  185. int requested;
  186. uint16_t work_id;
  187. int no_matching_work;
  188. time_t last_pipe_nonce[1024];
  189. unsigned char pipe_bitmap[128];
  190. struct thr_info *thr;
  191. pthread_mutex_t lock;
  192. pthread_mutex_t sendlock;
  193. notifier_t reset_notifier;
  194. };
  195. #endif /* COINTERRA_H */