driver-spondoolies-sp30.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright 2014 Con Kolivas <kernel@kolivas.org>
  3. * Copyright 2014 Zvi Shteingart - Spondoolies-tech.com
  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 SPONDA_HFILE
  11. #define SPONDA_HFILE
  12. #include "miner.h"
  13. #include "driver-spondoolies-sp30-p.h"
  14. typedef enum adapter_state {
  15. ADAPTER_STATE_INIT,
  16. ADAPTER_STATE_OPERATIONAL,
  17. } ADAPTER_STATE;
  18. typedef enum spond_work_state {
  19. SPONDWORK_STATE_EMPTY,
  20. SPONDWORK_STATE_IN_BUSY,
  21. } SPONDWORK_STATE;
  22. #define MAX_JOBS_PENDING_IN_MINERGATE_SP30 30
  23. #define MAX_NROLES 60
  24. typedef struct {
  25. struct work *cgminer_work;
  26. SPONDWORK_STATE state;
  27. uint32_t merkle_root;
  28. time_t start_time;
  29. int job_id;
  30. } spond_driver_work_sp30;
  31. struct spond_adapter {
  32. pthread_mutex_t lock;
  33. ADAPTER_STATE adapter_state;
  34. void *cgpu;
  35. // Statistics
  36. int wins;
  37. int good;
  38. int empty;
  39. int bad;
  40. int overflow;
  41. // state
  42. int works_in_driver;
  43. int works_in_minergate_and_pending_tx;
  44. int works_pending_tx;
  45. int socket_fd;
  46. int reset_mg_queue; // 3=reset, 2=fast send 1 job, 1=fast send 10 jobs, 0=nada
  47. int current_job_id;
  48. int parse_resp;
  49. minergate_req_packet_sp30* mp_next_req;
  50. minergate_rsp_packet_sp30* mp_last_rsp;
  51. spond_driver_work_sp30 my_jobs[MAX_JOBS_PENDING_IN_MINERGATE_SP30];
  52. // Temperature statistics
  53. int temp_rate;
  54. int front_temp;
  55. int rear_temp_top;
  56. int rear_temp_bot;
  57. // Last second we polled stats
  58. time_t last_stats;
  59. };
  60. // returns non-zero if needs to change ASICs.
  61. int spond_one_sec_timer_scaling(struct spond_adapter *a, int t);
  62. int spond_do_scaling(struct spond_adapter *a);
  63. extern void one_sec_spondoolies_watchdog(int uptime);
  64. #define REQUEST_PERIOD (100000) // times per second - in usec
  65. #define REQUEST_SIZE 10 // jobs per request
  66. #endif