driver-spondoolies-sp10.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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-sp10-p.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 front_temp;
  57. int rear_temp_top;
  58. int rear_temp_bot;
  59. // Last second we polled stats
  60. time_t last_stats;
  61. };
  62. // returns non-zero if needs to change ASICs.
  63. int spond_one_sec_timer_scaling(struct spond_adapter *a, int t);
  64. int spond_do_scaling(struct spond_adapter *a);
  65. extern void one_sec_spondoolies_watchdog(int uptime);
  66. #define REQUEST_PERIOD (100000) // times per second - in usec
  67. #define REQUEST_SIZE 100 // jobs per request
  68. #endif