driver-modminer.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /*
  2. * Copyright 2012 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. #include "config.h"
  10. #include <stdarg.h>
  11. #include <stdio.h>
  12. #include <unistd.h>
  13. #include "fpgautils.h"
  14. #include "logging.h"
  15. #include "miner.h"
  16. #define BITSTREAM_FILENAME "fpgaminer_top_fixed7_197MHz.ncd"
  17. #define BISTREAM_USER_ID "\2\4$B"
  18. struct device_api modminer_api;
  19. static inline bool
  20. _bailout(int fd, struct cgpu_info*modminer, int prio, const char *fmt, ...)
  21. {
  22. if (fd != -1)
  23. serial_close(fd);
  24. if (modminer) {
  25. modminer->device_fd = -1;
  26. mutex_unlock(&modminer->device_mutex);
  27. }
  28. va_list ap;
  29. va_start(ap, fmt);
  30. vapplog(prio, fmt, ap);
  31. va_end(ap);
  32. return false;
  33. }
  34. #define bailout(...) return _bailout(fd, NULL, __VA_ARGS__);
  35. static bool
  36. modminer_detect_one(const char *devpath)
  37. {
  38. int fd = serial_open(devpath, 0, 10, true);
  39. if (unlikely(fd == -1))
  40. bailout(LOG_DEBUG, "ModMiner detect: failed to open %s", devpath);
  41. char buf[0x100];
  42. size_t len;
  43. // Sending 45 noops, just in case the device was left in "start job" reading
  44. (void)(write(fd, "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff", 45) ?:0);
  45. while (serial_read(fd, buf, sizeof(buf)) > 0)
  46. ;
  47. if (1 != write(fd, "\x01", 1)) // Get version
  48. bailout(LOG_DEBUG, "ModMiner detect: write failed on %s (get version)", devpath);
  49. len = serial_read(fd, buf, sizeof(buf)-1);
  50. if (len < 1)
  51. bailout(LOG_DEBUG, "ModMiner detect: no response to version request from %s", devpath);
  52. buf[len] = '\0';
  53. char*devname = strdup(buf);
  54. applog(LOG_DEBUG, "ModMiner identified as: %s", devname);
  55. if (1 != write(fd, "\x02", 1)) // Get FPGA count
  56. bailout(LOG_DEBUG, "ModMiner detect: write failed on %s (get FPGA count)", devpath);
  57. len = read(fd, buf, 1);
  58. if (len < 1)
  59. bailout(LOG_ERR, "ModMiner detect: timeout waiting for FPGA count from %s", devpath);
  60. if (!buf[0])
  61. bailout(LOG_ERR, "ModMiner detect: zero FPGAs reported on %s", devpath);
  62. applog(LOG_DEBUG, "ModMiner %s has %u FPGAs", devname, buf[0]);
  63. serial_close(fd);
  64. struct cgpu_info *modminer;
  65. modminer = calloc(1, sizeof(*modminer));
  66. modminer->api = &modminer_api;
  67. mutex_init(&modminer->device_mutex);
  68. modminer->device_path = strdup(devpath);
  69. modminer->device_fd = -1;
  70. modminer->deven = DEV_ENABLED;
  71. modminer->threads = buf[0];
  72. modminer->name = devname;
  73. modminer->cutofftemp = 85;
  74. return add_cgpu(modminer);
  75. }
  76. #undef bailout
  77. static char
  78. modminer_detect_auto()
  79. {
  80. return
  81. serial_autodetect_udev (modminer_detect_one, "BTCFPGA*ModMiner") ?:
  82. serial_autodetect_devserial(modminer_detect_one, "BTCFPGA_ModMiner") ?:
  83. 0;
  84. }
  85. static void
  86. modminer_detect()
  87. {
  88. serial_detect_auto(modminer_api.dname, modminer_detect_one, modminer_detect_auto);
  89. }
  90. #define bailout(...) return _bailout(-1, modminer, __VA_ARGS__);
  91. #define bailout2(...) return _bailout(fd, modminer, __VA_ARGS__);
  92. #define bailout3(...) _bailout(fd, modminer, __VA_ARGS__);
  93. #define check_magic(L) do { \
  94. if (1 != fread(buf, 1, 1, f)) \
  95. bailout(LOG_ERR, "Error reading ModMiner firmware ('%c')", L); \
  96. if (buf[0] != L) \
  97. bailout(LOG_ERR, "ModMiner firmware has wrong magic ('%c')", L); \
  98. } while(0)
  99. #define read_str(eng) do { \
  100. if (1 != fread(buf, 2, 1, f)) \
  101. bailout(LOG_ERR, "Error reading ModMiner firmware (" eng " len)"); \
  102. len = (ubuf[0] << 8) | ubuf[1]; \
  103. if (len >= sizeof(buf)) \
  104. bailout(LOG_ERR, "ModMiner firmware " eng " too long"); \
  105. if (1 != fread(buf, len, 1, f)) \
  106. bailout(LOG_ERR, "Error reading ModMiner firmware (" eng ")"); \
  107. buf[len] = '\0'; \
  108. } while(0)
  109. #define status_read(eng) do { \
  110. FD_SET(fd, &fds); \
  111. select(fd+1, &fds, NULL, NULL, NULL); \
  112. if (1 != read(fd, buf, 1)) \
  113. bailout2(LOG_ERR, "%s %u: Error programming %s (" eng ")", modminer->api->name, modminer->device_id, modminer->device_path); \
  114. if (buf[0] != 1) \
  115. bailout2(LOG_ERR, "%s %u: Wrong " eng " programming %s", modminer->api->name, modminer->device_id, modminer->device_path); \
  116. } while(0)
  117. static bool
  118. modminer_fpga_upload_bitstream(struct cgpu_info*modminer)
  119. {
  120. fd_set fds;
  121. char buf[0x100];
  122. unsigned char *ubuf = (unsigned char*)buf;
  123. unsigned long len, flen;
  124. char *p;
  125. const char *fwfile = BITSTREAM_FILENAME;
  126. char fpgaid = 4; // "all FPGAs"
  127. FILE *f = open_bitstream("modminer", fwfile);
  128. if (!f)
  129. bailout(LOG_ERR, "Error opening ModMiner firmware file %s", fwfile);
  130. if (1 != fread(buf, 2, 1, f))
  131. bailout(LOG_ERR, "Error reading ModMiner firmware (magic)");
  132. if (buf[0] || buf[1] != 9)
  133. bailout(LOG_ERR, "ModMiner firmware has wrong magic (9)");
  134. if (-1 == fseek(f, 11, SEEK_CUR))
  135. bailout(LOG_ERR, "ModMiner firmware seek failed");
  136. check_magic('a');
  137. read_str("design name");
  138. applog(LOG_DEBUG, "ModMiner firmware file %s info:", fwfile);
  139. applog(LOG_DEBUG, " Design name: %s", buf);
  140. p = strrchr(buf, ';') ?: buf;
  141. p = strrchr(buf, '=') ?: p;
  142. if (p[0] == '=')
  143. ++p;
  144. unsigned long fwusercode = (unsigned long)strtoll(p, &p, 16);
  145. if (p[0] != '\0')
  146. bailout(LOG_ERR, "Bad usercode in ModMiner firmware file");
  147. if (fwusercode == 0xffffffff)
  148. bailout(LOG_ERR, "ModMiner firmware doesn't support user code");
  149. applog(LOG_DEBUG, " Version: %u, build %u", (fwusercode >> 8) & 0xff, fwusercode & 0xff);
  150. check_magic('b');
  151. read_str("part number");
  152. applog(LOG_DEBUG, " Part number: %s", buf);
  153. check_magic('c');
  154. read_str("build date");
  155. applog(LOG_DEBUG, " Build date: %s", buf);
  156. check_magic('d');
  157. read_str("build time");
  158. applog(LOG_DEBUG, " Build time: %s", buf);
  159. check_magic('e');
  160. if (1 != fread(buf, 4, 1, f))
  161. bailout(LOG_ERR, "Error reading ModMiner firmware (data len)");
  162. len = ((unsigned long)ubuf[0] << 24) | ((unsigned long)ubuf[1] << 16) | (ubuf[2] << 8) | ubuf[3];
  163. flen = len;
  164. applog(LOG_DEBUG, " Bitstream size: %lu", len);
  165. int fd = modminer->device_fd;
  166. applog(LOG_WARNING, "%s %u: Programming %s... DO NOT EXIT CGMINER UNTIL COMPLETE", modminer->api->name, modminer->device_id, modminer->device_path);
  167. buf[0] = '\x05'; // Program Bitstream
  168. buf[1] = fpgaid;
  169. buf[2] = (len >> 0) & 0xff;
  170. buf[3] = (len >> 8) & 0xff;
  171. buf[4] = (len >> 16) & 0xff;
  172. buf[5] = (len >> 24) & 0xff;
  173. if (6 != write(fd, buf, 6))
  174. bailout2(LOG_ERR, "%s %u: Error programming %s (cmd)", modminer->api->name, modminer->device_id, modminer->device_path);
  175. status_read("cmd reply");
  176. ssize_t buflen;
  177. time_t nextstatus = time(NULL) + opt_log_interval, now;
  178. while (len) {
  179. buflen = len < 32 ? len : 32;
  180. if (fread(buf, buflen, 1, f) != 1)
  181. bailout2(LOG_ERR, "%s %u: File underrun programming %s (%d bytes left)", modminer->api->name, modminer->device_id, modminer->device_path, len);
  182. if (write(fd, buf, buflen) != buflen)
  183. bailout2(LOG_ERR, "%s %u: Error programming %s (data)", modminer->api->name, modminer->device_id, modminer->device_path);
  184. time(&now);
  185. if (now >= nextstatus)
  186. {
  187. nextstatus = now + opt_log_interval;
  188. applog(LOG_WARNING, "%s %u: Programming %s... %d%% complete...", modminer->api->name, modminer->device_id, modminer->device_path, 100 - ((len * 100) / flen));
  189. }
  190. status_read("status");
  191. len -= buflen;
  192. }
  193. status_read("final status");
  194. applog(LOG_WARNING, "%s %u: Done programming %s", modminer->api->name, modminer->device_id, modminer->device_path);
  195. return true;
  196. }
  197. static bool
  198. modminer_device_prepare(struct cgpu_info *modminer)
  199. {
  200. int fd = serial_open(modminer->device_path, 0, /*FIXME=-1*/3000, true);
  201. if (unlikely(-1 == fd))
  202. bailout(LOG_ERR, "%s %u: Failed to open %s", modminer->api->name, modminer->device_id, modminer->device_path);
  203. modminer->device_fd = fd;
  204. applog(LOG_INFO, "%s %u: Opened %s", modminer->api->name, modminer->device_id, modminer->device_path);
  205. struct timeval now;
  206. gettimeofday(&now, NULL);
  207. get_datestamp(modminer->init, &now);
  208. return true;
  209. }
  210. #undef bailout
  211. struct modminer_fpga_state {
  212. bool work_running;
  213. struct work running_work;
  214. struct timeval tv_workstart;
  215. uint32_t hashes;
  216. char next_work_cmd[46];
  217. unsigned char clock;
  218. int no_nonce_counter;
  219. int good_share_counter;
  220. time_t last_cutoff_reduced;
  221. unsigned char temp;
  222. };
  223. static bool
  224. modminer_fpga_prepare(struct thr_info *thr)
  225. {
  226. struct cgpu_info *modminer = thr->cgpu;
  227. // Don't need to lock the mutex here, since prepare runs from the main thread before the miner threads start
  228. if (modminer->device_fd == -1 && !modminer_device_prepare(modminer))
  229. return false;
  230. struct modminer_fpga_state *state;
  231. state = thr->cgpu_data = calloc(1, sizeof(struct modminer_fpga_state));
  232. state->next_work_cmd[0] = '\x08'; // Send Job
  233. state->next_work_cmd[1] = thr->device_thread; // FPGA id
  234. return true;
  235. }
  236. static bool
  237. modminer_reduce_clock(struct thr_info*thr, bool needlock)
  238. {
  239. struct cgpu_info*modminer = thr->cgpu;
  240. struct modminer_fpga_state *state = thr->cgpu_data;
  241. char fpgaid = thr->device_thread;
  242. int fd = modminer->device_fd;
  243. unsigned char cmd[6], buf[1];
  244. if (state->clock <= 100)
  245. return false;
  246. cmd[0] = '\x06'; // set clock speed
  247. cmd[1] = fpgaid;
  248. cmd[2] = state->clock -= 2;
  249. cmd[3] = cmd[4] = cmd[5] = '\0';
  250. if (needlock)
  251. mutex_lock(&modminer->device_mutex);
  252. if (6 != write(fd, cmd, 6))
  253. bailout2(LOG_ERR, "%s %u.%u: Error writing (set clock speed)", modminer->api->name, modminer->device_id, fpgaid);
  254. if (serial_read(fd, &buf, 1) != 1)
  255. bailout2(LOG_ERR, "%s %u.%u: Error reading (set clock speed)", modminer->api->name, modminer->device_id, fpgaid);
  256. if (needlock)
  257. mutex_unlock(&modminer->device_mutex);
  258. applog(LOG_WARNING, "%s %u.%u: Setting clock speed to %u", modminer->api->name, modminer->device_id, fpgaid, state->clock);
  259. return true;
  260. }
  261. static bool
  262. modminer_fpga_init(struct thr_info *thr)
  263. {
  264. struct cgpu_info *modminer = thr->cgpu;
  265. struct modminer_fpga_state *state = thr->cgpu_data;
  266. int fd;
  267. char fpgaid = thr->device_thread;
  268. unsigned char cmd[2], buf[4];
  269. mutex_lock(&modminer->device_mutex);
  270. fd = modminer->device_fd;
  271. if (fd == -1) {
  272. // Died in another thread...
  273. mutex_unlock(&modminer->device_mutex);
  274. return false;
  275. }
  276. cmd[0] = '\x04'; // Read USER code (bitstream id)
  277. cmd[1] = fpgaid;
  278. if (write(fd, cmd, 2) != 2)
  279. bailout2(LOG_ERR, "%s %u.%u: Error writing (read USER code)", modminer->api->name, modminer->device_id, fpgaid);
  280. if (serial_read(fd, buf, 4) != 4)
  281. bailout2(LOG_ERR, "%s %u.%u: Error reading (read USER code)", modminer->api->name, modminer->device_id, fpgaid);
  282. if (memcmp(buf, BISTREAM_USER_ID, 4)) {
  283. applog(LOG_ERR, "%s %u.%u: FPGA not programmed", modminer->api->name, modminer->device_id, fpgaid);
  284. if (!modminer_fpga_upload_bitstream(modminer))
  285. return false;
  286. }
  287. else
  288. applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed :)", modminer->api->name, modminer->device_id, fpgaid);
  289. state->clock = 212; // Will be reduced to 210 by modminer_reduce_clock
  290. modminer_reduce_clock(thr, false);
  291. mutex_unlock(&modminer->device_mutex);
  292. thr->primary_thread = true;
  293. return true;
  294. }
  295. static void
  296. get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
  297. {
  298. char info[18] = " | ";
  299. int tc = modminer->threads;
  300. bool havetemp = false;
  301. int i;
  302. if (tc > 4)
  303. tc = 4;
  304. for (i = tc - 1; i >= 0; --i) {
  305. struct thr_info*thr = modminer->thr[i];
  306. struct modminer_fpga_state *state = thr->cgpu_data;
  307. unsigned char temp = state->temp;
  308. info[i*3+2] = '/';
  309. if (temp) {
  310. havetemp = true;
  311. if (temp > 9)
  312. info[i*3+0] = 0x30 + (temp / 10);
  313. info[i*3+1] = 0x30 + (temp % 10);
  314. }
  315. }
  316. if (havetemp) {
  317. info[tc*3-1] = ' ';
  318. info[tc*3] = 'C';
  319. strcat(buf, info);
  320. }
  321. else
  322. strcat(buf, " | ");
  323. }
  324. static struct api_data*
  325. get_modminer_api_extra_device_status(struct cgpu_info*modminer)
  326. {
  327. struct api_data*root = NULL;
  328. static char *k[4] = {"Board0", "Board1", "Board2", "Board3"};
  329. int i;
  330. for (i = modminer->threads - 1; i >= 0; --i) {
  331. struct thr_info*thr = modminer->thr[i];
  332. struct modminer_fpga_state *state = thr->cgpu_data;
  333. json_t *o = json_object();
  334. if (state->temp)
  335. json_object_set(o, "Temperature", json_integer(state->temp));
  336. json_object_set(o, "Frequency", json_real((double)state->clock * 1000000.));
  337. root = api_add_json(root, k[i], o, false);
  338. json_decref(o);
  339. }
  340. return root;
  341. }
  342. static bool
  343. modminer_prepare_next_work(struct modminer_fpga_state*state, struct work*work)
  344. {
  345. char *midstate = state->next_work_cmd + 2;
  346. char *taildata = midstate + 32;
  347. if (!(memcmp(midstate, work->midstate, 32) || memcmp(taildata, work->data + 64, 12)))
  348. return false;
  349. memcpy(midstate, work->midstate, 32);
  350. memcpy(taildata, work->data + 64, 12);
  351. return true;
  352. }
  353. static bool
  354. modminer_start_work(struct thr_info*thr)
  355. {
  356. fd_set fds;
  357. struct cgpu_info*modminer = thr->cgpu;
  358. struct modminer_fpga_state *state = thr->cgpu_data;
  359. char fpgaid = thr->device_thread;
  360. int fd = modminer->device_fd;
  361. char buf[1];
  362. mutex_lock(&modminer->device_mutex);
  363. if (46 != write(fd, state->next_work_cmd, 46))
  364. bailout2(LOG_ERR, "%s %u.%u: Error writing (start work)", modminer->api->name, modminer->device_id, fpgaid);
  365. gettimeofday(&state->tv_workstart, NULL);
  366. state->hashes = 0;
  367. status_read("start work");
  368. mutex_unlock(&modminer->device_mutex);
  369. return true;
  370. }
  371. #define work_restart(thr) thr->work_restart
  372. static int64_t
  373. modminer_process_results(struct thr_info*thr)
  374. {
  375. struct cgpu_info*modminer = thr->cgpu;
  376. struct modminer_fpga_state *state = thr->cgpu_data;
  377. char fpgaid = thr->device_thread;
  378. int fd = modminer->device_fd;
  379. struct work *work = &state->running_work;
  380. char cmd[2], temperature;
  381. uint32_t nonce;
  382. long iter;
  383. bool bad;
  384. cmd[0] = '\x0a';
  385. cmd[1] = fpgaid;
  386. mutex_lock(&modminer->device_mutex);
  387. if (2 == write(fd, cmd, 2) && read(fd, &temperature, 1) == 1)
  388. {
  389. state->temp = temperature;
  390. if (!fpgaid)
  391. modminer->temp = (float)temperature;
  392. if (temperature > modminer->cutofftemp - 2) {
  393. if (temperature > modminer->cutofftemp) {
  394. applog(LOG_WARNING, "%s %u.%u: Hit thermal cutoff limit, disabling device!", modminer->api->name, modminer->device_id, fpgaid);
  395. modminer->deven = DEV_RECOVER;
  396. modminer->device_last_not_well = time(NULL);
  397. modminer->device_not_well_reason = REASON_DEV_THERMAL_CUTOFF;
  398. ++modminer->dev_thermal_cutoff_count;
  399. } else {
  400. time_t now = time(NULL);
  401. if (state->last_cutoff_reduced != now) {
  402. state->last_cutoff_reduced = now;
  403. modminer_reduce_clock(thr, false);
  404. }
  405. }
  406. }
  407. }
  408. cmd[0] = '\x09';
  409. iter = 200;
  410. while (1) {
  411. if (write(fd, cmd, 2) != 2)
  412. {
  413. bailout3(LOG_ERR, "%s %u.%u: Error reading (get nonce)", modminer->api->name, modminer->device_id, fpgaid);
  414. return -1;
  415. }
  416. serial_read(fd, &nonce, 4);
  417. mutex_unlock(&modminer->device_mutex);
  418. if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) {
  419. state->no_nonce_counter = 0;
  420. bad = !test_nonce(work, nonce, false);
  421. if (!bad)
  422. {
  423. ++state->good_share_counter;
  424. submit_nonce(thr, work, nonce);
  425. }
  426. else
  427. if (unlikely((!state->good_share_counter) && nonce == 0xffffff00))
  428. // Firmware returns 0xffffff00 immediately if we set clockspeed too high; but it's not a hw error and shouldn't affect future downclocking
  429. modminer_reduce_clock(thr, true);
  430. else {
  431. ++hw_errors;
  432. if (++modminer->hw_errors * 100 > 1000 + state->good_share_counter)
  433. // Only reduce clocks if hardware errors are more than ~1% of results
  434. modminer_reduce_clock(thr, true);
  435. }
  436. }
  437. else
  438. if (++state->no_nonce_counter > 18000) {
  439. state->no_nonce_counter = 0;
  440. modminer_reduce_clock(thr, true);
  441. }
  442. if (work_restart(thr))
  443. break;
  444. usleep(10000);
  445. if (work_restart(thr) || !--iter)
  446. break;
  447. mutex_lock(&modminer->device_mutex);
  448. }
  449. struct timeval tv_workend, elapsed;
  450. gettimeofday(&tv_workend, NULL);
  451. timersub(&tv_workend, &state->tv_workstart, &elapsed);
  452. uint64_t hashes = (uint64_t)state->clock * (((uint64_t)elapsed.tv_sec * 1000000) + elapsed.tv_usec);
  453. if (hashes > 0xffffffff)
  454. hashes = 0xffffffff;
  455. else
  456. if (hashes <= state->hashes)
  457. hashes = 1;
  458. else
  459. hashes -= state->hashes;
  460. state->hashes += hashes;
  461. return hashes;
  462. }
  463. static int64_t
  464. modminer_scanhash(struct thr_info*thr, struct work*work, int64_t __maybe_unused max_nonce)
  465. {
  466. struct modminer_fpga_state *state = thr->cgpu_data;
  467. int64_t hashes = 0;
  468. bool startwork;
  469. startwork = modminer_prepare_next_work(state, work);
  470. if (state->work_running) {
  471. hashes = modminer_process_results(thr);
  472. if (work_restart(thr)) {
  473. state->work_running = false;
  474. return hashes;
  475. }
  476. } else
  477. state->work_running = true;
  478. if (startwork) {
  479. if (!modminer_start_work(thr))
  480. return -1;
  481. memcpy(&state->running_work, work, sizeof(state->running_work));
  482. }
  483. // This is intentionally early
  484. work->blk.nonce += hashes;
  485. return hashes;
  486. }
  487. static void
  488. modminer_fpga_shutdown(struct thr_info *thr)
  489. {
  490. free(thr->cgpu_data);
  491. }
  492. struct device_api modminer_api = {
  493. .dname = "modminer",
  494. .name = "MMQ",
  495. .api_detect = modminer_detect,
  496. .get_statline_before = get_modminer_statline_before,
  497. .get_api_extra_device_status = get_modminer_api_extra_device_status,
  498. .thread_prepare = modminer_fpga_prepare,
  499. .thread_init = modminer_fpga_init,
  500. .scanhash = modminer_scanhash,
  501. .thread_shutdown = modminer_fpga_shutdown,
  502. };