Browse Source

Implement basic API stats for BF1 and increase array of results to check for the rare straggling result.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
ce285ba602
  1. 13
      api.c
  2. 33
      driver-bitfury.c
  3. 5
      driver-bitfury.h

13
api.c

@ -29,7 +29,7 @@
#include "miner.h" #include "miner.h"
#include "util.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 #define HAVE_AN_ASIC 1
#endif #endif
@ -176,6 +176,9 @@ static const char *DEVICECODE = ""
#ifdef USE_BITFORCE #ifdef USE_BITFORCE
"BFL " "BFL "
#endif #endif
#ifdef USE_BITFURY
"BFU "
#endif
#ifdef USE_ICARUS #ifdef USE_ICARUS
"ICA " "ICA "
#endif #endif
@ -1223,6 +1226,10 @@ static int numascs()
#ifdef USE_BFLSC #ifdef USE_BFLSC
if (devices[i]->drv->drv_id == DRIVER_BFLSC) if (devices[i]->drv->drv_id == DRIVER_BFLSC)
count++; count++;
#endif
#ifdef USE_BITFURY
if (devices[i]->drv->drv_id == DRIVER_BITFURY)
count++;
#endif #endif
} }
rd_unlock(&devices_lock); rd_unlock(&devices_lock);
@ -1243,6 +1250,10 @@ static int ascdevice(int ascid)
#ifdef USE_BFLSC #ifdef USE_BFLSC
if (devices[i]->drv->drv_id == DRIVER_BFLSC) if (devices[i]->drv->drv_id == DRIVER_BFLSC)
count++; count++;
#endif
#ifdef USE_BITFURY
if (devices[i]->drv->drv_id == DRIVER_BITFURY)
count++;
#endif #endif
if (count == (ascid + 1)) if (count == (ascid + 1))
goto foundit; goto foundit;

33
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); usb_read(bitfury, buf, 7, &amount, C_BF1_GETWORK);
/* Only happens on startup */ /* Only happens on startup */
if (unlikely(!info->prevwork2)) if (unlikely(!info->prevwork[BF1ARRAY_SIZE]))
goto cascade; goto cascade;
/* Search for what work the nonce matches in order of likelihood. Last /* Search for what work the nonce matches in order of likelihood. Last
* entry is end of result marker. */ * entry is end of result marker. */
for (i = 0; i < info->tot - 7; i += 7) { for (i = 0; i < info->tot - 7; i += 7) {
uint32_t nonce; uint32_t nonce;
int j;
/* Ignore state & switched data in results for now. */ /* Ignore state & switched data in results for now. */
memcpy(&nonce, info->buf + i + 3, 4); memcpy(&nonce, info->buf + i + 3, 4);
nonce = decnonce(nonce); nonce = decnonce(nonce);
if (bitfury_checkresults(thr, info->prevwork1, nonce)) { for (j = 0; j < BF1ARRAY_SIZE; j++) {
if (bitfury_checkresults(thr, info->prevwork[j], nonce)) {
info->nonces++; info->nonces++;
continue; break;
} }
if (bitfury_checkresults(thr, info->prevwork2, nonce)) {
info->nonces++;
continue;
} }
} }
info->tot = 0; info->tot = 0;
free_work(info->prevwork2); free_work(info->prevwork[BF1ARRAY_SIZE]);
cascade: cascade:
info->prevwork2 = info->prevwork1; for (i = BF1ARRAY_SIZE; i > 0; i--)
info->prevwork1 = copy_work(work); info->prevwork[i] = info->prevwork[i - 1];
info->prevwork[0] = copy_work(work);
work->blk.nonce = 0xffffffff; work->blk.nonce = 0xffffffff;
if (info->nonces) { if (info->nonces) {
info->nonces--; info->nonces--;
@ -256,9 +256,20 @@ cascade:
return 0; 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) static void bitfury_init(struct cgpu_info *bitfury)

5
driver-bitfury.h

@ -13,12 +13,13 @@
#include "miner.h" #include "miner.h"
#include "usbutils.h" #include "usbutils.h"
#define BF1ARRAY_SIZE 2
struct bitfury_info { struct bitfury_info {
uint8_t version; uint8_t version;
char product[8]; char product[8];
uint32_t serial; uint32_t serial;
struct work *prevwork1; struct work *prevwork[BF1ARRAY_SIZE + 1];
struct work *prevwork2;
char buf[512]; char buf[512];
int tot; int tot;
int nonces; int nonces;

Loading…
Cancel
Save