Implement basic API stats for BF1 and increase array of results to check for the rare straggling result.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
diff --git a/api.c b/api.c
index c60414f..e86ac7b 100644
--- a/api.c
+++ b/api.c
@@ -29,7 +29,7 @@
#include "miner.h"
#include "util.h"
-#if defined(USE_BFLSC) || defined(USE_AVALON)
+#if defined(USE_BFLSC) || defined(USE_AVALON) || defined(USE_BITFURY)
#define HAVE_AN_ASIC 1
#endif
@@ -176,6 +176,9 @@ static const char *DEVICECODE = ""
#ifdef USE_BITFORCE
"BFL "
#endif
+#ifdef USE_BITFURY
+ "BFU "
+#endif
#ifdef USE_ICARUS
"ICA "
#endif
@@ -1224,6 +1227,10 @@ static int numascs()
if (devices[i]->drv->drv_id == DRIVER_BFLSC)
count++;
#endif
+#ifdef USE_BITFURY
+ if (devices[i]->drv->drv_id == DRIVER_BITFURY)
+ count++;
+#endif
}
rd_unlock(&devices_lock);
return count;
@@ -1244,6 +1251,10 @@ static int ascdevice(int ascid)
if (devices[i]->drv->drv_id == DRIVER_BFLSC)
count++;
#endif
+#ifdef USE_BITFURY
+ if (devices[i]->drv->drv_id == DRIVER_BITFURY)
+ count++;
+#endif
if (count == (ascid + 1))
goto foundit;
}
diff --git a/driver-bitfury.c b/driver-bitfury.c
index f83a003..2e0b163 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -222,32 +222,32 @@ static int64_t bitfury_scanhash(struct thr_info *thr, struct work *work,
usb_read(bitfury, buf, 7, &amount, C_BF1_GETWORK);
/* Only happens on startup */
- if (unlikely(!info->prevwork2))
+ if (unlikely(!info->prevwork[BF1ARRAY_SIZE]))
goto cascade;
/* Search for what work the nonce matches in order of likelihood. Last
* entry is end of result marker. */
for (i = 0; i < info->tot - 7; i += 7) {
uint32_t nonce;
+ int j;
/* Ignore state & switched data in results for now. */
memcpy(&nonce, info->buf + i + 3, 4);
nonce = decnonce(nonce);
- if (bitfury_checkresults(thr, info->prevwork1, nonce)) {
- info->nonces++;
- continue;
- }
- if (bitfury_checkresults(thr, info->prevwork2, nonce)) {
- info->nonces++;
- continue;
+ for (j = 0; j < BF1ARRAY_SIZE; j++) {
+ if (bitfury_checkresults(thr, info->prevwork[j], nonce)) {
+ info->nonces++;
+ break;
+ }
}
}
info->tot = 0;
- free_work(info->prevwork2);
+ free_work(info->prevwork[BF1ARRAY_SIZE]);
cascade:
- info->prevwork2 = info->prevwork1;
- info->prevwork1 = copy_work(work);
+ for (i = BF1ARRAY_SIZE; i > 0; i--)
+ info->prevwork[i] = info->prevwork[i - 1];
+ info->prevwork[0] = copy_work(work);
work->blk.nonce = 0xffffffff;
if (info->nonces) {
info->nonces--;
@@ -256,9 +256,20 @@ cascade:
return 0;
}
-static struct api_data *bitfury_api_stats(struct cgpu_info __maybe_unused *cgpu)
+static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
{
- return NULL;
+ struct bitfury_info *info = cgpu->device_data;
+ struct api_data *root = NULL;
+ char serial[16];
+ int version;
+
+ version = info->version;
+ root = api_add_int(root, "Version", &version, true);
+ root = api_add_string(root, "Product", info->product, false);
+ sprintf(serial, "%0x", info->serial);
+ root = api_add_string(root, "Serial", serial, true);
+
+ return root;
}
static void bitfury_init(struct cgpu_info *bitfury)
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 72bc267..4cc1300 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -13,12 +13,13 @@
#include "miner.h"
#include "usbutils.h"
+#define BF1ARRAY_SIZE 2
+
struct bitfury_info {
uint8_t version;
char product[8];
uint32_t serial;
- struct work *prevwork1;
- struct work *prevwork2;
+ struct work *prevwork[BF1ARRAY_SIZE + 1];
char buf[512];
int tot;
int nonces;