driver-minergate.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /*
  2. * Copyright 2014 Luke Dashjr
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. *
  9. * To avoid doubt: Programs using the minergate protocol to interface with
  10. * BFGMiner are considered part of the Corresponding Source, and not an
  11. * independent work. This means that such programs distrbuted with BFGMiner
  12. * must be released under the terms of the GPLv3 license, or sufficiently
  13. * compatible terms.
  14. */
  15. #include "config.h"
  16. #include <ctype.h>
  17. #include <math.h>
  18. #include <stdbool.h>
  19. #include <stdint.h>
  20. #include <sys/epoll.h>
  21. #include <sys/types.h>
  22. #include <sys/socket.h>
  23. #include <sys/un.h>
  24. #include "deviceapi.h"
  25. #include "logging.h"
  26. #include "lowlevel.h"
  27. #include "miner.h"
  28. #define MINERGATE_MAX_NONCE_DIFF 0x20
  29. static const char * const minergate_stats_file = "/var/run/mg_rate_temp";
  30. #define MINERGATE_MAGIC 0xcaf4
  31. #define MINERGATE_PKT_HEADER_SZ 8
  32. #define MINERGATE_PKT_REQ_ITEM_SZ 0x34
  33. #define MINERGATE_POLL_US 100000
  34. #define MINERGATE_RETRY_US 5000000
  35. BFG_REGISTER_DRIVER(minergate_drv)
  36. enum minergate_protocol_ver {
  37. MPV_SP10 = 6,
  38. MPV_SP30 = 30,
  39. };
  40. enum minergate_reqpkt_flags {
  41. MRPF_FIRST = 1,
  42. MRPF_FLUSH = 2,
  43. };
  44. struct minergate_config {
  45. uint8_t protover;
  46. int n_req;
  47. int n_req_queue;
  48. int n_rsp;
  49. int queue;
  50. int pkt_req_sz;
  51. int pkt_rsp_sz;
  52. int pkt_rsp_item_sz;
  53. };
  54. struct minergate_state {
  55. work_device_id_t next_jobid;
  56. unsigned ready_to_queue;
  57. uint8_t *req_buffer;
  58. long *stats;
  59. unsigned stats_count;
  60. struct work *flushed_work;
  61. };
  62. static
  63. int minergate_open(const char * const devpath)
  64. {
  65. size_t devpath_len = strlen(devpath);
  66. struct sockaddr_un sa = {
  67. .sun_family = AF_UNIX,
  68. };
  69. #ifdef UNIX_PATH_MAX
  70. if (devpath_len >= UNIX_PATH_MAX)
  71. #else
  72. if (devpath_len >= sizeof(sa.sun_path))
  73. #endif
  74. return -1;
  75. const int fd = socket(PF_UNIX, SOCK_STREAM, 0);
  76. strcpy(sa.sun_path, devpath);
  77. if (connect(fd, &sa, sizeof(sa)))
  78. {
  79. close(fd);
  80. return -1;
  81. }
  82. return fd;
  83. }
  84. static
  85. ssize_t minergate_read(const int fd, void * const buf_p, size_t bufLen)
  86. {
  87. uint8_t *buf = buf_p;
  88. ssize_t rv, ret = 0;
  89. while (bufLen > 0)
  90. {
  91. rv = read(fd, buf, bufLen);
  92. if (rv <= 0)
  93. {
  94. if (ret > 0)
  95. return ret;
  96. return rv;
  97. }
  98. buf += rv;
  99. bufLen -= rv;
  100. ret += rv;
  101. }
  102. return ret;
  103. }
  104. static
  105. const char *minergate_init_protover(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
  106. {
  107. struct minergate_config * const mgcfg = proc->device_data;
  108. int i = atoi(newvalue);
  109. if (i != MPV_SP10 || i != MPV_SP30)
  110. return "Invalid protocol version";
  111. mgcfg->protover = i;
  112. return NULL;
  113. }
  114. static
  115. const char *minergate_init_n_req(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
  116. {
  117. struct minergate_config * const mgcfg = proc->device_data;
  118. mgcfg->n_req = atoi(newvalue);
  119. return NULL;
  120. }
  121. static
  122. const char *minergate_init_n_req_queue(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
  123. {
  124. struct minergate_config * const mgcfg = proc->device_data;
  125. mgcfg->n_req_queue = atoi(newvalue);
  126. return NULL;
  127. }
  128. static
  129. const char *minergate_init_n_rsp(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
  130. {
  131. struct minergate_config * const mgcfg = proc->device_data;
  132. mgcfg->n_rsp = atoi(newvalue);
  133. return NULL;
  134. }
  135. static
  136. const char *minergate_init_queue(struct cgpu_info * const proc, const char * const optname, const char * const newvalue, char * const replybuf, enum bfg_set_device_replytype * const out_success)
  137. {
  138. struct minergate_config * const mgcfg = proc->device_data;
  139. mgcfg->queue = atoi(newvalue);
  140. return NULL;
  141. }
  142. static const struct bfg_set_device_definition minergate_set_device_funcs_probe[] = {
  143. {"protover", minergate_init_protover, NULL},
  144. {"n_req", minergate_init_n_req, NULL},
  145. {"n_req_queue", minergate_init_n_req_queue, NULL},
  146. {"n_rsp", minergate_init_n_rsp, NULL},
  147. {"queue", minergate_init_queue, NULL},
  148. {NULL},
  149. };
  150. static
  151. bool minergate_detect_one(const char * const devpath)
  152. {
  153. bool rv = false;
  154. const int fd = minergate_open(devpath);
  155. if (unlikely(fd < 0))
  156. applogr(false, LOG_DEBUG, "%s: %s: Cannot connect", minergate_drv.dname, devpath);
  157. struct minergate_config * const mgcfg = malloc(sizeof(*mgcfg));
  158. *mgcfg = (struct minergate_config){
  159. .protover = MPV_SP10,
  160. };
  161. drv_set_defaults(&minergate_drv, minergate_set_device_funcs_probe, mgcfg, devpath, NULL, 1);
  162. switch (mgcfg->protover)
  163. {
  164. case MPV_SP10:
  165. BFGINIT(mgcfg->n_req, 100);
  166. BFGINIT(mgcfg->n_req_queue, mgcfg->n_req);
  167. BFGINIT(mgcfg->n_rsp, 300);
  168. BFGINIT(mgcfg->queue, 300);
  169. mgcfg->pkt_rsp_item_sz = 0x14;
  170. break;
  171. case MPV_SP30:
  172. BFGINIT(mgcfg->n_req, 30);
  173. BFGINIT(mgcfg->n_req_queue, min(10, mgcfg->n_req));
  174. BFGINIT(mgcfg->n_rsp, 60);
  175. BFGINIT(mgcfg->queue, 40);
  176. mgcfg->pkt_rsp_item_sz = 0x10;
  177. break;
  178. }
  179. mgcfg->pkt_req_sz = MINERGATE_PKT_HEADER_SZ + (MINERGATE_PKT_REQ_ITEM_SZ * mgcfg->n_req);
  180. mgcfg->pkt_rsp_sz = MINERGATE_PKT_HEADER_SZ + (mgcfg->pkt_rsp_item_sz * mgcfg->n_rsp);
  181. int epfd = -1;
  182. uint8_t buf[mgcfg->pkt_req_sz];
  183. buf[0] = 0xbf;
  184. buf[1] = 0x90;
  185. buf[2] = mgcfg->protover;
  186. buf[3] = MRPF_FIRST;
  187. pk_u16le(buf, 4, MINERGATE_MAGIC);
  188. memset(&buf[6], '\0', mgcfg->pkt_req_sz - 6);
  189. if (mgcfg->pkt_req_sz != write(fd, buf, mgcfg->pkt_req_sz))
  190. return_via_applog(out, , LOG_DEBUG, "%s: %s: write incomplete or failed", minergate_drv.dname, devpath);
  191. epfd = epoll_create(1);
  192. if (epfd < 0)
  193. return_via_applog(out, , LOG_DEBUG, "%s: %s: %s failed", minergate_drv.dname, devpath, "epoll_create");
  194. struct epoll_event eev;
  195. eev.events = EPOLLIN;
  196. if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &eev))
  197. return_via_applog(out, , LOG_DEBUG, "%s: %s: %s failed", minergate_drv.dname, devpath, "epoll_ctl");
  198. size_t read_bytes = 0;
  199. static const size_t read_expect = MINERGATE_PKT_HEADER_SZ;
  200. ssize_t r;
  201. while (read_bytes < read_expect)
  202. {
  203. if (epoll_wait(epfd, &eev, 1, 1000) != 1)
  204. return_via_applog(out, , LOG_DEBUG, "%s: %s: Timeout waiting for response", minergate_drv.dname, devpath);
  205. r = read(fd, &buf[read_bytes], read_expect - read_bytes);
  206. if (r <= 0)
  207. return_via_applog(out, , LOG_DEBUG, "%s: %s: %s failed", minergate_drv.dname, devpath, "read");
  208. read_bytes += r;
  209. }
  210. if (buf[1] != 0x90)
  211. return_via_applog(out, , LOG_DEBUG, "%s: %s: %s mismatch", minergate_drv.dname, devpath, "request_id");
  212. if (buf[2] != mgcfg->protover)
  213. return_via_applog(out, , LOG_DEBUG, "%s: %s: %s mismatch", minergate_drv.dname, devpath, "Protocol version");
  214. if (upk_u16le(buf, 4) != MINERGATE_MAGIC)
  215. return_via_applog(out, , LOG_DEBUG, "%s: %s: %s mismatch", minergate_drv.dname, devpath, "magic");
  216. uint16_t responses = upk_u16le(buf, 6);
  217. if (responses > mgcfg->n_rsp)
  218. return_via_applog(out, , LOG_DEBUG, "%s: %s: More than maximum responses", minergate_drv.dname, devpath);
  219. if (bfg_claim_any2(&minergate_drv, devpath, "unix", devpath))
  220. goto out;
  221. struct cgpu_info * const cgpu = malloc(sizeof(*cgpu));
  222. *cgpu = (struct cgpu_info){
  223. .drv = &minergate_drv,
  224. .device_path = strdup(devpath),
  225. .device_data = mgcfg,
  226. .deven = DEV_ENABLED,
  227. .threads = 1,
  228. };
  229. rv = add_cgpu(cgpu);
  230. out:
  231. if (!rv)
  232. free(mgcfg);
  233. close(fd);
  234. if (epfd >= 0)
  235. close(epfd);
  236. return rv;
  237. }
  238. static
  239. int minergate_detect_auto(void)
  240. {
  241. return minergate_detect_one("/tmp/connection_pipe") ? 1 : 0;
  242. }
  243. static
  244. void minergate_detect(void)
  245. {
  246. generic_detect(&minergate_drv, minergate_detect_one, minergate_detect_auto, 0);
  247. }
  248. static
  249. bool minergate_init(struct thr_info * const thr)
  250. {
  251. struct cgpu_info * const dev = thr->cgpu;
  252. struct minergate_config * const mgcfg = dev->device_data;
  253. const int fd = minergate_open(dev->device_path);
  254. dev->device_fd = fd;
  255. if (fd < 0)
  256. applogr(false, LOG_ERR, "%s: Cannot connect", dev->dev_repr);
  257. struct minergate_state * const state = malloc(sizeof(*state) + mgcfg->pkt_req_sz);
  258. if (!state)
  259. applogr(false, LOG_ERR, "%s: %s failed", dev->dev_repr, "malloc");
  260. *state = (struct minergate_state){
  261. .req_buffer = (void*)&state[1]
  262. };
  263. thr->cgpu_data = state;
  264. thr->work = thr->work_list = NULL;
  265. mutex_init(&dev->device_mutex);
  266. memset(state->req_buffer, 0, mgcfg->pkt_req_sz);
  267. pk_u8(state->req_buffer, 2, mgcfg->protover);
  268. state->req_buffer[3] = MRPF_FIRST | MRPF_FLUSH;
  269. pk_u16le(state->req_buffer, 4, MINERGATE_MAGIC);
  270. timer_set_delay_from_now(&thr->tv_poll, 0);
  271. return true;
  272. }
  273. static
  274. bool minergate_queue_full(struct thr_info * const thr)
  275. {
  276. struct cgpu_info * const dev = thr->cgpu;
  277. struct minergate_config * const mgcfg = dev->device_data;
  278. struct minergate_state * const state = thr->cgpu_data;
  279. bool qf;
  280. if (HASH_COUNT(thr->work) + state->ready_to_queue >= mgcfg->queue)
  281. qf = true;
  282. else
  283. if (state->ready_to_queue >= mgcfg->n_req_queue)
  284. qf = true;
  285. else
  286. if (state->req_buffer[3] & MRPF_FLUSH)
  287. // Job flush occurs after new jobs get queued, so we have to wait until it completes
  288. qf = true;
  289. else
  290. qf = false;
  291. thr->queue_full = qf;
  292. return qf;
  293. }
  294. static
  295. bool minergate_queue_append(struct thr_info * const thr, struct work * const work)
  296. {
  297. struct cgpu_info * const dev = thr->cgpu;
  298. struct minergate_state * const state = thr->cgpu_data;
  299. if (minergate_queue_full(thr))
  300. return false;
  301. work->device_id = (uint32_t)(state->next_jobid++);
  302. work->tv_stamp.tv_sec = 0;
  303. uint8_t * const my_buf = &state->req_buffer[MINERGATE_PKT_HEADER_SZ + (MINERGATE_PKT_REQ_ITEM_SZ * state->ready_to_queue++)];
  304. pk_u32be(my_buf, 0, work->device_id);
  305. memcpy(&my_buf[ 4], &work->data[0x48], 4); // nbits
  306. memcpy(&my_buf[ 8], &work->data[0x44], 4); // ntime
  307. memcpy(&my_buf[0x0c], &work->data[0x40], 4); // merkle-tail
  308. memcpy(&my_buf[0x10], work->midstate, 0x20);
  309. if (work->work_difficulty >= MINERGATE_MAX_NONCE_DIFF)
  310. work->nonce_diff = MINERGATE_MAX_NONCE_DIFF;
  311. else
  312. work->nonce_diff = work->work_difficulty;
  313. const uint16_t zerobits = log2(floor(work->nonce_diff * 4294967296));
  314. work->nonce_diff = pow(2, zerobits) / 4294967296;
  315. pk_u8(my_buf, 0x30, zerobits);
  316. pk_u8(my_buf, 0x31, 0); // ntime limit
  317. pk_u8(my_buf, 0x32, 0); // pv6: ntime offset ; pv30: reserved
  318. pk_u8(my_buf, 0x33, 0); // reserved
  319. struct work *oldwork;
  320. HASH_FIND(hh, thr->work, &work->device_id, sizeof(work->device_id), oldwork);
  321. if (unlikely(oldwork))
  322. {
  323. applog(LOG_WARNING, "%s: Reusing allocated device id %"PRIwdi, dev->dev_repr, work->device_id);
  324. HASH_DEL(thr->work, oldwork);
  325. free_work(oldwork);
  326. }
  327. HASH_ADD(hh, thr->work, device_id, sizeof(work->device_id), work);
  328. LL_PREPEND(thr->work_list, work);
  329. timer_set_delay_from_now(&thr->tv_poll, 0);
  330. minergate_queue_full(thr);
  331. return true;
  332. }
  333. static
  334. void minergate_queue_flush(struct thr_info * const thr)
  335. {
  336. struct minergate_state * const state = thr->cgpu_data;
  337. struct work *work, *worktmp;
  338. // Flush internal ready-to-queue list
  339. LL_FOREACH_SAFE(thr->work_list, work, worktmp)
  340. {
  341. HASH_DEL(thr->work, work);
  342. LL_DELETE(thr->work_list, work);
  343. free_work(work);
  344. }
  345. state->ready_to_queue = 0;
  346. // Trigger minergate flush
  347. state->req_buffer[3] |= MRPF_FLUSH;
  348. timer_set_delay_from_now(&thr->tv_poll, 0);
  349. }
  350. static
  351. bool minergate_submit(struct thr_info * const thr, struct work * const work, const uint32_t nonce)
  352. {
  353. if (!nonce)
  354. return false;
  355. if (likely(work))
  356. submit_nonce(thr, work, nonce);
  357. else
  358. inc_hw_errors3(thr, NULL, &nonce, 1.);
  359. return true;
  360. }
  361. static
  362. void minergate_poll(struct thr_info * const thr)
  363. {
  364. struct cgpu_info * const dev = thr->cgpu;
  365. struct minergate_config * const mgcfg = dev->device_data;
  366. struct minergate_state * const state = thr->cgpu_data;
  367. const int fd = dev->device_fd;
  368. uint8_t buf[mgcfg->pkt_rsp_sz];
  369. if (opt_dev_protocol || state->ready_to_queue)
  370. applog(LOG_DEBUG, "%s: Polling with %u new jobs", dev->dev_repr, state->ready_to_queue);
  371. pk_u16le(state->req_buffer, 6, state->ready_to_queue);
  372. if (mgcfg->pkt_req_sz != write(fd, state->req_buffer, mgcfg->pkt_req_sz))
  373. return_via_applog(err, , LOG_ERR, "%s: write incomplete or failed", dev->dev_repr);
  374. uint8_t flags = state->req_buffer[3];
  375. state->req_buffer[3] = 0;
  376. state->ready_to_queue = 0;
  377. thr->work_list = NULL;
  378. if (minergate_read(fd, buf, mgcfg->pkt_rsp_sz) != mgcfg->pkt_rsp_sz)
  379. return_via_applog(err, , LOG_ERR, "%s: %s failed", dev->dev_repr, "read");
  380. if (upk_u8(buf, 2) != mgcfg->protover || upk_u16le(buf, 4) != MINERGATE_MAGIC)
  381. return_via_applog(err, , LOG_ERR, "%s: Protocol mismatch", dev->dev_repr);
  382. uint8_t *jobrsp = &buf[MINERGATE_PKT_HEADER_SZ];
  383. struct work *work;
  384. uint16_t rsp_count = upk_u16le(buf, 6);
  385. if (rsp_count || opt_dev_protocol)
  386. applog(LOG_DEBUG, "%s: Received %u job completions", dev->dev_repr, rsp_count);
  387. uint32_t nonce;
  388. int64_t hashes = 0;
  389. for (unsigned i = 0; i < rsp_count; ++i, (jobrsp += mgcfg->pkt_rsp_item_sz))
  390. {
  391. work_device_id_t jobid = upk_u32be(jobrsp, 0);
  392. nonce = upk_u32le(jobrsp, 8);
  393. HASH_FIND(hh, thr->work, &jobid, sizeof(jobid), work);
  394. if (unlikely(!work))
  395. applog(LOG_ERR, "%s: Unknown job %"PRIwdi, dev->dev_repr, jobid);
  396. if (minergate_submit(thr, work, nonce))
  397. {
  398. if (mgcfg->protover == MPV_SP10)
  399. {
  400. nonce = upk_u32le(jobrsp, 0xc);
  401. minergate_submit(thr, work, nonce);
  402. }
  403. }
  404. else
  405. if (unlikely(!work))
  406. // Increment HW errors even if no nonce to submit
  407. inc_hw_errors_only(thr);
  408. const bool work_completed = (mgcfg->protover == MPV_SP10) ? (bool)work : (bool)jobrsp[0xe];
  409. if (work_completed)
  410. {
  411. HASH_DEL(thr->work, work);
  412. applog(LOG_DEBUG, "%s: %s job %"PRIwdi" completed", dev->dev_repr, work->tv_stamp.tv_sec ? "Flushed" : "Active", work->device_id);
  413. if (!work->tv_stamp.tv_sec)
  414. hashes += 100000000 * work->nonce_diff;
  415. free_work(work);
  416. }
  417. }
  418. hashes_done2(thr, hashes, NULL);
  419. if (flags & MRPF_FLUSH)
  420. {
  421. // Mark all remaining jobs as flushed so we don't count them in hashes_done
  422. struct work *worktmp;
  423. HASH_ITER(hh, thr->work, work, worktmp)
  424. {
  425. work->tv_stamp.tv_sec = 1;
  426. }
  427. }
  428. minergate_queue_full(thr);
  429. timer_set_delay_from_now(&thr->tv_poll, MINERGATE_POLL_US);
  430. return;
  431. err:
  432. // TODO: reconnect
  433. timer_set_delay_from_now(&thr->tv_poll, MINERGATE_RETRY_US);
  434. }
  435. static
  436. bool minergate_get_stats(struct cgpu_info * const dev)
  437. {
  438. static const int skip_stats = 1;
  439. struct thr_info * const thr = dev->thr[0];
  440. struct minergate_state * const state = thr->cgpu_data;
  441. FILE *F = fopen(minergate_stats_file, "r");
  442. char buf[0x100];
  443. if (F)
  444. {
  445. char *p = fgets(buf, sizeof(buf), F);
  446. fclose(F);
  447. if (p)
  448. {
  449. long nums[0x80];
  450. char *endptr;
  451. unsigned i;
  452. float max_temp = 0;
  453. for (i = 0; 1; ++i)
  454. {
  455. if (!p[0])
  456. break;
  457. nums[i] = strtol(p, &endptr, 0);
  458. if (p == endptr)
  459. break;
  460. if (i >= skip_stats && nums[i] > max_temp)
  461. max_temp = nums[i];
  462. while (endptr[0] && !isspace(endptr[0]))
  463. ++endptr;
  464. while (endptr[0] && isspace(endptr[0]))
  465. ++endptr;
  466. p = endptr;
  467. }
  468. i -= skip_stats;
  469. long *new_stats = malloc(sizeof(*state->stats) * i);
  470. memcpy(new_stats, &nums[skip_stats], sizeof(*nums) * i);
  471. mutex_lock(&dev->device_mutex);
  472. free(state->stats);
  473. state->stats = new_stats;
  474. state->stats_count = i;
  475. mutex_unlock(&dev->device_mutex);
  476. dev->temp = max_temp;
  477. }
  478. }
  479. return true;
  480. }
  481. static
  482. struct api_data *minergate_api_extra_device_status(struct cgpu_info * const dev)
  483. {
  484. struct thr_info * const thr = dev->thr[0];
  485. struct minergate_state * const state = thr->cgpu_data;
  486. struct api_data *root = NULL;
  487. mutex_lock(&dev->device_mutex);
  488. if (state->stats_count > 1)
  489. {
  490. char buf[0x10];
  491. for (unsigned i = 0; i < state->stats_count; ++i)
  492. {
  493. float temp = state->stats[i];
  494. if (!temp)
  495. continue;
  496. sprintf(buf, "Temperature%u", i);
  497. root = api_add_temp(root, buf, &temp, true);
  498. }
  499. }
  500. mutex_unlock(&dev->device_mutex);
  501. return root;
  502. }
  503. struct device_drv minergate_drv = {
  504. .dname = "minergate",
  505. .name = "MGT",
  506. .drv_detect = minergate_detect,
  507. .thread_init = minergate_init,
  508. .minerloop = minerloop_queue,
  509. .queue_append = minergate_queue_append,
  510. .queue_flush = minergate_queue_flush,
  511. .poll = minergate_poll,
  512. .get_stats = minergate_get_stats,
  513. .get_api_extra_device_status = minergate_api_extra_device_status,
  514. };