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