|
|
|
@ -142,38 +142,20 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in
@@ -142,38 +142,20 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in
|
|
|
|
|
} |
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
static bool klondike_get_cfgs(struct cgpu_info *klncgpu) |
|
|
|
|
{ |
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
if (klncgpu->usbinfo.nodev || klninfo->status == NULL) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
for(dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'C', dev, 1, ""); |
|
|
|
|
if(reply != NULL) |
|
|
|
|
klninfo->cfg[dev] = *(WORKCFG *)(reply+2); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_get_stats(struct cgpu_info *klncgpu) |
|
|
|
|
static bool klondike_init(struct cgpu_info *klncgpu) |
|
|
|
|
{ |
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
bool allok = false; |
|
|
|
|
int slaves, dev; |
|
|
|
|
|
|
|
|
|
if (klncgpu->usbinfo.nodev) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'S', 0, 0, NULL); |
|
|
|
|
if(reply != NULL) { |
|
|
|
|
if(reply == NULL) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
// todo: detect slavecount change and realloc space
|
|
|
|
|
slaves = ((WORKSTATUS *)(reply+2))->slavecount; |
|
|
|
|
if(klninfo->status == NULL) { |
|
|
|
|
applog(LOG_DEBUG, "Klondike initializing status data"); |
|
|
|
|
applog(LOG_DEBUG, "Klondike initializing data"); |
|
|
|
|
|
|
|
|
|
// alloc space for status, devinfo and cfg for master and slaves
|
|
|
|
|
klninfo->status = calloc(slaves+1, sizeof(WORKSTATUS)); |
|
|
|
|
if (unlikely(!klninfo->status)) |
|
|
|
@ -184,26 +166,46 @@ static bool klondike_get_stats(struct cgpu_info *klncgpu)
@@ -184,26 +166,46 @@ static bool klondike_get_stats(struct cgpu_info *klncgpu)
|
|
|
|
|
klninfo->cfg = calloc(slaves+1, sizeof(WORKCFG)); |
|
|
|
|
if (unlikely(!klninfo->cfg)) |
|
|
|
|
quit(1, "Failed to calloc cfg array in klondke_get_stats"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// where does saved user cfg info come from?
|
|
|
|
|
// todo: set user cfg to devices
|
|
|
|
|
for(dev = 0; dev <= slaves; dev++) { |
|
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'C', dev, 2, "\0"); |
|
|
|
|
if(reply != NULL) { |
|
|
|
|
klninfo->cfg[dev] = *(WORKCFG *)(reply+2); |
|
|
|
|
applog(LOG_DEBUG, "Klondike config (%d: Clk: %d)", dev, klninfo->cfg[dev].hashclock); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
applog(LOG_DEBUG, "Klondike updating status"); |
|
|
|
|
|
|
|
|
|
// device 0 is master and must exist
|
|
|
|
|
wr_lock(&(klninfo->stat_lock)); |
|
|
|
|
klninfo->status[0] = *(WORKSTATUS *)(reply+2); |
|
|
|
|
SendCmdGetReply(klncgpu, 'E', 0, 1, "1"); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_get_stats(struct cgpu_info *klncgpu) |
|
|
|
|
{ |
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
int slaves, dev; |
|
|
|
|
|
|
|
|
|
// loop thru slaves and get status for each
|
|
|
|
|
for(dev = 1; dev <= slaves; dev++) { |
|
|
|
|
if (klncgpu->usbinfo.nodev || klninfo->status == NULL) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Klondike getting status"); |
|
|
|
|
slaves = klninfo->status[0].slavecount; |
|
|
|
|
|
|
|
|
|
// loop thru devices and get status for each
|
|
|
|
|
wr_lock(&(klninfo->stat_lock)); |
|
|
|
|
for(dev = 0; dev <= slaves; dev++) { |
|
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'S', dev, 0, NULL); |
|
|
|
|
if(reply != NULL) |
|
|
|
|
klninfo->status[dev] = *(WORKSTATUS *)(reply+2); |
|
|
|
|
} |
|
|
|
|
wr_unlock(&(klninfo->stat_lock)); |
|
|
|
|
allok = true; |
|
|
|
|
} |
|
|
|
|
return allok; |
|
|
|
|
|
|
|
|
|
// todo: detect slavecount change and realloc space
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devices *found) |
|
|
|
@ -276,6 +278,7 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
@@ -276,6 +278,7 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
|
|
|
|
|
struct work *work, *tmp; |
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Klondike FOUND NONCE (%02x:%08x)", result->workid, result->nonce); |
|
|
|
|
|
|
|
|
|
HASH_ITER(hh, klncgpu->queued_work, work, tmp) { |
|
|
|
|
if (work->queued && (work->subid == (result->device*256 + result->workid))) { |
|
|
|
|
|
|
|
|
@ -290,7 +293,7 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
@@ -290,7 +293,7 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
applog(LOG_ERR, "%s%i:%d failed to find nonce work (%02x:%08x) - can't be processed - ignored", |
|
|
|
|
applog(LOG_ERR, "%s%i:%d unknown work (%02x:%08x) - can't be processed - ignored", |
|
|
|
|
klncgpu->drv->name, klncgpu->device_id, result->device, result->workid, result->nonce); |
|
|
|
|
//inc_hw_errors(klncgpu->thr[0]);
|
|
|
|
|
} |
|
|
|
@ -330,33 +333,11 @@ static void *klondike_get_replies(void *userdata)
@@ -330,33 +333,11 @@ static void *klondike_get_replies(void *userdata)
|
|
|
|
|
return NULL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_thread_prepare(struct thr_info *thr) |
|
|
|
|
{ |
|
|
|
|
struct cgpu_info *klncgpu = thr->cgpu; |
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
struct timeval now; |
|
|
|
|
|
|
|
|
|
if (thr_info_create(&(klninfo->replies_thr), NULL, klondike_get_replies, (void *)klncgpu)) { |
|
|
|
|
applog(LOG_ERR, "%s%i: thread create failed", klncgpu->drv->name, klncgpu->device_id); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
pthread_detach(klninfo->replies_thr.pth); |
|
|
|
|
|
|
|
|
|
// init status data structures
|
|
|
|
|
nmsleep(500); |
|
|
|
|
klondike_get_stats(klncgpu); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void klondike_flush_work(struct cgpu_info *klncgpu) |
|
|
|
|
{ |
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
if(klninfo->status == NULL) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Klondike flushing work work"); |
|
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
|
char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL); |
|
|
|
@ -368,6 +349,24 @@ static void klondike_flush_work(struct cgpu_info *klncgpu)
@@ -368,6 +349,24 @@ static void klondike_flush_work(struct cgpu_info *klncgpu)
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_thread_prepare(struct thr_info *thr) |
|
|
|
|
{ |
|
|
|
|
struct cgpu_info *klncgpu = thr->cgpu; |
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
struct timeval now; |
|
|
|
|
|
|
|
|
|
if (thr_info_create(&(klninfo->replies_thr), NULL, klondike_get_replies, (void *)klncgpu)) { |
|
|
|
|
applog(LOG_ERR, "%s%i: thread create failed", klncgpu->drv->name, klncgpu->device_id); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
pthread_detach(klninfo->replies_thr.pth); |
|
|
|
|
|
|
|
|
|
// let the listening get started
|
|
|
|
|
nmsleep(100); |
|
|
|
|
|
|
|
|
|
return klondike_init(klncgpu); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_thread_init(struct thr_info *thr) |
|
|
|
|
{ |
|
|
|
|
struct cgpu_info *klncgpu = thr->cgpu; |
|
|
|
@ -386,6 +385,9 @@ static void klondike_shutdown(struct thr_info *thr)
@@ -386,6 +385,9 @@ static void klondike_shutdown(struct thr_info *thr)
|
|
|
|
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); |
|
|
|
|
|
|
|
|
|
klondike_flush_work(klncgpu); |
|
|
|
|
|
|
|
|
|
SendCmdGetReply(klncgpu, 'E', 0, 1, "0"); |
|
|
|
|
|
|
|
|
|
klninfo->shutdown = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -396,8 +398,8 @@ static void klondike_thread_enable(struct thr_info *thr)
@@ -396,8 +398,8 @@ static void klondike_thread_enable(struct thr_info *thr)
|
|
|
|
|
if (klncgpu->usbinfo.nodev) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
klondike_flush_work(klncgpu); |
|
|
|
|
klondike_get_cfgs(klncgpu); |
|
|
|
|
SendCmdGetReply(klncgpu, 'E', 0, 1, "0"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static bool klondike_send_work(struct cgpu_info *klncgpu, int dev, struct work *work) |
|
|
|
@ -492,6 +494,9 @@ static void get_klondike_statline_before(char *buf, struct cgpu_info *klncgpu)
@@ -492,6 +494,9 @@ static void get_klondike_statline_before(char *buf, struct cgpu_info *klncgpu)
|
|
|
|
|
uint8_t temp = 0xFF; |
|
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
if(klninfo->status == NULL) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
rd_lock(&(klninfo->stat_lock)); |
|
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
|
if (klninfo->status[dev].temp < temp) |
|
|
|
@ -509,6 +514,9 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu)
@@ -509,6 +514,9 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu)
|
|
|
|
|
char buf[32]; |
|
|
|
|
int dev; |
|
|
|
|
|
|
|
|
|
if(klninfo->status == NULL) |
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
rd_lock(&(klninfo->stat_lock)); |
|
|
|
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { |
|
|
|
|
|
|
|
|
|