driver-hashfast.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_NUM_SEQUENCE 256
  18. #define GWQ_SEQUENCE_DISTANCE(tx,rx) ((tx)>=(rx)?((tx)-(rx)):(HF_NUM_SEQUENCE+(tx)-(rx)))
  19. // Matching fields for hf_statistics, but large #'s for local accumulation, per-die
  20. struct hf_long_statistics {
  21. uint64_t rx_header_crc; // Header CRC's
  22. uint64_t rx_body_crc; // Data CRC's
  23. uint64_t rx_header_timeouts; // Header timeouts
  24. uint64_t rx_body_timeouts; // Data timeouts
  25. uint64_t core_nonce_fifo_full; // Core nonce Q overrun events
  26. uint64_t array_nonce_fifo_full; // System nonce Q overrun events
  27. uint64_t stats_overrun; // Overrun in statistics reporting
  28. } __attribute__((packed,aligned(4)));
  29. struct hashfast_info {
  30. int asic_count; // # of chips in the chain
  31. int core_count; // # of cores per chip
  32. int device_type; // What sort of device this 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 device_sequence_head; // The most recent sequence number the device dispatched
  45. uint16_t device_sequence_tail; // The most recently completed job in the device
  46. uint16_t hash_sequence_tail; // Follows device_sequence_tail around to free work
  47. int64_t hash_count;
  48. pthread_t read_thr;
  49. };
  50. #endif /* USE_HASHFAST */
  51. #endif /* HASHFAST_H */