Implement a bxf send work function and set update and restart functions to sending new work since that's the equivalent for that device.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 5adc5c5..a7301f9 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -286,6 +286,8 @@ static bool bitfury_prepare(struct thr_info *thr)
struct cgpu_info *bitfury = thr->cgpu;
struct bitfury_info *info = bitfury->device_data;
+ info->thr = thr;
+
switch(info->ident) {
case IDENT_BXF:
return bxf_prepare(bitfury, info);
@@ -472,6 +474,61 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
}
}
+static void bxf_send_work(struct cgpu_info *bitfury, struct work *work)
+{
+ char buf[512], hexwork[156];
+ int err, amount, len;
+
+ __bin2hex(hexwork, work->data, 76);
+ sprintf(buf, "work %s %d\n", hexwork, work->subid);
+ len = strlen(buf);
+ err = usb_write(bitfury, buf, len, &amount, C_BXF_WORK);
+ if (err) {
+ applog(LOG_WARNING, "%s %d: Error %d sending work sent %d of %d", bitfury->drv->name,
+ bitfury->device_id, err, amount, len);
+ }
+}
+
+static void bxf_update_work(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ struct thr_info *thr = info->thr;
+ struct work *work;
+
+ work = get_queue_work(thr, bitfury, thr->id);
+
+ mutex_lock(&info->lock);
+ work->subid = ++info->work_id;
+ mutex_unlock(&info->lock);
+
+ bxf_send_work(bitfury, work);
+}
+
+static void bitfury_flush_work(struct cgpu_info *bitfury)
+{
+ struct bitfury_info *info = bitfury->device_data;
+
+ switch(info->ident) {
+ case IDENT_BXF:
+ bxf_update_work(bitfury, info);
+ case IDENT_BF1:
+ default:
+ break;
+ }
+}
+
+static void bitfury_update_work(struct cgpu_info *bitfury)
+{
+ struct bitfury_info *info = bitfury->device_data;
+
+ switch(info->ident) {
+ case IDENT_BXF:
+ bxf_update_work(bitfury, info);
+ case IDENT_BF1:
+ default:
+ break;
+ }
+}
+
static struct api_data *bitfury_api_stats(struct cgpu_info *cgpu)
{
struct bitfury_info *info = cgpu->device_data;
@@ -544,6 +601,8 @@ struct device_drv bitfury_drv = {
.thread_prepare = bitfury_prepare,
.hash_work = &hash_driver_work,
.scanwork = bitfury_scanwork,
+ .flush_work = bitfury_flush_work,
+ .update_work = bitfury_update_work,
.get_api_stats = bitfury_api_stats,
.reinit_device = bitfury_init,
.thread_shutdown = bitfury_shutdown,
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 808f4ab..27f0411 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -15,6 +15,7 @@
struct bitfury_info {
struct cgpu_info *base_cgpu;
+ struct thr_info *thr;
enum sub_ident ident;
int nonces;
int total_nonces;
@@ -31,6 +32,7 @@ struct bitfury_info {
pthread_mutex_t lock;
pthread_t read_thr;
double temperature;
+ int work_id; // Current work->subid
};
#endif /* BITFURY_H */
diff --git a/usbutils.h b/usbutils.h
index 2ab4733..e810fe1 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -344,6 +344,7 @@ struct cg_usb_info {
USB_ADD_COMMAND(C_BF1_IFLUSH, "BF1InterruptFlush") \
USB_ADD_COMMAND(C_BF1_IDENTIFY, "BF1Identify") \
USB_ADD_COMMAND(C_BXF_READ, "BXFRead") \
+ USB_ADD_COMMAND(C_BXF_WORK, "BXFWork") \
USB_ADD_COMMAND(C_HF_RESET, "HFReset") \
USB_ADD_COMMAND(C_HF_PLL_CONFIG, "HFPLLConfig") \
USB_ADD_COMMAND(C_HF_ADDRESS, "HFAddress") \