Create a hashtable of work by uid as it's accepted by BMA
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
diff --git a/driver-bflsc.c b/driver-bflsc.c
index 81692a5..cef7dde 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -27,6 +27,7 @@
#include "compat.h"
#include "miner.h"
#include "usbutils.h"
+#include "uthash.h"
#include "driver-bflsc.h"
int opt_bflsc_overheat = BFLSC_TEMP_OVERHEAT;
@@ -1679,6 +1680,7 @@ out:
static bool bflsc28_queue_full(struct cgpu_info *bflsc)
{
+ struct bflsc_info *sc_info = bflsc->device_data;
int created, queued = 0, create, i, offset;
struct work *base_work, *work, *works[10];
char *buf, *field, *ptr;
@@ -1765,6 +1767,7 @@ static bool bflsc28_queue_full(struct cgpu_info *bflsc)
goto out;
}
for (i = 0; i < queued; i++) {
+ struct bflsc_work *bwork, *oldbwork;
unsigned int uid;
work = works[i];
@@ -1776,9 +1779,19 @@ static bool bflsc28_queue_full(struct cgpu_info *bflsc)
goto out;
}
sscanf(field, "%04x", &uid);
- /* FIXME: Do something useful with this uid */
- applog(LOG_WARNING, "%s%d: Got work uid %u",
- bflsc->drv->name, bflsc->device_id, uid);
+ bwork = malloc(sizeof(struct bflsc_work));
+ bwork->id = uid;
+ bwork->work = work;
+
+ wr_lock(&bflsc->qlock);
+ HASH_REPLACE_INT(sc_info->bworks, id, bwork, oldbwork);
+ if (oldbwork) {
+ __work_completed(bflsc, oldbwork->work);
+ free(oldbwork);
+ }
+ if (i > 0)
+ __add_queued(bflsc, work);
+ wr_unlock(&bflsc->qlock);
}
if (queued < created)
ret = true;
diff --git a/driver-bflsc.h b/driver-bflsc.h
index 402314a..f1b4105 100644
--- a/driver-bflsc.h
+++ b/driver-bflsc.h
@@ -116,6 +116,12 @@ struct bflsc_dev {
#define QUE_MAX_RESULTS 8
+struct bflsc_work {
+ UT_hash_handle hh;
+ int id;
+ struct work *work;
+};
+
struct bflsc_info {
enum driver_version driver_version;
pthread_rwlock_t stat_lock;
@@ -144,6 +150,8 @@ struct bflsc_info {
int flush_size;
// count of given size, [+2] is for any > QUE_MAX_RESULTS
uint64_t result_size[QUE_MAX_RESULTS+2];
+
+ struct bflsc_work *bworks;
};
#define BFLSC_XLINKHDR '@'