driver-spondoolies.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 "mg_proto_parser.h"
  14. #define SP_NTIME
  15. typedef enum adapter_state {
  16. ADAPTER_STATE_INIT,
  17. ADAPTER_STATE_OPERATIONAL,
  18. } ADAPTER_STATE;
  19. typedef enum spond_work_state {
  20. SPONDWORK_STATE_EMPTY,
  21. SPONDWORK_STATE_IN_BUSY,
  22. } SPONDWORK_STATE;
  23. #define MAX_JOBS_IN_MINERGATE MINERGATE_TOTAL_QUEUE // 1.5 sec worth of jobs
  24. #define MAX_NROLES 50
  25. typedef struct {
  26. struct work *cgminer_work;
  27. SPONDWORK_STATE state;
  28. uint32_t merkle_root;
  29. time_t start_time;
  30. int job_id[MAX_NROLES];
  31. int ntime_clones;
  32. } spond_driver_work;
  33. struct spond_adapter {
  34. pthread_mutex_t lock;
  35. ADAPTER_STATE adapter_state;
  36. void *cgpu;
  37. // Statistics
  38. int wins;
  39. int good;
  40. int empty;
  41. int bad;
  42. int overflow;
  43. // state
  44. int works_in_driver;
  45. int works_in_minergate_and_pending_tx;
  46. int works_pending_tx;
  47. int socket_fd;
  48. int reset_mg_queue; // 2=reset, 1=fast send, 0=nada
  49. int current_job_id;
  50. int parse_resp;
  51. minergate_req_packet* mp_next_req;
  52. minergate_rsp_packet* mp_last_rsp;
  53. spond_driver_work my_jobs[MAX_JOBS_IN_MINERGATE];
  54. // Temperature statistics
  55. int temp_rate;
  56. int rear_temp;
  57. int front_temp;
  58. // Last second we polled stats
  59. time_t last_stats;
  60. };
  61. // returns non-zero if needs to change ASICs.
  62. int spond_one_sec_timer_scaling(struct spond_adapter *a, int t);
  63. int spond_do_scaling(struct spond_adapter *a);
  64. extern void one_sec_spondoolies_watchdog(int uptime);
  65. #define REQUEST_PERIOD (100000) // times per second - in usec
  66. #define REQUEST_SIZE 100 // jobs per request
  67. #endif