driver-hashfast.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. struct hashfast_info {
  29. int asic_count; // # of chips in the chain
  30. int core_count; // # of cores per chip
  31. int device_type; // What sort of device this is
  32. int num_sequence; // A power of 2. What the sequence number range is.
  33. int ref_frequency; // Reference clock rate
  34. uint16_t hash_sequence; // The next hash sequence # to be sent
  35. struct hf_g1_die_data *die_status; // Array of per-die voltage, current, temperature sensor data
  36. struct hf_long_statistics *die_statistics; // Array of per-die error counters
  37. int hash_clock_rate; // Hash clock rate to use, in Mhz
  38. struct hf_usb_init_base usb_init_base; // USB Base information from USB_INIT
  39. struct hf_config_data config_data; // Configuration data used from USB_INIT
  40. int core_bitmap_size; // in bytes
  41. uint32_t *core_bitmap; // Core OK bitmap test results, run with PLL Bypassed
  42. pthread_mutex_t lock;
  43. struct work **works;
  44. uint16_t hash_sequence_head; // HOST: The next hash sequence # to be sent
  45. uint16_t hash_sequence_tail; // HOST: Follows device_sequence_tail around to free work
  46. uint16_t device_sequence_head; // DEVICE: The most recent sequence number the device dispatched
  47. uint16_t device_sequence_tail; // DEVICE: The most recently completed job in the device
  48. int64_t hash_count;
  49. uint16_t shed_count; // Dynamic copy of #cores device has shed for thermal control
  50. int no_matching_work;
  51. pthread_t read_thr;
  52. };
  53. #endif /* USE_HASHFAST */
  54. #endif /* HASHFAST_H */