Add support for newer protocol bi*fury commands job, clock and hwerror, setting clock to default 54 value, turning parsing into a compact macro.
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
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 8de63ce..569a69b 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -399,6 +399,47 @@ static void parse_bxf_needwork(struct cgpu_info *bitfury, struct bitfury_info *i
bxf_update_work(bitfury, info);
}
+static void parse_bxf_job(struct cgpu_info *bitfury, struct bitfury_info *info, char *buf)
+{
+ int job_id, timestamp, chip;
+
+ if (sscanf(&buf[4], "%x %x %x", &job_id, ×tamp, &chip) != 3) {
+ applog(LOG_INFO, "%s %d: Failed to parse job",
+ bitfury->drv->name, bitfury->device_id);
+ return;
+ }
+ if (chip > 1) {
+ applog(LOG_INFO, "%s %d: Invalid job chip number %d",
+ bitfury->drv->name, bitfury->device_id, chip);
+ return;
+ }
+ ++info->job[chip];
+}
+
+static void parse_bxf_hwerror(struct cgpu_info *bitfury, struct bitfury_info *info, char *buf)
+{
+ int chip;
+
+ if (!sscanf(&buf[8], "%d", &chip)) {
+ applog(LOG_INFO, "%s %d: Failed to parse hwerror",
+ bitfury->drv->name, bitfury->device_id);
+ return;
+ }
+ if (chip > 1) {
+ applog(LOG_INFO, "%s %d: Invalid hwerror chip number %d",
+ bitfury->drv->name, bitfury->device_id, chip);
+ return;
+ }
+ ++info->filtered_hw[chip];
+}
+
+#define PARSE_BXF_MSG(MSG) \
+ msg = strstr(buf, #MSG); \
+ if (msg) { \
+ parse_bxf_##MSG(bitfury, info, msg); \
+ continue; \
+ }
+
static void *bxf_get_results(void *userdata)
{
struct cgpu_info *bitfury = userdata;
@@ -435,21 +476,12 @@ static void *bxf_get_results(void *userdata)
if (!err)
continue;
- msg = strstr(buf, "submit");
- if (msg) {
- parse_bxf_submit(bitfury, info, msg);
- continue;
- }
- msg = strstr(buf, "temp");
- if (msg) {
- parse_bxf_temp(bitfury, info, msg);
- continue;
- }
- msg = strstr(buf, "needwork");
- if (msg) {
- parse_bxf_needwork(bitfury, info, msg);
- continue;
- }
+ PARSE_BXF_MSG(submit);
+ PARSE_BXF_MSG(temp);
+ PARSE_BXF_MSG(needwork);
+ PARSE_BXF_MSG(job);
+ PARSE_BXF_MSG(hwerror);
+
applog(LOG_DEBUG, "%s %d: Unrecognised string %s",
bitfury->drv->name, bitfury->device_id, buf);
}
@@ -459,10 +491,14 @@ out:
static bool bxf_prepare(struct cgpu_info *bitfury, struct bitfury_info *info)
{
+ char buf[64];
+
mutex_init(&info->lock);
if (pthread_create(&info->read_thr, NULL, bxf_get_results, (void *)bitfury))
quit(1, "Failed to create bxf read_thr");
- return true;
+ info->clocks = BXF_DEFAULT_CLOCK;
+ sprintf(buf, "clock %d %d\n", info->clocks, info->clocks);
+ return bxf_send_msg(bitfury, buf, C_BXF_CLOCK);
}
static bool bitfury_prepare(struct thr_info *thr)
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 851d3cc..9ddb2c6 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -13,6 +13,10 @@
#include "miner.h"
#include "usbutils.h"
+#define BXF_DEFAULT_CLOCK 54
+#define BXF_MIN_CLOCK 0
+#define BXF_MAX_CLOCK 63
+
struct bitfury_info {
struct cgpu_info *base_cgpu;
struct thr_info *thr;
@@ -40,6 +44,9 @@ struct bitfury_info {
int ver_minor;
int hw_rev;
int chips;
+ uint8_t clocks; // There are two but we set them equal
+ int filtered_hw[2]; // Hardware errors we're told about but are filtered
+ int job[2]; // Completed jobs we're told about
};
#endif /* BITFURY_H */
diff --git a/usbutils.h b/usbutils.h
index 0b883bd..7ab77ac 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -347,6 +347,7 @@ struct cg_usb_info {
USB_ADD_COMMAND(C_BXF_VERSION, "BXFVersion") \
USB_ADD_COMMAND(C_BXF_MAXROLL, "BXFMaxRoll") \
USB_ADD_COMMAND(C_BXF_FLUSH, "BXFFlush") \
+ USB_ADD_COMMAND(C_BXF_CLOCK, "BXFClock") \
USB_ADD_COMMAND(C_HF_RESET, "HFReset") \
USB_ADD_COMMAND(C_HF_PLL_CONFIG, "HFPLLConfig") \
USB_ADD_COMMAND(C_HF_ADDRESS, "HFAddress") \