driver-cointerra.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright 2013-2014 Con Kolivas <kernel@kolivas.org>
  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*0.9999847412109375
  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. #define CTA_RECV_IRSTAT 11
  58. /* Sent message types */
  59. #define CTA_SEND_UNUSED 0
  60. #define CTA_SEND_RESET 1
  61. #define CTA_SEND_WORK 2
  62. #define CTA_SEND_SETPERF 3
  63. #define CTA_SEND_REQUEST 4
  64. #define CTA_SEND_FMATCH 5
  65. #define CTA_SEND_IDENTIFY 6
  66. #define CTA_SEND_COREHASHRATE 7
  67. /* Types of reset in CTA_RESET_TYPE */
  68. #define CTA_RESET_NONE 0
  69. #define CTA_RESET_UPDATE 1
  70. #define CTA_RESET_NEW 2
  71. #define CTA_RESET_INIT 3
  72. #define CTA_INFO_HWREV 3
  73. #define CTA_INFO_SERNO 5
  74. #define CTA_INFO_NUMASICS 9
  75. #define CTA_INFO_NUMDIES 10
  76. #define CTA_INFO_NUMCORES 11
  77. #define CTA_INFO_BOARDNUMBER 13
  78. #define CTA_INFO_FWREV_MAJ 19
  79. #define CTA_INFO_FWREV_MIN 20
  80. #define CTA_INFO_FWREV_MIC 21
  81. #define CTA_INFO_FWDATE_YEAR 23
  82. #define CTA_INFO_FWDATE_MONTH 25
  83. #define CTA_INFO_FWDATE_DAY 26
  84. #define CTA_INFO_INITDIFFBITS 27
  85. #define CTA_INFO_MINDIFFBITS 28
  86. #define CTA_INFO_MAXDIFFBITS 29
  87. #define CTA_STAT_CORETEMPS 3
  88. #define CTA_STAT_AMBTEMP_LOW 19
  89. #define CTA_STAT_AMBTEMP_AVG 21
  90. #define CTA_STAT_AMBTEMP_HIGH 23
  91. #define CTA_STAT_PUMP_TACHS 25
  92. #define CTA_STAT_FAN_TACHS 29
  93. #define CTA_STAT_CORE_VOLTS 37
  94. #define CTA_STAT_VOLTS33 53
  95. #define CTA_STAT_VOLTS12 55
  96. #define CTA_STAT_INACTIVE 57
  97. #define CTA_STAT_ACTIVE 59
  98. #define CTA_STAT_PERFMODE 3
  99. #define CTA_STAT_FANSPEEDS 11
  100. #define CTA_STAT_DIES_ACTIVE 15
  101. #define CTA_STAT_PIPES_ENABLED 16
  102. #define CTA_STAT_MIN_FAN_SPEED 24
  103. #define CTA_STAT_UPTIME 25
  104. #define CTA_STAT_HEARTBEATS 29
  105. #define CTA_STAT_CORE_FREQS 45
  106. #define CTA_STAT_UNDERRUNS 3
  107. #define CTA_STAT_HW_ERRORS 5
  108. #define CTA_STAT_UPTIME_MS 21
  109. #define CTA_STAT_HASHES 25
  110. #define CTA_STAT_FLUSHED_HASHES 33
  111. #define CTA_STAT_AUTOVOLTAGE 41
  112. #define CTA_STAT_POWER_PERCENT 42
  113. #define CTA_STAT_POWER_USED 43
  114. #define CTA_STAT_VOLTAGE 45
  115. #define CTA_STAT_IPOWER_USED 47
  116. #define CTA_STAT_IVOLTAGE 49
  117. #define CTA_STAT_PS_TEMP1 51
  118. #define CTA_STAT_PS_TEMP2 53
  119. #define CTA_IRSTAT_CHANNEL 3
  120. #define CTA_IRSTAT_VIN 4
  121. #define CTA_IRSTAT_IIN 6
  122. #define CTA_IRSTAT_VOUT 8
  123. #define CTA_IRSTAT_IOUT 10
  124. #define CTA_IRSTAT_TEMP1 12
  125. #define CTA_IRSTAT_TEMP2 14
  126. #define CTA_IRSTAT_POUT 16
  127. #define CTA_IRSTAT_PIN 18
  128. #define CTA_IRSTAT_EFF 20
  129. #define CTA_IRSTAT_STATUS 22
  130. #define CTA_CORES 8
  131. #define CTA_PUMPS 2
  132. #define CTA_FANS 4
  133. #define CTA_REQ_MSGTYPE 3
  134. #define CTA_REQ_INTERVAL 5
  135. int opt_cta_load;
  136. int opt_ps_load;
  137. struct cointerra_info {
  138. /* Info data */
  139. uint16_t hwrev;
  140. uint32_t serial;
  141. uint8_t asics;
  142. uint8_t dies;
  143. uint16_t cores;
  144. uint8_t board_number;
  145. uint8_t fwrev[3];
  146. uint16_t fw_year;
  147. uint8_t fw_month;
  148. uint8_t fw_day;
  149. uint8_t init_diffbits;
  150. uint8_t min_diffbits;
  151. uint8_t max_diffbits;
  152. /* Status readings data */
  153. uint16_t coretemp[CTA_CORES];
  154. uint16_t ambtemp_low;
  155. uint16_t ambtemp_avg;
  156. uint16_t ambtemp_high;
  157. uint16_t pump_tachs[CTA_PUMPS];
  158. uint16_t fan_tachs[CTA_FANS];
  159. uint16_t corevolts[CTA_CORES];
  160. uint16_t volts33;
  161. uint16_t volts12;
  162. uint16_t inactive;
  163. uint16_t active;
  164. uint16_t corefreqs[CTA_CORES];
  165. uint32_t uptime;
  166. /* Status settings data */
  167. uint8_t coreperf[CTA_CORES];
  168. uint8_t fanspeed[CTA_FANS];
  169. uint8_t dies_active;
  170. uint8_t pipes_enabled[CTA_CORES];
  171. /* Status debug data */
  172. uint16_t underruns;
  173. uint16_t hw_errors[CTA_CORES];
  174. uint16_t fmatch_errors[CTA_CORES];
  175. /* Running total from debug messages */
  176. int tot_underruns;
  177. uint16_t tot_hw_errors[CTA_CORES];
  178. uint64_t tot_hashes;
  179. uint64_t tot_reset_hashes;
  180. uint64_t tot_flushed_hashes;
  181. uint8_t autovoltage;
  182. uint8_t current_ps_percent;
  183. uint16_t power_used;
  184. uint16_t power_voltage;
  185. uint16_t ipower_used;
  186. uint16_t ipower_voltage;
  187. uint16_t power_temps[2];
  188. bool autovoltage_complete;
  189. /* Calculated totals based on work done and nonces found */
  190. uint64_t hashes;
  191. uint64_t tot_calc_hashes;
  192. /* Calculated totals based on shares returned */
  193. uint64_t share_hashes;
  194. uint64_t tot_core_hashes[CTA_CORES];
  195. uint64_t tot_share_hashes;
  196. struct timeval core_hash_start;
  197. int requested;
  198. uint16_t work_id;
  199. int no_matching_work;
  200. time_t last_pipe_nonce[1024];
  201. unsigned char pipe_bitmap[128];
  202. struct thr_info *thr;
  203. pthread_mutex_t lock;
  204. pthread_mutex_t sendlock;
  205. pthread_cond_t wake_cond;
  206. pthread_t read_thr;
  207. cgsem_t reset_sem;
  208. uint16_t irstat_vin[CTA_CORES];
  209. uint16_t irstat_iin[CTA_CORES];
  210. uint16_t irstat_vout[CTA_CORES];
  211. uint16_t irstat_iout[CTA_CORES];
  212. uint16_t irstat_temp1[CTA_CORES];
  213. uint16_t irstat_temp2[CTA_CORES];
  214. uint16_t irstat_pout[CTA_CORES];
  215. uint16_t irstat_pin[CTA_CORES];
  216. uint16_t irstat_efficiency[CTA_CORES];
  217. uint16_t irstat_status[CTA_CORES];
  218. uint64_t old_hashes[16 * 2];
  219. };
  220. #endif /* COINTERRA_H */