driver-bitforce.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. /*
  2. * Copyright 2012 Luke Dashjr
  3. * Copyright 2012 Con Kolivas
  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. #include <limits.h>
  11. #include <pthread.h>
  12. #include <stdio.h>
  13. #include <strings.h>
  14. #include <sys/time.h>
  15. #include <unistd.h>
  16. #include "config.h"
  17. #include "compat.h"
  18. #include "fpgautils.h"
  19. #include "miner.h"
  20. #define BITFORCE_SLEEP_MS 500
  21. #define BITFORCE_TIMEOUT_S 7
  22. #define BITFORCE_TIMEOUT_MS (BITFORCE_TIMEOUT_S * 1000)
  23. #define BITFORCE_LONG_TIMEOUT_S 15
  24. #define BITFORCE_LONG_TIMEOUT_MS (BITFORCE_LONG_TIMEOUT_S * 1000)
  25. #define BITFORCE_CHECK_INTERVAL_MS 10
  26. #define WORK_CHECK_INTERVAL_MS 50
  27. #define MAX_START_DELAY_US 100000
  28. #define tv_to_ms(tval) (tval.tv_sec * 1000 + tval.tv_usec / 1000)
  29. #define TIME_AVG_CONSTANT 8
  30. #define KNAME_WORK "full work"
  31. #define KNAME_RANGE "nonce range"
  32. struct device_api bitforce_api;
  33. // Code must deal with a timeout
  34. #define BFopen(devpath) serial_open(devpath, 0, 1, true)
  35. static void BFgets(char *buf, size_t bufLen, int fd)
  36. {
  37. do {
  38. buf[0] = '\0';
  39. --bufLen;
  40. } while (likely(bufLen && read(fd, buf, 1) == 1 && (buf++)[0] != '\n'));
  41. buf[0] = '\0';
  42. }
  43. static ssize_t BFwrite(int fd, const void *buf, ssize_t bufLen)
  44. {
  45. if ((bufLen) != write(fd, buf, bufLen))
  46. return 0;
  47. else
  48. return bufLen;
  49. }
  50. #define BFclose(fd) close(fd)
  51. static bool bitforce_detect_one(const char *devpath)
  52. {
  53. int fdDev = BFopen(devpath);
  54. struct cgpu_info *bitforce;
  55. char pdevbuf[0x100];
  56. char *s;
  57. applog(LOG_DEBUG, "BFL: Attempting to open %s", devpath);
  58. if (unlikely(fdDev == -1)) {
  59. applog(LOG_ERR, "BFL: Failed to open %s", devpath);
  60. return false;
  61. }
  62. BFwrite(fdDev, "ZGX", 3);
  63. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  64. if (unlikely(!pdevbuf[0])) {
  65. applog(LOG_ERR, "BFL: Error reading/timeout (ZGX)");
  66. return 0;
  67. }
  68. BFclose(fdDev);
  69. if (unlikely(!strstr(pdevbuf, "SHA256"))) {
  70. applog(LOG_ERR, "BFL: Didn't recognise BitForce on %s", devpath);
  71. return false;
  72. }
  73. // We have a real BitForce!
  74. bitforce = calloc(1, sizeof(*bitforce));
  75. bitforce->api = &bitforce_api;
  76. bitforce->device_path = strdup(devpath);
  77. bitforce->deven = DEV_ENABLED;
  78. bitforce->threads = 1;
  79. /* Initially enable support for nonce range and disable it later if it
  80. * fails */
  81. if (opt_bfl_noncerange) {
  82. bitforce->nonce_range = true;
  83. bitforce->sleep_ms = BITFORCE_SLEEP_MS;
  84. bitforce->kname = KNAME_RANGE;
  85. } else {
  86. bitforce->sleep_ms = BITFORCE_SLEEP_MS * 5;
  87. bitforce->kname = KNAME_WORK;
  88. }
  89. if (likely((!memcmp(pdevbuf, ">>>ID: ", 7)) && (s = strstr(pdevbuf + 3, ">>>")))) {
  90. s[0] = '\0';
  91. bitforce->name = strdup(pdevbuf + 7);
  92. }
  93. mutex_init(&bitforce->device_mutex);
  94. return add_cgpu(bitforce);
  95. }
  96. static char bitforce_detect_auto()
  97. {
  98. return (serial_autodetect_udev (bitforce_detect_one, "BitFORCE*SHA256") ?:
  99. serial_autodetect_devserial(bitforce_detect_one, "BitFORCE_SHA256") ?:
  100. 0);
  101. }
  102. static void bitforce_detect()
  103. {
  104. serial_detect_auto(bitforce_api.dname, bitforce_detect_one, bitforce_detect_auto);
  105. }
  106. static void get_bitforce_statline_before(char *buf, struct cgpu_info *bitforce)
  107. {
  108. float gt = bitforce->temp;
  109. if (gt > 0)
  110. tailsprintf(buf, "%5.1fC ", gt);
  111. else
  112. tailsprintf(buf, " ", gt);
  113. tailsprintf(buf, " | ");
  114. }
  115. static bool bitforce_thread_prepare(struct thr_info *thr)
  116. {
  117. struct cgpu_info *bitforce = thr->cgpu;
  118. int fdDev = BFopen(bitforce->device_path);
  119. struct timeval now;
  120. if (unlikely(fdDev == -1)) {
  121. applog(LOG_ERR, "BFL%i: Failed to open %s", bitforce->device_id, bitforce->device_path);
  122. return false;
  123. }
  124. bitforce->device_fd = fdDev;
  125. applog(LOG_INFO, "BFL%i: Opened %s", bitforce->device_id, bitforce->device_path);
  126. gettimeofday(&now, NULL);
  127. get_datestamp(bitforce->init, &now);
  128. return true;
  129. }
  130. static void bitforce_clear_buffer(struct cgpu_info *bitforce)
  131. {
  132. int fdDev = bitforce->device_fd;
  133. char pdevbuf[0x100];
  134. int count = 0;
  135. if (!fdDev)
  136. return;
  137. applog(LOG_DEBUG, "BFL%i: Clearing read buffer", bitforce->device_id);
  138. mutex_lock(&bitforce->device_mutex);
  139. do {
  140. pdevbuf[0] = '\0';
  141. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  142. } while (pdevbuf[0] && (++count < 10));
  143. mutex_unlock(&bitforce->device_mutex);
  144. }
  145. void bitforce_init(struct cgpu_info *bitforce)
  146. {
  147. char *devpath = bitforce->device_path;
  148. int fdDev = bitforce->device_fd, retries = 0;
  149. char pdevbuf[0x100];
  150. char *s;
  151. applog(LOG_WARNING, "BFL%i: Re-initialising", bitforce->device_id);
  152. bitforce_clear_buffer(bitforce);
  153. mutex_lock(&bitforce->device_mutex);
  154. if (fdDev) {
  155. BFclose(fdDev);
  156. sleep(5);
  157. }
  158. bitforce->device_fd = 0;
  159. fdDev = BFopen(devpath);
  160. if (unlikely(fdDev == -1)) {
  161. mutex_unlock(&bitforce->device_mutex);
  162. applog(LOG_ERR, "BFL%i: Failed to open %s", bitforce->device_id, devpath);
  163. return;
  164. }
  165. do {
  166. BFwrite(fdDev, "ZGX", 3);
  167. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  168. if (unlikely(!pdevbuf[0])) {
  169. mutex_unlock(&bitforce->device_mutex);
  170. applog(LOG_ERR, "BFL%i: Error reading/timeout (ZGX)", bitforce->device_id);
  171. return;
  172. }
  173. if (retries++)
  174. nmsleep(10);
  175. } while (!strstr(pdevbuf, "BUSY") && (retries * 10 < BITFORCE_TIMEOUT_MS));
  176. if (unlikely(!strstr(pdevbuf, "SHA256"))) {
  177. mutex_unlock(&bitforce->device_mutex);
  178. applog(LOG_ERR, "BFL%i: Didn't recognise BitForce on %s returned: %s", bitforce->device_id, devpath, pdevbuf);
  179. return;
  180. }
  181. if (likely((!memcmp(pdevbuf, ">>>ID: ", 7)) && (s = strstr(pdevbuf + 3, ">>>")))) {
  182. s[0] = '\0';
  183. bitforce->name = strdup(pdevbuf + 7);
  184. }
  185. bitforce->device_fd = fdDev;
  186. bitforce->sleep_ms = BITFORCE_SLEEP_MS;
  187. mutex_unlock(&bitforce->device_mutex);
  188. }
  189. static bool bitforce_get_temp(struct cgpu_info *bitforce)
  190. {
  191. int fdDev = bitforce->device_fd;
  192. char pdevbuf[0x100];
  193. char *s;
  194. if (!fdDev)
  195. return false;
  196. /* It is not critical getting temperature so don't get stuck if we
  197. * can't grab the mutex here */
  198. if (mutex_trylock(&bitforce->device_mutex))
  199. return false;
  200. BFwrite(fdDev, "ZLX", 3);
  201. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  202. mutex_unlock(&bitforce->device_mutex);
  203. if (unlikely(!pdevbuf[0])) {
  204. applog(LOG_ERR, "BFL%i: Error: Get temp returned empty string/timed out", bitforce->device_id);
  205. bitforce->temp = 0;
  206. return false;
  207. }
  208. if ((!strncasecmp(pdevbuf, "TEMP", 4)) && (s = strchr(pdevbuf + 4, ':'))) {
  209. float temp = strtof(s + 1, NULL);
  210. if (temp > 0) {
  211. bitforce->temp = temp;
  212. if (unlikely(bitforce->cutofftemp > 0 && temp > bitforce->cutofftemp)) {
  213. applog(LOG_WARNING, "BFL%i: Hit thermal cutoff limit, disabling!", bitforce->device_id);
  214. bitforce->deven = DEV_RECOVER;
  215. bitforce->device_last_not_well = time(NULL);
  216. bitforce->device_not_well_reason = REASON_DEV_THERMAL_CUTOFF;
  217. bitforce->dev_thermal_cutoff_count++;
  218. }
  219. }
  220. } else {
  221. /* Use the temperature monitor as a kind of watchdog for when
  222. * our responses are out of sync and flush the buffer to
  223. * hopefully recover */
  224. applog(LOG_WARNING, "BFL%i: Garbled response probably throttling, clearing buffer");
  225. bitforce_clear_buffer(bitforce);
  226. return false;;
  227. }
  228. return true;
  229. }
  230. static bool bitforce_send_work(struct thr_info *thr, struct work *work)
  231. {
  232. struct cgpu_info *bitforce = thr->cgpu;
  233. int fdDev = bitforce->device_fd;
  234. unsigned char ob[70];
  235. char pdevbuf[0x100];
  236. char *s;
  237. if (!fdDev)
  238. return false;
  239. re_send:
  240. mutex_lock(&bitforce->device_mutex);
  241. if (bitforce->nonce_range)
  242. BFwrite(fdDev, "ZPX", 3);
  243. else
  244. BFwrite(fdDev, "ZDX", 3);
  245. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  246. if (!pdevbuf[0] || !strncasecmp(pdevbuf, "B", 1)) {
  247. mutex_unlock(&bitforce->device_mutex);
  248. nmsleep(WORK_CHECK_INTERVAL_MS);
  249. goto re_send;
  250. } else if (unlikely(strncasecmp(pdevbuf, "OK", 2))) {
  251. mutex_unlock(&bitforce->device_mutex);
  252. if (bitforce->nonce_range) {
  253. applog(LOG_WARNING, "BFL%i: Does not support nonce range, disabling", bitforce->device_id);
  254. bitforce->nonce_range = false;
  255. bitforce->sleep_ms *= 5;
  256. bitforce->kname = KNAME_WORK;
  257. goto re_send;
  258. }
  259. applog(LOG_ERR, "BFL%i: Error: Send work reports: %s", bitforce->device_id, pdevbuf);
  260. bitforce_clear_buffer(bitforce);
  261. return false;
  262. }
  263. sprintf((char *)ob, ">>>>>>>>");
  264. memcpy(ob + 8, work->midstate, 32);
  265. memcpy(ob + 8 + 32, work->data + 64, 12);
  266. if (!bitforce->nonce_range) {
  267. sprintf((char *)ob + 8 + 32 + 12, ">>>>>>>>");
  268. work->blk.nonce = bitforce->nonces = 0xffffffff;
  269. BFwrite(fdDev, ob, 60);
  270. } else {
  271. uint32_t *nonce;
  272. nonce = (uint32_t *)(ob + 8 + 32 + 12);
  273. *nonce = htobe32(work->blk.nonce);
  274. nonce = (uint32_t *)(ob + 8 + 32 + 12 + 4);
  275. /* Split work up into 1/5th nonce ranges */
  276. bitforce->nonces = 0x33333332;
  277. *nonce = htobe32(work->blk.nonce + bitforce->nonces);
  278. work->blk.nonce += bitforce->nonces + 1;
  279. sprintf((char *)ob + 8 + 32 + 12 + 8, ">>>>>>>>");
  280. BFwrite(fdDev, ob, 68);
  281. }
  282. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  283. mutex_unlock(&bitforce->device_mutex);
  284. if (opt_debug) {
  285. s = bin2hex(ob + 8, 44);
  286. applog(LOG_DEBUG, "BFL%i: block data: %s", bitforce->device_id, s);
  287. free(s);
  288. }
  289. if (unlikely(!pdevbuf[0])) {
  290. applog(LOG_ERR, "BFL%i: Error: Send block data returned empty string/timed out", bitforce->device_id);
  291. return false;
  292. }
  293. if (unlikely(strncasecmp(pdevbuf, "OK", 2))) {
  294. applog(LOG_ERR, "BFL%i: Error: Send block data reports: %s", bitforce->device_id, pdevbuf);
  295. bitforce_clear_buffer(bitforce);
  296. return false;
  297. }
  298. gettimeofday(&bitforce->work_start_tv, NULL);
  299. return true;
  300. }
  301. static int64_t bitforce_get_result(struct thr_info *thr, struct work *work)
  302. {
  303. struct cgpu_info *bitforce = thr->cgpu;
  304. int fdDev = bitforce->device_fd;
  305. unsigned int delay_time_ms;
  306. struct timeval elapsed;
  307. struct timeval now;
  308. char pdevbuf[0x100];
  309. char *pnoncebuf;
  310. uint32_t nonce;
  311. if (!fdDev)
  312. return -1;
  313. while (1) {
  314. if (unlikely(thr->work_restart))
  315. return 0;
  316. mutex_lock(&bitforce->device_mutex);
  317. BFwrite(fdDev, "ZFX", 3);
  318. BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
  319. mutex_unlock(&bitforce->device_mutex);
  320. gettimeofday(&now, NULL);
  321. timersub(&now, &bitforce->work_start_tv, &elapsed);
  322. if (elapsed.tv_sec >= BITFORCE_LONG_TIMEOUT_S) {
  323. applog(LOG_ERR, "BFL%i: took %dms - longer than %dms", bitforce->device_id,
  324. tv_to_ms(elapsed), BITFORCE_LONG_TIMEOUT_MS);
  325. return 0;
  326. }
  327. if (pdevbuf[0] && strncasecmp(pdevbuf, "B", 1)) /* BFL does not respond during throttling */
  328. break;
  329. /* if BFL is throttling, no point checking so quickly */
  330. delay_time_ms = (pdevbuf[0] ? BITFORCE_CHECK_INTERVAL_MS : 2 * WORK_CHECK_INTERVAL_MS);
  331. nmsleep(delay_time_ms);
  332. bitforce->wait_ms += delay_time_ms;
  333. }
  334. if (elapsed.tv_sec > BITFORCE_TIMEOUT_S) {
  335. applog(LOG_ERR, "BFL%i: took %dms - longer than %dms", bitforce->device_id,
  336. tv_to_ms(elapsed), BITFORCE_TIMEOUT_MS);
  337. bitforce->device_last_not_well = time(NULL);
  338. bitforce->device_not_well_reason = REASON_DEV_OVER_HEAT;
  339. bitforce->dev_over_heat_count++;
  340. if (!pdevbuf[0]) /* Only return if we got nothing after timeout - there still may be results */
  341. return 0;
  342. } else if (!strncasecmp(pdevbuf, "N", 1)) {/* Hashing complete (NONCE-FOUND or NO-NONCE) */
  343. /* Simple timing adjustment. Allow a few polls to cope with
  344. * OS timer delays being variably reliable. wait_ms will
  345. * always equal sleep_ms when we've waited greater than or
  346. * equal to the result return time.*/
  347. delay_time_ms = bitforce->sleep_ms;
  348. if (bitforce->wait_ms > bitforce->sleep_ms + (WORK_CHECK_INTERVAL_MS * 2))
  349. bitforce->sleep_ms += (bitforce->wait_ms - bitforce->sleep_ms) / 2;
  350. else if (bitforce->wait_ms == bitforce->sleep_ms) {
  351. if (bitforce->sleep_ms > WORK_CHECK_INTERVAL_MS)
  352. bitforce->sleep_ms -= WORK_CHECK_INTERVAL_MS;
  353. else if (bitforce->sleep_ms > BITFORCE_CHECK_INTERVAL_MS)
  354. bitforce->sleep_ms -= BITFORCE_CHECK_INTERVAL_MS;
  355. }
  356. if (delay_time_ms != bitforce->sleep_ms)
  357. applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d, waited %u", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms);
  358. /* Work out the average time taken. Float for calculation, uint for display */
  359. bitforce->avg_wait_f += (tv_to_ms(elapsed) - bitforce->avg_wait_f) / TIME_AVG_CONSTANT;
  360. bitforce->avg_wait_d = (unsigned int) (bitforce->avg_wait_f + 0.5);
  361. }
  362. applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf);
  363. if (!strncasecmp(&pdevbuf[2], "-", 1))
  364. return bitforce->nonces; /* No valid nonce found */
  365. else if (!strncasecmp(pdevbuf, "I", 1))
  366. return 0; /* Device idle */
  367. else if (strncasecmp(pdevbuf, "NONCE-FOUND", 11)) {
  368. applog(LOG_WARNING, "BFL%i: Error: Get result reports: %s", bitforce->device_id, pdevbuf);
  369. bitforce_clear_buffer(bitforce);
  370. return 0;
  371. }
  372. pnoncebuf = &pdevbuf[12];
  373. while (1) {
  374. hex2bin((void*)&nonce, pnoncebuf, 4);
  375. #ifndef __BIG_ENDIAN__
  376. nonce = swab32(nonce);
  377. #endif
  378. if (unlikely(bitforce->nonce_range && (nonce >= work->blk.nonce ||
  379. (work->blk.nonce > 0 && nonce < work->blk.nonce - bitforce->nonces - 1)))) {
  380. applog(LOG_WARNING, "BFL%i: Disabling broken nonce range support", bitforce->device_id);
  381. bitforce->nonce_range = false;
  382. work->blk.nonce = 0xffffffff;
  383. bitforce->sleep_ms *= 5;
  384. bitforce->kname = KNAME_WORK;
  385. }
  386. submit_nonce(thr, work, nonce);
  387. if (strncmp(&pnoncebuf[8], ",", 1))
  388. break;
  389. pnoncebuf += 9;
  390. }
  391. return bitforce->nonces;
  392. }
  393. static void bitforce_shutdown(struct thr_info *thr)
  394. {
  395. struct cgpu_info *bitforce = thr->cgpu;
  396. BFclose(bitforce->device_fd);
  397. bitforce->device_fd = 0;
  398. }
  399. static void biforce_thread_enable(struct thr_info *thr)
  400. {
  401. struct cgpu_info *bitforce = thr->cgpu;
  402. bitforce_init(bitforce);
  403. }
  404. static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_t __maybe_unused max_nonce)
  405. {
  406. struct cgpu_info *bitforce = thr->cgpu;
  407. unsigned int sleep_time;
  408. bool send_ret;
  409. int64_t ret;
  410. send_ret = bitforce_send_work(thr, work);
  411. if (!bitforce->nonce_range) {
  412. /* Initially wait 2/3 of the average cycle time so we can request more
  413. work before full scan is up */
  414. sleep_time = (2 * bitforce->sleep_ms) / 3;
  415. if (!restart_wait(sleep_time))
  416. return 0;
  417. bitforce->wait_ms = sleep_time;
  418. queue_request(thr, false);
  419. /* Now wait athe final 1/3rd; no bitforce should be finished by now */
  420. sleep_time = bitforce->sleep_ms - sleep_time;
  421. if (!restart_wait(sleep_time))
  422. return 0;
  423. bitforce->wait_ms += sleep_time;
  424. } else {
  425. sleep_time = bitforce->sleep_ms;
  426. if (!restart_wait(sleep_time))
  427. return 0;
  428. bitforce->wait_ms = sleep_time;
  429. }
  430. if (send_ret)
  431. ret = bitforce_get_result(thr, work);
  432. else
  433. ret = -1;
  434. if (ret == -1) {
  435. ret = 0;
  436. applog(LOG_ERR, "BFL%i: Comms error", bitforce->device_id);
  437. bitforce->device_last_not_well = time(NULL);
  438. bitforce->device_not_well_reason = REASON_DEV_COMMS_ERROR;
  439. bitforce->dev_comms_error_count++;
  440. /* empty read buffer */
  441. bitforce_clear_buffer(bitforce);
  442. }
  443. return ret;
  444. }
  445. static bool bitforce_get_stats(struct cgpu_info *bitforce)
  446. {
  447. return bitforce_get_temp(bitforce);
  448. }
  449. static bool bitforce_thread_init(struct thr_info *thr)
  450. {
  451. struct cgpu_info *bitforce = thr->cgpu;
  452. unsigned int wait;
  453. /* Pause each new thread at least 100ms between initialising
  454. * so the devices aren't making calls all at the same time. */
  455. wait = thr->id * MAX_START_DELAY_US;
  456. applog(LOG_DEBUG, "BFL%i: Delaying start by %dms", bitforce->device_id, wait / 1000);
  457. usleep(wait);
  458. return true;
  459. }
  460. static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu)
  461. {
  462. struct api_data *root = NULL;
  463. // Warning, access to these is not locked - but we don't really
  464. // care since hashing performance is way more important than
  465. // locking access to displaying API debug 'stats'
  466. // If locking becomes an issue for any of them, use copy_data=true also
  467. root = api_add_uint(root, "Sleep Time", &(cgpu->sleep_ms), false);
  468. root = api_add_uint(root, "Avg Wait", &(cgpu->avg_wait_d), false);
  469. return root;
  470. }
  471. struct device_api bitforce_api = {
  472. .dname = "bitforce",
  473. .name = "BFL",
  474. .api_detect = bitforce_detect,
  475. .get_api_stats = bitforce_api_stats,
  476. .reinit_device = bitforce_init,
  477. .get_statline_before = get_bitforce_statline_before,
  478. .get_stats = bitforce_get_stats,
  479. .thread_prepare = bitforce_thread_prepare,
  480. .thread_init = bitforce_thread_init,
  481. .scanhash = bitforce_scanhash,
  482. .thread_shutdown = bitforce_shutdown,
  483. .thread_enable = biforce_thread_enable
  484. };