driver-hashfast.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. * Copyright 2013-2014 Con Kolivas <kernel@kolivas.org>
  3. * Copyright 2013 Hashfast
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the Free
  7. * Software Foundation; either version 3 of the License, or (at your option)
  8. * any later version. See COPYING for more details.
  9. */
  10. #ifndef HASHFAST_H
  11. #define HASHFAST_H
  12. #ifdef USE_HASHFAST
  13. #include "miner.h"
  14. #include "elist.h"
  15. #include "hf_protocol.h"
  16. int opt_hfa_ntime_roll;
  17. int opt_hfa_hash_clock;
  18. int opt_hfa_overheat;
  19. int opt_hfa_target;
  20. bool opt_hfa_pll_bypass;
  21. bool opt_hfa_dfu_boot;
  22. int opt_hfa_fan_default;
  23. int opt_hfa_fan_max;
  24. int opt_hfa_fan_min;
  25. int opt_hfa_fail_drop;
  26. bool opt_hfa_noshed;
  27. char *set_hfa_fan(char *arg);
  28. char *opt_hfa_name;
  29. char *opt_hfa_options;
  30. #define HASHFAST_MINER_THREADS 1
  31. #define HFA_CLOCK_DEFAULT 550
  32. #define HFA_CLOCK_MIN 125
  33. #define HFA_CLOCK_MAX 1000
  34. #define HFA_CLOCK_MAXDIFF 100
  35. #define HFA_TEMP_OVERHEAT 95
  36. #define HFA_TEMP_TARGET 88
  37. #define HFA_TEMP_HYSTERESIS 3
  38. #define HFA_FAN_DEFAULT 33
  39. #define HFA_FAN_MAX 85
  40. #define HFA_FAN_MIN 5
  41. // Matching fields for hf_statistics, but large #s for local accumulation, per-die
  42. struct hf_long_statistics {
  43. uint64_t rx_header_crc; // Header CRCs
  44. uint64_t rx_body_crc; // Data CRCs
  45. uint64_t rx_header_timeouts; // Header timeouts
  46. uint64_t rx_body_timeouts; // Data timeouts
  47. uint64_t core_nonce_fifo_full; // Core nonce Q overrun events
  48. uint64_t array_nonce_fifo_full; // System nonce Q overrun events
  49. uint64_t stats_overrun; // Overrun in statistics reporting
  50. };
  51. // Matching fields for hf_usb_stats1, but large #s for local accumulation, per device
  52. struct hf_long_usb_stats1 {
  53. // USB incoming
  54. uint64_t usb_rx_preambles;
  55. uint64_t usb_rx_receive_byte_errors;
  56. uint64_t usb_rx_bad_hcrc;
  57. // USB outgoing
  58. uint64_t usb_tx_attempts;
  59. uint64_t usb_tx_packets;
  60. uint64_t usb_tx_timeouts;
  61. uint64_t usb_tx_incompletes;
  62. uint64_t usb_tx_endpointstalled;
  63. uint64_t usb_tx_disconnected;
  64. uint64_t usb_tx_suspended;
  65. #if 0
  66. /* We don't care about UART stats */
  67. // UART transmit
  68. uint64_t uart_tx_queue_dma;
  69. uint64_t uart_tx_interrupts;
  70. // UART receive
  71. uint64_t uart_rx_preamble_ints;
  72. uint64_t uart_rx_missed_preamble_ints;
  73. uint64_t uart_rx_header_done;
  74. uint64_t uart_rx_data_done;
  75. uint64_t uart_rx_bad_hcrc;
  76. uint64_t uart_rx_bad_dma;
  77. uint64_t uart_rx_short_dma;
  78. uint64_t uart_rx_buffers_full;
  79. #endif
  80. uint8_t max_tx_buffers;
  81. uint8_t max_rx_buffers;
  82. };
  83. /* Private per die data for dynamic clocking */
  84. struct hf_die_data {
  85. int hash_clock;
  86. double temp;
  87. double board_temp;
  88. time_t last_restart;
  89. };
  90. struct hashfast_info {
  91. struct cgpu_info *cgpu; // Points back to parent structure
  92. struct cgpu_info *old_cgpu ; // Points to old structure if hotplugged same device
  93. int asic_count; // # of chips in the chain
  94. int core_count; // # of cores per chip
  95. int device_type; // What sort of device this is
  96. int num_sequence; // A power of 2. What the sequence number range is.
  97. int ref_frequency; // Reference clock rate
  98. struct hf_g1_die_data *die_status; // Array of per-die voltage, current, temperature sensor data
  99. struct hf_long_statistics *die_statistics; // Array of per-die error counters
  100. struct hf_long_usb_stats1 stats1;
  101. struct hf_die_data *die_data;
  102. double firmware_version;
  103. double hardware_version;
  104. int hash_clock_rate; // Hash clock rate to use, in Mhz
  105. int base_clock; // Clock rate we actually got
  106. struct hf_usb_init_base usb_init_base; // USB Base information from USB_INIT
  107. struct hf_config_data config_data; // Configuration data used from USB_INIT
  108. int core_bitmap_size; // in bytes
  109. uint32_t *core_bitmap; // Core OK bitmap test results, run with PLL Bypassed
  110. int group_ntime_roll; // Total ntime roll amount per group
  111. int core_ntime_roll; // Total core ntime roll amount
  112. uint32_t serial_number; // db->serial_number if it exists
  113. char op_name[36];
  114. bool has_opname;
  115. bool opname_valid;
  116. pthread_mutex_t lock;
  117. pthread_mutex_t rlock;
  118. struct work **works;
  119. uint16_t hash_sequence_head; // HOST: The next hash sequence # to be sent
  120. uint16_t hash_sequence_tail; // HOST: Follows device_sequence_tail around to free work
  121. uint16_t device_sequence_head; // DEVICE: The most recent sequence number the device dispatched
  122. uint16_t device_sequence_tail; // DEVICE: The most recently completed job in the device
  123. int64_t hash_count;
  124. uint64_t raw_hashes;
  125. uint64_t calc_hashes;
  126. uint16_t shed_count; // Dynamic copy of #cores device has shed for thermal control
  127. int no_matching_work;
  128. int resets;
  129. int overheat;
  130. int last_max_temp;
  131. int temp_updates;
  132. int fanspeed; // Fanspeed in percent
  133. int last_die_adjusted;
  134. int clock_offset;
  135. pthread_t read_thr;
  136. time_t last_restart;
  137. time_t last_send;
  138. };
  139. #endif /* USE_HASHFAST */
  140. #endif /* HASHFAST_H */