driver-hashfast.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2013 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. #define HASHFAST_MINER_THREADS 1
  17. // Matching fields for hf_statistics, but large #s for local accumulation, per-die
  18. struct hf_long_statistics {
  19. uint64_t rx_header_crc; // Header CRCs
  20. uint64_t rx_body_crc; // Data CRCs
  21. uint64_t rx_header_timeouts; // Header timeouts
  22. uint64_t rx_body_timeouts; // Data timeouts
  23. uint64_t core_nonce_fifo_full; // Core nonce Q overrun events
  24. uint64_t array_nonce_fifo_full; // System nonce Q overrun events
  25. uint64_t stats_overrun; // Overrun in statistics reporting
  26. };
  27. // Matching fields for hf_usb_stats1, but large #s for local accumulation, per device
  28. struct hf_long_usb_stats1 {
  29. // USB incoming
  30. uint64_t usb_rx_preambles;
  31. uint64_t usb_rx_receive_byte_errors;
  32. uint64_t usb_rx_bad_hcrc;
  33. // USB outgoing
  34. uint64_t usb_tx_attempts;
  35. uint64_t usb_tx_packets;
  36. uint64_t usb_tx_timeouts;
  37. uint64_t usb_tx_incompletes;
  38. uint64_t usb_tx_endpointstalled;
  39. uint64_t usb_tx_disconnected;
  40. uint64_t usb_tx_suspended;
  41. #if 0
  42. /* We don't care about UART stats */
  43. // UART transmit
  44. uint64_t uart_tx_queue_dma;
  45. uint64_t uart_tx_interrupts;
  46. // UART receive
  47. uint64_t uart_rx_preamble_ints;
  48. uint64_t uart_rx_missed_preamble_ints;
  49. uint64_t uart_rx_header_done;
  50. uint64_t uart_rx_data_done;
  51. uint64_t uart_rx_bad_hcrc;
  52. uint64_t uart_rx_bad_dma;
  53. uint64_t uart_rx_short_dma;
  54. uint64_t uart_rx_buffers_full;
  55. #endif
  56. uint8_t max_tx_buffers;
  57. uint8_t max_rx_buffers;
  58. };
  59. struct hashfast_info {
  60. int asic_count; // # of chips in the chain
  61. int core_count; // # of cores per chip
  62. int device_type; // What sort of device this is
  63. int num_sequence; // A power of 2. What the sequence number range is.
  64. int ref_frequency; // Reference clock rate
  65. struct hf_g1_die_data *die_status; // Array of per-die voltage, current, temperature sensor data
  66. struct hf_long_statistics *die_statistics; // Array of per-die error counters
  67. struct hf_long_usb_stats1 stats1;
  68. int hash_clock_rate; // Hash clock rate to use, in Mhz
  69. struct hf_usb_init_base usb_init_base; // USB Base information from USB_INIT
  70. struct hf_config_data config_data; // Configuration data used from USB_INIT
  71. int core_bitmap_size; // in bytes
  72. uint32_t *core_bitmap; // Core OK bitmap test results, run with PLL Bypassed
  73. pthread_mutex_t lock;
  74. struct work **works;
  75. uint16_t hash_sequence_head; // HOST: The next hash sequence # to be sent
  76. uint16_t hash_sequence_tail; // HOST: Follows device_sequence_tail around to free work
  77. uint16_t device_sequence_head; // DEVICE: The most recent sequence number the device dispatched
  78. uint16_t device_sequence_tail; // DEVICE: The most recently completed job in the device
  79. int64_t hash_count;
  80. uint16_t shed_count; // Dynamic copy of #cores device has shed for thermal control
  81. int no_matching_work;
  82. pthread_t read_thr;
  83. };
  84. #endif /* USE_HASHFAST */
  85. #endif /* HASHFAST_H */